r/Forth

Design deep-dive: my toy Tetris for a C64 Forth
▲ 20 r/Forth+2 crossposts

Design deep-dive: my toy Tetris for a C64 Forth

(Document permalink at time of posting.)

A couple years ago I saw someone on 4chan /g/ writing a Tetris in 6502, and I was tinkering around with durexForth so I tried my hand at writing one myself. I start them sometimes but don't usually get that far. This one came together mostly fully-formed in a week or two and I've been picking at it to pass time ever since.

In recent months I've mostly been documenting it. Maybe I can upgrade one or two "Forth curious" persons dabbling in this subreddit into "Forth tinkerers" by way of a nontrivial thing to prod at. It's dense in the Tetris and C64 weeds, though, shrinking an already small audience!

For your perusal.

github.com
u/ekipan85 — 16 hours ago
▲ 6 r/Forth

Using Forth to run the OS and execute BASIC

Has anyone used Forth as a serious OS before? I need to cut something out of my KERNAL and I thought, I could remove Forth (7.5k), but I could also remove BASIC (~20k). Most of the OS commands are written into the BASIC interpreter. What if I move the OS commands to forth instead? So after some experimentation I found a way to make forth run commands that look like BASIC and/or shell commands. Currently, BASIC handles all the OS commands like DIR, COPY, etc.

I'm not sure if this would work but I can't see why not:

    : STRIP, DUP
      BEGIN
        DUP C@ 0= IF DROP EXIT THEN
        DUP C@ 44 = IF 0 OVER C! THEN
        1 +
      AGAIN ;
    
    : ARG WORD STRIP, NUMBER ;
    
    : POKE ARG ARG SWAP C! ;
    
    POKE 49152, 10  \\ example command

or this

    : SPLITARG
      WORD DUP
      BEGIN
        DUP C@ 0= IF DROP NUMBER EXIT THEN
        DUP C@ 44 = IF
          0 OVER C!            \ null-terminate first part
          1 +                  \ pointer to second part
          SWAP NUMBER          \ convert first part
          SWAP NUMBER          \ convert second part
          EXIT
        THEN
        1 +
      AGAIN ;
  
    : POKE SPLITARG SWAP C! ;

    POKE 49152,10  \\ example command

I could make commands like MKDIR dirname, COPY file1 file2 and so on. If this works, the OS prompt will feel exactly the same except it will have the power of FORTH inside. And I can clear up 20k of space in the kernal by removing BASIC. I will have to investigate this further.

reddit.com
u/AppledogHu — 3 days ago
▲ 40 r/Forth+1 crossposts

voxels in r3forth

Working on a voxel graphics system in r3forth (open source on GitHub), it's still missing some elements but some things are already showing up. The system works well on Windows and Linux.

u/Comprehensive_Chip49 — 4 days ago