Files
CoCo3_Plus_MiSTer/verilator/sim/sim_input.h
T
Alan SterembergandClaude Opus 5.5 874f4f3083 Add Verilator simulation (ImGui + headless)
verilator/ runs the core on the host with the shared FM-7 / Apple-IIgs sim
framework: windowed (ImGui/SDL2) or --headless, typing on a frame schedule,
screenshots, text-screen dump, 6809 disassembly trace, floppy/SDC/cart/cassette,
and RS-232 Pak serial debugging (TXD decoder, RXD driver, pty bridge, ACIA
trace) with a minimal DriveWire server and a script to run the real FujiNet
daemon against the sim. See verilator/README.md.

- The VHDL the build uses (ROMs, RAMs, font) is converted to Verilog in
  verilator/rtl/; the VHDL CPU is not instantiated (CoCo3_CYC_ACC_6809).
- sdram2.sv is simulated with its own controller logic and an SDR chip model.
- run_tests.sh: boot, keyboard, disk, WIDTH 80 and HSCREEN tests, judged on
  the text screen and byte-for-byte against test-ref/ screenshots.

rtl/wd1793.sv: spt_addr and buff_wr are declared at module scope instead of
inside generate blocks. They are assigned outside those blocks; Quartus
accepted it, Verilator rejected spt_addr and silently split buff_wr into a
separate net. No change on the FPGA (FM-7 made the same fix).

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-02 07:15:44 -04:00

72 lines
1.8 KiB
C++

#pragma once
#ifndef _MSC_VER
#else
#define WIN32
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
#endif
#include "verilated.h"
#include <queue>
#include <vector>
#include <set>
struct SimInput_PS2KeyEvent {
public:
char code;
bool pressed;
bool extended;
unsigned int mapped;
SimInput_PS2KeyEvent(char code, bool pressed, bool extended, unsigned int mapped) {
this->code = code;
this->pressed = pressed;
this->extended = extended;
this->mapped = mapped;
}
};
struct SimInput {
public:
int inputCount = 0;
bool inputs[16];
int mappings[16];
SData* ps2_key = NULL;
// Host scancodes the harness claims for itself and must NOT forward to the
// core. The capture hotkeys are ordinary printable keys -- see sim_main.cpp
// for why they are not function keys -- so without this, grabbing a frame
// also types a bracket into whatever the machine is running.
std::set<int> suppressScancodes;
std::queue<SimInput_PS2KeyEvent> keyEvents;
unsigned int keyEventTimer = 0;
unsigned int keyEventWait = 50000;
#define NONE 0xFF
#define LCTRL 0x000100
#define LSHIFT 0x000200
#define LALT 0x000400
#define LGUI 0x000800
#define RCTRL 0x001000
#define RSHIFT 0x002000
#define RALT 0x004000
#define RGUI 0x008000
#define MODMASK 0x00FF00
#define OSD 0x010000 // to be used by OSD, not the core itself
#define OSD_OPEN 0x020000 // OSD key not forwarded to core, but queued in arm controller
#define CAPS_TOGGLE 0x040000 // caps lock toggle behaviour
#define EXT 0x080000
#define EMU_SWITCH_1 0x100000
#define EMU_SWITCH_2 0x200000
void Read();
int Initialise();
void CleanUp();
void SetMapping(int index, int code);
void BeforeEval(void);
SimInput(int count, DebugConsole c);
~SimInput();
};