shithub: psxe

Download patch

ref: 2dc7215b163e03f426a1b01172f711283b371ade
parent: c9a8620e9e0dbba505b609a2027e51ce6f320a15
author: allkern <lisandroaalarcon@gmail.com>
date: Mon Jul 31 18:21:10 EDT 2023

Change `btoi` to table

--- a/psx/dev/cdrom.c
+++ b/psx/dev/cdrom.c
@@ -23,6 +23,9 @@
     return ((b >> 4) * 10) + (b & 0xf);
 }
 
+// #define BTOI(b) cdrom_btoi(b)
+#define BTOI(b) g_psx_cdrom_btoi_table[b]
+
 static const uint8_t g_psx_cdrom_btoi_table[] = {
     0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
     0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
@@ -123,9 +126,9 @@
             cdrom->delayed_command = CDL_SETLOC;
             cdrom->state = CD_STATE_SEND_RESP1;
 
-            cdrom->seek_sect = cdrom_btoi(PFIFO_POP);
-            cdrom->seek_ss = cdrom_btoi(PFIFO_POP);
-            cdrom->seek_mm = cdrom_btoi(PFIFO_POP);
+            cdrom->seek_sect = BTOI(PFIFO_POP);
+            cdrom->seek_ss = BTOI(PFIFO_POP);
+            cdrom->seek_mm = BTOI(PFIFO_POP);
 
             // Account for 2 second gap
             uint32_t seconds = (cdrom->seek_mm * 60) + cdrom->seek_ss - 2;
--