Jump to content
IGNORED

Emergency denial services / Cardinal arrested


 Share

Recommended Posts

This experimental apparatus monitors various types of events in your body and brain.

 

Get latest version of Classic99. Choose TurboForth 1.2.1 by Mark Wills.

 

Type, or copy and paste program listing. Enjoy. ;)

 

VARIABLE COL
CREATE COLS 30 CHARS ALLOT
: >COLS ( value offset -- ) COLS + C! ;
: <COLS ( offset -- n ) COLS + C@ ;
: CHART
  1 GMODE 14 SCREEN 4 4 0 COLOR 5 1 0 COLOR
  DATA 8 $0000 $0400 $0000 $0000 $0000 $0400 $0000 $1F1F 32 DCHAR
  DATA 8 $0000 $0400 $1F1F $0000 $0000 $1F1F $0000 $0000 34 DCHAR
  DATA 4 $1F1F $0400 $0000 $0000 36 DCHAR
  DATA 8 $040E $1F04 $0404 $0C04 $0404 $1C04 $0404 $0C04 40 DCHAR
  DATA 8 $0404 $1F04 $0400 $0000 $0000 $FF44 $0400 $0000 42 DCHAR
  DATA 4 $0406 $FF46 $0400 $0000 44 DCHAR
  40 0 V! 1 0 41 22 VCHAR 42 736 V! 23 1 43 30 HCHAR 44 767 V!
  30 0 DO
    30 I >COLS
  LOOP
  BEGIN
    30 RND COL !
    1 COL @ 1+ 32 22 VCHAR
    19 COL @ <COLS 2 >> - 
    COL @ 1+
    COL @ <COLS 3 AND 33 +
    1
    HCHAR
    2 RND 0 = IF -1 ELSE 1 THEN COL @ <COLS + 63 AND COL @ >COLS
  AGAIN
;
CHART
  • Like 3
Link to comment
Share on other sites

 

2 RND 0 = IF -1 ELSE 1 THEN 

 

TF has a word called 0= which you can use to replace the 0 =

 

 

2 RND 0= IF -1 ELSE 1 THEN

 

Does exactly the same thing, but 0= is (probably) more than twice as fast as your code, which pushes 0 to the stack, then pops it off again with =

 

0= just does a direct comparison to tos (top of stack).

 

Here's a description. :grin:

Link to comment
Share on other sites

Conventions:

In Forth speak, <cols would be more correctly written as cols>

 

If the > is before the word (example: >R ) then it's "to". So, >R is "to return stack"

If the > is after the word (example R> ) then it's "from". So, R> is "from return stack"

 

However, in the case of >cols and <cols in your above, I would name >cols as !cols and <cols as @cols respectively, because they are fetching and storing. If another Forther were reading your code, !cols and @cols would give him an immediate clue as to what is happening.

 

Just friendly advice - nothing wrong with your code! :thumbsup:

Link to comment
Share on other sites

Thanks everyone. :)

Updated version:

VARIABLE COL
CREATE COLS 31 CHARS ALLOT
: !COLS ( value offset -- ) COLS + C! ;
: @COLS ( offset -- n ) COLS + C@ ;
: CHART
  1 GMODE 14 SCREEN 4 4 0 COLOR 5 1 0 COLOR
  DATA 8 $0000 $0400 $0000 $0000 $0000 $0400 $0000 $1F1F 32 DCHAR
  DATA 8 $0000 $0400 $1F1F $0000 $0000 $1F1F $0000 $0000 34 DCHAR
  DATA 4 $1F1F $0400 $0000 $0000 36 DCHAR
  DATA 8 $040E $1F04 $0404 $0C04 $0404 $1C04 $0404 $0C04 40 DCHAR
  DATA 8 $0404 $1F04 $0400 $0000 $0000 $FF44 $0400 $0000 42 DCHAR
  DATA 4 $0406 $FF46 $0400 $0000 44 DCHAR
  40 0 V! 1 0 41 22 VCHAR 42 736 V! 23 1 43 30 HCHAR 44 767 V!
  31 0 DO
    31 I !COLS
  LOOP
  BEGIN
    31 RND COL !
    1 COL @ 1+ 32 22 VCHAR
    19 COL @ @COLS 2 >> - 
    COL @ 1+
    COL @ @COLS 3 AND 33 +
    1
    HCHAR
    2 RND 0= IF -1 ELSE 1 THEN COL @ @COLS + 63 AND COL @ !COLS
  AGAIN
;
CHART
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...