Category Archives: Tandy WP-2

Dumping the WP-2 ROM

As part of my project to run Zork on the Tandy WP-2, I found it useful to dump the ROM and take a peek at what it was doing.  While the Service Manual (available online from Club 100, the Internet Archive, and other places) contains a wealth of information, the code is the definitive place to look for information on how something works.

In order to dump the contents of the ROM, I wrote the below to read each code page, and write it out the serial port.  I compiled it with z80asm from Udo Munk’s z80pack.  I loaded the resulting binary onto the WP-2 by using a drive emulator (dlplus on Linux) and captured the results from the serial port to a file.  I then used an old version of IDA which supported the Z80 to perform the disassembly.

Combining the entry points from the service manual with the disassembly I could follow the code to answer questions regarding the operation of the WP-2 that were not completely clear from the manual.

; dumps all of the ROM banks to the serial port
; sets the serial port to 9600
; compile with z80asm -fb -vl DUMPROM.CO
CHARSENSE	equ		100H
CHARGET		equ		103H

SETLOC		equ		109H
GETLOC		equ		10CH
CURSORON	equ		10FH
CURSORTYPE	equ		112H

CHAROUT		equ		118h
PUTCHAR         equ		1A3H
STROUT		equ		11BH
CLS		equ		11EH
BEEP		equ		121H

RSINIT		equ		140H
GETDATALEN	equ		143H
SENDDATA	equ		146H
GETDATA		equ		149H
RSCLOSE		equ		14CH

CHGSLOT		equ		166H

LINEIN		equ		1A6H

BKSP		equ		008H
LF		equ		00AH
CR		equ		00DH
ESC		equ		01BH

		ORG		0AC00H-8
		DEFB		'PR'
		DEFW		PRGEND-PRGTOP+1
		DEFW		START
		DEFW		0000H

PRGTOP
START		CALL	CLS
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		NOP
		XOR	A
		ld	(CURSLOT),a
		CALL	CHGSLOT		; change to slot zero to start
		ld	hl,0h		; start at zero to read the first bank
		ld	(current),hl
		call	DUMPLOOP
MAINLOOP:
		call	BEEP		; We dumped another block
		ld	hl,4000h	; remaining banks start at 4000h
		ld	(current),hl
		ld	a,(curslot)
		inc	a
		ld	(curslot),a	; bump to next slot
		cp	0Fh		; if slot 15 (IC Card)
		jr	z,DONE		; then we are done
		call	CHGSLOT
		call	DUMPLOOP	; otherwise dump it
		jr	MAINLOOP
DONE:		xor	a
		CALL	CHGSLOT		; change back to slot zero
		xor	a
		ret

DUMPLOOP:	
		ld	hl,084Dh	; 9600 bps, 8n1, no xon, timer enabled
		call	RSINIT
BYTELOOP:
		ld	hl,(current)
		ld	a,(hl)
		inc	hl
		ld	(current),hl
		call	SENDDATA
		ld	a,h
		cp	080h
		jr	nz,BYTELOOP
		call	SENDDATA	; for some reason we have to send
					; another dummy byte before the close
		call	RSCLOSE
		ret

CURRENT		DEFW	00000H
CURSLOT		DEFB	0h
PRGEND

		END

 

Tandy WP-2 Running an Infocom Interpreter

Tandy WP-2 Running Infocom Interpreter
Tandy WP-2 Running Infocom Interpreter

A number of years ago I stopped off at a garage sale and picked up a Tandy portable wordprocessor WP-2.  I didn’t do anything with it at the time, but set it aside for further analysis.   Late this spring, I came across it on a shelf, and pulled it out to take a closer look.

The WP-2 is based on the Z80 processor and contains 256K of banked ROM, 32k RAM, an 8 character by 80 column display, serial port, cassette port, and printer port.  It also has a slot intended for extra RAM and ROM cards.  Inside, it has a socket for additional memory.  Most individuals added a second 32K ram chip, but 128K chips work as well.  The data in RAM is preserved in memory by a small coin cell battery.  The word processor normally runs for 20 hours off of 4 AA batteries.

The WP-2 serial port was intended for two purposes.  The WP-2 has a terminal program built into it, but will also connect to the same floppy drives that were used on the Model 100 and Model 102.   The Model 100 community has come up with software to emulate these drives, which proved to be extremely useful.

Some searching pulled up the service manual for the WP-2.  Unlike many service manuals of today, this one included a huge wealth of information.  Additionally, it appears that the original developers (in this case Citizen) had intended for the WP-2 to be expandable.  The service manual includes schematics, memory maps, and a description of the ROM entry points for procedures such as clearing and writing to the screen, operating on files, and accessing the additional memory banks.

In short, it was a treasure trove for the tinkerer!

As I considered my options, I looked at the core pieces of the device.  It had a keyboard, decent sized text display, 128K of built-in mass storage, 32K of RAM, and a floppy drive.  In my case, I would emulate the floppy drive with my laptop.  To me, a text adventure game would be a natural fit.

My own experiences with the Infocom games and their portability came to mind.  The early game files all fit within 128K, and use a text only output format.  The game interpreters themselves use only a fraction of the 32K of RAM, and automatically page in information as needed.

The next step was to try and find an interpreter that I could adapt to the WP-2.  I explored adapting the CP/M based interpreter, as well as others, but they were all tightly tuned to the systems upon which they ran.  However, I came across ZXZVM, which is written in a portable manner.  It already runs on the Spectrum, Spectrum +3, and Amstrad systems.  Source was available, as well as a brief porting guide.

My initial attempt at a program to write hello world to the screen was successful, and led to other small routines.  One of these was to dump the contents of the ROM to the serial port.  I could use this with a disassembler and the service manual to obtain a clear idea as to how the internal routines worked.  With the source to ZXZVM, a basic idea of how to use the internal routines, and a disassembly for a more detailed view of them, I was ready to start.

I started by breaking the large Infocom story file into smaller pieces and then loading them into the extra 128K of extra RAM.  This space is normally used for files, but I wanted to just store the raw data there.  ZXZVM includes routines to read/write each byte from the story file and the virtual machine’s memory.

Once the virtual machine was able to obtain the story data, it needed a mechanism to read the keyboard and write to the screen.  I was able to use the internal routines to do most of the work for this, although they needed some fine tuning to ensure that they fit the expectations of the interpreter.

In the process of adjusting the interpreter, I removed the code that handled later version games.  Given the small screen size, and additional game size, it wasn’t needed and the removal provided additional space in main memory.

At this point, with some polishing, I had a basic interpreter running.

However, I was still missing a key element required for some of the games.  I needed the ability to save and restore the game.

After searching, I came across and purchased one of the few 32K RAM cards that Tandy produced, and added it to my WP-2.

At this point, I added the additional code to save and restore the game files to the external memory card.  I found that I could save only two games to the card, but that the same code could be used to save to a virtual floppy drive if the system was attached to my laptop.

Tandy WP-2 Zork Leaflet
Tandy WP-2 Zork Leaflet

The net result is an extremely playable version of the Infocom interpreter.  I have been able to play games such as Zork and Planetfall to completion without issues.  The battery backup for the memory makes it just like picking up a book, to play for a while, and then put away until later.

As the leaflet in Zork 1 says, “No computer should be without one!”