DECLARE SUB setpal ()
'Future.Library simple map generater and software scrolling
'

'use arrow keys to scroll

DECLARE SUB DrawScreen4 ()
DECLARE SUB DrawScreen2 ()
DECLARE SUB DrawScreen3 ()
DECLARE SUB DrawScreen1 ()
DECLARE SUB Drawstuff ()
DECLARE SUB Drawdonuts ()

REM $INCLUDE: 'future.bi'

Set320x200 8'Set 320x200

KBHon

FOR I% = 0 TO 255
ChangePal I%, 0, 0, 0
NEXT


DIM SHARED Ball%(0 TO 130)
DIM SHARED Ball1%(0 TO 130)
DIM SHARED Ball2%(0 TO 130)
DIM SHARED Ball3%(0 TO 130)

Drawstuff

DIM SHARED X!(350), Y!(350), DX!(350), DY!(350)

FOR I% = 0 TO 350
DX!(I%) = 2 - (RND * 4)
DY!(I%) = 2 - (RND * 4)
X!(I%) = 160
Y!(I%) = 100
NEXT

Future.MouseOn

handle% = AllExpMem(256000)'get 256000 of EMS memory

Future.CLS 0
DrawScreen1
offsetX% = 0: offsetY% = 0
Future.EMSGet offsetX% + 0, offsetY% + 0, offsetX% + 639, offsetY% + 399, handle%
Future.CLS 0
DrawScreen2
offsetX% = -320: offsetY% = 0
Future.EMSGet offsetX% + 0, offsetY% + 0, offsetX% + 639, offsetY% + 399, handle%
Future.CLS 0
DrawScreen3
offsetX% = 0: offsetY% = -200
Future.EMSGet offsetX% + 0, offsetY% + 0, offsetX% + 639, offsetY% + 399, handle%
Future.CLS 0
DrawScreen4
offsetX% = -320: offsetY% = -200
Future.EMSGet offsetX% + 0, offsetY% + 0, offsetX% + 639, offsetY% + 399, handle%

posY% = -100
posX% = -160
Future.EMSPut posX%, posY%, handle%'redraw map


setpal
Future.CLS 0
DO
SetViewPort 0, 30, 320, 170
P% = P% XOR 1
SetPage P%

IF GetKey%(72) THEN posY% = posY% + 1: IF posY% >= 0 THEN posY% = 0
IF GetKey%(80) THEN posY% = posY% - 1: IF posY% <= -200 THEN posY% = -200
IF GetKey%(75) THEN posX% = posX% + 1: IF posX% >= 0 THEN posX% = 0
IF GetKey%(77) THEN posX% = posX% - 1: IF posX% <= -320 THEN posX% = -320

Future.EMSPut posX%, posY%, handle%'redraw map

SetMaskColor 0
Drawdonuts
SetMaskColor -1
SetViewPort 0, 0, 320, 200
ViewPage P%

LOOP UNTIL GetKey%(1)

KBHoff
DeallExpMem handle%  'free EMS memory
ReSetScreen

SUB Drawdonuts

FOR I% = 0 TO 15
X!(I%) = X!(I%) + DX!(I%)
IF X!(I%) > 320 THEN X!(I%) = -16
IF X!(I%) < -16 THEN X!(I%) = 320
Y!(I%) = Y!(I%) + DY!(I%)
IF Y!(I%) > 200 THEN Y!(I%) = -16
IF Y!(I%) < -16 THEN Y!(I%) = 200
Future.PUT INT(X!(I%)), INT(Y!(I%)), Ball%()
NEXT
FOR I% = 16 TO 31
X!(I%) = X!(I%) + DX!(I%)
IF X!(I%) > 320 THEN X!(I%) = -16
IF X!(I%) < -16 THEN X!(I%) = 320
Y!(I%) = Y!(I%) + DY!(I%)
IF Y!(I%) > 200 THEN Y!(I%) = -16
IF Y!(I%) < -16 THEN Y!(I%) = 200
Future.PUT INT(X!(I%)), INT(Y!(I%)), Ball1%()
NEXT

FOR I% = 32 TO 47
X!(I%) = X!(I%) + DX!(I%)
IF X!(I%) > 320 THEN X!(I%) = -16
IF X!(I%) < -16 THEN X!(I%) = 320
Y!(I%) = Y!(I%) + DY!(I%)
IF Y!(I%) > 200 THEN Y!(I%) = -16
IF Y!(I%) < -16 THEN Y!(I%) = 200
Future.PUT INT(X!(I%)), INT(Y!(I%)), Ball2%()
NEXT

