Add missing changelog entry
[jpcrr.git] / manual.lyx
blob96b25634994e3d719bc380b4ecaf975ffdb00da3
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 Reboot:
2245 \end_layout
2247 \begin_layout Itemize
2248 Dispatch to: org.jpc.emulator.PC$ResetButton
2249 \end_layout
2251 \begin_layout Itemize
2252 No arguments
2253 \end_layout
2255 \begin_layout Standard
2256 Reboots the PC.
2257 \end_layout
2259 \begin_layout Subsubsection
2260 Fda disk change:
2261 \end_layout
2263 \begin_layout Itemize
2264 Dispatch to: org.jpc.emulator.PC$DiskChanger
2265 \end_layout
2267 \begin_layout Itemize
2268 Argument #1: Fixed: "FDA"
2269 \end_layout
2271 \begin_layout Itemize
2272 Argument #2: Number of image slot to put there.
2274 \end_layout
2276 \begin_layout Standard
2277 The disk number MUST be -1 or valid disk number.
2278  -1 MUST NOT be used if there is no disk in floppy drive A.
2279  This event causes specified disk to be placed to FDA or FDA disk to be
2280  ejected with no replacement if disk number is -1.
2281  The specified disk if not -1 must be of floppy type.
2282  The specified disk if valid must not be in any other drive.
2283 \end_layout
2285 \begin_layout Subsubsection
2286 Fdb disk change:
2287 \end_layout
2289 \begin_layout Itemize
2290 Dispatch to: org.jpc.emulator.PC$DiskChanger
2291 \end_layout
2293 \begin_layout Itemize
2294 Argument #1: Fixed: "FDB"
2295 \end_layout
2297 \begin_layout Itemize
2298 Argument #2: Number of image slot to put there.
2300 \end_layout
2302 \begin_layout Standard
2303 The disk number MUST be -1 or valid disk number.
2304  -1 MUST NOT be used if there is no disk in floppy drive B.
2305  This event causes specified disk to be placed to FDB or FDB disk to be
2306  ejected with no replacement if disk number is -1.
2307  The specified disk if not -1 must be of floppy type.
2308  The specified disk if valid must not be in any other drive.
2309 \end_layout
2311 \begin_layout Subsubsection
2312 Change CDROM:
2313 \end_layout
2315 \begin_layout Itemize
2316 Dispatch to: org.jpc.emulator.PC$DiskChanger
2317 \end_layout
2319 \begin_layout Itemize
2320 Argument #1: Fixed: "CDROM"
2321 \end_layout
2323 \begin_layout Itemize
2324 Argument #2: Number of image slot to put there.
2326 \end_layout
2328 \begin_layout Standard
2329 The disk number MUST be -1 or valid disk number.
2330  -1 MUST NOT be used if there is no disk in CD-ROM.
2331  This event causes specified disk to be placed to CD-ROM or CD-ROM disk
2332  to be ejected with no replacement if disk number is -1.
2333  The specified disk if not -1 must be of CD-ROM type.
2334 \end_layout
2336 \begin_layout Standard
2337 This event has no effect if CD-ROM is locked.
2338 \end_layout
2340 \begin_layout Subsubsection
2341 Write protect floppy:
2342 \end_layout
2344 \begin_layout Itemize
2345 Dispatch to: org.jpc.emulator.PC$DiskChanger
2346 \end_layout
2348 \begin_layout Itemize
2349 Argument #1: Fixed: "WRITEPROTECT"
2350 \end_layout
2352 \begin_layout Itemize
2353 Argument #2: Number of image slot to manipulate 
2354 \end_layout
2356 \begin_layout Standard
2357 Write protects specified disk.
2358  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2359 \end_layout
2361 \begin_layout Subsubsection
2362 Write unprotect floppy:
2363 \end_layout
2365 \begin_layout Itemize
2366 Dispatch to: org.jpc.emulator.PC$DiskChanger
2367 \end_layout
2369 \begin_layout Itemize
2370 Argument #1: Fixed: "WRITEUNPROTECT"
2371 \end_layout
2373 \begin_layout Itemize
2374 Argument #2: Number of image slot to manipulate 
2375 \end_layout
2377 \begin_layout Standard
2378 Disables write protection specified disk.
2379  The disk MUST NOT be in any drive and MUST be valid floppy-type disk.
2380 \end_layout
2382 \begin_layout Subsection
2383 Savestates
2384 \end_layout
2386 \begin_layout Standard
2387 Actual savestate format is not documented here.
2388  It is close to impossible to comprehend without access to emulator source
2389  anyway.
2390 \end_layout
2392 \begin_layout Section
2393 Advanced: Making class dumpable
2394 \end_layout
2396 \begin_layout Standard
2397 Class is made dumpable by implementing interface org.jpc.emulator.SRDumpable
2398  and implementing method dumpSRPartial(org.jpc.emulator.SRDumper) and constructor
2399  <init>(org.jpc.emulator.SRLoader).
2400  Non-static inner classes can not be dumpable (make them static using tricks
2401  similar to what javac uses).
2402 \end_layout
2404 \begin_layout Standard
2405 If dumped class has dumpable superclass, the first thing dumping function
2406  needs to do is to call dumper function of superclass and first thing loading
2407  constructor needs to do is to call loading constructor of superclass.
2408  If class has no dumpable superclass, dumper doesn't need to do anything
2409  special, while loader needs to call objectCreated(this) on SRLoader object
2410  passed as parameter.
2412 \end_layout
2414 \begin_layout Standard
2415 Following these fixed parts, dump all members that are part of mutable state
2416  in emulator core.
2417 \end_layout
2419 \begin_layout Subsection
2420 Member dumping/loading functions
2421 \end_layout
2423 \begin_layout Standard
2424 There is dumping/loading function for following (all functions dumping/loading
2425  reference types can handle null):
2426 \end_layout
2428 \begin_layout Itemize
2429 boolean: SRDumper.dumpBoolean, SRLoader.loadBoolean
2430 \end_layout
2432 \begin_layout Itemize
2433 byte: SRDumper.dumpByte, SRLoader.loadByte
2434 \end_layout
2436 \begin_layout Itemize
2437 short: SRDumper.dumpShort, SRLoader.loadShort
2438 \end_layout
2440 \begin_layout Itemize
2441 int: SRDumper.dumpInt, SRLoader.loadInt
2442 \end_layout
2444 \begin_layout Itemize
2445 long: SRDumper.dumpLong, SRLoader.loadLong
2446 \end_layout
2448 \begin_layout Itemize
2449 String: SRDumper.dumpString, SRLoader.loadString
2450 \end_layout
2452 \begin_layout Itemize
2453 boolean[]: SRDumper.dumpArray, SRLoader.loadArrayBoolean
2454 \end_layout
2456 \begin_layout Itemize
2457 byte[]: SRDumper.dumpArray, SRLoader.loadArrayByte
2458 \end_layout
2460 \begin_layout Itemize
2461 short[]: SRDumper.dumpArray, SRLoader.loadArrayShort
2462 \end_layout
2464 \begin_layout Itemize
2465 int[]: SRDumper.dumpArray, SRLoader.loadArrayInt
2466 \end_layout
2468 \begin_layout Itemize
2469 long[]: SRDumper.dumpArray, SRLoader.loadArrayLong
2470 \end_layout
2472 \begin_layout Itemize
2473 double[]: SRDumper.dumpArray, SRLoader.loadArrayDouble
2474 \end_layout
2476 \begin_layout Itemize
2477 <dumpable type>: SRDumper.dumpObject, SRLoader.loadObject
2478 \end_layout
2480 \begin_layout Itemize
2481 special object: SRDumper.specialObject, SRLoader.specialObject
2482 \end_layout
2484 \begin_layout Subsubsection
2485 Notes:
2486 \end_layout
2488 \begin_layout Itemize
2489 Dumpable objects come out as type of org.jpc.emulator.SRDumpable.
2490 \end_layout
2492 \begin_layout Itemize
2493 Special objects are various static objects that don't need to be stored
2494  because they don't have mutable fields.
2495 \end_layout
2497 \begin_layout Itemize
2498 Don't dump fields related to event state feedback.
2499 \end_layout
2501 \begin_layout Itemize
2502 Don't dump temporary flags that are only used while PC is running.
2503  Savestate when PC is running isn't possible anyway.
2504 \end_layout
2506 \begin_layout Itemize
2507 Some connectors dump fields related to connector output, some don't.
2508 \end_layout
2510 \begin_layout Section
2511 Advanced: Making output connectors
2512 \end_layout
2514 \begin_layout Standard
2515 Implementing interface org.jpc.emulator.DisplayController signals that this
2516  is display controller, inhibiting loading of the standard VGA display controlle
2517 r if loaded as module.
2519 \end_layout
2521 \begin_layout Subsection
2522 Interface org.jpc.emulator.OutputConnector
2523 \end_layout
2525 \begin_layout Standard
2526 Class is made to be output connector by implementing this interface.
2527  This interface specifies the methods used for output hold locking.
2528  Class org.jpc.emulator.OutputConnectorLocking has implementations of these
2529  that are suitable for calling.
2531 \end_layout
2533 \begin_layout Subsubsection
2534 Method subscribeOutput(Object)
2535 \end_layout
2537 \begin_layout Standard
2538 Subscribes the output, with specified object as handle.
2539 \end_layout
2541 \begin_layout Subsubsection
2542 Method unsubscribeOutput(Object)
2543 \end_layout
2545 \begin_layout Standard
2546 Unsubscribe the specified handle object from output.
2547 \end_layout
2549 \begin_layout Subsubsection
2550 Method waitOutput(Object)
2551 \end_layout
2553 \begin_layout Standard
2554 Wait for output on specified connector using specified handle object.
2555  Returns true on success, false if wait was interrupted by thread interrupt.
2556  Blocking.
2557 \end_layout
2559 \begin_layout Subsubsection
2560 Method releaseOutput(Object)
2561 \end_layout
2563 \begin_layout Standard
2564 Release connector from p.o.v.
2565  of given handle.
2566  Does not block.
2567 \end_layout
2569 \begin_layout Subsubsection
2570 Method holdOutput()
2571 \end_layout
2573 \begin_layout Standard
2574 Release threads waiting on waitOutput() and block until all subscribers
2575  have returned from waitOutput() and enteired releaseOutput().
2576 \end_layout
2578 \begin_layout Subsubsection
2579 Method releaseOutputWaitAll(object)
2580 \end_layout
2582 \begin_layout Standard
2583 Like releaseOutput(), but waits until all handles have released their output.
2584 \end_layout
2586 \begin_layout Subsection
2587 Class org.jpc.emulator.VGADigtalOut
2588 \end_layout
2590 \begin_layout Standard
2591 Class org.jpc.emulator.VGADigtalOut (already implements OutputConnector) implements
2592  VGA output connector.
2593  If module provodes output connector, it needs to implement org.jpc.emulator.Displa
2594 yController.
2595 \end_layout
2597 \begin_layout Subsubsection
2598 Method getWidth()
2599 \end_layout
2601 \begin_layout Standard
2602 Get width of display (watch out, can return 0).
2603 \end_layout
2605 \begin_layout Subsubsection
2606 Method getHeight()
2607 \end_layout
2609 \begin_layout Standard
2610 Get height of display (watch out, can return 0).
2611 \end_layout
2613 \begin_layout Subsubsection
2614 Methods getDirtyXMin(), getDirtyXMax(), getDirtyYMin(), getDirtyYMax()
2615 \end_layout
2617 \begin_layout Standard
2618 Returns the dirty region (region modified since last output).
2619 \end_layout
2621 \begin_layout Subsubsection
2622 Method getBuffer()
2623 \end_layout
2625 \begin_layout Standard
2626 Get buffer of ints, at least width * height elements (left-to-right, top-down,
2627  one value per pixel) giving pixel data.
2628  Value for each pixel is 65536 * <red-component> + 256 * <green-component>
2629  + <blue-component>.
2630 \end_layout
2632 \begin_layout Subsubsection
2633 Method resizeDisplay(int _width, int _height)
2634 \end_layout
2636 \begin_layout Standard
2637 Resize the display to be of specified size.
2638 \end_layout
2640 \begin_layout Subsubsection
2641 Method dirtyDisplayRegion(int x, int y, int w, int h)
2642 \end_layout
2644 \begin_layout Standard
2645 Mark the specified region as dirty.
2646 \end_layout
2648 \begin_layout Subsubsection
2649 Method resetDirtyRegion()
2650 \end_layout
2652 \begin_layout Standard
2653 Resets the dirty region to be empty.
2654 \end_layout
2656 \begin_layout Subsection
2657 Class org.jpc.emulator.PC method getVideoOutput()
2658 \end_layout
2660 \begin_layout Standard
2661 Get VGA output connector for PC.
2662 \end_layout
2664 \begin_layout Subsection
2665 Interface org.jpc.emulator.DisplayController.
2666 \end_layout
2668 \begin_layout Standard
2669 Implementing this class signals that module is VGA controller.
2670  There can be only one such module active at time and presence of such module
2671  prevents loading builtin VGA controller emulation code.
2672 \end_layout
2674 \begin_layout Subsubsection
2675 Method getOutputDevice()
2676 \end_layout
2678 \begin_layout Standard
2679 Get VGA output connector for this VGA device.
2680 \end_layout
2682 \begin_layout Subsection
2683 Class org.jpc.emulator.SoundDigitalOut
2684 \end_layout
2686 \begin_layout Standard
2687 Class org.jpc.emulator.SoundDigitalOut provodes output connector for sound.
2688  Each connector can transfer stereo signal at arbitiary sampling rate.
2689  Modules that have audio connectors need to implement interface org.jpc.emulator.So
2690 undOutputDevice, as this signals that output connectors should be created.
2691 \end_layout
2693 \begin_layout Subsubsection
2694 Method addSample(long, short, short)
2695 \end_layout
2697 \begin_layout Standard
2698 Add stereo sample at time given by first argument.
2699  The second and third arguments give volume on left and right channels.
2700 \end_layout
2702 \begin_layout Subsubsection
2703 Method addSample(long, short)
2704 \end_layout
2706 \begin_layout Standard
2707 Add mono sample at time given by first argument.
2708  The second argument give volume on both channels.
2709 \end_layout
2711 \begin_layout Subsubsection
2712 Method readBlock(Block)
2713 \end_layout
2715 \begin_layout Standard
2716 Reads block of output (atomic versus addSample).
2717  Block structure has following fields which are filled:
2718 \end_layout
2720 \begin_layout Itemize
2721 timeBase: Time base for block.
2722 \end_layout
2724 \begin_layout Itemize
2725 baseLeft: Left volume at time base.
2726 \end_layout
2728 \begin_layout Itemize
2729 baseRight: Right volume at time base
2730 \end_layout
2732 \begin_layout Itemize
2733 blockNo: Sequence number of block filled.
2734 \end_layout
2736 \begin_layout Itemize
2737 samples: Number of samples in block
2738 \end_layout
2740 \begin_layout Itemize
2741 sampleTiming: Number of nanoseconds since last sample
2742 \end_layout
2744 \begin_layout Itemize
2745 sampleLeft: Left channel samples
2746 \end_layout
2748 \begin_layout Itemize
2749 sampleRight: Right channel samples
2750 \end_layout
2752 \begin_layout Subsection
2753 Interface org.jpc.emulator.SoundOutputDevice
2754 \end_layout
2756 \begin_layout Standard
2757 Implementing this interface signals that module has audio output channels.
2758 \end_layout
2760 \begin_layout Subsubsection
2761 Method org.jpc.emulator.SoundOutputDevice.requestedSoundChannels()
2762 \end_layout
2764 \begin_layout Standard
2765 Return the number of sound channels module has.
2766 \end_layout
2768 \begin_layout Subsubsection
2769 Method org.jpc.emulator.SoundOutputDevice.soundChannelCallback(SoundDigitalOut)
2770 \end_layout
2772 \begin_layout Standard
2773 This is called once per sound channel requested giving precreated sound
2774  channel.
2775 \end_layout
2777 \begin_layout Subsection
2778 Class org.jpc.emulator.PC method getSoundOut(String)
2779 \end_layout
2781 \begin_layout Standard
2782 Get sound output with specified name.
2783 \end_layout
2785 \begin_layout Section
2786 Advanced: Writing event targets
2787 \end_layout
2789 \begin_layout Standard
2790 Whereas output connectors are the way output is dispatched, input is dispatched
2791  via event targets.
2792  Event targets need to implement interface org.jpc.emulator.EventDispatchTarget.
2793 \end_layout
2795 \begin_layout Standard
2796 Event targets also provode methods which then encode events and dispatch
2797  them forward (without doing anything else) to event recorder.
2798  Also, event targets may have methods for obtaining state.
2799 \end_layout
2801 \begin_layout Subsection
2802 Interface org.jpc.emulator.EventDispatchTarget
2803 \end_layout
2805 \begin_layout Standard
2806 Interface that marks class capable of receiving events.
2807 \end_layout
2809 \begin_layout Subsubsection
2810 Method setEventRecorder(EventRecorder)
2811 \end_layout
2813 \begin_layout Standard
2814 Set the event recorder input events are sent to.
2815 \end_layout
2817 \begin_layout Subsubsection
2818 Method startEventCheck()
2819 \end_layout
2821 \begin_layout Standard
2822 Signals target to reset all state related to event checking and state feedback.
2823  This may be called at any time in order to reinitialialize event checking/feedb
2824 ack state.
2825 \end_layout
2827 \begin_layout Subsubsection
2828 Method doEvent(long, String[], int) throws IOException
2829 \end_layout
2831 \begin_layout Standard
2832 Event dispatch handler.
2833  The first argument is event time, second is parameters and third is what
2834  to do with it.
2835  If target doesn't like the event, throw IOException.
2836  Following types (the integer parameter) are used:
2837 \end_layout
2839 \begin_layout LyX-Code
2840 0 (EventRecorder.EVENT_TIMED): Time has been assigned for event.
2841 \end_layout
2843 \begin_layout LyX-Code
2844 1 (EventRecorder.EVENT_STATE_EFFECT_FUTURE): Future event in event replay
2845  for reinitialization
2846 \end_layout
2848 \begin_layout LyX-Code
2849 2 (EventRecorder.EVENT_STATE_EFFECT): Past event in event replay reinitialization
2850 \end_layout
2852 \begin_layout LyX-Code
2853 3 (EventRecorder.EVENT_EXECUTE): This event occurs now.
2854  Execute the effect.
2855 \end_layout
2857 \begin_layout Subsubsection
2858 Method endEventCheock()
2859 \end_layout
2861 \begin_layout Standard
2862 End event reinitialization.
2863  Usually unused.
2864 \end_layout
2866 \begin_layout Subsubsection
2867 Method getEventTimeLowBound(long, String[]) throws IOException
2868 \end_layout
2870 \begin_layout Standard
2871 Return the time value that's the earliest possiblity for this event to occur.
2872  Returning any time in past (including -1) causes event to fire as soon
2873  as possible.
2874  The long parameter gives the current scheduled time for event.
2875 \end_layout
2877 \begin_layout Section
2878 Writing modules
2879 \end_layout
2881 \begin_layout Standard
2882 Modules are various extensions that run inside emulator core.
2883  As such, they affect sync.
2884  Modules must implement interface org.jpc.emulator.HardwareComponent (they
2885  are hardware components) and must be dumpable.
2886  Additionally, they need either constructor <init>() or <init>(String).
2887  The first is if no parameters are passed, the second is for case where
2888  parameters are passed.
2889 \end_layout
2891 \begin_layout Standard
2892 Aside of the constructors, modules need to obey the ordinary conventions
2893  for hardware components.
2894  No code outside modules needs to know that module exists.
2895 \end_layout
2897 \begin_layout Section
2898 Writing plugins
2899 \end_layout
2901 \begin_layout Standard
2902 Plugins handle various UI tasks.
2903  They need to implement interface org.jpc.Plugin.
2904 \end_layout
2906 \begin_layout Subsection
2907 Interface org.jpc.pluginsbase.Plugin
2908 \end_layout
2910 \begin_layout Subsubsection
2911 Method systemShutdown()
2912 \end_layout
2914 \begin_layout Standard
2915 Called when emulator shuts down.
2916  Either called in dedicated thread or in thread that called emulatorShutdown().
2917  These handlers should do the bare minimum to get files on disk to consistent
2918  state.
2919  After these calls from all plugins have finished, emulator exits.
2920  Do not try to manipulate UI from these methods, as doing that easily leads
2921  into deadlock.
2922 \end_layout
2924 \begin_layout Subsubsection
2925 Method reconnect(PC) 
2926 \end_layout
2928 \begin_layout Standard
2929 Gives new PC to connect to.
2930  Null is passed if plugin should disconnect.
2931 \end_layout
2933 \begin_layout Subsubsection
2934 Method main()
2935 \end_layout
2937 \begin_layout Standard
2938 Called in dedicated thread after plugin is initialized.
2939 \end_layout
2941 \begin_layout Subsubsection
2942 Method pcStopping()
2943 \end_layout
2945 \begin_layout Standard
2946 Called after PC has stopped.
2947 \end_layout
2949 \begin_layout Subsubsection
2950 Method pcStarting()
2951 \end_layout
2953 \begin_layout Standard
2954 Called before PC starts.
2955 \end_layout
2957 \begin_layout Subsubsection
2958 Method notifyArguments(String[])
2959 \end_layout
2961 \begin_layout Standard
2962 Pass arguments from command line.
2963 \end_layout
2965 \begin_layout Subsubsection
2966 Constructor <init>(Plugins)
2967 \end_layout
2969 \begin_layout Standard
2970 This constructor is used to initialize plugins that don't take parameters.
2971 \end_layout
2973 \begin_layout Subsubsection
2974 Constructor <init>(Plugins, String)
2975 \end_layout
2977 \begin_layout Standard
2978 This constructor is used to initialize plugins that take parameters.
2979 \end_layout
2981 \begin_layout Subsection
2982 Class org.jpc.pluginsbase.Plugins
2983 \end_layout
2985 \begin_layout Standard
2986 This class provodes various methods for manipulating plugins.
2987 \end_layout
2989 \begin_layout Subsubsection
2990 Method isShuttingDown()
2991 \end_layout
2993 \begin_layout Standard
2994 Returns true if Plugins.shutdownEmulator() has been called somehow, either
2995  via VM exit, CTRL+C or explicitly.
2996  Useful to skip cleanups involving GUI, as these are too deadlock-prone.
2997 \end_layout
2999 \begin_layout Subsubsection
3000 Method shutdownEmulator()
3001 \end_layout
3003 \begin_layout Standard
3004 Shut down and exit the emulator.
3005  All plugin shutdown functions are called in this thread.
3006 \end_layout
3008 \begin_layout Subsubsection
3009 Method reconnectPC(PC)
3010 \end_layout
3012 \begin_layout Standard
3013 Signal reconnectPC event to all plugins.
3014 \end_layout
3016 \begin_layout Subsubsection
3017 Method pcStarted()
3018 \end_layout
3020 \begin_layout Standard
3021 Signal pcStarting() event to all plugins.
3022 \end_layout
3024 \begin_layout Subsubsection
3025 Method pcStopped()
3026 \end_layout
3028 \begin_layout Standard
3029 Signal pcStopping() event to all plugins.
3030 \end_layout
3032 \begin_layout Subsection
3033 Interface org.jpc.pluginsbase.ExternalCommandInterface
3034 \end_layout
3036 \begin_layout Standard
3037 Implementing interface org.jpc.pluginsbase.ExternalCommandInterface signals
3038  that plugin can receive commands via external commands interface.
3039 \end_layout
3041 \begin_layout Subsubsection
3042 Method invokeCommand(String cmd, String[] args)
3043 \end_layout
3045 \begin_layout Standard
3046 Invoke specified command using specified arguments.
3047  Return true if event is to be shallowed, false to continue trying to pass
3048  it to more plugins.
3049 \end_layout
3051 \begin_layout Section
3052 Lua kernel programming
3053 \end_layout
3055 \begin_layout Standard
3056 At startup, kernel gets its arguments in 'args' table and the script name
3057  to run in 'scriptname' string.
3058  It should enter the named script in protected mode.
3059 \end_layout
3061 \begin_layout Standard
3062 The Lua VM exports numerious callbacks to kernel.
3063  The kernel can then choose to omit, wrap or re-export these to Lua scripts.
3064 \end_layout
3066 \begin_layout Itemize
3067 Always grab any functions used into local variables so nobody can mess with
3068  them
3069 \end_layout
3071 \begin_layout Itemize
3072 Don't use global variables in kernel (except for those passed).
3073 \end_layout
3075 \begin_layout Subsection
3076 Lua standard
3077 \end_layout
3079 \begin_layout Standard
3080 All standard Lua functions in tables main, 'math', 'coroutine', 'string'
3081  and 'table' (safe to re-export with exception of print, loadfile and dofile,
3082  which should be wrapped).
3083 \end_layout
3085 \begin_layout Subsection
3086 Bit manipulation: none
3087 \end_layout
3089 \begin_layout Standard
3090 Bitwise none function is exported as 'jpcrr_raw.bit_none(num...)'.
3091  It takes zero or more numbers and returns number (numbers have 48 bits).
3092  The number returned has those bits set that are set in none of inputs.
3093  Safe to re-export.
3094 \end_layout
3096 \begin_layout Subsection
3097 Bit manipulation: any
3098 \end_layout
3100 \begin_layout Standard
3101 Bitwise any function is exported as 'jpcrr_raw.bit_any(num...)'.
3102  It takes zero or more numbers and returns number (numbers have 48 bits).
3103  The number returned has those bits set that are set in any of inputs.
3104  Safe to re-export.
3105 \end_layout
3107 \begin_layout Subsection
3108 Bit manipulation: parity
3109 \end_layout
3111 \begin_layout Standard
3112 Bitwise parity function is exported as 'jpcrr_raw.bit_parity(num...)'.
3113  It takes zero or more numbers and returns number (numbers have 48 bits).
3114  The number returned has those bits set that are set in even number of of
3115  inputs.
3116  Safe to re-export.
3117 \end_layout
3119 \begin_layout Subsection
3120 Bit manipulation: all
3121 \end_layout
3123 \begin_layout Standard
3124 Bitwise parity function is exported as 'jpcrr_raw.bit_all(num...)'.
3125  It takes zero or more numbers and returns number (numbers have 48 bits).
3126  The number returned has those bits set that are set in all of inputs.
3127  Safe to re-export.
3128 \end_layout
3130 \begin_layout Subsection
3131 Bit manipulation: lshift
3132 \end_layout
3134 \begin_layout Standard
3135 Left shift function is exported as 'jpcrr_raw.bit_lshift(num base, num shift)'.
3136  It takes two numbers and returns first number shifted by second.
3137  number places left.
3138  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3139  Safe to re-export.
3140 \end_layout
3142 \begin_layout Subsection
3143 Bit manipulation: rshift
3144 \end_layout
3146 \begin_layout Standard
3147 Right logical shift function is exported as 'jpcrr_raw.bit_rshift(num base,
3148  num shift)'.
3149  It takes two numbers and returns first number shifted by second number
3150  places right.
3151  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3152  Safe to re-export.
3153 \end_layout
3155 \begin_layout Subsection
3156 Bit manipulation: arshift
3157 \end_layout
3159 \begin_layout Standard
3160 Right arithmetic shift function is exported as 'jpcrr_raw.bit_arshift(num
3161  base, num shift)'.
3162  It takes two numbers and returns first number shifted by second number
3163  places right, with highest bit copied.
3164  Numbers have 48 bits, using shifts outside 0-47 gives unpredictable results.
3165  Safe to re-export.
3166 \end_layout
3168 \begin_layout Subsection
3169 Bit manipulation: add
3170 \end_layout
3172 \begin_layout Standard
3173 Add function is exported as 'jpcrr_raw.bit_add(num...)'.
3174  It takes zero or more numbers and returns number (numbers have 48 bits).
3175  The number returned is sum of all of inputs modulo 
3176 \begin_inset Formula $2^{48}$
3177 \end_inset
3180  Safe to re-export.
3181 \end_layout
3183 \begin_layout Subsection
3184 Bit manipulation: addneg
3185 \end_layout
3187 \begin_layout Standard
3188 Add negated function is exported as 'jpcrr_raw.bit_addneg(num...)'.
3189  It takes zero or more numbers and returns number (numbers have 48 bits).
3190  The number returned is 0 minus of all of inputs modulo 
3191 \begin_inset Formula $2^{48}$
3192 \end_inset
3195  Safe to re-export.
3196 \end_layout
3198 \begin_layout Subsection
3199 Bit manipulation: addalt
3200 \end_layout
3202 \begin_layout Standard
3203 Add alternate function is exported as 'jpcrr_raw.bit_addalt(num...)'.
3204  It takes zero or more numbers and returns number (numbers have 48 bits).
3205  The number returned is sum of odd arguments (first argument is odd) minus
3206  sum of even arguments modulo 
3207 \begin_inset Formula $2^{48}$
3208 \end_inset
3211  Safe to re-export.
3212 \end_layout
3214 \begin_layout Subsection
3215 Bit manipulation: tohex
3216 \end_layout
3218 \begin_layout Standard
3219 Add alternate function is exported as 'jpcrr_raw.bit_tohex(num number)'.
3220  It takes number and returns hexadecimal representation of it.
3221  Safe to re-export.
3222 \end_layout
3224 \begin_layout Subsection
3225 Console output:
3226 \end_layout
3228 \begin_layout Standard
3229 Console ouput function is exported as 'jpcrr_raw.print_console_msg(sring
3230  line)'.
3231  It prints its string argument as new line on Lua console (should not be
3232  re-exported, use to construct replacement print).
3233 \end_layout
3235 \begin_layout Subsection
3236 Binary I/O:
3237 \end_layout
3239 \begin_layout Standard
3240 Binary I/O file open function is exported as 'jpcrr_raw.io_openbinary(string
3241  name, string mode)'.
3242  It takes two strings, first is name of file to open, second is mode, either
3244 \begin_inset Quotes eld
3245 \end_inset
3248 \begin_inset Quotes erd
3249 \end_inset
3251  or 
3252 \begin_inset Quotes eld
3253 \end_inset
3256 \begin_inset Quotes erd
3257 \end_inset
3260  The returned object has following methods:
3261 \end_layout
3263 \begin_layout Itemize
3264 file:length(): Returns length of file as number.
3265 \end_layout
3267 \begin_layout Itemize
3268 file:set_length(num len): Truncate file to len bytes.
3269 \end_layout
3271 \begin_layout Itemize
3272 file:read(num offset, num length): Read up to length bytes starting from
3273  offset offset.
3274  The file character set is assumed to be Latin1.
3275 \end_layout
3277 \begin_layout Itemize
3278 file:write(num offset, string str): Write str starting from offset offset.
3279  Writing non-Latin1 characters gives unpredictable results.
3280  Only available on files opened for read/write.
3281 \end_layout
3283 \begin_layout Itemize
3284 file:close(): Close file.
3285  No file operations can be done anymore.
3286 \end_layout
3288 \begin_layout Standard
3289 The function should be filtered to enforce path constraints.
3290 \end_layout
3292 \begin_layout Subsection
3293 Text input:
3294 \end_layout
3296 \begin_layout Standard
3297 Text input open function is exported as 'jpcrr_raw.io_opentextinput(string
3298  name)'.
3299  It takes one string, name of file to open.
3300  The returned object has following methods:
3301 \end_layout
3303 \begin_layout Itemize
3304 file:read(): Read next line.
3305  The file encoding is assumed to be UTF-8.
3306 \end_layout
3308 \begin_layout Itemize
3309 file:close(): Close file.
3310  No file operations can be done anymore.
3311 \end_layout
3313 \begin_layout Standard
3314 The function should be filtered to enforce path constraints.
3315 \end_layout
3317 \begin_layout Subsection
3318 Text output:
3319 \end_layout
3321 \begin_layout Standard
3322 Text output open function is exported as 'jpcrr_raw.io_opentextoutput(string
3323  name)'.
3324  It takes one string, name of file to open.
3325  The returned object has following methods:
3326 \end_layout
3328 \begin_layout Itemize
3329 file:write(string line): Write line line to file.
3330  File encoding is assumed to be UTF-8.
3331 \end_layout
3333 \begin_layout Itemize
3334 file:close(): Close file.
3335  No file operations can be done anymore.
3336 \end_layout
3338 \begin_layout Standard
3339 The function should be filtered to enforce path constraints.
3340 \end_layout
3342 \begin_layout Subsection
3343 ECI invoke:
3344 \end_layout
3346 \begin_layout Standard
3347 ECI invocation functions 'jpcrr_raw.invoke(string name [, table args])' and
3348  'jpcrr_raw.invoke_synchronous(string name [, table args])'.
3349  These functions run specified ECI function with specified arguments.
3350  The updates ECI call makes to arguments is reflected to table passed as
3351  parameter.
3352  The synchronous version waits that any slow command processing gets done
3353  before returning (assemble, save, load and dump have such slow processing).
3354  These functions return nothing.
3355  Safe to re-export, use as base for more functions.
3356 \end_layout
3358 \begin_layout Subsection
3359 PC Running:
3360 \end_layout
3362 \begin_layout Standard
3363 'jpcrr_raw.pc_running()'.
3364  Returns true if PC is running, false otherwise.
3365  Assemble, save, load and dump require PC not being running to be possible.
3366 \end_layout
3368 \begin_layout Subsection
3369 PC Connected:
3370 \end_layout
3372 \begin_layout Standard
3373 'jpcrr_raw.pc_connected()'.
3374  Returns true if PC is connected, false otherwise.
3375 \end_layout
3377 \begin_layout Subsection
3378 VGA wait/release:
3379 \end_layout
3381 \begin_layout Standard
3382 'jpcrr_raw.wait_vga()' waits for VGA to enter frame hold mode and returns
3383  true (if it returns false, the wait got interrupted for some reason and
3384  VGA is in rendering mode).
3385  While VGA is in frame hold, PC execution is locked out and things like
3386  memory reading and writing can be done without races (but load/save is
3387  not possible).
3388  'jpcrr_raw.release_vga()' acknowledges frame hold processing (VGA can re-enter
3389  rendering mode).
3390 \end_layout
3392 \begin_layout Standard
3393 Frame hold happens once per frame at start of vertical retrace.
3394  Note that running Lua script must wait frame holds and release them or
3395  main PC execution will hang on first frame hold.
3396 \end_layout
3398 \end_body
3399 \end_document