-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral_mmc3.asm
61 lines (53 loc) · 1.5 KB
/
general_mmc3.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
.export GeneralMapperInit
.export GeneralMapperPrg8000ToC000
.include "include.mov-macros.asm"
MMC3_BANK_SELECT = $8000
MMC3_BANK_DATA = $8001
PRG_8000_SWAPPABLE = $00
PRG_C000_SWAPPABLE = $40
CHR_1000_GRANULAR = $00
CHR_0000_GRANULAR = $80
SELECT_CHR_LARGE_0 = $00
SELECT_CHR_LARGE_2 = $01
SELECT_CHR_SMALL_0 = $02
SELECT_CHR_SMALL_1 = $03
SELECT_CHR_SMALL_2 = $04
SELECT_CHR_SMALL_3 = $05
SELECT_PRG_8000 = $06
SELECT_PRG_A000 = $07
.segment "BOOT"
.proc GeneralMapperInit
lda #(SELECT_CHR_LARGE_0 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #0
lda #(SELECT_CHR_LARGE_2 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #2
lda #(SELECT_CHR_SMALL_0 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #4
lda #(SELECT_CHR_SMALL_1 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #5
lda #(SELECT_CHR_SMALL_2 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #6
lda #(SELECT_CHR_SMALL_3 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sta MMC3_BANK_SELECT
mov MMC3_BANK_DATA, #7
rts
.endproc
; A: Bank to swap in.
; Clobbers Y
.proc GeneralMapperPrg8000ToC000
ldy #(SELECT_PRG_8000 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sty MMC3_BANK_SELECT
asl a
sta MMC3_BANK_DATA
ldy #(SELECT_PRG_A000 | PRG_8000_SWAPPABLE | CHR_1000_GRANULAR)
sty MMC3_BANK_SELECT
clc
adc #1
sta MMC3_BANK_DATA
rts
.endproc