Users browsing this thread: 1 Guest(s)
SRAM Expansion
I think I got all the code for a SRAM Expansion. Instead of a toal of 8kb, I was able to expand to 128kb. There are limits on real hardware because of the carts but I think an emulator is only governed on this level by the SRAM byte and type of mapping. So basically there are 16 blocks of $2000 bytes each.
The hack is what FF6 T-Edition and FF6-G have, 3x $2000 bytes per save slot plus some all purpose SRAM that can be used as general RAM even. The code and some commentaries are not from me, I've only sorted this out and redirected the code to the US ROM equivalent routines. I'm not sure it works at 100%, but I had trouble until I changed the $C0 bank SRAM byte, then saving and loading was normal. I cannot test it outside this without more hacking but it's the same code as in FF6-G version 2016. Enjoy!
The hack is what FF6 T-Edition and FF6-G have, 3x $2000 bytes per save slot plus some all purpose SRAM that can be used as general RAM even. The code and some commentaries are not from me, I've only sorted this out and redirected the code to the US ROM equivalent routines. I'm not sure it works at 100%, but I had trouble until I changed the $C0 bank SRAM byte, then saving and loading was normal. I cannot test it outside this without more hacking but it's the same code as in FF6-G version 2016. Enjoy!
Code:
;-----------------------------------------------------------------------
; SRAM Expansion 1.0
;
; Slot 1 expanded to: $306000, $316000, $326000. $336000 is common SRAM.
; Slot 2 expanded to: $346000, $356000, $366000. $376000 is common SRAM.
; Slot 3 expanded to: $386000, $396000, $3A6000. $3B6000 is common SRAM.
; SRAM expanded to: $3C6000, $3D6000, $3E6000. $3F6000 is common SRAM.
;-----------------------------------------------------------------------
org $C0FFD8
db #$07 ;SRAM size
LAB_C37083 equ $C37083 ; Used for branches
LAB_C37047 equ $C37047
org $C3016F
LDA $3F6001 ; RNG index in SRAM (formely $307FF1)
INC ; RNG index +1
STA $3F6001 ; Save changes
org $C3151F
STA $3F6000 ; Set last altered file number (formley $307FF0)
org $C3154D
JSL SAVE_GAME
JMP LAB_C37083 ; Mark all files
org $C31577
JSL LOAD_GAME
RTS
org $C31D36
LDA $3F6000 ; Last altered file
org $C33AAA ; Skins and skin colors
LDA $32674E ; $30674E
org $C33AC6
LDA $36674E ; $31674E
org $C33AE2
LDA $3A674E ; $32674E
org $C33AF9
LDA $32674E ; $30674E
org $C33B0D
LDA $36674E ; $31674E
org $C33B21
LDA $3A674E ; $32674E
org $C37028
CMP $3F6008 ; In file A?
BEQ LAB_C37047 ; Okay if so
CMP $3F600A ; In file B?
BEQ LAB_C37047 ; Okay if so
CMP $3F600C ; In file C?
BEQ LAB_C37047 ; Okay if so
CMP $3F600E ; In file D?...
BEQ LAB_C37047 ; Okay if so
org $C3704B
JSL INIT_SRAM
RTS
org $C37088
STA $3F6008 ; Mark file A (formely $307FF8)
STA $3F600A ; Mark file B (formely $307FFA)
STA $3F600C ; Mark file C (formely $307FFC)
STA $3F600E ; No file D.. (formely $307FFE)
;=======================================
; Extra Code
;=======================================
org $F30000
SAVE_GAME:
CPX #$1400 ; Is it slot 3?
BEQ LAB_BR_SAVE386000 ; Branch if so
CPX #$0A00 ; Is it slot 2?
BEQ LAB_BR_SAVE346000 ; Branch if so
;=======================================
; Slot 1
;=======================================
TDC ;
TAX ;
LAB_LP_SAVE326000:
LDA $1600,y ; RAM to be saved
STA $326000,x ; Store in expanded SRAM
INX ; X++
INY ; Y++
CPX #$0A00 ;
BNE LAB_LP_SAVE326000 ; Loop until we copied 2560 bytes
TDC ;
TAX ;
LAB_LP_SAVE326A00:
LDA $3E6000,x ; Copy all purpose SRAM to Slot 1
STA $326A00,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_SAVE326A00 ;
TDC ;
TAX ;
LAB_LP_SAVE306000:
LDA $3C6000,x ; Copy all purpose SRAM to Slot 1
STA $306000,x ;
LDA $3D6000,x ;
STA $316000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_SAVE306000 ;
LDA #$00 ;
STA $3F6002 ; Some sort of slot index not used anywhere else (would be $307FF2)
JMP LAB_BR_SAVE___END ; Exit
LAB_BR_SAVE386000:
JMP LAB_JP_SAVE386000 ; Jump to Slot 3 saving (Original BEQ out of reach)
;=======================================
; Slot 2
;=======================================
LAB_BR_SAVE346000:
TDC ;
TAX ;
LAB_LP_SAVE366000:
LDA $1600,y ; RAM to be saved
STA $366000,x ; Store in SRAM
INX ; X++
INY ; Y++
CPX #$0A00 ;
BNE LAB_LP_SAVE366000 ; Loop until we copied 2560 bytes
TDC ;
TAX ;
LAB_LP_SAVE366A00:
LDA $3E6000,x ; Copy all purpose SRAM to Slot 2
STA $366A00,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_SAVE366A00 ;
TDC ;
TAX ;
LAB_LP_SAVE346000:
LDA $3C6000,x ; Copy all purpose SRAM to Slot 2
STA $346000,x ;
LDA $3D6000,x ;
STA $356000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_SAVE346000 ;
LDA #$01 ; Some sort of slot index not used anywhere else (would be $307FF2)
STA $3F6002 ;
JMP LAB_BR_SAVE___END ; Exit
;=======================================
; Slot 3
;=======================================
LAB_JP_SAVE386000:
TDC ;
TAX ;
LAB_LP_SAVE3A6000:
LDA $1600,y ; RAM to be saved
STA $3A6000,x ; Store in SRAM
INX ; X++
INY ; Y++
CPX #$0A00 ;
BNE LAB_LP_SAVE3A6000 ; Loop until we copied 2560 bytes
TDC ;
TAX ;
LAB_LP_SAVE3A6A00:
LDA $3E6000,x ; Copy all purpose SRAM to Slot 3
STA $3A6A00,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_SAVE3A6A00 ;
TDC ;
TAX ;
LAB_LP_SAVE386000:
LDA $3C6000,x ; Copy all purpose SRAM to Slot 3
STA $386000,x ;
LDA $3D6000,x ;
STA $396000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_SAVE386000 ;
LDA #$02 ;
STA $3F6002 ; Some sort of slot index not used anywhere else (would be $307FF2)
LAB_BR_SAVE___END:
RTL ; Exit
;=======================================
; SRAM Loading
;=======================================
LOAD_GAME:
CPX #$1400 ; Check if slot 3
BEQ LAB_BR_LOAD386000 ; Branch if so
CPX #$0A00 ; Check if slot 2
BEQ LAB_BR_LOAD346000 ; Branch if so
TDC ;
TAX
;=======================================
; Slot 1
;=======================================
LAB_LP_LOAD326000:
LDA $326000,x ; Load original SRAM
STA $1600,y ;
INX ;
INY ;
CPX #$0A00 ;
BNE LAB_LP_LOAD326000 ;
TDC ;
TAX ;
LAB_LP_LOAD326A00:
LDA $326A00,x ; Load All Purpose SRAM
STA $3E6000,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_LOAD326A00 ;
TDC ;
TAX ;
LAB_LP_LOAD306000:
LDA $306000,x ; Load All Purpose SRAM
STA $3C6000,x ;
LDA $316000,x ;
STA $3D6000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_LOAD306000 ;
JMP LAB_BR_LOAD___END ; Exit
;=======================================
; Slot 2
;=======================================
LAB_BR_LOAD346000:
TDC ;
TAX ;
LAB_LP_LOAD366000:
LDA $366000,x ; Load original SRAM
STA $1600,y ;
INX ;
INY ;
CPX #$0A00 ;
BNE LAB_LP_LOAD366000 ;
TDC ;
TAX ;
LAB_LP_LOAD366A00:
LDA $366A00,x ; Load All Purpose SRAM
STA $3E6000,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_LOAD366A00 ;
TDC ;
TAX ;
LAB_LP_LOAD346000:
LDA $346000,x ; Load All Purpose SRAM
STA $3C6000,x ;
LDA $356000,x ;
STA $3D6000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_LOAD346000 ;
JMP LAB_BR_LOAD___END ; Exit
;=======================================
; Slot 3
;=======================================
LAB_BR_LOAD386000:
TDC ;
TAX ;
LAB_LP_LOAD3A6000:
LDA $3A6000,x ; Load original SRAM
STA $1600,y ;
INX ;
INY ;
CPX #$0A00 ;
BNE LAB_LP_LOAD3A6000 ;
TDC ;
TAX ;
LAB_LP_LOAD3A6A00:
LDA $3A6A00,x ; Load All Purpose SRAM
STA $3E6000,x ;
INX ;
CPX #$1600 ;
BNE LAB_LP_LOAD3A6A00 ;
TDC ;
TAX ;
LAB_LP_LOAD386000:
LDA $386000,x ; Load All Purpose SRAM
STA $3C6000,x ;
LDA $396000,x ;
STA $3D6000,x ;
INX ;
CPX #$2000 ;
BNE LAB_LP_LOAD386000 ;
LAB_BR_LOAD___END:
RTL ; Exit
;=======================================
; SRAM Init
;=======================================
INIT_SRAM:
TDC ;
TAX ;
LAB_LP_INIT306000:
STA $306000,x ; $306000,x = 0
STA $316000,x ; $316000,x = 0
STA $326000,x ; $326000,x = 0
STA $336000,x ; $336000,x = 0
STA $346000,x ; $346000,x = 0
STA $356000,x ; $356000,x = 0
STA $366000,x ; $366000,x = 0
STA $376000,x ; $376000,x = 0
STA $386000,x ; $386000,x = 0
STA $396000,x ; $396000,x = 0
STA $3A6000,x ; $3A6000,x = 0
STA $3B6000,x ; $3B6000,x = 0
STA $3C6000,x ; New line added (see below)
STA $3D6000,x ; $3D6000,x = 0
STA $3E6000,x ; $3E6000,x = 0
STA $3F6000,x ; $3F6000,x = 0
INX ;
CPX #$2000 ;
BNE LAB_LP_INIT306000 ;
; TDC ; This code is some sort of item init, I leave it as reference.
; TAX ;
; DEC ;
; REP #$20 ;
; LDA #$02FF ;
;LAB_LP_INIT3C6000:
; STA $3C6000,x ;
; INX ;
; INX ;
; CPX #$0600 ;
; BNE LAB_LP_INIT3C6000 ;
; TDC ;
;LAB_LP_INIT3C6600:
; STA $3C6000,x ;
; INX ;
; CPX #$2000 ;
; BNE LAB_LP_INIT3C6600 ;
; SEP #$20 ;
RTL
« Next Oldest | Next Newest »
|
||||
Users browsing this thread: 1 Guest(s)