rpi4-osdev/part12-wgt
2021-04-17 21:40:09 +01:00
..
bin Added mouse.c and examples/wgt18.c to exercise it 2021-03-23 16:39:06 +00:00
boot Correcting comment in boot.S 2021-03-15 17:16:30 +00:00
controller-ios Added simple iOS controller to emulate 2-button mouse, and examples/wgt23.c 2021-03-30 22:18:58 +01:00
controller-node Added simple iOS controller to emulate 2-button mouse, and examples/wgt23.c 2021-03-30 22:18:58 +01:00
include Fixed palette index issue with wxor.c 2021-04-17 21:18:30 +01:00
lib Added simple iOS controller to emulate 2-button mouse, and examples/wgt23.c 2021-03-30 22:18:58 +01:00
samples Added examples/wgt39.c - mouse trails 2021-04-17 21:40:09 +01:00
wgt Fixed palette index issue with wxor.c 2021-04-17 21:18:30 +01:00
Makefile Restructured the codebase for a bit more clarity 2021-03-25 09:20:48 +00:00
README.md Doc changes 2021-03-31 09:05:49 +01:00

Writing a "bare metal" operating system for Raspberry Pi 4 (Part 12)

Porting the WordUp Graphics Toolkit

Back in the mid-1990s (when I was young!), programmers who wanted to build their own games didn't have rich frameworks like Unity. Perhaps the closest we got was the WordUp Graphics Toolkit, which I came across on the Hot Sound & Vision CD-ROM - a BBS archive. If you have a moment, perhaps use Google to see what "bulletin board systems" were... nostaglia awaits!

Much like my very simple fb.c, the WGT provides a library of graphics routines which can be depended upon for reuse. This library, however, is much more fully-fledged than mine, and makes it easy to build sprite-based games (like Breakout, Space Invaders, Pacman etc.).

The directory structure

As I port the WGT to my OS (a.k.a. make it work on my OS), I am using the following directories:

  • bin/ : for WGT binary files (fonts, sprites, bitmaps etc.)
  • controller-ios/ : a sample Swift BLE controller for the iOS platform
  • controller-node/ : a sample Node.js BLE controller
  • include/ : now contains wgt.h and wgtspr.h too (header files necessary for WGT code)
  • samples/ : sample "kernels" for my OS which exercise certain WGT library functions. To build them, copy one of these (and only one at a time) to the same directory as the Makefile.
  • wgt/ : the library itself. Where possible, I have stayed true to the original code, but do bear in mind it was written for the x86 architecture and we're on AArch64!

Please note: I am neither a Node.js developer, nor a Swift developer, and so the controllers are purely samples that serve my purpose. They are not intended to be exemplars! I am very aware of the multitudinous problems with both...

Building

So... to build the first WGT sample simply type cp samples/wgt01.c . from the top-level directory, and then type make. When you boot with the generated kernel8.img you will see the screen go into 320x200 (VGA!) mode and draw a white line from corner to corner. If you do, the library is doing its stuff!

boot/boot.S changes

We're still booting into a multicore environment (just in case we need it). There are a few significant changes to boot/boot.S though. I will write more on these later, but (for now) they are:

  • Enable FPU (floating-point unit) access so we can do non-integer mathematics
  • Switch from EL3 (supervisor exception level) down to EL1 (kernel exception level), disabling the MMU all the same
  • Move the addresses for the spin_cpu variables to accommodate a larger boot.S
  • Implement a get_el function to check which exception level we're at (for debug mainly)

Using the iOS BLE controller

To use the iOS BLE controller instead of the Node.JS controller, ensure that you have:

#define IOS_CONTROL

at the top of each of wgt/mouse.c and lib/bt.c. Without this #define, the code will be looking for the Node.JS controller (so remove these lines if that's what you want!).

Work in progress!

This part is still work in progress - and it's a lot of work - so keep watching this space!

In the meantime, do have a go at building some of the samples...