Add opcode_to_cycle_count map, update emu layout
This commit is contained in:
@@ -56,6 +56,43 @@ const std::unordered_map<uint8_t, std::string> opcode_to_mnemonic = {
|
||||
{0xF0, "BEQ"}, {0xF1, "SBC"}, {0xF2, "SBC"}, {0xF3, "SBC"}, {0xF4, "PEA"},
|
||||
{0xF5, "SBC"}, {0xF6, "INC"}, {0xF7, "SBC"}, {0xF8, "SED"}, {0xF9, "SBC"},
|
||||
{0xFA, "PLX"}, {0xFB, "XCE"}, {0xFC, "JSR"}, {0xFD, "SBC"}, {0xFE, "INC"},
|
||||
{0xFF, "SBC"}
|
||||
{0xFF, "SBC"}};
|
||||
|
||||
};
|
||||
const std::unordered_map<uint8_t, uint8_t> opcode_to_cycle_count = {
|
||||
{0x00, 7}, {0x01, 6}, {0x02, 8}, {0x03, 8}, {0x04, 3}, {0x05, 3}, {0x06, 5},
|
||||
{0x07, 5}, {0x08, 3}, {0x09, 2}, {0x0A, 2}, {0x0B, 4}, {0x0C, 4}, {0x0D, 4},
|
||||
{0x0E, 6}, {0x0F, 6}, {0x10, 2}, {0x11, 5}, {0x12, 6}, {0x13, 8}, {0x14, 4},
|
||||
{0x15, 4}, {0x16, 6}, {0x17, 6}, {0x18, 2}, {0x19, 4}, {0x1A, 2}, {0x1B, 4},
|
||||
{0x1C, 4}, {0x1D, 4}, {0x1E, 7}, {0x1F, 7}, {0x20, 6}, {0x21, 6}, {0x22, 8},
|
||||
{0x23, 8}, {0x24, 3}, {0x25, 3}, {0x26, 5}, {0x27, 5}, {0x28, 4}, {0x29, 2},
|
||||
{0x2A, 2}, {0x2B, 4}, {0x2C, 4}, {0x2D, 4}, {0x2E, 6}, {0x2F, 6}, {0x30, 2},
|
||||
{0x31, 5}, {0x32, 6}, {0x33, 8}, {0x34, 4}, {0x35, 4}, {0x36, 6}, {0x37, 6},
|
||||
{0x38, 2}, {0x39, 4}, {0x3A, 2}, {0x3B, 4}, {0x3C, 4}, {0x3D, 4}, {0x3E, 7},
|
||||
{0x3F, 7}, {0x40, 6}, {0x41, 6}, {0x42, 8}, {0x43, 8}, {0x44, 3}, {0x45, 3},
|
||||
{0x46, 5}, {0x47, 5}, {0x48, 3}, {0x49, 2}, {0x4A, 2}, {0x4B, 4}, {0x4C, 3},
|
||||
{0x4D, 4}, {0x4E, 6}, {0x4F, 6}, {0x50, 2}, {0x51, 5}, {0x52, 6}, {0x53, 8},
|
||||
{0x54, 4}, {0x55, 4}, {0x56, 6}, {0x57, 6}, {0x58, 2}, {0x59, 4}, {0x5A, 2},
|
||||
{0x5B, 4}, {0x5C, 4}, {0x5D, 4}, {0x5E, 7}, {0x5F, 7}, {0x60, 6}, {0x61, 6},
|
||||
{0x62, 8}, {0x63, 8}, {0x64, 3}, {0x65, 3}, {0x66, 5}, {0x67, 5}, {0x68, 4},
|
||||
{0x69, 2}, {0x6A, 2}, {0x6B, 4}, {0x6C, 5}, {0x6D, 4}, {0x6E, 6}, {0x6F, 6},
|
||||
{0x70, 2}, {0x71, 5}, {0x72, 6}, {0x73, 8}, {0x74, 4}, {0x75, 4}, {0x76, 6},
|
||||
{0x77, 6}, {0x78, 2}, {0x79, 4}, {0x7A, 2}, {0x7B, 4}, {0x7C, 6}, {0x7D, 4},
|
||||
{0x7E, 7}, {0x7F, 7}, {0x80, 2}, {0x81, 6}, {0x82, 5}, {0x83, 8}, {0x84, 3},
|
||||
{0x85, 3}, {0x86, 3}, {0x87, 5}, {0x88, 2}, {0x89, 2}, {0x8A, 2}, {0x8B, 4},
|
||||
{0x8C, 4}, {0x8D, 4}, {0x8E, 4}, {0x8F, 6}, {0x90, 2}, {0x91, 6}, {0x92, 5},
|
||||
{0x93, 8}, {0x94, 4}, {0x95, 4}, {0x96, 4}, {0x97, 6}, {0x98, 2}, {0x99, 5},
|
||||
{0x9A, 2}, {0x9B, 4}, {0x9C, 4}, {0x9D, 4}, {0x9E, 4}, {0x9F, 5}, {0xA0, 2},
|
||||
{0xA1, 6}, {0xA2, 2}, {0xA3, 8}, {0xA4, 3}, {0xA5, 3}, {0xA6, 3}, {0xA7, 5},
|
||||
{0xA8, 2}, {0xA9, 2}, {0xAA, 2}, {0xAB, 4}, {0xAC, 4}, {0xAD, 4}, {0xAE, 4},
|
||||
{0xAF, 6}, {0xB0, 2}, {0xB1, 5}, {0xB2, 5}, {0xB3, 8}, {0xB4, 4}, {0xB5, 4},
|
||||
{0xB6, 4}, {0xB7, 6}, {0xB8, 2}, {0xB9, 4}, {0xBA, 2}, {0xBB, 4}, {0xBC, 4},
|
||||
{0xBD, 4}, {0xBE, 4}, {0xBF, 5}, {0xC0, 2}, {0xC1, 6}, {0xC2, 2}, {0xC3, 8},
|
||||
{0xC4, 3}, {0xC5, 3}, {0xC6, 5}, {0xC7, 5}, {0xC8, 2}, {0xC9, 2}, {0xCA, 2},
|
||||
{0xCB, 4}, {0xCC, 4}, {0xCD, 4}, {0xCE, 6}, {0xCF, 6}, {0xD0, 2}, {0xD1, 5},
|
||||
{0xD2, 5}, {0xD3, 8}, {0xD4, 4}, {0xD5, 4}, {0xD6, 6}, {0xD7, 6}, {0xD8, 2},
|
||||
{0xD9, 4}, {0xDA, 2}, {0xDB, 4}, {0xDC, 3}, {0xDD, 4}, {0xDE, 7}, {0xDF, 7},
|
||||
{0xE0, 2}, {0xE1, 6}, {0xE2, 2}, {0xE3, 8}, {0xE4, 3}, {0xE5, 3}, {0xE6, 5},
|
||||
{0xE7, 5}, {0xE8, 2}, {0xE9, 2}, {0xEA, 2}, {0xEB, 2}, {0xEC, 4}, {0xED, 4},
|
||||
{0xEE, 6}, {0xEF, 6}, {0xF0, 2}, {0xF1, 5}, {0xF2, 5}, {0xF3, 8}, {0xF4, 4},
|
||||
{0xF5, 4}, {0xF6, 6}, {0xF7, 6}, {0xF8, 2}, {0xF9, 4}, {0xFA, 2}, {0xFB, 2},
|
||||
{0xFC, 3}, {0xFD, 4}, {0xFE, 7}, {0xFF, 7}};
|
||||
@@ -243,8 +243,8 @@ void Emulator::RenderBreakpointList() {
|
||||
ImGui::EndChild();
|
||||
}
|
||||
Separator();
|
||||
gui::InputHexByte("PB", &manual_pb_, 25.f);
|
||||
gui::InputHexWord("PC", &manual_pc_, 25.f);
|
||||
gui::InputHexByte("PB", &manual_pb_, 50.f);
|
||||
gui::InputHexWord("PC", &manual_pc_, 75.f);
|
||||
if (ImGui::Button("Set Current Address")) {
|
||||
snes_.cpu().PC = manual_pc_;
|
||||
snes_.cpu().PB = manual_pb_;
|
||||
@@ -310,7 +310,7 @@ void Emulator::RenderMemoryViewer() {
|
||||
|
||||
void Emulator::RenderCpuInstructionLog(
|
||||
const std::vector<InstructionEntry>& instruction_log) {
|
||||
if (ImGui::CollapsingHeader("CPU Instruction Log",
|
||||
if (ImGui::CollapsingHeader("Instruction Log",
|
||||
ImGuiTreeNodeFlags_DefaultOpen)) {
|
||||
// Filtering options
|
||||
static char filter[256];
|
||||
@@ -330,7 +330,7 @@ void Emulator::RenderCpuInstructionLog(
|
||||
ImVec4 color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
|
||||
ImGui::TextColored(color, "%s",
|
||||
opcode_to_mnemonic.at(entry.opcode).c_str());
|
||||
ImVec4 operand_color = ImVec4(0.5f, 0.5f, 0.5f, 1.0f);
|
||||
ImVec4 operand_color = ImVec4(0.7f, 0.5f, 0.3f, 1.0f);
|
||||
ImGui::SameLine();
|
||||
ImGui::TextColored(operand_color, "%s", entry.operands.c_str());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ class Emulator : public SharedRom {
|
||||
TableNextColumn,
|
||||
|
||||
CollapsingHeader id="cpuState" title="Register Values" flags="DefaultOpen" {
|
||||
BeginChild id="##CpuState" size="0,100" flags="NoMove|NoScrollbar" {
|
||||
BeginChild id="##CpuState" size="0,100" flags="NoMove|NoScrollbar" {
|
||||
Columns id="registersColumns" count="2" {
|
||||
Text text="A: 0x%04X" data="cpu.A",
|
||||
Text text="D: 0x%04X" data="cpu.D",
|
||||
|
||||
Reference in New Issue
Block a user