diff -r 87990958bdea src/configuration.c
--- a/src/configuration.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/configuration.c	Fri Jan 16 12:14:16 2009 +0100
@@ -520,22 +520,13 @@
 		Audio_SetOutputAudioFreq(ConfigureParams.Sound.nPlaybackQuality);
 	}
 	/* CPU settings */
-	if (ConfigureParams.System.nCpuFreq < 12)
-	{
-		ConfigureParams.System.nCpuFreq = 8;
-		nCpuFreqShift = 0;
-	}
-	else if (ConfigureParams.System.nCpuFreq > 26)
-	{
-		ConfigureParams.System.nCpuFreq = 32;
-		nCpuFreqShift = 2;
-	}
-	else
-	{
-		ConfigureParams.System.nCpuFreq = 16;
-		nCpuFreqShift = 1;
-	}
-	/* Change UAE cpu_level and cpu_compatible accordingly */
+  nCpuFreqShift = log2(ConfigureParams.System.nCpuFreq) - 3;
+  if(nCpuFreqShift<0 || nCpuFreqShift>6)
+    nCpuFreqShift = 0;
+  ConfigureParams.System.nCpuFreq = 8<<nCpuFreqShift;
+  
+	
+  /* Change UAE cpu_level and cpu_compatible accordingly */
 	M68000_CheckCpuLevel();
 
 	/* Clean file and directory names */
diff -r 87990958bdea src/debugui.c
--- a/src/debugui.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/debugui.c	Fri Jan 16 12:14:16 2009 +0100
@@ -8,7 +8,7 @@
   pressed, the emulator is (hopefully) halted and this little CLI can be used
   (in the terminal box) for debugging tasks like memory and register dumps.
 */
-const char DebugUI_rcsid[] = "Hatari $Id: debugui.c,v 1.26 2008-10-25 22:32:15 eerot Exp $";
+const char DebugUI_rcsid[] = "Hatari $Id: debugui.c,v 1.26 2008/10/25 22:32:15 eerot Exp $";
 
 #include <ctype.h>
 #include <stdio.h>
@@ -39,13 +39,13 @@
 #define NON_PRINT_CHAR '.'     /* character to display for non-printables */
 #define DISASM_INSTS   5       /* disasm - number of instructions */
 
+bool bDebugStep=FALSE;		/* Are we single stepping the CPU? */
+
 static bool bMemDump;          /* has memdump been called? */
 static unsigned long memdump_addr; /* memdump address */
 static unsigned long disasm_addr;  /* disasm address */
 
 static FILE *debugOutput;
