Sonic 1 Rev01 LZ deformation question

Discussion in 'Discussion and Q&A Archive' started by Ashuro, Mar 19, 2015.

Thread Status:
Not open for further replies.
  1. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Hi!

    i've see this topic ; http://sonicresearch.org/forums/index.php?showtopic=4094 ;

    And i remember that i have a level with so much fire (MZ).
     

    1. ; ===========================================================================
    2. ; ---------------------------------------------------------------------------
    3. ; Scroll routine for Labyrinth Zone - optimised by MarkeyJester
    4. ; ---------------------------------------------------------------------------
    5.  
    6. Deform_LZ:
    7.                 moveq   #$07,d0                                 ; prepare multiplication 100 / 2 for BG scrolling
    8.                 move.w  ($FFFFF73A).w,d4                        ; load horizontal movement distance (Since last frame)
    9.                 ext.l   d4                                      ; extend to long-word signed
    10.                 asl.l   d0,d4                                   ; align as fixed point 16, but divide by 2 for BG
    11.                 move.w  ($FFFFF73C).w,d5                        ; load vertical movement distance (Since last frame)
    12.                 ext.l   d5                                      ; extend to long-word signed
    13.                 asl.l   d0,d5                                   ; align as fixed point 16, but divide by 2 for BG
    14.                 bsr.w   ScrollBlock1                            ; adjust BG scroll positions (and set draw code direction flags)
    15.                 move.w  ($FFFFF70C).w,($FFFFF618).w             ; set BG V-scroll position
    16.                 lea     ($FFFFCC00).w,a1                        ; load H-scroll buffer
    17.                 move.w  ($FFFFF700).w,d0                        ; load FG X position
    18.                 neg.w   d0                                      ; reverse
    19.                 swap    d0                                      ; send to upper word
    20.                 move.w  ($FFFFF708).w,d0                        ; load BG X position
    21.                 neg.w   d0                                      ; reverse
    22.                 moveq   #$00,d3                                 ; clear d3
    23.                 move.b  ($FFFFF7D8).w,d3                        ; load wave-scroll timer
    24.                 addi.w  #$0080,($FFFFF7D8).w                    ; increase wave-scroll timer
    25.                 move.w  #$00E0,d2                               ; prepare water-line count
    26.                 move.w  ($FFFFF646).w,d1                        ; load water line position
    27.                 sub.w   ($FFFFF704).w,d1                        ; minus FG Y position
    28.                 bmi.s   DLZ_Water                               ; if the screen is already underwater, branch
    29.                 cmp.w   d2,d1                                   ; is the water line below the screen?
    30.                 ble.s   DLZ_NoWater                             ; if not, branch
    31.                 move.w  d2,d1                                   ; set at maximum
    32.  
    33. DLZ_NoWater:
    34.                 sub.w   d1,d2                                   ; subtract from water-line count
    35.                 add.b   d1,d3                                   ; advance scroll wave timer to correct amount
    36.                 subq.b  #$01,d1                                 ; decrease above water count
    37.                 bcs.s   DLZ_Water                               ; if finished, branch
    38.  
    39. DLZ_Above:
    40.                 move.l  d0,(a1)+                                ; save scroll position to buffer
    41.                 dbf     d1,DLZ_Above                            ; repeat for all above water lines
    42.  
    43. DLZ_Water:
    44.                 subq.b  #$01,d2                                 ; decrease below water count
    45.                 bcs.s   DLZ_Finish                              ; if finished, branch
    46.                 move.w  d0,d1                                   ; copy BG position back to d1
    47.                 swap    d0                                      ; move FG position back to lower word in d0
    48.                 move.w  d3,d4                                   ; copy sroll timer for BG use
    49.                 add.b   ($FFFFF704+$01).w,d3                    ; add FG Y position
    50.                 add.b   ($FFFFF70C+$01).w,d4                    ; add BG Y position
    51.                 add.w   d3,d3                                   ; multiply by word size (2)
    52.                 add.w   d4,d4                                   ; ''
    53.                 lea     (DLZ_WaveBG).l,a3                       ; load beginning of BG wave data
    54.                 adda.w  d4,a3                                   ; advance to correct starting point
    55.                 move.b  (a3),d4                                 ; get current position byte
    56.                 asr.b   #$02,d4                                 ; get only the position bits
    57.                 ext.w   d4                                      ; extend to word
    58.                 add.w   d4,d1                                   ; adjust BG's current position
    59.                 lea     DLZ_WaveFG(pc,d3.w),a2                  ; load correct starting point of FG wave data
    60.                 move.b  (a2),d4                                 ; get current position byte
    61.                 asr.b   #$02,d4                                 ; get only the position bits
    62.                 ext.w   d4                                      ; extend to word
    63.                 add.w   d4,d0                                   ; adjust FG's current position
    64.  
    65. DLZ_Below:
    66.                 add.w   (a2)+,d0                                ; alter FG horizontal position
    67.                 move.w  d0,(a1)+                                ; save to scroll buffer
    68.                 add.w   (a3)+,d1                                ; alter BG horizontal position
    69.                 move.w  d1,(a1)+                                ; save to scroll buffer
    70.                 dbf     d2,DLZ_Below                            ; repeat for all below water lines
    71.  
    72. DLZ_Finish:
    73.                 rts                                             ; return
    74.  
    75. ; ---------------------------------------------------------------------------
    76. ; Scroll data for the FG
    77. ; ---------------------------------------------------------------------------
    78.  
    79. DLZ_WaveFG:
    80.                 rept    $02
    81.                 dc.w    $0001,$0400,$0401,$0800,$0801,$0C00,$0C00,$0C00,$0FFF,$0800,$0BFF,$0400,$07FF,$0000,$0000,$0000
    82.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    83.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    84.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    85.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    86.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    87.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    88.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    89.                 dc.w    $03FF,$FC00,$FFFF,$F800,$FBFF,$F400,$F400,$F400,$F401,$F800,$F801,$FC00,$FC01,$0000,$0000,$0000
    90.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    91.                 dc.w    $0001,$0400,$0401,$0800,$0801,$0C00,$0C00,$0C00,$0FFF,$0800,$0BFF,$0400,$07FF,$0000,$0000,$0000
    92.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    93.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    94.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    95.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    96.                 dc.w    $0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
    97.                 endr
    98.  
    99. ; ---------------------------------------------------------------------------
    100. ; Scroll data for the BG
    101. ; ---------------------------------------------------------------------------
    102.  
    103. DLZ_WaveBG:     rept    $04
    104.                 dc.w    $FC01,$0000,$0000,$0000,$0000,$0000,$0001,$0400,$0400,$0400,$0400,$0401,$0800,$0800,$0800,$0800
    105.                 dc.w    $0800,$0800,$0801,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00
    106.                 dc.w    $0C01,$13FF,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0C00,$0FFF
    107.                 dc.w    $0800,$0800,$0800,$0800,$0800,$0800,$0BFF,$0400,$0400,$0400,$0400,$07FF,$0000,$0000,$0000,$0000
    108.                 dc.w    $0000,$03FF,$FC00,$FC00,$FC00,$FC00,$FFFF,$F800,$F800,$F800,$F800,$FBFF,$F400,$F400,$F400,$F400
    109.                 dc.w    $F400,$F400,$F7FF,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000
    110.                 dc.w    $F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F000,$F001
    111.                 dc.w    $F400,$F400,$F400,$F400,$F400,$F400,$F401,$F800,$F800,$F800,$F800,$F801,$FC00,$FC00,$FC00,$FC00
    112.                 endr
    113.  
    114. ; ===========================================================================

    I want to make the FG and BG of MZ deform like the LZ deformation in the Rev01 version of Sonic 1.

    How and where can i begin (i DON'T want a code or a solution, bug again, just learn).
     
  2. Pacca

    Pacca Having an online identity crisis since 2019 Member

    Joined:
    Jul 5, 2014
    Messages:
    1,175
    Location:
    Limbo
    First off, figure out where the water checks are, and remove them; unless your getting exceptionally creative with Marble Zones gimmicks, I highly doubt you'll be needing the deform to interact with water. DLZ_NoWater, at a glance, looks suspicious; try branching past it to one of the later routines.
     
  3. Ashuro

    Ashuro Anti-Cosmic Metal Of Death Member

    Joined:
    Sep 27, 2014
    Messages:
    550
    Location:
    France
    Ok, i almost see what you tell me. i will try something now!
     
Thread Status:
Not open for further replies.