Browse Source

Update NEO.emu 68K CPU core and add ARM64 builds

* Separate MD.emu specific bits from Musashi 68K emulator and port it to NEO.emu
* Use signed cycle count in Musashi
* Add 64-bit ARM Android & iOS builds
* Clean up frame skip checks
* Add Neo Turf Masters to timer interrupt game list
master
Robert Broglia 1 month ago
parent
commit
b02da4e556

MD.emu/src/genplus-gx/m68k/musashi/InstructionCycleTable.hh → MD.emu/src/InstructionCycleTable.hh View File


MD.emu/src/genplus-gx/m68k/musashi/InstructionCycleTableSCD.hh → MD.emu/src/InstructionCycleTableSCD.hh View File


+ 1
- 1
MD.emu/src/genplus-gx/genesis.cc View File

@@ -22,7 +22,7 @@
****************************************************************************************/
#include "shared.h"
#include <genplus-gx/m68k/musashi/InstructionCycleTable.hh>
#include "InstructionCycleTable.hh"
uint8 tmss[4]; /* TMSS security register */
uint8 bios_rom[0x800]; /* OS ROM */

+ 23
- 32
MD.emu/src/genplus-gx/m68k/musashi/m68k.h View File

@@ -29,7 +29,6 @@
/* ======================================================================== */
/* Import the configuration for this build */
#include <genplus-config.h>
#include <assert.h>
#include <imagine/logger/logger.h>
#include <stdlib.h>
@@ -199,16 +198,16 @@ typedef union
struct M68KCPU
{
constexpr M68KCPU(const unsigned char (&cycles)[0x10000], bool hasWorkingTas):
cycles(cycles), hasWorkingTas(hasWorkingTas) { }
cycles(cycles), hasWorkingTas(hasWorkingTas) {}
static const uint cpu_type = 1; /* CPU Type: 68000, 68008, 68010, 68EC020, or 68020 */
const unsigned char (&cycles)[0x10000];
uint dar[16] = {0}; /* Data and Address Registers */
uint dar[16]{}; /* Data and Address Registers */
#ifdef M68K_USE_PPC
uint ppc = 0; /* Previous program counter */
#endif
uint pc = 0; /* Program Counter */
uint sp[7] = {0}; /* User, Interrupt, and Master Stack Pointers */
uint sp[7]{}; /* User, Interrupt, and Master Stack Pointers */
uint ir = 0; /* Instruction Register */
#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040
uint vbr = 0; /* Vector Base Register (m68010+) */
@@ -216,7 +215,7 @@ struct M68KCPU
uint dfc = 0; /* Destination Function Code Register (m68010+) */
uint cacr = 0; /* Cache Control Register (m68020, unemulated) */
uint caar = 0; /* Cache Address Register (m68020, unemulated) */
fp_reg fpr[8] = {0}; /* FPU Data Register (m68040) */
fp_reg fpr[8]{}; /* FPU Data Register (m68040) */
uint fpiar = 0; /* FPU Instruction Address Register (m68040) */
uint fpsr = 0; /* FPU Status Register (m68040) */
uint fpcr = 0; /* FPU Control Register (m68040) */
@@ -250,15 +249,15 @@ struct M68KCPU
const bool hasWorkingTas;
/* Clocks required for instructions / exceptions */
static const uint cyc_bcc_notake_b = -2 * 7;
static const uint cyc_bcc_notake_w = 2 * 7;
static const uint cyc_dbcc_f_noexp = -2 * 7;
static const uint cyc_dbcc_f_exp = 2 * 7;
static const uint cyc_scc_r_true = 2 * 7;
static const uint cyc_movem_w = 4 * 7;
static const uint cyc_movem_l = 8 * 7;
static const uint cyc_shift = 2 * 7;
static const uint cyc_reset = 132 * 7;
static const uint cyc_bcc_notake_b = -2 * M68K_CYCLE_SCALER;
static const uint cyc_bcc_notake_w = 2 * M68K_CYCLE_SCALER;
static const uint cyc_dbcc_f_noexp = -2 * M68K_CYCLE_SCALER;
static const uint cyc_dbcc_f_exp = 2 * M68K_CYCLE_SCALER;
static const uint cyc_scc_r_true = 2 * M68K_CYCLE_SCALER;
static const uint cyc_movem_w = 4 * M68K_CYCLE_SCALER;
static const uint cyc_movem_l = 8 * M68K_CYCLE_SCALER;
static const uint cyc_shift = 2 * M68K_CYCLE_SCALER;
static const uint cyc_reset = 132 * M68K_CYCLE_SCALER;
/*static const uint8* cyc_instruction = m68ki_cycles;
static const uint16* cyc_exception = m68ki_exception_cycle_table;*/
@@ -282,8 +281,8 @@ struct M68KCPU
#endif
int irqLatency = 0;
uint32 cycleCount = 0;
uint32 endCycles = 0;
int32 cycleCount = 0;
int32 endCycles = 0;
_m68k_memory_map memory_map[256]{};
/* Set the IPL0-IPL2 pins on the CPU (IRQ).
@@ -313,8 +312,6 @@ struct M68KCPU
#endif
};
extern M68KCPU mm68k;
void m68k_read_immediate_16_hook(M68KCPU &cpu, uint address);
void m68k_read_immediate_32_hook(M68KCPU &cpu, uint address);
void m68k_read_pcrelative_8_hook(M68KCPU &cpu, uint address);
@@ -325,12 +322,11 @@ static inline uint16 m68k_read_immediate_16(M68KCPU &cpu, uint address)
if(cpu.callMemHooks)
m68k_read_immediate_16_hook(cpu, address);
uint mapIdx = ((address)>>16)&0xff;
/*#ifndef NDEBUG
_m68k_memory_map *temp = &cpu.memory_map[mapIdx];
if (temp->read16) return (*temp->read16)(address & cpu.address_mask);
const _m68k_memory_map *temp = &cpu.memory_map[mapIdx];
if(!M68K_DIRECT_IM_READS && temp->read16)
return (*temp->read16)(address & cpu.address_mask);
else
#endif*/
return *(uint16 *)(cpu.memory_map[mapIdx].base + ((address) & 0xffff));
return *(uint16 *)(cpu.memory_map[mapIdx].base + ((address) & 0xffff));
}
static inline uint32 m68k_read_immediate_32(M68KCPU &cpu, uint address)
@@ -346,11 +342,10 @@ static inline uint8 m68k_read_pcrelative_8(M68KCPU &cpu, uint address)
if(cpu.callMemHooks)
m68k_read_pcrelative_8_hook(cpu, address);
uint mapIdx = ((address)>>16)&0xff;
/*#ifndef NDEBUG
_m68k_memory_map *temp = &cpu.memory_map[mapIdx];
if (temp->read8) return (*temp->read8)(address & cpu.address_mask);
const _m68k_memory_map *temp = &cpu.memory_map[mapIdx];
if(!M68K_DIRECT_IM_READS && temp->read8)
return (*temp->read8)(address & cpu.address_mask);
else
#endif*/
return READ_BYTE(cpu.memory_map[mapIdx].base, (address) & 0xffff);
}
@@ -480,7 +475,7 @@ void m68k_pulse_reset(M68KCPU &m68ki_cpu);
//int m68k_execute(int num_cycles);
/* run until global cycle count is reached */
void m68k_run(M68KCPU &m68ki_cpu, unsigned int cycles) __attribute__((hot));
void m68k_run(M68KCPU &m68ki_cpu, int cycles) __attribute__((hot));
/* These functions let you read/write/modify the number of cycles left to run
* while m68k_execute() is running.
@@ -521,10 +516,6 @@ unsigned int m68k_disassemble(char* str_buff, unsigned int pc, unsigned int cpu_
*/
unsigned int m68k_disassemble_raw(char* str_buff, unsigned int pc, const unsigned char* opdata, const unsigned char* argdata, unsigned int cpu_type);
#ifdef NO_SCD
extern int vdp_68k_irq_ack(M68KCPU &m68ki_cpu, int int_level);
#endif
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */

+ 81
- 81
MD.emu/src/genplus-gx/m68k/musashi/m68kcpu.cc View File

