]> git.sesse.net Git - pistorm/commitdiff
Certified Musashi speed hax
authorbeeanyew <beeanyew@gmail.com>
Thu, 18 Feb 2021 04:29:59 +0000 (05:29 +0100)
committerbeeanyew <beeanyew@gmail.com>
Thu, 18 Feb 2021 04:29:59 +0000 (05:29 +0100)
Probably requires a make clean due to things being in header files.

m68k.h
m68kconf.h
m68kcpu.c
m68kcpu.h
platforms/amiga/piscsi/device_driver_amiga/build.bat [deleted file]

diff --git a/m68k.h b/m68k.h
index eb360b7606a43224cc6ecf196c91dc337e7c595e..3c6ee81fd5205b8ed50ebdb7fc94f3323e5fe595 100644 (file)
--- a/m68k.h
+++ b/m68k.h
@@ -216,8 +216,6 @@ void m68k_add_rom_range(uint32_t addr, uint32_t upper, unsigned char *ptr);
  */
 void m68k_write_memory_32_pd(unsigned int address, unsigned int value);
 
-
-
 /* ======================================================================== */
 /* ============================== CALLBACKS =============================== */
 /* ======================================================================== */
index 26ee063e9b08821558e7b05097e7bee07f1d11f4..bcfcb1353a3e90a7a2eb82425ac5d105194f0eeb 100644 (file)
@@ -75,7 +75,7 @@
  * and m68k_read_pcrelative_xx() for PC-relative addressing.
  * If off, all read requests from the CPU will be redirected to m68k_read_xx()
  */
-#define M68K_SEPARATE_READS         OPT_OFF
+#define M68K_SEPARATE_READS         OPT_ON
 
 /* If ON, the CPU will call m68k_write_32_pd() when it executes move.l with a
  * predecrement destination EA mode instead of m68k_write_32().
 
 
 /* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */
-#define M68K_EMULATE_PREFETCH       OPT_ON
+#define M68K_EMULATE_PREFETCH       OPT_OFF
 
 
 /* If ON, the CPU will generate address error exceptions if it tries to
index 0c036925369ba301f91f9c0c6325fbb6f255fb50..ecdf4dd7075aaed3d2632f792d9e9855148946da 100644 (file)
--- a/m68kcpu.c
+++ b/m68kcpu.c
@@ -969,7 +969,9 @@ int m68k_execute(int num_cycles)
                /* Return point if we had an address error */
                m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */
 
+#ifdef M68K_BUSERR_THING
                m68ki_check_bus_error_trap();
+#endif
 
                /* Main loop.  Keep going until we run out of clock cycles */
                do
@@ -1171,6 +1173,43 @@ void m68k_set_context(void* src)
        if(src) m68ki_cpu = *(m68ki_cpu_core*)src;
 }
 
+/* Read data immediately following the PC */
+inline unsigned int  m68k_read_immediate_16(unsigned int address) {
+       return m68k_read_memory_16(address);
+}
+inline unsigned int  m68k_read_immediate_32(unsigned int address) {
+       return m68k_read_memory_32(address);
+}
+
+/* Read data relative to the PC */
+inline unsigned int  m68k_read_pcrelative_8(unsigned int address) {
+       for (int i = 0; i < read_ranges; i++) {
+               if(address >= read_addr[i] && address < read_upper[i]) {
+                       return read_data[i][address - read_addr[i]];
+               }
+       }
+       
+       return m68k_read_memory_8(address);
+}
+inline unsigned int  m68k_read_pcrelative_16(unsigned int address) {
+       for (int i = 0; i < read_ranges; i++) {
+               if(address >= read_addr[i] && address < read_upper[i]) {
+                       return be16toh(((unsigned short *)(read_data[i] + (address - read_addr[i])))[0]);
+               }
+       }
+
+       return m68k_read_memory_16(address);
+}
+inline unsigned int  m68k_read_pcrelative_32(unsigned int address) {
+       for (int i = 0; i < read_ranges; i++) {
+               if(address >= read_addr[i] && address < read_upper[i]) {
+                       return be32toh(((unsigned int *)(read_data[i] + (address - read_addr[i])))[0]);
+               }
+       }
+
+    return m68k_read_memory_32(address);
+}
+
 void m68k_add_ram_range(uint32_t addr, uint32_t upper, unsigned char *ptr)
 {
        if ((addr == 0 && upper == 0) || upper < addr)
index a6bea82c231a4acc6e085336420f2ac7c09aa435..e1035c121c0ae0820d8fb20dc1a22f079045e3ac 100644 (file)
--- a/m68kcpu.h
+++ b/m68kcpu.h
@@ -1035,6 +1035,15 @@ char* m68ki_disassemble_quick(unsigned int pc, unsigned int cpu_type);
 
 /* ---------------------------- Read Immediate ---------------------------- */
 
+extern unsigned char read_ranges;
+extern unsigned int read_addr[8];
+extern unsigned int read_upper[8];
+extern unsigned char *read_data[8];
+extern unsigned char write_ranges;
+extern unsigned int write_addr[8];
+extern unsigned int write_upper[8];
+extern unsigned char *write_data[8];
+
 extern uint pmmu_translate_addr(uint addr_in);
 
 /* Handles all immediate reads, does address error check, function code setting,
@@ -1046,10 +1055,10 @@ static inline uint m68ki_read_imm_16(void)
        m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
 
 #if M68K_SEPARATE_READS
-#if M68K_EMULATE_PMMU
+/*#if M68K_EMULATE_PMMU
        if (PMMU_ENABLED)
-           address = pmmu_translate_addr(address);
-#endif
+           address = pmmu_translate_addr(ADDRESS_68K(CPU_PREF_ADDR));
+#endif*/
 #endif
 
 #if M68K_EMULATE_PREFETCH
@@ -1067,7 +1076,16 @@ static inline uint m68ki_read_imm_16(void)
        return result;
 }
 #else
