-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanks.asx
88 lines (83 loc) · 1.33 KB
/
banks.asx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
;Banks_MAX equ 255
; where to save current memory?
;Banks_temp equ $3d00 ; 256 bytes
; where to save results?
;Banks_tab equ $3e00 ; Banks_MAX bytes
; which byte to test?
Banks_base0 equ $0000
Banks_ext equ $4000
Banks_base2 equ $8000
Banks_base3 equ $c000
Banks_detect
sei
ldx #0
stx $d40e
Banks_detect_waitVBlank
ldy $d40b
bne Banks_detect_waitVBlank
stx $d400
lda $d301
pha
lda #$fe
sta $d301
lda Banks_base3
pha
lda Banks_base2
pha
lda Banks_base0
pha
Banks_detect_save
sty $d301
lda Banks_ext
sta Banks_temp,y
iny
bne Banks_detect_save
Banks_detect_storeIndexes
sty $d301
sty Banks_ext
iny
bne Banks_detect_storeIndexes
lda #$fe
sta $d301
sta Banks_base0
sta Banks_base2
sta Banks_base3
Banks_detect_checkIndexes
sty $d301
cpy Banks_ext
bne Banks_detect_noBank
; make sure we read
; what we wrote to PORTB!
; if not, skip this bank!
cpy $d301
bne Banks_detect_noBank
tya
sta Banks_tab,x
inx
cpx #Banks_MAX
beq Banks_restoreAll
Banks_detect_noBank
iny
bne Banks_detect_checkIndexes
Banks_restoreAll
ldy #0
Banks_restore
sty $d301
lda Banks_temp,y
sta Banks_ext
iny
bne Banks_restore
lda #$fe
sta $d301
pla
sta Banks_base0
pla
sta Banks_base2
pla
sta Banks_base3
pla
sta $d301
lsr $d40e
cli
rts
end