#COMPILE EXE
#DIM NONE

FUNCTION PBMAIN () AS LONG

    PRINT "sinetwister"
    OPEN ".\circlebg.map" FOR BINARY AS #1
    DIM x AS INTEGER
    DIM y AS INTEGER
    DIM i AS INTEGER
    DIM a AS INTEGER
    DIM b AS INTEGER

    DIM ypos(0 TO 255) AS INTEGER
    DIM xpos(0 TO 255) AS INTEGER
    DIM starttile(0 TO 255) AS INTEGER

    FOR i  = 1 TO 64*64*2
    PUT$ #1, CHR$(0)

    NEXT i
    PRINT "STARTIG"

    i=0
    DIM p AS LONG
    DIM putter AS INTEGER
    FOR y = 0 TO 5
        FOR x = 0 TO 3

            ypos(i) = y*32
            xpos(i) = x*32
            starttile(i) = 1+(y*4+x)*16
            FOR a = 0 TO 3
            FOR b = 0 TO 3
                p = (ypos(i)/8+b)*64*2+((xpos(i)/8 + a)*2) +1
            REM print p;
                putter = starttile(i)+a*4+b
                PRINT putter;
                d$ = CHR$(&H40+INT(putter/256))
                PUT #1, p, d$
                d$ = CHR$(INT(putter MOD 256))
                PUT #1, p+1,    d$
            NEXT b
            NEXT a

            i=i+1
        NEXT x
    NEXT y


    WAITKEY$

END FUNCTION
