|
Subject: Ten digit playfield routine, was: [stella] 20 columns of almost-readabletext From: Jake Patterson <jpatters@xxxxxxxxxxx> Date: Fri, 14 Sep 2001 03:07:21 -0400 (EDT) |
On Thu, 13 Sep 2001, B. Watson wrote: > > This is what I spent last night doing, to get my mind off the terrorist > bombings (there's nothing I can do to change the situation right now, so > obsessing over it isn't helping me sleep...) > Well, I guess I had similar ideas for how to cope... you managed to outdo my efforts, however. All I came up with is a ten digit numerical playfield routine. There is no flicker, but it is interlaced in more or less the same way as the scores in Space Invaders. It simply displays the even placed digits on even scanlines and the odd placed digits on odd scan lines. I set it up to count frames like an odometer. It could probably be adapted to alphanumerics fairly easily. There is enough time left over to read a color for each pair of scan lines from a table. The digit bitmaps are also read from a table, 205 byts of ROM for the tables, plus considerably more for the code, since the kernel is partially unwrapped. Source and two bins attached, the second bin, slodometer.bin, simply counts every 32 frames. The faster, odometer.bin, would take a little over five years to roll over all ten digits, at 60 frames per second, or just under 1 year at 340 frames per second, which is the fastest that MacStella can manage on my computer.
; Ten digit display routine, counts frames.
; Thursday, September 13, 2001
; By Jake Patterson
;
; Somewhat derived from:
; How to Draw A Playfield.
; by Nick Bensema 9:23PM 3/2/97
;
processor 6502
include vcs.h
org $F000
Temp = $80
Firstdigit = $90
Seconddigit = $91
Thirddigit = $92
Fourthdigit = $93
Fifthdigit = $94
Sixthdigit = $95
Seventhdigit = $96
Eigthdigit = $97
Ninthdigit = $98
Tenthdigit = $99
Framethingie = $9A
Start
SEI ; Disable interrupts, if there are any.
CLD ; Clear BCD math bit.
LDX #$FF
TXS ; Set stack to beginning.
LDA #0
B1 STA 0,X
DEX
BNE B1
LDA #8
STA Framethingie
; *****************************************************************************
MainLoop
; *****************************************************************************
JSR VerticalBlank ;Execute the vertical blank.
JSR CheckSwitches ;Check Console Switches.
JSR DrawScreen ;Draw the screen
JSR OverScan ;Do more calculations during overscan
JMP MainLoop ;Continue forever.
; *****************************************************************************
VerticalBlank
; *****************************************************************************
LDX #0
LDA #2
STA WSYNC
STA WSYNC
STA WSYNC
STA VSYNC ;Begin vertical sync.
STA WSYNC ; First line of VSYNC
STA WSYNC ; Second line of VSYNC.
LDA #44
STA TIM64T
LDA #0
STA CXCLR
STA WSYNC ; Third line of VSYNC.
STA VSYNC ; (0)
RTS
; *****************************************************************************
CheckSwitches
; *****************************************************************************
LDA #$0000
STA PF0
STA PF1
STA PF2
STA COLUPF
STA COLUBK
RTS
; *****************************************************************************
DrawScreen
; *****************************************************************************
; *************************************** 0th through 51st scanlines (52 total)
LDY #51
SplashTopLines
LDA #0
STA COLUBK
STA COLUPF
STA PF0
STA PF1
STA PF2
STA WSYNC
DEY
BNE SplashTopLines
; ************************************** 52nd through 71st scanlines (20 total)
LDY #2
FirstLineLoop
STA WSYNC ; [59]
LDA FirstLineColor ; [0] + 4
STA COLUPF ; [4] + 3
LDX Firstdigit ; [7] + 3
LDA FirstLinePF0Right,X ; [10] + 4
STA PF0 ; [14] + 3
LDX Thirddigit ; [17] + 3
LDA FirstLinePF1Right,X ; [20] + 4
STA PF1 ; [24] + 3
LDX Fifthdigit ; [27] + 3
LDA FirstLinePF0Right,X ; [30] + 4
STA PF2 ; [34] + 3
LDA #0 ; [37] + 2
STA PF0 ; [39] + 3
LDX Seventhdigit ; [42] + 3
LDA FirstLinePF1Left,X ; [45] + 4
STA PF1 ; [49] + 3
LDX Ninthdigit ; [52] + 3
LDA FirstLinePF2Left,X ; [55] + 4
STA PF2 ; [59] + 3
STA WSYNC ; [62]
LDX Seconddigit ; [0] + 3
LDA FirstLinePF1Left,X ; [3] + 4
STA PF1 ; [7] + 3
LDX Fourthdigit ; [10] + 3
LDA FirstLinePF2Left,X ; [13] + 4
STA PF2 ; [17] + 3
LDX Sixthdigit ; [20] + 3
LDA FirstLinePF0Right,X ; [23] + 4
NOP ; [27] + 2
STA PF0 ; [29] + 3
LDX Eigthdigit ; [32] + 3
LDA FirstLinePF1Right,X ; [35] + 4
NOP ; [39] + 2
STA PF1 ; [41] + 3
LDX Tenthdigit ; [44] + 3
LDA FirstLinePF0Right,X ; [47] + 4
STA PF2 ; [51] + 3
DEY ; [54] + 2
BNE FirstLineLoop ; [56] + 3
; *****************************************************************************
LDY #2
SecondLineLoop
STA WSYNC ; [59]
LDA SecondLineColor ; [0] + 4
STA COLUPF ; [7] + 3
LDX Firstdigit ; [7] + 3
LDA SecondLinePF0Right,X ; [10] + 4
STA PF0 ; [14] + 3
LDX Thirddigit ; [17] + 3
LDA SecondLinePF1Right,X ; [20] + 4
STA PF1 ; [24] + 3
LDX Fifthdigit ; [27] + 3
LDA SecondLinePF0Right,X ; [30] + 4
STA PF2 ; [34] + 3
LDA #0 ; [37] + 2
STA PF0 ; [39] + 3
LDX Seventhdigit ; [42] + 3
LDA SecondLinePF1Left,X ; [45] + 4
STA PF1 ; [49] + 3
LDX Ninthdigit ; [52] + 3
LDA SecondLinePF2Left,X ; [55] + 4
STA PF2 ; [59] + 3
STA WSYNC ; [62]
LDX Seconddigit ; [0] + 3
LDA SecondLinePF1Left,X ; [3] + 4
STA PF1 ; [7] + 3
LDX Fourthdigit ; [10] + 3
LDA SecondLinePF2Left,X ; [13] + 4
STA PF2 ; [17] + 3
LDX Sixthdigit ; [20] + 3
LDA SecondLinePF0Right,X ; [23] + 4
NOP ; [27] + 2
STA PF0 ; [29] + 3
LDX Eigthdigit ; [32] + 3
LDA SecondLinePF1Right,X ; [35] + 4
NOP ; [39] + 2
STA PF1 ; [41] + 3
LDX Tenthdigit ; [44] + 3
LDA SecondLinePF0Right,X ; [47] + 4
STA PF2 ; [51] + 3
DEY ; [54] + 2
BNE SecondLineLoop ; [56] + 3
; *****************************************************************************
LDY #2
ThirdLineLoop
STA WSYNC ; [59]
LDA ThirdLineColor ; [0] + 4
STA COLUPF ; [4] + 3
LDX Firstdigit ; [7] + 3
LDA ThirdLinePF0Right,X ; [10] + 4
STA PF0 ; [14] + 3
LDX Thirddigit ; [17] + 3
LDA ThirdLinePF1Right,X ; [20] + 4
STA PF1 ; [24] + 3
LDX Fifthdigit ; [27] + 3
LDA ThirdLinePF0Right,X ; [30] + 4
STA PF2 ; [34] + 3
LDA #0 ; [37] + 2
STA PF0 ; [39] + 3
LDX Seventhdigit ; [42] + 3
LDA ThirdLinePF1Left,X ; [45] + 4
STA PF1 ; [49] + 3
LDX Ninthdigit ; [52] + 3
LDA ThirdLinePF2Left,X ; [55] + 4
STA PF2 ; [59] + 3
STA WSYNC ; [62]
LDX Seconddigit ; [0] + 3
LDA ThirdLinePF1Left,X ; [3] + 4
STA PF1 ; [7] + 3
LDX Fourthdigit ; [10] + 3
LDA ThirdLinePF2Left,X ; [13] + 4
STA PF2 ; [17] + 3
LDX Sixthdigit ; [20] + 3
LDA ThirdLinePF0Right,X ; [23] + 4
NOP ; [27] + 2
STA PF0 ; [29] + 3
LDX Eigthdigit ; [32] + 3
LDA ThirdLinePF1Right,X ; [35] + 4
NOP ; [39] + 2
STA PF1 ; [41] + 3
LDX Tenthdigit ; [44] + 3
LDA ThirdLinePF0Right,X ; [47] + 4
STA PF2 ; [51] + 3
DEY ; [54] + 2
BNE ThirdLineLoop ; [56] + 3
; *****************************************************************************
LDY #2
FourthLineLoop
STA WSYNC ; [59]
LDA FourthLineColor ; [0] + 4
STA COLUPF ; [4] + 3
LDX Firstdigit ; [7] + 3
LDA FourthLinePF0Right,X ; [10] + 4
STA PF0 ; [14] + 3
LDX Thirddigit ; [17] + 3
LDA FourthLinePF1Right,X ; [20] + 4
STA PF1 ; [24] + 3
LDX Fifthdigit ; [27] + 3
LDA FourthLinePF0Right,X ; [30] + 4
STA PF2 ; [34] + 3
LDA #0 ; [37] + 2
STA PF0 ; [39] + 3
LDX Seventhdigit ; [42] + 3
LDA FourthLinePF1Left,X ; [45] + 4
STA PF1 ; [49] + 3
LDX Ninthdigit ; [52] + 3
LDA FourthLinePF2Left,X ; [55] + 4
STA PF2 ; [59] + 3
STA WSYNC ; [62]
LDX Seconddigit ; [0] + 3
LDA FourthLinePF1Left,X ; [3] + 4
STA PF1 ; [7] + 3
LDX Fourthdigit ; [10] + 3
LDA FourthLinePF2Left,X ; [13] + 4
STA PF2 ; [17] + 3
LDX Sixthdigit ; [20] + 3
LDA FourthLinePF0Right,X ; [23] + 4
NOP ; [27] + 2
STA PF0 ; [29] + 3
LDX Eigthdigit ; [32] + 3
LDA FourthLinePF1Right,X ; [35] + 4
NOP ; [39] + 2
STA PF1 ; [41] + 3
LDX Tenthdigit ; [44] + 3
LDA FourthLinePF0Right,X ; [47] + 4
STA PF2 ; [51] + 3
DEY ; [54] + 2
BNE FourthLineLoop ; [56] + 3
; *****************************************************************************
LDY #2
FifthLineLoop
STA WSYNC ; [59]
LDA FifthLineColor ; [0] + 4
STA COLUPF ; [4] + 3
LDX Firstdigit ; [7] + 3
LDA FifthLinePF0Right,X ; [10] + 4
STA PF0 ; [14] + 3
LDX Thirddigit ; [17] + 3
LDA FifthLinePF1Right,X ; [20] + 4
STA PF1 ; [24] + 3
LDX Fifthdigit ; [27] + 3
LDA FifthLinePF0Right,X ; [30] + 4
STA PF2 ; [34] + 3
LDA #0 ; [37] + 2
STA PF0 ; [39] + 3
LDX Seventhdigit ; [42] + 3
LDA FifthLinePF1Left,X ; [45] + 4
STA PF1 ; [49] + 3
LDX Ninthdigit ; [52] + 3
LDA FifthLinePF2Left,X ; [55] + 4
STA PF2 ; [59] + 3
STA WSYNC ; [62]
LDX Seconddigit ; [0] + 3
LDA FifthLinePF1Left,X ; [3] + 4
STA PF1 ; [7] + 3
LDX Fourthdigit ; [10] + 3
LDA FifthLinePF2Left,X ; [13] + 4
STA PF2 ; [17] + 3
LDX Sixthdigit ; [20] + 3
LDA FifthLinePF0Right,X ; [23] + 4
NOP ; [27] + 2
STA PF0 ; [29] + 3
LDX Eigthdigit ; [32] + 3
LDA FifthLinePF1Right,X ; [35] + 4
NOP ; [39] + 2
STA PF1 ; [41] + 3
LDX Tenthdigit ; [44] + 3
LDA FifthLinePF0Right,X ; [47] + 4
STA PF2 ; [51] + 3
DEY ; [54] + 2
BNE FifthLineLoop ; [56] + 3
STA WSYNC
; ************************************ 72nd through 191st scanlines (120 total)
; the incrimentor always does 9 scan lines.
LDY #0
STY COLUBK
STY COLUPF
STY PF0
STY PF1
STY PF2
DEC Framethingie
BEQ IncFirstDigit
JMP RemainingLines
IncFirstDigit
LDA #1
STA Framethingie
LDA Tenthdigit
SBC #8
BEQ IncSecondDigit
INC Tenthdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncSecondDigit
STY Tenthdigit
STA WSYNC
LDA Ninthdigit
SBC #9
BEQ IncThirdDigit
INC Ninthdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncThirdDigit
STY Ninthdigit
STA WSYNC
LDA Eigthdigit
SBC #9
BEQ IncFourthDigit
INC Eigthdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncFourthDigit
STY Eigthdigit
STA WSYNC
LDA Seventhdigit
SBC #9
BEQ IncFifthDigit
INC Seventhdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncFifthDigit
STY Seventhdigit
STA WSYNC
LDA Sixthdigit
SBC #9
BEQ IncSixthDigit
INC Sixthdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncSixthDigit
STY Sixthdigit
STA WSYNC
LDA Fifthdigit
SBC #9
BEQ IncSeventhDigit
INC Fifthdigit
STA WSYNC
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncSeventhDigit
STY Fifthdigit
STA WSYNC
LDA Fourthdigit
SBC #9
BEQ IncEigthDigit
INC Fourthdigit
STA WSYNC
STA WSYNC
STA WSYNC
JMP RemainingLines
IncEigthDigit
STY Fourthdigit
STA WSYNC
LDA Thirddigit
SBC #9
BEQ IncNinthDigit
INC Thirddigit
STA WSYNC
STA WSYNC
JMP RemainingLines
IncNinthDigit
STY Thirddigit
STA WSYNC
LDA Seconddigit
SBC #9
BEQ IncTenthDigit
INC Seconddigit
STA WSYNC
JMP RemainingLines
IncTenthDigit
STY Seconddigit
STA WSYNC
LDA Firstdigit
SBC #9
BEQ Rollover
INC Firstdigit
JMP RemainingLines
Rollover ; this should only happen if this program is allowed to
; run continuously for something like 6 years.
STY Firstdigit
RemainingLines
LDY #111
RemainingLinesLoop
STA WSYNC
DEY
BNE RemainingLinesLoop
; *****************************************************************************
LDA #$0000
STA PF0
STA PF1
STA PF2
STA COLUPF
STA COLUBK
RTS
; *****************************************************************************
OverScan
; *****************************************************************************
LDX #30
KillLines
STA WSYNC
DEX
BNE KillLines
RTS
; *****************************************************************************
; Graphics Data
; *****************************************************************************
org $FF00 ; 40 x 5 + 5 = 205 bytes in this page so far, 252 max *****
FirstLineColor .byte $82
SecondLineColor .byte $84
ThirdLineColor .byte $86
FourthLineColor .byte $88
FifthLineColor .byte $8A
; *****************************************************************************
FirstLinePF0Right ; 10 x 4 = 40 bytes
.byte %01000000, %01000000, %01000000, %01100000, %10100000
.byte %11100000, %01000000, %11100000, %01000000, %01000000
FirstLinePF1Left
.byte %00100000, %00100000, %00100000, %01100000, %01010000
.byte %01110000, %00100000, %01110000, %00100000, %00100000
FirstLinePF1Right
.byte %00000010, %00000010, %00000010, %00000110, %00000101
.byte %00000111, %00000010, %00000111, %00000010, %00000010
FirstLinePF2Left
.byte %00000100, %00000100, %00000100, %00000110, %00001010
.byte %00001110, %00000100, %00001110, %00000100, %00000100
; *****************************************************************************
SecondLinePF0Right ; 10 x 4 = 40 bytes
.byte %10100000, %01100000, %10100000, %10000000, %10100000
.byte %00100000, %00100000, %10000000, %10100000, %10100000
SecondLinePF1Left
.byte %01010000, %01100000, %01010000, %00010000, %01010000
.byte %01000000, %01000000, %00010000, %01010000, %01010000
SecondLinePF1Right
.byte %00000101, %00000110, %00000101, %00000001, %00000101
.byte %00000100, %00000100, %00000001, %00000101, %00000101
SecondLinePF2Left
.byte %00001010, %00000110, %00001010, %00001000, %00001010
.byte %00000010, %00000010, %00001000, %00001010, %00001010
; *****************************************************************************
ThirdLinePF0Right ; 10 x 4 = 40 bytes
.byte %10100000, %01000000, %10000000, %11000000, %11100000
.byte %01100000, %01100000, %01000000, %01000000, %11000000
ThirdLinePF1Left
.byte %01010000, %00100000, %00010000, %00110000, %01110000
.byte %01100000, %01100000, %00100000, %00100000, %00110000
ThirdLinePF1Right
.byte %00000101, %00000010, %00000001, %00000011, %00000111
.byte %00000110, %00000110, %00000010, %00000010, %00000011
ThirdLinePF2Left
.byte %00001010, %00000100, %00001000, %00001100, %00001110
.byte %00000110, %00000110, %00000100, %00000100, %00001100
; *****************************************************************************
FourthLinePF0Right ; 10 x 4 = 40 bytes
.byte %10100000, %01000000, %01000000, %10000000, %10000000
.byte %10000000, %10100000, %01000000, %10100000, %10000000
FourthLinePF1Left
.byte %01010000, %00100000, %00100000, %00010000, %00010000
.byte %00010000, %01010000, %00100000, %01010000, %00010000
FourthLinePF1Right
.byte %00000101, %00000010, %00000010, %00000001, %00000001
.byte %00000001, %00000101, %00000010, %00000101, %00000001
FourthLinePF2Left
.byte %00001010, %00000100, %00000100, %00001000, %00001000
.byte %00001000, %00001010, %00000100, %00001010, %00001000
; *****************************************************************************
FifthLinePF0Right ; 10 x 4 = 40 bytes
.byte %01000000, %11100000, %11100000, %01100000, %10000000
.byte %01100000, %01000000, %01000000, %01000000, %01000000
FifthLinePF1Left
.byte %00100000, %01110000, %01110000, %01100000, %00010000
.byte %01100000, %00100000, %00100000, %00100000, %00100000
FifthLinePF1Right
.byte %00000010, %00000111, %00000111, %00000110, %00000001
.byte %00000110, %00000010, %00000010, %00000010, %00000010
FifthLinePF2Left
.byte %00000100, %00001110, %00001110, %00000110, %00001000
.byte %00000110, %00000100, %00000100, %00000100, %00000100
; *****************************************************************************
org $FFFC
.word Start
.word Start
org $FF00Attachment:
odometer.bin
Description: odometer.bin
Attachment:
slodometer.bin
Description: slodometer.bin
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [stella] 20 columns of almost-reada, B. Watson | Thread | Re: Ten digit playfield routine, wa, B. Watson |
| [stella] 20 columns of almost-reada, B. Watson | Date | [stella] Tune2600 v0.5, Thomas Jentzsch |
| Month |