About 2 weeks ago, I got properly started on my QuickBASIC environment emulator. I call it QBX. It's now a bit over 21,000 lines of code, and it features:
- A code model for the QuickBASIC programming language that can take a structured representation of a program and output it with canonical formatting.
- A lexer and a parser that can read QuickBASIC code and build code models for it.
- Automated testing of the lexer and parser.
- A mostly-complete low-level emulator of the VGA chipset, the most popular graphics system for PCs in the late '80s.
- Code Page 437 translation to match the emulated VGA fonts.
- Keyboard handling that should do exactly what's needed to, eventually, be wired up to INKEY$, the QBASIC keyboard input function. This one is more involved that it looks on the surface. 🙂
- Maybe 10% of the QuickBASIC IDE, showcased here.
The classic blue screen you see here is fully emulated. The VGA memory is, as in the real chipset, divided into 4 64KB planes. In the mode shown here, characters are read from plane 0 and attributes from plane 1, and within each character box, the font from which the actual dots are generated is read from plane 2. The emulation also supports CGA/EGA/VGA graphics modes, including the classic 640x480x16 and 320x200x256 VGA modes. The emulation is based on the actual VGA hardware registers and timing. The idea is that, eventually, when this thing can actually run programs, a program that directly accessed the VGA hardware should work in this too.
The incomplete IDE here doesn't yet know how to run code, but it does parse code to the abstract code model and format it back out. You can see keywords being capitalized and expressions being spaced out here. The formatting should be a very close match to actual QuickBASIC, if not identical to it. (For instance, if I run the well-known gaem NIBBLES.BAS through it, the output it produces is byte-for-byte identical to the input file.) The editing experience is also as close as I've been able to make it and, as I find mistakes, will get better. Microsoft's DOS TUIs had interesting mechanics around selection and the clipboard, and those are also shown here.
The menu doesn't actually do anything yet, but it is complete and fully behaves the way the menu should.
I feel really good about this project and the way it's coming along. And, it was really awesome, having done all the development so far on a Windows machine, to pull the code down on a Linux machine, type "dotnet run", and have it start up immediately on a completely different operating system and do exactly what it's supposed to do 🙂
No comments:
Post a Comment