-
Notifications
You must be signed in to change notification settings - Fork 0
/
membank.asm
117 lines (100 loc) · 2.46 KB
/
membank.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
; retroinvaders
; Available functions
; get_vic_bank = returns the VICII bank, high byte in a
; set_vic_bank, a = 0 - 3 - set the vic bank
; get_screen_bank = returns the screen bank, high byte in a
; set_screen_bank, a = 0 - 15 - set the video bank
; get_char_bank = returns the character bank, high byte in a
; set_char_bank, a = 0 - 7 - set the char bank
; get_bitmap_bank = returns the bitmap bank, high byte in a
; set_bitmap_bank, a = 0 - 1 - set the bitmap bank $0000 or $2000
; returns the vic bank, only the high byte ($4000 bytes)
get_vic_bank
lda $dd00
and #$03
tax
lda bank_addr_tbl,x
rts
; sets the vic bank, see bank_addr_tbl
; a = 0 - 3
set_vic_bank
and #$03
sta $dd00
;tax
;lda bank_addr_tbl,x
;sta vic_bank
rts
; returns the screen bank, only the high byte ($400 bytes)
get_screen_bank
lda $dd00
and #$03
tax
lda $d018
and #$78
lsr
lsr
adc bank_addr_tbl,x
rts
; sets the screen bank, vic_bank + video_bank * $400
; a = 0 - 15
set_screen_bank
and #$0f
rol
rol
rol
sta _set_screen_bank_1 + 1
lda $d018
and #$87
_set_screen_bank_1
ora #$00
sta $d018
rts
; return the character bank, only the high byte ($800 bytes)
get_char_bank
lda $dd00
and #$03
tax
lda $d018
and #$0e
rol
rol
adc bank_addr_tbl,x
rts
; sets the char bank, vic_bank + char_bank * $800
; a = 0 - 7
set_char_bank
and #$07
rol
and #$0e
sta _set_char_bank_1 + 1
lda $d018
and #$f8
_set_char_bank_1
ora #$00
sta $d018
rts
; returns the bitmap bank, only the high byte ($0000 or $2000)
get_bitmap_bank
lda $dd00
and #$03
tax
lda $d018
and #$07
rol
rol
adc bank_addr_tbl,x
rts
; sets the bitmap address, vic_bank + bitmap_bank * $2000
; a = 0 or 1
set_bitmap_bank
and #$01
bne _set_bitmap_bank_1
lda #$f7
and $d018
sta $d018
rts
_set_bitmap_bank_1
lda #$08
ora $d018
sta $d018
rts