Skip to content

Commit

Permalink
Documented SwScrl_ARZ
Browse files Browse the repository at this point in the history
Some neat beta stuff in here
  • Loading branch information
Clownacy committed Jun 10, 2016
1 parent 9b133e9 commit d2af3c2
Showing 1 changed file with 58 additions and 31 deletions.
89 changes: 58 additions & 31 deletions s2.asm
Expand Up @@ -16160,25 +16160,32 @@ SwScrl_ARZ:
+
moveq #6,d6
bsr.w SetVertiScrollFlagsBG

move.w (Camera_BG_Y_pos).w,(Vscroll_Factor_BG).w

moveq #0,d2
tst.b (Screen_Shaking_Flag).w
beq.s +
beq.s .screenNotShaking

move.w (Timer_frames).w,d0
andi.w #$3F,d0
lea_ SwScrl_RippleData,a1
lea (a1,d0.w),a1
moveq #0,d0
; Shake camera Y-pos (note that BG scrolling is not affected by this, causing it to distort)
move.b (a1)+,d0
add.w d0,(Vscroll_Factor_FG).w
add.w d0,(Vscroll_Factor_BG).w
add.w d0,(Camera_Y_pos_copy).w
; Shake camera X-pos
move.b (a1)+,d2
add.w d2,(Camera_X_pos_copy).w
+
lea (TempArray_LayerDef).w,a2
lea 6(a2),a3

.screenNotShaking:
lea (TempArray_LayerDef).w,a2 ; Starts at BG scroll row 1
lea 6(a2),a3 ; Starts at BG scroll row 4

; Set up the speed of each row (there are 16 rows in total)
move.w (Camera_X_pos).w,d0
ext.l d0
asl.l #4,d0
Expand All @@ -16187,61 +16194,81 @@ SwScrl_ARZ:
asl.l #4,d0
asl.l #8,d0
move.l d0,d1

; Set row 4's speed
swap d1
move.w d1,(a3)+
move.w d1,(a3)+ ; Top row of background moves 10 ($A) times slower than foreground
swap d1
add.l d1,d1
add.l d0,d1
; Set rows 5-10's speed
rept 6
swap d1
move.w d1,(a3)+
move.w d1,(a3)+ ; Next row moves 3 times faster than top row, then next row is 4 times faster, then 5, etc.
swap d1
add.l d0,d1
endm
; Set row 11's speed
swap d1
move.w d1,(a3)+
move.w d1,(a2)
move.w d1,4(a2)

; These instructions reveal that ARZ had slightly different scrolling,
; at one point:
; Above the background's mountains is a row of leaves, which is actually
; composed of three separately-scrolling rows. According to this code,
; the first and third rows were meant to scroll at a different speed to the
; second. Possibly due to how bad it looks, the speed values are overwritten
; a few instructions later, so all three move at the same speed.
; This code seems to pre-date the Simon Wai build, which uses the final's
; scrolling.
move.w d1,(a2) ; Set row 1's speed
move.w d1,4(a2) ; Set row 3's speed

move.w (Camera_BG_X_pos).w,d0
move.w d0,2(a2)
move.w d0,$16(a2)
_move.w d0,0(a2)
move.w d0,4(a2)
move.w d0,$18(a2)
move.w d0,$1A(a2)
move.w d0,$1C(a2)
move.w d0,$1E(a2)
lea (byte_D5CE).l,a3
move.w d0,2(a2) ; Set row 2's speed
move.w d0,$16(a2) ; Set row 12's speed
_move.w d0,0(a2) ; Overwrite row 1's speed (now same as row 2's)
move.w d0,4(a2) ; Overwrite row 3's speed (now same as row 2's)
move.w d0,$18(a2) ; Set row 13's speed
move.w d0,$1A(a2) ; Set row 14's speed
move.w d0,$1C(a2) ; Set row 15's speed
move.w d0,$1E(a2) ; Set row 16's speed

lea (SwScrl_ARZ_RowHeights).l,a3
lea (TempArray_LayerDef).w,a2
lea (Horiz_Scroll_Buf).w,a1
move.w (Camera_BG_Y_pos).w,d1
moveq #0,d0

- move.b (a3)+,d0
addq.w #2,a2
; Find which row of background is visible at the top of the screen
.findTopRowLoop:
move.b (a3)+,d0 ; Get row height
addq.w #2,a2 ; Next row speed (note: is off by 2. This is fixed below)
sub.w d0,d1
bcc.s -
bcc.s .findTopRowLoop ; If current row is above the screen, loop and do next row

neg.w d1
subq.w #2,a2
move.w #bytesToLcnt($380),d2
neg.w d1 ; d1 now contains how many pixels of the row is currently on-screen
subq.w #2,a2 ; Get correct row speed

move.w #bytesToLcnt($380),d2 ; Actual size of Horiz_Scroll_Buf
move.w (Camera_X_pos).w,d0
neg.w d0
swap d0
move.w (a2)+,d0
swap d0 ; Store FG X-pos in upper 16-bits...
move.w (a2)+,d0 ; ...and BG X-pos in lower 16 bits, as Horiz_Scroll_Buf expects it
neg.w d0

- move.l d0,(a1)+
subq.w #1,d1
- move.l d0,(a1)+ ; Write 1 FG Horizontal Scroll value, and 1 BG Horizontal Scroll value
subq.w #1,d1 ; Loop until row at top of screen is done
bne.s +
move.b (a3)+,d1
move.w (a2)+,d0
move.b (a3)+,d1 ; Once that row is done, go to next row...
move.w (a2)+,d0 ; ...and use next speed
neg.w d0
+ dbf d2,-
+ dbf d2,- ; Loop until Horiz_Scroll_Buf is full

rts
; ===========================================================================
byte_D5CE:
; byte_D5CE:
SwScrl_ARZ_RowHeights:
dc.b $B0
dc.b $70 ; 1
dc.b $30 ; 2
Expand Down

0 comments on commit d2af3c2

Please sign in to comment.