+
+       uint32_t address = ADDRESS_68K(REG_PC);
        REG_PC += 2;
+
+       for (int i = 0; i < read_ranges; i++) {
+               if(address >= read_addr[i] && address < read_upper[i]) {
+                       return be16toh(((unsigned short *)(read_data[i] + (address - read_addr[i])))[0]);
+               }
+       }
+
        return m68k_read_immediate_16(ADDRESS_68K(REG_PC-2));
 #endif /* M68K_EMULATE_PREFETCH */
 }
@@ -1081,14 +1099,15 @@ static inline uint m68ki_read_imm_8(void)
 static inline uint m68ki_read_imm_32(void)
 {
 #if M68K_SEPARATE_READS
-#if M68K_EMULATE_PMMU
+/*#if M68K_EMULATE_PMMU
        if (PMMU_ENABLED)
-           address = pmmu_translate_addr(address);
-#endif
+           address = pmmu_translate_addr(ADDRESS_68K(CPU_PREF_ADDR));
+#endif*/
 #endif
 
 #if M68K_EMULATE_PREFETCH
        uint temp_val;
+       uint32_t address = ADDRESS_68K(CPU_PREF_ADDR);
 
        m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
        m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
@@ -1096,6 +1115,7 @@ static inline uint m68ki_read_imm_32(void)
        if(REG_PC != CPU_PREF_ADDR)
        {
                CPU_PREF_ADDR = REG_PC;
+
                CPU_PREF_DATA = m68k_read_immediate_16(ADDRESS_68K(CPU_PREF_ADDR));
        }
        temp_val = MASK_OUT_ABOVE_16(CPU_PREF_DATA);
@@ -1112,7 +1132,14 @@ static inline uint m68ki_read_imm_32(void)
 #else
        m68ki_set_fc(FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
        m68ki_check_address_error(REG_PC, MODE_READ, FLAG_S | FUNCTION_CODE_USER_PROGRAM); /* auto-disable (see m68kcpu.h) */
+       uint32_t address = ADDRESS_68K(REG_PC);
        REG_PC += 4;
+       for (int i = 0; i < read_ranges; i++) {
+               if(address >= read_addr[i] && address < read_upper[i]) {
+                       return be32toh(((unsigned int *)(read_data[i] + (address - read_addr[i])))[0]);
+               }
+       }
+
        return m68k_read_immediate_32(ADDRESS_68K(REG_PC-4));
 #endif /* M68K_EMULATE_PREFETCH */
 }
@@ -1126,15 +1153,6 @@ static inline uint m68ki_read_imm_32(void)
  * code if they are enabled in m68kconf.h.
  */
 
-extern unsigned char read_ranges;
-extern unsigned int read_addr[8];
-extern unsigned int read_upper[8];
-extern unsigned char *read_data[8];
-extern unsigned char write_ranges;
-extern unsigned int write_addr[8];
-extern unsigned int write_upper[8];
-extern unsigned char *write_data[8];
-
 static inline uint m68ki_read_8_fc(uint address, uint fc)
 {
        (void)fc;
diff --git a/platforms/amiga/piscsi/device_driver_amiga/build.bat b/platforms/amiga/piscsi/device_driver_amiga/build.bat
deleted file mode 100644 (file)
index 7e20377..0000000
+++ /dev/null
@@ -1 +0,0 @@
-vc +aos68k -nostdlib -I$VBCC/targets/m68k-amigaos/include2 -c99 -O2 -o pi-scsi.device piscsi-amiga.c -ldebug -lamiga -cpu=68020