← EGFX function index

EGFX · FUNCTION 40ALPHA · USE AT YOUR OWN RISK

FAST_COS_Q7

Fast cosine of a phase byte.

The sine table read 64 phase units later. BASIC: FNegcos8(phase%); direct entry &8178. The example for function 39 uses both.

Parameters

NameBytesDescription
PHASE8phase byte in; signed result byte out

BASIC example

Tested listing: ex39.bas, run in B-em on a Master 128. Append the EGFX helpers from gfx-basic.bas (the build does this for you), and put the Breakout EGASSETS.rom (with the beta release) in slot 7 where the example draws from &81/&87.

10 MODE 1:HIMEM=&2400:PROCeginit
20 PROCegbegin
30 FOR t%=0 TO 255 STEP 4
40 PROCegpixel(160+100*FNegsin8(t%) DIV 127,128+100*FNegcos8(t%) DIV 127,3)
50 NEXT
60 PROCegtext("FN39 OK",8,8):PROCegpresent
70 END

Assembly

        LDA #40 : STA block+5      ; function
        LDA #0  : STA block+7      ; clear ACK
        LDA #&C0 : LDX #block MOD 256 : LDY #block DIV 256
        JSR &FFF1                  ; OSWORD &C0; block+7 = &A5 on success

← Function index