@@ -131,77 +131,77 @@ const uint m68ki_shift_32_table[65] =
const uint16 m68ki_exception_cycle_table[256] =
{
/* 000 */
40 * 7, /* 0: Reset - Initial Stack Pointer */
4 * 7, /* 1: Reset - Initial Program Counter */
50 * 7, /* 2: Bus Error (unemulated) */
50 * 7, /* 3: Address Error (unemulated) */
34 * 7, /* 4: Illegal Instruction */
38 * 7, /* 5: Divide by Zero -- ASG: changed from 42 */
40 * 7, /* 6: CHK -- ASG: chanaged from 44 */
34 * 7, /* 7: TRAPV */
34 * 7, /* 8: Privilege Violation */
34 * 7, /* 9: Trace */
4 * 7, /* 10: 1010 */
4 * 7, /* 11: 1111 */
4 * 7, /* 12: RESERVED */
4 * 7, /* 13: Coprocessor Protocol Violation (unemulated) */
4 * 7, /* 14: Format Error */
44 * 7, /* 15: Uninitialized Interrupt */
4 * 7, /* 16: RESERVED */
4 * 7, /* 17: RESERVED */
4 * 7, /* 18: RESERVED */
4 * 7, /* 19: RESERVED */
4 * 7, /* 20: RESERVED */
4 * 7, /* 21: RESERVED */
4 * 7, /* 22: RESERVED */
4 * 7, /* 23: RESERVED */
44 * 7, /* 24: Spurious Interrupt */
44 * 7, /* 25: Level 1 Interrupt Autovector */
44 * 7, /* 26: Level 2 Interrupt Autovector */
44 * 7, /* 27: Level 3 Interrupt Autovector */
44 * 7, /* 28: Level 4 Interrupt Autovector */
44 * 7, /* 29: Level 5 Interrupt Autovector */
44 * 7, /* 30: Level 6 Interrupt Autovector */
44 * 7, /* 31: Level 7 Interrupt Autovector */
34 * 7, /* 32: TRAP #0 -- ASG: chanaged from 38 */
34 * 7, /* 33: TRAP #1 */
34 * 7, /* 34: TRAP #2 */
34 * 7, /* 35: TRAP #3 */
34 * 7, /* 36: TRAP #4 */
34 * 7, /* 37: TRAP #5 */
34 * 7, /* 38: TRAP #6 */
34 * 7, /* 39: TRAP #7 */
34 * 7, /* 40: TRAP #8 */
34 * 7, /* 41: TRAP #9 */
34 * 7, /* 42: TRAP #10 */
34 * 7, /* 43: TRAP #11 */
34 * 7, /* 44: TRAP #12 */
34 * 7, /* 45: TRAP #13 */
34 * 7, /* 46: TRAP #14 */
34 * 7, /* 47: TRAP #15 */
4 * 7, /* 48: FP Branch or Set on Unknown Condition (unemulated) */
4 * 7, /* 49: FP Inexact Result (unemulated) */
4 * 7, /* 50: FP Divide by Zero (unemulated) */
4 * 7, /* 51: FP Underflow (unemulated) */
4 * 7, /* 52: FP Operand Error (unemulated) */
4 * 7, /* 53: FP Overflow (unemulated) */
4 * 7, /* 54: FP Signaling NAN (unemulated) */
4 * 7, /* 55: FP Unimplemented Data Type (unemulated) */
4 * 7, /* 56: MMU Configuration Error (unemulated) */
4 * 7, /* 57: MMU Illegal Operation Error (unemulated) */
4 * 7, /* 58: MMU Access Level Violation Error (unemulated) */
4 * 7, /* 59: RESERVED */
4 * 7, /* 60: RESERVED */
4 * 7, /* 61: RESERVED */
4 * 7, /* 62: RESERVED */
4 * 7, /* 63: RESERVED */
40 * M68K_CYCLE_SCALER, /* 0: Reset - Initial Stack Pointer */
4 * M68K_CYCLE_SCALER, /* 1: Reset - Initial Program Counter */
50 * M68K_CYCLE_SCALER, /* 2: Bus Error (unemulated) */
50 * M68K_CYCLE_SCALER, /* 3: Address Error (unemulated) */
34 * M68K_CYCLE_SCALER, /* 4: Illegal Instruction */
38 * M68K_CYCLE_SCALER, /* 5: Divide by Zero -- ASG: changed from 42 */
40 * M68K_CYCLE_SCALER, /* 6: CHK -- ASG: chanaged from 44 */
34 * M68K_CYCLE_SCALER, /* 7: TRAPV */
34 * M68K_CYCLE_SCALER, /* 8: Privilege Violation */
34 * M68K_CYCLE_SCALER, /* 9: Trace */
4 * M68K_CYCLE_SCALER, /* 10: 1010 */
4 * M68K_CYCLE_SCALER, /* 11: 1111 */
4 * M68K_CYCLE_SCALER, /* 12: RESERVED */
4 * M68K_CYCLE_SCALER, /* 13: Coprocessor Protocol Violation (unemulated) */
4 * M68K_CYCLE_SCALER, /* 14: Format Error */
44 * M68K_CYCLE_SCALER, /* 15: Uninitialized Interrupt */
4 * M68K_CYCLE_SCALER, /* 16: RESERVED */
4 * M68K_CYCLE_SCALER, /* 17: RESERVED */
4 * M68K_CYCLE_SCALER, /* 18: RESERVED */
4 * M68K_CYCLE_SCALER, /* 19: RESERVED */
4 * M68K_CYCLE_SCALER, /* 20: RESERVED */
4 * M68K_CYCLE_SCALER, /* 21: RESERVED */
4 * M68K_CYCLE_SCALER, /* 22: RESERVED */
4 * M68K_CYCLE_SCALER, /* 23: RESERVED */
44 * M68K_CYCLE_SCALER, /* 24: Spurious Interrupt */
44 * M68K_CYCLE_SCALER, /* 25: Level 1 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 26: Level 2 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 27: Level 3 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 28: Level 4 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 29: Level 5 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 30: Level 6 Interrupt Autovector */
44 * M68K_CYCLE_SCALER, /* 31: Level 7 Interrupt Autovector */
34 * M68K_CYCLE_SCALER, /* 32: TRAP #0 -- ASG: chanaged from 38 */
34 * M68K_CYCLE_SCALER, /* 33: TRAP #1 */
34 * M68K_CYCLE_SCALER, /* 34: TRAP #2 */
34 * M68K_CYCLE_SCALER, /* 35: TRAP #3 */
34 * M68K_CYCLE_SCALER, /* 36: TRAP #4 */
34 * M68K_CYCLE_SCALER, /* 37: TRAP #5 */
34 * M68K_CYCLE_SCALER, /* 38: TRAP #6 */
34 * M68K_CYCLE_SCALER, /* 39: TRAP #7 */
34 * M68K_CYCLE_SCALER, /* 40: TRAP #8 */
34 * M68K_CYCLE_SCALER, /* 41: TRAP #9 */
34 * M68K_CYCLE_SCALER, /* 42: TRAP #10 */
34 * M68K_CYCLE_SCALER, /* 43: TRAP #11 */
34 * M68K_CYCLE_SCALER, /* 44: TRAP #12 */
34 * M68K_CYCLE_SCALER, /* 45: TRAP #13 */
34 * M68K_CYCLE_SCALER, /* 46: TRAP #14 */
34 * M68K_CYCLE_SCALER, /* 47: TRAP #15 */
4 * M68K_CYCLE_SCALER, /* 48: FP Branch or Set on Unknown Condition (unemulated) */
4 * M68K_CYCLE_SCALER, /* 49: FP Inexact Result (unemulated) */
4 * M68K_CYCLE_SCALER, /* 50: FP Divide by Zero (unemulated) */
4 * M68K_CYCLE_SCALER, /* 51: FP Underflow (unemulated) */
4 * M68K_CYCLE_SCALER, /* 52: FP Operand Error (unemulated) */
4 * M68K_CYCLE_SCALER, /* 53: FP Overflow (unemulated) */
4 * M68K_CYCLE_SCALER, /* 54: FP Signaling NAN (unemulated) */
4 * M68K_CYCLE_SCALER, /* 55: FP Unimplemented Data Type (unemulated) */
4 * M68K_CYCLE_SCALER, /* 56: MMU Configuration Error (unemulated) */
4 * M68K_CYCLE_SCALER, /* 57: MMU Illegal Operation Error (unemulated) */
4 * M68K_CYCLE_SCALER, /* 58: MMU Access Level Violation Error (unemulated) */
4 * M68K_CYCLE_SCALER, /* 59: RESERVED */
4 * M68K_CYCLE_SCALER, /* 60: RESERVED */
4 * M68K_CYCLE_SCALER, /* 61: RESERVED */
4 * M68K_CYCLE_SCALER, /* 62: RESERVED */
4 * M68K_CYCLE_SCALER, /* 63: RESERVED */
/* 64-255: User Defined */
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,4 * 7,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,4 * M68K_CYCLE_SCALER,
#if M68K_EMULATE_010 || M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040
@@ -719,15 +719,15 @@ void m68k_set_cpu_type(M68KCPU &m68ki_cpu, unsigned int cpu_type)
CPU_SR_MASK = 0xa71f; /* T1 -- S -- -- I2 I1 I0 -- -- -- X N Z V C */
/*CYC_INSTRUCTION = m68ki_cycles[0];
CYC_EXCEPTION = m68ki_exception_cycle_table[0];
CYC_BCC_NOTAKE_B = -2 * 7;
CYC_BCC_NOTAKE_W = 2 * 7;
CYC_DBCC_F_NOEXP = -2 * 7;
CYC_DBCC_F_EXP = 2 * 7;
CYC_SCC_R_TRUE = 2 * 7;
CYC_MOVEM_W = 4 * 7;
CYC_MOVEM_L = 8 * 7;
CYC_SHIFT = 2 * 7;
CYC_RESET = 132 * 7;*/
CYC_BCC_NOTAKE_B = -2 * M68K_CYCLE_SCALER;
CYC_BCC_NOTAKE_W = 2 * M68K_CYCLE_SCALER;
CYC_DBCC_F_NOEXP = -2 * M68K_CYCLE_SCALER;
CYC_DBCC_F_EXP = 2 * M68K_CYCLE_SCALER;
CYC_SCC_R_TRUE = 2 * M68K_CYCLE_SCALER;
CYC_MOVEM_W = 4 * M68K_CYCLE_SCALER;
CYC_MOVEM_L = 8 * M68K_CYCLE_SCALER;
CYC_SHIFT = 2 * M68K_CYCLE_SCALER;
CYC_RESET = 132 * M68K_CYCLE_SCALER;*/
return;
#if M68K_EMULATE_020 || M68K_EMULATE_EC020 || M68K_EMULATE_040
@@ -927,7 +927,7 @@ void M68KCPU::setIRQDelay(unsigned int mask)
m68ki_check_interrupts(*this); /* Level triggered (IRQ) */
}
void m68k_run(M68KCPU &m68ki_cpu, unsigned int cycles)
void m68k_run(M68KCPU &m68ki_cpu, int cycles)
{
/* Make sure we're not stopped */
if (CPU_STOPPED)
@@ -942,7 +942,7 @@ void m68k_run(M68KCPU &m68ki_cpu, unsigned int cycles)
/* Save end cycles count for when CPU is stopped */
m68ki_cpu.endCycles = cycles;
while (m68ki_cpu.cycleCount < cycles)//m68ki_cpu.endCycles)
while (m68ki_cpu.cycleCount < cycles)
{
/* Set tracing accodring to T1. */
m68ki_trace_t1() /* auto-disable (see m68kcpu.h) */

+ 12
- 12
MD.emu/src/genplus-gx/m68k/musashi/m68kcpu.h View File

@@ -1043,18 +1043,18 @@ SINLINE uint m68ki_read_imm_32(M68KCPU &m68ki_cpu)
* code if they are enabled in m68kconf.h.
*/
void m68ki_read_8_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map);
void m68ki_read_16_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map);
void m68ki_read_32_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map);
void m68ki_write_8_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value);
void m68ki_write_16_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value);
void m68ki_write_32_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value);
void m68ki_read_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map);
void m68ki_read_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map);
void m68ki_read_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map);
void m68ki_write_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value);
void m68ki_write_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value);
void m68ki_write_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value);
SINLINE uint m68ki_read_8_fc(M68KCPU &m68ki_cpu, uint address, uint fc)
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->read8) return (*temp->read8)(ADDRESS_68K(address));
else
{
@@ -1069,7 +1069,7 @@ SINLINE uint m68ki_read_16_fc(M68KCPU &m68ki_cpu, uint address, uint fc)
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->read16) return (*temp->read16)(ADDRESS_68K(address));
else
{
@@ -1084,7 +1084,7 @@ SINLINE uint m68ki_read_32_fc(M68KCPU &m68ki_cpu, uint address, uint fc)
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
m68ki_check_address_error_010_less(address, MODE_READ, fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->read16) return ((*temp->read16)(ADDRESS_68K(address)) << 16) | ((*temp->read16)(ADDRESS_68K(address + 2)));
else
{
@@ -1098,7 +1098,7 @@ SINLINE void m68ki_write_8_fc(M68KCPU &m68ki_cpu, uint address, uint fc, uint va
{
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->write8) (*temp->write8)(ADDRESS_68K(address),value);
else
{
@@ -1113,7 +1113,7 @@ SINLINE void m68ki_write_16_fc(M68KCPU &m68ki_cpu, uint address, uint fc, uint v
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value);
else
{
@@ -1128,7 +1128,7 @@ SINLINE void m68ki_write_32_fc(M68KCPU &m68ki_cpu, uint address, uint fc, uint v
m68ki_set_fc(fc); /* auto-disable (see m68kcpu.h) */
m68ki_check_address_error_010_less(address, MODE_WRITE, fc); /* auto-disable (see m68kcpu.h) */
_m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
const _m68k_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
if (temp->write16) (*temp->write16)(ADDRESS_68K(address),value>>16);
else *(uint16 *)(temp->base + ((address) & 0xffff)) = value >> 16;

+ 6
- 6
MD.emu/src/genplus-gx/mem68k.cc View File

@@ -880,37 +880,37 @@ void m68k_read_pcrelative_8_hook(M68KCPU &cpu, uint addr)
logMsg("read rel 8: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, addr), addr, cpu.memory_map[mapIdx].base, addr & 0xffff);
}
void m68ki_read_8_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map)
void m68ki_read_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 8: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}
void m68ki_read_16_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map)
void m68ki_read_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 16: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}
void m68ki_read_32_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map)
void m68ki_read_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 32: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}
void m68ki_write_8_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value)
void m68ki_write_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 8: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);
}
void m68ki_write_16_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value)
void m68ki_write_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 16: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);
}
void m68ki_write_32_hook(M68KCPU &cpu, uint address, _m68k_memory_map *map, uint value)
void m68ki_write_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 32: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);