FOR I% = 48 TO 62
X!(I%) = X!(I%) + DX!(I%)
IF X!(I%) > 320 THEN X!(I%) = -16
IF X!(I%) < -16 THEN X!(I%) = 320
Y!(I%) = Y!(I%) + DY!(I%)
IF Y!(I%) > 200 THEN Y!(I%) = -16
IF Y!(I%) < -16 THEN Y!(I%) = 200
Future.PUT INT(X!(I%)), INT(Y!(I%)), Ball3%()
NEXT

END SUB

SUB DrawScreen1

DIM temp%(130)

FOR I% = 0 TO 7
Future.BOX 7 - I%, 7 - I%, 7 + I%, 7 + I%, I% + 1
NEXT

Future.GET 0, 0, 15, 15, temp%()

FOR Y% = 0 TO 200 STEP 16
    FOR X% = 0 TO 320 STEP 16
       Future.PUT X%, Y%, temp%()
    NEXT
NEXT
END SUB

SUB DrawScreen2

DIM temp%(130)
FOR I% = 0 TO 7
Future.BOX 7 - I%, 7 - I%, 7 + I%, 7 + I%, I% + 1 + 32
NEXT

Future.GET 0, 0, 15, 15, temp%()

FOR Y% = 0 TO 200 STEP 16
    FOR X% = 0 TO 320 STEP 16
        Future.PUT X%, Y%, temp%()
    NEXT
NEXT

END SUB

SUB DrawScreen3


DIM temp%(130)
FOR I% = 0 TO 7
Future.BOX 7 - I%, 7 - I%, 7 + I%, 7 + I%, I% + 1 + 16
NEXT

Future.GET 0, 0, 15, 15, temp%()

FOR Y% = -8 TO 200 STEP 16
    FOR X% = 0 TO 320 STEP 16
        Future.PUT X%, Y%, temp%()
    NEXT
NEXT

END SUB

SUB DrawScreen4

DIM temp%(130)
FOR I% = 0 TO 7
Future.BOX 7 - I%, 7 - I%, 7 + I%, 7 + I%, I% + 1 + 24
NEXT

Future.GET 0, 0, 15, 15, temp%()

FOR Y% = -8 TO 200 STEP 16
    FOR X% = 0 TO 320 STEP 16
        Future.PUT X%, Y%, temp%()
    NEXT
NEXT


END SUB

SUB Drawstuff

Future.CLS 0
FOR I% = 1 TO 4
Future.CIRCLE 7, 7, 8 - I%, (I%)
Future.CIRCLE 7, 8, 8 - I%, (I%)
Future.CIRCLE 8, 7, 8 - I%, (I%)
Future.CIRCLE 8, 8, 8 - I%, (I%)
NEXT
Future.GET 0, 0, 15, 15, Ball%()

Future.CLS 0
FOR I% = 1 TO 4
Future.CIRCLE 7, 7, 8 - I%, (I% + 16)
Future.CIRCLE 7, 8, 8 - I%, (I% + 16)
Future.CIRCLE 8, 7, 8 - I%, (I% + 16)
Future.CIRCLE 8, 8, 8 - I%, (I% + 16)
NEXT
Future.GET 0, 0, 15, 15, Ball1%()

Future.CLS 0
FOR I% = 1 TO 4
Future.CIRCLE 7, 7, 8 - I%, (I% + 24)
Future.CIRCLE 7, 8, 8 - I%, (I% + 24)
Future.CIRCLE 8, 7, 8 - I%, (I% + 24)
Future.CIRCLE 8, 8, 8 - I%, (I% + 24)
NEXT
Future.GET 0, 0, 15, 15, Ball2%()

Future.CLS 0
FOR I% = 1 TO 4
Future.CIRCLE 7, 7, 8 - I%, (I% + 32)
Future.CIRCLE 7, 8, 8 - I%, (I% + 32)
Future.CIRCLE 8, 7, 8 - I%, (I% + 32)
Future.CIRCLE 8, 8, 8 - I%, (I% + 32)
NEXT
Future.GET 0, 0, 15, 15, Ball3%()


END SUB

SUB setpal

FOR I% = 0 TO 7
ChangePal 1 + I%, (7 - I%) * 8, 0, 0
NEXT

FOR I% = 0 TO 7
ChangePal 1 + I% + 32, 0, (7 - I%) * 8, 0
NEXT

FOR I% = 0 TO 7
ChangePal 1 + I% + 16, 0, 0, (7 - I%) * 8
NEXT

FOR I% = 0 TO 7
ChangePal 1 + I% + 24, (7 - I%) * 8, (7 - I%) * 8, 0
NEXT


ChangePal 15, 63, 63, 63

END SUB

