diff --git a/Makefile b/Makefile index b6a348d..4e2e63f 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ CL65=cl65 AC=AppleCommander.jar -ADDR=6000 +ADDR=800 PGM=gscats diff --git a/V2Make.scpt b/V2Make.scpt index 274dd79..cdcc6ea 100644 Binary files a/V2Make.scpt and b/V2Make.scpt differ diff --git a/equates.s b/equates.s index 4c06ca1..437135d 100644 --- a/equates.s +++ b/equates.s @@ -1,10 +1,12 @@ -TEXTCOLOR = $c022 -NEWVIDEO = $c029 -BORDERCOLOR = $c034 -CLOCKCTL = $c034 +TEXTCOLOR = $e0c022 +NEWVIDEO = $e0c029 +BORDERCOLOR = $e0c034 +CLOCKCTL = $e0c034 +SHADOW = $e0c035 +STACKCTL = $e0c068 +KBD = $e0c000 +KBDSTROBE = $e0c010 COUT = $fded -KBD = $c000 -KBDSTROBE = $c010 ; Zero page locations we use (unused by Monitor, Applesoft, or ProDOS) diff --git a/graphics.s b/graphics.s index fa80fc7..ae20319 100644 --- a/graphics.s +++ b/graphics.s @@ -1,19 +1,31 @@ -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; colorFill -; Fills the screen with a color (or two). Not very fast. +; Fills the screen with a color (or two). Pretty fast, but not fastest possible ; A 4:4:4:4 = Palette entries +; +; Trashes Y colorFill: - phx - ldx #32000 + FASTGRAPHICS + + lda #$9d00-1 ; Point stack to end of VRAM + tcs + + ldy #200 colorFillLoop: - sta $e11ffe,x - dex - dex - bne colorFillLoop - plx + ; 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 colorFillLoop + + SLOWGRAPHICS rts @@ -30,7 +42,7 @@ initSCBs: initSCBsLoop: dex dex - sta $e19cfe,x + sta $e19d00,x bne initSCBsLoop rts @@ -87,8 +99,19 @@ setPaletteLoop: iny inx inx - cmp #16 + cpx #32 bne setPaletteLoop RESTORE_XY rts + + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; caches +shadowRegister: + .byte 0 +stackRegister: + .byte 0 +stackPtr: + .word 0 + diff --git a/gscats.2mg b/gscats.2mg index 8809fe8..df51020 100644 Binary files a/gscats.2mg and b/gscats.2mg differ diff --git a/gscats.s b/gscats.s index 7ff91bc..aff6e36 100644 --- a/gscats.s +++ b/gscats.s @@ -10,13 +10,49 @@ .include "equates.s" -.org $6000 +.org $800 main: NATIVE +mainCopyStart: + ldx #0 + lda #mainBank2 + sta mainCopyDest+1 + +mainCopyLoop: + lda mainBank2,x + +mainCopyDest: + sta $020800,x + inx + cpx #endMainBank2-mainBank2 + bne mainCopyLoop + + lda #returnToProDOS + sta proDOSLongJump + lda #mainBank2 + sta mainLongJump + jml (mainLongJump) + +returnToProDOS: + SYNCDBR + EMULATION + rts + +mainLongJump: + .byte 00,08,02 +proDOSLongJump: + .byte 00,00,00 + + +mainBank2: + SYNCDBR + + BITS8 lda #$f0 sta TEXTCOLOR + BITS16 jsr initSCBs SHRVIDEO @@ -26,14 +62,13 @@ main: lda #0 jsr setPalette - lda #$3333 + ldx #$1111 jsr colorFill jsr kbdWait CLASSICVIDEO - EMULATION - rts + jml (proDOSLongJump) @@ -62,6 +97,8 @@ basePalette: .include "graphics.s" +endMainBank2: + ; Suppress some linker warnings - Must be the last thing in the file ; This is because Quinn doesn't really know how to use ca65 properly diff --git a/macros.s b/macros.s index 67c1dee..31a1f58 100644 --- a/macros.s +++ b/macros.s @@ -1,44 +1,114 @@ +.macro OP8 + .i8 + .a8 +.endmacro + + +.macro OP16 + .i16 + .a16 +.endmacro + + +.macro BITS8 + sep #%00110000 + OP8 +.endmacro + + +.macro BITS16 + rep #%00110000 + OP16 +.endmacro + + +.macro DBR bankNum + BITS8 + lda bankNum + pha + plb + BITS16 +.endmacro + + +.macro SYNCDBR + phk + plb +.endmacro + + .macro EMULATION sec ; Enable 8-bit mode xce - .i8 - .a8 + OP8 .endmacro .macro NATIVE clc ; Enable 16-bit mode xce - rep #$30 - .i16 - .a16 + BITS16 .endmacro + .macro SHRVIDEO - sep #$30 - .i8 - .a8 + BITS8 lda NEWVIDEO ora #%11000001 sta NEWVIDEO - rep #$30 - .i16 - .a16 + BITS16 .endmacro + .macro CLASSICVIDEO - sep #$30 - .i8 - .a8 + BITS8 lda NEWVIDEO and #%00111111 sta NEWVIDEO - rep #$30 - .i16 - .a16 + BITS16 .endmacro +.macro FASTGRAPHICS + sei + sep #%00100000 ; 16-bit A only, to preserve X/Y + .a8 + + lda SHADOW + sta shadowRegister + lda #0 + sta SHADOW + + lda STACKCTL + sta stackRegister + ora #$30 + sta STACKCTL + + rep #%00100000 + .a16 + tsc + sta stackPtr +.endmacro + + +.macro SLOWGRAPHICS + sep #%00100000 ; 16-bit A only, to preserve X/Y + .a8 + + lda shadowRegister + sta SHADOW + + lda stackRegister + sta STACKCTL + + rep #%00100000 + .a16 + lda stackPtr + tcs + + cli +.endmacro + ;;;;;;;;;;