2020-01-11 13:20:44 +11:00
|
|
|
#pragma once
|
2019-12-03 08:35:49 +11:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include "libz80/z80.h"
|
|
|
|
|
2019-12-03 09:44:54 +11:00
|
|
|
typedef byte (*IORD) ();
|
|
|
|
typedef void (*IOWR) (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;
|
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();
|
|
|
|
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();
|
2019-12-03 09:44:54 +11:00
|
|
|
void emul_printdebug();
|