mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 18:23:57 -06:00
next-cube: separate rtc read and write shift logic
Introduce a new next_rtc_cmd_is_write() function to determine if an rtc command is a read or write, and start by using it to avoid shifting the rtc input value if a rtc read command is executed. Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Reviewed-by: Thomas Huth <huth@tuxfamily.org> Message-ID: <20241222130012.1013374-21-mark.cave-ayland@ilande.co.uk> Signed-off-by: Thomas Huth <huth@tuxfamily.org>
This commit is contained in:
parent
825ac12564
commit
b37da8b95f
1 changed files with 76 additions and 66 deletions
|
@ -165,6 +165,12 @@ static void next_scr2_led_update(NeXTPC *s)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool next_rtc_cmd_is_write(uint8_t cmd)
|
||||||
|
{
|
||||||
|
return (cmd >= 0x80 && cmd <= 0x9f) ||
|
||||||
|
(cmd == 0xb1);
|
||||||
|
}
|
||||||
|
|
||||||
static void next_scr2_rtc_update(NeXTPC *s)
|
static void next_scr2_rtc_update(NeXTPC *s)
|
||||||
{
|
{
|
||||||
uint8_t old_scr2, scr2_2;
|
uint8_t old_scr2, scr2_2;
|
||||||
|
@ -186,13 +192,18 @@ static void next_scr2_rtc_update(NeXTPC *s)
|
||||||
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
||||||
}
|
}
|
||||||
if (rtc->phase >= 8 && rtc->phase < 16) {
|
if (rtc->phase >= 8 && rtc->phase < 16) {
|
||||||
|
if (next_rtc_cmd_is_write(rtc->command)) {
|
||||||
|
/* Shift in value to write */
|
||||||
rtc->value = (rtc->value << 1) |
|
rtc->value = (rtc->value << 1) |
|
||||||
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
||||||
|
} else {
|
||||||
|
/* Shift out value to read */
|
||||||
|
|
||||||
/* if we read RAM register, output RT_DATA bit */
|
/* if we read RAM register, output RT_DATA bit */
|
||||||
if (rtc->command <= 0x1F) {
|
if (rtc->command <= 0x1F) {
|
||||||
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
scr2_2 = scr2_2 & (~SCR2_RTDATA);
|
||||||
if (rtc->ram[rtc->command] & (0x80 >> (rtc->phase - 8))) {
|
if (rtc->ram[rtc->command] &
|
||||||
|
(0x80 >> (rtc->phase - 8))) {
|
||||||
scr2_2 |= SCR2_RTDATA;
|
scr2_2 |= SCR2_RTDATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,7 +257,6 @@ static void next_scr2_rtc_update(NeXTPC *s)
|
||||||
case 0x26:
|
case 0x26:
|
||||||
ret = SCR2_TOBCD((info->tm_year - 100));
|
ret = SCR2_TOBCD((info->tm_year - 100));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret & (0x80 >> (rtc->phase - 8))) {
|
if (ret & (0x80 >> (rtc->phase - 8))) {
|
||||||
|
@ -255,7 +265,7 @@ static void next_scr2_rtc_update(NeXTPC *s)
|
||||||
rtc->retval = (rtc->retval << 1) |
|
rtc->retval = (rtc->retval << 1) |
|
||||||
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
((scr2_2 & SCR2_RTDATA) ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
rtc->phase++;
|
rtc->phase++;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue