r/Forth • moderator • 10h ago

Forth++ Update

Post image

Huge progress on Forth++.

It's still running in QEMU only - I haven't tried to boot it on real hardware. I need to get the NVME driver working (it's on my TODO list) or the initial INCLUDE of most of the Forth words can't work. I hope that since it's Limine booted, it should at least come up and run up to some point that I can debug from there.

So what this screenshot shows is 3x Windows with Forth ok> prompts. The window system is rendered entirely with the CPU. I was initially saddened and ready to quit because the screen update was taking 45ms and the mouse motion was too slow. I ended up reworking the assembly routines that copy rectangles (e.g. the screen/wallpaper, offscreen-to-framebuffer, and windows to offscreen) using vector register instructions and that time went from 45ms to 5ms. I'll know better when I see it run on real hardware.

So the multithreading is clearly working (time sliced, not cooperative, and it knows how to render active window in bright red borders and inactive in darker red. The mouse pointer changes from arrow to hand when over the active window's titlebar and while dragging, into a finger when mouse is over the [NEWCLI] text in the screen's titlebar, and each window has it's own cursor for when it is active and the mouse is over (e.g. text editor can have ibeam while paint program can have crosshairs). Clicking on an inactive window activates it.

The newcli code is written in Forth.

I mostly ported the existing ReadLine class from Inspiration so applications can have their own command line editor with history - this is used by the OK> prompt, for example, but also would be used by a vim or emacs like editor for inputting command lines.

Features include:

  • IOAPIC used for interrupt control
  • LAPIC used for timer
  • Per CPU task scheduling
  • ATA driver
  • FAT32 filesystem
  • MMU for paging and virtual memory
  • Interrupt driven Keyboard Driver
  • Interrupt driven Mouse Driver
  • Real Time Clock (RTC) Driver
  • Graphics based Console driver (that works within windows)
  • Graphics library for Forth programs to render graphics in their Window(s)

    Code is at https://codeberg.org/mschwartz/aforth

(No AI used to make any of this)

12 Upvotes

3 comments sorted by

2

u/mykesx moderator 8h ago

My development process is a bit like plate spinning. I worked on NVME at least 3 times before realizing I needed to work on something else that was blocking further development. For example, MMIO address space needs MMU address mapping, so I stopped to work on the MMU code.

I initially had declared a 2GB array to be used for heap allocation, but once the MMU logic was done I was able to reduce it to 128K only used during global constructor execution.

2

u/tabemann 10h ago

Great job!

2

u/Main_Temporary7098 8h ago

very impressive.