From 2bb6eb557a59816eade4749a0b8f7de3c3c29d85 Mon Sep 17 00:00:00 2001 From: 4am Date: Fri, 31 May 2024 21:01:21 -0400 Subject: [PATCH] factor out more FX routines --- src/constants.a | 46 ++ ...ial.common.a => code.dhgr.dither.radial.a} | 13 +- ...hgr.radial.common.a => code.dhgr.radial.a} | 13 +- src/fx/code.hgr.48boxes.a | 496 +++++++++++++++ ...dial.common.a => code.hgr.dither.radial.a} | 10 +- src/fx/fx.dhgr.48boxes.2snakes.a | 32 +- src/fx/fx.dhgr.48boxes.a | 64 +- src/fx/fx.dhgr.48boxes.arrow.a | 32 +- src/fx/fx.dhgr.48boxes.common.a | 68 +-- src/fx/fx.dhgr.48boxes.down.a | 32 +- src/fx/fx.dhgr.48boxes.longdiagonal.a | 32 +- src/fx/fx.dhgr.48boxes.pageturn.clear.a | 64 +- src/fx/fx.dhgr.48boxes.sidetoside.a | 32 +- src/fx/fx.dhgr.48boxes.snake.a | 32 +- src/fx/fx.dhgr.48boxes.snake.clear.a | 64 +- src/fx/fx.dhgr.48boxes.spiral.a | 32 +- src/fx/fx.dhgr.48boxes.spiral.clear.a | 64 +- src/fx/fx.dhgr.48boxes.sync.a | 32 +- src/fx/fx.dhgr.48boxes.sync.clear.a | 64 +- src/fx/fx.dhgr.dither.radial2.a | 8 +- src/fx/fx.dhgr.dither.radial4.a | 8 +- src/fx/fx.dhgr.radial2.a | 8 +- src/fx/fx.dhgr.radial4.a | 8 +- src/fx/fx.dhgr.radial5.a | 8 +- src/fx/fx.hgr.48boxes.a | 1 + src/fx/fx.hgr.48boxes.common.a | 570 +----------------- src/fx/fx.hgr.dither.radial2.a | 8 +- src/fx/fx.hgr.dither.radial4.a | 8 +- src/fx/fx.hgr.dither.radial5.a | 8 +- src/index/artwork.idx.a | 2 +- src/index/attract.idx.a | 2 +- src/index/cache00.idx.a | 2 +- src/index/cache01.idx.a | 2 +- src/index/cache10.idx.a | 2 +- src/index/cache11.idx.a | 2 +- src/index/coverfade.idx.a | 2 +- src/index/credits.idx.a | 2 +- src/index/decrunch.idx.a | 2 +- src/index/demo.idx.a | 2 +- src/index/dfx.idx.a | 2 +- src/index/dgr.fizzle.idx.a | 2 +- src/index/dgr.idx.a | 2 +- src/index/dhgr.idx.a | 2 +- src/index/dtitle.idx.a | 2 +- src/index/fx.idx.a | 2 +- src/index/fxcode.idx.a | 4 +- src/index/fxdata.idx.a | 2 +- src/index/gamehelp.idx.a | 2 +- src/index/gr.fizzle.idx.a | 2 +- src/index/gr.idx.a | 2 +- src/index/helptext.idx.a | 2 +- src/index/hgr0.idx.a | 2 +- src/index/hgr1.idx.a | 2 +- src/index/hgr2.idx.a | 2 +- src/index/hgr3.idx.a | 2 +- src/index/hgr4.idx.a | 2 +- src/index/hgr5.idx.a | 2 +- src/index/hgr6.idx.a | 2 +- src/index/joystick.idx.a | 2 +- src/index/miniattract0.idx.a | 2 +- src/index/miniattract1.idx.a | 2 +- src/index/prelaunch.idx.a | 2 +- src/index/search00.idx.a | 2 +- src/index/search01.idx.a | 2 +- src/index/search10.idx.a | 2 +- src/index/search11.idx.a | 2 +- src/index/sfx.idx.a | 2 +- src/index/slideshow.idx.a | 2 +- src/index/title.idx.a | 2 +- src/index/xsingle.idx.a | 2 +- 70 files changed, 993 insertions(+), 948 deletions(-) rename src/fx/{fx.dhgr.dither.radial.common.a => code.dhgr.dither.radial.a} (94%) rename src/fx/{fx.dhgr.radial.common.a => code.dhgr.radial.a} (93%) create mode 100644 src/fx/code.hgr.48boxes.a rename src/fx/{fx.hgr.dither.radial.common.a => code.hgr.dither.radial.a} (93%) diff --git a/src/constants.a b/src/constants.a index dee91f8ab..68571414b 100644 --- a/src/constants.a +++ b/src/constants.a @@ -205,6 +205,52 @@ hgrhi3b = $6C00 ; $80 bytes hgrhi3c = $BD01 ; $80 bytes extra_cols = $BEF8 ; $08 bytes +; hgr.48boxes constants +StageDrawingRoutines = $7F00 +; High bytes of drawing routines for each stage (actual routines will be page-aligned). +; To minimize code size, we build drawing routines in this order: +; - copy01 (STAGE1 template) +; - copy00 (STAGE0 template) +; - copy0F..copy09 (OUTER_STAGE template) +; - copy08..copy02 (MIDDLE_STAGE template) +; - change some opcodes to turn the 'copy' routines into 'clear' routines +; - clear0F..clear08 (OUTER_STAGE) +; - clear07..clear02 (MIDDLE_STAGE) +; - clear01 (STAGE1) +; - clear00 (STAGE0) +clear00 = $80 +clear01 = $81 +clear02 = $82 +clear03 = $83 +clear04 = $84 +clear05 = $85 +clear06 = $86 +clear07 = $87 +clear08 = $88 +clear09 = $89 +clear0A = $8A +clear0B = $8B +clear0C = $8C +clear0D = $8D +clear0E = $8E +clear0F = $8F +copy02 = $90 +copy03 = $91 +copy04 = $92 +copy05 = $93 +copy06 = $94 +copy07 = $95 +copy08 = $96 +copy09 = $97 +copy0A = $98 +copy0B = $99 +copy0C = $9A +copy0D = $9B +copy0E = $9C +copy0F = $9D +copy00 = $9E +copy01 = $9F + ; 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 diff --git a/src/fx/fx.dhgr.dither.radial.common.a b/src/fx/code.dhgr.dither.radial.a similarity index 94% rename from src/fx/fx.dhgr.dither.radial.common.a rename to src/fx/code.dhgr.dither.radial.a index c2a55bd5f..f768a89de 100644 --- a/src/fx/fx.dhgr.dither.radial.common.a +++ b/src/fx/code.dhgr.dither.radial.a @@ -2,6 +2,13 @@ ;(c) 2019-2022 by 4am ; +!cpu 6502 +!to "build/FXCODE/DHGRDITHRAD",plain +*=$6200 + + !source "src/fx/macros.a" + +;DHGRDitherRadialPrecomputed1Bit evenrow_ptr = $E4 ; word oddrow_ptr = $E6 ; word mirror_src1 = $E8 ; word @@ -20,7 +27,7 @@ input = $FE ; word jsr iBuildHGRTables jsr iBuildHGRMirrorTables jsr iBuildDHGRMirrorCols - +COPY_TO_AUXMEM $60, 4 + +COPY_TO_AUXMEM $62, 4 +LDADDR evenrow_masks +ST16 evenrow_ptr @@ -34,9 +41,9 @@ input = $FE ; word sta FXCode + jsr iLoadFXCODE - ; drawing routines for each stage are constructed dynamically - ; and stored at copy00..copy0F and clear00..clear0F - jsr BuildDrawingRoutines - - ; set up zero page for drawing phase - ; A=0 here - tax -- ldy start-5, x - sty $00, x - sta EndStagesHi, x - inx - bne - - - jsr iBuildHGRTables - -; Generate |BoxesX| and |BoxesY| arrays -; BoxesX (starting row for each box) -; $00,$00,$00,$00,$00,$00,$00,$00 -; $20,$20,$20,$20,$20,$20,$20,$20 -; $40,$40,$40,$40,$40,$40,$40,$40 -; $60,$60,$60,$60,$60,$60,$60,$60 -; $80,$80,$80,$80,$80,$80,$80,$80 -; $A0,$A0,$A0,$A0,$A0,$A0,$A0,$A0 -; BoxesY (starting byte offset for each box) -; $00,$05,$0A,$0F,$14,$19,$1E,$23 -; $00,$05,$0A,$0F,$14,$19,$1E,$23 -; $00,$05,$0A,$0F,$14,$19,$1E,$23 -; $00,$05,$0A,$0F,$14,$19,$1E,$23 -; $00,$05,$0A,$0F,$14,$19,$1E,$23 -; $00,$05,$0A,$0F,$14,$19,$1E,$23 - ldx #48 - ldy #$A0 - lda #$23 - pha -- tya - sta BoxesX-1, x - pla - sta BoxesY-1, x - sec - sbc #5 - bcs + - lda #$23 -+ pha - dex - txa - and #7 - bne - - tya - sec - sbc #$20 - tay - txa - bne - - pla - - jmp MainLoop - -; These are all the pieces of code we need to construct the drawing routines. -; There are 32 drawing routines (16 if USES_CLEAR=0), which we construct from -; four templates (below). Templates use tokens to refer to these code pieces. -; Note that several pieces overlap in order to minimize code size. -; Everything from CODEGEN_COPY_START and onward is copied to zero page for -; the code generation phase on program startup. -CODEGEN_COPY_START -!pseudopc 0 { -RTS0 ; 1 byte - rts -RTS0_E -INX_AND_RECALC ; 16 bytes - inx -RECALC_AND_INY ; 16 bytes -RECALC ; 15 bytes - lda hgrlo, x - sta