]> git.sesse.net Git - pistorm/commitdiff
Fix silly RTC and emulator.c mistakes
authorbeeanyew <beeanyew@gmail.com>
Fri, 1 Jan 2021 10:59:35 +0000 (11:59 +0100)
committerbeeanyew <beeanyew@gmail.com>
Fri, 1 Jan 2021 10:59:35 +0000 (11:59 +0100)
emulator.c
platforms/shared/rtc.c

index d2d3eabfd5e6f65568c021ac572c6accc0250718..a8985412fcaa20f16d0956c0f55d7a2a22e6de0f 100644 (file)
@@ -566,7 +566,7 @@ void m68k_write_memory_8(unsigned int address, unsigned int value) {
   PLATFORM_CHECK_WRITE(OP_TYPE_BYTE);
 
   if (address == 0xbfe001) {
-    if (ovl != (value & (1 << 0)) {
+    if (ovl != (value & (1 << 0))) {
       ovl = (value & (1 << 0));
       printf("OVL:%x\n", ovl);
     }
index 8b3772caa59f18feddbfac98503aafa02ed10435..dd5edad5c4774f73baf6933ec1d4a31b8b717fdc 100644 (file)
@@ -49,20 +49,21 @@ void put_rtc_byte(uint32_t address_, uint8_t value, uint8_t rtc_type) {
           break;
         case 0x03:
         case 0x06:
-          ricoh_alarm[address] = (value & (0x08 & 0xFF));
+          ricoh_alarm[address] &= (value & (0x08 ^ 0xFF));
           break;
         case 0x05:
         case 0x08:
         case 0x0B:
-          ricoh_alarm[address] = (value & (0x0C & 0xFF));
+          ricoh_alarm[address] = (value & (0x0C ^ 0xFF));
           break;
         case 0x0A:
-          ricoh_alarm[address] = (value & (0x0E & 0xFF));
+          ricoh_alarm[address] = (value & (0x0E ^ 0xFF));
           break;
         default:
           ricoh_alarm[address] = value;
           break;
       }
+      //printf("Write to Ricoh alarm @%.2X: %.2X -> %.2X\n", address, value, ricoh_alarm[address]);
       return;
     }
     else if (address >= 0x0D) {
@@ -105,7 +106,7 @@ uint8_t get_rtc_byte(uint32_t address_, uint8_t rtc_type) {
     case 0x05: // Hours high?
       if (rtc_type == RTC_TYPE_MSM) {
         if (rtc_mystery_reg[2] & 4) {
-          return ((rtc_time->tm_hour / 10) | (rtc_time->tm_hour >= 12) ? 0x04 : 0x00);
+          return (((rtc_time->tm_hour % 12) / 10) | (rtc_time->tm_hour >= 12) ? 0x04 : 0x00);
         }
         else
           return rtc_time->tm_hour / 10;
@@ -115,7 +116,7 @@ uint8_t get_rtc_byte(uint32_t address_, uint8_t rtc_type) {
           return rtc_time->tm_hour / 10;
         }
         else {
-          return ((rtc_time->tm_hour / 10) | (rtc_time->tm_hour >= 12) ? 0x02 : 0x00);
+          return (((rtc_time->tm_hour % 12) / 10) | (rtc_time->tm_hour >= 12) ? 0x02 : 0x00);
         }
         break;
       }