Re: [hatari-devel] Sparrow TOS 2.07 support

[ Thread Index | Date Index | More lists.tuxfamily.org/hatari-devel Archives ]


On Sonntag, 27. Mai 2018 17:27:14 CEST Miro Kropáček wrote:
> On 27 May 2018 at 16:45, Thomas Huth <th.huth@xxxxxxxxx> wrote:
> > I've added a hack to the Videl emulation, and now it boots to the desktop.
> 
> Btw do you also get the CRC ROM error after the Atari symbol is shown
> during the boot?

That is to be expected. The rom check is skipped when the TOS is patched, but 
only for known TOS versions. For sparrow, the attached patch should add the 
necessary addresses.


diff -r 30c9b191506c src/ikbd.c
--- a/src/ikbd.c	Sun May 27 16:47:22 2018 +0200
+++ b/src/ikbd.c	Sun May 27 18:09:16 2018 +0200
@@ -108,6 +108,8 @@
 					/* Beside, some programs explicitly wait for 0xF1 after a reset (Dragonnels demo) */
 
 
+#define PRINTF printf
+
 /* Keyboard state */
 KEYBOARD Keyboard;
 
@@ -372,6 +374,7 @@
 static int	MemoryLoadNbBytesLeft = 0;		/* number of bytes that remain to be sent  */
 static Uint32	MemoryLoadCrc = 0xffffffff;		/* CRC of the bytes sent to the IKBD */
 static int	MemoryExeNbBytes = 0;			/* current number of bytes sent to the IKBD when IKBD_ExeMode is true */
+static unsigned char execode[256];
 
 static void	(*pIKBD_CustomCodeHandler_Read) ( void );
 static void	(*pIKBD_CustomCodeHandler_Write) ( Uint8 );
