2020-01-10 21:20:44 -05:00
|
|
|
#pragma once
|
2019-12-02 16:35:49 -05:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2020-10-24 15:39:22 -04:00
|
|
|
#include "z80.h"
|
2019-12-02 16:35:49 -05:00
|
|
|
|
2020-12-05 22:04:22 -05:00
|
|
|
#define MAX_PCHOOK_COUNT 8
|
|
|
|
|
2019-12-02 17:44:54 -05:00
|
|
|
typedef byte (*IORD) ();
|
|
|
|
typedef void (*IOWR) (byte data);
|
2020-10-29 15:01:25 -04:00
|
|
|
typedef byte (*EXCH) (byte data);
|
2019-12-02 16:35:49 -05:00
|
|
|
|
2020-12-05 22:04:22 -05:00
|
|
|
typedef struct _Machine {
|
2019-12-02 16:35:49 -05:00
|
|
|
Z80Context cpu;
|
2019-12-02 17:44:54 -05:00
|
|
|
byte mem[0x10000];
|
2019-12-02 16:35:49 -05:00
|
|
|
// Set to non-zero to specify where ROM ends. Any memory write attempt
|
|
|
|
// below ramstart will trigger a warning.
|
2019-12-02 17:44:54 -05:00
|
|
|
ushort ramstart;
|
|
|
|
// The minimum value reached by SP at any point during execution.
|
|
|
|
ushort minsp;
|
2020-05-14 18:41:09 -04:00
|
|
|
// same principle for IX
|
|
|
|
ushort maxix;
|
2019-12-02 16:35:49 -05:00
|
|
|
// Array of 0x100 function pointers to IO read and write routines. Leave to
|
|
|
|
// NULL when IO port is unhandled.
|
|
|
|
IORD iord[0x100];
|
|
|
|
IOWR iowr[0x100];
|
2020-12-05 22:04:22 -05:00
|
|
|
// function to call when PC falls in one of the hooks
|
|
|
|
void (*pchookfunc) (struct _Machine *m);
|
|
|
|
// List of PC values at which we want to call pchookfunc
|
|
|
|
ushort pchooks[MAX_PCHOOK_COUNT];
|
|
|
|
byte pchooks_cnt;
|
2019-12-02 16:35:49 -05:00
|
|
|
} Machine;
|
|
|
|
|
2020-01-10 21:20:44 -05:00
|
|
|
typedef enum {
|
|
|
|
TRI_HIGH,
|
|
|
|
TRI_LOW,
|
|
|
|
TRI_HIGHZ
|
|
|
|
} Tristate;
|
|
|
|
|
2020-12-05 22:04:22 -05:00
|
|
|
Machine* emul_init(char *binpath, ushort binoffset);
|
2020-05-23 10:08:40 -04:00
|
|
|
void emul_deinit();
|
2019-12-02 16:35:49 -05:00
|
|
|
bool emul_step();
|
2020-01-01 22:48:01 -05:00
|
|
|
bool emul_steps(unsigned int steps);
|
2019-12-02 16:35:49 -05:00
|
|
|
void emul_loop();
|
2020-03-29 22:13:54 -04:00
|
|
|
void emul_trace(ushort addr);
|
2020-04-09 08:26:41 -04:00
|
|
|
void emul_memdump();
|
2020-05-23 14:42:36 -04:00
|
|
|
void emul_debugstr(char *s);
|
2019-12-02 17:44:54 -05:00
|
|
|
void emul_printdebug();
|
2020-10-24 11:18:48 -04:00
|
|
|
// use when a port is a NOOP, but it's not an error to access it.
|
|
|
|
byte iord_noop();
|
|
|
|
void iowr_noop(byte val);
|