mirror of
https://github.com/a2-4am/4cade.git
synced 2025-01-01 15:32:00 +00:00
unrolled loops and other optimizations in soft diagonal effect
This commit is contained in:
parent
57465a59af
commit
347b8b0adb
@ -10,8 +10,21 @@ row = $fd
|
|||||||
col = $fe
|
col = $fe
|
||||||
counter = $ff
|
counter = $ff
|
||||||
|
|
||||||
|
hgrlo = $0200 ; [$C0 bytes]
|
||||||
|
hgr1hi = $0300 ; [$C0 bytes]
|
||||||
|
|
||||||
!source "src/fx/macros.a"
|
!source "src/fx/macros.a"
|
||||||
!source "src/constants.a"
|
|
||||||
|
!macro RESET_HGR_CALC_BY_7 {
|
||||||
|
lda $27
|
||||||
|
sec
|
||||||
|
sbc #$1c
|
||||||
|
sta $27
|
||||||
|
eor #$60
|
||||||
|
sta $3d
|
||||||
|
}
|
||||||
|
|
||||||
|
+BUILD_HGR_LOOKUP_TABLES hgrlo, hgr1hi
|
||||||
|
|
||||||
lda #(40+24+7-1) ; columns + rows + blocks per row - 1
|
lda #(40+24+7-1) ; columns + rows + blocks per row - 1
|
||||||
sta counter
|
sta counter
|
||||||
@ -29,108 +42,121 @@ RowLoop
|
|||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
asl
|
asl
|
||||||
+HGR_CALC
|
tax
|
||||||
|
lda hgrlo, x
|
||||||
|
sta $26
|
||||||
|
sta $3c
|
||||||
|
lda hgr1hi, x
|
||||||
|
sta $27
|
||||||
|
eor #$60
|
||||||
|
sta $3d
|
||||||
|
|
||||||
ldy y
|
ldy y
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block2
|
+LBCS @block2
|
||||||
|
|
||||||
; [speedopt] HGRBlockCopyWithMask but hardcoded for this block's masks
|
; [speedopt] HGRBlockCopyWithMask but hardcoded for this block's masks
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks1
|
+COPY_BIT $3c, $26, copymasks1
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
|
}
|
||||||
; [speedopt] reset HGR base addresses instead of recalculating them from scratch
|
; [speedopt] reset HGR base addresses instead of recalculating them from scratch
|
||||||
+RESET_HGR_CALC
|
+RESET_HGR_CALC_BY_7
|
||||||
@block2
|
@block2
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block3
|
+LBCS @block3
|
||||||
|
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks2
|
+COPY_BIT $3c, $26, copymasks2
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
+RESET_HGR_CALC
|
}
|
||||||
|
+RESET_HGR_CALC_BY_7
|
||||||
@block3
|
@block3
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block4
|
+LBCS @block4
|
||||||
|
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks3
|
+COPY_BIT $3c, $26, copymasks3
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
+RESET_HGR_CALC
|
}
|
||||||
|
+RESET_HGR_CALC_BY_7
|
||||||
@block4
|
@block4
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block5
|
+LBCS @block5
|
||||||
|
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks4
|
+COPY_BIT $3c, $26, copymasks4
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
+RESET_HGR_CALC
|
}
|
||||||
|
+RESET_HGR_CALC_BY_7
|
||||||
@block5
|
@block5
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block6
|
+LBCS @block6
|
||||||
|
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks5
|
+COPY_BIT $3c, $26, copymasks5
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
+RESET_HGR_CALC
|
}
|
||||||
|
+RESET_HGR_CALC_BY_7
|
||||||
@block6
|
@block6
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @block7
|
+LBCS @block7
|
||||||
|
|
||||||
ldx #7
|
ldx #7
|
||||||
clc
|
clc
|
||||||
-
|
!for i, 0, 7 {
|
||||||
+COPY_BIT $3c, $26, copymasks6
|
+COPY_BIT $3c, $26, copymasks6
|
||||||
+HGR_INC_WITHIN_BLOCK
|
!if i < 7 {
|
||||||
dex
|
dex
|
||||||
bpl -
|
+HGR_INC_WITHIN_BLOCK
|
||||||
|
}
|
||||||
+RESET_HGR_CALC
|
}
|
||||||
|
+RESET_HGR_CALC_BY_7
|
||||||
@block7
|
@block7
|
||||||
iny
|
iny
|
||||||
+IS_Y_OFFSCREEN
|
+IS_Y_OFFSCREEN
|
||||||
bcs @nextrow
|
+LBCS @nextrow
|
||||||
|
|
||||||
; [speedopt] HGRBlockCopy but inlined
|
; [speedopt] HGRBlockCopy but inlined
|
||||||
ldx #7
|
|
||||||
clc
|
clc
|
||||||
- lda ($3c),y
|
!for i, 0, 7 {
|
||||||
|
lda ($3c),y
|
||||||
sta ($26),y
|
sta ($26),y
|
||||||
|
!if i < 7 {
|
||||||
+HGR_INC_WITHIN_BLOCK
|
+HGR_INC_WITHIN_BLOCK
|
||||||
dex
|
}
|
||||||
bpl -
|
}
|
||||||
|
; don't need RESET_HGR_CALC_BY_7 here because we're done with this row
|
||||||
; don't need RESET_HGR_CALC here because we're done with this row
|
|
||||||
@nextrow
|
@nextrow
|
||||||
ldy y
|
ldy y
|
||||||
iny
|
iny
|
||||||
|
Loading…
Reference in New Issue
Block a user