Compare commits

..
Author SHA1 Message Date
dingusdev f511005461 More attempted fixes 2024-10-04 19:49:39 -07:00
dingusdev f5e2d3be48 Fix-ups 2024-10-04 19:49:05 -07:00
dingusdev 0f6c32245b First attempt at splitting decoding and execution 2024-10-04 19:47:48 -07:00
27 changed files with 1169 additions and 2090 deletions

No files matched your search

-1
View File
@@ -7,7 +7,6 @@
- maximumspatium
- joevt
- mihaip
- kkaisershot
## NT4/PPC fork
+1 -1
View File
@@ -42,7 +42,7 @@ uint32_t cs_code[] = {
0x80C30008, 0x7CA50114, 0x80E3000C, 0x7CA53114, 0x85030010, 0x7CA53914,
0x4200FFE0, 0x7CA54114, 0x70800002, 0x41E20010, 0xA0030004, 0x38630002,
0x7CA50114, 0x70800001, 0x41E20010, 0x88030004, 0x5400402E, 0x7CA50114,
0x7C650194, /* 0x4E800020 */ 0x00005AF0
0x7C650194, 0x4E800020
};
constexpr uint32_t test_size = 0x8000; // 0x7FFFFFFC is the max
-38
View File
@@ -40,8 +40,6 @@ enum : uint32_t {
MOUSE_EVENT_BUTTON = 1 << 1,
KEYBOARD_EVENT_DOWN = 1 << 0,
KEYBOARD_EVENT_UP = 1 << 1,
GAMEPAD_EVENT_DOWN = 1 << 0,
GAMEPAD_EVENT_UP = 1 << 1,
};
class MouseEvent {
@@ -67,36 +65,6 @@ public:
uint16_t keys_state;
};
/* AppleJack bits 3-7 are supported but unused */
enum GamepadButton : uint8_t {
Red = 14,
Green = 15,
Yellow = 9,
Blue = 8,
FrontLeft = 0,
FrontMiddle = 1,
FrontRight = 2,
LeftTrigger = 17,
RightTrigger = 16,
Up = 10,
Down = 13,
Left = 11,
Right = 12,
};
class GamepadEvent {
public:
GamepadEvent() = default;
~GamepadEvent() = default;
uint32_t gamepad_id;
uint32_t flags;
uint8_t button;
};
class EventManager {
public:
static EventManager* get_instance() {
@@ -123,11 +91,6 @@ public:
_keyboard_signal.connect_method(inst, func);
}
template <typename T>
void add_gamepad_handler(T* inst, void (T::*func)(const GamepadEvent&)) {
_gamepad_signal.connect_method(inst, func);
}
template <typename T>
void add_post_handler(T *inst, void (T::*func)()) {
_post_signal.connect_method(inst, func);
@@ -147,7 +110,6 @@ private:
CoreSignal<const WindowEvent&> _window_signal;
CoreSignal<const MouseEvent&> _mouse_signal;
CoreSignal<const KeyboardEvent&> _keyboard_signal;
CoreSignal<const GamepadEvent&> _gamepad_signal;
CoreSignal<> _post_signal;
uint64_t events_captured = 0;
-46
View File
@@ -130,52 +130,6 @@ void EventManager::poll_events()
}
break;
case SDL_CONTROLLERBUTTONDOWN: {
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;
case SDL_CONTROLLER_BUTTON_START: ge.button = GamepadButton::FrontRight; break;
case SDL_CONTROLLER_BUTTON_Y: ge.button = GamepadButton::Blue; break;
case SDL_CONTROLLER_BUTTON_X: ge.button = GamepadButton::Yellow; break;
case SDL_CONTROLLER_BUTTON_DPAD_UP: ge.button = GamepadButton::Up; break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: ge.button = GamepadButton::Left; break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: ge.button = GamepadButton::Right; break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: ge.button = GamepadButton::Down; break;
case SDL_CONTROLLER_BUTTON_A: ge.button = GamepadButton::Red; break;
case SDL_CONTROLLER_BUTTON_B: ge.button = GamepadButton::Green; break;
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: ge.button = GamepadButton::RightTrigger; break;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: ge.button = GamepadButton::LeftTrigger; break;
}
ge.gamepad_id = event.cbutton.which;
ge.flags = GAMEPAD_EVENT_DOWN;
this->_gamepad_signal.emit(ge);
}
break;
case SDL_CONTROLLERBUTTONUP: {
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;
case SDL_CONTROLLER_BUTTON_START: ge.button = GamepadButton::FrontRight; break;
case SDL_CONTROLLER_BUTTON_Y: ge.button = GamepadButton::Blue; break;
case SDL_CONTROLLER_BUTTON_X: ge.button = GamepadButton::Yellow; break;
case SDL_CONTROLLER_BUTTON_DPAD_UP: ge.button = GamepadButton::Up; break;
case SDL_CONTROLLER_BUTTON_DPAD_LEFT: ge.button = GamepadButton::Left; break;
case SDL_CONTROLLER_BUTTON_DPAD_RIGHT: ge.button = GamepadButton::Right; break;
case SDL_CONTROLLER_BUTTON_DPAD_DOWN: ge.button = GamepadButton::Down; break;
case SDL_CONTROLLER_BUTTON_A: ge.button = GamepadButton::Red; break;
case SDL_CONTROLLER_BUTTON_B: ge.button = GamepadButton::Green; break;
case SDL_CONTROLLER_BUTTON_RIGHTSHOULDER: ge.button = GamepadButton::RightTrigger; break;
case SDL_CONTROLLER_BUTTON_LEFTSHOULDER: ge.button = GamepadButton::LeftTrigger; break;
}
ge.gamepad_id = event.cbutton.which;
ge.flags = GAMEPAD_EVENT_UP;
this->_gamepad_signal.emit(ge);
}
break;
default:
unhandled_events++;
}
+151 -182
View File
@@ -37,13 +37,12 @@ static inline uint32_t power_rot_mask(unsigned rot_mb, unsigned rot_me) {
template <field_rc rec, field_ov ov>
void dppc_interpreter::power_abs() {
uint32_t ppc_result_d;
ppc_grab_regsda(ppc_cur_instruction);
if (ppc_result_a == 0x80000000) {
ppc_result_d = ppc_result_a;
if (ppc_state.gpr[instr.arg1] == 0x80000000) {
ppc_result_d = ppc_state.gpr[instr.arg1];
if (ov)
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
} else {
ppc_result_d = (int32_t(ppc_result_a) < 0) ? -ppc_result_a : ppc_result_a;
ppc_result_d = (int32_t(ppc_state.gpr[instr.arg1]) < 0) ? -ppc_state.gpr[instr.arg1] : ppc_state.gpr[instr.arg1];
if (ov)
ppc_state.spr[SPR::XER] &= ~XER::OV;
}
@@ -51,7 +50,7 @@ void dppc_interpreter::power_abs() {
if (rec)
ppc_changecrf0(ppc_result_d);
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
}
template void dppc_interpreter::power_abs<RC0, OV0>();
@@ -60,36 +59,39 @@ template void dppc_interpreter::power_abs<RC1, OV0>();
template void dppc_interpreter::power_abs<RC1, OV1>();
void dppc_interpreter::power_clcs() {
uint32_t ppc_result_d;
ppc_grab_da(ppc_cur_instruction);
switch (reg_a) {
switch (ppc_state.gpr[instr.arg1]) {
case 12: //instruction cache line size
case 13: //data cache line size
case 14: //minimum line size
case 15: //maximum line size
default: ppc_result_d = is_601 ? 64 : 32; break;
default:
ppc_state.gpr[instr.arg0] = is_601 ? 64 : 32;
break;
case 7:
case 23: ppc_result_d = is_601 ? 64 : 0; break;
case 23:
ppc_state.gpr[instr.arg0] = is_601 ? 64 : 0;
break;
case 8:
case 9:
case 24:
case 25: ppc_result_d = is_601 ? 64 : 4; break;
case 25:
ppc_state.gpr[instr.arg0] = is_601 ? 64 : 4;
break;
case 10:
case 11:
case 26:
case 27: ppc_result_d = is_601 ? 64 : 0x4000; break;
case 27:
ppc_state.gpr[instr.arg0] = is_601 ? 64 : 0x4000;
break;
}
ppc_store_iresult_reg(reg_d, ppc_result_d);
}
template <field_rc rec, field_ov ov>
void dppc_interpreter::power_div() {
uint32_t ppc_result_d;
ppc_grab_regsdab(ppc_cur_instruction);
int64_t dividend = (uint64_t(ppc_result_a) << 32) | ppc_state.spr[SPR::MQ];
int32_t divisor = ppc_result_b;
int64_t dividend = (uint64_t(ppc_state.gpr[instr.arg1]) << 32) | ppc_state.spr[SPR::MQ];
int32_t divisor = ppc_state.gpr[instr.arg2];
int64_t quotient;
int32_t remainder;
@@ -119,7 +121,7 @@ void dppc_interpreter::power_div() {
if (rec)
ppc_changecrf0(remainder);
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
ppc_state.spr[SPR::MQ] = remainder;
}
@@ -132,28 +134,27 @@ template <field_rc rec, field_ov ov>
void dppc_interpreter::power_divs() {
uint32_t ppc_result_d;
int32_t remainder;
ppc_grab_regsdab(ppc_cur_instruction);
if (!ppc_result_b) { // handle the "anything / 0" case
if (!ppc_state.gpr[instr.arg2]) { // handle the "anything / 0" case
ppc_result_d = -1;
remainder = ppc_result_a;
remainder = ppc_state.gpr[instr.arg1];
if (ov)
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
} else if (ppc_result_a == 0x80000000U && ppc_result_b == 0xFFFFFFFFU) {
} else if (ppc_state.gpr[instr.arg1] == 0x80000000U && ppc_state.gpr[instr.arg2] == 0xFFFFFFFFU) {
ppc_result_d = 0x80000000U;
remainder = 0;
if (ov)
ppc_state.spr[SPR::XER] |= XER::SO | XER::OV;
} else { // normal signed devision
ppc_result_d = int32_t(ppc_result_a) / int32_t(ppc_result_b);
remainder = (int32_t(ppc_result_a) % int32_t(ppc_result_b));
ppc_result_d = int32_t(ppc_state.gpr[instr.arg1]) / int32_t(ppc_state.gpr[instr.arg2]);
remainder = (int32_t(ppc_state.gpr[instr.arg1]) % int32_t(ppc_state.gpr[instr.arg2]));
if (ov)
ppc_state.spr[SPR::XER] &= ~XER::OV;
}
if (rec)
ppc_changecrf0(remainder);
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
ppc_state.spr[SPR::MQ] = remainder;
}
@@ -164,9 +165,8 @@ template void dppc_interpreter::power_divs<RC1, OV1>();
template <field_rc rec, field_ov ov>
void dppc_interpreter::power_doz() {
ppc_grab_regsdab(ppc_cur_instruction);
uint32_t ppc_result_d = (int32_t(ppc_result_a) < int32_t(ppc_result_b)) ?
ppc_result_b - ppc_result_a : 0;
uint32_t ppc_result_d = (int32_t(ppc_state.gpr[instr.arg1]) < int32_t(ppc_state.gpr[instr.arg2])) ?
ppc_state.gpr[instr.arg2] - ppc_state.gpr[instr.arg1] : 0;
if (ov) {
if (int32_t(ppc_result_d) < 0) {
@@ -178,7 +178,7 @@ void dppc_interpreter::power_doz() {
if (rec)
ppc_changecrf0(ppc_result_d);
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
}
template void dppc_interpreter::power_doz<RC0, OV0>();
@@ -188,19 +188,17 @@ template void dppc_interpreter::power_doz<RC1, OV1>();
void dppc_interpreter::power_dozi() {
uint32_t ppc_result_d;
ppc_grab_regsdasimm(ppc_cur_instruction);
if (((int32_t)ppc_result_a) > simm) {
if (((int32_t)ppc_state.gpr[instr.arg1]) > instr.i_simm) {
ppc_result_d = 0;
} else {
ppc_result_d = simm - ppc_result_a;
ppc_result_d = instr.i_simm - ppc_state.gpr[instr.arg1];
}
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
}
template <field_rc rec>
void dppc_interpreter::power_lscbx() {
ppc_grab_regsdab(ppc_cur_instruction);
uint32_t ea = ppc_result_b + (reg_a ? ppc_result_a : 0);
uint32_t ea = ppc_state.gpr[instr.arg2] + (instr.arg1 ? ppc_state.gpr[instr.arg1] : 0);
uint32_t bytes_to_load = (ppc_state.spr[SPR::XER] & 0x7F);
uint32_t bytes_remaining = bytes_to_load;
@@ -216,9 +214,9 @@ void dppc_interpreter::power_lscbx() {
ppc_result_d |= return_value << shift_amount;
if (!shift_amount) {
if (reg_d != reg_a && reg_d != reg_b)
ppc_store_iresult_reg(reg_d, ppc_result_d);
reg_d = (reg_d + 1) & 0x1F;
if (instr.arg0 != instr.arg1 && instr.arg0 != instr.arg2)
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
instr.arg0 = (instr.arg0 + 1) & 0x1F;
ppc_result_d = 0;
shift_amount = 24;
} else {
@@ -235,8 +233,8 @@ void dppc_interpreter::power_lscbx() {
}
// store partially loaded register if any
if (shift_amount != 24 && reg_d != reg_a && reg_d != reg_b)
ppc_store_iresult_reg(reg_d, ppc_result_d);
if (shift_amount != 24 && instr.arg0 != instr.arg1 && instr.arg0 != instr.arg2)
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
ppc_state.spr[SPR::XER] = (ppc_state.spr[SPR::XER] & ~0x7F) | (bytes_to_load - bytes_remaining);
@@ -253,9 +251,8 @@ template void dppc_interpreter::power_lscbx<RC1>();
template <field_rc rec>
void dppc_interpreter::power_maskg() {
ppc_grab_regssab(ppc_cur_instruction);
uint32_t mask_start = ppc_result_d & 0x1F;
uint32_t mask_end = ppc_result_b & 0x1F;
uint32_t mask_start = ppc_state.gpr[instr.arg0] & 0x1F;
uint32_t mask_end = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t insert_mask = 0;
if (mask_start < (mask_end + 1)) {
@@ -268,12 +265,12 @@ void dppc_interpreter::power_maskg() {
insert_mask = ~(power_rot_mask(mask_end + 1, mask_start - 1));
}
ppc_result_a = insert_mask;
ppc_state.gpr[instr.arg1] = insert_mask;
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_maskg<RC0>();
@@ -281,13 +278,11 @@ template void dppc_interpreter::power_maskg<RC1>();
template <field_rc rec>
void dppc_interpreter::power_maskir() {
ppc_grab_regssab(ppc_cur_instruction);
ppc_result_a = (ppc_result_a & ~ppc_result_b) | (ppc_result_d & ppc_result_b);
ppc_state.gpr[instr.arg1] = ((ppc_state.gpr[instr.arg1] & ~ppc_state.gpr[instr.arg2]) | \
(ppc_state.gpr[instr.arg0] & ppc_state.gpr[instr.arg2]));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_maskir<RC0>();
@@ -295,8 +290,7 @@ template void dppc_interpreter::power_maskir<RC1>();
template <field_rc rec, field_ov ov>
void dppc_interpreter::power_mul() {
ppc_grab_regsdab(ppc_cur_instruction);
int64_t product = int64_t(int32_t(ppc_result_a)) * int32_t(ppc_result_b);
int64_t product = int64_t(int32_t(ppc_state.gpr[instr.arg1])) * int32_t(ppc_state.gpr[instr.arg2]);
uint32_t ppc_result_d = uint32_t(uint64_t(product) >> 32);
ppc_state.spr[SPR::MQ] = uint32_t(product);
@@ -309,7 +303,7 @@ void dppc_interpreter::power_mul() {
}
if (rec)
ppc_changecrf0(uint32_t(product));
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
}
template void dppc_interpreter::power_mul<RC0, OV0>();
@@ -319,15 +313,14 @@ template void dppc_interpreter::power_mul<RC1, OV1>();
template <field_rc rec, field_ov ov>
void dppc_interpreter::power_nabs() {
ppc_grab_regsda(ppc_cur_instruction);
uint32_t ppc_result_d = (int32_t(ppc_result_a) < 0) ? ppc_result_a : -ppc_result_a;
uint32_t ppc_result_d = (int32_t(ppc_state.gpr[instr.arg1]) < 0) ? ppc_state.gpr[instr.arg1] : -ppc_state.gpr[instr.arg1];
if (ov)
ppc_state.spr[SPR::XER] &= ~XER::OV;
if (rec)
ppc_changecrf0(ppc_result_d);
ppc_store_iresult_reg(reg_d, ppc_result_d);
ppc_store_iresult_reg(instr.arg0, ppc_result_d);
}
template void dppc_interpreter::power_nabs<RC0, OV0>();
@@ -336,37 +329,32 @@ template void dppc_interpreter::power_nabs<RC1, OV0>();
template void dppc_interpreter::power_nabs<RC1, OV1>();
void dppc_interpreter::power_rlmi() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_mb = (ppc_cur_instruction >> 6) & 0x1F;
unsigned rot_me = (ppc_cur_instruction >> 1) & 0x1F;
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
uint32_t mask = power_rot_mask(rot_mb, rot_me);
uint32_t r =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
uint32_t mask = power_rot_mask(instr.arg3, instr.arg4);
ppc_result_a = ((r & mask) | (ppc_result_a & ~mask));
uint32_t ppc_result_a = ((r & mask) | (ppc_state.gpr[instr.arg1] & ~mask));
if ((ppc_cur_instruction & 0x01) == 1)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_result_a);
}
template <field_rc rec>
void dppc_interpreter::power_rrib() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
if (int32_t(ppc_result_d) < 0) {
ppc_result_a |= (0x80000000U >> rot_sh);
if (int32_t(ppc_state.gpr[instr.arg1]) < 0) {
ppc_state.gpr[instr.arg1] |= (0x80000000U >> rot_sh);
} else {
ppc_result_a &= ~(0x80000000U >> rot_sh);
ppc_state.gpr[instr.arg1] &= ~(0x80000000U >> rot_sh);
}
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_rrib<RC0>();
@@ -374,18 +362,18 @@ template void dppc_interpreter::power_rrib<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sle() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
ppc_result_a = ppc_result_d << rot_sh;
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] << rot_sh;
ppc_state.spr[SPR::MQ] =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_state.gpr[instr.arg1]);
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sle<RC0>();
@@ -393,18 +381,16 @@ template void dppc_interpreter::power_sle<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sleq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t r =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.spr[SPR::MQ] = r;
ppc_state.gpr[instr.arg1] = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.spr[SPR::MQ] = r;
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sleq<RC0>();
@@ -412,15 +398,16 @@ template void dppc_interpreter::power_sleq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sliq() {
ppc_grab_regssash(ppc_cur_instruction);
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
ppc_result_a = ppc_result_d << rot_sh;
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] << rot_sh;
ppc_state.spr[SPR::MQ] =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sliq<RC0>();
@@ -428,17 +415,17 @@ template void dppc_interpreter::power_sliq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_slliq() {
ppc_grab_regssash(ppc_cur_instruction);
uint32_t r = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t r =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
uint32_t mask = power_rot_mask(0, 31 - rot_sh);
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.spr[SPR::MQ] = r;
ppc_state.gpr[instr.arg1] = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.spr[SPR::MQ] = r;
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_slliq<RC0>();
@@ -446,19 +433,17 @@ template void dppc_interpreter::power_slliq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sllq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
if (ppc_result_b & 0x20) {
ppc_result_a = ppc_state.spr[SPR::MQ] & (-1U << rot_sh);
if (ppc_state.gpr[instr.arg2] & 0x20) {
ppc_state.gpr[instr.arg1] = ppc_state.spr[SPR::MQ] & (-1U << rot_sh);
} else {
ppc_result_a = ((ppc_result_d << rot_sh) | (ppc_state.spr[SPR::MQ] & ((1 << rot_sh) - 1)));
ppc_state.gpr[instr.arg1] =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.spr[SPR::MQ] & ((1 << rot_sh) - 1)));
}
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sllq<RC0>();
@@ -466,20 +451,19 @@ template void dppc_interpreter::power_sllq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_slq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
if (ppc_result_b & 0x20) {
ppc_result_a = 0;
if (ppc_state.gpr[instr.arg2] & 0x20) {
ppc_state.gpr[instr.arg1] = 0;
} else {
ppc_result_a = ppc_result_d << rot_sh;
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] << rot_sh;
}
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_state.spr[SPR::MQ] =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
}
template void dppc_interpreter::power_slq<RC0>();
@@ -487,12 +471,12 @@ template void dppc_interpreter::power_slq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sraiq() {
ppc_grab_regssash(ppc_cur_instruction);
uint32_t mask = (1 << rot_sh) - 1;
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
uint32_t mask = (1 << instr.arg2) - 1;
uint32_t ppc_result_a = (int32_t)ppc_state.gpr[instr.arg0] >> instr.arg2;
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> instr.arg2) |
(ppc_state.gpr[instr.arg0] << (32 - instr.arg2));
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
if ((int32_t(ppc_state.gpr[instr.arg1]) < 0) && (ppc_state.gpr[instr.arg1] & mask)) {
ppc_state.spr[SPR::XER] |= XER::CA;
} else {
ppc_state.spr[SPR::XER] &= ~XER::CA;
@@ -501,7 +485,7 @@ void dppc_interpreter::power_sraiq() {
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_result_a);
}
template void dppc_interpreter::power_sraiq<RC0>();
@@ -509,24 +493,24 @@ template void dppc_interpreter::power_sraiq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sraq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
uint32_t mask = (ppc_result_b & 0x20) ? -1 : (1 << rot_sh) - 1;
ppc_result_a = (int32_t)ppc_result_d >> ((ppc_result_b & 0x20) ? 31 : rot_sh);
ppc_state.spr[SPR::MQ] = ((ppc_result_d << rot_sh) | (ppc_result_d >> (32 - rot_sh)));
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t mask = (ppc_state.gpr[instr.arg2] & 0x20) ? -1 : (1 << rot_sh) - 1;
ppc_state.gpr[instr.arg1] = (int32_t)ppc_state.gpr[instr.arg0] >>
((ppc_state.gpr[instr.arg2] & 0x20) ? 31 : rot_sh);
ppc_state.spr[SPR::MQ] =
((ppc_state.gpr[instr.arg0] << rot_sh) | (ppc_state.gpr[instr.arg0] >> (32 - rot_sh)));
if ((int32_t(ppc_result_d) < 0) && (ppc_result_d & mask)) {
if ((int32_t(ppc_state.gpr[instr.arg0]) < 0) && (ppc_state.gpr[instr.arg0] & mask)) {
ppc_state.spr[SPR::XER] |= XER::CA;
} else {
ppc_state.spr[SPR::XER] &= ~XER::CA;
}
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> rot_sh) |
(ppc_state.gpr[instr.arg0] << (32 - rot_sh));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sraq<RC0>();
@@ -534,17 +518,14 @@ template void dppc_interpreter::power_sraq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sre() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] >> rot_sh;
unsigned rot_sh = ppc_result_b & 0x1F;
ppc_result_a = ppc_result_d >> rot_sh;
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> rot_sh) |
(ppc_state.gpr[instr.arg0] << (32 - rot_sh));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sre<RC0>();
@@ -552,13 +533,12 @@ template void dppc_interpreter::power_sre<RC1>();
template <field_rc rec>
void dppc_interpreter::power_srea() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
ppc_result_a = (int32_t)ppc_result_d >> rot_sh;
uint32_t r = ((ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh)));
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t ppc_result_a = (int32_t)ppc_state.gpr[instr.arg0] >> rot_sh;
uint32_t r = ((ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh)));
uint32_t mask = -1U >> rot_sh;
if ((int32_t(ppc_result_d) < 0) && (r & ~mask)) {
if ((int32_t(ppc_state.gpr[instr.arg0]) < 0) && (r & ~mask)) {
ppc_state.spr[SPR::XER] |= XER::CA;
} else {
ppc_state.spr[SPR::XER] &= ~XER::CA;
@@ -567,7 +547,7 @@ void dppc_interpreter::power_srea() {
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_result_a);
ppc_state.spr[SPR::MQ] = r;
}
@@ -576,17 +556,16 @@ template void dppc_interpreter::power_srea<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sreq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t mask = -1U >> rot_sh;
ppc_result_a = (ppc_result_d >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
uint32_t ppc_result_a = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.spr[SPR::MQ] & ~mask);
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_store_iresult_reg(instr.arg1, ppc_result_a);
}
template void dppc_interpreter::power_sreq<RC0>();
@@ -594,14 +573,12 @@ template void dppc_interpreter::power_sreq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_sriq() {
ppc_grab_regssash(ppc_cur_instruction);
ppc_result_a = ppc_result_d >> rot_sh;
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
uint32_t rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] >> rot_sh;
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_sriq<RC0>();
@@ -609,17 +586,15 @@ template void dppc_interpreter::power_sriq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_srliq() {
ppc_grab_regssash(ppc_cur_instruction);
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
unsigned mask = power_rot_mask(rot_sh, 31);
uint32_t rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t r = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh));
unsigned mask = power_rot_mask(ppc_state.gpr[instr.arg2], 31);
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.gpr[instr.arg1] = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.spr[SPR::MQ] = r;
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_srliq<RC0>();
@@ -627,21 +602,18 @@ template void dppc_interpreter::power_srliq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_srlq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
uint32_t r = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
uint32_t r = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh));
unsigned mask = power_rot_mask(rot_sh, 31);
if (ppc_result_b & 0x20) {
ppc_result_a = (ppc_state.spr[SPR::MQ] & mask);
if (ppc_state.gpr[instr.arg2] & 0x20) {
ppc_state.gpr[instr.arg1] = (ppc_state.spr[SPR::MQ] & mask);
} else {
ppc_result_a = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
ppc_state.gpr[instr.arg1] = ((r & mask) | (ppc_state.spr[SPR::MQ] & ~mask));
}
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_srlq<RC0>();
@@ -649,21 +621,18 @@ template void dppc_interpreter::power_srlq<RC1>();
template <field_rc rec>
void dppc_interpreter::power_srq() {
ppc_grab_regssab(ppc_cur_instruction);
unsigned rot_sh = ppc_result_b & 0x1F;
unsigned rot_sh = ppc_state.gpr[instr.arg2] & 0x1F;
if (ppc_result_b & 0x20) {
ppc_result_a = 0;
if (ppc_state.gpr[instr.arg2] & 0x20) {
ppc_state.gpr[instr.arg1] = 0;
} else {
ppc_result_a = ppc_result_d >> rot_sh;
ppc_state.gpr[instr.arg1] = ppc_state.gpr[instr.arg0] >> rot_sh;
}
ppc_state.spr[SPR::MQ] = (ppc_result_d >> rot_sh) | (ppc_result_d << (32 - rot_sh));
ppc_state.spr[SPR::MQ] = (ppc_state.gpr[instr.arg0] >> rot_sh) | (ppc_state.gpr[instr.arg0] << (32 - rot_sh));
if (rec)
ppc_changecrf0(ppc_result_a);
ppc_store_iresult_reg(reg_a, ppc_result_a);
ppc_changecrf0(ppc_state.gpr[instr.arg1]);
}
template void dppc_interpreter::power_srq<RC0>();
+21 -9
View File
@@ -68,6 +68,25 @@ fpscr = FP Status and Condition Register
sr = Segment Register
**/
typedef struct struct_ppc_instr {
uint8_t arg0;
uint8_t arg1;
uint8_t arg2;
uint8_t arg3;
uint8_t arg4;
int32_t addr;
int32_t mask;
uint8_t main_op;
uint16_t sub_op;
union {
int32_t i_simm;
uint32_t i_uimm;
};
} SetInstr;
extern SetInstr instr;
typedef struct struct_ppc_state {
FPR_storage fpr[32];
uint32_t pc; // Referred as the CIA in the PPC manual
@@ -406,14 +425,8 @@ void ppc_fpu_off();
void ppc_assert_int();
void ppc_release_int();
//void ppc_opcode4();
void ppc_opcode16();
void ppc_opcode18();
template <field_601 for601> void ppc_opcode19();
void ppc_opcode31();
void ppc_opcode59();
void ppc_opcode63();
void decode_instr();
void exec_instr();
void initialize_ppc_opcode_tables(bool include_601);
extern double fp_return_double(uint32_t reg);
@@ -645,7 +658,6 @@ template <field_rc rec> extern void power_srq();
extern uint64_t get_virt_time_ns(void);
extern void ppc_main_opcode(void);
extern void ppc_exec(void);
extern void ppc_exec_single(void);
extern void ppc_exec_until(uint32_t goal_addr);
+243 -49
View File
@@ -22,6 +22,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <core/timermanager.h>
#include <loguru.hpp>
#include "ppcemu.h"
#include "ppcmacros.h"
#include "ppcmmu.h"
#include "ppcdisasm.h"
@@ -55,13 +56,14 @@ using namespace dppc_interpreter;
MemCtrlBase* mem_ctrl_instance = 0;
SetPRS ppc_state;
SetInstr instr;
bool is_601 = false;
bool power_on = false;
Po_Cause power_off_reason = po_enter_debugger;
SetPRS ppc_state;
uint32_t ppc_cur_instruction; // Current instruction for the PPC
uint32_t ppc_next_instruction_address; // Used for branching, setting up the NIA
@@ -229,19 +231,200 @@ void ppc_release_int() {
/** Opcode decoding functions. */
void ppc_opcode16() {
SubOpcode16Grabber[ppc_cur_instruction & 3]();
static void ppc_opcode16() {
instr.sub_op = ppc_cur_instruction & 0x3;
ppc_grab_branch(ppc_cur_instruction);
}
void ppc_opcode18() {
SubOpcode18Grabber[ppc_cur_instruction & 3]();
static void ppc_opcode18() {
instr.sub_op = ppc_cur_instruction & 0x3;
ppc_grab_branch(ppc_cur_instruction);
}
template<field_601 for601>
void ppc_opcode19() {
uint16_t subop_grab = ppc_cur_instruction & 0x7FF;
instr.sub_op = ppc_cur_instruction & 0x7FF;
switch (subop_grab) {
switch (instr.sub_op) {
case 0:
ppc_grab_regs_crfds(ppc_cur_instruction);
break;
case 32:
ppc_grab_branch_cond(ppc_cur_instruction);
break;
case 33:
ppc_grab_branch_cond(ppc_cur_instruction);
break;
case 66:
ppc_grab_dab(ppc_cur_instruction);
break;
case 100:
break;
case 258:
ppc_grab_dab(ppc_cur_instruction);
break;
case 300:
break;
case 386:
ppc_grab_dab(ppc_cur_instruction);
break;
case 450:
ppc_grab_dab(ppc_cur_instruction);
break;
case 514:
ppc_grab_dab(ppc_cur_instruction);
break;
case 578:
ppc_grab_dab(ppc_cur_instruction);
break;
case 834:
ppc_grab_dab(ppc_cur_instruction);
break;
case 898:
ppc_grab_dab(ppc_cur_instruction);
break;
case 1056:
ppc_grab_branch_cond(ppc_cur_instruction);
break;
case 1057:
ppc_grab_branch_cond(ppc_cur_instruction);
break;
}
}
template void ppc_opcode19<NOT601>();
template void ppc_opcode19<IS601>();
static void ppc_opcode31() {
instr.sub_op = ppc_cur_instruction & 0x7FFUL;
switch ((instr.sub_op >> 1)) {
case 0:
case 32:
ppc_grab_crfd_regsab(ppc_cur_instruction);
break;
case 8:
ppc_grab_tw(ppc_cur_instruction);
break;
case 83:
ppc_grab_d(ppc_cur_instruction);
break;
case 144:
ppc_grab_crfd(ppc_cur_instruction);
break;
case 210:
case 595:
ppc_grab_sr(ppc_cur_instruction);
break;
case 512:
ppc_grab_mcrxr(ppc_cur_instruction);
break;
default:
ppc_grab_regsdab(ppc_cur_instruction);
}
}
static void ppc_opcode59() {
instr.sub_op = ppc_cur_instruction & 0x3FUL;
ppc_grab_regsfpdabc(ppc_cur_instruction);
}
static void ppc_opcode63() {
instr.sub_op = ppc_cur_instruction & 0x7FFUL;
switch ((instr.sub_op >> 1)) {
case 0:
case 32:
ppc_grab_regsfpsab(ppc_cur_instruction);
break;
case 38:
case 70:
ppc_grab_crfd(ppc_cur_instruction);
break;
case 64:
ppc_grab_regs_crfds(ppc_cur_instruction);
break;
case 134:
ppc_grab_mtfsfi(ppc_cur_instruction);
break;
case 711:
default:
ppc_grab_regsfpdabc(ppc_cur_instruction);
}
}
/* Dispatch using main opcode */
static void ppc_main_opcode() {
switch (instr.main_op) {
case 3:
ppc_grab_twi(ppc_cur_instruction);
break;
case 7: case 8: case 9:
case 12: case 13:
case 14: case 15:
ppc_grab_regs_dasimm(ppc_cur_instruction);
break;
case 20: case 21:
case 22: case 23:
ppc_grab_regs_sab_rot(ppc_cur_instruction);
break;
case 24: case 25:
case 26: case 27:
case 28: case 29:
ppc_grab_regs_sauimm(ppc_cur_instruction);
break;
case 32: case 33: case 34: case 35:
case 36: case 37: case 38: case 39:
case 40: case 31: case 42: case 43:
case 44: case 45: case 46: case 47:
case 48: case 49: case 50: case 51:
case 52: case 53: case 54: case 55:
ppc_grab_regs_da_addr(ppc_cur_instruction);
break;
}
}
void decode_instr() {
instr.main_op = (ppc_cur_instruction >> 26) & 0x3F;
switch (instr.main_op) {
case 16:
ppc_opcode16();
break;
case 18:
ppc_opcode18();
break;
case 19:
if (is_601)
ppc_opcode19<IS601>();
else
ppc_opcode19<NOT601>();
break;
case 31:
ppc_opcode31();
break;
case 59:
ppc_opcode59();
break;
case 63:
ppc_opcode63();
break;
default:
ppc_main_opcode();
}
#ifdef CPU_PROFILING
num_executed_instrs++;
#if defined(CPU_PROFILING_OPS)
num_opcodes[ppc_cur_instruction]++;
#endif
#endif
}
template <field_601 for601>
inline static void exec_op19() {
switch (instr.sub_op) {
case 0:
ppc_mcrf();
break;
@@ -292,34 +475,32 @@ void ppc_opcode19() {
}
}
template void ppc_opcode19<NOT601>();
template void ppc_opcode19<IS601>();
void ppc_opcode31() {
uint16_t subop_grab = ppc_cur_instruction & 0x7FFUL;
SubOpcode31Grabber[subop_grab]();
}
void ppc_opcode59() {
uint16_t subop_grab = ppc_cur_instruction & 0x3FUL;
SubOpcode59Grabber[subop_grab]();
}
void ppc_opcode63() {
uint16_t subop_grab = ppc_cur_instruction & 0x7FFUL;
SubOpcode63Grabber[subop_grab]();
}
/* Dispatch using main opcode */
void ppc_main_opcode()
{
#ifdef CPU_PROFILING
num_executed_instrs++;
#if defined(CPU_PROFILING_OPS)
num_opcodes[ppc_cur_instruction]++;
#endif
#endif
OpcodeGrabber[(ppc_cur_instruction >> 26) & 0x3F]();
void exec_instr() {
switch (instr.main_op) {
case 16:
SubOpcode16Grabber[instr.sub_op]();
break;
case 18:
SubOpcode18Grabber[instr.sub_op]();
break;
case 19:
if (is_601)
exec_op19<IS601>();
else
exec_op19<NOT601>();
break;
case 31:
SubOpcode31Grabber[instr.sub_op]();
break;
case 59:
SubOpcode59Grabber[instr.sub_op]();
break;
case 63:
SubOpcode63Grabber[instr.sub_op]();
break;
default:
OpcodeGrabber[instr.main_op]();
}
}
static long long cpu_now_ns() {
@@ -377,10 +558,11 @@ static void ppc_exec_inner()
exec_flags = 0;
pc_real = mmu_translate_imem(eb_start);
decode_instr();
// interpret execution block
while (power_on && ppc_state.pc < eb_end) {
ppc_main_opcode();
exec_instr();
if (g_icycles++ >= max_cycles || exec_timer) {
max_cycles = process_events();
}
@@ -391,10 +573,12 @@ static void ppc_exec_inner()
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
pc_real += (int)eb_start - (int)ppc_state.pc;
ppc_set_cur_instruction(pc_real);
decode_instr();
} else {
page_start = eb_start & PPC_PAGE_MASK;
eb_end = page_start + PPC_PAGE_SIZE - 1;
pc_real = mmu_translate_imem(eb_start);
eb_end = page_start + PPC_PAGE_SIZE - 1;
pc_real = mmu_translate_imem(eb_start);
decode_instr();
}
ppc_state.pc = eb_start;
exec_flags = 0;
@@ -402,6 +586,7 @@ static void ppc_exec_inner()
ppc_state.pc += 4;
pc_real += 4;
ppc_set_cur_instruction(pc_real);
decode_instr();
}
}
}
@@ -433,7 +618,8 @@ void ppc_exec_single()
}
mmu_translate_imem(ppc_state.pc);
ppc_main_opcode();
decode_instr();
exec_instr();
g_icycles++;
process_events();
@@ -464,11 +650,12 @@ static void ppc_exec_until_inner(const uint32_t goal_addr)
eb_end = page_start + PPC_PAGE_SIZE - 1;
exec_flags = 0;
pc_real = mmu_translate_imem(eb_start);
pc_real = mmu_translate_imem(eb_start);
decode_instr();
// interpret execution block
while (power_on && ppc_state.pc < eb_end) {
ppc_main_opcode();
exec_instr();
if (g_icycles++ >= max_cycles || exec_timer) {
max_cycles = process_events();
}
@@ -479,10 +666,12 @@ static void ppc_exec_until_inner(const uint32_t goal_addr)
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
pc_real += (int)eb_start - (int)ppc_state.pc;
ppc_set_cur_instruction(pc_real);
decode_instr();
} else {
page_start = eb_start & PPC_PAGE_MASK;
eb_end = page_start + PPC_PAGE_SIZE - 1;
pc_real = mmu_translate_imem(eb_start);
pc_real = mmu_translate_imem(eb_start);
decode_instr();
}
ppc_state.pc = eb_start;
exec_flags = 0;
@@ -490,6 +679,7 @@ static void ppc_exec_until_inner(const uint32_t goal_addr)
ppc_state.pc += 4;
pc_real += 4;
ppc_set_cur_instruction(pc_real);
decode_instr();
}
if (ppc_state.pc == goal_addr)
@@ -499,7 +689,7 @@ static void ppc_exec_until_inner(const uint32_t goal_addr)
}
// outer interpreter loop
void ppc_exec_until(volatile uint32_t goal_addr)
void ppc_exec_until(uint32_t goal_addr)
{
if (setjmp(exc_env)) {
// process low-level exceptions
@@ -531,12 +721,13 @@ static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size)
eb_end = page_start + PPC_PAGE_SIZE - 1;
exec_flags = 0;
pc_real = mmu_translate_imem(eb_start);
pc_real = mmu_translate_imem(eb_start);
decode_instr();
// interpret execution block
while (power_on && (ppc_state.pc < start_addr || ppc_state.pc >= start_addr + size)
&& (ppc_state.pc < eb_end)) {
ppc_main_opcode();
exec_instr();
if (g_icycles++ >= max_cycles || exec_timer) {
max_cycles = process_events();
}
@@ -547,10 +738,12 @@ static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size)
if (!(exec_flags & EXEF_RFI) && (eb_start & PPC_PAGE_MASK) == page_start) {
pc_real += (int)eb_start - (int)ppc_state.pc;
ppc_set_cur_instruction(pc_real);
decode_instr();
} else {
page_start = eb_start & PPC_PAGE_MASK;
eb_end = page_start + PPC_PAGE_SIZE - 1;
pc_real = mmu_translate_imem(eb_start);
pc_real = mmu_translate_imem(eb_start);
decode_instr();
}
ppc_state.pc = eb_start;
exec_flags = 0;
@@ -558,13 +751,14 @@ static void ppc_exec_dbg_inner(const uint32_t start_addr, const uint32_t size)
ppc_state.pc += 4;
pc_real += 4;
ppc_set_cur_instruction(pc_real);
decode_instr();
}
}
}
}
// outer interpreter loop
void ppc_exec_dbg(volatile uint32_t start_addr, volatile uint32_t size)
void ppc_exec_dbg(uint32_t start_addr, uint32_t size)
{
if (setjmp(exc_env)) {
// process low-level exceptions
@@ -898,7 +1092,7 @@ void ppc_cpu_init(MemCtrlBase* mem_ctrl, uint32_t cpu_version, bool include_601,
tbr_wr_timestamp = 0;
rtc_timestamp = 0;
tbr_wr_value = 0;
tbr_freq_ghz = (tb_freq << 32) / NS_PER_SEC;
tbr_freq_ghz = uint32_t((tb_freq << 32) / NS_PER_SEC);
tbr_period_ns = ((uint64_t)NS_PER_SEC << 32) / tb_freq;
exec_flags = 0;
+217 -542
View File
File diff suppressed because it is too large. Load diff
+138 -149
View File
@@ -23,194 +23,183 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#define PPC_MACROS_H
#include <cinttypes>
#include "ppcemu.h"
#define ppc_grab_regsdasimm(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int32_t simm = int32_t(int16_t(opcode)); \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define reg_d(opcode) ((opcode >> 21) & 0x1F)
#define reg_a(opcode) ((opcode >> 16) & 0x1F)
#define reg_b(opcode) ((opcode >> 11) & 0x1F)
#define reg_c(opcode) ((opcode >> 6) & 0x1F)
#define reg_s(opcode) reg_d(opcode)
#define trap_to(opcode) reg_d(opcode)
#define simm(opcode) int32_t(int16_t(opcode))
#define uimm(opcode) uint16_t(opcode)
#define rot_sh(opcode) reg_b(opcode)
#define rot_mb(opcode) ((opcode >> 6) & 0x1F)
#define rot_me(opcode) ((opcode >> 1) & 0x1F)
#define crf_d(opcode) ((opcode >> 21) & 0x1C)
#define crf_s(opcode) ((opcode >> 16) & 0x1C)
#define crm(opcode) ((opcode >> 12) & 0xFFU)
#define fcrm(opcode) crm(opcode)
#define fmmask(opcode) ((opcode >> 17) & 0xFFU)
#define br_bo(opcode) reg_d(opcode)
#define br_bi(opcode) reg_a(opcode)
#define br_bd(opcode) int32_t(int16_t(opcode & ~3UL))
#define adr_li(opcode) int32_t((opcode & ~3UL) << 6) >> 6
#define adr_d(opcode) int32_t(int16_t(opcode))
#define segreg(opcode) ((opcode >> 16) & 0xF)
#define mtfsfi_mask(opcode) ((opcode << 16) & 0xF0000000UL)
#define ppc_grab_regsdauimm(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t uimm = uint16_t(opcode); \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_twi(opcode) \
instr.i_simm = simm(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg0 = trap_to(opcode);
#define ppc_grab_regsasimm(opcode) \
int reg_a = (opcode >> 16) & 31; \
int32_t simm = int32_t(int16_t(opcode)); \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_tw(opcode) \
instr.i_simm = simm(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg0 = trap_to(opcode); \
#define ppc_grab_regssauimm(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t uimm = uint16_t(opcode); \
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_crfd(opcode) \
instr.arg0 = crf_d(opcode);
#define ppc_grab_crfd_regsauimm(opcode) \
int crf_d = (opcode >> 21) & 0x1C; \
int reg_a = (opcode >> 16) & 31; \
uint32_t uimm = uint16_t(opcode); \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_mcrxr(opcode) \
instr.arg0 = crf_d(opcode); \
instr.arg4 = crf_d(opcode); \
#define ppc_grab_da(opcode)\
int reg_d = (opcode >> 21) & 31;\
int reg_a = (opcode >> 16) & 31;\
#define ppc_grab_sr(opcode) \
instr.arg0 = reg_d(opcode); \
instr.arg1 = segreg(opcode); \
#define ppc_grab_mtfsfi(opcode) \
instr.arg0 = reg_d(opcode); \
instr.mask = mtfsfi_mask(opcode); \
#define ppc_grab_mtfsf(opcode) \
instr.arg2 = reg_b(opcode); \
instr.mask = fmmask(opcode);\
#define ppc_grab_regs_dasimm(opcode) \
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.i_simm = simm(opcode); \
#define ppc_grab_regs_sauimm(opcode) \
instr.arg0 = reg_s(opcode); \
instr.arg1 = reg_a(opcode); \
instr.i_simm = simm(opcode); \
#define ppc_grab_regs_da_addr(opcode) \
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.addr = adr_d(opcode); \
#define ppc_grab_branch(opcode) \
instr.addr = adr_li(opcode); \
#define ppc_grab_branch_cond(opcode) \
instr.arg0 = br_bo(opcode); \
instr.arg1 = br_bi(opcode); \
#define ppc_grab_d(opcode) \
instr.arg0 = reg_d(opcode);
#define ppc_grab_dab(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31;
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regsasimm(opcode) \
instr.arg0 = reg_s(opcode); \
instr.arg1 = reg_a(opcode); \
instr.i_simm = simm(opcode); \
#define ppc_grab_regssauimm(opcode) \
instr.arg0 = reg_s(opcode); \
instr.arg1 = reg_a(opcode); \
instr.i_simm = simm(opcode); \
#define ppc_grab_crfd_regsauimm(opcode) \
instr.arg0 = crf_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.i_simm = simm(opcode); \
#define ppc_grab_crfd_regsab(opcode) \
instr.arg0 = crf_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode);
#define ppc_grab_s(opcode) \
int reg_s = (opcode >> 21) & 31; \
uint32_t ppc_result_d = ppc_state.gpr[reg_s];
instr.arg0 = reg_s(opcode); \
#define ppc_grab_regs_crfds(opcode) \
instr.arg0 = crf_d(opcode); \
instr.arg1 = crf_s(opcode); \
#define ppc_grab_regsdab(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regssab(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
#define ppc_grab_regssab_stswx(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a]; \
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
#define ppc_grab_regsab(opcode) \
int reg_a = (opcode >> 16) & 31;\
int reg_b = (opcode >> 11) & 31;\
uint32_t ppc_result_a = ppc_state.gpr[reg_a];\
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
#define ppc_grab_regssa(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_regssa_stmw(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_regssash(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int rot_sh = (opcode >> 11) & 31; \
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_regssash_stswi(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int rot_sh = (opcode >> 11) & 31; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_regssb(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t ppc_result_d = ppc_state.gpr[reg_s]; \
uint32_t ppc_result_b = ppc_state.gpr[reg_b]; \
#define ppc_grab_regsda(opcode) \
int reg_d = (opcode >> 21) & 31; \
uint32_t reg_a = (opcode >> 16) & 31; \
uint32_t ppc_result_a = ppc_state.gpr[reg_a];
#define ppc_grab_regsdb(opcode) \
int reg_d = (opcode >> 21) & 31; \
uint32_t reg_b = (opcode >> 11) & 31; \
uint32_t ppc_result_b = ppc_state.gpr[reg_b];
#define ppc_grab_regs_sab_rot(opcode) \
instr.arg0 = reg_s(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
instr.arg3 = rot_mb(opcode); \
instr.arg4 = rot_me(opcode); \
#define ppc_store_iresult_reg(reg, ppc_result)\
ppc_state.gpr[reg] = ppc_result;
#define ppc_store_sfpresult_int(reg, ppc_result64_d)\
ppc_state.fpr[(reg)].int64_r = ppc_result64_d;
#define ppc_store_sfpresult_flt(reg, ppc_dblresult64_d)\
ppc_state.fpr[(reg)].dbl64_r = ppc_dblresult64_d;
#define ppc_store_dfpresult_int(reg, ppc_result64_d)\
#define ppc_store_fpresult_int(reg, ppc_result64_d)\
ppc_state.fpr[(reg)].int64_r = ppc_result64_d;
#define ppc_store_dfpresult_flt(reg, ppc_dblresult64_d)\
#define ppc_store_fpresult_flt(reg, ppc_dblresult64_d)\
ppc_state.fpr[(reg)].dbl64_r = ppc_dblresult64_d;
#define ppc_grab_regsfpdb(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_b = (opcode >> 11) & 31;
instr.arg0 = reg_d(opcode); \
instr.arg2 = reg_b(opcode); \
#define GET_FPR(reg) \
#define GET_FPR(reg) \
ppc_state.fpr[(reg)].dbl64_r
#define ppc_grab_regsfpdiab(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t val_reg_a = ppc_state.gpr[reg_a]; \
uint32_t val_reg_b = ppc_state.gpr[reg_b];
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regsfpdia(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t val_reg_a = ppc_state.gpr[reg_a];
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
#define ppc_grab_regsfpsia(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
uint32_t val_reg_a = ppc_state.gpr[reg_a];
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
#define ppc_grab_regsfpsiab(opcode) \
int reg_s = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
uint32_t val_reg_a = ppc_state.gpr[reg_a]; \
uint32_t val_reg_b = ppc_state.gpr[reg_b];
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regsfpsab(opcode) \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
int crf_d = (opcode >> 21) & 0x1C; \
double db_test_a = GET_FPR(reg_a); \
double db_test_b = GET_FPR(reg_b);
instr.arg0 = crf_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regsfpdab(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
double val_reg_a = GET_FPR(reg_a); \
double val_reg_b = GET_FPR(reg_b);
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
#define ppc_grab_regsfpdac(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_c = (opcode >> 6) & 31; \
double val_reg_a = GET_FPR(reg_a); \
double val_reg_c = GET_FPR(reg_c);
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg3 = reg_c(opcode); \
#define ppc_grab_regsfpdabc(opcode) \
int reg_d = (opcode >> 21) & 31; \
int reg_a = (opcode >> 16) & 31; \
int reg_b = (opcode >> 11) & 31; \
int reg_c = (opcode >> 6) & 31; \
double val_reg_a = GET_FPR(reg_a); \
double val_reg_b = GET_FPR(reg_b); \
double val_reg_c = GET_FPR(reg_c);
instr.arg0 = reg_d(opcode); \
instr.arg1 = reg_a(opcode); \
instr.arg2 = reg_b(opcode); \
instr.arg3 = reg_c(opcode); \
#endif // PPC_MACROS_H
+355 -443
View File
File diff suppressed because it is too large. Load diff
+10 -7
View File
@@ -42,12 +42,13 @@ void ppc_exception_handler(Except_Type exception_type, uint32_t srr1_bits) {
}
#endif
void xer_ov_test(string mnem, uint32_t opcode) {
static 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_cur_instruction = opcode;
ppc_main_opcode();
decode_instr();
exec_instr();
if (ppc_state.spr[SPR::XER] & 0x40000000UL) {
cout << "Invalid " << mnem << " emulation! XER[OV] should not be set." << endl;
nfailed++;
@@ -55,7 +56,7 @@ void xer_ov_test(string mnem, uint32_t opcode) {
ntested++;
}
void xer_update_test() {
static void xer_update_test() {
xer_ov_test("ADDCO", 0x7C632414);
xer_ov_test("ADDCO.", 0x7C632415);
xer_ov_test("ADDO", 0x7C632614);
@@ -152,8 +153,9 @@ static void read_test_data() {
ppc_state.cr = 0;
ppc_cur_instruction = opcode;
ppc_main_opcode();
decode_instr();
exec_instr();
ntested++;
@@ -172,7 +174,7 @@ static void read_test_data() {
}
}
double double_from_string(string str) {
static double double_from_string(string str) {
if (str == "snan")
return std::numeric_limits<double>::signaling_NaN();
if (str == "qnan")
@@ -297,7 +299,8 @@ static void read_test_float_data() {
ppc_cur_instruction = opcode;
ppc_main_opcode();
decode_instr();
exec_instr();
ntested++;
-100
View File
@@ -1,100 +0,0 @@
/*
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/>.
*/
/** @file Apple Desktop Bus AppleJack controller emulation. */
#include <devices/common/adb/adbapplejack.h>
#include <devices/common/adb/adbbus.h>
#include <devices/deviceregistry.h>
#include <core/hostevents.h>
#include <loguru.hpp>
AdbAppleJack::AdbAppleJack(std::string name) : AdbMouse(name, AdbMouse::TRACKBALL, 2, 7, 300) {
EventManager::get_instance()->add_gamepad_handler(this, &AdbAppleJack::event_handler);
}
void AdbAppleJack::event_handler(const GamepadEvent& event) {
uint32_t button_bit = 1 << event.button;
if (event.flags & GAMEPAD_EVENT_DOWN)
this->buttons_state |= button_bit;
else if (event.flags & GAMEPAD_EVENT_UP)
this->buttons_state &= ~button_bit;
if (button_bit & ((1 << GamepadButton::LeftTrigger) | (1 << GamepadButton::RightTrigger)))
this->triggers_changed = true;
else
this->buttons_changed = true;
}
void AdbAppleJack::reset() {
this->AdbMouse::reset();
this->buttons_state = 0;
this->triggers_changed = false;
this->buttons_changed = false;
LOG_F(INFO, "%s: reset; in mouse emulation mode", this->name.c_str());
}
bool AdbAppleJack::get_register_0() {
bool changed = this->triggers_changed || this->buttons_changed;
uint8_t mouse_buttons = this->AdbMouse::get_buttons_state();
// AppleJack triggers always affect the mouse button bits.
mouse_buttons |= (this->buttons_state >> (GamepadButton::LeftTrigger - 0)) & 1;
mouse_buttons |= (this->buttons_state >> (GamepadButton::RightTrigger - 1)) & 2;
changed |= this->AdbMouse::get_register_0(mouse_buttons, changed);
this->triggers_changed = false;
if (this->dev_handler_id == APPLEJACK_HANDLER_ID && this->buttons_changed) {
uint8_t* out_buf = this->host_obj->get_output_buf();
out_buf[2] = ~this->buttons_state >> 8;
out_buf[3] = ~this->buttons_state & 0xFF;
this->host_obj->set_output_count(4);
this->buttons_changed = false;
}
return changed;
}
void AdbAppleJack::set_register_3() {
if (this->host_obj->get_input_count() < 2) // ensure we got enough data
return;
const uint8_t* in_data = this->host_obj->get_input_buf();
switch (in_data[1]) {
case APPLEJACK_HANDLER_ID: // switch over to AppleJack protocol
this->dev_handler_id = in_data[1];
LOG_F(INFO, "%s: switched to AppleJack mode", this->name.c_str());
break;
default:
this->AdbMouse::set_register_3();
break;
}
}
static const DeviceDescription AdbAppleJack_Descriptor = {
AdbAppleJack::create, {}, {}
};
REGISTER_DEVICE(AdbAppleJack, AdbAppleJack_Descriptor);
-60
View File
@@ -1,60 +0,0 @@
/*
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/>.
*/
/** @file Apple Desktop Bus AppleJack controller definitions. */
#ifndef ADB_APPLEJACK_H
#define ADB_APPLEJACK_H
#include <devices/common/adb/adbmouse.h>
#include <devices/common/hwcomponent.h>
#include <memory>
#include <string>
enum : uint8_t {
APPLEJACK_HANDLER_ID = 0x46,
};
class GamepadEvent;
class AdbAppleJack : public AdbMouse {
public:
AdbAppleJack(std::string name);
~AdbAppleJack() = default;
static std::unique_ptr<HWComponent> create() {
return std::unique_ptr<AdbAppleJack>(new AdbAppleJack("ADB-APPLEJACK"));
}
void reset() override;
void event_handler(const GamepadEvent& event);
bool get_register_0() override;
void set_register_3() override;
private:
uint32_t buttons_state = 0;
bool triggers_changed = false;
bool buttons_changed = false;
};
#endif // ADB_APPLEJACK_H
+1 -31
View File
@@ -25,8 +25,6 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <devices/common/adb/adbdevice.h>
#include <devices/deviceregistry.h>
#include <loguru.hpp>
#include <machines/machinebase.h>
#include <sstream>
AdbBus::AdbBus(std::string name) {
this->set_name(name);
@@ -34,30 +32,6 @@ AdbBus::AdbBus(std::string name) {
this->devices.clear();
}
int AdbBus::device_postinit() {
std::string adb_device_list = GET_STR_PROP("adb_devices");
if (adb_device_list.empty())
return 0;
std::string adb_device;
std::istringstream adb_device_stream(adb_device_list);
while (getline(adb_device_stream, adb_device, ',')) {
string dev_name = "Adb" + adb_device;
if (dev_name == this->name)
continue; // don't register a second ADB bus
if (DeviceRegistry::device_registered(dev_name)) {
gMachineObj->add_device(dev_name, DeviceRegistry::get_descriptor(dev_name).m_create_func());
} else {
LOG_F(WARNING, "Unknown specified ADB device \"%s\"", adb_device.c_str());
}
}
return 0;
}
void AdbBus::register_device(AdbDevice* dev_obj) {
this->devices.push_back(dev_obj);
}
@@ -128,12 +102,8 @@ uint8_t AdbBus::process_command(const uint8_t* in_data, int data_size) {
return ADB_STAT_OK;
}
static const PropMap AdbBus_Properties = {
{"adb_devices", new StrProperty("Mouse,Keyboard")},
};
static const DeviceDescription AdbBus_Descriptor = {
AdbBus::create, {}, AdbBus_Properties
AdbBus::create, {}, {}
};
REGISTER_DEVICE(AdbBus, AdbBus_Descriptor);
-2
View File
@@ -51,8 +51,6 @@ public:
return std::unique_ptr<AdbBus>(new AdbBus("ADB-BUS"));
}
int device_postinit() override;
void register_device(AdbDevice* dev_obj);
uint8_t process_command(const uint8_t* in_data, int data_size);
uint8_t get_output_count() { return this->output_count; };
+5 -16
View File
@@ -28,8 +28,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
#include <memaccess.h>
#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) {
AdbMouse::AdbMouse(std::string name) : AdbDevice(name) {
EventManager::get_instance()->add_mouse_handler(this, &AdbMouse::event_handler);
this->reset();
@@ -64,10 +63,8 @@ void AdbMouse::reset() {
this->changed = false;
}
bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
bool should_update = this->x_rel || this->y_rel || this->changed || force;
if (should_update) {
bool AdbMouse::get_register_0() {
if (this->x_rel || this->y_rel || this->changed) {
uint8_t* p;
uint8_t* out_buf = this->host_obj->get_output_buf();
@@ -89,7 +86,7 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
bits = 7;
while (bits_remaining > 0) {
*p = (val & ((1 << bits) - 1)) | (((buttons_state >> button) ^ 1) << bits) | (*p << (bits + 1));
*p = (val & ((1 << bits) - 1)) | (((this->buttons_state >> button) ^ 1) << bits) | (*p << (bits + 1));
val >>= bits;
bits_remaining -= bits;
p = bits == 7 ? &out_buf[2] : p + 1;
@@ -112,16 +109,12 @@ bool AdbMouse::get_register_0(uint8_t buttons_state, bool force) {
if (this->device_class == MOUSE && this->dev_handler_id == 1)
count = 2;
this->host_obj->set_output_count(count);
return should_update;
return true;
}
return false;
}
bool AdbMouse::get_register_0() {
return get_register_0(this->buttons_state, false);
}
bool AdbMouse::get_register_1() {
uint8_t* out_buf = this->host_obj->get_output_buf();
// Identifier
@@ -163,10 +156,6 @@ void AdbMouse::set_register_3() {
}
}
uint8_t AdbMouse::get_buttons_state() const {
return this->buttons_state;
}
static const DeviceDescription AdbMouse_Descriptor = {
AdbMouse::create, {}, {}
};
+15 -24
View File
@@ -35,31 +35,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
class MouseEvent;
class AdbMouse : public AdbDevice {
public:
enum DeviceClass {
TABLET = 0,
MOUSE = 1,
TRACKBALL = 2,
};
AdbMouse(
std::string name, uint8_t device_class, int num_buttons, int num_bits, uint16_t resolution);
public:
AdbMouse(std::string name);
~AdbMouse() = default;
static std::unique_ptr<HWComponent> create() {
#ifdef ABSOLUTE
uint8_t device_class = TABLET;
int num_buttons = 3;
int num_bits = 16;
uint16_t resolution = 72;
#else
uint8_t device_class = MOUSE;
int num_buttons = 3;
int num_bits = 10;
uint16_t resolution = 300;
#endif
return std::unique_ptr<AdbMouse>(
new AdbMouse("ADB-MOUSE", device_class, num_buttons, num_bits, resolution));
return std::unique_ptr<AdbMouse>(new AdbMouse("ADB-MOUSE"));
}
void reset() override;
@@ -69,10 +57,6 @@ enum DeviceClass {
bool get_register_1() override;
void set_register_3() override;
protected:
bool get_register_0(uint8_t buttons_state, bool force);
uint8_t get_buttons_state() const;
private:
int32_t x_rel = 0;
int32_t y_rel = 0;
@@ -80,10 +64,17 @@ private:
int32_t y_abs = 0;
uint8_t buttons_state = 0;
bool changed = false;
uint8_t device_class;
int num_buttons;
int num_bits;
uint16_t resolution;
#ifdef ABSOLUTE
uint8_t device_class = TABLET;
int num_buttons = 3;
int num_bits = 16;
uint16_t resolution = 72;
#else
uint8_t device_class = MOUSE;
int num_buttons = 3;
int num_bits = 10;
uint16_t resolution = 300;
#endif
};
#endif // ADB_MOUSE_H
-238
View File
@@ -1,238 +0,0 @@
/*
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/>.
*/
/** @file CMD646U2 PCI Ultra ATA controller emulation. */
#include <devices/common/ata/cmd646.h>
#include <devices/deviceregistry.h>
#include <loguru.hpp>
#include <machines/machinebase.h>
CmdIdeCtrl::CmdIdeCtrl() : PCIDevice("cmd-ide") {
this->supports_types(HWCompType::PCI_DEV | HWCompType::IDE_HOST);
// set up PCI configuration space header
this->vendor_id = this->subsys_vndr = PCI_VENDOR_SILICON_IMAGE;
this->device_id = this->subsys_id = DEV_ID_CMD646;
this->class_rev = ((MY_DEV_CLASS | this->prog_if) << 8) | MY_REV_ID;
this->max_lat = 4;
this->min_gnt = 2;
this->irq_pin = 1;
this->bars_cfg[0] = 0xFFFFFFF9; // Command block I/O space, primary channel
this->bars_cfg[1] = 0xFFFFFFFD; // Control block I/O space, primary channel
this->bars_cfg[2] = 0xFFFFFFF9; // Command block I/O space, secondary channel
this->bars_cfg[3] = 0xFFFFFFFD; // Control block I/O space, secondary channel
this->bars_cfg[4] = 0xFFFFFFF1; // Bus master I/O space, both channels
this->finish_config_bars();
this->pci_notify_bar_change = [this](int bar_num) {
this->notify_bar_change(bar_num);
};
gMachineObj->add_device("CmdAta0", std::unique_ptr<IdeChannel>(new IdeChannel("CmdAta0")));
gMachineObj->add_device("CmdAta1", std::unique_ptr<IdeChannel>(new IdeChannel("CmdAta1")));
this->ch0 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("CmdAta0"));
this->ch1 = dynamic_cast<IdeChannel*>(gMachineObj->get_comp_by_name("CmdAta1"));
this->ch0->set_irq_callback([this](const uint8_t intrq_state) {
LOG_F(INFO, "CmdAta0 INTRQ updated to %d", intrq_state);
this->update_irq(0, intrq_state);
});
this->ch1->set_irq_callback([this](const uint8_t intrq_state) {
LOG_F(INFO, "CmdAta1 INTRQ updated to %d", intrq_state);
this->update_irq(1, intrq_state);
});
}
uint32_t CmdIdeCtrl::pci_cfg_read(uint32_t reg_offs, AccessDetails &details) {
if (reg_offs < 64)
return PCIDevice::pci_cfg_read(reg_offs, details);
if (details.size != 1)
ABORT_F("%s: non-byte read from PCI config reg 0x%X", this->name.c_str(),
reg_offs + details.offset);
if (reg_offs < 112)
return this->read_config_reg(reg_offs + details.offset);
LOG_F(WARNING, "%s: reading config reg at 0x%X", this->name.c_str(), reg_offs);
return 0;
}
void CmdIdeCtrl::pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details) {
if (reg_offs < 64) {
PCIDevice::pci_cfg_write(reg_offs, value, details);
return;
}
if (details.size != 1)
ABORT_F("%s: non-byte write to PCI config reg 0x%X", this->name.c_str(),
reg_offs + details.offset);
if (reg_offs < 112)
this->write_config_reg(reg_offs + details.offset, value);
else
LOG_F(WARNING, "%s: writing config reg at 0x%X", this->name.c_str(), reg_offs);
}
void CmdIdeCtrl::notify_bar_change(int bar_num) {
if (bar_num >= 0 && bar_num <= 4)
this->io_bases[bar_num] = this->bars[bar_num] & ~3;
}
bool CmdIdeCtrl::pci_io_read(uint32_t offset, uint32_t size, uint32_t* res) {
*res = 0;
if ((offset & ~7) == this->io_bases[0]) {
*res = this->ch0->read(offset & 7, size);
} else if ((offset & ~7) == this->io_bases[2]) {
*res = this->ch1->read(offset & 7, size);
} else if ((offset & ~3) == this->io_bases[1]) {
*res = this->ch0->read((offset & 3) + DEV_CTRL_BLK_OFFSET, size);
} else if ((offset & ~3) == this->io_bases[3]) {
*res = this->ch1->read((offset & 3) + DEV_CTRL_BLK_OFFSET, size);
} else if ((offset & ~0xF) == this->io_bases[4]) {
*res = this->read_bus_master_reg(offset & 0xF);
} else {
*res = 0xFFFFFFFFUL;
return false;
}
return true;
}
bool CmdIdeCtrl::pci_io_write(uint32_t offset, uint32_t value, uint32_t size) {
if ((offset & ~7) == this->io_bases[0]) {
this->ch0->write(offset & 7, value, size);
} else if ((offset & ~7) == this->io_bases[2]) {
this->ch1->write(offset & 7, value, size);
} else if ((offset & ~3) == this->io_bases[1]) {
this->ch0->write((offset & 3) + DEV_CTRL_BLK_OFFSET, value, size);
} else if ((offset & ~3) == this->io_bases[3]) {
this->ch1->write((offset & 3) + DEV_CTRL_BLK_OFFSET, value, size);
} else if ((offset & ~0xF) == this->io_bases[4]) {
this->write_bus_master_reg(offset & 0xF, value & 0xFFU);
} else
return false;
return true;
};
uint8_t CmdIdeCtrl::read_config_reg(uint32_t reg_offset) {
switch(reg_offset) {
case ARTTIM0:
return this->addr_setup_time_0;
case DRWTIM0:
return this->data_rw_time_0;
case ARTTIM1:
return this->addr_setup_time_1;
case DRWTIM1:
return this->data_rw_time_1;
default:
LOG_F(ERROR, "%s: unimplemented config reg at 0x%X", this->name.c_str(),
reg_offset);
}
return 0;
}
void CmdIdeCtrl::write_config_reg(uint32_t reg_offset, uint8_t val) {
switch(reg_offset) {
case ARTTIM0:
this->addr_setup_time_0 = val;
LOG_F(9, "%s: ARTTIM0 set to 0x%X", this->name.c_str(), val);
break;
case DRWTIM0:
this->data_rw_time_0 = val;
LOG_F(9, "%s: DRWTIM0 set to 0x%X", this->name.c_str(), val);
break;
case ARTTIM1:
this->addr_setup_time_1 = val;
LOG_F(9, "%s: ARTTIM1 set to 0x%X", this->name.c_str(), val);
break;
case DRWTIM1:
this->data_rw_time_1 = val;
LOG_F(9, "%s: DRWTIM1 set to 0x%X", this->name.c_str(), val);
break;
default:
LOG_F(ERROR, "%s: unimplemented config reg at 0x%X", this->name.c_str(),
reg_offset);
}
}
uint8_t CmdIdeCtrl::read_bus_master_reg(const uint8_t reg_offset) {
switch(reg_offset) {
case MRDMODE:
return this->mrdmode;
default:
LOG_F(ERROR, "%s: unimplemented bus master reg at 0x%X", this->name.c_str(),
reg_offset);
}
return 0;
}
void CmdIdeCtrl::write_bus_master_reg(const uint8_t reg_offset, const uint8_t val) {
switch(reg_offset) {
case MRDMODE:
if (val & BM_CH0_INT)
this->mrdmode &= ~BM_CH0_INT;
if (val & BM_CH1_INT)
this->mrdmode &= ~BM_CH1_INT;
this->mrdmode = (this->mrdmode & ~(BM_BLOCK_CH0_INT | BM_BLOCK_CH1_INT)) |
(val & (BM_BLOCK_CH0_INT | BM_BLOCK_CH1_INT));
LOG_F(INFO, "%s: MRDMODE set to 0x%X", this->name.c_str(), val);
if ((this->mrdmode & BM_CH0_INT) && !(this->mrdmode & BM_BLOCK_CH0_INT))
this->update_irq(0, 1);
if ((this->mrdmode & BM_CH1_INT) && !(this->mrdmode & BM_BLOCK_CH1_INT))
this->update_irq(1, 1);
break;
case UDIDETCR0:
this->udma_time_cr = val;
break;
default:
LOG_F(ERROR, "%s: unimplemented bus master reg at 0x%X", this->name.c_str(),
reg_offset);
}
}
void CmdIdeCtrl::update_irq(const int ch_num, const uint8_t irq_level) {
bool forward_irq = !(this->mrdmode & (ch_num ? BM_BLOCK_CH1_INT : BM_BLOCK_CH0_INT));
if (irq_level)
this->mrdmode |= ch_num ? BM_CH1_INT : BM_CH0_INT;
else
this->mrdmode &= ~(ch_num ? BM_CH1_INT : BM_CH0_INT);
if (!irq_level || forward_irq)
this->irq_info.int_ctrl_obj->ack_int(this->irq_info.irq_id, irq_level);
}
static const DeviceDescription CmdIde_Descriptor = {
CmdIdeCtrl::create, {}, {}
};
REGISTER_DEVICE(CmdAta, CmdIde_Descriptor);
-115
View File
@@ -1,115 +0,0 @@
/*
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/>.
*/
/** @file CMD646U2 PCI Ultra ATA controller definitions. */
#ifndef CMD646_IDE_H
#define CMD646_IDE_H
#include <devices/common/hwcomponent.h>
#include <devices/common/hwinterrupt.h>
#include <devices/common/ata/idechannel.h>
#include <devices/common/pci/pcidevice.h>
#include <memory>
#define DEV_ID_CMD646 0x646
#define MY_DEV_CLASS 0x010180 // mass storage | IDE controller | IDE master
#define MY_REV_ID 7
// Offset for converting addresses of the device control block registers
// defined in the PCI IDE Controller specification, rev. 1.0 3/4/94
// to the addresses used in IdeChannel
#define DEV_CTRL_BLK_OFFSET 0x14
/** CMD646 control/status registers. */
enum {
ARTTIM0 = 0x53,
DRWTIM0 = 0x54,
ARTTIM1 = 0x55,
DRWTIM1 = 0x56,
};
/** CMD646 bus master registers. */
enum {
MRDMODE = 1, // misnomer, contains interrupt control/status bits (CMD646U2 specific)
UDIDETCR0 = 3, // Ultra DMA timing control register (CMD646U2 specific)
};
/** Bit definitions for the MRDMODE register. */
enum {
BM_CH0_INT = 1 << 2,
BM_CH1_INT = 1 << 3,
BM_BLOCK_CH0_INT = 1 << 4,
BM_BLOCK_CH1_INT = 1 << 5,
};
class CmdIdeCtrl : public PCIDevice {
public:
CmdIdeCtrl();
~CmdIdeCtrl() = default;
static std::unique_ptr<HWComponent> create() {
return std::unique_ptr<CmdIdeCtrl>(new CmdIdeCtrl());
}
// PCIDevice methods
uint32_t pci_cfg_read(uint32_t reg_offs, AccessDetails &details) override;
void pci_cfg_write(uint32_t reg_offs, uint32_t value, AccessDetails &details) override;
bool pci_io_read(uint32_t offset, uint32_t size, uint32_t* res) override;
bool pci_io_write(uint32_t offset, uint32_t value, uint32_t size) override;
int device_postinit() override {
this->irq_info = this->host_instance->register_pci_int(this);
return 0;
};
private:
void notify_bar_change(int bar_num);
uint8_t read_config_reg(uint32_t reg_offset);
void write_config_reg(uint32_t reg_offset, uint8_t val);
uint8_t read_bus_master_reg(const uint8_t reg_offset);
void write_bus_master_reg(const uint8_t reg_offset, const uint8_t val);
void update_irq(const int ch_num, const uint8_t irq_level);
// on reset, programming interface defaults to
// "both channels operating in native mode"
uint8_t prog_if = 0x0F;
uint32_t io_bases[5] = {};
IdeChannel *ch0 = nullptr;
IdeChannel *ch1 = nullptr;
// unknown default, set it to 2 clocks (60 ns)
uint8_t addr_setup_time_0 = 0x40; // address setup time for drive 0
uint8_t addr_setup_time_1 = 0x40; // address setup time for drive 1
uint8_t data_rw_time_0 = 0x00; // data read/write time for drive 0
uint8_t data_rw_time_1 = 0x00; // data read/write time for drive 1
uint8_t mrdmode = 0;
uint8_t udma_time_cr = 0;
IntDetails irq_info = {};
};
#endif // CMD646_IDE_H
+5 -6
View File
@@ -52,12 +52,11 @@ enum {
/** PCI Vendor IDs for devices used in Power Macintosh computers. */
enum {
PCI_VENDOR_ATI = 0x1002,
PCI_VENDOR_DEC = 0x1011,
PCI_VENDOR_MOTOROLA = 0x1057,
PCI_VENDOR_APPLE = 0x106B,
PCI_VENDOR_SILICON_IMAGE = 0x1095,
PCI_VENDOR_NVIDIA = 0x10DE,
PCI_VENDOR_ATI = 0x1002,
PCI_VENDOR_DEC = 0x1011,
PCI_VENDOR_MOTOROLA = 0x1057,
PCI_VENDOR_APPLE = 0x106B,
PCI_VENDOR_NVIDIA = 0x10DE,
};
/** PCI BAR types */
+1 -1
View File
@@ -836,7 +836,7 @@ void ViaCuda::i2c_comb_transaction(
}
static const vector<string> Cuda_Subdevices = {
"AdbBus"
"AdbBus", "AdbMouse", "AdbKeyboard"
};
static const DeviceDescription ViaCuda_Descriptor = {
-1
View File
@@ -98,7 +98,6 @@ static const map<string, string> PropHelp = {
{"serial_backend", "specifies the backend for the serial port"},
{"emmo", "enables/disables factory HW tests during startup"},
{"cpu", "specifies CPU"},
{"adb_devices", "specifies which ADB device(s) to attach"},
};
bool MachineFactory::add(const string& machine_id, MachineDescription desc)
-2
View File
@@ -74,8 +74,6 @@ static const PropMap Pippin_Settings = {
new IntProperty(0, vector<uint32_t>({0, 1, 4, 8, 16}))},
{"emmo",
new BinProperty(0)},
{"adb_devices",
new StrProperty("AppleJack,Keyboard")},
};
static vector<string> Pippin_Devices = {
+1 -8
View File
@@ -59,10 +59,6 @@ int initialize_yosemite(std::string& id)
grackle_obj->pci_register_device(DEV_FUN(13,0),
dynamic_cast<PCIBase*>(gMachineObj->get_comp_by_name("Dec21154")));
// register CMD646U2 PCI Ultra ATA Controller
sec_bridge->pci_register_device(DEV_FUN(1,0),
dynamic_cast<PCIDevice*>(gMachineObj->get_comp_by_name("CmdAta")));
sec_bridge->pci_register_device(DEV_FUN(5,0),
dynamic_cast<PCIDevice*>(gMachineObj->get_comp_by_name("Heathrow")));
@@ -125,15 +121,12 @@ static const PropMap yosemite_settings = {
new IntProperty( 0, vector<uint32_t>({0, 8, 16, 32, 64, 128, 256}))},
{"emmo",
new BinProperty(0)},
{"hdd_config",
new StrProperty("CmdAta0:0")},
{"cdr_config",
new StrProperty("Ide0:0")},
};
static vector<string> yosemite_devices = {
"Grackle", "Dec21154", "CmdAta", "BurgundySnd", "Heathrow", "AtaHardDisk",
"AtapiCdrom"
"Grackle", "Dec21154", "BurgundySnd", "Heathrow", "AtapiCdrom"
};
static const MachineDescription yosemite_descriptor = {
+2 -2
View File
@@ -53,9 +53,9 @@ static void sigabrt_handler(int signum) {
}
static string appDescription = string(
"\nDingusPPC - Alpha 1.01 (10/31/2024) "
"\nDingusPPC - Alpha 1 (5/10/2024) "
"\nWritten by divingkatae, maximumspatium, "
"\njoevt, mihaip, kkaisershot, et. al. "
"\njoevt, mihaip, et. al. "
"\n(c) 2018-2024 The DingusPPC Dev Team. "
"\nThis is a build intended for testing. "
"\nUse at your own discretion. "
+1 -9
View File
@@ -30,19 +30,11 @@ extern "C" void remap_appkit_menu_shortcuts();
#endif
bool init() {
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_GAMECONTROLLER)) {
if (SDL_Init(SDL_INIT_VIDEO)) {
LOG_F(ERROR, "SDL_Init error: %s", SDL_GetError());
return false;
}
int num_joysticks = SDL_NumJoysticks();
for (int i = 0; i < num_joysticks; ++i) {
if (SDL_IsGameController(i)) {
SDL_GameControllerOpen(i); /* only support one controller for now */
break;
}
}
#ifdef __APPLE__
remap_appkit_menu_shortcuts();
#endif
+2 -8
View File
@@ -5,7 +5,7 @@
* Interpreter (with 601, FPU, and MMU support)
* IDE and SCSI
* Floppy disk image reading (Raw, Disk Copy 4.2, WOZ v1 and v2)
* ADB mouse, keyboard, and AppleJack (Pippin) controller emulation
* ADB mouse and keyboard emulation
* Some audio support
* Basic video output support (i.e. ATI Rage, Control, Platinum)
@@ -112,12 +112,6 @@ Access the factory tests
--serial_backend=socket
```
Set the ADB devices to attach, comma-separated
```
--adb_devices TEXT
```
Change where the output of OpenFirmware is directed to, either to the command line (with stdio) or a Unix socket (unavailable in Windows builds). OpenFirmware 1.x outputs here by default.
### Command Line Examples
@@ -177,4 +171,4 @@ Currently, the Power Mac 6100 cannot boot any OS image containing Mac OS 8.0 or
* AltiVec
* 3D acceleration support
* Additional ADB and USB peripherals
* Networking
* Networking