Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ===========================================================================
- ; Scrolling BG from the The Pirates of Dark Water.
- ; Ripped by TheBlad768.
- ; ===========================================================================
- ; RAM Address
- long_221E: = RAM+$00 ; 4 bytes
- long_2222: = RAM+$04 ; 4 bytes
- long_2226: = RAM+$08 ; 4 bytes
- long_222A: = RAM+$0C ; 4 bytes
- long_222E: = RAM+$10 ; 4 bytes
- long_2232: = RAM+$14 ; 4 bytes
- ; =============== S U B R O U T I N E =======================================
- Scrolling_BG_Init:
- bsr.w Random_Number
- andi.l #$1FF,d0
- btst #4,d0
- beq.s +
- neg.l d0
- subi.l #$100,d0
- + addi.l #$80,d0
- move.l d0,(long_221E).w
- bsr.w Random_Number
- andi.l #$1FF,d0
- btst #4,d0
- beq.s +
- neg.l d0
- subi.l #$100,d0
- + addi.l #$80,d0
- move.l d0,(long_222A).w
- bsr.w Random_Number
- andi.l #$7FF,d0
- btst #4,d0
- beq.s +
- neg.l d0
- subi.l #$200,d0
- + addi.l #$100,d0
- move.l d0,(long_2222).w
- bsr.w Random_Number
- andi.l #$7FF,d0
- btst #4,d0
- beq.s +
- neg.l d0
- subi.l #$200,d0
- + addi.l #$100,d0
- move.l d0,(long_222E).w
- bsr.w Random_Number
- andi.l #$3F0000,d0
- subi.l #$1F0000,d0
- move.l d0,(long_2226).w
- bsr.w Random_Number
- andi.l #$3F0000,d0
- subi.l #$1F0000,d0
- move.l d0,(long_2232).w
- rts
- ; End of function Scrolling_BG_Init
- ; =============== S U B R O U T I N E =======================================
- Scrolling_BG:
- move.l (long_221E).w,d0
- add.l d0,(long_2222).w
- tst.l (long_2226).w
- bpl.s loc_6CC56
- tst.l (long_221E).w
- bpl.s loc_6CCB4
- neg.l (long_221E).w
- bra.s loc_6CC64
- ; ---------------------------------------------------------------------------
- loc_6CC56:
- tst.l (long_221E).w
- bmi.s loc_6CCB4
- neg.l (long_221E).w
- loc_6CC64:
- add.l d0,(long_2222).w
- bsr.w Random_Number
- andi.l #$1FF,d0
- subi.l #$FF,d0
- sub.l d0,(long_221E).w
- move.l (long_221E).w,d0
- bpl.s loc_6CC9E
- cmpi.l #-$800,d0
- bge.s loc_6CCAE
- move.l #-$800,d0
- bra.s loc_6CCAE
- ; ---------------------------------------------------------------------------
- loc_6CC9E:
- cmpi.l #$800,d0
- ble.s loc_6CCAE
- move.l #$800,d0
- loc_6CCAE:
- move.l d0,(long_221E).w
- loc_6CCB4:
- move.l (long_222A).w,d0
- add.l d0,(long_222E).w
- tst.l (long_2232).w
- bpl.s loc_6CCD8
- tst.l (long_222A).w
- bpl.s loc_6CD36
- neg.l (long_222A).w
- bra.s loc_6CCE6
- ; ---------------------------------------------------------------------------
- loc_6CCD8:
- tst.l (long_222A).w
- bmi.s loc_6CD36
- neg.l (long_222A).w
- loc_6CCE6:
- add.l d0,(long_222E).w
- bsr.w Random_Number
- andi.l #$1FF,d0
- subi.l #$FF,d0
- sub.l d0,(long_222A).w
- move.l (long_222A).w,d0
- bpl.s loc_6CD20
- cmpi.l #-$800,d0
- bge.s loc_6CD30
- move.l #-$800,d0
- bra.s loc_6CD30
- ; ---------------------------------------------------------------------------
- loc_6CD20:
- cmpi.l #$800,d0
- ble.s loc_6CD30
- move.l #$800,d0
- loc_6CD30:
- move.l d0,(long_222A).w
- loc_6CD36:
- move.l (long_2222).w,d0
- bpl.s loc_6CD54
- cmpi.l #-$30000,d0
- bge.s loc_6CD64
- move.l #-$30000,d0
- bra.s loc_6CD64
- ; ---------------------------------------------------------------------------
- loc_6CD54:
- cmpi.l #$30000,d0
- ble.s loc_6CD64
- move.l #$30000,d0
- loc_6CD64:
- move.l (long_222E).w,d1
- bpl.s loc_6CD82
- cmpi.l #-$30000,d1
- bge.s loc_6CD92
- move.l #-$30000,d1
- bra.s loc_6CD92
- ; ---------------------------------------------------------------------------
- loc_6CD82:
- cmpi.l #$30000,d1
- ble.s loc_6CD92
- move.l #$30000,d1
- loc_6CD92:
- add.l d0,(long_2226).w
- add.l d1,(long_2232).w
- move.w (long_2226).w,(H_scroll_buffer+2).w
- move.w (long_2232).w,(V_scroll_value+2).w
- rts
- ; End of function Scrolling_BG
- ; ---------------------------------------------------------------------------
- ; Generates a pseudo-random number in d0
- ; ---------------------------------------------------------------------------
- word_CB6: = RAM+$18 ; 2 bytes
- byte_CC54: = RAM+$1A ; 1 byte
- byte_CC55: = RAM+$1B ; 1 byte
- ; =============== S U B R O U T I N E =======================================
- Random_Number:
- tst.w (word_CB6).w
- beq.s Random_Number_2
- move.w (V_int_run_count).w,d0
- rts
- ; ---------------------------------------------------------------------------
- Random_Number_2:
- movem.l d1-d2/a0,-(sp)
- move.w (V_int_run_count).w,d2
- move.w d2,d1
- andi.w #$FF,d2
- lsr.w #8,d1
- move.b (byte_CC55).w,d0
- eor.b d0,d2
- move.b (byte_CC54).w,d0
- eor.b d0,d1
- moveq #0,d0
- move.w d1,d0
- lsl.w #8,d0
- or.b d2,d0
- add.l d0,d0
- movea.l d0,a0
- moveq #0,d0
- move.w (a0),d0
- sub.w d0,d2
- sub.w d0,d1
- ror.b #1,d2
- rol.b #1,d1
- add.b d1,(byte_CC55).w
- add.b d2,(byte_CC54).w
- eor.b d2,d0
- lsl.w #8,d1
- eor.b d1,d0
- movem.l (sp)+,d1-d2/a0
- rts
- ; End of function Random_Number
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement