Jump to content
IGNORED

.btye value storage question


Recommended Posts

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.

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...