mirror of
https://github.com/a2-4am/4cade.git
synced 2024-06-09 17:29:32 +00:00
146 lines
3.6 KiB
Plaintext
146 lines
3.6 KiB
Plaintext
;license:MIT
|
|
;(c) 2020 by 4am
|
|
;
|
|
!source "src/fx/fx.hgr.precomputed.1bit.a"
|
|
!source "src/fx/fx.dhgr.common.a"
|
|
|
|
!macro BUILD_SPARSE_BITMASKS_DHGR .copymasks, .mirror_copymasks {
|
|
; build sparse lookup tables for bitmasks
|
|
ldx #$00
|
|
txa
|
|
- sta .copymasks, x
|
|
sta $C005
|
|
sta .copymasks, x
|
|
sta $C004
|
|
inx
|
|
bne -
|
|
|
|
lda #%00000111
|
|
sta .copymasks+$80
|
|
sta .mirror_copymasks+$40
|
|
|
|
lda #%00011000
|
|
sta .copymasks+$A0
|
|
sta .mirror_copymasks+$20
|
|
|
|
lda #%01100000
|
|
sta .copymasks+$C0
|
|
sta .mirror_copymasks
|
|
|
|
sta $C005
|
|
|
|
lda #%10000011
|
|
sta .copymasks
|
|
sta .mirror_copymasks+$C0
|
|
|
|
lda #%10001100
|
|
sta .copymasks+$20
|
|
sta .mirror_copymasks+$A0
|
|
|
|
lda #%10110000
|
|
sta .copymasks+$40
|
|
sta .mirror_copymasks+$80
|
|
|
|
lda #%11000000
|
|
sta .copymasks+$60
|
|
sta .mirror_copymasks+$60
|
|
|
|
sta $C004
|
|
; X=0
|
|
}
|
|
|
|
!macro FX_PRECOMPUTED_1BIT_DHGR .coords {
|
|
+BUILD_SPARSE_BITMASKS_DHGR copymasks, mirror_copymasks
|
|
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 hgrlo, hgr1hi
|
|
+BUILD_HGR_MIRROR_LOOKUP_TABLES hgrlomirror, hgr1himirror
|
|
+BUILD_MIRROR_COLS mirror_cols
|
|
+COPY_SELF_TO_AUXMEM
|
|
+COPY_TO_0 start, end
|
|
jmp InputLoop
|
|
start
|
|
!pseudopc 0 {
|
|
Exit1Bit rts
|
|
InputLoop
|
|
ldy #0
|
|
input=*+1
|
|
ldx .coords ; first value: HGR row (only 0..95 will be in input array)
|
|
bmi Exit1Bit ; if > 127 then we're done
|
|
+ROW_X_TO_BASE_ADDRESSES
|
|
+ROW_X_TO_MIRROR_ADDRESSES
|
|
|
|
inc input
|
|
lda (input), y
|
|
+HIGH_3_LOW_5 input
|
|
sty <y
|
|
clc
|
|
bankloop
|
|
lda copymasks, x
|
|
beq +
|
|
sta <copymask
|
|
|
|
; main 1x2 block in top-left quadrant
|
|
src1=*+1
|
|
lda $FDFD, y
|
|
eor (<dest1), y
|
|
copymask=*+1
|
|
and #$FD ; SMC
|
|
eor (<dest1), y
|
|
dest1=*+1
|
|
sta $FDFD, y
|
|
src2=*+1
|
|
lda $FDFD, y
|
|
eor (<dest2), y
|
|
and <copymask
|
|
eor (<dest2), y
|
|
dest2=*+1
|
|
sta $FDFD, y
|
|
|
|
; corresponding 1x2 block in bottom-left quadrant (opposite row, original column)
|
|
+COPY_BIT_ZP mirror_src1, mirror_dest1, copymask
|
|
+COPY_BIT_ZP mirror_src2, mirror_dest2, copymask
|
|
|
|
+
|
|
lda mirror_copymasks, x
|
|
beq +
|
|
sta <mirror_copymask
|
|
; corresponding 1x2 block in bottom-right quadrant (opposite row, opposite column)
|
|
lda mirror_cols, y
|
|
tay
|
|
mirror_src1=*+1
|
|
lda $FDFD, y
|
|
eor (<mirror_dest1), y
|
|
mirror_copymask=*+1
|
|
and #$FD ; SMC
|
|
eor (<mirror_dest1), y
|
|
mirror_dest1=*+1
|
|
sta $FDFD, y
|
|
mirror_src2=*+1
|
|
lda $FDFD, y
|
|
eor (<mirror_dest2), y
|
|
and <mirror_copymask
|
|
eor (<mirror_dest2), y
|
|
mirror_dest2=*+1
|
|
sta $FDFD, y
|
|
|
|
; corresponding 1x2 block in top-right quadrant (same row, opposite column)
|
|
+COPY_BIT_ZP src1, dest1, mirror_copymask
|
|
+COPY_BIT_ZP src2, dest2, mirror_copymask
|
|
+
|
|
bcs +
|
|
sta $C003
|
|
sta $C005
|
|
y=*+1
|
|
ldy #$FD
|
|
sec
|
|
bcs bankloop
|
|
+ sta $C002
|
|
sta $C004
|
|
|
|
+INC_INPUT_AND_LOOP InputLoop
|
|
}
|
|
end
|
|
!if * and 1 {
|
|
!byte 0 ;align 2 but avoids the fake allocation bug if it was aligned already
|
|
}
|
|
}
|