1.00beta2 now with the source :)

Thanks:
-------

Christoph Gieelink for Emu42 sources (used to start this emulator)
John Shadbolt for first system roms, roms, programs and ideas 
Andre Koppel for MANY docs (manuals and system listings), systems roms and personal roms
Vassili Prevelakis for manuals, roms and programs 

For programmers:
----------------

Feel free to correct the source but please forward me the changes.
I'm not very good at WIN32 programming, there are certainly MANY bugs there, feel free
to help me for hunting those bugs...

If someone is interested, I have a Mac OS X port from an old version (circa 2004).
It is only usefull for a developer to point the endianess troubles and some
problems. If someone know a good intro about Mac os X programming, i'm interested.
Especially in how to use bitmap without using quickdraw !!!

Hints
-----

The comments and changes are at the end of this document.

Links
-----
John : http://www.vintagecomputers.freeserve.co.uk/hp80/
Vassili : http://www.series80.org
Andre : http://www2.akso.de/files/series_80

Intro
-----

New release with HP86/87 and HP86 emulators

Files
-----

readme.txt     		: this file
HP8..-debug.exe    	: emulator compiled with debug infos (use it to assert mis-behavior before complaining)
HP8..-release.exe	: emulator compiled with full speed optimization (PPro mode)
HP85...exe		: HP85 emulator (use x2 and x3 kml, see later)
HP87p...exe		: HP87 emulator (use only +x2 kml) special 64K vram mode (1016*480 graph mode)
HP87...exe		: HP87 emulator (use x1 and x2 kml) normal 16K vram

85...kml       : script for HP85 at x2 and x3 zoom
87+...kml      : script for HP87 1016*480 64K vram mode at zoom x1
87...kml       : script for HP87 at x1 and x2 zoom

.bmp           : associated bmp for kml

