dos33fsprogs/graphics/hgr/sine/table_sine.s

68 lines
949 B
ArmAsm
Raw Normal View History

2022-01-26 05:06:20 +00:00
; table look up sine
; trying to make a 64 entry 32*sin() in the zero page
; want to beat 35 bytes (that's what the cos/ROM does)
; 57 bytes -- original
; 48 bytes -- optimize
; 46 bytes -- zero page
2022-01-25 20:44:27 +00:00
; zero page
2022-01-26 05:06:20 +00:00
2022-01-25 20:44:27 +00:00
HGR_X = $E0
HGR_XH = $E1
HGR_Y = $E2
HGR_COLOR = $E4
HGR_PAGE = $E6
FRAME = $FC
SUM = $FD
SAVEX = $FE
SAVEY = $FF
2022-01-26 05:06:20 +00:00
sinetable=$70
2022-01-25 20:44:27 +00:00
2022-01-26 05:06:20 +00:00
table_sine:
2022-01-25 20:44:27 +00:00
;==================
; create sinetable
2022-01-26 05:06:20 +00:00
ldx #0 ; Y is 0
ldy #$10
2022-01-25 20:44:27 +00:00
2022-01-26 05:06:20 +00:00
sinetable_loop:
2022-01-25 20:44:27 +00:00
lda sinetable_base,X ; 4+
2022-01-26 05:06:20 +00:00
sta sinetable+$10,X
sta sinetable+$00,Y
2022-01-25 20:44:27 +00:00
eor #$ff
2022-01-26 05:06:20 +00:00
sec ; these maybe not needed
adc #$0
2022-01-25 20:44:27 +00:00
2022-01-26 05:06:20 +00:00
sta sinetable+$30,X
sta sinetable+$20,Y
inx
dey
bpl sinetable_loop
2022-01-25 20:44:27 +00:00
; Y is 0 at this point?
done:
jmp done
sinetable_base:
; this is actually (32*sin(x))
2022-01-26 05:06:20 +00:00
;.byte $00,$03,$06,$09,$0C,$0F,$11,$14
;.byte $16,$18,$1A,$1C,$1D,$1E,$1F,$1F,$20
2022-01-25 20:44:27 +00:00
2022-01-26 05:06:20 +00:00
.byte $20,$1F,$1F,$1E,$1D,$1C,$1A,$18,$16
.byte $14,$11,$0F,$0C,$09,$06,$03,$00
2022-01-25 20:44:27 +00:00