don't click here

Basic Questions & Answers thread

Discussion in 'Engineering & Reverse Engineering' started by Tweaker, May 29, 2008.

  1. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    Regen has an issue with swapping bytes when saving files. First established this problem in this topic. So the file shows the art glitched; same with palettes, SRAM, etc. Try using Gens debugger, that works fine.
     
  2. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Awesome that works. Thank you much!

    I've got one more question for right now: What is with the massive amounts of non-art data (Probably.. code?) that's always sitting in Sonic 1 and 2's VRAM? Is there any simple way to heavily reduce the amount of VRAM space that's used by it so I can have room for other things?

    The main bit of code I want to move/remove is the code that sits under Sonic and Tails' art in Sonic 2, so I can s shift some data there comfortably.
     
  3. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Those non-art data are 4 tables used by the VDP to render things: you have the planes A and B tables (foreground and background), the sprite attribute table (Sonic, Tails, shields) and the horizontal scroll table (deformation for background and foreground). Theoretically, you could rewrite the game engine to use less space in the plane tables as they are slightly larger than the screen; the game would probably be a lot slower due to all the extra processing required to still render everything, though. The horizontal scroll table can be greatly reduced by forgoing good background or foreground scrolling (would be restricted to scrolling the entire plane instead of each line of each plane independently). The sprite attribute table could be safety reduced by putting a limit on how many sprite pieces are rendered, which is annoying to do with the S1 or S2 engines (but which could be done with the S&K engine rather easily). The gains would be minimal, though...

    The only way to really free VRAM is to remove stuff that is already there.

    An alternative would be to wait for the hardware folks to finish studying the recently-discovered 128kB mode of the Genesis' VDP (that of the original console) then write hardware-modding guides on how to add the additional 64kB VRAM, then finally, wait for emulator developers to add support for it. Hopefully, emulator support can come before the hardware-modding guides...
     
  4. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,203
    432
    63
    Japan
    You could perhaps change the horizontal tile resolution from 28 tiles to 20: http://mrjester.hapisan.com/RES.PNG

    By doing so, the number of sprites you can use will automatically be reduced from 50 sprites to 40. Additionally, you might be able to reduce the planes horizontal size (if you're willing to accept the fact that you cannot hide the level drawing). The downside of course, is the graphics will appear stretched to make up for the resolution, and I'm not sure you really want to sacrifice the number of sprites you can use, just for a bit of art space. But it's an idea none the less.
     
  5. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Just an FYI, the numbers MarkeyJester used (28, 20, 50, 40) are all in hex.
     
  6. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    It's an interesting idea.. But uh...

    Yeah, I think I'm just going to work out another way. Should just have to shift a few mappings around to achieve what I want.
     
  7. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    One thing you can do is convert shields to use uncompressed art and DPLC. If you then also uncompress the invincibility art and send it to VRAM when needed (I.e., at about the time when the shield would disappear and the invincibility starts appear), and make the invincibility and shield use the same VRAM space, you will free up 32 tiles in S2. If you then do the same for the super stars, you can free up 14 more tiles. For reference, S3&K does that.
     
  8. Steelrush

    Steelrush

    Every good deed has its reward. Member
    19
    0
    1
    A humid place
    Blaze the Cat in Sonic 2
    I've almost completed porting a Sonic 1 zone to Sonic 2, except I've come across another problem. I can't get it to show up in level select, or get to it when I completed a previous zone. Does anyone have an idea on how to help me solve the issue? :\
     
  9. RetroKoH

    RetroKoH

    Member
    1,662
    22
    18
    Project Sonic 8x16
    As for level select pointers, you'll want to look here in s2.asm:
    Code (Text):
    1.  
    2.  
    3. ;Misc_9454:
    4. LevelSelect_Order:
    5.     dc.w    hidden_palace_zone_act_1;emerald_hill_zone_act_1
    6.     dc.w    emerald_hill_zone_act_2 ; 1
    7.     dc.w    chemical_plant_zone_act_1   ; 2
    8.     dc.w    chemical_plant_zone_act_2   ; 3
    9.  
    As you can see in this example I made it so the first selection takes you to Hidden Palace Zone Act 1. As for actually editing the text to reflect this change... SCHG page. I haven't gotten around to this myself for Sonic 2, only done it for Sonic 1 so I cannot really tell you anything concrete on how to do it... also you'll want to add Level Select icons for the Sonic 1 zones, again, someone else may be better suited to explain this.


    And for level order in normal gameplay, go here in s2.asm:
    Code (Text):
    1.  
    2.  
    3. ; -------------------------------------------------------------------------------
    4. ; Main game level order
    5.  
    6. ; One value per act. That value is the level/act number of the level to load when
    7. ; that act finishes.
    8. ; -------------------------------------------------------------------------------
    9. ;word_142F8:
    10. LevelOrder: zoneOrderedTable 2,2    ; WrdArr_LevelOrder
    11.     zoneTableEntry.w  emerald_hill_zone_act_2
    12.     zoneTableEntry.w  chemical_plant_zone_act_1 ; 1
    13.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 2
    14.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 3
    15.     zoneTableEntry.w  wood_zone_act_2       ; 4
    16.     zoneTableEntry.w  metropolis_zone_act_1     ; 5
    17.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 6
    18.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 7
    19.     zoneTableEntry.w  metropolis_zone_act_2     ; 8
    20.     zoneTableEntry.w  metropolis_zone_act_3     ; 9
    21.     zoneTableEntry.w  sky_chase_zone_act_1      ; 10
    22.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 11
    23.     zoneTableEntry.w  death_egg_zone_act_1      ; 12
    24.     zoneTableEntry.w  emerald_hill_zone_act_1   ; 13
    25.     zoneTableEntry.w  hill_top_zone_act_2       ; 14
    26.     zoneTableEntry.w  mystic_cave_zone_act_1    ; 15
    27.     zoneTableEntry.w  hidden_palace_zone_act_2  ; 16
    28.  

    If you've ever edited the Level Order.bin in Sonic 1, this works much the same way. The value on the list is the level the game goes to when the respective level is finished... For example, the FIRST slot is Emerald Hill Zone Act 2. Now, the first level in the game, is Emerald Hill Zone Act 1. This means that EHZ Act 2 will follow Act 1. Hope that clarifies this a bit. ALSO the order of these entries doesn't reflect the actual order of the game, rather the order that they are in the code... so if you look below EHZ 2, you'll see Chemical Plant Zone 1, which is where you go after EHZ Act 2... following this are two EHZ Act 1 entries... these are not for Chemical Plant Zone... these are for an unused zone slot that automatically redirects to EHZ Act 1. If your Sonic 1 zone is in one of these previously unused slots, change the EHZ 1 to whatever you want to follow the zone you put in.

    Hope this helps. I hope I clarified it well enough. And as an aside... I saw the above topic.

    Thank you for clarifying this about the non-sprite data in VRAM and what it was exactly, you guys... and this is also very much like what MarkeyJester recommended I do with the Goggles. I'll look into doing it with the Shield and Invincibility as well.
     
  10. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Does anyone know how to edit Sonic 2 so all regions display Tails' data as 'MILES' rather than just Japan?
     
  11. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    I'm using Xeno's dis. For "end of level" results screen, go to "loc_14102:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     btst    #7,(Graphics_Flags).w
    2.     beq.s   loc_14118
    3.     addq.w  #1,d0


    For "end of special stage" results screen, go to "loc_1449A:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     btst    #7,(Graphics_Flags).w
    2.     beq.s   loc_144AE
    3.     addq.w  #1,d0


    In the special stage results, there's a bit called ""Tails" rings". To change that to Miles, go to "loc_14532:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     btst    #7,(Graphics_Flags).w
    2.     beq.s   loc_1454E
    3.     addq.w  #1,d0


    When Sonic and Tails, ""Tails" rings" will need changing too. To change that to Miles, go to "loc_144DC:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     btst    #7,(Graphics_Flags).w
    2.     beq.s   loc_144FA
    3.     addq.w  #1,d0


    For the HUD in special stage, go to "loc_7002:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     tst.b   (Graphics_Flags).w
    2.     bpl.s   loc_7012
    3.     addq.w  #3,d1 ; set special stage tails name to "TAILS" instead of MILES


    For his lives, go to "Level_ClrRam:", and just above this label, locate and comment out (or delete) these four lines:

    Code (ASM):
    1.     tst.b   (Graphics_Flags).w
    2.     bpl.s   +
    3.     addq.w  #2,d0
    4. +


    For the text in options, go to "loc_9268:" and comment out (or delete) these three lines:

    Code (ASM):
    1.     tst.b   (Graphics_Flags).w
    2.     bpl.s   loc_927A
    3.     lea (off_92DE).l,a4


    Seeming as it's not being used anymore, to save space, you can go and comment out (or delete) these seeming as it's never going to be used anymore. Locate "off_92DE:" and comment out (or delete) these four lines:

    Code (ASM):
    1. off_92DE:
    2.     dc.l byte_97EC
    3.     dc.l byte_97FC
    4.     dc.l byte_981C

    and then search for "byte_97EC:" and comment out (or delete) this:

    Code (ASM):
    1. byte_97EC:  dc.b  $E,"SONIC AND TAILS"

    and then search for "byte_981C:" and comment out (or delete) this:
    Code (ASM):
    1. byte_981C:  dc.b  $E,"TAILS ALONE    "

    DO NOT COMMENT OUT OR DELETE:

    [ASM]byte_97FC: dc.b $E,"SONIC ALONE "[/ASM]

    as it is being used for something else.



    You might as well delete the coding for inserting the cheat to change the text to Miles. Under "TitleScreen_Loop:" locate and then comment out (or delete) this command:

    Code (ASM):
    1.     bsr.w   TailsNameCheat

    Then go to "TailsNameCheat:" and comment out (or delete) all this:

    Code (ASM):
    1. TailsNameCheat:
    2.     lea (TailsNameCheat_Buttons).l,a0
    3.     move.w  (Correct_cheat_entries).w,d0
    4.     adda.w  d0,a0
    5.     move.b  (Ctrl_1_Press).w,d0
    6.     andi.b  #$F,d0
    7.     beq.s   return_3DEC
    8.     cmp.b   (a0),d0
    9.     bne.s   loc_3DE6
    10.     addq.w  #1,(Correct_cheat_entries).w
    11.     tst.b   1(a0)
    12.     bne.s   return_3DEC
    13.     bchg    #7,(Graphics_Flags).w ; turn on the cheat that changes MILES to "TAILS"
    14.     move.b  #$35+$80,d0 ; play the ring sound for a successfully entered cheat
    15.     bsr.w   PlaySound
    16.  
    17. loc_3DE6:
    18.     move.w  #0,(Correct_cheat_entries).w
    19.  
    20. return_3DEC:
    21.     rts
    22. ; End of function TailsNameCheat
    23.  
    24. ; ===========================================================================
    25. ; byte_3DEE:
    26. TailsNameCheat_Buttons:
    27.     dc.b     1 ; up
    28.     dc.b     2 ; down
    29.     dc.b     2 ; down
    30.     dc.b     2 ; down
    31.     dc.b     1 ; up
    32.     dc.b     0

    I think that's it.



    EDIT: Or, if you're feeling really lazy and just want to set the flag to automatically turn all text to Miles, you can insert this somewhere:

    Code (ASM):
    1.     bclr    #7,(Graphics_Flags).w   ; Set flag to make all "Tails" text turn to "Miles"

    Like at, I don't know, in the SEGA screen coding, like so:

    Code (ASM):
    1. SegaScreen:
    2.     bclr    #7,(Graphics_Flags).w   ; Set flag to make all "Tails" text turn to "Miles"
    3.     move.b  #$7D+$80,d0
    4.     bsr.w   PlayMusic ; stop music
    5. ;   ...

    So when you play the game, as soon as the SEGA screen appears, it will set the flag to make all "Tails" text turn to "Miles". The beautiful thing about this is, you can then do the Tails cheat on the main title screen, and then all the Miles will turn back in Tails. Until you hit the SEGA screen again which will automatically turn it back to Miles (even if it's already Miles), but whatever.
     
  12. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    You need to change a few locations for it: the toggle is in places that test bit 7 of Graphics_Flags ($FFF8); this can be done by one of the following sequences of code:
    Code (Text):
    1.     btst    #7,(Graphics_Flags).w   ; Is this a Japanese Mega Drive?
    2.     bne.*   <location>  ; Branch if yes
    3.     btst    #7,(Graphics_Flags).w   ; Is this a Japanese Mega Drive?
    4.     beq.*   <location>  ; Branch if not
    5.     tst.*    (Graphics_Flags).w ; Is this a Japanese Mega Drive?
    6.     bmi.*   <location>  ; Branch if yes
    7.     tst.*    (Graphics_Flags).w ; Is this a Japanese Mega Drive?
    8.     bpl.*   <location>  ; Branch if not
    Some of these sequences control whether to display Tails or Miles. There aren't many locations; the end of level signposts, special stage HUD, normal game HUD and options screen are the ones I can remember off the top of my head.

    Another possibility is to set bit 7 of Graphics_Flags when it is initialized (near loc_370) if you can live with the "TM" near the Sega logo on the Sega screen; to do so, just add a "bset #7,(Graphics_Flags).w" there.

    In either case, you may want to disable the cheat.

    Edit: ninja'd by RedHotSonic.
     
  13. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    That will make all the text as Tails. It needs to be a bclr for it to become Miles :)
     
  14. flamewing

    flamewing

    Emerald Hunter Tech Member
    1,161
    65
    28
    France
    Sonic Classic Heroes; Sonic 2 Special Stage Editor; Sonic 3&K Heroes (on hold)
    Right. That shows I am too tired to be useful today [​IMG]
     
  15. Caverns 4

    Caverns 4

    Member
    346
    0
    16
    Sonic: Retold
    Okay, so stupid question time:

    Looking in the SonLvL ini file for Sonic 1-28, I see these lines:
    Code (Text):
    1. chunkfmt=S2
    2. layoutfmt=S2
    3. layoutcmp=Uncompressed
    4. colindfmt=S2
    5. colindcmp=Uncompressed
    It's pretty obvious what these do; they're telling SonLvL that these components are formatted differently from the ones normally belonging to the game.

    Art there commands to do this for other data too, like 16x16 block mappings, object art, level art, etc.? If so, what are they?
     
  16. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,743
    338
    63
    SonLVL
    User:MainMemory/S2LVL INI File Setup
    I really need to write a user manual sometime.

    Object art though is determined by the object definitions, which varies depending on whether you're using plain ini, xml, or C#/VB.NET for the definitions.
     
  17. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    Thanx for the fixes guys. Didn't know you could do them all individually, which is helpful.

    Does anyone know why whenever I try to edit anything from the continue screen the game freezes?
     
  18. MarkeyJester

    MarkeyJester

    Original, No substitute Resident Jester
    2,203
    432
    63
    Japan
    I recall there being a few places in the old Sonic 2 disassembly that were not disassembled correctly, one of them was in fact in the continue screen in the routine "loc_7AF8:"

    Code (ASM):
    1.     move.l  #$7CB6,mappings(a1)
    That of which 7CB6 is the ROM location of the mappings, but since it's the raw offset as opposed to a lable, editing the source code and changing the size of the data in the ROM in places can cause the data to shift, and results in that instruction's offset being "unlinked".

    I'm asssuming it should be this:

    Code (ASM):
    1.     move.l  #ObjDA_MapUnc_7CB6,mappings(a0)
    I'm not sure if that is your problem, but it's the only bug I can think of available with the original stock disassembly that could be your problem. Get back me on that.
     
  19. E-122-Psi

    E-122-Psi

    Member
    2,470
    612
    93
    I'm not sure really, what I've edited are the art files of the 'mini characters', not the mappings. I edited Tails' animation and got it to work, but there's some garbage on the screen.
     
  20. redhotsonic

    redhotsonic

    Also known as RHS Tech Member
    1,587
    10
    18
    United Kingdom
    YouTuber
    All Xeno's disassembly users have this issue. Although, making the change that MJ mentioned, should fix it. Well, it did for me when I did it years ago anyway. IF there's still a problem, it might be a change you made.

    Can you show a screenshot of this "garbage" on the screen?

    Oh, and MJ, lol at your signiture. I like watching Frasier!