Re: [hatari-devel] Timestamp problem with GEMDOS drive

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




On 03/26/2017 12:43 PM, Thorsten Otto wrote:
On Sunday 26 March 2017 11:27:02 Uwe Seimet wrote:
Thank you for addressing this, but I'm afraid it does not work, at least
not as I expected it to work. I may be missing something.

I think for this to work as expected, it is neccesary to also catch
Tgetdate()/Tgettime and report the host time there.

Attached is preliminary/untested patch for doing something like
that with "--gemdos-time atari" (which should only be needed with
ST/STE which don't have RTC).

However, few of the programs I tried, didn't actually call
those GEMDOS functions.

Uwe, where your program actually gets the wrong date/time from?


Maybe also for the Xbios
function Gettime(), and when accessing the hardware clock registers. The patch
now just leaves the creation time of files alone, but if that does not match
the current GEMDOS time, tools like make simply can't work.

If it requires changing something else than GEMDOS functionality,
it's not appropriate as a GEMDOS option.

Then one is better off using machine configuration with RTC
(i.e. anything else than ST/STE).


	- Eero
diff -r c5be68d38664 src/gemdos.c
--- a/src/gemdos.c	Fri Jan 26 22:20:59 2018 +0200
+++ b/src/gemdos.c	Fri Jan 26 23:59:54 2018 +0200
@@ -177,7 +177,8 @@
 
 	if (x == NULL)
 	{
-		Log_Printf(LOG_WARN, "WARNING: '%s' timestamp is invalid for (Windows?) localtime(), defaulting to TOS epoch!",  fname);
+		if (fname)
+			Log_Printf(LOG_WARN, "WARNING: '%s' timestamp is invalid for (Windows?) localtime(), defaulting to TOS epoch!",  fname);
 		DateTime->dateword = 1|(1<<5);	/* 1980-01-01 */
 		DateTime->timeword = 0;
 		return;
@@ -3007,6 +3008,64 @@
 }
 
 
+/*-----------------------------------------------------------------------*/
+
+typedef enum {
+	TOS_DATE,
+	TOS_TIME
+} datetime_type_t;
+
+/**
+ * Helper for GetDate & GetTime
+ *
+ * Returns date or time in TOS format as requested
+ */
+static Uint32 get_datetime(datetime_type_t t)
+{
+	DATETIME DateTime;
+	Uint32 ret, val;
+
+	GemDOS_DateTime2Tos(time(NULL), &DateTime, NULL);
+
+	if (t == TOS_DATE)
+		val = DateTime.dateword;
+	else
+		val = DateTime.timeword;
+	do_put_mem_long(&ret, val);
+	return ret;
+}
+
+/**
+ * GEMDOS GetDate
+ * Call 0x2a
+ */
+static bool GemDOS_GetDate(Uint32 Params)
+{
+	LOG_TRACE(TRACE_OS_GEMDOS, "GEMDOS 0x2A Tgetdate() at PC 0x%X\n", M68000_GetPC());
+	if (ConfigureParams.HardDisk.bGemdosHostTime)
+	{
+		Regs[REG_D0] = get_datetime(TOS_DATE);
+		return true;
+	}
+	return false;
+}
+
+/**
+ * GEMDOS GetTime
+ * Call 0x2c
+ */
+static bool GemDOS_GetTime(Uint32 Params)
+{
+	LOG_TRACE(TRACE_OS_GEMDOS, "GEMDOS 0x2C Tgettime() at PC 0x%X\n", M68000_GetPC());
+	if (ConfigureParams.HardDisk.bGemdosHostTime)
+	{
+		Regs[REG_D0] = get_datetime(TOS_TIME);
+		return true;
+	}
+	return false;
+}
+
+
 #if ENABLE_TRACING
 /*-----------------------------------------------------------------------*/
 /**
@@ -3308,6 +3367,12 @@
 	 case 0x0e:
 		Finished = GemDOS_SetDrv(Params);
 		break;
+	case 0x2a:
+		Finished = GemDOS_GetDate(Params);
+		break;
+	case 0x2c:
+		Finished = GemDOS_GetTime(Params);
+		break;
 	 case 0x31:
 		Finished = GemDOS_Ptermres(Params);
 		break;
@@ -3387,8 +3452,6 @@
 	case 0x19:	/* Dgetdrv */
 	case 0x2F:	/* Fgetdta */
 	case 0x30:	/* Sversion */
-	case 0x2A:	/* Tgetdate */
-	case 0x2C:	/* Tgettime */
 		/* commands with no args */
 		LOG_TRACE(TRACE_OS_GEMDOS, "GEMDOS 0x%02hX %s() at PC 0x%X\n",
 			  GemDOSCall, GemDOS_Opcode2Name(GemDOSCall),


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