Jump to content
IGNORED

Sprite pixels disappearing on the left side of screen


xucaen

Recommended Posts

Hi, I'm still reading Andrew's tutorial and I'm sure I'll figure this out eventually. I'm certain it's a timing issue.. probably have some wsyncs in the wrong place.. But anyways, I'm only testing moving a sprite up, down, left and right. There is also a simple reflected playfield on the bottom 6 scanlines. When my sprite reaches the left side of the screen one of the top bits disappears, almost as is there is an invisible line doesn the side. I'm attaching two screen shots, the first shows what the screen looks like when it first starts up, the second shows when the sprite reaches the left side. I guess what I'm looking for are some possibilities for me to look at, I don't anyone to hand hold me.. not unless you really care. :D

 

Thanks!

 

Jim

post-6228-1105428259_thumb.jpg

post-6228-1105428260_thumb.jpg

Link to comment
Share on other sites

Could be anything. Post the source for a diagnose.

 

Hi, I'm going to do more reading on sprites. I only got up to session 14 then skipped up to session 22, so I definately missed some important information. I cleaned it up the best I could, plus pulled out all my subroutine calls as soon as I learned that each one uses up 6 cycles to call, then 6 cycles to RTS. Yikes! Next I'm going to count the cycles and see if this is a timing issue which I think it is.

So, for anyone who may be interested here's my source. I appreciate any hints, but I'm not looking for a flat out answer.. that would take all the fun and learning out of it.

 


   processor 6502

   include vcs.h

   include macro.h

  ;set origin to the start of the 4k rom

    SEG

    ORG $F000


; vet up variables

YPosP0 = $80; first address in RAM

HeightP0 = $81

SpeedCounter = $83

ScanLineCount = $84



Reset



      ;Clear RAM and all TIA registers



       ldx #0

       lda #0

Clear   sta 0,x

       inx

       bne Clear

      ;total 9 bytes!





InitializeVariables

       lda #90

       sta YPosP0

       lda #186;we have 6 lines of playfield at the botton so

               ;192-6=186

       sta ScanLineCount
;EndInitializeVariables


;////////////////////////////////////////

StartOfFrame; Beginning of the game
;////////////////////////////////////////




;=====================================
; VerticalSync   ;top 3 scanlines

      ;using macro. this also stops vsync

       VERTICAL_SYNC
;=====================================






;=====================================
;VerticalBlank  ;37 scanlines

       ldx #37    ; 37 scanlines of vertical blank...

vblankloop

       sta WSYNC

       dex

       bne vblankloop


; check the joystick controls here
;;;;;;;;;;;;;;;
;MovePlayers
;;;;;;;;;;;;;;;



      ; for up and down, we INC or DEC

      ; the Y Position
; MoveDown

       LDA #%00010000 ;Down?

       BIT SWCHA

       BNE EndMoveDown

       LDA ScanLineCount

       CMP YPosP0

       BEQ ResetYDown

       INC YPosP0

       JMP EndMoveDown

ResetYDown

       LDA #11

       STA YPosP0



EndMoveDown


; MoveUp

       LDA #%00100000 ;Up?

       BIT SWCHA

       BNE EndMoveUp

       LDA #11

       CMP YPosP0

       BEQ ResetYUp

       DEC YPosP0

       JMP EndMoveUp

ResetYUp

       LDA ScanLineCount

       STA YPosP0



EndMoveUp


;assum horiz speed will be zero

   LDX #0


; MoveLeft

   LDA #%01000000 ;Left?

   BIT SWCHA

   BNE EndMoveLeft

   LDX #%00010000   ;a 1 in the left nibble means go left


;; moving left, so we need the mirror image

   LDA #%00001000  ;a 1 in D3 of REFP0 says make it mirror

   STA REFP0



EndMoveLeft


; MoveRight

   LDA #%10000000 ;Right?

   BIT SWCHA

   BNE EndMoveRight

   LDX #%11110000   ;a -1 in the left nibble means go right...


;; moving right, cancel any mirrorimage

   LDA #%00000000

   STA REFP0



EndMoveRight



   STX HMP0   ;set the move for player 0



  ;testing. trying to fix obstruction on left side of screen

   LDA WSYNC


;;;;;;;;;;;;;;;;
;EndMovePlayers
;;;;;;;;;;;;;;;;



       STX VBLANK


;EndVerticalBlank
;========================================






;========================================
;DrawScreen ;192 scanlines



      ;now you have 192 scanlines of picture 

      ;remember, that's 160 clocks / 3 = 53 cpu cycles