-
-
 
 /*-----------------------------------------------------------------------*/
 /**
@@ -570,6 +570,7 @@
 	        " l filename address - load a file into memory starting at address. \n"
 	        " s filename address length - dump length bytes from memory to a file. \n"
 	        " o [command line] - set Hatari command line options\n\n"
+		" i - step one instruction\n"
 	        " q - quit emulator\n"
 	        " c - continue emulation\n\n"
 	        " Adresses may be given as a range e.g. fc0000-fc0100\nAll values in hexadecimal.\n"
@@ -684,6 +685,11 @@
 			DebugUI_SaveBin(input);
 		break;
 
+	case 'i':
+		//DebugUI_Step();
+		retval = DEBUG_STEP;
+		break;
+			
 	 default:
 		if (command[0])
 			fprintf(stderr,"  Unknown command: '%s'\n", command);
@@ -722,20 +728,38 @@
 	return retval;
 }
 
-
 /*-----------------------------------------------------------------------*/
 /**
  * Debug UI
  */
 void DebugUI(void)
 {
+	int cmd;
 	bMemDump = FALSE;
 	disasm_addr = 0;
 
-	fprintf(stderr, "\nYou have entered debug mode. Type c to continue emulation, h for help."
+	if(bDebugStep)
+	{
+		uaecptr disasm_addr = M68000_GetPC();
+		uaecptr nextpc;
+		m68k_disasm(debugOutput, (uaecptr)disasm_addr, &nextpc, 1);		
+	}
+	else
+	{
+		fprintf(stderr, "\nYou have entered debug mode. Type c to continue emulation, h for help."
 	                "\n----------------------------------------------------------------------\n");
-	while (DebugUI_GetCommand() != DEBUG_QUIT)
-		;
+	}
+	
+	while ( (cmd=DebugUI_GetCommand()) != DEBUG_QUIT)
+	{
+		if(cmd == DEBUG_STEP)
+		{
+			fprintf(stderr,"Stepping...\n");
+			bDebugStep=TRUE;
+			return;
+		}
+	}
+	bDebugStep=FALSE;
 	fprintf(stderr,"Returning to emulation...\n------------------------------\n\n");
 	DebugUI_SetLogDefault();
 }
diff -r 87990958bdea src/gui-osx/SDLMain.nib/classes.nib
--- a/src/gui-osx/SDLMain.nib/classes.nib	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/gui-osx/SDLMain.nib/classes.nib	Fri Jan 16 12:14:16 2009 +0100
@@ -1,129 +1,263 @@
-{
-    IBClasses = (
-        {
-            ACTIONS = {createFloppyImage = id; runModal = id; }; 
-            CLASS = CreateFloppyController; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                sectors = NSMatrix; 
-                sides = NSMatrix; 
-                tracks = NSPopUpButton; 
-                window = NSWindow; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {CLASS = FirstResponder; LANGUAGE = ObjC; SUPERCLASS = NSObject; }, 
-        {CLASS = NSPanel; LANGUAGE = ObjC; SUPERCLASS = NSWindow; }, 
-        {
-            ACTIONS = {
-                changeViewedJoystick = id; 
-                chooseCartridgeImage = id; 
-                chooseDefaultImagesLocation = id; 
-                chooseFloppyImageA = id; 
-                chooseFloppyImageB = id; 
-                chooseGemdosImage = id; 
-                chooseHdImage = id; 
-                chooseKeyboardMappingFile = id; 
-                chooseMidiOutputFile = id; 
-                choosePrintToFile = id; 
-                chooseRS232InputFile = id; 
-                chooseRS232OutputFile = id; 
-                chooseTosImage = id; 
-                commitAndClose = id; 
-                ejectFloppyA = id; 
-                ejectFloppyB = id; 
-                ejectGemdosImage = id; 
-                ejectHdImage = id; 
-                loadConfigFrom = id; 
-                loadPrefs = id; 
-                myAction = id; 
-                saveConfigAs = id; 
-                updateEnabledStates = id; 
-            }; 
-            CLASS = PrefsController; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                autoInsertB = NSButton; 
-                blitter = NSButton; 
-                bootFromHD = NSButton; 
-                captureOnChange = NSButton; 
-                cartridgeImage = NSTextField; 
-                colorDepth = NSMatrix; 
-                compatibleCpu = NSButton; 
-                cpuClock = NSMatrix; 
-                cpuType = NSMatrix; 
-                currentJoystick = NSPopUpButton; 
-                defaultImagesLocation = NSTextField; 
-                enableAutoFire = NSButton; 
-                enableDSP = NSPopUpButton; 
-                enableMidi = NSButton; 
-                enablePrinter = NSButton; 
-                enableRS232 = NSButton; 
-                enableSound = NSButton; 
-                floppyImageA = NSTextField; 
-                floppyImageB = NSTextField; 
-                force8bpp = NSButton; 
-                frameSkip = NSPopUpButton; 
-                gemdosImage = NSTextField; 
-                hdImage = NSTextField; 
-                joystickDown = NSPopUpButton; 
-                joystickFire = NSPopUpButton; 
-                joystickLeft = NSPopUpButton; 
-                joystickMode = NSMatrix; 
-                joystickRight = NSPopUpButton; 
-                joystickUp = NSPopUpButton; 
-                keyboardMapping = NSMatrix; 
-                keyboardMappingFile = NSTextField; 
-                machineType = NSMatrix; 
-                monitor = NSMatrix; 
-                patchTimerD = NSButton; 
-                playbackQuality = NSMatrix; 
-                printToFile = NSTextField; 
-                ramSize = NSMatrix; 
-                readRS232FromFile = NSTextField; 
-                realJoystick = NSPopUpButton; 
-                realTime = NSButton; 
-                resolution = NSMatrix; 
-                showStatusBar = NSButton; 
-                slowFDC = NSButton; 
-                tosImage = NSTextField; 
-                useBorders = NSButton; 
-                useVDIResolution = NSButton; 
-                window = NSWindow; 
-                writeMidiToFile = NSTextField; 
-                writeProtection = NSMatrix; 
-                writeRS232ToFile = NSTextField; 
-                zoomSTLowRes = NSButton; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }, 
-        {
-            ACTIONS = {
-                captureAnimation = id; 
-                captureScreen = id; 
-                captureSound = id; 
-                coldReset = id; 
-                doFullScreen = id; 
-                endCaptureAnimation = id; 
-                endCaptureSound = id; 
-                help = id; 
-                insertDiskA = id; 
-                insertDiskB = id; 
-                prefsMenu = id; 
-                restoreMemorySnap = id; 
-                saveMemorySnap = id; 
-                warmReset = id; 
-            }; 
-            CLASS = SDLMain; 
-            LANGUAGE = ObjC; 
-            OUTLETS = {
-                beginCaptureAnim = NSMenuItem; 
-                beginCaptureSound = NSMenuItem; 
-                endCaptureAnim = NSMenuItem; 
-                endCaptureSound = NSMenuItem; 
-            }; 
-            SUPERCLASS = NSObject; 
-        }
-    ); 
-    IBVersion = 1; 
-}
\ No newline at end of file
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>IBClasses</key>
+	<array>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>changeViewedJoystick</key>
+				<string>id</string>
+				<key>chooseCartridgeImage</key>
+				<string>id</string>
+				<key>chooseDefaultImagesLocation</key>
+				<string>id</string>
+				<key>chooseFloppyImageA</key>
+				<string>id</string>
+				<key>chooseFloppyImageB</key>
+				<string>id</string>
+				<key>chooseGemdosImage</key>
+				<string>id</string>
+				<key>chooseHdImage</key>
+				<string>id</string>
+				<key>chooseKeyboardMappingFile</key>
+				<string>id</string>
+				<key>chooseMidiOutputFile</key>
+				<string>id</string>
+				<key>choosePrintToFile</key>
+				<string>id</string>
+				<key>chooseRS232InputFile</key>
+				<string>id</string>
+				<key>chooseRS232OutputFile</key>
+				<string>id</string>
+				<key>chooseTosImage</key>
+				<string>id</string>
+				<key>commitAndClose</key>
+				<string>id</string>
+				<key>ejectFloppyA</key>
+				<string>id</string>
+				<key>ejectFloppyB</key>
+				<string>id</string>
+				<key>ejectGemdosImage</key>
+				<string>id</string>
+				<key>ejectHdImage</key>
+				<string>id</string>
+				<key>loadConfigFrom</key>
+				<string>id</string>
+				<key>loadPrefs</key>
+				<string>id</string>
+				<key>myAction</key>
+				<string>id</string>
+				<key>saveConfigAs</key>
+				<string>id</string>
+				<key>updateEnabledStates</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>PrefsController</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>autoInsertB</key>
+				<string>NSButton</string>
+				<key>blitter</key>
+				<string>NSButton</string>
+				<key>bootFromHD</key>
+				<string>NSButton</string>
+				<key>captureOnChange</key>
+				<string>NSButton</string>
+				<key>cartridgeImage</key>
+				<string>NSTextField</string>
+				<key>colorDepth</key>
+				<string>NSMatrix</string>
+				<key>compatibleCpu</key>
+				<string>NSButton</string>
+				<key>configFile</key>
+				<string>NSTextField</string>
+				<key>cpuClock</key>
+				<string>NSMatrix</string>
+				<key>cpuType</key>
+				<string>NSMatrix</string>
+				<key>currentJoystick</key>
+				<string>NSPopUpButton</string>
+				<key>defaultImagesLocation</key>
+				<string>NSTextField</string>
+				<key>enableAutoFire</key>
+				<string>NSButton</string>
+				<key>enableDSP</key>
+				<string>NSPopUpButton</string>
+				<key>enableMidi</key>
+				<string>NSButton</string>
+				<key>enablePrinter</key>
+				<string>NSButton</string>
+				<key>enableRS232</key>
+				<string>NSButton</string>
+				<key>enableSound</key>
+				<string>NSButton</string>
+				<key>floppyImageA</key>
+				<string>NSTextField</string>
+				<key>floppyImageB</key>
+				<string>NSTextField</string>
+				<key>force8bpp</key>
+				<string>NSButton</string>
+				<key>frameSkip</key>
+				<string>NSPopUpButton</string>
+				<key>gemdosImage</key>
+				<string>NSTextField</string>
+				<key>hdImage</key>
+				<string>NSTextField</string>
+				<key>interleaved</key>
+				<string>NSButton</string>
+				<key>joystickDown</key>
+				<string>NSPopUpButton</string>
+				<key>joystickFire</key>
+				<string>NSPopUpButton</string>
+				<key>joystickLeft</key>
+				<string>NSPopUpButton</string>
+				<key>joystickMode</key>
+				<string>NSMatrix</string>
+				<key>joystickRight</key>
+				<string>NSPopUpButton</string>
+				<key>joystickUp</key>
+				<string>NSPopUpButton</string>
+				<key>keyboardMapping</key>
+				<string>NSMatrix</string>
+				<key>keyboardMappingFile</key>
+				<string>NSTextField</string>
+				<key>machineType</key>
+				<string>NSMatrix</string>
+				<key>monitor</key>
+				<string>NSMatrix</string>
+				<key>nSpec512Treshold</key>
+				<string>NSSlider</string>
+				<key>patchTimerD</key>
+				<string>NSButton</string>
+				<key>playbackQuality</key>
+				<string>NSMatrix</string>
+				<key>printToFile</key>
+				<string>NSTextField</string>
+				<key>ramSize</key>
+				<string>NSMatrix</string>
+				<key>readRS232FromFile</key>
+				<string>NSTextField</string>
+				<key>realJoystick</key>
+				<string>NSPopUpButton</string>
+				<key>realTime</key>
+				<string>NSButton</string>
+				<key>resolution</key>
+				<string>NSMatrix</string>
+				<key>showStatusBar</key>
+				<string>NSButton</string>
+				<key>slowFDC</key>
+				<string>NSButton</string>
+				<key>tosImage</key>
+				<string>NSTextField</string>
+				<key>useBorders</key>
+				<string>NSButton</string>
+				<key>useVDIResolution</key>
+				<string>NSButton</string>
+				<key>window</key>
+				<string>NSWindow</string>
+				<key>writeMidiToFile</key>
+				<string>NSTextField</string>
+				<key>writeProtection</key>
+				<string>NSMatrix</string>
+				<key>writeRS232ToFile</key>
+				<string>NSTextField</string>
+				<key>zoomSTLowRes</key>
+				<string>NSButton</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>CLASS</key>
+			<string>FirstResponder</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>captureAnimation</key>
+				<string>id</string>
+				<key>captureScreen</key>
+				<string>id</string>
+				<key>captureSound</key>
+				<string>id</string>
+				<key>coldReset</key>
+				<string>id</string>
+				<key>doFullScreen</key>
+				<string>id</string>
+				<key>endCaptureAnimation</key>
+				<string>id</string>
+				<key>endCaptureSound</key>
+				<string>id</string>
+				<key>help</key>
+				<string>id</string>
+				<key>insertDiskA</key>
+				<string>id</string>
+				<key>insertDiskB</key>
+				<string>id</string>
+				<key>prefsMenu</key>
+				<string>id</string>
+				<key>restoreMemorySnap</key>
+				<string>id</string>
+				<key>saveMemorySnap</key>
+				<string>id</string>
+				<key>warmReset</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>SDLMain</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>beginCaptureAnim</key>
+				<string>NSMenuItem</string>
+				<key>beginCaptureSound</key>
+				<string>NSMenuItem</string>
+				<key>endCaptureAnim</key>
+				<string>NSMenuItem</string>
+				<key>endCaptureSound</key>
+				<string>NSMenuItem</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+		<dict>
+			<key>ACTIONS</key>
+			<dict>
+				<key>createFloppyImage</key>
+				<string>id</string>
+				<key>runModal</key>
+				<string>id</string>
+			</dict>
+			<key>CLASS</key>
+			<string>CreateFloppyController</string>
+			<key>LANGUAGE</key>
+			<string>ObjC</string>
+			<key>OUTLETS</key>
+			<dict>
+				<key>sectors</key>
+				<string>NSMatrix</string>
+				<key>sides</key>
+				<string>NSMatrix</string>
+				<key>tracks</key>
+				<string>NSPopUpButton</string>
+				<key>window</key>
+				<string>NSWindow</string>
+			</dict>
+			<key>SUPERCLASS</key>
+			<string>NSObject</string>
+		</dict>
+	</array>
+	<key>IBVersion</key>
+	<string>1</string>
+</dict>
+</plist>
diff -r 87990958bdea src/gui-osx/SDLMain.nib/info.nib
--- a/src/gui-osx/SDLMain.nib/info.nib	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/gui-osx/SDLMain.nib/info.nib	Fri Jan 16 12:14:16 2009 +0100
@@ -1,23 +1,19 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 <plist version="1.0">
 <dict>
-	<key>IBDocumentLocation</key>
-	<string>613 15 503 374 0 0 1680 1028 </string>
 	<key>IBFramework Version</key>
-	<string>489.0</string>
+	<string>629</string>
 	<key>IBLastKnownRelativeProjectPath</key>
-	<string>../../Hatari.xcodeproj</string>
+	<string>../../../Hatari.xcodeproj</string>
 	<key>IBOldestOS</key>
-	<integer>3</integer>
+	<integer>5</integer>
 	<key>IBOpenObjects</key>
 	<array>
-		<integer>326</integer>
+		<integer>398</integer>
 	</array>
 	<key>IBSystem Version</key>
-	<string>8S165</string>
-	<key>IBUsesTextArchiving</key>
-	<true/>
+	<string>9G55</string>
 	<key>targetFramework</key>
 	<string>IBCocoaFramework</string>
 </dict>
diff -r 87990958bdea src/gui-osx/SDLMain.nib/keyedobjects.nib
Binary file src/gui-osx/SDLMain.nib/keyedobjects.nib has changed
diff -r 87990958bdea src/gui-sdl/dlgSystem.c
--- a/src/gui-sdl/dlgSystem.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/gui-sdl/dlgSystem.c	Fri Jan 16 12:14:16 2009 +0100
@@ -4,7 +4,7 @@
   This file is distributed under the GNU Public License, version 2 or at
   your option any later version. Read the file gpl.txt for details.
 */
-const char DlgSystem_rcsid[] = "Hatari $Id: dlgSystem.c,v 1.11 2008-06-08 16:07:42 eerot Exp $";
+const char DlgSystem_rcsid[] = "Hatari $Id: dlgSystem.c,v 1.11 2008/06/08 16:07:42 eerot Exp $";
 
 #include "main.h"
 #include "configuration.h"
@@ -24,12 +24,13 @@
 #define DLGSYS_8MHZ     17
 #define DLGSYS_16MHZ    18
 #define DLGSYS_32MHZ    19
-#define DLGSYS_PREFETCH 20
-#define DLGSYS_BLITTER  21
-#define DLGSYS_RTC      22
-#define DLGSYS_TIMERD   23
-#define DLGSYS_SLOWFDC  24
-
+#define DLGSYS_64MHZ    20
+#define DLGSYS_128MHZ   21
+#define DLGSYS_PREFETCH 22
+#define DLGSYS_BLITTER  23
+#define DLGSYS_RTC      24
+#define DLGSYS_TIMERD   25
+#define DLGSYS_SLOWFDC  26
 
 /* The "System" dialog: */
 static SGOBJ systemdlg[] =
@@ -57,6 +58,8 @@
 	{ SGRADIOBUT, 0, 0, 19,13, 3,1, "8" },
 	{ SGRADIOBUT, 0, 0, 24,13, 4,1, "16" },
 	{ SGRADIOBUT, 0, 0, 30,13, 4,1, "32" },
+	{ SGRADIOBUT, 0, 0, 19,14, 4,1, "64" },
+	{ SGRADIOBUT, 0, 0, 30,14, 4,1, "128" },
 
 	{ SGCHECKBOX, 0, 0, 2,15, 32,1, "Slower but more compatible CPU" },
 	{ SGCHECKBOX, 0, 0, 2,16, 20,1, "Blitter emulation" },
@@ -93,11 +96,15 @@
 	}
 	systemdlg[DLGSYS_ST + ConfigureParams.System.nMachineType].state |= SG_SELECTED;
 
-	for (i = DLGSYS_8MHZ; i <= DLGSYS_16MHZ; i++)
+	for (i = DLGSYS_8MHZ; i <= DLGSYS_128MHZ; i++)
 	{
 		systemdlg[i].state &= ~SG_SELECTED;
 	}
-	if (ConfigureParams.System.nCpuFreq == 32)
+	if (ConfigureParams.System.nCpuFreq == 128)
+	  systemdlg[DLGSYS_128MHZ].state |= SG_SELECTED;
+	else if (ConfigureParams.System.nCpuFreq == 64)
+	  systemdlg[DLGSYS_64MHZ].state |= SG_SELECTED;
+	else if (ConfigureParams.System.nCpuFreq == 32)
 	  systemdlg[DLGSYS_32MHZ].state |= SG_SELECTED;
 	else if (ConfigureParams.System.nCpuFreq == 16)
 	  systemdlg[DLGSYS_16MHZ].state |= SG_SELECTED;
@@ -152,7 +159,11 @@
 		}
 	}
 
