Skip to content

Commit

Permalink
Improvements to 6280
Browse files Browse the repository at this point in the history
  • Loading branch information
drhelius committed Jul 19, 2024
1 parent 66289d4 commit 66632db
Show file tree
Hide file tree
Showing 15 changed files with 416 additions and 211 deletions.
20 changes: 0 additions & 20 deletions platforms/shared/desktop/emu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,26 +318,6 @@ void emu_debug_continue(void)
debugger_command = Debugger_Command_Continue;
}

// void emu_debug_step(void)
// {
// debugging = debug_step = true;
// debug_next_frame = false;
// geargrafx->Pause(false);
// }

// void emu_debug_continue(void)
// {
// debugging = debug_step = debug_next_frame = false;
// geargrafx->Pause(false);
// }

// void emu_debug_next_frame(void)
// {
// debugging = debug_next_frame = true;
// debug_step = false;
// geargrafx->Pause(false);
// }

void emu_video_no_sprite_limit(bool enabled)
{
// geargrafx->GetVideo()->SetNoSpriteLimit(enabled);
Expand Down
236 changes: 139 additions & 97 deletions platforms/shared/desktop/gui_debug_huc6280.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,104 +42,146 @@ void gui_debug_window_huc6280(void)
HuC6280::Processor_State* proc_state = processor->GetState();
Memory* memory = core->GetMemory();

ImGui::TextColored(cyan, " STATUS");
ImGui::TextColored(orange, " N V T B D I Z C");
ImGui::Text(" " BYTE_TO_BINARY_PATTERN_ALL_SPACED, BYTE_TO_BINARY(proc_state->P->GetValue()));

ImGui::Columns(2, "registers");
ImGui::Separator();
ImGui::TextColored(cyan, " A"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->A->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->A->GetValue()));

ImGui::NextColumn();
ImGui::TextColored(cyan, " S"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->S->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->S->GetValue()));

ImGui::NextColumn();
ImGui::Separator();
ImGui::TextColored(cyan, " X"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->X->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->X->GetValue()));

ImGui::NextColumn();
ImGui::TextColored(cyan, " Y"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->Y->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->Y->GetValue()));

ImGui::NextColumn();
ImGui::Separator();
ImGui::TextColored(violet, "MPR0"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(0));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(0)));

ImGui::NextColumn();
ImGui::TextColored(violet, "MPR1"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(1));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(1)));

ImGui::NextColumn();
ImGui::Separator();
ImGui::TextColored(violet, "MPR2"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(2));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(2)));

ImGui::NextColumn();
ImGui::TextColored(violet, "MPR3"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(3));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(3)));

ImGui::NextColumn();
ImGui::Separator();
ImGui::TextColored(violet, "MPR4"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(4));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(4)));

ImGui::NextColumn();
ImGui::TextColored(violet, "MPR5"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(5));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(5)));

ImGui::NextColumn();
ImGui::Separator();
ImGui::TextColored(violet, "MPR6"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(6));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(6)));

ImGui::NextColumn();
ImGui::TextColored(violet, "MPR7"); ImGui::SameLine();
ImGui::Text("$%02X", memory->GetMpr(7));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(7)));

ImGui::NextColumn();
ImGui::Columns(1);

ImGui::Separator();
ImGui::TextColored(yellow, " SP"); ImGui::SameLine();
ImGui::Text("= $%04X", 0x2100 | proc_state->S->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(0x21), BYTE_TO_BINARY(proc_state->S->GetValue()));

ImGui::Separator();
ImGui::TextColored(yellow, " PC"); ImGui::SameLine();
ImGui::Text("= $%04X", proc_state->PC->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->PC->GetHigh()), BYTE_TO_BINARY(proc_state->PC->GetLow()));

ImGui::Separator();
ImGui::TextColored(yellow, " PHYS PC"); ImGui::SameLine();
ImGui::Text("= $%06X", memory->GetPhysicalAddress(proc_state->PC->GetValue()));

ImGui::Separator();

ImGui::TextColored(!*proc_state->SPEED ? green : gray, " 1.79 MHz"); ImGui::SameLine();
ImGui::TextColored(*proc_state->SPEED ? green : gray, "7.16 MHz");

