Jump to content
IGNORED

Geneve FORTH


GDMike

Recommended Posts

Well GDMike, it looks like you got some really good answers to your Forth+ questions: "This week's question. Maybe someone knows the answer good enough to try and explain.  What is a "Parameter field address" PFA, and what is a "Name field address", NFA as they relate to FORTH+?"

 

I would suggest you use TheBF's detailed description along with Lee Stuart's diagram of the fig-forth structure to get the basic understanding you will need to write low-level forth for regular dictionary and library WORDs.  As some day, if you stick with Forth+, you'll want to implement the dual library zone feature described in the documents I sent you.  And don't forget to include the system configuration tool, so libraries you create for Forth+, won't require any stack parameters, and allow others who want to join in all the Forth+ fun can without the difficulties you had using the built in library system now that it's simple (KISS) operation is understood!

 

RetroBill (fdos)

  • Like 4
Link to comment
Share on other sites

This is exactly what I was looking for. Now I can relate. Well, since I Know how general databases work in design creation and use, this is very understandable.

I just couldn't place the words referenced into some sort of structure, now I see it.

Thx so much for that. And as far as design, I've seen mention of fig83 and fig-forth as well as TI Forth. But I think you were more concerned with the Fig83 standard being applied?

But I'll study what Lee shot at me. Pictures...lol... thanks for enlightening me on that.

 

 

Edited by GDMike
Link to comment
Share on other sites

2 hours ago, GDMike said:

This is exactly what I was looking for. Now I can relate. Well, since I Know how general databases work in design creation and use, this is very understandable.

I just couldn't place the words referenced into some sort of structure, now I see it.

Thx so much for that. And as far as design, I've seen mention of fig83 and fig-forth as well as TI Forth. But I think you were more concerned with the Fig83 standard being applied?

But I'll study what Lee shot at me. Pictures...lol... thanks for enlightening me on that.

 

 

By way of clarification:

 

Fig-Forth was an early public domain version of Forth that became a standard by popularity. TI-Forth, FbForth and Forth+ are built in that vein.

 

Forth83 was a standard created in of course 1983.  It assumed 16bit computers which made it obsolete when 32bit machines became common. It open some new doors with vocabulary search order control and changed DO LOOPs and other stuff.

TurboForth is built on the Forth83 model.

 

Forth 94 was certified by ANS and ISO as  a "standard" computer language after a lot of war and battles. It's the one Camel Forth was built on.  Brad's opinion on Forth 94 comes through in the name Camel Forth.

"A camel is a horse designed by a committee" :)

 

Forth2012 is the latest update but nobody has the stamina to go through the ANS process again so it's more of an informal committee and a web site.

 

Most of this stuff doesn't matter to hobby computing. You use one and get use to it like a BASIC dialect.

 

 

 

 

  • Like 1
Link to comment
Share on other sites

3 hours ago, Bill R Sullivan said:

So GDMike, arn't you now anxious to get started on the dual library zone structure?  Today is laundry day for me, which means I'll be very busy.

Always wanting time to work on this, but my AC is out and we're looking at replacement of everything... so unfortunately I've been busy another way.

Link to comment
Share on other sites

7 hours ago, Bill R Sullivan said:

So GDMike, arn't you now anxious to get started on the dual library zone structure?  Today is laundry day for me, which means I'll be very busy.

I had some time today after all, not much, but enough to play. Ok, I did some sound WORDS using (( ))SOUND and some graphics and switching through the libraries was clean and quick and loading up the EDITOR, through MY GOEDIT call, (ED\ASM library), and I'm getting somewhere. Things are spicing up and im so happy to report, not one freeze up at all over the couple hours learning the sound word and fumbling around, defining words, FORGETTING words etc..

I'm just thumbing through the Library of words list in my FORTH+ book and seeing what I can figure out on my own and scratching off those that I understand. Also made use of the "+LOOP", and I didn't see

 a  "-LOOP",  but using a negative number kinda resolves that need anyway.

So yeah, it's been a good beginning.

 

Edited by GDMike
Link to comment
Share on other sites

4 hours ago, GDMike said:

Always wanting time to work on this, but my AC is out and we're looking at replacement of everything... so unfortunately I've been busy another way.

Too bad!

 

33 minutes ago, GDMike said:

I had some time today after all, not much, but enough to play. Ok, I did some sound WORDS using (( ))SOUND and some graphics and switching through the libraries was clean and quick and loading up the EDITOR, through MY GOEDIT call, (ED\ASM library), and I'm getting somewhere. Things are spicing up and im so happy to report, not one freeze up at all over the couple hours learning the sound word and fumbling around, defining words, FORGETTING words etc..

I'm just thumbing through the Library of words list in my FORTH+ book and seeing what I can figure out on my own and scratching off those that I understand. Also made use of the "+LOOP", and I didn't see

 a  "-LOOP",  but using a negative number kinda resolves that need anyway.

So yeah, it's been a good beginning.

 

