So a bit ago I asked how to show some graphics on the screen and managed to get it to work!
Now I wanted to add some sound! I arranged a song using SNES GSS and created the .spc file for it.
Now I tried reading online about how to load SPC programs and run them, and the documentation that I managed to find was... lacking (so to speak)
However I did manage to find a SNES program that plays SPC files. It was written with the wla-dx assembler in mind. Porting it to fit into my ca65 project seemed impossible; there was a lot of code!
Instead, I had the bright idea that rather than try to figure out how to port and incorporate that code into my program, it'd be a hell of a lot easier to port and incorporate my meager program into that.
To begin, I tweaked the spc player a bit and got it to play my .spc without showing anything on the screen. So far so good.
Now the next logical step to me would be to just include my binaries (palette data, map data, and tile data) in the ROM.
There was already some code in the spcplayer's main .asm file that included the needed data from the .spc file:
That looked good to me. However I had an additional 32K of data to add in along with a single zero byte to use for DMA purposes. Clearly banks 1-3 are full, and bank 0 is for code. So I thought, "Ok, I'll use banks 4 and 5". Thus I added these lines of code:
Well the assembler did NOT like that at all...
Are banks 4 and 5 not a thing? I read the wikibooks article on memory mapping and it says that the SNES has 256 banks and that ROMs can have up to 4 megabytes of data. To be honest though, the article is pretty sparse and I have no idea what the hell anything is at all! There's this table that I have no idea what it's saying:
That table honestly goes in one ear and out the other...
Furthermore, in my code I need to use some variables, i.e. some scratch space. So in my original project which used ca65, I had the following:
The thing is, wla-dx has no "zero page" directive. But I also realized that while I understand the definition of a zero page (the page that is at address $0000), I don't understand why variables need to go there only...
So here are my questions:
I'm totally cool with just being handed some reading materials if they clearly explain what is going on. The problem is I'm stuck between small, vague snippets of text here and there, and the full-on SNES development manual. Neither is great, and so here I am (or I should say, here I have been lol)
UPDATE:
In case it's relevant / anyone wants it, I've attached a zip file containing my entire project (or more accurately, my cannibalized version of spcplayer)
Now I wanted to add some sound! I arranged a song using SNES GSS and created the .spc file for it.
Now I tried reading online about how to load SPC programs and run them, and the documentation that I managed to find was... lacking (so to speak)
However I did manage to find a SNES program that plays SPC files. It was written with the wla-dx assembler in mind. Porting it to fit into my ca65 project seemed impossible; there was a lot of code!
Instead, I had the bright idea that rather than try to figure out how to port and incorporate that code into my program, it'd be a hell of a lot easier to port and incorporate my meager program into that.
To begin, I tweaked the spc player a bit and got it to play my .spc without showing anything on the screen. So far so good.
Now the next logical step to me would be to just include my binaries (palette data, map data, and tile data) in the ROM.
There was already some code in the spcplayer's main .asm file that included the needed data from the .spc file:
Code:
.bank 1 slot 0
; SPC-700 register values
.org $0000
.incbin SPC_FILE skip $00025 read $0008
; DSP register values
.org $4000
.incbin SPC_FILE skip $10100 read $0080
; The actual 64k SPC RAM dump
.bank 2
.section "musicDataLow"
.incbin SPC_FILE skip $0100 read $8000
.ends
.bank 3
.section "musicDataHigh"
.incbin SPC_FILE skip $8100 read $8000
.ends
; SPC-700 register values
.org $0000
.incbin SPC_FILE skip $00025 read $0008
; DSP register values
.org $4000
.incbin SPC_FILE skip $10100 read $0080
; The actual 64k SPC RAM dump
.bank 2
.section "musicDataLow"
.incbin SPC_FILE skip $0100 read $8000
.ends
.bank 3
.section "musicDataHigh"
.incbin SPC_FILE skip $8100 read $8000
.ends
That looked good to me. However I had an additional 32K of data to add in along with a single zero byte to use for DMA purposes. Clearly banks 1-3 are full, and bank 0 is for code. So I thought, "Ok, I'll use banks 4 and 5". Thus I added these lines of code:
Code:
.bank 4
palette0: .incbin "img/frame0.pal" FSIZE palettelen
palette1: .incbin "img/frame1.pal"
frame0map: .incbin "img/frame0.map" FSIZE frame0maplen
frame0chr: .incbin "img/frame0.chr" FSIZE frame0chrlen
.bank 5
frame1map: .incbin "img/frame1.map" FSIZE frame1maplen
frame1chr: .incbin "img/frame1.chr" FSIZE frame1chrlen
zerobyte: .db $00
.define counter_limit 50
palette0: .incbin "img/frame0.pal" FSIZE palettelen
palette1: .incbin "img/frame1.pal"
frame0map: .incbin "img/frame0.map" FSIZE frame0maplen
frame0chr: .incbin "img/frame0.chr" FSIZE frame0chrlen
.bank 5
frame1map: .incbin "img/frame1.map" FSIZE frame1maplen
frame1chr: .incbin "img/frame1.chr" FSIZE frame1chrlen
zerobyte: .db $00
.define counter_limit 50
Well the assembler did NOT like that at all...
Code:
project $ wla-65816 -o main.o main.asm
main.asm:185: DIRECTIVE_ERROR: ROM banks == 4, selected bank 4.
main.asm:185: ERROR: Couldn't parse ".bank".
project $
main.asm:185: DIRECTIVE_ERROR: ROM banks == 4, selected bank 4.
main.asm:185: ERROR: Couldn't parse ".bank".
project $
Are banks 4 and 5 not a thing? I read the wikibooks article on memory mapping and it says that the SNES has 256 banks and that ROMs can have up to 4 megabytes of data. To be honest though, the article is pretty sparse and I have no idea what the hell anything is at all! There's this table that I have no idea what it's saying:
That table honestly goes in one ear and out the other...
Furthermore, in my code I need to use some variables, i.e. some scratch space. So in my original project which used ca65, I had the following:
Code:
.segment "ZEROPAGE"
bgstatus: .res 1
counter: .res 1
init_bg = %00000001
bgmask = %00000011
bgstatus: .res 1
counter: .res 1
init_bg = %00000001
bgmask = %00000011
The thing is, wla-dx has no "zero page" directive. But I also realized that while I understand the definition of a zero page (the page that is at address $0000), I don't understand why variables need to go there only...
So here are my questions:
- 1. What in the hell is a bank and why is it important?
2. Why does the assembler not like more than 3 banks?
3. Why do variables need to go in the zero page? What's important about the zero page?
4. How do I define the zero page using wla-dx?
I'm totally cool with just being handed some reading materials if they clearly explain what is going on. The problem is I'm stuck between small, vague snippets of text here and there, and the full-on SNES development manual. Neither is great, and so here I am (or I should say, here I have been lol)
UPDATE:
In case it's relevant / anyone wants it, I've attached a zip file containing my entire project (or more accurately, my cannibalized version of spcplayer)