← EGFX function index

EGFX · FUNCTION 39ALPHA · USE AT YOUR OWN RISK

FAST_SIN_Q7

Fast sine of a phase byte.

Looks up a signed Q7 sine, −127 to 127, for a phase byte where 256 units make a full turn (64 is +1). It uses the ROM’s own page-aligned table, the same one its arcs use. BASIC: FNegsin8(phase%), which wraps any integer. Assembler callers can JSR &8175 with the phase in A.

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 #39 : 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