Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; This code is made to add SRAM enabling and disabling done by S3K to the S3A SRAM routines, therefore making the second
- ; half of storage accessible without issues. Hopefully, this also fixes an issue Vladik's code has. However, this does
- ; take up more storage on the ROM, so be careful, since the S3A Z80 sound driver hasn't been properly disasm'd yet.
- SRAM_Load:
- lea ($200011).l,a0
- lea ($2000BD).l,a1
- lea (Competition_saved_data).w,a2
- moveq #$29,d0
- move.w #$4C44,d1
- jsr Get_From_SRAM(pc)
- beq.s loc_B674
- lea SaveData_GeneralDefault(pc),a0
- lea (Competition_saved_data).w,a1
- moveq #$28,d0
- loc_B66A:
- move.w (a0)+,(a1)+
- dbf d0,loc_B66A
- jsr Write_SaveGeneral(pc)
- loc_B674:
- lea ($200169).l,a0
- lea ($2001F5).l,a1
- lea (Saved_data).w,a2
- moveq #$19,d0
- move.w #$4244,d1
- jsr Get_From_SRAM(pc)
- beq.s loc_B6A4
- lea SaveData_GameDefault(pc),a0
- lea (Saved_data).w,a1
- moveq #$18,d0
- loc_B69A:
- move.w (a0)+,(a1)+
- dbf d0,loc_B69A
- jsr Write_SaveGame(pc)
- loc_B6A4:
- clr.w ($FFFFEF4C).w
- move.b #1,($FFFFEF4B).w
- rts
- ; End of function SRAM_Load
- ; ---------------------------------------------------------------------------
- SaveData_GeneralDefault:
- dc.w $8000, 0, $8000, 0, $8000, 0, 1, $200
- dc.w $8000, 0, $8000, 0, $8000, 0, 1, $200
- dc.w $8000, 0, $8000, 0, $8000, 0, 1, $200
- dc.w $8000, 0, $8000, 0, $8000, 0, 1, $200
- dc.w $8000, 0, $8000, 0, $8000, 0, 1, $200
- dc.w $4C44
- SaveData_GameDefault:
- dc.w $8000, 0, 0, 0, $8000, 0, 0, 0
- dc.w $8000, 0, 0, 0, $8000, 0, 0, 0
- dc.w $8000, 0, 0, 0, $8000, 0, 0, 0
- dc.w $4244
- ; =============== S U B R O U T I N E =======================================
- Get_From_SRAM:
- movea.l a2,a3
- move.w d0,d2
- bsr.s Read_SRAM
- beq.s locret_B744
- movea.l a1,a0
- movea.l a3,a2
- move.w d2,d0
- bsr.s Read_SRAM
- locret_B744:
- rts
- ; End of function Get_From_SRAM
- ; =============== S U B R O U T I N E =======================================
- Read_SRAM:
- move.b #1,(SRAM_access_flag).l ; Moved by S3K, this is so that it only enables when we are reading SRAM or writing to it.
- movea.l a2,a6
- move.w d0,d6
- loc_B74A:
- movep.w 0(a0),d3
- move.w d3,(a2)+
- addq.w #4,a0
- dbf d0,loc_B74A
- move.b #0,(SRAM_access_flag).l ; Added by S3K, this makes it so that we no longer access SRAM.
- subq.w #1,d6
- bsr.s Create_SRAMChecksum
- cmp.w (a6),d7
- bne.s locret_B762
- cmp.w -2(a6),d1
- locret_B762:
- rts
- ; End of function Read_SRAM
- ; =============== S U B R O U T I N E =======================================
- Create_SRAMChecksum:
- moveq #0,d7
- loc_B766:
- move.w (a6)+,d5
- eor.w d5,d7
- lsr.w #1,d7
- bcc.s loc_B772
- eori.w #$8810,d7
- loc_B772:
- dbf d6,loc_B766
- rts
- ; End of function Create_SRAMChecksum
- ; =============== S U B R O U T I N E =======================================
- Write_SRAM:
- movea.l a2,a6
- move.w d0,d6
- subq.w #1,d6
- bsr.s Create_SRAMChecksum
- move.w d7,(a6)
- move.b #1,(SRAM_access_flag).l ; Added by S3K, this is so that it only enables when we are reading SRAM or writing to it.
- movea.l a2,a3
- move.w d0,d1
- loc_B786:
- move.w (a2)+,d2
- movep.w d2,0(a0)
- addq.w #4,a0
- dbf d0,loc_B786
- loc_B792:
- move.w (a3)+,d2
- movep.w d2,0(a1)
- addq.w #4,a1
- dbf d1,loc_B792
- move.b #0,(SRAM_access_flag).l ; Added by S3K, this makes it so that we no longer access SRAM.
- rts
- ; End of function Write_SRAM
- ; =============== S U B R O U T I N E =======================================
- Write_SaveGeneral:
- move.l a0,-(sp)
- move.w d7,-(sp)
- lea ($200011).l,a0
- lea ($2000BD).l,a1
- lea (Competition_saved_data).w,a2
- moveq #$29,d0
- bsr.s Write_SRAM
- move.w (sp)+,d7
- movea.l (sp)+,a0
- rts
- ; End of function Write_SaveGeneral
- ; =============== S U B R O U T I N E =======================================
- Write_SaveGame:
- move.l a0,-(sp)
- move.w d7,-(sp)
- lea ($200169).l,a0
- lea ($2001F5).l,a1
- lea (Saved_data).w,a2
- moveq #$19,d0
- bsr.s Write_SRAM
- move.w (sp)+,d7
- movea.l (sp)+,a0
- rts
- ; End of function Write_SaveGame
- ; =============== S U B R O U T I N E =======================================
- SaveGame:
- tst.b (Apparent_act).w
- beq.s locret_B80E
- move.l (Save_pointer).w,d0
- beq.s loc_B80A
- movea.l d0,a1
- cmpi.b #6,3(a1)
- bhi.s loc_B80A
- moveq #0,d0
- move.b (Apparent_zone).w,d0
- move.b SaveGame_NextLevel(pc,d0.w),3(a1)
- clr.b 7(a1)
- clr.b 1(a1)
- jsr Write_SaveGame(pc)
- loc_B80A:
- clr.l (Collected_special_ring_array).w
- locret_B80E:
- rts
- ; End of function SaveGame
- ; ---------------------------------------------------------------------------
- SaveGame_NextLevel:dc.b 1, 2, 3, 5, 5, 6, 7, 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement