Re: [stella] 6 digit score display and other ramblings

Subject: Re: [stella] 6 digit score display and other ramblings
From: Robin Harbron <macbeth@xxxxxxxxxxxxxxxxxxx>
Date: Sun, 15 Mar 1998 23:48:21 -0500
Erik Mooney wrote:

> The standard does a wsync on each line too, but it uses every one of the
> other 71 available cycles.  If we could get a look at your source, it'd be
> great.

Okay - it's just the same then - 3 cycles "spare" on each line, since
a WSYNC isn't necessary, as long as you've synced it up earlier, and
use exactly 76 cycles per line.  You did mean 73, not 71 cycles above,
right? :)

> 3 instructions * 2 cycles = 2 instructions * 3 cycles, last I checked :)
> If you're somehow doing a LDX instead of LDA, the stack-pointer method is
> faster.

Ah, I see what you mean... I needed a 2 cycle instruction to get new
data in any one of the 3 registers - txs is the only one I know of
that can do that.

> If you can, we'll love you for life :)  (Did anyone even get a 32-pixel
> movable sprite to work?  With color changes?  Using wsyncs?)

What sort of colour changes?  A unique colour for every scan line?  Or 
something fancier?  Of course, it's easy to get every 2nd 8 pixel chunk
a different colour :)  Why use wsyncs if they're not necessary?  Is
there
something I don't know?  Or is it just to show that there's at least 3
cycles free? :)

I would think that it would be pretty easy to move a big sprite around
_if_ you wrote individual routines to handle the whole bunch of cases.
There isn't enough time left over to make one general purpose loop.

Here's the whole source, minus the vcs.h equates.  Sorry about the
length, and the general sloppiness - you should see the source to
one of my C64 demos :/  Head right down to the startscore label to
see the beginning of the setup - then to mainloop for the actual
loop that does the 8 lines of score.

I know there's all sorts of suggestions that could be made - this
isn't a final product, and I'll do a lot of cleanup if this is ever
going to be included in a "real" program.  This was just the result
of a couple hours of experimentation.  There are many leftover
and inaccurate comments as well.

	 * = $1000
         ;my own equates

height   = 8

score    = $81 ; - $86 6 digits

ptr0     = $90
ptr1     = $92
ptr2     = $94
ptr3     = $96
ptr4     = $98
ptr5     = $9a
tmp      = $9c
count1   = $a0

         ;c64 code here
         jsr $0c00 ;call playbin
         jmp 384

         ;atari code starts here
         sei
         cld
         ldx #$ff
         txs

         ;gfx setup
         lda #0
         sta colubk


         ;initialize score value
         ldx #5
         lda #4 ;5 or greater
clr1     sta score,x
         clc
         adc #1
         dex
         bpl clr1

         ;clear data pointers
         ldx #11
         lda #0
clr2     sta ptr0,x
         dex
         bpl clr2


         lda #1
         sta ctrlpf ;$a

         lda #0
         sta $0281;joystick inputs

         sta wsync
         ldy #3
pos0     dey
         bne pos0
         sta resp0

main
         ;3 lines of 
         lda #2;on
         sta vsync
         sta wsync

         lda #%01000110
         sta colup0;colour

         sta vsync
         sta wsync
         sta vsync
         sta wsync
         lda #0;off
         sta vsync


         ;37 lines of 
         ldy #37
         lda #2 ;on
         sta vblank
dovblank sta wsync
         dey
         bne dovblank
         lda #0 ;off
         sta vblank

         lda #227
         sta tim64t

startscore
         ;make pointers to num data
         ldx #5
         ldy #10
loop2    lda score,x
         asl a
         asl a
         asl a
         adc #<zero
         sta ptr0,y
         lda #0
         adc #>zero
         sta ptr0+1,y
         dey
         dey
         dex
         bpl loop2



         lda #254 ;orange
         sta colup0
      ;   lda #%10001110 ;blue
         sta colup1

         lda #3
         sta nusiz0
         sta nusiz1 ;3 copies close
         sta wsync

         ldx #22
