mirror of
https://github.com/michaelcmartin/Ophis.git
synced 2024-10-08 15:55:11 +00:00
778fbf7e2c
Add the color test program as a sample program. Also update the hi_stella example so that it runs properly when run in a Harmony cartridge.
152 lines
3.1 KiB
Plaintext
152 lines
3.1 KiB
Plaintext
.require "../../platform/stella.oph"
|
|
.outfile "hi_stella.bin"
|
|
|
|
.data
|
|
.org $0080
|
|
.space col'0 1
|
|
.space col'1 1
|
|
.space temp 1
|
|
.space counter 1
|
|
|
|
.text
|
|
.org $F800
|
|
|
|
reset: `clean'start
|
|
|
|
; Initialize the player sprites.
|
|
|
|
; We're going to use quad-sized players for our
|
|
; letters, and each one is 5 notional pixels wide.
|
|
; When we write RESP*, the start cycle after WSYNC
|
|
; determines the pixel it appears at with the
|
|
; formula 3N - 54 (minimum 1). Cycles 36 and 44
|
|
; get us close. We end up 4 pixels too far left.
|
|
|
|
; While we wait, we set up our sprites to be
|
|
; quad-sized and initialize the independent
|
|
; color-counters for each sprite.
|
|
|
|
sta WSYNC
|
|
lda #$07 ; +2= 2
|
|
sta NUSIZ0 ; +3= 5
|
|
sta NUSIZ1 ; +3= 8
|
|
lda #$20 ; +2=10
|
|
ldy #5 ; +2=12
|
|
* dey
|
|
bne - ; 17-22-27-32-36
|
|
sta RESP0 ; +3=39 (P0 at pixel 54)
|
|
sta col'0 ; +3=42
|
|
eor #$80 ; +2=44
|
|
sta RESP1 ; (P1 at pixel 78)
|
|
sta col'1
|
|
sta temp
|
|
lda #$C0 ; HMOVE us 4 right
|
|
sta HMP0
|
|
sta HMP1
|
|
sta WSYNC
|
|
sta HMOVE
|
|
|
|
frame: `vertical'sync
|
|
lda #43
|
|
sta TIM64T
|
|
|
|
; Advance the color bars once every fourth frame.
|
|
inc counter
|
|
lda #$03
|
|
bit counter
|
|
bne +
|
|
inc col'0
|
|
dec col'1
|
|
|
|
; Wait for VBLANK to finish, then turn off the VBLANK signal.
|
|
* lda INTIM
|
|
bne -
|
|
sta WSYNC
|
|
sta VBLANK
|
|
|
|
; Kernel. 78 blank lines on each side of
|
|
; a 36-line letter. The 'letter kernel' is a 4-line
|
|
; kernel at the top level, and expects .A and .X
|
|
; to have the player 0 and 1 colors at the start.
|
|
; We set those during the top wait, because why not.
|
|
lda col'0
|
|
ldx col'1
|
|
|
|
; Wait 78 lines for vertical placement...
|
|
ldy #78
|
|
* sta WSYNC
|
|
dey
|
|
bne -
|
|
|
|
; And draw the letter. This is a 4-line kernel, but
|
|
; the colors update every line. To keep that working
|
|
; we need to juggle the registers a bit. The accumulator
|
|
; _starts_ with P0's color, but it's needed to load the
|
|
; graphics, so we stash it in TEMP first.
|
|
ldy #9
|
|
* sta COLUP0
|
|
stx COLUP1
|
|
sta temp
|
|
lda hgr-1, y
|
|
sta GRP0
|
|
lda igr-1, y
|
|
sta GRP1
|
|
|
|
; Now, to make the lines update cleanly, we want a fast
|
|
; incrementer, but with two counters, we need to stash
|
|
; away .Y. Fortunately, the accumulator was just trashed
|
|
; by the graphics loads and so is available for this.
|
|
tya
|
|
ldy temp
|
|
inx
|
|
iny
|
|
sta WSYNC ; Go through three more lines,
|
|
sty COLUP0 ; updating the colors and bumping
|
|
stx COLUP1 ; the counters.
|
|
inx
|
|
iny
|
|
sta WSYNC
|
|
sty COLUP0
|
|
stx COLUP1
|
|
inx
|
|
iny
|
|
sta WSYNC
|
|
sty COLUP0
|
|
stx COLUP1
|
|
inx ; .X is only touched here, so we
|
|
iny ; can keep it around, but .Y is
|
|
sty temp ; our line count. Use temp again
|
|
tay ; to trade back .A and .Y, which
|
|
lda temp ; also preps .A for the color write
|
|
sta WSYNC ; at the top of the whole 4-line
|
|
dey ; loop.
|
|
bne -
|
|
|
|
; Clear out the player graphics...
|
|
lda #$00
|
|
sta GRP0
|
|
sta GRP1
|
|
|
|
; Wait 78 lines for the rest of the screen...
|
|
ldy #78
|
|
* sta WSYNC
|
|
dey
|
|
bne -
|
|
|
|
; Turn on VBLANK, do 30 lines of Overscan
|
|
lda #$02
|
|
sta VBLANK
|
|
ldy #30
|
|
* sta WSYNC
|
|
dey
|
|
bne -
|
|
jmp frame ; And the frame is done, back to VSYNC.
|
|
|
|
; Graphics for the letters.
|
|
hgr: .byte $88,$88,$88,$88,$f8,$88,$88,$88,$88
|
|
igr: .byte $f8,$20,$20,$20,$20,$20,$20,$20,$f8
|
|
|
|
; Interrupt vectors.
|
|
.advance $FFFA
|
|
.word reset, reset, reset
|