#ifndef _DEBUGGER_H
#define _DEBUGGER_H 1
+#if 0 // set to 1 to enable debugging printf
+#define debugger_instruction_hook(addr) fprintf(stderr, "%04x\n", addr);
+#else
#define debugger_instruction_hook(addr)
+#endif
#endif
assert(!m_icountptr);
m_icountptr = &icount;
}
+ int standard_irq_callback_member(device_t &device, int irqline) {
+ return standard_irq_callback(device, irqline);
+ }
+ virtual int standard_irq_callback(device_t &device, int irqline) = 0;
};
class machine_config {
union PAIR
{
//nick#ifdef LSB_FIRST
- struct { u8 l,h,h2,h3; } b;
- struct { u16 l,h; } w;
- struct { s8 l,h,h2,h3; } sb;
- struct { s16 l,h; } sw;
+ struct { u8 l,h,h2,h3; } b;
+ struct { u16 l,h; } w;
+ struct { s8 l,h,h2,h3; } sb;
+ struct { s16 l,h; } sw;
//nick#else
-//nick struct { u8 h3,h2,h,l; } b;
-//nick struct { s8 h3,h2,h,l; } sb;
-//nick struct { u16 h,l; } w;
-//nick struct { s16 h,l; } sw;
+//nick struct { u8 h3,h2,h,l; } b;
+//nick struct { s8 h3,h2,h,l; } sb;
+//nick struct { u16 h,l; } w;
+//nick struct { s16 h,l; } sw;
//nick#endif
- u32 d;
- s32 sd;
+ u32 d;
+ s32 sd;
};
-#define INPUT_LINE_NMI 0
+enum {
+ INPUT_LINE_NMI = -1
+ // device specific input lines start at 0
+};
-#define CLEAR_LINE 0
-#define ASSERT_LINE 1
+enum {
+ CLEAR_LINE,
+ ASSERT_LINE
+};
#endif
#define _LOGMACRO_H 1
#include <stdio.h>
-#define LOG printf
-#define logerror printf
+
+#if 0 // set to 1 to enable debugging printf
+#define LOG(...) fprintf(stderr, __VA_ARGS__)
+#define logerror(...) fprintf(stderr, __VA_ARGS__)
+#else
+#define LOG(msg, ...)
+#define logerror(msg, ...)
+#endif
#endif
device_z80daisy_interface *daisy_get_irq_device() {
return NULL;
}
- int standard_irq_callback_member(device_t &device, int irqline) {
- return 0;
- }
};
#endif
#include "sim.h"
#include "simglb.h"
#include "memory.h"
+#include "../z180/z180.h"
#define BUFSIZE 256 /* max line length of command buffer */
#define MAX_BUSY_COUNT 10 /* max counter to detect I/O busy waiting
*/
static void time_out(BYTE data)
{
+#if 1 // set to 0 to disable timer interrupts
static struct itimerval tim;
static struct sigaction newact;
tim.it_value.tv_usec = 0;
setitimer(ITIMER_REAL, &tim, NULL);
}
+#endif
}
/*
{
sig = sig; /* to avoid compiler warning */
-#if 0
+#if 1
+ cpu_dev->execute_set_input(Z180_INPUT_LINE_IRQ0, ASSERT_LINE);
+ //fputc('!', stderr);
+#else
int_int = 1;
- int_data = 0xff; /* RST 38H for IM 0, 0FFH for IM 2 */
#endif
+ int_data = 0xff; /* RST 38H for IM 0, 0FFH for IM 2 */
}
#if defined(NETWORKING) && defined(TCPASYNC)
static void init_cpu(void)
{
#if 1
- z180_device *z180_dev = new z180_device();
+ class sim_z180_device : public z180_device {
+ virtual int standard_irq_callback(device_t &device, int irqline) override {
+ assert(irqline == Z180_INPUT_LINE_IRQ0);
+ execute_set_input(Z180_INPUT_LINE_IRQ0, CLEAR_LINE);
+ return int_data;
+ }
+ };
+ z180_device *z180_dev = new sim_z180_device();
z180_dev->device_start();
*z180_dev->m_icountptr = 0;
- class memory_address_space : public address_space {
+ class sim_memory_address_space : public address_space {
virtual u8 read_byte(offs_t address) override {
return memrdr((WORD)address);
}
memwrt((WORD)address, (BYTE)data);
}
};
- z180_dev->m_program = new memory_address_space();
+ z180_dev->m_program = new sim_memory_address_space();
BYTE io_in(BYTE addrl, BYTE addrh);
void io_out(BYTE addrl, BYTE addrh, BYTE data);
- class io_address_space : public address_space {
+ class sim_io_address_space : public address_space {
virtual u8 read_byte(offs_t address) override {
return io_in((BYTE)address, (BYTE)(address >> 8));
}
io_out((BYTE)address, (BYTE)(address >> 8), (BYTE)data);
}
};
- z180_dev->m_iospace = new io_address_space();
+ z180_dev->m_iospace = new sim_io_address_space();
z180_dev->device_reset();
cpu_dev = z180_dev;
while (true) {
*cpu_dev->m_icountptr += 1000;
cpu_dev->execute_run();
+ // we require at least one console poll per 1000 t-states to detect busy
+ if (busy_loop_cnt[0] > 0)
+ --busy_loop_cnt[0];
//fputc('.', stderr);
}
#else
int int_mode; /* CPU interrupt mode (IM 0, IM 1, IM 2) */
int int_nmi; /* non maskable interrupt request */
int int_int; /* interrupt request */
+#endif
int int_data = -1; /* data from interrupting device on data bus */
+#if 1
int int_protection; /* to delay interrupts after EI */
BYTE bus_request; /* request address/data bus from CPU */
#endif
#endif
extern BYTE cpu_state, bus_request;
-extern int int_data;
#endif
+extern int int_data;
extern int s_flag, l_flag, m_flag, x_flag, i_flag, f_flag;
#if 0