| 1 | // Recording stand-ins for the devices behind the I/O page, so memory.c can be |
| 2 | // linked and exercised without SDL, a ROM, or any real hardware model. |
| 3 | // |
| 4 | // This is the seam the debugger contract lives on. real_read6502() carries a |
| 5 | // debugOn flag down to every device, and the rule is that a debug read reports |
| 6 | // what is there without disturbing anything: no device state moved, no cycles |
| 7 | // spent. Nothing enforces that today, and it can break from either side -- a |
| 8 | // debugger path that forgets the flag, or a device that gains a side effect and |
| 9 | // ignores it. |
| 10 | // |
| 11 | // Each fake records what it was asked and, crucially, models a device that has |
| 12 | // something to lose: a real read advances `state`, standing in for VERA's |
| 13 | // address auto-increment or the VIA's read-to-clear interrupt flag. A debug |
| 14 | // read that moves `state` has broken the contract, and the test can say so |
| 15 | // without knowing anything about the device it is standing in for. |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | typedef enum |
| 24 | |
| 25 | |
| 26 | |
| 27 | |
| 28 | |
| 29 | |
| 30 | |
| 31 | fake_dev_t; |
| 32 | |
| 33 | typedef struct |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 | |
| 39 | |
| 40 | |
| 41 | |
| 42 | fake_dev_log_t; |
| 43 | |
| 44 | extern fake_dev_log_t fake_dev; |
| 45 | |
| 46 | const char *; |
| 47 | |
| 48 | // Clear every log and every device's state. Also zeroes the CPU cycle counter, |
| 49 | // since "did this read cost anything?" is half of the contract. |
| 50 | void ; |
| 51 | |
| 52 | // Total device state across all fakes, for asserting that a sweep of the I/O |
| 53 | // page moved nothing. |
| 54 | uint32_t ; |
| 55 | |
| 56 | // Reads and writes seen by every fake since the last reset. |
| 57 | int ; |
| 58 | int ; |
| 59 | |
| 60 | // YM_read_status() takes no debug flag, so the YM fake cannot tell a debug read |
| 61 | // from a real one and always advances. Tests that sweep the I/O page have to |
| 62 | // account for that rather than pretend otherwise. |
| 63 | |
| 64 | |
| 65 | // X16_TEST_FAKE_DEVICES_H |