Mirror of CollapseOS
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5KB

  1. #pragma once
  2. #include <stdint.h>
  3. #include <stdbool.h>
  4. #include "z80.h"
  5. #define MAX_PCHOOK_COUNT 8
  6. #define LEN8BIT 0x100
  7. #define LEN16BIT 0x10000
  8. typedef byte (*IORD) ();
  9. typedef void (*IOWR) (byte data);
  10. typedef byte (*EXCH) (byte data);
  11. typedef struct _Machine {
  12. Z80Context cpu;
  13. byte mem[LEN16BIT];
  14. // Set to non-zero to specify where ROM ends. Any memory write attempt
  15. // below ramstart will trigger a warning.
  16. ushort ramstart;
  17. // The minimum value reached by SP at any point during execution.
  18. ushort minsp;
  19. // same principle for IX
  20. ushort maxix;
  21. // Array of 0x100 function pointers to IO read and write routines. Leave to
  22. // NULL when IO port is unhandled.
  23. IORD iord[LEN8BIT];
  24. IOWR iowr[LEN8BIT];
  25. // function to call when PC falls in one of the hooks
  26. void (*pchookfunc) (struct _Machine *m);
  27. // List of PC values at which we want to call pchookfunc
  28. ushort pchooks[MAX_PCHOOK_COUNT];
  29. byte pchooks_cnt;
  30. } Machine;
  31. typedef enum {
  32. TRI_HIGH,
  33. TRI_LOW,
  34. TRI_HIGHZ
  35. } Tristate;
  36. Machine* emul_init(char *binpath, ushort binoffset);
  37. bool emul_step();
  38. bool emul_steps(unsigned int steps);
  39. void emul_loop();
  40. void emul_trace(ushort addr);
  41. void emul_memdump();
  42. void emul_debugstr(char *s);
  43. void emul_printdebug();
  44. uint8_t emul_mem_read(int unused, uint16_t addr);
  45. void emul_mem_write(int unused, uint16_t addr, uint8_t val);
  46. // use when a port is a NOOP, but it's not an error to access it.
  47. byte iord_noop();
  48. void iowr_noop(byte val);