The p-code card for the TI-99/4a

So I was at that moment when I pack away some old computer I’ve been working on for a while  (the TI-99/4a) and I happen to read about the p-code card. When I was a kid I remember seeing books about the UCSD p-system or UCSD Pascal and hey the 99/4a had this p-code card to let you run this stuff. In a nutshell its a whole operating system environment that uses a sort of byte code for a virtual machine (like java but a decade or two before).

The operating environment has a ‘Filer’ for letting you look at your disk drives, a full screen ‘Editor’ to edit source code and you could compile UCSD Pascal programs and run them. There’s TI Pilot and TI Forth as well that use this whole system. There is a word processor too.

This video by PixelPedant about the p-system is really good at covering the basics of how this all works.

Back in the day you needed the TI-99/4a, the PEB expansion, the 32K RAM expansion, the floppy expansion card, the p-code card and having 2 or more floppy drives would have helped enormously.

It didn’t take me long to find Thierry’s excellent pages about the p-code card. It turns out that its mainly a weird ROM/GROM cartridge. So the ROMs on the card don’t map into the normal 0x6000-0x7fff cartridge space. The ROMs map into the DSR space at 0x4000-0x5ffff. The GROMs are not accessed via the normal 0x98xx/0x9cxx interface. Instead they are accessed by some locations within the DSR memory space. Instead of ‘up to 5 GROMs’ there are 8 GROMs.

There are a couple of CRU bits at 0x1fxx as well. 0x1f00 is used to enable or disable the p-code card, and 0x1f80 controls the highest order address line of an 8K ROM on the card. So there are two ROMs on the card. The first one is 4K and appears at 0x4000-0x4ffff. The second is an 8K. Either the first or second half of this 8K ROM appears at 0x5000-0x5fff depending on that 0x1f80 CRU bit. There are also a few memory ‘holes’ in that area as well for interfacing to the GROMs. Thierry’s pages have all the details.

The dumped ROMs and GROMs I found as part of a MAME package at the very good ti99resources emulation page.

Anyway, it didn’t take long to adapt my ti994a-rom-grom-ram-and floppy-emulator to also emulate the p-code card. I was slow booting to a blank cyan screen in no time.

It is no speed demon. Eventually you see something like this (it may say System Initialized rather than System Re-initialized).

Pressing ‘E’ will take you to the editor. I think the first time you run it it may ask you some questions (read the documentation on the Editor) and open whatever was the last ‘workfile’ (NB: there is a way of changing what it loads by getting in to the Filer and using the ‘G’ option).

Here’s my workfile after I’ve typed in one of the example programs from the UCSD Pascal compiler manual. There are a bunch of special keystrokes to remember (read the manual), but ctrl-c is kind of like save and ctrl- . is like cancel. Generally in the Editor you get into insert mode by hitting ‘I’ and then type some stuff and then are probably hitting ctrl-c to get the menu bar accessible again, then ‘Q’ to quit and ‘U’ to update the workfile.

If you are like me you probably just wanted to type in the shortest possible Pascal program possible. Something like this:



So you type that in insert mode, hit ctrl-c, then Q, then U and you are back to the main menu. Then you can hit ‘C’ to compile

And finally ‘R’ to run

So what else can you do?. It also runs TI Pilot. ‘Pilot‘ was a programming language from a long time ago. It looks like this:

So I’ll stop for a moment and talk about disks. The p-system stuff is completely dependent on a bunch of disks as far as I can tell. So you need p-card plus floppy controller to make this all work.  For the Pascal stuff I found that I needed to have:

  • DSK1 – Compiler (there is a library on here that prefers to be on DSK1)
  • DSK2 – Editor/Filer
  • DSK3 – I had the Assembler/Linker but it might not be needed.

For TI Pilot I had

  • DSK1 – TI Pilot
  • DSK2 – Editor/Filer

There is no compiler with Pilot. Someone at the Italian TI-99 club has kindly scanned the English TI-Pilot manual. To use Pilot you basically

  • Use the Editor to type your program in and save it to the workfile
  • Instead of hitting ‘C’ to compile , you hit ‘X’ to execute and I entered ‘#4:PILOT’ (#4 being the p-system name for DSK1). The Pilot interpreter starts.
  • You get prompted for ‘PATTERNS’. In the manual it says to press ENTER. It’s actually asking you for a file full of character patterns to preload. If you are doing any kind of graphics you probably want to enter a filename here. When I ran the DEMO pilot program I found I had to enter ‘#4:PATTERNS’ for this prompt.
  • You now get prompted for COURSE: which is the actual pilot program you want to run. When I ran the DEMO program I entered ‘#4:DEMO’. But normally you would enter the name of the file you saved to from the Editor.

The DEMO is quite cool:

I’ll note here as well, that a lot of the disk images I found for the p-system are I think Classic99 disk images. These have filesizes of 260240 bytes. I hadn’t even looked at the Classic99 formats previously, but it turns out that the 260240 byte files are just Single Sided Single Density disks with extra raw track information. ie. the equivalent of the 92160 byte raw disk sector images I was using.

There is a way to convert between the two. In the whtech FTP site you have emulators/pc99/pc99utilities . I had seen a reference to using the PC992V9.EXE program from that directory, but I ended up using the dskdata.exe.gz file from the same directory. It’s an old DOS program. I don’t use DOS or Windows, but the program is simple enough to use with the emu2 command line DOS emulator. So then I could do something like this:

emu2 dskdata.exe Pilot669a.dsk output.dsk 0 359

The output.dsk should be a 92160 byte disk image.

I’ve merged the changes to . There are details in the README about how to set up the pcard emulation.