From 2e3a9cba3527b1e9da014d21c4680b349640e4eb Mon Sep 17 00:00:00 2001 From: 4am Date: Fri, 3 Dec 2021 16:42:47 -0500 Subject: [PATCH] split out shr.80boxes.common --- src/fx/fx.shr.80boxes.a | 478 +-------------------------------- src/fx/fx.shr.80boxes.common.a | 232 ++++++++++++++++ 2 files changed, 242 insertions(+), 468 deletions(-) create mode 100644 src/fx/fx.shr.80boxes.common.a diff --git a/src/fx/fx.shr.80boxes.a b/src/fx/fx.shr.80boxes.a index 0c38d4a04..311505b8c 100644 --- a/src/fx/fx.shr.80boxes.a +++ b/src/fx/fx.shr.80boxes.a @@ -6,154 +6,8 @@ !to "build/FX.INDEXED/SHR.80BOXES",plain *=$A000 -; The SHR screen in 320x200 mode is separated into 80 boxes. -; Boxes are laid out in a grid, left-to-right, top-down: -; -; 0 1 2 3 4 5 6 7 8 9 -; 10 11 12 13 14 15 16 17 18 19 -; 20 21 22 23 24 25 26 27 28 29 -; 30 31 32 33 34 35 36 37 38 39 -; 40 41 42 43 44 45 46 47 48 49 -; 50 51 52 53 54 55 56 57 58 59 -; 60 61 62 63 64 65 66 67 68 69 -; 70 71 72 73 74 75 76 77 78 79 -; -; Each box is 32x25 pixels, so each row of each box is 16 consecutive -; bytes in memory (2 pixels per byte) once you calculate the SHR base -; address for that row. -; -; |BoxStages| defines the initial grid of stages for each box. -; Each stage is used as an index into the |StagesHi| array -; to find the drawing routine for that stage (if any). -; Each box's stage is incremented after each iteration through the main loop. -; When the main loop iterates through all 80 boxes without drawing anything, -; the program exits. -; -; There are 7 clear routines that set certain pixels to color 0 (usually black) -; labeled clear00..clear06. clear00 clears the inner-most box, and -; clear06 clears the outermost box (see diagram). -; There are 7 copy routines that copy certain pixels from the source -; image in mainmem to the destination image in auxmem, labeled copy00..copy06. -; -; row| pixels -; ---+.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- -; 00 |66666666666666666666666666666666 -; 01 |66666666666666666666666666666666 -; 02 |66555555555555555555555555555566 -; 03 |66555555555555555555555555555566 -; 04 |66554444444444444444444444445566 -; 05 |66554444444444444444444444445566 -; 06 |66554433333333333333333333445566 -; 07 |66554433333333333333333333445566 -; 08 |66554433222222222222222233445566 -; 09 |66554433222222222222222233445566 -; 10 |66554433221111111111112233445566 -; 11 |66554433221111111111112233445566 -; 12 |66554433221100000000112233445566 -; 13 |66554433221111111111112233445566 -; 14 |66554433221111111111112233445566 -; 15 |66554433222222222222222233445566 -; 16 |66554433222222222222222233445566 -; 17 |66554433333333333333333333445566 -; 18 |66554433333333333333333333445566 -; 19 |66554444444444444444444444445566 -; 20 |66554444444444444444444444445566 -; 21 |66555555555555555555555555555566 -; 22 |66555555555555555555555555555566 -; 23 |66666666666666666666666666666666 -; 24 |66666666666666666666666666666666 -; -; Each routine manipulates pixels in horizontal pairs, meaning we can copy -; bytes without having to worry about masking high and low nibbles. -; Each routine except copy00 is similar, defined by 4 parameters: -; - top row (absolute row, i.e. 00..C7) -; - bottom row (should probably use the first of the two, also absolute) -; - left (should probably be in bytes, also absolute) -; - right (should probably be in bytes, also absolute) -; -; On [top row] and [top row + 1], copy bytes from [left offset] to [right offset] -; While [current row] < [bottom row], draw 1 byte at [left offset] and 1 byte at [right offset] -; On [bottom row] and [bottom row + 1], copy bytes from [left offset] to [right offset] + !source "src/fx/fx.shr.80boxes.common.a" -shrlo = $201 ; [$C8 bytes] -shrhi = $301 ; [$C8 bytes] - - !source "src/fx/macros.a" - !source "src/fx/fx.shr.common.a" - - ldx #0 -- ldy start, x - sty $00, x - sta EndStagesHi, x - inx - bne - - - stx seta+1 - stx sub1+1 - ldx #-25 - stx sub2+1 ---- ldx #8 -seta lda #0 --- pha - ldy #10-1 -- sta (BoxesY != >BoxesX) { - !error "Boxes array crosses a page" -} - -!align $FF,0,0 ; align to page -copy01 - +INIT_DRAW 10, 1, 5 - bit copy00 - !byte >copy01 - !byte >copy02 - !byte >copy03 - !byte >copy04 - !byte >copy05 - !byte >copy06 -EndStagesHi +StageInitialIndexes + !byte 1 + !byte 2 + !byte 3 + !byte 4 + !byte 5 + !byte 6 + !byte 7 +EndStageInitialIndexes diff --git a/src/fx/fx.shr.80boxes.common.a b/src/fx/fx.shr.80boxes.common.a new file mode 100644 index 000000000..19edd293d --- /dev/null +++ b/src/fx/fx.shr.80boxes.common.a @@ -0,0 +1,232 @@ +;license:MIT +;(c) 2021 by 4am & qkumba +; +; The SHR screen in 320x200 mode is separated into 80 boxes. +; Boxes are laid out in a grid, left-to-right, top-down: +; +; 0 1 2 3 4 5 6 7 8 9 +; 10 11 12 13 14 15 16 17 18 19 +; 20 21 22 23 24 25 26 27 28 29 +; 30 31 32 33 34 35 36 37 38 39 +; 40 41 42 43 44 45 46 47 48 49 +; 50 51 52 53 54 55 56 57 58 59 +; 60 61 62 63 64 65 66 67 68 69 +; 70 71 72 73 74 75 76 77 78 79 +; +; Each box is 32x25 pixels, so each row of each box is 16 consecutive +; bytes in memory (2 pixels per byte) once you calculate the SHR base +; address for that row. +; +; |BoxInitialStages| defines the initial grid of stages for each box. +; Each stage is used as an index into the |StageInitialIndexes| array +; to find the drawing routine for that stage (if any). +; Each box's stage is incremented after each iteration through the main loop. +; When the main loop iterates through all 80 boxes without drawing anything, +; the program exits. +; +; There are 7 copy routines that copy certain pixels from the source +; image in mainmem to the destination image in auxmem. Technically +; these all have the same entry point, with X = 1..7 on entry. +; We always copy pixels in horizontal pairs, meaning we can just copy +; bytes without having to worry about masking high and low nibbles. +; +; row| pixels +; ---+.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- +; 00 |77777777777777777777777777777777 +; 01 |77777777777777777777777777777777 +; 02 |77666666666666666666666666666677 +; 03 |77666666666666666666666666666677 +; 04 |77665555555555555555555555556677 +; 05 |77665555555555555555555555556677 +; 06 |77665544444444444444444444556677 +; 07 |77665544444444444444444444556677 +; 08 |77665544333333333333333344556677 +; 09 |77665544333333333333333344556677 +; 10 |77665544332222222222223344556677 +; 11 |77665544332222222222223344556677 +; 12 |77665544332211111111223344556677 +; 13 |77665544332222222222223344556677 +; 14 |77665544332222222222223344556677 +; 15 |77665544333333333333333344556677 +; 16 |77665544333333333333333344556677 +; 17 |77665544444444444444444444556677 +; 18 |77665544444444444444444444556677 +; 19 |77665555555555555555555555556677 +; 20 |77665555555555555555555555556677 +; 21 |77666666666666666666666666666677 +; 22 |77666666666666666666666666666677 +; 23 |77777777777777777777777777777777 +; 24 |77777777777777777777777777777777 +; + +!macro SET_ROW_X { +; out: Z=0 because shrhi is never 0 + lda shrlo, x + sta =$FF) { + !error "Code is too big to fit on zero page! ", *-start +} + +BoxInitialStages