Previous 199869 Revisions Next

r19755 Sunday 23rd December, 2012 at 18:29:33 UTC by Ryan Holtz
- esrip.c: Modernized Entertainment Sciences Real Time Image Processor (ESRIP) core. [MooglyGuy]
[src/emu/cpu/esrip]esrip.c esrip.h
[src/emu/cpu/m6809]m6809.h
[src/mame/drivers]esripsys.c
[src/mame/includes]esripsys.h

trunk/src/mame/includes/esripsys.h
r19754r19755
44
55*************************************************************************/
66
7#ifndef _ESRIPSYS_H_
8#define _ESRIPSYS_H_
9
10#pragma once
11
12#include "cpu/esrip/esrip.h"
13
714/* TODO */
815#define ESRIPSYS_PIXEL_CLOCK   (XTAL_25MHz / 2)
916#define ESRIPSYS_HTOTAL         (512 + 141 + 2)
r19754r19755
2835public:
2936   esripsys_state(const machine_config &mconfig, device_type type, const char *tag)
3037      : driver_device(mconfig, type, tag),
38          m_videocpu(*this, "video_cpu"),
3139        m_pal_ram(*this, "pal_ram") { }
3240
41    required_device<esrip_device> m_videocpu;
42
3343   UINT8 m_g_iodata;
3444   UINT8 m_g_ioaddr;
3545   UINT8 m_coin_latch;
r19754r19755
102112
103113/*----------- defined in video/esripsys.c -----------*/
104114int esripsys_draw(running_machine &machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int bank);
115
116#endif // _ESRIPSYS_H_
trunk/src/mame/drivers/esripsys.c
r19754r19755
9595
9696READ8_MEMBER(esripsys_state::g_status_r)
9797{
98   int bank4 = BIT(get_rip_status(machine().device("video_cpu")), 2);
98   int bank4 = BIT(m_videocpu->get_rip_status(), 2);
9999   int vblank = machine().primary_screen->vblank();
100100
101101   return (!vblank << 7) | (bank4 << 6) | (m_f_status & 0x2f);
r19754r19755
144144READ8_MEMBER(esripsys_state::f_status_r)
145145{
146146   int vblank = machine().primary_screen->vblank();
147   UINT8 rip_status = get_rip_status(machine().device("video_cpu"));
147   UINT8 rip_status = m_videocpu->get_rip_status();
148148
149149   rip_status = (rip_status & 0x18) | (BIT(rip_status, 6) << 1) |  BIT(rip_status, 7);
150150
r19754r19755
705705
706706   MCFG_CPU_ADD("video_cpu", ESRIP, XTAL_40MHz / 4)
707707   MCFG_CPU_PROGRAM_MAP(video_cpu_map)
708   MCFG_CPU_CONFIG(rip_config)
708   MCFG_CPU_ESRIP_CONFIG(rip_config)
709709
710710   MCFG_CPU_ADD("sound_cpu", M6809E, XTAL_8MHz)
711711   MCFG_CPU_PROGRAM_MAP(sound_cpu_map)
trunk/src/emu/cpu/esrip/esrip.c
r19754r19755
1111#include "debugger.h"
1212#include "esrip.h"
1313
14CPU_DISASSEMBLE( esrip );
1514
16
1715/***************************************************************************
1816    CONSTANTS
1917***************************************************************************/
r19754r19755
2523    MACROS
2624***************************************************************************/
2725
28#define RIP_PC      (cpustate->pc | ((cpustate->status_out & 1) << 8))
26#define RIP_PC      (m_pc | ((m_status_out & 1) << 8))
2927#define _BIT(x, n)   ((x) & (1 << (n)))
3028#define RISING_EDGE(old_val, new_val, bit)   (!(old_val & (1 << bit)) && (new_val & (1 << bit)))
3129
r19754r19755
5351#define   C_FLAG      (1 << 1)
5452#define   Z_FLAG      (1 << 0)
5553
56#define CLEAR_FLAGS(a)   (cpustate->new_status &= ~(a))
57#define SET_FLAGS(a)   (cpustate->new_status |=  (a))
54#define CLEAR_FLAGS(a)   (m_new_status &= ~(a))
55#define SET_FLAGS(a)   (m_new_status |=  (a))
5856
5957
6058/***************************************************************************
6159    STRUCTURES & TYPEDEFS
6260***************************************************************************/
6361
64struct esrip_state
65{
66   UINT16   ram[32];
67   UINT16   acc;
68   UINT16   d_latch;
69   UINT16   i_latch;
70   UINT16   result;
71   UINT8   new_status;
72   UINT8   status;
73   UINT16   inst;
74   UINT8   immflag;
75   UINT8   ct;
76   UINT8   t;
77
78   /* Instruction latches - current and previous values */
79   UINT8   l1, pl1;
80   UINT8   l2, pl2;
81   UINT8   l3, pl3;
82   UINT8   l4, pl4;
83   UINT8   l5, pl5;
84   UINT8   l6, pl6;
85   UINT8   l7, pl7;
86
87   UINT8   pc;
88   UINT8   status_out;
89
90   UINT8   x_scale;
91   UINT8   y_scale;
92   UINT8   img_bank;
93   UINT8   line_latch;
94   UINT16   fig_latch;
95   UINT16   attr_latch;
96   UINT16   adl_latch;
97   UINT16   adr_latch;
98   UINT16   iaddr_latch;
99   UINT8   c_latch;
100
101   UINT16   fdt_cnt;
102   UINT16   ipt_cnt;
103
104   UINT8   fig;
105   UINT16   fig_cycles;
106
107   UINT8   *optable;
108
109   UINT16   *ipt_ram;
110   UINT8   *lbrm;
111
112   legacy_cpu_device *device;
113   address_space *program;
114   direct_read_data *direct;
115   int      icount;
116
117   read16_device_func   fdt_r;
118   write16_device_func   fdt_w;
119   UINT8 (*status_in)(running_machine &machine);
120   int (*draw)(running_machine &machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int bank);
121};
122
123
124INLINE esrip_state *get_safe_token(device_t *device)
125{
126   assert(device != NULL);
127   assert(device->type() == ESRIP);
128   return (esrip_state *)downcast<legacy_cpu_device *>(device)->token();
129}
130
131
13262/***************************************************************************
13363    PUBLIC FUNCTIONS
13464***************************************************************************/
13565
136UINT8 get_rip_status(device_t *cpu)
66UINT8 esrip_device::get_rip_status()
13767{
138   esrip_state *cpustate = get_safe_token(cpu);
139   return cpustate->status_out;
68   return m_status_out;
14069}
14170
14271
r19754r19755
15180   ROTNR, BONR, BOR1, SONR, SHFTNR, PRTNR, TONR
15281};
15382
154static void make_ops(esrip_state *cpustate)
83void esrip_device::make_ops()
15584{
15685   int inst;
15786
r19754r19755
16291      if (quad == 0)
16392      {
16493         if (((inst >> 5) & 0xc) == 0xc)
165            cpustate->optable[inst] = ROTR1;
94            m_optable[inst] = ROTR1;
16695         else
167            cpustate->optable[inst] = TOR1;
96            m_optable[inst] = TOR1;
16897      }
16998      else if (quad == 1)
17099      {
171100         if (OPCODE < 2)
172            cpustate->optable[inst] = ROTR2;
101            m_optable[inst] = ROTR2;
173102         else if (OPCODE < 6)
174            cpustate->optable[inst] = ROTC;
103            m_optable[inst] = ROTC;
175104         else
176            cpustate->optable[inst] = ROTM;
105            m_optable[inst] = ROTM;
177106      }
178107      else if (quad == 2)
179108      {
180109         if (OPCODE > 11)
181            cpustate->optable[inst] = BOR2;
110            m_optable[inst] = BOR2;
182111         else
183112         {
184113            int tmp = (inst >> 5) & 0xff;
185114
186115            if (tmp == 0x63)
187               cpustate->optable[inst] = CRCF;
116               m_optable[inst] = CRCF;
188117            else if (tmp == 0x69)
189               cpustate->optable[inst] = CRCR;
118               m_optable[inst] = CRCR;
190119            else if (tmp == 0x7a)
191               cpustate->optable[inst] = SVSTR;
120               m_optable[inst] = SVSTR;
192121            else
193122            {
194123               if ((SRC > 7) && (SRC < 12))
195                  cpustate->optable[inst] = PRT;
124                  m_optable[inst] = PRT;
196125               else if (SRC > 11)
197                  cpustate->optable[inst] = SOR;
126                  m_optable[inst] = SOR;
198127               else if (SRC < 6)
199                  cpustate->optable[inst] = TOR2;
128                  m_optable[inst] = TOR2;
200129               else
201                  cpustate->optable[inst] = SHFTR;
130                  m_optable[inst] = SHFTR;
202131            }
203132         }
204133      }
205134      else
206135      {
207136         if (inst == 0x7140)
208            cpustate->optable[inst] = NOP;
137            m_optable[inst] = NOP;
209138         else
210139         {
211140            int x = (inst & 0xffe0);
212141            if (x == 0x7340)
213               cpustate->optable[inst] = TEST;
142               m_optable[inst] = TEST;
214143            else if (x == 0x7740)
215               cpustate->optable[inst] = SETST;
144               m_optable[inst] = SETST;
216145            else if (x == 0x7540)
217               cpustate->optable[inst] = RSTST;
146               m_optable[inst] = RSTST;
218147            else
219148            {
220149               int op = OPCODE;
221150               if (op == 0xc)
222151               {
223152                  if ((inst & 0x18) == 0x18)
224                     cpustate->optable[inst] = ROTNR;
153                     m_optable[inst] = ROTNR;
225154                  else
226                     cpustate->optable[inst] = BONR;
155                     m_optable[inst] = BONR;
227156               }
228157               else if ((op & 0xc) == 0xc)
229                  cpustate->optable[inst] = BOR1;
158                  m_optable[inst] = BOR1;
230159               else
231160               {
232161                  int src = SRC;
233162
234163                  if ((src & 0xc) == 0xc)
235                     cpustate->optable[inst] = SONR;
164                     m_optable[inst] = SONR;
236165                  else if ((src & 0x6) == 0x6)
237                     cpustate->optable[inst] = SHFTNR;
166                     m_optable[inst] = SHFTNR;
238167                  else if (src & 0x8)
239                     cpustate->optable[inst] = PRTNR;
168                     m_optable[inst] = PRTNR;
240169                  else
241                     cpustate->optable[inst] = TONR;
170                     m_optable[inst] = TONR;
242171               }
243172            }
244173         }
r19754r19755
246175   }
247176}
248177
249static CPU_INIT( esrip )
178void esrip_device::device_start()
250179{
251   esrip_state *cpustate = get_safe_token(device);
252   esrip_config* _config = (esrip_config*)device->static_config();
180   esrip_config* _config = (esrip_config*)static_config();
253181
254   memset(cpustate, 0, sizeof(*cpustate));
255
256182   /* Register configuration structure callbacks */
257   cpustate->fdt_r = _config->fdt_r;
258   cpustate->fdt_w = _config->fdt_w;
259   cpustate->lbrm = (UINT8*)device->machine().root_device().memregion(_config->lbrm_prom)->base();
260   cpustate->status_in = _config->status_in;
261   cpustate->draw = _config->draw;
183   m_fdt_r = _config->fdt_r;
184   m_fdt_w = _config->fdt_w;
185   m_lbrm = (UINT8*)machine().root_device().memregion(_config->lbrm_prom)->base();
186   m_status_in = _config->status_in;
187   m_draw = _config->draw;
262188
263189   /* Allocate image pointer table RAM */
264   cpustate->ipt_ram = auto_alloc_array(device->machine(), UINT16, IPT_RAM_SIZE/2);
190   m_ipt_ram = auto_alloc_array(machine(), UINT16, IPT_RAM_SIZE/2);
265191
266   cpustate->device = device;
267   cpustate->program = &device->space(AS_PROGRAM);
268   cpustate->direct = &cpustate->program->direct();
192   m_program = &space(AS_PROGRAM);
193   m_direct = &m_program->direct();
269194
195   // register our state for the debugger
196   astring tempstr;
197   state_add(STATE_GENPC,     "GENPC",     m_rip_pc).noshow();
198   state_add(STATE_GENFLAGS,  "GENFLAGS",  m_status).callimport().callexport().formatstr("%8s").noshow();
199   state_add(ESRIP_PC,        "PC:",       m_rip_pc).mask(0xffff);
200   state_add(ESRIP_ACC,       "ACC:",      m_acc).mask(0xffff);
201   state_add(ESRIP_DLATCH,    "DLATCH:",   m_d_latch).mask(0xff);
202   state_add(ESRIP_ILATCH,    "ILATCH:",   m_i_latch).mask(0xffff);
203   state_add(ESRIP_RAM00,     "RAM[00]:",  m_ram[0x00]).mask(0xffff);
204   state_add(ESRIP_RAM01,     "RAM[01]:",  m_ram[0x01]).mask(0xffff);
205   state_add(ESRIP_RAM02,     "RAM[02]:",  m_ram[0x02]).mask(0xffff);
206   state_add(ESRIP_RAM03,     "RAM[03]:",  m_ram[0x03]).mask(0xffff);
207   state_add(ESRIP_RAM04,     "RAM[04]:",  m_ram[0x04]).mask(0xffff);
208   state_add(ESRIP_RAM05,     "RAM[05]:",  m_ram[0x05]).mask(0xffff);
209   state_add(ESRIP_RAM06,     "RAM[06]:",  m_ram[0x06]).mask(0xffff);
210   state_add(ESRIP_RAM07,     "RAM[07]:",  m_ram[0x07]).mask(0xffff);
211   state_add(ESRIP_RAM08,     "RAM[08]:",  m_ram[0x08]).mask(0xffff);
212   state_add(ESRIP_RAM09,     "RAM[09]:",  m_ram[0x09]).mask(0xffff);
213   state_add(ESRIP_RAM0A,     "RAM[0A]:",  m_ram[0x0a]).mask(0xffff);
214   state_add(ESRIP_RAM0B,     "RAM[0B]:",  m_ram[0x0b]).mask(0xffff);
215   state_add(ESRIP_RAM0C,     "RAM[0C]:",  m_ram[0x0c]).mask(0xffff);
216   state_add(ESRIP_RAM0D,     "RAM[0D]:",  m_ram[0x0d]).mask(0xffff);
217   state_add(ESRIP_RAM0E,     "RAM[0E]:",  m_ram[0x0e]).mask(0xffff);
218   state_add(ESRIP_RAM0F,     "RAM[0F]:",  m_ram[0x0f]).mask(0xffff);
219   state_add(ESRIP_RAM10,     "RAM[10]:",  m_ram[0x10]).mask(0xffff);
220   state_add(ESRIP_RAM11,     "RAM[11]:",  m_ram[0x11]).mask(0xffff);
221   state_add(ESRIP_RAM12,     "RAM[12]:",  m_ram[0x12]).mask(0xffff);
222   state_add(ESRIP_RAM13,     "RAM[13]:",  m_ram[0x13]).mask(0xffff);
223   state_add(ESRIP_RAM14,     "RAM[14]:",  m_ram[0x14]).mask(0xffff);
224   state_add(ESRIP_RAM15,     "RAM[15]:",  m_ram[0x15]).mask(0xffff);
225   state_add(ESRIP_RAM16,     "RAM[16]:",  m_ram[0x16]).mask(0xffff);
226   state_add(ESRIP_RAM17,     "RAM[17]:",  m_ram[0x17]).mask(0xffff);
227   state_add(ESRIP_RAM18,     "RAM[18]:",  m_ram[0x18]).mask(0xffff);
228   state_add(ESRIP_RAM19,     "RAM[19]:",  m_ram[0x19]).mask(0xffff);
229   state_add(ESRIP_RAM1A,     "RAM[1A]:",  m_ram[0x1a]).mask(0xffff);
230   state_add(ESRIP_RAM1B,     "RAM[1B]:",  m_ram[0x1b]).mask(0xffff);
231   state_add(ESRIP_RAM1C,     "RAM[1C]:",  m_ram[0x1c]).mask(0xffff);
232   state_add(ESRIP_RAM1D,     "RAM[1D]:",  m_ram[0x1d]).mask(0xffff);
233   state_add(ESRIP_RAM1E,     "RAM[1E]:",  m_ram[0x1e]).mask(0xffff);
234   state_add(ESRIP_RAM1F,     "RAM[1F]:",  m_ram[0x1f]).mask(0xffff);
235   state_add(ESRIP_STATW,     "STAT:",     m_status_out).mask(0xffff);
236   state_add(ESRIP_FDTC,      "FDTC:",     m_fdt_cnt).mask(0xffff);
237   state_add(ESRIP_IPTC,      "IPTC:",     m_ipt_cnt).mask(0xffff);
238   state_add(ESRIP_XSCALE,    "XSCL:",     m_x_scale).mask(0xffff);
239   state_add(ESRIP_YSCALE,    "YSCL:",     m_y_scale).mask(0xffff);
240   state_add(ESRIP_BANK,      "BANK:",     m_img_bank).mask(0xffff);
241   state_add(ESRIP_LINE,      "LINE:",     m_line_latch).mask(0xffff);
242   state_add(ESRIP_FIG,       "FIG:",      m_fig_latch).mask(0xffff);
243   state_add(ESRIP_ATTR,      "ATTR:",     m_attr_latch).mask(0xffff);
244   state_add(ESRIP_ADRL,      "ADRL:",     m_adl_latch).mask(0xffff);
245   state_add(ESRIP_ADRR,      "ADRR:",     m_adr_latch).mask(0xffff);
246   state_add(ESRIP_COLR,      "COLR:",     m_c_latch).mask(0xffff);
247   state_add(ESRIP_IADDR,     "IADR:",     m_iaddr_latch).mask(0xffff);
248
270249   /* Create the instruction decode lookup table */
271   cpustate->optable = auto_alloc_array(device->machine(), UINT8, 65536);
272   make_ops(cpustate);
250   make_ops();
273251
274252   /* Register stuff for state saving */
275   device->save_item(NAME(cpustate->acc));
276   device->save_item(NAME(cpustate->ram));
277   device->save_item(NAME(cpustate->d_latch));
278   device->save_item(NAME(cpustate->i_latch));
279   device->save_item(NAME(cpustate->result));
280   device->save_item(NAME(cpustate->new_status));
281   device->save_item(NAME(cpustate->status));
282   device->save_item(NAME(cpustate->inst));
283   device->save_item(NAME(cpustate->immflag));
284   device->save_item(NAME(cpustate->ct));
285   device->save_item(NAME(cpustate->t));
286   device->save_item(NAME(cpustate->l1));
287   device->save_item(NAME(cpustate->l2));
288   device->save_item(NAME(cpustate->l3));
289   device->save_item(NAME(cpustate->l4));
290   device->save_item(NAME(cpustate->l5));
291   device->save_item(NAME(cpustate->l6));
292   device->save_item(NAME(cpustate->l7));
293   device->save_item(NAME(cpustate->pl1));
294   device->save_item(NAME(cpustate->pl2));
295   device->save_item(NAME(cpustate->pl3));
296   device->save_item(NAME(cpustate->pl4));
297   device->save_item(NAME(cpustate->pl5));
298   device->save_item(NAME(cpustate->pl6));
299   device->save_item(NAME(cpustate->pl7));
300   device->save_item(NAME(cpustate->pc));
301   device->save_item(NAME(cpustate->status_out));
302   device->save_item(NAME(cpustate->x_scale));
303   device->save_item(NAME(cpustate->y_scale));
304   device->save_item(NAME(cpustate->img_bank));
305   device->save_item(NAME(cpustate->line_latch));
306   device->save_item(NAME(cpustate->fig_latch));
307   device->save_item(NAME(cpustate->attr_latch));
308   device->save_item(NAME(cpustate->adl_latch));
309   device->save_item(NAME(cpustate->adr_latch));
310   device->save_item(NAME(cpustate->iaddr_latch));
311   device->save_item(NAME(cpustate->c_latch));
312   device->save_item(NAME(cpustate->fdt_cnt));
313   device->save_item(NAME(cpustate->ipt_cnt));
314   device->save_item(NAME(cpustate->fig));
315   device->save_item(NAME(cpustate->fig_cycles));
316   device->save_pointer(NAME(cpustate->ipt_ram), IPT_RAM_SIZE / sizeof(UINT16));
253   save_item(NAME(m_acc));
254   save_item(NAME(m_ram));
255   save_item(NAME(m_d_latch));
256   save_item(NAME(m_i_latch));
257   save_item(NAME(m_result));
258   save_item(NAME(m_new_status));
259   save_item(NAME(m_status));
260   save_item(NAME(m_inst));
261   save_item(NAME(m_immflag));
262   save_item(NAME(m_ct));
263   save_item(NAME(m_t));
264   save_item(NAME(m_l1));
265   save_item(NAME(m_l2));
266   save_item(NAME(m_l3));
267   save_item(NAME(m_l4));
268   save_item(NAME(m_l5));
269   save_item(NAME(m_l6));
270   save_item(NAME(m_l7));
271   save_item(NAME(m_pl1));
272   save_item(NAME(m_pl2));
273   save_item(NAME(m_pl3));
274   save_item(NAME(m_pl4));
275   save_item(NAME(m_pl5));
276   save_item(NAME(m_pl6));
277   save_item(NAME(m_pl7));
278   save_item(NAME(m_pc));
279   save_item(NAME(m_status_out));
280   save_item(NAME(m_x_scale));
281   save_item(NAME(m_y_scale));
282   save_item(NAME(m_img_bank));
283   save_item(NAME(m_line_latch));
284   save_item(NAME(m_fig_latch));
285   save_item(NAME(m_attr_latch));
286   save_item(NAME(m_adl_latch));
287   save_item(NAME(m_adr_latch));
288   save_item(NAME(m_iaddr_latch));
289   save_item(NAME(m_c_latch));
290   save_item(NAME(m_fdt_cnt));
291   save_item(NAME(m_ipt_cnt));
292   save_item(NAME(m_fig));
293   save_item(NAME(m_fig_cycles));
294   save_pointer(NAME(m_ipt_ram), IPT_RAM_SIZE / sizeof(UINT16));
295
296   // set our instruction counter
297   m_icountptr = &m_icount;
317298}
318299
319300
320static CPU_RESET( esrip )
301void esrip_device::device_reset()
321302{
322   esrip_state *cpustate = get_safe_token(device);
303   m_pc = 0;
323304
324   cpustate->pc = 0;
305   m_pl1 = 0xff;
306   m_pl2 = 0xff;
307   m_pl3 = 0xff;
308   m_pl4 = 0xff;
309   m_pl5 = 0xff;
310   m_pl6 = 0xff;
311   m_pl7 = 0xff;
325312
326   cpustate->pl1 = 0xff;
327   cpustate->pl2 = 0xff;
328   cpustate->pl3 = 0xff;
329   cpustate->pl4 = 0xff;
330   cpustate->pl5 = 0xff;
331   cpustate->pl6 = 0xff;
332   cpustate->pl7 = 0xff;
313   m_l1 = 0xff;
314   m_l2 = 0xff;
315   m_l3 = 0xff;
316   m_l4 = 0xff;
317   m_l5 = 0xff;
318   m_l6 = 0xff;
319   m_l7 = 0xff;
333320
334   cpustate->l1 = 0xff;
335   cpustate->l2 = 0xff;
336   cpustate->l3 = 0xff;
337   cpustate->l4 = 0xff;
338   cpustate->l5 = 0xff;
339   cpustate->l6 = 0xff;
340   cpustate->l7 = 0xff;
321   m_status_out = 0;
322   m_immflag = 0;
341323
342   cpustate->status_out = 0;
343   cpustate->immflag = 0;
324   m_rip_pc = (m_pc | ((m_status_out & 1) << 8));
344325}
345326
327void esrip_device::device_stop()
328{
346329
347static CPU_EXIT( esrip )
330}
331
332
333//-------------------------------------------------
334//  memory_space_config - return the configuration
335//  of the specified address space, or NULL if
336//  the space doesn't exist
337//-------------------------------------------------
338
339const address_space_config *esrip_device::memory_space_config(address_spacenum spacenum) const
348340{
341   if (spacenum == AS_PROGRAM)
342   {
343      return &m_program_config;
344   }
345   return NULL;
346}
349347
348
349//-------------------------------------------------
350//  state_string_export - export state as a string
351//  for the debugger
352//-------------------------------------------------
353
354void esrip_device::state_string_export(const device_state_entry &entry, astring &string)
355{
356   switch (entry.index())
357   {
358      case STATE_GENFLAGS:
359         string.printf("%c%c%c%c%c%c%c%c%c",
360            (m_status & 0x80) ? '3' : '.',
361            (m_status & 0x40) ? '2' : '.',
362            (m_status & 0x20) ? '1' : '.',
363            (m_status & 0x10) ? 'L' : '.',
364            (m_status & 0x08) ? 'V' : '.',
365            (m_status & 0x04) ? 'N' : '.',
366            (m_status & 0x02) ? 'C' : '.',
367            (m_status & 0x01) ? 'Z' : '.',
368            get_hblank() ? 'H' : '.');
369         break;
370   }
350371}
351372
352373
374//-------------------------------------------------
375//  disasm_min_opcode_bytes - return the length
376//  of the shortest instruction, in bytes
377//-------------------------------------------------
378
379UINT32 esrip_device::disasm_min_opcode_bytes() const
380{
381   return 8;
382}
383
384
385//-------------------------------------------------
386//  disasm_max_opcode_bytes - return the length
387//  of the longest instruction, in bytes
388//-------------------------------------------------
389
390UINT32 esrip_device::disasm_max_opcode_bytes() const
391{
392   return 8;
393}
394
395
396//-------------------------------------------------
397//  disasm_disassemble - call the disassembly
398//  helper function
399//-------------------------------------------------
400
401offs_t esrip_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
402{
403   extern CPU_DISASSEMBLE( esrip );
404   return disassemble(buffer, pc, oprom, opram, 0);
405}
406
407
353408/***************************************************************************
354409    PRIVATE FUNCTIONS
355410***************************************************************************/
356411
357static int get_hblank(running_machine &machine)
412int esrip_device::get_hblank()
358413{
359   return machine.primary_screen->hblank();
414   return machine().primary_screen->hblank();
360415}
361416
362417/* Return the state of the LBRM line (Y-scaling related) */
363static int get_lbrm(esrip_state *cpustate)
418int esrip_device::get_lbrm()
364419{
365   int addr = ((cpustate->y_scale & 0x3f) << 3) | ((cpustate->line_latch >> 3) & 7);
366   int sel = (cpustate->line_latch & 7);
420   int addr = ((m_y_scale & 0x3f) << 3) | ((m_line_latch >> 3) & 7);
421   int sel = (m_line_latch & 7);
367422
368   UINT8 val = cpustate->lbrm[addr];
423   UINT8 val = m_lbrm[addr];
369424
370425   return (val >> sel) & 1;
371426}
372427
373INLINE int check_jmp(esrip_state *cpustate, UINT8 jmp_ctrl)
428int esrip_device::check_jmp(UINT8 jmp_ctrl)
374429{
375430   int ret = 0;
376431
r19754r19755
378433   {
379434      switch (jmp_ctrl & 7)
380435      {
381         /* CT */      case 0: ret = cpustate->ct;         break;
382         /* T1 */      case 4: ret = BIT(cpustate->t, 0);  break;
383         /* T2 */      case 2: ret = BIT(cpustate->t, 1);  break;
384         /* T3 */      case 6: ret = BIT(cpustate->t, 2);  break;
385         /* T4 */      case 1: ret = BIT(cpustate->t, 3);  break;
386         /* /LBRM */   case 5: ret = !get_lbrm(cpustate);  break;
387         /* /HBLANK */ case 3: ret = !get_hblank(cpustate->device->machine()); break;
436         /* CT */      case 0: ret = m_ct;         break;
437         /* T1 */      case 4: ret = BIT(m_t, 0);  break;
438         /* T2 */      case 2: ret = BIT(m_t, 1);  break;
439         /* T3 */      case 6: ret = BIT(m_t, 2);  break;
440         /* T4 */      case 1: ret = BIT(m_t, 3);  break;
441         /* /LBRM */   case 5: ret = !get_lbrm();  break;
442         /* /HBLANK */ case 3: ret = !get_hblank(); break;
388443         /* JMP */     case 7: ret = 0;                    break;
389444      }
390445
r19754r19755
394449   {
395450      switch (jmp_ctrl & 7)
396451      {
397         /* CT */      case 0: ret = cpustate->ct;        break;
398         /* T1 */      case 4: ret = BIT(cpustate->t, 0); break;
399         /* T2 */      case 2: ret = BIT(cpustate->t, 1); break;
400         /* T3 */      case 6: ret = BIT(cpustate->t, 2); break;
401         /* T4 */      case 1: ret = BIT(cpustate->t, 3); break;
402         /* /LBRM */   case 5: ret = !get_lbrm(cpustate); break;
403         /* /FIG */    case 3: ret = !cpustate->fig;      break;
452         /* CT */      case 0: ret = m_ct;        break;
453         /* T1 */      case 4: ret = BIT(m_t, 0); break;
454         /* T2 */      case 2: ret = BIT(m_t, 1); break;
455         /* T3 */      case 6: ret = BIT(m_t, 2); break;
456         /* T4 */      case 1: ret = BIT(m_t, 3); break;
457         /* /LBRM */   case 5: ret = !get_lbrm(); break;
458         /* /FIG */    case 3: ret = !m_fig;      break;
404459         /* JMP */     case 7: ret = 1;                   break;
405460      }
406461   }
407462   else
463   {
408464      assert(!"RIP: Invalid jump control");
465   }
409466
410467   return ret;
411468}
412469
413470
414INLINE void calc_z_flag(esrip_state *cpustate, UINT16 res)
471void esrip_device::calc_z_flag(UINT16 res)
415472{
416   cpustate->new_status &= ~Z_FLAG;
417   cpustate->new_status |= (res == 0);
473   m_new_status &= ~Z_FLAG;
474   m_new_status |= (res == 0);
418475}
419476
420INLINE void calc_c_flag_add(esrip_state *cpustate, UINT16 a, UINT16 b)
477void esrip_device::calc_c_flag_add(UINT16 a, UINT16 b)
421478{
422   cpustate->new_status &= ~C_FLAG;
423   cpustate->new_status |= ((UINT16)(b) > (UINT16)(~(a))) ? 2 : 0;
479   m_new_status &= ~C_FLAG;
480   m_new_status |= ((UINT16)(b) > (UINT16)(~(a))) ? 2 : 0;
424481}
425482
426INLINE void calc_c_flag_sub(esrip_state *cpustate, UINT16 a, UINT16 b)
483void esrip_device::calc_c_flag_sub(UINT16 a, UINT16 b)
427484{
428   cpustate->new_status &= ~C_FLAG;
429   cpustate->new_status |= ((UINT16)(b) <= (UINT16)(a)) ? 2 : 0;
485   m_new_status &= ~C_FLAG;
486   m_new_status |= ((UINT16)(b) <= (UINT16)(a)) ? 2 : 0;
430487}
431488
432INLINE void calc_n_flag(esrip_state *cpustate, UINT16 res)
489void esrip_device::calc_n_flag(UINT16 res)
433490{
434   cpustate->new_status &= ~N_FLAG;
435   cpustate->new_status |= (res & 0x8000) ? 4 : 0;
491   m_new_status &= ~N_FLAG;
492   m_new_status |= (res & 0x8000) ? 4 : 0;
436493}
437494
438INLINE void calc_v_flag_add(esrip_state *cpustate, UINT16 a, UINT16 b, UINT32 r)
495void esrip_device::calc_v_flag_add(UINT16 a, UINT16 b, UINT32 r)
439496{
440   cpustate->new_status &= ~V_FLAG;
441   cpustate->new_status |= ((a ^ r) & (b ^ r) & 0x8000) ? 8 : 0;
497   m_new_status &= ~V_FLAG;
498   m_new_status |= ((a ^ r) & (b ^ r) & 0x8000) ? 8 : 0;
442499}
443500
444INLINE void calc_v_flag_sub(esrip_state *cpustate, UINT16 a, UINT16 b, UINT32 r)
501void esrip_device::calc_v_flag_sub(UINT16 a, UINT16 b, UINT32 r)
445502{
446   cpustate->new_status &= ~V_FLAG;
447   cpustate->new_status |= ((a ^ b) & (r ^ b) & 0x8000) ? 8 : 0;
503   m_new_status &= ~V_FLAG;
504   m_new_status |= ((a ^ b) & (r ^ b) & 0x8000) ? 8 : 0;
448505}
449506
450507
r19754r19755
465522 *  Single operand
466523 *
467524 *************************************/
525
468526enum
469527{
470528   MOVE = 0xc,
r19754r19755
487545   SORR  = 0xb
488546};
489547
490static UINT16 sor_op(esrip_state *cpustate, UINT16 r, UINT16 opcode)
548UINT16 esrip_device::sor_op(UINT16 r, UINT16 opcode)
491549{
492550   UINT32 res = 0;
493551
r19754r19755
497555      {
498556         res = r;
499557         CLEAR_FLAGS(V_FLAG | C_FLAG);
500         calc_n_flag(cpustate, res);
501         calc_z_flag(cpustate, res);
558         calc_n_flag(res);
559         calc_z_flag(res);
502560         break;
503561      }
504562      case COMP:
505563      {
506564         res = r ^ 0xffff;
507565         CLEAR_FLAGS(V_FLAG | C_FLAG);
508         calc_n_flag(cpustate, res);
509         calc_z_flag(cpustate, res);
566         calc_n_flag(res);
567         calc_z_flag(res);
510568         break;
511569      }
512570      case INC:
513571      {
514572         res = r + 1;
515         calc_v_flag_add(cpustate, r, 1, res);
516         calc_n_flag(cpustate, res);
517         calc_c_flag_add(cpustate, r, 1);
518         calc_z_flag(cpustate, res);
573         calc_v_flag_add(r, 1, res);
574         calc_n_flag(res);
575         calc_c_flag_add(r, 1);
576         calc_z_flag(res);
519577         break;
520578      }
521579      case NEG:
522580      {
523581         res = (r ^ 0xffff) + 1;
524         calc_v_flag_sub(cpustate, 0, r, res);
525         calc_n_flag(cpustate, res);
526         calc_c_flag_sub(cpustate, 0, r);
527         calc_z_flag(cpustate, res);
582         calc_v_flag_sub(0, r, res);
583         calc_n_flag(res);
584         calc_c_flag_sub(0, r);
585         calc_z_flag(res);
528586         break;
529587      }
530588      default: assert(0);
r19754r19755
533591   return res & 0xffff;
534592}
535593
536static void sor(esrip_state *cpustate, UINT16 inst)
594void esrip_device::sor(UINT16 inst)
537595{
538596   UINT16   r = 0;
539597   UINT16   dst = 0;
r19754r19755
547605
548606   switch ((inst >> 5) & 0xf)
549607   {
550      case SORA: r = cpustate->ram[RAM_ADDR];      dst = ACC;      break;
551      case SORY: r = cpustate->ram[RAM_ADDR];      dst = Y_BUS;   break;
552      case SORS: r = cpustate->ram[RAM_ADDR];      dst = STATUS;   break;
553      case SOAR: r = cpustate->acc;            dst = RAM;      break;
554      case SODR: r = cpustate->d_latch;         dst = RAM;      break;
608      case SORA: r = m_ram[RAM_ADDR];      dst = ACC;      break;
609      case SORY: r = m_ram[RAM_ADDR];      dst = Y_BUS;   break;
610      case SORS: r = m_ram[RAM_ADDR];      dst = STATUS;   break;
611      case SOAR: r = m_acc;            dst = RAM;      break;
612      case SODR: r = m_d_latch;         dst = RAM;      break;
555613      case SOIR:
556614      {
557         if (cpustate->immflag == 0)      // Macrofiy this?
615         if (m_immflag == 0)      // Macrofiy this?
558616         {
559            cpustate->i_latch = inst;
560            cpustate->immflag = 1;
617            m_i_latch = inst;
618            m_immflag = 1;
561619            return;
562620         }
563621         else
564622         {
565            r = cpustate->inst;
623            r = m_inst;
566624            dst = RAM;
567            cpustate->immflag = 0;
625            m_immflag = 0;
568626         }
569627         break;
570628      }
571629      case SOZR: r = 0;                  dst = RAM;      break;
572      case SORR: r = cpustate->ram[RAM_ADDR];   dst = RAM;      break;
630      case SORR: r = m_ram[RAM_ADDR];   dst = RAM;      break;
573631      default: UNHANDLED;
574632   }
575633
576634   /* Operation */
577   res = sor_op(cpustate, r, (inst >> 9) & 0xf);
635   res = sor_op(r, (inst >> 9) & 0xf);
578636
579637   switch (dst)
580638   {
581639      case Y_BUS: break;
582      case ACC: cpustate->acc = res; break;
583      case RAM: cpustate->ram[RAM_ADDR] = res; break;
640      case ACC: m_acc = res; break;
641      case RAM: m_ram[RAM_ADDR] = res; break;
584642      default: UNHANDLED;
585643   }
586644
587   cpustate->result = res;
645   m_result = res;
588646}
589647
590648enum
r19754r19755
605663   NRAS = 5,
606664};
607665
608static void sonr(esrip_state *cpustate, UINT16 inst)
666void esrip_device::sonr(UINT16 inst)
609667{
610668   UINT16   r = 0;
611669   UINT16   res = 0;
612670
613671   switch ((inst >> 5) & 0xf)
614672   {
615      case SOA:   r = cpustate->acc;      break;
616      case SOD:   r = cpustate->d_latch;   break;
673      case SOA:   r = m_acc;      break;
674      case SOD:   r = m_d_latch;   break;
617675      case SOI:
618676      {
619         if (cpustate->immflag == 0)
677         if (m_immflag == 0)
620678         {
621            cpustate->i_latch = inst;
622            cpustate->immflag = 1;
679            m_i_latch = inst;
680            m_immflag = 1;
623681            return;
624682         }
625683         else
626684         {
627            r = cpustate->inst;
628            cpustate->immflag = 0;
685            r = m_inst;
686            m_immflag = 0;
629687         }
630688         break;
631689      }
r19754r19755
634692   }
635693
636694   /* Operation */
637   res = sor_op(cpustate, r, (inst >> 9) & 0xf);
695   res = sor_op(r, (inst >> 9) & 0xf);
638696
639697   /* Destination */
640698   switch (inst & 0x1f)
641699   {
642700      case NRY: break;
643      case NRA: cpustate->acc = res; break;
701      case NRA: m_acc = res; break;
644702      default: UNHANDLED;
645703   }
646704
647   cpustate->result = res;
705   m_result = res;
648706}
649707
650708/*************************************
r19754r19755
669727   EXNOR = 0xb
670728};
671729
672static UINT16 tor_op(esrip_state *cpustate, UINT16 r, UINT16 s, int opcode)
730UINT16 esrip_device::tor_op(UINT16 r, UINT16 s, int opcode)
673731{
674732   UINT32 res = 0;
675733
r19754r19755
678736      case SUBR:
679737      {
680738         res = s - r;
681         calc_v_flag_sub(cpustate, s, r, res);
682         calc_n_flag(cpustate, res);
683         calc_c_flag_sub(cpustate, s, r);
684         calc_z_flag(cpustate, res);
739         calc_v_flag_sub(s, r, res);
740         calc_n_flag(res);
741         calc_c_flag_sub(s, r);
742         calc_z_flag(res);
685743         break;
686744      }
687745      case SUBRC: assert(0); break;
688746      case SUBS:
689747      {
690748         res = r - s;
691         calc_v_flag_sub(cpustate, r, s, res);
692         calc_n_flag(cpustate, res);
693         calc_c_flag_sub(cpustate, r, s);
694         calc_z_flag(cpustate, res);
749         calc_v_flag_sub(r, s, res);
750         calc_n_flag(res);
751         calc_c_flag_sub(r, s);
752         calc_z_flag(res);
695753         break;
696754      }
697755      case SUBSC: assert(0); break;
698756      case ADD:
699757      {
700758         res = r + s;
701         calc_v_flag_add(cpustate, r, s, res);
702         calc_n_flag(cpustate, res);
703         calc_c_flag_add(cpustate, r, s);
704         calc_z_flag(cpustate, res);
759         calc_v_flag_add(r, s, res);
760         calc_n_flag(res);
761         calc_c_flag_add(r, s);
762         calc_z_flag(res);
705763         break;
706764      }
707765      case ADDC:
708766      {
709767         // TODO TODO CHECK ME ETC
710         res = r + s + ((cpustate->status >> 1) & 1);
711         calc_v_flag_add(cpustate, r, s, res);
712         calc_n_flag(cpustate, res);
713         calc_c_flag_add(cpustate, r, s);
714         calc_z_flag(cpustate, res);
768         res = r + s + ((m_status >> 1) & 1);
769         calc_v_flag_add(r, s, res);
770         calc_n_flag(res);
771         calc_c_flag_add(r, s);
772         calc_z_flag(res);
715773         break;
716774      }
717775      case AND:
718776      {
719777         res = r & s;
720778         CLEAR_FLAGS(V_FLAG | C_FLAG);
721         calc_n_flag(cpustate, res);
722         calc_z_flag(cpustate, res);
779         calc_n_flag(res);
780         calc_z_flag(res);
723781         break;
724782      }
725783      case NAND:
726784      {
727785         res = (r & s) ^ 0xffff;
728786         CLEAR_FLAGS(V_FLAG | C_FLAG);
729         calc_n_flag(cpustate, res);
730         calc_z_flag(cpustate, res);
787         calc_n_flag(res);
788         calc_z_flag(res);
731789         break;
732790      }
733791      case EXOR:
734792      {
735793         res = r ^ s;
736794         CLEAR_FLAGS(V_FLAG | C_FLAG);
737         calc_n_flag(cpustate, res);
738         calc_z_flag(cpustate, res);
795         calc_n_flag(res);
796         calc_z_flag(res);
739797         break;
740798      }
741799      case NOR:
742800      {
743801         res = (r | s) ^ 0xffff;
744802         CLEAR_FLAGS(V_FLAG | C_FLAG);
745         calc_n_flag(cpustate, res);
746         calc_z_flag(cpustate, res);
803         calc_n_flag(res);
804         calc_z_flag(res);
747805         break;
748806      }
749807      case OR:
750808      {
751809         res = r | s;
752810         CLEAR_FLAGS(V_FLAG | C_FLAG);
753         calc_n_flag(cpustate, res);
754         calc_z_flag(cpustate, res);
811         calc_n_flag(res);
812         calc_z_flag(res);
755813         break;
756814      }
757815      case EXNOR:
758816      {
759817         res = (r ^ s) ^ 0xffff;
760818         CLEAR_FLAGS(V_FLAG | N_FLAG | C_FLAG);
761         calc_z_flag(cpustate, res);
819         calc_z_flag(res);
762820         break;
763821      }
764822      default: assert(0);
r19754r19755
767825   return res & 0xffff;
768826}
769827
770static void tor1(esrip_state *cpustate, UINT16 inst)
828void esrip_device::tor1(UINT16 inst)
771829{
772830   UINT16 r = 0;
773831   UINT16 s = 0;
r19754r19755
789847
790848   switch (SRC)
791849   {
792      case TORAA: r = cpustate->ram[RAM_ADDR];   s = cpustate->acc;   dst = ACC;   break;
850      case TORAA: r = m_ram[RAM_ADDR];   s = m_acc;   dst = ACC;   break;
793851      case TORIA:
794852      {
795         if (cpustate->immflag == 0)
853         if (m_immflag == 0)
796854         {
797            cpustate->i_latch = inst;
798            cpustate->immflag = 1;
855            m_i_latch = inst;
856            m_immflag = 1;
799857            return;
800858         }
801859         else
802860         {
803            r = cpustate->ram[RAM_ADDR];
804            s = cpustate->inst;
861            r = m_ram[RAM_ADDR];
862            s = m_inst;
805863            dst = ACC;
806            cpustate->immflag = 0;
864            m_immflag = 0;
807865         }
808866         break;
809867      }
810      case TODRA: r = cpustate->d_latch;      s = cpustate->ram[RAM_ADDR];   dst = ACC;   break;
811      case TORAY: r = cpustate->ram[RAM_ADDR];   s = cpustate->acc;         dst = Y_BUS;break;
868      case TODRA: r = m_d_latch;      s = m_ram[RAM_ADDR];   dst = ACC;   break;
869      case TORAY: r = m_ram[RAM_ADDR];   s = m_acc;         dst = Y_BUS;break;
812870      case TORIY:
813871      {
814         if (cpustate->immflag == 0)
872         if (m_immflag == 0)
815873         {
816            cpustate->i_latch = inst;
817            cpustate->immflag = 1;
874            m_i_latch = inst;
875            m_immflag = 1;
818876            return;
819877         }
820878         else
821879         {
822            r = cpustate->ram[RAM_ADDR];
823            s = cpustate->inst;
880            r = m_ram[RAM_ADDR];
881            s = m_inst;
824882            dst = Y_BUS;
825            cpustate->immflag = 0;
883            m_immflag = 0;
826884         }
827885         break;
828886      }
829      case TODRY: r = cpustate->d_latch;      s = cpustate->ram[RAM_ADDR];   dst = Y_BUS;break;
830      case TORAR: r = cpustate->ram[RAM_ADDR];   s = cpustate->acc;         dst = RAM;   break;
887      case TODRY: r = m_d_latch;      s = m_ram[RAM_ADDR];   dst = Y_BUS;break;
888      case TORAR: r = m_ram[RAM_ADDR];   s = m_acc;         dst = RAM;   break;
831889      case TORIR:
832890      {
833         if (cpustate->immflag == 0)
891         if (m_immflag == 0)
834892         {
835            cpustate->i_latch = inst;
836            cpustate->immflag = 1;
893            m_i_latch = inst;
894            m_immflag = 1;
837895            return;
838896         }
839897         else
840898         {
841            r = cpustate->ram[RAM_ADDR];
842            s = cpustate->inst;
899            r = m_ram[RAM_ADDR];
900            s = m_inst;
843901            dst = RAM;
844            cpustate->immflag = 0;
902            m_immflag = 0;
845903         }
846904         break;
847905      }
848      case TODRR: r = cpustate->d_latch;      s = cpustate->ram[RAM_ADDR];   dst = RAM;   break;
906      case TODRR: r = m_d_latch;      s = m_ram[RAM_ADDR];   dst = RAM;   break;
849907      default: INVALID;
850908   }
851909
852910   /* Operation */
853   res = tor_op(cpustate, r, s, (inst >> 5) & 0xf);
911   res = tor_op(r, s, (inst >> 5) & 0xf);
854912
855913   /* Destination */
856914   switch (dst)
857915   {
858      case ACC:   cpustate->acc = res; break;
916      case ACC:   m_acc = res; break;
859917      case Y_BUS:   break;
860      case RAM:   cpustate->ram[RAM_ADDR] = res; break;
918      case RAM:   m_ram[RAM_ADDR] = res; break;
861919      default:   INVALID;
862920   }
863921
864   cpustate->result = res;
922   m_result = res;
865923}
866924
867static void tor2(esrip_state *cpustate, UINT16 inst)
925void esrip_device::tor2(UINT16 inst)
868926{
869927   UINT16 r = 0;
870928   UINT16 s = 0;
r19754r19755
879937
880938   switch (SRC)
881939   {
882      case TODAR: r = cpustate->d_latch;   s = cpustate->acc;   break;
940      case TODAR: r = m_d_latch;   s = m_acc;   break;
883941      case TOAIR:
884942      {
885         if (cpustate->immflag == 0)
943         if (m_immflag == 0)
886944         {
887            cpustate->i_latch = inst;
888            cpustate->immflag = 1;
945            m_i_latch = inst;
946            m_immflag = 1;
889947            return;
890948         }
891949         else
892950         {
893            r = cpustate->acc;
894            s = cpustate->inst;
895            cpustate->immflag = 0;
951            r = m_acc;
952            s = m_inst;
953            m_immflag = 0;
896954         }
897955         break;
898956      }
899957      case TODIR:
900958      {
901         if (cpustate->immflag == 0)
959         if (m_immflag == 0)
902960         {
903            cpustate->i_latch = inst;
904            cpustate->immflag = 1;
961            m_i_latch = inst;
962            m_immflag = 1;
905963            return;
906964         }
907965         else
908966         {
909            r = cpustate->d_latch;
910            s = cpustate->inst;
911            cpustate->immflag = 0;
967            r = m_d_latch;
968            s = m_inst;
969            m_immflag = 0;
912970         }
913971         break;
914972      }
r19754r19755
916974   }
917975
918976   /* Operation */
919   res = tor_op(cpustate, r, s, (inst >> 5) & 0xf);
977   res = tor_op(r, s, (inst >> 5) & 0xf);
920978
921979   /* Destination is always RAM */
922   cpustate->ram[RAM_ADDR] = res;
980   m_ram[RAM_ADDR] = res;
923981
924   cpustate->result = res;
982   m_result = res;
925983}
926984
927static void tonr(esrip_state *cpustate, UINT16 inst)
985void esrip_device::tonr(UINT16 inst)
928986{
929987   enum
930988   {
r19754r19755
9491007   {
9501008      case TODA:
9511009      {
952         r = cpustate->d_latch;
953         s = cpustate->acc;
1010         r = m_d_latch;
1011         s = m_acc;
9541012         break;
9551013      }
9561014      case TOAI:
r19754r19755
9591017      }
9601018      case TODI:
9611019      {
962         if (cpustate->immflag == 0)
1020         if (m_immflag == 0)
9631021         {
964            cpustate->i_latch = inst;
965            cpustate->immflag = 1;
1022            m_i_latch = inst;
1023            m_immflag = 1;
9661024            return;
9671025         }
9681026         else
9691027         {
970            r = cpustate->d_latch;
971            s = cpustate->inst;
972            cpustate->immflag = 0;
1028            r = m_d_latch;
1029            s = m_inst;
1030            m_immflag = 0;
9731031         }
9741032         break;
9751033      }
r19754r19755
9771035   }
9781036
9791037   /* Operation */
980   res = tor_op(cpustate, r, s, (inst >> 5) & 0xf);
1038   res = tor_op(r, s, (inst >> 5) & 0xf);
9811039
9821040   /* Destination */
9831041   switch (DST)
r19754r19755
9851043      case NRY:
9861044         break;
9871045      case NRA:
988         cpustate->acc = res;
1046         m_acc = res;
9891047         break;
9901048      case NRS:
9911049         UNHANDLED;
r19754r19755
9961054      default:
9971055         INVALID;
9981056   }
999   cpustate->result = res;
1057   m_result = res;
10001058}
10011059
10021060/*************************************
r19754r19755
10051063 *
10061064 *************************************/
10071065
1008static void bonr(esrip_state *cpustate, UINT16 inst)
1066void esrip_device::bonr(UINT16 inst)
10091067{
10101068   enum
10111069   {
r19754r19755
10311089   {
10321090      case TSTNA:
10331091      {
1034         res = cpustate->acc & (1 << N);
1092         res = m_acc & (1 << N);
10351093         CLEAR_FLAGS(V_FLAG | C_FLAG);
1036         calc_n_flag(cpustate, res);
1037         calc_z_flag(cpustate, res);
1094         calc_n_flag(res);
1095         calc_z_flag(res);
10381096         break;
10391097      }
10401098      case RSTNA:
10411099      {
1042         res = cpustate->acc & ~(1 << N);
1100         res = m_acc & ~(1 << N);
10431101         CLEAR_FLAGS(V_FLAG | C_FLAG);
1044         calc_n_flag(cpustate, res);
1045         calc_z_flag(cpustate, res);
1046         cpustate->acc = res;
1102         calc_n_flag(res);
1103         calc_z_flag(res);
1104         m_acc = res;
10471105         break;
10481106      }
10491107      case SETNA:
10501108      {
1051         res = cpustate->acc | (1 << N);
1109         res = m_acc | (1 << N);
10521110         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1053         calc_n_flag(cpustate, res);
1054         cpustate->acc = res;
1111         calc_n_flag(res);
1112         m_acc = res;
10551113         break;
10561114      }
10571115      case A2NA:
10581116      {
1059         UINT16 r = cpustate->acc;
1117         UINT16 r = m_acc;
10601118         UINT16 s = 1 << N;
10611119         res = r + s;
1062         calc_z_flag(cpustate, res);
1063         calc_n_flag(cpustate, res);
1064         calc_c_flag_add(cpustate, r, s);
1065         calc_v_flag_add(cpustate, r, s, res);
1066         cpustate->acc = res;
1120         calc_z_flag(res);
1121         calc_n_flag(res);
1122         calc_c_flag_add(r, s);
1123         calc_v_flag_add(r, s, res);
1124         m_acc = res;
10671125         break;
10681126      }
10691127      case S2NA:
10701128      {
1071         UINT16 r = cpustate->acc;
1129         UINT16 r = m_acc;
10721130         UINT16 s = 1 << N;
10731131         res = r - s;
1074         calc_z_flag(cpustate, res);
1075         calc_n_flag(cpustate, res);
1076         calc_c_flag_sub(cpustate, r, s);
1077         calc_v_flag_sub(cpustate, r, s, res);
1078         cpustate->acc = res;
1132         calc_z_flag(res);
1133         calc_n_flag(res);
1134         calc_c_flag_sub(r, s);
1135         calc_v_flag_sub(r, s, res);
1136         m_acc = res;
10791137         break;
10801138      }
10811139
10821140      case TSTND:
10831141      {
1084         res = cpustate->d_latch & (1 << N);
1142         res = m_d_latch & (1 << N);
10851143         CLEAR_FLAGS(V_FLAG | C_FLAG);
1086         calc_n_flag(cpustate, res);
1087         calc_z_flag(cpustate, res);
1144         calc_n_flag(res);
1145         calc_z_flag(res);
10881146         break;
10891147      }
10901148
10911149      case SETND:
10921150      {
1093         UINT16 r = cpustate->d_latch;
1151         UINT16 r = m_d_latch;
10941152         res = r | (1 << N);
1095         cpustate->d_latch = res;
1153         m_d_latch = res;
10961154
10971155         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1098         calc_n_flag(cpustate, res);
1156         calc_n_flag(res);
10991157         break;
11001158      }
11011159      case LD2NY:
11021160      {
11031161         res = (1 << N);
11041162         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1105         calc_n_flag(cpustate, res);
1163         calc_n_flag(res);
11061164         break;
11071165      }
11081166      case LDC2NY:
11091167      {
11101168         res = (1 << N) ^ 0xffff;
11111169         CLEAR_FLAGS(Z_FLAG | C_FLAG | V_FLAG);
1112         calc_n_flag(cpustate, res);
1170         calc_n_flag(res);
11131171         break;
11141172      }
11151173
11161174      case A2NDY:
11171175      {
1118         UINT16 r = cpustate->d_latch;
1176         UINT16 r = m_d_latch;
11191177         UINT16 s = 1 << N;
11201178         res = r + s;
11211179
1122         calc_z_flag(cpustate, res);
1123         calc_n_flag(cpustate, res);
1124         calc_c_flag_add(cpustate, r, s);
1125         calc_v_flag_add(cpustate, r, s, res);
1180         calc_z_flag(res);
1181         calc_n_flag(res);
1182         calc_c_flag_add(r, s);
1183         calc_v_flag_add(r, s, res);
11261184         break;
11271185      }
11281186
r19754r19755
11301188         UNHANDLED;
11311189   }
11321190
1133   cpustate->result = res;
1191   m_result = res;
11341192}
11351193
1136static void bor1(esrip_state *cpustate, UINT16 inst)
1194void esrip_device::bor1(UINT16 inst)
11371195{
11381196   enum
11391197   {
r19754r19755
11481206   {
11491207      case SETNR:
11501208      {
1151         res = cpustate->ram[RAM_ADDR] | (1 << N);
1152         cpustate->ram[RAM_ADDR] = res;
1209         res = m_ram[RAM_ADDR] | (1 << N);
1210         m_ram[RAM_ADDR] = res;
11531211         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1154         calc_n_flag(cpustate, res);
1212         calc_n_flag(res);
11551213         break;
11561214      }
11571215      case RSTNR:
11581216      {
1159         res = cpustate->ram[RAM_ADDR] & ~(1 << N);
1160         cpustate->ram[RAM_ADDR] = res;
1217         res = m_ram[RAM_ADDR] & ~(1 << N);
1218         m_ram[RAM_ADDR] = res;
11611219         CLEAR_FLAGS(V_FLAG | C_FLAG);
1162         calc_n_flag(cpustate, res);
1163         calc_z_flag(cpustate, res);
1220         calc_n_flag(res);
1221         calc_z_flag(res);
11641222         break;
11651223      }
11661224      case TSTNR:
11671225      {
1168         res = cpustate->ram[RAM_ADDR] & (1 << N);
1226         res = m_ram[RAM_ADDR] & (1 << N);
11691227         CLEAR_FLAGS(V_FLAG | C_FLAG);
1170         calc_n_flag(cpustate, res);
1171         calc_z_flag(cpustate, res);
1228         calc_n_flag(res);
1229         calc_z_flag(res);
11721230         break;
11731231      }
11741232      default: INVALID;
11751233   }
11761234
1177   cpustate->result = res;
1235   m_result = res;
11781236}
11791237
1180
1181
1182static void bor2(esrip_state *cpustate, UINT16 inst)
1238void esrip_device::bor2(UINT16 inst)
11831239{
11841240   enum
11851241   {
r19754r19755
11971253      {
11981254         res = 1 << N;
11991255         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1200         calc_n_flag(cpustate, res);
1256         calc_n_flag(res);
12011257         break;
12021258      }
12031259      case LDC2NR:
12041260      {
12051261         res = (1 << N) ^ 0xffff;
12061262         CLEAR_FLAGS(V_FLAG | C_FLAG | Z_FLAG);
1207         calc_n_flag(cpustate, res);
1263         calc_n_flag(res);
12081264         break;
12091265      }
12101266      case A2NR:
12111267      {
1212         UINT16 r = cpustate->ram[RAM_ADDR];
1268         UINT16 r = m_ram[RAM_ADDR];
12131269         UINT16 s = 1 << N;
12141270
12151271         res = r + s;
1216         calc_v_flag_add(cpustate, r, s, res);
1217         calc_n_flag(cpustate, res);
1218         calc_c_flag_add(cpustate, r, s);
1219         calc_z_flag(cpustate, res);
1272         calc_v_flag_add(r, s, res);
1273         calc_n_flag(res);
1274         calc_c_flag_add(r, s);
1275         calc_z_flag(res);
12201276         break;
12211277      }
12221278      case S2NR:
12231279      {
1224         UINT16 r = cpustate->ram[RAM_ADDR];
1280         UINT16 r = m_ram[RAM_ADDR];
12251281         UINT16 s = 1 << N;
12261282
12271283         res = r - s;
1228         calc_v_flag_sub(cpustate, r, s, res);
1229         calc_n_flag(cpustate, res);
1230         calc_c_flag_sub(cpustate, r, s);
1231         calc_z_flag(cpustate, res);
1284         calc_v_flag_sub(r, s, res);
1285         calc_n_flag(res);
1286         calc_c_flag_sub(r, s);
1287         calc_z_flag(res);
12321288         break;
12331289      }
12341290      default: INVALID;
12351291   }
12361292
12371293   /* Destination is RAM */
1238   cpustate->ram[RAM_ADDR] = res;
1239   cpustate->result = res;
1294   m_ram[RAM_ADDR] = res;
1295   m_result = res;
12401296}
12411297
12421298/*************************************
r19754r19755
12461302 *************************************/
12471303
12481304/* TODO Combine these */
1249static void rotr1(esrip_state *cpustate, UINT16 inst)
1305void esrip_device::rotr1(UINT16 inst)
12501306{
12511307   enum
12521308   {
r19754r19755
12621318
12631319   switch ((inst >> 5) & 0xf)
12641320   {
1265      case RTRA: u = cpustate->ram[RAM_ADDR];   dst = ACC;      break;
1266      case RTRY: u = cpustate->ram[RAM_ADDR];   dst = Y_BUS;   break;
1267      case RTRR: u = cpustate->ram[RAM_ADDR];   dst = RAM;      break;
1321      case RTRA: u = m_ram[RAM_ADDR];   dst = ACC;      break;
1322      case RTRY: u = m_ram[RAM_ADDR];   dst = Y_BUS;   break;
1323      case RTRR: u = m_ram[RAM_ADDR];   dst = RAM;      break;
12681324      default: INVALID;
12691325   }
12701326
12711327   res = (u << n) | (u >> (16 - n));
12721328   CLEAR_FLAGS(V_FLAG | C_FLAG);
1273   calc_n_flag(cpustate, res);
1274   calc_z_flag(cpustate, res);
1329   calc_n_flag(res);
1330   calc_z_flag(res);
12751331
12761332   switch (dst)
12771333   {
1278      case ACC: cpustate->acc = res; break;
1279      case RAM: cpustate->ram[RAM_ADDR] = res; break;
1334      case ACC: m_acc = res; break;
1335      case RAM: m_ram[RAM_ADDR] = res; break;
12801336   }
12811337
1282   cpustate->result = res;
1338   m_result = res;
12831339}
12841340
1285static void rotr2(esrip_state *cpustate, UINT16 inst)
1341void esrip_device::rotr2(UINT16 inst)
12861342{
12871343   enum
12881344   {
r19754r19755
12951351
12961352   switch ((inst >> 5) & 0xf)
12971353   {
1298      case RTAR: u = cpustate->acc;      break;
1299      case RTDR: u = cpustate->d_latch;   break;
1354      case RTAR: u = m_acc;      break;
1355      case RTDR: u = m_d_latch;   break;
13001356      default: INVALID;
13011357   }
13021358
13031359   res = (u << N) | (u >> (16 - N));
13041360   CLEAR_FLAGS(V_FLAG | C_FLAG);
1305   calc_n_flag(cpustate, res);
1306   calc_z_flag(cpustate, res);
1307   cpustate->ram[RAM_ADDR] = res;
1361   calc_n_flag(res);
1362   calc_z_flag(res);
1363   m_ram[RAM_ADDR] = res;
13081364
1309   cpustate->result = res;
1365   m_result = res;
13101366}
13111367
1312static void rotnr(esrip_state *cpustate, UINT16 inst)
1368void esrip_device::rotnr(UINT16 inst)
13131369{
13141370   enum
13151371   {
r19754r19755
13251381
13261382   switch (inst & 0x1f)
13271383   {
1328      case RTDY: u = cpustate->d_latch;   dst = Y_BUS;   break;
1329      case RTDA: u = cpustate->d_latch;   dst = ACC;      break;
1330      case RTAY: u = cpustate->acc;      dst = Y_BUS;   break;
1331      case RTAA: u = cpustate->acc;      dst = ACC;      break;
1384      case RTDY: u = m_d_latch;   dst = Y_BUS;   break;
1385      case RTDA: u = m_d_latch;   dst = ACC;      break;
1386      case RTAY: u = m_acc;      dst = Y_BUS;   break;
1387      case RTAA: u = m_acc;      dst = ACC;      break;
13321388      default: INVALID;
13331389   }
13341390
13351391   res = (u << N) | (u >> (16 - N));
13361392   CLEAR_FLAGS(V_FLAG | C_FLAG);
1337   calc_n_flag(cpustate, res);
1338   calc_z_flag(cpustate, res);
1393   calc_n_flag(res);
1394   calc_z_flag(res);
13391395
13401396   switch (dst)
13411397   {
13421398      case Y_BUS: break;
1343      case ACC: cpustate->acc = res; break;
1344      case RAM: cpustate->ram[RAM_ADDR] = res; break;
1399      case ACC: m_acc = res; break;
1400      case RAM: m_ram[RAM_ADDR] = res; break;
13451401      default: UNHANDLED;
13461402   }
13471403
1348   cpustate->result = res;
1404   m_result = res;
13491405}
13501406
13511407/*************************************
r19754r19755
13541410 *
13551411 *************************************/
13561412
1357static void rotc(esrip_state *cpustate, UINT16 inst)
1413void esrip_device::rotc(UINT16 inst)
13581414{
13591415   UNHANDLED;
13601416}
r19754r19755
13651421 *
13661422 *************************************/
13671423
1368static void rotm(esrip_state *cpustate, UINT16 inst)
1424void esrip_device::rotm(UINT16 inst)
13691425{
13701426   UNHANDLED;
13711427}
r19754r19755
13761432 *
13771433 *************************************/
13781434
1379static void prt(esrip_state *cpustate, UINT16 inst)
1435void esrip_device::prt(UINT16 inst)
13801436{
13811437   UNHANDLED;
13821438}
13831439
1384static void prtnr(esrip_state *cpustate, UINT16 inst)
1440void esrip_device::prtnr(UINT16 inst)
13851441{
13861442   UNHANDLED;
13871443}
r19754r19755
13931449 *
13941450 *************************************/
13951451
1396static void crcf(esrip_state *cpustate, UINT16 inst)
1452void esrip_device::crcf(UINT16 inst)
13971453{
13981454   UNHANDLED;
13991455}
14001456
1401static void crcr(esrip_state *cpustate, UINT16 inst)
1457void esrip_device::crcr(UINT16 inst)
14021458{
14031459   UNHANDLED;
14041460}
r19754r19755
14211477   SHDNOV = 8,
14221478};
14231479
1424#define   SET_LINK_flag(cpustate, x)   (cpustate->new_status &= ~L_FLAG); \
1425                     (cpustate->new_status |= x ? L_FLAG : 0)
1480#define   SET_LINK_flag(x)   (m_new_status &= ~L_FLAG); \
1481                     (m_new_status |= x ? L_FLAG : 0)
14261482
1427static UINT16 shift_op(esrip_state *cpustate, UINT16 u, int opcode)
1483UINT16 esrip_device::shift_op(UINT16 u, int opcode)
14281484{
14291485   UINT32 res = 0;
14301486
r19754r19755
14331489      case SHUPZ:
14341490      {
14351491         res = (u << 1);
1436         SET_LINK_flag(cpustate, u & 0x8000);
1492         SET_LINK_flag(u & 0x8000);
14371493         CLEAR_FLAGS(V_FLAG | C_FLAG);
1438         calc_n_flag(cpustate, res);
1439         calc_z_flag(cpustate, res);
1494         calc_n_flag(res);
1495         calc_z_flag(res);
14401496         break;
14411497      }
14421498      case SHUP1:
14431499      {
14441500         res = (u << 1) | 1;
1445         SET_LINK_flag(cpustate, u & 0x8000);
1501         SET_LINK_flag(u & 0x8000);
14461502         CLEAR_FLAGS(V_FLAG | C_FLAG);
1447         calc_n_flag(cpustate, res);
1448         calc_z_flag(cpustate, res);
1503         calc_n_flag(res);
1504         calc_z_flag(res);
14491505         break;
14501506      }
14511507      case SHUPL:
14521508      {
1453         res = (u << 1) | ((cpustate->status & L_FLAG) ? 1 : 0);
1454         SET_LINK_flag(cpustate, u & 0x8000);
1509         res = (u << 1) | ((m_status & L_FLAG) ? 1 : 0);
1510         SET_LINK_flag(u & 0x8000);
14551511         CLEAR_FLAGS(V_FLAG | C_FLAG);
1456         calc_n_flag(cpustate, res);
1457         calc_z_flag(cpustate, res);
1512         calc_n_flag(res);
1513         calc_z_flag(res);
14581514         break;
14591515      }
14601516
r19754r19755
14691525   return res;
14701526}
14711527
1472static void shftr(esrip_state *cpustate, UINT16 inst)
1528void esrip_device::shftr(UINT16 inst)
14731529{
14741530   enum
14751531   {
r19754r19755
14821538
14831539   switch ((inst >> 9) & 0xf)
14841540   {
1485      case SHRR: u = cpustate->ram[RAM_ADDR];   break;
1486      case SHDR: u = cpustate->d_latch;         break;
1541      case SHRR: u = m_ram[RAM_ADDR];   break;
1542      case SHDR: u = m_d_latch;         break;
14871543      default: INVALID;
14881544   }
14891545
1490   res = shift_op(cpustate, u, (inst >> 5) & 0xf);
1546   res = shift_op(u, (inst >> 5) & 0xf);
14911547
14921548   /* Destination is always RAM */
1493   cpustate->ram[RAM_ADDR] = res;
1494   cpustate->result = res;
1549   m_ram[RAM_ADDR] = res;
1550   m_result = res;
14951551}
14961552
1497static void shftnr(esrip_state *cpustate, UINT16 inst)
1553void esrip_device::shftnr(UINT16 inst)
14981554{
14991555   enum
15001556   {
r19754r19755
15071563
15081564   switch ((inst >> 9) & 0xf)
15091565   {
1510      case SHA: u = cpustate->acc;         break;
1511      case SHD: u = cpustate->d_latch;      break;
1566      case SHA: u = m_acc;         break;
1567      case SHD: u = m_d_latch;      break;
15121568      default: INVALID;
15131569   }
15141570
1515   res = shift_op(cpustate, u, (inst >> 5) & 0xf);
1571   res = shift_op(u, (inst >> 5) & 0xf);
15161572
15171573   switch (DST)
15181574   {
15191575      case NRY:   break;
1520      case NRA:   cpustate->acc = res; break;
1576      case NRA:   m_acc = res; break;
15211577      default:   INVALID;
15221578   }
1523   cpustate->result = res;
1579   m_result = res;
15241580}
15251581
15261582
r19754r19755
15301586 *
15311587 *************************************/
15321588
1533static void svstr(esrip_state *cpustate, UINT16 inst)
1589void esrip_device::svstr(UINT16 inst)
15341590{
15351591   UNHANDLED;
15361592}
15371593
1538static void rstst(esrip_state *cpustate, UINT16 inst)
1594void esrip_device::rstst(UINT16 inst)
15391595{
15401596   enum
15411597   {
r19754r19755
15551611      case RF3:   CLEAR_FLAGS(FLAG_3); break;
15561612   }
15571613
1558   cpustate->result = 0;
1614   m_result = 0;
15591615}
15601616
1561static void setst(esrip_state *cpustate, UINT16 inst)
1617void esrip_device::setst(UINT16 inst)
15621618{
15631619   enum
15641620   {
r19754r19755
15781634      case SF3:   SET_FLAGS(FLAG_3); break;
15791635   }
15801636
1581   cpustate->result = 0xffff;
1637   m_result = 0xffff;
15821638}
15831639
1584static void test(esrip_state *cpustate, UINT16 inst)
1640void esrip_device::test(UINT16 inst)
15851641{
15861642   enum
15871643   {
r19754r19755
16051661   {
16061662      case TNOZ: UNHANDLED; break;
16071663      case TNO:  UNHANDLED; break;
1608      case TZ:   res = cpustate->status & (Z_FLAG); break;
1609      case TOVR: res = cpustate->status & (V_FLAG); break;
1664      case TZ:   res = m_status & (Z_FLAG); break;
1665      case TOVR: res = m_status & (V_FLAG); break;
16101666      case TLOW: UNHANDLED; break;
1611      case TC:   res = cpustate->status & (C_FLAG); break;
1667      case TC:   res = m_status & (C_FLAG); break;
16121668      case TZC:  UNHANDLED; break;
1613      case TN:   res = cpustate->status & (N_FLAG); break;
1614      case TL:   res = cpustate->status & (L_FLAG); break;
1615      case TF1:  res = cpustate->status & (FLAG_1); break;
1616      case TF2:  res = cpustate->status & (FLAG_2); break;
1617      case TF3:  res = cpustate->status & (FLAG_3); break;
1669      case TN:   res = m_status & (N_FLAG); break;
1670      case TL:   res = m_status & (L_FLAG); break;
1671      case TF1:  res = m_status & (FLAG_1); break;
1672      case TF2:  res = m_status & (FLAG_2); break;
1673      case TF3:  res = m_status & (FLAG_3); break;
16181674      default:   INVALID;
16191675   }
16201676
1621   cpustate->ct = res ? 1 : 0;
1677   m_ct = res ? 1 : 0;
16221678}
16231679
16241680
r19754r19755
16281684 *
16291685 *************************************/
16301686
1631static void nop(esrip_state *cpustate, UINT16 inst)
1687void esrip_device::nop(UINT16 inst)
16321688{
1633   cpustate->result = 0xff;   // Undefined
1689   m_result = 0xff;   // Undefined
16341690}
16351691
1636static void (*const operations[24])(esrip_state *cpustate, UINT16 inst) =
1692//**************************************************************************
1693//  DEVICE INTERFACE
1694//**************************************************************************
1695
1696const device_type ESRIP = &device_creator<esrip_device>;
1697
1698//-------------------------------------------------
1699//  esrip_device - constructor
1700//-------------------------------------------------
1701
1702esrip_device::esrip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
1703   : cpu_device(mconfig, ESRIP, "ESRIP", tag, owner, clock),
1704     m_program_config("program", ENDIANNESS_BIG, 64, 9, -3)
16371705{
1638   rotr1, tor1, rotr2, rotc, rotm, bor2, crcf, crcr,
1639   svstr, prt, sor, tor2, shftr, test, nop, setst, rstst,
1640   rotnr, bonr, bor1, sonr, shftnr, prtnr, tonr
1706   // build the opcode table
1707   for (int op = 0; op < 24; op++)
1708      m_opcode[op] = s_opcodetable[op];
1709}
1710
1711
1712//-------------------------------------------------
1713//  static_set_config - set the configuration
1714//  structure
1715//-------------------------------------------------
1716
1717void esrip_device::static_set_config(device_t &device, const esrip_config &config)
1718{
1719   esrip_device &esrip = downcast<esrip_device &>(device);
1720   static_cast<esrip_config &>(esrip) = config;
1721   static_set_static_config(device, &config);
1722}
1723
1724
1725//**************************************************************************
1726//  STATIC OPCODE TABLES
1727//**************************************************************************
1728
1729const esrip_device::ophandler esrip_device::s_opcodetable[24] =
1730{
1731   &esrip_device::rotr1,   &esrip_device::tor1,   &esrip_device::rotr2,   &esrip_device::rotc,
1732   &esrip_device::rotm,   &esrip_device::bor2,   &esrip_device::crcf,   &esrip_device::crcr,
1733   &esrip_device::svstr,   &esrip_device::prt,      &esrip_device::sor,      &esrip_device::tor2,
1734   &esrip_device::shftr,   &esrip_device::test,   &esrip_device::nop,      &esrip_device::setst,
1735   &esrip_device::rstst,   &esrip_device::rotnr,   &esrip_device::bonr,   &esrip_device::bor1,
1736   &esrip_device::sonr,   &esrip_device::shftnr,   &esrip_device::prtnr,   &esrip_device::tonr
16411737};
16421738
1643INLINE void am29116_execute(esrip_state *cpustate, UINT16 inst, int _sre)
1739
1740void esrip_device::am29116_execute(UINT16 inst, int _sre)
16441741{
16451742   /* Status register shadow */
1646   cpustate->new_status = cpustate->status;
1743   m_new_status = m_status;
16471744
16481745   /* Required for immediate source instructions */
1649   cpustate->inst = inst;
1746   m_inst = inst;
16501747
1651   if (cpustate->immflag == 1)
1652      inst = cpustate->i_latch;
1748   if (m_immflag == 1)
1749      inst = m_i_latch;
16531750
1654   (*operations[cpustate->optable[inst]])(cpustate, inst);
1751   (this->*m_opcode[m_optable[inst]])(inst);
16551752
16561753   if (!_sre)
16571754   {
1658      cpustate->status = cpustate->new_status;
1659      cpustate->t = cpustate->status;
1755      m_status = m_new_status;
1756      m_t = m_status;
16601757   }
16611758}
16621759
16631760
1664static CPU_EXECUTE( esrip )
1761//-------------------------------------------------
1762//  execute_min_cycles - return minimum number of
1763//  cycles it takes for one instruction to execute
1764//-------------------------------------------------
1765
1766UINT32 esrip_device::execute_min_cycles() const
16651767{
1666   esrip_state *cpustate = get_safe_token(device);
1667   int calldebugger = (device->machine().debug_flags & DEBUG_FLAG_ENABLED) != 0;
1768   return 1;
1769}
1770
1771
1772//-------------------------------------------------
1773//  execute_max_cycles - return maximum number of
1774//  cycles it takes for one instruction to execute
1775//-------------------------------------------------
1776
1777UINT32 esrip_device::execute_max_cycles() const
1778{
1779   return 1;
1780}
1781
1782
1783//-------------------------------------------------
1784//  execute_input_lines - return the number of
1785//  input/interrupt lines
1786//-------------------------------------------------
1787
1788UINT32 esrip_device::execute_input_lines() const
1789{
1790   return 0;
1791}
1792
1793
1794//-------------------------------------------------
1795//  execute_set_input - act on a changed input/
1796//  interrupt line
1797//-------------------------------------------------
1798
1799void esrip_device::execute_set_input(int inputnum, int state)
1800{
1801}
1802
1803
1804void esrip_device::execute_run()
1805{
1806   int calldebugger = (machine().debug_flags & DEBUG_FLAG_ENABLED) != 0;
16681807   UINT8 status;
16691808
16701809   /* I think we can get away with placing this outside of the loop */
1671   status = cpustate->status_in(device->machine());
1810   status = m_status_in(machine());
16721811
16731812   /* Core execution loop */
16741813   do
r19754r19755
16791818      UINT16   ipt_bus = 0;
16801819      UINT16   y_bus = 0;
16811820
1682      int yoe = _BIT(cpustate->l5, 1);
1683      int bl46 = BIT(cpustate->l4, 6);
1684      int bl44 = BIT(cpustate->l4, 4);
1821      int yoe = _BIT(m_l5, 1);
1822      int bl46 = BIT(m_l4, 6);
1823      int bl44 = BIT(m_l4, 4);
16851824
16861825      UINT32 in_h;
16871826      UINT32 in_l;
16881827
1689      if (cpustate->fig_cycles)
1828      if (m_fig_cycles)
16901829      {
1691         if (--cpustate->fig_cycles == 0)
1692            cpustate->fig = 0;
1830         if (--m_fig_cycles == 0)
1831            m_fig = 0;
16931832      }
16941833
16951834      /* /OEY = 1 : Y-bus is high imped */
16961835      if (yoe)
16971836      {
16981837         /* Status In */
1699         if (!_BIT(cpustate->l2, 0))
1700            y_bus = status | (!cpustate->fig << 3);
1838         if (!_BIT(m_l2, 0))
1839            y_bus = status | (!m_fig << 3);
17011840
17021841         /* FDT RAM: /Enable, Direction and /RAM OE */
1703         else if (!bl44 && !_BIT(cpustate->l2, 3) && bl46)
1704            y_bus = cpustate->fdt_r(device, *cpustate->program, cpustate->fdt_cnt, 0);
1842         else if (!bl44 && !_BIT(m_l2, 3) && bl46)
1843            y_bus = m_fdt_r(this, *m_program, m_fdt_cnt, 0);
17051844
17061845         /* IPT RAM: /Enable and /READ */
1707         else if (!_BIT(cpustate->l2, 6) && !_BIT(cpustate->l4, 5))
1708            y_bus = cpustate->ipt_ram[cpustate->ipt_cnt];
1846         else if (!_BIT(m_l2, 6) && !_BIT(m_l4, 5))
1847            y_bus = m_ipt_ram[m_ipt_cnt];
17091848
17101849         /* DLE  - latch the value on the Y-BUS into the data latch */
1711         if (_BIT(cpustate->l5, 0))
1712            cpustate->d_latch = y_bus;
1850         if (_BIT(m_l5, 0))
1851            m_d_latch = y_bus;
17131852
17141853         /* Now execute the AM29116 instruction */
1715         am29116_execute(cpustate, (cpustate->l7 << 8) | cpustate->l6, BIT(cpustate->l5, 2));
1854         am29116_execute((m_l7 << 8) | m_l6, BIT(m_l5, 2));
17161855      }
17171856      else
17181857      {
1719         am29116_execute(cpustate, (cpustate->l7 << 8) | cpustate->l6, BIT(cpustate->l5, 2));
1858         am29116_execute((m_l7 << 8) | m_l6, BIT(m_l5, 2));
17201859
1721         y_bus = cpustate->result;
1860         y_bus = m_result;
17221861
1723         if (BIT(cpustate->l5, 0))
1724            cpustate->d_latch = y_bus;
1862         if (BIT(m_l5, 0))
1863            m_d_latch = y_bus;
17251864      }
17261865
17271866      /* Determine what value is on the X-Bus */
17281867
17291868      /* FDT RAM */
17301869      if (!bl44)
1731         x_bus = cpustate->fdt_r(device, *cpustate->program, cpustate->fdt_cnt, 0);
1870         x_bus = m_fdt_r(this, *m_program, m_fdt_cnt, 0);
17321871
17331872      /* Buffer is enabled - write direction */
1734      else if (!BIT(cpustate->l2, 3) && !bl46)
1873      else if (!BIT(m_l2, 3) && !bl46)
17351874      {
17361875         if (!yoe)
17371876            x_bus = y_bus;
1738         else if ( !BIT(cpustate->l2, 6) && !BIT(cpustate->l4, 5) )
1739            x_bus = cpustate->ipt_ram[cpustate->ipt_cnt];
1877         else if ( !BIT(m_l2, 6) && !BIT(m_l4, 5) )
1878            x_bus = m_ipt_ram[m_ipt_cnt];
17401879      }
17411880
17421881      /* IPT BUS */
1743      if (!BIT(cpustate->l2, 6))
1744         ipt_bus = cpustate->ipt_ram[cpustate->ipt_cnt];
1745      else if (!BIT(cpustate->l4, 5))
1882      if (!BIT(m_l2, 6))
1883         ipt_bus = m_ipt_ram[m_ipt_cnt];
1884      else if (!BIT(m_l4, 5))
17461885      {
1747         if (!BIT(cpustate->l5, 1))
1886         if (!BIT(m_l5, 1))
17481887            ipt_bus = y_bus;
17491888         else
17501889            ipt_bus = x_bus;
r19754r19755
17521891
17531892
17541893      /* Write FDT RAM: /Enable, Direction and WRITE */
1755      if (!BIT(cpustate->l2, 3) && !bl46 && !BIT(cpustate->l4, 3))
1756         cpustate->fdt_w(device, *cpustate->program, cpustate->fdt_cnt, x_bus, 0);
1894      if (!BIT(m_l2, 3) && !bl46 && !BIT(m_l4, 3))
1895         m_fdt_w(this, *m_program, m_fdt_cnt, x_bus, 0);
17571896
17581897      /* Write IPT RAM: /Enable and /WR */
1759      if (!BIT(cpustate->l2, 7) && !BIT(cpustate->l4, 5))
1760         cpustate->ipt_ram[cpustate->ipt_cnt] = ipt_bus;
1898      if (!BIT(m_l2, 7) && !BIT(m_l4, 5))
1899         m_ipt_ram[m_ipt_cnt] = ipt_bus;
17611900
17621901
1763      if ((((cpustate->l5 >> 3) & 0x1f) & 0x18) != 0x18)
1902      if ((((m_l5 >> 3) & 0x1f) & 0x18) != 0x18)
17641903      {
1765         if ( check_jmp(cpustate, (cpustate->l5 >> 3) & 0x1f) )
1766            next_pc = cpustate->l1;
1904         if ( check_jmp((m_l5 >> 3) & 0x1f) )
1905            next_pc = m_l1;
17671906         else
1768            next_pc = cpustate->pc + 1;
1907            next_pc = m_pc + 1;
17691908      }
17701909      else
1771         next_pc = cpustate->pc + 1;
1910         next_pc = m_pc + 1;
17721911
1773      cpustate->pl1 = cpustate->l1;
1774      cpustate->pl2 = cpustate->l2;
1775      cpustate->pl3 = cpustate->l3;
1776      cpustate->pl4 = cpustate->l4;
1777      cpustate->pl5 = cpustate->l5;
1778      cpustate->pl6 = cpustate->l6;
1779      cpustate->pl7 = cpustate->l7;
1912      m_pl1 = m_l1;
1913      m_pl2 = m_l2;
1914      m_pl3 = m_l3;
1915      m_pl4 = m_l4;
1916      m_pl5 = m_l5;
1917      m_pl6 = m_l6;
1918      m_pl7 = m_l7;
17801919
17811920      /* Latch instruction */
1782      inst = cpustate->direct->read_decrypted_qword(RIP_PC << 3);
1921      inst = m_direct->read_decrypted_qword(RIP_PC << 3);
17831922
17841923      in_h = inst >> 32;
17851924      in_l = inst & 0xffffffff;
17861925
1787      cpustate->l1 = (in_l >> 8);
1788      cpustate->l2 = (in_l >> 16);
1789      cpustate->l3 = (in_l >> 24);
1926      m_l1 = (in_l >> 8);
1927      m_l2 = (in_l >> 16);
1928      m_l3 = (in_l >> 24);
17901929
1791      cpustate->l4 = (in_h >> 0);
1792      cpustate->l5 = (in_h >> 8);
1793      cpustate->l6 = (in_h >> 16);
1794      cpustate->l7 = (in_h >> 24);
1930      m_l4 = (in_h >> 0);
1931      m_l5 = (in_h >> 8);
1932      m_l6 = (in_h >> 16);
1933      m_l7 = (in_h >> 24);
17951934
17961935      /* Colour latch */
1797      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 0))
1798         cpustate->c_latch = (x_bus >> 12) & 0xf;
1936      if (RISING_EDGE(m_pl3, m_l3, 0))
1937         m_c_latch = (x_bus >> 12) & 0xf;
17991938
18001939      /* Right pixel line buffer address */
1801      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 1))
1802         cpustate->adr_latch = x_bus & 0xfff;
1940      if (RISING_EDGE(m_pl3, m_l3, 1))
1941         m_adr_latch = x_bus & 0xfff;
18031942
18041943      /* Left pixel line buffer address */
1805      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 2))
1806         cpustate->adl_latch = x_bus & 0xfff;
1944      if (RISING_EDGE(m_pl3, m_l3, 2))
1945         m_adl_latch = x_bus & 0xfff;
18071946
18081947      /* FIGLD: Start the DMA */
1809      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 3))
1948      if (RISING_EDGE(m_pl3, m_l3, 3))
18101949      {
1811         cpustate->attr_latch = x_bus;
1950         m_attr_latch = x_bus;
18121951
1813         cpustate->fig = 1;
1814         cpustate->fig_cycles = cpustate->draw(device->machine(), cpustate->adl_latch, cpustate->adr_latch, cpustate->fig_latch, cpustate->attr_latch, cpustate->iaddr_latch, cpustate->c_latch, cpustate->x_scale, cpustate->img_bank);
1952         m_fig = 1;
1953         m_fig_cycles = m_draw(machine(), m_adl_latch, m_adr_latch, m_fig_latch, m_attr_latch, m_iaddr_latch, m_c_latch, m_x_scale, m_img_bank);
18151954      }
18161955
18171956      /* X-scale */
1818      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 4))
1819         cpustate->x_scale = x_bus >> 8;
1957      if (RISING_EDGE(m_pl3, m_l3, 4))
1958         m_x_scale = x_bus >> 8;
18201959
18211960      /* Y-scale and image bank */
1822      if (RISING_EDGE(cpustate->pl4, cpustate->l4, 2))
1961      if (RISING_EDGE(m_pl4, m_l4, 2))
18231962      {
1824         cpustate->y_scale = x_bus & 0xff;
1825         cpustate->img_bank = (y_bus >> 14) & 3;
1963         m_y_scale = x_bus & 0xff;
1964         m_img_bank = (y_bus >> 14) & 3;
18261965      }
18271966
18281967      /* Image ROM address */
1829      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 5))
1830         cpustate->iaddr_latch = y_bus;
1968      if (RISING_EDGE(m_pl3, m_l3, 5))
1969         m_iaddr_latch = y_bus;
18311970
18321971      /* IXLLD */
1833      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 6))
1972      if (RISING_EDGE(m_pl3, m_l3, 6))
18341973      {
1835         cpustate->line_latch = ipt_bus >> 10;
1836         cpustate->fig_latch  = ipt_bus & 0x3ff;
1974         m_line_latch = ipt_bus >> 10;
1975         m_fig_latch  = ipt_bus & 0x3ff;
18371976      }
18381977
18391978      /* Status write */
1840      if (RISING_EDGE(cpustate->pl3, cpustate->l3, 7))
1841         cpustate->status_out = y_bus & 0xff;
1979      if (RISING_EDGE(m_pl3, m_l3, 7))
1980         m_status_out = y_bus & 0xff;
18421981
18431982      /* FDT address counter */
1844      if (!BIT(cpustate->pl2, 1))
1845         cpustate->fdt_cnt = y_bus & 0xfff;
1846      else if (BIT(cpustate->pl2, 2))
1847         cpustate->fdt_cnt = (cpustate->fdt_cnt + 1) & 0xfff;
1983      if (!BIT(m_pl2, 1))
1984         m_fdt_cnt = y_bus & 0xfff;
1985      else if (BIT(m_pl2, 2))
1986         m_fdt_cnt = (m_fdt_cnt + 1) & 0xfff;
18481987
18491988      /* Now we can alter the IPT address counter */
1850      if (!BIT(cpustate->pl2, 4))
1851         cpustate->ipt_cnt = y_bus & 0x1fff;
1852      else if (BIT(cpustate->pl2, 5))
1853         cpustate->ipt_cnt = (cpustate->ipt_cnt + 1) & 0x1fff;
1989      if (!BIT(m_pl2, 4))
1990         m_ipt_cnt = y_bus & 0x1fff;
1991      else if (BIT(m_pl2, 5))
1992         m_ipt_cnt = (m_ipt_cnt + 1) & 0x1fff;
18541993
18551994      if (calldebugger)
1856         debugger_instruction_hook(device, RIP_PC);
1995         debugger_instruction_hook(this, RIP_PC);
18571996
1858      cpustate->pc = next_pc;
1997      m_pc = next_pc;
1998      m_rip_pc = (m_pc | ((m_status_out & 1) << 8));
18591999
1860      cpustate->icount--;
1861   } while (cpustate->icount > 0);
2000      m_icount--;
2001   } while (m_icount > 0);
18622002}
1863
1864
1865/**************************************************************************
1866 * set_info
1867 **************************************************************************/
1868
1869static CPU_SET_INFO( esrip )
1870{
1871   esrip_state *cpustate = get_safe_token(device);
1872
1873   switch (state)
1874   {
1875      /* --- the following bits of info are set as 64-bit signed integers --- */
1876      case CPUINFO_INT_PC:
1877      case CPUINFO_INT_REGISTER + ESRIP_PC:   cpustate->pc = info->i & 0xff;
1878                                    cpustate->status_out &= ~1;
1879                                    cpustate->status_out |= ((info->i >> 8) & 1);
1880                                    break;
1881   }
1882}
1883
1884/**************************************************************************
1885 * get_info
1886 **************************************************************************/
1887
1888CPU_GET_INFO( esrip )
1889{
1890   esrip_state *cpustate = (device != NULL && device->token() != NULL) ? get_safe_token(device) : NULL;
1891
1892   switch (state)
1893   {
1894      /* --- the following bits of info are returned as 64-bit signed integers --- */
1895      case CPUINFO_INT_CONTEXT_SIZE:               info->i = sizeof(esrip_state);   break;
1896      case CPUINFO_INT_ENDIANNESS:               info->i = ENDIANNESS_BIG;      break;
1897      case CPUINFO_INT_CLOCK_MULTIPLIER:            info->i = 1;               break;
1898      case CPUINFO_INT_CLOCK_DIVIDER:               info->i = 1;               break;
1899      case CPUINFO_INT_MIN_INSTRUCTION_BYTES:         info->i = 8;               break;
1900      case CPUINFO_INT_MAX_INSTRUCTION_BYTES:         info->i = 8;               break;
1901      case CPUINFO_INT_MIN_CYCLES:               info->i = 1;               break;
1902      case CPUINFO_INT_MAX_CYCLES:               info->i = 1;               break;
1903
1904      case CPUINFO_INT_DATABUS_WIDTH + AS_PROGRAM:   info->i = 64;         break;
1905      case CPUINFO_INT_ADDRBUS_WIDTH + AS_PROGRAM: info->i = 9;         break;
1906      case CPUINFO_INT_ADDRBUS_SHIFT + AS_PROGRAM: info->i = -3;         break;
1907      case CPUINFO_INT_DATABUS_WIDTH + AS_DATA:   info->i = 0;         break;
1908      case CPUINFO_INT_ADDRBUS_WIDTH + AS_DATA:   info->i = 0;         break;
1909      case CPUINFO_INT_ADDRBUS_SHIFT + AS_DATA:   info->i = 0;         break;
1910      case CPUINFO_INT_DATABUS_WIDTH + AS_IO:      info->i = 0;         break;
1911      case CPUINFO_INT_ADDRBUS_WIDTH + AS_IO:      info->i = 0;         break;
1912      case CPUINFO_INT_ADDRBUS_SHIFT + AS_IO:      info->i = 0;         break;
1913
1914      case CPUINFO_INT_REGISTER:
1915      case CPUINFO_INT_PC:                     info->i = RIP_PC;   break;
1916      case CPUINFO_INT_REGISTER + ESRIP_STATW:      info->i = cpustate->status_out; break;
1917      case CPUINFO_INT_REGISTER + ESRIP_FDTC:         info->i = cpustate->fdt_cnt; break;
1918      case CPUINFO_INT_REGISTER + ESRIP_IPTC:         info->i = cpustate->ipt_cnt; break;
1919
1920      /* --- the following bits of info are returned as pointers to data or functions --- */
1921      case CPUINFO_FCT_SET_INFO:                  info->setinfo = CPU_SET_INFO_NAME(esrip);      break;
1922      case CPUINFO_FCT_INIT:                     info->init = CPU_INIT_NAME(esrip);         break;
1923      case CPUINFO_FCT_RESET:                     info->reset = CPU_RESET_NAME(esrip);         break;
1924      case CPUINFO_FCT_EXIT:                     info->exit = CPU_EXIT_NAME(esrip);         break;
1925      case CPUINFO_FCT_EXECUTE:                  info->execute = CPU_EXECUTE_NAME(esrip);      break;
1926      case CPUINFO_FCT_BURN:                     info->burn = NULL;                  break;
1927      case CPUINFO_FCT_DISASSEMBLE:               info->disassemble = CPU_DISASSEMBLE_NAME(esrip);      break;
1928      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &cpustate->icount;      break;
1929
1930      /* --- the following bits of info are returned as NULL-terminated strings --- */
1931      case CPUINFO_STR_NAME:                     strcpy(info->s, "Real Time Image Processor");      break;
1932      case CPUINFO_STR_FAMILY:               strcpy(info->s, "Entertainment Sciences");         break;
1933      case CPUINFO_STR_VERSION:               strcpy(info->s, "1.0");               break;
1934      case CPUINFO_STR_SOURCE_FILE:                  strcpy(info->s, __FILE__);            break;
1935      case CPUINFO_STR_CREDITS:               strcpy(info->s, "Copyright Philip J Bennett"); break;
1936
1937      case CPUINFO_STR_FLAGS:                     sprintf(info->s, "%c%c%c%c%c%c%c%c%c",
1938                                                      cpustate->status & 0x80 ? '3' : '.',
1939                                                      cpustate->status & 0x40 ? '2' : '.',
1940                                                      cpustate->status & 0x20 ? '1' : '.',
1941                                                      cpustate->status & 0x10 ? 'L' : '.',
1942                                                      cpustate->status & 0x08 ? 'V' : '.',
1943                                                      cpustate->status & 0x04 ? 'N' : '.',
1944                                                      cpustate->status & 0x02 ? 'C' : '.',
1945                                                      cpustate->status & 0x01 ? 'Z' : '.',
1946                                                      get_hblank(device->machine()) ? 'H' : '.'); break;
1947
1948      case CPUINFO_STR_REGISTER + ESRIP_PC:         sprintf(info->s, "PC: %04X", RIP_PC); break;
1949      case CPUINFO_STR_REGISTER + ESRIP_ACC:         sprintf(info->s, "ACC: %04X", cpustate->acc); break;
1950      case CPUINFO_STR_REGISTER + ESRIP_DLATCH:      sprintf(info->s, "DLATCH: %04X", cpustate->d_latch); break;
1951      case CPUINFO_STR_REGISTER + ESRIP_ILATCH:      sprintf(info->s, "ILATCH: %04X", cpustate->i_latch); break;
1952      case CPUINFO_STR_REGISTER + ESRIP_RAM00:      sprintf(info->s, "RAM[00]: %04X", cpustate->ram[0x00]); break;
1953      case CPUINFO_STR_REGISTER + ESRIP_RAM01:      sprintf(info->s, "RAM[01]: %04X", cpustate->ram[0x01]); break;
1954      case CPUINFO_STR_REGISTER + ESRIP_RAM02:      sprintf(info->s, "RAM[02]: %04X", cpustate->ram[0x02]); break;
1955      case CPUINFO_STR_REGISTER + ESRIP_RAM03:      sprintf(info->s, "RAM[03]: %04X", cpustate->ram[0x03]); break;
1956      case CPUINFO_STR_REGISTER + ESRIP_RAM04:      sprintf(info->s, "RAM[04]: %04X", cpustate->ram[0x04]); break;
1957      case CPUINFO_STR_REGISTER + ESRIP_RAM05:      sprintf(info->s, "RAM[05]: %04X", cpustate->ram[0x05]); break;
1958      case CPUINFO_STR_REGISTER + ESRIP_RAM06:      sprintf(info->s, "RAM[06]: %04X", cpustate->ram[0x06]); break;
1959      case CPUINFO_STR_REGISTER + ESRIP_RAM07:      sprintf(info->s, "RAM[07]: %04X", cpustate->ram[0x07]); break;
1960      case CPUINFO_STR_REGISTER + ESRIP_RAM08:      sprintf(info->s, "RAM[08]: %04X", cpustate->ram[0x08]); break;
1961      case CPUINFO_STR_REGISTER + ESRIP_RAM09:      sprintf(info->s, "RAM[09]: %04X", cpustate->ram[0x09]); break;
1962      case CPUINFO_STR_REGISTER + ESRIP_RAM0A:      sprintf(info->s, "RAM[0A]: %04X", cpustate->ram[0x0a]); break;
1963      case CPUINFO_STR_REGISTER + ESRIP_RAM0B:      sprintf(info->s, "RAM[0B]: %04X", cpustate->ram[0x0b]); break;
1964      case CPUINFO_STR_REGISTER + ESRIP_RAM0C:      sprintf(info->s, "RAM[0C]: %04X", cpustate->ram[0x0c]); break;
1965      case CPUINFO_STR_REGISTER + ESRIP_RAM0D:      sprintf(info->s, "RAM[0D]: %04X", cpustate->ram[0x0d]); break;
1966      case CPUINFO_STR_REGISTER + ESRIP_RAM0E:      sprintf(info->s, "RAM[0E]: %04X", cpustate->ram[0x0e]); break;
1967      case CPUINFO_STR_REGISTER + ESRIP_RAM0F:      sprintf(info->s, "RAM[0F]: %04X", cpustate->ram[0x0f]); break;
1968      case CPUINFO_STR_REGISTER + ESRIP_RAM10:      sprintf(info->s, "RAM[10]: %04X", cpustate->ram[0x10]); break;
1969      case CPUINFO_STR_REGISTER + ESRIP_RAM11:      sprintf(info->s, "RAM[11]: %04X", cpustate->ram[0x11]); break;
1970      case CPUINFO_STR_REGISTER + ESRIP_RAM12:      sprintf(info->s, "RAM[12]: %04X", cpustate->ram[0x12]); break;
1971      case CPUINFO_STR_REGISTER + ESRIP_RAM13:      sprintf(info->s, "RAM[13]: %04X", cpustate->ram[0x13]); break;
1972      case CPUINFO_STR_REGISTER + ESRIP_RAM14:      sprintf(info->s, "RAM[14]: %04X", cpustate->ram[0x14]); break;
1973      case CPUINFO_STR_REGISTER + ESRIP_RAM15:      sprintf(info->s, "RAM[15]: %04X", cpustate->ram[0x15]); break;
1974      case CPUINFO_STR_REGISTER + ESRIP_RAM16:      sprintf(info->s, "RAM[16]: %04X", cpustate->ram[0x16]); break;
1975      case CPUINFO_STR_REGISTER + ESRIP_RAM17:      sprintf(info->s, "RAM[17]: %04X", cpustate->ram[0x17]); break;
1976      case CPUINFO_STR_REGISTER + ESRIP_RAM18:      sprintf(info->s, "RAM[18]: %04X", cpustate->ram[0x18]); break;
1977      case CPUINFO_STR_REGISTER + ESRIP_RAM19:      sprintf(info->s, "RAM[19]: %04X", cpustate->ram[0x19]); break;
1978      case CPUINFO_STR_REGISTER + ESRIP_RAM1A:      sprintf(info->s, "RAM[1A]: %04X", cpustate->ram[0x1a]); break;
1979      case CPUINFO_STR_REGISTER + ESRIP_RAM1B:      sprintf(info->s, "RAM[1B]: %04X", cpustate->ram[0x1b]); break;
1980      case CPUINFO_STR_REGISTER + ESRIP_RAM1C:      sprintf(info->s, "RAM[1C]: %04X", cpustate->ram[0x1c]); break;
1981      case CPUINFO_STR_REGISTER + ESRIP_RAM1D:      sprintf(info->s, "RAM[1D]: %04X", cpustate->ram[0x1d]); break;
1982      case CPUINFO_STR_REGISTER + ESRIP_RAM1E:      sprintf(info->s, "RAM[1E]: %04X", cpustate->ram[0x1e]); break;
1983      case CPUINFO_STR_REGISTER + ESRIP_RAM1F:      sprintf(info->s, "RAM[1F]: %04X", cpustate->ram[0x1f]); break;
1984      case CPUINFO_STR_REGISTER + ESRIP_STATW:      sprintf(info->s, "STAT: %04X", cpustate->status_out); break;
1985      case CPUINFO_STR_REGISTER + ESRIP_FDTC:         sprintf(info->s, "FDTC: %04X", cpustate->fdt_cnt); break;
1986      case CPUINFO_STR_REGISTER + ESRIP_IPTC:         sprintf(info->s, "IPTC: %04X", cpustate->ipt_cnt); break;
1987      case CPUINFO_STR_REGISTER + ESRIP_XSCALE:      sprintf(info->s, "XSCL: %04X", cpustate->x_scale); break;
1988      case CPUINFO_STR_REGISTER + ESRIP_YSCALE:      sprintf(info->s, "YSCL: %04X", cpustate->y_scale); break;
1989      case CPUINFO_STR_REGISTER + ESRIP_BANK:         sprintf(info->s, "BANK: %04X", cpustate->img_bank); break;
1990      case CPUINFO_STR_REGISTER + ESRIP_LINE:         sprintf(info->s, "LINE: %04X", cpustate->line_latch); break;
1991      case CPUINFO_STR_REGISTER + ESRIP_FIG:         sprintf(info->s, "FIG: %04X", cpustate->fig_latch); break;
1992      case CPUINFO_STR_REGISTER + ESRIP_ATTR:         sprintf(info->s, "ATTR: %04X", cpustate->attr_latch); break;
1993      case CPUINFO_STR_REGISTER + ESRIP_ADRL:         sprintf(info->s, "ADRL: %04X", cpustate->adl_latch); break;
1994      case CPUINFO_STR_REGISTER + ESRIP_ADRR:         sprintf(info->s, "ADRR: %04X", cpustate->adr_latch); break;
1995      case CPUINFO_STR_REGISTER + ESRIP_COLR:         sprintf(info->s, "COLR: %04X", cpustate->c_latch); break;
1996      case CPUINFO_STR_REGISTER + ESRIP_IADDR:      sprintf(info->s, "IADR: %04X", cpustate->iaddr_latch); break;
1997   }
1998}
1999
2000DEFINE_LEGACY_CPU_DEVICE(ESRIP, esrip);
trunk/src/emu/cpu/esrip/esrip.h
r19754r19755
2121
2222
2323/***************************************************************************
24    INTERFACE CONFIGURATION MACROS
25***************************************************************************/
26
27#define MCFG_CPU_ESRIP_CONFIG(_config) \
28   esrip_device::static_set_config(*device, _config); \
29
30
31/***************************************************************************
2432    REGISTER ENUMERATION
2533***************************************************************************/
2634
r19754r19755
7785   ESRIP_IADDR,
7886};
7987
80/***************************************************************************
81    CONFIGURATION STRUCTURE
82***************************************************************************/
88
89//**************************************************************************
90//  TYPE DEFINITIONS
91//**************************************************************************
92
93class esrip_device;
94
95// ======================> esrip_config
96
8397struct esrip_config
8498{
8599   read16_device_func   fdt_r;
86100   write16_device_func   fdt_w;
87101   UINT8 (*status_in)(running_machine &machine);
88102   int (*draw)(running_machine &machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int bank);
89   const char* const lbrm_prom;
103   const char* lbrm_prom;
90104};
91105
92/***************************************************************************
93    PUBLIC FUNCTIONS
94***************************************************************************/
106// device type definition
107extern const device_type ESRIP;
95108
96DECLARE_LEGACY_CPU_DEVICE(ESRIP, esrip);
109// ======================> esrip_device
97110
98extern UINT8 get_rip_status(device_t *cpu);
111// Used by core CPU interface
112class esrip_device : public cpu_device,
113                public esrip_config
114{
115public:
116   // construction/destruction
117   esrip_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
99118
119   // inline configuration helpers
120   static void static_set_config(device_t &device, const esrip_config &config);
121
122   // public interfaces
123   UINT8 get_rip_status();
124
125protected:
126   // device-level overrides
127   virtual void device_start();
128   virtual void device_reset();
129   virtual void device_stop();
130
131   void make_ops();
132
133   // device_execute_interface overrides
134   virtual UINT32 execute_min_cycles() const;
135   virtual UINT32 execute_max_cycles() const;
136   virtual UINT32 execute_input_lines() const;
137   virtual void execute_run();
138   virtual void execute_set_input(int inputnum, int state);
139
140   // device_memory_interface overrides
141   virtual const address_space_config *memory_space_config(address_spacenum spacenum = AS_0) const;
142
143   // device_disasm_interface overrides
144   virtual UINT32 disasm_min_opcode_bytes() const;
145   virtual UINT32 disasm_max_opcode_bytes() const;
146   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
147
148   // device_state_interface overrides
149   virtual void state_string_export(const device_state_entry &entry, astring &string);
150
151   // address spaces
152   const address_space_config m_program_config;
153
154   // CPU registers
155   UINT16   m_ram[32];
156   UINT16   m_acc;
157   UINT16   m_d_latch;
158   UINT16   m_i_latch;
159   UINT16   m_result;
160   UINT8   m_new_status;
161   UINT8   m_status;
162   UINT16   m_inst;
163   UINT8   m_immflag;
164   UINT8   m_ct;
165   UINT8   m_t;
166
167   /* Instruction latches - current and previous values */
168   UINT8   m_l1, m_pl1;
169   UINT8   m_l2, m_pl2;
170   UINT8   m_l3, m_pl3;
171   UINT8   m_l4, m_pl4;
172   UINT8   m_l5, m_pl5;
173   UINT8   m_l6, m_pl6;
174   UINT8   m_l7, m_pl7;
175
176   UINT8   m_pc;
177   UINT16   m_rip_pc;
178   UINT8   m_status_out;
179
180   UINT8   m_x_scale;
181   UINT8   m_y_scale;
182   UINT8   m_img_bank;
183   UINT8   m_line_latch;
184   UINT16   m_fig_latch;
185   UINT16   m_attr_latch;
186   UINT16   m_adl_latch;
187   UINT16   m_adr_latch;
188   UINT16   m_iaddr_latch;
189   UINT8   m_c_latch;
190
191   UINT16   m_fdt_cnt;
192   UINT16   m_ipt_cnt;
193
194   UINT8   m_fig;
195   UINT16   m_fig_cycles;
196
197   UINT8   m_optable[65536];
198
199   UINT16   *m_ipt_ram;
200   UINT8   *m_lbrm;
201
202   address_space *m_program;
203   direct_read_data *m_direct;
204
205   int      m_icount;
206
207   read16_device_func   m_fdt_r;
208   write16_device_func   m_fdt_w;
209   UINT8 (*m_status_in)(running_machine &machine);
210   int (*m_draw)(running_machine &machine, int l, int r, int fig, int attr, int addr, int col, int x_scale, int bank);
211
212   typedef void (esrip_device::*ophandler)(UINT16 inst);
213
214   ophandler m_opcode[24];
215
216   static const ophandler s_opcodetable[24];
217
218private:
219   int get_hblank();
220   int get_lbrm();
221   int check_jmp(UINT8 jmp_ctrl);
222
223   // flags
224   void calc_z_flag(UINT16 res);
225   void calc_c_flag_add(UINT16 a, UINT16 b);
226   void calc_c_flag_sub(UINT16 a, UINT16 b);
227   void calc_n_flag(UINT16 res);
228   void calc_v_flag_add(UINT16 a, UINT16 b, UINT32 r);
229   void calc_v_flag_sub(UINT16 a, UINT16 b, UINT32 r);
230
231   // opcodes
232   UINT16 sor_op(UINT16 r, UINT16 opcode);
233   void sor(UINT16 inst);
234   void sonr(UINT16 inst);
235
236   UINT16 tor_op(UINT16 r, UINT16 s, int opcode);
237   void tonr(UINT16 inst);
238   void tor1(UINT16 inst);
239   void tor2(UINT16 inst);
240
241   void bonr(UINT16 inst);
242   void bor1(UINT16 inst);
243   void bor2(UINT16 inst);
244
245   void rotr1(UINT16 inst);
246   void rotr2(UINT16 inst);
247   void rotnr(UINT16 inst);
248   void rotc(UINT16 inst);
249   void rotm(UINT16 inst);
250
251   void prt(UINT16 inst);
252   void prtnr(UINT16 inst);
253
254   void crcf(UINT16 inst);
255   void crcr(UINT16 inst);
256
257   UINT16 shift_op(UINT16 u, int opcode);
258   void shftr(UINT16 inst);
259   void shftnr(UINT16 inst);
260
261   void svstr(UINT16 inst);
262
263   void rstst(UINT16 inst);
264   void setst(UINT16 inst);
265
266   void test(UINT16 inst);
267
268   void nop(UINT16 inst);
269
270   void am29116_execute(UINT16 inst, int _sre);
271};
272
273
274CPU_DISASSEMBLE( esrip );
275
100276#endif /* _ESRIP_H */
trunk/src/emu/cpu/m6809/m6809.h
r19754r19755
129129    direct_read_data *m_direct;
130130};
131131
132// device type definition
133extern const device_type ATMEGA88;
134extern const device_type ATMEGA644;
135
136132// ======================> m6809_device
137133
138134class m6809_device : public m6809_base_device

Previous 199869 Revisions Next


© 1997-2024 The MAME Team