;RestoreGraphics

       LDA #$00

       STA COLUBK ; Set Background to Black

       LDA #15*8

       STA COLUPF

       LDA #1

       sta CTRLPF

       lda #$1C

       sta COLUP0

       lda #%00000101

       sta NUSIZ0
;end restore graphics


;paint image here

       LDY #0

       STY HeightP0;init height to zero

       LDX ScanLineCount;192-6=186 because we have 6 lines of playfield to draw

       sta WSYNC

       STA HMOVE;set the sprite in motion

loop

       sta WSYNC 

       LDA #0

       STA GRP0



       CPX YPosP0

       BNE SkipP0

       LDY #8

       STY HeightP0;if we are at the correct local, set the height

                      ;use this to determine if we should start

                      ;painting

SkipP0

       LDY HeightP0;put HeightP0 into Y for addressing

       BEQ FinishP0

IsP0

       LDA Player_0_up-1,Y;put a line of graphics into A

       STA GRP0; put the line of graphics into the graphics register

       DEC HeightP0; to decriment so we know when to stop

FinishP0;jump here if we are not painting

       DEX

       BNE loop



       

       LDA #0

       STA GRP0;turn off player graphics

       ldx #6

Draw_Picture_loop

       STA WSYNC 

       LDA Playfield_PF0-1,X

       STA PF0

       sta PF1

       sta PF2

       DEX

       bne Draw_Picture_loop



       LDA #%01000010     ; Disable TIA Output

       STA VBLANK
;EndDrawScreen
;================================






;================================

OverScan

      ;now you have 30 scanlines of overscan

      ;(2280 machine cycles, 6840 color clocks
;initialize graphics

       LDA     #$00   ; put $00 in A

       STA WSYNC 

       STA     PF0; clear out first playfield section

       STA     PF1; clear out second playfield section

       STA     PF2; clear out third playfield section

       STA     GRP0   ; clear out player graphic 0

       STA     GRP1   ; clear out player graphic 1

       STA     ENAM0  ; clear out missile 0

       STA     ENAM1  ; clear out missile 1

       STA     ENABL  ; clear out ball

       STA     COLUP0 ; set player 0 to black

       STA     COLUP1 ; set player 1 to black

       STA     COLUPF ; set playfield to black

       STA     COLUBK ; set background to black
;end initialize graphics

       

       LDX #29

       LDA #2



O1

       STA WSYNC 

       DEX

       BNE O1


;EndOverScan
;==================================


;///////////////////////////////////////
;go back to the beginning: 
;inifinate loop

       JMP StartOfFrame
;//////////////////////////////////////


;*****************************
;Graphics 
;*****************************



Playfield_PF0

   .byte #%10000001   ;

   .byte #%10000001   ;

   .byte #%01000010   ;

   .byte #%01000010   ;

   .byte #%00100100   ;

   .byte #%00011000   ;



Player_0_up

   .byte #%00001000

   .byte #%00011100

   .byte #%00111110

   .byte #%01111111

   .byte #%11111110

   .byte #%01111100

   .byte #%00111000

   .byte #%00010000



      ;this is the end. change origin to the end of the 4k rom

       org $FFFA

TheEnd

       .word Reset    ;NMI;used in 7800?

       .word Reset    ;RESET 

       .word Reset    ;IRQ;used in 7800?



      ;end of file

       END



Link to comment
Share on other sites

Hi there!

 

With a little re-arranging of your loop this'll work:

 


loop 

       LDA #0 

       CPX YPosP0 

       BNE SkipP0 

       LDY #8 

       STY HeightP0;if we are at the correct local, set the height 

                      ;use this to determine if we should start 

                      ;painting 

SkipP0 

       sta WSYNC 

       STA GRP0 



       LDY HeightP0;put HeightP0 into Y for addressing 

       BEQ FinishP0 

IsP0 

       LDA Player_0_up-1,Y;put a line of graphics into A 

       STA GRP0; put the line of graphics into the graphics register 

       DEC HeightP0; to decriment so we know when to stop 

FinishP0;jump here if we are not painting 

       DEX 

       BNE loop 

 

The write to GRP0 was just coming too late in the first line displaying your sprite, due to the extra cycles for setting HeightP0.

 

I think there is a lesson from Andrew regarding vertical positioning, you should definetely read that for getting a better idea of some more effective strategies for this.

 

Greetings,

Manuel

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...