annotations, tweak

This commit is contained in:
Brooke Vibber 2024-12-30 19:17:02 -08:00
parent ed79c80b16
commit 67649d4743

View file

@ -310,18 +310,21 @@ viewport_oy:
.endrepeat .endrepeat
.endmacro .endmacro
; 20 cycles
.macro add16 dest, arg1, arg2 .macro add16 dest, arg1, arg2
add 2, dest, arg1, arg2 add 2, dest, arg1, arg2
.endmacro .endmacro
; 38 cycles
.macro add32 dest, arg1, arg2 .macro add32 dest, arg1, arg2
add 4, dest, arg2, dest add 4, dest, arg2, dest
.endmacro .endmacro
; 8 cycles
.macro add_carry dest .macro add_carry dest
lda dest lda dest ; 3 cyc
adc #0 adc #0 ; 2 cyc
sta dest sta dest ; 3 cyc
.endmacro .endmacro
; 2 + 9 * byte cycles ; 2 + 9 * byte cycles
@ -334,29 +337,35 @@ viewport_oy:
.endrepeat .endrepeat
.endmacro .endmacro
; 20 cycles
.macro sub16 dest, arg1, arg2 .macro sub16 dest, arg1, arg2
sub 2, dest, arg1, arg2 sub 2, dest, arg1, arg2
.endmacro .endmacro
; 38 cycles
.macro sub32 dest, arg1, arg2 .macro sub32 dest, arg1, arg2
sub 4, dest, arg1, arg2 sub 4, dest, arg1, arg2
.endmacro .endmacro
; 3 + 5 * bytes cycles
.macro shl bytes, arg .macro shl bytes, arg
asl arg asl arg ; 3 cyc
.repeat bytes-1, i .repeat bytes-1, i
rol arg + 1 + i rol arg + 1 + i ; 5 cyc
.endrepeat .endrepeat
.endmacro .endmacro
; 13 cycles
.macro shl16 arg .macro shl16 arg
shl 2, arg shl 2, arg
.endmacro .endmacro
; 18 cycles
.macro shl24 arg .macro shl24 arg
shl 3, arg shl 3, arg
.endmacro .endmacro
; 23 cycles
.macro shl32 arg .macro shl32 arg
shl 4, arg shl 4, arg
.endmacro .endmacro
@ -369,14 +378,17 @@ viewport_oy:
.endrepeat .endrepeat
.endmacro .endmacro
; 12 cycles
.macro copy16 dest, arg .macro copy16 dest, arg
copy 2, dest, arg copy 2, dest, arg
.endmacro .endmacro
; 24 cycles
.macro copy32 dest, arg .macro copy32 dest, arg
copy 4, dest, arg copy 4, dest, arg
.endmacro .endmacro
; 36 cycles
.macro copyfloat dest, arg .macro copyfloat dest, arg
copy 6, dest, arg copy 6, dest, arg
.endmacro .endmacro
@ -401,9 +413,10 @@ viewport_oy:
neg 4, arg neg 4, arg
.endmacro .endmacro
; 23 * shift
.macro shift_round_16 arg, shift .macro shift_round_16 arg, shift
.repeat shift .repeat shift
shl32 arg shl32 arg ; 23 cycles
.endrepeat .endrepeat
round16 arg round16 arg
.endmacro .endmacro
@ -806,6 +819,7 @@ arg2_pos:
sqr16_impl 1 sqr16_impl 1
.endproc .endproc
; 11-27 cycles
.macro round16 arg .macro round16 arg
; Round top 16 bits of 32-bit fixed-point number in-place ; Round top 16 bits of 32-bit fixed-point number in-place
.local increment .local increment
@ -818,21 +832,28 @@ arg2_pos:
; round down if negative ; round down if negative
; < $8000: round down ; < $8000: round down
lda arg + 1 ; $8000 17
cmp #$80 ; $8001 27
beq high_half ; $8100 21
bpl increment ; $7fff 11
bmi next
lda arg + 1 ; 3 cyc
cmp #$80 ; 2 cyc
beq high_half ; 2 cyc
bpl increment ; 2 cyc
bmi next ; 2 cyc
high_half: high_half:
lda arg lda arg ; 3 cyc
beq check_sign beq check_sign ; 2 cyc
bpl increment
bmi next jmp increment ; 3 cyc
check_sign: check_sign:
lda arg + 3 lda arg + 3 ; 3 cyc
bmi next bmi next ; 2 cyc
increment: ; 5-10 cyc increment: ; 5-10 cyc
inc arg + 2 ; 5 cyc inc arg + 2 ; 5 cyc