Not so bad after all.  I just finished my laundry 10 minutes ago, so now time to shower and shave, before my daughter and grand daughter get home (my daughter works as an in home care giver, and my grand daughter has a baby sitting job).

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

So this is what I need to start with..

 

"Chuck, he'd typically go through the following process:"

  • Read the spec. Assert confidently that it really isn't as complicated as that, and write a very clever program that solves the essence of the problem.
  • Enter a phase in which the customer repeatedly points out aspects of the spec that have been ignored or omitted; in fixing these, the code gets more and more complicated.
  • At some point, a full understanding of the problem emerges. All the previous code is thrown out and a new program emerges which represents a simple, elegant solution to the whole problem.
 
  • Like 1
Link to comment
Share on other sites

11 hours ago, GDMike said:

So this is what I need to start with..

 

"Chuck, he'd typically go through the following process:"

  • Read the spec. Assert confidently that it really isn't as complicated as that, and write a very clever program that solves the essence of the problem.
  • Enter a phase in which the customer repeatedly points out aspects of the spec that have been ignored or omitted; in fixing these, the code gets more and more complicated.
  • At some point, a full understanding of the problem emerges. All the previous code is thrown out and a new program emerges which represents a simple, elegant solution to the whole problem.
 

You can for sure use this approach to your projects.  This should be done for all software projects but it hard for people to rip up what they did and do it over.

Chuck re-wrote his own stuff many times over. He could do this partly because he added no frills; only what was needed.

 

Your first job  I think, is to get a lot of Forth+ words in your "wet-ware" vocabulary like learning to speak a foreign language.

Then you are can talk to the machine and it will talk back.  

That is the hard part with Forth. The language is simple but there are lots of word. It's a lot more like a human language that way.

There are about 200ish words in just the Core wordset and then all the extras that Forth+ gives you. 

 

In Pascal there are only 54 keywords and the math operators. Way smaller to memorize.

 

I would start with trying some ordinary stuff with Forth+ words. Screen formatting, filling up an array of ints, and array of chars. printing the array contents.

Stuff like that but using the Forth+ tools so you know what you have there. Your nose will be in the docs a lot for a while.

 

My 2 cents in the morning. (but it's Canadian money so its only worth 1.6 cents USD) :) 

  • Like 1
  • Haha 1
Link to comment
Share on other sites

I found this web site a while back. 

https://skilldrick.github.io/easyforth/#introduction 

You know the easy stuff on the site already but the snake game is a nice introduction project. 

It's not very efficient but it works and it shows nice Forth style factoring

I re-wrote it for Camel99 (a few too many times) :)

 

You will have to learn enough Forth+ to adapt it here and there.

 

There is no KEY word used in CHECK-INPUT. That needs to be changed to some way to continuously read the 99 keyboard.

It doesn't put chars on the screen the way TI-99 does so you need to make that part but most of it will run as is once you capitalize the text.

So fix DRAW, DRAW-WHITE, DRAW-BLACK and I think that's it. ( I think EMIT and GOTOXY will give you a solution)

(the VARIABLE word needs a 0 everywhere for Fig Forth)

 

No pressure here BTW. Just looking to help.

 

variable snake-x-head
500 cells allot

variable snake-y-head
500 cells allot

variable apple-x
variable apple-y

0 constant left
1 constant up
2 constant right
3 constant down

24 constant width
24 constant height

variable direction
variable length

: snake-x ( offset -- address )
  cells snake-x-head + ;

: snake-y ( offset -- address )
  cells snake-y-head + ;

: convert-x-y ( x y -- offset )  24 cells * + ;
: draw ( color x y -- )  convert-x-y graphics + ! ;
: draw-white ( x y -- )  1 rot rot draw ;
: draw-black ( x y -- )  0 rot rot draw ;

: draw-walls
  width 0 do
    i 0 draw-black
    i height 1 - draw-black
  loop
  height 0 do
    0 i draw-black
    width 1 - i draw-black
  loop ;

: initialize-snake
  4 length !
  length @ 1 + 0 do
    12 i - i snake-x !
    12 i snake-y !
  loop
  right direction ! ;

: set-apple-position apple-x ! apple-y ! ;

: initialize-apple  4 4 set-apple-position ;

: initialize
  width 0 do
    height 0 do
      j i draw-white
    loop
  loop
  draw-walls
  initialize-snake
  initialize-apple ;

: move-up  -1 snake-y-head +! ;
: move-left  -1 snake-x-head +! ;
: move-down  1 snake-y-head +! ;
: move-right  1 snake-x-head +! ;

: move-snake-head  direction @
  left over  = if move-left else
  up over    = if move-up else
  right over = if move-right else
  down over  = if move-down
  then then then then drop ;

\ Move each segment of the snake forward by one
: move-snake-tail  0 length @ do
    i snake-x @ i 1 + snake-x !
    i snake-y @ i 1 + snake-y !
  -1 +loop ;

: is-horizontal  direction @ dup
  left = swap
  right = or ;

: is-vertical  direction @ dup
  up = swap
  down = or ;

