Skip to content

Commit

Permalink
GPIO minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
telecomadm1145 committed Aug 20, 2024
1 parent 62fa758 commit 7b4a274
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CasioEmuMsvc/Chipset/Chipset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ namespace casioemu {
}

void Chipset::RaiseSoftware(size_t index) {
if (tiDiagMode && index == 0x02) {
if ((tiDiagMode || !emulator.modeldef.real_hardware) && index == 0x02) {
emulator.chipset.cpu.reg_r[1] = 0;
emulator.chipset.cpu.reg_r[0] = tiKey;
tiKey = 0;
Expand Down
5 changes: 2 additions & 3 deletions CasioEmuMsvc/Gui/Editors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ inline auto Highlight_Default(auto he) {

std::vector<UIWindow*> GetEditors() {
SetupHook(on_memory_write, [](casioemu::MMU& mmu, MemoryEventArgs& mea) {
// if (mmu.ReadData(mea.offset) != mea.value)
if (mea.offset < 0x10000)
if (mea.offset < 0x80000)
ram_edit_ov[mea.offset] = 255;
});
std::vector<UIWindow*> windows;
Expand All @@ -72,7 +71,7 @@ std::vector<UIWindow*> GetEditors() {
GetCommonMemLabels(m_emu->hardware_id)})));
windows.push_back(new HexEditor{"Rom", m_emu->chipset.rom_data.data(), m_emu->chipset.rom_data.size(), 0});
if (m_emu->hardware_id == casioemu::HW_FX_5800P) {
windows.push_back(MMU_Hex(new HexEditor{"PRam", (void*)0x40000, 0x8000, 0x40000}));
windows.push_back(MMU_Hex(new SpansHexEditor{"PRam", (void*)0x40000, 0x8000, 0x40000, GetCommonMemLabels(m_emu->hardware_id)}));
windows.push_back(new HexEditor{"Flash", m_emu->chipset.flash_data.data(), m_emu->chipset.flash_data.size(), 0});
}
windows.push_back(MMU_Hex(new HexEditor{"All", 0, 0xfffff, 0}));
Expand Down
15 changes: 14 additions & 1 deletion CasioEmuMsvc/Peripheral/Keyboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,13 @@ namespace casioemu {
clock_type = CLOCK_UNDEFINED;
if (emulator.hardware_id == HW_TI) {
auto pp = emulator.chipset.QueryInterface<IPortProvider>();
if (!pp)
return;
pp->SetPortOutputCallback(3, [&](uint8_t new_output) {
keyboard_out = new_output;
RecalculateKI();
});
pp->SetPortInput(0, 0, 0x20);
pp->SetPortInput(4, 0, 0xff);
goto init_kbd;
}
Expand Down Expand Up @@ -596,10 +599,20 @@ namespace casioemu {
void Keyboard::RecalculateKI() {
if (emulator.hardware_id == HW_TI) {
auto pp = emulator.chipset.QueryInterface<IPortProvider>();
if (!pp) // No port provider :(
return;
auto is_on_pressed = false;
keyboard_in = 0;
for (auto& button : buttons)
for (auto& button : buttons) {
if (button.code == 0x29) { // right, [ON] is a gpio button xd
if (button.pressed)
is_on_pressed = true;
continue;
}
if (button.type == Button::BT_BUTTON && button.pressed && button.ko_bit & keyboard_out)
keyboard_in |= button.ki_bit;
}
pp->SetPortInput(0, is_on_pressed ? 0x20 : 0, 0x20);
pp->SetPortInput(4, keyboard_in, 0xff);
return;
}
Expand Down
4 changes: 2 additions & 2 deletions CasioEmuMsvc/Peripheral/ML620Ports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ namespace casioemu {
auto d = ExiSelect_d[j] & 0xf;
if (d > 7)
continue;
auto rise = ExiCon_d[1], fall = ExiCon_d[0];
auto it = ((After & (After ^ Before) & rise) | (Before & (After ^ Before) & fall)) & (1 << d);
auto rise = ExiCon_d[1] & (1 << j) ? (1 << d) : 0, fall = ExiCon_d[0] & (1 << j) ? (1 << d) : 0;
auto it = ((After & (After ^ Before) & rise) | (Before & (After ^ Before) & fall));
if (it)
emulator.chipset.MaskableInterrupts[7 + j].TryRaise();
}
Expand Down
2 changes: 1 addition & 1 deletion CasioEmuMsvc/Peripheral/Timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ namespace casioemu {
};
Peripheral* CreateTimer(Emulator& emu) {
if (emu.hardware_id == HW_TI) {
//return new Timer16Bit(emu);
return new Timer16Bit(emu);
}
return new Timer(emu);
}
Expand Down
2 changes: 1 addition & 1 deletion CasioEmuMsvc/Peripheral/TimerBaseCounter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace casioemu {
clock_type = CLOCK_LSCLK;

reg_LTBINT.Setup(
0xF064, 2, "Chipset/LTBINT", this,
0xF064, 2, "TimerBaseCounter/LTBINT", this,
[](MMURegion* sender, size_t offset) -> uint8_t {
auto pthis = (TBC2*)sender->userdata;
if (offset == 0xF064) {
Expand Down

0 comments on commit 7b4a274

Please sign in to comment.