--- hatari/doc/manual.html 2019/04/01 07:11:39 1.1.1.2 +++ hatari/doc/manual.html 2019/04/09 08:59:42 1.1.1.22 @@ -1,645 +1,2108 @@ - - + +
-project initiator and main developer of Hatari: Thomas Huth <thothy@users.sourceforge.net>
-manual by Matthias Arndt <marndt@asmsoftware.de>
+
+
+Version 2.2.0, January 2019
--Hatari on the WWW: http://hatari.sourceforge.net/ +
+Manual written by: Thomas Huth, Matthias Arndt + & Eero Tamminen
-+Hatari on the WWW: + +http://hatari.tuxfamily.org/ + +
+ +Hatari is an Atari ST emulator for Linux, FreeBSD, BeOS and other -Systems which are supported by the SDL library. See Appendix B -for details on emulation in general.
-Hatari is based on two main sources:
- --Hatari started as an adaption of the free WinSTon source code to Linux. -(WinSTon is a ST emulator for Windows). But since WinSTon's CPU core was -written in i86 assembler, it was not possible to use it for Hatari as -Hatari is intended to be platform independent. So the UAE's CPU core was -used for Hatari instead, because this CPU core has been written in -portable C and also has some nice features like 68040 and FPU support. +
+Hatari is an Atari ST, STE, TT and Falcon emulator for Linux, *BSD, macOS, +Windows and other Systems which are supported by the SDL library. +The emulator is open source software and is distributed under the terms of the +GNU General +Public License (GPL). +
++The Atari ST was a 16/32-bit computer system which was first released by Atari +in 1985. Using the Motorola 68000 CPU, it was a very popular computer having +quite a lot of CPU power at that time. See Appendix B for details on emulation +in general. +
++Unlike many other Atari emulators which try to give you a good +environment for running GEM applications, Hatari tries to emulate the hardware +as close as possible so that it is able to run most of the old games +and demos. Of course you can run normal GEM applications with Hatari, too.
There is support for following additional STE features:
+-At the time of this writing there is neither a complete MMU emulation -nor support for STE specific features. +Hatari can also emulate a Mega-STE, which had slightly different hardware +compared to a normal STE (like a built-in real time clock chip).
-Hatari currently has the following system requirements:
+There is support for following additional TT features:
-
+Note that TT emulation is incomplete – e.g. the second MFP is not +emulated yet. +
+ +There is support for following additional Falcon features:
++Both TT and Falcon emulation support NVRAM for persistent OS configuration +and RTC (real time clock). +
+ +See the developers' doc/todo.txt file +(included with Hatari sources) for the details on the few remaining +emulation gaps and the Hatari Atari +Software Compatibility List for which Atari programs are known +to be affected by them.
+ + ++Hatari needs a fast machine (1 GHz or more for ST/STE emulation, > 2 GHz +for Falcon emulation) which is running a POSIX compatible operating system +(preferably GNU/Linux) that supports the SDL library. +There are also some ports to other operating systems like macOS or Windows, +but they are not used by the developers, so such builds are normally not very +well tested. +
First, you need the SDL library, you can get it at: -http://www.libsdl.org/. Most distributions already ship a suitable version. -Make sure to install the appropriate header files as well often called "libsdl-dev" or the like. -
-Second, you need the zLib compression library. You can get it from http://www.gzip.org/zlib/ -but the version shipped with your distribution will be sufficient in most cases. Make sure to have the header files -for it installed as well. -
+Required:
+Optional:
+-Of course, you need the GNU C compiler and (GNU) Make, too! +The versions available in your Linux distribution will be sufficient +in most cases, but make sure you have also the header files installed +for the libraries as well! Typically they're in a corresponding -dev +package.
-Change to the hatari/ directory and adapt the configuration file -Makefile.cnf to suite your system. -Alternatively, you can use the supplied configure script to auto-detect -all parameters (type "./configure --help" to see the options of the script). -Then compile Hatari by typing make. If all -works fine, you'll get the executable hatari in the src/ subdirectory. +
+After you have verified that you have the required libraries and their +development files, change to the hatari/ +directory. Create a build/ directory under +it and configure the build system for your environment: +
+mkdir -p build +cd build +cmake .. ++
+Then compile Hatari by typing make. +If all works fine, you'll get the executable hatari +in the src/ subdirectory. +
++Note: Instead of calling CMake directly, you can also use the supplied +configure script to run CMake and to give the arguments (like install +prefix) in a format familiar from GNU Autotools using programs. Type +"./configure --help" +to see all the options supported by this script.
Then you'll have to copy a TOS ROM to the data directory (the data directory is specified -in the configuration file Makefile.cnf) and rename it to tos.img, or use the ---tos command line option to tell Hatari where to find a TOS ROM. + +
+Before you can start Hatari, you have to copy a TOS ROM image to the data +directory (<prefix>/share/hatari/, by +default /usr/local/share/hatari/) and +rename it to tos.img, or use the +--tos command line option to tell +Hatari where to find a TOS ROM. Hatari needs a TOS ROM image because this contains the operating system -of the emulated Atari. Sorry, it is not possible to ship an image with -the Hatari package since these images are still copyrighted. But you can -easily create an image with a real ST and one of those various -ROM-image programs for the ST. Or search the internet, but don't ask the Hatari team -where to find one. -
-Another solution is EmuTOS, which is an open-source -TOS clone. You can find EmuTOS at: http://emutos.sourceforge.net/. It's -not the best solution for playing games or running other old software -due to compatibility issues, but it's free and officially compatible with Hatari!
-If you do not specify a TOS image on the commandline nor can Hatari -find a suitable TOS image in the default dir, you'll get the chance to -select a TOS image file from the GUI.
+of the emulated Atari. + ++Unfortunately it is not possible to ship an original ROM +image with the Hatari package since these images are still copyrighted. +But you can easily create an image with a real Atari machine and one of +those various ROM-image programs for them (search for "TOSDUMP" with your +favourite internet search engine).
+Another solution is EmuTOS, which is also shipped with the official +release versions of Hatari. EmuTOS is an open-source TOS clone. You can find +it at: +http://emutos.sourceforge.net/. +It is not the best solution for Falcon emulation, playing old games +or running other old software due to compatibility issues (see +emutos.txt for more details), +but it is free, compatible with Hatari, doesn't require driver to +support harddisk images, and it boots much faster than original TOS.
+If you do not specify a TOS image on the commandline and Hatari +cannot find a suitable TOS image in the default dir, you'll get the +chance to select a TOS image file from the GUI.
Type make install as root to do a systemwide installation. In this case it is recommended -to set the DATADIR variable in Makefile.cnf to a proper value. /usr/local/share/hatari is a good value in that case.
-The Hatari executable should now be in your PATH and accessible from anywhere.
+Type make install as "root" user to +do a systemwide installation.
+Assuming you didn't change the default installation prefix and that +/usr/local/bin/ is in your PATH, you should +be now able to start the Hatari executable from anywhere.
When you finally have got a TOS image, try starting Hatari with the -option --help to find out more about its command line parameters.
+option --help to find out more about +its command line parameters.Now type hatari to run the emulator for the first time. If all goes -well, you should now be presented with a window showing you the familiar -little green desktop of the Atari ST. Press F12 to turn on the GUI to -configure Hatari to suit your needs, press F11 to toggle windowed and fullscreen mode.
- -Hatari ofcourse understands several command line options.
-Type hatari --help to list them all.
-The command line options in detail are as follows (in brackets the -long version):
-| Option | -Purpose | -||
| -h (--help) | -prints command line options and terminates | -||
| -v (--version) | -prints version information and terminates | -||
| -m (--mono) | -starts the emulated Atari ST in monochrome -resolution | -||
| -f (--fullscreen) | -tries to use a fullscreen mode | -||
| -j (--joystick) | -activates joystick emulation via cursor keys | -||
| --nosound | -disables sound (makes emulation faster) | -||
| --frameskip | -drops every second frame (accelerates -emulation) | -||
| -D (--debug) | -activates the simple builtin debugger | -||
| --slowfdc | -slows down FDC emulation (needed to make some games and demos work) | -||
| -d <dir> (--harddrive <dir>) | -emulates <dir> as a hard disk | +Shortcut | +Purpose |
|---|---|---|---|
| --hdimage <imagefile> | -emulate hard disk with an image file | +AltGr+a | +record animation |
| --tos <imagefile> | -specify TOS ROM image to use | -||
| --memsize x | -set amount of emulated RAM - x=0 for 512K, x=1,x=2 or x=4 for 1,2 or 4 MB |
+ AltGr+g | +grab a screenshot |
| --cpulevel x | -specify CPU (680x0) to use (TOS 2.06 only!!) | +AltGr+i | +boss key: leave full screen mode, pause Hatari + and iconify its window |
| --compatible | -use a more compatible but slower 68000 CPU mode | +AltGr+m | +(un-)lock the mouse into the window |
| --blitter | -enable blitter emulation | +AltGr+r | +(warm) reset the ST |
| --vdi | -use extended VDI resolution | -||
| --printer | -enable experimental printer support | +AltGr+c | +cold reset the ST (same as the original power switch) |
| --midi <filename> | -enable experimental MIDI output to the mentioned file | +AltGr+d | +open dialog to select/change disk A |
| --rs232 <filename> | -enable experimental RS232 communication via the mentioned file | +AltGr+s | +enable/disable sound |
| -c <filename> (--configfile) | -Use the mentioned file as configuration file instead of ~/.hatari.cfg | -
Once you've started Hatari succesfully, you can use the emulator as -an allmost complete Atari ST computer system.
- -Press F12 to enter the GUI. Navigate it with the mouse. -The GUI is rather self explanatory.
-Click to go back to the emulated ST. All checked options will be applied.
-Check the option if you want the emulated ST to perform a soft reset. This should be equal to pressing the reset button on your ST. -
-Click to terminate Hatari and return to the host OS.
-Click to abandon any changes made.
- -Check the CPU type to use here, enable prefetch mode and if the Blitter should be active.
-For best Atari ST compatibility choose plain 68000 here.
-The Timer-D patch changes the Timer-D initialization from TOS. TOS uses Timer-D as a baudrate generator for RS232. -The TOS default slows the emulation down so the patch gives you a faster emulation. -
-You can disable the Timer-D patch if games or demos require the original TOS setting.
-NOTE: These parameters are very sensitive to the emulated ST and it is strongly recommended to -reset the emulated ST after changing these options.
- -Use the upper dialog to choose which floppy disks should be emulated in the disk drives.
-You can use most standard Atari ST disk image files. See the chapter "Floppy disk images" -for details.
-Click on the button next to the A: and B: option to go to the fileselector. -You may select and browse zipped disk images as well.
-Click on to eject a disk image from the emulated drive. The emulated ST will act as if had no floppy disk in its drive.
-You can specify a default directory where Hatari will start to browse the filesystem.
-Check the "Auto insert B" option if you want Hatari to be smart and insert the second disk -of a two disk game automatically. This option will insert the second disk in drive B and some -games may not be able to find the disks there. In that rare case you will need to insert the -second disk manually when prompted.
--NOTE: This option does not always work properly. -
- -If you need to create a new blank disk image, click on . -Parameters for the new image can be set in the following dialog. Click on create to create the image or on to get back to the -disk dialog. -
--After clicking , a fileselector appears. You can browse the filesystem now. Select the target directory, click beside File: -and type in a name for the new disk image. The name should terminate with .st or .msa. -
-Hatari can currently create plain .ST and .MSA disk images exclusively.
- -Use the lower dialog to change the harddisk settings.
-You can select a harddrive image for harddrive emulation via image file here or you may select -a directory of your local filesystem to be emulated as the ST's harddrive.
-Check "Boot from HD" if you want Hatari to execute the AUTO folder on the harddrive. -This option is checked by default if you specify a harddrive image or a directory via the command line.
- -You can select the amount of RAM for the emulated ST here.
-Note: This option is critical and you are strongly advised to reset the emulated ST -when changing this option.
-Here you will find the options to save memory snapshots as well.
-Click on to save a memory snapshot to file. You can select a new filename here.
-Click on to restore a memory snapshot from a file. Use the fileselector to select the snapshot to be restored.
-NOTE: Memory snapshots should be considered EXPERIMENTAL and the Hatari team strongly advises you not to rely on them yet!
- -Here you can select the TOS image to use. Click on to select it via the fileselector.
-In the GEM setup you can select a larger resolution for GEM conformant apps. Select resolution -and colour depth. Almost all games and demos will not work in one of these resolutions.
-Note: These options are critical and you are strongly advised to reset the emulated ST -when changing one of these option.
- -Here you can select which joystick you want to emulate via the cursor keys.
-Joystick 1 is the normal ST joystick port and 99.9% of all ST games use this port, Joystick 0 -emulates a joystick plugged into the ST mouse port allowing you to play 2 player games.
-If no joystick is checked here, joystick emulation is done via a connected PC joystick.
-See the chapter "Emulated Joystick" for details.
- -Here you control the video output of the emulated ST.
-Check "Fullscreen" to run Hatari fullscreen, default is windowed.
-Check "Interlace" if you wish to have that old TV feeling in Hatari. Every second line will be black. -This will only work in ST-MEDIUM or ST-LOW in scaled up resolutions.
-Check "Frame Skip" to speed Hatari up if emulation is too slow. This will only draw every second ST frame -instead of the default of drawing every ST frame. Uncheck if you have a fast PC.
-Check "Use Borders" if you wish to have the borders around the ST screen.
-"Force 8Bpp" will force SDL to use an 8bit video mode. You don't need this for modern video cards.
-You can select which sort of monitor to use. Check "Color" for games and demos. If you check "Mono" here, -Hatari will emulate the good old SM124 and will not allow you to switch to color modes from the running ST. -This toggle acts like a monitor switch with a color and monochrome monitor connected.
-"ST-Low mode" will control if Hatari renders ST-LOW to a 320x200 or 640x400 PC display (with borders turned off) or 384x267 or 768x534. -Basically select this to toggle between a small or a large window.
-Click to create a screenshot in .BMP format to the current working directory or click to record a sequence of single screenshots. -
- -Here you can select the keyboard mapping to use.
-Two different mappings called "Symbolic" and "Scancode" are predefined.
-You can also load a custom keymapping file here if you wish. Please note that selecting to use a custom keyboard mapping will -use the "symbolic" mapping for all keys not defined by your map file. See the supplied example mapfile on how to build your -own keyboard mapping.
- -Here you can control the sound subsystem.
-Check if you want emulated sound at all. Emulation is faster if sound emulation is turned off.
-3 frequencies from low to high quality are available. Experiment a little bit to find out which fits best for your setup. -Medium quality will work ok in most cases.
-You can select to record a piece of sound here. Check which format to use and click the button. It is a toggle button so -you will need to return to the GUI to switch sound recording off again.
- -Check here if you want to enable experimental printer support. See the chapter "Emulated printer" for details.
-As Hatari currently only supports printing to file, click on to select the file to print to. You can enter a new filename as well.
-NOTE: As the printer emulation is not perfect yet, activated printer support may interfere with the emulated sound. -This is due to the fact that the Atari ST uses some general I/O ports of the soundchip for the printer port. The Hatari team suggests to -disable printing while using games and demos. -
-Check the second checkmark if you want to enable experimental RS232 support. The RS232 device is configured according to the settings of the emulated RS232 of the Atari ST. This means Hatari will automatically use baudrate and handshaking as configured for the emulated ST.
-Select a suitable device file for input and output. Click on to select. -A good choice is /dev/ttyS0 or /dev/ttyS1. -
-You can enable MIDI as well. This currently work for outputting MIDI data only. A good choice is /dev/midi00.
-Click on to select a suitable MIDI device file for output.
-Your sound driver must support MIDI to make this work.
- -NOTE: RS232 and MIDI emulation are very experimental, too. -Don't enable them unless you really need them! -
- -While the emulator is running, you can activate or toggle various -features via the following keyboard shortcuts.
- -| Shortcut | -Purpose | +AltGr+q | +quit the emulator |
| ALTGR+a | -record animation | +AltGr+x | +toggle normal speed/fast forward |
| ALTGR+g | -grabs a screenshot | +AltGr+y | +enable/disable sound recording |
| ALTGR+i | -boss key: leave full screen mode and iconify window | +AltGr+k | +save memory snapshot |
| ALTGR+j | -activates joystick emulation via cursor keys | +AltGr+l | +load memory snapshot |
| ALTGR+m | -(un-)locks the mouse into the window | +AltGr+j | +toggle joystick emulation via cursor keys + on/off between ports 0 and 1 |
| ALTGR+r | -(warm) reset the ST | +AltGr+F1 | +switch joystick type on joy port 0 |
| ALTGR+c | -coldreset the ST (same as the original power switch) | +AltGr+F2 | +switch joystick type on joy port 1 |
| ALTGR+s | -enable/disable sound | +AltGr+F3 | +switch joystick type for joypad A |
| ALTGR+q | -quit the emulator | +AltGr+F4 | +switch joystick type for joypad B |
| ALTGR+x | -toggle normal/max speed | +AltGr+b | +toggle borders on/off |
| ALTGR+y | -enable/disable sound recording | +AltGr+f or F11 | +toggle between fullscreen and windowed mode |
| F11 | -toggles fullscreen and windowed mode | +AltGr+o or F12 | +activate the options GUI |
| F12 | -activate the GUI You may need to hold SHIFT down while in windowed mode. |
+ Pause | +pause emulation |
| PAUSE | -will go to the debugger if it was activated at compile time | +AltGr+Pause | +invoke the internal Hatari debugger |
You can change the key bindings from the Hatari configuration file. +See keymap-sample.txt file for instructions.
+ +All other keys on the keyboard act as the normal Atari ST keys so pressing SPACE on your PC will result in an emulated press of the SPACE key on the ST. The following keys have special meanings:
-| Key | -Meaning | +Key | +Meaning |
|---|---|---|---|
| Alt | -will act as the ST's ALTERNATE key | +Alt | +will act as the ST's ALTERNATE key |
| left CTRL | -will act as the ST's CONTROL key | +left CTRL | +will act as the ST's CONTROL key |
| Print Screen | -will emulate the ST's HELP key | +Print Screen | +will emulate the ST's HELP key |
| Scroll Lock | -will emulate the ST's UNDO key | +Scroll Lock | +will emulate the ST's UNDO key |
| Page Up | -will emulate the ST's ( key in the keypad | +Page Up | +will emulate the ST's ( key in the keypad |
| Page Down | -will emulate the ST's ) in the keypad | +Page Down | +will emulate the ST's ) in the keypad |
ALTGR will act as ALTERNATE as well as long as you do not press it -together with a Hatari hotkey combination.
-The right CTRL key is used as the fire button of the emulated -joystick when you turn on joystick emulation via keyboard.
-The cursor keys will act as the cursor keys on the Atari ST as long as joystick emulation -via keyboard has been turned off.
+If joystick emulation via keyboard is enabled, by default cursor keys +are used for the directions and right CTRL key +as the fire button. Otherwise they act as corresponding keys of the emulated +Atari ST.
+ +NOTE: Problems with simultaneous keypresses most likely aren't an +issue in Hatari as many modern keyboards report/support only three +simultaneous key presses (or even just two depending on which keys +are in question). Expensive gaming keyboards support more.
+For obvious reasons your PC mouse will act as the emulated Atari ST mouse. In fullscreen mode it will act as expected, directly controlling the ST mouse pointer.
-However it is a little bit different in windowed mode. To make the -mouse work there as expected you need to grab it first or lock it into -the Hatari window. Do this by pressing the ALTGR+m hotkey combination. -Press it again to go back to normal mouse behaviour which allows you to -work in other X11 windows while Hatari is up and running.
+However it is a little bit different in windowed mode as +mouse cursor positions between host and emulated Atari can get +out of sync. This can be worked around by constraining the mouse +to the Hatari window. Pressing the AltGr+m +hotkey combination or starting Hatari with the +--grab command line option +grabs the mouse i.e. locks its movements to the Hatari window. +Press the shortcut key (again) to go back to normal mouse behaviour +which allows you to move mouse outside the Hatari window while +Hatari is up and running. Note: pausing the emulation will also +(temporarily) release the mouse grab.
+Middle button click emulates double click, which is very useful +in Fast Forward mode (where normal double clicking is nearly +impossible).
+Mouse scrollwheel will act as cursor up and down keys.
The Atari ST joysticks are emulated ofcourse allowing you to play + +
The Atari ST joysticks are emulated of course allowing you to play your favourite games with Hatari.
The default mode is to use a connected PC joystick. You can use any -joystick that is supported by your kernel. If your joystick works with -other applications, it will likely work with Hatari as well. Make sure +joystick that is supported by your kernel / SDL library. If your joystick works +with other applications, it will likely work with Hatari as well. Make sure it is calibrated and then off you go. Move the stick to point into the desired direction. Please note that Hatari will not detect analogue movement as the Atari ST only had digital joysticks. The first -firebutton will act as the normal firebutton on the Atari ST while the second -firebutton will emulate a keypress of the SPACE key on the ST as many ST -games utilitze the SPACE bar for secondary game functions. (Xenon for example)
+firebutton will act as the normal firebutton on the Atari ST while the +second +firebutton will emulate a keypress of the SPACE +key on the ST as many ST +games utilize the SPACE bar for secondary game functions. (Xenon for +example)If you do not have a PC joystick or joypad, then you do not need to desperate. You can emulate one of the two Atari ST joysticks via the cursor keys. Just activate it in the GUI. Then the cursor keys will act as the joystick directions, the right CTRL key will act as the firebutton. You can still use the cursor keys as the ST's -cursorkeys in this mode as long as you press SHIFT along with the cursorkeys.
+cursorkeys in this mode as long as you press SHIFT +along with the cursorkeys. You can also configure these keys from the +joystick options.Hatari by default only handles ST modes, ST-LOW, ST-MED and ST-HIGH.
-Overscan effects and socalled "Border Removal" are possible too.
-Due to the fact that these effects are achieved by using quirks and glitches in the original chips to do things beyond their specification emulation is a bit tricky for these and not all ST applications utilizing these techniques will work properly in Hatari. -Especially socalled "Sync Scrolling", a special technique to emulate the low byte of the video address, currently does not work properly in Hatari. -
-Beside that you can setup extended VDI modes. These only work with GEM-compliant applications and they are equal to fitting a videocard into your Mega ST.
-Make sure to disable extended VDI modes for playing games as 99% of all ST games will not be able to make use of higher resolutions.
- -Due to the fact that printer handling is very different between Unix style machines and the Atari ST, emulation -of the printer is achieved by writing all printer output to a file.
-The file will contain a sequence of data, the same that would appear on the data pins of the Atari ST printer port. -That would include control characters and commands for graphic printing. Clicking "Print desktop" on the GEM desktop would result +
Hatari emulates all screen modes of the original machine.
++ST/STE shifter overscan effects are emulated, but due to the fact +that these effects are achieved by using quirks and glitches in the +original chips to do things beyond their specification, emulation is +a bit tricky for these effects. As a result, some demos using these +techniques might not be displayed correctly in Hatari, known ones are +listed in the compatibility.html file. +
+Beside that you can setup extended VDI modes. These only work with +GEM-compliant applications and they are equal to fitting a videocard +into your Mega ST.
+Make sure to disable extended VDI modes for playing games as 99% of +all ST games will not be able to make use of higher resolutions.
+ +Due to the fact that printer handling is different on Atari and +current machines, emulation of the printer is achieved by writing all +printer output to a file.
+The file will contain a sequence of data, the same that would appear +on the data pins of the Atari ST printer port. +That would include control characters and commands for graphic +printing. Clicking "Print desktop" on the GEM desktop would result in a messy data dump in the printer output.
-Printer emulation works best for plain text files or programs that do not format the output for a specific printer. -The file contents can be used with your favourite text editor for further processing and printing to a real printer.
-To get real direct printing out of Hatari on a PostScript printer, you may set up a GDOS printer with a PostScript driver on the emulated Atari and set your printer device file as Hatari's printer output.
-NOTE: This has not been tested yet and the Hatari team cannot guarantee that it will work.
Printer emulation works best for plain text files or programs that +do not format the output for a specific printer. +The file contents can be used with your favourite text editor for +further processing and printing to a real printer.
+To get real direct printing out of Hatari you may set up a suitable
+(e.g. PostScript) GDOS or NVDI printer driver on the emulated Atari and
+set your printer device file as Hatari's printer output.
+NOTE: If the driver doesn't match or there's some other problem,
+this can cause your printer to print out hundreds of pages of garbage.
Serial communications in Hatari is designed to directly use a serial port on your PC.
-Communications parameters are set automatically upon the settings of the emulated ST. This means all you do is to set -the communication parameters like baudrate from your ST communications software. Hatari will do the rest and handle -the serial input and output for you.
-Serial communications in Hatari is designed to directly use a serial +port on your PC.
+Communications parameters are set automatically upon the settings of +the emulated machine. This means all you do is to set the communication +parameters like baudrate from the emulated communications software. +Hatari will do the rest and handle the serial input and output for you.
+Note that the “normal” RS232 port of Hatari is the one that +is connected to the MFP chip of the selected system. This port is only +wired on the ST, STE and TT machines, but not on the Falcon. To use serial +port emulation in Falcon mode, you have to use the “SCC channel B” +emulation instead.
+ +Hatari does not use floppy disks directly but disk images due to differences between the floppy disk controllers of the ST and the PC. -Three types of disk images are currently supported: The raw "ST" type, the similar "DIM" type and -the compressed "MSA" (Magic-Shadow-Archiver) type.
+Several types of disk images are currently supported : + + +The raw type (file suffix should be "*.st") is simply a sector by sector image of a real floppy disk. You can easily create such an image -with the dd program which should normally be pre-installed on every -Unix-like system. Simply type something like dd if=/dev/fd0 of=myimage.st to create a disk image. Of course you need access to +with the dd program which should +normally be pre-installed on every +Unix-like system. Simply type something like dd +if=/dev/fd0 of=myimage.st to create a disk image. Of course you +need access to /dev/fd0, and depending on your system and the type of floppy disk you might have to use another device name here (for example I use -/dev/fd0u720 for 720kB disks). However, if the disk is copy-protected or +/dev/fd0u720 for 720kB disks). However, if the disk is copy-protected +or doesn't use a MSDOS compatible file system, this might fail. So be very -careful if you're not sure about the disk format.
-The other possibility is to image the disk on a real Atari ST. There +careful if you are not sure about the disk format.
+The other possibility is to image the disk on a real Atari ST. +For non-protected disk, there are programs like the Magic Shadow Archiver for this task. Hatari -supports this slightly compressed MSA disk images, too. Note that Hatari -only supports the "old" MSA format, there are some Magic Shadow Archiver +supports this slightly compressed MSA disk images, too. Note that +Hatari +only supports the "old" MSA format, there are some Magic Shadow +Archiver clones (like Jay-MSA) that create better compressed but Hatari-incompatible disk images. However, if you have got such a MSA -disk and want to use it with Hatari, you can still run the corresponding +disk and want to use it with Hatari, you can still run the +corresponding MSA program within Hatari to extract the incompatible disk image to a -normal floppy disk image.
-While *.ST and *.MSA are more or less the "standard" types of Atari +normal floppy disk image. +
+For protected disk, the most widely used method is to run pasti.prg on
+a real Atari ST and get a .STX image.
+
+For more complex protections or altered disk, one can use *.IPF or *.CTR
+which include tools to check MFM data and possible problems when dumping a disk.
+
While *.ST, *.MSA and *.STX are more or less the "standard" types of Atari disk images, you might sometimes also find STT or ADF images on the -internet. These currently do not work with Hatari.
- -Hatari can now also utilize *.DIM images just as *.ST ones without any problems. +internet. These currently do not work with Hatari.
+Hatari can now also utilize *.DIM images just as *.ST ones without +any problems. Note that DIM images are nearly the same as the raw ST images -(they only have an additional 32 bytes header), so you can easily transform +(they only have an additional 32 bytes header), so you can easily +transform the DIM images into ST images by stripping the header from the files. For example try something like: dd if=input.dim of=output.st bs=32 skip=1
- -If you've got a disk image that has been created with the old ST +
If you have got a disk image that has been created with the old ST emulator PaCifiST (for DOS) or with early versions of the program Makedisk, and the disk image does not work with Hatari, then the disk -probably suffers from the "PaCifiST bootsector bug" (Hatari will print a +probably suffers from the "PaCifiST bootsector bug" (Hatari will +display a warning message then). In this case, the bootsector of the disk contains some illegal data, so that the disk even does not work on a real ST any more. However, if it is a .ST and not a .MSA disk, you can -easily fix it by using a hex-editor to change the byte at offset $D (13) +easily fix it by using a hex-editor to change the byte at offset $D +(13) from 0 to 1 (don't forget to backup your disk image first, since you can also easily destroy your disk image when changing a wrong byte there). If the disk contains a bootsector program, you probably have to @@ -647,319 +2110,2608 @@ adjust the boot sector check sum, too (i $1FF).
Hatari supports disk images that are compressed with (Pk-)ZIP (file suffix must be ".zip") or GZip (file suffix must be ".st.gz" or -".msa.gz"), so you can archive your disk images into zip archives. +".msa.gz"), so you can archive your disk images into zip archives. You can also directly run the zip archives you may download from the net as long as the archive contains a disk image in .ST or .MSA format.
-Note: Hatari does not save disk images back to *.ZIP files so +
Note: Hatari does not save disk images back to *.ZIP files +so your highscores and savegames are lost if you load the game from such a zipped disk image.
+Hatari supports two ways of emulating a ST hard drive: The low-level -ACSI hard disk emulation and a GEMDOS based drive emulation.
-To use the ACSI hard disk emulation, you need a hard disk image file -with a pre-installed HD driver in it. So either try to image your old ST -hard disk or grab one from the internet. There is a HD image on the -Hatari web page for download. Perhaps we'll also provide a tool for -creating HD images one day.
-With the GEMDOS based drive emulation, you can easily "mount" a -folder from the host file system to a drive of the emulated Atari. To -use the GEMDOS based drive emulation, you should use a folder on your -hard disk that only contains files and folders with valid TOS filenames. -That means that all files/folders should be written in capital letters -and their length mustn't exceed the 8+3 file name length limit. If you -don't want to rename all files to get capital letters, it is also -possible to store that folder on a FAT filesystem since those -filesystems are case-insensitive.
-GEMDOS drive emulation is an easy way to share files between the -host system and the emulated Atari, but it is known to be incomplete and -a little bit unstable, especially if you use it together with the ACSI -hard disk emulation. So if your programs complain that they could not -find/read/write files on the GEMDOS HD drive, you should try to copy -them to a floppy disk image or a real hard disk image!
-Note that changing the HD-image or the GEMDOS HD-folder will reset -the emulated Atari since it is not possible to switch the hard disk -while the emulator is running.
-May the fun without the price to be with you ;-) !
+ ++Hatari supports three ways of emulating Atari hard drives: The +low-level ACSI and IDE hard drive emulation and a GEMDOS based HD +emulation. In most cases the GEMDOS HD emulation is best as it allows +exchanging files easily between the emulated and the host environment. +
++Please note that changing the HD-image or the GEMDOS HD-folder will reset +the emulated Atari since it is not possible to switch the hard drive +while the emulator is running. +
++On a 32-bit host system, the size of a hard disk image is limited to 2 GB. +On 64-bit host systems, bigger images might be possible but the support +for bigger images is not tested very well yet. +
++The maximum size of partitions inside the hard disk (images) depends on the +TOS version. TOS 1.00 and 1.02 support up to 256 MB, TOS 1.04 to 3.06 up to +512 MB and TOS 4.0x supports up to 1 GB partitions. +
++NOTE: you need to be careful when mounting device files. Depending on +the system setup (e.g. udev settings) partitions on memory cards etc. +can be mounted automatically. When Hatari is started and uses a device +file with partitions that are already mounted, data can be destroyed +(when several programs independently write to the same device). +Disable your desktop automount, or remember to manually unmount +devices before giving them to Hatari. +
+ + ++With GEMDOS HD emulation, you can easily "mount" a folder from the +host file system to a drive of the emulated Atari. +
++If you provide Hatari a directory containing only single letter (C-Z) +subdirectories, each of these subdirectories will be treated as a +separate partition, otherwise the given directory itself will be +assigned to drive "C:". In the multiple partition case, the letters +used as the subdirectory names will determine to which +drives/partitions they're assigned. For example following +directory setup: +
++partitions/ + + C/ + + D/ ++
+That is given to Hatari as "hatari -d partitions", will give you +GEMDOS HD emulated C: and D: drives. +
++GEMDOS HD emulation is an easy way to share files between the +host system and the emulated Atari, but there are also several +limitations: +
++If your programs complain that they could not find/read/write +files on the GEMDOS emulated drive, you can copy and use them +from a floppy disk image or a real hard disk image instead. +
+ + ++Accessing HD image files is easiest with EmuTOS. It supports both +ASCI and IDE interfaces, regardless of emulated machine type, and +understands DOS partition tables without additional drivers. +atari-hd-image.sh script coming +with Hatari can be used to create such image files and to copy +initial data to them. +
++If you have an hard drive (image) with Atari format partition table, +that should already have hard disk driver on it and work fine. +Partitioning/formatting them is the problem. Creating such images +from scratch is described in following sections. +
+ + ++To use the ACSI hard drive emulation, you need a hard disk image file +with a pre-installed HD driver in it. You can try to get an image of +your old ST hard disk or grab one from the internet (e.g. from the +Hatari website). +Please note that the size of ACSI hard drive is normally limited to 1 GB +due to some addressing constraints of the ACSI bus. Bigger disks were only +possible with certain host adapters – this behaviour is emulated by +Hatari, too, but you need a hard disk driver that supports these extensions. +
++To create a new ACSI hard disk image, you can start with an empty +image that you have created for example with the following command: +dd if=/dev/zero of=hd.img bs=512 count=xxx +(where 'xxx' is size in 512 byte blocks). Copy the complete AHDI 5.0 +package to a floppy disk image, then boot Hatari with this floppy disk +image and the fresh hard disk image like this: +--acsi hd.img ahdi.st. +Then start HDX.PRG from the floppy disk and format + partition the hard +disk image with it. +
++Formatting and partitioning works currently only with AHDI 5, but you +can install the AHDI 6 driver to the hard disk after it is formatted. +Restart the emulated system, run AHDI.PRG from the floppy disk to access +the hard disk image from the emulated Atari and then run HINSTALL.PRG. +After installing the hard disk driver to the fresh HD image with +HINSTALL.PRG, you can boot directly from the hard disk image. +
++HD Driver (v9) partitioning is also compatible with Hatari ACSI +emulation. CBHD and ICDPro AdSCSI drivers work on images which have +been partitioned elsewhere. +
+ + ++As the IDE disk format (little endian) differs from the ACSI disk format +(big endian), you need separate disk images for them. Hatari doesn't +currently support partitioning IDE disks with AHDI, but you can do it with +Cecile. +
++First create an empty image file with the size of your choice with: +dd if=/dev/zero of=hd.img bs=1k count=xxx. +Then get the Cecile hard disk driver from +http://centek.free.fr/atari/softs/s_cecile.htm +and put it on a floppy disk image (e.g. to one named "cecile.st" using: +zip2st.sh cecile.zip). +
++Run Hatari with +hatari --machine falcon --tos tos404.rom +--ide-master hd.img cecile.st, switch to larger color resolution +and warm up your French language skills. Then start the Cecile hard +disk driver CECILE.PRG and run CC_TOOLS.APP to partition your hard +disk image. Click the "Partition" button, select "Hatari IDE disk" and set +suitable partition size with the arrows (below type field). Then click +"Valider". +
++If you only want to use your HD image in Falcon mode, you can install +the Cecile hard disk driver to the image from the Cecile CC_TOOLS.APP: +Click the "Installer" button and save the Cecile driver to the +1st partition on "Hatari IDE disk". If you want to also use your HD +image in ST/STE mode, you need to get and install either HD Driver or +AHDI 6 driver on it instead (see ASCI +hard drive emulation section). +
++Then you can boot from your hard disk image by simply specifying it +with the --ide-master parameter. +
+ + +Moving files to and from Atari hard disk images can be done +either through GEMDOS HD partitions (host directories mounted inside +Hatari emulation) or accessing the images directly on the host +(outside the emulation). Both have their own limitations.
+ +If it is fine for the IDE/ACSI partitions to be first, you can +either use ACSI/IDE partition skip option, or a multipartition GEMDOS +HD setup as described in above sections. +
+ +If you want to boot from a GEMDOS HD partition i.e. such to be +before hard disk image partitions, and still to be able to access all +the IDE/ACSI partitions, you need to use HD Driver. Note: this is the +preferred method with EmuTOS (v0.9.x), because it doesn't run/use +driver installed to the IDE/ACSI image directly although its own +partition table/type support is very limited.
+ +Uwe Seimet's HD +Driver works fine with both the Hatari GEMDOS HD partitions and normal +hard disk images. +
+ +First copy the HDDRIVER.PRG binary into your GEMDOS HD emulation +directory AUTO folder. Then start the HDDRUTIL.APP configuration utility, +locate HDDRIVER.PRG, open the +"Devices +and Partitions" dialog and select the "Preserve Existing Partitions" +option. Then you can just start Hatari with your hard disk image and +this GEMDOS HD directory, for example like this: +"hatari --harddrive gemdos-hd/ --ide-master +ide-hd.image".
+ +If you're using +the demo version +of HD Driver, you can write files only to the C: partition, i.e. in +above case only copy files from the hard disk image partition to the +GEMDOS HD partition (with some write slowdowns included into the demo +version). If you want to copy files to the hard disk image with +the demo version of the HD Driver, you need to set the hard disk +image as drive C:.
+ +To accomplish this, set the GEMDOS HD partitions to be from D: forward, +i.e. have a directory which contains only single letter subdirectories, +starting from "D" like in "mkdir gemdos-hd; +mkdir gemdos-hd/D". Then give Hatari (as the last parameter) +a boot floppy image containing the demo version of HDDRIVER.PRG in +its AUTO folder, like this: "hatari +--ide-master ide-hd.image --harddrive gemdos-hd/ hd-driver-floppy.st". +You can convert HD Driver ZIP package to floppy image with the +zip2st utility.
+ + ++If you want to access the hard disk image partitions also outside +the emulation, the disk image needs to have a DOS partition table. +The atari-hd-image script included +with Hatari can be used to create such an image. +
++Inside the Hatari emulator, EmuTOS can access partition(s) on these +kind of images directly without any driver software. Of the Atari HD +drivers mentioned above, Centek's Cecile and Uwe Seimet's HD Driver +(demo) work fine with these partitions. E.g. AHDI and CBHD don't. +Cecile works only with TT or Falcon. +
++To summarise; if EmuTOS is enough, use that. Otherwise, if you want to +use TT or Falcon emulation, use Cecile (or full HD Driver version if +you have it), otherwise use HD Driver (demo). +
++To access the content of the partitions on Linux host, there are two +possibilities: + +
+For this you need to add an entry for the hard disk +image to your ~/.mtoolsrc and +specify which partition you want to access from the image. For +an image created with the above mentioned script, the line in +the configuration file should look something like this: +
++MTOOLS_NO_VFAT=1 +drive c: file="/home/user/hatari/hd.img" partition=1 ++
+Note that Mtools is instructed to use FAT compatibility mode because +EmuTOS cannot deal properly with VFAT file information. If you don't +want this setting for all your Mtools drives, you can set it also via +the environment like this ("::" refers to the drive image given with +the "-i" option): +
++MTOOLS_NO_VFAT=1 mcopy -spmv -i hd.img files/* :: ++ +
+This is recommended even by Mtools documentation, but it is less convenient +as it requires root rights. First you need to "loop" mount the image: +
+
+$ su
+# image="hd.img"; mountdir="hd"
+# start=$(parted $image unit s print | awk '/ 1 /{print $2}' | tr -d s)
+# losetup -f $image -o $((512*$start))
+# loop=$(losetup -a | tail -1 | cut -d: -f1)
+# mkdir -p $mountdir
+# mount -t msdos $loop $mountdir
+
++This uses parted to find out the first +partition offset in sectors and then tells losetup +to bind the first free loop device to a corresponding offset from +the hd.img image. +mount is then used to mount the file system +from the loop device on top of the "hd" directory. +
++After you have copied the relevant files to the "hd" directory, you need +to unmount the file system and remove the loop device binding before +using the disk image from Hatari: +
++# umount $mountdir +# losetup -d $loop ++ + +
+Hatari has a built-in debugging interface which can be used for +analyzing code that runs in the emulated system. +
+ ++On Unix (Linux / macOS) debugger uses Hatari's parent console window, so +make sure you run Hatari from the command line when you want to use +the debugger. On Windows you need to use "-W" option to get console +window. You can add an icon to your desktop that does it. On Linux +it should do something like this (replace "xterm" with your favorite +terminal program): +
++xterm -T "Hatari debug window" -e hatari ++ +
+To run debugger commands from a file at Hatari startup, one can use +the "--parse <file>" command line option. This is useful e.g. +for debugging TOS or some demo startup code, or if you always want to +use some specific debugger setup (breakpoints etc). +
+ ++Note that when debugger scripts are run, current directory is set to +the currently running script's directory i.e. all file operations are +relative to it. After script finishes, earlier current directory is +restored. To set current directory from a setup script, e.g. for +scripts run at breakpoints, you need to give '-f' option for the +'cd' command. +
+ + ++You can invoke the debugger manually by pressing the +AltGr + Pause key combination. +
+ ++With the "-D" command line option, you can toggle whether m68k +exceptions will also invoke the debugger. Which exceptions cause +this, can be controlled with the "--debug-except" option. +
+ ++Giving "-D" option at Hatari startup is not advised because TOS HW +checks generate some exceptions at every TOS boot. It is better to +toggle exception catching later from the debugger with the "setopt -D" +command. +
+ ++Alternatively, you can give "--debug-except" option "autostart" flag +(e.g. "--debug-except all,autostart"). This will enable catching of +(specified) exceptions after TOS boot, when Atari program given on +Hatari command line is autostarted. +
+ + ++At the debugger prompt, type "help" to get a list of all +the available commands and their shortcuts: +
++Generic commands: + cd ( ) : change directory + evaluate ( e) : evaluate an expression + help ( h) : print help + history (hi) : show last CPU/DSP PC values & executed instructions + info ( i) : show machine/OS information + lock ( ) : specify information to show on entering the debugger + logfile ( f) : open or close log file + parse ( p) : get debugger commands from file + rename ( ) : rename given file + reset ( ) : reset emulation + setopt ( o) : set Hatari command line and debugger options + stateload ( ) : restore emulation state + statesave ( ) : save emulation state + trace ( t) : select Hatari tracing settings + variables ( v) : List builtin symbols / variables + quit ( q) : quit emulator + +CPU commands: + address ( a) : set CPU PC address breakpoints + breakpoint ( b) : set/remove/list conditional CPU breakpoints + disasm ( d) : disassemble from PC, or given address + profile ( ) : profile CPU code + cpureg ( r) : dump register values or set register to value + memdump ( m) : dump memory + memwrite ( w) : write bytes to memory + loadbin ( l) : load a file into memory + savebin ( ) : save memory to a file + symbols ( ) : load CPU symbols & their addresses + step ( s) : single-step CPU + next ( n) : step CPU through subroutine calls / to given instruction type + cont ( c) : continue emulation / CPU single-stepping + +DSP commands: + dspaddress (da) : set DSP PC address breakpoints + dspbreak (db) : set/remove/list conditional DSP breakpoints + dspdisasm (dd) : disassemble DSP code + dspmemdump (dm) : dump DSP memory + dspsymbols ( ) : load DSP symbols & their addresses + dspprofile (dp) : profile DSP code + dspreg (dr) : read/write DSP registers + dspstep (ds) : single-step DSP + dspnext (dn) : step DSP through subroutine calls / to given instruction type + dspcont (dc) : continue emulation / DSP single-stepping ++ + +
+After writing (with TAB completion) one of the above command names, +pressing TAB will (for most commands) show all the available subcommands. +
+ ++If you want to give numbers in other number bases +than the default/selected one, they need to be prefixed with a +character indicating this. For decimals this prefix is "#" (#15), +for hexadecimals "$" ($F), and for binary values it is "%" (%1111). +
+ ++By default debugger expects all numbers without a prefix to be +decimals, but you can change the default number base with the "setopt" +command, just give it the desired default number base (bin/dec/hex). +When using the hexadecimal number base, remember still to prefix +hexadecimal numbers with '$' if they could be confused with register +names (a0-7, d0-7)! Otherwise results from expressions and +conditional breakpoints can be unexpected. +
+ + ++Instead of a number, you can also use an arithmetic expression, by +surrounding it with quotes (""). An expression can contain +calculations with CPU and DSP registers, symbols and Hatari variables +in addition to numbers. For example to give a sum of A0 and D0 +register values to a command, use "a0+d0". +
+ ++Also within arithmetic expressions, parenthesis are used to indicate +indirect addressing, not to change the order of precedence. +Unlike with conditional breakpoint expressions (explained below), you +cannot give size for the indirect addressing, a long value is always +read from the RAM address given within parenthesis. For example to +get a long value pointed by stack pointer + 2, use "(a7+2)". +
+ ++Values of arithmetic expressions are always evaluated before being +given to a command. Except for "evaluate" and "address" commands, +they always need to be marked with quotes (""). Besides arithmetic, +this can be used also to give symbol/register/variable values to +commands that don't otherwise interpret them. If command complains +that it didn't recognize e.g. a register name, just put it to quotes +and it will be "evaluated" before being given to the command. +
+ ++Virtual V0-V7 "registers" can be used to store intermediate results +for calculations. For example, to get a sum of "_counter" symbol +address contents one could use following in suitable breakpoint: +
++# store counter sum to V0 virtual register +r v0=(_counter) +# store count of how many values are added +r v1="v1+1" ++
And then later on, calculate the average:
++# round the counter sum (add half count to sum) +r v2="v0 + v1/2" +# and calculate the rounded average (rounded sum / count) +e v2/v1 ++
(Another virtual register was used for rounding here, in case one +wants to continue summing the _counter values with the original +value.) +
+ ++With command argument completion (see build +notes), result from the last "evaluate" command can be inserted +by typing '$' and pressing TAB. +
+ + ++In the beginning, probably the most interesting commands are "m" and "d" +for dumping and disassembling memory regions. You can use "dm" and "dd" +commands to do the same for the DSP. +
++> help memdump +'memdump' or 'm' - dump memory +Usage: m [b|w|l] [start address-[end address| count]] + dump memory at address or continue dump from previous address. + By default memory output is done as bytes, with 'w' or 'l' + option, it will be done as words/longs instead. Output amount + can be given either as a count or an address range. ++
+> help disasm +'disasm' or 'd' - disassemble from PC, or given address +Usage: d [start address-[end address]] + If no address is given, this command disassembles from the last + position or from current PC if no last position is available. ++
+> disasm pc +$00aa6e : 2f08 move.l a0,-(sp) +$00aa70 : 0241 0fff andi.w #$fff,d1 +$00aa74 : 207c 00fe 78c0 movea.l #$fe78c0,a0 +$00aa7a : 2070 1000 movea.l (a0,d1.w),a0 +$00aa7e : 4ed0 jmp (a0) ++ +
+Both commands accept in addition to numeric addresses also register +and symbol names, like in above example. If you don't specify an +address, the commands continue showing from an address that comes +after the previously shown data. "disasm" command default address +will be reset to PC address every time you re-enter the debugger. +
+ ++Use "setopt --disasm help" if you want to set options controlling +the disassembly output. +
+ ++You can use the "info" command to see state of specific sets of HW +registers (e.g. "info videl") and Atari OS structures (e.g. "info gemdos"). +
+ + ++By using the "lock" command, you can ask Hatari to show specific +information whenever you enter the debugger / hit a breakpoint. For +example to see disassembly from current PC address, use "lock disasm". +
+ ++With the "regaddr" subcommand, you see disassembly or memory +dump of an address pointed by a given register ("lock regaddr disasm +a0"). Of the DSP registers, only Rx ones are valid for this +subcommand. +
+ ++"file" subcommand can be used to get (arbitrary number of) commands +parsed and executed from a given debugger input file whenever debugger +is entered. With this you can output any information you need: +
++lock file debugger.ini ++ +
+To disable showing of this extra information, use "lock default". +Without arguments "lock" command will show the available options +(like the "info" command does). +
+ + ++You can load debugging symbols to the debugger with the "symbols" +command (and with "dspsymbols" for DSP). These symbolic names can be +used in arithmetic expressions and conditional breakpoint expressions. +They also show up in the "disasm" command output and you can trace +calls to them with "trace cpu_symbols" (and DSP symbols with "trace +dsp_symbols"). +
+ + ++If currently running program contains debug symbol table, +and it is started from GEMDOS HD emulated drive, its symbol names / +addresses are automatically loaded when debugger is entered, and +removed when program terminates.
+ ++Above happens only if there are no symbols loaded when the program +starts. If there are, you can load program symbol data manually with +the following command, after program has been loaded to the memory by +TOS (see setting breakpoint at program +startup): +
++symbols prg ++ +
+The options you need to add suitable symbol table to your programs, +depend on which toolchain you use to build it: +
+You can view the generated symbols (and convert them to debugger +ASCII format) with tool installed with Hatari:
++$ gst2ascii -l -o program.tos > program.sym ++(Options -l and -o are used to exclude useless symbols from the output.) + + +
+If the program isn't run from a GEMDOS HD emulated drive, but from +a cartridge, floppy or HD image, you need to have the corresponding +program also as a normal host file which location you can give to +the debugger: +
++symbols /path/to/the/program.tos ++ + +
+If Hatari complains that your program doesn't have debug symbol table, +or its symbols are in some unsupported format, and you cannot re-compile +it to include a.out or GST/DRI symbols, you have two options: +
+NOTE: nm output for GCC generated +a.out binaries includes labels also for loops, +not just functions. While loop labels are fine for debugging, they should +be removed before profiling. Besides causing misleading profile +results, loop labels can seriously slow down profiling +(call graph tracking is automatically enabled for profiling when debug +symbols are loaded, and operations done on each matched symbol address +cause huge overhead if that match is for something happening every few +instructions). +
+ + +ASCII symbols file format is following:
++e01034 T random +e01076 T kbdvbase +e0107e T supexec ++
+Where 'T' means text (code), 'D' means data and 'B' means BSS section +type of address. The hexadecimal address, address type letter and the +symbol name are separated by white space. Empty lines and lines +starting with '#' (comments) are ignored. +
+ ++Debugger will automatically "relocate" the symbol addresses when it +loads them from a program binary, but with ASCII symbol files you need +to give the relocation offset(s) separately, unless the symbol names +are for fixed addresses (like is the case e.g. with EmuTOS): +
++symbols program.sym TEXT DATA BSS ++
+If you're interested only about code symbols, you can leave DATA and +BSS offsets out (the values of the above virtual debugger variables +like TEXT come from the currently loaded program's basepage, they're +set after the program is loaded by TOS, see "info basepage" output). +
+ + ++There are two ways to specify breakpoints for Hatari. First, there are +the simple address breakpoints which trigger when the CPU (or DSP) +program counter hits a given address. Use "a" (or "da" for the DSP) +to create them, for example: +
++a $e01034 +a some_symbol ++ +
+Note that address breakpoints are just wrappers for conditional +breakpoints so you need to use "b" command to remove or list them. +
+ ++Then there are the conditional breakpoints which can handle much more +complex break condition expressions; they can track changes to +register and memory values with bitmasks, include multiple conditions +for triggering a breakpoint and so on. Use "b" (or "db" for the DSP) +to manage them. +
+ +Help explains the general syntax:
++> help b +'breakpoint' or 'b' - set/remove/list conditional CPU breakpoints +Usage: b <condition> [&& <condition> ...] [:<option>] | <index> | help | all + +Set breakpoint with given <conditions>, remove breakpoint with +given <index>, remove all breakpoints with 'all' or output +breakpoint condition syntax with 'help'. Without arguments, +lists currently active breakpoints. ++ +
+Unless you give breakpoint one of the pre-defined subcommands ('all', +'help'), index for a breakpoint to remove or no arguments (to list +breakpoints), the arguments are interpreted as a new breakpoint +definition. +
+ ++Each conditional breakpoint can have (currently up to 4) conditions +which are separated by "&&". All of the breakpoint's +conditions need to be true for a breakpoint to trigger. +
+ + ++Normally when a breakpoint is triggered, emulation is stopped and you +get to the debugger. Breakpoint options can be used to affect what +happens when a breakpoint is triggered. These options are given after +the conditions and are prefixed with ':'. +
+ ++a $1234 :2 ++
+b pc > "pc" :once +continue ++
+Note: you can give multiple options for conditional breakpoints, but +for address breakpoints you can give only one these options. And +"file" option is supported only for conditional breakpoints. +
+ + ++"b help" explains very briefly the breakpoint condition syntax: +
++> b help +condition = <value>[.mode] [& <mask>] <comparison> <value>[.mode] + +where: + value = [(] <register/symbol/variable name | number> [)] + number/mask = [#|$|%]<digits> + comparison = '<' | '>' | '=' | '!' + addressing mode (width) = 'b' | 'w' | 'l' + addressing mode (space) = 'p' | 'x' | 'y' ++ +
+For CPU breakpoints, mode is the address width; it can be byte ("b"), +word ("w") or long ("l", default). For DSP breakpoints, mode specifies +the address space: "P", "X" or "Y". Note that on DSP only R0-R7 +registers can be used for memory addressing. For example; +
+db (r0).x = 1 && (r0).y = 2 ++ +
+If the value is in parenthesis like in '($ff820)' or '(a0)', then the +used value will be read from the memory address pointed by it. Note +that this conditional breakpoint expression value is checked at +run-time whereas quoted arithmetic expressions (mentioned in +Entering arguments +to debugger commands above) are evaluated already when +adding a breakpoint. For example, to break when a value in an address +(later) pointed by A0 matches the value currently in D0, one +would use: +
++b (a0) = "d0" ++ +
+If you're interested only on certain bits in the value, you can use +'&' and a numeric mask on either side of comparison operator to +mask the corresponding value, like this: +
+b ($ff820).w & 3 = (a0) && (a1) = d0 & %1100 ++ +
+Comparison operators should be familiar and obvious, except for '!' +which indicates inequality ("is not") comparison. For example: +
++b d0 > $20 && d0 < $40 && d0 ! $30 ++ + +
+As a convenience, if the both sides of the comparison are exactly the +same (i.e. condition is redundant as it is always either true or +false), the right side of the comparison is replaced with +its current value. This way you can give something like this: +
++b pc > "pc" ++
As:
++b pc > pc ++ +
+That in itself isn't so useful, but for inequality ('!') comparison, +conditional breakpoint will additionally track and output all further +changes for the given address/register expression. This can be used +for example to find out all value changes in a given memory address, +like this: +
++b ($ffff9202).w ! ($ffff9202).w :trace ++
+Because tracking breakpoint conditions will print the evaluated +value when it changes, they're typically used with the trace option +to track changes e.g. to some I/O register. +
+ + ++In addition to loaded symbols, the debugger supports also setting +conditional breakpoints on values of some "virtual" variables listed +by "variables" (v) command. For example: +
++b AesOpcode ! AesOpcode && AesOpcode < 0xffff :trace ++
+b GemdosOpcode = 0x4B && OsCallParam = 0x0 ++
+b pc = TEXT :once ++Note1: It is better to trigger it only once, because if you would leave it +on, during (re)boot you would get a warning for every instruction +(until TOS sets a valid basepage). +
+m DATA +m BSS ++
+b HBL = "HBL+20" ++
+Hint: "info" command "aes", "bios", "gemdos", "vdi" and "xbios" +subcommands can be used to list the corresponding OS-call opcodes. +For example, to see the GEMDOS opcodes, use:
++info gemdos 1 ++ + +
+As the file pointed by the breakpoint ":file" option (see +Breakpoint options) can contain any +debugger commands, it can also be used to do automatic "chaining" of +debugger and breakpoint actions so that after one breakpoint is hit, +another one is set. +
+ +For example if you have these input files:
++# continue to "program.ini" on Pexec(0, ....) +b GemdosOpcode = 0x4B && OsCallParam = 0x0 :trace :once :file program.ini ++
+# continue to "trace.ini" when program execution starts +b pc = TEXT :trace :once :file trace.ini ++
+# load symbols, trace gemdos & program function calls +symbols prg +trace gemdos,cpu_symbols +# continue to "disable.ini" after 4 VBLs +b VBL = "VBL+4" :trace :once :file disable.ini ++
+# stop tracing and remove breakpoints +trace none +b all ++
+And then start Hatari with the first debugger input file: +
++hatari --parse pexec.ini /path/to/your/program.tos ++ +
Note:
++Hint: It is better to test each input file separately before testing +the whole chain. Besides the ":file" breakpoint option, you can test +these debugger input files also with the debugger "file" command, +"file" option for the "lock" command, and with the Hatari "--parse" +command line option. +
+ ++After analyzing the emulation state and/or setting new breakpoints, +you can continue the emulation with the "c" command. You can continue +for a given number of CPU instructions (or DSP instructions when "dc" +is used), or you can continue forever (until a non-tracing breakpoint +triggers) if you omit the instruction count. +
+ ++If you want to continue just to the next instruction, use "s" (step) +command to continue for exactly one instruction, or "n" (next), if you +want to skip subroutine + exception calls and DBCC branching backwards +(i.e. loops). "ds" and "dn" commands do the same for DSP (except that +"dn" doesn't skip loops). +
+ ++You can also continue with the "n" until instruction of certain +type is encountered, by giving it the instruction type: +
+For example: "n branch", or "dn branch". +
+ ++(Note: CHK, CHK2, FBCC, FDBCC, & FTRAPCC exception / branch CPU +instructions aren't supported currently.) +
+ + ++If you want e.g. to continue with real-time disassembling, you can +enable it with "trace cpu_disasm" (or "trace dsp_disasm" for DSP) at +the debugger prompt before continuing. +
++Disable tracing with "trace none" when you enter the debugger again. +"trace help" (or TAB) can be used to list all the (over 40) supported +traceable things, from HW events to OS functions. +
++Notes: +
++If there isn't a trace option for something you would like to track, +you may be able to use tracing breakpoints, explained above. +For example, following tracks Line-A calls: +
++b LineAOpcode ! LineAOpcode && LineAOpcode < 0xffff :trace ++ + +
+Profiling tells where the emulated code spends most of its (emulated) +time. It can be used to find out where a program is (apparently) +stuck, or what are the largest performance bottlenecks for a program. +
+ ++Profiling is used by first enabling the profiler (use "dp" for DSP): +
++> profile on +Profiling enabled. ++
+And profiling will start once you continue the emulation: +
++> c +Returning to emulation... +Allocated CPU profile buffer (27 MB). ++ +
+When you get back to the debugger, the collected profiling information +is processed and a summary of in which parts of memory the execution +happened, and how long it took, is shown: +
++Allocated CPU profile address buffer (57 KB). +ROM TOS (0xE00000-0xE80000): +- active address range: + 0xe00030-0xe611a4 +- active instruction addresses: + 14240 (100.00% of all) +- executed instructions: + 4589668 (100.00% of all) +- used cycles: + 56898472 (100.00% of all) + = 7.09347s +Cartridge ROM (0xFA0000-0xFC0000): + - no activity + += 7.09347s ++
+(DSP RAM will be shown only as single area in profile information.) +
+ + ++When you are back in debugger, you can inspect the collected profile data: +
+
+> h profile
+'profile' - profile CPU code
+Usage: profile <subcommand> [parameter]
+
+ Subcommands:
+ - on
+ - off
+ - counts [count]
+ - cycles [count]
+ - i-misses [count]
+ - d-hits [count]
+ - symbols [count]
+ - addresses [address]
+ - callers
+ - caches
+ - stack
+ - stats
+ - save <file>
+ - loops <file> [CPU limit] [DSP limit]
+
+ 'on' ¨ 'off' enable and disable profiling. Data is collected
+ until debugger is entered again at which point you get profiling
+ statistics ('stats') summary.
+
+ Then you can ask for list of the PC addresses, sorted either by
+ execution 'counts', used 'cycles', i-cache misses or d-cache hits.
+ First can be limited just to named addresses with 'symbols'.
+ Optional count will limit how many items will be shown.
+
+ 'caches' shows histogram of CPU cache usage.
+
+ 'addresses' lists the profiled addresses in order, with the
+ instructions (currently) residing at them. By default this
+ starts from the first executed instruction, or you can
+ specify the starting address.
+
+ 'callers' shows (raw) caller information for addresses which
+ had symbol(s) associated with them. 'stack' shows the current
+ profile stack (this is useful only with :noinit breakpoints).
+
+ Profile address and callers information can be saved with
+ 'save' command.
+
+ Detailed (spin) looping information can be collected by
+ specifying to which file it should be saved, with optional
+ limit(s) on how many bytes first and last instruction
+ address of the loop can differ (0 = no limit).
+
+
+For example, to see which memory addresses were executed most +and what instructions those have at the end of profiling, use:
++> profile counts 8 +addr: count: +0xe06f10 12.11% 555724 move.l $4ba,d1 +0xe06f16 12.11% 555724 cmp.l d1,d0 +0xe06f18 12.11% 555724 bgt.s $e06f06 +0xe06f06 12.11% 555708 move.b $fffffa01.w,d1 +0xe06f0a 12.11% 555708 btst #5,d1 +0xe06f0e 12.11% 555708 beq.s $e06f1e +0xe00ed8 1.66% 76001 subq.l #1,d0 +0xe00eda 1.66% 76001 bpl.s $e00ed8 +8 CPU addresses listed. ++ +
+Then, to see what the executed code and its costs look like +around top addresses: +
+> profile addresses 0xe06f04 +# disassembly with profile data: +# <instructions percentage>% (<sum of instructions>, <sum of cycles>, <sum of i-cache misses>, <sum of d-cache hits>) + +$e06f04 : bra.s $e06f10 0.00% (48, 576, 0, 0) +$e06f06 : move.b $fffffa01.w,d1 12.11% (555708, 8902068, 0, 0) +$e06f0a : btst #5,d1 12.11% (555708, 6685268, 0, 0) +$e06f0e : beq.s $e06f1e 12.11% (555708, 4457312, 0, 0) +$e06f10 : move.l $4ba,d1 12.11% (555724, 11125668, 0, 0) +$e06f16 : cmp.l d1,d0 12.11% (555724, 4461708, 0, 0) +$e06f18 : bgt.s $e06f06 12.11% (555724, 4455040, 0, 0) +$e06f1a : moveq #1,d0 0.00% (16, 64, 0, 0) +Disassembled 8 (of active 14240) CPU addresses. ++
+Unlike normal disassembly, "profile addresses" command shows only +memory addresses which instructions were executed during profiling. +You get instruction cache misses only when using cycle-accurate 030 +emulation with a Hatari version configured to use WinUAE CPU core. +
+If you have loaded symbol information, symbol names are shown above +the corresponding addresses. With the "profile symbols" command you +get a list of how many times the code execution passed through the +defined symbol addresses. +
+ + +Profile data accuracy depends on Hatari emulation accuracy. +Profile data accuracy from most to least accurate when Hatari's +default emulation options are used is following:
++If you have loaded symbols (see Debug symbols) +before continuing emulation/profiling, additional caller information +will be collected for all the code symbol addresses which are called +as subroutines. This information includes callstack, call counts, +calling instruction type (subroutine call, branch, return etc), and +costs for those calls, both including costs for further subroutine +calls and without them. +
+ +When debugger is re-entered, current callstack is output before +profiling information:
++> a _P_LineAttack +CPU condition breakpoint 1 with 1 condition(s) added: + pc = $30f44 +$030f44 : 48e7 3820 movem.l d2-d4/a2,-(sp) +> c +... +CPU breakpoint condition(s) matched 1 times. + pc = $30f44 +Finalizing costs for 12 non-returned functions: +- 0x32a3c: _P_GunShot (return = 0x32b7e) +- 0x32b18: _A_FireShotgun (return = 0x3229a) +- 0x3223a: _P_SetPsprite (return = 0x32e86) +- 0x32e4e: _P_MovePsprites (return = 0x38070) +- 0x37f44: _P_PlayerThink (return = 0x36ea0) +- 0x36e44: _P_Ticker (return = 0x260e0) +- 0x25dcc: _G_Ticker (return = 0x1e4c6) +- 0x1e29e: _TryRunTics (return = 0x239fa) +- 0x238e8: _D_DoomLoop (return = 0x2556a) +- 0x24d7a: _D_DoomMain (return = 0x44346) +... ++ +
("profile stack" command can be used in breakpoints with :noinit +option to show backtraces during caller profiling.)
+ +Note: rest of this subsection is about caller information format +which is mainly of interest for people writing profiling +post-processing tools. Come back here if you think there's +some problem with callgraphs produced by those tools.
+ +Other information collected during profiling is shown with +following command:
++> profile callers +# <callee>: <caller1> = <calls> <types>[ <inclusive/totals>[ <exclusive/totals>]], <caller2> ..., <callee name> +# types: s = subroutine call, r = return from subroutine, e = exception, x = return from exception, +# b = branch/jump, n = PC moved to next instruction, u = unknown PC change +# totals: calls/instructions/cycles/misses +0xe00030: 0xffffff = 1 e, _main +0xe000fe: 0xe00a0c = 1 b, memdone +0xe0010a: 0xe04e34 = 1 s 1/5/72 1/5/72, _run_cartridge_applications +0xe00144: 0xe04dbe = 1 s 4/118/1512 1/27/444, _init_acia_vecs +0xe001ea: 0xe00ec6 = 1 b, _int_acia +0xe0038c: 0xe04c28 = 1 s 1/191/2052 1/191/2052, _init_exc_vec +0xe003a6: 0xe04c2e = 1 s 1/388/4656 1/388/4656, _init_user_vec +... ++ +
+For example, if you don't know all the places from which a certain +function is called, or in what context a certain interrupt handler can +be called during the period you are profiling, profile caller +information will tell you: +
++callee: caller: calls: calltype: + | | | / +0x379: 0x155 = 144 r, 0x283 = 112 b, 0x2ef = 112 b, 0x378 = 72 s +583236/359708265/1631189180 72/4419020/19123430, dsp_interrupt + | | | + inclusive costs exclusive costs callee name + (of calls from 0x378) + +Calltypes: +- b: jump/branch +- n: PC just moved to next address +- r: subroutine return +- s: subroutine call ++
+(Most "calls" to "dsp_interrupt" were subroutine call returns (=r) +to it from address 0x155.) +
+ ++With the execution counts in normal profiling data, caller information +can actually be used to have complete picture of what exactly the code +did during profiling. Main/overview work for this analysis is best done +automatically, by the profiler data post-processor (documented below). +
+ + +Everything about profile data accuracy applies also to caller costs, +but there are additional things to take into account, mainly because +profiler cannot determine when exceptions are being handled:
+It is useful to save the profile data to a file:
++> profile save program-profile.txt ++ +
With the saved profile disassembly (and optional caller information) +you can more easily investigate what your program did during +profiling, search symbols & addresses in it, and compare the +results to profiles you have saved from earlier versions of your code.
+ +You may even create your own post-processing tools for +investigating the profiling data more closely, e.g. to +find +CPU/DSP communication bottlenecks.
+ + +Saved profile data can be post-processed with (Python) script +installed by Hatari, to:
+When the data is post-processed, you should always provide +the post-processor symbols for the profile code! Relying just on the +symbol in the profile data can cause costs to be assigned to wrong +symbol, if symbol's code wasn't called through symbol's own address, +but by jumping inside its code.
+ +If your code is in fixed location, you should tell +post-processor to handle symbol addresses as absolute (-a):
++$ hatari_profile.py -a etos512k.sym emutos-profile.txt ++ +
Normal programs are relocated and you should instead give +the symbols as TEXT (code) section relative ones (-r):
++$ hatari_profile.py -r program.sym program-profile.txt ++ +
If symbols are included to your binary, first they need to be +extracted to the ASCII format +understood by the post-processor:
++$ gst2ascii -a -l -o program.prg > program.sym ++ +
If there are some extra symbols that you don't want to see +separately in profiles, because they aren't real functions, +but e.g. loop labels, you can either remove them manually +from the ASCII *.sym file, or filter them out with grep: +
++$ gst2ascii -a -l -o program.prg | grep -v -e useless1 -e useless2 > program.sym ++ + +
Above post-processor examples just parse + verify the given data +and produce output like this:
++Hatari profile data processor + +Parsing TEXT relative symbol address information from program.sym... +[...] +3237 lines with 1550 code symbols/addresses parsed, 0 unknown. + +Parsing profile information from program-profile.txt... +[...] +9575 lines processed with 368 functions. + +CPU profile information from 'program-profile.txt': +- Hatari v1.6.2+ (May 4 2013), WinUAE CPU core ++ +
To get statistics (-s) and list of top (-t) CPU users in profile, +add "-st" option:
++$ hatari_profile.py -st -r program.sym program-profile.txt +[...] +CPU profile information from 'program-profile.txt': +- Hatari v1.6.2+ (May 4 2013), WinUAE CPU core + +Time spent in profile = 34.49539s. + +Calls: +- max = 187738, in __toupper at 0x52b88, on line 8286 +- 1585901 in total +Executed instructions: +- max = 1900544, in flat_remap_mips+14 at 0x47654, on line 7020 +- 64499351 in total +Used cycles: +- max = 15224620, in flat_remap_mips+18 at 0x47658, on line 7022 +- 553392132 in total +Instruction cache misses: +- max = 184308, in _BM_T_GetTicks at 0x43b90, on line 4772 +- 4941307 in total + +Calls: + 11.84% 187698 __toupper + 11.48% 182105 _BM_T_GetTicks + 11.48% 182019 _I_GetTime +[...] +Executed instructions: + 34.83% 22462729 flat_generate_mips + 14.08% 9080215 flat_remap_mips + 8.55% 5515945 render_patch_direct + 5.09% 3283328 _TryRunTics +[...] +Used cycles: + 23.62% 130702768 flat_generate_mips + 12.42% 68735832 flat_remap_mips + 9.77% 54041148 _TryRunTics + 5.80% 32111536 correct_element +[...] +Instruction cache misses: + 37.03% 1829764 _TryRunTics + 11.20% 553314 _BM_T_GetTicks + 9.44% 466319 _NetUpdate + 9.27% 457899 _HGetPacket +[...] ++ +
If you want to see also symbol addresses and what is per call +cost, add -i option:
++$ hatari_profile.py -st -i -r program.sym program-profile.txt +[...] +Executed instructions: + 34.83% 22462729 flat_generate_mips (0x04778a, 774576 / call) + 14.08% 9080215 flat_remap_mips (0x047646, 313110 / call) + 8.55% 5515945 render_patch_direct (0x047382, 29977 / call) + 5.09% 3283328 _TryRunTics (0x042356, 19660 / call) +[...] +Used cycles: + 23.62% 8.14728s 130702768 flat_generate_mips (0x04778a, 0.28094s / call) + 12.42% 4.28461s 68735832 flat_remap_mips (0x047646, 0.14775s / call) + 9.77% 3.36863s 54041148 _TryRunTics (0x042356, 0.02017s / call) + 5.80% 2.00165s 32111536 correct_element (0x04a658, 0.00001s / call) +[...] +Instruction cache misses: + 37.03% 1829764 _TryRunTics (0x042356, 10956 / call) + 11.20% 553314 _BM_T_GetTicks (0x043b90, 3 / call) + 9.44% 466319 _NetUpdate (0x041bcc, 5 / call) + 9.27% 457899 _HGetPacket (0x041754, 5 / call) +[...] ++ +
(For cycles the "per call" information is in seconds, not as +a cost count.)
+ +If your profile file contains caller information, you should +add -p option to see it, as that will also help in detecting symbol +issues (see Interpreting +the numbers):
++$ hatari_profile.py -st -p -r program.sym program-profile.txt +[...] +9575 lines processed with 368 functions. +[...] +Of all 1570498 switches, ignored 581 for type(s) ['r', 'u', 'x']. + +CPU profile information from 'badmood-level-load-CPU.txt': +- Hatari v1.6.2+ (May 4 2013), WinUAE CPU core +[...] +Calls: + 11.84% 11.84% 187698 187698 __toupper + 11.48% 11.48% 182105 182105 _BM_T_GetTicks + 11.48% 22.95% 182019 364038 _I_GetTime +[...] +Executed instructions: + 34.83% 34.86% 34.86% 22462729 22484024 22484024 flat_generate_mips + 14.08% 14.10% 14.10% 9080215 9091270 9091676 flat_remap_mips + 8.55% 5515945 render_patch_direct + 5.09% 5.11% 94.96% 3283328 3294022 61247717 _TryRunTics +[...] +Used cycles: + 23.62% 23.69% 23.69% 130702768 131100604 131100604 flat_generate_mips + 12.42% 12.46% 12.46% 68735832 68928816 68930904 flat_remap_mips + 9.77% 9.80% 95.66% 54041148 54238744 529368824 _TryRunTics + 5.80% 5.82% 5.82% 32111536 32193664 32193664 correct_element +[...] +Instruction cache misses: + 37.03% 37.14% 98.57% 1829764 1835261 4870573 _TryRunTics + 11.20% 11.24% 11.24% 553314 555191 555191 _BM_T_GetTicks + 9.44% 9.49% 29.13% 466319 468782 1439340 _NetUpdate + 9.27% 9.29% 9.37% 457899 459197 463217 _HGetPacket +[...] ++ +
Now there's a message telling that some of the calls were ignored +because according to their "call type", they were actually returns from +exceptions, not real calls (this is mainly important for callgraph +generation, discussed below).
+ + +In addition to accuracy issues mentioned in previous Profiling +sections, function/symbol level costs have gotchas of their own.
+ +The first cost percentage and count columns are sums for all +the instructions that were in profile data file between +the indicated symbol's address and the address of the next symbol +(= "between-symbols" cost).
+ +NOTE: If your symbol file doesn't contain addresses +for all the relevant symbols, results from this can be misleading because +instructions costs get assigned to whatever symbol's address +happened to precede those instructions. And you don't see which +caller is causing it from caller info or callgraph either, as entry +point for that time sink lacking a symbol means profiler hadn't +tracked calls to it...
+ +The next two cost percentage and count columns are for subroutine +calls costs, first one for exclusive and latter for inclusive cost +i.e. including costs for further subroutine calls. Values are based on +caller information documented above.
+ +Reasons why between-symbol costs, and subroutine call costs can +differ, are following:
+In the first case, you should check the profile data to find out +whether there are missing symbols for executed function entry points. +You can notice function entry points as address gap and/or code +retrieving arguments from stack. Exit points can be seen from RTS +instructions.
+ +Second case can also be seen from the profile data. Call count +is same as count for how many times first instruction is executed +(worst case: large loop on subroutine's first instruction).
+ +While subroutine costs should be more accurate and relevant, due to +code optimizations many of the functions are not called as subroutines +(on m68k, using JSR/BSR), but just jumped or branched to. Because of +this, it is useful to compare both subroutine and between-symbols +costs. One should be able to see from the profile disassembly which +of the above cases is cause for the discrepancy in the values.
+ +NOTE: Before starting to do any serious source +level optimizations, you should always verify from profile +data (disassembly) where exactly the costs are in a function, to make +sure your optimization efforts can actually help the performance.
+ + +Callgraphs require that saved profile data contains caller +function address information, i.e. symbols for the code should +be loaded before starting profiling it (see +loading symbol data).
+ +Separate callgraphs will be created for each of the costs +(0=calls, 1=instructions, 2=cycles) with the -g option:
++$ hatari_profile.py -p -g -r program.sym program-profile.txt +[...] +Generating 'program-profile-0.dot' DOT callgraph file... + +Generating 'program-profile-1.dot' DOT callgraph file... + +Generating 'program-profile-2.dot' DOT callgraph file... +[...] ++ +
Callgraphs are saved in GraphViz +"dot" format. Dot files can be viewed:
++$ dot -Tsvg program-profile-1.dot > program-profile-1.svg ++ (problem with most PS/PDF and SVG viewers is that either they + don't allow zooming large callgraphs enough or they use huge + amounts of memory and get very slow) +
Produced callgraph will look like this:
+
+
+Interpreting the callgraph:
++If profile is for larger and more varied amount of code (e.g. program startup), +the resulting callgraph can be so huge that it not really readable anymore. +
+ +If your code has interrupt handlers, they can get called +at any point, which can show in callgraph as "explicit" calls +from the interrupted functions. To get rid of such incorrect +calls, give interrupt handler names to --ignore-to option:
++$ hatari_profile.py -p -g --ignore-to handler1,handler2 -r program.sym program-profile.txt ++ +
In large callgraph most of the functions aren't really interesting, +because their contribution to the cost is insignificant. You can +remove large number of them with --no-leafs and --no-intermediate +options, those options act only on nodes which costs are below +given threshold. Leaf nodes are ones which don't have any parents +and/or children. Intermediate ones have only single parent and +children (node calling itself is not taken into account). + +
Threshold for this is given with the --limit (-l) option. With +that it typically makes also sense to change the node emphasis +threshold with --emph-limit (-e) option:
++$ hatari_profile.py -p -g -l 0.5 -e 2.0 -r program.sym program-profile.txt ++ +
If you are not interested in from how many different addresses +a given function calls another function, use --compact option. If you +still see multiple calls between two nodes with it, the reason is that +they happened through different call paths which were removed from +the callgraph after --compact option was applied:
++$ hatari_profile.py -p -g -l 1.0 -e 2.0 --no-leafs --no-intermediate --compact -r program.sym program-profile.txt ++ +
If even this doesn't help, you can remove all nodes below +the given cost threshold limit with --no-limited option, but this +often doesn't leave much of a call hierarchy. Instead you may +consider removing all nodes except for subroutine call ones, with the +--only-subroutines option.
+ +If you have trouble locating nodes you are specially interested +about, you can either color them differently with the --mark option, +or exclude everything else from the callgraph except those nodes and +their immediate callers & callees, with the --only option:
++$ hatari_profile.py -p -g --only func1,func2 -r program.sym program-profile.txt ++ +
Last option for reading the callgraph is using -k option to +export the data for use in (Linux) Kcachegrind UI. Kcachegrind generates +callgraphs on the fly, and just for the area around the function +you selected, so navigating in callgraph may be easier. It also +shows the related profile disassembly, which can make verifying +matters easier:
++$ hatari_profile.py -p -k -r program.sym program-profile.txt +[...] +Generating callgrind file 'program-profile.cg'... +[...] +$ kcachegrind program-profile.cg ++
++Here's a list of some common debugging tasks and how to do them +with the Hatari debugger: +
+ ++trace gemdos,io_all ++Please see Tracing section for more information +on tracing, what's possible with it and what are its limitations. +
+a $12345 :6 ++
+history on +b pc=($8) ++After bus error invokes debugger, 'history' command can then be used +to see (executed memory addresses with their current) instructions +leading to the error. The most interesting vector addresses are: +$8 (Bus error), $C (Address error), $10 (Illegal instruction), +$14 (Division by zero).
+b d1 = 5 ++
+b d1 ! d1 ++
+b d1 & 0xff ! d1 & 0xff ++
+b d1 > 9 && d1 < 31 ++
+b ($ff820a).b & 2 = 2 ++
+b ($ff820a).b & 2 ! ($ff820a).b & 2 ++
+b ($ff820a).b & 2 ! ($ff820a).b & 2 :trace ++
+info basepage ++To see e.g. all Falcon Videl register values, use: +
+info videl ++
+b VBL = 100 && HBL = 40 && FrameCycles = 5 ++
+b d0 = "d0 + 10" ++
+> trace gemdos
+> b GemdosOpcode = $3D
+> c
+[...continue until breakpoint...]
+1. CPU breakpoint condition(s) matched 1 times.
+ GemdosOpcode = $3D
+> n
+GEMDOS 0x3D Fopen("TEST.TXT", read-only)
+> e d0
+= %1000000 (bin), #64 (dec), $40 (hex)
+
++history cpu +c +[breakpoint is hit and debugger entered] +history 16 ++
+history on +lock history 16 +c ++
+lock registers +s +[new register values] +s +[new register values] +... ++
+m "a7-64"-a7 ++
+lock file stack.ini ++Please see also Chaining breakpoints +section for more examples on what you can do with the debugger input files. +
+profile on +c +[after a while, use AltGr+Pause to get back to debugger] +d +[or if you want to see just the executed instructions] +profile addresses ++Please see Profiling section for more info. +
+profile on +c +[after a while, use AltGr+Pause to get back to debugger] +profile counts ++Please see Profiling section for more info. +
+profile on +symbols prg +b pc = _my_function :quiet :noinit :file showstack.ini ++I.e. whenever 'my_function' address is called, quietly trigger a +breakpoint without resetting profiling (callstack) information and run +debugger command(s) from the 'showstack.ini' debugger script file, +which contains following command: +
+profile stack ++
+Hint: for most of the above commands, one just needs to prefix them with +"d" (or "dsp" when using full command names) to do similar operation on +the DSP. +
+ + ++Lastly, the debugger is much nicer to use with the command line +history, editing and especially the completion support for the +command, command argument and symbol names. +
++If you are building Hatari yourself, please make sure that you have the +GNU readline development files installed (on Debian / Ubuntu these +come from the libreadline5-dev package). Otherwise the name completion +and other features don't get enabled when you configure Hatari. +
++ENABLE_TRACING define needs to be set for tracing to work. +By default it should be enabled. +
+ + +Hatari performance varies between Atari programs, depending on what +features Hatari needs to emulate for them. Less accurate Atari +emulators may be faster as emulation accuracy has a performance +overhead.
+ +The operating system and libraries below Hatari can also sometimes +have a noticeable effect on performance.
+ ++Hatari can be sped up considerably by giving up some emulation or +emulator accuracy. With ST/STe emulation, these options should be +needed only on slow devices, typically ARM and/or mobile ones (e.g. +Rasberry Pi). +
+ + ++Finding out whether there's a performance problem with the system +components (like SDL) in your setup, requires profiling Hatari and +rest of the system. How to do that is OS specific. On Linux that would +involve running "perf record -a" command (as root) on the background +for few minutes while Hatari is running, and then investigating +the results with "perf report" command. +
+ ++Some other process eating CPU cycles from Hatari one can see just with +the (Linux/Unix) "top" command. +
+ + ++Linux: Some HW platforms don't have properly HW accelerated +3D driver and SDL implementation. On these platforms it's better to +build Hatari with SDL v1.x than SDL 2.x, as latter can cause CPU +based 3D driver to be used for scaling Hatari graphics. +
+ ++MacOS: With SDL v1.x, frame skipping, zooming and drive LED +options (listed below) seem to have a large effect on performance in +the windowed mode. This is apparently due to issues in the SDL macOS +backend and how macOS itself composites non-fullscreen window +contents. These shouldn't be an issue with the SDL2 build of Hatari. +
+ ++Compiler: Unless you have disabled compiler optimizations +(like GCC's -O2 or -O3 options) in the Hatari build, the extra +optimization flags (like GCC's "-mtune=i686") don't seem to have very +large effect on Hatari performance. Using GCC -O3 option instead of +-O2 can give minor (5-10%) performance improvements for things (mainly +demos) that use very heavily interrupts. +
+ ++CPU emulation: Hatari can be built with two different CPU +core implementations. The newer WinUAE CPU core has more accurate CPU +emulation and supports all of the higher end 680x0 CPU features. This +accuracy causes it to be clearly slower, than the OldAUE CPU core +implementation. If run-time options (acceptable to you) don't give +enough performance, give the OldUAE CPU core also a try. +
+ ++Older versions: If nothing else helps, try (building) much +earlier Hatari version. More accurate emulation in newer Hatari +versions means that they can be slower despite optimizations. +
+ ++Hatari currently runs best in 16 or 32 bits per pixel color depth +mode, so try to avoid 24 bits per pixel display modes if possible. +16-bit mode is faster with SDL1. MacOS uses always 32-bit mode. +
+ + ++Emulation options have the largest impact on Hatari performance. These +options can be changed from the Hatari GUI System and CPU dialogs and +the emulation needs to be rebooted for any of these changes to take an +effect! They are enabled by default. +
+ ++Emulating the Falcon DSP is performance-wise several times more demanding +than emulating the m68k; DSP runs at higher frequency, executes many +instructions for each m68k instruction and emulation isn't as mature +and optimized. Unless some Falcon program needs DSP, none or +dummy DSP emulation mode could be used. Even of the programs +that do use DSP, many use it only for background music and work +fine without the real DSP emulation. +
+ ++WinUAE CPU core supports 030 cache emulation for cycle accuracy. This +is very heavy. Unless program needs cycle accuracy to work correctly, +you can disable it. Many Falcon demos need it, application and games +normally don't. +
+ ++With ST/STe, the single largest factor contributing to general Hatari +emulation performance is the handling of interrupts. Enabling Timer-D +patching option (about) doubles Hatari ST/STE emulation performance +with OldUAE CPU core as it significantly reduces the number of +interrupts generated by the emulated Atari machine. Using this has +adverse effect only for very rare programs. +
+ ++While accurate FDC emulation doesn't take that much CPU, it slows down +floppy image accesses (and Hatari startup) a lot. Only very +few demos and games require accurate FDC emulation for their copy +protection, so enabling fast floppy access is fairly safe. +
+ ++After the DSP, cycle accuracy and interrupts, m68k emulation takes +most time. Disabling the "Prefetch" / "Compatible" option can speed up +the emulation noticeably, but it will be less accurate. This can be +fine for many games and other programs, but won't work e.g. for demos +using overscan or rasters. This is recommended only as a last resort. +
+ ++Roughly speaking, for Falcon DSP emulation with cycle exact 030 cache +emulation, one needs at least 3Ghz machine. For normal (unpatched) +Timer-D frequency on some specific cases (like demos with overscan 512 +color animations) one may need over 1GHz machine for ST/STE emulation, +but some rare demos may require over 1GHz machine even with Timer-D +patching. +
+ ++NOTE: Above options may cause some programs to work in correctly. +The Hatari Software Compatibility List +lists programs known to need real Falcon DSP emulation, Timer-D +frequency or accurate FDC timings. +
+ + ++Emulator options don't usually have as large effect on performance as +emulation options, but they don't affect the emulated programs at all, +just the quality of the emulation "output". These options can also +be toggled at run-time without rebooting the emulation. +
+ ++Internal Hatari sound handling and the SDL_mixer sound thread +libALSA sound processing can account up to 1/3 of the Hatari CPU usage +in normal ST/STE emulation. Disabling sound will get rid of that. +Using low sound frequency or one matching your sound card may also help. +Best is if you disable also background music from the programs you run +in Hatari as this can significantly reduce the number of generated +interrupts. +
+ ++If program supports both ST and STE, use STE. Emulating DMA sound, is +more lightweight than interrupt heavy ST sound. +
+ ++If problem is occasional performance related audio glitches, increasing +the sound buffer size (with "--sound-buffer-size" option) may help, but +it increases sound latency. +
+ ++Screen rendering can take noticeable amount of CPU time. The default +Hatari "auto" frame skipping should be used unless there's a good +reason not to. It will skip converting and showing some of the frames +if there's not enough time for them. +
+ ++Also, if your monitor refresh frequency is lower than the selected +Hatari monitor frequency (e.g. LCD monitors usually use 60Hz whereas +Atari monochrome monitor uses 71Hz), you should use frameskip of one. +The reason is that if your SDL library uses VSync to synchronize the +output to screen, with zero frame skip that forces the emulation to +run slower than a real Atari. If SDL doesn't use VSync, Hatari does +redundant work to convert frames you can't see. +
+ ++If you are not using frame skip, disabling zooming can have +noticeable improvement on performance. You can do this by specifying +suitably low "Max zoomed" resolution (--zoom +1 command line option sets it to 320x200). If you still want to +have a nice fullscreen mode, you should rather add the right resolution +mode-lines (e.g. "320x200") to your xorg.conf file. If you still want +to use zooming, disabling borders may help a bit. +
+ ++Handling Spec512 color modes which change the ST/e palette constantly +takes some extra CPU. If you have problems with CPU usage in such +screens and you care more e.g. from the sound quality than visuals, you +can either increase the threshold or disable the Spec512 mode handling +completely by zeroing the threshold for that with the +--spec512 0 option. +
+ ++If your version of the SDL library uses VSync to synchronize the screen +output, drawing of the statusbar or the drive LED may have some minor +impact on performance too. Normally they shouldn't. +
+ + ++There are a couple of ways to monitor and measure Hatari performance. +
++By default Hatari has Statusbar visible and automatic frameskip +enabled. When Hatari has enough time that it can sleep a little each +frame, the statusbar frame skip ("FS") value keeps at zero. If Hatari +is completely busy, it will increase to the maximum specified +(automatic) frame skip value. +
++Hatari has also a facility to measure FPS i.e. Frames Per Second. +Enable frame skipping with +--fast-forward yes option +(or use the corresponding keyboard shortcut) and set +--log-level info. +Then after a while, press the "Pause" key. Whenever Hatari emulation +is paused, Hatari will output on console info on how many VBLs it +could show per second, along with some other numbers. +
++It depends on what you want to measure, but usually it is best to +disable sound and set high frame skip like +--sound off --frameskips 60 so that +the associated external overheads are minimized. E.g. video output +can on some platforms do VSync and measurements would then show your +monitor refresh frequency instead of the actual Hatari performance. +
++On Unix systems with times() function +call, only the time spent by the Hatari process itself is measured. +On other systems, much less accurate SDL "wall clock" timings are +used. To make latter more accurate you could use also +--run-vbls option to specify how many +VBLs Hatari should run before it exits. In this case it is best to +either have the test-case run automatically from the AUTO-folder or +given as memory snapshot to Hatari with the frame skip set equal to +the VBL count. +
++Note that these numbers can fluctuate quite a bit, especially +when the SDL timings are used, so for (statistically) reliable numbers +you may need to repeat the measurement several times. You should of +course make also sure that the system doesn't have any other activity +at the same time you are making the measurements. +
+This program is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by the +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -License for more details.
-You should have received a copy of the GNU General Public License -along with this program; if not, write to Free Software Foundation, -Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +Public License for more details. ++You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software Foundation, +Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA +
The GNU Project and the Free Software Foundation | The GNU General Public License
+The GNU Project and the Free Software +Foundation | The +GNU General Public License
Emulation via software is an art and Hatari is an example of this.
-Emulation is to make a computer behave like a (probably) completely different machine on the lowest possible niveau. -This includes CPU and custom chip emulation allowing software written for the emulated machine to be run without notice. -A good emulator will run most of the software intended for the emulated platform without trouble. +
Emulation is to make a computer behave like a (probably) completely +different machine on the lowest possible level. +This includes CPU and custom chip emulation allowing software written +for the emulated machine to be run without it noticing a difference.
-The key to emulation is to simply do those things with a software program, the emulator, that normally chips would perform. -So you have an CPU emulator that basically consists of a large loop that does exactly what the real thing would do: +The key to emulation is to simply do those things with a software +program, the emulator, that normally chips would perform. +So you have an CPU emulator that basically consists of a large loop +that does exactly what the real thing would do:
-The typical von-Neumann CPU can be emulated very fast, stable and error-free using such a simple loop system. +The typical von-Neumann CPU can be emulated very fast, stable and +error-free using such a simple loop system.
-But in most cases the CPU emulation is the simplest part. Correct emulation of the various custom chips and hardware -parts of the emulated system is much trickier. +But in most cases the CPU emulation is the simplest part. Correct +emulation of the various custom chips and hardware parts of the +emulated system, and their proper synchronization, is much trickier.
- -This is a little compilation of what Atari software does work in Hatari. It is by no means finished.
- -| Game | -Working | -Sound | -Comment | -
| Eliminator | -yes | -perfect | -- |
| Speedball | -yes | -perfect | -- |
| Xenon | -yes | -music ok - fx dodgy | -bullets and explosions sound weired | -
| Bubble Bobble | -yes | -- | - |
| F15 Strike Eagle 2 | -yes | -ok | -keyboard emulation seems to be dodgy | -
| Rick Dangerous | -yes | -perfect | -- |
| Slayer | -yes | -ok | -raster fx at highscore entry dodgy | -
| Lethal Xcess | -no | -- | crashes while loading, sync scrolling will not work properly | -
| Star Goose | -yes | -music ok - bullet sound dodgy | -- |
| Xenon 2 - Megablast | -yes | -nearly perfect (including sampled intro) | -- |
| Metal Mutant | -yes | -seems ok | -some color effects in the lower screen seem buggy | -
| Defenders Of The Earth | -yes | -- | - |
| Nebulus | -yes | -music ok; snowball, balls and trapdoors dodgy | -otherwise working to a playable extend | -
| Leander | -yes | -- | - |
| Navy Seals | -yes | -- | - |
| Armalyte | -yes | -- | - |
| Wings Of Death | -yes | -- | - |
| Alien World | -yes | -- | Only works with "--slowfdc" | -
| Fantasia (Demo by Dune) | -yes | -- | Only works with "--slowfdc" | -
| If pigs could fly (Demo by Syndicate) | -yes | -- | Only works with "--slowfdc" | -
| Application | -Working | -Comment | -
| DevPac 2.2 | -yes | -MonST crashy | -
| Turbo Assembler | -yes | -- |
| GFABASIC 3.6TT | -yes | -MENU.PRG does not like harddisks. Use diskimages for compiling. | -
| ST Basic | -yes | -- |
| Neochrome | -yes | -rasters sometimes unstable | -
| Crackart | -yes | -- |
| Tempus | -yes | -- |
| Sagrotan | -yes | -- |
| SidSound Designer | -yes | -- |
| MusicMon 2 | -yes | -- |
| Protracker | -yes | -- |
| Teradesk | -yes | -- |
| Qed | -yes | -- |
| Everest | -yes | -- |
| Speed Of Light | -yes | -- |
| Matthias ArndtJuly 08 2004 | -