SavedByZero Posted July 24, 2019 Share Posted July 24, 2019 This may seem like a minor hangup, but I'm trying to learn why this code block does NOT properly store the value #5 inside YPOS: processor 6502 include "vcs.h" include "macro.h" include "xmacro.h" org $f000 YPos .byte BGColor equ $81 counter equ #0 SpriteHeight equ 9 TooLow equ 5 Start CLEAN_START NextFrame lda #2 ; turn VBLANK on sta VBLANK ; sta VSYNC ; turn VSYNC on sta WSYNC sta WSYNC sta WSYNC lda #0 ; turn VSYNC off sta VSYNC ; ldx #37 LVBlank sta WSYNC dex bne LVBlank lda #0 ; turn VBLANK off sta VBLANK ; ldx #192 ;ldy counter lda #5 sta YPos and this one DOES store it properly: processor 6502 include "vcs.h" include "macro.h" seg.u variables include "xmacro.h" org $80 YPos .byte seg code org $f000 BGColor equ $81 counter equ #0 SpriteHeight equ 9 TooLow equ 5 Start CLEAN_START NextFrame lda #2 ; turn VBLANK on sta VBLANK ; sta VSYNC ; turn VSYNC on sta WSYNC sta WSYNC sta WSYNC lda #0 ; turn VSYNC off sta VSYNC ; ldx #37 LVBlank sta WSYNC dex bne LVBlank lda #0 ; turn VBLANK off sta VBLANK ; ldx #192 ;ldy counter lda #5 sta YPos The only thing I do differently in part 2, thanks to easmith's help, is that "org $80" section and import of seg.u variables. Unfortunately the chapter I'm up to in the "Making Games For..." book (8) is not at the point where it explains this, or where to put its sample snippets of code. Quote Link to comment Share on other sites More sharing options...
easmith Posted July 24, 2019 Share Posted July 24, 2019 the variables section is the RAM, which you can read from and write to . The code section is ROM which can not be written to . All variables must be defined in RAM which is $80 to $FF in memory Quote Link to comment Share on other sites More sharing options...
SavedByZero Posted July 25, 2019 Author Share Posted July 25, 2019 3 hours ago, easmith said: the variables section is the RAM, which you can read from and write to . The code section is ROM which can not be written to . All variables must be defined in RAM which is $80 to $FF in memory Now *that* makes sense... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.