Basic Questions & Answers thread

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

  1. MarkeyJester

    MarkeyJester

    A D V A N C E Resident Jester
    2,083
    215
    43
    Japan
    I tried delving deep into the assembler, and the only option I could think of would be to remove all of the checks for ' symbol, unfortunately it's tied quite heavily to " symbol (obviously as a string has to end with the same symbol it started with), so I substituted ' for " so there are no string references. But then I would hit an issue where it wasn't accepting ' and so I'm assuming there's gonna be a table of acceptable characters or an array of comparison and conditional jumps for it somewhere (haven't found it yet). It's such an annoying quirk about Z80 assembly, the ' serves really no purpose being with af,af other than to indicate visually to the programmer it's swapping with an alternate af, but I'd ask "what else would it swap with?", so it seems mute.

    With regards to your macro issue, I'm not sure what you mean, I suspect I'm misunderstanding, because I tried your macro myself and it worked fine:

    Code (Text):
    1.  
    2.     getzreg   a
    3.  
    4.        dc.b   zreg
    5.  
    6.    getzreg   c
    7.  
    8.        dc.b   zreg
    ...this produced...

    Code (Text):
    1. 07 01
    I'm assuming your using this macro in a particular way that mitigates the above?
     
  2. Hivebrain

    Hivebrain

    Administrator
    2,927
    66
    28
    53.4N, 1.5W
    HiveView
    Turns out it was just a typo. I was sending the wrong value to getzreg.

    ex af,af' will have to be the one instruction that isn't perfectly matched then. Everything else seems to be working, including instructions shared with 68000. I just have a few details to iron out and it'll be ready for release.
     
  3. Rrose80149

    Rrose80149

    Member
    59
    3
    8
    I saw that in Sonic 1 Kawarino hack the goggles object was loaded on Sonic in Labyrinth Zone and Scrap Brain Zone, Act 3. But, I tried everything to get them to load. How do I implement them? I know I need VRAM, pattern load cues, and mappings, but does anyone know?
     
  4. Ravenfreak

    Ravenfreak

    Is actually a guy. Tech Member
    2,964
    98
    28
    O'Fallon Mo
    Hacking Sonic Drift, Writer at Sonic Cage Dome
  5. Rrose80149

    Rrose80149

    Member
    59
    3
    8
  6. DeltaWooloo

    DeltaWooloo

    The sheep goes quack! Member
    I've had this issue for a few months but didn't get a chance to say it here. Everyone but Sonic stays blank when they switch to path 2. I know it's a bit 6 issue, but I can't say where the issue lies. Here's a screenshot for reference:
    S1WOOLOOFIED_31.000.png
    For all I know, it's in Sonic_Loops, and it ties to bit 6. I'll send the code below:

    Code (Text):
    1. ; ---------------------------------------------------------------------------
    2. ; Subroutine to    make Sonic run around loops (GHZ/SLZ)
    3. ; ---------------------------------------------------------------------------
    4.  
    5. ; ||||||||||||||| S U B    R O U T    I N E |||||||||||||||||||||||||||||||||||||||
    6.  
    7.  
    8. Sonic_Loops:                ; XREF: Obj01_Control
    9.         cmpi.b    #id_SLZ,(v_zone).w ; is level SLZ ?
    10.         beq.s    @isstarlight    ; if yes, branch
    11.         tst.b    (v_zone).w    ; is level GHZ ?
    12.         bne.w    @noloops    ; if not, branch
    13.  
    14.     @isstarlight:
    15.         move.w    obY(a0),d0
    16.         lsr.w    #1,d0
    17.         andi.w    #$380,d0
    18.         move.b    obX(a0),d1
    19.         andi.w    #$7F,d1
    20.         add.w    d1,d0
    21.         lea    (v_lvllayout).w,a1
    22.         move.b    (a1,d0.w),d1    ; d1 is    the 256x256 tile Sonic is currently on
    23.  
    24.         cmp.b    (v_256roll1).w,d1 ; is Sonic on a "roll tunnel" tile?
    25.         beq.w    Obj01_ChkRoll    ; if yes, branch
    26.         cmp.b    (v_256roll2).w,d1
    27.         beq.w    Obj01_ChkRoll
    28.  
    29.         cmp.b    (v_256loop1).w,d1 ; is Sonic on a loop tile?
    30.         beq.s    @chkifleft    ; if yes, branch
    31.         cmp.b    (v_256loop2).w,d1
    32.         beq.s    @chkifinair
    33.         bclr    #6,obRender(a0) ; return Sonic to high plane
    34.         rts
    35. ; ===========================================================================
    36.  
    37. @chkifinair:
    38.         btst    #1,obStatus(a0)    ; is Sonic in the air?
    39.         beq.s    @chkifleft    ; if not, branch
    40.  
    41.         bclr    #6,obRender(a0)    ; return Sonic to high plane
    42.         rts
    43. ; ===========================================================================
    44.  
    45. @chkifleft:
    46.         move.w    obX(a0),d2
    47.         cmpi.b    #$2C,d2
    48.         bcc.s    @chkifright
    49.  
    50.         bclr    #6,obRender(a0)    ; return Sonic to high plane
    51.         rts
    52. ; ===========================================================================
    53.  
    54. @chkifright:
    55.         cmpi.b    #$E0,d2
    56.         bcs.s    @chkangle1
    57.  
    58.         bset    #6,obRender(a0)    ; send Sonic to    low plane
    59.         rts
    60. ; ===========================================================================
    61.  
    62. @chkangle1:
    63.         btst    #6,obRender(a0) ; is Sonic on low plane?
    64.         bne.s    @chkangle2    ; if yes, branch
    65.  
    66.         move.b    obAngle(a0),d1
    67.         beq.s    @done
    68.         cmpi.b    #$80,d1        ; is Sonic upside-down?
    69.         bhi.s    @done        ; if yes, branch
    70.         bset    #6,obRender(a0)    ; send Sonic to    low plane
    71.         rts
    72. ; ===========================================================================
    73.  
    74. @chkangle2:
    75.         move.b    obAngle(a0),d1
    76.         cmpi.b    #$80,d1        ; is Sonic upright?
    77.         bls.s    @done        ; if yes, branch
    78.         bclr    #6,obRender(a0)    ; send Sonic to    high plane
    79.  
    80. @noloops:
    81. @done:
    82.         rts
    83. ; End of function Sonic_Loops

    All the code is pretty much the same as ReadySonic and has not changed. Unfortunately, I initially used the Hivebrain code which also didn't work either. Does anyone know how I'm able to fix this?
     
  7. JayRay

    JayRay

    Member
    2
    0
    1
    Hello! I'm brand spanking new to creating mods for Sonic Gens, and I would like to completely remove a set of models/enemies. Specifically I would like to alter the 06 mod to not have any Iblis or Mephiles, and replace them with the G.U.N. robots and shadow respectively. Can anyone point me in the right direction of what I need to look into doing? I read all the guides on this site but don't see anything specific on how to do what I'm trying to do with character models. I can research how to use the tools, I just need a bit help knowing what tools I need/a birdseye view of what's involved.

    Hello! I asked on the Basic Q&A but not sure if that's the right place for this question.

    I'm brand spanking new to creating mods for Sonic Gens, and I would like to completely remove a set of models/enemies. Specifically I would like to alter the 06 mod to not have any Iblis or Mephiles, and replace them with the G.U.N. robots and shadow respectively. Can anyone point me in the right direction of what I need to look into doing? I read all the guides on this site but don't see anything specific on how to do what I'm trying to do with character models. I can research how to use the tools, I just need a bit help knowing what tools I need/a birdseye view of what's involved.

    Thank you so much for your patience!
     
    Last edited by a moderator: Sep 21, 2021
  8. Hivebrain

    Hivebrain

    Administrator
    2,927
    66
    28
    53.4N, 1.5W
    HiveView
    EDIT: I solved it myself. Apparently under no circumstances can = make a forward reference, even if it's referencing a fixed value (equ). I just had to define the sizeof values earlier.


    I'm trying to automate VRAM management with some macros, and I've run into a bit of a problem:

    What's causing this error? sizeof_nem_ring is definitely $1C0, it's defined by the following line which I'm quite sure is working:

    sizeof_nem_ring is defined after last_vram, but that shouldn't be a problem because it's an equ.

    This is the line in the macro that's causing trouble.
     
    Last edited: Sep 26, 2021
  9. Hivebrain

    Hivebrain

    Administrator
    2,927
    66
    28
    53.4N, 1.5W
    HiveView
    If I have a bclr instruction followed by a beq, does that mean it branches if the bit was already clear? I'm assuming that's how it works but I just wanted to confirm.

    Example:
    Code (Text):
    1. bclr   #0,d0       ; clear bit 0
    2. beq.s   @offset_even   ; branch if already clear
     
  10. AURORA☆FIELDS

    AURORA☆FIELDS

    The cute one here Tech Member
    216
    21
    18
    Finland
    AMPS
    yes, only if it was clear before the bclr instruction
     
    • Like Like x 1
    • Agree Agree x 1
    • Useful Useful x 1
    • List
  11. Inferno

    Inferno

    Member
    33
    57
    18
    Sonic 1 Definitive
    Aight, here we go again.

    Sonic 1 Definitive, I'm currently working slowly on level transitions. This doesn't cover the entire portion of that mess, though, specifically one part: Moduled Kosinski.

    It, for some reason, only wants to load 1 module.

    I'll send the code involved and the relevant portion of my variables file.

    Code (Text):
    1. ;---------------------------------------------------------------------------
    2. ; Adds a Kosinski Moduled archive to the module queue
    3. ; Inputs:
    4. ; a1 = address of the archive
    5. ; d2 = destination in VRAM
    6. ; ---------------------------------------------------------------------------
    7.  
    8. ; =============== S U B R O U T I N E =======================================
    9.  
    10.  
    11. Queue_Kos_Module:
    12.         lea    (Kos_module_queue).w,a2
    13.         tst.l    (a2)    ; is the first slot free?
    14.         beq.s    Process_Kos_Module_Queue_Init    ; if it is, branch
    15.         addq.w    #6,a2    ; otherwise, check next slot
    16.  
    17. KosM_FindFreeSlot:
    18.         tst.l    (a2)
    19.         beq.s    KosM_FreeSlotFound
    20.         addq.w    #6,a2
    21.         bra.s    KosM_FindFreeSlot
    22. ; ---------------------------------------------------------------------------
    23.  
    24. KosM_FreeSlotFound:
    25.         move.l    a1,(a2)+    ; store source address
    26.         move.w    d2,(a2)+    ; store destination VRAM address
    27.         rts
    28. ; End of function Queue_Kos_Module
    29.  
    30. ; ---------------------------------------------------------------------------
    31. ; Initializes processing of the first module on the queue
    32. ; ---------------------------------------------------------------------------
    33.  
    34. ; =============== S U B R O U T I N E =======================================
    35.  
    36.  
    37. Process_Kos_Module_Queue_Init:
    38.         move.w    (a1)+,d3    ; get uncompressed size
    39.         cmpi.w    #$A000,d3
    40.         bne.s    @size
    41.         move.w    #$8000,d3    ; $A000 means $8000 for some reason
    42. @size:
    43.         lsr.w    #1,d3
    44.         move.w    d3,d0
    45.         rol.w    #5,d0
    46.         andi.w    #$1F,d0    ; get number of complete modules
    47.         move.b    d0,(Kos_modules_left).w
    48.         andi.l    #$7FF,d3    ; get size of last module in words
    49.         bne.s    @nonzero    ; branch if it's non-zero
    50.         subq.b    #1,(Kos_modules_left).w    ; otherwise decrement the number of modules
    51.         move.l    #$800,d3    ; and take the size of the last module to be $800 words
    52. @nonzero:
    53.         move.w    d3,(Kos_last_module_size).w
    54.         move.w    d2,(Kos_module_destination).w
    55.         move.l    a1,(Kos_module_queue).w
    56.         addq.b    #1,(Kos_modules_left).w    ; store total number of modules
    57.         rts
    58. ; End of function Process_Kos_Module_Queue_Init
    59.  
    60. ; ---------------------------------------------------------------------------
    61. ; Processes the first module on the queue
    62. ; ---------------------------------------------------------------------------
    63.  
    64. ; =============== S U B R O U T I N E =======================================
    65.  
    66.  
    67. Process_Kos_Module_Queue:
    68.         tst.b    (Kos_modules_left).w
    69.         bne.s    KosM_ModulesLeft
    70.  
    71. KosM_Done:
    72.         rts
    73. ; ---------------------------------------------------------------------------
    74.  
    75. KosM_ModulesLeft:
    76.         bmi.s    KosM_DecompressionStarted
    77.         cmpi.w    #4,(Kos_decomp_queue_count).w
    78.         bhs.s    KosM_Done    ; branch if the Kosinski decompression queue is full
    79.         movea.l    (Kos_module_queue).w,a1
    80.         lea    (Kos_decomp_buffer).w,a2
    81.         bsr.w    Queue_Kos    ; add current module to decompression queue
    82.         ori.b    #$80,(Kos_modules_left).w    ; and set bit to signify decompression in progress
    83.         rts
    84. ; ---------------------------------------------------------------------------
    85.  
    86. KosM_DecompressionStarted:
    87.         tst.w    (Kos_decomp_queue_count).w
    88.         bne.s    KosM_Done    ; branch if the decompression isn't complete
    89.  
    90.         ; otherwise, DMA the decompressed data to VRAM
    91.         andi.b    #$7F,(Kos_modules_left).w
    92.         move.l    #$800,d3
    93.         subq.b    #1,(Kos_modules_left).w
    94.         bne.s    @notlast    ; branch if it isn't the last module
    95.         move.w    (Kos_last_module_size).w,d3
    96. @notlast:
    97.         move.w    (Kos_module_destination).w,d2
    98.         move.w    d2,d0
    99.         add.w    d3,d0
    100.         add.w    d3,d0
    101.         move.w    d0,(Kos_module_destination).w    ; set new destination
    102.         move.l    (Kos_module_queue).w,d0
    103.         move.l    (Kos_decomp_queue).w,d1
    104.         sub.l    d1,d0
    105.         andi.l    #$F,d0
    106.         add.l    d0,d1    ; round to the nearest $10 boundary
    107.         move.l    d1,(Kos_module_queue).w    ; and set new source
    108.         move.l    #Kos_decomp_buffer,d1
    109.         andi.l    #$FFFFFF,d1
    110.         jsr    (QueueDMATransfer).l
    111.         tst.b    (Kos_modules_left).w
    112.         bne.s    @return    ; return if this wasn't the last module
    113.         lea    (Kos_module_queue).w,a0
    114.         lea    (Kos_module_queue+6).w,a1
    115.         move.l    (a1)+,(a0)+    ; otherwise, shift all entries up
    116.         move.w    (a1)+,(a0)+
    117.         move.l    (a1)+,(a0)+
    118.         move.w    (a1)+,(a0)+
    119.         move.l    (a1)+,(a0)+
    120.         move.w    (a1)+,(a0)+
    121.         move.l    #0,(a0)+    ; and mark the last slot as free
    122.         move.w    #0,(a0)+
    123.         move.l    (Kos_module_queue).w,d0
    124.         beq.s    @return    ; return if the queue is now empty
    125.         movea.l    d0,a1
    126.         move.w    (Kos_module_destination).w,d2
    127.         jmp    (Process_Kos_Module_Queue_Init).l
    128. @return:
    129.         rts
    130. ; End of function Process_Kos_Module_Queue
    131.  
    132. ; =============== S U B R O U T I N E =======================================
    133.  
    134.  
    135. Queue_Kos:
    136.         move.w    (Kos_decomp_queue_count).w,d0
    137.         lsl.w    #3,d0
    138.         lea    (Kos_decomp_queue).w,a3
    139.         move.l    a1,(a3,d0.w)    ; store source
    140.         move.l    a2,4(a3,d0.w)    ; store destination
    141.         addq.w    #1,(Kos_decomp_queue_count).w
    142.         rts
    143. ; End of function Queue_Kos
    144.  
    145. ; ---------------------------------------------------------------------------
    146. ; Checks if V-int occured in the middle of Kosinski queue processing
    147. ; and stores the location from which processing is to resume if it did
    148. ; ---------------------------------------------------------------------------
    149.  
    150. ; =============== S U B R O U T I N E =======================================
    151.  
    152.  
    153. Set_Kos_Bookmark:
    154.         tst.w    (Kos_decomp_queue_count).w
    155.         bpl.s    @no    ; branch if a decompression wasn't in progress
    156.         move.l    $42(sp),d0    ; check address V-int is supposed to rte to
    157.         cmpi.l    #Process_Kos_Queue_Main,d0
    158.         blo.s    @no
    159.         cmpi.l    #Process_Kos_Queue_Done,d0
    160.         bhs.s    @no
    161.         move.l    $42(sp),(Kos_decomp_bookmark).w
    162.         move.l    #Backup_Kos_Registers,$42(sp)    ; force V-int to rte here instead if needed
    163. @no:
    164.         rts
    165. ; End of function Set_Kos_Bookmark
    166.  
    167. ; ---------------------------------------------------------------------------
    168. ; Processes the first entry in the Kosinski decompression queue
    169. ; ---------------------------------------------------------------------------
    170.  
    171. ; =============== S U B R O U T I N E =======================================
    172.  
    173.  
    174. Process_Kos_Queue:
    175.         tst.w    (Kos_decomp_queue_count).w
    176.         beq.w    Process_Kos_Queue_Done
    177.         bmi.w    Restore_Kos_Bookmark    ; branch if a decompression was interrupted by V-int
    178.  
    179. Process_Kos_Queue_Main:
    180.         ori.w    #$8000,(Kos_decomp_queue_count).w    ; set sign bit to signify decompression in progress
    181.         movea.l    (Kos_decomp_queue).w,a0
    182.         movea.l    (Kos_decomp_destination).w,a1
    183.  
    184.         ; what follows is identical to the normal Kosinski decompressor except for using Kos_description_field instead of the stack
    185.         lea    (Kos_description_field).w,a2
    186.         move.b    (a0)+,1(a2)
    187.         move.b    (a0)+,(a2)
    188.         move.w    (a2),d5
    189.         moveq    #$F,d4
    190.  
    191. Process_Kos_Queue_Loop:
    192.         lsr.w    #1,d5
    193.         move    sr,d6
    194.         dbf    d4,Process_Kos_Queue_ChkBit
    195.         move.b    (a0)+,1(a2)
    196.         move.b    (a0)+,(a2)
    197.         move.w    (a2),d5
    198.         moveq    #$F,d4
    199.  
    200. Process_Kos_Queue_ChkBit:
    201.         move    d6,ccr
    202.         bcc.s    Process_Kos_Queue_RLE
    203.         move.b    (a0)+,(a1)+
    204.         bra.s    Process_Kos_Queue_Loop
    205. ; ---------------------------------------------------------------------------
    206.  
    207. Process_Kos_Queue_RLE:
    208.         moveq    #0,d3
    209.         lsr.w    #1,d5
    210.         move    sr,d6
    211.         dbf    d4,Process_Kos_Queue_ChkBit2
    212.         move.b    (a0)+,1(a2)
    213.         move.b    (a0)+,(a2)
    214.         move.w    (a2),d5
    215.         moveq    #$F,d4
    216.  
    217. Process_Kos_Queue_ChkBit2:
    218.         move    d6,ccr
    219.         bcs.s    Process_Kos_Queue_SeparateRLE
    220.         lsr.w    #1,d5
    221.         dbf    d4,@loop
    222.         move.b    (a0)+,1(a2)
    223.         move.b    (a0)+,(a2)
    224.         move.w    (a2),d5
    225.         moveq    #$F,d4
    226. @loop:
    227.         roxl.w    #1,d3
    228.         lsr.w    #1,d5
    229.         dbf    d4,@loop2
    230.         move.b    (a0)+,1(a2)
    231.         move.b    (a0)+,(a2)
    232.         move.w    (a2),d5
    233.         moveq    #$F,d4
    234. @loop2:
    235.         roxl.w    #1,d3
    236.         addq.w    #1,d3
    237.         moveq    #-1,d2
    238.         move.b    (a0)+,d2
    239.         bra.s    Process_Kos_Queue_RLELoop
    240. ; ---------------------------------------------------------------------------
    241.  
    242. Process_Kos_Queue_SeparateRLE:
    243.         move.b    (a0)+,d0
    244.         move.b    (a0)+,d1
    245.         moveq    #-1,d2
    246.         move.b    d1,d2
    247.         lsl.w    #5,d2
    248.         move.b    d0,d2
    249.         andi.w    #7,d1
    250.         beq.s    Process_Kos_Queue_SeparateRLE2
    251.         move.b    d1,d3
    252.         addq.w    #1,d3
    253.  
    254. Process_Kos_Queue_RLELoop:
    255.         move.b    (a1,d2.w),d0
    256.         move.b    d0,(a1)+
    257.         dbf    d3,Process_Kos_Queue_RLELoop
    258.         bra.s    Process_Kos_Queue_Loop
    259. ; ---------------------------------------------------------------------------
    260.  
    261. Process_Kos_Queue_SeparateRLE2:
    262.         move.b    (a0)+,d1
    263.         beq.s    Process_Kos_Queue_EndReached
    264.         cmpi.b    #1,d1
    265.         beq.w    Process_Kos_Queue_Loop
    266.         move.b    d1,d3
    267.         bra.s    Process_Kos_Queue_RLELoop
    268. ; ---------------------------------------------------------------------------
    269.  
    270. Process_Kos_Queue_EndReached:
    271.         move.l    a0,(Kos_decomp_queue).w
    272.         move.l    a1,(Kos_decomp_destination).w
    273.         andi.w    #$7FFF,(Kos_decomp_queue_count).w    ; clear decompression in progress bit
    274.         subq.w    #1,(Kos_decomp_queue_count).w
    275.         beq.s    Process_Kos_Queue_Done    ; branch if there aren't any entries remaining in the queue
    276.         lea    (Kos_decomp_queue).w,a0
    277.         lea    (Kos_decomp_queue+8).w,a1    ; otherwise, shift all entries up
    278.         move.l    (a1)+,(a0)+
    279.         move.l    (a1)+,(a0)+
    280.         move.l    (a1)+,(a0)+
    281.         move.l    (a1)+,(a0)+
    282.         move.l    (a1)+,(a0)+
    283.         move.l    (a1)+,(a0)+
    284.  
    285. Process_Kos_Queue_Done:
    286.         rts
    287. ; ---------------------------------------------------------------------------
    288.  
    289. Restore_Kos_Bookmark:
    290.         movem.l    (Kos_decomp_stored_registers).w,d0-d6/a0-a2
    291.         move.l    (Kos_decomp_bookmark).w,-(sp)
    292.         move.w    (Kos_decomp_stored_SR).w,-(sp)
    293.         rte
    294. ; ---------------------------------------------------------------------------
    295.  
    296. Backup_Kos_Registers:
    297.         move    sr,(Kos_decomp_stored_SR).w
    298.         movem.l    d0-d6/a0-a2,(Kos_decomp_stored_registers).w
    299.         rts
    300. ; End of function Process_Kos_Queue

    VBla_02:
    Code (Text):
    1. VBla_02:
    2.         bsr.w    sub_106E
    3.  
    4. VBla_14:
    5.         tst.w    (v_demolength).w
    6.         beq.w    @end
    7.         subq.w    #1,(v_demolength).w
    8.  
    9.     @end:
    10.         jmp    (Set_Kos_Bookmark).l
    VBla_08:
    Code (Text):
    1. VBla_08:
    2. ;        stopZ80
    3. ;        waitZ80
    4.         bsr.w    ReadJoypads
    5.         tst.b    (f_wtr_state).w
    6.         bne.s    @waterabove
    7.  
    8.         writeCRAM    v_pal_dry,$80,0
    9.         bra.s    @waterbelow
    10.  
    11. @waterabove:
    12.         writeCRAM    v_pal_water,$80,0
    13.  
    14.     @waterbelow:
    15.         move.w    (v_hbla_hreg).w,(a5)
    16.         move.b   (v_hbla_line).w,(v_cramwaterpos).w
    17.  
    18.         writeVRAM    v_hscrolltablebuffer,$380,vram_hscroll
    19.         writeVRAM    v_spritetablebuffer,$280,vram_sprites
    20.         jsr    (ProcessDMAQueue).l
    21.  
    22.     @nochg:
    23.         startZ80
    24.         movem.l    (v_screenposx).w,d0-d7
    25.         movem.l    d0-d7,(v_screenposx_dup).w
    26.         movem.l    (v_fg_scroll_flags).w,d0-d1
    27.         movem.l    d0-d1,(v_fg_scroll_flags_dup).w
    28.         bsr.s Demo_Time
    29.         jmp    (Set_Kos_Bookmark).l
    VBla_0A:
    Code (Text):
    1. VBla_0A:
    2. ;        stopZ80
    3. ;        waitZ80
    4.         bsr.w    ReadJoypads
    5.         writeCRAM    v_pal_dry,$80,0
    6.         writeVRAM    v_spritetablebuffer,$280,vram_sprites
    7.         writeVRAM    v_hscrolltablebuffer,$380,vram_hscroll
    8.         startZ80
    9.         bsr.w    PalCycle_SS
    10.         jsr    (ProcessDMAQueue).l
    11.  
    12.     @nochg:
    13.         cmpi.b    #96,(v_hbla_line).w
    14.         bcc.s   @update
    15.         bra.w   @end
    16.      
    17.     @update:
    18.         jsr    SS_LoadWalls
    19.      
    20.         tst.w    (v_demolength).w    ; is there time left on the demo?
    21.         beq.w    @end    ; if not, return
    22.         subq.w    #1,(v_demolength).w    ; subtract 1 from time left in demo
    23.  
    24.     @end:
    25.         jmp    (Set_Kos_Bookmark).l
    VBla_0C:
    Code (Text):
    1. VBla_0C:
    2. ;        stopZ80
    3. ;        waitZ80
    4.         bsr.w    ReadJoypads
    5.         tst.b    (f_wtr_state).w
    6.         bne.s    @waterabove
    7.  
    8.         writeCRAM    v_pal_dry,$80,0
    9.         bra.s    @waterbelow
    10.  
    11. @waterabove:
    12.         writeCRAM    v_pal_water,$80,0
    13.  
    14.     @waterbelow:
    15.         move.w    (v_hbla_hreg).w,(a5)
    16.         move.b   (v_hbla_line).w,(v_cramwaterpos).w
    17.         writeVRAM    v_hscrolltablebuffer,$380,vram_hscroll
    18.         writeVRAM    v_spritetablebuffer,$280,vram_sprites
    19.         jsr    (ProcessDMAQueue).l
    20.  
    21.     @nochg:
    22.         startZ80
    23.         movem.l    (v_screenposx).w,d0-d7
    24.         movem.l    d0-d7,(v_screenposx_dup).w
    25.         movem.l    (v_fg_scroll_flags).w,d0-d1
    26.         movem.l    d0-d1,(v_fg_scroll_flags_dup).w
    27.         jsr    LoadTilesAsYouMove
    28.         jsr    (AnimateLevelGfx).l
    29.         cmpi.b #id_BS,(v_zone).w
    30.         bne.s  @normal
    31.         jsr    (HUD_UpdateBS).l
    32.         bra.s @cont
    33.      
    34. @normal:
    35.         jsr    (HUD_Update).l
    36. @cont:
    37.         bsr.w    sub_1642
    38.         jmp    (Set_Kos_Bookmark).l
    VBla_16:
    Code (Text):
    1. VBla_16:
    2. ;        stopZ80
    3. ;        waitZ80
    4.         bsr.w    ReadJoypads
    5.         writeCRAM    v_pal_dry,$80,0
    6.         writeVRAM    v_spritetablebuffer,$280,vram_sprites
    7.         writeVRAM    v_hscrolltablebuffer,$380,vram_hscroll
    8.         startZ80
    9.         jsr    (ProcessDMAQueue).l
    10.  
    11.     @nochg:
    12.         cmpi.b    #96,(v_hbla_line).w
    13.         bcc.s   @update
    14.         bra.w   @end
    15.      
    16.     @update:
    17.         jsr    SS_LoadWalls
    18.         tst.w    (v_demolength).w
    19.         beq.w    @end
    20.         subq.w    #1,(v_demolength).w
    21.  
    22.     @end:
    23.         jmp    (Set_Kos_Bookmark).l

    Code (Text):
    1. Level_TtlCardLoop:
    2.         move.b    #$C,(v_vbla_routine).w
    3.         jsr    (Process_Kos_Queue).l
    4.         bsr.w    WaitForVBla
    5.         jsr    (ExecuteObjects).l
    6.         jsr    (BuildSprites).l
    7.         bsr.w    RunPLC
    8.         jsr    (Process_Kos_Module_Queue).l
    9.         move.w    (v_objspace+$108).w,d0
    10.         cmp.w    (v_objspace+$130).w,d0 ; has title card sequence finished?
    11.         bne.s    Level_TtlCardLoop ; if not, branch
    12.         tst.l    (v_plc_buffer).w ; are there any items in the pattern load cue?
    13.         bne.s    Level_TtlCardLoop ; if yes, branch
    14.         jsr    (Hud_Base).l    ; load basic HUD gfx
    Code (Text):
    1. Level_MainLoop:
    2.         bsr.w    PauseGame
    3.         move.b    #8,(v_vbla_routine).w
    4.         jsr    (Process_Kos_Queue).l
    5.         bsr.w    WaitForVBla
    6.         addq.w    #1,(v_framecount).w ; add 1 to level timer
    7.         bsr.w    MoveSonicInDemo
    8.         bsr.w    LZWaterFeatures
    9.         jsr    (ExecuteObjects).l
    10.         if Revision=0
    11.         else
    12.             tst.w   (f_restart).w
    13.             bne     GM_Level
    14.         endc
    15.         tst.w    (v_debuguse).w    ; is debug mode being used?
    16.         bne.s    Level_DoScroll    ; if yes, branch
    17.         cmpi.b    #6,(v_player+obRoutine).w ; has Sonic just died?
    18.         bhs.s    Level_SkipScroll ; if yes, branch
    19.  
    20.     Level_DoScroll:
    21.         bsr.w    DeformLayers
    22.  
    23.     Level_SkipScroll:
    24.         jsr    (BuildSprites).l
    25.         jsr    (ObjPosLoad).l
    26.         jsr    RingsManager
    27.         bsr.w    PaletteCycle
    28.         bsr.w    RunPLC
    29.         jsr    (Process_Kos_Module_Queue).l
    30.         bsr.w    OscillateNumDo
    31.         bsr.w    SynchroAnimate
    32.         bsr.w    SignpostArtLoad
    33.  
    34.         cmpi.b    #id_Demo,(v_gamemode).w
    35.         beq.s    Level_ChkDemo    ; if mode is 8 (demo), branch
    36.         if Revision=0
    37.         tst.w    (f_restart).w    ; is the level set to restart?
    38.         bne.w    GM_Level    ; if yes, branch
    39.         else
    40.         endc
    41.         cmpi.b    #id_Level,(v_gamemode).w
    42.         beq.w    Level_MainLoop    ; if mode is $C (level), branch
    43.         rts    

    Code (Text):
    1. Camera_X_pos_last: equ $FFFFDC02
    2. Camera_Y_pos_last: equ $FFFFDC04
    3.  
    4. ; $FFFFDC06 - $FFFFEFFF are unused.
    5.  
    6. Kos_last_module_size:    equ $FFFFDC06            ; the uncompressed size of the last module in words. All other modules are $800 words.
    7. Kos_module_queue:    equ $FFFFDC08        ; 6 bytes per entry, first longword is source location and next word is VRAM destination. Twelve words.
    8. Kos_module_source:    equ $FFFFDC30    ; long ; the compressed data location for the first module in the queue
    9. Kos_decomp_source:    equ    Kos_decomp_queue    ; long ; the compressed data location for the first entry in the queue
    10. Kos_decomp_destination:    equ    Kos_decomp_queue+4    ; long ; the decompression location for the first entry in the queue
    11. Kos_module_destination: equ    Kos_module_queue+4    ; word ; the VRAM destination for the first module in the queue
    12.  
    13. Kos_decomp_queue_count:    equ $FFFFDC38        ; the number of pieces of data on the queue. Sign bit set indicates a decompression is in progress. A word.
    14. Kos_decomp_stored_registers:    equ $FFFFDC3A        ; allows decompression to be spread over multiple frames. 40 bytes.
    15. Kos_decomp_stored_SR:    equ $FFFFDC80 ; word
    16. Kos_decomp_bookmark:    equ $FFFFDC82            ; the address within the Kosinski queue processor at which processing is to be resumed. A longword.
    17. Kos_description_field:    equ $FFFFDC86            ; used by the Kosinski queue processor the same way the stack is used by the normal Kosinski decompression routine. A word.
    18. Kos_decomp_queue:    equ $FFFFDC90        ; 2 longwords per entry, first is source location and second is decompression location. 32 bytes.
    19. Kos_modules_left:    equ $FFFFDDFE        ; the number of modules left to decompresses. Sign bit set indicates a module is being decompressed/has been decompressed. Byte.
    20.  
    21. Kos_decomp_buffer:    equ $FFFFDE00 ; $1000 byte buffer used by KosM.
    22. v_snddriver_ram:    equ $FFFFF000 ; start of RAM for the sound driver data ($5C0 bytes)

    I'm seriously baffled. If anyone can help, that'd be nice.
     
  12. E-122-Psi

    E-122-Psi

    Member
    2,131
    328
    63
    Is anyone here experienced with monitor editing or adding new icons?

    Basically I wanna add new monitors to Sonic 2, but I'm out of space, so my plan was to compress by having some icons like Eggman and the shield mirror one half. It displays alright on the monitor itself, but when you break it...

    [​IMG]

    It seems like the programming for the floating icon only takes the first block on the sprite. Anyone know how to fix this so the mirrored tiles take their extra block?

    EDIT: Now I have more technical info on the situation, what I wanna do is edit Obj2E (the hovering icon when you break a monitor natch).

    Code (Text):
    1. loc_128C2:
    2.  
    3.   move.b    d0,anim(a0)
    4.  
    5. loc_128C6:            ; Determine correct mappings offset.
    6.    addq.b    #1,d0
    7.    move.b    d0,mapping_frame(a0)
    8.    movea.l    #Obj26_MapUnc_12D36,a1
    9.    add.b    d0,d0
    10.    adda.w    (a1,d0.w),a1
    11.    addq.w    #2,a1
    12.    move.l    a1,mappings(a0)
    13.  
    14. loc_128DE:
    15.    bsr.s    sub_128E4
    16.    bra.w    DisplaySprite
    Basically from what I get the jist of, it just shows the very front chunk of the monitor frame (which is always the icon). This of course causes issue when I try to make the icon out of two mirrored chunks. Is there any way to get this routine to load the first TWO chunks of a frame instead of just one?
     
    Last edited: Oct 26, 2021
  13. Hivebrain

    Hivebrain

    Administrator
    2,927
    66
    28
    53.4N, 1.5W
    HiveView
    I don't know the specifics for Sonic 2, but in Sonic 1 there's a render flag for "raw mappings" which has the object display a single sprite. You'd need to disable that flag and create a new set of mappings for all monitor icons.
     
  14. So, SonLVL suddenly started working on my computer again, so I'm back to work on Sonic Like Legos. However, before I can release a demo, I would very much appreciate assistance with 2 things.

    Firstly, in the Github disassembly for Sonic 1, how would one edit the level order? I tried using the guide, but it's not written with this version in mind...

    And second, might anyone know how to fix this draw order issue on Robotnik's chain? Thanks in advance. sll.PNG
     
  15. RazorKillBen

    RazorKillBen

    Benny the Hog Member
    10
    1
    1
    London, UK
    Sonic Seasons
    This does appear to be the perfect thread for my question after spending a long time piecing together the answer from different articles with zero success...

    Super new to ASM and the file structures so apologies in advance, but I'm looking to load a different palette in Sonic 1 once a monitor is broken. I'm using the disassembly, and I've found the events in the '2E Monitor Content Power-Up.asm' file. As this file is completely separate and cannot reference Sonic.asm etc, do I need to write/copy the whole palette swap routine within the 2E.asm file itself and then reference it that way? It seems disconnected and can't work out an easy way to just simply load the palette into memory. I guess I was hoping for a nice single line call, but know that isn't the case. Any help appreciated - thanks!
     
  16. Brainulator

    Brainulator

    Regular garden-variety member Member
    I'll leave the second question to someone else, but for the first one, if you mean the order in which levels are played, you simply have to move stuff around in an array stored in, of all things, the code for the "SONIC HAS PASSED ACT X" object.

    Actually, if you're using the Sonic Retro GitHub version, if you've already set up the palette within the pointer list, you can simply do this within the monitor power-up file:
    Code (Text):
    1. moveq    #palid_Sonic2,d0    ; load replacement palette for Sonic
    2. bsr.w    PalLoad1
    Labels and routines can be cross-referenced between files so long as they're not local labels (i.e. start with @).
     
  17. Thanks for the help! Already got it though lol...
     
  18. RazorKillBen

    RazorKillBen

    Benny the Hog Member
    10
    1
    1
    London, UK
    Sonic Seasons
    Super helpful, thanks so much. That's what I had thought, but unfortunately, when I try to call the routine from Sonic.asm in the Monitor Power-up File I get an error trying to build the ROM:
    Code (Text):
    1. Illegal value (-35330)
    Any ideas?
     
    Last edited: Nov 11, 2021
  19. MainMemory

    MainMemory

    Kate the Wolf Tech Member
    4,551
    145
    43
    SonLVL
    The label you're referencing is too far away from the instruction. Change the "bsr.w PalLoad1" to "jsr (PalLoad1).l".
     
  20. RazorKillBen

    RazorKillBen

    Benny the Hog Member
    10
    1
    1
    London, UK
    Sonic Seasons
    Thanks, that compiles correctly now. Unfortunately, it still crashes the game with an ILLEGAL INSTRUCTION reference. I can replace the level palette in the game just fine, but I want the level palette to only change on monitor break and it's just not playing ball.