mirror of
https://github.com/garrettsworkshop/GWRAM.SYSTEM.git
synced 2024-06-15 10:29:27 +00:00
Merge branch 'dev-accelerator' into dev
This commit is contained in:
commit
40481a8237
BIN
bin/GWRAM.dbg.po
Normal file
BIN
bin/GWRAM.dbg.po
Normal file
Binary file not shown.
BIN
bin/GWRAM.po
Normal file
BIN
bin/GWRAM.po
Normal file
Binary file not shown.
292
ram2gs_asm.s
292
ram2gs_asm.s
|
@ -6,6 +6,10 @@
|
||||||
.export _ram2gs_detect
|
.export _ram2gs_detect
|
||||||
.export _ram2gs_cmd
|
.export _ram2gs_cmd
|
||||||
|
|
||||||
|
.define GetTWConfig $BCFF3C
|
||||||
|
.define SetTWConfig $BCFF40
|
||||||
|
.define DisableDataCache $BCFF4C
|
||||||
|
|
||||||
.macro A8
|
.macro A8
|
||||||
sep #$20 ; put the 65C816 in 8-bit accumulator mode
|
sep #$20 ; put the 65C816 in 8-bit accumulator mode
|
||||||
.A8
|
.A8
|
||||||
|
@ -40,67 +44,87 @@
|
||||||
|
|
||||||
.segment "CODE"
|
.segment "CODE"
|
||||||
|
|
||||||
.proc _ram2gs_getsize: near
|
|
||||||
|
.proc _thrash: near
|
||||||
.A8
|
.A8
|
||||||
.I8
|
.I8
|
||||||
; Preamble
|
; Preamble
|
||||||
php ; Push status
|
php ; Push status
|
||||||
sei ; Disable interrupts
|
AI16
|
||||||
clc ; Clear carry
|
|
||||||
xce ; Clear emulation bit
|
|
||||||
php ; Push status again, reflecting emulation bit
|
|
||||||
phb ; Push bank
|
phb ; Push bank
|
||||||
|
pha ; Push accumulator
|
||||||
|
pha ; Push X
|
||||||
|
phy ; Push Y
|
||||||
|
|
||||||
|
; Read 0x100000-0x11FFFF
|
||||||
AI8
|
AI8
|
||||||
|
lda #$20 ; A = 0x10 (bank)
|
||||||
; Go to bank 3F
|
_thrash_loop:
|
||||||
ldy #$3F
|
pha ; Switch to bank stored in A
|
||||||
phy
|
|
||||||
plb
|
plb
|
||||||
; Save 3F/3456
|
AI16
|
||||||
ldx $3456
|
lda #$0000 ; Get index in A
|
||||||
|
clc ; Clear carry in preparation to add in loop
|
||||||
|
|
||||||
; Go to bank 7F
|
; Read loop
|
||||||
ldy #$7F
|
_thrash_loop0:
|
||||||
phy
|
tax ; Get index from A into X to do LDYs
|
||||||
plb
|
ldy $0100,X ; Read 64 bytes
|
||||||
; Invert 7F/3456
|
ldy $0102,X ; ...
|
||||||
lda $3456
|
ldy $0104,X
|
||||||
eor #$FF
|
ldy $0106,X
|
||||||
sta $3456
|
ldy $0108,X
|
||||||
|
ldy $010A,X
|
||||||
|
ldy $010C,X
|
||||||
|
ldy $010E,X
|
||||||
|
ldy $0110,X
|
||||||
|
ldy $0112,X
|
||||||
|
ldy $0114,X
|
||||||
|
ldy $0116,X
|
||||||
|
ldy $0118,X
|
||||||
|
ldy $011A,X
|
||||||
|
ldy $011C,X
|
||||||
|
ldy $011E,X
|
||||||
|
ldy $0120,X
|
||||||
|
ldy $0122,X
|
||||||
|
ldy $0124,X
|
||||||
|
ldy $0126,X
|
||||||
|
ldy $0128,X
|
||||||
|
ldy $012A,X
|
||||||
|
ldy $012C,X
|
||||||
|
ldy $012E,X
|
||||||
|
ldy $0130,X
|
||||||
|
ldy $0132,X
|
||||||
|
ldy $0134,X
|
||||||
|
ldy $0136,X
|
||||||
|
ldy $0138,X
|
||||||
|
ldy $013A,X
|
||||||
|
ldy $013C,X
|
||||||
|
ldy $013E,X
|
||||||
|
adc #$0040 ; Add 64 to index in A
|
||||||
|
cmp #0
|
||||||
|
bne _thrash_loop0 ; Repeat if we haven't passed 0xFFFF
|
||||||
|
|
||||||
; Go to bank 3F
|
; Bank increment
|
||||||
ldy #$3F
|
AI8
|
||||||
phy
|
phb ; Transfer bank to A
|
||||||
plb
|
pla
|
||||||
; Has 3F/3456 changed?
|
inc ; Increment bank
|
||||||
cpx $3456
|
cmp #$21 ; Stop after bank 0x20
|
||||||
php
|
bne _thrash_loop
|
||||||
|
|
||||||
; Go to bank 7F
|
|
||||||
ldy #$7F
|
|
||||||
phy
|
|
||||||
plb
|
|
||||||
; Restore 7F/3456
|
|
||||||
eor #$FF
|
|
||||||
sta $3456
|
|
||||||
|
|
||||||
; Check result
|
|
||||||
ldx #$80
|
|
||||||
plp
|
|
||||||
beq _ram2gs_getsize_return
|
|
||||||
ldx #$40
|
|
||||||
|
|
||||||
; Postamble
|
; Postamble
|
||||||
_ram2gs_getsize_return:
|
AI16
|
||||||
|
ply ; Restore Y
|
||||||
|
plx ; Restore X
|
||||||
|
pla ; Restore accumulator
|
||||||
plb ; Restore bank
|
plb ; Restore bank
|
||||||
|
AI8
|
||||||
plp ; Restore status
|
plp ; Restore status
|
||||||
xce ; Restore emulation bit
|
|
||||||
txa ; Transfer bank count to A
|
|
||||||
plp ; Pull status again to pull I flag
|
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
|
||||||
.proc _unswap: near
|
.proc _unswap: near
|
||||||
.A8
|
.A8
|
||||||
.I8
|
.I8
|
||||||
|
@ -149,6 +173,122 @@
|
||||||
rts
|
rts
|
||||||
.endproc
|
.endproc
|
||||||
|
|
||||||
|
.proc _ram2gs_getsize: near
|
||||||
|
.A8
|
||||||
|
.I8
|
||||||
|
; Preamble
|
||||||
|
php ; Push status
|
||||||
|
sei ; Disable interrupts
|
||||||
|
clc ; Clear carry
|
||||||
|
xce ; Clear emulation bit
|
||||||
|
php ; Push status again, reflecting emulation bit
|
||||||
|
phb ; Push bank
|
||||||
|
|
||||||
|
; Check for TranswarpGS
|
||||||
|
AI8
|
||||||
|
lda #0
|
||||||
|
pha ; Push "TWGS absent" flag
|
||||||
|
; AI16
|
||||||
|
; lda $BCFF00
|
||||||
|
; cmp #$5754 ; "WT"
|
||||||
|
; bne _ram2gs_getsize_notwgs1
|
||||||
|
; lda $BCFF02
|
||||||
|
; cmp #$5347 ; "SG"
|
||||||
|
; bne _ram2gs_getsize_notwgs1
|
||||||
|
;
|
||||||
|
; ; Get and push TWGS config
|
||||||
|
; jsl GetTWConfig
|
||||||
|
; pha
|
||||||
|
; ; Disable TWGS data cache
|
||||||
|
; jsl DisableDataCache ; Disable data cache
|
||||||
|
;
|
||||||
|
; ; Pull to restore TWGS settings into A
|
||||||
|
; pla
|
||||||
|
; ; Pull "TWGS absent" flag into x, and discard it
|
||||||
|
; AI8
|
||||||
|
; plx
|
||||||
|
; AI16
|
||||||
|
; ; Push TWGS settings
|
||||||
|
; pha
|
||||||
|
; ; Push "TWGS exists" flag
|
||||||
|
; AI8
|
||||||
|
; ldx #1
|
||||||
|
; phx
|
||||||
|
|
||||||
|
_ram2gs_getsize_notwgs1:
|
||||||
|
AI8
|
||||||
|
; Go to bank 3F
|
||||||
|
ldy #$3F
|
||||||
|
phy
|
||||||
|
plb
|
||||||
|
; Save 3F/3456
|
||||||
|
lda $3456
|
||||||
|
pha
|
||||||
|
|
||||||
|
; Go to bank 7F
|
||||||
|
ldy #$7F
|
||||||
|
phy
|
||||||
|
plb
|
||||||
|
; Save and then invert 7F/3456
|
||||||
|
lda $3456
|
||||||
|
pha
|
||||||
|
eor #$FF
|
||||||
|
sta $3456
|
||||||
|
|
||||||
|
; Go to bank 3F
|
||||||
|
ldy #$3F
|
||||||
|
phy
|
||||||
|
plb
|
||||||
|
; Has 3F/3456 changed?
|
||||||
|
jsr _thrash
|
||||||
|
plx ; X = saved 7F/3456
|
||||||
|
pla ; A = saved 3F/3456
|
||||||
|
cmp $3456
|
||||||
|
php ; Push to save processor status
|
||||||
|
|
||||||
|
; Go to bank 7F
|
||||||
|
ldy #$7F
|
||||||
|
phy
|
||||||
|
plb
|
||||||
|
; Restore 3F/3456
|
||||||
|
sta $3456
|
||||||
|
|
||||||
|
; Go to bank 7F
|
||||||
|
ldy #$7F
|
||||||
|
phy
|
||||||
|
plb
|
||||||
|
; Restore 7F/3456
|
||||||
|
stx $3456
|
||||||
|
|
||||||
|
; Check result
|
||||||
|
ldx #$80
|
||||||
|
plp
|
||||||
|
beq _ram2gs_getsize_return
|
||||||
|
ldx #$40
|
||||||
|
; Restore TWGS config
|
||||||
|
_ram2gs_getsize_return:
|
||||||
|
pla ; Pull TWGS flag
|
||||||
|
phx ; Push to save return value
|
||||||
|
; beq _ram2gs_getsize_post ; Skip if no TWGS
|
||||||
|
; plx ; Get return value back
|
||||||
|
; AI16
|
||||||
|
; pla ; Pull TWGS config
|
||||||
|
; AI8
|
||||||
|
; phx
|
||||||
|
; AI16
|
||||||
|
; jsl SetTWConfig
|
||||||
|
; AI8
|
||||||
|
|
||||||
|
; Postamble
|
||||||
|
_ram2gs_getsize_post:
|
||||||
|
pla ; Pull return value
|
||||||
|
plb ; Restore bank
|
||||||
|
plp ; Restore status
|
||||||
|
xce ; Restore emulation bit
|
||||||
|
plp ; Pull status again to pull I flag
|
||||||
|
rts
|
||||||
|
.endproc
|
||||||
|
|
||||||
.proc _ram2gs_detect: near
|
.proc _ram2gs_detect: near
|
||||||
.A8
|
.A8
|
||||||
.I8
|
.I8
|
||||||
|
@ -159,8 +299,40 @@
|
||||||
xce ; Clear emulation bit
|
xce ; Clear emulation bit
|
||||||
php ; Push status again, reflecting emulation bit
|
php ; Push status again, reflecting emulation bit
|
||||||
phb ; Push bank
|
phb ; Push bank
|
||||||
AI8
|
|
||||||
|
|
||||||
|
; Check for TranswarpGS
|
||||||
|
AI8
|
||||||
|
lda #0
|
||||||
|
pha ; Push "TWGS absent" flag
|
||||||
|
; AI16
|
||||||
|
; lda $BCFF00
|
||||||
|
; cmp #$5754 ; "WT"
|
||||||
|
; bne _ram2gs_detect_notwgs1
|
||||||
|
; lda $BCFF02
|
||||||
|
; cmp #$5347 ; "SG"
|
||||||
|
; bne _ram2gs_detect_notwgs1
|
||||||
|
;
|
||||||
|
; ; Get and push TWGS config
|
||||||
|
; jsl GetTWConfig
|
||||||
|
; pha
|
||||||
|
; ; Disable TWGS data cache
|
||||||
|
; jsl DisableDataCache ; Disable data cache
|
||||||
|
;
|
||||||
|
; ; Pull to restore TWGS settings into A
|
||||||
|
; pla
|
||||||
|
; ; Pull "TWGS absent" flag into x, and discard it
|
||||||
|
; AI8
|
||||||
|
; plx
|
||||||
|
; AI16
|
||||||
|
; ; Push TWGS settings
|
||||||
|
; pha
|
||||||
|
; ; Push "TWGS exists" flag
|
||||||
|
; AI8
|
||||||
|
; ldx #1
|
||||||
|
; phx
|
||||||
|
|
||||||
|
_ram2gs_detect_notwgs1:
|
||||||
|
AI8
|
||||||
; Switch to bank 0x3F
|
; Switch to bank 0x3F
|
||||||
lda #$3F
|
lda #$3F
|
||||||
pha
|
pha
|
||||||
|
@ -169,11 +341,13 @@
|
||||||
; Unswap
|
; Unswap
|
||||||
jsr _unswap
|
jsr _unswap
|
||||||
; Save unswapped 3F/8000
|
; Save unswapped 3F/8000
|
||||||
|
jsr _thrash
|
||||||
lda $8000
|
lda $8000
|
||||||
pha
|
pha
|
||||||
; Swap
|
; Swap
|
||||||
jsr _swap
|
jsr _swap
|
||||||
; Save swapped 3F/8000
|
; Save swapped 3F/8000
|
||||||
|
jsr _thrash
|
||||||
lda $8000
|
lda $8000
|
||||||
pha
|
pha
|
||||||
|
|
||||||
|
@ -181,6 +355,7 @@
|
||||||
lda #$FF
|
lda #$FF
|
||||||
sta $8000
|
sta $8000
|
||||||
; Verify 0xFF stored
|
; Verify 0xFF stored
|
||||||
|
jsr _thrash
|
||||||
lda $8000
|
lda $8000
|
||||||
cmp #$FF
|
cmp #$FF
|
||||||
bne _ram2gs_detect_fail
|
bne _ram2gs_detect_fail
|
||||||
|
@ -191,6 +366,7 @@
|
||||||
lda #$00
|
lda #$00
|
||||||
sta $8000
|
sta $8000
|
||||||
; Verify 0x00 stored
|
; Verify 0x00 stored
|
||||||
|
jsr _thrash
|
||||||
lda $8000
|
lda $8000
|
||||||
cmp #$00
|
cmp #$00
|
||||||
bne _ram2gs_detect_fail
|
bne _ram2gs_detect_fail
|
||||||
|
@ -198,27 +374,45 @@
|
||||||
; Swap
|
; Swap
|
||||||
jsr _swap
|
jsr _swap
|
||||||
; Verify 0xFF stored
|
; Verify 0xFF stored
|
||||||
|
jsr _thrash
|
||||||
lda $8000
|
lda $8000
|
||||||
cmp #$FF
|
cmp #$FF
|
||||||
bne _ram2gs_detect_fail
|
bne _ram2gs_detect_fail
|
||||||
|
|
||||||
; Get success return value and jump to postamble
|
; Get success return value and jump to postamble
|
||||||
ldx #$01 ; Get success falue
|
ldx #$01 ; Get success falue
|
||||||
bne _ram2gs_detect_return ; Jump to postamble
|
bne _ram2gs_detect_done ; Jump to postamble
|
||||||
|
|
||||||
; Fail
|
; Fail
|
||||||
_ram2gs_detect_fail:
|
_ram2gs_detect_fail:
|
||||||
ldx #$00 ; Get fail value
|
ldx #$00 ; Get fail value
|
||||||
|
|
||||||
; Postamble
|
; Done, now put back clobbered bytes
|
||||||
_ram2gs_detect_return:
|
_ram2gs_detect_done:
|
||||||
jsr _swap ; Swap
|
jsr _swap ; Swap
|
||||||
pla ; Get value to restore to swapped bank 3F
|
pla ; Get value to restore to swapped bank 3F
|
||||||
sta $8000 ; Restore
|
sta $8000 ; Restore
|
||||||
jsr _unswap ; Unswap
|
jsr _unswap ; Unswap
|
||||||
pla ; Get value to restore to unswapped bank 3F
|
pla ; Get value to restore to unswapped bank 3F
|
||||||
sta $8000 ; Restore
|
sta $8000 ; Restore
|
||||||
txa ; Put return value in accumulator
|
|
||||||
|
; Restore TWGS config
|
||||||
|
_ram2gs_detect_return:
|
||||||
|
pla ; Pull TWGS flag
|
||||||
|
phx ; Push to save return value
|
||||||
|
; beq _ram2gs_detect_post ; Skip if no TWGS
|
||||||
|
; plx ; Get return value back
|
||||||
|
; AI16
|
||||||
|
; pla ; Pull TWGS config
|
||||||
|
; AI8
|
||||||
|
; phx
|
||||||
|
; AI16
|
||||||
|
; jsl SetTWConfig
|
||||||
|
; AI8
|
||||||
|
|
||||||
|
; Postamble
|
||||||
|
_ram2gs_detect_post:
|
||||||
|
pla ; Pull return value
|
||||||
plb ; Restore bank
|
plb ; Restore bank
|
||||||
plp ; Restore status
|
plp ; Restore status
|
||||||
xce ; Restore emulation bit
|
xce ; Restore emulation bit
|
||||||
|
|
Loading…
Reference in New Issue
Block a user