5 JPC-RR is licenced under GNU GPL v2. See file “LICENSE”
11 To get started, you need BIOS image, VGABIOS image and DOS boot
12 floppy and JDK for Java 6 standard edition (later versions should
13 they appear should also work). Note: JRE is not enough.
15 Note that to play back recorded movies, you need exact same
16 version of BIOS image, VGABIOS image and DOS boot floppy as was
17 used when making the movie (in addition to exact same versions of
20 See compile.sh. The stuff in streamtools is only needed for
25 See compile.sh. The streamtools stuff is only needed for dumping
30 First you need to get and make some important images. Obtain BIOS
31 image, VGABIOS image and DOS boot floppy from somewhere. After
32 starting the emulator, use File -> Import Image to import the
33 images (ignore the error about no BIOS images being found).
37 There is premade autoexec script called assemble.bat that has
38 fairly reasonable defaults. To use it:
40 java JPCApplication -library library -autoexec assemble.bat
42 The “-library library” specifies that contents of directory
43 'library' are to be used as library. The script pops up settings
44 for new emulated PC (if you want to load savestate, click
45 cancel). Select BIOS and VGABIOS for BIOS and VGABIOS image (they
46 should be already selected), DOSfloppy for fda (boot device
47 should be set to fda) and game image as some HD drive
51 • Putting the game as hdd causes boot to be bit faster.
53 • Some BIOS versions have “press F12 to select boot device”. Hit
54 <enter> from emulated keyboard and that prompt will go away in
55 about half emulated second (it stays several emulated seconds
58 • If game doesn't need lots of memory, hitting F5 to skip
59 intialization files is fastest. If it does need more memory,
60 run config.sys commands but not autoexec.bat.
62 • Some DOS disks have DOSIDLE with them, don't use it as it
63 messes badly with emulator.
65 3 Making JPC-RR format images from raw images
67 Due to various factors, JPC-RR can't use raw image files directly
68 but requires its own image format.
70 3.1 Importing images from GUI:
72 Use File -> Import Image to import existing directories or image
73 files. Dialog prompting parameters will be displayed. When
74 importing floppy images, check “standard geometry” if possible,
75 that enables geometry autodetection, which is reasonable
76 virtually all of the time it is offered.
80 • If making image from directory, the names of the files must
81 conform to FAT naming restrictions (8+3 character names, no
82 spaces, etc). Avoid filenames with non-ASCII characters.
84 • The DOS limit of 112 or 224 files for floppies does not apply
85 to images created from directory trees. The minimum limit value
86 used is 512. If even that isn't enough, the limit is
87 automatically increased to fit all the needed directory
90 • Making boot disks from tree does NOT work. Even if you got
91 system boot files there, it still won't work.
93 • Only floppy disks and hard drives can be made from directory
94 trees. BIOS images and CDROM images require image file.
96 • Avoid floppies with custom geometry (floppy geometry does
97 affect disk ID). Disks with over 63 sectors per track don't
98 work with DOS. Wheither disks with over 127 tracks per side
99 work with DOS is unknown. Also avoid 1024-tracks per side HDDs.
101 • The geometry limits are: 2-1024 tracks per side for HDD, 1-256
102 tracks per side for floppy. 1-63 sectors per track for HDD,
103 1-255 sectors per track for floppy. 1-16 sides for HDD, 1 or 2
104 sides for floppy. This gives size limit of 65280KiB for floppy
105 disks (but note the DOS limit!) and 516096KiB for HDDs.
107 • There are multiple image file contents that represent the same
108 image. The one with smallest size is picked when creating
111 • Note: Although the IDs are 128 bits long, they are not MD5
114 3.3 Importing from command line
116 There is tool called ImageMaker that can make JPC-RR images from
117 raw images. Each image has format, ID an name. Format and name
118 are specified when making image. ID is automatically calculated
119 from format and contents. Name does not affect the ID but is
120 purely for convience so one doesn't have to specify long image
125 The syntax for ImageMaker when making images is:
127 $ java ImageMaker <format> [<options>...] <destination> <source>
130 <destination> is file name for JPC-RR format image to write.
131 <source> is either name of regular file (raw image file) or name
132 of directory tree with files (supported for making floppy or hard
133 disk images only). In case of directory tree, the files are
134 layout deterministically to disk, so the ID will always be the
135 same for given geometry and type. <name> is name to give to disk.
138 --BIOS BIOS image (note: VGABIOS is also of this type).
140 --CDROM CD-ROM image.
142 --HDD=cylinders,sectors,heads Hard disk with specified geometry.
144 --floppy=tracks,sectors,sides Floppy disk with specified
147 --floppy160 160KiB floppy (40 tracks, 8 sectors, Single sided).
149 --floppy180 180KiB floppy (40 tracks, 9 sectors, Single sided).
151 --floppy320 320KiB floppy (40 tracks, 8 sectors, Double sided).
153 --floppy360 360KiB floppy (40 tracks, 9 sectors, Double sided).
155 --floppy410 410KiB floppy (41 tracks, 10 sectors, Double sided).
157 --floppy420 420KiB floppy (42 tracks, 10 sectors, Double sided).
159 --floppy720 720KiB floppy (80 tracks, 9 sectors, Double sided).
161 --floppy800 800KiB floppy (80 tracks, 10 sectors, Double sided).
163 --floppy820 820KiB floppy (82 tracks, 10 sectors, Double sided).
165 --floppy830 830KiB floppy (83 tracks, 10 sectors, Double sided).
167 --floppy880 880KiB floppy (80 tracks, 11 sectors, Double sided).
169 --floppy1040 1040KiB floppy (80 tracks, 13 sectors, Double
172 --floppy1120 1120KiB floppy (80 tracks, 14 sectors, Double
175 --floppy1200 1200KiB floppy (80 tracks, 15 sectors, Double
178 --floppy1440 1440KiB floppy (80 tracks, 18 sectors, Double
181 --floppy1476 1476KiB floppy (82 tracks, 18 sectors, Double
184 --floppy1494 1494KiB floppy (83 tracks, 18 sectors, Double
187 --floppy1600 1600KiB floppy (80 tracks, 20 sectors, Double
190 --floppy1680 1680KiB floppy (80 tracks, 21 sectors, Double
193 --floppy1722 1722KiB floppy (82 tracks, 21 sectors, Double
196 --floppy1743 1743KiB floppy (83 tracks, 21 sectors, Double
199 --floppy1760 1760KiB floppy (80 tracks, 22 sectors, Double
202 --floppy1840 1840KiB floppy (80 tracks, 23 sectors, Double
205 --floppy1920 1920KiB floppy (80 tracks, 24 sectors, Double
208 --floppy2880 2880KiB floppy (80 tracks, 36 sectors, Double
211 --floppy3120 3120KiB floppy (80 tracks, 39 sectors, Double
214 --floppy3200 3200KiB floppy (80 tracks, 40 sectors, Double
217 --floppy3520 3520KiB floppy (80 tracks, 44 sectors, Double
220 --floppy3840 3840KiB floppy (80 tracks, 48 sectors, Double
225 --volumelabel=label Give specified volume label (affects ID).
226 Only meaningful when making image out of directory tree. Default
229 --timestamp=YYYYMMDDHHMMSS Give specified timestamp for files
230 (affects ID). Only meaningful when making image out of directory
231 tree. The default timestamp is 19900101T000000Z.
233 3.3.3 Image information
237 $ java ImageMaker <imagefile>
239 Variety of information about image is displayed (especially for
240 floppies/HDDs). Two important fields are calculated and claimed
241 disk ID. They should be the same. If they are not, then the image
242 file is corrupt (sadly, imagemaker has bugs and bugs that cause
243 it to write corrupt images have been seen).
245 3.4 Advanced: The disk ID algorithm
247 The disk ID is calculated as:
249 Skein-256-128-deprecated(<typecode>|<geometry>|<image>)
251 Where Skein-256-128-deprecated is Skein hash function with
252 256-bit internal state and 128-bit output using the deprecated
253 rotation constants (as specified in Skein hash function reference
254 documentation versions 1.0 and 1.1). The <image> is the whole
255 image, including parts not stored in image file. The reason for
256 keeping using the deprecated constants are:
258 • Changing the constants would change the IDs, which would
259 invalidate existing images
261 • This is not about cryptographic security
263 • The new constants don't improve security that much anyway.
265 3.4.1 Floppies and HDDs
267 Floppies have <typecode> value 0 (single byte) and HDDs have 1
268 (single byte). <geometry> is as follows (this is exactly the same
269 form as it appears in image header):
271 Byte 0 bits 0-1: Bits 8-9 of track count per side - 1.
273 Byte 0 bits 2-5: Head count - 1.
275 Byte 0 bits 6-7: Reserved, must be 0.
277 Byte 1: Bits 0-7 of track count per side - 1.
279 Byte 2: Sector count per track - 1.
281 3.4.2 CD-ROM and BIOS images
283 CD-ROMs have <typecode> value 2 (single byte) and BIOS images
284 have 3 (single byte). <geometry> is blank.
286 3.5 Advanced: Disk Image format
288 The disk image consists of following parts:
300 • type-specific geometry/size data
306 Magic in disk image files is following 5 bytes: “IMAGE”
310 Disk ID is given as 16 bytes, encoding the 128-bit disk ID.
314 Type code is single byte. 0 for floppies, 1 for HDDs, 2 for
315 CD-ROMs and 3 for BIOS images. Other values are reserved.
319 Disk comment length is given as two-byte big-endian value. New
320 images should have 0 here.
324 Ignored. Comment field is there for backward compatiblity.
325 Comment length gives length of this field in bytes.
327 3.5.6 Type-specific geometry/size data (floppies and HDDs)
329 Floppies and HDDs have 3-byte geometry data:
331 Byte 0 bits 0-1: Bits 8-9 of track count per side - 1.
333 Byte 0 bits 2-5: Head count - 1.
335 Byte 0 bits 6-7: Reserved, must be 0.
337 Byte 1: Bits 0-7 of track count per side - 1.
339 Byte 2: Sector count per track - 1.
341 3.5.7 Type specific-geometry/size data (CD-ROMs)
343 CD-ROMs have 4-byte big-endian sector (512 bytes!) count.
345 3.5.8 Type specific-geometry/size data (BIOS images)
347 BIOS images have 4-byte big-endian byte (not sector or block)
350 3.5.9 Actual image data (floppy/HDD)
352 Floppy or HDD imagedata consists of following subparts:
362 Storage method is single byte. Sectors present gives number of
363 last nonzero sector + 1 (zero if image is all zeroes)
365 3.5.10 Floppy/HDD storage method 0: Raw storage
367 This storage method has empty header. Image data is raw dump of
368 first sectors present sectors.
370 3.5.11 Floppy/HDD storage method 1: Sectormap
372 Image data header contains bitfield with just enough bytes to
373 have one bit per present sector. The order of bits is such that
374 number of bit corresponding to each sector in byte is sector
375 number modulo 8 and byte number is floor of sector number divided
376 by 8 when sector numbers are counted from zero. If bit
377 corresponding to sector is set, then the sector is present in
378 image data, otherwise it is absent and assumed to be all-zeroes.
380 Image data contains dumps of all present sectors in order of
381 increasing sector number.
383 3.5.12 Floppy/HDD storage method 2: Extent first sector zero
385 Image data is empty as storage-specific data is mangled with
386 image data. The image data alternates between blocks encoding
387 zero sectors and blocks encoding nonzero sectors. The first block
388 encodes zero sectors.
390 Block encoding zero sectors consist of single 1-4 byte
391 little-endian value encoding number of sectors in block - 1.
392 Number of bytes is determined by sectors present value. It is 1
393 for 1-256 sectors, 2 for 257-65536, 3 for 65537-16777216 and 4
394 for more than 16777216. All sectors in block are filled with
395 zeroes and are not stored.
397 Block encoding nonzero sectors has same block count as zero
398 sector block but is followed by the sectors stored raw.
400 3.5.13 Floppy/HDD storage method 3: Extent first sector nonzero
402 Same as storage method 2 but first block is nonzero sector block.
404 3.5.14 Actual image data (CD-ROMs and BIOS images)
406 These store image data raw. The amount of data is specified by
411 4.1 org.jpc.utils.RAWToPNG
415 $ java org.jpc.utils.RAWToPNG <input> <outputprefix>
417 Reads RAW video data from <input> (may be named pipe) and dumps
418 PNG frames received as '<outputprefix><runningcount>.png'. Also
419 saves '<outputprefix>.timing' which contains frame timing data
420 (each line consists of time in nanoseconds, space, and filename).
422 5 The actual emulator
424 The actual emulator is invoked as:
426 $ java JPCApplication <options>...
428 The valid options are:
430 -library <library> Use the specified directory when searching for
431 images (can only be specified once).
433 -autoexec <script> Execute contents of specified file as commands
438 When emulator is started, command line comes up. Following
441 • 'exit': exit immediately
443 • 'load <plugin>': Load plugin (no arguments)
445 • 'load <plugin>(<arguments>)': load plugin with arguments.
447 • 'command <command> [<arguments>...]': Invoke command via
448 external command interface.
450 When one gets command line, its useful to load some plugins. See
451 section about plugins. Note: Load runner plugin
452 (PCControl/PCRunner and so) last, as some runners like to start
455 5.2 PC settings dialog notes
457 • CPU divider base frequency before division is 1GHz.
459 • Images can be specified by name or by ID. Name is relative to
460 library directory. If the image is in subdirectory of image
461 directory, the directory separator is is '/' regardless of what
464 • CD-ROM and hdc are mutually exclusive
466 • Modules is comma-seperated list of modules to load. To pass
467 arguments to some modules, enclose the arguments in (). Same
468 module can be specified twice only if parameters differ.
470 • FPU emulator is specified by class name. If core has built-in
471 FPU emulator, then this should be left blank. Without
472 core-builtin FPU emulator, blank value means “no fpu”.
474 • Setting boot device doesn't work with some BIOS versions. Those
475 versions prompt the boot device anyway.
477 5.3 Audio output channels
479 PC can have one or more audio output channels. The name of audio
480 output associated with PC speaker is:
481 'org.jpc.emulator.peripheral.PCSpeaker-0'. Modules that have
482 audio outputs get channel names of form <classname>-<sequential>,
483 where <classname> is name of main module class and sequential is
484 number starting from zero. Note that same module can have
485 multiple output channels. If multiple modules of same class
486 request audio outputs, the <sequential> values of subsequent
487 module start where previous left off.
491 Plugins actually execute the tasks of the emulator. They can be
492 loaded using “load <plugin>” or 'load <plugin>(<arguments>)” from
495 Different Plugins using the same output (like running PCMonitor
496 and PNGDumper) should not conflict because connector output hold
497 locking is desinged to handle multiple readers.
499 If no plugin used requires GUI, then the emulator can be run
500 without having GUI available.
502 5.4.1 plugin: org.jpc.plugins.PCControl
504 No arguments, requires and uses GUI.
506 Runs the PC emulator core. Has capability to start/stop
507 emulation, breakpoint after certain time or start/end of VGA
508 vertical retrace. Also can create, savestate and loadstate PC
509 emulation. Memory dumping is supported.
511 5.4.2 plugin: org.jpc.plugins.PCRunner
513 Takes 'movie=<file>' as argument and optionally 'stoptime=<time>'
514 Does not require nor use GUI.
516 Loads PC from savestate and just runs it. CTRL+C to quit. Also
517 automatically quits once stoptime is reached.
519 5.4.3 plugin: org.jpc.plugins.PCMonitor
521 No arguments, requires and uses GUI.
523 VGA monitor for emulated PC.
525 5.4.4 plugin: org.jpc.plugins.VirtualKeyboard
527 No arguments, requires and uses GUI.
529 On-screen keyboard for emulated PC.
531 5.4.5 plugin: org.jpc.plugins.PCStartStopTest
533 No arguments, requires and uses GUI.
535 Small plugin testing remote PC start/stop. Also supports sending
536 some common keypresses.
538 5.4.6 plugin: org.jpc.plugins.RAWVideoDumper
540 Takes 'rawoutput=<file>' as argument. Does not require nor use
543 Dumps all generated frames to RAW file <file>. Rawoutput is
544 required. The raw file consists of concatenation of zlib streams.
545 The uncompressed stream is concatenation of time skips (FFh FFh
546 FFh FFh), each acting as time offset of 2^32-1 nanoseconds and
547 saved frames. The saved frame has time offset in nanoseconds (big
548 endian) as first four bytes (must be at most 2^32-2, as 2^32-1 is
549 reserved for time skip). The next two bytes are big-endian width,
550 next two big-endian height. Finally frame has 4 * width * height
551 bytes of data that encodes pixels using 4 bytes per pixel, in
552 left-to-right, up-to-down order. Byte 0 of each pixel is
553 reserved, byte 1 is the red channel, byte 2 is green channel and
554 byte 3 is blue channel.
556 Dumping to pipe is supported.
558 5.4.7 plugin: org.jpc.plugins.RAWAudioDumper
560 Takes 'src=<name of audio output channel>',
561 'file=<output-filename>' and 'offset=<offset>' as arguments,
562 separated by ','. Does not require nor use GUI.
564 Dumps output from specified audio output channel (src, mandatory)
565 to RAW-format file (file, mandatory). The resulting file consists
566 of records, 4 or 8 bytes each. 4 byte record consists of 0xFF
567 0xFF 0xFF 0xFF and means to increase next time delta by 2^{32}-1
568 ns. Otherwise record is 8 bytes. Each 8 byte record has three
569 fields. First 4 byte unsinged big endian timedelta value (in
570 nanoseconds, must be smaller than 2^{32}-1), then 2 byte signed
571 big endian new left channel volume, then 2 byte signed big endian
572 new right channel volume. Optionally 'offset' can be set to
573 positive value (in nanoseconds) to delay the audio by.
575 5.4.8 plugin: org.jpc.plugins.LuaPlugin
577 Takes 'kernel=<name of lua kernel file>', other parameters are
578 passed to kernel, requires and uses GUI.
580 Lua VM for executing scripts.
584 6.1 org.jpc.modules.Joystick:
588 • Resources: I/O port 0x201
590 Emulates joystick game port.
592 6.2 org.jpc.modules.BasicFPU:
598 Crude FPU (x87) emulator.
602 Hacks are saved to savestates but not movies.
606 Force bit 1 of physical address 0x0410 to zero, signaling that
607 the system has no FPU. BIOS assumes system has FPU but some games
608 use that bit to detect FPU, trying to use it if it is “present”.
609 Try this if game startup hangs with lots of trying to use FPU but
610 not present errors. Don't use if there is FPU present. Needed to
611 get games like Blake Stone to work (FPU emulator allows it to
612 start but causes graphical glitches).
616 Update basic VGA parameters before vretrace, not after it. Some
617 games (e.g. Commander Keen 4) don't like if this isn't done and
618 some games (e.g. Mario & Luigi) don't like if it is done. Wrong
619 value manifests as jerky scrolling (scrolling back and forth and
620 fixed statusbars move).
622 8 Some error messages and explanations
624 • <filename> is Not a valid image file
626 • <filename> is not image file
628 • <filename> claims to be floppy with illegal geometry: <x>
629 tracks, <y> sides and <z> sectors.
631 • <filename> claims to be HDD with illegal geometry: <x> tracks,
632 <y> sides and <z> sectors.
634 • Can't read disk image sector map.
636 • Can't read disk image extent.
638 Code expects <filename> to be valid JPC-RR format image, but it
639 isn't JPC-RR image at all or its corrupt.
641 • <filename> is image of unknown type.
643 • <filename> has unrecognized geometry <x> <y> <z>
645 Possibly corrupt image, not JPC-RR image, or JPC-RR image from
646 future version containing something current version can't
649 • Invalid format specifier <something>.
651 • Invalid syntax of --floppy= or --HDD= option.
653 • Invalid format specifier/option <something>.
655 Invalid option or format specifier was given. Check for typos.
657 • java ImageMaker [<options>...] <format> <destination> <source>
660 Check syntax of command. Especially that diskname is present!
662 • The image has <nnn> sectors while it should have <yyy>
663 according to selected geometry.
665 • Raw image file length not divisible by 512.
667 • Trying to read sector out of range.
669 The selected geometry is wrong or raw image is incomplete.
671 • Invalid disk name (Should not happen!).
673 • Invalid geometry to be written.
675 This is a very likely a bug in program.
677 • What the heck <filename> is? It's not regular file nor
680 That sort of file can't be used as input for image making, or the
681 file just doesn't exist.
683 • BIOS images can only be made out of regular files.
685 • CD images can only be made out of regular files.
687 Source image specified is not regular file, but image of that
688 type can't be made of anything else.
690 • Can't read raw bios image file.
692 • Can't read sector <nnn> from image.
694 Reading the raw image file failed for some reason.
696 • Bad library line: "<something>". Ignored.
698 Syntax error in image library.
700 • Removing image <something> a.k.a. "<something>" as it no longer
703 The image file no longer exists so it gets removed from library.
705 • Removing image <something> a.k.a. "<something>" due to <some>
708 Image library code killed some image from library due to some
709 kind of conflict with image being added.
711 • Too much data to fit into given space.
713 The tree you gave contains takes just too much space to fit into
716 9 Advanced: Savestate/movie format
718 9.1 Special character classes
722 Following Unicode codepoints (encoded as UTF-8) are interpretted
725 • Codepoints 0x20, and 0x09.
727 • Codepoints 0x1680, 0x180E, 0x2028, 0x205F and 0x3000
729 • Codepoints 0x2000-0x200A.
733 Following byte sequences are interpretted as linefeeds (line
740 • Bytes 0x0D 0x0A (interpretted as single line change, not two!)
742 • Bytes 0xC2 0x85 (UTF-8 for unicode control character NL)
746 JRSR archive format packs multiple text archive members to text
747 archive. It does not support binary members. JRSR archives have
748 first five or six bytes form the magic. It is “JRSR” followed by
749 LINEFEED character There are four kinds of lines after that
750 (lines are terminated by LINEFEED byte/bytes):
760 Sequencing rules are as follows: Start member is allowed anywhere
761 (after magic). Member line is allowed only inside member (member
762 started but not ended). End member is only allowed inside member.
763 End of file is only allowed outside member. Blank line is allowed
764 anywhere after magic.
768 Start member line is given as “!BEGIN” <SPACE>+ <membername>
769 <LINEFEED>. <SPACE>+ any number of SPACE characters at least one
770 and <LINEFEED> is LINEFEED chacter. The member name is UTF-8
771 encoded and maximum allowed line length is 2048 bytes (including
772 LINEFEED, which means name is limited to 509-2040 codepoints
773 depending on characters used). Starting member inside another
774 implicitly ends the previous member.
778 Member line is given as “+”<content><LINEFEED>. It gives another
779 line for member contents. <content> is passed raw to layers above
780 (followed by line termination)
784 End member line is given as “!END”<LINEFEED>. It ends the current
785 member. The following line can only be start member line or file
790 Blank line is given as <LINEFEED>. Lines like that are ignored.
792 9.3 Four-to-Five encoding
794 Binary members are encoded into text by so-called four-to-five
795 encoding. This encoding can encode single byte to two, two bytes
796 to three, three bytes to four and four bytes to five.
797 Four-to-five encoding has five kinds of blocks. All SPACE and
798 LINEFEED characters are completely ignored, even in middle of
801 9.3.1 End stream block
803 End stream block is encoded as '!'. It ends the stream instantly.
804 There is also implicit end of stream at end of input to decoding.
806 9.3.2 Other four block types
808 Other four block types take the value to be encoded, read it as
809 big-endian value. Then they write it as base-93 big-endian value.
810 Then length specific constants are added to digits of that number
811 to yield ASCII values for characters (those are stored in order):
814 +------------+------------+------------+------------+------------+-----------+
815 | To encode | 1st char. | 2nd char. | 3rd char. | 4th char. | 5th char. |
816 +------------+------------+------------+------------+------------+-----------+
817 +------------+------------+------------+------------+------------+-----------+
818 | 1 byte | 34 | 34 | - | - | - |
819 +------------+------------+------------+------------+------------+-----------+
820 | 2 bytes | 37 | 34 | 34 | - | - |
821 +------------+------------+------------+------------+------------+-----------+
822 | 3 bytes | 45 | 34 | 34 | 34 | - |
823 +------------+------------+------------+------------+------------+-----------+
824 | 4 bytes | 66 | 34 | 34 | 34 | 34 |
825 +------------+------------+------------+------------+------------+-----------+
828 Blocks which encode values greater than what is possible for
829 value of that length are fatal errors.
831 9.4 Line component encoing
833 Line component encoding sits on top of UTF-8 encoding. Line
834 component encoding encodes non-empty 1-D array of non-empty
835 strings into line, and thus array of those into member. Empty
836 lines or lines that don't contain any components are ignored.
837 Line starts with depth value of 0 and must end with depth value
840 Components are seperated by component separators. Empty
841 components are ignored. Following codepoints are separators on
842 depth 0 if not escaped:
844 • Codepoint of '('. The depth is read pre-increment.
846 • Codepoint of ')'. The depth is read post-decrement.
848 • Any SPACE character
850 The following characters are special:
852 • '('. Increments depth by 1 if not escaped (and appears in
855 • ')'. Decrements depth by 1 if not escaped (and appears in
856 component). Depth going negative is an error.
858 • '\'. Next character is interpretted as literal. Error if at end
861 Otherwise, characters are interpretted as literals and appear in
862 components. Depth must be zero at end of line.
866 Header section is in archive member "header". It uses line
867 component encoding. The first component of each line is name of
868 header, and subsequent ones are arguments. How many parameters
869 are expected is dependent on what header it is:
871 9.5.1 PROJECTID header:
873 • Header name: "PROJECTID"
877 • Argument #1: <project-id-string>
881 Gives project ID. Project ID is generated when PC is assembled
882 and is then preserved in save states. It is used for computing
883 rerecord counts. Emulator treats it as opaque string, the IDs it
884 generates are formed by 48 random hexadecimal digits.
886 9.5.2 SAVESTATEID header:
888 • Header name: "SAVESTATEID"
892 • Argument #1: <savestate-id-string>
896 Gives save state ID. Each save state has its own save state ID.
897 Treated as opaque string, but generated as 48 random hexadecimal
898 digits. The presence of this header signals whether there is save
899 state to be loaded. If this header is present, save state load
900 will be attempted. If absent, save state is not to be loaded even
901 if present (and correct savestate load would be technically
904 The value is used to prevent loading incompatible save states in
905 preserve event stream mode and also to find the point in event
906 stream where one left off.
908 9.5.3 RERECORDS header:
910 • Header name: "RERECORDS"
914 • Argument #1: <rerecords>
918 Gives rerecord count. PC assembly (except when loading save
919 state) initializes current rerecord count to zero. Must be
920 non-negative and decimal number using ASCII digit characters.
922 On loading save state:
924 1) If project ID matches with previous:
926 1a) If loaded rerecord count is larger or equal to current
929 1a-a) Current rerecord count is loaded rerecord count + 1.
933 1b-a) Current rerecord count increments by 1.
937 2a) Current rerecord count is loaded rerecord count + 1.
939 The current rerecord count at time of save is saved to save
942 9.5.4 AUTHORS header:
944 • Header name: "AUTHORS"
946 • Components: 2 or more
948 • Arguments: free form
952 Gives authors of run. Each argument gives one author. May be
953 present multiple times.
955 9.5.5 COMMENT header:
957 • Header name: "COMMENT"
959 • Components: 2 or more
961 • Arguments: free form
965 Various kinds of free form data. Not parsed further by emulator.
967 9.6 Initialization segment:
969 If SAVESTATEID header isn't present (not a save state), member
970 "initialization" gives PC initialization parameters for
971 assembling the PC. It is present anyway even if SAVESTATEID is
974 Following parameters are used (space separates components):
978 Gives Image ID of main system BIOS (mandatory)
982 Gives Image ID of VGA BIOS (mandatory).
986 Gives Image ID of hda. Present only if system has hard disk hda.
990 Gives Image ID of hdb. Present only if system has hard disk hdb.
994 Gives Image ID of hdc. Present only if system has hard disk hdc.
998 Gives Image ID of hdd. Present only if system has hard disk hdd.
1002 Gives Image ID of disk in slot <num>. Slot number must be
1005 “DISKNAME” <num> <name>
1007 kGives image name of disk in slot <num>. Slot number must be
1008 non-negative. The slot must be previously declared using “DISK”.
1012 Gives Image slot to initially put into floppy drive fda. Disk
1013 must be of floppy type. If none present, no disk is initially put
1018 Gives Image slot to initially put into floppy drive fdb. Disk
1019 must be of floppy type. If none present, no disk is initially put
1024 Gives Image slot to initially put into CD-ROM drive hdc. Not
1025 allowed if hard disk hdc is present. Disk must be of CD-ROM type.
1026 If none present no disk is initially put there.
1028 "INITIALTIME" <time>
1030 Number of milliseconds since Unix epoch to system start up time.
1033 0-4102444799999. Mandatory.
1035 "CPUDIVIDER" <divider>
1037 Set CPU frequency divider (dividing the 1GHz master clock).
1038 Allowed range is 1-256. Mandatory.
1040 "MEMORYSIZE" <pages>
1042 Number of 4KiB pages of RAM memory. Allowed range 256-262144.
1047 Set boot device. Valid devices are "FLOPPY" (boot from fda),
1048 "HDD" (boot from hda) and "CDROM" (boot from CD).
1050 "LOADMODULEA" <module> <parameters>
1052 Load module <module> with parameters <parameters>.
1054 "LOADMODULE" <module>
1056 Load module <module> with no parameters
1060 Use class <fpu> as FPU emulator.
1062 9.7 Event record format:
1064 Event record is in archive member "events". It uses line
1065 component encoding. Each line gives an event. First component of
1066 each line gives time stamp. These timestamps MUST be in
1067 increasing order and all MUST be non-negative. Time stamp time
1068 unit is exactly 1 nanosecond of emulated time.
1070 The second component of each line is name of class to dispatch
1071 to. Further components are passed as-is to event handlers.
1073 9.7.1 Savestate event
1075 • Dispatch to: SAVESTATE
1077 • Argument #1: Savestate id
1079 • Argument #2 (optional): Rerecord count at time of saving
1082 Signals that savestate has occured here. The save state IDs MUST
1083 be unique in entire event stream. The second argument to
1084 savestate (if present) is rerecord count at time of saving that
1085 savestate (useful for calulating rerecord count of movie starting
1086 from savestate). No time restrictions
1090 • Dispatch to: OPTION
1092 • Argument #1: “ABSOLUTE” or “RELATIVE”
1094 Controls various options. “ABSOLUTE” turns on absolute mode
1095 (default) where event timestamps are absolute. “RELATIVE” turns
1096 on relative mode where event timestamps are relative to last
1097 event in stream. The OPTION event itself is not affected by
1098 timing change. No time restrictions
1100 9.7.3 Keyboard keypress/keyrelease event:
1102 • Dispatch to: org.jpc.emulator.peripheral.Keyboard
1104 • Argument #1: Fixed: "KEYEDGE"
1106 • Argument #2: Key number. Valid values are 1-83, 85-95, 129-197
1109 Send key press or key release. Keys work in toggle button manner.
1110 The event time must be multiple of 66 666, and must not be less
1111 than 60 * 66 666 TUs after last PAUSE event, 20 * 66 666 TUs
1112 after last KEYEDGE on key >128 and 10 * 66 666 TUs after last
1113 KEYEDGE on key <128.
1117 • Dispatch to: org.jpc.emulator.peripheral.Keyboard
1119 • Argument #1: Fixed: "PAUSE"
1121 Send pause key event. The time restrictions are identical to
1124 9.7.5 Joystick button event:
1126 • Dispatch to: org.jpc.modules.Joystick
1128 • Argument #1: “BUTTONA”, “BUTTONB”, “BUTTONC” or “BUTTOND”
1130 • Argument #2: “0” if released, “1” if pressed
1132 Send button down/up event. No time restrictions.
1134 9.7.6 Joystick axis event:
1136 • Dispatch to: org.jpc.modules.Joystick
1138 • Argument #1: “AXISA”, “AXISB”, “AXISC” or “AXISD”
1140 • Argument #2: Multivibrator unstable state length in ns.
1142 Set amount of time multivibrator remains in unstable state. No
1147 • Dispatch to: org.jpc.emulator.PC$ResetButton
1153 9.7.8 Fda disk change:
1155 • Dispatch to: org.jpc.emulator.PC$DiskChanger
1157 • Argument #1: Fixed: "FDA"
1159 • Argument #2: Number of image slot to put there.
1161 The disk number MUST be -1 or valid disk number. -1 MUST NOT be
1162 used if there is no disk in floppy drive A. This event causes
1163 specified disk to be placed to FDA or FDA disk to be ejected with
1164 no replacement if disk number is -1. The specified disk if not -1
1165 must be of floppy type. The specified disk if valid must not be
1168 9.7.9 Fdb disk change:
1170 • Dispatch to: org.jpc.emulator.PC$DiskChanger
1172 • Argument #1: Fixed: "FDB"
1174 • Argument #2: Number of image slot to put there.
1176 The disk number MUST be -1 or valid disk number. -1 MUST NOT be
1177 used if there is no disk in floppy drive B. This event causes
1178 specified disk to be placed to FDB or FDB disk to be ejected with
1179 no replacement if disk number is -1. The specified disk if not -1
1180 must be of floppy type. The specified disk if valid must not be
1183 9.7.10 Change CDROM:
1185 • Dispatch to: org.jpc.emulator.PC$DiskChanger
1187 • Argument #1: Fixed: "CDROM"
1189 • Argument #2: Number of image slot to put there.
1191 The disk number MUST be -1 or valid disk number. -1 MUST NOT be
1192 used if there is no disk in CD-ROM. This event causes specified
1193 disk to be placed to CD-ROM or CD-ROM disk to be ejected with no
1194 replacement if disk number is -1. The specified disk if not -1
1195 must be of CD-ROM type.
1197 This event has no effect if CD-ROM is locked.
1199 9.7.11 Write protect floppy:
1201 • Dispatch to: org.jpc.emulator.PC$DiskChanger
1203 • Argument #1: Fixed: "WRITEPROTECT"
1205 • Argument #2: Number of image slot to manipulate
1207 Write protects specified disk. The disk MUST NOT be in any drive
1208 and MUST be valid floppy-type disk.
1210 9.7.12 Write unprotect floppy:
1212 • Dispatch to: org.jpc.emulator.PC$DiskChanger
1214 • Argument #1: Fixed: "WRITEUNPROTECT"
1216 • Argument #2: Number of image slot to manipulate
1218 Disables write protection specified disk. The disk MUST NOT be in
1219 any drive and MUST be valid floppy-type disk.
1221 9.8 Diskinfo sections
1223 Diskinfo sections are named “diskinfo-”<id of disk>. They use
1224 line component encoding, fieldtype being first component on each
1225 line (value being the second). Following fields are defined:
1229 Gives type of image. Possible values are
1231 • “FLOPPY” (floppy disk)
1237 • “BIOS” (BIOS/VGABIOS image)
1239 • “UNKNOWN” (what the heck is this???)
1247 (BIOS images only) Gives length of BIOS image
1251 MD5 of raw disk/BIOS image without any headers or trailers.
1255 (FLOPPY/HDD/CDROM images only) Number of total sectors on disk.
1259 (FLOPPY/HDD images only) Number of tracks on disk per side (1-256
1260 for floppy, 1-1024 for HDD).
1264 (FLOPPY/HDD images only) Number of sides on disk (1 or 2 for
1265 floppy, 1-16 for HDD).
1269 (FLOPPY/HDD images only) Number of sectors per track (1-255 for
1270 floppy, 1-63 for HDD).
1274 Line from image comment block. Usually give data about files
1275 image has. May or may not be present.
1279 Actual savestate format is not documented here. It is close to
1280 impossible to comprehend without access to emulator source
1283 10 Advanced: Making class dumpable
1285 Class is made dumpable by implementing interface
1286 org.jpc.emulator.SRDumpable and implementing method
1287 dumpSRPartial(org.jpc.emulator.SRDumper) and constructor
1288 <init>(org.jpc.emulator.SRLoader). Non-static inner classes can
1289 not be dumpable (make them static using tricks similar to what
1292 If dumped class has dumpable superclass, the first thing dumping
1293 function needs to do is to call dumper function of superclass and
1294 first thing loading constructor needs to do is to call loading
1295 constructor of superclass. If class has no dumpable superclass,
1296 dumper doesn't need to do anything special, while loader needs to
1297 call objectCreated(this) on SRLoader object passed as parameter.
1299 Following these fixed parts, dump all members that are part of
1300 mutable state in emulator core.
1302 10.1 Member dumping/loading functions
1304 There is dumping/loading function for following (all functions
1305 dumping/loading reference types can handle null):
1307 • boolean: SRDumper.dumpBoolean, SRLoader.loadBoolean
1309 • byte: SRDumper.dumpByte, SRLoader.loadByte
1311 • short: SRDumper.dumpShort, SRLoader.loadShort
1313 • int: SRDumper.dumpInt, SRLoader.loadInt
1315 • long: SRDumper.dumpLong, SRLoader.loadLong
1317 • String: SRDumper.dumpString, SRLoader.loadString
1319 • boolean[]: SRDumper.dumpArray, SRLoader.loadArrayBoolean
1321 • byte[]: SRDumper.dumpArray, SRLoader.loadArrayByte
1323 • short[]: SRDumper.dumpArray, SRLoader.loadArrayShort
1325 • int[]: SRDumper.dumpArray, SRLoader.loadArrayInt
1327 • long[]: SRDumper.dumpArray, SRLoader.loadArrayLong
1329 • double[]: SRDumper.dumpArray, SRLoader.loadArrayDouble
1331 • <dumpable type>: SRDumper.dumpObject, SRLoader.loadObject
1333 • special object: SRDumper.specialObject, SRLoader.specialObject
1337 • Dumpable objects come out as type of
1338 org.jpc.emulator.SRDumpable.
1340 • Special objects are various static objects that don't need to
1341 be stored because they don't have mutable fields.
1343 • Don't dump fields related to event state feedback.
1345 • Don't dump temporary flags that are only used while PC is
1346 running. Savestate when PC is running isn't possible anyway.
1348 • Some connectors dump fields related to connector output, some
1351 11 Advanced: Making output connectors
1353 Implementing interface org.jpc.emulator.DisplayController signals
1354 that this is display controller, inhibiting loading of the
1355 standard VGA display controller if loaded as module.
1357 11.1 Interface org.jpc.emulator.OutputConnector
1359 Class is made to be output connector by implementing this
1360 interface. This interface specifies the methods used for output
1361 hold locking. Class org.jpc.emulator.OutputConnectorLocking has
1362 implementations of these that are suitable for calling.
1364 11.1.1 Method subscribeOutput(Object)
1366 Subscribes the output, with specified object as handle.
1368 11.1.2 Method unsubscribeOutput(Object)
1370 Unsubscribe the specified handle object from output.
1372 11.1.3 Method waitOutput(Object)
1374 Wait for output on specified connector using specified handle
1375 object. Returns true on success, false if wait was interrupted by
1376 thread interrupt. Blocking.
1378 11.1.4 Method releaseOutput(Object)
1380 Release connector from p.o.v. of given handle. Does not block.
1382 11.1.5 Method holdOutput()
1384 Release threads waiting on waitOutput() and block until all
1385 subscribers have returned from waitOutput() and enteired
1388 11.1.6 Method releaseOutputWaitAll(object)
1390 Like releaseOutput(), but waits until all handles have released
1393 11.2 Class org.jpc.emulator.VGADigtalOut
1395 Class org.jpc.emulator.VGADigtalOut (already implements
1396 OutputConnector) implements VGA output connector. If module
1397 provodes output connector, it needs to implement
1398 org.jpc.emulator.DisplayController.
1400 11.2.1 Method getWidth()
1402 Get width of display (watch out, can return 0).
1404 11.2.2 Method getHeight()
1406 Get height of display (watch out, can return 0).
1408 11.2.3 Methods getDirtyXMin(), getDirtyXMax(), getDirtyYMin(),
1411 Returns the dirty region (region modified since last output).
1413 11.2.4 Method getBuffer()
1415 Get buffer of ints, at least width * height elements
1416 (left-to-right, top-down, one value per pixel) giving pixel data.
1417 Value for each pixel is 65536 * <red-component> + 256 *
1418 <green-component> + <blue-component>.
1420 11.2.5 Method resizeDisplay(int _width, int _height)
1422 Resize the display to be of specified size.
1424 11.2.6 Method dirtyDisplayRegion(int x, int y, int w, int h)
1426 Mark the specified region as dirty.
1428 11.2.7 Method resetDirtyRegion()
1430 Resets the dirty region to be empty.
1432 11.3 Class org.jpc.emulator.PC method getVideoOutput()
1434 Get VGA output connector for PC.
1436 11.4 Interface org.jpc.emulator.DisplayController.
1438 Implementing this class signals that module is VGA controller.
1439 There can be only one such module active at time and presence of
1440 such module prevents loading builtin VGA controller emulation
1443 11.4.1 Method getOutputDevice()
1445 Get VGA output connector for this VGA device.
1447 11.5 Class org.jpc.emulator.SoundDigitalOut
1449 Class org.jpc.emulator.SoundDigitalOut provodes output connector
1450 for sound. Each connector can transfer stereo signal at arbitiary
1451 sampling rate. Modules that have audio connectors need to
1452 implement interface org.jpc.emulator.SoundOutputDevice, as this
1453 signals that output connectors should be created.
1455 11.5.1 Method addSample(long, short, short)
1457 Add stereo sample at time given by first argument. The second and
1458 third arguments give volume on left and right channels.
1460 11.5.2 Method addSample(long, short)
1462 Add mono sample at time given by first argument. The second
1463 argument give volume on both channels.
1465 11.5.3 Method readBlock(Block)
1467 Reads block of output (atomic versus addSample). Block structure
1468 has following fields which are filled:
1470 • timeBase: Time base for block.
1472 • baseLeft: Left volume at time base.
1474 • baseRight: Right volume at time base
1476 • blockNo: Sequence number of block filled.
1478 • samples: Number of samples in block
1480 • sampleTiming: Number of nanoseconds since last sample
1482 • sampleLeft: Left channel samples
1484 • sampleRight: Right channel samples
1486 11.6 Interface org.jpc.emulator.SoundOutputDevice
1488 Implementing this interface signals that module has audio output
1492 org.jpc.emulator.SoundOutputDevice.requestedSoundChannels()
1494 Return the number of sound channels module has.
1497 org.jpc.emulator.SoundOutputDevice.soundChannelCallback(SoundDigitalOut)
1499 This is called once per sound channel requested giving precreated
1502 11.7 Class org.jpc.emulator.PC method getSoundOut(String)
1504 Get sound output with specified name.
1506 12 Advanced: Writing event targets
1508 Whereas output connectors are the way output is dispatched, input
1509 is dispatched via event targets. Event targets need to implement
1510 interface org.jpc.emulator.EventDispatchTarget.
1512 Event targets also provode methods which then encode events and
1513 dispatch them forward (without doing anything else) to event
1514 recorder. Also, event targets may have methods for obtaining
1517 12.1 Interface org.jpc.emulator.EventDispatchTarget
1519 Interface that marks class capable of receiving events.
1521 12.1.1 Method setEventRecorder(EventRecorder)
1523 Set the event recorder input events are sent to.
1525 12.1.2 Method startEventCheck()
1527 Signals target to reset all state related to event checking and
1528 state feedback. This may be called at any time in order to
1529 reinitialialize event checking/feedback state.
1531 12.1.3 Method doEvent(long, String[], int) throws IOException
1533 Event dispatch handler. The first argument is event time, second
1534 is parameters and third is what to do with it. If target doesn't
1535 like the event, throw IOException. Following types (the integer
1536 parameter) are used:
1538 0 (EventRecorder.EVENT_TIMED): Time has been assigned for event.
1540 1 (EventRecorder.EVENT_STATE_EFFECT_FUTURE): Future event in
1541 event replay for reinitialization
1543 2 (EventRecorder.EVENT_STATE_EFFECT): Past event in event replay
1546 3 (EventRecorder.EVENT_EXECUTE): This event occurs now. Execute
1549 12.1.4 Method endEventCheock()
1551 End event reinitialization. Usually unused.
1553 12.1.5 Method getEventTimeLowBound(long, String[]) throws
1556 Return the time value that's the earliest possiblity for this
1557 event to occur. Returning any time in past (including -1) causes
1558 event to fire as soon as possible. The long parameter gives the
1559 current scheduled time for event.
1563 Modules are various extensions that run inside emulator core. As
1564 such, they affect sync. Modules must implement interface
1565 org.jpc.emulator.HardwareComponent (they are hardware components)
1566 and must be dumpable. Additionally, they need either constructor
1567 <init>() or <init>(String). The first is if no parameters are
1568 passed, the second is for case where parameters are passed.
1570 Aside of the constructors, modules need to obey the ordinary
1571 conventions for hardware components. No code outside modules
1572 needs to know that module exists.
1576 Plugins handle various UI tasks. They need to implement interface
1579 14.1 Interface org.jpc.pluginsbase.Plugin
1581 14.1.1 Method systemShutdown()
1583 Called when emulator shuts down. Either called in dedicated
1584 thread or in thread that called emulatorShutdown(). These
1585 handlers should do the bare minimum to get files on disk to
1586 consistent state. After these calls from all plugins have
1587 finished, emulator exits. Do not try to manipulate UI from these
1588 methods, as doing that easily leads into deadlock.
1590 14.1.2 Method reconnect(PC)
1592 Gives new PC to connect to. Null is passed if plugin should
1595 14.1.3 Method main()
1597 Called in dedicated thread after plugin is initialized.
1599 14.1.4 Method pcStopping()
1601 Called after PC has stopped.
1603 14.1.5 Method pcStarting()
1605 Called before PC starts.
1607 14.1.6 Method notifyArguments(String[])
1609 Pass arguments from command line.
1611 14.1.7 Constructor <init>(Plugins)
1613 This constructor is used to initialize plugins that don't take
1616 14.1.8 Constructor <init>(Plugins, String)
1618 This constructor is used to initialize plugins that take
1621 14.2 Class org.jpc.pluginsbase.Plugins
1623 This class provodes various methods for manipulating plugins.
1625 14.2.1 Method isShuttingDown()
1627 Returns true if Plugins.shutdownEmulator() has been called
1628 somehow, either via VM exit, CTRL+C or explicitly. Useful to skip
1629 cleanups involving GUI, as these are too deadlock-prone.
1631 14.2.2 Method shutdownEmulator()
1633 Shut down and exit the emulator. All plugin shutdown functions
1634 are called in this thread.
1636 14.2.3 Method reconnectPC(PC)
1638 Signal reconnectPC event to all plugins.
1640 14.2.4 Method pcStarted()
1642 Signal pcStarting() event to all plugins.
1644 14.2.5 Method pcStopped()
1646 Signal pcStopping() event to all plugins.
1648 14.3 Interface org.jpc.pluginsbase.ExternalCommandInterface
1650 Implementing interface
1651 org.jpc.pluginsbase.ExternalCommandInterface signals that plugin
1652 can receive commands via external commands interface.
1654 14.3.1 Method invokeCommand(String cmd, String[] args)
1656 Invoke specified command using specified arguments. Return true
1657 if event is to be shallowed, false to continue trying to pass it
1660 15 Lua kernel programming
1662 At startup, kernel gets its arguments in 'args' table and the
1663 script name to run in 'scriptname' string. It should enter the
1664 named script in protected mode.
1666 The Lua VM exports numerious callbacks to kernel. The kernel can
1667 then choose to omit, wrap or re-export these to Lua scripts.
1669 • Always grab any functions used into local variables so nobody
1672 • Don't use global variables in kernel (except for those passed).