mirror of
https://github.com/hsoft/collapseos.git
synced 2024-11-24 00:38:06 +11:00
97a46a7b9b
My idea of plugging a RC2014 bridge directly onto a Sega Master System cartridge doesn't work. The SMS eats all I/O addr space, we can't use it. Therefore, this naive idea, in the emulator, of reusing sdc.c in sms.c as-is, doesn't work either. I'll have to find another way of communicating to a SPI device on the SMS. I'll probably do it through a controller port. Meanwhile, I need to decouple SPI from SDC in the emulator code so that I can reuse sdc.c. This is what is done here.
44 lines
1.1 KiB
C
44 lines
1.1 KiB
C
#pragma once
|
|
#include <stdint.h>
|
|
#include <stdbool.h>
|
|
#include "z80.h"
|
|
|
|
typedef byte (*IORD) ();
|
|
typedef void (*IOWR) (byte data);
|
|
typedef byte (*EXCH) (byte data);
|
|
|
|
typedef struct {
|
|
Z80Context cpu;
|
|
byte mem[0x10000];
|
|
// Set to non-zero to specify where ROM ends. Any memory write attempt
|
|
// below ramstart will trigger a warning.
|
|
ushort ramstart;
|
|
// The minimum value reached by SP at any point during execution.
|
|
ushort minsp;
|
|
// same principle for IX
|
|
ushort maxix;
|
|
// 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;
|
|
|
|
typedef enum {
|
|
TRI_HIGH,
|
|
TRI_LOW,
|
|
TRI_HIGHZ
|
|
} Tristate;
|
|
|
|
Machine* emul_init();
|
|
void emul_deinit();
|
|
bool emul_step();
|
|
bool emul_steps(unsigned int steps);
|
|
void emul_loop();
|
|
void emul_trace(ushort addr);
|
|
void emul_memdump();
|
|
void emul_debugstr(char *s);
|
|
void emul_printdebug();
|
|
// use when a port is a NOOP, but it's not an error to access it.
|
|
byte iord_noop();
|
|
void iowr_noop(byte val);
|