: turn-up     is-horizontal if up direction ! then ;
: turn-left   is-vertical if left direction ! then ;
: turn-down   is-horizontal if down direction ! then ;
: turn-right  is-vertical if right direction ! then ;

: change-direction ( key -- )
  37 over = if turn-left else
  38 over = if turn-up else
  39 over = if turn-right else
  40 over = if turn-down
  then then then then drop ;

: check-input
  last-key @ change-direction
  0 last-key ! ;

\ get random x or y position within playable area
: random-position ( -- pos )
  width 4 - random 2 + ;

: move-apple
  apple-x @ apple-y @ draw-white
  random-position random-position
  set-apple-position ;

: grow-snake  1 length +! ;

: check-apple
  snake-x-head @ apple-x @ =
  snake-y-head @ apple-y @ =
  and if
    move-apple
    grow-snake
  then ;

: check-collision ( -- flag )
  \ get current x/y position
  snake-x-head @ snake-y-head @

  \ get color at current position
  convert-x-y graphics + @

  \ leave boolean flag on stack
  0 = ;

: draw-snake
  length @ 0 do
    i snake-x @ i snake-y @ draw-black
  loop
  length @ snake-x @
  length @ snake-y @
  draw-white ;

: draw-apple
  apple-x @ apple-y @ draw-black ;


: game-loop ( -- )
  begin
    draw-snake
    draw-apple
    100 sleep
    check-input
    move-snake-tail
    move-snake-head
    check-apple
    check-collision
  until
  ." Game Over" ;

: start  initialize game-loop ;

 

  • Like 1
Link to comment
Share on other sites

Yeah, I've got variables, constants, video addressing, and a few other stuff already known from back in my Turboforth days, but NOW learning how to call WORDS from one library to another is my next lesson, there is a word here called "CALL("   and ends with  ")"

And I'm supposed to supply library + library word but it ain't working yet...

I'm not sure what I'm doing wrong...

The FORTH+ book also explains that those library words can also be placed on the stack and called but wouldn't be the quickest way, and I'm not having luck with that either.. but I haven't given up .

:)

 

  • Like 1
Link to comment
Share on other sites

I'm looking for the word "CELLS" and it's not in FORTH+, but I do see "=CELLS" 

I'll keep looking but I need to see what the definition of "CELLS" is and the function to verify a match for what they may be using here as there are lots of words.

I'm still gathering up what I know already with what they have listed here to match. 

 

Link to comment
Share on other sites

16 minutes ago, GDMike said:

I'm looking for the word "CELLS" and it's not in FORTH+, but I do see "=CELLS" 

I'll keep looking but I need to see what the definition of "CELLS" is and the function to verify a match for what they may be using here as there are lots of words.

I'm still gathering up what I know already with what they have listed here to match. 

 

CELLS simply multiplies a number by 2. It expects the number to represent a number of cells (16-bit numbers) and converts it to a number of bytes so that, in this case, ALLOT can reserve the correct number of bytes.

 

=CELLS is used to convert an address to an even, 16-bit boundary. It is used by CREATE to start a word definition on an even address boundary.

 

...lee

  • Like 1
Link to comment
Share on other sites

7 minutes ago, Lee Stewart said:

=CELLS is used to convert an address to an even, 16-bit boundary. It is used by CREATE to start a word definition on an even address boundary.

Right. That's why I knew that wasn't the same word as "CELLS" and didn't use it.

TF defines CELLS as   *2

But I'm not sure if my : CELLS 2 * ; would work?

 

 

 

Link to comment
Share on other sites

1 minute ago, GDMike said:

I was thinking after reading something online, and the definition should look something like

Variable CELL 1 allot 

 

First of all, I think the version of VARIABLE you are using needs a value on the stack to store in the new word’s parameter field. Secondly, I have no idea what you think that definition does. 

 

...lee

 

 

 

Link to comment
Share on other sites

8 minutes ago, GDMike said:

Right. That's why I knew that wasn't the same word as "CELLS" and didn't use it.

TF defines CELLS as   *2

But I'm not sure if my : CELLS 2 * ; would work?

 

That would work just fine. A left shift of 1 would accomplish the same thing and be faster, however.

 

...lee

  • Thanks 1
Link to comment
Share on other sites

46 minutes ago, GDMike said:

but I do see "=CELLS"

 

30 minutes ago, Lee Stewart said:

=CELLS is used to convert an address to an even, 16-bit boundary.

 

TurboForth uses ALIGN to align HERE to an even address boundary, but does not define the more generic =CELLS for some reason. Perhaps it is almost never used except to adjust HERE .

 

...lee

Edited by Lee Stewart
CORRECTION
  • Like 1
Link to comment
Share on other sites

26 minutes ago, Lee Stewart said:

 

         TurboForth uses ALIGN to align HERE to an even address boundary, but does not define the more generic =CELLS for some reason. Perhaps it is almost never used except to adjust HERE .

...lee

For an address?

Btw, I do have a SLA word.

: CELLS 1 SLA ;  so this should work?

 

Edited by GDMike
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...
  • Recently Browsing   0 members

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