// ImGui::TextColored(*proc_state->IFF1 ? green : gray, " IFF1"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->IFF2 ? green : gray, " IFF2"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->Halt ? green : gray, " HALT");
if (ImGui::BeginTable("huc6280", 1, ImGuiTableFlags_BordersInnerH))
{
ImGui::TableNextColumn();
ImGui::TextColored(cyan, " STATUS");
ImGui::TextColored(orange, " N V T B D I Z C");
ImGui::Text(" " BYTE_TO_BINARY_PATTERN_ALL_SPACED, BYTE_TO_BINARY(proc_state->P->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(yellow, " PC"); ImGui::SameLine();
ImGui::Text("= $%04X", proc_state->PC->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->PC->GetHigh()), BYTE_TO_BINARY(proc_state->PC->GetLow()));

ImGui::TableNextColumn();
ImGui::TextColored(yellow, " PHYS PC"); ImGui::SameLine();
ImGui::Text("= $%06X", memory->GetPhysicalAddress(proc_state->PC->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(yellow, " SP"); ImGui::SameLine();
ImGui::Text("= $%04X", 0x2100 | proc_state->S->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED " " BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(0x21), BYTE_TO_BINARY(proc_state->S->GetValue()));

ImGui::TableNextColumn();

ImGui::PushStyleVar(ImGuiStyleVar_CellPadding, ImVec2(2.0f, 2.0f));

if (ImGui::BeginTable("regs", 2, ImGuiTableFlags_BordersInnerH |ImGuiTableFlags_BordersInnerV | ImGuiTableFlags_NoPadOuterX))
{
ImGui::TableNextColumn();
ImGui::TextColored(cyan, " A"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->A->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->A->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(cyan, " S"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->S->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->S->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(cyan, " X"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->X->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->X->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(cyan, " Y"); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->Y->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->Y->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR0"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(0));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(0)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR1"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(1));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(1)));

// ImGui::TextColored(*proc_state->INT ? green : gray, " INT"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->NMI ? green : gray, " NMI");
ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR2"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(2));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(2)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR3"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(3));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(3)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR4"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(4));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(4)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR5"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(5));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(5)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR6"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(6));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(6)));

ImGui::TableNextColumn();
ImGui::TextColored(violet, "MPR7"); ImGui::SameLine();
ImGui::Text(" $%02X", memory->GetMpr(7));
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(memory->GetMpr(7)));

ImGui::TableNextColumn();
ImGui::TextColored(red, "I/O "); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->A->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->A->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(blue, "TIM "); ImGui::SameLine();
ImGui::Text("$%02X", *proc_state->TIMER ? 1 : 0);
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(*proc_state->TIMER ? 1 : 0));

ImGui::TableNextColumn();
ImGui::TextColored(blue, "TIMC"); ImGui::SameLine();
ImGui::Text(" $%02X", *proc_state->TIMER_COUNTER);
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(*proc_state->TIMER_COUNTER));

ImGui::TableNextColumn();
ImGui::TextColored(blue, "TIMR"); ImGui::SameLine();
ImGui::Text(" $%02X", *proc_state->TIMER_RELOAD);
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(*proc_state->TIMER_RELOAD));

ImGui::TableNextColumn();
ImGui::TextColored(magenta, "IDR "); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->A->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->A->GetValue()));

ImGui::TableNextColumn();
ImGui::TextColored(magenta, "IRR "); ImGui::SameLine();
ImGui::Text(" $%02X", proc_state->A->GetValue());
ImGui::Text(BYTE_TO_BINARY_PATTERN_SPACED, BYTE_TO_BINARY(proc_state->A->GetValue()));

ImGui::EndTable();
}

ImGui::PopStyleVar();

ImGui::TableNextColumn();
ImGui::TextColored(*proc_state->IRQ1 ? green : gray, " IRQ1"); ImGui::SameLine();
ImGui::TextColored(*proc_state->IRQ2 ? green : gray, " IRQ2"); ImGui::SameLine();
ImGui::TextColored(*proc_state->TIMER_IRQ ? green : gray, " TIQ ");

ImGui::TableNextColumn();
ImGui::TextColored(!*proc_state->SPEED ? green : gray, " 1.79 MHz"); ImGui::SameLine();
ImGui::TextColored(*proc_state->SPEED ? green : gray, "7.16 MHz");

// ImGui::TextColored(*proc_state->IFF1 ? green : gray, " IFF1"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->IFF2 ? green : gray, " IFF2"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->Halt ? green : gray, " HALT");

// ImGui::TextColored(*proc_state->INT ? green : gray, " INT"); ImGui::SameLine();
// ImGui::TextColored(*proc_state->NMI ? green : gray, " NMI");

ImGui::EndTable();
}

ImGui::PopFont();

Expand Down
2 changes: 1 addition & 1 deletion platforms/shared/desktop/gui_debug_memeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ void MemEditor::Draw(uint8_t* mem_data, int mem_size, int base_display_addr)
m_mem_base_addr = base_display_addr;

