Jump to content

Photo

How could I add the score at the top of the screen?


3 replies to this topic

#1 Nico OFFLINE  

Nico

    Space Invader

  • 15 posts
  • Location:Argentina

Posted Wed May 30, 2012 10:16 AM

Hi, I would like to add the score at the top of the screen just like Combat or Video Olimpics does. I guess I should use PF1 to acomplish this right? but I cant seem to get the kernel to work. This is what I have so far:

					LDY #SCORE_HEIGHT
.scoreloop		  STA WSYNC
				   LDX #AMBAR+5
					TYA
					SEC
					SBC #SCORE_HEIGHT-10
					CMP #20
					BCC .drawnumber
					LDX #WHITE
.drawnumber		 STX COLUBK
					DEY
					BNE .scoreloop
				  
				   LDA #GREEN
				   STA COLUBK		  ; Playfield Backfround color
				  
					LDY #SCREEN_LINES-SCORE_HEIGHT
.screenloop		 STA WSYNC
					; Ball vertical position
					LDX #%00000010	; Set ball enable bit
					TYA			   ; Move line number to A
					SEC			   ; Set carry before subtracting
					SBC BallVPos	  ; Subtract ball start line
					CMP #BALL_HEIGHT  ; Test if line is in [0, BALL_HEIGHT-1]
					BCC .enableball   ; yes -> enable ball
					LDX #%00000000	; no -> clear ball enable bit
.enableball		 STX ENABL
					; Player 0 vertical position
					LDX #PLAYER_GFX
					TYA
					SEC
					SBC P0VPos
					CMP #PLAYER_HEIGHT
					BCC .enableP0
					LDX #0
.enableP0		   STX GRP0
					; Player 1 vertical position
					LDX #PLAYER_GFX				  
					TYA
					SEC
					SBC P1VPos
					CMP #PLAYER_HEIGHT
					BCC .enableP1
					LDX #0
.enableP1		   STX GRP1
					DEY
					BNE .screenloop

Basicly its two loops, one for the score and the other one to draw the paddles and the ball, is this the correct way of doing it?

#2 SvOlli OFFLINE  

SvOlli

    Chopper Commander

  • 151 posts
  • Location:Hannover, Germany

Posted Wed May 30, 2012 2:25 PM

Hi, I would like to add the score at the top of the screen just like Combat or Video Olimpics does. I guess I should use PF1 to acomplish this right? but I cant seem to get the kernel to work. This is what I have so far:
[...]
Basicly its two loops, one for the score and the other one to draw the paddles and the ball, is this the correct way of doing it?

I can't be of a complete help, since I've only done demos so far, but I can help you with showing the score. Drawing the playfield asymmetrically, what you need for displaying scores, is a bit tricky. This is your first step into the depth of the TIA, since you now also need horizontal timing additionally to your vertical timing.

The playfield data is displayed as 40 bits, but there are only 20 bits of registers. After displaying the first 20 bits, a bit in CTRLPF tells the TIA if the bit should be displayed again or in reverse order. You want to got with the first option, wait after PF1 gets drawn for the left half, then change the data to the values for the right half. At the beginning of the next line, you'll fill PF1 again with the data for the left half and so on...

CTRLPF also has a bit that toggles the color of the playfield from COLUPF to COLUP0 (left halt) and COLUP1 (right half), intended for drawing scores as used in Combat and many others.

#3 SpiceWare OFFLINE  

SpiceWare

    Quadrunner

  • 8,260 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Wed May 30, 2012 3:19 PM

Have you gone through the sub forum 2600 Programming For Newbies? yet? If not, I suggest you use the second pinned entry in that forum to follow the lessons in order.

Lesson 18 has a nice timing diagram that shows when you need to update the play field registers to display different things(like scores!) on both sides of the screen. I printed out a copy and reference it all the time when I'm working on my projects.

#4 Nico OFFLINE  

Nico

    Space Invader

  • Topic Starter
  • 15 posts
  • Location:Argentina

Posted Thu May 31, 2012 12:04 PM

ok, I'm going to do some reading to see how I can do this... thanks!




0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users