diff --git a/V2Make.scpt b/V2Make.scpt index 5da294f..050b92c 100644 Binary files a/V2Make.scpt and b/V2Make.scpt differ diff --git a/graphics.s b/graphics.s index 7b09809..d23c9bb 100644 --- a/graphics.s +++ b/graphics.s @@ -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: diff --git a/gscats.2mg b/gscats.2mg index 724a57f..97ee450 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/gscats.s b/gscats.s index 7a9218f..38801ea 100644 --- a/gscats.s +++ b/gscats.s @@ -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 diff --git a/macros.s b/macros.s index 93153ab..2b12de4 100644 --- a/macros.s +++ b/macros.s @@ -117,6 +117,7 @@ sta PARAM24 .endmacro + ;;;;;;;;;; ; Stack Macros diff --git a/terrain.s b/terrain.s index 83afeb8..02905ca 100644 --- a/terrain.s +++ b/terrain.s @@ -6,7 +6,7 @@ TERRAINWIDTH = 640 ; In pixels -MAXTERRAINHEIGHT = 100 ; In pixels +MAXTERRAINHEIGHT = 20 ; In pixels ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; renderTerrain