factor out more FX routines

This commit is contained in:
4am 2024-05-29 14:41:36 -04:00
parent 70f62c2e66
commit 965d7bed5f
49 changed files with 241 additions and 242 deletions

View File

@ -159,6 +159,7 @@ gGlobalPrefsStore
; be set to $55 as part of the 64K memory test,
; which is apparently one of the acceptable values)
+DEFINE_INDIRECT_VECTOR iHGRDitherPrecomputed3Bit, HGRDitherPrecomputed3Bit
+DEFINE_INDIRECT_VECTOR iHGRPrecomputed3Bit, HGRPrecomputed3Bit
+DEFINE_INDIRECT_VECTOR iRippleCoordinates3Bit, RippleCoordinates3Bit
+DEFINE_INDIRECT_VECTOR iReverseCoordinates3Bit, ReverseCoordinates3Bit

View File

@ -116,7 +116,7 @@ ROM_NORMAL = $FE84 ; NORMAL text (instead of INVERSE or FLASH)
ROM_IN0 = $FE89 ; SETKBD
ROM_PR0 = $FE93 ; SETVID
; zero page during init ONLY
; zero page addresses during init ONLY
zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
; bit 6 = 1 if machine has 128K
; bit 5 = 1 if machine has a VidHD card
@ -124,7 +124,7 @@ zpMachineStatus= $F0 ; bit 7 = 1 if machine has joystick
; only used during init, then copied to MachineStatus in LC RAM
zpCharMask = $F1 ; only used during init, then clobbered
; zero page
; zero page addresses
PARAM = $00 ; word (used by PARAMS_ON_STACK macro, so basically everywhere)
PTR = $02 ; word
SRC = $04 ; word
@ -135,6 +135,7 @@ WCOUNT = $0C ; word
HTAB = $24 ; byte
VTAB = $25 ; byte
RNDSEED = $4E ; word
PrelaunchInit= $EB
; textrank
BestMatchIndex = $E5 ; word
tmpx = $E7 ; byte
@ -153,9 +154,7 @@ firstletter= $FA ; byte
MatchCount = $FB ; byte
BestMatchScore = $FC ; byte
; main memory
gStackSize = 6 ; seems like only six are needed
gPathname = $BFD0 ; used by SetPath/AddToPath
; main memory addresses
gKeyLen = $1F00 ; used by ParseKeyValueList
gKey = $1F01 ; ""
gValLen = $1F80 ; ""
@ -164,12 +163,48 @@ UILine1 = $1FB0 ; used by DrawUI
UILine2 = $1FD8 ; ""
UI_ToPlay = $1FF7 ; ""
ProBootEntry = $2025 ; used by ProBoot
gSearchIndex = $6000
gSearchCache = $A000
gPathname = $BFD0 ; used by SetPath/AddToPath
; LC RAM 1 & 2
; main memory addresses used by graphic effects
hgrlo = $0201 ; $C0 bytes
mirror_cols = $02C1 ; $28 bytes
hgrhi = $0301 ; $C0 bytes
hgr1hi = hgrhi
Coordinates1Bit= $8600 ; $3481 bytes ($3480 on disk + 1 byte EOF marker added at runtime)
EndCoordinates1Bit = Coordinates1Bit + $3480
Coordinates2Bit= $8100 ; $3C01 bytes ($3C00 on disk + 1 byte EOF marker added at runtime)
EndCoordinates2Bit = Coordinates2Bit + $3C00
Coordinates3Bit= $6D00 ; $5001 bytes ($5000 on disk + 1 byte EOF marker added at runtime)
EndCoordinates3Bit = Coordinates3Bit + $5000
hgrlomirror = $BB01 ; $C0 bytes
hgr1himirror = $BC01 ; $C0 bytes
dithermasks = $BDA8 ; $58 bytes, must not cross page boundary
evenrow_masks = dithermasks
oddrow_masks = dithermasks+2
no_masks = dithermasks+44
copymasks1bit = $BE00 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0
copymasks2bit = copymasks1bit ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00,$20,$40,$60,$80
copymasks3bit = copymasks1bit ; $100 bytes but sparse, index is 0..7 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0,$E0
mirror_copymasks1bit = copymasks1bit+1
mirror_copymasks2bit = copymasks2bit+1
hgrlo3a = $6A00 ; $80 bytes
hgrlo3b = $6A80 ; $80 bytes
hgrlo3c = $6B00 ; $80 bytes
hgrhi3a = $6B80 ; $80 bytes
dither1_lo = $6880 ; $80 bytes
dither2_lo = $6900 ; $80 bytes
dither3_lo = $6980 ; $80 bytes
hgrhi3b = $6C00 ; $80 bytes
hgrhi3c = $BD01 ; $80 bytes
extra_cols = $BEF8 ; $08 bytes
; LC RAM 1 & 2 addresses
; these are defined here because they are also called by other targets
; that are assembled separately, e.g. prelaunchers, demo launchers, and graphic effects
UnwaitForVBL = $FFEE
@ -208,6 +243,7 @@ iSetupPrecomputed3Bit = iDHGRDitherPrecomputed2Bit-3
iReverseCoordinates3Bit = iSetupPrecomputed3Bit-3
iRippleCoordinates3Bit = iReverseCoordinates3Bit-3
iHGRPrecomputed3Bit = iRippleCoordinates3Bit-3
iHGRDitherPrecomputed3Bit = iHGRPrecomputed3Bit-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")
@ -217,10 +253,14 @@ MockingboardStuff = $FFF8 ; bit 7 = 1 if SC-01 speech chip present (Speech I)
; bits 0-3: slot number
MachineStatus = $FFF9
; LC RAM 2
; LC RAM 2 addresses
DisableAccelerator = $DFB4
EnableAccelerator = DisableAccelerator+3
; application constants
gStackSize = 6 ; seems like only six are needed
PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be determined at build-time
; AND masks for MockingboardStuff
MOCKINGBOARD_SLOT = %00001111
HAS_STEREO = %00100000
@ -251,8 +291,6 @@ ATTRACT_SHR = %00100000
ATTRACT_GR = %01000000
ATTRACT_DGR = %10000000
PRELAUNCH_STANDARD_SIZE = 61 ; LoadStandardPrelaunch, eventually to be determined at build-time
; shared symbols for prelaunch and effects to call ProRWTS2 functions
iCurBlockLo = $D601 ; constant
iCurBlockHi = $D603 ; constant
@ -268,42 +306,5 @@ ldrhi2 = $65 ; constant
; Columns and Dangerous Dave also call (de)accelerator functions directly
PrelaunchInit = $EB
; addresses used by graphic effects
hgrlo = $0201 ; $C0 bytes
mirror_cols = $02C1 ; $28 bytes
hgrhi = $0301 ; $C0 bytes
hgr1hi = hgrhi
Coordinates1Bit= $8600 ; $3481 bytes ($3480 on disk + 1 byte EOF marker added at runtime)
EndCoordinates1Bit = Coordinates1Bit + $3480
Coordinates2Bit= $8100 ; $3C01 bytes ($3C00 on disk + 1 byte EOF marker added at runtime)
EndCoordinates2Bit = Coordinates2Bit + $3C00
Coordinates3Bit= $6D00 ; $5001 bytes ($5000 on disk + 1 byte EOF marker added at runtime)
EndCoordinates3Bit = Coordinates3Bit + $5000
hgrlomirror = $BB01 ; $C0 bytes
hgr1himirror = $BC01 ; $C0 bytes
dithermasks = $BDA8 ; $58 bytes, must not cross page boundary
evenrow_masks = dithermasks
oddrow_masks = dithermasks+2
no_masks = dithermasks+44
copymasks1bit = $BE00 ; $100 bytes but sparse, index is 0..6 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0
copymasks2bit = copymasks1bit ; $100 bytes but sparse, index is 0..4 but in high 3 bits, so $00,$20,$40,$60,$80
copymasks3bit = copymasks1bit ; $100 bytes but sparse, index is 0..7 but in high 3 bits, so $00,$20,$40,$60,$80,$A0,$C0,$E0
mirror_copymasks1bit = copymasks1bit+1
mirror_copymasks2bit = copymasks2bit+1
hgrlo3a = $6A00 ; $80 bytes
hgrlo3b = $6A80 ; $80 bytes
hgrlo3c = $6B00 ; $80 bytes
hgrhi3a = $6B80 ; $80 bytes
hgrhi3b = $6C00 ; $80 bytes
hgrhi3c = $BD01 ; $80 bytes
extra_cols = $BEF8 ; $08 bytes
_CONSTANTS_=*
}

