[stella] newbie question

Subject: [stella] newbie question
From: Thomas Dunn <td629@xxxxxxxxx>
Date: Wed, 24 Sep 2003 08:07:57 -0700 (PDT)
Hello all,

I was on the list for a short period a couple years ago.  Well, I'm back at it again, on my slow
journey to writing 2600 games...

Here's a newbie question for you.  I'm just trying to have player0 start in the middle of the
screen, move down until it hits scanline 180, and then jump back to the top of the screen
(scanline 5), and continue down again, looping at the bottom.

This bit of code doesn't seem to be working for me, it continues way past scanline 180 (probably
to scanline 255?), and then loops back to the top

                inc SpriteYPosition    ; move player down

                sta #180
                cmp SpriteYPosition    ; check if at scanline 180

                bcc DontMoveToTop      ; if accum < spriteY, branch
                lda #5                 ; jump the sprite back to scanline 5
                sta SpriteYPosition

DontMoveToTop

I'm sure the problem will jump right out at you guys.
Here's the full code, thanks a lot!

Tom Dunn

--------------------------------------------------------------------------------------


; Thomas Dunn
; 2003-09-23

; to position player0 vertically:
; x counts scanline
; keep doing blank until cpx SpriteYPosition
; draw 8 lines of sprite
; draw (192 - SpriteYPosition - 8 = 184 - SpriteYPosition) lines
; move sprite down

                processor 6502 
                include "vcs.h" 
                include "macro.h" 

;------------------------------------------------------------------------------ 

                SEG.U vars  ; define variables
                ORG $80
SpriteYPosition     ds 1

                SEG 
                ORG $F000 

;------------------------------------------------------------------------------

INITIAL_SPRITE_Y_POSITION = 92
SPRITE_HEIGHT             = 8



Reset 


    ; Clear RAM and all TIA registers 

                ldx #0 
                lda #0 
Clear           sta 0,x 
                inx 
                bne Clear 


        ;------------------------------------------------ 
        ; one time initialization

                lda #INITIAL_SPRITE_Y_POSITION    ; set initial scanline of player
                sta SpriteYPosition
                        
                lda #45               ; set colors
                sta COLUPF
                lda #$45
                sta COLUP0


StartOfFrame 

    ; Start of new frame 
    ; Start of vertical blank processing 

                lda #0 
                sta VBLANK 

                lda #2 
                sta VSYNC 

                sta WSYNC 
                sta WSYNC 
                sta WSYNC                ; 3 scanlines of VSYNC signal 

                lda #0 
                sta VSYNC 

        ;------------------------------------------------ 
        ; 36+1=37 scanlines of vertical blank
            
                ldx #0 
VerticalBlank   sta WSYNC 
                inx 
                cpx #36
                bne VerticalBlank 
                
	
                sleep 25                  ; set initial horizontal position of player
                sta RESP0
                sta WSYNC
                

        ;------------------------------------------------ 
        ; Do 192 scanlines (before player, player, after player)
                
                ldx #0                   ; counts scanline
                lda #0
                sta GRP0

BeforePlayer

                sta WSYNC

                inx
                cpx SpriteYPosition
                bne BeforePlayer
        
        ;------------------------------------------------ 

                ldx #0                   ; counts scanline
                lda #%10101010           ; load the graphics for the player
                sta GRP0
Player

                sta WSYNC

                inx
                cpx #SPRITE_HEIGHT
                bne Player
        
        ;------------------------------------------------ 

                sta #184
                sbc SpriteYPosition
                tax

                lda #%00000000         ; clear player graphics
                sta GRP0
AfterPlayer

                sta WSYNC

                dex
                beq AfterPlayer
 
        
        ;------------------------------------------------ 

                inc SpriteYPosition    ; move player down

                sta #180
                cmp SpriteYPosition    ; check if at scanline 180

                bcc DontMoveToTop      ; if accum < spriteY, branch
                lda #5                 ; jump the sprite back to scanline 5
                sta SpriteYPosition

DontMoveToTop

        ;------------------------------------------------ 
        

                lda #%01000010 
                sta VBLANK           ; end of screen - enter blanking 

    ; 30 scanlines of overscan... 

                ldx #0 
Overscan        sta WSYNC 
                inx 
                cpx #30 
                bne Overscan 




                jmp StartOfFrame 


;------------------------------------------------------------------------------ 

            ORG $FFFA 

InterruptVectors 

            .word Reset           ; NMI 
            .word Reset           ; RESET 
            .word Reset           ; IRQ 

          END 


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
----------------------------------------------------------------------------------------------
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/


Current Thread