Jump to content
IGNORED

Problem with displaying the score


Recommended Posts

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

Link to comment
Share on other sites

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+,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

Link to comment
Share on other sites

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?

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