View File

@ -42,6 +42,7 @@
; - ReverseCoordinates3Bit
; - RippleCoordinates3Bit
; - HGRPrecomputed3Bit
; - HGRDitherPrecomputed3Bit
!source "src/fx/macros.hgr.a"
!source "src/fx/macros.dhgr.a"
@ -1739,3 +1740,148 @@ HGRPrecomputed3Bit
}
.end
}
!zone {
HGRDitherPrecomputed3Bit
jsr BuildHGRDitherMasks
jsr SetupPrecomputed3Bit
; phase 1 - in reverse, with additional masking
+COPY_TO_0 .start, .end
; set up starting coordinate for reading coordinates in reverse order
+LDADDR EndCoordinates3Bit-2
sta <.input
sty <.input+1
; set up EOF marker to stop reading coordinates in reverse order
lda #$80
sta Coordinates3Bit-2
; set up logic to advance to next coordinates in reverse order
ldx #(.next2_end-.next2_start-1)
- lda .next2_start, x
sta <.next, x
dex
bpl -
; set up pointers to dither mask pointers so even rows do even-row dithering and odd rows do odd-row dithering
ldx #$7F
- lda #<evenrow_masks
sta dither1_lo, x
sta dither2_lo-1, x
sta dither3_lo, x
lda #<oddrow_masks
sta dither1_lo-1, x
sta dither2_lo, x
sta dither3_lo-1, x
dex
dex
bpl -
jsr .InputLoop
bit KBD
bmi .start
; phase 2 - in order, without additional masking
+COPY_TO_0 .start, .end
; set up pointers to dither mask pointers so all rows do no dithering
ldx #$7F
- lda #<no_masks
sta dither1_lo, x
sta dither2_lo, x
sta dither3_lo, x
dex
bpl -
jmp .InputLoop
.start
!pseudopc 0 {
.Exit3Bit rts
.dither1_ptr
!word evenrow_masks
.dither2_ptr
!word oddrow_masks
.dither3_ptr
!word evenrow_masks
.InputLoop
ldy #0
.input=*+1
lda Coordinates3Bit
bmi .Exit3Bit ; if high bit is 1 then we're done
cmp #$40
php
tax
lda dither1_lo, x
sta .dither1_ptr
lda dither2_lo, x
sta .dither2_ptr
lda dither3_lo, x
sta .dither3_ptr
+ROW_X_TO_3BIT_BASE_ADDRESSES .src1, .src2, .src3, .dest1, .dest2, .dest3
iny
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
and (<.dither1_ptr), y
eor (<.dest1), y
.dest1=*+1
sta $FDFD, y
.src2=*+1
lda $FDFD, y
eor (<.dest2), y
and copymasks3bit, x
and (<.dither2_ptr), y
eor (<.dest2), y
.dest2=*+1
sta $FDFD, y
.src3=*+1
lda $FDFD, y
eor (<.dest3), y
and copymasks3bit, x
and (<.dither3_ptr), y
eor (<.dest3), y
.dest3=*+1
sta $FDFD, y
.next
inc <.input
inc <.input
bne +
bit KBD
bmi ++
inc <.input+1
+ jmp .InputLoop
++ rts
}
.end
.next2_start
!pseudopc .next {
lda <.input
php
dec <.input
dec <.input
plp
bne +
dec <.input+1
bit KBD
bmi ++
+ jmp .InputLoop
++ rts
}
.next2_end
}

