home *** CD-ROM | disk | FTP | other *** search
- \ Problem 4.13 04/15/90 17:50:45.80
-
-
- CREATE TABLE 12 ALLOT \ Here space is alloted but not initialized.
- TABLE 12 ERASE \ Here the 12 bytes or 6 16-bit numbers are
- \ set to zero.
-
- VARIABLE MODE
-
-
- 0 CONSTANT RED 2 CONSTANT BLUE 4 CONSTANT YELLOW
- 6 CONSTANT BLACK 8 CONSTANT WHITE 10 CONSTANT GREEN
-
- : LESS -1 MODE ! ; \ Subtract top of stack from current position.
- : SHOW 0 MODE ! ; \ Display current array position.
- : MORE 1 MODE ! ; \ Add top of stack to current position.
- : ONLY 2 MODE ! ; \ Store top of stack to current array position.
-
- : LESS? MODE @ -1 = ;
- : SHOW? MODE @ 0= ;
- : MORE? MODE @ 1 = ;
- : ONLY? MODE @ 2 = ;
-
- : MARBLES ( {n} color -- ) \ There may be 1 or 2 numbers on stack.
- TABLE + \ Add colour offset to TABLE
- DEPTH 1 = \ Check for {n} present.
- IF SHOW THEN \ Set display mode if no {n}
- LESS? IF SWAP NEGATE SWAP +! \ Do the subtract function.
- ELSE SHOW?
- IF @ . \ Do the display function.
- ELSE MORE?
- IF +! \ Do the add function.
- ELSE ONLY?
- IF ! \ Do the reset function.
- ELSE ." Invalid mode!!! Try again."
- THEN
- THEN
- THEN
- THEN
- ONLY ; \ Set the default mode to the reset function.
-
-
-