OXYGENHUB
◆ rrdc-perf enhanced-x16-emulator / src / smc.h
1.5 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
9120e874 Andy McCall 1
// Commander X16 Emulator
2
// Copyright (c) 2021 Michael Steil
3
// All rights reserved. License: 2-clause BSD
4
5
#ifndef _SMC_H_
6
#define _SMC_H_
7
8
#define SMC_VERSION_MAJOR 47
9
#define SMC_VERSION_MINOR 0
10
#define SMC_VERSION_PATCH 0
11
12
#include <stdint.h>
13
#include <stdbool.h>
14
15
#ifdef __cplusplus
16
extern "C" {
17
#endif
18
19
extern void nmi6502();
20
void smc_i2c_data(uint8_t v);
21
uint8_t smc_read();
22
void smc_write();
23
24
extern bool smc_requested_reset;
25
26
// ─── Debugger accessor ───────────────────────────────────────────────────────
27
// Side-effect-free snapshot of SMC state. Safe to call every frame from the
28
// debugger while the emulation is running.
29
30
#define SMC_I2C_DATA_LEN 16
31
32
typedef struct {
33
	uint8_t default_read_op;                  // current default read operation register
34
	uint8_t activity_led;                     // activity LED brightness (0 or 255)
35
	uint8_t i2c_data[SMC_I2C_DATA_LEN];      // pending I2C data buffer
36
	uint8_t i2c_data_pos;                     // write position in i2c_data[]
37
	uint8_t mse_count;                        // mouse packet byte counter
38
	bool    requested_reset;                  // SMC has requested a machine reset
39
	uint8_t kbd_fill;                         // keyboard buffer occupancy (bytes pending)
40
	uint8_t mse_fill;                         // mouse buffer occupancy (bytes pending)
41
} smc_debug_state_t;
42
43
void smc_debug_get_state(smc_debug_state_t *out);
44
45
#ifdef __cplusplus
46
}
47
#endif
48
49
#endif