VAR long speed, dira_, ctrb_, cnt_, volume PUB start(pos_pin, neg_pin) dira_ |= (|< pos_pin + |< neg_pin) ctrb_ := $1C000000 + (pos_pin & $3F) + ((neg_pin & $3F) << 9) speed := $007FFFFF volume := 0 cnt_ := clkfreq / 44_100 return cognew(@entry, @speed) PUB change1(parameter) speed := parameter PUB change2(parameter) volume := parameter & %0111 DAT entry org call #initial jmp #loop retadd long :wait :wait jmpret retadd,#loop jmp #:wait loop waitcnt cnt_value,cnt_ticks mov y,x mov t1,par add t1,#4*4 rdlong t2,t1 and t2,#%0111 sar x,t2 add x,h80000000 mov frqb,x mov t1,par rdlong t2,t1 add phase,t2 mov t2,phase shr t2,#32-13 'get 13-bit angle test t2,h00001000 wz 'get sine quadrant 3|4 into nz test t2,h00000800 wc 'get sine quadrant 2|4 into c negc t2,t2 'if sine quadrant 2|4, negate table offset or t2,h00007000 'insert sine table base address >> 1 shl t2,#1 'shift left to get final word address rdword t1,t2 'read sine word from table negnz t1,t1 'if quadrant 3|4, negate word shl t1,#7 mov x,y add x,t1 jmp retadd initial mov reserves,#0 add initial,d0 djnz clear_cnt,#initial mov t1,par add t1,#4 rdlong dira,t1 add t1,#4 rdlong ctrb,t1 add t1,#4 rdlong cnt_ticks,t1 mov cnt_value,cnt add cnt_value,cnt_ticks initial_ret ret h80000000 long $80000000 h7FFFFFFF long $7FFFFFFF h00007000 long $00007000 h00001000 long $00001000 h00000800 long $00000800 d0 long $00000200 clear_cnt long $1F0 - reserves reserves cnt_ticks res 1 cnt_value res 1 x res 1 y res 1 t1 res 1 t2 res 1 phase res 1