Re: [stella] Gas gauge - revisited

Subject: Re: [stella] Gas gauge - revisited
From: Joe Grand <jgrand@xxxxxxxxxxxxxx>
Date: Wed, 21 Mar 2001 22:57:54 -0500
Hi everyone-

It's been about a week since I got some comments about the gas guage..

I guess the alternating color idea wasn't such a good one. :) As you all noted, this would result in an orangish flicker. That would not be good.

I am experimenting with doing something like Manuel and Chris suggested, using a background color of red and the actual green gas gauge value in the PF. So far, it seems to be working.

Here was Manuel's post:

The easiest way would be faking it with the background color, like Chris

Let's say, you'd do a defined background color change during a scannline
like this:

<-- Green --><--------- normal BG color ------------> | Cycle X

Now, you'd always change the background color at the beginning of a
scannline and again on cycle X. Now you can easily draw a growing red PF
bar within the green bar.

My positioning of the gas guage is on the right side of the screen more like:

<-----------normal BG----------><-------Red--------><--normal BG-->

In this case, I assume the timing will need to be tight to get this to work, but that shouldn't be a problem. I don't really like the idea of having the gas guage all the over on one side or the other of the screen.

Anyway, attached is the source and the binary that I am currently playing with. Hopefully I'll make some more progress on this tonight - I don't think it will be too hard..

See ya.


Attachment: TEST.BIN
Description: Binary data

        processor 6502
        include vcs.h

Temp0   =       $80
MaxScr  EQU     $20

        ORG     $F800
Start:  SEI             ; Initialize the machine, set interrupt disable
        CLD             ; clear decimal mode
        LDX     #$FF    ; start X at $FF (255d)
        TXS             ; transfer it to the stack
        INX             ; set X to $00
        TXA             ; transfer it to the accumulator, A
        STA     0,X     ; store $00 at 0+X
        INX             ; increment X
        BNE     B1      ; if X is not zero yet, go back to @1
                        ; the above loop zeros out $00 to $FF
                        ; at this point X is $00
        LDA     #$04    ; number of lines alike
        STA     Temp0   ;

Top:                    ; Start a new screen
        ;LDA     #$05
        LDA     #$35
        STA     TIM64T  ; set timer for $05*$40 = $140 (320d) clocks

          ; do overscan stuff here

        LDA     #$00    ; put $00 in A
        STA     PF0     ; clear out first playfield section
        STA     PF1     ; clear out second playfield section
        STA     PF2     ; clear out third playfield section
        STA     GRP0    ; clear out player graphic 0
        STA     GRP1    ; clear out player graphic 1
        STA     ENAM0   ; clear out missile 0
        STA     ENAM1   ; clear out missile 1
        STA     ENABL   ; clear out ball
        STA     COLUP1  ; set player 1 to black
        STA     COLUP0  ; set player 0 to black
        STA     COLUBK  ; set background to black

          ;wait for overscan to finish, then start blanking

        LDA     INTIM   ; find current value of timer
        BNE     B2      ; if timer not zero, wait
                        ; when we get here, A will be $00
        LDY     #$02    ; this is 10000010b
        STY     WSYNC   ; wait for end of current line
        STY     VBLANK  ; start vertical, disable latches, dump orts
                        ; this is from the 10000010b
        STY     VSYNC   ; start vertical sync
        STY     WSYNC   ; send three lines while doing vertical sync
        STY     WSYNC
        STY     WSYNC
        STA     VSYNC   ; end vertical sync

         ;LDA     #$05    ; put $05 in A
        LDA     #$43
        STA     TIM64T  ; start VBLANK timer

        ; Setup the playfield graphics
        LDA     #%10111000 ; green
        STA     COLUPF

        JSR     Blank   ; do blanking stuff
        STA     WSYNC   ; one more line for good measure