blah2    dex
         bne blah2
         sta resp0


         sta wsync
         ldx #22
blah1    dex
         bne blah1
         nop
         sta resp1
         sta hmclr
         lda #%10100000;2 more than belo
         sta hmp1
         lda #%11000000;
         sta hmp0
         sta wsync
         sta hmove
         sta wsync

         ;draw score
         lda #7
         sta count1

         ldx #10
pause1   dex
         bne pause1
         nop
         nop
         nop

mainloop ldy count1   ;3
         lda (ptr0),y ;5
         sta grp0     ;3 = 11

        ; sta wsync    ;3 =  3
         bit $00

         lda (ptr1),y ;5
         sta grp1     ;3
         lda (ptr5),y ;5
         tax          ;2
         txs          ;2
         lda (ptr2),y ;5
         sta tmp      ;3
         lda (ptr3),y ;5
         tax          ;2
         lda (ptr4),y ;5 = 37


         ldy tmp      ;3
         sty grp0     ;3
         stx grp1     ;3
         sta grp0     ;3
         tsx          ;2
         stx grp1     ;3 = 17

         dec count1   ;5
         bpl mainloop ;3 =  8

         lda #0
         sta grp0
         sta grp1

endoframe lda intim
         bne endoframe
         sta wsync


         ;30 lines of overscan
         lda #35
         sta $0296

         ;increase score
         ldx #5
scloop1  inc score,x
         lda score,x
         cmp #10
         bne scdone
         lda #0
         sta score,x
         dex
         bpl scloop1
scdone


cont     ;wait until overscan is over
         lda $0284
         bne cont
         nop
         nop
         sta $02

         jmp main

         *= $1200

zero     .byte %00111100
         .byte %01100010
         .byte %01010010
         .byte %01010010
         .byte %01001010
         .byte %01001010
         .byte %01000110
         .byte %00111100

one      .byte %01111110
         .byte %00011000
         .byte %00011000
         .byte %00011000
         .byte %00011000
         .byte %00011000
         .byte %00111000
         .byte %00011000

two      .byte %01111110
         .byte %00100000
         .byte %00010000
         .byte %00001000
         .byte %00000100
         .byte %00000010
         .byte %01000010
         .byte %00111100

three    .byte %00111100
         .byte %01000010
         .byte %00000010
         .byte %00011100
         .byte %00011100
         .byte %00000010
         .byte %01000010
         .byte %00111100

four     .byte %00001100
         .byte %00001100
         .byte %00001100
         .byte %01111110
         .byte %01001100
         .byte %00101100
         .byte %00011100
         .byte %00001100

five     .byte %00011000
         .byte %01100100
         .byte %00000010
         .byte %00000010
         .byte %01100100
         .byte %01011000
         .byte %01000000
         .byte %01111110

six      .byte %00111100
         .byte %01000010
         .byte %01000010
         .byte %01111100
         .byte %00100000
         .byte %00010000
         .byte %00001000
         .byte %00000100

seven    .byte %00001000
         .byte %00001000
         .byte %00001000
         .byte %00000100
         .byte %00000100
         .byte %00000010
         .byte %00000010
         .byte %01111110

eight    .byte %00111100
         .byte %01000010
         .byte %01000010
         .byte %00111100
         .byte %00111100
         .byte %01000010
         .byte %01000010
         .byte %00111100

nine     .byte %00111100
         .byte %00000010
         .byte %00000010
         .byte %00000010
         .byte %00111110
         .byte %01000010
         .byte %01000010
         .byte %00111100

         *= $1ffc
         .word $f000
         .word $f000


-- 
Robin Harbron    macbeth@xxxxxxxxxxx
   http://www.tbaytel.net/macbeth


--
Archives (includes files) at http://www.biglist.com/lists/stella/archives/
Unsub & more at http://www.biglist.com/lists/stella/stella.html
Don't post pirate BINs to Stellalist.  Be a programmer, not a pirate.
Write the best game, win framed autographs of famous Atari alumni!!

Current Thread