View File

@ -9,7 +9,7 @@
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
jmp iHGRDitherPrecomputed3Bit
CoordinatesFile
+PSTRING "APPLE.DATA"

View File

@ -12,7 +12,7 @@
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
jmp iHGRDitherPrecomputed3Bit
CoordinatesFile
+PSTRING "BOLT.DATA"

View File

@ -9,7 +9,7 @@
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
jmp iHGRDitherPrecomputed3Bit
CoordinatesFile
+PSTRING "FLOWER.DATA"

View File

@ -9,7 +9,7 @@
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
jmp iHGRDitherPrecomputed3Bit
CoordinatesFile
+PSTRING "FLOWER.RAD.DATA"

View File

@ -9,7 +9,7 @@
+FX_INITONCE_3BIT CoordinatesFile, Start
Start
+FX_PRECOMPUTED_3BIT_DITHER Coordinates3Bit, EndCoordinates3Bit
jmp iHGRDitherPrecomputed3Bit
CoordinatesFile
+PSTRING "MANDELBROT.DATA"

View File

@ -22,10 +22,6 @@
; BF00..BFFF - ProRWTS glue
;
dither1_lo = $6880 ; $80 bytes
dither2_lo = $6900 ; $80 bytes
dither3_lo = $6980 ; $80 bytes
!source "src/fx/macros.a"
!macro FX_INITONCE_3BIT .CoordinatesFile, .Start {
@ -41,148 +37,3 @@ InitOnce
sec
ror EndCoordinates3Bit
}
!macro FX_PRECOMPUTED_3BIT_DITHER .coords, .endcoords {
jsr iBuildHGRDitherMasks
jsr iSetupPrecomputed3Bit
; phase 1 - in reverse, with additional masking
+COPY_TO_0 start, end
; set up starting coordinate for reading coordinates in reverse order
+LDADDR .endcoords-2
sta <input
sty <input+1
; set up EOF marker to stop reading coordinates in reverse order
lda #$80
sta .coords-2
; set up logic to advance to next coordinates in reverse order
ldx #(next2_end-next2_start-1)
- lda next2_start, x
sta <next, x
dex
bpl -
; set up pointers to dither mask pointers so even rows do even-row dithering and odd rows do odd-row dithering
ldx #$7F
- lda #<evenrow_masks
sta dither1_lo, x
sta dither2_lo-1, x
sta dither3_lo, x
lda #<oddrow_masks
sta dither1_lo-1, x
sta dither2_lo, x
sta dither3_lo-1, x
dex
dex
bpl -
jsr InputLoop
bit KBD
bmi start
; phase 2 - in order, without additional masking
+COPY_TO_0 start, end
; set up pointers to dither mask pointers so all rows do no dithering
ldx #$7F
- lda #<no_masks
sta dither1_lo, x
sta dither2_lo, x
sta dither3_lo, x
dex
bpl -
jmp InputLoop
start
!pseudopc 0 {
Exit3Bit rts
dither1_ptr
!word evenrow_masks
dither2_ptr
!word oddrow_masks
dither3_ptr
!word evenrow_masks
InputLoop
ldy #0
input=*+1
lda .coords
bmi Exit3Bit ; if high bit is 1 then we're done
cmp #$40
php
tax
lda dither1_lo, x
sta dither1_ptr
lda dither2_lo, x
sta dither2_ptr
lda dither3_lo, x
sta dither3_ptr
+ROW_X_TO_3BIT_BASE_ADDRESSES src1, src2, src3, dest1, dest2, dest3
iny
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
and (dither1_ptr), y
eor (<dest1), y
dest1=*+1
sta $FDFD, y
src2=*+1
lda $FDFD, y
eor (<dest2), y
and copymasks3bit, x
and (dither2_ptr), y
eor (<dest2), y
dest2=*+1
sta $FDFD, y
src3=*+1
lda $FDFD, y
eor (<dest3), y
and copymasks3bit, x
and (dither3_ptr), y
eor (<dest3), y
dest3=*+1
sta $FDFD, y
next
inc <input
inc <input
bne +
bit KBD
bmi ++
inc <input+1
+ jmp InputLoop
++ rts
}
end
next2_start
!pseudopc next {
lda <input
php
dec <input
dec <input
plp
bne +
dec <input+1
bit KBD
bmi ++
+ jmp InputLoop
++ rts
}
next2_end
}

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15886779
!be24 15885374
!le16 5130

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15831437
!be24 15830032
!le16 5732

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15763204
!be24 15761799
!le16 4194

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15777918
!be24 15776513
!le16 4652

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15796633
!be24 15795228
!le16 5621

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15817674
!be24 15816269
!le16 6199

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15891909
!be24 15890504
!le16 410

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15892663
!be24 15891258
!le16 449

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15893112
!be24 15891707
!le16 303

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 12659422
!be24 12658017
!le16 1652

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15839809
!be24 15838404
!le16 1640

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15892395
!be24 15890990
!le16 67

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15886720
!be24 15885315
!le16 59

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15885140
!be24 15883735
!le16 1426

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15869906
!be24 15868501
!le16 557

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15837169
!be24 15835764
!le16 2640

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15841807
!be24 15840402
!le16 473

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15842280
!be24 15840875
!le16 7564

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15892319
!be24 15890914
!le16 76

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15886566
!be24 15885161
!le16 154

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15892462
!be24 15891057
!le16 201

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15870463
!be24 15869058
!le16 4334

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15874797
!be24 15873392
!le16 1733

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15876530
!be24 15875125
!le16 1181

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15877711
!be24 15876306
!le16 3394

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15881105
!be24 15879700
!le16 3429

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15884534
!be24 15883129
!le16 479

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15885013
!be24 15883608
!le16 127

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15893415
!be24 15892010
!le16 2370

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15855249
!be24 15853844
!le16 5083

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15860332
!be24 15858927
!le16 2485

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15823873
!be24 15822468
!le16 7564

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15753621
!be24 15752216
!le16 9583

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15767398
!be24 15765993
!le16 10520

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15782570
!be24 15781165
!le16 14063

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15802254
!be24 15800849
!le16 15420

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15841449
!be24 15840044
!le16 358

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15849844
!be24 15848439
!le16 5405

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15862817
!be24 15861412
!le16 7089

View File

@ -4,5 +4,5 @@
; This file is automatically generated
;
!byte 0
!be24 15749273
!be24 15747868
!le16 4348