Code: Select all
.rsset $0000
Var .rs 1 ; Reserve one byte ($0000)Moderator: Moderators
Code: Select all
.rsset $0000
Var .rs 1 ; Reserve one byte ($0000)Code: Select all
lda #5
sta $80Code: Select all
lives = $80
STARTING_LIVES = 5
; ...
lda #STARTING_LIVES
sta livesCode: Select all
STARTING_LIVES = 5
.segment "ZEROPAGE"
lives: .res 1
.segment "CODE"
; ...
lda #STARTING_LIVES
sta livesI'm guessing it has something to do with bare-bones dialects of assembly language used by interactive assemblers such as another platform's debug.exe and the Apple II mini-assembler, or the sort of assembly language you get from the disassembler built into Nintendulator or FCEUX. These dialects tend to lack labels.Dwedit wrote:I have no idea what you mean when you say "Pure 6502 assembly". There are assemblers which let you use labels and equates, and there's the binary machine code itself which has no idea what a label is, just memory addresses.
Addresses $0200-$07FF are free, and $6000-$7FFF are also free if you have PRG RAM on your cartridge board. Addresses $0000-$01FF have special meanings, but you can put variables in unused parts of those. Shall I explain how my games use memory?67726e wrote:as far as writing to the RAM goes, you can write anywhere between $0000-$0800 which would be the NES' 2K worth of RAM? If I have WRAM in my game, then I could also use $6000-$8000? Am I in the ballpark here? Anything missing?
Code: Select all
LDA $0200Code: Select all
LDA Some_LabelHow exactly would one know where the unused slots are? The information that I have on the '.rsset' directive with NESASM3 allows you to start the addressing at $0000 and work your way up from there so wouldn't that have the potential to screw with the 'special meanings'Addresses $0000-$01FF have special meanings, but you can put variables in unused parts of those.
Code: Select all
LDX #$00
LoadSprite:
LDA Sprite, x
STA $0200, x
INX
CPX #$18
BNE LoadSpriteCode: Select all
LDA #$00
STA $2003
LDA #$02
STA $4014Instructions using indirection need to use addresses in $0000-$00FF, the 256-byte "zero page". Stack instructions (PHA, PLA, JSR, RTS, etc.) need to use addresses in $0100-$01FF, the 256-byte "stack page". Those are the only two areas with special meanings to the CPU, but rough conventions about the use of some other areas arose during the NES's commercial era. I just wrote a wiki article showing suggested uses for parts of RAM.67726e wrote:How exactly would one know where the unused slots are? The information that I have on the '.rsset' directive with NESASM3 allows you to start the addressing at $0000 and work your way up from there so wouldn't that have the potential to screw with the 'special meanings'
The CPU's DMA unit always copies exactly 256 bytes from this page to the OAM data port on the PPU ($2004). Unused memory in this page should be cleared to values between $EF and $FF, so that unused sprites are hidden below the bottom of the visible area of the screen.To load the sprites into the RAM so it occupies $0200-$0217, now in NMI I have to put:
I actually have two question regarding this:Code: Select all
LDA #$00 STA $2003 LDA #$02 STA $4014
1) How does the PPU know when to stop reading?
You're writing the destination address, which is inside OAM, to PPU port $2003. (This address should always be set to zero unless you really know what you're doing.) You're writing the upper 8 bits of the source address, which is inside ordinary RAM, to $4014. The copy always starts at the first byte ($xx00) of this page.2) Why do I write the second byte of the address to $4014 instead of $2003?
Keep in mind that if you plan on coding like this, it will be hell to move stuff around when you need to, and trust me, that will happen eventually. Say that you decide to use 64 bytes to keep track of a number of items available in a level, but later you decide that you want to have 128 items per level instead of just 64. What happens if you have used the space that comes after those 64 bytes for something else? You'll have to go through all of the code looking for the parts where you used those addresses and change them to something else. If you had named the variables, it would just be a matter of changing their declarations, and the whole program would use the variables in their new place.67726e wrote:What I mean with 'pure 6502' was just the bare mnemonics/operands i.e.
Code: Select all
LDA $0200