-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathbanking.asm
118 lines (110 loc) · 1.41 KB
/
banking.asm
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
PRG_RAM_BANKS .equ 1 ; number of PRG RAM banks
banking_init:
; CHR at $0000-$07FF
lda #$00
sta $8000
lda #$00
sta $8001
; CHR at $0800-$0FFF
lda #$01
sta $8000
lda #$02
sta $8001
; CHR at $1000-$13FF
lda #$02
sta $8000
lda #$04
sta $8001
; CHR at $1400-$17FF
lda #$03
sta $8000
lda #$05
sta $8001
; CHR at $1800-$1BFF
lda #$04
sta $8000
lda #$06
sta $8001
; CHR at $1C00-$1FFF
lda #$05
sta $8000
lda #$07
sta $8001
; mirroring
lda #$01
sta $A000
; PRG-RAM protect
lda #$00
sta $A001
rts
enable_prg_ram:
lda #$80
sta $A001
rts
disable_prg_ram:
lda #$00
sta $A001
rts
enable_chr_write:
; not supported on COOLBOY :(
rts
disable_chr_write:
; not supported on COOLBOY :(
rts
; select 16KB bank at $8000-$BFFF
select_prg_bank:
clc
adc #$18 ; start of ROM (+368K)
ldx #6
stx $8000
asl A
sta $8001
inx
stx $8000
ora #1
sta $8001
rts
; select 8KB bank
select_chr_bank:
asl A
asl A
asl A
pha
lda #0
sta $8000
pla
pha
sta $8001
lda #1
sta $8000
pla
pha
ora #%00000010
sta $8001
lda #2
sta $8000
pla
pha
ora #%00000100
sta $8001
lda #3
sta $8000
pla
pha
ora #%00000101
sta $8001
lda #4
sta $8000
pla
pha
ora #%00000110
sta $8001
lda #5
sta $8000
pla
ora #%00000111
sta $8001
rts
; COOLBOY has not any PRG RAM banking
select_prg_ram_bank:
rts