Skip to content

Commit

Permalink
ui: move everything to the dear imgui Table API
Browse files Browse the repository at this point in the history
  • Loading branch information
floooh committed Dec 22, 2024
1 parent 2c29fd2 commit 92b4f9e
Show file tree
Hide file tree
Showing 6 changed files with 318 additions and 307 deletions.
37 changes: 27 additions & 10 deletions ui/ui_ay38910.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ void ui_ay38910_init(ui_ay38910_t* win, const ui_ay38910_desc_t* desc) {
win->init_x = (float) desc->x;
win->init_y = (float) desc->y;
win->init_w = (float) ((desc->w == 0) ? 440 : desc->w);
win->init_h = (float) ((desc->h == 0) ? 378 : desc->h);
win->init_h = (float) ((desc->h == 0) ? 420 : desc->h);
win->open = desc->open;
win->valid = true;
ui_chip_init(&win->chip, &desc->chip_desc);
Expand Down Expand Up @@ -163,15 +163,32 @@ static void _ui_ay38910_draw_state(ui_ay38910_t* win) {
}
ImGui::EndTable();
}
ImGui::Separator();
ImGui::Text("Noise Period %02X (reg:%02X)", ay->noise.period, ay->reg[AY38910_REG_PERIOD_NOISE]);
ImGui::Text("Noise Count %02X", ay->noise.counter);
ImGui::Text("Noise Rand %05X", ay->noise.rng);
ImGui::Text("Noise Bit %s", ay->noise.bit ? "ON":"OFF");
ImGui::Separator();
ImGui::Text("Env Period %04X (reg:%04X)", ay->env.period, (ay->reg[AY38910_REG_ENV_PERIOD_COARSE]<<8)|ay->reg[AY38910_REG_ENV_PERIOD_FINE]);
ImGui::Text("Env Count %04X", ay->env.counter);
ImGui::Text("Env Ampl %02X", ay->env.shape_state);
if (ImGui::BeginTable("##ay_noise", 2)) {
ImGui::TableSetupColumn("Noise", ImGuiTableColumnFlags_WidthFixed, 86);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Text("Period"); ImGui::TableNextColumn();
ImGui::Text("%02X (reg:%02X)", ay->noise.period, ay->reg[AY38910_REG_PERIOD_NOISE]); ImGui::TableNextColumn();
ImGui::Text("Count"); ImGui::TableNextColumn();
ImGui::Text("%02X", ay->noise.counter); ImGui::TableNextColumn();
ImGui::Text("Rand"); ImGui::TableNextColumn();
ImGui::Text("%05X", ay->noise.rng); ImGui::TableNextColumn();
ImGui::Text("Bit"); ImGui::TableNextColumn();
ImGui::Text("%s", ay->noise.bit ? "ON":"OFF"); ImGui::TableNextColumn();
ImGui::EndTable();
}
if (ImGui::BeginTable("##ay_envelope", 2)) {
ImGui::TableSetupColumn("Envelope", ImGuiTableColumnFlags_WidthFixed, 86);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Text("Period"); ImGui::TableNextColumn();
ImGui::Text("%04X (reg:%04X)", ay->env.period, (ay->reg[AY38910_REG_ENV_PERIOD_COARSE]<<8)|ay->reg[AY38910_REG_ENV_PERIOD_FINE]); ImGui::TableNextColumn();
ImGui::Text("Count"); ImGui::TableNextColumn();
ImGui::Text("%04X", ay->env.counter); ImGui::TableNextColumn();
ImGui::Text("Amplitude"); ImGui::TableNextColumn();
ImGui::Text("%02X", ay->env.shape_state); ImGui::TableNextColumn();
ImGui::EndTable();
}
const int num_ports = (ay->type==AY38910_TYPE_8910) ? 2 : ((ay->type == AY38910_TYPE_8912) ? 1 : 0);
const int max_ports = 2;
if (ImGui::BeginTable("##ay_ports", max_ports + 1)) {
Expand Down
169 changes: 83 additions & 86 deletions ui/ui_m6526.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,95 +122,92 @@ void ui_m6526_discard(ui_m6526_t* win) {

static void _ui_m6526_draw_state(ui_m6526_t* win) {
const m6526_t* cia = win->cia;
ImGui::Columns(3, "##cia_columns", false);
ImGui::SetColumnWidth(0, 64);
ImGui::SetColumnWidth(1, 80);
ImGui::SetColumnWidth(2, 80);

/* ports */
ImGui::NextColumn();
ImGui::Text("Port A"); ImGui::NextColumn();
ImGui::Text("Port B"); ImGui::NextColumn();
ImGui::Separator();
ImGui::Text("DDR"); ImGui::NextColumn();
ui_util_b8("", cia->pa.ddr); ImGui::NextColumn();
ui_util_b8("", cia->pb.ddr); ImGui::NextColumn();
ImGui::Text("Reg"); ImGui::NextColumn();
ui_util_b8("", cia->pa.reg); ImGui::NextColumn();
ui_util_b8("", cia->pb.reg); ImGui::NextColumn();
ImGui::Text("Inp"); ImGui::NextColumn();
ui_util_b8("", cia->pa.inp); ImGui::NextColumn();
ui_util_b8("", cia->pb.inp); ImGui::NextColumn();
ImGui::Text("Pins"); ImGui::NextColumn();
ui_util_b8("", cia->pa.pins); ImGui::NextColumn();
ui_util_b8("", cia->pb.pins); ImGui::NextColumn();

/* timers */
ImGui::Separator();
ImGui::NextColumn();
ImGui::Text("Timer A"); ImGui::NextColumn();
ImGui::Text("Timer B"); ImGui::NextColumn();
ImGui::Separator();
ImGui::Text("Latch"); ImGui::NextColumn();
ImGui::Text("%04X", cia->ta.latch); ImGui::NextColumn();
ImGui::Text("%04X", cia->tb.latch); ImGui::NextColumn();
ImGui::Text("Counter"); ImGui::NextColumn();
ImGui::Text("%04X", cia->ta.counter); ImGui::NextColumn();
ImGui::Text("%04X", cia->tb.counter); ImGui::NextColumn();
ImGui::Text("Control"); ImGui::NextColumn();
ui_util_b8("", cia->ta.cr); ImGui::NextColumn();
ui_util_b8("", cia->tb.cr); ImGui::NextColumn();
ImGui::Text(":START"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TIMER_STARTED(cia->ta.cr) ? "STARTED":"STOP"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TIMER_STARTED(cia->tb.cr) ? "STARTED":"STOP"); ImGui::NextColumn();
ImGui::Text(":PBON"); ImGui::NextColumn();
ImGui::Text("%s", M6526_PBON(cia->ta.cr) ? "PB6":"---"); ImGui::NextColumn();
ImGui::Text("%s", M6526_PBON(cia->tb.cr) ? "PB7":"---"); ImGui::NextColumn();
ImGui::Text(":OUTMODE"); ImGui::NextColumn();
ImGui::Text("%s", M6526_OUTMODE_TOGGLE(cia->ta.cr) ? "TOGGLE":"PULSE"); ImGui::NextColumn();
ImGui::Text("%s", M6526_OUTMODE_TOGGLE(cia->tb.cr) ? "TOGGLE":"PULSE"); ImGui::NextColumn();
ImGui::Text(":RUNMODE"); ImGui::NextColumn();
ImGui::Text("%s", M6526_RUNMODE_ONESHOT(cia->ta.cr) ? "ONESHOT":"CONT"); ImGui::NextColumn();
ImGui::Text("%s", M6526_RUNMODE_ONESHOT(cia->tb.cr) ? "ONESHOT":"CONT"); ImGui::NextColumn();
ImGui::Text(":INMODE"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TA_INMODE_PHI2(cia->ta.cr) ? "PHI2":"CNT"); ImGui::NextColumn();
if (M6526_TB_INMODE_PHI2(cia->tb.cr)) {
ImGui::Text("PHI2");
if (ImGui::BeginTable("##cia_ports", 3)) {
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 64);
ImGui::TableSetupColumn("Port A", ImGuiTableColumnFlags_WidthFixed, 72);
ImGui::TableSetupColumn("Port B", ImGuiTableColumnFlags_WidthFixed, 72);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Text("DDR"); ImGui::TableNextColumn();
ui_util_b8("", cia->pa.ddr); ImGui::TableNextColumn();
ui_util_b8("", cia->pb.ddr); ImGui::TableNextColumn();
ImGui::Text("Reg"); ImGui::TableNextColumn();
ui_util_b8("", cia->pa.reg); ImGui::TableNextColumn();
ui_util_b8("", cia->pb.reg); ImGui::TableNextColumn();
ImGui::Text("Inp"); ImGui::TableNextColumn();
ui_util_b8("", cia->pa.inp); ImGui::TableNextColumn();
ui_util_b8("", cia->pb.inp); ImGui::TableNextColumn();
ImGui::Text("Pins"); ImGui::TableNextColumn();
ui_util_b8("", cia->pa.pins); ImGui::TableNextColumn();
ui_util_b8("", cia->pb.pins); ImGui::TableNextColumn();
ImGui::EndTable();
}
else if (M6526_TB_INMODE_CNT(cia->tb.cr)) {
ImGui::Text("CNT");
if (ImGui::BeginTable("##cia_timers", 3)) {
ImGui::TableSetupColumn("", ImGuiTableColumnFlags_WidthFixed, 64);
ImGui::TableSetupColumn("Timer A", ImGuiTableColumnFlags_WidthFixed, 72);
ImGui::TableSetupColumn("Timer B", ImGuiTableColumnFlags_WidthFixed, 72);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Text("Latch"); ImGui::TableNextColumn();
ImGui::Text("%04X", cia->ta.latch); ImGui::TableNextColumn();
ImGui::Text("%04X", cia->tb.latch); ImGui::TableNextColumn();
ImGui::Text("Counter"); ImGui::TableNextColumn();
ImGui::Text("%04X", cia->ta.counter); ImGui::TableNextColumn();
ImGui::Text("%04X", cia->tb.counter); ImGui::TableNextColumn();
ImGui::Text("Control"); ImGui::TableNextColumn();
ui_util_b8("", cia->ta.cr); ImGui::TableNextColumn();
ui_util_b8("", cia->tb.cr); ImGui::TableNextColumn();
ImGui::Text(" START"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TIMER_STARTED(cia->ta.cr) ? "STARTED":"STOP"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TIMER_STARTED(cia->tb.cr) ? "STARTED":"STOP"); ImGui::TableNextColumn();
ImGui::Text(" PBON"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_PBON(cia->ta.cr) ? "PB6":"---"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_PBON(cia->tb.cr) ? "PB7":"---"); ImGui::TableNextColumn();
ImGui::Text(" OUTMODE"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_OUTMODE_TOGGLE(cia->ta.cr) ? "TOGGLE":"PULSE"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_OUTMODE_TOGGLE(cia->tb.cr) ? "TOGGLE":"PULSE"); ImGui::TableNextColumn();
ImGui::Text(" RUNMODE"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_RUNMODE_ONESHOT(cia->ta.cr) ? "ONESHOT":"CONT"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_RUNMODE_ONESHOT(cia->tb.cr) ? "ONESHOT":"CONT"); ImGui::TableNextColumn();
ImGui::Text(" INMODE"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TA_INMODE_PHI2(cia->ta.cr) ? "PHI2":"CNT"); ImGui::TableNextColumn();
if (M6526_TB_INMODE_PHI2(cia->tb.cr)) {
ImGui::Text("PHI2");
} else if (M6526_TB_INMODE_CNT(cia->tb.cr)) {
ImGui::Text("CNT");
} else if (M6526_TB_INMODE_TA(cia->tb.cr)) {
ImGui::Text("TA");
} else if (M6526_TB_INMODE_TACNT(cia->tb.cr)) {
ImGui::Text("TACNT");
}
ImGui::TableNextColumn();
ImGui::Text(" SPMODE"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TA_SPMODE_OUTPUT(cia->ta.cr) ? "OUTPUT":"INPUT"); ImGui::TableNextColumn();
ImGui::Text("---"); ImGui::TableNextColumn();
ImGui::Text(" TODIN"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TA_TODIN_50HZ(cia->ta.cr) ? "50HZ":"60HZ"); ImGui::TableNextColumn();
ImGui::Text("---"); ImGui::TableNextColumn();
ImGui::Text(" ALARM"); ImGui::TableNextColumn();
ImGui::Text("%s", M6526_TB_ALARM_ALARM(cia->ta.cr) ? "ALARM":"CLOCK"); ImGui::TableNextColumn();
ImGui::Text("---"); ImGui::TableNextColumn();
ImGui::Text("Bit"); ImGui::TableNextColumn();
ImGui::Text("%s", cia->ta.t_bit ? "ON":"OFF"); ImGui::TableNextColumn();
ImGui::Text("%s", cia->tb.t_bit ? "ON":"OFF"); ImGui::TableNextColumn();
ImGui::Text("Out"); ImGui::TableNextColumn();
ImGui::Text("%s", cia->ta.t_out ? "ON":"OFF"); ImGui::TableNextColumn();
ImGui::Text("%s", cia->tb.t_out ? "ON":"OFF"); ImGui::TableNextColumn();
ImGui::EndTable();
}
else if (M6526_TB_INMODE_TA(cia->tb.cr)) {
ImGui::Text("TA");
if (ImGui::BeginTable("##cia_interrupt", 2)) {
ImGui::TableSetupColumn("Interrupt", ImGuiTableColumnFlags_WidthFixed, 64);
ImGui::TableHeadersRow();
ImGui::TableNextColumn();
ImGui::Text("Mask"); ImGui::TableNextColumn();
ui_util_b8("", cia->intr.imr); ImGui::TableNextColumn();
ImGui::Text("Control"); ImGui::TableNextColumn();
ui_util_b8("", cia->intr.icr); ImGui::TableNextColumn();
ImGui::EndTable();
}
else if (M6526_TB_INMODE_TACNT(cia->tb.cr)) {
ImGui::Text("TACNT");
}
ImGui::NextColumn();
ImGui::Text(":SPMODE"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TA_SPMODE_OUTPUT(cia->ta.cr) ? "OUTPUT":"INPUT"); ImGui::NextColumn();
ImGui::Text("---"); ImGui::NextColumn();
ImGui::Text(":TODIN"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TA_TODIN_50HZ(cia->ta.cr) ? "50HZ":"60HZ"); ImGui::NextColumn();
ImGui::Text("---"); ImGui::NextColumn();
ImGui::Text(":ALARM"); ImGui::NextColumn();
ImGui::Text("%s", M6526_TB_ALARM_ALARM(cia->ta.cr) ? "ALARM":"CLOCK"); ImGui::NextColumn();
ImGui::Text("---"); ImGui::NextColumn();
ImGui::Text("Bit"); ImGui::NextColumn();
ImGui::Text("%s", cia->ta.t_bit ? "ON":"OFF"); ImGui::NextColumn();
ImGui::Text("%s", cia->tb.t_bit ? "ON":"OFF"); ImGui::NextColumn();
ImGui::Text("Out"); ImGui::NextColumn();
ImGui::Text("%s", cia->ta.t_out ? "ON":"OFF"); ImGui::NextColumn();
ImGui::Text("%s", cia->tb.t_out ? "ON":"OFF"); ImGui::NextColumn();

/* interrupt */
ImGui::Columns();
ImGui::Separator();
ImGui::Text("Interrupt");
ImGui::Separator();
ui_util_b8("Mask ", cia->intr.imr);
ui_util_b8("Control ", cia->intr.icr);

}

void ui_m6526_draw(ui_m6526_t* win) {
Expand Down
Loading

0 comments on commit 92b4f9e

Please sign in to comment.