2019-10-28 00:28:28 +00:00
|
|
|
;license:MIT
|
2024-05-27 17:32:07 +00:00
|
|
|
;(c) 2019-2024 by 4am
|
2019-10-28 00:28:28 +00:00
|
|
|
;
|
2024-05-26 17:41:21 +00:00
|
|
|
|
2024-05-27 17:32:07 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; YE OLDE GRAND UNIFIED MEMORY MAP
|
|
|
|
;
|
|
|
|
; 0201..02C0 - hgrlo
|
|
|
|
; 02C1..02E8 - mirror_cols
|
|
|
|
; 02E9..0300
|
|
|
|
; 0301..03C0 - hgrhi
|
|
|
|
; 03C1..03EE
|
|
|
|
; 6000.. - module code (length varies)
|
|
|
|
; 8100..BD00 - Coordinates2Bit
|
|
|
|
; BD01..BDA9
|
|
|
|
; BDA8..BDFF - dithermasks
|
|
|
|
; BE00..BEFF - copymasks2bit
|
|
|
|
; BF00..BFFF - ProRWTS glue
|
|
|
|
;
|
2019-10-28 00:28:28 +00:00
|
|
|
|
|
|
|
!source "src/fx/macros.a"
|
|
|
|
|
2020-11-13 04:26:15 +00:00
|
|
|
!macro FX_INITONCE_2BIT .CoordinatesFile, .Start {
|
|
|
|
InitOnce
|
|
|
|
bit .Start
|
|
|
|
lda #$4C
|
|
|
|
sta InitOnce
|
2024-05-25 17:07:22 +00:00
|
|
|
|
|
|
|
+LDADDR .CoordinatesFile
|
|
|
|
ldx #>Coordinates2Bit
|
|
|
|
jsr iLoadFXDATA
|
|
|
|
|
2020-11-13 04:26:15 +00:00
|
|
|
lda #$00
|
2022-08-25 02:30:49 +00:00
|
|
|
sta EndCoordinates2Bit
|
2020-11-13 04:26:15 +00:00
|
|
|
}
|
|
|
|
|
2022-08-25 02:30:49 +00:00
|
|
|
!macro FX_PRECOMPUTED_2BIT_DITHER .coords, .endcoords {
|
2024-05-27 17:32:07 +00:00
|
|
|
jsr iBuildHGRDitherMasks
|
2024-05-26 17:41:21 +00:00
|
|
|
jsr iBuildHGRTables
|
2024-05-27 17:32:07 +00:00
|
|
|
jsr iBuildHGRMirrorCols
|
|
|
|
jsr iBuildHGRSparseBitmasks2Bit
|
2022-08-25 02:30:49 +00:00
|
|
|
|
|
|
|
; phase 1 - in reverse, with additional masking (dithering)
|
|
|
|
jsr copytozp
|
|
|
|
|
|
|
|
; 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 #$00
|
|
|
|
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 -
|
|
|
|
|
|
|
|
jsr InputLoop
|
|
|
|
|
|
|
|
bit KBD
|
|
|
|
bmi start
|
|
|
|
|
|
|
|
; phase 2 - in order, without additional masking
|
|
|
|
jsr copytozp
|
|
|
|
|
|
|
|
; redirect additional masking pointers to an array that contains #$FFs (so no dithering)
|
|
|
|
lda #<no_masks
|
|
|
|
sta <evenrow_ptr
|
|
|
|
sta <oddrow_ptr
|
|
|
|
|
|
|
|
jmp InputLoop
|
|
|
|
|
|
|
|
copytozp
|
|
|
|
+COPY_TO_0 start, end
|
|
|
|
start
|
|
|
|
!pseudopc 0 {
|
|
|
|
Exit2Bit rts
|
|
|
|
evenrow_ptr
|
|
|
|
!word evenrow_masks
|
|
|
|
oddrow_ptr
|
|
|
|
!word oddrow_masks
|
|
|
|
InputLoop
|
|
|
|
ldy #0
|
|
|
|
input=*+1
|
|
|
|
ldx .coords ; first value: HGR row + 1
|
|
|
|
beq Exit2Bit ; if 0 then we're done
|
2024-05-28 22:57:51 +00:00
|
|
|
+ROW_X_TO_2BIT_BASE_ADDRESSES src1, src2, dest1, dest2
|
2022-08-25 02:30:49 +00:00
|
|
|
|
|
|
|
iny
|
|
|
|
lda (<input), y
|
|
|
|
+HIGH_3_LOW_5 input
|
|
|
|
|
|
|
|
; main 2x2 block in left half
|
|
|
|
src1=*+1
|
|
|
|
lda $FDFD, y
|
|
|
|
eor (<dest1), y
|
2024-05-27 17:32:07 +00:00
|
|
|
and copymasks2bit, x
|
2022-08-25 02:30:49 +00:00
|
|
|
and (<evenrow_ptr), y
|
|
|
|
eor (<dest1), y
|
|
|
|
dest1=*+1
|
|
|
|
sta $FDFD, y
|
|
|
|
src2=*+1
|
|
|
|
lda $FDFD, y
|
|
|
|
eor (<dest2), y
|
2024-05-27 17:32:07 +00:00
|
|
|
and copymasks2bit, x
|
2022-08-25 02:30:49 +00:00
|
|
|
and (<oddrow_ptr), y
|
|
|
|
eor (<dest2), y
|
|
|
|
dest2=*+1
|
|
|
|
sta $FDFD, y
|
|
|
|
|
|
|
|
; corresponding 2x2 block in right half (same row, opposite column)
|
|
|
|
lda mirror_cols, y
|
|
|
|
tay
|
|
|
|
lda (src1), y
|
|
|
|
eor (dest1), y
|
2024-05-27 17:32:07 +00:00
|
|
|
and mirror_copymasks2bit, x
|
2022-08-25 02:30:49 +00:00
|
|
|
and (<evenrow_ptr), y
|
|
|
|
eor (dest1), y
|
|
|
|
sta (dest1), y
|
|
|
|
|
|
|
|
lda (src2), y
|
|
|
|
eor (dest2), y
|
2024-05-27 17:32:07 +00:00
|
|
|
and mirror_copymasks2bit, x
|
2022-08-25 02:30:49 +00:00
|
|
|
and (<oddrow_ptr), y
|
|
|
|
eor (dest2), y
|
|
|
|
sta (dest2), y
|
|
|
|
|
|
|
|
next
|
|
|
|
inc <input
|
|
|
|
inc <input
|
|
|
|
bne InputLoop
|
|
|
|
bit KBD
|
|
|
|
bmi Exit2Bit
|
|
|
|
inc <input+1
|
|
|
|
bne InputLoop ; always branches
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
next2_start
|
|
|
|
!pseudopc next {
|
|
|
|
lda <input
|
|
|
|
php
|
|
|
|
dec <input
|
|
|
|
dec <input
|
|
|
|
plp
|
|
|
|
bne InputLoop
|
|
|
|
dec <input+1
|
|
|
|
bit KBD
|
|
|
|
bpl InputLoop
|
|
|
|
rts
|
|
|
|
}
|
|
|
|
next2_end
|
2019-10-28 00:28:28 +00:00
|
|
|
}
|