-	if (systemdlg[DLGSYS_32MHZ].state & SG_SELECTED)
+	if (systemdlg[DLGSYS_128MHZ].state & SG_SELECTED)
+		ConfigureParams.System.nCpuFreq = 128;
+	else if (systemdlg[DLGSYS_64MHZ].state & SG_SELECTED)
+		ConfigureParams.System.nCpuFreq = 64;
+	else if (systemdlg[DLGSYS_32MHZ].state & SG_SELECTED)
 		ConfigureParams.System.nCpuFreq = 32;
 	else if (systemdlg[DLGSYS_16MHZ].state & SG_SELECTED)
 		ConfigureParams.System.nCpuFreq = 16;
diff -r 87990958bdea src/includes/debugui.h
--- a/src/includes/debugui.h	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/includes/debugui.h	Fri Jan 16 12:14:16 2009 +0100
@@ -11,10 +11,13 @@
 /* DebugUI_ParseCommand() return values */
 enum {
 	DEBUG_QUIT,
-	DEBUG_CMD
+	DEBUG_CMD,
+	DEBUG_STEP
 };
 
 extern void DebugUI(void);
 extern int DebugUI_ParseCommand(char *input);
 
+extern bool bDebugStep;
+
 #endif /* HATARI_DEBUGUI_H */
