#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN () AS LONG

    PRINT "sinetwister"
    OPEN ".\SINETABLE.BIN" FOR BINARY AS #1
    DIM x AS INTEGER
    DIM i AS INTEGER
    DIM a AS INTEGER
    DIM pi AS DOUBLE
    pi = 3.1415926535
    FOR x = 0 TO 3
        FOR i = 0 TO 511
            a = SIN((i/2)/128*pi)*76 +76
            PRINT a; " ";
            PUT$ #1, CHR$(INT(a/256)) + CHR$(INT(a MOD 256))
        NEXT i
    NEXT x


    CLOSE

    PRINT "sinetwister"
    OPEN ".\SINETABLE2.BIN" FOR BINARY AS #1
    pi = 3.1415926535
    FOR x = 0 TO 3
        FOR i = 0 TO 511
            a = SIN((i/2)/128*pi)*255 +255
            PRINT a; " ";
            PUT$ #1, CHR$(INT(a/256)) + CHR$(INT(a MOD 256))
        NEXT i
    NEXT x


    CLOSE
    WAITKEY$

END FUNCTION
