add mmc5 option + fix preprocessor related bug

This commit is contained in:
Safyrus 2022-04-01 14:09:46 +02:00
parent 9969c5ba6b
commit 0388617280
10 changed files with 460 additions and 40 deletions

32
Boilerplate_mmc5.cfg Normal file
View File

@ -0,0 +1,32 @@
MEMORY {
ZP: start = $0000, size = $0100, type = rw, define = yes;
OAM: start = $0200, size = $0100, type = rw, define = yes;
RAM: start = $0300, size = $0500, type = rw, define = yes;
HEADER: start = $0000, size = $0010, type = ro, file = %O, fill = yes, fillval = $00;
BNK0: start = $8000, size = $2000, type = ro, file = %O, fill = yes, fillval = $00, define = yes;
BNK1: start = $A000, size = $2000, type = ro, file = %O, fill = yes, fillval = $00, define = yes;
BNK2: start = $C000, size = $2000, type = ro, file = %O, fill = yes, fillval = $00, define = yes;
BNK3: start = $E000, size = $2000, type = ro, file = %O, fill = yes, fillval = $00, define = yes;
CHR: start = $0000, size = $2000, type = ro, file = %O, fill = yes, fillval = $00;
}
SEGMENTS {
HEADER: load = HEADER, type = ro;
STARTUP: load = BNK0, type = ro, define = yes;
LOWCODE: load = BNK0, type = ro, optional = yes;
INIT: load = BNK0, type = ro, define = yes, optional = yes;
CODE: load = BNK0, type = ro, define = yes;
RODATA: load = BNK0, type = ro, define = yes;
DATA: load = BNK0, run = RAM, type = rw, define = yes;
BNK0: load = BNK0, type = ro, start = $8000, optional = yes;
BNK1: load = BNK1, type = ro, start = $A000, optional = yes;
BNK2: load = BNK2, type = ro, start = $C000, optional = yes;
BNK3: load = BNK3, type = ro, start = $E000, optional = yes;
LAST_BNK: load = BNK3, type = ro, start = $E000;
VECTORS: load = BNK3, type = ro, start = $FFFA;
OAM: load = OAM, type = rw;
BSS: load = RAM, type = bss, define = yes;
HEAP: load = RAM, type = bss, optional = yes;
ZEROPAGE: load = ZP, type = zp;
CHARS: load = CHR, type = ro;
}

View File

