Jump to content



0

player 0 and 1 are different sizes but using same data table


2 replies to this topic

#1 xucaen OFFLINE  

xucaen

    Star Raider

  • 94 posts
  • Looking for new owner for commodore 64
  • Location:Ma

Posted Sun Jan 23, 2005 11:48 PM

Hi, I'm playing with getting two sprites to display on the screen. For some reason the data that I load into GRP1 appears smaller on the screen than the same data loaded into GRP0. I don't understand why. I don't quite have cycle counting down yet so my timing could be off. I tested this with another example of mine that displays one sprite and a playfield. When I changed all GRP0 to GRP1 the sprite appeared smaller. Has anyone seen this sort of behaviour?


    processor 6502

    include vcs.h

    include macro.h

    

   ;set origin to the start RAM

   ;this is where variables are declared

     SEG.U vars;this declares Uninitialized space. i.e. RAM

               ; "vars" is the label. YOU NEED THIS!!

     ORG $80   ;$80 is the beginning of RAM


; vet up variables

YPosP0          ds 1

HeightP0        ds 1

YPosP1          ds 1

HeightP1        ds 1



       ;set origin to the start of the 4k rom

        SEG;this end the unitialized space and begins Initialized space

           ; i.e. ROM

        ORG $F000  ;$F000 is the beginning of ROM

                  

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

        sta YPosP1
;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...

    

        SLEEP 23

        STA RESP0;put player 0  at clock 68

        SLEEP 20

        STA RESP1  ;put player 1 at clock 130

vblankloop 

        sta WSYNC

        dex

        bne vblankloop



        LDX #0

        STX VBLANK


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






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



       ;now you have 192 scanlines of picture 

       ;remember, that's 228 clocks or 76 cpu cycles

        LDA #$00       ;2 (load immediate)

        STA COLUBK     ;3  [5] (store zero page); Set Background to Black

        STA COLUPF     ;3  [8]

        STA GRP0       ;3  [11]

        STA GRP1       ;3  [14]

        LDA #1         ;2  [16]

        sta CTRLPF     ;3  [19]

        lda #$1C       ;2  [21]

        sta COLUP0     ;3  [24]

        lda #$66       ;2  [26]

        sta COLUP1     ;3  [29]

        lda #%00000101 ;2  [31]

        sta NUSIZ0     ;3  [34]

        LDY #0         ;2  [36]

        STY HeightP0   ;3  [39]

        STY HeightP1   ;3  [42]

        

        LDX #191       ;2  [44]

        STA WSYNC

LoopScanLines

        LDA #0         ;2

        STA GRP0       ;3  [5]

        STA GRP1       ;3  [8]


;test player 0

        CPX YPosP0     ;3  [11]

        BNE EndP0      ;2+ [13][14];if not at Y position, then jump to end 

                                           ;else

        LDY #8         ;2  [15] ;load Y with Player 0 height

        STY HeightP0   ;3  [18]



EndP0

        
;do we draw player 0?

        LDY HeightP0   ;2  [20 if bne wasnot taken]

                       ;   [16 if bne was taken]

        

        BEQ EndDrawP0  ;2+ [22][18]  ;if heightP0 is zero we are done drawing

        LDA Player_0-1,Y;4+ [26][22]  ;else draw Player 0

        STA GRP0       ;3  [29][25]

        DEC HeightP0   ;5  [34][30]



EndDrawP0


;test player 1

        CPX YPosP1     ;3  [37][33]

        BNE EndP1      ;2+ [39][35]

        LDY #8         ;2  [41][37]

        STY HeightP1   ;3  [44][40]



EndP1

        
;do we draw player 1?

        LDY HeightP1   ;2  [46][42]

        BEQ EndDrawP1  ;2+ [48][44]

        LDA Player_0-1,Y;4+ [52]

        STA GRP1       ;3  [55]

        DEC HeightP1   ;5  [60]

        

EndDrawP1        



FinishP0 sta WSYNC     ;3  [63][51]

        DEX            ;2  ;jump here if we are not painting

        BNE LoopScanLines;2+



        LDA #2;#%01000010     ; Disable TIA Output

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






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

OverScan

       ;now you have 30 scanlines of overscan

       ;(2280 machine cycles, 6840 color clocks



        LDX #30

O1

        STA WSYNC 

        DEX

        BNE O1


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


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

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


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

Player_0

    .byte #%00001000

    .byte #%00010100

    .byte #%00100010

    .byte #%01000001

    .byte #%10000010

    .byte #%01000100

    .byte #%00101000

    .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




Jim

#2 Nukey Shay ONLINE  

Nukey Shay

    Sheik Yerbouti

  • 20,458 posts
  • Location:The land of Gorch

Posted Mon Jan 24, 2005 12:26 AM

You are setting P0's size register (NUSIZ0), but not P1's. Also, the display is sending 263 scanlines (which will roll the television in NTSC and not display colors in PAL). Adding a write to NUSIZ1 and reducing the scanline counter to 190 corrected both (tho P1 now has a missing pixel) :P

#3 xucaen OFFLINE  

xucaen

    Star Raider

  • 94 posts
  • Looking for new owner for commodore 64
  • Location:Ma

Posted Mon Jan 24, 2005 2:48 PM

Yikes! I remember in my playfield test, I set up NUSIZO because I wanted a larger sprite, then I forgot all about it! ::embarrassed:: I basically took my playfield source code and removed all the playfield and joystick code so I could start learning how to use RESPx and have 2 sprites. Thanks Nukey!

Jim




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users