+ 2
- 2
MD.emu/src/genplus-gx/vdp_ctrl.cc View File

@@ -1787,7 +1787,7 @@ static void vdp_bus_w(unsigned int data)
}
/* CRAM modified during HBLANK (Striker, Zero the Kamikaze, etc) */
if ((v_counter < bitmap.viewport.h) && (reg[1]& 0x40) && (mm68k.cycleCount <= (mcycles_vdp + 860)))
if ((v_counter < bitmap.viewport.h) && (reg[1]& 0x40) && (mm68k.cycleCount <= int(mcycles_vdp + 860)))
{
//logMsg("CRAM modified during HBLANK");
/* Remap current line */
@@ -1808,7 +1808,7 @@ static void vdp_bus_w(unsigned int data)
if (reg[11] & 0x04)
{
/* VSRAM writes during HBLANK (Adventures of Batman & Robin) */
if ((v_counter < bitmap.viewport.h) && (reg[1]& 0x40) && (mm68k.cycleCount <= (mcycles_vdp + 860)))
if ((v_counter < bitmap.viewport.h) && (reg[1]& 0x40) && (mm68k.cycleCount <= int(mcycles_vdp + 860)))
{
//logMsg("VSRAM modified during HBLANK");
/* Remap current line */

MD.emu/src/genplus-gx/m68k/musashi/m68kconf.h → MD.emu/src/m68kconf.h View File

@@ -55,6 +55,9 @@
/* ============================= CONFIGURATION ============================ */
/* ======================================================================== */
static constexpr int M68K_CYCLE_SCALER = 7;
static constexpr bool M68K_DIRECT_IM_READS = true;
/* Turn ON if you want to use the following M68K variants */
#define M68K_EMULATE_008 OPT_OFF
#define M68K_EMULATE_010 OPT_OFF
@@ -87,6 +90,8 @@
#else
#define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER
#define M68K_INT_ACK_CALLBACK(CPU, A) vdp_68k_irq_ack(CPU, A)
struct M68KCPU;
extern int vdp_68k_irq_ack(M68KCPU &m68ki_cpu, int int_level);
#endif

+ 1
- 1
MD.emu/src/scd/memMain.cc View File

@@ -11,7 +11,7 @@ uchar comWriteTarget = 0;
uint comFlagsPoll[2] = { 0 };
uint comPoll[0x20] = { 0 };

static void syncSubCpu(uint cycles, uint target)
static void syncSubCpu(int cycles, uint target)
{
assert(extraCpuSync);
doingSync = 1;

+ 1
- 0
MD.emu/src/scd/memSub.cc View File

@@ -22,6 +22,7 @@ extern bool doingSync;
extern uchar comWriteTarget;
extern uint comFlagsPoll[2];
extern uint comPoll[0x20];
extern M68KCPU mm68k;

static void endSyncSubCpu(uint target)
{

+ 1
- 1
MD.emu/src/scd/scd.h View File

@@ -5,7 +5,7 @@
#include "LC89510.h"
#include "cd_sys.h"
#include "gfx_cd.h"
#include <genplus-gx/m68k/musashi/InstructionCycleTableSCD.hh>
#include "InstructionCycleTableSCD.hh"
#include <mednafen/cdrom/CDAccess.h>
#include <imagine/util/builtins.h>

+ 1
- 1
NEO.emu/android-15.mk View File

@@ -1,4 +1,4 @@
metadata_confDeps := ../EmuFramework/metadata/conf.mk
android_arch := x86
android_arch := arm64 x86
android_minSDK := 15
include $(IMAGINE_PATH)/make/shortcut/meta-builds/android.mk

+ 1
- 1
NEO.emu/android-release-15.mk View File

@@ -1,4 +1,4 @@
metadata_confDeps := ../EmuFramework/metadata/conf.mk
android_arch := x86
android_arch := arm64 x86
android_minSDK := 15
include $(IMAGINE_PATH)/make/shortcut/meta-builds/android-release.mk

+ 5
- 22
NEO.emu/build.mk View File

@@ -17,7 +17,6 @@ GEO := gngeo

SRC += $(GEO)/mamez80/z80.c \
$(GEO)/mamez80_interf.c
#SRC += $(GEO)/z80/z80.cc $(GEO)/z80_interf.cc

SRC += $(GEO)/ym2610/2610intf.c \
$(GEO)/ym2610/ym2610.c
@@ -50,27 +49,11 @@ ifeq ($(ARCH), arm)
$(GEO)/cyclone/Cyclone.s
endif
else
SRC += $(GEO)/generator68k_interf.c \
$(GEO)/generator68k/cpu68k.c \
$(GEO)/generator68k/reg68k.c \
$(GEO)/generator68k/diss68k.c \
$(GEO)/generator68k/tab68k.c \
$(GEO)/generator68k/cpu68k-0.c \
$(GEO)/generator68k/cpu68k-1.c \
$(GEO)/generator68k/cpu68k-2.c \
$(GEO)/generator68k/cpu68k-3.c \
$(GEO)/generator68k/cpu68k-4.c \
$(GEO)/generator68k/cpu68k-5.c \
$(GEO)/generator68k/cpu68k-6.c \
$(GEO)/generator68k/cpu68k-7.c \
$(GEO)/generator68k/cpu68k-8.c \
$(GEO)/generator68k/cpu68k-9.c \
$(GEO)/generator68k/cpu68k-a.c \
$(GEO)/generator68k/cpu68k-b.c \
$(GEO)/generator68k/cpu68k-c.c \
$(GEO)/generator68k/cpu68k-d.c \
$(GEO)/generator68k/cpu68k-e.c \
$(GEO)/generator68k/cpu68k-f.c
M68K_PATH = $(EMUFRAMEWORK_PATH)/../MD.emu/src/genplus-gx/m68k
CPPFLAGS += -I$(M68K_PATH)
VPATH += $(M68K_PATH)
SRC += musashi/m68kcpu.cc \
$(GEO)/musashi_interf.cc
endif

configInc += <gngeo-config.h>

+ 0
- 1
NEO.emu/ios-release.mk View File

@@ -1,3 +1,2 @@
metadata_confDeps := ../EmuFramework/metadata/conf.mk
ios_arch := armv7
include $(IMAGINE_PATH)/make/shortcut/meta-builds/ios-release.mk

+ 0
- 1
NEO.emu/ios.mk View File

@@ -1,3 +1,2 @@
metadata_confDeps := ../EmuFramework/metadata/conf.mk
ios_arch := armv7
include $(IMAGINE_PATH)/make/shortcut/meta-builds/ios.mk

+ 8197
- 0
NEO.emu/src/InstructionCycleTable.hh
File diff suppressed because it is too large
View File


+ 2
- 7
NEO.emu/src/gngeo-config.h View File

@@ -177,15 +177,10 @@
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
/* #undef TM_IN_SYS_TIME */

#if defined(__arm__) //&& !defined(__APPLE__)
/* Define to enable cyclone */
#if defined(__arm__)
#define USE_CYCLONE 1
//#define USE_GENERATOR68K 1
/* Define to enable drz80 */
/* #undef USE_DRZ80 */
#else
/* Define to enable generator68k */
#define USE_GENERATOR68K 1
#define USE_MUSASHI 1
#endif

/* Define to use alternative opengl blitter */

+ 1
- 7
NEO.emu/src/gngeo/cyclone_interf.c View File

@@ -24,8 +24,6 @@
#include <gngeo-config.h>
#endif

#ifdef USE_CYCLONE

#include <stdlib.h>

#include "cyclone/Cyclone.h"
@@ -568,11 +566,7 @@ void cpu_68k_fill_state(M68K_STATE *st) {
void cpu_68k_set_state(M68K_STATE *st) {
}

int cpu_68k_debuger(void (*execstep)(void),void (*dump)(void)) {
int cpu_68k_debuger(void (*execstep)(int),void (*dump)(void)) {
/* TODO */
return 0;
}



#endif

+ 25
- 35
NEO.emu/src/gngeo/emu.c View File

@@ -55,10 +55,6 @@
#include "menu.h"
#include "event.h"

int frame;
//int current_line = 0;
static int arcade;

void setup_misc_patch(char *name) {


@@ -74,7 +70,7 @@ void setup_misc_patch(char *name) {
/* patch out protection checks */
int i;
Uint8 *RAM = memory.rom.cpu_m68k.p;
for (i = 0; i < memory.rom.cpu_m68k.size; i += 2) {
for (i = 0; i < (int)memory.rom.cpu_m68k.size; i += 2) {
if ((READ_WORD_ROM(&RAM[i + 0]) == 0x0243)
&& (READ_WORD_ROM(&RAM[i + 2]) == 0x0001) && /* andi.w #$1, D3 */
(READ_WORD_ROM(&RAM[i + 4]) == 0x6600)) { /* bne xxxx */
@@ -126,14 +122,14 @@ void init_sound(void) {
if (conf.sound) init_sdl_audio();

#ifdef ENABLE_940T
printf("Init all neo");
//logMsg("Init all neo");
shared_data->sample_rate = conf.sample_rate;
shared_data->z80_cycle = (z80_overclk == 0 ? 73333 : 73333
+ (z80_overclk * 73333 / 100.0));
//gp2x_add_job940(JOB940_INITALL);
gp2x_add_job940(JOB940_INITALL);
wait_busy_940(JOB940_INITALL);
printf("The YM2610 have been initialized\n");
logMsg("The YM2610 have been initialized\n");
#else
cpu_z80_init();
//streams_sh_start();
@@ -197,11 +193,10 @@ void init_neo(void) {
SDL_SaveBMP(shoot, buf);
}*/

static int fc;
static unsigned int fc;
static int last_line;
int skip_this_frame = 0;

static inline int neo_interrupt(void) {
static inline int neo_interrupt(int skip_this_frame) {
static int frames;

pd4990a_addretrace();
@@ -214,9 +209,6 @@ static inline int neo_interrupt(void) {
fc++;
}

//skip_this_frame = skip_next_frame;
//skip_next_frame = frame_skip(0);

if (!skip_this_frame) {
PROFILER_START(PROF_VIDEO);

@@ -238,7 +230,7 @@ static inline int neo_interrupt(void) {
return 1;
}

static inline void update_screen(void) {
static inline void update_screen(int skip_this_frame) {

if (memory.vid.irq2control & 0x40)
memory.vid.irq2start = (memory.vid.irq2pos + 3) / 0x180; /* ridhero gives 0x17d */
@@ -262,12 +254,9 @@ static inline void update_screen(void) {
neogeo_frame_counter++;
}
fc++;

//skip_this_frame = skip_next_frame;
//skip_next_frame = frame_skip(0);
}

static inline int update_scanline(void) {
static inline int update_scanline(int skip_this_frame) {
memory.vid.irq2taken = 0;

if (memory.vid.irq2control & 0x10) {
@@ -293,9 +282,6 @@ static inline int update_scanline(void) {
return memory.vid.irq2taken;
}

static Uint16 pending_save_state = 0, pending_load_state = 0;
static int slow_motion = 0;

static inline void state_handling(int save,int load) {
if (save) {
//if (conf.sound) SDL_LockAudio();
@@ -309,20 +295,24 @@ static inline void state_handling(int save,int load) {
//if (conf.sound) SDL_UnlockAudio();
reset_frame_skip();
}
pending_load_state = pending_save_state = 0;
}

void main_frame(void) {
void main_frame(int skip_this_frame) {
uint m68k_overclk = 0;
uint z80_overclk = 0;
Uint32 cpu_68k_timeslice = (m68k_overclk == 0 ? 200000 : 200000
+ (m68k_overclk * 200000 / 100.0));
Uint32 cpu_68k_timeslice_scanline = cpu_68k_timeslice / 264.0;
Uint32 cpu_z80_timeslice = (z80_overclk == 0 ? 73333 : 73333 + (z80_overclk
#ifdef USE_MUSASHI
const Uint32 baseTimeslice = 250000;
#else
const Uint32 baseTimeslice = 200000;
#endif
const Uint32 cpu_68k_timeslice = (m68k_overclk == 0 ? baseTimeslice : baseTimeslice
+ (m68k_overclk * baseTimeslice / 100.0));
const Uint32 cpu_68k_timeslice_scanline = cpu_68k_timeslice / 264.0;
const Uint32 cpu_z80_timeslice = (z80_overclk == 0 ? 73333 : 73333 + (z80_overclk
* 73333 / 100.0));
Uint32 tm_cycle = 0;

Uint32 cpu_z80_timeslice_interlace = cpu_z80_timeslice
const Uint32 cpu_z80_timeslice_interlace = cpu_z80_timeslice
/ (float) nb_interlace;

// run one frame
@@ -368,7 +358,7 @@ void main_frame(void) {
for (int i = 0; i < 264; i++) {
tm_cycle = cpu_68k_run(cpu_68k_timeslice_scanline
- tm_cycle);
if (update_scanline())
if (update_scanline(skip_this_frame))
{
//logMsg("irq 2");
cpu_68k_interrupt(2);
@@ -377,7 +367,7 @@ void main_frame(void) {
tm_cycle = cpu_68k_run(cpu_68k_timeslice_scanline - tm_cycle);
//state_handling(pending_save_state, pending_load_state);

update_screen();
update_screen(skip_this_frame);
memory.watchdog++;
if (memory.watchdog > 7) {
logMsg("WATCHDOG RESET\n");
@@ -388,7 +378,7 @@ void main_frame(void) {
PROFILER_START(PROF_68K);
tm_cycle = cpu_68k_run(cpu_68k_timeslice - tm_cycle);
PROFILER_STOP(PROF_68K);
int a = neo_interrupt();
int a = neo_interrupt(skip_this_frame);

/* state handling (we save/load before interrupt) */
//state_handling(pending_save_state, pending_load_state);
@@ -827,7 +817,7 @@ void main_loop(void) {
#endif
}

void cpu_68k_dpg_step(void) {
void cpu_68k_dpg_step(int skip_this_frame) {
static Uint32 nb_cycle;
static Uint32 line_cycle;
Uint32 cpu_68k_timeslice = 200000;
@@ -843,9 +833,9 @@ void cpu_68k_dpg_step(void) {
if (nb_cycle >= cpu_68k_timeslice) {
nb_cycle = line_cycle = 0;
if (conf.raster) {
update_screen();
update_screen(skip_this_frame);
} else {
neo_interrupt();
neo_interrupt(skip_this_frame);
}
//state_handling(pending_save_state, pending_load_state);
cpu_68k_interrupt(1);
@@ -853,7 +843,7 @@ void cpu_68k_dpg_step(void) {
if (line_cycle >= cpu_68k_timeslice_scanline) {
line_cycle = 0;
if (conf.raster) {
if (update_scanline())
if (update_scanline(skip_this_frame))
cpu_68k_interrupt(2);
}
}

+ 1
- 1
NEO.emu/src/gngeo/emu.h View File

@@ -136,7 +136,7 @@ extern Uint32 joy_numaxes[2];
void debug_loop(void);
void main_loop(void);
void init_neo(void);
void cpu_68k_dpg_step(void);
void cpu_68k_dpg_step(int skip_this_frame);
void setup_misc_patch(char *name);
void neogeo_reset(void);


+ 2
- 5
NEO.emu/src/gngeo/generator68k_interf.c View File

@@ -24,7 +24,6 @@
#include <gngeo-config.h>
#endif

#ifdef USE_GENERATOR68K
#include <stdlib.h>

#include "generator68k/generator.h"
@@ -415,7 +414,7 @@ int cpu_68k_run_step(void)
return reg68k_external_step();
}

int cpu_68k_debuger(void (*execstep)(void),void (*dump)(void)) {
int cpu_68k_debuger(void (*execstep)(int),void (*dump)(void)) {
char buf[200];
char *res;
char *args,*argsend;
@@ -554,7 +553,7 @@ int cpu_68k_debuger(void (*execstep)(void),void (*dump)(void)) {

void cpu_68k_interrupt(int a)
{
// printf("Interrupt %d\n",a);
//logMsg("interrupt:%d", a);
reg68k_external_autovector(a);
}

@@ -562,5 +561,3 @@ int cpu_68k_getcycle(void)
{
return cpu68k_clocks;
}

#endif

+ 2
- 2
NEO.emu/src/gngeo/mamez80/z80.h View File

@@ -6,7 +6,7 @@
#endif

#ifndef WORDS_BIGENDIAN
#define LSB_FIRST
#define Z80_LSB_FIRST
#endif

//#include "SDL_types.h"
@@ -26,7 +26,7 @@
/* ----- Extracted from MAME cpuintrf --------- */

typedef union {
#ifdef LSB_FIRST
#ifdef Z80_LSB_FIRST
struct { UINT8 l,h,h2,h3; } b;
struct { UINT16 l,h; } w;
#else

+ 17
- 21
NEO.emu/src/gngeo/memory.c View File

@@ -66,22 +66,16 @@ static __inline__ Uint16 read_neo_control(void) {
unsigned int scan;

if (!conf.raster) {

#if defined(__arm__)
#ifdef USE_CYCLONE
scan = memory.vid.current_line;
/*
printf("%d %d %d\n",current_line,
(cpu_68k_getcycle()/3)>>7,
(int)(cpu_68k_getcycle() / 766.28));
*/
#else
scan = cpu_68k_getcycle()/3;
scan = scan>>7;
#endif
#else
scan = cpu_68k_getcycle() / 766.28; /* current scanline */
#endif
#if defined USE_MUSASHI || defined USE_CYCLONE
scan = memory.vid.current_line;
/*
printf("%d %d %d\n",current_line,
(cpu_68k_getcycle()/3)>>7,
(int)(cpu_68k_getcycle() / 766.28));
*/
#else
scan = cpu_68k_getcycle() / 766.28; /* current scanline */
#endif

// scan+=0x100;
// if (scan >=0x200) scan=scan-0x108;
@@ -266,11 +260,12 @@ LONG_FETCH(mem68k_fetch_bios)

/**** SRAM ****/
Uint8 mem68k_fetch_sram_byte(Uint32 addr) {
return memory.sram[addr - 0xd00000];
addr &= 0xFFFF;
return memory.sram[addr];
}

Uint16 mem68k_fetch_sram_word(Uint32 addr) {
addr -= 0xd00000;
addr &= 0xFFFF;
return (memory.sram[addr] << 8) | (memory.sram[addr + 1] & 0xff);
}

@@ -500,7 +495,8 @@ void mem68k_store_sram_byte(Uint32 addr, Uint8 data) {
if (addr == 0xd00000 + sram_protection_hack && ((data & 0xff) == 0x01))
return;
*/
memory.sram[addr - 0xd00000] = data;
addr &= 0xFFFF;
memory.sram[addr] = data;
}

void mem68k_store_sram_word(Uint32 addr, Uint16 data) {
@@ -511,7 +507,7 @@ void mem68k_store_sram_word(Uint32 addr, Uint16 data) {
&& ((data & 0xffff) == 0x01))
return;
*/
addr -= 0xd00000;
addr &= 0xFFFF;
memory.sram[addr] = data >> 8;
memory.sram[addr + 1] = data & 0xff;
}
@@ -705,7 +701,7 @@ void mem68k_store_z80_long(Uint32 addr, Uint32 data) {

/**** SETTINGS ****/
void mem68k_store_setting_byte(Uint32 addr, Uint8 data) {
//printf("mem68k_store_setting_byte %08x\n",addr);
//logMsg("mem68k_store_setting_byte 0x%08X = 0x%X", addr, data);
addr &= 0xFFFF;
if (addr == 0x0003) {
logMsg("Selecting Bios Vector");

+ 2
- 2
NEO.emu/src/gngeo/memory.h View File

@@ -63,7 +63,7 @@
# define READ_BYTE_ROM(a) READ_BYTE(SWAP_BYTE_ADDRESS(a))
#endif

#if defined(USE_CYCLONE)
#if defined(USE_CYCLONE) || defined(USE_MUSASHI)
# undef WRITE_WORD_ROM
# undef READ_WORD_ROM
# undef WRITE_BYTE_ROM
@@ -156,7 +156,7 @@ int cpu_68k_run_step(void);
Uint32 cpu_68k_getpc(void);
void cpu_68k_fill_state(M68K_STATE *st);
void cpu_68k_set_state(M68K_STATE *st);
int cpu_68k_debuger(void (*execstep)(void),void (*dump)(void));
int cpu_68k_debuger(void (*execstep)(int),void (*dump)(void));

/* cpu z80 interface */
void cpu_z80_run(int nbcycle);

+ 498
- 0
NEO.emu/src/gngeo/musashi_interf.cc View File

@@ -0,0 +1,498 @@
#ifdef HAVE_CONFIG_H
#include <gngeo-config.h>
#endif

extern "C"
{
#include "memory.h"
#include "emu.h"
}
#undef READ_WORD
#undef WRITE_WORD
#undef READ_BYTE
#undef WRITE_BYTE
#include <musashi/m68k.h>
#include "InstructionCycleTable.hh"
#include <imagine/util/utility.h>

static M68KCPU mm68k(m68ki_cycles, true);

int neogeo68KIrqAck(M68KCPU &m68ki_cpu, int int_level)
{
//logMsg("got interrupt level:%d", int_level);
m68ki_cpu.int_level = 0;
return M68K_INT_ACK_AUTOVECTOR;
}

CLINK void cpu_68k_init(void)
{
m68k_init(mm68k);

for(int i = 0; i < 0x100; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_invalid_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_invalid_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_invalid_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_invalid_word(addr, data);
};
}

// CPU ROM
for(int i = 0; i < 0x10; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_cpu_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_cpu_word(addr);
};
}

// Work RAM
for(int i = 0x10; i < 0x20; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ram_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ram_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_ram_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_ram_word(addr, data);
};
}

// CPU ROM Bank #2
for(int i = 0x20; i < 0x30; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_bk_normal_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_bk_normal_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_bk_normal_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_bk_normal_word(addr, data);
};
}

// Controller #1
mm68k.memory_map[0x30].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl1_byte(addr);
};
mm68k.memory_map[0x30].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl1_word(addr);
};

// Controller #2
mm68k.memory_map[0x34].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl2_byte(addr);
};
mm68k.memory_map[0x34].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl2_word(addr);
};

// Controller #3 & PD4990
mm68k.memory_map[0x38].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl3_byte(addr);
};
mm68k.memory_map[0x38].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_ctl3_word(addr);
};
mm68k.memory_map[0x38].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_pd4990_byte(addr, data);
};
mm68k.memory_map[0x38].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_pd4990_word(addr, data);
};

// Coin & Z80
mm68k.memory_map[0x32].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_coin_byte(addr);
};
mm68k.memory_map[0x32].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_coin_word(addr);
};
mm68k.memory_map[0x32].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_z80_byte(addr, data);
};
mm68k.memory_map[0x32].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_z80_word(addr, data);
};

// Video
mm68k.memory_map[0x3c].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_video_byte(addr);
};
mm68k.memory_map[0x3c].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_video_word(addr);
};
mm68k.memory_map[0x3c].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_video_byte(addr, data);
};
mm68k.memory_map[0x3c].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_video_word(addr, data);
};

// Settings
mm68k.memory_map[0x3a].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_setting_byte(addr, data);
};
mm68k.memory_map[0x3a].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_setting_word(addr, data);
};

// Palette RAM
for(int i = 0x40; i < 0x80; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_pal_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_pal_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_pal_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_pal_word(addr, data);
};
}

// Memory Card
for(int i = 0x80; i < 0x81; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_memcrd_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_memcrd_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_memcrd_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_memcrd_word(addr, data);
};
}

// System ROM
for(int i = 0xC0; i < 0xD0; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_bios_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_bios_word(addr);
};
}

// Backup RAM
for(int i = 0xD0; i < 0xE0; i++)
{
mm68k.memory_map[i].read8 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_sram_byte(addr);
};
mm68k.memory_map[i].read16 =
[](unsigned int addr) -> unsigned int
{
return mem68k_fetch_sram_word(addr);
};
mm68k.memory_map[i].write8 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_sram_byte(addr, data);
};
mm68k.memory_map[i].write16 =
[](unsigned int addr, unsigned int data)
{
mem68k_store_sram_word(addr, data);
};
}

bankaddress = 0;
if (memory.rom.cpu_m68k.size > 0x100000)
{
bankaddress = 0x100000;
}
}

CLINK void cpu_68k_reset(void)
{
m68k_pulse_reset(mm68k);
}

CLINK void cpu_68k_bankswitch(Uint32 address)
{
//logMsg("bank switch:0x%X", address);
bankaddress = address;
}

CLINK int cpu_68k_run(Uint32 nb_cycle)
{
if(conf.raster)
{
mm68k.cycleCount = 0;
m68k_run(mm68k, nb_cycle);
int overCycles = mm68k.cycleCount - nb_cycle;
/*logMsg("ran %u cycles (%d over) for line:%d",
nb_cycle, overCycles, memory.vid.current_line);*/
return overCycles;
}
else
{
//logMsg("running cycles:%u", nb_cycle);
memory.vid.current_line = 0;
mm68k.cycleCount = 0;
const int cyclesPerLine = nb_cycle / 264.0;
int cycles = cyclesPerLine;
for(int i = 0; i < 265; i++)
{
m68k_run(mm68k, cycles);
//logMsg("line:%d ran to cycle:%u", i, mm68k.cycleCount);
cycles += cyclesPerLine;
memory.vid.current_line++;
}
return 0;
}
}

CLINK void cpu_68k_interrupt(int a)
{
//logMsg("interrupt:%d", a);
mm68k.updateIRQ(a);
}

CLINK Uint32 cpu_68k_getpc(void)
{
logMsg("current PC:0x%X", mm68k.pc);
return mm68k.pc;
}

CLINK void cpu_68k_mkstate(gzFile gzf,int mode)
{
mkstate_data(gzf, &mm68k.cycleCount, sizeof(mm68k.cycleCount), mode);
if(mode == STWRITE)
{
unsigned int tmp16, tmp32;
tmp32 = m68k_get_reg(mm68k, M68K_REG_D0); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D1); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D2); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D3); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D4); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D5); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D6); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_D7); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A0); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A1); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A2); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A3); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A4); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A5); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A6); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_A7); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_PC); mkstate_data(gzf, &tmp32, 4, mode);
tmp16 = m68k_get_reg(mm68k, M68K_REG_SR); mkstate_data(gzf, &tmp16, 2, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_USP); mkstate_data(gzf, &tmp32, 4, mode);
tmp32 = m68k_get_reg(mm68k, M68K_REG_ISP); mkstate_data(gzf, &tmp32, 4, mode);
}
else
{
unsigned int tmp16, tmp32;
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D0, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D1, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D2, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D3, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D4, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D5, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D6, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_D7, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A0, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A1, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A2, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A3, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A4, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A5, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A6, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_A7, tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_PC, tmp32);
mkstate_data(gzf, &tmp16, 2, mode); m68k_set_reg(mm68k, M68K_REG_SR, tmp16);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_USP,tmp32);
mkstate_data(gzf, &tmp32, 4, mode); m68k_set_reg(mm68k, M68K_REG_ISP,tmp32);
}
}

