2019-10-18 18:00:25 +00:00
|
|
|
!ifndef _HGRMACROS_ {
|
|
|
|
!source "src/macros.a"
|
|
|
|
|
2019-10-21 20:00:38 +00:00
|
|
|
; .hgrlo, .hgr1hi will each be filled with $C0 bytes
|
2019-10-20 00:30:48 +00:00
|
|
|
; based on routine by John Brooks
|
|
|
|
; posted on comp.sys.apple2 on 2018-07-11
|
|
|
|
; https://groups.google.com/d/msg/comp.sys.apple2/v2HOfHOmeNQ/zD76fJg_BAAJ
|
2019-10-21 20:00:38 +00:00
|
|
|
!macro BUILD_HGR_LOOKUP_TABLES .hgrlo, .hgr1hi {
|
2019-10-20 00:30:48 +00:00
|
|
|
ldx #0
|
2020-10-26 04:38:16 +00:00
|
|
|
+BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 .hgrlo, .hgr1hi
|
|
|
|
}
|
|
|
|
|
|
|
|
!macro BUILD_HGR_LOOKUP_TABLES_X_IS_ALREADY_0 .hgrlo, .hgr1hi {
|
2019-10-20 00:30:48 +00:00
|
|
|
- txa
|
|
|
|
and #$F8
|
|
|
|
bpl +
|
|
|
|
ora #5
|
|
|
|
+ asl
|
|
|
|
bpl +
|
|
|
|
ora #5
|
|
|
|
+ asl
|
|
|
|
asl
|
|
|
|
sta .hgrlo,x
|
|
|
|
txa
|
|
|
|
and #7
|
|
|
|
rol
|
|
|
|
asl .hgrlo,x
|
|
|
|
rol
|
2019-10-23 05:15:33 +00:00
|
|
|
ora #$20
|
2019-10-20 00:30:48 +00:00
|
|
|
sta .hgr1hi,x
|
|
|
|
inx
|
|
|
|
cpx #$C0
|
|
|
|
bne -
|
|
|
|
}
|
|
|
|
|
2019-10-23 05:15:33 +00:00
|
|
|
; .hgrlomirror, .hgr1himirror will each be filled with $C0 bytes
|
|
|
|
!macro BUILD_HGR_MIRROR_LOOKUP_TABLES .hgrlomirror, .hgr1himirror {
|
|
|
|
ldx #$C0
|
|
|
|
ldy #0
|
|
|
|
- tya
|
|
|
|
and #$F8
|
|
|
|
bpl +
|
|
|
|
ora #5
|
|
|
|
+ asl
|
|
|
|
bpl +
|
|
|
|
ora #5
|
|
|
|
+ asl
|
|
|
|
asl
|
|
|
|
sta .hgrlomirror-1,x
|
|
|
|
tya
|
|
|
|
and #7
|
|
|
|
rol
|
|
|
|
asl .hgrlomirror-1,x
|
|
|
|
rol
|
|
|
|
ora #$20
|
|
|
|
sta .hgr1himirror-1,x
|
|
|
|
iny
|
|
|
|
dex
|
|
|
|
bne -
|
|
|
|
}
|
|
|
|
|
2018-11-03 15:04:09 +00:00
|
|
|
!macro HGR_CALC {
|
|
|
|
asl
|
|
|
|
tax
|
|
|
|
and #$F0
|
|
|
|
bpl @calc1
|
|
|
|
ora #$05
|
|
|
|
@calc1 bcc @calc2
|
|
|
|
ora #$0A
|
|
|
|
@calc2 asl
|
|
|
|
asl
|
|
|
|
sta $26
|
|
|
|
txa
|
|
|
|
and #$0E
|
|
|
|
adc #$10
|
|
|
|
asl $26
|
|
|
|
rol
|
|
|
|
sta $27
|
|
|
|
eor #$60
|
|
|
|
sta $3d
|
|
|
|
lda $26
|
|
|
|
sta $3c
|
|
|
|
}
|
|
|
|
|
2019-10-20 03:44:08 +00:00
|
|
|
!macro HGR_ROW_CALC {
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
asl
|
|
|
|
+HGR_CALC
|
|
|
|
}
|
|
|
|
|
2019-10-18 22:06:24 +00:00
|
|
|
; /!\ C must be clear before using this macro
|
2018-11-03 15:04:09 +00:00
|
|
|
!macro HGR_INC_WITHIN_BLOCK {
|
|
|
|
lda $27
|
|
|
|
adc #$04
|
|
|
|
sta $27
|
|
|
|
eor #$60
|
|
|
|
sta $3d
|
|
|
|
}
|
|
|
|
|
2019-10-18 19:41:41 +00:00
|
|
|
!macro RESET_HGR_CALC {
|
|
|
|
lda $27
|
|
|
|
sec
|
|
|
|
sbc #$20
|
|
|
|
sta $27
|
|
|
|
eor #$60
|
|
|
|
sta $3d
|
|
|
|
}
|
|
|
|
|
2019-10-24 19:41:08 +00:00
|
|
|
!macro COPY_BIT .src1, .dest1, .copymasks {
|
2019-10-26 02:06:13 +00:00
|
|
|
lda (.src1),y
|
|
|
|
eor (.dest1),y ; merge source and destination bits
|
|
|
|
and .copymasks,x ; isolate the bits to replace, zero the rest
|
|
|
|
eor (.dest1),y ; unmerge source and destination bits, leaves 'to keep' destination bits intact
|
|
|
|
sta (.dest1),y ; write the result
|
2019-10-24 19:41:08 +00:00
|
|
|
}
|
|
|
|
|
2019-10-26 02:06:13 +00:00
|
|
|
!macro SWITCH_TO_MASKS .copy {
|
|
|
|
lda #<.copy
|
|
|
|
sta CopyMaskAddr
|
|
|
|
lda #>.copy
|
|
|
|
sta CopyMaskAddr+1
|
2019-10-18 18:00:25 +00:00
|
|
|
}
|
|
|
|
|
2019-10-19 15:10:48 +00:00
|
|
|
; must set N flag based on Y immediately before using this macro
|
|
|
|
; e.g. LDY, INY, DEY, TYA
|
|
|
|
!macro IS_Y_OFFSCREEN {
|
|
|
|
bpl +
|
|
|
|
sec
|
|
|
|
bcs ++
|
|
|
|
+ cpy #40
|
|
|
|
++
|
|
|
|
}
|
|
|
|
|
2019-10-18 18:00:25 +00:00
|
|
|
_HGRMACROS_=*
|
2018-11-03 15:04:09 +00:00
|
|
|
}
|