diff --git a/src/4cade.a b/src/4cade.a index da5da0909..80da06935 100644 --- a/src/4cade.a +++ b/src/4cade.a @@ -159,14 +159,17 @@ gGlobalPrefsStore ; be set to $55 as part of the 64K memory test, ; which is apparently one of the acceptable values) + +DEFINE_INDIRECT_VECTOR iHGRPrecomputed3Bit, HGRPrecomputed3Bit +DEFINE_INDIRECT_VECTOR iRippleCoordinates3Bit, RippleCoordinates3Bit +DEFINE_INDIRECT_VECTOR iReverseCoordinates3Bit, ReverseCoordinates3Bit +DEFINE_INDIRECT_VECTOR iSetupPrecomputed3Bit, SetupPrecomputed3Bit + +DEFINE_INDIRECT_VECTOR iDHGRPrecomputed2Bit, DHGRPrecomputed2Bit +DEFINE_INDIRECT_VECTOR iHGRPrecomputed2Bit, HGRPrecomputed2Bit +DEFINE_INDIRECT_VECTOR iRippleCoordinates2Bit, RippleCoordinates2Bit +DEFINE_INDIRECT_VECTOR iReverseCoordinates2Bit, ReverseCoordinates2Bit +DEFINE_INDIRECT_VECTOR iBuildDHGRSparseBitmasks2Bit, BuildDHGRSparseBitmasks2Bit +DEFINE_INDIRECT_VECTOR iBuildHGRSparseBitmasks2Bit, BuildHGRSparseBitmasks2Bit + +DEFINE_INDIRECT_VECTOR iDHGRPrecomputed1Bit, DHGRPrecomputed1Bit +DEFINE_INDIRECT_VECTOR iHGRPrecomputed1Bit, HGRPrecomputed1Bit +DEFINE_INDIRECT_VECTOR iBuildDHGRSparseBitmasks1Bit, BuildDHGRSparseBitmasks1Bit +DEFINE_INDIRECT_VECTOR iBuildHGRSparseBitmasks1Bit, BuildHGRSparseBitmasks1Bit @@ -251,5 +254,8 @@ EvenLasterMover !warn "OKVS CACHE at ", OKVS_CACHE !warn "LCRAM2 ends at ", LCRAM2_END !warn "RELBASE = ", $10000 - (LastMover - FirstMover) + !if ($10000 - (LastMover - FirstMover) < $D500) { ; end of font data + !serious "code is too large, RELBASE overlaps with font data" + } } } diff --git a/src/constants.a b/src/constants.a index e9445882b..9c906f1a1 100644 --- a/src/constants.a +++ b/src/constants.a @@ -193,14 +193,17 @@ iRippleCoordinates1Bit4 = iRippleCoordinates1Bit3-3 iBuildHGRSparseBitmasks1Bit = iRippleCoordinates1Bit4-3 iBuildDHGRSparseBitmasks1Bit = iBuildHGRSparseBitmasks1Bit-3 iHGRPrecomputed1Bit = iBuildDHGRSparseBitmasks1Bit-3 -iBuildHGRSparseBitmasks2Bit = iHGRPrecomputed1Bit-3 +iDHGRPrecomputed1Bit = iHGRPrecomputed1Bit-3 +iBuildHGRSparseBitmasks2Bit = iDHGRPrecomputed1Bit-3 iBuildDHGRSparseBitmasks2Bit = iBuildHGRSparseBitmasks2Bit-3 iReverseCoordinates2Bit = iBuildDHGRSparseBitmasks2Bit-3 iRippleCoordinates2Bit = iReverseCoordinates2Bit-3 iHGRPrecomputed2Bit = iRippleCoordinates2Bit-3 -iSetupPrecomputed3Bit = iHGRPrecomputed2Bit-3 +iDHGRPrecomputed2Bit = iHGRPrecomputed2Bit-3 +iSetupPrecomputed3Bit = iDHGRPrecomputed2Bit-3 iReverseCoordinates3Bit = iSetupPrecomputed3Bit-3 iRippleCoordinates3Bit = iReverseCoordinates3Bit-3 +iHGRPrecomputed3Bit = iRippleCoordinates3Bit-3 MockingboardStuff = $FFF8 ; bit 7 = 1 if SC-01 speech chip present (Speech I) ; bit 6 = 1 if SSI-263 speech chip present (Mockingboard "B"-"D") diff --git a/src/fx.lib.a b/src/fx.lib.a index 09f66b37c..7fadaf084 100644 --- a/src/fx.lib.a +++ b/src/fx.lib.a @@ -25,16 +25,19 @@ ; - RippleCoordinates1Bit3 ; - RippleCoordinates1Bit4 ; - HGRPrecomputed1Bit +; - DHGRPrecomputed1Bit ; - BuildHGRSparseBitmasks2Bit ; - BuildDHGRSparseBitmasks2Bit ; - ReverseCoordinates2Bit ; - RippleCoordinates2Bit ; - HGRPrecomputed2Bit +; - DHGRPrecomputed2Bit ; - SetupPrecomputed3Bit ; - ReverseCoordinates3Bit ; - RippleCoordinates3Bit +; - HGRPrecomputed3Bit !source "src/fx/macros.hgr.a" !source "src/fx/macros.dhgr.a" @@ -495,6 +498,98 @@ HGRPrecomputed1Bit .end } +!zone { +DHGRPrecomputed1Bit + jsr BuildDHGRSparseBitmasks1Bit + jsr BuildHGRTables + jsr BuildHGRMirrorTables + jsr BuildDHGRMirrorCols + +COPY_TO_0 .start, .end + jmp .InputLoop +.start +!pseudopc 0 { +.Exit1Bit rts +.InputLoop + ldy #0 +.input=*+1 + ldx Coordinates1Bit ; first value: HGR row (only 0..95 will be in input array) + bmi .Exit1Bit ; if > 127 then we're done + +ROW_X_TO_BASE_ADDRESSES .src1, .src2, .dest1, .dest2 + +ROW_X_TO_MIRROR_ADDRESSES .mirror_src1, .mirror_src2, .mirror_dest1, .mirror_dest2 + + inc .input + lda (.input), y + +HIGH_3_LOW_5 .input + sty <.y + clc +.bankloop + lda copymasks1bit, x + beq + + sta <.copymask + + ; main 1x2 block in top-left quadrant +.src1=*+1 + lda $FDFD, y + eor (<.dest1), y +.copymask=*+1 + and #$FD ; SMC + eor (<.dest1), y +.dest1=*+1 + sta $FDFD, y +.src2=*+1 + lda $FDFD, y + eor (<.dest2), y + and <.copymask + eor (<.dest2), y +.dest2=*+1 + sta $FDFD, y + + ; corresponding 1x2 block in bottom-left quadrant (opposite row, original column) + +COPY_BIT_ZP .mirror_src1, .mirror_dest1, .copymask + +COPY_BIT_ZP .mirror_src2, .mirror_dest2, .copymask + ++ + lda mirror_copymasks1bit, x ; exists at the same address in mainmem and auxmem but each is different + beq + + sta <.mirror_copymask + ; corresponding 1x2 block in bottom-right quadrant (opposite row, opposite column) + lda mirror_cols, y ; duplicated in mainmem and auxmem + tay +.mirror_src1=*+1 + lda $FDFD, y + eor (<.mirror_dest1), y +.mirror_copymask=*+1 + and #$FD ; SMC + eor (<.mirror_dest1), y +.mirror_dest1=*+1 + sta $FDFD, y +.mirror_src2=*+1 + lda $FDFD, y + eor (<.mirror_dest2), y + and <.mirror_copymask + eor (<.mirror_dest2), y +.mirror_dest2=*+1 + sta $FDFD, y + + ; corresponding 1x2 block in top-right quadrant (same row, opposite column) + +COPY_BIT_ZP .src1, .dest1, .mirror_copymask + +COPY_BIT_ZP .src2, .dest2, .mirror_copymask ++ + bcs + + sta $C003 + sta $C005 +.y=*+1 + ldy #$FD + sec + bcs .bankloop ++ sta $C002 + sta $C004 + + +INC_INPUT_AND_LOOP .input, .InputLoop +} +.end +} + BuildHGRSparseBitmasks2Bit lda #%10000011 sta copymasks2bit @@ -791,6 +886,81 @@ HGRPrecomputed2Bit .end } +!zone { +DHGRPrecomputed2Bit + jsr BuildDHGRSparseBitmasks2Bit + jsr BuildHGRTables + jsr BuildDHGRMirrorCols + +COPY_TO_0 .start, .end + jmp .InputLoop + +.start +!pseudopc 0 { +.Exit2Bit rts +.InputLoop + ldy #0 +.input=*+1 + ldx Coordinates2Bit ; first value: HGR row + 1 + beq .Exit2Bit ; if 0 then we're done + +ROW_X_TO_2BIT_BASE_ADDRESSES .src1, .src2, .dest1, .dest2 + + inc <.input + lda (<.input), y + +HIGH_3_LOW_5 .input + + ; main 2x2 block in left half + clc +- lda copymasks2bit, x + beq + +.src1=*+1 + lda $FDFD, y + eor (<.dest1), y + and copymasks2bit, x + eor (<.dest1), y +.dest1=*+1 + sta $FDFD, y +.src2=*+1 + lda $FDFD, y + eor (<.dest2), y + and copymasks2bit, x + eor (<.dest2), y +.dest2=*+1 + sta $FDFD, y ++ bcs + + sta $C003 + sta $C005 + sec + bcs - ++ sta $C002 + sta $C004 + + ; corresponding 2x2 block in right half (same row, opposite column) + lda mirror_cols, y + tay + clc +- lda mirror_copymasks2bit, x + beq + + +COPY_BIT .src1, .dest1, mirror_copymasks2bit + +COPY_BIT .src2, .dest2, mirror_copymasks2bit ++ bcs + + sta $C003 + sta $C005 + sec + bcs - ++ sta $C002 + sta $C004 + + inc <.input + +LBNE .InputLoop + bit $c000 + bmi + + inc <.input+1 + jmp .InputLoop ++ rts +} +.end +} + SetupPrecomputed3Bit ; build regular HGR lookup tables, then split them jsr BuildHGRTables @@ -951,3 +1121,65 @@ RippleCoordinates3Bit !byte $1E,$F3,$1F,$54,$00,$00,$AA,$06 !byte $02,$00,$04,$00,$06,$00,$0C,$00 !byte $16,$00,$1A,$00 + +!zone { +HGRPrecomputed3Bit + jsr SetupPrecomputed3Bit + +COPY_TO_0 .start, .end + jmp .InputLoop +.start +!pseudopc 0 { +.Exit3Bit rts +.InputLoop + ldy #0 +.input=*+1 + lda Coordinates3Bit + bmi .Exit3Bit ; if high bit is 1 then we're done + cmp #$40 + php + tax + +ROW_X_TO_3BIT_BASE_ADDRESSES .src1, .src2, .src3, .dest1, .dest2, .dest3 + + inc <.input + lda (<.input), y + and #%11100000 + tax + eor (<.input), y + plp + bcc + + tay + lda extra_cols, y ++ tay + + ; 2x3 block +.src1=*+1 + lda $FDFD, y + eor (<.dest1), y + and copymasks3bit, x + eor (<.dest1), y +.dest1=*+1 + sta $FDFD, y +.src2=*+1 + lda $FDFD, y + eor (<.dest2), y + and copymasks3bit, x + eor (<.dest2), y +.dest2=*+1 + sta $FDFD, y +.src3=*+1 + lda $FDFD, y + eor (<.dest3), y + and copymasks3bit, x + eor (<.dest3), y +.dest3=*+1 + sta $FDFD, y + + inc <.input + bne .InputLoop + bit KBD + bmi .Exit3Bit + inc <.input+1 + bne .InputLoop ; always branches +} +.end +} diff --git a/src/fx/fx.dhgr.bubbles.a b/src/fx/fx.dhgr.bubbles.a index 9a67963a0..0891c7551 100644 --- a/src/fx/fx.dhgr.bubbles.a +++ b/src/fx/fx.dhgr.bubbles.a @@ -9,7 +9,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "BUBBLES.DATA" diff --git a/src/fx/fx.dhgr.bubbles.in.a b/src/fx/fx.dhgr.bubbles.in.a index fa88f5a7f..a45606180 100644 --- a/src/fx/fx.dhgr.bubbles.in.a +++ b/src/fx/fx.dhgr.bubbles.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start jsr iReverseCoordinates1Bit Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "BUBBLES.DATA" diff --git a/src/fx/fx.dhgr.butterfly.a b/src/fx/fx.dhgr.butterfly.a index a68bf3e35..17ce5bfca 100644 --- a/src/fx/fx.dhgr.butterfly.a +++ b/src/fx/fx.dhgr.butterfly.a @@ -9,7 +9,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "BUTTERFLY.DATA" diff --git a/src/fx/fx.dhgr.butterfly.in.a b/src/fx/fx.dhgr.butterfly.in.a index 48ab014b1..8b368dd88 100644 --- a/src/fx/fx.dhgr.butterfly.in.a +++ b/src/fx/fx.dhgr.butterfly.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iReverseCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "BUTTERFLY.DATA" diff --git a/src/fx/fx.dhgr.butterfly.ripple.a b/src/fx/fx.dhgr.butterfly.ripple.a index b64decc64..6066a4040 100644 --- a/src/fx/fx.dhgr.butterfly.ripple.a +++ b/src/fx/fx.dhgr.butterfly.ripple.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iRippleCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "BUTTERFLY.DATA" diff --git a/src/fx/fx.dhgr.corner4.a b/src/fx/fx.dhgr.corner4.a index 062422af1..866a97419 100644 --- a/src/fx/fx.dhgr.corner4.a +++ b/src/fx/fx.dhgr.corner4.a @@ -9,7 +9,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "CORNER4.DATA" diff --git a/src/fx/fx.dhgr.corner4.in.a b/src/fx/fx.dhgr.corner4.in.a index 2ca0739f1..161094cac 100644 --- a/src/fx/fx.dhgr.corner4.in.a +++ b/src/fx/fx.dhgr.corner4.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start jsr iReverseCoordinates1Bit Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "CORNER4.DATA" diff --git a/src/fx/fx.dhgr.corner4.ripple.a b/src/fx/fx.dhgr.corner4.ripple.a index f01458673..03c825d54 100644 --- a/src/fx/fx.dhgr.corner4.ripple.a +++ b/src/fx/fx.dhgr.corner4.ripple.a @@ -11,7 +11,7 @@ jsr iRippleCoordinates1Bit2 Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "CORNER4.DATA" diff --git a/src/fx/fx.dhgr.heart.a b/src/fx/fx.dhgr.heart.a index a4e3b4118..0e630e86e 100644 --- a/src/fx/fx.dhgr.heart.a +++ b/src/fx/fx.dhgr.heart.a @@ -9,7 +9,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "HEART.DATA" diff --git a/src/fx/fx.dhgr.heart.in.a b/src/fx/fx.dhgr.heart.in.a index d61aa1891..55f8f7b4f 100644 --- a/src/fx/fx.dhgr.heart.in.a +++ b/src/fx/fx.dhgr.heart.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iReverseCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "HEART.DATA" diff --git a/src/fx/fx.dhgr.heart.ripple.a b/src/fx/fx.dhgr.heart.ripple.a index 75fd8bfd4..8971923f9 100644 --- a/src/fx/fx.dhgr.heart.ripple.a +++ b/src/fx/fx.dhgr.heart.ripple.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iRippleCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "HEART.DATA" diff --git a/src/fx/fx.dhgr.iris.a b/src/fx/fx.dhgr.iris.a index e69fddd7d..91ea64221 100644 --- a/src/fx/fx.dhgr.iris.a +++ b/src/fx/fx.dhgr.iris.a @@ -9,7 +9,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "IRIS.DATA" diff --git a/src/fx/fx.dhgr.iris.in.a b/src/fx/fx.dhgr.iris.in.a index 81624b062..6b42cde1c 100644 --- a/src/fx/fx.dhgr.iris.in.a +++ b/src/fx/fx.dhgr.iris.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_1BIT CoordinatesFile, Start jsr iReverseCoordinates1Bit Start - +FX_PRECOMPUTED_1BIT_DHGR Coordinates1Bit + jmp iDHGRPrecomputed1Bit CoordinatesFile +PSTRING "IRIS.DATA" diff --git a/src/fx/fx.dhgr.maple.a b/src/fx/fx.dhgr.maple.a index 0affaf7c7..33df20ba7 100644 --- a/src/fx/fx.dhgr.maple.a +++ b/src/fx/fx.dhgr.maple.a @@ -9,7 +9,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "MAPLE.DATA" diff --git a/src/fx/fx.dhgr.maple.in.a b/src/fx/fx.dhgr.maple.in.a index db71fa6a3..17d2418a3 100644 --- a/src/fx/fx.dhgr.maple.in.a +++ b/src/fx/fx.dhgr.maple.in.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iReverseCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "MAPLE.DATA" diff --git a/src/fx/fx.dhgr.maple.ripple.a b/src/fx/fx.dhgr.maple.ripple.a index 9fb4fd11b..6819e73bb 100644 --- a/src/fx/fx.dhgr.maple.ripple.a +++ b/src/fx/fx.dhgr.maple.ripple.a @@ -10,7 +10,7 @@ +FX_INITONCE_2BIT CoordinatesFile, Start jsr iRippleCoordinates2Bit Start - +FX_PRECOMPUTED_2BIT_DHGR Coordinates2Bit + jmp iDHGRPrecomputed2Bit CoordinatesFile +PSTRING "MAPLE.DATA" diff --git a/src/fx/fx.dhgr.precomputed.1bit.a b/src/fx/fx.dhgr.precomputed.1bit.a index cd864133f..2d94b502d 100644 --- a/src/fx/fx.dhgr.precomputed.1bit.a +++ b/src/fx/fx.dhgr.precomputed.1bit.a @@ -4,97 +4,6 @@ !source "src/fx/fx.hgr.precomputed.1bit.a" -!macro FX_PRECOMPUTED_1BIT_DHGR .coords { - jsr iBuildDHGRSparseBitmasks1Bit - jsr iBuildHGRTables - jsr iBuildHGRMirrorTables - jsr iBuildDHGRMirrorCols - +COPY_TO_0 start, end - jmp InputLoop -start -!pseudopc 0 { -Exit1Bit rts -InputLoop - ldy #0 -input=*+1 - ldx .coords ; first value: HGR row (only 0..95 will be in input array) - bmi Exit1Bit ; if > 127 then we're done - +ROW_X_TO_BASE_ADDRESSES src1, src2, dest1, dest2 - +ROW_X_TO_MIRROR_ADDRESSES mirror_src1, mirror_src2, mirror_dest1, mirror_dest2 - - inc input - lda (input), y - +HIGH_3_LOW_5 input - sty