“The Abominable iPhone Zombies”
– A PETSCII Horror Doom Scroller
A new game for the Commodore PET, also, how to detect keyboards on a Commodore PET.
A Brand New PET Game
Rumors about me working on a game for the Commodore PET may not be entirely unfounded. In fact, I’ve been doing so, and I’ve progressed to the point that there is a playable WIP (work in progress). It still lacks sound and I may tune the level progression, but story and essential game mechanics are already in place.
Speaking of which, this is how the game (and our story) starts, right at the beginning:
![The first screen of "The abominable iPhone Zombies" for Commodore PET](/nowgobang/images/2024-iphone-zombies-in-the-beginning-white.png)
The game is intended for any Commodore PET with a 40-column screen, ideally running at 60Hz. It will run on 50Hz models, as well, but the timing has been set up with 60Hz in mind. And, while I have invested in some PETSCII text effects, it runs on minimal memory requirements of 8K RAM. (There’s still some left in order to fit sound.)
As may be told by the title screen, the game isn’t meant exactly dead seriously, more as a playable joke. So, in the spirit of bringing the story home, it’s not an easy game. (In fact, I tried an easier introductory level, but found that it really harms the game and the general idea.) Just as in real life, there is no guaranteed path to success, but it’s astonishing where you can actually sqeeze through.
![The title screen of "The abominable iPhone Zombies" for Commodore PET](/nowgobang/images/2024-iphone-zombies-title.png)
For a change in green phosphor emulation.
The real inspiring aspect of this, though, is that the game has been drafted and developed entirely in the emulator. The screens were drafted with convenient use of the “click cursor”, which allows you to position the PET’s cursor anywhere on the screen by a simple mouse click or touch-tap. Then, the drafts were exported as BASIC programs for later review and change, and eventually exported as hex-dumps, ready for integration in assembler code. This has been written in a simple text editor and was then assembled and test-run by a simple drag&drop of the source file onto the emulator. Finally, the assembled program was exported as a PRG-file, which is now ready to play.
So, without further ado or spoilers: you can always find the latest code here (in the “PRG Library” inside the emulator, in the ”New PET Games” section, or under this link,
where you will find links for both download and a to fire it up in the emulator.
Or just click here, for a direct link to the game in emulation:
We could have included a demo video, but why should we, if you can have the “real thing”?
Well, here’s a video, anyway:
(That transition, BTW, is not a simulation, but a proper implementation of the “10 PRINT” random maze swiping by.)
The emulator came also handy for testing the various ROM versions and keyboard types. (Just switch the configuration in the ROM menu and reload the assembled object code by a right-click on the displayed file label, which brings up its associated context menu.) — Speaking of keyboards…
PET Keyboard Adventures, Continued
Complementing our previous excursion into PET keyboards, here‘s how to detect the keyboard type of a Commodore PET (as used in “iPhone Zombies”), in order to implement our own low-level keyboard scan routine in 6502 code.
Generally speaking, there are just two types of keyboard layouts and related kezboard matrices, the graphics keyboard (including the chiclet keyboard of the original PET 2001) and the business keyboard.
Moreover, there are 3 ROM revisions to consider:
- ROM 1 (or 2, AKA “Old ROM”),
- ROM 2 (or 3, AKA ”New ROM”), and
- ROM 4 (with BASIC 4.0 — no ambiguity here).
Regardless of the keyboard type and the editor used, each of these ROMs has the keyboard decoding table in their exact same location. Which, in turn, allows us to determine the keyboard type by inspecting that table.
So, first, we’re going detect the ROM revision, based on a well known value. Say, based on the IRQ vector, which is distinctive for each of the ROMs and easy enough to locate (at the very top of the addressable memory range, at address $FFFE
.)
And here are the IRQ vectors of the major ROM revisions (we will check just the low-byte, as this is already significant):
- ROM 1 ……
$E66B
- ROM 2 ……
$E618
- ROM 4 ……
$E442
Once we have figured out the ROM revision, we may try to determine the keyboard type:
- For ROM 1, it’s easy enough, since this came with early PET 2001s and there had been only the chiclet keyboard, which is the same as the graphics keyboard layout.
- For ROM 2 and 4, however, we must dig a little deeper: As we know the address of the keyboard decoding table for each of these ROMs, we may pick any index into this and compare it to a known value.
E.g., for ROM 4 this is at$E60B
(and for ROM 2 at$E6F8
), regardless, if this a machine with the business keyboard or the graphics keyboard. Based on this, we may look up the index which holds the code for “A” (PETSCII$41
) for the graphics keyboard, but contains a destinctive different value for the business keyboard (which happens to be the code for TAB.) So this should be a simple test.- Et voilà, all that is left to do is to store our findings in a convenient flag.
- For ROM 2 and 4, however, we must dig a little deeper: As we know the address of the keyboard decoding table for each of these ROMs, we may pick any index into this and compare it to a known value.
And here is our little subroutine:
kbdDetect lda $FFFE ;IRQ vector, low-byte cmp #$1B ;is it ROM 2? beq kbdROM2 ;yes, branch… cmp #$42 ;is it ROM 4? beq kbdROM4 ;yes, branch… kbdIsGfx lda #0 ;must be the graphics keyboard kbdStoreFlag sta kbdBusiness ;store as keyboard type flag rts ;exit (all branches) kbdROM2 lda $E727 ;ROM 2: load code for row 4, column 0 kbdCheckCode cmp #$41 ;is it "A"? beq kbdIsGfx ;yes: it's the graphics keyboard lda #$FF ;no: it's the business keyboard bne kbdStoreFlag ;unconditional kbdROM4 lda $E63A ;ROM 4: load code for row 4, column 0 jmp kbdCheckCode kbdBusiness .byte 0 ;keyboard type flag: ; 0 .... graphics ; $FF .... business
Feel free to use this in your code. :-)
And that’s it, for this post.
Note: the section on the Japanese PET character ROMs and keyboard, found previously here, has moved to a post of its own: Japanese Attractions: Kana on the PET 2001.
Norbert Landsteiner,
Vienna, 2024-05-21