don't click here

Basic Questions & Answers thread

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

  1. CS

    CS

    Member
    29
    4
    3
    Guys, what files do I need to load into Flex2 to load the last Sonic sprites? In the default configuration, loading the Sonic sprites, mapping and DPLC, the following sprites do not appear:
    - Sonic from the "Continue" screen,
    - Sonic at the end of the game;

    I tried to insert the TOEI Sonic sprites made by Welber13 into the game Sonic 1, but they did not fit perfectly, and besides, there were no frames of Sonic running at 45º. So I fixed the frames that were necessary, readapted several of them and adjusted the collision problems due to the 8x8 tile limitation (which each frame has individually), so I'm almost done, I had to readapted a lot of things, but now it's great. It can be used in any game that uses the Sonic 1 frame scheme as an alternative version of the traditional Sonic.

    So now I just need a few frames of Sonic to finish and have a truly functional TOEI Sonic sprite sheet and binary that works on Sonic 1.

    I'm using Flex 2 and the HiveBrain disassembly, version 2005 (according to the Readme).
     

    Attached Files:

  2. Brainulator

    Brainulator

    Regular garden-variety member Member
    Both of these are separate objects with their own graphics.
     
  3. CS

    CS

    Member
    29
    4
    3
    Yes, I noticed this, I just couldn't identify which files to load to modify them, as I said. Do you know which ones they are?
     
  4. DaBigJ

    DaBigJ

    The Bubsy fan of all time Member
    54
    18
    8
    I'm using the hivebrain disassembly here, and I'm trying to modify the hud sprites. Does anyone know what files are the mappings and palettes for it?
     
  5. Kilo

    Kilo

    The Scatterbrained Hacker Tech Member
    1,362
    1,299
    93
    Canada
    Sonic 1 Source Code Recration
    Hivebrain 2005 or 2022?
    I'll provide answers for both regardless...
    So first thing we need to note is that the HUD tiles are split up into 4 files. artnem/hud.bin (2005) or Graphics Nemesis/HUD.nem (2022) contains the lettering for SCOR, TIME, and RINGS. artnem/lifeicon.bin (2005) or Graphics Nemesis/HUD - Life Counter Icon.nem (2022) has Sonic's life icon and the text that reads Sonic X:. artunc/HUD.bin (2005) or Graphics/HUD Numbers.bin (2022) contains the E for the score text and the numbers used by the upper section of the HUD. Lastly, artunc/livescnt.bin (2005) or Graphics/Lives Counter Numbers.bin (2022) contains the numbers for Sonic's life counter. Make sure you load these graphics with the correct compression, Nemesis for the main HUD and life icon, and uncompressed for the numbers.
    As for palette, it uses Sonic's palette and the stage's palette. And the mappings file will be _maps/obj21.asm (2005) or Objects/HUD Score, Time & Rings [Mappings].asm (2022).
    Currently, Flex 2, the best sprite editor on offer, doesn't allow for loading multiple graphics files sigh, so you'll only partially be able to view the HUD in editor, but it should be enough that you can edit the layout at the very least.
     
  6. DaBigJ

    DaBigJ

    The Bubsy fan of all time Member
    54
    18
    8
    @Kilo should've specified 2005, sorry. Thanks for the answers!
     
  7. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    A while ago I tried to port an alt background for the tite screen, but seems that i broke all of it, how i can fix it?:
    blastem_20250320_090917.png
     
  8. Kilo

    Kilo

    The Scatterbrained Hacker Tech Member
    1,362
    1,299
    93
    Canada
    Sonic 1 Source Code Recration
    There's 3 possibilities I can gleam from just the screenshot
    - You could have replaced the tile at tile 0 in VRAM with that checkerboard tile, it should be a blank tile, otherwise everything that should be blank will use that tile.
    - Or you've shifted where the emblem is loaded in VRAM without adjusting it in SonPLN, or PlaneED or whatever tool you use, which assumes the tiles are loaded at tile $200 to adjust the tile IDs properly.
    - Or you've improperly loaded something in code.
    The only way to narrow it down is by providing more details, what does VRAM look like in a debugger, what did you intend for the title screen to look like, and what code did you change if any.
     
  9. DaBigJ

    DaBigJ

    The Bubsy fan of all time Member
    54
    18
    8
    Got some questions for Sonic 1 Github. I'm working on a Bubsy over Sonic mod...thing, and I was wondering:
    1. How can I make it so that the jump breaks enemies and monitors when it's not using the rolling animation?
    2. How can I give the monitors, badniks and Eggman their own palettes?

    Been mainly fiddling around with the first one, and I've even managed to disable rolling all together (will probably repurpose into a glide if I can figure it out)
     
  10. Kilo

    Kilo

    The Scatterbrained Hacker Tech Member
    1,362
    1,299
    93
    Canada
    Sonic 1 Source Code Recration
    1. Open _incObj/sub ReactToItem.asm, you want to find React_Monitor and React_Enemy and find these lines:
    Code (Text):
    1. .movingdown:
    2.         cmpi.b    #id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
    3.         bne.s    .donothing
    4.         neg.w    obVelY(a0)    ; reverse Sonic's y-motion
    5.         addq.b    #2,obRoutine(a1) ; advance the monitor's routine counter
    Code (Text):
    1. React_Enemy:
    2.         tst.b    (v_invinc).w    ; is Sonic invincible?
    3.         bne.s    .donthurtsonic    ; if yes, branch
    4.         cmpi.b    #id_Roll,obAnim(a0) ; is Sonic rolling/jumping?
    5.         bne.w    React_ChkHurt    ; if not, branch
    There are 2 approaches we can take since you're replicating Bubsy. The easy way is to just change the animation ID to the falling animation, assuming you've already imported that. Alternatively, you could also just check if the player is moving downward in general. For the monitor, you can just delete the cmpi and bne instructions, since it had already done a check to see if the player was moving downwards beforehand. For enemies, you'd have to replace the cmpi and bne with this:
    Code (Text):
    1.         tst.w    obVelY(a0)    ; is Sonic moving upwards?
    2.         bmi.w    React_ChkHurt    ; if so, branch
    Or you can combine them both and do a check for the falling animation and the player moving downwards if you wanted to be 500% sure.

    2. Go to _incObj/26 Monitor.asm and find Mon_Main, you'll see
    Code (Text):
    1.         move.w    #make_art_tile(ArtTile_Monitor,0,0),obGfx(a0)
    Change the 0 after 'ArtTile_Monitor' to the palette line you want to change it to. 1 is probably the best option for your situation, since it stays relatively the same throughout the game. You'll also want to make the same change in _incObj/2E Monitor Content Power-Up.asm since it sets its own palette line. And you will have to edit the art a little to work with palette line 1.
     
  11. DaBigJ

    DaBigJ

    The Bubsy fan of all time Member
    54
    18
    8
    You are genuinely such a life savor, thank you so much. I assume this also applies to badniks and eggman too, I'll be sure to make these changes!
     
  12. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    Hmmm... what?
    [​IMG]
     
  13. MarkeyJester

    MarkeyJester

    You smash your heart against the rocks Resident Jester
    2,316
    565
    93
    Japan
    4A54 is tst.w (a4)
    6700 is beq.w

    There's only one place in Sonic 1 where these two instructions exist together, and that's in the sprite building subroutine.

    I suspect the longword data 4A546700 is being loaded from this subroutine address, and the longword is treated as an address by mistake.

    Unfortunately, that's all the help we can give with limited information.
     
  14. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    So, this is a trouble i tried to fix long time ago, and honestly, im still not able to fix it.
    I tried to do this guide, but it brokes the game in another emulators (Kega, Clownmdemu, etc.)
    upload_2025-4-17_23-23-1.png
    (Image of Clownmdemu)
    And also I tried to add this under "CheckSumCheck":
    Code (Text):
    1.  
    2.        bra.s    CheckSumOk
    3.  
    But it has the same result.

    Any help?
     
  15. Kilo

    Kilo

    The Scatterbrained Hacker Tech Member
    1,362
    1,299
    93
    Canada
    Sonic 1 Source Code Recration
    Should have posted this in the basic questions and answers thread, not to minimod. Regardless, I'll try my best to help. The checksum error has no direct connection to collision or scrolling code which seems to be giving you problems. It's only purpose to validate that all the bytes in the ROM are correct, and if not it locks up the game. It seems that there is something wrong with your ROM data and instead of trying to find the source of it, you've brute forced past the error and these are the concequences. The checksum check serves a purpose, do not remove it. Without knowing exactly what changes you've made before (Which you have a bad habit of leaving out, we can't fix your hack without info) my only educated guess is that the ROM header is misaligned. If you could share the area from StartOfRom: up until ErrorTrap: then we could verify if that is the case.
     
  16. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    I cant find the "ErrorTrap:" line
    upload_2025-5-7_14-14-29.png
    But sure!
    Code (Text):
    1.  
    2. StartOfRom:
    3. Vectors:    dc.l v_systemstack&$FFFFFF    ; Initial stack pointer value
    4.         dc.l EntryPoint            ; Start of program
    5.         dc.l BusError            ; Bus error
    6.         dc.l AddressError        ; Address error (4)
    7.         dc.l IllegalInstr        ; Illegal instruction
    8.         dc.l ZeroDivide            ; Division by zero
    9.         dc.l ChkInstr            ; CHK exception
    10.         dc.l TrapvInstr            ; TRAPV exception (8)
    11.         dc.l PrivilegeViol        ; Privilege violation
    12.         dc.l Trace                ; TRACE exception
    13.         dc.l Line1010Emu        ; Line-A emulator
    14.         dc.l Line1111Emu        ; Line-F emulator (12)
    15.         dc.l ErrorExcept        ; Unused (reserved)
    16.         dc.l ErrorExcept        ; Unused (reserved)
    17.         dc.l ErrorExcept        ; Unused (reserved)
    18.         dc.l ErrorExcept        ; Unused (reserved) (16)
    19.         dc.l ErrorExcept        ; Unused (reserved)
    20.         dc.l ErrorExcept        ; Unused (reserved)
    21.         dc.l ErrorExcept        ; Unused (reserved)
    22.         dc.l ErrorExcept        ; Unused (reserved) (20)
    23.         dc.l ErrorExcept        ; Unused (reserved)
    24.         dc.l ErrorExcept        ; Unused (reserved)
    25.         dc.l ErrorExcept        ; Unused (reserved)
    26.         dc.l ErrorExcept        ; Unused (reserved) (24)
    27.         dc.l ErrorExcept        ; Spurious exception
    28.         dc.l ErrorTrap            ; IRQ level 1
    29.         dc.l ErrorTrap            ; IRQ level 2
    30.         dc.l ErrorTrap            ; IRQ level 3 (28)
    31.         dc.l HBlank                ; IRQ level 4 (horizontal retrace interrupt)
    32.         dc.l ErrorTrap            ; IRQ level 5
    33.         dc.l VBlank                ; IRQ level 6 (vertical retrace interrupt)
    34.         dc.l ErrorTrap            ; IRQ level 7 (32)
    35.         dc.l ErrorTrap            ; TRAP #00 exception
    36.         dc.l ErrorTrap            ; TRAP #01 exception
    37.         dc.l ErrorTrap            ; TRAP #02 exception
    38.         dc.l ErrorTrap            ; TRAP #03 exception (36)
    39.         dc.l ErrorTrap            ; TRAP #04 exception
    40.         dc.l ErrorTrap            ; TRAP #05 exception
    41.         dc.l ErrorTrap            ; TRAP #06 exception
    42.         dc.l ErrorTrap            ; TRAP #07 exception (40)
    43.         dc.l ErrorTrap            ; TRAP #08 exception
    44.         dc.l ErrorTrap            ; TRAP #09 exception
    45.         dc.l ErrorTrap            ; TRAP #10 exception
    46.         dc.l ErrorTrap            ; TRAP #11 exception (44)
    47.         dc.l ErrorTrap            ; TRAP #12 exception
    48.         dc.l ErrorTrap            ; TRAP #13 exception
    49.         dc.l ErrorTrap            ; TRAP #14 exception
    50.         dc.l ErrorTrap            ; TRAP #15 exception (48)
    51.         dc.l ErrorTrap            ; Unused (reserved)
    52.         dc.l ErrorTrap            ; Unused (reserved)
    53.         dc.l ErrorTrap            ; Unused (reserved)
    54.         dc.l ErrorTrap            ; Unused (reserved)
    55.         dc.l ErrorTrap            ; Unused (reserved)
    56.         dc.l ErrorTrap            ; Unused (reserved)
    57.         dc.l ErrorTrap            ; Unused (reserved)
    58.         dc.l ErrorTrap            ; Unused (reserved)
    59.     if Revision<>2
    60.         dc.l ErrorTrap            ; Unused (reserved)
    61.         dc.l ErrorTrap            ; Unused (reserved)
    62.         dc.l ErrorTrap            ; Unused (reserved)
    63.         dc.l ErrorTrap            ; Unused (reserved)
    64.         dc.l ErrorTrap            ; Unused (reserved)
    65.         dc.l ErrorTrap            ; Unused (reserved)
    66.         dc.l ErrorTrap            ; Unused (reserved)
    67.         dc.l ErrorTrap            ; Unused (reserved)
    68.     else
    69. loc_E0:
    70.         ; Relocated code from Spik_Hurt. REVXB was a nasty hex-edit.
    71.         move.l    obY(a0),d3
    72.         move.w    obVelY(a0),d0
    73.         ext.l    d0
    74.         asl.l    #8,d0
    75.         jmp    (loc_D5A2).l
    76.  
    77.         dc.w ErrorTrap
    78.         dc.l ErrorTrap
    79.         dc.l ErrorTrap
    80.         dc.l ErrorTrap
    81.     endif
    82.         dc.b "SEGA MEGA DRIVE " ; Hardware system ID (Console name)
    83.         dc.b "(C)SEGA 1991.APR" ; Copyright holder and release date (generally year)
    84.         dc.b "Sonic: New Adventures (By PeanutNoceda)         " ; Domestic name
    85.         dc.b "Sonic: New Adventures (By PeanutNoceda)         " ; International name
    86.         if Revision=0
    87.         dc.b "GM 00001009-00"   ; Serial/version number (Rev 0)
    88.         else
    89.             dc.b "GM 00004049-01" ; Serial/version number (Rev non-0)
    90.         endif
    91. Checksum:
    92.         if Revision=0
    93.         dc.w $264A    ; Hardcoded to make it easier to check for ROM correctness
    94.         else
    95.         dc.w $AFC7
    96.         endif
    97.         dc.b "J               " ; I/O support
    98.         dc.l StartOfRom        ; Start address of ROM
    99. RomEndLoc:    dc.l EndOfRom-1        ; End address of ROM
    100.         dc.l $FF0000        ; Start address of RAM
    101.         dc.l $FFFFFF        ; End address of RAM
    102.         if EnableSRAM=1
    103.         dc.b $52, $41, $A0+(BackupSRAM<<6)+(AddressSRAM<<3), $20 ; SRAM support
    104.         else
    105.         dc.l $20202020
    106.         endif
    107.         dc.l $20202020        ; SRAM start ($200001)
    108.         dc.l $20202020        ; SRAM end ($20xxxx)
    109.         dc.b "                                                    " ; Notes (unused, anything can be put in this space, but it has to be 52 bytes.)
    110.         dc.b "JUE             " ; Region (Country code)
    111. EndOfHeader:
    112.  
    113. ; ===========================================================================
    114.  
    115. EntryPoint:
    116.         tst.l    (z80_port_1_control).l ; test port A & B control registers
    117.         bne.s    PortA_Ok
    118.         tst.w    (z80_expansion_control).l ; test port C control register
    119.  
    120. PortA_Ok:
    121.         bne.s    SkipSetup ; Skip the VDP and Z80 setup code if port A, B or C is ok...?
    122.         lea    SetupValues(pc),a5    ; Load setup values array address.
    123.         movem.w    (a5)+,d5-d7
    124.         movem.l    (a5)+,a0-a4
    125.         move.b    -$10FF(a1),d0    ; get hardware version (from $A10001)
    126.         andi.b    #$F,d0
    127.         beq.s    SkipSecurity    ; If the console has no TMSS, skip the security stuff.
    128.         move.l    #'SEGA',$2F00(a1) ; move "SEGA" to TMSS register ($A14000)
    129.  
    130. SkipSecurity:
    131.         move.w    (a4),d0    ; clear write-pending flag in VDP to prevent issues if the 68k has been reset in the middle of writing a command long word to the VDP.
    132.         moveq    #0,d0    ; clear d0
    133.         movea.l    d0,a6    ; clear a6
    134.         move.l    a6,usp    ; set usp to $0
    135.  
    136.         moveq    #$17,d1
    137. VDPInitLoop:
    138.         move.b    (a5)+,d5    ; add $8000 to value
    139.         move.w    d5,(a4)        ; move value to    VDP register
    140.         add.w    d7,d5        ; next register
    141.         dbf    d1,VDPInitLoop
    142.      
    143.         move.l    (a5)+,(a4)
    144.         move.w    d0,(a3)        ; clear    the VRAM
    145.         move.w    d7,(a1)        ; stop the Z80
    146.         move.w    d7,(a2)        ; reset    the Z80
    147.  
    148. WaitForZ80:
    149.         btst    d0,(a1)        ; has the Z80 stopped?
    150.         bne.s    WaitForZ80    ; if not, branch
    151.  
    152.         moveq    #$25,d2
    153. Z80InitLoop:
    154.         move.b    (a5)+,(a0)+
    155.         dbf    d2,Z80InitLoop
    156.      
    157.         move.w    d0,(a2)
    158.         move.w    d0,(a1)        ; start    the Z80
    159.         move.w    d7,(a2)        ; reset    the Z80
    160.  
    161. ClrRAMLoop:
    162.         move.l    d0,-(a6)    ; clear 4 bytes of RAM
    163.         dbf    d6,ClrRAMLoop    ; repeat until the entire RAM is clear
    164.         move.l    (a5)+,(a4)    ; set VDP display mode and increment mode
    165.         move.l    (a5)+,(a4)    ; set VDP to CRAM write
    166.  
    167.         moveq    #$1F,d3    ; set repeat times
    168. ClrCRAMLoop:
    169.         move.l    d0,(a3)    ; clear 2 palettes
    170.         dbf    d3,ClrCRAMLoop    ; repeat until the entire CRAM is clear
    171.         move.l    (a5)+,(a4)    ; set VDP to VSRAM write
    172.  
    173.         moveq    #$13,d4
    174. ClrVSRAMLoop:
    175.         move.l    d0,(a3)    ; clear 4 bytes of VSRAM.
    176.         dbf    d4,ClrVSRAMLoop    ; repeat until the entire VSRAM is clear
    177.         moveq    #3,d5
    178.  
    179. PSGInitLoop:
    180.         move.b    (a5)+,$11(a3)    ; reset    the PSG
    181.         dbf    d5,PSGInitLoop    ; repeat for other channels
    182.         move.w    d0,(a2)
    183.         movem.l    (a6),d0-a6    ; clear all registers
    184.         disable_ints
    185.  
    186. SkipSetup:
    187.         bra.s    GameProgram    ; begin game
     
  17. Kilo

    Kilo

    The Scatterbrained Hacker Tech Member
    1,362
    1,299
    93
    Canada
    Sonic 1 Source Code Recration
    Not really sure where you moved ErrorTrap, but alright. Nothing seems wrong with the header. What were you doing before you removed the checksum? Ideally a list of multiple things too. And I strongly suggest making a GitHub page for your project and regularly backing it up if you haven't already so you can backtrack easily when these kinds of errors start occuring.
     
  18. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    Weird...
    Well, the checksum started to appear after adding the Sonic 3 art and the victory poses.
    Oh? That problem started in the disasm that are in the github repositoty...
     
  19. CupcakeLove67

    CupcakeLove67

    More known as PeanutNoceda Member
    Someone know how I can port levels using Level Converter?
    I tried to port Hydrocity into Sonic 1, but i have this as result
    E9219853-1C7B-4DFC-8120-5D1E2E2270C6.png
    After adding the chunks and blocks files the game started to crash for some reason.
    That was what happened.
    Any help?
     
  20. MarkeyJester

    MarkeyJester

    You smash your heart against the rocks Resident Jester
    2,316
    565
    93
    Japan
    There's limited information in that screenshot.

    The address error was very likely caused by word/long-word accessing 8(a1), because a1 is 01000077 and the address error is 0100007F, the instruction is wherever "CSI_MiniSonicLoop:" is located.

    How a1 ended up with that value is unknown from that screenshot. Could be any reason, but a few to note, overflow from 00FFXXXX, or the few rare instances where the MSB byte has a non-0 value but is also used for addressing (like the main level load block list, where the Nemesis compressed art address holds a PLC index number in its MSB byte).

    EDIT: I did a little further digging, this is the instruction in question:

    Code (Text):
    1. move.w   (a2)+,8(a1)
    Under normal circumstances, a1 is a copy of a0, so a0 should have an identical value, or at the very least should hold a RAM address, specifically the object RAM. The only thing I can think of which could cause this would be an interrupt without register backup. But I feel like that's something you wouldn't touch (though it does say the caller is from Vblank (VBla_Music), did you touch anything here?).

    Maybe a last dodge effort here, but do you have "even" under all of the incbin/binclude files for HCZ when you ported them over? (Not that I think it would cause this, but there's not much information to give you a clear answer).
     
    Last edited: May 16, 2025