Just Jeff Posted June 3, 2017 Share Posted June 3, 2017 Hi! I'm going to try to make a 2K old school, launch title type game. When I'm stuck, I'm trying to figure it out but I'll also post it here in with the hope that it might speed things up a bit. If you like debugging then go for it- it is appreciated! Right now I'm working on inserting a score kernel (Spiceware's). I got it mostly working, but something seems to be wrong with the indexing. Its supposed to display 12 34 but displays other numbers. Not sure if it has anything to do with decimal mode- I've turned it on and off with no effect. If I change the score- 12 and 34 to other numbers, again, it displays numbers, but not those numbers. Thanks! PROCESSOR 6502 ; paddle game ; 27 May 2017 ; ; ; paddle 1 = player 0 ;TIA_BASE_READ_ADDRESS = $30 include VCS.H include macro.h SEG.U VARS ORG $80 Paddle1: ds 1 DigitTens: ds 2 ScoreGfx: ds 2 DigitOnes: ds 2 Score: ds 2 Temp: ds 1 SEG CODE org $F000 InitSystem: CLEAN_START ;sed lda #12 sta Score lda #34 sta Score+1 ;cld sta COLUPF VerticalBlank: lda #$82 sta WSYNC sta VSYNC ; 3 start vertical sync, D1=1 sta VBLANK ; 3 6 start vertical blank and dump paddles to ground lda #$2C ; 2 8 set timer for end of Vertical Blank sta TIM64T ; 4 12 sta WSYNC ; 1st line of vertical sync sta WSYNC ; 2nd line of vertical sync lda #0 sta WSYNC ; 3rd line of vertical sync sta VSYNC ; stop vertical sync, D1=0 ldx #3 PosObjectLoop lda Paddle1 ;+4 9 sec ;;;;;;;;;;;;;;;;;;;Jeff added sta WSYNC DivideLoop sbc #15 bcs DivideLoop ;+4 13 eor #7 asl asl asl asl sta HMP0 ;+4 17 sta RESP0 ;+4 23 sta WSYNC sta HMOVE jsr PrepScoreForDisplay ;jeff added lda #$0f ; set color for paddle 1 display sta COLUP0 lda #153 ; prep paddle results with highest possible value sta Paddle1 ; our initial paddle results will be 1-153 ldx #0 VblankWait lda INTIM bpl VblankWait sta WSYNC sta HMCLR ; clear hmoves for next time around stx VBLANK ; turn on video output & remove paddle dump to ground ;------------------------------------------------------------------------ ; Score Loop ;------------------------------------------------------------------------ ldx #5 ; 2 11 - use X as the loop counter for ScoreLoop ;ldy #0 ; temp to test score ScoreLoop: ; 43 - cycle after bpl ScoreLoop ldy DigitTens ; 3 46 - get the tens digit offset for the Score lda DigitGfx,y ; 5 51 - use it to load the digit graphics and #$F0 ; 2 53 - remove the graphics for the ones digit sta ScoreGfx ; 3 56 - and save it ldy DigitOnes ; 3 59 - get the ones digit offset for the Score lda DigitGfx,y ; 5 64 - use it to load the digit graphics and #$0F ; 2 66 - remove the graphics for the tens digit ora ScoreGfx ; 3 69 - merge with the tens digit graphics sta ScoreGfx ; 3 72 - and save it sta WSYNC ; 3 75 - wait for end of scanline ;--------------------------------------- sta PF1 ; 3 3 - @66-28, update playfield for Score dislay ldy DigitTens+1 ; 3 6 - get the left digit offset for the Score+1 lda DigitGfx,y ; 5 11 - use it to load the digit graphics and #$F0 ; 2 13 - remove the graphics for the ones digit sta ScoreGfx+1 ; 3 16 - and save it ldy DigitOnes+1 ; 3 19 - get the ones digit offset for the Score+1 lda DigitGfx,y ; 5 24 - use it to load the digit graphics and #$0F ; 2 26 - remove the graphics for the tens digit ora ScoreGfx+1 ; 3 29 - merge with the tens digit graphics sta ScoreGfx+1 ; 3 32 - and save it nop ;12 44 - waste some cycles nop nop nop nop nop ; 2 44 sta PF1 ; 3 47 - @39-54, update playfield for Score+1 display ldy ScoreGfx ; 3 50 - preload for next scanline sta WSYNC ; 3 53 - wait for end of scanline ;--------------------------------------- sty PF1 ; 3 3 - update playfield for the Score display inc DigitTens ; 5 8 - advance for the next line of graphic data inc DigitTens+1 ; 5 13 - advance for the next line of graphic data inc DigitOnes ; 5 18 - advance for the next line of graphic data inc DigitOnes+1 ; 5 23 - advance for the next line of graphic data nop ;12 35 - waste some cycles nop nop nop nop nop dex ; 2 37 - decrease the loop counter sta PF1 ; 3 40 - @39-54, update playfield for the Score+1 display bne ScoreLoop ; 2 42 - (3 43) if dex != 0 then branch to ScoreLoop sta WSYNC ; 3 45 - wait for end of scanline ;--------------------------------------- stx PF1 ; 3 3 - x = 0, so this blanks out playfield sta WSYNC ; 3 6 - wait for end of scanline ;--------------------------------------- lda #0 ; 2 2 sta CTRLPF ; 3 5 - turn off SCORE mode ldx #1 ; 2 7 ;------------------------------------------------------------------------ ldy #152 ReadLoop sta WSYNC sty COLUBK lda INPT0 ; 3 - always 9 bpl .save ; 2 3 .byte $2c ; 4 0 .save sty Paddle1 ; 0 3 dey bne ReadLoop ; display Paddle 1's value by using Player 0 sta WSYNC lda #$FF sta GRP0 ldy #24 P0loop sta WSYNC dey bne P0loop lda #0 sta GRP0 lda #$26 ; prep overscan delay sta WSYNC sta TIM64T ; set overscan delay OSwait lda INTIM bpl OSwait jmp VerticalBlank ;=============================================================================== ; PrepScoreForDisplay ; -------------- ; Converts the high and low nybbles of the RAM variables Score and Score+1 ; into offsets into the digit graphics so the values can be displayed. ; Each digit uses 5 bytes of data for the graphics. For the low nybble we need ; to multiply by 5, but the 6507 does not have a multiply feature. It can, ; however, shift the bits in a byte left, which is the same as a multiply by 2. ; Using this, we can get multiply a # by 5 like this: ; # * 5 = (# * 2 * 2) + # ; The value in the upper nybble is already times 16, so we need to divide it. ; The 6507 can shift the bits the right, which is the same as divide by 2. ; (# / 16) * 5 = (# / 2 / 2) + (# / 2 / 2 / 2 / 2) ;=============================================================================== PrepScoreForDisplay: ldx #1 ; use X as the loop counter for PSFDloop PSFDloop: lda Score,x ; LoaD A with Score+1(first pass) or Score(second pass) and #$0F ; remove the tens digit sta Temp ; Store A into Temp asl ; asl ; Multiply by 5 adc Temp ; ADd with Carry value in Temp (# * 5) sta DigitOnes,x ; STore A in DigitOnes+1(first pass) or DigitOnes(second pass) lda Score,x ; LoaD A with Score+1(first pass) or Score(second pass) and #$F0 ; remove the ones digit lsr ; Logical Shift Right (# / 2) lsr ; Logical Shift Right (# / 4) sta Temp ; Store A into Temp lsr ; Logical Shift Right (# / lsr ; Logical Shift Right (# / 16) adc Temp ; ADd with Carry value in Temp ((# / 16) * 5) sta DigitTens,x ; STore A in DigitTens+1(first pass) or DigitTens(second pass) dex ; DEcrement X by 1 bpl PSFDloop ; Branch PLus (positive) to PSFDloop rts ; ReTurn from Subroutine ;=============================================================================== ; Digit Graphics ;=============================================================================== align 256 DigitGfx: .byte %00000111 .byte %00000101 .byte %00000101 .byte %00000101 .byte %00000111 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %01110111 .byte %00010001 .byte %01110111 .byte %01000100 .byte %01110111 .byte %01110111 .byte %00010001 .byte %00110011 .byte %00010001 .byte %01110111 .byte %01010101 .byte %01010101 .byte %01110111 .byte %00010001 .byte %00010001 .byte %01110111 .byte %01000100 .byte %01110111 .byte %00010001 .byte %01110111 .byte %01110111 .byte %01000100 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01110111 .byte %00010001 .byte %00010001 .byte %00010001 .byte %00010001 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01010101 .byte %01110111 .byte %01110111 .byte %01010101 .byte %01110111 .byte %00010001 .byte %01110111 .byte %00000000 ; used to blank out right score in 1 player games .byte %00000000 .byte %00000000 .byte %00000000 .byte %00000000 .byte %01010101 .byte %01010101 .byte %01010101 .byte %00000000 .byte %01010101 org $FFFA .word InitSystem ; NMI .word InitSystem ; RESET .word InitSystem ; IRQ JS.asm JS.bin Quote Link to comment Share on other sites More sharing options...
Just Jeff Posted June 3, 2017 Author Share Posted June 3, 2017 and 1 minute later I figure something out... commented the the RAM with their addresses and sure enough $87 & $88 contain the numbers displayed and the code in the debugger shows them too. My #12 and #34 has their hex values displayed- $0c 22. Quote Link to comment Share on other sites More sharing options...
+SpiceWare Posted June 3, 2017 Share Posted June 3, 2017 decimal 12 = $c decimal 34 = $22 Scores displays on the 2600 tend to use Binary Coded Decimal values. As such, you should use hex values when initializing your score to a specific value: lda #$12 sta Score lda #$34 sta Score+1 Likewise if you add 10 to your score you need to use $10. 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.