Fix 880KiB standard floppy format
[jpcrr.git] / manual.lyx
blob9dd003e71d3cb939af2377ef5665e01a61a2fef0
1 #LyX 1.6.5 created this file. For more info see http://www.lyx.org/
2 \lyxformat 345
3 \begin_document
4 \begin_header
5 \textclass article
6 \use_default_options true
7 \language finnish
8 \inputencoding auto
9 \font_roman default
10 \font_sans default
11 \font_typewriter default
12 \font_default_family default
13 \font_sc false
14 \font_osf false
15 \font_sf_scale 100
16 \font_tt_scale 100
18 \graphics default
19 \paperfontsize default
20 \spacing single
21 \use_hyperref false
22 \papersize default
23 \use_geometry true
24 \use_amsmath 1
25 \use_esint 1
26 \cite_engine basic
27 \use_bibtopic false
28 \paperorientation portrait
29 \leftmargin 2cm
30 \topmargin 2cm
31 \rightmargin 1cm
32 \bottommargin 2cm
33 \headheight 1cm
34 \headsep 1cm
35 \footskip 1cm
36 \secnumdepth 3
37 \tocdepth 3
38 \paragraph_separation indent
39 \defskip medskip
40 \quotes_language english
41 \papercolumns 1
42 \papersides 1
43 \paperpagestyle default
44 \tracking_changes false
45 \output_changes false
46 \author "" 
47 \author "" 
48 \end_header
50 \begin_body
52 \begin_layout Title
53 JPC-RR: User's manual
54 \end_layout
56 \begin_layout Section
57 Licence
58 \end_layout
60 \begin_layout Standard
61 JPC-RR is licenced under GNU GPL v2.
62  See file 
63 \begin_inset Quotes eld
64 \end_inset
66 LICENSE
67 \begin_inset Quotes erd
68 \end_inset
71 \end_layout
73 \begin_layout Section
74 Getting started
75 \end_layout
77 \begin_layout Subsection
78 Prerequisites
79 \end_layout
81 \begin_layout Standard
82 To get started, you need BIOS image, VGABIOS image and DOS boot floppy and
83  JDK for Java 6 standard edition (later versions should they appear should
84  also work).
85  Note: JRE is not enough.
87 \end_layout
89 \begin_layout Standard
90 Note that to play back recorded movies, you need exact same version of BIOS
91  image, VGABIOS image and DOS boot floppy as was used when making the movie
92  (in addition to exact same versions of other needed media).
93 \end_layout
95 \begin_layout Standard
96 See compile.sh.
97  The stuff in streamtools is only needed for recording videos.
98 \end_layout
100 \begin_layout Subsection
101 Compiling
102 \end_layout
104 \begin_layout Standard
105 See compile.sh.
106  The streamtools stuff is only needed for dumping videos.
107 \end_layout
109 \begin_layout Subsection
110 Getting started
111 \end_layout
113 \begin_layout Standard
114 First you need to get and make some important images.
115  Obtain BIOS image, VGABIOS image and DOS boot floppy from somewhere and
116  do:
117 \end_layout
119 \begin_layout LyX-Code
120 mkdir library
121 \end_layout
123 \begin_layout LyX-Code
124 java ImageMaker --BIOS library/BIOS <bios image file>
125 \end_layout
127 \begin_layout LyX-Code
128 java ImageMaker --BIOS library/VGABIOS <vgabios image file>
129 \end_layout
131 \begin_layout LyX-Code
132 java ImageMaker --floppy1440 library/DOSfloppy <dos floppy name>
133 \end_layout
135 \begin_layout Standard
136 This makes loadable images out of what you obtained.
137  Most DOS boot floppies are 1440KiB in size (if yours isn't change that
138  floppy1440 part).
139  You also might want to make some game images:
140 \end_layout
142 \begin_layout LyX-Code
143 java ImageMaker --HDD=128,63,16 library/somegame <game installation directory>
144 \end_layout
146 \begin_layout Standard
147 This makes ~128MB HDD image out of installation directory.
148 \end_layout
150 \begin_layout Subsection
151 Running emulator
152 \end_layout
154 \begin_layout Standard
155 There is premade autoexec script called assemble.bat that has fairly reasonable
156  defaults.
157  To use it:
158 \end_layout
160 \begin_layout LyX-Code
161 java JPCApplication -library library -autoexec assemble.bat
162 \end_layout
164 \begin_layout Standard
165 The 
166 \begin_inset Quotes eld
167 \end_inset
169 -library library
170 \begin_inset Quotes erd
171 \end_inset
173  specifies that contents of directory 'library' are to be used as library.
174  The script pops up settings for new emulated PC (if you want to load savestate,
175  click cancel).
176  Select BIOS and VGABIOS for BIOS and VGABIOS image (they should be already
177  selected), DOSfloppy for fda (boot device should be set to fda) and game
178  image as some HD drive 
179 \end_layout
181 \begin_layout Subsection
182 Bootup tips
183 \end_layout
185 \begin_layout Itemize
186 Putting the game as hdd causes boot to be bit faster.
187 \end_layout
189 \begin_layout Itemize
190 Some BIOS versions have 
191 \begin_inset Quotes eld
192 \end_inset
194 press F12 to select boot device
195 \begin_inset Quotes erd
196 \end_inset
199  Hit <enter> from emulated keyboard and that prompt will go away in about
200  half emulated second (it stays several emulated seconds otherwise).
202 \end_layout
204 \begin_layout Itemize
205 If game doesn't need lots of memory, hitting F5 to skip intialization files
206  is fastest.
207  If it does need more memory, run config.sys commands but not autoexec.bat.
209 \end_layout
211 \begin_layout Itemize
212 Some DOS disks have DOSIDLE with them, don't use it as it messes badly with
213  emulator.
214 \end_layout
216 \begin_layout Section
217 Making JPC-RR format images from raw images
218 \end_layout
220 \begin_layout Standard
221 Due to various factors, JPC-RR can't use raw image files directly but requires
222  its own image format.
223  There is tool called ImageMaker that can make JPC-RR images from raw images.
224  Each image has format, ID an name.
225  Format and name are specified when making image.
226  ID is automatically calculated from format and contents.
227  Name does not affect the ID but is purely for convience so one doesn't
228  have to specify long image IDs manually.
229 \end_layout
231 \begin_layout Subsection
232 Syntax
233 \end_layout
235 \begin_layout Standard
236 The syntax for ImageMaker when making images is:
237 \end_layout
239 \begin_layout LyX-Code
240 $ java ImageMaker <format> [<options>...] <destination> <source> <name>
241 \end_layout
243 \begin_layout Standard
244 <destination> is file name for JPC-RR format image to write.
245  <source> is either name of regular file (raw image file) or name of directory
246  tree with files (supported for making floppy or hard disk images only).
247  In case of directory tree, the files are layout deterministically to disk,
248  so the ID will always be the same for given geometry and type.
249  <name> is name to give to disk.
250  <format> is one of:
251 \end_layout
253 \begin_layout LyX-Code
254 --BIOS BIOS image (note: VGABIOS is also of this type).
255 \end_layout
257 \begin_layout LyX-Code
258 --CDROM CD-ROM image.
259 \end_layout
261 \begin_layout LyX-Code
262 --HDD=cylinders,sectors,heads Hard disk with specified geometry.
263 \end_layout
265 \begin_layout LyX-Code
266 --floppy=tracks,sectors,sides Floppy disk with specified geometry.
267 \end_layout
269 \begin_layout LyX-Code
270 --floppy160 160KiB floppy (40 tracks, 8 sectors, Single sided).
271 \end_layout
273 \begin_layout LyX-Code
274 --floppy180 180KiB floppy (40 tracks, 9 sectors, Single sided).
275 \end_layout
277 \begin_layout LyX-Code
278 --floppy320 320KiB floppy (40 tracks, 8 sectors, Double sided).
279 \end_layout
281 \begin_layout LyX-Code
282 --floppy360 360KiB floppy (40 tracks, 9 sectors, Double sided).
283 \end_layout
285 \begin_layout LyX-Code
286 --floppy410 410KiB floppy (41 tracks, 10 sectors, Double sided).
287 \end_layout
289 \begin_layout LyX-Code
290 --floppy420 420KiB floppy (42 tracks, 10 sectors, Double sided).
291 \end_layout
293 \begin_layout LyX-Code
294 --floppy720 720KiB floppy (80 tracks, 9 sectors, Double sided).
295 \end_layout
297 \begin_layout LyX-Code
298 --floppy800 800KiB floppy (80 tracks, 10 sectors, Double sided).
299 \end_layout
301 \begin_layout LyX-Code
302 --floppy820 820KiB floppy (82 tracks, 10 sectors, Double sided).
303 \end_layout
305 \begin_layout LyX-Code
306 --floppy830 830KiB floppy (83 tracks, 10 sectors, Double sided).
307 \end_layout
309 \begin_layout LyX-Code
310 --floppy880 880KiB floppy (80 tracks, 11 sectors, Double sided).
311 \end_layout
313 \begin_layout LyX-Code
314 --floppy1040 1040KiB floppy (80 tracks, 13 sectors, Double sided).
315 \end_layout
317 \begin_layout LyX-Code
318 --floppy1120 1120KiB floppy (80 tracks, 14 sectors, Double sided).
319 \end_layout
321 \begin_layout LyX-Code
322 --floppy1200 1200KiB floppy (80 tracks, 15 sectors, Double sided).
323 \end_layout
325 \begin_layout LyX-Code
326 --floppy1440 1440KiB floppy (80 tracks, 18 sectors, Double sided).
327 \end_layout
329 \begin_layout LyX-Code
330 --floppy1476 1476KiB floppy (82 tracks, 18 sectors, Double sided).
331 \end_layout
333 \begin_layout LyX-Code
334 --floppy1494 1494KiB floppy (83 tracks, 18 sectors, Double sided).
335 \end_layout
337 \begin_layout LyX-Code
338 --floppy1600 1600KiB floppy (80 tracks, 20 sectors, Double sided).
339 \end_layout
341 \begin_layout LyX-Code
342 --floppy1680 1680KiB floppy (80 tracks, 21 sectors, Double sided).
343 \end_layout
345 \begin_layout LyX-Code
346 --floppy1722 1722KiB floppy (82 tracks, 21 sectors, Double sided).
347 \end_layout
349 \begin_layout LyX-Code
350 --floppy1743 1743KiB floppy (83 tracks, 21 sectors, Double sided).
351 \end_layout
353 \begin_layout LyX-Code
354 --floppy1760 1760KiB floppy (80 tracks, 22 sectors, Double sided).
355 \end_layout
357 \begin_layout LyX-Code
358 --floppy1840 1840KiB floppy (80 tracks, 23 sectors, Double sided).
359 \end_layout
361 \begin_layout LyX-Code
362 --floppy1920 1920KiB floppy (80 tracks, 24 sectors, Double sided).
363 \end_layout
365 \begin_layout LyX-Code
366 --floppy2880 2880KiB floppy (80 tracks, 36 sectors, Double sided).
367 \end_layout
369 \begin_layout LyX-Code
370 --floppy3120 3120KiB floppy (80 tracks, 39 sectors, Double sided).
371 \end_layout
373 \begin_layout LyX-Code
374 --floppy3200 3200KiB floppy (80 tracks, 40 sectors, Double sided).
375 \end_layout
377 \begin_layout LyX-Code
378 --floppy3520 3520KiB floppy (80 tracks, 44 sectors, Double sided).
379 \end_layout
381 \begin_layout LyX-Code
382 --floppy3840 3840KiB floppy (80 tracks, 48 sectors, Double sided).
383 \end_layout
385 \begin_layout Subsection
386 Notes
387 \end_layout
389 \begin_layout Itemize
390 If making image from directory, the names of the files must conform to FAT
391  naming restrictions (8+3 character names, no spaces, etc).
392  Avoid filenames with non-ASCII characters.
394 \end_layout
396 \begin_layout Itemize
397 The DOS limit of 112 or 224 files for floppies does not apply to images
398  created from directory trees.
399  The minimum limit value used is 512.
400  If even that isn't enough, the limit is automatically increased to fit
401  all the needed directory entries.
402 \end_layout
404 \begin_layout Itemize
405 Making boot disks from tree does NOT work.
406  Even if you got system boot files there, it still won't work.
407 \end_layout
409 \begin_layout Itemize
410 Only floppy disks and hard drives can be made from directory trees.
411  BIOS images and CDROM images require image file.
412 \end_layout
414 \begin_layout Itemize
415 Avoid floppies with custom geometry (floppy geometry does affect disk ID).
416  Disks with over 63 sectors per track don't work with DOS.
417  Wheither disks with over 127 tracks per side work with DOS is unknown.
418  Also avoid 1024-tracks per side HDDs.
419 \end_layout
421 \begin_layout Itemize
422 The geometry limits are: 2-1024 tracks per side for HDD, 1-256 tracks per
423  side for floppy.
424  1-63 sectors per track for HDD, 1-255 sectors per track for floppy.
425  1-16 sides for HDD, 1 or 2 sides for floppy.
426  This gives size limit of 65280KiB for floppy disks (but note the DOS limit!)
427  and 516096KiB for HDDs.
428 \end_layout
430 \begin_layout Itemize
431 There are multiple image file contents that represent the same image.
432  The one with smallest size is picked when creating image.
433 \end_layout
435 \begin_layout Itemize
436 Note: Although the IDs are 128 bits long, they are not MD5 hashes.
438 \end_layout
440 \begin_layout Subsection
441 Other options
442 \end_layout
444 \begin_layout LyX-Code
445 --volumelabel=label Give specified volume label (affects ID).
446  Only meaningful when making image out of directory tree.
447  Default is no volume label.
448 \end_layout
450 \begin_layout LyX-Code
451 --timestamp=YYYYMMDDHHMMSS Give specified timestamp for files (affects ID).
452  Only meaningful when making image out of directory tree.
453  The default timestamp is 19900101T000000Z.
454 \end_layout
456 \begin_layout Subsection
457 Image information
458 \end_layout
460 \begin_layout Standard
461 When invoked as:
462 \end_layout
464 \begin_layout LyX-Code
465 $ java ImageMaker <imagefile>
466 \end_layout
468 \begin_layout Standard
469 Variety of information about image is displayed (especially for floppies/HDDs).
470  Two important fields are calculated and claimed disk ID.
471  They should be the same.
472  If they are not, then the image file is corrupt (sadly, imagemaker has
473  bugs and bugs that cause it to write corrupt images have been seen).
474 \end_layout
476 \begin_layout Subsection
477 Advanced: The disk ID algorithm
478 \end_layout
480 \begin_layout Standard
481 The disk ID is calculated as:
482 \end_layout
484 \begin_layout LyX-Code
485 Skein-256-128-deprecated(<typecode>|<geometry>|<image>)
486 \end_layout
488 \begin_layout Standard
489 Where Skein-256-128-deprecated is Skein hash function with 256-bit internal
490  state and 128-bit output using the deprecated rotation constants (as specified
491  in Skein hash function reference documentation versions 1.0 and 1.1).
492  The <image> is the whole image, including parts not stored in image file.
493  The reason for keeping using the deprecated constants are:
494 \end_layout
496 \begin_layout Itemize
497 Changing the constants would change the IDs, which would invalidate existing
498  images
499 \end_layout
501 \begin_layout Itemize
502 This is not about cryptographic security
503 \end_layout
505 \begin_layout Itemize
506 The new constants don't improve security that much anyway.
507 \end_layout
509 \begin_layout Subsubsection
510 Floppies and HDDs
511 \end_layout
513 \begin_layout Standard
514 Floppies have <typecode> value 0 (single byte) and HDDs have 1 (single byte).
515  <geometry> is as follows (this is exactly the same form as it appears in
516  image header):
517 \end_layout
519 \begin_layout LyX-Code
520 Byte 0 bits 0-1: Bits 8-9 of track count per side - 1.
521 \end_layout
523 \begin_layout LyX-Code
524 Byte 0 bits 2-5: Head count - 1.
525 \end_layout
527 \begin_layout LyX-Code
528 Byte 0 bits 6-7: Reserved, must be 0.
529 \end_layout
531 \begin_layout LyX-Code
532 Byte 1: Bits 0-7 of track count per side - 1.
533 \end_layout
535 \begin_layout LyX-Code
536 Byte 2: Sector count per track - 1.
537 \end_layout
539 \begin_layout Subsubsection
540 CD-ROM and BIOS images
541 \end_layout
543 \begin_layout Standard
544 CD-ROMs have <typecode> value 2 (single byte) and BIOS images have 3 (single
545  byte).
546  <geometry> is blank.
547 \end_layout
549 \begin_layout Subsection
550 Advanced: Disk Image format
551 \end_layout
553 \begin_layout Standard
554 The disk image consists of following parts:
555 \end_layout
557 \begin_layout Itemize
558 Magic
559 \end_layout
561 \begin_layout Itemize
562 Disk ID
563 \end_layout
565 \begin_layout Itemize
566 Type code
567 \end_layout
569 \begin_layout Itemize
570 Disk name length
571 \end_layout
573 \begin_layout Itemize
574 Disk name
575 \end_layout
577 \begin_layout Itemize
578 type-specific geometry/size data
579 \end_layout
581 \begin_layout Itemize
582 Actual image data
583 \end_layout
585 \begin_layout Subsubsection
586 Magic
587 \end_layout
589 \begin_layout Standard
590 Magic in disk image files is following 5 bytes: 
591 \begin_inset Quotes eld
592 \end_inset
594 IMAGE
595 \begin_inset Quotes erd
596 \end_inset
599 \end_layout
601 \begin_layout Subsubsection
602 Disk ID
603 \end_layout
605 \begin_layout Standard
606 Disk ID is given as 16 bytes, encoding the 128-bit disk ID.
607 \end_layout
609 \begin_layout Subsubsection
610 Type code
611 \end_layout
613 \begin_layout Standard
614 Type code is single byte.
615  0 for floppies, 1 for HDDs, 2 for CD-ROMs and 3 for BIOS images.
616  Other values are reserved.
617 \end_layout
619 \begin_layout Subsubsection
620 Comment length
621 \end_layout
623 \begin_layout Standard
624 Disk comment length is given as two-byte big-endian value.
625  New images should have 0 here.
626 \end_layout
628 \begin_layout Subsubsection
629 Disk coment
630 \end_layout
632 \begin_layout Standard
633 Ignored.
634  Comment field is there for backward compatiblity.
635  Comment length gives length of this field in bytes.
636 \end_layout
638 \begin_layout Subsubsection
639 Type-specific geometry/size data (floppies and HDDs)
640 \end_layout
642 \begin_layout Standard
643 Floppies and HDDs have 3-byte geometry data:
644 \end_layout
646 \begin_layout LyX-Code
647 Byte 0 bits 0-1: Bits 8-9 of track count per side - 1.
648 \end_layout
650 \begin_layout LyX-Code
651 Byte 0 bits 2-5: Head count - 1.
652 \end_layout
654 \begin_layout LyX-Code
655 Byte 0 bits 6-7: Reserved, must be 0.
656 \end_layout
658 \begin_layout LyX-Code
659 Byte 1: Bits 0-7 of track count per side - 1.
660 \end_layout
662 \begin_layout LyX-Code
663 Byte 2: Sector count per track - 1.
664 \end_layout
666 \begin_layout Subsubsection
667 Type specific-geometry/size data (CD-ROMs)
668 \end_layout
670 \begin_layout Standard
671 CD-ROMs have 4-byte big-endian sector (512 bytes!) count.
672 \end_layout
674 \begin_layout Subsubsection
675 Type specific-geometry/size data (BIOS images)
676 \end_layout
678 \begin_layout Standard
679 BIOS images have 4-byte big-endian byte (not sector or block) count.
680 \end_layout
682 \begin_layout Subsubsection
683 Actual image data (floppy/HDD)
684 \end_layout
686 \begin_layout Standard
687 Floppy or HDD imagedata consists of following subparts:
688 \end_layout
690 \begin_layout Itemize
691 Storage method
692 \end_layout
694 \begin_layout Itemize
695 Sectors present
696 \end_layout
698 \begin_layout Itemize
699 Image data header
700 \end_layout
702 \begin_layout Itemize
703 Image data
704 \end_layout
706 \begin_layout Standard
707 Storage method is single byte.
708  Sectors present gives number of last nonzero sector + 1 (zero if image
709  is all zeroes)
710 \end_layout
712 \begin_layout Subsubsection
713 Floppy/HDD storage method 0: Raw storage
714 \end_layout
716 \begin_layout Standard
717 This storage method has empty header.
718  Image data is raw dump of first sectors present sectors.
719 \end_layout
721 \begin_layout Subsubsection
722 Floppy/HDD storage method 1: Sectormap
723 \end_layout
725 \begin_layout Standard
726 Image data header contains bitfield with just enough bytes to have one bit
727  per present sector.
728  The order of bits is such that number of bit corresponding to each sector
729  in byte is sector number modulo 8 and byte number is floor of sector number
730  divided by 8 when sector numbers are counted from zero.
731  If bit corresponding to sector is set, then the sector is present in image
732  data, otherwise it is absent and assumed to be all-zeroes.
733 \end_layout
735 \begin_layout Standard
736 Image data contains dumps of all present sectors in order of increasing
737  sector number.
738 \end_layout
740 \begin_layout Subsubsection
741 Floppy/HDD storage method 2: Extent first sector zero
742 \end_layout
744 \begin_layout Standard
745 Image data is empty as storage-specific data is mangled with image data.
746  The image data alternates between blocks encoding zero sectors and blocks
747  encoding nonzero sectors.
748  The first block encodes zero sectors.
750 \end_layout
752 \begin_layout Standard
753 Block encoding zero sectors consist of single 1-4 byte little-endian value
754  encoding number of sectors in block - 1.
755  Number of bytes is determined by sectors present value.
756  It is 1 for 1-256 sectors, 2 for 257-65536, 3 for 65537-16777216 and 4
757  for more than 16777216.
758  All sectors in block are filled with zeroes and are not stored.
759 \end_layout
761 \begin_layout Standard
762 Block encoding nonzero sectors has same block count as zero sector block
763  but is followed by the sectors stored raw.
764 \end_layout
766 \begin_layout Subsubsection
767 Floppy/HDD storage method 3: Extent first sector nonzero
768 \end_layout
770 \begin_layout Standard
771 Same as storage method 2 but first block is nonzero sector block.
772 \end_layout
774 \begin_layout Subsubsection
775 Actual image data (CD-ROMs and BIOS images)
776 \end_layout
778 \begin_layout Standard
779 These store image data raw.
780  The amount of data is specified by sector/byte count.
781 \end_layout
783 \begin_layout Section
784 Utilities
785 \end_layout
787 \begin_layout Subsection
788 org.jpc.utils.RAWToPNG
789 \end_layout
791 \begin_layout Standard
792 Invoked as:
793 \end_layout
795 \begin_layout LyX-Code
796 $ java org.jpc.utils.RAWToPNG <input> <outputprefix>
797 \end_layout
799 \begin_layout Standard
800 Reads RAW video data from <input> (may be named pipe) and dumps PNG frames
801  received as '<outputprefix><runningcount>.png'.
802  Also saves '<outputprefix>.timing' which contains frame timing data (each
803  line consists of time in nanoseconds, space, and filename).
804 \end_layout
806 \begin_layout Section
807 The actual emulator
808 \end_layout
810 \begin_layout Standard
811 The actual emulator is invoked as:
812 \end_layout
814 \begin_layout LyX-Code
815 $ java JPCApplication <options>...
816 \end_layout
818 \begin_layout Standard
819 The valid options are:
820 \end_layout
822 \begin_layout LyX-Code
823 -library <library> Use the specified directory when searching for images
824  (can only be specified once).
825 \end_layout
827 \begin_layout LyX-Code
828 -autoexec <script> Execute contents of specified file as commands when starting
829  up.
830 \end_layout
832 \begin_layout Subsection
833 Command line
834 \end_layout
836 \begin_layout Standard
837 When emulator is started, command line comes up.
838  Following commands are known:
839 \end_layout
841 \begin_layout Itemize
842 'exit': exit immediately
843 \end_layout
845 \begin_layout Itemize
846 'load <plugin>': Load plugin (no arguments)
847 \end_layout
849 \begin_layout Itemize
850 'load <plugin>(<arguments>)': load plugin with arguments.
851 \end_layout
853 \begin_layout Itemize
854 'command <command> [<arguments>...]': Invoke command via external command interface.
855 \end_layout
857 \begin_layout Standard
858 When one gets command line, its useful to load some plugins.
859  See section about plugins.
860  Note: Load runner plugin (PCControl/PCRunner and so) last, as some runners
861  like to start PC immediately.
862 \end_layout
864 \begin_layout Subsection
865 PC settings dialog notes
866 \end_layout
868 \begin_layout Itemize
869 CPU divider base frequency before division is 1GHz.
870 \end_layout
872 \begin_layout Itemize
873 Images can be specified by name or by ID.
874  Name is relative to library directory.
875  If the image is in subdirectory of image directory, the directory separator
876  is is '/' regardless of what the host OS uses.
877 \end_layout
879 \begin_layout Itemize
880 CD-ROM and hdc are mutually exclusive
881 \end_layout
883 \begin_layout Itemize
884 Modules is comma-seperated list of modules to load.
885  To pass arguments to some modules, enclose the arguments in ().
886  Same module can be specified twice only if parameters differ.
887 \end_layout
889 \begin_layout Itemize
890 FPU emulator is specified by class name.
891  If core has built-in FPU emulator, then this should be left blank.
892  Without core-builtin FPU emulator, blank value means 
893 \begin_inset Quotes eld
894 \end_inset
896 no fpu
897 \begin_inset Quotes erd
898 \end_inset
901 \end_layout
903 \begin_layout Itemize
904 Setting boot device doesn't work with some BIOS versions.
905  Those versions prompt the boot device anyway.
906 \end_layout
908 \begin_layout Subsection
909 Audio output channels
910 \end_layout
912 \begin_layout Standard
913 PC can have one or more audio output channels.
914  The name of audio output associated with PC speaker is: 'org.jpc.emulator.peripher
915 al.PCSpeaker-0'.
916  Modules that have audio outputs get channel names of form <classname>-<sequenti
917 al>, where <classname> is name of main module class and sequential is number
918  starting from zero.
919  Note that same module can have multiple output channels.
920  If multiple modules of same class request audio outputs, the <sequential>
921  values of subsequent module start where previous left off.
922 \end_layout
924 \begin_layout Subsection
925 Plugins
926 \end_layout
928 \begin_layout Standard
929 Plugins actually execute the tasks of the emulator.
930  They can be loaded using 
931 \begin_inset Quotes eld
932 \end_inset
934 load <plugin>
935 \begin_inset Quotes erd
936 \end_inset
938  or 'load <plugin>(<arguments>)
939 \begin_inset Quotes erd
940 \end_inset
942  from command line.
943 \end_layout
945 \begin_layout Standard
946 Different Plugins using the same output (like running PCMonitor and PNGDumper)
947  should not conflict because connector output hold locking is desinged to
948  handle multiple readers.
949 \end_layout
951 \begin_layout Standard
952 If no plugin used requires GUI, then the emulator can be run without having
953  GUI available.
954 \end_layout
956 \begin_layout Subsubsection
957 plugin: org.jpc.plugins.PCControl
958 \end_layout
960 \begin_layout Standard
961 No arguments, requires and uses GUI.
962 \end_layout
964 \begin_layout Standard
965 Runs the PC emulator core.
966  Has capability to start/stop emulation, breakpoint after certain time or
967  start/end of VGA vertical retrace.
968  Also can create, savestate and loadstate PC emulation.
969  Memory dumping is supported.
971 \end_layout
973 \begin_layout Subsubsection
974 plugin: org.jpc.plugins.PCRunner
975 \end_layout
977 \begin_layout Standard
978 Takes 'movie=<file>' as argument and optionally 'stoptime=<time>' Does not
979  require nor use GUI.
980 \end_layout
982 \begin_layout Standard
983 Loads PC from savestate and just runs it.
984  CTRL+C to quit.
985  Also automatically quits once stoptime is reached.
986 \end_layout
988 \begin_layout Subsubsection
989 plugin: org.jpc.plugins.PCMonitor
990 \end_layout
992 \begin_layout Standard
993 No arguments, requires and uses GUI.
994 \end_layout
996 \begin_layout Standard
997 VGA monitor for emulated PC.
998 \end_layout
1000 \begin_layout Subsubsection
1001 plugin: org.jpc.plugins.VirtualKeyboard
1002 \end_layout
1004 \begin_layout Standard
1005 No arguments, requires and uses GUI.
1006 \end_layout
1008 \begin_layout Standard
1009 On-screen keyboard for emulated PC.
1010 \end_layout
1012 \begin_layout Subsubsection
1013 plugin: org.jpc.plugins.PCStartStopTest
1014 \end_layout
1016 \begin_layout Standard
1017 No arguments, requires and uses GUI.
1018 \end_layout
1020 \begin_layout Standard
1021 Small plugin testing remote PC start/stop.
1022  Also supports sending some common keypresses.
1023 \end_layout
1025 \begin_layout Subsubsection
1026 plugin: org.jpc.plugins.RAWVideoDumper
1027 \end_layout
1029 \begin_layout Standard
1030 Takes 'rawoutput=<file>' as argument.
1031  Does not require nor use GUI.
1032 \end_layout
1034 \begin_layout Standard
1035 Dumps all generated frames to RAW file <file>.
1036  Rawoutput is required.
1037  The raw file consists of concatenation of zlib streams.
1038  The uncompressed stream is concatenation of time skips (FFh FFh FFh FFh),
1039  each acting as time offset of 2^32-1 nanoseconds and saved frames.
1040  The saved frame has time offset in nanoseconds (big endian) as first four
1041  bytes (must be at most 2^32-2, as 2^32-1 is reserved for time skip).
1042  The next two bytes are big-endian width, next two big-endian height.
1043  Finally frame has 4 * width * height bytes of data that encodes pixels
1044  using 4 bytes per pixel, in left-to-right, up-to-down order.
1045  Byte 0 of each pixel is reserved, byte 1 is the red channel, byte 2 is
1046  green channel and byte 3 is blue channel.
1047 \end_layout
1049 \begin_layout Standard
1050 Dumping to pipe is supported.
1051 \end_layout
1053 \begin_layout Subsubsection
1054 plugin: org.jpc.plugins.RAWAudioDumper
1055 \end_layout
1057 \begin_layout Standard
1058 Takes 'src=<name of audio output channel>', 'file=<output-filename>' and
1059  'offset=<offset>' as arguments, separated by ','.
1060  Does not require nor use GUI.
1061 \end_layout
1063 \begin_layout Standard
1064 Dumps output from specified audio output channel (src, mandatory) to RAW-format
1065  file (file, mandatory).
1066  The resulting file consists of records, 4 or 8 bytes each.
1067  4 byte record consists of 0xFF 0xFF 0xFF 0xFF and means to increase next
1068  time delta by 
1069 \begin_inset Formula $2^{32}-1$
1070 \end_inset
1073  Otherwise record is 8 bytes.
1074  Each 8 byte record has three fields.
1075  First 4 byte unsinged big endian timedelta value (in nanoseconds, must
1076  be smaller than 
1077 \begin_inset Formula $2^{32}-1$
1078 \end_inset
1080 ), then 2 byte signed big endian new left channel volume, then 2 byte signed
1081  big endian new right channel volume.
1082  Optionally 'offset' can be set to positive value (in nanoseconds) to delay
1083  the audio by.
1084 \end_layout
1086 \begin_layout Subsubsection
1087 plugin: org.jpc.plugins.LuaPlugin
1088 \end_layout
1090 \begin_layout Standard
1091 Takes 'kernel=<name of lua kernel file>', other parameters are passed to
1092  kernel, requires and uses GUI.
1093 \end_layout
1095 \begin_layout Standard
1096 Lua VM for executing scripts.
1097 \end_layout
1099 \begin_layout Section
1100 Modules
1101 \end_layout
1103 \begin_layout Subsection
1104 org.jpc.modules.Joystick:
1105 \end_layout
1107 \begin_layout Itemize
1108 Arguments: none.
1109 \end_layout
1111 \begin_layout Itemize
1112 Resources: I/O port 0x201
1113 \end_layout
1115 \begin_layout Standard
1116 Emulates joystick game port.
1117 \end_layout
1119 \begin_layout Subsection
1120 org.jpc.modules.BasicFPU:
1121 \end_layout
1123 \begin_layout Itemize
1124 Arguments: none.
1125 \end_layout
1127 \begin_layout Itemize
1128 Resources: None.
1129 \end_layout
1131 \begin_layout Standard
1132 Crude FPU (x87) emulator.
1133 \end_layout
1135 \begin_layout Section
1136 Hacks
1137 \end_layout
1139 \begin_layout Standard
1140 Hacks are saved to savestates but not movies.
1141 \end_layout
1143 \begin_layout Subsection
1144 NO_FPU
1145 \end_layout
1147 \begin_layout Standard
1148 Force bit 1 of physical address 0x0410 to zero, signaling that the system
1149  has no FPU.
1150  BIOS assumes system has FPU but some games use that bit to detect FPU,
1151  trying to use it if it is 
1152 \begin_inset Quotes eld
1153 \end_inset
1155 present
1156 \begin_inset Quotes erd
1157 \end_inset
1160  Try this if game startup hangs with lots of trying to use FPU but not present
1161  errors.
1162  Don't use if there is FPU present.
1163  Needed to get games like Blake Stone to work (FPU emulator allows it to
1164  start but causes graphical glitches).
1165 \end_layout
1167 \begin_layout Subsection
1168 VGA_DRAW
1169 \end_layout
1171 \begin_layout Standard
1172 Update basic VGA parameters before vretrace, not after it.
1173  Some games (e.g.
1174  Commander Keen 4) don't like if this isn't done and some games (e.g.
1175  Mario & Luigi) don't like if it is done.
1176  Wrong value manifests as jerky scrolling (scrolling back and forth and
1177  fixed statusbars move).
1178 \end_layout
1180 \begin_layout Section
1181 Some error messages and explanations
1182 \end_layout
1184 \begin_layout Itemize
1185 <filename> is Not a valid image file
1186 \end_layout
1188 \begin_layout Itemize
1189 <filename> is not image file
1190 \end_layout
1192 \begin_layout Itemize
1193 <filename> claims to be floppy with illegal geometry: <x> tracks, <y> sides
1194  and <z> sectors.
1195 \end_layout
1197 \begin_layout Itemize
1198 <filename> claims to be HDD with illegal geometry: <x> tracks, <y> sides
1199  and <z> sectors.
1200 \end_layout
1202 \begin_layout Itemize
1203 Can't read disk image sector map.
1204 \end_layout
1206 \begin_layout Itemize
1207 Can't read disk image extent.
1208 \end_layout
1210 \begin_layout Standard
1211 Code expects <filename> to be valid JPC-RR format image, but it isn't JPC-RR
1212  image at all or its corrupt.
1213 \end_layout
1215 \begin_layout Itemize
1216 <filename> is image of unknown type.
1217 \end_layout
1219 \begin_layout Itemize
1220 <filename> has unrecognized geometry <x> <y> <z>
1221 \end_layout
1223 \begin_layout Standard
1224 Possibly corrupt image, not JPC-RR image, or JPC-RR image from future version
1225  containing something current version can't comprehend.
1226 \end_layout
1228 \begin_layout Itemize
1229 Invalid format specifier <something>.
1230 \end_layout
1232 \begin_layout Itemize
1233 Invalid syntax of --floppy= or --HDD= option.
1234 \end_layout
1236 \begin_layout Itemize
1237 Invalid format specifier/option <something>.
1238 \end_layout
1240 \begin_layout Standard
1241 Invalid option or format specifier was given.
1242  Check for typos.
1243 \end_layout
1245 \begin_layout Itemize
1246 java ImageMaker [<options>...] <format> <destination> <source> <diskname>
1247 \end_layout
1249 \begin_layout Standard
1250 Check syntax of command.
1251  Especially that diskname is present!
1252 \end_layout
1254 \begin_layout Itemize
1255 The image has <nnn> sectors while it should have <yyy> according to selected
1256  geometry.
1257 \end_layout
1259 \begin_layout Itemize
1260 Raw image file length not divisible by 512.
1261 \end_layout
1263 \begin_layout Itemize
1264 Trying to read sector out of range.
1265 \end_layout
1267 \begin_layout Standard
1268 The selected geometry is wrong or raw image is incomplete.
1269 \end_layout
1271 \begin_layout Itemize
1272 Invalid disk name (Should not happen!).
1273 \end_layout
1275 \begin_layout Itemize
1276 Invalid geometry to be written.
1277 \end_layout
1279 \begin_layout Standard
1280 This is a very likely a bug in program.
1281 \end_layout
1283 \begin_layout Itemize
1284 What the heck <filename> is? It's not regular file nor directory.
1285 \end_layout
1287 \begin_layout Standard
1288 That sort of file can't be used as input for image making, or the file just
1289  doesn't exist.
1290 \end_layout
1292 \begin_layout Itemize
1293 BIOS images can only be made out of regular files.
1294 \end_layout
1296 \begin_layout Itemize
1297 CD images can only be made out of regular files.
1298 \end_layout
1300 \begin_layout Standard
1301 Source image specified is not regular file, but image of that type can't
1302  be made of anything else.
1303 \end_layout
1305 \begin_layout Itemize
1306 Can't read raw bios image file.
1307 \end_layout
1309 \begin_layout Itemize
1310 Can't read sector <nnn> from image.
1311 \end_layout
1313 \begin_layout Standard
1314 Reading the raw image file failed for some reason.
1315 \end_layout
1317 \begin_layout Itemize
1318 Bad library line: "<something>".
1319  Ignored.
1320 \end_layout
1322 \begin_layout Standard
1323 Syntax error in image library.
1324 \end_layout
1326 \begin_layout Itemize
1327 Removing image <something> a.k.a.
1328  "<something>" as it no longer exists.
1329 \end_layout
1331 \begin_layout Standard
1332 The image file no longer exists so it gets removed from library.
1333 \end_layout
1335 \begin_layout Itemize
1336 Removing image <something> a.k.a.
1337  "<something>" due to <some> conflict.
1338 \end_layout
1340 \begin_layout Standard
1341 Image library code killed some image from library due to some kind of conflict
1342  with image being added.
1343 \end_layout
1345 \begin_layout Itemize
1346 Too much data to fit into given space.
1347 \end_layout
1349 \begin_layout Standard
1350 The tree you gave contains takes just too much space to fit into disk of
1351  this size.
1352 \end_layout
1354 \begin_layout Section
1355 Advanced: Savestate/movie format
1356 \end_layout
1358 \begin_layout Subsection
1359 Special character classes
1360 \end_layout
1362 \begin_layout Subsubsection
1363 SPACE
1364 \end_layout
1366 \begin_layout Standard
1367 Following Unicode codepoints (encoded as UTF-8) are interpretted as space
1368  characters:
1369 \end_layout
1371 \begin_layout Itemize
1372 Codepoints 0x20, and 0x09.
1373 \end_layout
1375 \begin_layout Itemize
1376 Codepoints 0x1680, 0x180E, 0x2028, 0x205F and 0x3000
1377 \end_layout
1379 \begin_layout Itemize
1380 Codepoints 0x2000-0x200A.
1381 \end_layout
1383 \begin_layout Subsubsection
1384 LINEFEED
1385 \end_layout
1387 \begin_layout Standard
1388 Following byte sequences are interpretted as linefeeds (line change):
1389 \end_layout
1391 \begin_layout Itemize
1392 Byte 0x0A
1393 \end_layout
1395 \begin_layout Itemize
1396 Byte 0x0D
1397 \end_layout
1399 \begin_layout Itemize
1400 Bytes 0x0D 0x0A (interpretted as single line change, not two!)
1401 \end_layout
1403 \begin_layout Itemize
1404 Bytes 0xC2 0x85 (UTF-8 for unicode control character NL)
1405 \end_layout
1407 \begin_layout Subsection
1408 JRSR archive
1409 \end_layout
1411 \begin_layout Standard
1412 JRSR archive format packs multiple text archive members to text archive.
1413  It does not support binary members.
1414  JRSR archives have first five or six bytes form the magic.
1415  It is 
1416 \begin_inset Quotes eld
1417 \end_inset
1419 JRSR
1420 \begin_inset Quotes erd
1421 \end_inset
1423  followed by LINEFEED character There are four kinds of lines after that
1424  (lines are terminated by LINEFEED byte/bytes):
1425 \end_layout
1427 \begin_layout Itemize
1428 Start member
1429 \end_layout
1431 \begin_layout Itemize
1432 Member line
1433 \end_layout
1435 \begin_layout Itemize
1436 End member
1437 \end_layout
1439 \begin_layout Itemize
1440 Blank line
1441 \end_layout
1443 \begin_layout Standard
1444 Sequencing rules are as follows: Start member is allowed anywhere (after
1445  magic).
1446  Member line is allowed only inside member (member started but not ended).
1447  End member is only allowed inside member.
1448  End of file is only allowed outside member.
1449  Blank line is allowed anywhere after magic.
1450 \end_layout
1452 \begin_layout Subsubsection
1453 Start member
1454 \end_layout
1456 \begin_layout Standard
1457 Start member line is given as 
1458 \begin_inset Quotes eld
1459 \end_inset
1461 !BEGIN
1462 \begin_inset Quotes erd
1463 \end_inset
1465  <SPACE>+ <membername> <LINEFEED>.
1466  <SPACE>+ any number of SPACE characters at least one and <LINEFEED> is
1467  LINEFEED chacter.
1468  The member name is UTF-8 encoded and maximum allowed line length is 2048
1469  bytes (including LINEFEED, which means name is limited to 509-2040 codepoints
1470  depending on characters used).
1471  Starting member inside another implicitly ends the previous member.
1472 \end_layout
1474 \begin_layout Subsubsection
1475 Member line:
1476 \end_layout
1478 \begin_layout Standard
1479 Member line is given as 
1480 \begin_inset Quotes eld
1481 \end_inset
1484 \begin_inset Quotes erd
1485 \end_inset
1487 <content><LINEFEED>.
1488  It gives another line for member contents.
1489  <content> is passed raw to layers above (followed by line termination)
1490 \end_layout
1492 \begin_layout Subsubsection
1493 End member
1494 \end_layout
1496 \begin_layout Standard
1497 End member line is given as 
1498 \begin_inset Quotes eld
1499 \end_inset
1501 !END
1502 \begin_inset Quotes erd
1503 \end_inset
1505 <LINEFEED>.
1506  It ends the current member.
1507  The following line can only be start member line or file may end.
1508 \end_layout
1510 \begin_layout Subsubsection
1511 Blank line
1512 \end_layout
1514 \begin_layout Standard
1515 Blank line is given as <LINEFEED>.
1516  Lines like that are ignored.
1517 \end_layout
1519 \begin_layout Subsection
1520 Four-to-Five encoding
1521 \end_layout
1523 \begin_layout Standard
1524 Binary members are encoded into text by so-called four-to-five encoding.
1525  This encoding can encode single byte to two, two bytes to three, three
1526  bytes to four and four bytes to five.
1527  Four-to-five encoding has five kinds of blocks.
1528  All SPACE and LINEFEED characters are completely ignored, even in middle
1529  of blocks.
1530 \end_layout
1532 \begin_layout Subsubsection
1533 End stream block
1534 \end_layout
1536 \begin_layout Standard
1537 End stream block is encoded as '!'.
1538  It ends the stream instantly.
1539  There is also implicit end of stream at end of input to decoding.
1540 \end_layout
1542 \begin_layout Subsubsection
1543 Other four block types
1544 \end_layout
1546 \begin_layout Standard
1547 Other four block types take the value to be encoded, read it as big-endian
1548  value.
1549  Then they write it as base-93 big-endian value.
1550  Then length specific constants are added to digits of that number to yield
1551  ASCII values for characters (those are stored in order):
1552 \end_layout
1554 \begin_layout Standard
1555 \begin_inset Tabular
1556 <lyxtabular version="3" rows="5" columns="6">
1557 <features>
1558 <column alignment="center" valignment="top" width="0">
1559 <column alignment="center" valignment="top" width="0">
1560 <column alignment="center" valignment="top" width="0">
1561 <column alignment="center" valignment="top" width="0">
1562 <column alignment="center" valignment="top" width="0">
1563 <column alignment="center" valignment="top" width="0">
1564 <row>
1565 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1566 \begin_inset Text
1568 \begin_layout Plain Layout
1569 To encode
1570 \end_layout
1572 \end_inset
1573 </cell>
1574 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1575 \begin_inset Text
1577 \begin_layout Plain Layout
1578 1st char.
1579 \end_layout
1581 \end_inset
1582 </cell>
1583 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1584 \begin_inset Text
1586 \begin_layout Plain Layout
1587 2nd char.
1588 \end_layout
1590 \end_inset
1591 </cell>
1592 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1593 \begin_inset Text
1595 \begin_layout Plain Layout
1596 3rd char.
1597 \end_layout
1599 \end_inset
1600 </cell>
1601 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1602 \begin_inset Text
1604 \begin_layout Plain Layout
1605 4th char.
1606 \end_layout
1608 \end_inset
1609 </cell>
1610 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1611 \begin_inset Text
1613 \begin_layout Plain Layout
1614 5th char.
1615 \end_layout
1617 \end_inset
1618 </cell>
1619 </row>
1620 <row>
1621 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1622 \begin_inset Text
1624 \begin_layout Plain Layout
1625 1 byte
1626 \end_layout
1628 \end_inset
1629 </cell>
1630 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1631 \begin_inset Text
1633 \begin_layout Plain Layout
1635 \end_layout
1637 \end_inset
1638 </cell>
1639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1640 \begin_inset Text
1642 \begin_layout Plain Layout
1644 \end_layout
1646 \end_inset
1647 </cell>
1648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1649 \begin_inset Text
1651 \begin_layout Plain Layout
1653 \end_layout
1655 \end_inset
1656 </cell>
1657 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1658 \begin_inset Text
1660 \begin_layout Plain Layout
1662 \end_layout
1664 \end_inset
1665 </cell>
1666 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1667 \begin_inset Text
1669 \begin_layout Plain Layout
1671 \end_layout
1673 \end_inset
1674 </cell>
1675 </row>
1676 <row>
1677 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1678 \begin_inset Text
1680 \begin_layout Plain Layout
1681 2 bytes
1682 \end_layout
1684 \end_inset
1685 </cell>
1686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1687 \begin_inset Text
1689 \begin_layout Plain Layout
1691 \end_layout
1693 \end_inset
1694 </cell>
1695 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1696 \begin_inset Text
1698 \begin_layout Plain Layout
1700 \end_layout
1702 \end_inset
1703 </cell>
1704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1705 \begin_inset Text
1707 \begin_layout Plain Layout
1709 \end_layout
1711 \end_inset
1712 </cell>
1713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1714 \begin_inset Text
1716 \begin_layout Plain Layout
1718 \end_layout
1720 \end_inset
1721 </cell>
1722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1723 \begin_inset Text
1725 \begin_layout Plain Layout
1727 \end_layout
1729 \end_inset
1730 </cell>
1731 </row>
1732 <row>
1733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1734 \begin_inset Text
1736 \begin_layout Plain Layout
1737 3 bytes
1738 \end_layout
1740 \end_inset
1741 </cell>
1742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1743 \begin_inset Text
1745 \begin_layout Plain Layout
1747 \end_layout
1749 \end_inset
1750 </cell>
1751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1752 \begin_inset Text
1754 \begin_layout Plain Layout
1756 \end_layout
1758 \end_inset
1759 </cell>
1760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1761 \begin_inset Text
1763 \begin_layout Plain Layout
1765 \end_layout
1767 \end_inset
1768 </cell>
1769 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1770 \begin_inset Text
1772 \begin_layout Plain Layout
1774 \end_layout
1776 \end_inset
1777 </cell>
1778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1779 \begin_inset Text
1781 \begin_layout Plain Layout
1783 \end_layout
1785 \end_inset
1786 </cell>
1787 </row>
1788 <row>
1789 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1790 \begin_inset Text
1792 \begin_layout Plain Layout
1793 4 bytes
1794 \end_layout
1796 \end_inset
1797 </cell>
1798 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1799 \begin_inset Text
1801 \begin_layout Plain Layout
1803 \end_layout
1805 \end_inset
1806 </cell>
1807 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1808 \begin_inset Text
1810 \begin_layout Plain Layout
1812 \end_layout
1814 \end_inset
1815 </cell>
1816 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1817 \begin_inset Text
1819 \begin_layout Plain Layout
1821 \end_layout
1823 \end_inset
1824 </cell>
1825 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1826 \begin_inset Text
1828 \begin_layout Plain Layout
1830 \end_layout
1832 \end_inset
1833 </cell>
1834 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1835 \begin_inset Text
1837 \begin_layout Plain Layout
1839 \end_layout
1841 \end_inset
1842 </cell>
1843 </row>
1844 </lyxtabular>
1846 \end_inset
1849 \end_layout
1851 \begin_layout Standard
1852 Blocks which encode values greater than what is possible for value of that
1853  length are fatal errors.
1855 \end_layout
1857 \begin_layout Subsection
1858 Line component encoing
1859 \end_layout
1861 \begin_layout Standard
1862 Line component encoding sits on top of UTF-8 encoding.
1863  Line component encoding encodes non-empty 1-D array of non-empty strings
1864  into line, and thus array of those into member.
1865  Empty lines or lines that don't contain any components are ignored.
1866  Line starts with depth value of 0 and must end with depth value of zero.
1867 \end_layout
1869 \begin_layout Standard
1870 Components are seperated by component separators.
1871  Empty components are ignored.
1872  Following codepoints are separators on depth 0 if not escaped:
1873 \end_layout
1875 \begin_layout Itemize
1876 Codepoint of '('.
1877  The depth is read pre-increment.
1878 \end_layout
1880 \begin_layout Itemize
1881 Codepoint of ')'.
1882  The depth is read post-decrement.
1883 \end_layout
1885 \begin_layout Itemize
1886 Any SPACE character
1887 \end_layout
1889 \begin_layout Standard
1890 The following characters are special:
1891 \end_layout
1893 \begin_layout Itemize
1894 '('.
1895  Increments depth by 1 if not escaped (and appears in component).
1896 \end_layout
1898 \begin_layout Itemize
1899 ')'.
1900  Decrements depth by 1 if not escaped (and appears in component).
1901  Depth going negative is an error.
1902 \end_layout
1904 \begin_layout Itemize
1906 \backslash
1908  Next character is interpretted as literal.
1909  Error if at end of line.
1910 \end_layout
1912 \begin_layout Standard
1913 Otherwise, characters are interpretted as literals and appear in components.
1914  Depth must be zero at end of line.
1915 \end_layout
1917 \begin_layout Subsection
1918 Header section:
1919 \end_layout
1921 \begin_layout Standard
1922 Header section is in archive member "header".
1923  It uses line component encoding.
1924  The first component of each line is name of header, and subsequent ones
1925  are arguments.
1926  How many parameters are expected is dependent on what header it is:
1927 \end_layout
1929 \begin_layout Subsubsection
1930 PROJECTID header:
1931 \end_layout
1933 \begin_layout Itemize
1934 Header name: "PROJECTID"
1935 \end_layout
1937 \begin_layout Itemize
1938 Components: 2
1939 \end_layout
1941 \begin_layout Itemize
1942 Argument #1: <project-id-string>
1943 \end_layout
1945 \begin_layout Itemize
1946 Mandatory: Yes
1947 \end_layout
1949 \begin_layout Standard
1950 Gives project ID.
1951  Project ID is generated when PC is assembled and is then preserved in save
1952  states.
1953  It is used for computing rerecord counts.
1954  Emulator treats it as opaque string, the IDs it generates are formed by
1955  48 random hexadecimal digits.
1956 \end_layout
1958 \begin_layout Subsubsection
1959 SAVESTATEID header:
1960 \end_layout
1962 \begin_layout Itemize
1963 Header name: "SAVESTATEID"
1964 \end_layout
1966 \begin_layout Itemize
1967 Components: 2
1968 \end_layout
1970 \begin_layout Itemize
1971 Argument #1: <savestate-id-string>
1972 \end_layout
1974 \begin_layout Itemize
1975 Mandatory: No
1976 \end_layout
1978 \begin_layout Standard
1979 Gives save state ID.
1980  Each save state has its own save state ID.
1981  Treated as opaque string, but generated as 48 random hexadecimal digits.
1982  The presence of this header signals whether there is save state to be loaded.
1983  If this header is present, save state load will be attempted.
1984  If absent, save state is not to be loaded even if present (and correct
1985  savestate load would be technically impossible anyway).
1986 \end_layout
1988 \begin_layout Standard
1989 The value is used to prevent loading incompatible save states in preserve
1990  event stream mode and also to find the point in event stream where one
1991  left off.
1992 \end_layout
1994 \begin_layout Subsubsection
1995 RERECORDS header:
1996 \end_layout
1998 \begin_layout Itemize
1999 Header name: "RERECORDS"
2000 \end_layout
2002 \begin_layout Itemize
2003 Components: 2
2004 \end_layout
2006 \begin_layout Itemize
2007 Argument #1: <rerecords>
2008 \end_layout
2010 \begin_layout Itemize
2011 Mandatory: Yes
2012 \end_layout
2014 \begin_layout Standard
2015 Gives rerecord count.
2016  PC assembly (except when loading save state) initializes current rerecord
2017  count to zero.
2018  Must be non-negative and decimal number using ASCII digit characters.
2019 \end_layout
2021 \begin_layout LyX-Code
2022 On loading save state:
2023 \end_layout
2025 \begin_layout LyX-Code
2026 1) If project ID matches with previous:
2027 \end_layout
2029 \begin_layout LyX-Code
2030 1a) If loaded rerecord count is larger or equal to current rerecord count:
2031 \end_layout
2033 \begin_layout LyX-Code
2034 1a-a) Current rerecord count is loaded rerecord count + 1.
2035 \end_layout
2037 \begin_layout LyX-Code
2038 1b) Otherwise
2039 \end_layout
2041 \begin_layout LyX-Code
2042 1b-a) Current rerecord count increments by 1.
2043 \end_layout
2045 \begin_layout LyX-Code
2046 2) Otherwise
2047 \end_layout
2049 \begin_layout LyX-Code
2050 2a) Current rerecord count is loaded rerecord count + 1.
2051 \end_layout
2053 \begin_layout Standard
2054 The current rerecord count at time of save is saved to save state.
2055 \end_layout
2057 \begin_layout Subsubsection
2058 AUTHORS header:
2059 \end_layout
2061 \begin_layout Itemize
2062 Header name: "AUTHORS"
2063 \end_layout
2065 \begin_layout Itemize
2066 Components: 2 or more
2067 \end_layout
2069 \begin_layout Itemize
2070 Arguments: free form
2071 \end_layout
2073 \begin_layout Itemize
2074 Mandatory: No
2075 \end_layout
2077 \begin_layout Standard
2078 Gives authors of run.
2079  Each argument gives one author.
2080  May be present multiple times.
2081 \end_layout
2083 \begin_layout Subsubsection
2084 COMMENT header:
2085 \end_layout
2087 \begin_layout Itemize
2088 Header name: "COMMENT"
2089 \end_layout
2091 \begin_layout Itemize
2092 Components: 2 or more
2093 \end_layout
2095 \begin_layout Itemize
2096 Arguments: free form
2097 \end_layout
2099 \begin_layout Itemize
2100 Mandatory: No
2101 \end_layout
2103 \begin_layout Standard
2104 Various kinds of free form data.
2105  Not parsed further by emulator.
2106 \end_layout
2108 \begin_layout Subsection
2109 Initialization segment:
2110 \end_layout
2112 \begin_layout Standard
2113 If SAVESTATEID header isn't present (not a save state), member "initialization"
2114  gives PC initialization parameters for assembling the PC.
2115  It is present anyway even if SAVESTATEID is present (savestate).
2116 \end_layout
2118 \begin_layout Standard
2119 Following parameters are used (space separates components):
2120 \end_layout
2122 \begin_layout LyX-Code
2123 "BIOS" <id>
2124 \end_layout
2126 \begin_layout Standard
2127 Gives Image ID of main system BIOS (mandatory)
2128 \end_layout
2130 \begin_layout LyX-Code
2131 "VGABIOS" <id>
2132 \end_layout
2134 \begin_layout Standard
2135 Gives Image ID of VGA BIOS (mandatory).
2136 \end_layout
2138 \begin_layout LyX-Code
2139 "HDA" <id>
2140 \end_layout
2142 \begin_layout Standard
2143 Gives Image ID of hda.
2144  Present only if system has hard disk hda.
2145 \end_layout
2147 \begin_layout LyX-Code
2148 "HDB" <id>
2149 \end_layout
2151 \begin_layout Standard
2152 Gives Image ID of hdb.
2153  Present only if system has hard disk hdb.
2154 \end_layout
2156 \begin_layout LyX-Code
2157 "HDC" <id>
2158 \end_layout
2160 \begin_layout Standard
2161 Gives Image ID of hdc.
2162  Present only if system has hard disk hdc.
2163 \end_layout
2165 \begin_layout LyX-Code
2166 "HDD" <id>
2167 \end_layout
2169 \begin_layout Standard
2170 Gives Image ID of hdd.
2171  Present only if system has hard disk hdd.
2172 \end_layout
2174 \begin_layout LyX-Code
2175 "DISK" <num> <id>
2176 \end_layout
2178 \begin_layout Standard
2179 Gives Image ID of disk in slot <num>.
2180  Slot number must be non-negative.
2181 \end_layout
2183 \begin_layout LyX-Code
2184 \begin_inset Quotes eld
2185 \end_inset
2187 DISKNAME
2188 \begin_inset Quotes erd
2189 \end_inset
2191  <num> <name>
2192 \end_layout
2194 \begin_layout Standard
2195 kGives image name of disk in slot <num>.
2196  Slot number must be non-negative.
2197  The slot must be previously declared using 
2198 \begin_inset Quotes eld
2199 \end_inset
2201 DISK
2202 \begin_inset Quotes erd
2203 \end_inset
2206 \end_layout
2208 \begin_layout LyX-Code
2209 "FDA" <num>
2210 \end_layout
2212 \begin_layout Standard
2213 Gives Image slot to initially put into floppy drive fda.
2214  Disk must be of floppy type.
2215  If none present, no disk is initially put there.
2216 \end_layout
2218 \begin_layout LyX-Code
2219 "FDB" <num>
2220 \end_layout
2222 \begin_layout Standard
2223 Gives Image slot to initially put into floppy drive fdb.
2224  Disk must be of floppy type.
2225  If none present, no disk is initially put there.
2226 \end_layout
2228 \begin_layout LyX-Code
2229 "CDROM" <num>
2230 \end_layout
2232 \begin_layout Standard
2233 Gives Image slot to initially put into CD-ROM drive hdc.
2234  Not allowed if hard disk hdc is present.
2235  Disk must be of CD-ROM type.
2236  If none present no disk is initially put there.
2237 \end_layout
2239 \begin_layout LyX-Code
2240 "INITIALTIME" <time>
2241 \end_layout
2243 \begin_layout Standard
2244 Number of milliseconds since Unix epoch to system start up time.
2245  Allowed range:
2246 \end_layout
2248 \begin_layout Standard
2249 0-4102444799999.
2250  Mandatory.
2251 \end_layout
2253 \begin_layout LyX-Code
2254 "CPUDIVIDER" <divider>
2255 \end_layout
2257 \begin_layout Standard
2258 Set CPU frequency divider (dividing the 1GHz master clock).
2259  Allowed range is 1-256.
2260  Mandatory.
2261 \end_layout
2263 \begin_layout LyX-Code
2264 "MEMORYSIZE" <pages>
2265 \end_layout
2267 \begin_layout Standard
2268 Number of 4KiB pages of RAM memory.
2269  Allowed range 256-262144.
2270  Mandatory.
2271 \end_layout
2273 \begin_layout LyX-Code
2274 "BOOT" <device>
2275 \end_layout
2277 \begin_layout Standard
2278 Set boot device.
2279  Valid devices are "FLOPPY" (boot from fda), "HDD" (boot from hda) and "CDROM"
2280  (boot from CD).
2281 \end_layout
2283 \begin_layout LyX-Code
2284 "LOADMODULEA" <module> <parameters>
2285 \end_layout
2287 \begin_layout Standard
2288 Load module <module> with parameters <parameters>.
2289 \end_layout
2291 \begin_layout LyX-Code
2292 "LOADMODULE" <module>
2293 \end_layout
2295 \begin_layout Standard
2296 Load module <module> with no parameters
2297 \end_layout
2299 \begin_layout LyX-Code
2300 \begin_inset Quotes eld
2301 \end_inset
2304 \begin_inset Quotes erd
2305 \end_inset
2307  <fpu>
2308 \end_layout
2310 \begin_layout Standard
2311 Use class <fpu> as FPU emulator.
2312 \end_layout
2314 \begin_layout Subsection
2315 Event record format:
2316 \end_layout
2318 \begin_layout Standard
2319 Event record is in archive member "events".
2320  It uses line component encoding.
2321  Each line gives an event.
2322  First component of each line gives time stamp.
2323  These timestamps MUST be in increasing order and all MUST be non-negative.
2324  Time stamp time unit is exactly 1 nanosecond of emulated time.
2325 \end_layout
2327 \begin_layout Standard
2328 The second component of each line is name of class to dispatch to.
2329  Further components are passed as-is to event handlers.
2331 \end_layout
2333 \begin_layout Subsubsection
2334 Savestate event
2335 \end_layout
2337 \begin_layout Itemize
2338 Dispatch to: SAVESTATE
2339 \end_layout
2341 \begin_layout Itemize
2342 Argument #1: Savestate id
2343 \end_layout
2345 \begin_layout Itemize
2346 Argument #2 (optional): Rerecord count at time of saving savestate
2347 \end_layout
2349 \begin_layout Standard
2350 Signals that savestate has occured here.
2351  The save state IDs MUST be unique in entire event stream.
2352  The second argument to savestate (if present) is rerecord count at time
2353  of saving that savestate (useful for calulating rerecord count of movie
2354  starting from savestate).
2355  No time restrictions
2356 \end_layout
2358 \begin_layout Subsubsection
2359 Option event
2360 \end_layout
2362 \begin_layout Itemize
2363 Dispatch to: OPTION
2364 \end_layout
2366 \begin_layout Itemize
2367 Argument #1: 
2368 \begin_inset Quotes eld
2369 \end_inset
2371 ABSOLUTE
2372 \begin_inset Quotes erd
2373 \end_inset
2375  or 
2376 \begin_inset Quotes eld
2377 \end_inset
2379 RELATIVE
2380 \begin_inset Quotes erd
2381 \end_inset
2384 \end_layout
2386 \begin_layout Standard
2387 Controls various options.
2389 \begin_inset Quotes eld
2390 \end_inset
2392 ABSOLUTE
2393 \begin_inset Quotes erd
2394 \end_inset
2396  turns on absolute mode (default) where event timestamps are absolute.
2398 \begin_inset Quotes eld
2399 \end_inset
2401 RELATIVE
2402 \begin_inset Quotes erd
2403 \end_inset
2405  turns on relative mode where event timestamps are relative to last event
2406  in stream.
2407  The OPTION event itself is not affected by timing change.
2408  No time restrictions
2409 \end_layout
2411 \begin_layout Subsubsection
2412 Keyboard keypress/keyrelease event:
2413 \end_layout
2415 \begin_layout Itemize
2416 Dispatch to: org.jpc.emulator.peripheral.Keyboard
2417 \end_layout
2419 \begin_layout Itemize
2420 Argument #1: Fixed: "KEYEDGE"
2421 \end_layout
2423 \begin_layout Itemize
2424 Argument #2: Key number.
2425  Valid values are 1-83, 85-95, 129-197 and 199-223
2426 \end_layout
2428 \begin_layout Standard
2429 Send key press or key release.
2430  Keys work in toggle button manner.
2431  The event time must be multiple of 66 666, and must not be less than 60
2432  * 66 666 TUs after last PAUSE event, 20 * 66 666 TUs after last KEYEDGE
2433  on key >128 and 10 * 66 666 TUs after last KEYEDGE on key <128.
2434 \end_layout
2436 \begin_layout Subsubsection
2437 Pause event:
2438 \end_layout
2440 \begin_layout Itemize
2441 Dispatch to: org.jpc.emulator.peripheral.Keyboard
2442 \end_layout
2444 \begin_layout Itemize
2445 Argument #1: Fixed: "PAUSE"
2446 \end_layout
2448 \begin_layout Standard
2449 Send pause key event.
2450  The time restrictions are identical to KEYEDGE event.
2451 \end_layout
2453 \begin_layout Subsubsection
2454 Joystick button event:
2455 \end_layout
2457 \begin_layout Itemize
2458 Dispatch to: org.jpc.modules.Joystick
2459 \end_layout
2461 \begin_layout Itemize
2462 Argument #1: 
2463 \begin_inset Quotes eld
2464 \end_inset
2466 BUTTONA
2467 \begin_inset Quotes erd
2468 \end_inset
2471 \begin_inset Quotes eld
2472 \end_inset
2474 BUTTONB
2475 \begin_inset Quotes erd
2476 \end_inset
2479 \begin_inset Quotes eld
2480 \end_inset
2482 BUTTONC
2483 \begin_inset Quotes erd
2484 \end_inset
2486  or 
2487 \begin_inset Quotes eld
2488 \end_inset
2490 BUTTOND
2491 \begin_inset Quotes erd
2492 \end_inset
2495 \end_layout
2497 \begin_layout Itemize
2498 Argument #2: 
2499 \begin_inset Quotes eld
2500 \end_inset
2503 \begin_inset Quotes erd
2504 \end_inset
2506  if released, 
2507 \begin_inset Quotes eld
2508 \end_inset
2511 \begin_inset Quotes erd
2512 \end_inset
2514  if pressed
2515 \end_layout
2517 \begin_layout Standard
2518 Send button down/up event.
2519  No time restrictions.
2520 \end_layout
2522 \begin_layout Subsubsection
2523 Joystick axis event:
2524 \end_layout
2526 \begin_layout Itemize
2527 Dispatch to: org.jpc.modules.Joystick
2528 \end_layout
2530 \begin_layout Itemize
2531 Argument #1: 
2532 \begin_inset Quotes eld
2533 \end_inset
2535 AXISA
2536 \begin_inset Quotes erd
2537 \end_inset
2540 \begin_inset Quotes eld
2541 \end_inset
2543 AXISB
2544 \begin_inset Quotes erd
2545 \end_inset
2548 \begin_inset Quotes eld
2549 \end_inset
2551 AXISC
2552 \begin_inset Quotes erd
2553 \end_inset
2555  or 
2556 \begin_inset Quotes eld
2557 \end_inset
2559 AXISD
2560 \begin_inset Quotes erd
2561 \end_inset
2564 \end_layout
2566 \begin_layout Itemize
2567 Argument #2: Multivibrator unstable state length in ns.
2568 \end_layout
2570 \begin_layout Standard
2571 Set amount of time multivibrator remains in unstable state.
2572  No time restrictions.
2573 \end_layout
2575 \begin_layout Subsubsection
2576 Reboot:
2577 \end_layout
2579 \begin_layout Itemize
2580 Dispatch to: org.jpc.emulator.PC$ResetButton
2581 \end_layout
2583 \begin_layout Itemize
2584 No arguments
2585 \end_layout
2587 \begin_layout Standard
2588 Reboots the PC.
2589 \end_layout
2591 \begin_layout Subsubsection
2592 Fda disk change:
2593 \end_layout
2595 \begin_layout Itemize
2596 Dispatch to: org.jpc.emulator.PC$DiskChanger
2597 \end_layout
2599 \begin_layout Itemize
2600 Argument #1: Fixed: "FDA"
2601 \end_layout
2603 \begin_layout Itemize
2604 Argument #2: Number of image slot to put there.
2606 \end_layout
2608 \begin_layout Standard
2609 The disk number MUST be -1 or valid disk number.
2610  -1 MUST NOT be used if there is no disk in floppy drive A.
2611  This event causes specified disk to be placed to FDA or FDA disk to be
2612  ejected with no replacement if disk number is -1.
2613  The specified disk if not -1 must be of floppy type.
2614  The specified disk if valid must not be in any other drive.
2615 \end_layout
2617 \begin_layout Subsubsection
2618 Fdb disk change:
2619 \end_layout
2621 \begin_layout Itemize
2622 Dispatch to: org.jpc.emulator.PC$DiskChanger
2623 \end_layout
2625 \begin_layout Itemize
2626 Argument #1: Fixed: "FDB"
2627 \end_layout
2629 \begin_layout Itemize
2630 Argument #2: Number of image slot to put there.
2632 \end_layout
2634 \begin_layout Standard
2635 The disk number MUST be -1 or valid disk number.
2636  -1 MUST NOT be used if there is no disk in floppy drive B.
2637  This event causes specified disk to be placed to FDB or FDB disk to be
2638  ejected with no replacement if disk number is -1.
2639  The specified disk if not -1 must be of floppy type.
2640  The specified disk if valid must not be in any other drive.
2641 \end_layout
2643 \begin_layout Subsubsection
2644 Change CDROM:
2645 \end_layout
2647 \begin_layout Itemize
2648 Dispatch to: org.jpc.emulator.PC$DiskChanger
2649 \end_layout
2651 \begin_layout Itemize
2652 Argument #1: Fixed: "CDROM"
2653 \end_layout
2655 \begin_layout Itemize
2656 Argument #2: Number of image slot to put there.
2658 \end_layout
2660 \begin_layout Standard
2661 The disk number MUST be -1 or valid disk number.
2662  -1 MUST NOT be used if there is no disk in CD-ROM.
2663  This event causes specified disk to be placed to CD-ROM or CD-ROM disk
2664  to be ejected with no replacement if disk number is -1.
2665  The specified disk if not -1 must be of CD-ROM type.
2666 \end_layout
2668 \begin_layout Standard
2669 This event has no effect if CD-ROM is locked.
2670 \end_layout
2672 \begin_layout Subsubsection
2673 Write protect floppy:
2674 \end_layout
2676 \begin_layout Itemize
2677 Dispatch to: org.jpc.emulator.PC$DiskChanger
2678 \end_layout
2680 \begin_layout Itemize
2681 Argument #1: Fixed: "WRITEPROTECT"
2682 \end_layout
2684 \begin_layout Itemize
2685 Argument #2: Number of image slot to manipulate 
2686 \end_layout
2688 \begin_layout Standard
2689 Write protects specified disk.
2690  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2691 \end_layout
2693 \begin_layout Subsubsection
2694 Write unprotect floppy:
2695 \end_layout
2697 \begin_layout Itemize
2698 Dispatch to: org.jpc.emulator.PC$DiskChanger
2699 \end_layout
2701 \begin_layout Itemize
2702 Argument #1: Fixed: "WRITEUNPROTECT"
2703 \end_layout
2705 \begin_layout Itemize
2706 Argument #2: Number of image slot to manipulate 
2707 \end_layout
2709 \begin_layout Standard
2710 Disables write protection specified disk.
2711  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2712 \end_layout
2714 \begin_layout Subsection
2715 Diskinfo sections
2716 \end_layout
2718 \begin_layout Standard
2719 Diskinfo sections are named 
2720 \begin_inset Quotes eld
2721 \end_inset
2723 diskinfo-
2724 \begin_inset Quotes erd
2725 \end_inset
2727 <id of disk>.
2728  They use line component encoding, fieldtype being first component on each
2729  line (value being the second).
2730  Following fields are defined:
2731 \end_layout
2733 \begin_layout Subsubsection
2734 TYPE
2735 \end_layout
2737 \begin_layout Standard
2738 Gives type of image.
2739  Possible values are
2740 \end_layout
2742 \begin_layout Itemize
2743 \begin_inset Quotes eld
2744 \end_inset
2746 FLOPPY
2747 \begin_inset Quotes erd
2748 \end_inset
2750  (floppy disk)
2751 \end_layout
2753 \begin_layout Itemize
2754 \begin_inset Quotes eld
2755 \end_inset
2758 \begin_inset Quotes erd
2759 \end_inset
2761  (Hard disk)
2762 \end_layout
2764 \begin_layout Itemize
2765 \begin_inset Quotes eld
2766 \end_inset
2768 CDROM
2769 \begin_inset Quotes erd
2770 \end_inset
2772  (CD-ROM)
2773 \end_layout
2775 \begin_layout Itemize
2776 \begin_inset Quotes eld
2777 \end_inset
2779 BIOS
2780 \begin_inset Quotes erd
2781 \end_inset
2783  (BIOS/VGABIOS image)
2784 \end_layout
2786 \begin_layout Itemize
2787 \begin_inset Quotes eld
2788 \end_inset
2790 UNKNOWN
2791 \begin_inset Quotes erd
2792 \end_inset
2794  (what the heck is this???)
2795 \end_layout
2797 \begin_layout Subsubsection
2799 \end_layout
2801 \begin_layout Standard
2802 Gives ID of disk.
2803 \end_layout
2805 \begin_layout Subsubsection
2806 IMAGELENGTH
2807 \end_layout
2809 \begin_layout Standard
2810 (BIOS images only) Gives length of BIOS image
2811 \end_layout
2813 \begin_layout Subsubsection
2814 IMAGEMD5
2815 \end_layout
2817 \begin_layout Standard
2818 MD5 of raw disk/BIOS image without any headers or trailers.
2819 \end_layout
2821 \begin_layout Subsubsection
2822 TOTALSECTORS
2823 \end_layout
2825 \begin_layout Standard
2826 (FLOPPY/HDD/CDROM images only) Number of total sectors on disk.
2827 \end_layout
2829 \begin_layout Subsubsection
2830 TRACKS
2831 \end_layout
2833 \begin_layout Standard
2834 (FLOPPY/HDD images only) Number of tracks on disk per side (1-256 for floppy,
2835  1-1024 for HDD).
2836 \end_layout
2838 \begin_layout Subsubsection
2839 SIDES
2840 \end_layout
2842 \begin_layout Standard
2843 (FLOPPY/HDD images only) Number of sides on disk (1 or 2 for floppy, 1-16
2844  for HDD).
2845 \end_layout
2847 \begin_layout Subsubsection
2848 SECTORS
2849 \end_layout
2851 \begin_layout Standard
2852 (FLOPPY/HDD images only) Number of sectors per track (1-255 for floppy,
2853  1-63 for HDD).
2854 \end_layout
2856 \begin_layout Subsubsection
2857 COMMENT
2858 \end_layout
2860 \begin_layout Standard
2861 Line from image comment block.
2862  Usually give data about files image has.
2863  May or may not be present.
2864 \end_layout
2866 \begin_layout Subsection
2867 Savestates
2868 \end_layout
2870 \begin_layout Standard
2871 Actual savestate format is not documented here.
2872  It is close to impossible to comprehend without access to emulator source
2873  anyway.
2874 \end_layout
2876 \begin_layout Section
2877 Advanced: Making class dumpable
2878 \end_layout
2880 \begin_layout Standard
2881 Class is made dumpable by implementing interface org.jpc.emulator.SRDumpable
2882  and implementing method dumpSRPartial(org.jpc.emulator.SRDumper) and constructor
2883  <init>(org.jpc.emulator.SRLoader).
2884  Non-static inner classes can not be dumpable (make them static using tricks
2885  similar to what javac uses).
2886 \end_layout
2888 \begin_layout Standard
2889 If dumped class has dumpable superclass, the first thing dumping function
2890  needs to do is to call dumper function of superclass and first thing loading
2891  constructor needs to do is to call loading constructor of superclass.
2892  If class has no dumpable superclass, dumper doesn't need to do anything
2893  special, while loader needs to call objectCreated(this) on SRLoader object
2894  passed as parameter.
2896 \end_layout
2898 \begin_layout Standard
2899 Following these fixed parts, dump all members that are part of mutable state
2900  in emulator core.
2901 \end_layout
2903 \begin_layout Subsection
2904 Member dumping/loading functions
2905 \end_layout
2907 \begin_layout Standard
2908 There is dumping/loading function for following (all functions dumping/loading
2909  reference types can handle null):
2910 \end_layout
2912 \begin_layout Itemize
2913 boolean: SRDumper.dumpBoolean, SRLoader.loadBoolean
2914 \end_layout
2916 \begin_layout Itemize
2917 byte: SRDumper.dumpByte, SRLoader.loadByte
2918 \end_layout
2920 \begin_layout Itemize
2921 short: SRDumper.dumpShort, SRLoader.loadShort
2922 \end_layout
2924 \begin_layout Itemize
2925 int: SRDumper.dumpInt, SRLoader.loadInt
2926 \end_layout
2928 \begin_layout Itemize
2929 long: SRDumper.dumpLong, SRLoader.loadLong
2930 \end_layout
2932 \begin_layout Itemize
2933 String: SRDumper.dumpString, SRLoader.loadString
2934 \end_layout
2936 \begin_layout Itemize
2937 boolean[]: SRDumper.dumpArray, SRLoader.loadArrayBoolean
2938 \end_layout
2940 \begin_layout Itemize
2941 byte[]: SRDumper.dumpArray, SRLoader.loadArrayByte
2942 \end_layout
2944 \begin_layout Itemize
2945 short[]: SRDumper.dumpArray, SRLoader.loadArrayShort
2946 \end_layout
2948 \begin_layout Itemize
2949 int[]: SRDumper.dumpArray, SRLoader.loadArrayInt
2950 \end_layout
2952 \begin_layout Itemize
2953 long[]: SRDumper.dumpArray, SRLoader.loadArrayLong
2954 \end_layout
2956 \begin_layout Itemize
2957 double[]: SRDumper.dumpArray, SRLoader.loadArrayDouble
2958 \end_layout
2960 \begin_layout Itemize
2961 <dumpable type>: SRDumper.dumpObject, SRLoader.loadObject
2962 \end_layout
2964 \begin_layout Itemize
2965 special object: SRDumper.specialObject, SRLoader.specialObject
2966 \end_layout
2968 \begin_layout Subsubsection
2969 Notes:
2970 \end_layout
2972 \begin_layout Itemize
2973 Dumpable objects come out as type of org.jpc.emulator.SRDumpable.
2974 \end_layout
2976 \begin_layout Itemize
2977 Special objects are various static objects that don't need to be stored
2978  because they don't have mutable fields.
2979 \end_layout
2981 \begin_layout Itemize
2982 Don't dump fields related to event state feedback.
2983 \end_layout
2985 \begin_layout Itemize
2986 Don't dump temporary flags that are only used while PC is running.
2987  Savestate when PC is running isn't possible anyway.
2988 \end_layout
2990 \begin_layout Itemize
2991 Some connectors dump fields related to connector output, some don't.
2992 \end_layout
2994 \begin_layout Section
2995 Advanced: Making output connectors
2996 \end_layout
2998 \begin_layout Standard
2999 Implementing interface org.jpc.emulator.DisplayController signals that this
3000  is display controller, inhibiting loading of the standard VGA display controlle
3001 r if loaded as module.
3003 \end_layout
3005 \begin_layout Subsection
3006 Interface org.jpc.emulator.OutputConnector
3007 \end_layout
3009 \begin_layout Standard
3010 Class is made to be output connector by implementing this interface.
3011  This interface specifies the methods used for output hold locking.
3012  Class org.jpc.emulator.OutputConnectorLocking has implementations of these
3013  that are suitable for calling.
3015 \end_layout
3017 \begin_layout Subsubsection
3018 Method subscribeOutput(Object)
3019 \end_layout
3021 \begin_layout Standard
3022 Subscribes the output, with specified object as handle.
3023 \end_layout
3025 \begin_layout Subsubsection
3026 Method unsubscribeOutput(Object)
3027 \end_layout
3029 \begin_layout Standard
3030 Unsubscribe the specified handle object from output.
3031 \end_layout
3033 \begin_layout Subsubsection
3034 Method waitOutput(Object)
3035 \end_layout
3037 \begin_layout Standard
3038 Wait for output on specified connector using specified handle object.
3039  Returns true on success, false if wait was interrupted by thread interrupt.
3040  Blocking.
3041 \end_layout
3043 \begin_layout Subsubsection
3044 Method releaseOutput(Object)
3045 \end_layout
3047 \begin_layout Standard
3048 Release connector from p.o.v.
3049  of given handle.
3050  Does not block.
3051 \end_layout
3053 \begin_layout Subsubsection
3054 Method holdOutput()
3055 \end_layout
3057 \begin_layout Standard
3058 Release threads waiting on waitOutput() and block until all subscribers
3059  have returned from waitOutput() and enteired releaseOutput().
3060 \end_layout
3062 \begin_layout Subsubsection
3063 Method releaseOutputWaitAll(object)
3064 \end_layout
3066 \begin_layout Standard
3067 Like releaseOutput(), but waits until all handles have released their output.
3068 \end_layout
3070 \begin_layout Subsection
3071 Class org.jpc.emulator.VGADigtalOut
3072 \end_layout
3074 \begin_layout Standard
3075 Class org.jpc.emulator.VGADigtalOut (already implements OutputConnector) implements
3076  VGA output connector.
3077  If module provodes output connector, it needs to implement org.jpc.emulator.Displa
3078 yController.
3079 \end_layout
3081 \begin_layout Subsubsection
3082 Method getWidth()
3083 \end_layout
3085 \begin_layout Standard
3086 Get width of display (watch out, can return 0).
3087 \end_layout
3089 \begin_layout Subsubsection
3090 Method getHeight()
3091 \end_layout
3093 \begin_layout Standard
3094 Get height of display (watch out, can return 0).
3095 \end_layout
3097 \begin_layout Subsubsection
3098 Methods getDirtyXMin(), getDirtyXMax(), getDirtyYMin(), getDirtyYMax()
3099 \end_layout
3101 \begin_layout Standard
3102 Returns the dirty region (region modified since last output).
3103 \end_layout
3105 \begin_layout Subsubsection
3106 Method getBuffer()
3107 \end_layout
3109 \begin_layout Standard
3110 Get buffer of ints, at least width * height elements (left-to-right, top-down,
3111  one value per pixel) giving pixel data.
3112  Value for each pixel is 65536 * <red-component> + 256 * <green-component>
3113  + <blue-component>.
3114 \end_layout
3116 \begin_layout Subsubsection
3117 Method resizeDisplay(int _width, int _height)
3118 \end_layout
3120 \begin_layout Standard
3121 Resize the display to be of specified size.
3122 \end_layout
3124 \begin_layout Subsubsection
3125 Method dirtyDisplayRegion(int x, int y, int w, int h)
3126 \end_layout
3128 \begin_layout Standard
3129 Mark the specified region as dirty.
3130 \end_layout
3132 \begin_layout Subsubsection
3133 Method resetDirtyRegion()
3134 \end_layout
3136 \begin_layout Standard
3137 Resets the dirty region to be empty.
3138 \end_layout
3140 \begin_layout Subsection
3141 Class org.jpc.emulator.PC method getVideoOutput()
3142 \end_layout
3144 \begin_layout Standard
3145 Get VGA output connector for PC.
3146 \end_layout
3148 \begin_layout Subsection
3149 Interface org.jpc.emulator.DisplayController.
3150 \end_layout
3152 \begin_layout Standard
3153 Implementing this class signals that module is VGA controller.
3154  There can be only one such module active at time and presence of such module
3155  prevents loading builtin VGA controller emulation code.
3156 \end_layout
3158 \begin_layout Subsubsection
3159 Method getOutputDevice()
3160 \end_layout
3162 \begin_layout Standard
3163 Get VGA output connector for this VGA device.
3164 \end_layout
3166 \begin_layout Subsection
3167 Class org.jpc.emulator.SoundDigitalOut
3168 \end_layout
3170 \begin_layout Standard
3171 Class org.jpc.emulator.SoundDigitalOut provodes output connector for sound.
3172  Each connector can transfer stereo signal at arbitiary sampling rate.
3173  Modules that have audio connectors need to implement interface org.jpc.emulator.So
3174 undOutputDevice, as this signals that output connectors should be created.
3175 \end_layout
3177 \begin_layout Subsubsection
3178 Method addSample(long, short, short)
3179 \end_layout
3181 \begin_layout Standard
3182 Add stereo sample at time given by first argument.
3183  The second and third arguments give volume on left and right channels.
3184 \end_layout
3186 \begin_layout Subsubsection
3187 Method addSample(long, short)
3188 \end_layout
3190 \begin_layout Standard
3191 Add mono sample at time given by first argument.
3192  The second argument give volume on both channels.
3193 \end_layout
3195 \begin_layout Subsubsection
3196 Method readBlock(Block)
3197 \end_layout
3199 \begin_layout Standard
3200 Reads block of output (atomic versus addSample).
3201  Block structure has following fields which are filled:
3202 \end_layout
3204 \begin_layout Itemize
3205 timeBase: Time base for block.
3206 \end_layout
3208 \begin_layout Itemize
3209 baseLeft: Left volume at time base.
3210 \end_layout
3212 \begin_layout Itemize
3213 baseRight: Right volume at time base
3214 \end_layout
3216 \begin_layout Itemize
3217 blockNo: Sequence number of block filled.
3218 \end_layout
3220 \begin_layout Itemize
3221 samples: Number of samples in block
3222 \end_layout
3224 \begin_layout Itemize
3225 sampleTiming: Number of nanoseconds since last sample
3226 \end_layout
3228 \begin_layout Itemize
3229 sampleLeft: Left channel samples
3230 \end_layout
3232 \begin_layout Itemize
3233 sampleRight: Right channel samples
3234 \end_layout
3236 \begin_layout Subsection
3237 Interface org.jpc.emulator.SoundOutputDevice
3238 \end_layout
3240 \begin_layout Standard
3241 Implementing this interface signals that module has audio output channels.
3242 \end_layout
3244 \begin_layout Subsubsection
3245 Method org.jpc.emulator.SoundOutputDevice.requestedSoundChannels()
3246 \end_layout
3248 \begin_layout Standard
3249 Return the number of sound channels module has.
3250 \end_layout
3252 \begin_layout Subsubsection
3253 Method org.jpc.emulator.SoundOutputDevice.soundChannelCallback(SoundDigitalOut)
3254 \end_layout
3256 \begin_layout Standard
3257 This is called once per sound channel requested giving precreated sound
3258  channel.
3259 \end_layout
3261 \begin_layout Subsection
3262 Class org.jpc.emulator.PC method getSoundOut(String)
3263 \end_layout
3265 \begin_layout Standard
3266 Get sound output with specified name.
3267 \end_layout
3269 \begin_layout Section
3270 Advanced: Writing event targets
3271 \end_layout
3273 \begin_layout Standard
3274 Whereas output connectors are the way output is dispatched, input is dispatched
3275  via event targets.
3276  Event targets need to implement interface org.jpc.emulator.EventDispatchTarget.
3277 \end_layout
3279 \begin_layout Standard
3280 Event targets also provode methods which then encode events and dispatch
3281  them forward (without doing anything else) to event recorder.
3282  Also, event targets may have methods for obtaining state.
3283 \end_layout
3285 \begin_layout Subsection
3286 Interface org.jpc.emulator.EventDispatchTarget
3287 \end_layout
3289 \begin_layout Standard
3290 Interface that marks class capable of receiving events.
3291 \end_layout
3293 \begin_layout Subsubsection
3294 Method setEventRecorder(EventRecorder)
3295 \end_layout
3297 \begin_layout Standard
3298 Set the event recorder input events are sent to.
3299 \end_layout
3301 \begin_layout Subsubsection
3302 Method startEventCheck()
3303 \end_layout
3305 \begin_layout Standard
3306 Signals target to reset all state related to event checking and state feedback.
3307  This may be called at any time in order to reinitialialize event checking/feedb
3308 ack state.
3309 \end_layout
3311 \begin_layout Subsubsection
3312 Method doEvent(long, String[], int) throws IOException
3313 \end_layout
3315 \begin_layout Standard
3316 Event dispatch handler.
3317  The first argument is event time, second is parameters and third is what
3318  to do with it.
3319  If target doesn't like the event, throw IOException.
3320  Following types (the integer parameter) are used:
3321 \end_layout
3323 \begin_layout LyX-Code
3324 0 (EventRecorder.EVENT_TIMED): Time has been assigned for event.
3325 \end_layout
3327 \begin_layout LyX-Code
3328 1 (EventRecorder.EVENT_STATE_EFFECT_FUTURE): Future event in event replay
3329  for reinitialization
3330 \end_layout
3332 \begin_layout LyX-Code
3333 2 (EventRecorder.EVENT_STATE_EFFECT): Past event in event replay reinitialization
3334 \end_layout
3336 \begin_layout LyX-Code
3337 3 (EventRecorder.EVENT_EXECUTE): This event occurs now.
3338  Execute the effect.
3339 \end_layout
3341 \begin_layout Subsubsection
3342 Method endEventCheock()
3343 \end_layout
3345 \begin_layout Standard
3346 End event reinitialization.
3347  Usually unused.
3348 \end_layout
3350 \begin_layout Subsubsection
3351 Method getEventTimeLowBound(long, String[]) throws IOException
3352 \end_layout
3354 \begin_layout Standard
3355 Return the time value that's the earliest possiblity for this event to occur.
3356  Returning any time in past (including -1) causes event to fire as soon
3357  as possible.
3358  The long parameter gives the current scheduled time for event.
3359 \end_layout
3361 \begin_layout Section
3362 Writing modules
3363 \end_layout
3365 \begin_layout Standard
3366 Modules are various extensions that run inside emulator core.
3367  As such, they affect sync.
3368  Modules must implement interface org.jpc.emulator.HardwareComponent (they
3369  are hardware components) and must be dumpable.
3370  Additionally, they need either constructor <init>() or <init>(String).
3371  The first is if no parameters are passed, the second is for case where
3372  parameters are passed.
3373 \end_layout
3375 \begin_layout Standard
3376 Aside of the constructors, modules need to obey the ordinary conventions
3377  for hardware components.
3378  No code outside modules needs to know that module exists.
3379 \end_layout
3381 \begin_layout Section
3382 Writing plugins
3383 \end_layout
3385 \begin_layout Standard
3386 Plugins handle various UI tasks.
3387  They need to implement interface org.jpc.Plugin.
3388 \end_layout
3390 \begin_layout Subsection
3391 Interface org.jpc.pluginsbase.Plugin
3392 \end_layout
3394 \begin_layout Subsubsection
3395 Method systemShutdown()
3396 \end_layout
3398 \begin_layout Standard
3399 Called when emulator shuts down.
3400  Either called in dedicated thread or in thread that called emulatorShutdown().
3401  These handlers should do the bare minimum to get files on disk to consistent
3402  state.
3403  After these calls from all plugins have finished, emulator exits.
3404  Do not try to manipulate UI from these methods, as doing that easily leads
3405  into deadlock.
3406 \end_layout
3408 \begin_layout Subsubsection
3409 Method reconnect(PC) 
3410 \end_layout
3412 \begin_layout Standard
3413 Gives new PC to connect to.
3414  Null is passed if plugin should disconnect.
3415 \end_layout
3417 \begin_layout Subsubsection
3418 Method main()
3419 \end_layout
3421 \begin_layout Standard
3422 Called in dedicated thread after plugin is initialized.
3423 \end_layout
3425 \begin_layout Subsubsection
3426 Method pcStopping()
3427 \end_layout
3429 \begin_layout Standard
3430 Called after PC has stopped.
3431 \end_layout
3433 \begin_layout Subsubsection
3434 Method pcStarting()
3435 \end_layout
3437 \begin_layout Standard
3438 Called before PC starts.
3439 \end_layout
3441 \begin_layout Subsubsection
3442 Method notifyArguments(String[])
3443 \end_layout
3445 \begin_layout Standard
3446 Pass arguments from command line.
3447 \end_layout
3449 \begin_layout Subsubsection
3450 Constructor <init>(Plugins)
3451 \end_layout
3453 \begin_layout Standard
3454 This constructor is used to initialize plugins that don't take parameters.
3455 \end_layout
3457 \begin_layout Subsubsection
3458 Constructor <init>(Plugins, String)
3459 \end_layout
3461 \begin_layout Standard
3462 This constructor is used to initialize plugins that take parameters.
3463 \end_layout
3465 \begin_layout Subsection
3466 Class org.jpc.pluginsbase.Plugins
3467 \end_layout
3469 \begin_layout Standard
3470 This class provodes various methods for manipulating plugins.
3471 \end_layout
3473 \begin_layout Subsubsection
3474 Method isShuttingDown()
3475 \end_layout
3477 \begin_layout Standard
3478 Returns true if Plugins.shutdownEmulator() has been called somehow, either
3479  via VM exit, CTRL+C or explicitly.
3480  Useful to skip cleanups involving GUI, as these are too deadlock-prone.
3481 \end_layout
3483 \begin_layout Subsubsection
3484 Method shutdownEmulator()
3485 \end_layout
3487 \begin_layout Standard
3488 Shut down and exit the emulator.
3489  All plugin shutdown functions are called in this thread.
3490 \end_layout
3492 \begin_layout Subsubsection
3493 Method reconnectPC(PC)
3494 \end_layout
3496 \begin_layout Standard
3497 Signal reconnectPC event to all plugins.
3498 \end_layout
3500 \begin_layout Subsubsection
3501 Method pcStarted()
3502 \end_layout
3504 \begin_layout Standard
3505 Signal pcStarting() event to all plugins.
3506 \end_layout
3508 \begin_layout Subsubsection
3509 Method pcStopped()
3510 \end_layout
3512 \begin_layout Standard
3513 Signal pcStopping() event to all plugins.
3514 \end_layout
3516 \begin_layout Subsection
3517 Interface org.jpc.pluginsbase.ExternalCommandInterface
3518 \end_layout
3520 \begin_layout Standard
3521 Implementing interface org.jpc.pluginsbase.ExternalCommandInterface signals
3522  that plugin can receive commands via external commands interface.
3523 \end_layout
3525 \begin_layout Subsubsection
3526 Method invokeCommand(String cmd, String[] args)
3527 \end_layout
3529 \begin_layout Standard
3530 Invoke specified command using specified arguments.
3531  Return true if event is to be shallowed, false to continue trying to pass
3532  it to more plugins.
3533 \end_layout
3535 \begin_layout Section
3536 Lua kernel programming
3537 \end_layout
3539 \begin_layout Standard
3540 At startup, kernel gets its arguments in 'args' table and the script name
3541  to run in 'scriptname' string.
3542  It should enter the named script in protected mode.
3543 \end_layout
3545 \begin_layout Standard
3546 The Lua VM exports numerious callbacks to kernel.
3547  The kernel can then choose to omit, wrap or re-export these to Lua scripts.
3548 \end_layout
3550 \begin_layout Itemize
3551 Always grab any functions used into local variables so nobody can mess with
3552  them
3553 \end_layout
3555 \begin_layout Itemize
3556 Don't use global variables in kernel (except for those passed).
3557 \end_layout
3559 \end_body
3560 \end_document