Roms/*.bin     : various needed roms (keep this structure of directory)
Disks/*.BIN    : various disk image in lif format (warning some doen't fit on a REAL floppy)

Keymap
------

KEY LABEL 		esc
RUN			apps windows key
PAUSE/STEP		attn
CONT/TR NORM		scroll lock
LIST/P LIST		print screen

-LINE/CLEAR		end
home			shift cursor up
I/R			ins
-CHAR			suppr
ROLL			previous/next

A/G			F9
TEST			shift F9
RESET			shift F10
INIT			shift F11
RESULT			(shift) F12

Other keys generate their Ascii code (normally :)

Menu
----

File 
- New      : choose a new KML script for a session
- Open     : load an existing saved state
- Save     : save the current state
- Save as  : save the current state as ..
- Close    : close current session
------------
- Settings : choose emulation speed (timers are preserved) normal or fastest
             date and time can be set from the host (sometime, need to launch then quit the debugger
             to activate it (bug))
------------
- Exit     : quit the emulator

Edit
- Paste string : paste the current text clipboard content as keystroke
- Copy string  : Copy the alpha screen as text in the windows clipboard
- Copy screen  : Copy the screen as bitmap in the windows clipboard
----------------
- Reset        : Reset the system (power cycle)
- Backup       
  - Save       : save the current system state in memory (buggy ?)
  - Restore    : restore the previously saved state (buggy ?)
  - Delete     : scratch the previously saved state (buggy ?)
- :D000 Lif file
  - Load       : load a lif file in the e-disk as 'New file'
  - Save       : not done
- :D000 E-disk
  - Load       : load a lif disk image over the e-disk
  - Save       : save the e-disk as an image
- :D70x		HP-IB 9921 floppy unit (up to 10 for HP87, 4 for HP85)
  - Load       : load a lif image (reset resistant) | the button under the screen can
  - Save       : save a lif image                   | be user as accelerators :
  - Eject      : eject the disk                     | 'load' when unlit, 'eject' when lit
Tool
- Debug        : open the debugger window (more on that later)
- Run          : not done
- Stop         : not done

Help
- About        : some info

Paste string and lif operations needs the emulator in the basic idle state (no program running)
(try with sky.txt) but can sometimes hang the emulator ...

Lif operation use the first e-disk (only tested in that configuration, I miss the exact syntax of 'config'
statement)

For HP86/87

Create it with a fresh reseted emulation with 
'config "foo",":d000",12,512' : create a 512Ko e-disk named 'foo' with 12*8 name entry as msu ':d000'
then use 'mass storage is ":d000"' (use F4) to make it the default msu.

For HP85, need to use MS IO ED roms, e-disk created at startup if more than 32K of ram

Lif file operations only activated for HP87 emulator.

Lif file operations needs correct lif file (from lifutil i.e.) and use the first entry in it.
The loaded file is renamed 'New file', it's up to you to change it after
(use 'rename "New file" to "bar" in emulator).

Lif disk image can be loaded only on a greater or equal e-disk in size. When saved this image will be of 
the new size, but the number of entry doesn't extend.

The lif disk image are correct lif files (could be used with lifutils ?). Some are given.

P.S. - p-System doesn't like the e-disk (want a real disk even on real HP87 ?)
     - VzCalc seem to work :)
     - Demo is ok
     - MathPac ok
     - Action Games ok ... can be too fast in fast mode
     - Perso is from a real HP86b :)

Roms
----

HP 86/87

- System 0x0000-0x5FFFF : HP87/86 roms
- Paged 0x00 : HP87 system rom 000
- Paged 0x01 : HP87 system rom 001
- Paged 0x0e : HP86 miksam rom 016
- Paged 0x18 : HP86 langage rom 030
- Paged 0x28 : HP87 assembler rom 050
- Paged 0x38 : HP86 Andre Koppel rom 070
- Paged 0xb0 : HP87 matrix1 rom 260
- Paged 0xb1 : HP87 matrix2 rom 260
- Paged 0xcf : HP87 enhanced mass storage rom 317
- Paged 0xd0 : HP87 mass storage rom 320
- Paged 0xd1 : HP87 electronic disk rom 321
- Paged 0xe7 : HP87 advanced programming 2 347
- Paged 0xe8 : HP87 advanced programming 1 350
- Paged 0xf0 : HP87 printer/plotter rom 360

With language rom 030, the emulator start as an HP86b with an HP87 CRT :)

some roms are patched to allow special 1016x480 graphic mode

Some infos for HP86 Andre Koppel rom 070:

ADR(String)            		converts a String to a number
ADR$(Number)        		converts a number to a string
AND$(String1,String2)
AREAD Stringvar   		read screen contents to string
AWRITE 				row,column,String
BCAT Number             	shows the catalog of the binary with the given number
BFLABEL Linemark        	searches within a program for the line that contains a
				linemark with the given name
BLANK$(count)
BPGM?(Number)        		returns 1, if the binary with the given number was loaded
BSET?(String,Bitmask)
CBIT$(String,Bitmask)
CHKSUM(String)
C_RETURN                	removed all sublevel from the return stack
O_D(Octal_Number)       	converts a octal number to decimal
ODD(Number)             	return 1, if number is not even
PEEK(Adr)               	returns octal coded byte from the given address (address must be
given in octal)
PEEK$(Adr,ROM_Number,count)     returns string with length "count" from base
				address Adr (must be given in octal) from ROM (or system)
POKE Adr,Byte        		Parameters ar octal
POP RETURN                	removes one return level from stack
RCAT ROM_Number        		shows the catalog of the statements and functions provided
				by the ROM with the given number
REGREP (String)        		converts string that is given in CPU-notation to Number
REGREP$(Number)        		converts number to internal BCD CPU-notation
REGREP$$(Number)  		same as REGREP$, but result is in octal (for assembler
programming)
RELEASE KEYBOARD
REPLACE$(String1,String2)
RESTOREX Number        		Like standard RESTORE, but also accepts a variable as Number
REV$(String)
ROM?(ROM_Number)        	Returns 1, if ROM was found within the system
ROUND(Number,Pos)
RPL$(String)        		changes characters within the string according to SET REPLACE$S
RPT$(String,count)        	repeats a string
RSECTOR String,Record_Number,MSUS$       reads records from disk
SADR (String)        		returns starting address of string in RAM
SBIT$ (String,Number)
SCALL Adr[,ROM]        		jumps directly to the machine code at the given address
(octal)
SCALL String        		processes machine code within string
SET ERRBR                 	reactivates old ON ERROR
SET REPLACE$ String1,String2
SETPTR2 Adr,Value        	Loads 2-Byte PTR2 value
SETPTR3 Adr,Value 		Loads 3-Byte PTR2 value
SORT String,Substringlen,start,end
START CRT AT row        	starts screen at given row
TAKE KEYBOARD
TOKEN EXECUTE String 		executes a previously tokenized BASIC-command stat is
				stored within the string
TOKEN$ (String)        		parses and converts the BASIC commands given within the
				string for further use with TOKEN EXECUTE
TRIM$ (String)
UNMASK                		demasks keyboard
WSECTOR String,record,MSUS      like rsector
XOR$(String1,string2)

There are several other commands within the ROM for structured programming.
(use RCAT or given listing of roms)

HP 85

- System 0x0000-0x5FFFF : HP85 roms
- Paged 0x00 : HP85B system rom 000
- Paged 0x08 : HP9915A development rom 010 (don't work actually)
- Paged 0x28 : HP85 assembler rom 050
- Paged 0xb0 : HP85 matrix rom 260
- Paged 0xc0 : HP85B io rom 300
- Paged 0xcf : HP85B enhanced mass storage rom 317
- Paged 0xd0 : HP85B mass storage rom 320
- Paged 0xd1 : HP85B electronic disk rom 321
- Paged 0xe0 : HP85 service rom 340
- Paged 0xe8 : HP85 advanced programming rom 350
- Paged 0xf0 : HP85 printer/plotter rom 360

The system use HP85B roms.

Debugger
--------
Some bugs here.

Icons:
- Run
- Run to cursor (code window)
- Break
- Set breakpoint to cursor
- Edit breakpoints
- Step in
- Step over (for JSB, i.e.)
- Step out by stack level (be carefull the HP87 os likes to play with the stack)
- forget ??

Menu should work : Debug menu : ok (with accelerator keys)
                   Breakpoints menu : only code breakpoints
                   Interrups & Info : do nothing

Code windows : lclick select line (use arrows to scroll), rclick context menu (not fully tested)

Memory window : on byte data : lclick select byte (use arrows to scroll), double lclick change byte
                               rclick context menu (not fully tested)

Register windows : can change some registers (don't know why ...) warning, cancel doesn't work !!

Hardware
--------
Capricorn CPU :
---------------
Rather good actually, some optimizations needed, some specific behavior guessed (BCD arithmetic with non BCD numbers).

Roms :
------
Paged roms supported. Max is 15 from the software part (size of a table).

EMC :
-----
ok up to 16 Mo, but 8 Mo really usefull for basic (basic use MSB for allocation of basic lines).
In this case use the top 8Mo as e-disk ? 
Specific behavior (wrap around address not known) guessed (false ?)
Some roms make strange access to the emc (read PTR2-+ to get the PTR2) : coded

CRT :
-----
Quite good, perhaps more optimization ? even support inverse video mode for HP87 :)
Can pass the test from the HP85 service rom on normal speed

KEYBOARD :
----------
International Ascii character not defined in map. Should work with any keyboard (and language)
Some harware keycode are not mapped (i.e. the E from HP numeric keypad isn't mapped at all)

Timers should work. At normal speed, timers use capricorn cycles count. PC high resolution counter used for waiting. At fastest speed high resolution counter are used for all timers.
Perhaps a bit of drift (should make some measurements) ?

As timeslices used are sub ms, the emulator use all PC cpu. Btw the capricorn CPU doesn't have a sleep mode (as Saturn processor), so the cpu always run.


Olivier De Smet

18/07/2004 updated 23/02/2006

------------------------------------------------------
22/07/2004

- last touch on cpu emulation (DCB arithmetic, very tricky, non symmetric operation)

------------------------------------------------------
26/07/2004

- new HMI with correct fonts 
- finished minimal iop and hpib support for HP9121Q (4 units :)
- correct some bugs on CPU emulation (status bits for shifts) : correct basic run pb.
- p-SYSTEM still don't work :(
- orange led emulated
- the left red dot is the activity of the HP9121 controller, the four next green dots
  are the activity of the 4 units. When the name is red, a disk is loaded. By clicking on it
  you can load then eject a disk.
- It's possible to have 8" floppy (~1Mb) or Winchester HD (~4.8Mb). Is there a need for that ?
  (capabilities of the MS rom, I didn't look at the EMS rom). It's also possible to have
  10 unit per drive. Is it useful ?
- D700 is the same as D704 and D708. I can change it ...

------------------------------------------------------
29/07/04

- bug on IC & DC opcode (OVF)
- rework 'New ' -> change of internals
- done ten units for discs (at boot the system only search on 0-3 for Autost and MSUS)
- done different type of disc unit (floppy, 8" and HD)
- a disk will load a smaller image
- the discs loaded are emulator-RESET resistant :) (no need to save before RESET)

------------------------------------------------------
30/07/04

- some optimizations
- time and date are set on startup (use time$ and date$ from Advanced Programming)
  and reset when leaving debugger (in debuger mode, timers use cycles count)

------------------------------------------------------
31/07/04

- add sound. Some troubles to stop sound in windows. Must generate wave in real time ...
- use registery to save settings (in 'settings' 'file' menu)
  /SOFTWARE/HP8x as base key
- when idle (main EXEC loop) Sleep a bit (so don't use all host cpu)

------------------------------------------------------
01/08/04

- add 701 HPIB printer (should use I/O ROM and PRINTER) : actually dump is done on printer-000.txt file
- correct some IOP behavior due to I/O rom
- thinking about serial I/O from/to COM1
- no 705 HPIB plotter support actually (I miss the HP-GL syntax)

bugs:
- still 'DO' from SYSEXT rom reset the HP86 ?? (is it true on a real one ?)
- be carefull with PLOTTER and I/O ROM, all syntax isn't already coded -> many will ASSERT exceptions
- p-System don't work ... CPU bug ? (need the service rom ?)

------------------------------------------------------
04/08/04

- SYSEXT 'DO' bug is normal
- corrected behavior for EMC PTR and now p-SYSTEM works :)
  Btw the etx key is CONT on HP (SCROLLLOCK on emu)
  esc is KEYLABEL on HP (ESC on emu)
  some other key doesn't seem to work in editor ??
- many small optimizations everywhere
- added a settings to set the date & time at startup
  (do not set it to use TIME p-SYSTEM function)

------------------------------------------------------
06/08/04

- many minor optimization (~8% faster)
- ONE HUGE optimization (~600% faster) (NEVER read too rapidly the High performance counter)
  but now the sound in high speed is very bad :(
  In Debug : 12,75 Mhz Capricorn, in Release 25 Mhz Capricorn, p-System is now more than useable. :)
  (Athlon XP2100+)
- Due to some changes, when pasting string, put the emulator in background, it will be faster !
- I don't have too much docs on p-SYSTEM (units and others). Btw it miss some utilities to be
  complete.
  You can use the Web-site 'Jefferson Computer Museum - UCSD P-System Museum' for info
  and files. (I already convert all USUS volumes to p-disk, just ask (2.5Mb archive))

------------------------------------------------------
08/08/04

- new model : 64Ko video ram, only useable in zoom x2 KML modes: new program
  somes patches to rom 001, 208 and system rom and :
  GRAPH & GRAPHALL : 1016*480, all software using basic works.
  No changes are required on software, except for FAST LABEL (using screen coordinates)
  and BPLOT for the size (4 times smaller now). The display is just finer :)
  (FAST LABEL in UTIL/1 need a patch, done, btw the patch is ok for all models even real hardware)
  (1016 x 512 is the maximum possible, due to a multiply algorithm used in rom 001
   # of bits of (X/8) + # of bits of Y can't be greater than 16)
  I keep 480 for the ratio (the new max LIMIT is 0,159,0,75)
  ALPHALL is still limited to 204 lines (could be changed, just need more patch)
  GRAPHALL isn't usefull anymore (except to avoid flipping to ALPHA)
  GSTORE and GLOAD works, but only for files of their own size.
  Be carefull, now the default (as size, not as preset) CSIZE is 2.5 (same size as FAST LABEL)

  Just for fun, try the demos from DEMO disk (use given UTIL/1)
  you can also try 'SKI-85' but choose 'real speed', otherwise you can't win !
  Try new fractal also

------------------------------------------------------
10/08/04

- modified new model, now works with a zoom x 3 KML script and use new BMP
  The display is now 1016*480, with a new 12x20 font (nice display on 1024*768
  screen, ie my laptop)
- rewrote UTIL/1 (more bugs removed and optimizations, included in fl86-asm.lif)
- sometimes, the emulator loose the keyboard focus from windows ??
  in this case just open and close the debugger to regain focus
  Strange bug but I don't know where it come from.
 
------------------------------------------------------
12/02/06

- correct some bugs for HP86 emulator
- include now an HP85 emulator :
  - the keymap is similar to the HP86 one
  - only KML x2 and x3 are supported
  - only 4 hp-ib disks (with MS ROM) supported as :d700, :d701, :d702 and :d703
  - if you use the ED ROM, the ed is configured (see with debugger) but not useable ??
  - the service ROM is supported but only CPU, ROM, XROM, XRAM and DISPLAY are ok
  - the tape is configured as 'NO TAPE INSERTED'
  - the printer is configured as 'OUT OF PAPER', HP-IB printer is not always supported 
    (it depends of the set of roms loaded, ie it doesn't work with ED rom ...)
  - some bugs with timers (time doesn't elapse correctly when the HP is waiting for input)
- I thinks some bugs come from the ROMS, I got various roms and I'm not sure if they came from
  HP85(A) or HP85B. Can someone dump a full set of rom from an HP85B and forward them to me ?
  (John send me 2 sets from HP85A and HP85B, but they are identical...)
- The HP85 emulator is not complete due to lack of docs

Hints : load ED ROM so you can use 'msi ":d700"' instead of 'mass storage is ":d700"' :)

-------------------------------------------------------
16/02/06

- actually it's not a good idea to load the ED rom as it interfere with the MS rom a lot !!
  perhaps the MS rom of an HP85B isn't the same as the stand-alone MS rom ??
- done the integrated printer in a crude way:
  - no paper advance
  - only 10000 pixels long paper ! (wrap after that)
  - no saving
  - only zoom x2 in blue :)
   text dumped in 'prt85-000.txt' file

-------------------------------------------------------
23/02/06

- got some MS and IO roms from John Shadbolt (thanks again) from his HP85B and now the ED is ok.
  So we have now an HP85B emulator with up to 4MB e-disk. (should we go up to 16MB ?)
  (as I thought, MS and IO roms from HP85B are different from those for an HP85A)
- some bugs corrected after a 'reset' (the HP-IB inserted disks are more persistant now)