diff -r 87990958bdea src/includes/m68000.h
--- a/src/includes/m68000.h	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/includes/m68000.h	Fri Jan 16 12:14:16 2009 +0100
@@ -147,11 +147,9 @@
 #define BUS_ERROR_WRITE 0
 #define BUS_ERROR_READ 1
 
-
 /* bus acces mode */
-#define	BUS_MODE_CPU		0			/* bus is owned by the cpu */
-#define	BUS_MODE_BLITTER	1			/* bus is owned by the blitter */
-
+#define	BUS_MODE_CPU  0     /* bus is owned by the cpu */
+#define	BUS_MODE_BLITTER  1     /* bus is owned by the blitter */
 
 extern Uint32 BusErrorAddress;
 extern Uint32 BusErrorPC;
@@ -176,7 +174,9 @@
 {
 	cycles = (cycles + 3) & ~3;
 	cycles = cycles >> nCpuFreqShift;
-
+  /* we have to advance the cycle counter by at least one cycle! */
+  if(cycles<1) cycles=1;
+  
 	PendingInterruptCount -= INT_CONVERT_TO_INTERNAL(cycles, INT_CPU_CYCLE);
 	nCyclesMainCounter += cycles;
 }
@@ -232,6 +232,9 @@
 
 	cycles = cycles >> nCpuFreqShift;
 
