2020-01-11 13:20:44 +11:00
|
|
|
#pragma once
|
2019-12-03 08:35:49 +11:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
2020-10-25 06:39:22 +11:00
|
|
|
#include "z80.h"
|
2019-12-03 08:35:49 +11:00
|
|
|
|
2019-12-03 09:44:54 +11:00
|
|
|
typedef byte (*IORD) ();
|
|
|
|
typedef void (*IOWR) (byte data);
|
2020-10-30 06:01:25 +11:00
|
|
|
typedef byte (*EXCH) (byte data);
|
2019-12-03 08:35:49 +11:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
Z80Context cpu;
|
2019-12-03 09:44:54 +11:00
|
|
|
byte mem[0x10000];
|
2019-12-03 08:35:49 +11:00
|
|
|
// Set to non-zero to specify where ROM ends. Any memory write attempt
|
|
|
|
// below ramstart will trigger a warning.
|
2019-12-03 09:44:54 +11:00
|
|
|
ushort ramstart;
|
|
|
|
// The minimum value reached by SP at any point during execution.
|
|
|
|
ushort minsp;
|
2020-05-15 08:41:09 +10:00
|
|
|
// same principle for IX
|
|
|
|
ushort maxix;
|
2019-12-03 08:35:49 +11: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];
|
|
|
|
} Machine;
|
|
|
|
|
2020-01-11 13:20:44 +11:00
|
|
|
typedef enum {
|
|
|
|
TRI_HIGH,
|
|
|
|
TRI_LOW,
|
|
|
|
TRI_HIGHZ
|
|
|
|
} Tristate;
|
|
|
|
|
2019-12-03 08:35:49 +11:00
|
|
|
Machine* emul_init();
|
2020-05-24 00:08:40 +10:00
|
|
|
void emul_deinit();
|
2019-12-03 08:35:49 +11:00
|
|
|
bool emul_step();
|
2020-01-02 14:48:01 +11:00
|
|
|
bool emul_steps(unsigned int steps);
|
2019-12-03 08:35:49 +11:00
|
|
|
void emul_loop();
|
2020-03-30 13:13:54 +11:00
|
|
|
void emul_trace(ushort addr);
|
2020-04-09 22:26:41 +10:00
|
|
|
void emul_memdump();
|
2020-05-24 04:42:36 +10:00
|
|
|
void emul_debugstr(char *s);
|
2019-12-03 09:44:54 +11:00
|
|
|
void emul_printdebug();
|
2020-10-25 02:18:48 +11: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);
|