@@ -2450,11 +2453,12 @@
  */
 static void IKBD_Cmd_LoadMemory(void)
 {
-	LOG_TRACE(TRACE_IKBD_CMDS, "IKBD_Cmd_LoadMemory addr 0x%x count %d\n",
+	PRINTF("IKBD_Cmd_LoadMemory addr 0x%x count %d\n",
 		  (Keyboard.InputBuffer[1] << 8) + Keyboard.InputBuffer[2], Keyboard.InputBuffer[3]);
 
 	MemoryLoadNbBytesTotal = Keyboard.InputBuffer[3];
 	MemoryLoadNbBytesLeft = MemoryLoadNbBytesTotal;
+	
 	crc32_reset ( &MemoryLoadCrc );
 }
 
@@ -2509,14 +2513,14 @@
 
 	if ( pIKBD_CustomCodeHandler_Write )
 	{
-		LOG_TRACE(TRACE_IKBD_EXEC, "ikbd execute addr 0x%x using custom handler\n",
+		PRINTF("ikbd execute addr 0x%x using custom handler\n",
 			  (Keyboard.InputBuffer[1] << 8) + Keyboard.InputBuffer[2]);
 
 		IKBD_ExeMode = true;				/* turn 6301's custom mode ON */
 	}
 	else							/* unknown code uploaded to ikbd RAM */
 	{
-		LOG_TRACE(TRACE_IKBD_EXEC, "ikbd execute addr 0x%x ignored, no custom handler found\n",
+		PRINTF("ikbd execute addr 0x%x ignored, no custom handler found\n",
 			  (Keyboard.InputBuffer[1] << 8) + Keyboard.InputBuffer[2]);
 	}
 }
@@ -2824,10 +2828,17 @@
 //	FILE *f = fopen ( "/tmp/ikbd_loadmemory.dump" , "ab" ) ; fprintf ( f , "%c" , aciabyte ) ; fclose ( f );
 
 	crc32_add_byte ( &MemoryLoadCrc , aciabyte );
+	execode[MemoryExeNbBytes] = aciabyte;
+	MemoryExeNbBytes++;
 
 	MemoryLoadNbBytesLeft--;
 	if ( MemoryLoadNbBytesLeft == 0 )				/* all bytes were received */
 	{
+		{
+			FILE *f = fopen ( "/tmp/ikbd_loadmemory" , "wb" );
+			fwrite(execode, 1, MemoryLoadNbBytesTotal, f);
+			fclose (f);
+		}
 		/* Search for a match amongst the known custom routines */
 		for ( i = 0 ; i < sizeof ( CustomCodeDefinitions ) / sizeof ( CustomCodeDefinitions[0] ) ; i++ )
 			if ( CustomCodeDefinitions[ i ].LoadMemCrc == MemoryLoadCrc )
@@ -2835,7 +2846,7 @@
 
 		if ( i < sizeof ( CustomCodeDefinitions ) / sizeof ( CustomCodeDefinitions[0] ) )	/* found */
 		{
-			LOG_TRACE(TRACE_IKBD_EXEC, "ikbd loadmemory %d bytes crc=0x%x matches <%s>\n",
+			PRINTF("ikbd loadmemory %d bytes crc=0x%x matches <%s>\n",
 				  MemoryLoadNbBytesTotal, MemoryLoadCrc, CustomCodeDefinitions[ i ].Name);
 
 			crc32_reset ( &MemoryLoadCrc );
@@ -2846,7 +2857,7 @@
 
 		else							/* unknown code uploaded to IKBD's RAM */
 		{
-			LOG_TRACE(TRACE_IKBD_EXEC, "ikbd loadmemory %d bytes crc=0x%x : unknown code\n",
+			PRINTF("ikbd loadmemory %d bytes crc=0x%x : unknown code\n",
 				  MemoryLoadNbBytesTotal, MemoryLoadCrc);
 
 			pIKBD_CustomCodeHandler_Read = NULL;
@@ -2874,6 +2885,7 @@
 //	FILE *f = fopen ( "/tmp/ikbd_custom_program.dump" , "ab" ) ; fprintf ( f , "%c" , aciabyte ) ; fclose ( f );
 
 	crc32_add_byte ( &MemoryLoadCrc , aciabyte );
+	execode[MemoryExeNbBytes] = aciabyte;
 	MemoryExeNbBytes++;
 
 	LOG_TRACE(TRACE_IKBD_EXEC, "ikbd custom exe common boot write 0x%02x count %d crc=0x%x\n",
@@ -2887,7 +2899,20 @@
 
 	if ( i < sizeof ( CustomCodeDefinitions ) / sizeof ( CustomCodeDefinitions[0] ) )	/* found */
 	{
-		LOG_TRACE(TRACE_IKBD_EXEC, "ikbd custom exe common boot, uploaded code matches <%s>\n",
+		{
+			FILE *f = fopen ( "/tmp/ikbd_custom_program.dump" , "wb" );
+			fwrite(execode, 1, CustomCodeDefinitions[ i ].MainProgNbBytes, f);
+			fclose (f);
+		}
+		{
+			int j;
+			
+			FILE *f = fopen ( "/tmp/ikbd_custom_program_rev.dump" , "wb" );
+			for (j = 0; j < CustomCodeDefinitions[ i ].MainProgNbBytes; j++)
+				fputc(execode[CustomCodeDefinitions[ i ].MainProgNbBytes - j - 1], f);
+			fclose (f);
+		}
+		PRINTF("ikbd custom exe common boot, uploaded code matches <%s>\n",
 			  CustomCodeDefinitions[i].Name);
 
 		pIKBD_CustomCodeHandler_Read = CustomCodeDefinitions[ i ].ExeMainHandler_Read;
diff -r 30c9b191506c src/includes/vdi.h
--- a/src/includes/vdi.h	Sun May 27 16:47:22 2018 +0200
+++ b/src/includes/vdi.h	Sun May 27 18:09:16 2018 +0200
@@ -26,7 +26,7 @@
  * which fills nicely qHD (960x540), DVGA (960x640) and WSVGA (1024x600)
  * standard resolution displays.
  */
-#define MAX_VDI_BYTES 300*1024
+#define MAX_VDI_BYTES 600*1024
 #define MAX_VDI_WIDTH  2048
 #define MAX_VDI_HEIGHT 1280
 /* smaller doesn't make sense even for testing */
diff -r 30c9b191506c src/mfp.c
--- a/src/mfp.c	Sun May 27 16:47:22 2018 +0200
+++ b/src/mfp.c	Sun May 27 18:09:16 2018 +0200
@@ -1060,7 +1060,8 @@
 		if (TimerData == 0)             /* Data=0 is actually Data=256 */
 			TimerData = 256;
 		TimerClockCycles = MFP_REG_TO_CYCLES ( TimerData, TimerControl );
-
+        if (Handler == INTERRUPT_MFP_TIMERC && ConfigureParams.System.bFastForward)
+             TimerClockCycles *= 10;
 		if ( LOG_TRACE_LEVEL( TRACE_MFP_START ) )
 		{
 			int FrameCycles, HblCounterVideo, LineCycles;
diff -r 30c9b191506c src/tos.c
--- a/src/tos.c	Sun May 27 16:47:22 2018 +0200
+++ b/src/tos.c	Sun May 27 18:09:16 2018 +0200
@@ -101,6 +101,7 @@
         0x4E, 0x71, 0x4E, 0x71, 0x4E, 0x71, 0x4E, 0x71, 0x4E, 0x71, 0x4E, 0x71 };  /* 0x4E71 = NOP */
 static const Uint8 pMouseOpcode[] = { 0xD3, 0xC1 };  /* "ADDA.L D1,A1" (instead of "ADDA.W D1,A1") */
 static const Uint8 pRomCheckOpcode206[] = { 0x60, 0x00, 0x00, 0x98 };  /* BRA $e00894 */
+static const Uint8 pRomCheckOpcode207[] = { 0x60, 0x00, 0x00, 0x98 };  /* BRA $e00892 */
 static const Uint8 pRomCheckOpcode306[] = { 0x60, 0x00, 0x00, 0xB0 };  /* BRA $e00886 */
 static const Uint8 pRomCheckOpcode404[] = { 0x60, 0x00, 0x00, 0x94 };  /* BRA $e00746 */
 static const Uint8 pBraOpcode[] = { 0x60 };  /* 0x60XX = BRA */
@@ -236,6 +237,9 @@
   { 0x206, -1, pszAtariLogo, TP_VDIRES, 0xE0076C, 0x1038044c, sizeof( pAtariLogo ), pAtariLogo },
 
   { 0x207, -1, pszNoSparrowHw, TP_ALWAYS, 0xE02D90, 0x08F80005, 6, pNopOpcodes },  /* BSET #5,$ffff8e0d.w */
+  { 0x207, -1, pszRomCheck, TP_ALWAYS, 0xE007F8, 0x2E3C0001, 4, pRomCheckOpcode207 },
+  { 0x207, -1, pszDmaBoot, TP_HDIMAGE_OFF, 0xE008DC, 0x610000E0, 4, pNopOpcodes }, /* BSR.W $E009BE */
+  { 0x207, -1, pszAtariLogo, TP_VDIRES, 0xE0076A, 0x1038044c, sizeof( pAtariLogo ), pAtariLogo },
 
   { 0x208, -1, pszDmaBoot, TP_HDIMAGE_OFF, 0xE00806, 0x610000E8, 4, pNopOpcodes }, /* BSR.W $E008F0 */
   { 0x208, -1, pszAtariLogo, TP_VDIRES, 0xE006B4, 0x1038044c, sizeof( pAtariLogo ), pAtariLogo },


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/