+  /* we have to advance the cycle counter by at least one cycle! */
+  if(cycles<1) cycles=1;
+
 	PendingInterruptCount -= INT_CONVERT_TO_INTERNAL ( cycles , INT_CPU_CYCLE );
 
 	nCyclesMainCounter += cycles;
diff -r 87990958bdea src/options.c
--- a/src/options.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/options.c	Fri Jan 16 12:14:16 2009 +0100
@@ -46,7 +46,7 @@
 
 bool bLoadAutoSave;        /* Load autosave memory snapshot at startup */
 bool bLoadMemorySave;      /* Load memory snapshot provided via option at startup */
-bool bBiosIntercept;       /* whether UAE should intercept Bios & XBios calls */
+bool bBiosIntercept=TRUE;  /* whether UAE should intercept Bios & XBios calls */
 
 
 /*  List of supported options. */
diff -r 87990958bdea src/uae-cpu/newcpu.c
--- a/src/uae-cpu/newcpu.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/uae-cpu/newcpu.c	Fri Jan 16 12:14:16 2009 +0100
@@ -1660,10 +1660,11 @@
     uae_u16 *oldpcp;
 #endif
 
-    for (;;) {
-	int cycles;
-	uae_u32 opcode = get_iword_prefetch (0);
-
+  for (;;) {
+      int cycles;
+      uae_u32 opcode = get_iword_prefetch (0);
+      if(bDebugStep) DebugUI();
+      
 #ifdef DEBUG_PREFETCH
 	if (get_ilong (0) != do_get_mem_long (&regs.prefetch)) {
 	    fprintf (stderr, "Prefetch differs from memory.\n");
@@ -1754,8 +1755,9 @@
 static void m68k_run_2 (void)
 {
     for (;;) {
-	int cycles;
-	uae_u32 opcode = get_iword (0);
+      int cycles;
+      uae_u32 opcode = get_iword (0);
+      if(bDebugStep) DebugUI();
 
 	/*m68k_dumpstate(stderr, NULL);*/
 	if ( HATARI_TRACE_LEVEL ( HATARI_TRACE_CPU_DISASM ) )
diff -r 87990958bdea src/xbios.c
--- a/src/xbios.c	Tue Jan 13 23:42:16 2009 +0200
+++ b/src/xbios.c	Fri Jan 16 12:14:16 2009 +0100
@@ -9,7 +9,7 @@
   We intercept and direct some XBios calls to handle the RS-232 etc. and help
   with floppy debugging.
 */
-const char XBios_rcsid[] = "Hatari $Id: xbios.c,v 1.18 2008-11-03 20:24:25 thothy Exp $";
+const char XBios_rcsid[] = "Hatari $Id: xbios.c,v 1.18 2008/11/03 20:24:25 thothy Exp $";
 
 #include "main.h"
 #include "configuration.h"
@@ -20,10 +20,9 @@
 #include "screenSnapShot.h"
 #include "stMemory.h"
 #include "xbios.h"
-
+#include "debugui.h"
 
 #define XBIOS_DEBUG 0	/* for floppy read/write */
-
 
 /* List of Atari ST RS-232 baud rates */
 static const int BaudRates[] =
@@ -161,6 +160,186 @@
 }
 
 
+/*----------------------------------------------------------------------- */
+/**
+ * XBIOS Prtblk
+ * Call 36
+ */
+static bool XBios_Prtblk(Uint32 Params)
+{
+	/* Correct return code? */
+	Regs[REG_D0] = 0;
+
+	return TRUE;
+}
+
+/*----------------------------------------------------------------------- */
+/**
+ * XBIOS Change Emulator Options
+ * Call 255
+ */
+static bool XBios_HatariOption(Uint32 Params)
+{
+  int option = STMemory_ReadWord(Params+2);
+  fprintf(stderr, "Intercepted XBIOS HatariOption(), option=%d (%08x), ", option, Params);
+
+  switch(option)
+  {
+  case 1: /* Min speed? */
+    ConfigureParams.System.bFastForward = false;
+    //ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MIN;
+    /* Reset the sound emulation variables: */
+    Sound_ResetBufferIndex();
+    fprintf(stderr, "Normal speed\n");
+    Regs[REG_D0] = 0;
+    break;
+  case 2: /* Max speed? */
+    ConfigureParams.System.bFastForward = true;
+    //ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MAX;
+    fprintf(stderr, "Maximum speed!\n");
+    Regs[REG_D0] = 0;
+    break;
+  case 3:  /* Enable debugger? */
+	  bEnableDebug = TRUE;  
+	  fprintf(stderr, "Debugger enabled\n");
+	  Regs[REG_D0] = 0;
+    break;
+  case 4:  /* Disable debugger? */
+	  bEnableDebug = FALSE;  
+	  fprintf(stderr, "Debugger disabled\n");
+	  Regs[REG_D0] = 0;
+    break;
+  default:
+    fprintf(stderr, "Unknown argument (%d)\n",Params);
+    Regs[REG_D0] = -1;
+  }
+
+  return(TRUE);
+}
+
+/*----------------------------------------------------------------------- */
+/**
+ * XBIOS Debug output to console
+ * Call 254
+ * Parameters: memptr at -2(sp) and numbytes at -6(sp)
+ */
+static bool XBios_Debug(Uint32 Params)
+{
+  int i;
+  Uint32 memptr = STMemory_ReadLong(Params+2);
+  Uint32 length = STMemory_ReadLong(Params+6);
+  
+  fprintf(stderr, "Memory dump at 0x%08x (%d bytes): ", memptr, length);
+  if(length>256)
+  {
+    length = 256;
+    fprintf(stderr,"length truncated to 256 bytes! ");
+  }
+  for(i=0;i<length;i++)
+  {
+    if( (i%16) == 0) fprintf(stderr,"\n");
+    fprintf(stderr,"%02x ",STMemory_ReadByte(memptr+i));
+  }
+  fprintf(stderr,"\n");
+  
+  return(TRUE);
+}
+
+/**
+ * XBIOS Dump all registers to console
+ * Call 251
+ * Parameters: none
+ */
+static bool XBios_Registers(Uint32 Params)
+{
+//	Uint32 memptr = STMemory_ReadLong(Params+2);
+//	Uint32 length = STMemory_ReadLong(Params+6);
+	
+	fprintf(stderr, "Registers: \n");
+	fprintf(stderr,"d/a0     d/a1     d/a2     d/a3      d/a4     d/a5     d/a6     d/a7 \n");
+	fprintf(stderr,"%08x %08x %08x %08x %08x %08x %08x %08x \n",
+		Regs[REG_D0], Regs[REG_D1], Regs[REG_D2], Regs[REG_D3],
+		Regs[REG_D4], Regs[REG_D5], Regs[REG_D6], Regs[REG_D7] );
+	fprintf(stderr,"%08x %08x %08x %08x %08x %08x %08x %08x \n",
+		Regs[REG_A0], Regs[REG_A1], Regs[REG_A2], Regs[REG_A3],
+		Regs[REG_A4], Regs[REG_A5], Regs[REG_A6], Regs[REG_A7] );
+	
+	return(TRUE);
+}
+
+static Uint32 sCycleCounter[256];
+extern int nScanlinesPerFrame;                   /* Number of scan lines per frame */
+extern int nCyclesPerLine;                       /* Cycles per horizontal line scan */
+
+/**
+ * XBIOS Start or restart a cycle counter
+ * Call 253
+ * Parameters: counter no at -2(sp)
+ */
+static bool XBios_CounterStart(Uint32 Params)
+{
+  Params = STMemory_ReadWord(Params+2);
+  Params &= 0xFF;  /* we only use 255 cycle counters */
+  sCycleCounter[Params] = Cycles_GetCounter(CYCLES_COUNTER_VIDEO);
+/*  fprintf(stderr,"XBios cycle counter #%d started at %d\n",Params,sCycleCounter[Params]); */
+  return(TRUE);
+}
+
+/**
+ * XBIOS Stop a cycle counter
+ * Call 252
+ * Parameters: counter no at -2(sp)
+ */
+static bool XBios_CounterRead(Uint32 Params)
+{
+  Uint32 cycles,curr_cycles;
+  Params = STMemory_ReadWord(Params+2);
+  Params &= 0xFF;  /* we only use 255 cycle counters */
+/*  sCycleCounter[Params] = nCycleMainCounter - sCycleCounter[Params]; */
+
+  cycles = Cycles_GetCounter(CYCLES_COUNTER_VIDEO);
+
+  /* has the frame refreshed? */
+  if(cycles < sCycleCounter[Params])
+  {  /* extend the frame... */
+    cycles += nScanlinesPerFrame*nCyclesPerLine;;
+  }
+
+  curr_cycles = cycles-sCycleCounter[Params];
+  fprintf(stderr,"Cnt #%d at %d : %d cycles (%d frames + %d cycles)\n",
+    Params,cycles,curr_cycles,curr_cycles/nCyclesPerLine,curr_cycles%nCyclesPerLine);
+  return(TRUE);
+}
+
+/**
+ * XBIOS Set Hatari CPU frequency
+ * Call 249
+ * Parameters: CPU frequency (word)
+ */
+static bool XBios_CPUFreq(Uint32 Params)
+{
+  int cpuFreq = STMemory_ReadWord(Params+2);
+  cpuFreq &= 0x1FF; /* max freq is 511 MHz */
+  nCpuFreqShift = log2(cpuFreq) - 3;
+  if(nCpuFreqShift<0 || nCpuFreqShift>6)
+    nCpuFreqShift = 0;
+  ConfigureParams.System.nCpuFreq = 8<<nCpuFreqShift;
+  printf("cpu freq: %d , cpu shift: %d \n", cpuFreq ,  nCpuFreqShift);  
+	return(TRUE);
+}
+
+/**
+ * XBIOS Enter Hatari debug UI
+ * Call 251
+ * Parameters: none
+ */
+static bool XBios_DebugUI(Uint32 Params)
+{
+	DebugUI();
+	return(TRUE);
+}
+
+
 /*-----------------------------------------------------------------------*/
 /**
  * Check if we need to re-direct XBios call to our own routines
@@ -169,11 +348,10 @@
 {
 	Uint32 Params;
 	Uint16 XBiosCall;
-
 	/* Find call */
 	Params = Regs[REG_A7];
 	XBiosCall = STMemory_ReadWord(Params);
-
+	Log_Printf(LOG_DEBUG, "XBIOS %d\n",XBiosCall);
 	switch (XBiosCall)
 	{
 	 case 8:
@@ -189,6 +367,29 @@
 		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS Scrdmp()\n" );
 		return XBios_Scrdmp(Params);
 
+	/* DHS specific debug patches */
+  case 249:
+    HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS CPUFreq()\n" );
+    return(XBios_CPUFreq(Params));
+  case 250:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS Registers()\n" );
+		return(XBios_Registers(Params));
+	case 251:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS DebugUI()\n" );
+		return(XBios_DebugUI(Params));
+	case 252:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS CounterRead()\n" );
+		return(XBios_CounterRead(Params));
+	case 253:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS CounterStart()\n" );
+		return(XBios_CounterStart(Params));
+	case 254:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS Debug()\n" );
+		return(XBios_Debug(Params));
+	case 255:
+		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS DHS HatariOption()\n" );
+		return(XBios_HatariOption(Params));
+			
 	 default:  /* Call as normal! */
 		HATARI_TRACE ( HATARI_TRACE_OS_XBIOS, "XBIOS %d\n", XBiosCall );
 		return FALSE;
