- Bitwise operations and bit shifts
- Fixed point calculations
- Pointers
- Registers
- Zero page
- Stack page
- CHR ROM
- Nametables
- Palettes
- Sprites
- VBlank time and VRAM access
- CPU and PPU memory maps
; assembly version |
// C version |
nsf2data sounds.nsf -ca65The resulting sounds.s file is placed into the project directory, it is always included into the project from crt0.s. If you don't need sound effects in your project, you can disable them with a define there. This will exclude all related code as well.
text2data music.txt -ca65If FamiTone2 feature set is somehow too limited for you, you can hook up the native FamiTracker player instead. Its code is compilable with ca65, but it would require quite some work that requires 6502 assembly knowledge, especially if you need to have sound effects support. It is also three times larger and twice slower, so make a decision judging by how much free memory and CPU time you have in a project.
#pragma bssseg (push,"BSS")Please note that for the next release of CC65, which is currently only avaialble as a development snapshot, it should be changed to this:
#pragma dataseg(push,"BSS")
#pragma bss-name (push,"ZEROPAGE")If your project really needs more than ~1500 bytes of RAM, there is an option to use extra 8K RAM. This is not an easy decision if you going to make a physical release, because that'll require to put an extra RAM chip into every cartridge. To make this memory usable by CC65 you have to edit nes.cfg, check comments there.
#pragma data-name(push,"ZEROPAGE")
void __fastcall__ func(void);Assembly counterpart will look like this:
.export _func ;makes the function available outside of the fileNow a function that takes a parameter and returns a parameter as well:
_func:
... ;your code
rts
unsigned char __fastcall__ func(unsigned char n);For 16-bit vars you should to use X:A pair, with LSB in A and MSB in X.
.export _func
_func:
;n is already in the register A
...
;put your return value into the register A
rts
unsigned int __fastcall__ func(unsigned int x,unsigned int y,unsigned char n,const unsigned char *ptr);
.export _func
_func:
;ptr is in X:A
jsr popa
;n is in A
jsr popax
;y is in X:A
jsr popax
;x is in X:A
...
;put your return value into X:A
rts
*(unsigned char*)0x00ff=1; //write 1 into $00ff, it is the last byte of the zero page