In the section on Sprite Movement: https://famicom.party/book/14-spritemovement/ the book discusses initializing some zeropage memory, and discusses how to do that, and also how to make the symbols available to the rest of the code. That makes sense, but I'm hung up on this statement:
specifically "we can't just write zero page values directly"Let's start using zero-page RAM in our code. Because only addresses from $8000 and up are ROM (i.e., part of your actual cartridge / code that you write), we can't just write zero page values directly. Instead, we tell the assembler to reserve memory in page zero, like this:Code: Select all
.segment "ZEROPAGE" player_x: .res 1 player_y: .res 1
Can't we? I'm sure that the assembler (ca65) wouldn't complain if I referred to a memory address directly, such as
Code: Select all
LDA $01
Code: Select all
.segment "ZEROPAGE"
player_x:
.byte $00
player_y:
.byte $00
Finally, I notice that the book reserves and initializes the ZP mem separately. Is there a reason it doesn't use the single instruction to do both? For example:
Code: Select all
.segment "ZEROPAGE"
player_x: .res 1, $80