dos33fsprogs/vaporlock/demo/sinetable.s

55 lines
842 B
ArmAsm
Raw Normal View History

2023-05-18 17:43:07 +00:00
;=================================
; fakes sines based on parabolas
2023-05-18 20:57:20 +00:00
; based on code by White Flame via Cruzer/Camelot
; from codebase64
2023-05-18 17:43:07 +00:00
;=================================
; makes 256 entries, min 0 max 127
2023-05-18 20:57:20 +00:00
; call with X=0!
;DELTA = $2000
;VALUE = $2002
2023-05-18 17:43:07 +00:00
initSineTable:
ldy #$3f
2023-05-18 20:57:20 +00:00
; ldx #$00
2023-05-18 17:43:07 +00:00
; Accumulate the delta (16-bit addition)
init_sine_loop:
2023-05-18 20:57:20 +00:00
value_l_smc:
lda #0
2023-05-18 17:43:07 +00:00
clc
adc DELTA
2023-05-18 20:57:20 +00:00
sta value_l_smc+1
value_h_smc:
lda #0
2023-05-18 17:43:07 +00:00
adc DELTA+1
2023-05-18 20:57:20 +00:00
sta value_h_smc+1
2023-05-18 17:43:07 +00:00
; Reflect the value around for a sine wave
2023-05-18 20:57:20 +00:00
sta sine+$c0,X
sta sine+$80,Y
2023-05-18 17:43:07 +00:00
eor #$7f
2023-05-18 20:57:20 +00:00
sta sine+$40,X
sta sine+$00,Y
2023-05-18 17:43:07 +00:00
; Increase the delta, which creates the
; "acceleration" for a parabola
lda DELTA
adc #$08 ; this value adds up to the proper amplitude
sta DELTA
bcc init_sine_noflo
inc DELTA+1
init_sine_noflo:
; Loop
inx
dey
bpl init_sine_loop
2023-05-18 20:57:20 +00:00
; rts
2023-05-18 17:43:07 +00:00