@ -41,6 +41,9 @@ ASM = asm
# Change this to 0 if you don't want FamiStudio # Change this to 0 if you don't want FamiStudio
FAMISTUDIO = 1 FAMISTUDIO = 1
# Change this to 1 if you want the MMC5 mapper
MMC5 = 0
# ! - - - - - - - - - - - - - - - - ! # # ! - - - - - - - - - - - - - - - - ! #
# DO NOT CHANGE ANYTHING AFTER THIS # # DO NOT CHANGE ANYTHING AFTER THIS #
@ -74,17 +77,25 @@ $(GAME_NAME)_a.nes:
# create folder if it does not exist # create folder if it does not exist
@-if not exist "$(BIN)" ( mkdir "$(BIN)" ) @-if not exist "$(BIN)" ( mkdir "$(BIN)" )
# assemble main file # assemble main file
.\$(CA65) asm/crt0.asm -o $(BIN)/$(GAME_NAME).o --debug-info -DFAMISTUDIO=$(FAMISTUDIO) .\$(CA65) asm/crt0.asm -o $(BIN)/$(GAME_NAME).o --debug-info -DFAMISTUDIO=$(FAMISTUDIO) -DMMC5=$(MMC5)
# link files # link files
ifeq ($(MMC5),1)
.\$(LD65) $(BIN)/$(GAME_NAME).o -C $(GAME_NAME)_mmc5.cfg -o $(GAME_NAME)_a.nes --dbgfile $(GAME_NAME)_a.DBG
else
.\$(LD65) $(BIN)/$(GAME_NAME).o -C $(GAME_NAME).cfg -o $(GAME_NAME)_a.nes --dbgfile $(GAME_NAME)_a.DBG .\$(LD65) $(BIN)/$(GAME_NAME).o -C $(GAME_NAME).cfg -o $(GAME_NAME)_a.nes --dbgfile $(GAME_NAME)_a.DBG
endif
# create the nes file from c sources # create the nes file from c sources
$(GAME_NAME)_c.nes: $(addprefix $(BIN)/,$(SRCFILE:.c=.o)) $(GAME_NAME)_c.nes: $(addprefix $(BIN)/,$(SRCFILE:.c=.o))
# assemble main file # assemble main file
$(CA65) $(ASM)/crt0.asm -g -o $(BIN)/$(GAME_NAME).o -I$(ASMINC) -DC_CODE -DFAMISTUDIO=$(FAMISTUDIO) $(CA65) $(ASM)/crt0.asm -g -o $(BIN)/$(GAME_NAME).o -I$(ASMINC) -DC_CODE -DFAMISTUDIO=$(FAMISTUDIO) -DMMC5=$(MMC5)
# link files # link files
ifeq ($(MMC5),1)
$(LD65) $(BIN)/$(GAME_NAME).o $^ -C $(GAME_NAME)_mmc5.cfg -o $@ $(NESLIB) --dbgfile $(GAME_NAME)_c.DBG
else
$(LD65) $(BIN)/$(GAME_NAME).o $^ -C $(GAME_NAME).cfg -o $@ $(NESLIB) --dbgfile $(GAME_NAME)_c.DBG $(LD65) $(BIN)/$(GAME_NAME).o $^ -C $(GAME_NAME).cfg -o $@ $(NESLIB) --dbgfile $(GAME_NAME)_c.DBG
endif
# assemble object files # assemble object files
@ -92,7 +103,7 @@ $(BIN)/%.o: $(BIN)/%.asm
# create folder if it does not exist # create folder if it does not exist
@-if not exist "$(@D)" ( mkdir "$(@D)" ) @-if not exist "$(@D)" ( mkdir "$(@D)" )
# assemble a file # assemble a file
$(CA65) -g -I$(INC) -I$(ASMINC) -o $@ $^ -DC_CODE -DFAMISTUDIO=$(FAMISTUDIO) $(CA65) -g -I$(INC) -I$(ASMINC) -o $@ $^ -DC_CODE -DFAMISTUDIO=$(FAMISTUDIO) -DMMC5=$(MMC5)
# compile c files # compile c files
@ -100,7 +111,7 @@ $(BIN)/%.asm: %.c
# create folder if it does not exist # create folder if it does not exist
@-if not exist "$(@D)" ( mkdir "$(@D)" ) @-if not exist "$(@D)" ( mkdir "$(@D)" )
# compile a file # compile a file
$(CC65) -O -g -I$(INC) -I$(ASM) -o $@ $^ $(NESLIB) --add-source $(CC65) -O -g -I$(INC) -I$(ASM) -o $@ $^ $(NESLIB) --add-source -DFAMISTUDIO=$(FAMISTUDIO) -DMMC5=$(MMC5)
# clean object files # clean object files

View File

