diff options
author | 2008-09-04 09:07:03 +0000 | |
---|---|---|
committer | 2008-09-04 09:07:03 +0000 | |
commit | a50feca332b53ffb9f71bdf4a8743d63c4a3fa5d (patch) | |
tree | 9a55ea62a90d4482384a420227958f74a3413e0a /src | |
parent | 503786f7d7a74906cde5cfdded417ab04f515a57 (diff) |
From: Barry Rodewald [mailto:bsr@xnet.co.nz]
Subject: Update to MC146818 RTC
Hi,
Here's a small patch to the MC146818 code, which gives a basic
implementation of the "update ended" interrupt flag.
The code is based on the behaviour of the Aleste 520EX (Russian Amstrad
CPC clone) BIOS, which periodically (about 7 or 8 times a second) checks
the flag to see if the date and time display on the BIOS setup screen
needs to be updated. Without the flag implemented, the date and time
are static on the setup screen, or if the time hasn't been initialised
(blank NVRAM) it is blank.
The BIOS function that does this basically checks bit 4 of register
0x0c, and if 0, ends there, otherwise it will read register 0x0b, sets
bit 7 of the result and writes it back to register 0x0b (presumably,
this resets the interrupt flags). Then it continues on to the display
refresh function.
(Disassembly attached)
Diffstat (limited to 'src')
-rw-r--r-- | src/emu/machine/mc146818.c | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/emu/machine/mc146818.c b/src/emu/machine/mc146818.c index b5682e9323d..6f29c1a05e2 100644 --- a/src/emu/machine/mc146818.c +++ b/src/emu/machine/mc146818.c @@ -90,6 +90,8 @@ struct mc146818_chip UINT16 eindex; UINT8 edata[0x2000]; + int updated; /* update ended interrupt flag */ + attotime last_refresh; }; @@ -189,7 +191,7 @@ static TIMER_CALLBACK( mc146818_timer ) } } } - + mc146818->updated = 1; /* clock has been updated */ mc146818->last_refresh = timer_get_time(); } @@ -324,6 +326,12 @@ READ8_HANDLER(mc146818_port_r) #endif break; + case 0xc: + if(mc146818->updated != 0) /* the clock has been updated */ + data = 0x10; + else + data = 0x00; + break; case 0xd: /* battery ok */ data = mc146818->data[mc146818->index % MC146818_DATA_SIZE] | 0x80; @@ -354,7 +362,16 @@ WRITE8_HANDLER(mc146818_port_w) break; case 1: - mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data; + switch(mc146818->index % MC146818_DATA_SIZE) + { + case 0x0b: + if(data & 0x80) + mc146818->updated = 0; + mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data; + break; + default: + mc146818->data[mc146818->index % MC146818_DATA_SIZE] = data; + } break; } } |