// debug hooks

const char *m68KAddrToStr(M68KCPU &cpu, uint addr)
{
uint idx = (addr>>16)&0xff;
return "";
}

static bool isVerboseCPUWrite(M68KCPU &cpu, uint addr)
{
uint idx = (addr>>16)&0xff;
return false;
}

static bool isVerboseCPURead(M68KCPU &cpu, uint addr)
{
uint idx = (addr>>16)&0xff;
return false;
}

void m68k_read_immediate_16_hook(M68KCPU &cpu, uint addr)
{
uint mapIdx = ((addr)>>16)&0xff;
if(isVerboseCPURead(cpu, addr))
//if(cpu.id() == 0 && mapIdx < 0xFF)
logMsg("read im 16: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, addr), addr, cpu.memory_map[mapIdx].base, addr & 0xffff);
}

void m68k_read_immediate_32_hook(M68KCPU &cpu, uint addr)
{

}

void m68k_read_pcrelative_8_hook(M68KCPU &cpu, uint addr)
{
uint mapIdx = ((addr)>>16)&0xff;
if(isVerboseCPURead(cpu, addr))
logMsg("read rel 8: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, addr), addr, cpu.memory_map[mapIdx].base, addr & 0xffff);
}

void m68ki_read_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 8: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}

void m68ki_read_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 16: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}

