OXYGENHUB
◆ main enhanced-x16-emulator / tests / support / video_fixture.c
4.5 KiB · C · last changed chore(): initial commit 25 days ago source blame history raw
9120e874 Andy McCall 1
// Link seam for testing the real video.c.
2
//
3
// video.c is the VERA implementation and the emulator's SDL host rolled into
4
// one file. The emulation half -- register decode, the data ports, address
5
// increment, the layer and sprite arithmetic, video_step() and the framebuffer
6
// -- touches no SDL at all. The host half owns the window, the event pump and
7
// the debugger overlay.
8
//
9
// The tests want the first half and nothing else, so this supplies everything
10
// the second half refers to. Every function here is inert: a test that reaches
11
// one has left emulation and gone into presentation, and wants rewriting rather
12
// than accommodating. Nothing records, because nothing here should be called.
13
//
14
// video_init(), video_update() and video_end() are therefore never called by a
15
// test. video_reset() is, and is deterministic.
16
//
17
// The audio modules are linked for real rather than faked. video.c routes
18
// $9F3B-$9F3D straight into them, they have no dependencies of their own, and
19
// they already have their own tests -- so a fake would add a second thing to
20
// keep true for no benefit.
21
22
#include "video_fixture.h"
23
24
#include "cpu/registers.h"
25
#include "glue.h"
26
27
#include <stdbool.h>
28
#include <stddef.h>
29
#include <stdint.h>
30
31
// ─── Machine state video.c reads ────────────────────────────────────────────
32
33
struct regs regs;
34
35
uint8_t  activity_led;
36
uint8_t  MHZ = 8;
37
uint16_t opcode_addr;
38
bool     warp_mode;
39
bool     testbench;
40
bool     enable_midline;
41
bool     grab_mouse;
42
bool     is_gen2;
43
bool     debugger_enabled;
44
bool     imgui_debugger_enabled;
45
bool     disable_emu_cmd_keys;
46
bool     log_video;
47
// An enum, not a bool: declaring it too narrow leaves the linker with a symbol
48
// smaller than the reads against it (MSVC C4739).
49
gif_recorder_state_t record_gif = RECORD_GIF_PAUSE;
50
char    *gif_path;
51
char     window_title[64] = "x16 test";
52
int      showDebugOnRender;
53
54
// ─── Host side: window, input, lifecycle ────────────────────────────────────
55
56
void machine_dump(const char *reason) { (void)reason; }
57
void machine_nmi(void) { }
58
void machine_paste(char *text, bool handle_free) { (void)text; (void)handle_free; }
59
void machine_reset(void) { }
60
void machine_toggle_warp(void) { }
61
void main_shutdown(void) { }
62
63
void handle_keyboard(bool down, SDL_Keycode sym, SDL_Scancode scancode)
64
	{ (void)down; (void)sym; (void)scancode; }
65
66
void joystick_add(int index) { (void)index; }
67
void joystick_remove(int index) { (void)index; }
68
void joystick_button_down(int instance_id, uint8_t button) { (void)instance_id; (void)button; }
69
void joystick_button_up(int instance_id, uint8_t button) { (void)instance_id; (void)button; }
70
71
void mouse_button_down(int num) { (void)num; }
72
void mouse_button_up(int num) { (void)num; }
73
void mouse_move(int x, int y) { (void)x; (void)y; }
74
void mouse_send_state(void) { }
75
void mouse_set_wheel(int8_t y) { (void)y; }
76
77
void sdcard_attach(void) { }
78
void sdcard_detach(void) { }
79
80
// vera_spi.c drives the card through these; there is no card in a test.
81
bool    sdcard_attached;
82
void    sdcard_select(bool select) { (void)select; }
83
uint8_t sdcard_handle(uint8_t inbyte) { (void)inbyte; return 0xFF; }
84
85
SDL_Surface *CommanderX16Icon(void) { return NULL; }
86
87
// video.c declares these itself under _WIN32 and calls them from window setup.
88
#ifdef _WIN32
89
void video_win32_set_rounded_corners(SDL_Window *window) { (void)window; }
90
void video_win32_install_move_hook(SDL_Window *window) { (void)window; }
91
void video_win32_remove_move_hook(void) { }
92
#endif
93
94
// ─── Debugger overlay ───────────────────────────────────────────────────────
95
96
void DEBUGBreakToDebugger(void) { }
97
void DEBUGFreeUI(void) { }
98
void DEBUGInitUI(SDL_Renderer *r) { (void)r; }
99
void DEBUGRenderDisplay(int width, int height) { (void)width; (void)height; }
100
void DEBUGSetStopReason(const char *reason) { (void)reason; }
101
102
// ─── Audio mixing ───────────────────────────────────────────────────────────
103
//
104
// video.c calls this before every audio register access so the mixer catches up
105
// to the current cycle. The PSG and PCM modules themselves are linked for real;
106
// only the pull from the audio backend is stubbed, since there is no device to
107
// render into.
108
109
void audio_render(void) { }
110