VBL experiments

This commit is contained in:
blondie7575 2017-08-09 19:33:52 -07:00
parent 0a6c36c9b4
commit 3c43a0bc78
6 changed files with 126 additions and 7 deletions

Binary file not shown.

View File

@ -30,6 +30,38 @@ colorFillLoop:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; bottomFill
; Fills the bottom of the screen with a color (or two). Pretty fast, but not fastest possible
; A 4:4:4:4 = Palette entries
; X = Color to fill (doubled)
;
; Trashes Y
bottomFill:
FASTGRAPHICS
lda #$9d00-1 ; Point stack to end of VRAM
tcs
ldy #58
bottomFillLoop:
; 80 PHXs, for 1 line
; We could do the entire screen with PHXs, but this is a
; balance between speed and super-verbose code
.byte $da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da
.byte $da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da
.byte $da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da
.byte $da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da,$da
dey
bne bottomFillLoop
SLOWGRAPHICS
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; initSCBs
; Initialize all scanline control bytes
@ -107,6 +139,58 @@ setPaletteLoop:
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Vertical blank checkers
;
; The Brutal Deluxe version, taken from LemminGS
;
nextVBL:
lda #75
pha
nextVBL0:
lda $e0c02e
and #$7f
cmp 1,s
blt nextVBL0
cmp #100
bge nextVBL0
pla
waitVBL:
lda $e0c018
bpl waitVBL
rts
; The Apple version, taken from GS Tech Note 039
;
syncVBL:
BITS8
syncVBL0:
lda $E0C02F
asl ; VA is now in the Carry flag
lda $E0C02E
rol ; Roll Carry into bit 0
cmp #200 ; A now contains line number
bne syncVBL0
BITS16
rts
; The old style //e version
;
vblSync:
BITS8
waitVBLToFinish:
lda $E0C019
bmi waitVBLToFinish
waitVBLToStart:
lda $E0C019
bpl waitVBLToStart
BITS16
rts
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; caches
shadowRegister:

Binary file not shown.

View File

@ -32,9 +32,35 @@ mainBank2:
jsr generateTerrain
mainGameLoop:
ldy mapScrollPos
; jsr renderTerrainColumns
jsr syncVBL
; ldx #$2222
; jsr bottomFill
; ldx #$1111
; jsr bottomFill
lda scrollV
bmi negV
clc
lda mapScrollPos
adc scrollV
cmp #TERRAINWIDTH/4-80
beq reverseScroll
sta mapScrollPos
bra render
negV:
clc
lda mapScrollPos
adc scrollV
beq reverseScroll
sta mapScrollPos
render:
tay
jsr renderTerrain
jsr kbdScan
@ -46,7 +72,15 @@ mainGameLoop:
CLASSICVIDEO
jml (proDOSLongJump)
reverseScroll:
lda scrollV
eor #$ffff
inc
sta scrollV
jmp mainGameLoop
scrollV:
.word 1
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; kbdScan
@ -60,7 +94,7 @@ kbdScan:
kbdScanLoop:
lda KBD
bpl kbdScanLoop
bpl kbdScanDone
sta KBDSTROBE
cmp #(8 + $80)
@ -71,9 +105,9 @@ kbdScanLoop:
cmp #(32 + $80)
beq kbdScanSpace
NATIVE
kbdScanDone:
NATIVE
rts
kbdScanLeftArrow:
@ -105,9 +139,9 @@ kbdScanSpace:
basePalette:
.word $0800,$0080,$0000,$000F,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
.word $0800,$0080,$0000,$000F,$0FFF,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000,$0000
mapScrollPos: ; 4-pixel columns distance from right terrain edge
.word 80
.word 79
quitRequested:
.word $0000

View File

@ -117,6 +117,7 @@
sta PARAM24
.endmacro
;;;;;;;;;;
; Stack Macros

View File

@ -6,7 +6,7 @@
TERRAINWIDTH = 640 ; In pixels
MAXTERRAINHEIGHT = 100 ; In pixels
MAXTERRAINHEIGHT = 20 ; In pixels
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; renderTerrain