Fix serious bugs in dump to PCM converter
[jpcrr.git] / manual.lyx
blob712e8b0ccd8be657896c21ed14e3ea6acae5fd02
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, 8 bytes each.
1067  Each record has three fields.
1068  First 4 byte unsinged little endian timedelta value (in nanoseconds), then
1069  2 byte unsigned little endian new left channel volume, then 2 byte unsigned
1070  little endian new right channel volume.
1071  Optionally 'offset' can be set to positive value (in nanoseconds) to delay
1072  the audio by.
1073 \end_layout
1075 \begin_layout Subsubsection
1076 plugin: org.jpc.plugins.LuaPlugin
1077 \end_layout
1079 \begin_layout Standard
1080 Takes 'kernel=<name of lua kernel file>', other parameters are passed to
1081  kernel, requires and uses GUI.
1082 \end_layout
1084 \begin_layout Standard
1085 Lua VM for executing scripts.
1086 \end_layout
1088 \begin_layout Section
1089 Some error messages and explanations
1090 \end_layout
1092 \begin_layout Itemize
1093 <filename> is Not a valid image file
1094 \end_layout
1096 \begin_layout Itemize
1097 <filename> is not image file
1098 \end_layout
1100 \begin_layout Itemize
1101 <filename> claims to be floppy with illegal geometry: <x> tracks, <y> sides
1102  and <z> sectors.
1103 \end_layout
1105 \begin_layout Itemize
1106 <filename> claims to be HDD with illegal geometry: <x> tracks, <y> sides
1107  and <z> sectors.
1108 \end_layout
1110 \begin_layout Itemize
1111 Can't read disk image sector map.
1112 \end_layout
1114 \begin_layout Itemize
1115 Can't read disk image extent.
1116 \end_layout
1118 \begin_layout Standard
1119 Code expects <filename> to be valid JPC-RR format image, but it isn't JPC-RR
1120  image at all or its corrupt.
1121 \end_layout
1123 \begin_layout Itemize
1124 <filename> is image of unknown type.
1125 \end_layout
1127 \begin_layout Itemize
1128 <filename> has unrecognized geometry <x> <y> <z>
1129 \end_layout
1131 \begin_layout Standard
1132 Possibly corrupt image, not JPC-RR image, or JPC-RR image from future version
1133  containing something current version can't comprehend.
1134 \end_layout
1136 \begin_layout Itemize
1137 Invalid format specifier <something>.
1138 \end_layout
1140 \begin_layout Itemize
1141 Invalid syntax of --floppy= or --HDD= option.
1142 \end_layout
1144 \begin_layout Itemize
1145 Invalid format specifier/option <something>.
1146 \end_layout
1148 \begin_layout Standard
1149 Invalid option or format specifier was given.
1150  Check for typos.
1151 \end_layout
1153 \begin_layout Itemize
1154 java ImageMaker [<options>...] <format> <destination> <source> <diskname>
1155 \end_layout
1157 \begin_layout Standard
1158 Check syntax of command.
1159  Especially that diskname is present!
1160 \end_layout
1162 \begin_layout Itemize
1163 The image has <nnn> sectors while it should have <yyy> according to selected
1164  geometry.
1165 \end_layout
1167 \begin_layout Itemize
1168 Raw image file length not divisible by 512.
1169 \end_layout
1171 \begin_layout Itemize
1172 Trying to read sector out of range.
1173 \end_layout
1175 \begin_layout Standard
1176 The selected geometry is wrong or raw image is incomplete.
1177 \end_layout
1179 \begin_layout Itemize
1180 Invalid disk name (Should not happen!).
1181 \end_layout
1183 \begin_layout Itemize
1184 Invalid geometry to be written.
1185 \end_layout
1187 \begin_layout Standard
1188 This is a very likely a bug in program.
1189 \end_layout
1191 \begin_layout Itemize
1192 What the heck <filename> is? It's not regular file nor directory.
1193 \end_layout
1195 \begin_layout Standard
1196 That sort of file can't be used as input for image making, or the file just
1197  doesn't exist.
1198 \end_layout
1200 \begin_layout Itemize
1201 BIOS images can only be made out of regular files.
1202 \end_layout
1204 \begin_layout Itemize
1205 CD images can only be made out of regular files.
1206 \end_layout
1208 \begin_layout Standard
1209 Source image specified is not regular file, but image of that type can't
1210  be made of anything else.
1211 \end_layout
1213 \begin_layout Itemize
1214 Can't read raw bios image file.
1215 \end_layout
1217 \begin_layout Itemize
1218 Can't read sector <nnn> from image.
1219 \end_layout
1221 \begin_layout Standard
1222 Reading the raw image file failed for some reason.
1223 \end_layout
1225 \begin_layout Itemize
1226 Bad library line: "<something>".
1227  Ignored.
1228 \end_layout
1230 \begin_layout Standard
1231 Syntax error in image library.
1232 \end_layout
1234 \begin_layout Itemize
1235 Removing image <something> a.k.a.
1236  "<something>" as it no longer exists.
1237 \end_layout
1239 \begin_layout Standard
1240 The image file no longer exists so it gets removed from library.
1241 \end_layout
1243 \begin_layout Itemize
1244 Removing image <something> a.k.a.
1245  "<something>" due to <some> conflict.
1246 \end_layout
1248 \begin_layout Standard
1249 Image library code killed some image from library due to some kind of conflict
1250  with image being added.
1251 \end_layout
1253 \begin_layout Itemize
1254 Too much data to fit into given space.
1255 \end_layout
1257 \begin_layout Standard
1258 The tree you gave contains takes just too much space to fit into disk of
1259  this size.
1260 \end_layout
1262 \begin_layout Section
1263 Advanced: Savestate/movie format
1264 \end_layout
1266 \begin_layout Subsection
1267 JRSR archive
1268 \end_layout
1270 \begin_layout Standard
1271 JRSR archive format packs multiple text archive members to text archive.
1272  It does not support binary members.
1273  JRSR archives have first five bytes form the magic.
1274  It is 
1275 \begin_inset Quotes eld
1276 \end_inset
1278 JRSR
1279 \begin_inset Quotes erd
1280 \end_inset
1282  followed by LINEFEED character (0x0A, 0x0D, 0x0D 0x0A, 0xC2 0x85).
1283  There are three kinds of lines after that (lines are terminated by LINEFEED
1284  character):
1285 \end_layout
1287 \begin_layout Itemize
1288 Start member
1289 \end_layout
1291 \begin_layout Itemize
1292 Member line
1293 \end_layout
1295 \begin_layout Itemize
1296 End member
1297 \end_layout
1299 \begin_layout Standard
1300 Sequencing rules are as follows: Start member is allowed anywhere.
1301  Member line is allowed only inside member (member started but not ended).
1302  End member is only allowed inside member.
1303  End of file is only allowed outside member.
1304  Note that those three are all the kinds of lines allowed.
1305 \end_layout
1307 \begin_layout Subsubsection
1308 Start member
1309 \end_layout
1311 \begin_layout Standard
1312 Start member line is given as 
1313 \begin_inset Quotes eld
1314 \end_inset
1316 !BEGIN
1317 \begin_inset Quotes erd
1318 \end_inset
1320  <SPACE> <membername> <LINEFEED>.
1321  <SPACE> is SPACE character (only one!, 0x20) and <LINEFEED> is LINEFEED
1322  chacter.
1323  Multiple <SPACE>s would mean member with name beginning with <SPACE>.
1324  The member name is UTF-8 encoded and maximum allowed length is 1024 bytes
1325  (256-1024 codepoints).
1326  Starting member inside another implicitly ends the previous member.
1327 \end_layout
1329 \begin_layout Subsubsection
1330 Member line:
1331 \end_layout
1333 \begin_layout Standard
1334 Member line is given as 
1335 \begin_inset Quotes eld
1336 \end_inset
1339 \begin_inset Quotes erd
1340 \end_inset
1342 <content><LINEFEED>.
1343  It gives another line for member contents.
1344  <content> is passed raw to layers above.
1345 \end_layout
1347 \begin_layout Subsubsection
1348 End member
1349 \end_layout
1351 \begin_layout Standard
1352 End member line is given as 
1353 \begin_inset Quotes eld
1354 \end_inset
1356 !END
1357 \begin_inset Quotes erd
1358 \end_inset
1360 <LINEFEED>.
1361  It ends the current member.
1362  The following line can only be start member line or file may end.
1363 \end_layout
1365 \begin_layout Subsection
1366 Four-to-Five encoding
1367 \end_layout
1369 \begin_layout Standard
1370 Binary members are encoded into text by so-called four-to-five encoding.
1371  This encoding can encode single byte to two, two bytes to three, three
1372  bytes to four and four bytes to five.
1373  Four-to-five encoding has five kinds of blocks.
1374  All SPACE and CHARACTER TABULATION characters are completely ignored, even
1375  in middle of blocks.
1376 \end_layout
1378 \begin_layout Subsubsection
1379 End stream block
1380 \end_layout
1382 \begin_layout Standard
1383 End stream block is encoded as '!'.
1384  It ends the stream instantly.
1385  There is also implicit end of stream at end of input to decoding.
1386 \end_layout
1388 \begin_layout Subsubsection
1389 Other four block types
1390 \end_layout
1392 \begin_layout Standard
1393 Other four block types take the value to be encoded, read it as big-endian
1394  value.
1395  Then they write it as base-93 big-endian value.
1396  Then length specific constants are added to digits of that number to yield
1397  ASCII values for characters (those are stored in order):
1398 \end_layout
1400 \begin_layout Standard
1401 \begin_inset Tabular
1402 <lyxtabular version="3" rows="5" columns="6">
1403 <features>
1404 <column alignment="center" valignment="top" width="0">
1405 <column alignment="center" valignment="top" width="0">
1406 <column alignment="center" valignment="top" width="0">
1407 <column alignment="center" valignment="top" width="0">
1408 <column alignment="center" valignment="top" width="0">
1409 <column alignment="center" valignment="top" width="0">
1410 <row>
1411 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1412 \begin_inset Text
1414 \begin_layout Plain Layout
1415 To encode
1416 \end_layout
1418 \end_inset
1419 </cell>
1420 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1421 \begin_inset Text
1423 \begin_layout Plain Layout
1424 1st char.
1425 \end_layout
1427 \end_inset
1428 </cell>
1429 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1430 \begin_inset Text
1432 \begin_layout Plain Layout
1433 2nd char.
1434 \end_layout
1436 \end_inset
1437 </cell>
1438 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1439 \begin_inset Text
1441 \begin_layout Plain Layout
1442 3rd char.
1443 \end_layout
1445 \end_inset
1446 </cell>
1447 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1448 \begin_inset Text
1450 \begin_layout Plain Layout
1451 4th char.
1452 \end_layout
1454 \end_inset
1455 </cell>
1456 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1457 \begin_inset Text
1459 \begin_layout Plain Layout
1460 5th char.
1461 \end_layout
1463 \end_inset
1464 </cell>
1465 </row>
1466 <row>
1467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1468 \begin_inset Text
1470 \begin_layout Plain Layout
1471 1 byte
1472 \end_layout
1474 \end_inset
1475 </cell>
1476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1477 \begin_inset Text
1479 \begin_layout Plain Layout
1481 \end_layout
1483 \end_inset
1484 </cell>
1485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1486 \begin_inset Text
1488 \begin_layout Plain Layout
1490 \end_layout
1492 \end_inset
1493 </cell>
1494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1495 \begin_inset Text
1497 \begin_layout Plain Layout
1499 \end_layout
1501 \end_inset
1502 </cell>
1503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1504 \begin_inset Text
1506 \begin_layout Plain Layout
1508 \end_layout
1510 \end_inset
1511 </cell>
1512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1513 \begin_inset Text
1515 \begin_layout Plain Layout
1517 \end_layout
1519 \end_inset
1520 </cell>
1521 </row>
1522 <row>
1523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1524 \begin_inset Text
1526 \begin_layout Plain Layout
1527 2 bytes
1528 \end_layout
1530 \end_inset
1531 </cell>
1532 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1533 \begin_inset Text
1535 \begin_layout Plain Layout
1537 \end_layout
1539 \end_inset
1540 </cell>
1541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1542 \begin_inset Text
1544 \begin_layout Plain Layout
1546 \end_layout
1548 \end_inset
1549 </cell>
1550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1551 \begin_inset Text
1553 \begin_layout Plain Layout
1555 \end_layout
1557 \end_inset
1558 </cell>
1559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1560 \begin_inset Text
1562 \begin_layout Plain Layout
1564 \end_layout
1566 \end_inset
1567 </cell>
1568 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1569 \begin_inset Text
1571 \begin_layout Plain Layout
1573 \end_layout
1575 \end_inset
1576 </cell>
1577 </row>
1578 <row>
1579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1580 \begin_inset Text
1582 \begin_layout Plain Layout
1583 3 bytes
1584 \end_layout
1586 \end_inset
1587 </cell>
1588 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1589 \begin_inset Text
1591 \begin_layout Plain Layout
1593 \end_layout
1595 \end_inset
1596 </cell>
1597 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1598 \begin_inset Text
1600 \begin_layout Plain Layout
1602 \end_layout
1604 \end_inset
1605 </cell>
1606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1607 \begin_inset Text
1609 \begin_layout Plain Layout
1611 \end_layout
1613 \end_inset
1614 </cell>
1615 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1616 \begin_inset Text
1618 \begin_layout Plain Layout
1620 \end_layout
1622 \end_inset
1623 </cell>
1624 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1625 \begin_inset Text
1627 \begin_layout Plain Layout
1629 \end_layout
1631 \end_inset
1632 </cell>
1633 </row>
1634 <row>
1635 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1636 \begin_inset Text
1638 \begin_layout Plain Layout
1639 4 bytes
1640 \end_layout
1642 \end_inset
1643 </cell>
1644 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1645 \begin_inset Text
1647 \begin_layout Plain Layout
1649 \end_layout
1651 \end_inset
1652 </cell>
1653 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1654 \begin_inset Text
1656 \begin_layout Plain Layout
1658 \end_layout
1660 \end_inset
1661 </cell>
1662 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1663 \begin_inset Text
1665 \begin_layout Plain Layout
1667 \end_layout
1669 \end_inset
1670 </cell>
1671 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
1672 \begin_inset Text
1674 \begin_layout Plain Layout
1676 \end_layout
1678 \end_inset
1679 </cell>
1680 <cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
1681 \begin_inset Text
1683 \begin_layout Plain Layout
1685 \end_layout
1687 \end_inset
1688 </cell>
1689 </row>
1690 </lyxtabular>
1692 \end_inset
1695 \end_layout
1697 \begin_layout Standard
1698 Blocks which encode values greater than what is possible for value of that
1699  length are fatal errors.
1701 \end_layout
1703 \begin_layout Subsection
1704 UTF-8 encoding
1705 \end_layout
1707 \begin_layout Standard
1708 UTF-8 encoding is used to encode lines of Unicode codepoints into bytes.
1709 \end_layout
1711 \begin_layout Subsection
1712 Line component encoing
1713 \end_layout
1715 \begin_layout Standard
1716 Line component encoding sits on top of UTF-8 encoding.
1717  Line component encoding encodes non-empty 1-D array of non-empty strings
1718  into line, and thus array of those into member.
1719  Empty lines or lines that don't contain any components are ignored.
1720  Line starts with depth value of 0 and must end with depth value of zero.
1721 \end_layout
1723 \begin_layout Standard
1724 Components are seperated by component separators.
1725  Empty components are ignored.
1726  Following codepoints are separators on depth 0 if not escaped:
1727 \end_layout
1729 \begin_layout Itemize
1730 Codepoint of '('.
1731  The depth is read pre-increment.
1732 \end_layout
1734 \begin_layout Itemize
1735 Codepoint of ')'.
1736  The depth is read post-decrement.
1737 \end_layout
1739 \begin_layout Itemize
1740 Codepoints 0x20, and 0x09.
1741 \end_layout
1743 \begin_layout Itemize
1744 Codepoints 0x1680, 0x180E, 0x2028, 0x205F and 0x3000
1745 \end_layout
1747 \begin_layout Itemize
1748 Codepoints 0x2000-0x200A.
1749 \end_layout
1751 \begin_layout Standard
1752 The following characters are special:
1753 \end_layout
1755 \begin_layout Itemize
1756 '('.
1757  Increments depth by 1 if not escaped (and appears in component).
1758 \end_layout
1760 \begin_layout Itemize
1761 ')'.
1762  Decrements depth by 1 if not escaped (and appears in component).
1763  Depth going negative is an error.
1764 \end_layout
1766 \begin_layout Itemize
1768 \backslash
1770  Next character is interpretted as literal.
1771  Error if at end of line.
1772 \end_layout
1774 \begin_layout Standard
1775 Otherwise, characters are interpretted as literals and appear in components.
1776  Depth must be zero at end of line.
1777 \end_layout
1779 \begin_layout Subsection
1780 Header section:
1781 \end_layout
1783 \begin_layout Standard
1784 Header section is in archive member "header".
1785  It uses line component encoding.
1786  The first component of each line is name of header, and subsequent ones
1787  are arguments.
1788  How many parameters are expected is dependent on what header it is:
1789 \end_layout
1791 \begin_layout Subsubsection
1792 PROJECTID header:
1793 \end_layout
1795 \begin_layout Itemize
1796 Header name: "PROJECTID"
1797 \end_layout
1799 \begin_layout Itemize
1800 Components: 2
1801 \end_layout
1803 \begin_layout Itemize
1804 Argument #1: <project-id-string>
1805 \end_layout
1807 \begin_layout Itemize
1808 Mandatory: Yes
1809 \end_layout
1811 \begin_layout Standard
1812 Gives project ID.
1813  Project ID is generated when PC is assembled and is then preserved in save
1814  states.
1815  It is used for computing rerecord counts.
1816  Emulator treats it as opaque string, the IDs it generates are formed by
1817  48 random hexadecimal digits.
1818 \end_layout
1820 \begin_layout Subsubsection
1821 SAVESTATEID header:
1822 \end_layout
1824 \begin_layout Itemize
1825 Header name: "SAVESTATEID"
1826 \end_layout
1828 \begin_layout Itemize
1829 Components: 2
1830 \end_layout
1832 \begin_layout Itemize
1833 Argument #1: <savestate-id-string>
1834 \end_layout
1836 \begin_layout Itemize
1837 Mandatory: No
1838 \end_layout
1840 \begin_layout Standard
1841 Gives save state ID.
1842  Each save state has its own save state ID.
1843  Treated as opaque string, but generated as 48 random hexadecimal digits.
1844  The presence of this header signals whether there is save state to be loaded.
1845  If this header is present, save state load will be attempted.
1846  If absent, save state is not to be loaded even if present (and correct
1847  savestate load would be technically impossible anyway).
1848 \end_layout
1850 \begin_layout Standard
1851 The value is used to prevent loading incompatible save states in preserve
1852  event stream mode and also to find the point in event stream where one
1853  left off.
1854 \end_layout
1856 \begin_layout Subsubsection
1857 RERECORDS header:
1858 \end_layout
1860 \begin_layout Itemize
1861 Header name: "RERECORDS"
1862 \end_layout
1864 \begin_layout Itemize
1865 Components: 2
1866 \end_layout
1868 \begin_layout Itemize
1869 Argument #1: <rerecords>
1870 \end_layout
1872 \begin_layout Itemize
1873 Mandatory: Yes
1874 \end_layout
1876 \begin_layout Standard
1877 Gives rerecord count.
1878  PC assembly (except when loading save state) initializes current rerecord
1879  count to zero.
1880  Must be non-negative and decimal number using ASCII digit characters.
1881 \end_layout
1883 \begin_layout LyX-Code
1884 On loading save state:
1885 \end_layout
1887 \begin_layout LyX-Code
1888 1) If project ID matches with previous:
1889 \end_layout
1891 \begin_layout LyX-Code
1892 1a) If loaded rerecord count is larger or equal to current rerecord count:
1893 \end_layout
1895 \begin_layout LyX-Code
1896 1a-a) Current rerecord count is loaded rerecord count + 1.
1897 \end_layout
1899 \begin_layout LyX-Code
1900 1b) Otherwise
1901 \end_layout
1903 \begin_layout LyX-Code
1904 1b-a) Current rerecord count increments by 1.
1905 \end_layout
1907 \begin_layout LyX-Code
1908 2) Otherwise
1909 \end_layout
1911 \begin_layout LyX-Code
1912 2a) Current rerecord count is loaded rerecord count + 1.
1913 \end_layout
1915 \begin_layout Standard
1916 The current rerecord count at time of save is saved to save state.
1917 \end_layout
1919 \begin_layout Subsubsection
1920 AUTHORS header:
1921 \end_layout
1923 \begin_layout Itemize
1924 Header name: "AUTHORS"
1925 \end_layout
1927 \begin_layout Itemize
1928 Components: 2 or more
1929 \end_layout
1931 \begin_layout Itemize
1932 Arguments: free form
1933 \end_layout
1935 \begin_layout Itemize
1936 Mandatory: No
1937 \end_layout
1939 \begin_layout Standard
1940 Gives authors of run.
1941  Each argument gives one author.
1942  May be present multiple times.
1943 \end_layout
1945 \begin_layout Subsubsection
1946 COMMENT header:
1947 \end_layout
1949 \begin_layout Itemize
1950 Header name: "COMMENT"
1951 \end_layout
1953 \begin_layout Itemize
1954 Components: 2 or more
1955 \end_layout
1957 \begin_layout Itemize
1958 Arguments: free form
1959 \end_layout
1961 \begin_layout Itemize
1962 Mandatory: No
1963 \end_layout
1965 \begin_layout Standard
1966 Various kinds of free form data.
1967  Not parsed further by emulator.
1968 \end_layout
1970 \begin_layout Subsection
1971 Initialization segment:
1972 \end_layout
1974 \begin_layout Standard
1975 If SAVESTATEID header isn't present (not a save state), member "initialization"
1976  gives PC initialization parameters for assembling the PC.
1977  It is present anyway even if SAVESTATEID is present (savestate).
1978 \end_layout
1980 \begin_layout Standard
1981 Following parameters are used (space separates components):
1982 \end_layout
1984 \begin_layout LyX-Code
1985 "BIOS" <id>
1986 \end_layout
1988 \begin_layout Standard
1989 Gives Image ID of main system BIOS (mandatory)
1990 \end_layout
1992 \begin_layout LyX-Code
1993 "VGABIOS" <id>
1994 \end_layout
1996 \begin_layout Standard
1997 Gives Image ID of VGA BIOS (mandatory).
1998 \end_layout
2000 \begin_layout LyX-Code
2001 "HDA" <id>
2002 \end_layout
2004 \begin_layout Standard
2005 Gives Image ID of hda.
2006  Present only if system has hard disk hda.
2007 \end_layout
2009 \begin_layout LyX-Code
2010 "HDB" <id>
2011 \end_layout
2013 \begin_layout Standard
2014 Gives Image ID of hdb.
2015  Present only if system has hard disk hdb.
2016 \end_layout
2018 \begin_layout LyX-Code
2019 "HDC" <id>
2020 \end_layout
2022 \begin_layout Standard
2023 Gives Image ID of hdc.
2024  Present only if system has hard disk hdc.
2025 \end_layout
2027 \begin_layout LyX-Code
2028 "HDD" <id>
2029 \end_layout
2031 \begin_layout Standard
2032 Gives Image ID of hdd.
2033  Present only if system has hard disk hdd.
2034 \end_layout
2036 \begin_layout LyX-Code
2037 "DISK" <num> <id>
2038 \end_layout
2040 \begin_layout Standard
2041 Gives Image ID of disk in slot <num>.
2042  Slot number must be non-negative.
2043 \end_layout
2045 \begin_layout LyX-Code
2046 \begin_inset Quotes eld
2047 \end_inset
2049 DISKNAME
2050 \begin_inset Quotes erd
2051 \end_inset
2053  <num> <name>
2054 \end_layout
2056 \begin_layout Standard
2057 Gives image name of disk in slot <num>.
2058  Slot number must be non-negative.
2059  The slot must be previously declared using 
2060 \begin_inset Quotes eld
2061 \end_inset
2063 DISK
2064 \begin_inset Quotes erd
2065 \end_inset
2068 \end_layout
2070 \begin_layout LyX-Code
2071 "FDA" <num>
2072 \end_layout
2074 \begin_layout Standard
2075 Gives Image slot to initially put into floppy drive fda.
2076  Disk must be of floppy type.
2077  If none present, no disk is initially put there.
2078 \end_layout
2080 \begin_layout LyX-Code
2081 "FDB" <num>
2082 \end_layout
2084 \begin_layout Standard
2085 Gives Image slot to initially put into floppy drive fdb.
2086  Disk must be of floppy type.
2087  If none present, no disk is initially put there.
2088 \end_layout
2090 \begin_layout LyX-Code
2091 "CDROM" <num>
2092 \end_layout
2094 \begin_layout Standard
2095 Gives Image slot to initially put into CD-ROM drive hdc.
2096  Not allowed if hard disk hdc is present.
2097  Disk must be of CD-ROM type.
2098  If none present no disk is initially put there.
2099 \end_layout
2101 \begin_layout LyX-Code
2102 "INITIALTIME" <time>
2103 \end_layout
2105 \begin_layout Standard
2106 Number of milliseconds since Unix epoch to system start up time.
2107  Allowed range:
2108 \end_layout
2110 \begin_layout Standard
2111 0-4102444799999.
2112  Mandatory.
2113 \end_layout
2115 \begin_layout LyX-Code
2116 "CPUDIVIDER" <divider>
2117 \end_layout
2119 \begin_layout Standard
2120 Set CPU frequency divider (dividing the 1GHz master clock).
2121  Allowed range is 1-256.
2122  Mandatory.
2123 \end_layout
2125 \begin_layout LyX-Code
2126 "MEMORYSIZE" <pages>
2127 \end_layout
2129 \begin_layout Standard
2130 Number of 4KiB pages of RAM memory.
2131  Allowed range 256-262144.
2132  Mandatory.
2133 \end_layout
2135 \begin_layout LyX-Code
2136 "BOOT" <device>
2137 \end_layout
2139 \begin_layout Standard
2140 Set boot device.
2141  Valid devices are "FLOPPY" (boot from fda), "HDD" (boot from hda) and "CDROM"
2142  (boot from CD).
2143 \end_layout
2145 \begin_layout LyX-Code
2146 "LOADMODULEA" <module> <parameters>
2147 \end_layout
2149 \begin_layout Standard
2150 Load module <module> with parameters <parameters>.
2151 \end_layout
2153 \begin_layout LyX-Code
2154 "LOADMODULE" <module>
2155 \end_layout
2157 \begin_layout Standard
2158 Load module <module> with no parameters
2159 \end_layout
2161 \begin_layout LyX-Code
2162 \begin_inset Quotes eld
2163 \end_inset
2166 \begin_inset Quotes erd
2167 \end_inset
2169  <fpu>
2170 \end_layout
2172 \begin_layout Standard
2173 Use class <fpu> as FPU emulator.
2174 \end_layout
2176 \begin_layout Subsection
2177 Event record format:
2178 \end_layout
2180 \begin_layout Standard
2181 Event record is in archive member "events".
2182  It uses line component encoding.
2183  Each line gives an event.
2184  First component of each line gives time stamp.
2185  These timestamps MUST be in increasing order and all MUST be non-negative.
2186  Time stamp time unit is exactly 1 nanosecond of emulated time.
2187 \end_layout
2189 \begin_layout Standard
2190 The second component of each line is name of class to dispatch to.
2191  Further components are passed as-is to event handlers.
2192  "Class" name "SAVESTATE" is special.
2193  This takes one or two additional components, first of which gives the save
2194  state ID of save state that occurred there.
2195  The save state IDs MUST be unique in entire event stream.
2196  The second argument to savestate (if present) is rerecord count at time
2197  of saving that savestate (useful for calulating rerecord count of movie
2198  starting from savestate).
2199 \end_layout
2201 \begin_layout Subsubsection
2202 Keyboard keypress/keyrelease event:
2203 \end_layout
2205 \begin_layout Itemize
2206 Dispatch to: org.jpc.emulator.peripheral.Keyboard
2207 \end_layout
2209 \begin_layout Itemize
2210 Argument #1: Fixed: "KEYEDGE"
2211 \end_layout
2213 \begin_layout Itemize
2214 Argument #2: Key number.
2215  Valid values are 1-83, 85-95, 129-197 and 199-223
2216 \end_layout
2218 \begin_layout Standard
2219 Send key press or key release.
2220  Keys work in toggle button manner.
2221  The event time must be multiple of 66 666, and must not be less than 60
2222  * 66 666 TUs after last PAUSE event, 20 * 66 666 TUs after last KEYEDGE
2223  on key >128 and 10 * 66 666 TUs after last KEYEDGE on key <128.
2224 \end_layout
2226 \begin_layout Subsubsection
2227 Pause event:
2228 \end_layout
2230 \begin_layout Itemize
2231 Dispatch to: org.jpc.emulator.peripheral.Keyboard
2232 \end_layout
2234 \begin_layout Itemize
2235 Argument #1: Fixed: "PAUSE"
2236 \end_layout
2238 \begin_layout Standard
2239 Send pause key event.
2240  The time restrictions are identical to KEYEDGE event.
2241 \end_layout
2243 \begin_layout Subsubsection
2244 Joystick button event:
2245 \end_layout
2247 \begin_layout Itemize
2248 Dispatch to: org.jpc.modules.Joystick
2249 \end_layout
2251 \begin_layout Itemize
2252 Argument #1: 
2253 \begin_inset Quotes eld
2254 \end_inset
2256 BUTTONA
2257 \begin_inset Quotes erd
2258 \end_inset
2261 \begin_inset Quotes eld
2262 \end_inset
2264 BUTTONB
2265 \begin_inset Quotes erd
2266 \end_inset
2269 \begin_inset Quotes eld
2270 \end_inset
2272 BUTTONC
2273 \begin_inset Quotes erd
2274 \end_inset
2276  or 
2277 \begin_inset Quotes eld
2278 \end_inset
2280 BUTTOND
2281 \begin_inset Quotes erd
2282 \end_inset
2285 \end_layout
2287 \begin_layout Itemize
2288 Argument #2: 
2289 \begin_inset Quotes eld
2290 \end_inset
2293 \begin_inset Quotes erd
2294 \end_inset
2296  if released, 
2297 \begin_inset Quotes eld
2298 \end_inset
2301 \begin_inset Quotes erd
2302 \end_inset
2304  if pressed
2305 \end_layout
2307 \begin_layout Standard
2308 Send button down/up event.
2309  No time restrictions.
2310 \end_layout
2312 \begin_layout Subsubsection
2313 Joystick axis event:
2314 \end_layout
2316 \begin_layout Itemize
2317 Dispatch to: org.jpc.modules.Joystick
2318 \end_layout
2320 \begin_layout Itemize
2321 Argument #1: 
2322 \begin_inset Quotes eld
2323 \end_inset
2325 AXISA
2326 \begin_inset Quotes erd
2327 \end_inset
2330 \begin_inset Quotes eld
2331 \end_inset
2333 AXISB
2334 \begin_inset Quotes erd
2335 \end_inset
2338 \begin_inset Quotes eld
2339 \end_inset
2341 AXISC
2342 \begin_inset Quotes erd
2343 \end_inset
2345  or 
2346 \begin_inset Quotes eld
2347 \end_inset
2349 AXISD
2350 \begin_inset Quotes erd
2351 \end_inset
2354 \end_layout
2356 \begin_layout Itemize
2357 Argument #2: Multivibrator unstable state length in ns.
2358 \end_layout
2360 \begin_layout Standard
2361 Set amount of time multivibrator remains in unstable state.
2362  No time restrictions.
2363 \end_layout
2365 \begin_layout Subsubsection
2366 Reboot:
2367 \end_layout
2369 \begin_layout Itemize
2370 Dispatch to: org.jpc.emulator.PC$ResetButton
2371 \end_layout
2373 \begin_layout Itemize
2374 No arguments
2375 \end_layout
2377 \begin_layout Standard
2378 Reboots the PC.
2379 \end_layout
2381 \begin_layout Subsubsection
2382 Fda disk change:
2383 \end_layout
2385 \begin_layout Itemize
2386 Dispatch to: org.jpc.emulator.PC$DiskChanger
2387 \end_layout
2389 \begin_layout Itemize
2390 Argument #1: Fixed: "FDA"
2391 \end_layout
2393 \begin_layout Itemize
2394 Argument #2: Number of image slot to put there.
2396 \end_layout
2398 \begin_layout Standard
2399 The disk number MUST be -1 or valid disk number.
2400  -1 MUST NOT be used if there is no disk in floppy drive A.
2401  This event causes specified disk to be placed to FDA or FDA disk to be
2402  ejected with no replacement if disk number is -1.
2403  The specified disk if not -1 must be of floppy type.
2404  The specified disk if valid must not be in any other drive.
2405 \end_layout
2407 \begin_layout Subsubsection
2408 Fdb disk change:
2409 \end_layout
2411 \begin_layout Itemize
2412 Dispatch to: org.jpc.emulator.PC$DiskChanger
2413 \end_layout
2415 \begin_layout Itemize
2416 Argument #1: Fixed: "FDB"
2417 \end_layout
2419 \begin_layout Itemize
2420 Argument #2: Number of image slot to put there.
2422 \end_layout
2424 \begin_layout Standard
2425 The disk number MUST be -1 or valid disk number.
2426  -1 MUST NOT be used if there is no disk in floppy drive B.
2427  This event causes specified disk to be placed to FDB or FDB disk to be
2428  ejected with no replacement if disk number is -1.
2429  The specified disk if not -1 must be of floppy type.
2430  The specified disk if valid must not be in any other drive.
2431 \end_layout
2433 \begin_layout Subsubsection
2434 Change CDROM:
2435 \end_layout
2437 \begin_layout Itemize
2438 Dispatch to: org.jpc.emulator.PC$DiskChanger
2439 \end_layout
2441 \begin_layout Itemize
2442 Argument #1: Fixed: "CDROM"
2443 \end_layout
2445 \begin_layout Itemize
2446 Argument #2: Number of image slot to put there.
2448 \end_layout
2450 \begin_layout Standard
2451 The disk number MUST be -1 or valid disk number.
2452  -1 MUST NOT be used if there is no disk in CD-ROM.
2453  This event causes specified disk to be placed to CD-ROM or CD-ROM disk
2454  to be ejected with no replacement if disk number is -1.
2455  The specified disk if not -1 must be of CD-ROM type.
2456 \end_layout
2458 \begin_layout Standard
2459 This event has no effect if CD-ROM is locked.
2460 \end_layout
2462 \begin_layout Subsubsection
2463 Write protect floppy:
2464 \end_layout
2466 \begin_layout Itemize
2467 Dispatch to: org.jpc.emulator.PC$DiskChanger
2468 \end_layout
2470 \begin_layout Itemize
2471 Argument #1: Fixed: "WRITEPROTECT"
2472 \end_layout
2474 \begin_layout Itemize
2475 Argument #2: Number of image slot to manipulate 
2476 \end_layout
2478 \begin_layout Standard
2479 Write protects specified disk.
2480  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2481 \end_layout
2483 \begin_layout Subsubsection
2484 Write unprotect floppy:
2485 \end_layout
2487 \begin_layout Itemize
2488 Dispatch to: org.jpc.emulator.PC$DiskChanger
2489 \end_layout
2491 \begin_layout Itemize
2492 Argument #1: Fixed: "WRITEUNPROTECT"
2493 \end_layout
2495 \begin_layout Itemize
2496 Argument #2: Number of image slot to manipulate 
2497 \end_layout
2499 \begin_layout Standard
2500 Disables write protection specified disk.
2501  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2502 \end_layout
2504 \begin_layout Subsection
2505 Savestates
2506 \end_layout
2508 \begin_layout Standard
2509 Actual savestate format is not documented here.
2510  It is close to impossible to comprehend without access to emulator source
2511  anyway.
2512 \end_layout
2514 \begin_layout Section
2515 Advanced: Making class dumpable
2516 \end_layout
2518 \begin_layout Standard
2519 Class is made dumpable by implementing interface org.jpc.emulator.SRDumpable
2520  and implementing method dumpSRPartial(org.jpc.emulator.SRDumper) and constructor
2521  <init>(org.jpc.emulator.SRLoader).
2522  Non-static inner classes can not be dumpable (make them static using tricks
2523  similar to what javac uses).
2524 \end_layout
2526 \begin_layout Standard
2527 If dumped class has dumpable superclass, the first thing dumping function
2528  needs to do is to call dumper function of superclass and first thing loading
2529  constructor needs to do is to call loading constructor of superclass.
2530  If class has no dumpable superclass, dumper doesn't need to do anything
2531  special, while loader needs to call objectCreated(this) on SRLoader object
2532  passed as parameter.
2534 \end_layout
2536 \begin_layout Standard
2537 Following these fixed parts, dump all members that are part of mutable state
2538  in emulator core.
2539 \end_layout
2541 \begin_layout Subsection
2542 Member dumping/loading functions
2543 \end_layout
2545 \begin_layout Standard
2546 There is dumping/loading function for following (all functions dumping/loading
2547  reference types can handle null):
2548 \end_layout
2550 \begin_layout Itemize
2551 boolean: SRDumper.dumpBoolean, SRLoader.loadBoolean
2552 \end_layout
2554 \begin_layout Itemize
2555 byte: SRDumper.dumpByte, SRLoader.loadByte
2556 \end_layout
2558 \begin_layout Itemize
2559 short: SRDumper.dumpShort, SRLoader.loadShort
2560 \end_layout
2562 \begin_layout Itemize
2563 int: SRDumper.dumpInt, SRLoader.loadInt
2564 \end_layout
2566 \begin_layout Itemize
2567 long: SRDumper.dumpLong, SRLoader.loadLong
2568 \end_layout
2570 \begin_layout Itemize
2571 String: SRDumper.dumpString, SRLoader.loadString
2572 \end_layout
2574 \begin_layout Itemize
2575 boolean[]: SRDumper.dumpArray, SRLoader.loadArrayBoolean
2576 \end_layout
2578 \begin_layout Itemize
2579 byte[]: SRDumper.dumpArray, SRLoader.loadArrayByte
2580 \end_layout
2582 \begin_layout Itemize
2583 short[]: SRDumper.dumpArray, SRLoader.loadArrayShort
2584 \end_layout
2586 \begin_layout Itemize
2587 int[]: SRDumper.dumpArray, SRLoader.loadArrayInt
2588 \end_layout
2590 \begin_layout Itemize
2591 long[]: SRDumper.dumpArray, SRLoader.loadArrayLong
2592 \end_layout
2594 \begin_layout Itemize
2595 double[]: SRDumper.dumpArray, SRLoader.loadArrayDouble
2596 \end_layout
2598 \begin_layout Itemize
2599 <dumpable type>: SRDumper.dumpObject, SRLoader.loadObject
2600 \end_layout
2602 \begin_layout Itemize
2603 special object: SRDumper.specialObject, SRLoader.specialObject
2604 \end_layout
2606 \begin_layout Subsubsection
2607 Notes:
2608 \end_layout
2610 \begin_layout Itemize
2611 Dumpable objects come out as type of org.jpc.emulator.SRDumpable.
2612 \end_layout
2614 \begin_layout Itemize
2615 Special objects are various static objects that don't need to be stored
2616  because they don't have mutable fields.
2617 \end_layout
2619 \begin_layout Itemize
2620 Don't dump fields related to event state feedback.
2621 \end_layout
2623 \begin_layout Itemize
2624 Don't dump temporary flags that are only used while PC is running.
2625  Savestate when PC is running isn't possible anyway.
2626 \end_layout
2628 \begin_layout Itemize
2629 Some connectors dump fields related to connector output, some don't.
2630 \end_layout
2632 \begin_layout Section
2633 Advanced: Making output connectors
2634 \end_layout
2636 \begin_layout Standard
2637 Implementing interface org.jpc.emulator.DisplayController signals that this
2638  is display controller, inhibiting loading of the standard VGA display controlle
2639 r if loaded as module.
2641 \end_layout
2643 \begin_layout Subsection
2644 Interface org.jpc.emulator.OutputConnector
2645 \end_layout
2647 \begin_layout Standard
2648 Class is made to be output connector by implementing this interface.
2649  This interface specifies the methods used for output hold locking.
2650  Class org.jpc.emulator.OutputConnectorLocking has implementations of these
2651  that are suitable for calling.
2653 \end_layout
2655 \begin_layout Subsubsection
2656 Method subscribeOutput(Object)
2657 \end_layout
2659 \begin_layout Standard
2660 Subscribes the output, with specified object as handle.
2661 \end_layout
2663 \begin_layout Subsubsection
2664 Method unsubscribeOutput(Object)
2665 \end_layout
2667 \begin_layout Standard
2668 Unsubscribe the specified handle object from output.
2669 \end_layout
2671 \begin_layout Subsubsection
2672 Method waitOutput(Object)
2673 \end_layout
2675 \begin_layout Standard
2676 Wait for output on specified connector using specified handle object.
2677  Returns true on success, false if wait was interrupted by thread interrupt.
2678  Blocking.
2679 \end_layout
2681 \begin_layout Subsubsection
2682 Method releaseOutput(Object)
2683 \end_layout
2685 \begin_layout Standard
2686 Release connector from p.o.v.
2687  of given handle.
2688  Does not block.
2689 \end_layout
2691 \begin_layout Subsubsection
2692 Method holdOutput()
2693 \end_layout
2695 \begin_layout Standard
2696 Release threads waiting on waitOutput() and block until all subscribers
2697  have returned from waitOutput() and enteired releaseOutput().
2698 \end_layout
2700 \begin_layout Subsubsection
2701 Method releaseOutputWaitAll(object)
2702 \end_layout
2704 \begin_layout Standard
2705 Like releaseOutput(), but waits until all handles have released their output.
2706 \end_layout
2708 \begin_layout Subsection
2709 Class org.jpc.emulator.VGADigtalOut
2710 \end_layout
2712 \begin_layout Standard
2713 Class org.jpc.emulator.VGADigtalOut (already implements OutputConnector) implements
2714  VGA output connector.
2715  If module provodes output connector, it needs to implement org.jpc.emulator.Displa
2716 yController.
2717 \end_layout
2719 \begin_layout Subsubsection
2720 Method getWidth()
2721 \end_layout
2723 \begin_layout Standard
2724 Get width of display (watch out, can return 0).
2725 \end_layout
2727 \begin_layout Subsubsection
2728 Method getHeight()
2729 \end_layout
2731 \begin_layout Standard
2732 Get height of display (watch out, can return 0).
2733 \end_layout
2735 \begin_layout Subsubsection
2736 Methods getDirtyXMin(), getDirtyXMax(), getDirtyYMin(), getDirtyYMax()
2737 \end_layout
2739 \begin_layout Standard
2740 Returns the dirty region (region modified since last output).
2741 \end_layout
2743 \begin_layout Subsubsection
2744 Method getBuffer()
2745 \end_layout
2747 \begin_layout Standard
2748 Get buffer of ints, at least width * height elements (left-to-right, top-down,
2749  one value per pixel) giving pixel data.
2750  Value for each pixel is 65536 * <red-component> + 256 * <green-component>
2751  + <blue-component>.
2752 \end_layout
2754 \begin_layout Subsubsection
2755 Method resizeDisplay(int _width, int _height)
2756 \end_layout
2758 \begin_layout Standard
2759 Resize the display to be of specified size.
2760 \end_layout
2762 \begin_layout Subsubsection
2763 Method dirtyDisplayRegion(int x, int y, int w, int h)
2764 \end_layout
2766 \begin_layout Standard
2767 Mark the specified region as dirty.
2768 \end_layout
2770 \begin_layout Subsubsection
2771 Method resetDirtyRegion()
2772 \end_layout
2774 \begin_layout Standard
2775 Resets the dirty region to be empty.
2776 \end_layout
2778 \begin_layout Subsection
2779 Class org.jpc.emulator.PC method getVideoOutput()
2780 \end_layout
2782 \begin_layout Standard
2783 Get VGA output connector for PC.
2784 \end_layout
2786 \begin_layout Subsection
2787 Interface org.jpc.emulator.DisplayController.
2788 \end_layout
2790 \begin_layout Standard
2791 Implementing this class signals that module is VGA controller.
2792  There can be only one such module active at time and presence of such module
2793  prevents loading builtin VGA controller emulation code.
2794 \end_layout
2796 \begin_layout Subsubsection
2797 Method getOutputDevice()
2798 \end_layout
2800 \begin_layout Standard
2801 Get VGA output connector for this VGA device.
2802 \end_layout
2804 \begin_layout Subsection
2805 Class org.jpc.emulator.SoundDigitalOut
2806 \end_layout
2808 \begin_layout Standard
2809 Class org.jpc.emulator.SoundDigitalOut provodes output connector for sound.
2810  Each connector can transfer stereo signal at arbitiary sampling rate.
2811  Modules that have audio connectors need to implement interface org.jpc.emulator.So
2812 undOutputDevice, as this signals that output connectors should be created.
2813 \end_layout
2815 \begin_layout Subsubsection
2816 Method addSample(long, short, short)
2817 \end_layout
2819 \begin_layout Standard
2820 Add stereo sample at time given by first argument.
2821  The second and third arguments give volume on left and right channels.
2822 \end_layout
2824 \begin_layout Subsubsection
2825 Method addSample(long, short)
2826 \end_layout
2828 \begin_layout Standard
2829 Add mono sample at time given by first argument.
2830  The second argument give volume on both channels.
2831 \end_layout
2833 \begin_layout Subsubsection
2834 Method readBlock(Block)
2835 \end_layout
2837 \begin_layout Standard
2838 Reads block of output (atomic versus addSample).
2839  Block structure has following fields which are filled:
2840 \end_layout
2842 \begin_layout Itemize
2843 timeBase: Time base for block.
2844 \end_layout
2846 \begin_layout Itemize
2847 baseLeft: Left volume at time base.
2848 \end_layout
2850 \begin_layout Itemize
2851 baseRight: Right volume at time base
2852 \end_layout
2854 \begin_layout Itemize
2855 blockNo: Sequence number of block filled.
2856 \end_layout
2858 \begin_layout Itemize
2859 samples: Number of samples in block
2860 \end_layout
2862 \begin_layout Itemize
2863 sampleTiming: Number of nanoseconds since last sample
2864 \end_layout
2866 \begin_layout Itemize
2867 sampleLeft: Left channel samples
2868 \end_layout
2870 \begin_layout Itemize
2871 sampleRight: Right channel samples
2872 \end_layout
2874 \begin_layout Subsection
2875 Interface org.jpc.emulator.SoundOutputDevice
2876 \end_layout
2878 \begin_layout Standard
2879 Implementing this interface signals that module has audio output channels.
2880 \end_layout
2882 \begin_layout Subsubsection
2883 Method org.jpc.emulator.SoundOutputDevice.requestedSoundChannels()
2884 \end_layout
2886 \begin_layout Standard
2887 Return the number of sound channels module has.
2888 \end_layout
2890 \begin_layout Subsubsection
2891 Method org.jpc.emulator.SoundOutputDevice.soundChannelCallback(SoundDigitalOut)
2892 \end_layout
2894 \begin_layout Standard
2895 This is called once per sound channel requested giving precreated sound
2896  channel.
2897 \end_layout
2899 \begin_layout Subsection
2900 Class org.jpc.emulator.PC method getSoundOut(String)
2901 \end_layout
2903 \begin_layout Standard
2904 Get sound output with specified name.
2905 \end_layout
2907 \begin_layout Section
2908 Advanced: Writing event targets
2909 \end_layout
2911 \begin_layout Standard
2912 Whereas output connectors are the way output is dispatched, input is dispatched
2913  via event targets.
2914  Event targets need to implement interface org.jpc.emulator.EventDispatchTarget.
2915 \end_layout
2917 \begin_layout Standard
2918 Event targets also provode methods which then encode events and dispatch
2919  them forward (without doing anything else) to event recorder.
2920  Also, event targets may have methods for obtaining state.
2921 \end_layout
2923 \begin_layout Subsection
2924 Interface org.jpc.emulator.EventDispatchTarget
2925 \end_layout
2927 \begin_layout Standard
2928 Interface that marks class capable of receiving events.
2929 \end_layout
2931 \begin_layout Subsubsection
2932 Method setEventRecorder(EventRecorder)
2933 \end_layout
2935 \begin_layout Standard
2936 Set the event recorder input events are sent to.
2937 \end_layout
2939 \begin_layout Subsubsection
2940 Method startEventCheck()
2941 \end_layout
2943 \begin_layout Standard
2944 Signals target to reset all state related to event checking and state feedback.
2945  This may be called at any time in order to reinitialialize event checking/feedb
2946 ack state.
2947 \end_layout
2949 \begin_layout Subsubsection
2950 Method doEvent(long, String[], int) throws IOException
2951 \end_layout
2953 \begin_layout Standard
2954 Event dispatch handler.
2955  The first argument is event time, second is parameters and third is what
2956  to do with it.
2957  If target doesn't like the event, throw IOException.
2958  Following types (the integer parameter) are used:
2959 \end_layout
2961 \begin_layout LyX-Code
2962 0 (EventRecorder.EVENT_TIMED): Time has been assigned for event.
2963 \end_layout
2965 \begin_layout LyX-Code
2966 1 (EventRecorder.EVENT_STATE_EFFECT_FUTURE): Future event in event replay
2967  for reinitialization
2968 \end_layout
2970 \begin_layout LyX-Code
2971 2 (EventRecorder.EVENT_STATE_EFFECT): Past event in event replay reinitialization
2972 \end_layout
2974 \begin_layout LyX-Code
2975 3 (EventRecorder.EVENT_EXECUTE): This event occurs now.
2976  Execute the effect.
2977 \end_layout
2979 \begin_layout Subsubsection
2980 Method endEventCheock()
2981 \end_layout
2983 \begin_layout Standard
2984 End event reinitialization.
2985  Usually unused.
2986 \end_layout
2988 \begin_layout Subsubsection
2989 Method getEventTimeLowBound(long, String[]) throws IOException
2990 \end_layout
2992 \begin_layout Standard
2993 Return the time value that's the earliest possiblity for this event to occur.
2994  Returning any time in past (including -1) causes event to fire as soon
2995  as possible.
2996  The long parameter gives the current scheduled time for event.
2997 \end_layout
2999 \begin_layout Section
3000 Writing modules
3001 \end_layout
3003 \begin_layout Standard
3004 Modules are various extensions that run inside emulator core.
3005  As such, they affect sync.
3006  Modules must implement interface org.jpc.emulator.HardwareComponent (they
3007  are hardware components) and must be dumpable.
3008  Additionally, they need either constructor <init>() or <init>(String).
3009  The first is if no parameters are passed, the second is for case where
3010  parameters are passed.
3011 \end_layout
3013 \begin_layout Standard
3014 Aside of the constructors, modules need to obey the ordinary conventions
3015  for hardware components.
3016  No code outside modules needs to know that module exists.
3017 \end_layout
3019 \begin_layout Section
3020 Writing plugins
3021 \end_layout
3023 \begin_layout Standard
3024 Plugins handle various UI tasks.
3025  They need to implement interface org.jpc.Plugin.
3026 \end_layout
3028 \begin_layout Subsection
3029 Interface org.jpc.pluginsbase.Plugin
3030 \end_layout
3032 \begin_layout Subsubsection
3033 Method systemShutdown()
3034 \end_layout
3036 \begin_layout Standard
3037 Called when emulator shuts down.
3038  Either called in dedicated thread or in thread that called emulatorShutdown().
3039  These handlers should do the bare minimum to get files on disk to consistent
3040  state.
3041  After these calls from all plugins have finished, emulator exits.
3042  Do not try to manipulate UI from these methods, as doing that easily leads
3043  into deadlock.
3044 \end_layout
3046 \begin_layout Subsubsection
3047 Method reconnect(PC) 
3048 \end_layout
3050 \begin_layout Standard
3051 Gives new PC to connect to.
3052  Null is passed if plugin should disconnect.
3053 \end_layout
3055 \begin_layout Subsubsection
3056 Method main()
3057 \end_layout
3059 \begin_layout Standard
3060 Called in dedicated thread after plugin is initialized.
3061 \end_layout
3063 \begin_layout Subsubsection
3064 Method pcStopping()
3065 \end_layout
3067 \begin_layout Standard
3068 Called after PC has stopped.
3069 \end_layout
3071 \begin_layout Subsubsection
3072 Method pcStarting()
3073 \end_layout
3075 \begin_layout Standard
3076 Called before PC starts.
3077 \end_layout
3079 \begin_layout Subsubsection
3080 Method notifyArguments(String[])
3081 \end_layout
3083 \begin_layout Standard
3084 Pass arguments from command line.
3085 \end_layout
3087 \begin_layout Subsubsection
3088 Constructor <init>(Plugins)
3089 \end_layout
3091 \begin_layout Standard
3092 This constructor is used to initialize plugins that don't take parameters.
3093 \end_layout
3095 \begin_layout Subsubsection
3096 Constructor <init>(Plugins, String)
3097 \end_layout
3099 \begin_layout Standard
3100 This constructor is used to initialize plugins that take parameters.
3101 \end_layout
3103 \begin_layout Subsection
3104 Class org.jpc.pluginsbase.Plugins
3105 \end_layout
3107 \begin_layout Standard
3108 This class provodes various methods for manipulating plugins.
3109 \end_layout
3111 \begin_layout Subsubsection
3112 Method isShuttingDown()
3113 \end_layout
3115 \begin_layout Standard
3116 Returns true if Plugins.shutdownEmulator() has been called somehow, either
3117  via VM exit, CTRL+C or explicitly.
3118  Useful to skip cleanups involving GUI, as these are too deadlock-prone.
3119 \end_layout
3121 \begin_layout Subsubsection
3122 Method shutdownEmulator()
3123 \end_layout
3125 \begin_layout Standard
3126 Shut down and exit the emulator.
3127  All plugin shutdown functions are called in this thread.
3128 \end_layout
3130 \begin_layout Subsubsection
3131 Method reconnectPC(PC)
3132 \end_layout
3134 \begin_layout Standard
3135 Signal reconnectPC event to all plugins.
3136 \end_layout
3138 \begin_layout Subsubsection
3139 Method pcStarted()
3140 \end_layout
3142 \begin_layout Standard
3143 Signal pcStarting() event to all plugins.
3144 \end_layout
3146 \begin_layout Subsubsection
3147 Method pcStopped()
3148 \end_layout
3150 \begin_layout Standard
3151 Signal pcStopping() event to all plugins.
3152 \end_layout
3154 \begin_layout Subsection
3155 Interface org.jpc.pluginsbase.ExternalCommandInterface
3156 \end_layout
3158 \begin_layout Standard
3159 Implementing interface org.jpc.pluginsbase.ExternalCommandInterface signals
3160  that plugin can receive commands via external commands interface.
3161 \end_layout
3163 \begin_layout Subsubsection
3164 Method invokeCommand(String cmd, String[] args)
3165 \end_layout
3167 \begin_layout Standard
3168 Invoke specified command using specified arguments.
3169  Return true if event is to be shallowed, false to continue trying to pass
3170  it to more plugins.
3171 \end_layout
3173 \begin_layout Section
3174 Lua kernel programming
3175 \end_layout
3177 \begin_layout Standard
3178 At startup, kernel gets its arguments in 'args' table and the script name
3179  to run in 'scriptname' string.
3180  It should enter the named script in protected mode.
3181 \end_layout
3183 \begin_layout Standard
3184 The Lua VM exports numerious callbacks to kernel.
3185  The kernel can then choose to omit, wrap or re-export these to Lua scripts.
3186 \end_layout
3188 \begin_layout Itemize
3189 Always grab any functions used into local variables so nobody can mess with
3190  them
3191 \end_layout
3193 \begin_layout Itemize
3194 Don't use global variables in kernel (except for those passed).
3195 \end_layout
3197 \begin_layout Subsection
3198 Lua standard
3199 \end_layout
3201 \begin_layout Standard
3202 All standard Lua functions in tables main, 'math', 'coroutine', 'string'
3203  and 'table' (safe to re-export with exception of print, loadfile and dofile,
3204  which should be wrapped).
3205 \end_layout
3207 \begin_layout Subsection
3208 Bit manipulation: none
3209 \end_layout
3211 \begin_layout Standard
3212 Bitwise none function is exported as 'jpcrr_raw.bit_none(num...)'.
3213  It takes zero or more numbers and returns number (numbers have 48 bits).
3214  The number returned has those bits set that are set in none of inputs.
3215  Safe to re-export.
3216 \end_layout
3218 \begin_layout Subsection
3219 Bit manipulation: any
3220 \end_layout
3222 \begin_layout Standard
3223 Bitwise any function is exported as 'jpcrr_raw.bit_any(num...)'.
3224  It takes zero or more numbers and returns number (numbers have 48 bits).
3225  The number returned has those bits set that are set in any of inputs.
3226  Safe to re-export.
3227 \end_layout
3229 \begin_layout Subsection
3230 Bit manipulation: parity
3231 \end_layout
3233 \begin_layout Standard
3234 Bitwise parity function is exported as 'jpcrr_raw.bit_parity(num...)'.
3235  It takes zero or more numbers and returns number (numbers have 48 bits).
3236  The number returned has those bits set that are set in even number of of
3237  inputs.
3238  Safe to re-export.
3239 \end_layout
3241 \begin_layout Subsection
3242 Bit manipulation: all
3243 \end_layout
3245 \begin_layout Standard
3246 Bitwise parity function is exported as 'jpcrr_raw.bit_all(num...)'.
3247  It takes zero or more numbers and returns number (numbers have 48 bits).
3248  The number returned has those bits set that are set in all of inputs.
3249  Safe to re-export.
3250 \end_layout
3252 \begin_layout Subsection
3253 Bit manipulation: lshift
3254 \end_layout
3256 \begin_layout Standard
3257 Left shift function is exported as 'jpcrr_raw.bit_lshift(num base, num shift)'.
3258  It takes two numbers and returns first number shifted by second.
3259  number places left.
3260  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3261  Safe to re-export.
3262 \end_layout
3264 \begin_layout Subsection
3265 Bit manipulation: rshift
3266 \end_layout
3268 \begin_layout Standard
3269 Right logical shift function is exported as 'jpcrr_raw.bit_rshift(num base,
3270  num shift)'.
3271  It takes two numbers and returns first number shifted by second number
3272  places right.
3273  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3274  Safe to re-export.
3275 \end_layout
3277 \begin_layout Subsection
3278 Bit manipulation: arshift
3279 \end_layout
3281 \begin_layout Standard
3282 Right arithmetic shift function is exported as 'jpcrr_raw.bit_arshift(num
3283  base, num shift)'.
3284  It takes two numbers and returns first number shifted by second number
3285  places right, with highest bit copied.
3286  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3287  Safe to re-export.
3288 \end_layout
3290 \begin_layout Subsection
3291 Bit manipulation: add
3292 \end_layout
3294 \begin_layout Standard
3295 Add function is exported as 'jpcrr_raw.bit_add(num...)'.
3296  It takes zero or more numbers and returns number (numbers have 48 bits).
3297  The number returned is sum of all of inputs modulo 
3298 \begin_inset Formula $2^{48}$
3299 \end_inset
3302  Safe to re-export.
3303 \end_layout
3305 \begin_layout Subsection
3306 Bit manipulation: addneg
3307 \end_layout
3309 \begin_layout Standard
3310 Add negated function is exported as 'jpcrr_raw.bit_addneg(num...)'.
3311  It takes zero or more numbers and returns number (numbers have 48 bits).
3312  The number returned is 0 minus of all of inputs modulo 
3313 \begin_inset Formula $2^{48}$
3314 \end_inset
3317  Safe to re-export.
3318 \end_layout
3320 \begin_layout Subsection
3321 Bit manipulation: addalt
3322 \end_layout
3324 \begin_layout Standard
3325 Add alternate function is exported as 'jpcrr_raw.bit_addalt(num...)'.
3326  It takes zero or more numbers and returns number (numbers have 48 bits).
3327  The number returned is sum of odd arguments (first argument is odd) minus
3328  sum of even arguments modulo 
3329 \begin_inset Formula $2^{48}$
3330 \end_inset
3333  Safe to re-export.
3334 \end_layout
3336 \begin_layout Subsection
3337 Bit manipulation: tohex
3338 \end_layout
3340 \begin_layout Standard
3341 Add alternate function is exported as 'jpcrr_raw.bit_tohex(num number)'.
3342  It takes number and returns hexadecimal representation of it.
3343  Safe to re-export.
3344 \end_layout
3346 \begin_layout Subsection
3347 Console output:
3348 \end_layout
3350 \begin_layout Standard
3351 Console ouput function is exported as 'jpcrr_raw.print_console_msg(sring
3352  line)'.
3353  It prints its string argument as new line on Lua console (should not be
3354  re-exported, use to construct replacement print).
3355 \end_layout
3357 \begin_layout Subsection
3358 Binary I/O:
3359 \end_layout
3361 \begin_layout Standard
3362 Binary I/O file open function is exported as 'jpcrr_raw.io_openbinary(string
3363  name, string mode)'.
3364  It takes two strings, first is name of file to open, second is mode, either
3366 \begin_inset Quotes eld
3367 \end_inset
3370 \begin_inset Quotes erd
3371 \end_inset
3373  or 
3374 \begin_inset Quotes eld
3375 \end_inset
3378 \begin_inset Quotes erd
3379 \end_inset
3382  The returned object has following methods:
3383 \end_layout
3385 \begin_layout Itemize
3386 file:length(): Returns length of file as number.
3387 \end_layout
3389 \begin_layout Itemize
3390 file:set_length(num len): Truncate file to len bytes.
3391 \end_layout
3393 \begin_layout Itemize
3394 file:read(num offset, num length): Read up to length bytes starting from
3395  offset offset.
3396  The file character set is assumed to be Latin1.
3397 \end_layout
3399 \begin_layout Itemize
3400 file:write(num offset, string str): Write str starting from offset offset.
3401  Writing non-Latin1 characters gives unpredictable results.
3402  Only available on files opened for read/write.
3403 \end_layout
3405 \begin_layout Itemize
3406 file:close(): Close file.
3407  No file operations can be done anymore.
3408 \end_layout
3410 \begin_layout Standard
3411 The function should be filtered to enforce path constraints.
3412 \end_layout
3414 \begin_layout Subsection
3415 Text input:
3416 \end_layout
3418 \begin_layout Standard
3419 Text input open function is exported as 'jpcrr_raw.io_opentextinput(string
3420  name)'.
3421  It takes one string, name of file to open.
3422  The returned object has following methods:
3423 \end_layout
3425 \begin_layout Itemize
3426 file:read(): Read next line.
3427  The file encoding is assumed to be UTF-8.
3428 \end_layout
3430 \begin_layout Itemize
3431 file:close(): Close file.
3432  No file operations can be done anymore.
3433 \end_layout
3435 \begin_layout Standard
3436 The function should be filtered to enforce path constraints.
3437 \end_layout
3439 \begin_layout Subsection
3440 Text output:
3441 \end_layout
3443 \begin_layout Standard
3444 Text output open function is exported as 'jpcrr_raw.io_opentextoutput(string
3445  name)'.
3446  It takes one string, name of file to open.
3447  The returned object has following methods:
3448 \end_layout
3450 \begin_layout Itemize
3451 file:write(string line): Write line line to file.
3452  File encoding is assumed to be UTF-8.
3453 \end_layout
3455 \begin_layout Itemize
3456 file:close(): Close file.
3457  No file operations can be done anymore.
3458 \end_layout
3460 \begin_layout Standard
3461 The function should be filtered to enforce path constraints.
3462 \end_layout
3464 \begin_layout Subsection
3465 ECI invoke:
3466 \end_layout
3468 \begin_layout Standard
3469 ECI invocation functions 'jpcrr_raw.invoke(string name [, table args])' and
3470  'jpcrr_raw.invoke_synchronous(string name [, table args])'.
3471  These functions run specified ECI function with specified arguments.
3472  The updates ECI call makes to arguments is reflected to table passed as
3473  parameter.
3474  The synchronous version waits that any slow command processing gets done
3475  before returning (assemble, save, load and dump have such slow processing).
3476  These functions return nothing.
3477  Safe to re-export, use as base for more functions.
3478 \end_layout
3480 \begin_layout Subsection
3481 PC Running:
3482 \end_layout
3484 \begin_layout Standard
3485 'jpcrr_raw.pc_running()'.
3486  Returns true if PC is running, false otherwise.
3487  Assemble, save, load and dump require PC not being running to be possible.
3488 \end_layout
3490 \begin_layout Subsection
3491 PC Connected:
3492 \end_layout
3494 \begin_layout Standard
3495 'jpcrr_raw.pc_connected()'.
3496  Returns true if PC is connected, false otherwise.
3497 \end_layout
3499 \begin_layout Subsection
3500 VGA wait/release:
3501 \end_layout
3503 \begin_layout Standard
3504 'jpcrr_raw.wait_vga()' waits for VGA to enter frame hold mode and returns
3505  true (if it returns false, the wait got interrupted for some reason and
3506  VGA is in rendering mode).
3507  While VGA is in frame hold, PC execution is locked out and things like
3508  memory reading and writing can be done without races (but load/save is
3509  not possible).
3510  'jpcrr_raw.release_vga()' acknowledges frame hold processing (VGA can re-enter
3511  rendering mode).
3512 \end_layout
3514 \begin_layout Standard
3515 Frame hold happens once per frame at start of vertical retrace.
3516  Note that running Lua script must wait frame holds and release them or
3517  main PC execution will hang on first frame hold.
3518 \end_layout
3520 \end_body
3521 \end_document