mirror of
https://github.com/dschmenk/VM02.git
synced 2024-12-02 22:49:48 +00:00
127 lines
2.5 KiB
Plaintext
127 lines
2.5 KiB
Plaintext
|
CONST FALSE = 0
|
||
|
CONST TRUE = NOT FALSE
|
||
|
CONST SHOWLORES = $C056
|
||
|
CONST KEYBOARD = $C000
|
||
|
CONST KEYSTROBE = $C010
|
||
|
CONST EMPTY = 0
|
||
|
CONST TREE = 4
|
||
|
CONST FIRE = 13
|
||
|
CONST FORESTSIZE = 42*42
|
||
|
BYTE HELLOMSG[] = "PRESS ANY KEY TO BEGIN..."
|
||
|
BYTE EXITMSG[] = "PRESS ANY KEY TO EXIT."
|
||
|
BYTE GOODBYE[] = "THAT'S ALL FOLKS!"
|
||
|
BYTE TREES1[FORESTSIZE]
|
||
|
BYTE TREES2[FORESTSIZE]
|
||
|
WORD RNDNUM
|
||
|
|
||
|
DEF TEXTMODE
|
||
|
DROP ROMCALL(0, 0, 0, 0, $FB39)
|
||
|
END
|
||
|
|
||
|
DEF HOME
|
||
|
DROP ROMCALL(0, 0, 0, 0, $FC58)
|
||
|
END
|
||
|
|
||
|
DEF GOTOXY(X, Y)
|
||
|
^($24) = X
|
||
|
DROP ROMCALL(Y, 0, 0, 0, $FB5B)
|
||
|
END
|
||
|
|
||
|
DEF GRMODE
|
||
|
DROP ROMCALL(0, 0, 0, 0, $FB40)
|
||
|
DROP ^SHOWLORES
|
||
|
END
|
||
|
|
||
|
DEF RANDOMIZE(SEED)
|
||
|
RNDNUM = (SEED >> 8) + (SEED << 8) + SEED
|
||
|
END
|
||
|
|
||
|
DEF RND
|
||
|
RNDNUM = (RNDNUM << 8) + RNDNUM + 12345
|
||
|
RETURN RNDNUM & $7FFF
|
||
|
END
|
||
|
|
||
|
DEF BYFIRE(TREEPTR)
|
||
|
IF ^(TREEPTR - 43) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR - 42) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR - 41) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR - 1) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR + 1) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR + 41) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR + 42) == FIRE
|
||
|
RETURN TRUE
|
||
|
ELSIF ^(TREEPTR + 43) == FIRE
|
||
|
RETURN TRUE
|
||
|
FIN
|
||
|
RETURN FALSE
|
||
|
END
|
||
|
DEF FORESTFIRE
|
||
|
WORD NEWTREES, OLDTREES, NEWTREE, OLDTREE, YROW
|
||
|
BYTE X, Y
|
||
|
|
||
|
MEMSET(EMPTY, @TREES1, FORESTSIZE)
|
||
|
MEMSET(EMPTY, @TREES2, FORESTSIZE)
|
||
|
OLDTREES = @TREES1
|
||
|
NEWTREES = @TREES2
|
||
|
|
||
|
FOR Y = 1 TO 40
|
||
|
YROW = Y * 42
|
||
|
FOR X = 1 TO 40
|
||
|
IF RND < 8000
|
||
|
^(OLDTREES + X + YROW) = TREE
|
||
|
FIN
|
||
|
NEXT
|
||
|
NEXT
|
||
|
WHILE ^$C000 < 128
|
||
|
FOR Y = 1 TO 40
|
||
|
YROW = Y * 42
|
||
|
FOR X = 1 TO 40
|
||
|
OLDTREE = OLDTREES + X + YROW
|
||
|
NEWTREE = NEWTREES + X + YROW
|
||
|
WHEN ^OLDTREE
|
||
|
IS EMPTY
|
||
|
IF RND < 5000
|
||
|
^NEWTREE = TREE
|
||
|
ELSE
|
||
|
^NEWTREE = EMPTY
|
||
|
FIN
|
||
|
IS TREE
|
||
|
IF RND < 5 OR BYFIRE(OLDTREE)
|
||
|
^NEWTREE = FIRE
|
||
|
ELSE
|
||
|
^NEWTREE = TREE
|
||
|
FIN
|
||
|
IS FIRE
|
||
|
^NEWTREE = EMPTY
|
||
|
WEND
|
||
|
DROP ROMCALL(^NEWTREE, 0, 0, 0, $F864)
|
||
|
DROP ROMCALL(Y - 1, 0, X - 1, 0, $F800)
|
||
|
NEXT
|
||
|
NEXT
|
||
|
NEWTREES =, OLDTREES = OLDTREES, NEWTREES
|
||
|
LOOP
|
||
|
DROP ^$C010
|
||
|
END
|
||
|
|
||
|
PRSTR(@HELLOMSG)
|
||
|
WHILE ^$C000 < 128
|
||
|
RNDNUM = RNDNUM + 1
|
||
|
LOOP
|
||
|
RANDOMIZE(RNDNUM)
|
||
|
DROP ^$C010
|
||
|
GRMODE
|
||
|
HOME
|
||
|
GOTOXY(10,22)
|
||
|
PRSTR(@EXITMSG)
|
||
|
FORESTFIRE
|
||
|
TEXTMODE
|
||
|
HOME
|
||
|
PRSTR(@GOODBYE)
|
||
|
DONE
|