--- z80pack-1.14/cpmsim/srcsim/iosim.c 2007-10-06 18:26:57.000000000 +0200 +++ z80pack-1.15/cpmsim/srcsim/iosim.c 2007-11-03 14:46:15.000000000 +0100 @@ -23,6 +23,8 @@ * 25-DEC-06 CPU speed option and 100 ticks interrupt * 19-FEB-07 improved networking * 22-JUL-07 added second FDC sector port for implementing large harddisks + * 30-OCT-07 printer port returns EOF on input + * 03-SEP-07 improved the clock chip for support of other OS's */ /* @@ -113,6 +115,7 @@ static BYTE dmadl; /* current DMA address destination low */ static BYTE dmadh; /* current DMA address destination high */ static BYTE clkcmd; /* clock command */ +static BYTE clkfmt; /* clock format, 0 = BCD, 1 = decimal */ static BYTE timer; /* 10ms timer */ static int drivea; /* fd for file "drivea.cpm" */ static int driveb; /* fd for file "driveb.cpm" */ @@ -1201,11 +1204,11 @@ /* * I/O handler for read printer data: - * always read a 0 from the printer + * always read a EOF from the printer */ static BYTE prtd_in(void) { - return((BYTE) 0); + return((BYTE) 0x1a); /* CP/M EOF */ } /* @@ -1577,22 +1580,28 @@ /* * I/O handler for write clock command: * set the wanted clock command + * toggle BCD/decimal format if toggle command (255) */ static BYTE clkc_out(BYTE data) { clkcmd = data; + if (data == 255) + clkfmt = clkfmt ^ 1; return((BYTE) 0); } /* * I/O handler for read clock data: - * dependent from the last clock command the following + * dependent on the last clock command the following * informations are returned from the system clock: - * 0 - seconds in BCD - * 1 - minutes in BCD - * 2 - hours in BCD + * 0 - seconds in BCD or decimal + * 1 - minutes in BCD or decimal + * 2 - hours in BCD or decimal * 3 - low byte number of days since 1.1.1978 * 4 - high byte number of days since 1.1.1978 + * 5 - day of month in BCD or decimal + * 6 - month in BCD or decimal + * 7 - year in BCD or decomal * for every other clock command a 0 is returned */ static BYTE clkd_in(void) @@ -1604,14 +1613,23 @@ time(&Time); t = localtime(&Time); switch(clkcmd) { - case 0: /* seconds in BCD */ - val = to_bcd(t->tm_sec); + case 0: /* seconds */ + if (clkfmt) + val = t->tm_sec; + else + val = to_bcd(t->tm_sec); break; - case 1: /* minutes in BCD */ - val = to_bcd(t->tm_min); + case 1: /* minutes */ + if (clkfmt) + val = t->tm_min; + else + val = to_bcd(t->tm_min); break; - case 2: /* hours in BCD */ - val = to_bcd(t->tm_hour); + case 2: /* hours */ + if (clkfmt) + val = t->tm_hour; + else + val = to_bcd(t->tm_hour); break; case 3: /* low byte days */ val = get_date(t) & 255; @@ -1619,6 +1637,24 @@ case 4: /* high byte days */ val = get_date(t) >> 8; break; + case 5: /* day of month */ + if (clkfmt) + val = t->tm_mday; + else + val = to_bcd(t->tm_mday); + break; + case 6: /* month */ + if (clkfmt) + val = t->tm_mon; + else + val = to_bcd(t->tm_mon); + break; + case 7: /* year */ + if (clkfmt) + val = t->tm_year; + else + val = to_bcd(t->tm_year); + break; default: val = 0; break;