int hex_digits = 1;
int size = mem_size;
int size = mem_size - 1;

while (size >>= 4)
{
Expand Down
17 changes: 14 additions & 3 deletions platforms/shared/desktop/gui_debug_memory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ void gui_debug_window_memory(void)

if (ImGui::BeginTabBar("##memory_tabs", ImGuiTabBarFlags_None))
{
if (ImGui::BeginTabItem("BRAM", NULL, mem_edit_select == 0 ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None))
if (ImGui::BeginTabItem("RAM", NULL, mem_edit_select == 0 ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None))
{
ImGui::PushFont(gui_default_font);
if (mem_edit_select == 0)
Expand All @@ -68,12 +68,23 @@ void gui_debug_window_memory(void)
ImGui::EndTabItem();
}

if (IsValidPointer(cart->GetROM()) && ImGui::BeginTabItem("ROM", NULL, mem_edit_select == 1 ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None))
if (ImGui::BeginTabItem("ZERO PAGE", NULL, mem_edit_select == 1 ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None))
{
ImGui::PushFont(gui_default_font);
if (mem_edit_select == 1)
if (mem_edit_select == 1)
mem_edit_select = -1;
current_mem_edit = 1;
mem_edit[current_mem_edit].Draw(memory->GetWram(), 0x100);
ImGui::PopFont();
ImGui::EndTabItem();
}

if (IsValidPointer(cart->GetROM()) && ImGui::BeginTabItem("ROM", NULL, mem_edit_select == 2 ? ImGuiTabItemFlags_SetSelected : ImGuiTabItemFlags_None))
{
ImGui::PushFont(gui_default_font);
if (mem_edit_select == 2)
mem_edit_select = -1;
current_mem_edit = 2;
mem_edit[current_mem_edit].Draw(cart->GetROM(), cart->GetROMSize());
ImGui::PopFont();
ImGui::EndTabItem();
Expand Down
6 changes: 3 additions & 3 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Audio
void Init();
void Reset();
void Mute(bool mute);
void Tick(unsigned int clock_cycles);
void Tick(unsigned int cycles);
void EndFrame(s16* sample_buffer, int* sample_count);
// void SaveState(std::ostream& stream);
// void LoadState(std::istream& stream);
Expand All @@ -42,7 +42,7 @@ class Audio
bool m_mute;
};

inline void Audio::Tick(unsigned int clock_cycles)
inline void Audio::Tick(unsigned int cycles)
{
m_elapsed_cycles += clock_cycles;
m_elapsed_cycles += cycles;
}
19 changes: 8 additions & 11 deletions src/geargrafx_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,15 @@ void GeargrafxCore::Init(GG_Pixel_Format pixel_format)
m_pixel_format = pixel_format;

m_cartridge = new Cartridge();
m_memory = new Memory(m_cartridge);
m_huc6280 = new HuC6280(m_memory);
m_huc6280 = new HuC6280();
m_input = new Input();
m_memory = new Memory(m_huc6280, m_cartridge, m_input);
m_audio = new Audio();
// m_huc6270 = new HuC6270(m_memory, m_huc6280);
m_input = new Input();

m_cartridge->Init();
m_memory->Init();
m_huc6280->Init();
m_huc6280->Init(m_memory);
m_audio->Init();
// m_huc6270->Init();
m_input->Init();
Expand All @@ -88,9 +88,10 @@ bool GeargrafxCore::RunToVBlank(u8* frame_buffer, s16* sample_buffer, int* sampl
{
unsigned int cpu_clocks = m_huc6280->Tick();
unsigned int timer_clocks = high_speed ? cpu_clocks : cpu_clocks << 2;
unsigned int audio_clocks = high_speed ? cpu_clocks << 1 : cpu_clocks >> 1;
unsigned int video_clocks = high_speed ? cpu_clocks : cpu_clocks << 2;
unsigned int audio_clocks = high_speed ? cpu_clocks << 1 : cpu_clocks >> 1;

m_huc6280->TickTimer(timer_clocks);
// stop = m_huc6270->Tick(clockCycles);
m_audio->Tick(audio_clocks);

Expand Down Expand Up @@ -196,14 +197,10 @@ void GeargrafxCore::KeyReleased(GG_Controllers controller, GG_Keys key)

void GeargrafxCore::Pause(bool paused)
{
if (paused)
{
if (!m_paused && paused)
Log("Geargrafx PAUSED");
}
else
{
else if (m_paused && !paused)
Log("Geargrafx RESUMED");
}
m_paused = paused;
}

Expand Down
Loading

0 comments on commit 66632db

Please sign in to comment.