Fix warnings, add -std=c++11 for systems that default to -std=c++03 or lower
[fuzix_sim.git] / emu.h
1 #ifndef _EMU_H
2 #define _EMU_H 1
3
4 #include <assert.h>
5 #include <stdint.h>
6 #include <string.h>
7 typedef uint8_t u8;
8 typedef uint16_t u16;
9 typedef uint32_t u32;
10 typedef int8_t s8;
11 typedef int16_t s16;
12 typedef int32_t s32;
13
14 // this must be large enough to hold a physical address:
15 typedef uint32_t offs_t;
16
17 #include <memory>
18
19 class device_state_entry {
20 };
21
22 class device_t {
23 public:
24   virtual void device_start() = 0;
25   virtual void device_reset() = 0;
26 };
27
28 class cpu_device : public device_t {
29 public:
30   int *m_icountptr;
31
32   cpu_device() : m_icountptr(NULL) {}
33   virtual uint32_t execute_min_cycles() const = 0;
34   virtual uint32_t execute_max_cycles() const = 0;
35   virtual uint32_t execute_input_lines() const = 0;
36   virtual uint32_t execute_default_irq_vector(int inputnum) const = 0;
37   virtual bool execute_input_edge_triggered(int inputnum) const = 0;
38   virtual void execute_run() = 0;
39   virtual void execute_burn(int32_t cycles) = 0;
40   virtual void execute_set_input(int inputnum, int state) = 0;
41   void set_icountptr(int &icount) {
42     assert(!m_icountptr);
43     m_icountptr = &icount;
44   }
45   int standard_irq_callback_member(device_t &device, int irqline) {
46     return standard_irq_callback(device, irqline);
47   }
48   virtual int standard_irq_callback(device_t &device, int irqline) = 0;
49 };
50
51 class machine_config {
52 };
53
54 class address_space {
55 public:
56   virtual u8 read_byte(offs_t address) = 0;
57   virtual void write_byte(offs_t address, u8 data) = 0;
58 };
59
60 // PAIR is an endian-safe union useful for representing 32-bit CPU registers
61 union PAIR
62 {
63 //nick#ifdef LSB_FIRST
64   struct { u8 l,h,h2,h3; } b;
65   struct { u16 l,h; } w;
66   struct { s8 l,h,h2,h3; } sb;
67   struct { s16 l,h; } sw;
68 //nick#else
69 //nick  struct { u8 h3,h2,h,l; } b;
70 //nick  struct { s8 h3,h2,h,l; } sb;
71 //nick  struct { u16 h,l; } w;
72 //nick  struct { s16 h,l; } sw;
73 //nick#endif
74   u32 d;
75   s32 sd;
76 };
77
78 enum {
79   INPUT_LINE_NMI = -1
80   // device specific input lines start at 0
81 };
82
83 enum {
84   CLEAR_LINE,
85   ASSERT_LINE
86 };
87
88 #endif