Kevin Holditch Posted September 30, 2011 Share Posted September 30, 2011 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 Quote Link to comment Share on other sites More sharing options...
GroovyBee Posted September 30, 2011 Share Posted September 30, 2011 Search the Stella mailing list and the AA programming forums for six digit score. Its been covered plenty of times. Quote Link to comment Share on other sites More sharing options...
Kevin Holditch Posted October 4, 2011 Author Share Posted October 4, 2011 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? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted October 4, 2011 Share Posted October 4, 2011 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 Quote Link to comment Share on other sites More sharing options...
Kevin Holditch Posted October 11, 2011 Author Share Posted October 11, 2011 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? Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted October 11, 2011 Share Posted October 11, 2011 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 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.