;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