void m68ki_read_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map)
{
if(isVerboseCPURead(cpu, address))
logMsg("read 32: %s:0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, map->base, address & 0xffff);
}

void m68ki_write_8_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 8: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);
}

void m68ki_write_16_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 16: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);
}

void m68ki_write_32_hook(M68KCPU &cpu, uint address, const _m68k_memory_map *map, uint value)
{
if(isVerboseCPUWrite(cpu, address))
logMsg("write 32: %s:0x%X with 0x%X, real %p+0x%X", m68KAddrToStr(cpu, address), address, value, map->base, address & 0xffff);
}

+ 6
- 6
NEO.emu/src/gngeo/roms.c View File

@@ -873,14 +873,14 @@ static int allocate_region(ROM_REGION *r, Uint32 size, int region) {
r->p = gp2x_ram_malloc(size, 1);
#ifdef ENABLE_940T
shared_data->sm1 = (Uint8*) ((r->p - gp2x_ram2) + 0x1000000);
printf("Z80 code: %08x\n", (Uint32) shared_data->sm1);
logMsg("Z80 code: %08x\n", (Uint32) shared_data->sm1);
#endif
break;
case REGION_AUDIO_DATA_1:
r->p = gp2x_ram_malloc(size, 0);
#ifdef ENABLE_940T
shared_data->pcmbufa = (Uint8*) (r->p - gp2x_ram);
printf("SOUND1 code: %08x\n", (Uint32) shared_data->pcmbufa);
logMsg("SOUND1 code: %08x\n", (Uint32) shared_data->pcmbufa);
shared_data->pcmbufa_size = size;
#endif
break;
@@ -888,7 +888,7 @@ static int allocate_region(ROM_REGION *r, Uint32 size, int region) {
r->p = gp2x_ram_malloc(size, 0);
#ifdef ENABLE_940T
shared_data->pcmbufb = (Uint8*) (r->p - gp2x_ram);
printf("SOUND2 code: %08x\n", (Uint32) shared_data->pcmbufa);
logMsg("SOUND2 code: %08x\n", (Uint32) shared_data->pcmbufa);
shared_data->pcmbufb_size = size;
#endif
break;
@@ -1450,10 +1450,10 @@ int dr_load_roms(GAME_ROMS *r, char *rom_path, char *name, char romerror[1024])
/* Now, load the roms */
read_counter = 0;
romsize = 0;
for (i = 0; i < drv->nb_romfile; i++)
for (i = 0; i < (int)drv->nb_romfile; i++)
romsize += drv->rom[i].size;
gn_init_pbar(PBAR_ACTION_LOADROM, romsize);
for (i = 0; i < drv->nb_romfile; i++) {
for (i = 0; i < (int)drv->nb_romfile; i++) {
// gn_update_pbar(i, drv->nb_romfile);
if (load_region(gz, r, drv->rom[i].region, drv->rom[i].src,
drv->rom[i].dest, drv->rom[i].size, drv->rom[i].crc,
@@ -1494,7 +1494,7 @@ int dr_load_roms(GAME_ROMS *r, char *rom_path, char *name, char romerror[1024])
r->adpcmb.size = r->adpcma.size;
#ifdef ENABLE_940T
shared_data->pcmbufb = (Uint8*) (r->adpcmb.p - gp2x_ram);
printf("SOUND2 code: %08x\n", (Uint32) shared_data->pcmbufb);
logMsg("SOUND2 code: %08x\n", (Uint32) shared_data->pcmbufb);
shared_data->pcmbufb_size = r->adpcmb.size;
#endif
}

+ 2
- 0
NEO.emu/src/gngeo/state.c View File

@@ -26,6 +26,8 @@ static int m68k_flag=0x1;
static int m68k_flag=0x2;
#elif USE_CYCLONE
static int m68k_flag=0x3;
#elif USE_MUSASHI
static int m68k_flag=0x4;
#endif

#ifdef USE_RAZE

+ 220
- 0
NEO.emu/src/m68kconf.h View File

@@ -0,0 +1,220 @@
/* ======================================================================== */
/* ========================= LICENSING & COPYRIGHT ======================== */
/* ======================================================================== */
/*
* MUSASHI
* Version 3.32
*
* A portable Motorola M680x0 processor emulation engine.
* Copyright Karl Stenerud. All rights reserved.
*
* This code may be freely used for non-commercial purposes as long as this
* copyright notice remains unaltered in the source code and any binary files
* containing this code in compiled form.
*
* All other licensing terms must be negotiated with the author
* (Karl Stenerud).
*
* The latest version of this code can be obtained at:
* http://kstenerud.cjb.net
*/
#ifndef M68KCONF__HEADER
#define M68KCONF__HEADER
/* Configuration switches.
* Use OPT_SPECIFY_HANDLER for configuration options that allow callbacks.
* OPT_SPECIFY_HANDLER causes the core to link directly to the function
* or macro you specify, rather than using callback functions whose pointer
* must be passed in using m68k_set_xxx_callback().
*/
#define OPT_OFF 0
#define OPT_ON 1
#define OPT_SPECIFY_HANDLER 2
/* ======================================================================== */
/* ============================== MAME STUFF ============================== */
/* ======================================================================== */
/* If you're compiling this for MAME, only change M68K_COMPILE_FOR_MAME
* to OPT_ON and use m68kmame.h to configure the 68k core.
*/
#ifndef M68K_COMPILE_FOR_MAME
#define M68K_COMPILE_FOR_MAME OPT_OFF
#endif /* M68K_COMPILE_FOR_MAME */
#if M68K_COMPILE_FOR_MAME == OPT_OFF
/* ======================================================================== */
/* ============================= CONFIGURATION ============================ */
/* ======================================================================== */
static constexpr int M68K_CYCLE_SCALER = 1;
static constexpr bool M68K_DIRECT_IM_READS = false;
/* Turn ON if you want to use the following M68K variants */
#define M68K_EMULATE_008 OPT_OFF
#define M68K_EMULATE_010 OPT_OFF
#define M68K_EMULATE_EC020 OPT_OFF
#define M68K_EMULATE_020 OPT_OFF
#define M68K_EMULATE_040 OPT_OFF
//#define M68K_USE_PPC
/* If ON, the CPU will call m68k_read_immediate_xx() for immediate addressing
* 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_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().
* To simulate real 68k behavior, m68k_write_32_pd() must first write the high
* word to [address+2], and then write the low word to [address].
*/
#define M68K_SIMULATE_PD_WRITES OPT_OFF
/* If ON, CPU will call the interrupt acknowledge callback when it services an
* interrupt.
* If off, all interrupts will be autovectored and all interrupt requests will
* auto-clear when the interrupt is serviced.
*/
#define M68K_EMULATE_INT_ACK OPT_SPECIFY_HANDLER
#define M68K_INT_ACK_CALLBACK(CPU, A) neogeo68KIrqAck(CPU, A)
struct M68KCPU;
extern int neogeo68KIrqAck(M68KCPU &m68ki_cpu, int int_level);
/* If ON, CPU will call the breakpoint acknowledge callback when it encounters
* a breakpoint instruction and it is running a 68010+.
*/
#define M68K_EMULATE_BKPT_ACK OPT_OFF
#define M68K_BKPT_ACK_CALLBACK() your_bkpt_ack_handler_function()
/* If ON, the CPU will monitor the trace flags and take trace exceptions
*/
#define M68K_EMULATE_TRACE OPT_OFF
/* If ON, CPU will call the output reset callback when it encounters a reset
* instruction.
*/
#define M68K_EMULATE_RESET OPT_OFF
#define M68K_RESET_CALLBACK() your_reset_handler_function()
/* If ON, CPU will call the callback when it encounters a cmpi.l #v, dn
* instruction.
*/
#define M68K_CMPILD_HAS_CALLBACK OPT_OFF
#define M68K_CMPILD_CALLBACK(v,r) your_cmpild_handler_function(v,r)
/* If ON, CPU will call the callback when it encounters a rte
* instruction.
*/
#define M68K_RTE_HAS_CALLBACK OPT_OFF
#define M68K_RTE_CALLBACK() your_rte_handler_function()
/* If ON, CPU will call the callback when it encounters a tas
* instruction.
*/
#define M68K_TAS_HAS_CALLBACK OPT_OFF
#define M68K_TAS_CALLBACK() your_tas_handler_function()
/* If ON, CPU will call the set fc callback on every memory access to
* differentiate between user/supervisor, program/data access like a real
* 68000 would. This should be enabled and the callback should be set if you
* want to properly emulate the m68010 or higher. (moves uses function codes
* to read/write data from different address spaces)
*/
#define M68K_EMULATE_FC OPT_OFF
#define M68K_SET_FC_CALLBACK(A) your_set_fc_handler_function(A)
/* If ON, CPU will call the pc changed callback when it changes the PC by a
* large value. This allows host programs to be nicer when it comes to
* fetching immediate data and instructions on a banked memory system.
*/
/*#ifndef NDEBUG
#define M68K_MONITOR_PC OPT_ON
#else
#define M68K_MONITOR_PC OPT_OFF
#define M68K_SET_PC_CALLBACK(A) your_pc_changed_handler_function(A)
#endif*/
#define M68K_MONITOR_PC OPT_OFF
/* If ON, CPU will call the instruction hook callback before every
* instruction.
*/
#define M68K_INSTRUCTION_HOOK OPT_OFF
#define M68K_INSTRUCTION_CALLBACK() your_instruction_hook_function()
/* If ON, the CPU will emulate the 4-byte prefetch queue of a real 68000 */
#define M68K_EMULATE_PREFETCH OPT_OFF
/* If ON, the CPU will generate address error exceptions if it tries to
* access a word or longword at an odd address.
* NOTE: This is only emulated properly for 68000 mode.
*/
//#define M68K_EMULATE_ADDRESS_ERROR OPT_ON
/* If ON, branch instructions will check for infinite loop and
* freeze current CPU execution .
* Unnecessary checking might be disabled to improve instruction
* emulation speed since infinite loops are going to "lock" the CPU
* execution anyway.
*/
#define M68K_CHECK_INFINITE_LOOP OPT_OFF
/* Turn ON to enable logging of illegal instruction calls.
* M68K_LOG_FILEHANDLE must be #defined to a stdio file stream.
* Turn on M68K_LOG_1010_1111 to log all 1010 and 1111 calls.
*/
#define M68K_LOG_ENABLE OPT_OFF
#define M68K_LOG_1010_1111 OPT_OFF
#define M68K_LOG_FILEHANDLE some_file_handle
/* ----------------------------- COMPATIBILITY ---------------------------- */
/* The following options set optimizations that violate the current ANSI
* standard, but will be compliant under the forthcoming C9X standard.
*/
/* If ON, the enulation core will use 64-bit integers to speed up some
* operations.
*/
#define M68K_USE_64_BIT OPT_OFF
/* Set to your compiler's static inline keyword to enable it, or
* set it to blank to disable it.
* If you define INLINE in the makefile, it will override this value.
* NOTE: not enabling inline functions will SEVERELY slow down emulation.
*/
#ifndef SINLINE
#define SINLINE static __inline__
#endif /* SINLINE */
#endif /* M68K_COMPILE_FOR_MAME */
/* ======================================================================== */
/* ============================== END OF FILE ============================= */
/* ======================================================================== */
#endif /* M68KCONF__HEADER */

+ 36
- 0
NEO.emu/src/macros.h View File

@@ -0,0 +1,36 @@
#ifndef _MACROS_H_
#define _MACROS_H_
#ifdef LSB_FIRST
#define READ_BYTE(BASE, ADDR) (BASE)[(ADDR)^1]
#define READ_WORD(BASE, ADDR) (((BASE)[ADDR]<<8) | (BASE)[(ADDR)+1])
#define READ_WORD_LONG(BASE, ADDR) (((BASE)[(ADDR)+1]<<24) | \
((BASE)[(ADDR)]<<16) | \
((BASE)[(ADDR)+3]<<8) | \
(BASE)[(ADDR)+2])
#define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[(ADDR)^1] = (VAL)&0xff
#define WRITE_WORD(BASE, ADDR, VAL) (BASE)[ADDR] = ((VAL)>>8) & 0xff; \
(BASE)[(ADDR)+1] = (VAL)&0xff
#define WRITE_WORD_LONG(BASE, ADDR, VAL) (BASE)[(ADDR+1)] = ((VAL)>>24) & 0xff; \
(BASE)[(ADDR)] = ((VAL)>>16)&0xff; \
(BASE)[(ADDR+3)] = ((VAL)>>8)&0xff; \
(BASE)[(ADDR+2)] = (VAL)&0xff
#else
#define READ_BYTE(BASE, ADDR) (BASE)[ADDR]
#define READ_WORD(BASE, ADDR) *(uint16 *)((BASE) + (ADDR))
#define READ_WORD_LONG(BASE, ADDR) *(uint32 *)((BASE) + (ADDR))
#define WRITE_BYTE(BASE, ADDR, VAL) (BASE)[ADDR] = VAL & 0xff
#define WRITE_WORD(BASE, ADDR, VAL) *(uint16 *)((BASE) + (ADDR)) = VAL & 0xffff
#define WRITE_WORD_LONG(BASE, ADDR, VAL) *(uint32 *)((BASE) + (ADDR)) = VAL & 0xffffffff
#endif
#endif /* _MACROS_H_ */

+ 2
- 4
NEO.emu/src/main/Main.cc View File

@@ -37,7 +37,6 @@ extern "C"
CONFIG conf{};
GN_Rect visible_area;

extern int skip_this_frame;
Uint16 play_buffer[16384]{};
GN_Surface *buffer{};
static CONF_ITEM rompathConfItem{};
@@ -93,7 +92,7 @@ static EmuVideo *emuVideo{};
static IG::Pixmap srcPix{{{304, 224}, pixFmt}, (char*)screenBuff + (16*FBResX*2) + (24*2), {FBResX, IG::Pixmap::PIXEL_UNITS}};
static EmuSystem::OnLoadProgressDelegate onLoadProgress{};

CLINK void main_frame();
CLINK void main_frame(int skip_this_frame);

const char *EmuSystem::shortSystemName()
{
@@ -360,10 +359,9 @@ void EmuSystem::runFrame(EmuVideo *video, bool renderAudio)
{
//logMsg("run frame %d", (int)processGfx);
emuVideo = video;
skip_this_frame = !video;
if(video)
IG::fillData(screenBuff, (uint16)current_pc_pal[4095]);
main_frame();
main_frame(!video);
YM2610Update_stream(audioFramesPerVideoFrame);
if(renderAudio)
{

+ 1
- 1
NEO.emu/src/main/options.cc View File

@@ -67,7 +67,7 @@ void setTimerIntOption()
auto gameStr = gameName.data();
if(EmuSystem::gameIsRunning() && (strstr(gameStr, "Sidekicks 2") || strstr(gameStr, "Sidekicks 3")
|| strstr(gameStr, "Ultimate 11") || strstr(gameStr, "Neo-Geo Cup")
|| strstr(gameStr, "Spin Master")))
|| strstr(gameStr, "Spin Master") || strstr(gameStr, "Neo Turf Masters")))
needsTimer = 1;
if(needsTimer) logMsg("auto enabled timer interrupt");
conf.raster = needsTimer;

Loading…
Cancel
Save