Jump to content



0

Problem with displaying the score


5 replies to this topic

#1 Kevin Holditch OFFLINE  

Kevin Holditch

    Combat Commando

  • 5 posts

Posted Fri Sep 30, 2011 12:06 PM

I am having trouble trying to display a score in my Atari game. After quite a few evenings of hard toil I've managed to work out the code to read the digits from my memory map and load them into variables ready to be drawn in the game loop.

My aim is to draw the score at the top of the screen using the sprite registers. My code is as follows:


ldy #8

TopBar sta WSYNC
lda (digtwo),y
sta GRP0

lda (digone),y
sta HMOVE
sta GRP1

dey
bne TopBar

The above code works as far as the digits are drawn to the screen correctly however the digits are widely spaced and I want to put them close together in the centre. Then if it's not asking too much display my other digits too.

Can anyone help me with how to position the digits correctly? Thanks in advance

#2 GroovyBee OFFLINE  

GroovyBee

    7800 Developer

  • 5,782 posts
  • Busy bee!
  • Location:North, England

Posted Fri Sep 30, 2011 12:35 PM

Search the Stella mailing list and the AA programming forums for six digit score. Its been covered plenty of times.

#3 Kevin Holditch OFFLINE  

Kevin Holditch

    Combat Commando

  • 5 posts

Posted Tue Oct 4, 2011 1:09 AM

I can find loads of examples of how to calculate the score but none on displaying the 6 digits, unless I'm missing something? Can you provide me with a link please?

#4 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 5,991 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Tue Oct 4, 2011 11:39 AM

Have you checked MiniDig?

Checking the Comsic Ark disassembly (could also check the others) you'll find this routine that utilizes the standard 48 pixel routine to display the score:

.drawScore:
	lda	#BROWN+4		 ; 2			 set score color
	and	colorMask		; 3
	sta	COLUP1		   ; 3
	sta	COLUP0		   ; 3
	lda	#BLUE+4		  ; 2			 set frame color
	and	colorMask		; 3
	sta	COLUPF		   ; 3
	lda	#%01			 ; 2			 enable PF reflection
	sta	CTRLPF		   ; 3
	lda	#THREE_COPIES	; 2
	sta	NUSIZ0		   ; 3
	sta	NUSIZ1		   ; 3
	ldy	#5			   ; 2
	sta	WSYNC			; 3
;------------------------------
	lda	#$ff			 ; 2			 draw top of frame around digits
	sta	PF2			  ; 3
 
;position score sprites:
.delayPos:
	dey					 ; 2
	bpl	.delayPos		; 2³
	nop					 ; 2
	sta	RESP0			; 3
	sta	RESP1			; 3
	lda	#$f0			 ; 2
	sta	HMP0			 ; 3
	ldx	#$00			 ; 2
	stx	HMP1			 ; 3
	inx					 ; 2
	stx	VDELP0		   ; 3
	stx	VDELP1		   ; 3
	sta	WSYNC			; 3
	sta	HMOVE			; 3
	stx	PF2			  ; 3
	sta	WSYNC			; 3
;------------------------------
;draw score:
	lda	#DIGIT_HEIGHT-1  ; 2			 48 pixel routine
	sta	tempVar2		 ; 3
.digitLoop:
	ldy	tempVar2		 ; 3
	lda	(digitPtr),y	 ; 5
	sta	GRP0			 ; 3
	sta	WSYNC			; 3
;------------------------------
	lda	(digitPtr+2),y   ; 5
	sta	GRP1			 ; 3
	lda	(digitPtr+4),y   ; 5
	sta	GRP0			 ; 3
	lda	(digitPtr+6),y   ; 5
	sta	tempVar		  ; 3
	lda	(digitPtr+8),y   ; 5
	tax					 ; 2
	lda	(digitPtr+10),y  ; 5
	tay					 ; 2
	lda	tempVar		  ; 3
	sta	GRP1			 ; 3
	stx	GRP0			 ; 3
	sty	GRP1			 ; 3
	sty	GRP0			 ; 3
	dec	tempVar2		 ; 5
	bpl	.digitLoop	   ; 2³
	ldx	#$00			 ; 2
	sta	WSYNC			; 3
;------------------------------
	stx	GRP0			 ; 3
	stx	GRP1			 ; 3


#5 Kevin Holditch OFFLINE  

Kevin Holditch

    Combat Commando

  • 5 posts

Posted Tue Oct 11, 2011 3:21 PM

Thanks a lot for this. With a bit of jiggery pokery I've managed to port the code (more or less) and get it to work (only 2 digits at the moment but positioning is correct). I'm still not 100% sure how a bit of this code works though. I understand mapping the digits in memory. What I think it's doing is setting each sprite to have 3 copies on the screen and then quickly changing the contents of the register in before each copy can be drawn, hence the reason you get 3 different instances of each sprite and hence 6 digits on the screen. Is that more or less right?

#6 SpiceWare ONLINE  

SpiceWare

    Quadrunner

  • 5,991 posts
  • Medieval Mayhem
  • Location:Planet Houston

Posted Tue Oct 11, 2011 4:38 PM

That's the gist of it - the tricky part is it only works because of VDELP0 and VDELP1. There's a post in the old stella mailing list that helped me to understand how it worked.

<google>

http://www.biglist.c...4/msg00137.html




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users