; Draw the screen
; GOAL: draw 1 2 3 4 5 6 7 8 9 0 across screen in playfield graphics
; JOE'S NEW GOAL: draw multi-colored gas gauge in playfield graphics

        LDX     #100    ; position drawing vertically
        STA     WSYNC   ; wait for one line to be done
        DEX             ; decrease X by one
        BNE     PreDraw ; if not done with blank space, do another line
        LDX     #$00
        STA     WSYNC   ; wait for line to finish

        LDA     #%00110100 ; red
        STA     COLUBK  ; set background

        LDA     #$00
        STA     PF0
        STA     PF1
        STA     PF2

        ; First half of screen
        ;LDA     Table1,X ; get the Xth line for playfield 0
        ;STA     PF0      ; store it in playfield 0 register
        ;LDA     Table2,X ; get the Xth line for playfield 1
        ;STA     PF1      ; store it in playfield 1 register
        ;LDA     Table3,X ; get the Xth line for playfield 2
        ;STA     PF2      ; store it in playfield 2 register

        NOP             ; wait
        NOP             ; wait
        NOP             ; wait
        NOP             ; wait
        NOP             ; wait
        NOP             ; wait

        ; Second half of screen
        LDA     Table4,X ; get the Xth line for playfield 0
        STA     PF0      ; store it in playfield 0 register
        LDA     Table5,X ; get the Xth line for playfield 1
        STA     PF1      ; store it in playfield 1 register
        ;LDA     Table6,X ; get the Xth line for playfield 2
        ;STA     PF2      ; store it in playfield 2 register

        DEC     Temp0
        BNE     NxtLine
        LDA     #$04
        STA     Temp0   ; Temp0 is how many lines alike
        INX             ; increment X
        CPX     #$02    ; done with data yet? PF for gas gauge is only 2 bytes wide
        ;CPX     #$08
        BNE     NxtLine ; if not do next line

        STA     WSYNC
        LDA     #$00    ; get ready to clear playfield
        STA     PF0
        STA     PF1
        ;STA     PF2
        STA     COLUBK

        LDX     #71    ; get ready to finish screen (172 lines total)
        STA     WSYNC   ; do one line
        DEX             ; decrement counter
        BNE     Finish  ; if not on last line, do another one
        JMP     Top     ; done with this frame, go back to Top

        LDA     INTIM   ; find out current status of timer
        BNE     B3      ; if timer is zero, then done, otherwise check timer
        STA     WSYNC   ; A is $00, kick out another line
        STA     VBLANK  ; blank off, disable latches, remove dump

        org $FE00 ; *********************** GRAPHICS DATA

;Table1: .byte   $00, $00, $00, $00, $00, $00, $F0, $F0  ;PF0 left half (20 bits total)

        ;.word $6040
        ;.word $4040
        ;.word $00E0
        ;.word $0000

;Table2: .byte   $00, $00, $00, $00, $00, $00, $F0, $F0  ;PF1 left half

        ;.word $1177
        ;.word $4173
        ;.word $0077
        ;.word $0000

;Table3: .byte   $00, $00, $00, $00, $00, $00, $F0, $F0  ;PF2 left half

        ;.word $2AEA
        ;.word $88EE
        ;.word $00E8
        ;.word $0000

Table4: ;.byte   $00, $00, $00, $00, $00, $00, $F0, $F0  ;PF0 right half (20 bits total)
        .byte $F0, $F0

        ;.word $20E0
        ;.word $A0E0
        ;.word $00E0
        ;.word $0000

Table5: ;.byte   $00, $00, $00, $00, $00, $00, $FC, $FC  ;PF1 right half
        .byte $FC, $FC

        ;.word $1577
        ;.word $1517
        ;.word $0017
        ;.word $0000

;Table6: .byte   $00, $00, $00, $00, $00, $00, $00, $00  ;PF2 right half

        ;.word $AAEE
        ;.word $A8AE
        ;.word $00E8
        ;.word $0000

         ORG     $FFFC   ; vectors for 4k cart
        .word      Start   ; reset
        .word      Start   ; IRQ
Current Thread