@ -26,8 +26,9 @@ This project has/can:
- An IRQ handler (that does nothing, but we need one). - An IRQ handler (that does nothing, but we need one).
- Support for the FamiStudio Sound Engine (<https://famistudio.org>) - Support for the FamiStudio Sound Engine (<https://famistudio.org>)
- Some defined constant (PPU, APU, etc.). - Some defined constant (PPU, APU, etc.).
- Compile the game with the MMC5 mapper. (<https://www.nesdev.org/wiki/MMC5>)
Note: *This project has no mapper. i.e. it is a NROM game with 32K of PRG and 8K of CHR by default.* Note: *This project has by default 32K of PRG and 8K of CHR.*
----------------- -----------------
@ -86,7 +87,8 @@ To configure the sources files, you must:
``` ```
3. Rename the .cfg file to `your_game_name.cfg`. 3. Rename the .cfg file to `your_game_name.cfg`.
4. *(Optional)* get the FamiStudio Sound Engine 4. *(Optional)* If you want to use the MMMC5 mapper, rename the mmc5 .cfg file to `your_game_name_mmc5.cfg`. It must end with `_mmc5.cfg`.
5. *(Optional)* get the FamiStudio Sound Engine
1. Place the `famistudio_ca65.s` file in `asm/audio/` 1. Place the `famistudio_ca65.s` file in `asm/audio/`
*Note: if you are coding in C, you should include `famistudio_cc65.h` somewhere in your include folder* *Note: if you are coding in C, you should include `famistudio_cc65.h` somewhere in your include folder*
2. in the `crt0.asm` in the FamiStudio section, include your music files. Example: 2. in the `crt0.asm` in the FamiStudio section, include your music files. Example:
@ -198,11 +200,20 @@ You will need to indicate to the Makefile where cc65 and other software programs
FAMISTUDIO = 1 FAMISTUDIO = 1
``` ```
- **MMC5**: *(Required)*
If you want to use the MMC5 mapper for your game, set this to 1, otherwise set it to 0. Example:
```make
MMC5 = 0
```
### **FamiStudio configuration** ### **FamiStudio configuration**
You can configure the engine by editing `asm/audio/famistudio_config.asm`. You can configure the engine by editing `asm/audio/famistudio_config.asm`.
If you need help, you can check the FamiStudio documentation: <https://famistudio.org/doc/soundengine> If you need help, you can check the FamiStudio documentation: <https://famistudio.org/doc/soundengine>
Note: *The 'FAMISTUDIO_EXP_MMC5' option is configured correctly by default. You do not need to change it*
## **Building the game** ## **Building the game**
Note: make sure that you have correctly set up the Makefile and source files. Note: make sure that you have correctly set up the Makefile and source files.

View File

@ -26,7 +26,7 @@
; Konami VRC7 (6 FM channels) ; Konami VRC7 (6 FM channels)
FAMISTUDIO_EXP_VRC7 = 0 FAMISTUDIO_EXP_VRC7 = 0
; Nintendo MMC5 (2 extra squares, extra DPCM not supported) ; Nintendo MMC5 (2 extra squares, extra DPCM not supported)
FAMISTUDIO_EXP_MMC5 = 0 FAMISTUDIO_EXP_MMC5 = MMC5
; Sunsoft S5B (2 extra squares, advanced features not supported.) ; Sunsoft S5B (2 extra squares, advanced features not supported.)
FAMISTUDIO_EXP_S5B = 0 FAMISTUDIO_EXP_S5B = 0
; Famicom Disk System (extra wavetable channel) ; Famicom Disk System (extra wavetable channel)

View File

@ -0,0 +1,291 @@
; This file for the FamiStudio Sound Engine and was generated by FamiStudio
.if FAMISTUDIO_CFG_C_BINDINGS
.export _music_data_arpeggio_mmc5=music_data_arpeggio_mmc5
.endif
music_data_arpeggio_mmc5:
.byte 1
.word @instruments
.word @samples-4
.word @song0ch0,@song0ch1,@song0ch2,@song0ch3,@song0ch4,@song0ch5,@song0ch6
.byte .lobyte(@tempo_env_7_mid), .hibyte(@tempo_env_7_mid), 0, 0
.export music_data_arpeggio_mmc5
.global FAMISTUDIO_DPCM_PTR
@instruments:
.word @env1,@env0,@env3,@env2
.word @env5,@env0,@env4,@env2
@samples:
@env0:
.byte $c0,$7f,$00,$00
@env1:
.byte $00,$cc,$c7,$c4,$c2,$c1,$c0,$00,$06
@env2:
.byte $00,$c0,$7f,$00,$01
@env3:
.byte $7f,$00,$00
@env4:
.byte $c2,$7f,$00,$00
@env5:
.byte $07,$c7,$c6,$c6,$c5,$00,$04,$c3,$c2,$c1,$c1,$00,$0a
@tempo_env_7_mid:
.byte $03,$05,$05,$06,$03,$06,$05,$05,$80
@song0ch0:
.byte $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7
@song0ch0loop:
.byte $6a, .lobyte(@tempo_env_7_mid), .hibyte(@tempo_env_7_mid), $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7, $6b
.byte $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7, $6b, $f7, $e7
@song0ref39:
.byte $6b
@song0ref40:
.byte $82
@song0ref41:
.byte $3d, $83, $00, $85, $41, $83, $00, $85, $42, $83, $00, $85, $44, $83, $00, $85, $3d, $83, $00, $85, $41, $83, $00, $85
.byte $42, $83, $00, $85, $44, $83, $00, $85
.byte $ff, $20
.word @song0ref41
@song0ref76:
.byte $6b
@song0ref77:
.byte $3a, $83, $00, $85, $3e, $83, $00, $85, $3f, $83, $00, $85, $41, $83, $00, $85, $3a, $83, $00, $85, $3e, $83, $00, $85
.byte $3f, $83, $00, $85, $41, $83, $00, $85
.byte $ff, $20
.word @song0ref77
.byte $6b, $80
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref76
.byte $ff, $20
.word @song0ref77
.byte $ff, $20
.word @song0ref39
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref76
.byte $ff, $20
.word @song0ref77
.byte $6b, $80, $44, $8b, $00, $a7, $44, $8b, $00, $a7, $44, $8b, $00, $a7, $44, $8b, $00, $8b, $44, $8b, $00, $8b, $6b, $41
.byte $8b, $00, $a7, $41, $8b, $00, $a7, $41, $8b, $00, $a7, $41, $8b, $00, $8b, $41, $8b, $00, $8b, $6b, $42, $8b, $00, $a7
.byte $42, $8b, $00, $a7, $42, $8b, $00, $a7, $42, $8b, $00, $8b, $42, $8b, $00, $8b, $6b, $3f, $8b, $00, $a7, $3f, $8b, $00
.byte $a7, $3f, $8b, $00, $a7, $3f, $8b, $00, $8b, $3f, $8b, $00, $8b, $fd
.word @song0ch0loop
@song0ch1:
@song0ref226:
.byte $82
@song0ref227:
.byte $31, $83, $00, $85, $35, $83, $00, $85, $36, $83, $00, $85, $38, $83, $00, $85, $31, $83, $00, $85, $35, $83, $00, $85
.byte $36, $83, $00, $85, $38, $83, $00, $85
.byte $ff, $20
.word @song0ref227
@song0ref262:
.byte $2e, $83, $00, $85, $32, $83, $00, $85, $33, $83, $00, $85, $35, $83, $00, $85, $2e, $83, $00, $85, $32, $83, $00, $85
.byte $33, $83, $00, $85, $35, $83, $00, $85
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
@song0ch1loop:
.byte $ff, $20
.word @song0ref226
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $80, $38, $8b, $00, $a7, $38, $8b, $00, $a7, $38, $8b, $00, $a7, $38, $8b, $00, $8b, $38, $8b, $00, $8b, $35, $8b, $00
.byte $a7, $35, $8b, $00, $a7, $35, $8b, $00, $a7, $35, $8b, $00, $8b, $35, $8b, $00, $8b, $36, $8b, $00, $a7, $36, $8b, $00
.byte $a7, $36, $8b, $00, $a7, $36, $8b, $00, $8b, $36, $8b, $00, $8b, $33, $8b, $00, $a7, $33, $8b, $00, $a7, $33, $8b, $00
.byte $a7, $33, $8b, $00, $8b, $33, $8b, $00, $8b
.byte $ff, $20
.word @song0ref226
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $80
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref226
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref227
.byte $ff, $20
.word @song0ref262
.byte $ff, $20
.word @song0ref262
.byte $fd
.word @song0ch1loop
@song0ch2:
.byte $f7, $e7, $f7, $e7
@song0ref483:
.byte $80
@song0ref484:
.byte $25, $8b, $29, $8b, $2a, $8b, $2c, $8b, $25, $8b, $29, $8b, $2a, $8b, $2c, $8b, $25, $8b, $29, $8b, $2a, $8b, $2c, $8b
.byte $25, $8b, $29, $8b, $2a, $8b, $2c, $8b, $22, $8b, $26, $8b, $27, $8b, $29, $8b, $22, $8b, $26, $8b, $27, $8b, $29, $8b
.byte $22, $8b, $26, $8b, $27, $8b, $29, $8b, $22, $8b, $26, $8b, $27, $8b, $29, $8b
@song0ch2loop:
.byte $ff, $40
.word @song0ref483
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $ff, $40
.word @song0ref484
.byte $fd
.word @song0ch2loop
@song0ch3:
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7
@song0ch3loop:
.byte $80
@song0ref589:
.byte $1e, $8b, $00, $8b, $1e, $8b, $00, $8b, $1e, $8b, $00, $8b, $1e, $8b, $00, $8b, $1e, $8b, $1e, $8b, $1e, $8b, $00, $8b
.byte $1e, $8b, $00, $a7
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $ff, $1c
.word @song0ref589
.byte $fd
.word @song0ch3loop
@song0ch4:
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7
@song0ch4loop:
@song0ref680:
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7, $fd
.word @song0ch4loop
@song0ch5:
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7
@song0ch5loop:
.byte $ff, $1c
.word @song0ref680
.byte $85, $82
@song0ref733:
.byte $25, $83, $00, $85, $29, $83, $00, $85, $2a, $83, $00, $85, $2c, $83, $00, $85, $25, $83, $00, $85, $29, $83, $00, $85
.byte $2a, $83, $00, $85, $2c, $83, $00, $85
.byte $ff, $20
.word @song0ref733
@song0ref768:
.byte $22, $83, $00, $85, $26, $83, $00, $85, $27, $83, $00, $85, $29, $83, $00, $85, $22, $83, $00, $85, $26, $83, $00, $85
.byte $27, $83, $00, $85, $29, $83, $00, $85
.byte $ff, $20
.word @song0ref768
.byte $ff, $20
.word @song0ref733
.byte $ff, $20
.word @song0ref733
.byte $ff, $20
.word @song0ref768
.byte $ff, $1f
.word @song0ref768
.byte $fd
.word @song0ch5loop
@song0ch6:
.byte $f7, $e7, $f7, $e7, $f7, $e7, $f7, $e7
@song0ch6loop:
.byte $ff, $1c
.word @song0ref680
.byte $ff, $20
.word @song0ref40
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref77
.byte $ff, $20
.word @song0ref77
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref41
.byte $ff, $20
.word @song0ref77
.byte $ff, $20
.word @song0ref77
.byte $fd
.word @song0ch6loop

View File

@ -97,3 +97,17 @@ NMI_PLT = %00001000
NMI_ATR = %00000100 NMI_ATR = %00000100
NMI_SPR = %00000010 NMI_SPR = %00000010
NMI_BKG = %00000001 NMI_BKG = %00000001
;----------
; MMC5
;----------
.ifdef MMC5
MMC5_PRG_MODE := $5100
MMC5_CHR_MODE := $5101
MMC5_RAM_BNK := $5113
MMC5_PRG_BNK0 := $5114
MMC5_PRG_BNK1 := $5115
MMC5_PRG_BNK2 := $5116
MMC5_PRG_BNK3 := $5117
.endif

View File

@ -12,7 +12,11 @@
.byte "NES", $1A; 0-3: Header .byte "NES", $1A; 0-3: Header
.byte $02 ; 4: PRG ROM .byte $02 ; 4: PRG ROM
.byte $01 ; 5: CHR ROM .byte $01 ; 5: CHR ROM
.if MMC5=1
.byte $51 ; 6: Flags 6
.else
.byte $01 ; 6: Flags 6 .byte $01 ; 6: Flags 6
.endif
.byte $00 ; 7: Flags 7 .byte $00 ; 7: Flags 7
.byte $00 ; 8: Flags 8 .byte $00 ; 8: Flags 8
.byte $00 ; 9: Flags 9 .byte $00 ; 9: Flags 9
@ -23,23 +27,57 @@
.include "macro.asm" .include "macro.asm"
.include "memory.asm" .include "memory.asm"
; This is the code to use when using the MMC5 mapper
.if MMC5=1
.segment "LAST_BNK"
; 6502 vectors subrountines
.include "vector/rst.asm"
.include "vector/nmi.asm"
.include "vector/irq.asm"
.segment "STARTUP" .if FAMISTUDIO=1
.ifdef C_CODE ; FamiStudio Sound Engine
_exit: .include "audio/famistudio_config.asm"
.endif .include "audio/famistudio_ca65.s"
.endif
.segment "STARTUP"
.ifdef C_CODE
_exit:
.endif
.ifndef C_CODE
; main file
.include "main.asm"
.endif
.segment "BNK1"
.if FAMISTUDIO=1
; Musics
.include "audio/music/arpeggio_mmc5.s"
.endif
; This is the code to use when not using any mapper
.else
.segment "STARTUP"
.ifdef C_CODE
_exit:
.endif
; 6502 vectors subrountines ; 6502 vectors subrountines
.include "vector/rst.asm" .include "vector/rst.asm"
.include "vector/nmi.asm" .include "vector/nmi.asm"
.include "vector/irq.asm" .include "vector/irq.asm"
.ifndef C_CODE .ifndef C_CODE
; main file ; main file
.include "main.asm" .include "main.asm"
.endif .endif
.if FAMISTUDIO=1 .if FAMISTUDIO=1
; FamiStudio Sound Engine ; FamiStudio Sound Engine
.include "audio/famistudio_config.asm" .include "audio/famistudio_config.asm"
.include "audio/famistudio_ca65.s" .include "audio/famistudio_ca65.s"
@ -47,6 +85,7 @@ _exit:
; Musics ; Musics
.include "audio/music/arpeggio.s" .include "audio/music/arpeggio.s"
.endif
.endif .endif

View File

@ -4,8 +4,13 @@
MAIN: MAIN:
.if FAMISTUDIO=1 .if FAMISTUDIO=1
.if MMC5=1
LDX #<music_data_arpeggio_mmc5 ; music data (lo)
LDY #>music_data_arpeggio_mmc5 ; music data (hi)
.else
LDX #<music_data_arpeggio ; music data (lo) LDX #<music_data_arpeggio ; music data (lo)
LDY #>music_data_arpeggio ; music data (hi) LDY #>music_data_arpeggio ; music data (hi)
.endif
LDA #$01 ; NTSC LDA #$01 ; NTSC
JSR famistudio_init JSR famistudio_init

View File

@ -46,6 +46,21 @@ RST:
STA PPU_CTRL STA PPU_CTRL
STA ppu_ctrl_val STA ppu_ctrl_val
.if MMC5=1
; - - - - - - -
; setup MMC5
; - - - - - - -
; set $8000-9FFF to BNK 0
LDA #$80
STA MMC5_PRG_BNK0
; set $A000-BFFF to BNK 1
LDA #$81
STA MMC5_PRG_BNK1
; set $C000-DFFF to BNK 2
LDA #$82
STA MMC5_PRG_BNK2
.endif
CLI CLI
.ifdef C_CODE .ifdef C_CODE

View File

@ -1,26 +1,28 @@
#include "constant.h" #include "constant.h"
#include "zp_variables.h" #include "zp_variables.h"
#include "ram_variables.h" #include "ram_variables.h"
#if FAMISTUDIO 1
#include "famistudio_cc65.h" #include "famistudio_cc65.h"
// #pragma bss-name(push, "ZEROPAGE") #if MMC5 1
extern uint8_t music_data_arpeggio_mmc5[];
// test variable in zeropage #else
// uint8_t zeroPageVar;
// #pragma bss-name(push, "BSS")
// test variable in RAM
// uint8_t ramVar;
extern uint8_t music_data_arpeggio[]; extern uint8_t music_data_arpeggio[];
#endif
#endif
void init() void init()
{ {
#if FAMISTUDIO 1
#if MMC5 1
famistudio_init(1, music_data_arpeggio_mmc5);
#else
famistudio_init(1, music_data_arpeggio); famistudio_init(1, music_data_arpeggio);
#endif
famistudio_music_play(0); famistudio_music_play(0);
// zeroPageVar = 0; #endif
// ramVar = 0;
} }
void loop() void loop()
@ -68,9 +70,7 @@ void loop()
background[7] = 0x03; background[7] = 0x03;
background[8] = 0x00; background[8] = 0x00;
// inc variables // inc variable
// ++zeroPageVar;
// ++ramVar;
++game_state; ++game_state;
} }
@ -83,7 +83,9 @@ void main()
while ((nmi_flags & 0x80) == 0) while ((nmi_flags & 0x80) == 0)
{ {
} }
#if FAMISTUDIO 1
famistudio_update(); famistudio_update();
#endif
loop(); loop();
} }