mirror of
https://github.com/dingusdev/dingusppc.git
synced 2026-12-01 06:23:18 -10:00
Compare commits
18
Commits
remove_execflags
...
i18n
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
49a97bd487 | ||
|
|
2f30395d00 | ||
|
|
8de2c9dafc | ||
|
|
66f2c79605 | ||
|
|
1a7ccce774 | ||
|
|
134339ae9d | ||
|
|
7df166a99e | ||
|
|
acc6e77ec5 | ||
|
|
38c4f1e4cc | ||
|
|
a6483fa895 | ||
|
|
40617692b8 | ||
|
|
a5ba986666 | ||
|
|
497ab52ff0 | ||
|
|
24baf77dba | ||
|
|
ce245f8885 | ||
|
|
e508031c98 | ||
|
|
4ed13cdd04 | ||
|
|
f31f13f77b |
No files matched your search
+13
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
Copyright (C) 2018-25 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@@ -73,6 +73,17 @@ public:
|
||||
uint16_t keys_state;
|
||||
};
|
||||
|
||||
|
||||
enum KeyboardLocale : uint32_t {
|
||||
Eng_USA = 0,
|
||||
Eng_GBR = 1,
|
||||
Fra_FRA = 10,
|
||||
Deu_DEU = 20,
|
||||
Ita_ITA = 30,
|
||||
Spa_ESP = 40,
|
||||
Jpn_JPN = 80,
|
||||
};
|
||||
|
||||
/* AppleJack bits 3-7 are supported but unused */
|
||||
enum GamepadButton : uint8_t {
|
||||
Red = 14,
|
||||
@@ -112,7 +123,7 @@ public:
|
||||
return event_manager;
|
||||
};
|
||||
|
||||
void poll_events();
|
||||
void poll_events(uint32_t kbd_locale);
|
||||
|
||||
template <typename T>
|
||||
void add_window_handler(T *inst, void (T::*func)(const WindowEvent&)) {
|
||||
|
||||
+14
-14
@@ -28,11 +28,10 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
EventManager* EventManager::event_manager;
|
||||
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event);
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent& event, uint32_t kbd_locale);
|
||||
static void toggle_mouse_grab(const SDL_KeyboardEvent &event);
|
||||
|
||||
void EventManager::poll_events()
|
||||
{
|
||||
void EventManager::poll_events(uint32_t kbd_locale) {
|
||||
SDL_Event event;
|
||||
|
||||
while (SDL_PollEvent(&event)) {
|
||||
@@ -45,7 +44,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_WINDOWEVENT: {
|
||||
WindowEvent we;
|
||||
WindowEvent we{};
|
||||
we.sub_type = event.window.event;
|
||||
we.window_id = event.window.windowID;
|
||||
this->_window_signal.emit(we);
|
||||
@@ -65,16 +64,16 @@ void EventManager::poll_events()
|
||||
// Control-S: scale quality
|
||||
if (event.key.keysym.sym == SDLK_s && SDL_GetModState() & KMOD_LCTRL) {
|
||||
if (event.type == SDL_KEYUP) {
|
||||
WindowEvent we;
|
||||
WindowEvent we{};
|
||||
we.sub_type = WINDOW_SCALE_QUALITY_TOGGLE;
|
||||
we.window_id = event.window.windowID;
|
||||
this->_window_signal.emit(we);
|
||||
}
|
||||
return;
|
||||
}
|
||||
int key_code = get_sdl_event_key_code(event.key);
|
||||
int key_code = get_sdl_event_key_code(event.key, kbd_locale);
|
||||
if (key_code != -1) {
|
||||
KeyboardEvent ke;
|
||||
KeyboardEvent ke{};
|
||||
ke.key = key_code;
|
||||
if (event.type == SDL_KEYDOWN) {
|
||||
ke.flags = KEYBOARD_EVENT_DOWN;
|
||||
@@ -96,7 +95,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEMOTION: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
me.xrel = event.motion.xrel;
|
||||
me.yrel = event.motion.yrel;
|
||||
me.xabs = event.motion.x;
|
||||
@@ -107,7 +106,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONDOWN: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
Uint8 adb_button;
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT : adb_button = 0; break;
|
||||
@@ -124,7 +123,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_MOUSEBUTTONUP: {
|
||||
MouseEvent me;
|
||||
MouseEvent me{};
|
||||
Uint8 adb_button;
|
||||
switch (event.button.button) {
|
||||
case SDL_BUTTON_LEFT : adb_button = 0; break;
|
||||
@@ -141,7 +140,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONDOWN: {
|
||||
GamepadEvent ge;
|
||||
GamepadEvent ge{};
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
@@ -164,7 +163,7 @@ void EventManager::poll_events()
|
||||
break;
|
||||
|
||||
case SDL_CONTROLLERBUTTONUP: {
|
||||
GamepadEvent ge;
|
||||
GamepadEvent ge{};
|
||||
switch (event.cbutton.button) {
|
||||
case SDL_CONTROLLER_BUTTON_BACK: ge.button = GamepadButton::FrontLeft; break;
|
||||
case SDL_CONTROLLER_BUTTON_GUIDE: ge.button = GamepadButton::FrontMiddle; break;
|
||||
@@ -196,7 +195,7 @@ void EventManager::poll_events()
|
||||
}
|
||||
|
||||
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event)
|
||||
static int get_sdl_event_key_code(const SDL_KeyboardEvent &event, uint32_t kbd_locale)
|
||||
{
|
||||
switch (event.keysym.sym) {
|
||||
case SDLK_a: return AdbKey_A;
|
||||
@@ -331,7 +330,8 @@ static int get_sdl_event_key_code(const SDL_KeyboardEvent &event)
|
||||
|
||||
//Japanese keyboard
|
||||
case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INTERNATIONAL3):
|
||||
return AdbKey_JIS_Yen;
|
||||
if (kbd_locale == Jpn_JPN)
|
||||
return AdbKey_JIS_Yen;
|
||||
case SDL_SCANCODE_TO_KEYCODE(SDL_SCANCODE_INTERNATIONAL1):
|
||||
return AdbKey_JIS_Underscore;
|
||||
case 0XBC:
|
||||
|
||||
+4
-2
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-23 divingkatae and maximum
|
||||
Copyright (C) 2018-25 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@@ -146,7 +146,9 @@ private:
|
||||
std::function<void()> notify_timer_changes;
|
||||
|
||||
std::atomic<uint32_t> id{0};
|
||||
bool cb_active = false; // true if a timer callback is executing // FIXME: Do we need this? It gets written in main thread and read in audio thread.
|
||||
|
||||
// FIXME: Do we need this? It gets written in main thread and read in audio thread.
|
||||
bool cb_active = false; // true if a timer callback is executing
|
||||
};
|
||||
|
||||
#endif // TIMER_MANAGER_H
|
||||
+10
-5
@@ -182,9 +182,10 @@ extern uint32_t rtc_lo, rtc_hi;
|
||||
|
||||
/* Flags for controlling interpreter execution. */
|
||||
enum {
|
||||
EXEF_BRANCH = 1 << 0,
|
||||
EXEF_EXCEPTION = 1 << 1,
|
||||
EXEF_RFI = 1 << 2,
|
||||
EXEF_BRANCH = 1 << 0, // Branch taken, target PC is is in ppc_next_instruction_address
|
||||
EXEF_EXCEPTION = 1 << 1, // Exception handler invoked
|
||||
EXEF_RFI = 1 << 2, // RFI instruction executed
|
||||
EXEF_OPC_DECODER = 1 << 3, // Opcode decoder has changed
|
||||
};
|
||||
|
||||
enum CR_select : int32_t {
|
||||
@@ -326,7 +327,8 @@ extern bool int_pin;
|
||||
extern bool dec_exception_pending;
|
||||
|
||||
extern bool is_601; // For PowerPC 601 Emulation
|
||||
extern bool include_601; // For non-PowerPC 601 emulation with 601 extras (matches Mac OS 9 environment which can emulate MPC 601 instructions)
|
||||
extern bool include_601; // For non-PowerPC 601 emulation with 601 extras
|
||||
// (matches Mac OS 9 environment which can emulate MPC 601 instructions)
|
||||
extern bool is_altivec; // For Altivec Emulation
|
||||
extern bool is_64bit; // For PowerPC G5 Emulation
|
||||
|
||||
@@ -640,12 +642,15 @@ template <field_rc rec> extern void power_srq(uint32_t opcode);
|
||||
|
||||
extern uint64_t get_virt_time_ns(void);
|
||||
|
||||
extern void ppc_main_opcode(uint32_t opcode);
|
||||
extern void ppc_main_opcode(PPCOpcode* ppc_opcode_grabber, uint32_t opcode);
|
||||
extern void ppc_exec(void);
|
||||
extern void ppc_exec_single(void);
|
||||
extern void ppc_exec_until(uint32_t goal_addr);
|
||||
extern void ppc_exec_dbg(uint32_t start_addr, uint32_t size);
|
||||
|
||||
extern PPCOpcode *ppc_opcode_grabber();
|
||||
extern void ppc_msr_did_change(uint32_t old_msr_val, bool set_next_instruction_address = true);
|
||||
|
||||
/* debugging support API */
|
||||
void print_fprs(void); /* print content of the floating-point registers */
|
||||
uint64_t get_reg(std::string reg_name); /* get content of the register reg_name */
|
||||
|
||||
@@ -57,7 +57,7 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
break;
|
||||
|
||||
case Except_Type::EXC_ISI:
|
||||
if (exec_flags) {
|
||||
if (exec_flags & ~EXEF_OPC_DECODER) {
|
||||
ppc_state.spr[SPR::SRR0] = ppc_next_instruction_address;
|
||||
} else {
|
||||
ppc_state.spr[SPR::SRR0] = ppc_state.pc & 0xFFFFFFFCUL;
|
||||
@@ -66,7 +66,7 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
break;
|
||||
|
||||
case Except_Type::EXC_EXT_INT:
|
||||
if (exec_flags) {
|
||||
if (exec_flags & ~EXEF_OPC_DECODER) {
|
||||
ppc_state.spr[SPR::SRR0] = ppc_next_instruction_address;
|
||||
} else {
|
||||
ppc_state.spr[SPR::SRR0] = (ppc_state.pc & 0xFFFFFFFCUL) + 4;
|
||||
@@ -90,7 +90,7 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
break;
|
||||
|
||||
case Except_Type::EXC_DECR:
|
||||
if (exec_flags) {
|
||||
if (exec_flags & ~EXEF_OPC_DECODER) {
|
||||
ppc_state.spr[SPR::SRR0] = ppc_next_instruction_address;
|
||||
} else {
|
||||
ppc_state.spr[SPR::SRR0] = (ppc_state.pc & 0xFFFFFFFCUL) + 4;
|
||||
@@ -114,9 +114,12 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
|
||||
}
|
||||
|
||||
ppc_state.spr[SPR::SRR1] = (ppc_state.msr & 0x0000FF73) | srr1_bits;
|
||||
uint32_t old_msr_val = ppc_state.msr;
|
||||
ppc_state.msr &= 0xFFFB1041;
|
||||
/* copy MSR[ILE] to MSR[LE] */
|
||||
ppc_state.msr = (ppc_state.msr & ~MSR::LE) | !!(ppc_state.msr & MSR::ILE);
|
||||
// Don't clobber the ppc_next_instruction_address value
|
||||
ppc_msr_did_change(old_msr_val, false);
|
||||
|
||||
if (ppc_state.msr & MSR::IP) {
|
||||
ppc_next_instruction_address |= 0xFFF00000;
|
||||
|
||||
+108
-39
@@ -153,9 +153,12 @@ public:
|
||||
op_name_counts.emplace_back(op_name, pair.second);
|
||||
}
|
||||
size_t top_ops_size = std::min(op_name_counts.size(), size_t(20));
|
||||
std::partial_sort(op_name_counts.begin(), op_name_counts.begin() + top_ops_size, op_name_counts.end(), [](const auto& a, const auto& b) {
|
||||
return b.second < a.second;
|
||||
});
|
||||
std::partial_sort(
|
||||
op_name_counts.begin(), op_name_counts.begin() + top_ops_size, op_name_counts.end(),
|
||||
[](const auto& a, const auto& b) {
|
||||
return b.second < a.second;
|
||||
}
|
||||
);
|
||||
op_name_counts.resize(top_ops_size);
|
||||
for (const auto& pair : op_name_counts) {
|
||||
vars.push_back({.name = "Instruction " + pair.first,
|
||||
@@ -184,12 +187,38 @@ public:
|
||||
primary opcode (bits 0...5) and modifier (bits 21...31). */
|
||||
static PPCOpcode OpcodeGrabber[64 * 2048];
|
||||
|
||||
/** Alternate lookup table when floating point instructions are disabled.
|
||||
Floating point instructions are mapped to ppc_fpu_off,
|
||||
everything else is the same.*/
|
||||
static PPCOpcode OpcodeGrabberNoFPU[64 * 2048];
|
||||
|
||||
void ppc_msr_did_change(uint32_t old_msr_val, bool set_next_instruction_address) {
|
||||
bool old_fp = old_msr_val & MSR::FP;
|
||||
bool new_fp = ppc_state.msr & MSR::FP;
|
||||
if (old_fp != new_fp) {
|
||||
exec_flags |= EXEF_OPC_DECODER;
|
||||
if (set_next_instruction_address) {
|
||||
// Even though we're setting an exception flag, we want normal
|
||||
// instruction execution to continue.
|
||||
ppc_next_instruction_address = ppc_state.pc + 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PPCOpcode* ppc_opcode_grabber() {
|
||||
return ppc_state.msr & MSR::FP ? OpcodeGrabber : OpcodeGrabberNoFPU;
|
||||
}
|
||||
|
||||
/** Exception helpers. */
|
||||
|
||||
void ppc_illegalop(uint32_t opcode) {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::ILLEGAL_OP);
|
||||
}
|
||||
|
||||
void ppc_fpu_off(uint32_t opcode) {
|
||||
ppc_exception_handler(Except_Type::EXC_NO_FPU, Exc_Cause::FPU_OFF);
|
||||
}
|
||||
|
||||
void ppc_assert_int() {
|
||||
int_pin = true;
|
||||
if (ppc_state.msr & MSR::EE) {
|
||||
@@ -207,7 +236,7 @@ void ppc_release_int() {
|
||||
/** Opcode decoding functions. */
|
||||
|
||||
/* Dispatch using primary and modifier opcode */
|
||||
void ppc_main_opcode(uint32_t opcode)
|
||||
void ppc_main_opcode(PPCOpcode *opcodeGrabber, uint32_t opcode)
|
||||
{
|
||||
#ifdef CPU_PROFILING
|
||||
num_executed_instrs++;
|
||||
@@ -215,7 +244,7 @@ void ppc_main_opcode(uint32_t opcode)
|
||||
num_opcodes[opcode]++;
|
||||
#endif
|
||||
#endif
|
||||
OpcodeGrabber[(opcode >> 15 & 0x1F800) | (opcode & 0x7FF)](opcode);
|
||||
opcodeGrabber[(opcode >> 15 & 0x1F800) | (opcode & 0x7FF)](opcode);
|
||||
}
|
||||
|
||||
static long long cpu_now_ns() {
|
||||
@@ -267,6 +296,7 @@ static void ppc_exec_inner(uint32_t start_addr, uint32_t size)
|
||||
uint64_t max_cycles = 0;
|
||||
uint32_t page_start, eb_start, eb_end = 0;
|
||||
uint32_t opcode;
|
||||
PPCOpcode* opcode_grabber = ppc_opcode_grabber();
|
||||
uint8_t* pc_real;
|
||||
|
||||
while (power_on) {
|
||||
@@ -285,11 +315,14 @@ static void ppc_exec_inner(uint32_t start_addr, uint32_t size)
|
||||
}
|
||||
|
||||
opcode = ppc_read_instruction(pc_real);
|
||||
ppc_main_opcode(opcode);
|
||||
if (g_icycles++ >= max_cycles || exec_timer)
|
||||
ppc_main_opcode(opcode_grabber, opcode);
|
||||
if (g_icycles++ >= max_cycles || exec_timer) [[unlikely]]
|
||||
max_cycles = process_events();
|
||||
|
||||
if (exec_flags) {
|
||||
if (exec_flags & EXEF_OPC_DECODER) [[unlikely]] {
|
||||
opcode_grabber = ppc_opcode_grabber();
|
||||
}
|
||||
// define next execution block
|
||||
eb_start = ppc_next_instruction_address;
|
||||
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
|
||||
@@ -344,7 +377,7 @@ void ppc_exec_single()
|
||||
|
||||
uint8_t* pc_real = mmu_translate_imem(ppc_state.pc);
|
||||
uint32_t opcode = ppc_read_instruction(pc_real);
|
||||
ppc_main_opcode(opcode);
|
||||
ppc_main_opcode(ppc_opcode_grabber(), opcode);
|
||||
g_icycles++;
|
||||
process_events();
|
||||
|
||||
@@ -414,17 +447,39 @@ for (uint32_t mod = 0; mod < 2048; mod++) { \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OP_fp(opcode, fn) \
|
||||
do { \
|
||||
for (uint32_t mod = 0; mod < 2048; mod++) { \
|
||||
OpcodeGrabber[((opcode) << 11) | mod] = fn; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | mod] = ppc_fpu_off; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OPX(opcode, subopcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1)] = fn; \
|
||||
} while (0)
|
||||
|
||||
#define OPX_fp(opcode, subopcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1)] = fn; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | ((subopcode)<<1)] = ppc_fpu_off; \
|
||||
} while (0)
|
||||
|
||||
#define OPXd(opcode, subopcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<RC0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<RC1>; \
|
||||
} while (0)
|
||||
|
||||
#define OPXd_fp(opcode, subopcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<RC0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<RC1>; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | ((subopcode)<<1) | 0x000] = ppc_fpu_off; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | ((subopcode)<<1) | 0x001] = ppc_fpu_off; \
|
||||
} while (0)
|
||||
|
||||
#define OPXod(opcode, subopcode, fn) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<RC0, OV0>; \
|
||||
@@ -439,6 +494,14 @@ do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<carry, RC1>; \
|
||||
} while (0)
|
||||
|
||||
#define OPXdc_fp(opcode, subopcode, fn, carry) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<carry, RC0>; \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x001] = fn<carry, RC1>; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | ((subopcode)<<1) | 0x000] = ppc_fpu_off; \
|
||||
OpcodeGrabberNoFPU[((opcode) << 11) | ((subopcode)<<1) | 0x001] = ppc_fpu_off; \
|
||||
} while (0)
|
||||
|
||||
#define OPXcod(opcode, subopcode, fn, carry) \
|
||||
do { \
|
||||
OpcodeGrabber[((opcode) << 11) | ((subopcode)<<1) | 0x000] = fn<carry, RC0, OV0>; \
|
||||
@@ -460,36 +523,33 @@ do { \
|
||||
} while (0)
|
||||
|
||||
#define OP31(subopcode, fn) OPX(31, subopcode, fn)
|
||||
#define OP31_fp(subopcode, fn) OPX_fp(31, subopcode, fn)
|
||||
#define OP31d(subopcode, fn) OPXd(31, subopcode, fn)
|
||||
#define OP31od(subopcode, fn) OPXod(31, subopcode, fn)
|
||||
#define OP31dc(subopcode, fn, carry) OPXdc(31, subopcode, fn, carry)
|
||||
#define OP31cod(subopcode, fn, carry) OPXcod(31, subopcode, fn, carry)
|
||||
|
||||
#define OP63(subopcode, fn) OPX(63, subopcode, fn)
|
||||
#define OP63d(subopcode, fn) OPXd(63, subopcode, fn)
|
||||
#define OP63dc(subopcode, fn, carry) OPXdc(63, subopcode, fn, carry)
|
||||
#define OP63(subopcode, fn) OPX_fp(63, subopcode, fn)
|
||||
#define OP63d(subopcode, fn) OPXd_fp(63, subopcode, fn)
|
||||
#define OP63dc(subopcode, fn, carry) OPXdc_fp(63, subopcode, fn, carry)
|
||||
|
||||
#define OP59d(subopcode, fn) \
|
||||
do { \
|
||||
OPXd(59, (subopcode), fn); \
|
||||
OPXd_fp(59, (subopcode), fn); \
|
||||
} while (0)
|
||||
|
||||
#define OP59cd(subopcode, fn) \
|
||||
do { \
|
||||
for (uint32_t ccccc = 0; ccccc < 32; ccccc++) { \
|
||||
OPXd(59, (ccccc << 5) | (subopcode), fn); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
#define OP4_ccccc10xxxx(subopcode, fn) \
|
||||
do { \
|
||||
for (uint32_t ccccc = 0; ccccc < 32; ccccc++) { \
|
||||
OPr(4, (ccccc << 6) | (subopcode), fn); \
|
||||
OPXd_fp(59, (ccccc << 5) | (subopcode), fn); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
void initialize_ppc_opcode_table() {
|
||||
std::fill_n(OpcodeGrabber, 64 * 2048, ppc_illegalop);
|
||||
auto opcodeGrabberSize = sizeof(OpcodeGrabber) / sizeof(OpcodeGrabber[0]);
|
||||
std::fill_n(OpcodeGrabber, opcodeGrabberSize, ppc_illegalop);
|
||||
std::fill_n(OpcodeGrabberNoFPU, opcodeGrabberSize, ppc_illegalop);
|
||||
|
||||
OP(3, ppc_twi);
|
||||
//OP(4, ppc_opcode4); - Altivec instructions not emulated yet. Uncomment once they're implemented.
|
||||
OP(7, ppc_mulli);
|
||||
@@ -528,14 +588,14 @@ void initialize_ppc_opcode_table() {
|
||||
OP(45, ppc_stu<uint16_t>);
|
||||
OP(46, ppc_lmw);
|
||||
OP(47, ppc_stmw);
|
||||
OP(48, ppc_lfs);
|
||||
OP(49, ppc_lfsu);
|
||||
OP(50, ppc_lfd);
|
||||
OP(51, ppc_lfdu);
|
||||
OP(52, ppc_stfs);
|
||||
OP(53, ppc_stfsu);
|
||||
OP(54, ppc_stfd);
|
||||
OP(55, ppc_stfdu);
|
||||
OP_fp(48, ppc_lfs);
|
||||
OP_fp(49, ppc_lfsu);
|
||||
OP_fp(50, ppc_lfd);
|
||||
OP_fp(51, ppc_lfdu);
|
||||
OP_fp(52, ppc_stfs);
|
||||
OP_fp(53, ppc_stfsu);
|
||||
OP_fp(54, ppc_stfd);
|
||||
OP_fp(55, ppc_stfdu);
|
||||
|
||||
OPla(16, 0x0, (dppc_interpreter::ppc_bc<LK0, AA0>)); // bc
|
||||
OPla(16, 0x1, (dppc_interpreter::ppc_bc<LK1, AA0>)); // bcl
|
||||
@@ -597,11 +657,11 @@ void initialize_ppc_opcode_table() {
|
||||
OP31(375, ppc_lhaux);
|
||||
OP31(533, ppc_lswx);
|
||||
OP31(534, ppc_lwbrx);
|
||||
OP31(535, ppc_lfsx);
|
||||
OP31(567, ppc_lfsux);
|
||||
OP31_fp(535, ppc_lfsx);
|
||||
OP31_fp(567, ppc_lfsux);
|
||||
OP31(597, ppc_lswi);
|
||||
OP31(599, ppc_lfdx);
|
||||
OP31(631, ppc_lfdux);
|
||||
OP31_fp(599, ppc_lfdx);
|
||||
OP31_fp(631, ppc_lfdux);
|
||||
OP31(790, ppc_lhbrx);
|
||||
|
||||
OPr(31, (150<<1) | 1, ppc_stwcx); // No Rc=0 variant.
|
||||
@@ -613,13 +673,13 @@ void initialize_ppc_opcode_table() {
|
||||
OP31(439, ppc_stux<uint16_t>);
|
||||
OP31(661, ppc_stswx);
|
||||
OP31(662, ppc_stwbrx);
|
||||
OP31(663, ppc_stfsx);
|
||||
OP31(695, ppc_stfsux);
|
||||
OP31_fp(663, ppc_stfsx);
|
||||
OP31_fp(695, ppc_stfsux);
|
||||
OP31(725, ppc_stswi);
|
||||
OP31(727, ppc_stfdx);
|
||||
OP31(759, ppc_stfdux);
|
||||
OP31_fp(727, ppc_stfdx);
|
||||
OP31_fp(759, ppc_stfdux);
|
||||
OP31(918, ppc_sthbrx);
|
||||
if (!is_601) OP31(983, ppc_stfiwx);
|
||||
if (!is_601) OP31_fp(983, ppc_stfiwx);
|
||||
|
||||
OP31(310, ppc_eciwx);
|
||||
OP31(438, ppc_ecowx);
|
||||
@@ -739,6 +799,12 @@ void initialize_ppc_opcode_table() {
|
||||
OP63d(i + 30, ppc_fnmsub);
|
||||
OP63d(i + 31, ppc_fnmadd);
|
||||
}
|
||||
|
||||
for (auto i = 0; i < opcodeGrabberSize; i++) {
|
||||
if (OpcodeGrabberNoFPU[i] != ppc_fpu_off) {
|
||||
OpcodeGrabberNoFPU[i] = OpcodeGrabber[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool do_include_601, uint64_t tb_freq)
|
||||
@@ -845,8 +911,11 @@ static uint64_t reg_op(string& reg_name, uint64_t val, bool is_write) {
|
||||
return ppc_state.pc;
|
||||
}
|
||||
if (reg_name_u == "MSR") {
|
||||
if (is_write)
|
||||
if (is_write) {
|
||||
uint32_t old_msr_val = ppc_state.msr;
|
||||
ppc_state.msr = (uint32_t)val;
|
||||
ppc_msr_did_change(old_msr_val);
|
||||
}
|
||||
return ppc_state.msr;
|
||||
}
|
||||
if (reg_name_u == "CR") {
|
||||
|
||||
@@ -801,7 +801,9 @@ void dppc_interpreter::ppc_mtmsr(uint32_t opcode) {
|
||||
ppc_exception_handler(Except_Type::EXC_PROGRAM, Exc_Cause::NOT_ALLOWED);
|
||||
}
|
||||
uint32_t reg_s = (opcode >> 21) & 0x1F;
|
||||
uint32_t old_msr_val = ppc_state.msr;
|
||||
ppc_state.msr = ppc_state.gpr[reg_s];
|
||||
ppc_msr_did_change(old_msr_val);
|
||||
|
||||
// generate External Interrupt Exception
|
||||
// if CPU interrupt line is asserted
|
||||
@@ -1376,9 +1378,11 @@ void dppc_interpreter::ppc_rfi(uint32_t opcode) {
|
||||
#ifdef CPU_PROFILING
|
||||
num_supervisor_instrs++;
|
||||
#endif
|
||||
uint32_t old_msr_val = ppc_state.msr;
|
||||
uint32_t new_srr1_val = (ppc_state.spr[SPR::SRR1] & 0x87C0FF73UL);
|
||||
uint32_t new_msr_val = (ppc_state.msr & ~0x87C0FF73UL);
|
||||
ppc_state.msr = (new_msr_val | new_srr1_val) & 0xFFFBFFFFUL;
|
||||
ppc_msr_did_change(old_msr_val);
|
||||
|
||||
// generate External Interrupt Exception
|
||||
// if CPU interrupt line is still asserted
|
||||
@@ -1404,7 +1408,7 @@ void dppc_interpreter::ppc_rfi(uint32_t opcode) {
|
||||
|
||||
mmu_change_mode();
|
||||
|
||||
exec_flags = EXEF_RFI;
|
||||
exec_flags |= EXEF_RFI;
|
||||
}
|
||||
|
||||
void dppc_interpreter::ppc_sc(uint32_t opcode) {
|
||||
|
||||
@@ -46,7 +46,7 @@ void xer_ov_test(string mnem, uint32_t opcode) {
|
||||
ppc_state.gpr[3] = 2;
|
||||
ppc_state.gpr[4] = 2;
|
||||
ppc_state.spr[SPR::XER] = 0xFFFFFFFF;
|
||||
ppc_main_opcode(opcode);
|
||||
ppc_main_opcode(ppc_opcode_grabber(), opcode);
|
||||
if (ppc_state.spr[SPR::XER] & 0x40000000UL) {
|
||||
cout << "Invalid " << mnem << " emulation! XER[OV] should not be set." << endl;
|
||||
nfailed++;
|
||||
@@ -150,7 +150,7 @@ static void read_test_data() {
|
||||
ppc_state.spr[SPR::XER] = 0;
|
||||
ppc_state.cr = 0;
|
||||
|
||||
ppc_main_opcode(opcode);
|
||||
ppc_main_opcode(ppc_opcode_grabber(), opcode);
|
||||
|
||||
ntested++;
|
||||
|
||||
@@ -292,7 +292,7 @@ static void read_test_float_data() {
|
||||
|
||||
ppc_state.cr = 0;
|
||||
|
||||
ppc_main_opcode(opcode);
|
||||
ppc_main_opcode(ppc_opcode_grabber(), opcode);
|
||||
|
||||
ntested++;
|
||||
|
||||
@@ -302,10 +302,11 @@ static void read_test_float_data() {
|
||||
if ((tokens[0].rfind("FCMP") && (ppc_state.fpr[3].int64_r != dest_64)) ||
|
||||
(ppc_state.fpscr != check_fpscr) ||
|
||||
(ppc_state.cr != check_cr)) {
|
||||
cout << "Mismatch: instr=" << tokens[0] << ", src1=" << scientific << dfp_src1 << ", src2=" << scientific << dfp_src2 << ", src3=" << scientific << dfp_src3 << endl;
|
||||
cout << "Mismatch: instr=" << tokens[0] << ", src1=" << scientific << dfp_src1
|
||||
<< ", src2=" << scientific << dfp_src2 << ", src3=" << scientific << dfp_src3 << endl;
|
||||
cout << "expected: dest=0x" << hex << dest_64 << ", FPSCR=0x" << hex << check_fpscr
|
||||
<< ", CR=0x"
|
||||
<< hex << check_cr << endl;
|
||||
<< hex << check_cr << endl;
|
||||
cout << "got: dest=0x" << hex << ppc_state.fpr[3].int64_r << ", FPSCR=0x" << hex
|
||||
<< ppc_state.fpscr << ", CR=0x" << hex << ppc_state.cr << endl;
|
||||
cout << "Test file line #: " << dec << lineno << endl << endl;
|
||||
@@ -318,6 +319,9 @@ static void read_test_float_data() {
|
||||
int main() {
|
||||
is_601 = true;
|
||||
initialize_ppc_opcode_table(); //kludge
|
||||
// MPC601 sets MSR[ME] bit during hard reset / Power-On.
|
||||
// Also set MSR[FP] bit so we can test FPU instructions.
|
||||
ppc_state.msr = (MSR::ME | MSR::IP | MSR::FP);
|
||||
|
||||
cout << "Running DingusPPC emulator tests..." << endl << endl;
|
||||
|
||||
|
||||
@@ -111,7 +111,7 @@ static void show_help() {
|
||||
|
||||
static uint32_t disasm_68k(uint32_t count, uint32_t address) {
|
||||
csh cs_handle;
|
||||
uint8_t code[10];
|
||||
uint8_t code[12];
|
||||
size_t code_size;
|
||||
uint64_t dis_addr;
|
||||
|
||||
@@ -123,7 +123,7 @@ static uint32_t disasm_68k(uint32_t count, uint32_t address) {
|
||||
cs_insn* insn = cs_malloc(cs_handle);
|
||||
|
||||
for (; power_on && count > 0; count--) {
|
||||
/* prefetch opcode bytes (a 68k instruction can occupy 2...10 bytes) */
|
||||
// prefetch opcode bytes (a 68k instruction can occupy 2...12 bytes)
|
||||
for (int i = 0; i < sizeof(code); i++) {
|
||||
code[i] = mem_read_dbg(address + i, 1);
|
||||
}
|
||||
|
||||
@@ -8,8 +8,10 @@ include_directories("${PROJECT_SOURCE_DIR}"
|
||||
platform_glob(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/adb/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/clockgen/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/i2c/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/ata/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/nubus/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/pci/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/common/scsi/*.cpp"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/ethernet/*.cpp"
|
||||
|
||||
@@ -29,7 +29,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <loguru.hpp>
|
||||
|
||||
AdbMouse::AdbMouse(
|
||||
std::string name, uint8_t device_class, int num_buttons, int num_bits, uint16_t resolution) : AdbDevice(name), device_class(device_class), num_buttons(num_buttons), num_bits(num_bits), resolution(resolution) {
|
||||
std::string name, uint8_t device_class, int num_buttons, int num_bits, uint16_t resolution
|
||||
) : AdbDevice(name), device_class(device_class), num_buttons(num_buttons), num_bits(num_bits), resolution(resolution)
|
||||
{
|
||||
EventManager::get_instance()->add_mouse_handler(this, &AdbMouse::event_handler);
|
||||
|
||||
this->reset();
|
||||
|
||||
@@ -241,7 +241,8 @@ void AtapiCdrom::perform_packet_command() {
|
||||
else {
|
||||
disk_image_byte_count = (this->r_byte_count / bytes_per_block) * this->block_size; // whole blocks
|
||||
if ((this->r_byte_count % bytes_per_block) > bytes_prolog) { // partial block
|
||||
int disk_image_byte_count_partial_block = (this->r_byte_count % bytes_per_block) - bytes_prolog; // remove prolog from partial block
|
||||
int disk_image_byte_count_partial_block =
|
||||
(this->r_byte_count % bytes_per_block) - bytes_prolog; // remove prolog from partial block
|
||||
if (disk_image_byte_count_partial_block > this->block_size) { // partial block includes some epilog?
|
||||
disk_image_byte_count_partial_block = this->block_size; // // remove epilog from partial block
|
||||
}
|
||||
@@ -252,7 +253,8 @@ void AtapiCdrom::perform_packet_command() {
|
||||
|
||||
int disk_image_bytes_received = this->read_begin(xfer_len, disk_image_byte_count);
|
||||
|
||||
int bytes_received = (disk_image_bytes_received / this->block_size) * bytes_per_block + bytes_prolog + (disk_image_bytes_received % this->block_size); // whole blocks + prolog + partial block
|
||||
int bytes_received = (disk_image_bytes_received / this->block_size) * bytes_per_block + bytes_prolog +
|
||||
(disk_image_bytes_received % this->block_size); // whole blocks + prolog + partial block
|
||||
if (bytes_received > this->r_byte_count) { // if partial epilog or partial prolog
|
||||
bytes_received = this->r_byte_count; // confine to r_byte_count
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
This is helpful especially for calculating video parameters.
|
||||
*/
|
||||
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/common/clockgen/athens.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
File renamed without changes.
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-21 divingkatae and maximum
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@@ -27,11 +27,13 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#ifndef I2C_H
|
||||
#define I2C_H
|
||||
|
||||
#include <stdexcept>
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <loguru.hpp>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
/** Base class for I2C devices */
|
||||
class I2CDevice {
|
||||
public:
|
||||
|
||||
@@ -0,0 +1,156 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/nubus/nubusutils.h>
|
||||
#include <devices/memctrl/memctrlbase.h>
|
||||
#include <machines/machinebase.h>
|
||||
#include <loguru.hpp>
|
||||
#include <memaccess.h>
|
||||
|
||||
#include <cinttypes>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
uint32_t calculate_rom_crc(uint8_t *data_ptr, int length)
|
||||
{
|
||||
uint32_t sum = 0;
|
||||
|
||||
for (int i = 0; i < length; i++) {
|
||||
// rotate sum left by one bit
|
||||
if (sum & 0x80000000UL)
|
||||
sum = (sum << 1) | 1;
|
||||
else
|
||||
sum = (sum << 1) | 0;
|
||||
sum += data_ptr[i];
|
||||
}
|
||||
|
||||
return sum;
|
||||
}
|
||||
|
||||
int load_declaration_rom(const std::string rom_path, int slot_num)
|
||||
{
|
||||
std::ifstream rom_file;
|
||||
|
||||
int result = 0;
|
||||
|
||||
try {
|
||||
rom_file.open(rom_path, std::ios::in | std::ios::binary);
|
||||
if (rom_file.fail())
|
||||
throw std::runtime_error("could not open declaration ROM image " + rom_path);
|
||||
|
||||
// determine image size
|
||||
rom_file.seekg(0, std::ios::end);
|
||||
uint64_t rom_size = rom_file.tellg();
|
||||
|
||||
if (rom_size > 16 * 1024 * 1024)
|
||||
throw std::runtime_error("declaration ROM image " + rom_path + " size " +
|
||||
std::to_string(rom_size) + " is too large");
|
||||
|
||||
// load it
|
||||
auto rom_data = std::unique_ptr<uint8_t[]> (new uint8_t[rom_size]);
|
||||
rom_file.seekg(0, std::ios::beg);
|
||||
rom_file.read((char *)rom_data.get(), rom_size);
|
||||
|
||||
// verify image data
|
||||
uint8_t byte_lane = rom_data[rom_size - 1];
|
||||
if ((byte_lane & 0xF) != ((byte_lane >> 4) ^ 0xF))
|
||||
throw std::runtime_error("declaration ROM image " + rom_path +
|
||||
" has invalid byte lane value");
|
||||
|
||||
if (READ_DWORD_BE_A(&rom_data[rom_size - 6]) != 0x5A932BC7UL)
|
||||
throw std::runtime_error("declaration ROM image " + rom_path +
|
||||
" has invalid test pattern");
|
||||
|
||||
if (rom_data[rom_size - 7] != 1)
|
||||
throw std::runtime_error("declaration ROM image " + rom_path +
|
||||
" has unsupported format");
|
||||
|
||||
uint32_t crc = READ_DWORD_BE_A(&rom_data[rom_size - 12]);
|
||||
int hdr_length = READ_DWORD_BE_A(&rom_data[rom_size - 16]);
|
||||
|
||||
// patch the CRC field of the format header to 0
|
||||
WRITE_DWORD_BE_A(&rom_data[rom_size - 12], 0);
|
||||
|
||||
uint32_t test_crc = calculate_rom_crc(rom_data.get(), hdr_length);
|
||||
|
||||
// restore the CRC field value
|
||||
WRITE_DWORD_BE_A(&rom_data[rom_size - 12], crc);
|
||||
|
||||
if (test_crc != crc) {
|
||||
std::stringstream err;
|
||||
err << "declaration ROM image " + rom_path + " has invalid CRC, expected = 0x"
|
||||
<< std::hex << crc << ", got = 0x" << std::hex << test_crc;
|
||||
throw std::runtime_error(err.str());
|
||||
}
|
||||
|
||||
int lanes_used = 0;
|
||||
|
||||
// count meaningful lanes in a data quad
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (byte_lane & (1 << i))
|
||||
lanes_used++;
|
||||
}
|
||||
|
||||
// padded_len is the size in bytes of all pages needed to contain all the bytes of the ROM
|
||||
uint32_t padded_len =
|
||||
uint32_t(((rom_size * 4 + lanes_used - 1) / lanes_used + 4095) / 4096 * 4096);
|
||||
|
||||
if (padded_len > 16 * 1024 * 1024)
|
||||
throw std::runtime_error("declaration ROM image " + rom_path + " size " +
|
||||
std::to_string(rom_size) + " is too large");
|
||||
|
||||
// calculate starting physical address of the ROM
|
||||
uint32_t rom_phys_start = (0xF0FFFFFFUL | ((slot_num & 0xF) << 24)) - padded_len + 1;
|
||||
|
||||
auto mem_crtl = dynamic_cast<MemCtrlBase*>(gMachineObj->get_comp_by_type(HWCompType::MEM_CTRL));
|
||||
if (!mem_crtl->add_rom_region(rom_phys_start, padded_len))
|
||||
throw std::runtime_error("could not allocate ROM space for declaration ROM image " +
|
||||
rom_path);
|
||||
|
||||
int data_pos = int(rom_size) - 1;
|
||||
|
||||
auto new_data = std::unique_ptr<uint8_t[]> (new uint8_t[padded_len]);
|
||||
|
||||
// prepare new ROM data by copying over used lanes
|
||||
// and padding unused lanes with 0xFF
|
||||
// NOTE: speed uncritical - don't optimize!
|
||||
for (int i = padded_len - 1; i >= 0; ) {
|
||||
for (int b = 8; i>= 0 && b != 0; b >>= 1) {
|
||||
if (data_pos >= 0 && (byte_lane & b))
|
||||
new_data[i--] = rom_data[data_pos--];
|
||||
else
|
||||
new_data[i--] = 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
// move padded ROM data to the memory region
|
||||
mem_crtl->set_data(rom_phys_start, new_data.get(), padded_len);
|
||||
}
|
||||
catch (const std::exception& exc) {
|
||||
LOG_F(ERROR, "load_declaration_rom failed: %s", exc.what());
|
||||
result = -1;
|
||||
}
|
||||
|
||||
rom_file.close();
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NUBUS_UTILS_H
|
||||
#define NUBUS_UTILS_H
|
||||
|
||||
#include <cinttypes>
|
||||
#include <string>
|
||||
|
||||
int load_declaration_rom(const std::string rom_path, int slot_num);
|
||||
|
||||
#endif // NUBUS_UTILS_H
|
||||
@@ -191,7 +191,8 @@ void PCIBase::set_bar_value(int bar_num, uint32_t value)
|
||||
case PCIBarType::Io_32_Bit:
|
||||
this->bars[bar_num] = (value & bar_cfg & ~3) | (bar_cfg & 3);
|
||||
if (value != 0xFFFFFFFFUL && (value & ~3) != (value & bar_cfg & ~3)) {
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->get_name().c_str(), bar_num, (value & ~3), (value & bar_cfg & ~3));
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)",
|
||||
this->get_name().c_str(), bar_num, (value & ~3), (value & bar_cfg & ~3));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -200,7 +201,8 @@ void PCIBase::set_bar_value(int bar_num, uint32_t value)
|
||||
case PCIBarType::Mem_64_Bit_Lo:
|
||||
this->bars[bar_num] = (value & bar_cfg & ~0xF) | (bar_cfg & 0xF);
|
||||
if (value != 0xFFFFFFFFUL && (value & ~0xF) != (value & bar_cfg & ~0xF)) {
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)", this->get_name().c_str(), bar_num, (value & ~0xF), (value & bar_cfg & ~0xF));
|
||||
LOG_F(ERROR, "%s: BAR %d cannot be 0x%08x (set to 0x%08x)",
|
||||
this->get_name().c_str(), bar_num, (value & ~0xF), (value & bar_cfg & ~0xF));
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -47,7 +47,9 @@ enum {
|
||||
PCI_CFG_BAR0 = 0x10, // base address register 0 (type 0, 1, and 2)
|
||||
PCI_CFG_BAR1 = 0x14, // base address register 1 (type 0 and 1)
|
||||
PCI_CFG_DWORD_13 = 0x34, // capabilities pointer (type 0 and 1)
|
||||
PCI_CFG_DWORD_15 = 0x3C, // Max_Lat, Min_Gnt (Type 0); Bridge Control (Type 1 and 2); Int_Pin and Int_Line registers (type 0, 1, and 2)
|
||||
PCI_CFG_DWORD_15 = 0x3C, // Max_Lat, Min_Gnt (Type 0)
|
||||
// Bridge Control (Type 1 and 2)
|
||||
// Int_Pin and Int_Line registers (type 0, 1, and 2)
|
||||
};
|
||||
|
||||
/** PCI Vendor IDs for devices used in Power Macintosh computers. */
|
||||
|
||||
@@ -81,7 +81,8 @@ void PCIHost::pci_unregister_device(int dev_fun_num)
|
||||
HWComponent *hwc = dynamic_cast<HWComponent*>(this);
|
||||
LOG_F(
|
||||
// FIXME: need destructors to remove memory regions and downstream devices.
|
||||
ERROR, "%s: pci_unregister_device(%s) not supported yet (every PCI device needs a working destructor to unregister memory and downstream devices etc.)",
|
||||
ERROR, "%s: pci_unregister_device(%s) not supported yet (every PCI device needs "
|
||||
"a working destructor to unregister memory and downstream devices etc.)",
|
||||
hwc ? hwc->get_name().c_str() : "PCIHost", dev_instance->get_name().c_str()
|
||||
);
|
||||
|
||||
|
||||
@@ -223,7 +223,8 @@ void ScsiHardDisk::inquiry() {
|
||||
|
||||
int lun;
|
||||
if (this->last_selection_has_atention) {
|
||||
LOG_F(INFO, "%s: INQUIRY (%d bytes) with ATN LUN = %02x & 7", this->name.c_str(), alloc_len, this->last_selection_message);
|
||||
LOG_F(INFO, "%s: INQUIRY (%d bytes) with ATN LUN = %02x & 7",
|
||||
this->name.c_str(), alloc_len, this->last_selection_message);
|
||||
lun = this->last_selection_message & 7;
|
||||
}
|
||||
else {
|
||||
@@ -455,14 +456,18 @@ void ScsiHardDisk::read(uint32_t lba, uint16_t transfer_len, uint8_t cmd_len) {
|
||||
return;
|
||||
|
||||
uint32_t transfer_size = transfer_len;
|
||||
|
||||
std::memset(this->data_buf, 0, sizeof(this->data_buf));
|
||||
|
||||
if (cmd_len == 6 && transfer_len == 0) {
|
||||
transfer_size = 256;
|
||||
}
|
||||
|
||||
transfer_size *= this->sector_size;
|
||||
|
||||
size_t data_buf_size = sizeof(this->data_buf);
|
||||
if (transfer_size > data_buf_size) {
|
||||
ABORT_F("%s: cannot read %d bytes (%d sectors * %d bytes/sector), maximum size is %lu bytes",
|
||||
this->name.c_str(), transfer_size, transfer_len, this->sector_size, data_buf_size);
|
||||
}
|
||||
std::memset(this->data_buf, 0, data_buf_size);
|
||||
|
||||
uint64_t device_offset = (uint64_t)lba * this->sector_size;
|
||||
|
||||
this->disk_img.read(this->data_buf, device_offset, transfer_size);
|
||||
@@ -474,12 +479,17 @@ void ScsiHardDisk::read(uint32_t lba, uint16_t transfer_len, uint8_t cmd_len) {
|
||||
|
||||
void ScsiHardDisk::write(uint32_t lba, uint16_t transfer_len, uint8_t cmd_len) {
|
||||
uint32_t transfer_size = transfer_len;
|
||||
|
||||
if (cmd_len == 6 && transfer_len == 0) {
|
||||
transfer_size = 256;
|
||||
}
|
||||
|
||||
transfer_size *= this->sector_size;
|
||||
|
||||
size_t data_buf_size = sizeof(this->data_buf);
|
||||
if (transfer_size > data_buf_size) {
|
||||
ABORT_F("%s: cannot write %d bytes (%d sectors * %d bytes/sector), maximum size is %lu bytes",
|
||||
this->name.c_str(), transfer_size, transfer_len, this->sector_size, data_buf_size);
|
||||
}
|
||||
|
||||
uint64_t device_offset = (uint64_t)lba * this->sector_size;
|
||||
|
||||
this->incoming_size = transfer_size;
|
||||
|
||||
@@ -67,7 +67,8 @@ void MacSuperDrive::command(uint8_t addr, uint8_t value)
|
||||
if (this->cur_track < 0)
|
||||
this->cur_track = 0;
|
||||
else if (this->cur_track >= this->num_tracks) {
|
||||
LOG_F(ERROR, "%s: track:%d is greater than max track:%d", this->get_name().c_str(), this->cur_track, this->num_tracks - 1);
|
||||
LOG_F(ERROR, "%s: track:%d is greater than max track:%d",
|
||||
this->get_name().c_str(), this->cur_track, this->num_tracks - 1);
|
||||
this->cur_track = this->num_tracks - 1;
|
||||
}
|
||||
this->track_zero = this->cur_track == 0;
|
||||
|
||||
@@ -252,7 +252,10 @@ uint32_t GrandCentral::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
case MIO_GC_DMA_AUDIO_OUT:
|
||||
return this->snd_out_dma->reg_read(offset & 0xFF, size);
|
||||
case MIO_GC_DMA_AUDIO_IN:
|
||||
//LOG_F(WARNING, "%s: Unsupported DMA channel DMA_AUDIO_IN read @%02x.%c", this->name.c_str(), offset & 0xFF, SIZE_ARG(size));
|
||||
#if 0
|
||||
LOG_F(WARNING, "%s: Unsupported DMA channel DMA_AUDIO_IN read @%02x.%c",
|
||||
this->name.c_str(), offset & 0xFF, SIZE_ARG(size));
|
||||
#endif
|
||||
return 0; // this->snd_in_dma->reg_read(offset & 0xFF, size);
|
||||
case MIO_GC_DMA_SCSI_MESH:
|
||||
if (this->mesh_dma) {
|
||||
|
||||
@@ -390,8 +390,10 @@ void HeathrowIC::feature_control(const uint32_t value)
|
||||
}
|
||||
}
|
||||
|
||||
#define FIRST_INT1_BIT 12 // The first ten are DMA, the next 2 appear to be unused. We'll map 1:1 the INT1 bits 31..12 (0x1F..0x0C) as IRQ_ID bits.
|
||||
#define FIRST_INT2_BIT 2 // Skip the first two which are Ethernet DMA. We'll map INT2 bits 13..2 (interrupts 45..34 or 0x2D..0x22) as IRQ_ID bits 11..0.
|
||||
#define FIRST_INT1_BIT 12 // The first ten are DMA, the next 2 appear to be unused.
|
||||
// We'll map 1:1 the INT1 bits 31..12 (0x1F..0x0C) as IRQ_ID bits.
|
||||
#define FIRST_INT2_BIT 2 // Skip the first two which are Ethernet DMA.
|
||||
// We'll map INT2 bits 13..2 (interrupts 45..34 or 0x2D..0x22) as IRQ_ID bits 11..0.
|
||||
#define FIRST_INT1_IRQ_ID_BIT 12 // Same as INT1_BIT so there won't be any shifting required.
|
||||
#define FIRST_INT2_IRQ_ID_BIT 0
|
||||
|
||||
@@ -481,7 +483,8 @@ void HeathrowIC::ack_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
IRQ_ID_TO_INT2_MASK(irq_id);
|
||||
#if 0
|
||||
LOG_F(INFO, "%s: native interrupt events:%08x.%08x levels:%08x.%08x change2:%08x state:%d",
|
||||
this->name.c_str(), this->int_events1 + 0, this->int_events2 + 0, this->int_levels1 + 0, this->int_levels2 + 0, irq_id, irq_line_state
|
||||
this->name.c_str(), this->int_events1 + 0, this->int_events2 + 0,
|
||||
this->int_levels1 + 0, this->int_levels2 + 0, irq_id, irq_line_state
|
||||
);
|
||||
#endif
|
||||
// native mode: set IRQ bits in int_events2 on a 0-to-1 transition
|
||||
@@ -504,7 +507,8 @@ void HeathrowIC::ack_int(uint32_t irq_id, uint8_t irq_line_state)
|
||||
// emulated mode: set IRQ bits in int_events1 on all transitions
|
||||
#if 0
|
||||
LOG_F(INFO, "%s: native interrupt events:%08x.%08x levels:%08x.%08x change1:%08x state:%d",
|
||||
this->name.c_str(), this->int_events1 + 0, this->int_events2 + 0, this->int_levels1 + 0, this->int_levels2 + 0, irq_id, irq_line_state);
|
||||
this->name.c_str(), this->int_events1 + 0, this->int_events2 + 0,
|
||||
this->int_levels1 + 0, this->int_levels2 + 0, irq_id, irq_line_state);
|
||||
#endif
|
||||
if ((this->int_mask1 & MACIO_INT_MODE) ||
|
||||
(irq_line_state && !(this->int_levels1 & irq_id))) {
|
||||
|
||||
@@ -394,7 +394,10 @@ bool CharIoSocket::rcv_char_available_now()
|
||||
int received = (int)recv(this->sockfd, &c, 1, 0);
|
||||
if (received == -1) {
|
||||
if (this->acceptfd == -1) {
|
||||
//LOG_F(INFO, "socket sock read (not accepted yet) err: %s", strerror(errno)); // this happens once before accept
|
||||
#if 0
|
||||
LOG_F(INFO, "socket sock read (not accepted yet) err: %s",
|
||||
strerror(errno)); // this happens once before accept
|
||||
#endif
|
||||
}
|
||||
else {
|
||||
LOG_F(INFO, "socket sock read err: %s", strerror(errno)); // should never happen
|
||||
|
||||
@@ -275,7 +275,9 @@ void EsccChannel::write_reg(int reg_num, uint8_t value)
|
||||
this->read_regs[RR0] |= RR0_SYNC_HUNT;
|
||||
}
|
||||
}
|
||||
this->write_regs[WR3] = (this->write_regs[WR3] & (WR3_RX_ENABLE | WR3_ENTER_HUNT_MODE)) | (value & ~(WR3_RX_ENABLE | WR3_ENTER_HUNT_MODE));
|
||||
this->write_regs[WR3] =
|
||||
(this->write_regs[WR3] & (WR3_RX_ENABLE | WR3_ENTER_HUNT_MODE)) |
|
||||
(value & ~(WR3_RX_ENABLE | WR3_ENTER_HUNT_MODE));
|
||||
return;
|
||||
case WR7:
|
||||
if (this->write_regs[WR15] & WR15_SDLC_HDLC_ENHANCEMENT_ENABLE) {
|
||||
|
||||
+11
-6
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
DingusPPC - The Experimental PowerPC Macintosh emulator
|
||||
Copyright (C) 2018-24 divingkatae and maximum
|
||||
Copyright (C) 2018-25 divingkatae and maximum
|
||||
(theweirdo) spatium
|
||||
|
||||
(Contact divingkatae#1017 or powermax#2286 on Discord for more info)
|
||||
@@ -215,7 +215,8 @@ enum
|
||||
WR3_SYNC_CHARACTER_LOAD_INHIBIT = 1 << 1,
|
||||
WR3_RX_ENABLE = 1 << 0,
|
||||
|
||||
// WR4 - Transmit/Receiver Miscellaneous Parameters and Modes // Transmit/Receive miscellaneous parameters and codes, clock rate, number of sync characters, stop bits, parity
|
||||
// WR4 - Transmit/Receiver Miscellaneous Parameters and Modes
|
||||
// Transmit/Receive miscellaneous parameters and codes, clock rate, number of sync characters, stop bits, parity
|
||||
|
||||
WR4_CLOCK_RATE = 3 << 6,
|
||||
WR4_X1_CLOCK_MODE = 0 << 6,
|
||||
@@ -257,7 +258,8 @@ enum
|
||||
|
||||
// WR8 - Transmit buffer
|
||||
|
||||
// WR9 - Master Interrupt Control // Master interrupt control and reset (accessed through either channel), reset bits, control interrupt daisy chain
|
||||
// WR9 - Master Interrupt Control
|
||||
// Master interrupt control and reset (accessed through either channel), reset bits, control interrupt daisy chain
|
||||
|
||||
WR9_RESET_COMMAND_BITS = 3 << 6,
|
||||
WR9_NO_RESET = 0 << 6,
|
||||
@@ -272,7 +274,8 @@ enum
|
||||
WR9_NO_VECTOR = 1 << 1,
|
||||
WR9_VECTOR_INCLUDES_STATUS = 1 << 0,
|
||||
|
||||
// WR10 - Miscellaneous Transmitter/Receiver Control Bits // Miscellaneous transmitter/receiver control bits, NRZI, NRZ, FM encoding, CRC reset
|
||||
// WR10 - Miscellaneous Transmitter/Receiver Control Bits
|
||||
// Miscellaneous transmitter/receiver control bits, NRZI, NRZ, FM encoding, CRC reset
|
||||
|
||||
WR10_CRC_PRESET = 1 << 7,
|
||||
WR10_DATA_ENCODING = 3 << 5,
|
||||
@@ -318,7 +321,8 @@ enum
|
||||
|
||||
// WR13 - Upper Byte of Baud Rate Generator Time Constant
|
||||
|
||||
// WR14 - Miscellaneous Control Bits // Miscellaneous control bits: baud rate generator, Phase-Locked Loop control, auto echo, local loopback
|
||||
// WR14 - Miscellaneous Control Bits
|
||||
// Miscellaneous control bits: baud rate generator, Phase-Locked Loop control, auto echo, local loopback
|
||||
|
||||
WR14_DPLL_COMMAND_BITS = 7 << 5,
|
||||
WR14_DPLL_NULL_COMMAND = 0 << 5,
|
||||
@@ -335,7 +339,8 @@ enum
|
||||
WR14_BR_GENERATOR_SOURCE = 1 << 1,
|
||||
WR14_BR_GENERATOR_ENABLE = 1 << 0,
|
||||
|
||||
// WR15 - External/Status Interrupt Control // External/Status interrupt control information-control external conditions causing interrupts
|
||||
// WR15 - External/Status Interrupt Control
|
||||
// External/Status interrupt control information-control external conditions causing interrupts
|
||||
|
||||
WR15_SDLC_HDLC_ENHANCEMENT_ENABLE = 1 << 0,
|
||||
WR15_ZERO_COUNT_IE = 1 << 1,
|
||||
|
||||
@@ -223,7 +223,8 @@ int SoundServer::start_out_stream()
|
||||
{
|
||||
if (is_deterministic) {
|
||||
LOG_F(9, "Starting sound output deterministic polling.");
|
||||
impl->deterministic_poll_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(10), impl->deterministic_poll_cb);
|
||||
impl->deterministic_poll_timer =
|
||||
TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(10), impl->deterministic_poll_cb);
|
||||
return 0;
|
||||
}
|
||||
return cubeb_stream_start(impl->out_stream);
|
||||
|
||||
@@ -70,7 +70,9 @@ enum RamdacRegs : uint8_t {
|
||||
CURSOR_POS_HI = 0x10, // cursor position, high-order byte
|
||||
CURSOR_POS_LO = 0x11, // cursor position, low-order byte
|
||||
MISC_CTRL = 0x20, // miscellaneus control bits ; Dacula: read ; when 1MB VRAM then write (mode&15) else write (mode)
|
||||
DBL_BUF_CTRL = 0x21, // double buffer control bits ; Dacula: write 4; Radical: set to 0 if using optional bank (bankb) in Open Firmware or for 2nd page in ndrv
|
||||
DBL_BUF_CTRL = 0x21, // double buffer control bits ;
|
||||
// - Dacula: write 4;
|
||||
// - Radical: set to 0 if using optional bank (bankb) in Open Firmware or for 2nd page in ndrv
|
||||
TEST_CTRL = 0x22, // enable/disable DAC tests ; Dacula: write 0
|
||||
|
||||
// multipurpose section registers (DACula only)
|
||||
|
||||
@@ -398,7 +398,8 @@ void ATIRage::write_reg(uint32_t reg_offset, uint32_t value, uint32_t size) {
|
||||
|
||||
|
||||
if (bit_changed(old_value, new_value, ATI_CRTC_ENABLE)
|
||||
|| extract_bits(old_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size) != extract_bits(new_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size)
|
||||
|| extract_bits(old_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size) !=
|
||||
extract_bits(new_value, ATI_CRTC_PIX_WIDTH, ATI_CRTC_PIX_WIDTH_size)
|
||||
) {
|
||||
draw_fb = true;
|
||||
if (bit_set(new_value, ATI_CRTC_ENABLE) &&
|
||||
|
||||
+20
-11
@@ -36,7 +36,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
Kudos to joevt#3510 for his precious technical help and HW hacking.
|
||||
*/
|
||||
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/common/i2c/i2c.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <devices/ioctrl/macio.h>
|
||||
@@ -322,7 +321,8 @@ uint32_t ControlVideo::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
break;
|
||||
case ControlRegs::MON_SENSE:
|
||||
value = (this->cur_mon_id << 6) | this->mon_sense;
|
||||
LOG_F(CONTROL, "%s: read MON_SENSE %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(CONTROL, "%s: read MON_SENSE %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
break;
|
||||
case ControlRegs::MISC_ENABLES:
|
||||
value = this->enables;
|
||||
@@ -349,7 +349,8 @@ uint32_t ControlVideo::read(uint32_t rgn_start, uint32_t offset, int size)
|
||||
details.offset = offset & 3;
|
||||
uint32_t result = pci_conv_rd_data(value, value, details);
|
||||
if ((offset & 3) || (size != 4)) {
|
||||
LOG_F(WARNING, "%s: read %s %03x.%c = %08x -> %0*x", this->name.c_str(), get_name_controlreg(offset), offset, SIZE_ARG(size), value, size * 2, result);
|
||||
LOG_F(WARNING, "%s: read %s %03x.%c = %08x -> %0*x", this->name.c_str(),
|
||||
get_name_controlreg(offset), offset, SIZE_ARG(size), value, size * 2, result);
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -430,9 +431,11 @@ void ControlVideo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
case ControlRegs::PIPE_DELAY:
|
||||
this->swatch_params[(offset >> 4) - ControlRegs::VFPEQ] = value & 0x3FF;
|
||||
if (value & ~0x3FF)
|
||||
LOG_F(ERROR, "%s: write PIPE_DELAY %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(ERROR, "%s: write PIPE_DELAY %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
else
|
||||
LOG_F(CONTROL, "%s: write PIPE_DELAY %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(CONTROL, "%s: write PIPE_DELAY %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
if (this->display_enabled) {
|
||||
this->enable_display();
|
||||
}
|
||||
@@ -440,9 +443,11 @@ void ControlVideo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
case ControlRegs::HEQ:
|
||||
this->swatch_params[(offset >> 4) - ControlRegs::VFPEQ] = value & 0xFFU;
|
||||
if (value & ~0xFFU)
|
||||
LOG_F(ERROR, "%s: write HEQ %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(ERROR, "%s: write HEQ %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
else
|
||||
LOG_F(CONTROL, "%s: write HEQ %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(CONTROL, "%s: write HEQ %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
if (this->display_enabled) {
|
||||
this->enable_display();
|
||||
}
|
||||
@@ -463,9 +468,11 @@ void ControlVideo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
case ControlRegs::HSERR:
|
||||
this->swatch_params[(offset >> 4) - ControlRegs::VFPEQ] = value & 0xFFF;
|
||||
if (value & ~0xFFF)
|
||||
LOG_F(ERROR, "%s: write %s %03x.%c = %0*x", this->name.c_str(), get_name_controlreg(offset), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(ERROR, "%s: write %s %03x.%c = %0*x", this->name.c_str(),
|
||||
get_name_controlreg(offset), offset, SIZE_ARG(size), size * 2, value);
|
||||
else
|
||||
LOG_F(CONTROL, "%s: write %s %03x.%c = %0*x", this->name.c_str(), get_name_controlreg(offset), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(CONTROL, "%s: write %s %03x.%c = %0*x", this->name.c_str(),
|
||||
get_name_controlreg(offset), offset, SIZE_ARG(size), size * 2, value);
|
||||
if (this->display_enabled) {
|
||||
this->enable_display();
|
||||
}
|
||||
@@ -511,9 +518,11 @@ void ControlVideo::write(uint32_t rgn_start, uint32_t offset, uint32_t value, in
|
||||
break;
|
||||
case ControlRegs::MON_SENSE: {
|
||||
if (value & ~0x3F)
|
||||
LOG_F(ERROR, "%s: write MON_SENSE %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(ERROR, "%s: write MON_SENSE %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
else
|
||||
LOG_F(CONTROL, "%s: write MON_SENSE %03x.%c = %0*x", this->name.c_str(), offset, SIZE_ARG(size), size * 2, value);
|
||||
LOG_F(CONTROL, "%s: write MON_SENSE %03x.%c = %0*x", this->name.c_str(),
|
||||
offset, SIZE_ARG(size), size * 2, value);
|
||||
uint8_t dirs = ((value >> 3) & 7) ^ 7;
|
||||
uint8_t levels = ((value & 7) & dirs) | (dirs ^ 7);
|
||||
this->mon_sense = value & 0x3F;
|
||||
|
||||
@@ -24,7 +24,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#ifndef CONTROL_VIDEO_H
|
||||
#define CONTROL_VIDEO_H
|
||||
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/common/clockgen/athens.h>
|
||||
#include <devices/common/pci/pcidevice.h>
|
||||
#include <devices/video/appleramdac.h>
|
||||
#include <devices/video/displayid.h>
|
||||
|
||||
@@ -21,7 +21,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file SAA7187 Digital video encoder emulation. */
|
||||
|
||||
#include <devices/common/i2c/saa7187.h>
|
||||
#include <devices/video/saa7187.h>
|
||||
#include <loguru.hpp>
|
||||
|
||||
Saa7187VideoEncoder::Saa7187VideoEncoder(uint8_t dev_addr)
|
||||
File renamed without changes.
@@ -21,11 +21,11 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
/** @file TNT on-board NTSC/PAL video output emulation. */
|
||||
|
||||
#include <devices/video/sixty6.h>
|
||||
#include <devices/video/control.h>
|
||||
#include <devices/common/i2c/saa7187.h>
|
||||
#include <devices/common/machineid.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <devices/video/control.h>
|
||||
#include <devices/video/sixty6.h>
|
||||
#include <loguru.hpp>
|
||||
#include <machines/machinebase.h>
|
||||
|
||||
namespace loguru {
|
||||
@@ -93,22 +93,26 @@ uint16_t Sixty6Video::iodev_read(uint32_t address)
|
||||
last_control_1_count++;
|
||||
} else {
|
||||
if (last_control_1_count) {
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_1 = %02x x %d", address, last_control_1_value, last_control_1_count);
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_1 = %02x x %d",
|
||||
address, last_control_1_value, last_control_1_count);
|
||||
}
|
||||
last_control_1_value = value;
|
||||
last_control_1_count = 0;
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_1 = %02x x %d", address, last_control_1_value, last_control_1_count);
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_1 = %02x x %d",
|
||||
address, last_control_1_value, last_control_1_count);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
value = 0;
|
||||
LOG_F(ERROR, "Sixty6: read %d:CONTROL_DATA 0x%02x = %02x", address, this->control_addr, value);
|
||||
LOG_F(ERROR, "Sixty6: read %d:CONTROL_DATA 0x%02x = %02x",
|
||||
address, this->control_addr, value);
|
||||
}
|
||||
break;
|
||||
|
||||
case Sixty6BaseReg::CONTROL_ADDR:
|
||||
value = this->control_addr;
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_ADDR = %02x", address, value);
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: read %d:CONTROL_ADDR = %02x",
|
||||
address, value);
|
||||
break;
|
||||
}
|
||||
return value;
|
||||
@@ -412,7 +416,8 @@ int Sixty6Video::device_postinit()
|
||||
this->control_1 |= 0x80;
|
||||
else
|
||||
this->control_1 &= ~0x80;
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: interrupt state:%d doit:%d", irq_line_state, ((this->control_1 & 0x40) && this->crtc_on));
|
||||
LOG_F(SIXTY6_INTERRUPT, "Sixty6: interrupt state:%d doit:%d",
|
||||
irq_line_state, ((this->control_1 & 0x40) && this->crtc_on));
|
||||
|
||||
if (this->interrupt_enabled && this->crtc_on) {
|
||||
//this->pci_interrupt(irq_line_state);
|
||||
|
||||
@@ -25,6 +25,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#define SIXTY6_VIDEO_H
|
||||
|
||||
#include <devices/ioctrl/macio.h>
|
||||
#include <devices/video/saa7187.h>
|
||||
#include <devices/video/videoctrl.h>
|
||||
|
||||
#include <cinttypes>
|
||||
|
||||
@@ -22,7 +22,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
/** @file Taos video controller emulation. */
|
||||
|
||||
#include <core/bitops.h>
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/deviceregistry.h>
|
||||
#include <devices/memctrl/memctrlbase.h>
|
||||
#include <devices/video/taos.h>
|
||||
|
||||
@@ -28,6 +28,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#ifndef TAOS_VIDEO_H
|
||||
#define TAOS_VIDEO_H
|
||||
|
||||
#include <devices/common/clockgen/athens.h>
|
||||
#include <devices/common/i2c/i2c.h>
|
||||
#include <devices/common/mmiodevice.h>
|
||||
#include <devices/video/videoctrl.h>
|
||||
|
||||
@@ -60,7 +60,7 @@ typedef struct {
|
||||
uint32_t ow_expected_checksum;
|
||||
uint32_t nw_product_id;
|
||||
uint32_t nw_subconfig_expected_checksum; // checksum of the system config section but without the firmware version and date
|
||||
const char *id_str; // Bootstrap string located at offset 0x30D064 (PCI Macs) or 0x30C064 (Nubus Macs) to machine name and description.
|
||||
const char *id_str; // Bootstrap string located at offset 0x30D064 (PCI Macs) or 0x30C064 (Nubus Macs)
|
||||
const char *nw_firmware_updater_name;
|
||||
const char *nw_openfirmware_name;
|
||||
const char *dppc_machine;
|
||||
@@ -788,10 +788,13 @@ string MachineFactory::machine_name_from_rom(char *rom_data, size_t rom_size) {
|
||||
(info->nw_product_id && info->nw_product_id == nw_product_id )
|
||||
) {
|
||||
int match_count = 1
|
||||
+ (info->ow_expected_checksum && info->ow_expected_checksum == ow_checksum_stored )
|
||||
+ (info->ow_expected_checksum && info->ow_expected_checksum == ow_checksum_calculated )
|
||||
+ (info->nw_subconfig_expected_checksum && info->nw_subconfig_expected_checksum == nw_subconfig_checksum_calculated )
|
||||
+ (info->id_str && strcmp(rom_id_str, info->id_str) == 0)
|
||||
+ (info->ow_expected_checksum
|
||||
&& info->ow_expected_checksum == ow_checksum_stored)
|
||||
+ (info->ow_expected_checksum
|
||||
&& info->ow_expected_checksum == ow_checksum_calculated)
|
||||
+ (info->nw_subconfig_expected_checksum
|
||||
&& info->nw_subconfig_expected_checksum == nw_subconfig_checksum_calculated)
|
||||
+ (info->id_str && strcmp(rom_id_str, info->id_str) == 0)
|
||||
;
|
||||
|
||||
if (!match_pass) {
|
||||
@@ -870,7 +873,8 @@ string MachineFactory::machine_name_from_rom(char *rom_data, size_t rom_size) {
|
||||
if (firmware_version < 0xffff)
|
||||
LOG_F(INFO, " ROM Version: %x.%03x", (firmware_version >> 12) & 15, firmware_version & 0xfff);
|
||||
else
|
||||
LOG_F(INFO, " ROM Version: %x.%x.%03x", firmware_version >> 16, (firmware_version >> 12) & 15, firmware_version & 0xfff);
|
||||
LOG_F(INFO, " ROM Version: %x.%x.%03x",
|
||||
firmware_version >> 16, (firmware_version >> 12) & 15, firmware_version & 0xfff);
|
||||
if (has_nw_config) {
|
||||
LOG_F(INFO, " Product ID: 0x%04x.%02x 0x%08x = %s%d,%d",
|
||||
nw_product_id >> 8, nw_product_id & 0xff,
|
||||
|
||||
@@ -25,9 +25,9 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <cpu/ppc/ppcemu.h>
|
||||
#include <devices/common/clockgen/athens.h>
|
||||
#include <devices/common/hwcomponent.h>
|
||||
#include <devices/common/i2c/i2c.h>
|
||||
#include <devices/common/i2c/athens.h>
|
||||
#include <devices/common/i2c/i2cprom.h>
|
||||
#include <devices/common/machineid.h>
|
||||
#include <devices/common/scsi/scsihd.h>
|
||||
|
||||
+29
-45
@@ -150,46 +150,30 @@ int initialize_tnt(std::string& id)
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <uint32_t cpu>
|
||||
static const PropMap pm7500_settings = {
|
||||
{"rambank0_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank1_size",
|
||||
new IntProperty(16, std::vector<uint32_t>({ 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank2_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank3_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank4_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank5_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank6_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank7_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank8_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank9_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank10_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank11_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"rambank12_size",
|
||||
new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))},
|
||||
{"emmo",
|
||||
new BinProperty(0)},
|
||||
{"cpu",
|
||||
new StrProperty(
|
||||
cpu == PPC_VER::MPC601 ? "601" :
|
||||
cpu == PPC_VER::MPC604 ? "604" :
|
||||
cpu == PPC_VER::MPC604E ? "604e" :
|
||||
"604e", std::vector<std::string>({"601", "604", "604e", "750"})
|
||||
)
|
||||
},
|
||||
// If this is templated, it hits a compiler bug in MSVC, so use #define instead.
|
||||
#define static_const_pm7500_settings(cpu) \
|
||||
static const PropMap pm7500_settings_ ## cpu = { \
|
||||
{"rambank0_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank1_size" , new IntProperty(16, std::vector<uint32_t>({ 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank2_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank3_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank4_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank5_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank6_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank7_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank8_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank9_size" , new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank10_size", new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank11_size", new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"rambank12_size", new IntProperty( 0, std::vector<uint32_t>({0, 4, 8, 16, 32, 64, 128}))}, \
|
||||
{"emmo", new BinProperty(0)}, \
|
||||
{"cpu", new StrProperty(# cpu, std::vector<std::string>({"601", "604", "604e", "750"}))}, \
|
||||
};
|
||||
|
||||
static_const_pm7500_settings(601)
|
||||
static_const_pm7500_settings(604)
|
||||
static_const_pm7500_settings(604e)
|
||||
|
||||
static std::vector<std::string> pm7500_devices = {
|
||||
"Hammerhead", "Bandit1", "Chaos", "ScsiMesh", "MeshTnt", "GrandCentral",
|
||||
"ControlVideo"
|
||||
@@ -208,7 +192,7 @@ static const MachineDescription pm7300_descriptor = {
|
||||
.name = "pm7300",
|
||||
.description = "Power Macintosh 7300",
|
||||
.devices = pm7500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604E>,
|
||||
.settings = pm7500_settings_604e,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -216,7 +200,7 @@ static const MachineDescription pm7500_descriptor = {
|
||||
.name = "pm7500",
|
||||
.description = "Power Macintosh 7500",
|
||||
.devices = pm7500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC601>,
|
||||
.settings = pm7500_settings_601,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -224,7 +208,7 @@ static const MachineDescription pm8500_descriptor = {
|
||||
.name = "pm8500",
|
||||
.description = "Power Macintosh 8500",
|
||||
.devices = pm8500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604>,
|
||||
.settings = pm7500_settings_604,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -232,7 +216,7 @@ static const MachineDescription pm9500_descriptor = {
|
||||
.name = "pm9500",
|
||||
.description = "Power Macintosh 9500",
|
||||
.devices = pm9500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604>,
|
||||
.settings = pm7500_settings_604,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -240,7 +224,7 @@ static const MachineDescription pm7600_descriptor = {
|
||||
.name = "pm7600",
|
||||
.description = "Power Macintosh 7600",
|
||||
.devices = pm7500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604E>,
|
||||
.settings = pm7500_settings_604e,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -248,7 +232,7 @@ static const MachineDescription pm8600_descriptor = {
|
||||
.name = "pm8600",
|
||||
.description = "Power Macintosh 8600",
|
||||
.devices = pm8500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604E>,
|
||||
.settings = pm7500_settings_604e,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
@@ -256,7 +240,7 @@ static const MachineDescription pm9600_descriptor = {
|
||||
.name = "pm9600",
|
||||
.description = "Power Macintosh 9600",
|
||||
.devices = pm9500_devices,
|
||||
.settings = pm7500_settings<PPC_VER::MPC604E>,
|
||||
.settings = pm7500_settings_604e,
|
||||
.init_func = &initialize_tnt
|
||||
};
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#include <csignal>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <optional>
|
||||
#include <CLI11.hpp>
|
||||
#include <loguru.hpp>
|
||||
|
||||
@@ -60,7 +61,7 @@ static void sigabrt_handler(int signum) {
|
||||
}
|
||||
|
||||
static string appDescription = string(
|
||||
"\nDingusPPC - Alpha 1.01 (10/31/2024) "
|
||||
"\nDingusPPC - Alpha 1.02 (5/10/2025) "
|
||||
"\nWritten by divingkatae, maximumspatium, "
|
||||
"\njoevt, mihaip, kkaisershot, et. al. "
|
||||
"\n(c) 2018-2024 The DingusPPC Dev Team. "
|
||||
@@ -69,6 +70,8 @@ static string appDescription = string(
|
||||
"\n"
|
||||
);
|
||||
|
||||
uint32_t keyboard_id = 0;
|
||||
|
||||
/// Check for an existing directory (returns error message if check fails)
|
||||
class WorkingDirectoryValidator : public CLI::detail::ExistingDirectoryValidator {
|
||||
public:
|
||||
@@ -89,7 +92,10 @@ public:
|
||||
|
||||
const WorkingDirectoryValidator WorkingDirectory;
|
||||
|
||||
void run_machine(std::string machine_str, char *rom_data, size_t rom_size, uint32_t execution_mode, uint32_t profiling_interval_ms);
|
||||
void run_machine(
|
||||
std::string machine_str, char *rom_data, size_t rom_size, uint32_t execution_mode
|
||||
,uint32_t profiling_interval_ms
|
||||
);
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
@@ -99,8 +105,15 @@ int main(int argc, char** argv) {
|
||||
app.allow_windows_style_options(); /* we want Windows-style options */
|
||||
app.allow_extras();
|
||||
|
||||
bool realtime_enabled = false;
|
||||
bool debugger_enabled = false;
|
||||
bool realtime_enabled = false;
|
||||
bool debugger_enabled = false;
|
||||
string keyboard_string = "Eng_USA";
|
||||
|
||||
const std::map<std::string, int> kbd_map{
|
||||
{"Eng_USA", 0}, {"Eng_GBR", 1}, {"Fra_FRA", 10}, {"Deu_DEU", 20},
|
||||
{"Ita_ITA", 30},{"Spa_ESP", 40}, {"Jpn_JPN", 80},
|
||||
};
|
||||
|
||||
string bootrom_path("bootrom.bin");
|
||||
string working_directory_path(".");
|
||||
|
||||
@@ -110,6 +123,7 @@ int main(int argc, char** argv) {
|
||||
"Run the emulator in real-time");
|
||||
execution_mode_group->add_flag("-d,--debugger", debugger_enabled,
|
||||
"Enter the built-in debugger");
|
||||
app.add_option("-k,--keyboard", keyboard_string, "Specify keyboard ID");
|
||||
app.add_option("-w,--workingdir", working_directory_path, "Specifies working directory")
|
||||
->check(WorkingDirectory);
|
||||
app.add_option("-b,--bootrom", bootrom_path, "Specifies BootROM path")
|
||||
@@ -179,7 +193,7 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
auto rom_data = std::unique_ptr<char[]>(new char[4 * 1024 * 1024]);
|
||||
memset(&rom_data[0], 0, 4 * 1024 * 1024);
|
||||
memset(&rom_data[0], 0, static_cast<size_t>(4 * 1024 * 1024));
|
||||
size_t rom_size = MachineFactory::read_boot_rom(bootrom_path, &rom_data[0]);
|
||||
if (!rom_size) {
|
||||
return 1;
|
||||
@@ -258,8 +272,15 @@ int main(int argc, char** argv) {
|
||||
// redirect SIGABRT to our own handler
|
||||
signal(SIGABRT, sigabrt_handler);
|
||||
|
||||
keyboard_id = kbd_map.at(keyboard_string);
|
||||
|
||||
while (true) {
|
||||
run_machine(machine_str, &rom_data[0], rom_size, execution_mode, profiling_interval_ms);
|
||||
run_machine(
|
||||
machine_str,
|
||||
&rom_data[0],
|
||||
rom_size,
|
||||
execution_mode,
|
||||
profiling_interval_ms);
|
||||
if (power_off_reason == po_restarting) {
|
||||
LOG_F(INFO, "Restarting...");
|
||||
power_on = true;
|
||||
@@ -282,10 +303,12 @@ int main(int argc, char** argv) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
void run_machine(std::string machine_str, char *rom_data, size_t rom_size, uint32_t execution_mode,
|
||||
void run_machine(std::string machine_str, char* rom_data,
|
||||
size_t rom_size,
|
||||
uint32_t execution_mode,
|
||||
uint32_t
|
||||
#ifdef CPU_PROFILING
|
||||
profiling_interval_ms
|
||||
profiling_interval_ms
|
||||
#endif
|
||||
) {
|
||||
if (MachineFactory::create_machine_for_id(machine_str, rom_data, rom_size) < 0) {
|
||||
@@ -309,8 +332,8 @@ void run_machine(std::string machine_str, char *rom_data, size_t rom_size, uint3
|
||||
|
||||
// set up system wide event polling using
|
||||
// default Macintosh polling rate of 11 ms
|
||||
uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [] {
|
||||
EventManager::get_instance()->poll_events();
|
||||
uint32_t event_timer = TimerManager::get_instance()->add_cyclic_timer(MSECS_TO_NSECS(11), [] {
|
||||
EventManager::get_instance()->poll_events(keyboard_id);
|
||||
});
|
||||
|
||||
#ifdef CPU_PROFILING
|
||||
|
||||
+4
-4
@@ -56,7 +56,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
((((uint8_t*)(addr))[0] << 24) | (((uint8_t*)(addr))[1] << 16) | \
|
||||
(((uint8_t*)(addr))[2] << 8) | ((uint8_t*)(addr))[3] )
|
||||
|
||||
/* read an unaligned big-endian QWORD (32bit) */
|
||||
/* read an unaligned big-endian QWORD (64bit) */
|
||||
#define READ_QWORD_BE_U(addr) \
|
||||
((uint64_t(((uint8_t*)(addr))[0]) << 56) | (uint64_t(((uint8_t*)(addr))[1]) << 48) | \
|
||||
(uint64_t(((uint8_t*)(addr))[2]) << 40) | (uint64_t(((uint8_t*)(addr))[3]) << 32) | \
|
||||
@@ -71,7 +71,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
((((uint8_t*)(addr))[3] << 24) | (((uint8_t*)(addr))[2] << 16) | \
|
||||
(((uint8_t*)(addr))[1] << 8) | ((uint8_t*)(addr))[0] )
|
||||
|
||||
/* read an unaligned little-endian DWORD (64bit) */
|
||||
/* read an unaligned little-endian QWORD (64bit) */
|
||||
#define READ_QWORD_LE_U(addr) \
|
||||
((uint64_t(((uint8_t*)(addr))[7]) << 56) | (uint64_t(((uint8_t*)(addr))[6]) << 48) | \
|
||||
(uint64_t(((uint8_t*)(addr))[5]) << 40) | (uint64_t(((uint8_t*)(addr))[4]) << 32) | \
|
||||
@@ -103,7 +103,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
((uint8_t*)(addr))[3] = (uint8_t)(val); \
|
||||
} while (0)
|
||||
|
||||
/* write an unaligned big-endian DWORD (64bit) */
|
||||
/* write an unaligned big-endian QWORD (64bit) */
|
||||
#define WRITE_QWORD_BE_U(addr, val) \
|
||||
do { \
|
||||
((uint8_t*)(addr))[0] = ((uint64_t)(val) >> 56); \
|
||||
@@ -141,7 +141,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
((uint8_t*)(addr))[3] = ((val) >> 24); \
|
||||
} while (0)
|
||||
|
||||
/* write an unaligned little-endian DWORD (64bit) */
|
||||
/* write an unaligned little-endian QWORD (64bit) */
|
||||
#define WRITE_QWORD_LE_U(addr, val) \
|
||||
do { \
|
||||
((uint8_t*)(addr))[0] = (uint8_t)(val) ; \
|
||||
|
||||
Reference in new issue
Block a user