Jump to content

TheBF

+AtariAge Subscriber
  • Content Count

    2,440
  • Joined

  • Last visited

Community Reputation

2,459 Excellent

About TheBF

  • Rank
    River Patroller

Profile Information

  • Gender
    Male
  • Location
    The Great White North
  • Interests
    Music/music production, The Forth programming language and implementations.
  • Currently Playing
    Guitar
  • Playing Next
    Trumpet ;)

Recent Profile Visitors

6,338 profile views
  1. I finally convinced my V2.67 code to run over RS232. It turns out that for reasons I don't understand yet, I had to reset my stacks before entering the interpreter. That's usually an indication that there is something I am missing in the startup code but I can't see what it might be. I will figure that out eventually. I really want to make a file editor that works over RS232. I took to studying a paper on editors by Ray Valdes written in 1993. It has a lot of good ideas and it showed a factored out single line editor in C. That seem like a good way to start and after way more time than I wanted it to take, I have EDITLN ( addr buffsize col -- ) that lets me point this thing at a block of memory and edit it. I re-worked some code to handle escape sequences from the keyboard so I can have the HOME,END, arrow keys etc. work as expected. They work ok as long as I set the terminal to send characters with a slightly delay. Without a receive interrupt on the com port I have to do it that way. (I may revisit bringing in some code I have that successfully gave me interrupt driven receive. It might make more sense to compile it into a running kernel than trying to wake up the machine with it.) I have used DEFER words as place holders for the future functions that will be coded for whatever the editor becomes. I have one bug to kill when I cursor back and forth too much but it is working otherwise. I am excited about getting this TTY based system working as a development environment on real hardware. I envision using the VDP screen on a separate workspace/task that can be used to for graphics and games but the PC keyboard can still be the controller.
  2. I didn't know these were also in ROM. I suspect it would awkward to use them if you are not in the GPL workspace. How do I find them to take a look?
  3. I don't know if this is sacrilegious but I put lines of 1/8" holes on the right side of the cover and the top of the coffee warmer sits at 32.2 C now. (89.6F)
  4. Is it just me or does this game need to be re-configured for the TI-99 way of doing things? By that I mean don't use a bit map image but create sets of re-useable characters for the bricks and the windows and the weeds etc. and draw the image that way. Yes the screen will look slightly different but it will be recognizable.
  5. Another way to do this is might be to write a different interpreter in BASIC and then write the program in that new language.
  6. 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 ;
  7. 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)
  8. This totally blew my mind when I saw it. Here it is slightly modified to run on ANS/ISO Forth systems just in case anyone wants to use it on GNU Forth. :-))) \ brainfuk.f in ANS Forth based on work by Mark Wills \ Thanks to Willsy on Atariage.com who wrote this in TurboForth \ A M A Z I N G !!!!!!!!!!! HEX CREATE MEMORY 2000 ALLOT VARIABLE ^P \ the memory pointer : RESET ( -- ) MEMORY DUP 2000 0 FILL ^P ! ; : PEEK ( -- ) ^P @ [email protected] ; : POKE ( -- ) ^P @ C! ; : > ( -- ) 1 ^P +! ; : < ( -- ) -1 ^P +! ; : + ( -- ) PEEK 1+ POKE ; : - ( -- ) PEEK 1- POKE ; : . ( -- ) PEEK EMIT ; : , ( -- ) PAD DUP 3 ACCEPT EVALUATE POKE ; \ jump forward past the matching ] if the byte at the ^P is zero : [ ( -- ) POSTPONE BEGIN POSTPONE PEEK POSTPONE WHILE ; IMMEDIATE \ jump backward to the matching [ unless the byte at the ^P is zero : ] ( -- ) POSTPONE REPEAT ; IMMEDIATE : RUN ( hello world in BrainF__k ) RESET + + + + + + + + [ > + + + + [ > + + > + + + > + + + > + < < < < - ] > + > + > - > > + [ < ] < - ] > > . > - - - . + + + + + + + . . + + + . > > . < - . < . + + + . - - - - - - . - - - - - - - - . > > + . > + + . ;
  9. That reminds me of a song... Colorectal Surgeon -- Bowser & Blue - YouTube
  10. 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.
  11. From the wisdom of Fred Brooks "The management question, therefore, is not whether to build a pilot system and throw it away. You will do that. […] Hence plan to throw one away; you will, anyhow." “The general tendency is to over-design the second system, using all the ideas and frills that were cautiously sidetracked on the first one.” ― Frederick P. Brooks Jr., The Mythical Man-Month: Essays on Software Engineering May the Forth Force be with you For more of these: https://www.goodreads.com/author/quotes/3174788.Frederick_P_Brooks_Jr_
  12. @GDMike, do you know if Forth+ uses this dictionary design? It might be called "FIG-Forth" in the manual if it does. Forth Interest Group published this dictionary structure back in the 1970s and it became its own standard. And of course there is a wealth of deep dive information on Forth and some on Camel Forth in this series of papers by Brad Rodriguez if you really haven't had enough. :) Moving Forth: Part 1 (bradrodriguez.com)
  13. The details of this stuff will be in your Forth+ docs but here is some general theory. Some of this you know but I want to try and cover it from the beginning. Think of Forth as a list of words, the dictionary, and to each word some programming code is connected. That's easy to understand. You give Forth a word, it looks it up in the dictionary and runs the code. Done. But how do you build a dictionary that can do that? This is what the CFA PFA NFA stuff is dealing with. Like most problems in computing there are many ways to skin this cat and Forth people have found MANY. So there is no "standard" way to make a Forth dictionary but in general here is what is needed. I don't know what else you do with computers but maybe you have used databases. The Forth dictionary is like a database of records and in each record there are things called fields. Each Record has an identifier which is the word name. That is text of course. To make the dictionary work however you need a few more fields of info than just the text name. These fields are called: Link field, Name field, Code Field and Parameter Field. (Parameter field has been renamed to the DATA field in standard Forth which explains what it is for a bit better) The address in memory where these fields are located is confusingly called the Link Field Address, Name field address etc. So this has lead to the short forms LFA, NFA, CFA and PFA. Now you know what that names mean and how they came to be. But remember they are really just fields in the record of a Forth Dictionary. What they do Link Field: The link field holds a memory address that lets you find the next word in the dictionary. Since each word's "record" has a different amount of code with it they are all different sizes so they are not in pre-sized chunks. That would waste space. So when you make a new Forth word, the new word's link field is filled in with the address of the last word that was created (ie before the one you are making) So Forth searches the dictionary from the last word created, going backwards, following the bread crumbs in the LINK FIELD until it gets to a link field that contains zero. That's the end of the dictionary. This is called a "linked list". Computer scientists aren't always creative with their names. Name Field: The name field is where the text name of the word is held. It is variable in length and can be up to 31 characters these days. Fun fact: In Chucks first Forth systems he made all words 3 characters long maximum to save space and speed up searching. The name field is typically a "counted string" where the first byte is the length followed by the text of the word. In Fig-Forth I believe they also add a magic character at the end of the word name but that is not done in modern systems. Consult your documentation for Forth+ Code Field: This is maybe the most confusing field for people. This is because what it does depends on how the implementor of the system made their Forth. Forth+ is an "indirect threaded code" system (ITC) so I will only describe that. In simplest terms the code field contains the address of some real 9900 instruction code. That's it. This is because the computer has to run some kind of machine code instructions to do some work right? In Forth words the code in CFA controls what happens to the stuff in the Parameter field. (do the variable code, do the constant code, do the colon definition code etc.) In a CODE word, the CFA just holds the address of the next cell in memory. In other words it "points" to the machine code the Assembler laid down in this CODE word. Parameter (Data) Field: Like the name says, the parameter field holds other stuff. In a colon definition is contains the Code Field addresses (CFA) of other Forth words. If you make a variable it holds the value in the variable If you make a constant it holds the value of the constant. If you make an array it holds all the elements of the array and so on... Do you need to know this? To do some advanced programming yes. Like it or not Forth is a low level set of tools like a CPU. The more you understand about what it is made of the better you can use it to do your bidding. Do you need this everyday? No. Most of the time you can have a hell of a lot fun using the higher level words that Forth provides. And Forth+ is a "fat Forth" meaning it gives you a ton of stuff in the libraries so you don't need to dig into the innards of the system ... most of the time.
×
×
  • Create New...