Previous 15994 Revisions Next

r9381 Thursday 14th October, 2010 at 12:35:02 UTC by Curt Coder
[CDP1802] Refactored the RCA CDP1802 CPU into a C++ device (COSMAC). The old CDP1802 will coexist until all drivers are refactored to use the new implementation.
[VIP] Refactored driver to define ADDRESS_MAP_MODERN and use the new RCA COSMAC CPU.
[docs]messnew.txt
[src/emu/cpu]cpu.mak
[src/emu/cpu/cosmac]cosdasm.c* cosmac.c* cosmac.h*
[src/mess]mess.mak
[src/mess/drivers]vip.c
[src/mess/includes]vip.h

src/emu/cpu/cpu.mak
r9380r9381
291291
292292
293293#-------------------------------------------------
294# RCA COSMAC
295#-------------------------------------------------
296
297ifneq ($(filter COSMAC,$(CPUS)),)
298OBJDIRS += $(CPUOBJ)/cosmac
299CPUOBJS += $(CPUOBJ)/cosmac/cosmac.o
300DASMOBJS += $(CPUOBJ)/cosmac/cosdasm.o
301endif
302
303$(CPUOBJ)/cosmac/cosmac.o:   $(CPUSRC)/cosmac/cosmac.c \
304                     $(CPUSRC)/cosmac/cosmac.h
305
306
307
308#-------------------------------------------------
294309# National Semiconductor COP400 family
295310#-------------------------------------------------
296311
src/emu/cpu/cosmac/cosmac.c
r0r9381
1/**********************************************************************
2
3    RCA "COSMAC" CPU emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "emu.h"
11#include "debugger.h"
12#include "cosmac.h"
13
14
15/*
16
17   TODO:
18
19   - debugger cursor is not on R(P)
20   - divide clock by 8
21   - min cycles -> 2 and 3
22
23*/
24
25//**************************************************************************
26//  DEVICE DEFINITIONS
27//**************************************************************************
28
29const device_type COSMAC = cosmac_device_config::static_alloc_device_config;
30
31
32
33//**************************************************************************
34//  CONSTANTS
35//**************************************************************************
36
37#define CLOCKS_RESET      8
38#define CLOCKS_INIT         8 // really 9, but needs to be 8 to synchronize cdp1861 video timings
39#define CLOCKS_FETCH      8
40#define CLOCKS_EXECUTE      8
41#define CLOCKS_DMA         8
42#define CLOCKS_INTERRUPT   8
43
44const cosmac_state_code COSMAC_STATE_CODE[] =
45{
46   COSMAC_STATE_CODE_S0_FETCH,      // COSMAC_STATE_0_FETCH
47   COSMAC_STATE_CODE_S1_EXECUTE,   // COSMAC_STATE_1_RESET
48   COSMAC_STATE_CODE_S1_EXECUTE,   // COSMAC_STATE_1_INIT
49   COSMAC_STATE_CODE_S1_EXECUTE,   // COSMAC_STATE_1_EXECUTE
50   COSMAC_STATE_CODE_S2_DMA,       // COSMAC_STATE_2_DMA_IN
51   COSMAC_STATE_CODE_S2_DMA,      // COSMAC_STATE_2_DMA_OUT
52   COSMAC_STATE_CODE_S3_INTERRUPT   // COSMAC_STATE_3_INT
53};
54
55
56
57//**************************************************************************
58//  MACROS
59//**************************************************************************
60
61#define OPCODE_R(addr)      read_opcode(addr)
62#define RAM_R(addr)         read_byte(addr)
63#define RAM_W(addr, data)   write_byte(addr, data)
64#define IO_R(addr)         read_io_byte(addr)
65#define IO_W(addr, data)   write_io_byte(addr, data)
66
67#define P   m_p
68#define X   m_x
69#define D   m_d
70#define B   m_b
71#define T   m_t
72#define R   m_r
73#define DF   m_df
74#define IE   m_ie
75#define Q   m_q
76#define N   m_n
77#define I   m_i
78#define EF   m_ef
79
80#define GET_FLAGS()            ((m_df << 2) | (m_ie << 1) | m_q)
81
82#define SET_FLAGS(v)         do { \
83                           m_df = BIT(v, 2); \
84                           m_ie = BIT(v, 1); \
85                           m_q = BIT(v, 0); \
86                        } while (0);
87
88
89
90//**************************************************************************
91//  STATIC OPCODE TABLES
92//**************************************************************************
93
94const cosmac_device::ophandler cosmac_device::s_opcodetable[256] =
95{
96   &cosmac_device::idl,   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,
97   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,
98   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,
99   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,   &cosmac_device::ldn,
100
101   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,
102   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,
103   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,
104   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,   &cosmac_device::inc,
105
106   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,
107   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,
108   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,
109   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,   &cosmac_device::dec,
110
111   &cosmac_device::br,      &cosmac_device::bq,      &cosmac_device::bz,      &cosmac_device::bdf,
112   &cosmac_device::b,      &cosmac_device::b,      &cosmac_device::b,      &cosmac_device::b,   
113   &cosmac_device::nbr,   &cosmac_device::bnq,   &cosmac_device::bnz,   &cosmac_device::bnf,
114   &cosmac_device::bn,      &cosmac_device::bn,      &cosmac_device::bn,      &cosmac_device::bn,   
115
116   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,
117   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,
118   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,
119   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,   &cosmac_device::lda,
120
121   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,
122   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,
123   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,
124   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,   &cosmac_device::str,
125
126   &cosmac_device::irx,   &cosmac_device::out,   &cosmac_device::out,   &cosmac_device::out,
127   &cosmac_device::out,   &cosmac_device::out,   &cosmac_device::out,   &cosmac_device::out,
128   &cosmac_device::inp,   &cosmac_device::inp,   &cosmac_device::inp,   &cosmac_device::inp,
129   &cosmac_device::inp,   &cosmac_device::inp,   &cosmac_device::inp,   &cosmac_device::inp,
130
131   &cosmac_device::ret,   &cosmac_device::dis,   &cosmac_device::ldxa,   &cosmac_device::stxd,
132   &cosmac_device::adc,   &cosmac_device::sdb,   &cosmac_device::shrc,   &cosmac_device::smb,
133   &cosmac_device::sav,   &cosmac_device::mark,   &cosmac_device::req,   &cosmac_device::seq,
134   &cosmac_device::adci,   &cosmac_device::sdbi,   &cosmac_device::shlc,   &cosmac_device::smbi,
135
136   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,
137   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,
138   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,
139   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,   &cosmac_device::glo,
140
141   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,
142   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,
143   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,
144   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,   &cosmac_device::ghi,
145
146   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,
147   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,
148   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,
149   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,   &cosmac_device::plo,
150
151   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,
152   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,
153   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,
154   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,   &cosmac_device::phi,
155
156   &cosmac_device::lbr,   &cosmac_device::lbq,   &cosmac_device::lbz,   &cosmac_device::lbdf,
157   &cosmac_device::nop,   &cosmac_device::lsnq,   &cosmac_device::lsnz,   &cosmac_device::lsnf,
158   &cosmac_device::nlbr,   &cosmac_device::lbnq,   &cosmac_device::lbnz,   &cosmac_device::lbnf,
159   &cosmac_device::lsie,   &cosmac_device::lsq,   &cosmac_device::lsz,   &cosmac_device::lsdf,
160
161   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,
162   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,
163   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,
164   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,   &cosmac_device::sep,
165
166   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,
167   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,
168   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,
169   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,   &cosmac_device::sex,
170
171   &cosmac_device::ldx,   &cosmac_device::_or,   &cosmac_device::_and,   &cosmac_device::_xor,
172   &cosmac_device::add,   &cosmac_device::sd,      &cosmac_device::shr,   &cosmac_device::sm,   
173   &cosmac_device::ldi,   &cosmac_device::ori,   &cosmac_device::ani,   &cosmac_device::xri,
174   &cosmac_device::adi,   &cosmac_device::sdi,   &cosmac_device::shl,   &cosmac_device::smi
175};
176
177
178
179//**************************************************************************
180//  COSMAC DEVICE CONFIG
181//**************************************************************************
182
183//-------------------------------------------------
184//  cosmac_device_config - constructor
185//-------------------------------------------------
186
187cosmac_device_config::cosmac_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
188   : cpu_device_config(mconfig, static_alloc_device_config, "COSMAC", tag, owner, clock),
189     m_program_config("program", ENDIANNESS_LITTLE, 8, 16),
190     m_io_config("io", ENDIANNESS_LITTLE, 8, 3)
191{
192}
193
194
195//-------------------------------------------------
196//  static_alloc_device_config - allocate a new
197//  configuration object
198//-------------------------------------------------
199
200device_config *cosmac_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
201{
202   return global_alloc(cosmac_device_config(mconfig, tag, owner, clock));
203}
204
205
206//-------------------------------------------------
207//  alloc_device - allocate a new device object
208//-------------------------------------------------
209
210device_t *cosmac_device_config::alloc_device(running_machine &machine) const
211{
212   return auto_alloc(&machine, cosmac_device(machine, *this));
213}
214
215
216//-------------------------------------------------
217//  execute_min_cycles - return minimum number of
218//  cycles it takes for one instruction to execute
219//-------------------------------------------------
220
221UINT32 cosmac_device_config::execute_min_cycles() const
222{
223   return 8 * 2;
224}
225
226
227//-------------------------------------------------
228//  execute_max_cycles - return maximum number of
229//  cycles it takes for one instruction to execute
230//-------------------------------------------------
231
232UINT32 cosmac_device_config::execute_max_cycles() const
233{
234   return 8 * 3;
235}
236
237
238//-------------------------------------------------
239//  execute_input_lines - return the number of
240//  input/interrupt lines
241//-------------------------------------------------
242
243UINT32 cosmac_device_config::execute_input_lines() const
244{
245   return 7;
246}
247
248
249//-------------------------------------------------
250//  memory_space_config - return the configuration
251//  of the specified address space, or NULL if
252//  the space doesn't exist
253//-------------------------------------------------
254
255const address_space_config *cosmac_device_config::memory_space_config(int spacenum) const
256{
257   switch (spacenum)
258   {
259   case AS_PROGRAM:
260      return &m_program_config;
261
262   case AS_IO:
263      return &m_io_config;
264
265   default:
266      return NULL;
267   }
268}
269
270
271//-------------------------------------------------
272//  disasm_min_opcode_bytes - return the length
273//  of the shortest instruction, in bytes
274//-------------------------------------------------
275
276UINT32 cosmac_device_config::disasm_min_opcode_bytes() const
277{
278   return 1;
279}
280
281
282//-------------------------------------------------
283//  disasm_max_opcode_bytes - return the length
284//  of the longest instruction, in bytes
285//-------------------------------------------------
286
287UINT32 cosmac_device_config::disasm_max_opcode_bytes() const
288{
289   return 3;
290}
291
292
293//-------------------------------------------------
294//  device_config_complete - perform any
295//  operations now that the configuration is
296//  complete
297//-------------------------------------------------
298
299void cosmac_device_config::device_config_complete()
300{
301   // inherit a copy of the static data
302   const cosmac_interface *intf = reinterpret_cast<const cosmac_interface *>(static_config());
303   if (intf != NULL)
304      *static_cast<cosmac_interface *>(this) = *intf;
305
306   // or initialize to defaults if none provided
307   else
308   {
309      memset(&m_in_wait_func, 0, sizeof(m_in_wait_func));
310      memset(&m_in_clear_func, 0, sizeof(m_in_clear_func));
311      memset(&m_out_q_func, 0, sizeof(m_out_q_func));
312      memset(&m_in_dma_func, 0, sizeof(m_in_dma_func));
313      // TODO: clear ef1-4
314      m_out_sc_func = NULL;
315      memset(&m_out_dma_func, 0, sizeof(m_out_dma_func));
316      memset(&m_out_tpa_func, 0, sizeof(m_out_tpa_func));
317      memset(&m_out_tpb_func, 0, sizeof(m_out_tpb_func));
318   }
319}
320
321
322
323//**************************************************************************
324//  DEVICE INTERFACE
325//**************************************************************************
326
327//-------------------------------------------------
328//  cosmac_device - constructor
329//-------------------------------------------------
330
331cosmac_device::cosmac_device(running_machine &_machine, const cosmac_device_config &config)
332   : cpu_device(_machine, config),
333     m_op(0),
334     m_state(COSMAC_STATE_1_RESET),
335     m_irq(0),
336     m_dmain(0),
337     m_dmaout(0),
338     m_program(NULL),
339     m_io(NULL),
340     m_direct(NULL),
341      m_config(config)
342{
343   for (int i = 0; i < 4; i++)
344      EF[i] = 0;
345}
346
347
348//-------------------------------------------------
349//  device_start - start up the device
350//-------------------------------------------------
351
352void cosmac_device::device_start()
353{
354   // get our address spaces
355   m_program = space(AS_PROGRAM);
356   m_direct = &m_program->direct();
357   m_io = space(AS_IO);
358
359   // register our state for the debugger
360   state_add(STATE_GENPC,      "GENPC",      R[P]).noshow();
361   state_add(STATE_GENFLAGS,   "GENFLAGS",      m_flagsio).mask(0x7).callimport().callexport().noshow().formatstr("%3s");
362   
363   state_add(COSMAC_P,      "P",   m_p).mask(0xf);
364   state_add(COSMAC_X,      "X",   m_x).mask(0xf);
365   state_add(COSMAC_D,      "D",   m_d);
366   state_add(COSMAC_B,      "B",   m_b);
367   state_add(COSMAC_T,      "T",   m_t);
368   
369   state_add(COSMAC_I,      "I",   m_i).mask(0xf);
370   state_add(COSMAC_N,      "N",   m_n).mask(0xf);
371   
372   astring tempstr;
373   for (int regnum = 0; regnum < 16; regnum++)
374      state_add(COSMAC_R0 + regnum, tempstr.format("R%x", regnum), m_r[regnum]);
375
376   state_add(COSMAC_DF,   "DF",   m_df).mask(0x1).noshow();
377   state_add(COSMAC_IE,   "IE",   m_ie).mask(0x1).noshow();
378   state_add(COSMAC_Q,      "Q",   m_q).mask(0x1).noshow();
379
380   // resolve callbacks
381   devcb_resolve_read_line(&m_in_wait_func, &m_config.m_in_wait_func, this);
382   devcb_resolve_read_line(&m_in_clear_func, &m_config.m_in_clear_func, this);
383   devcb_resolve_read_line(&m_in_ef_func[0], &m_config.m_in_ef1_func, this);
384   devcb_resolve_read_line(&m_in_ef_func[1], &m_config.m_in_ef2_func, this);
385   devcb_resolve_read_line(&m_in_ef_func[2], &m_config.m_in_ef3_func, this);
386   devcb_resolve_read_line(&m_in_ef_func[3], &m_config.m_in_ef4_func, this);
387   devcb_resolve_write_line(&m_out_q_func, &m_config.m_out_q_func, this);
388    devcb_resolve_read8(&m_in_dma_func, &m_config.m_in_dma_func, this);
389    devcb_resolve_write8(&m_out_dma_func, &m_config.m_out_dma_func, this);
390   m_out_sc_func = m_config.m_out_sc_func;
391   devcb_resolve_write_line(&m_out_tpa_func, &m_config.m_out_tpa_func, this);
392   devcb_resolve_write_line(&m_out_tpb_func, &m_config.m_out_tpb_func, this);
393
394   // register our state for saving
395   state_save_register_device_item(this, 0, m_op);
396   state_save_register_device_item(this, 0, m_flagsio);
397   state_save_register_device_item(this, 0, m_state);
398   state_save_register_device_item(this, 0, m_mode);
399   state_save_register_device_item(this, 0, m_pmode);
400   state_save_register_device_item(this, 0, m_irq);
401   state_save_register_device_item(this, 0, m_dmain);
402   state_save_register_device_item(this, 0, m_dmaout);
403   state_save_register_device_item_array(this, 0, m_ef);
404   state_save_register_device_item(this, 0, m_d);
405   state_save_register_device_item(this, 0, m_b);
406   state_save_register_device_item_array(this, 0, m_r);
407   state_save_register_device_item(this, 0, m_p);
408   state_save_register_device_item(this, 0, m_x);
409   state_save_register_device_item(this, 0, m_n);
410   state_save_register_device_item(this, 0, m_i);
411   state_save_register_device_item(this, 0, m_t);
412   state_save_register_device_item(this, 0, m_df);
413   state_save_register_device_item(this, 0, m_ie);
414   state_save_register_device_item(this, 0, m_q);
415   state_save_register_device_item(this, 0, m_icount);
416
417   // set our instruction counter
418   m_icountptr = &m_icount;
419}
420
421
422//-------------------------------------------------
423//  device_reset - reset the device
424//-------------------------------------------------
425
426void cosmac_device::device_reset()
427{
428}
429   
430
431//-------------------------------------------------
432//  state_import - import state into the device,
433//  after it has been set
434//-------------------------------------------------
435
436void cosmac_device::state_import(const device_state_entry &entry)
437{
438   switch (entry.index())
439   {
440      case STATE_GENFLAGS:
441         SET_FLAGS(m_flagsio);
442         break;
443   }
444}
445
446
447//-------------------------------------------------
448//  state_export - export state from the device,
449//  to a known location where it can be read
450//-------------------------------------------------
451
452void cosmac_device::state_export(const device_state_entry &entry)
453{
454   switch (entry.index())
455   {
456      case STATE_GENFLAGS:
457         m_flagsio = GET_FLAGS();
458         break;
459   }
460}
461
462
463//-------------------------------------------------
464//  state_string_export - export state as a string
465//  for the debugger
466//-------------------------------------------------
467
468void cosmac_device::state_string_export(const device_state_entry &entry, astring &string)
469{
470   switch (entry.index())
471   {
472      case STATE_GENFLAGS:
473         string.printf("%c%c%c",
474                     m_df ? 'D' : '.',
475                     m_ie ? 'I' : '.',
476                     m_q  ? 'Q' : '.');
477         break;
478   }
479}
480
481
482//-------------------------------------------------
483//  disasm_disassemble - call the disassembly
484//  helper function
485//-------------------------------------------------
486
487offs_t cosmac_device::disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options)
488{
489   extern CPU_DISASSEMBLE( cosmac );
490   return CPU_DISASSEMBLE_NAME(cosmac)(NULL, buffer, pc, oprom, opram, 0);
491}
492
493
494
495//**************************************************************************
496//  INLINE HELPERS
497//**************************************************************************
498
499//-------------------------------------------------
500//  read_opcode - read an opcode at the given address
501//-------------------------------------------------
502
503inline UINT8 cosmac_device::read_opcode(offs_t pc)
504{
505   return m_direct->read_decrypted_byte(pc);
506}
507
508
509//-------------------------------------------------
510//  read_byte - read a byte at the given address
511//-------------------------------------------------
512
513inline UINT8 cosmac_device::read_byte(offs_t address)
514{
515   return m_program->read_byte(address);
516}
517
518
519//-------------------------------------------------
520//  read_io_byte - read an I/O byte at the given
521//  address
522//-------------------------------------------------
523
524inline UINT8 cosmac_device::read_io_byte(offs_t address)
525{
526   return m_io->read_byte(address);
527}
528
529
530//-------------------------------------------------
531//  write_byte - write a byte at the given address
532//-------------------------------------------------
533
534inline void cosmac_device::write_byte(offs_t address, UINT8 data)
535{
536   m_program->write_byte(address, data);
537}
538
539
540//-------------------------------------------------
541//  write_io_byte - write an I/O byte at the given
542//  address
543//-------------------------------------------------
544
545inline void cosmac_device::write_io_byte(offs_t address, UINT8 data)
546{
547   m_io->write_byte(address, data);
548}
549
550
551
552//**************************************************************************
553//  CORE EXECUTION
554//**************************************************************************
555
556//-------------------------------------------------
557//  execute_set_input -
558//-------------------------------------------------
559
560void cosmac_device::execute_set_input(int inputnum, int state)
561{
562   switch (inputnum)
563   {
564   case COSMAC_INPUT_LINE_INT:
565      m_irq = state;
566      break;
567
568   case COSMAC_INPUT_LINE_DMAIN:
569      m_dmain = state;
570      break;
571
572   case COSMAC_INPUT_LINE_DMAOUT:
573      m_dmaout = state;
574      break;
575
576   case COSMAC_INPUT_LINE_EF1:
577   case COSMAC_INPUT_LINE_EF2:
578   case COSMAC_INPUT_LINE_EF3:
579   case COSMAC_INPUT_LINE_EF4:
580      EF[inputnum - COSMAC_INPUT_LINE_EF1] = state;
581      break;
582   }
583}
584
585
586//-------------------------------------------------
587//  execute_run -
588//-------------------------------------------------
589
590void cosmac_device::execute_run()
591{
592   do
593   {
594      sample_wait_clear();
595
596      switch (m_mode)
597      {
598      case COSMAC_MODE_LOAD:
599         if (m_pmode == COSMAC_MODE_RESET)
600         {
601            m_pmode = COSMAC_MODE_LOAD;
602
603            // execute initialization cycle
604            m_state = COSMAC_STATE_1_INIT;
605            run();
606
607            // next state is IDLE
608            m_state = COSMAC_STATE_1_EXECUTE;
609         }
610         else
611         {
612            // idle
613            m_op = 0;
614            I = 0;
615            N = 0;
616            run();
617
618            m_icount--;
619         }
620         break;
621
622      case COSMAC_MODE_RESET:
623         m_state = COSMAC_STATE_1_RESET;
624         run();
625         break;
626
627      case COSMAC_MODE_PAUSE:
628         m_icount--;
629         break;
630
631      case COSMAC_MODE_RUN:
632         switch (m_pmode)
633         {
634         case COSMAC_MODE_LOAD:
635            // RUN mode cannot be initiated from LOAD mode
636            logerror("COSMAC '%s' Tried to initiate RUN mode from LOAD mode\n", tag());
637            m_mode = COSMAC_MODE_LOAD;
638            break;
639
640         case COSMAC_MODE_RESET:
641            m_pmode = COSMAC_MODE_RUN;
642            m_state = COSMAC_STATE_1_INIT;
643            run();
644            break;
645
646         case COSMAC_MODE_PAUSE:
647            m_pmode = COSMAC_MODE_RUN;
648            m_state = COSMAC_STATE_0_FETCH;
649            run();
650            break;
651
652         case COSMAC_MODE_RUN:
653            run();
654            break;
655         }
656         break;
657      }
658   }
659   while (m_icount > 0);
660}
661
662
663//-------------------------------------------------
664//  run - run the CPU state machine
665//-------------------------------------------------
666
667inline void cosmac_device::run()
668{
669   output_state_code();
670   
671   switch (m_state)
672   {
673   case COSMAC_STATE_0_FETCH:
674      fetch_instruction();
675      break;
676
677   case COSMAC_STATE_1_RESET:
678      reset();
679      debug();
680      break;
681
682   case COSMAC_STATE_1_INIT:
683      initialize();
684      debug();
685      break;
686
687   case COSMAC_STATE_1_EXECUTE:
688      sample_ef_lines();
689      execute_instruction();
690      debug();
691      break;
692
693   case COSMAC_STATE_2_DMA_IN:
694      dma_input();
695      break;
696
697   case COSMAC_STATE_2_DMA_OUT:
698      dma_output();
699      break;
700
701   case COSMAC_STATE_3_INT:
702      interrupt();
703      debug();
704      break;
705   }
706}
707
708
709//-------------------------------------------------
710//  debug - hook into debugger
711//-------------------------------------------------
712
713inline void cosmac_device::debug()
714{
715   if (device_t::m_machine.debug_flags & DEBUG_FLAG_ENABLED)
716   {
717      debugger_instruction_hook(this, R[P]);
718   }
719}
720
721
722//-------------------------------------------------
723//  sample_wait_clear - sample wait/clear lines
724//-------------------------------------------------
725
726inline void cosmac_device::sample_wait_clear()
727{
728   int wait = devcb_call_read_line(&m_in_wait_func);
729   int clear = devcb_call_read_line(&m_in_clear_func);
730
731   m_pmode = m_mode;
732   m_mode = (cosmac_mode) ((clear << 1) | wait);
733}
734
735
736//-------------------------------------------------
737//  sample_ef_lines - sample EF input lines
738//-------------------------------------------------
739
740inline void cosmac_device::sample_ef_lines()
741{
742   for (int i = 0; i < 4; i++)
743   {
744      if (m_in_ef_func[i].target != NULL)
745      {
746         EF[i] = devcb_call_read_line(&m_in_ef_func[i]);
747      }
748   }
749}
750
751
752//-------------------------------------------------
753//  output_state_code - output state code
754//-------------------------------------------------
755
756inline void cosmac_device::output_state_code()
757{
758   if (m_out_sc_func != NULL)
759   {
760      m_out_sc_func(this, COSMAC_STATE_CODE[m_state]);
761   }
762}
763
764
765//-------------------------------------------------
766//  set_q_flag - set Q flag state and output it
767//-------------------------------------------------
768
769inline void cosmac_device::set_q_flag(bool state)
770{
771   Q = state;
772
773   devcb_call_write_line(&m_out_q_func, Q ? 1 : 0);
774}
775
776
777//-------------------------------------------------
778//  fetch_instruction - fetch instruction from
779//  the program memory
780//-------------------------------------------------
781
782inline void cosmac_device::fetch_instruction()
783{
784   // instruction fetch
785   m_op = read_opcode(R[P]);
786   R[P]++;
787
788   I = m_op >> 4;
789   N = m_op & 0x0f;
790
791   m_icount -= CLOCKS_FETCH;
792
793   m_state = COSMAC_STATE_1_EXECUTE;
794}
795
796
797//-------------------------------------------------
798//  reset - handle reset state
799//-------------------------------------------------
800
801inline void cosmac_device::reset()
802{
803   m_op = 0;
804   I = 0;
805   N = 0;
806   Q = false;
807   IE = true;
808
809   m_icount -= CLOCKS_RESET;
810}
811
812
813//-------------------------------------------------
814//  initialize - handle initialization state
815//-------------------------------------------------
816
817inline void cosmac_device::initialize()
818{
819   X = 0;
820   P = 0;
821   R[0] = 0;
822
823   m_icount -= CLOCKS_INIT;
824
825   if (m_dmain)
826   {
827      m_state = COSMAC_STATE_2_DMA_IN;
828   }
829   else if (m_dmaout)
830   {
831      m_state = COSMAC_STATE_2_DMA_OUT;
832   }
833   else
834   {
835      m_state = COSMAC_STATE_0_FETCH;
836   }
837}
838
839
840//-------------------------------------------------
841//  execute_instruction - execute instruction
842//-------------------------------------------------
843
844inline void cosmac_device::execute_instruction()
845{
846   // parse the instruction
847   (this->*s_opcodetable[m_op])();
848
849   m_icount -= CLOCKS_EXECUTE;
850
851   if (m_dmain)
852   {
853      m_state = COSMAC_STATE_2_DMA_IN;
854   }
855   else if (m_dmaout)
856   {
857      m_state = COSMAC_STATE_2_DMA_OUT;
858   }
859   else if (IE && m_irq)
860   {
861      m_state = COSMAC_STATE_3_INT;
862   }
863   else if ((I > 0) || (N > 0)) // not idling
864   {
865      m_state = COSMAC_STATE_0_FETCH;
866   }
867}
868
869
870//-------------------------------------------------
871//  dma_input - handle DMA input state
872//-------------------------------------------------
873
874inline void cosmac_device::dma_input()
875{
876   RAM_W(R[0], devcb_call_read8(&m_in_dma_func, R[0]));
877
878   R[0]++;
879
880    m_icount -= CLOCKS_DMA;
881
882    if (m_dmain)
883    {
884        m_state = COSMAC_STATE_2_DMA_IN;
885    }
886    else if (m_dmaout)
887    {
888        m_state = COSMAC_STATE_2_DMA_OUT;
889    }
890    else if (IE && m_irq)
891    {
892        m_state = COSMAC_STATE_3_INT;
893    }
894    else if (m_mode == COSMAC_MODE_LOAD)
895    {
896        m_state = COSMAC_STATE_1_EXECUTE;
897    }
898    else
899    {
900        m_state = COSMAC_STATE_0_FETCH;
901    }
902}
903
904
905//-------------------------------------------------
906//  dma_output - handle DMA output state
907//-------------------------------------------------
908
909inline void cosmac_device::dma_output()
910{
911   devcb_call_write8(&m_out_dma_func, R[0], RAM_R(R[0]));
912
913   R[0]++;
914
915    m_icount -= CLOCKS_DMA;
916
917    if (m_dmain)
918    {
919        m_state = COSMAC_STATE_2_DMA_IN;
920    }
921    else if (m_dmaout)
922    {
923        m_state = COSMAC_STATE_2_DMA_OUT;
924    }
925    else if (IE && m_irq)
926    {
927        m_state = COSMAC_STATE_3_INT;
928    }
929    else
930    {
931        m_state = COSMAC_STATE_0_FETCH;
932    }
933}
934
935
936//-------------------------------------------------
937//  interrupt - handle interrupt state
938//-------------------------------------------------
939
940inline void cosmac_device::interrupt()
941{
942   T = (X << 4) | P;
943   X = 2;
944   P = 1;
945   IE = false;
946
947   m_icount -= CLOCKS_INTERRUPT;
948
949   if (m_dmain)
950   {
951      m_state = COSMAC_STATE_2_DMA_IN;
952   }
953   else if (m_dmaout)
954   {
955      m_state = COSMAC_STATE_2_DMA_OUT;
956   }
957   else
958   {
959      m_state = COSMAC_STATE_0_FETCH;
960   }
961}
962
963
964
965//**************************************************************************
966//  OPCODE IMPLEMENTATIONS
967//**************************************************************************
968
969// memory reference opcode handlers
970void cosmac_device::ldn()   { D = RAM_R(R[N]); }
971void cosmac_device::lda()   { D = RAM_R(R[N]++); }
972void cosmac_device::ldx()   { D = RAM_R(R[X]); }
973void cosmac_device::ldxa()   { D = RAM_R(R[X]++); }
974void cosmac_device::ldi()   { D = RAM_R(R[P]++); }
975void cosmac_device::str()   { RAM_W(R[N], D); }
976void cosmac_device::stxd()   { RAM_W(R[X]--, D); }
977
978// register operations opcode handlers
979void cosmac_device::inc()   { R[N]++; }
980void cosmac_device::dec()   { R[N]--; }
981void cosmac_device::irx()   { R[X]++; }
982void cosmac_device::glo()   { D = R[N] & 0xff; }
983void cosmac_device::plo()   { R[N] = (R[N] & 0xff00) | D; }
984void cosmac_device::ghi()   { D = R[N] >> 8; }
985void cosmac_device::phi()   { R[N] = (D << 8) | (R[N] & 0xff); }
986
987// logic operations opcode handlers
988void cosmac_device::_or()   { D = RAM_R(R[X]) | D; }
989void cosmac_device::ori()   { D = RAM_R(R[P]++) | D; }
990void cosmac_device::_xor()   { D = RAM_R(R[X]) ^ D; }
991void cosmac_device::xri()   { D = RAM_R(R[P]++) ^ D; }
992void cosmac_device::_and()   { D = RAM_R(R[X]) & D; }
993void cosmac_device::ani()   { D = RAM_R(R[P]++) & D; }
994void cosmac_device::shr()   { DF = BIT(D, 0); D >>= 1; }
995void cosmac_device::shrc()   { DF = BIT(D, 0); D >>= 1; D |= DF ? 0x80 : 0; }
996void cosmac_device::shl()   { DF = BIT(D, 7); D <<= 1; }
997void cosmac_device::shlc()   { DF = BIT(D, 7); D <<= 1; D |= DF ? 0x01 : 0; }
998
999// arithmetic operations opcode handlers
1000void cosmac_device::add(int left, int right)
1001{
1002   int result = left + right;
1003   D = result & 0xff;
1004   DF = BIT(result, 8) ? true : false;
1005}
1006
1007void cosmac_device::add_with_carry(int left, int right)
1008{
1009   int result = left + right + DF;
1010   D = result & 0xff;
1011   DF = BIT(result, 8) ? true : false;
1012}
1013
1014void cosmac_device::subtract(int left, int right)
1015{
1016   int result = left + (~right & 0xff) + 1;
1017
1018   D = result & 0xff;
1019   DF = BIT(result, 8) ? true : false;
1020}
1021
1022void cosmac_device::subtract_with_borrow(int left, int right)
1023{
1024   int result = left + (~right & 0xff) + DF;
1025
1026   D = result & 0xff;
1027   DF = BIT(result, 8) ? true : false;
1028}
1029
1030void cosmac_device::add()   { add(RAM_R(R[X]), D); }
1031void cosmac_device::adi()   { add(RAM_R(R[P]++), D); }
1032void cosmac_device::adc()   { add_with_carry(RAM_R(R[X]), D); }
1033void cosmac_device::adci()   { add_with_carry(RAM_R(R[P]++), D); }
1034void cosmac_device::sd()   { subtract(RAM_R(R[X]), D); }
1035void cosmac_device::sdi()   { subtract(RAM_R(R[P]++), D); }
1036void cosmac_device::sdb()   { subtract_with_borrow(RAM_R(R[X]), D); }
1037void cosmac_device::sdbi()   { subtract_with_borrow(RAM_R(R[P]++), D); }
1038void cosmac_device::sm()   { subtract(D, RAM_R(R[X])); }
1039void cosmac_device::smi()   { subtract(D, RAM_R(R[P]++)); }
1040void cosmac_device::smb()   { subtract_with_borrow(D, RAM_R(R[X])); }
1041void cosmac_device::smbi()   { subtract_with_borrow(D, RAM_R(R[P]++)); }
1042
1043// short branch instructions opcode handlers
1044void cosmac_device::short_branch(bool taken)
1045{
1046   if (taken)
1047   {
1048      R[P] = (R[P] & 0xff00) | OPCODE_R(R[P]);
1049   }
1050   else
1051   {
1052      R[P] = R[P] + 1;
1053   }
1054}
1055
1056void cosmac_device::br()   { short_branch(true); }
1057void cosmac_device::nbr()   { short_branch(false); }
1058void cosmac_device::bz()   { short_branch(D == 0); }
1059void cosmac_device::bnz()   { short_branch(D != 0); }
1060void cosmac_device::bdf()   { short_branch(DF); }
1061void cosmac_device::bnf()   { short_branch(!DF); }
1062void cosmac_device::bq()   { short_branch(Q); }
1063void cosmac_device::bnq()   { short_branch(!Q); }
1064void cosmac_device::b()      { short_branch(EF[N & 0x03]); }
1065void cosmac_device::bn()   { short_branch(!EF[N & 0x03]); }
1066
1067// long branch instructions opcode handlers
1068void cosmac_device::long_branch(bool taken)
1069{
1070   if (taken)
1071   {
1072      // S1#1
1073      B = OPCODE_R(R[P]++);
1074
1075      // S1#2
1076      R[P] = (B << 8) | OPCODE_R(R[P]);
1077   }
1078   else
1079   {
1080      // S1#1
1081      R[P]++;
1082
1083      // S1#2
1084      R[P]++;
1085   }
1086
1087   m_icount -= CLOCKS_EXECUTE;
1088}
1089
1090void cosmac_device::lbr()   { long_branch(true); }
1091void cosmac_device::nlbr()   { long_skip(true); }
1092void cosmac_device::lbz()   { long_branch(D == 0); }
1093void cosmac_device::lbnz()   { long_branch(D != 0); }
1094void cosmac_device::lbdf()   { long_branch(DF); }
1095void cosmac_device::lbnf()   { long_branch(!DF); }
1096void cosmac_device::lbq()   { long_branch(Q); }
1097void cosmac_device::lbnq()   { long_branch(!Q); }
1098
1099// skip instructions opcode handlers
1100void cosmac_device::long_skip(bool taken)
1101{
1102   if (taken)
1103   {
1104      // S1#1
1105      R[P]++;
1106
1107      // S1#2
1108      R[P]++;
1109   }
1110
1111   m_icount -= CLOCKS_EXECUTE;
1112}
1113
1114void cosmac_device::lsz()   { long_skip(D == 0); }
1115void cosmac_device::lsnz()   { long_skip(D != 0); }
1116void cosmac_device::lsdf()   { long_skip(DF); }
1117void cosmac_device::lsnf()   { long_skip(!DF); }
1118void cosmac_device::lsq()   { long_skip(Q); }
1119void cosmac_device::lsnq()   { long_skip(!Q); }
1120void cosmac_device::lsie()   { long_skip(IE); }
1121   
1122// control instructions opcode handlers
1123void cosmac_device::idl()   { /* idle */ }
1124void cosmac_device::nop()   { m_icount -= CLOCKS_EXECUTE; }
1125void cosmac_device::sep()   { P = N; }
1126void cosmac_device::sex()   { X = N; }
1127void cosmac_device::seq()   { set_q_flag(true); }
1128void cosmac_device::req()   { set_q_flag(false); }
1129void cosmac_device::sav()   { RAM_W(R[X], T); }
1130
1131void cosmac_device::mark()
1132{
1133   UINT8 result = (X << 4) | P;
1134   T = result;
1135   RAM_W(R[2], result);
1136   X = P;
1137   R[2] = R[2] - 1;
1138}
1139
1140void cosmac_device::return_from_interrupt(bool ie)
1141{
1142   UINT8 data = RAM_R(R[X]++);
1143   P = data & 0xf;
1144   X = data >> 4;
1145   IE = ie;
1146}
1147
1148void cosmac_device::ret()   { return_from_interrupt(true); }
1149void cosmac_device::dis()   { return_from_interrupt(false); }
1150
1151// input/output byte transfer opcode handlers
1152void cosmac_device::out()   { IO_W(N, RAM_R(R[X]++)); }
1153
1154/*
1155
1156    A note about INP 0 (0x68) from Tom Pittman's "A Short Course in Programming":
1157
1158    If you look carefully, you will notice that we never studied the opcode "68".
1159    That's because it is not a defined 1802 instruction. It has the form of an INP
1160    instruction, but 0 is not a defined input port, so if you execute it (try it!)
1161    nothing is input. "Nothing" is the answer to a question; it is data, and something
1162    will be put in the accumulator and memory (so now you know what the computer uses
1163    to mean "nothing").
1164
1165    However, since the result of the "68" opcode is unpredictable, it should not be
1166    used in your programs. In fact, "68" is the first byte of a series of additional
1167    instructions for the 1804 and 1805 microprocessors.
1168
1169    http://www.ittybittycomputers.com/IttyBitty/ShortCor.htm
1170
1171*/
1172void cosmac_device::inp()   { D = IO_R(N & 0x07); RAM_W(R[X], D); }
src/emu/cpu/cosmac/cosdasm.c
r0r9381
1/*****************************************************************************
2 *
3 *   disasm.c
4 *   portable cosmac cdp1802 emulator interface
5 *
6 *   Copyright Peter Trauner, all rights reserved.
7 *
8 *   - This source code is released as freeware for non-commercial purposes.
9 *   - You are free to use and redistribute this code in modified or
10 *     unmodified form, provided you list me in the credits.
11 *   - If you modify this source code, you must add a notice to each modified
12 *     source file that it has been changed.  If you're a nice person, you
13 *     will clearly mark each change too.  :)
14 *   - If you wish to use this for commercial purposes, please contact me at
15 *     peter.trauner@jk.uni-linz.ac.at
16 *   - The author of this copywritten work reserves the right to change the
17 *     terms of its usage and license at any time, including retroactively
18 *   - This entire notice must remain in the source code.
19 *
20 *****************************************************************************/
21
22#include "emu.h"
23#include "debugger.h"
24
25#include "cosmac.h"
26
27typedef enum
28{
29   Ill,
30   Imm,
31   Imp,
32   Imp2, // lownibble contains register number
33   Imp3, // bit 0,1,2 1..7 contains n0,n1,n2 level
34   Low, // only low byte of address specified
35   Abs
36} Adr;
37
38static const struct { const char *mnemonic; Adr adr; } table[]={
39   { "IDL",   Imp }, { "LDN",   Imp2},{ 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
40   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
41
42   { "INC",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
43   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
44
45   { "DEC",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
46   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
47
48
49   { "BR",      Low   }, { "BQ",      Low }, { "BZ",      Low   }, { "BDF",      Low },
50   { "B1",      Low   }, { "B2",      Low }, { "B3",      Low   }, { "B4",      Low },
51   { "SKP",   Low   }, { "BNQ",      Low }, { "BNZ",      Low   }, { "BNF",      Low },
52   { "BN1",   Low   }, { "BN2",      Low }, { "BN3",      Low   }, { "BN4",      Low },
53
54   { "LDA",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
55   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
56
57   { "STR",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
58   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
59
60   { "IRX",   Imp } ,{ "OUT",   Imp3},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 },
61   { 0 } ,{ "INP",   Imp3},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 },
62
63   { "RET",   Imp   }, { "DIS",      Imp }, { "LDXA",   Imp   }, { "STXD",   Imp },
64   { "ADC",   Imp   }, { "SDB",      Imp }, { "SHRC",   Imp   }, { "SMB",      Imp },
65   { "SAV",   Imp   }, { "MARK",   Imp }, { "REQ",      Imp   }, { "SEQ",      Imp },
66   { "ADCI",   Imm   }, { "SDBI",   Imm }, { "SHLC",   Imp   }, { "SMBI",   Imm },
67
68
69   { "GLO",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
70   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
71
72   { "GHI",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
73   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
74
75   { "PLO",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
76   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
77
78   { "PHI",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
79   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
80
81   { "LBR",   Abs   }, { "LBQ",      Abs }, { "LBZ",      Abs   }, { "LBDF",   Abs },
82   { "NOP",   Imp   }, { "LSNQ",   Imp }, { "LSNZ",   Imp   }, { "LSNF",   Imp },
83   { "LSKP",   Imp   }, { "LBNQ",   Abs }, { "LBNZ",   Abs   }, { "LBNF",   Abs },
84   { "LSIE",   Imp   }, { "LSQ",      Imp }, { "LSZ",      Imp   }, { "LSDF",   Imp },
85
86   { "SEP",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
87   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
88
89   { "SEX",   Imp2},{ 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
90   { 0 }, { 0 }, { 0 }, { 0 },  { 0 }, { 0 }, { 0 }, { 0 },
91
92   { "LDX",   Imp   }, { "OR",      Imp }, { "AND",      Imp   }, { "XOR",      Imp },
93   { "ADD",   Imp   }, { "SD",      Imp }, { "SHR",      Imp   }, { "SM",      Imp },
94   { "LDI",   Imm   }, { "ORI",      Imm }, { "ANI",      Imm   }, { "XRI",      Imm },
95   { "ADI",   Imm   }, { "SDI",      Imm }, { "SHL",      Imp   }, { "SMI",      Imm },
96
97};
98
99CPU_DISASSEMBLE( cosmac )
100{
101   UINT32 flags = 0;
102   int oldpc = pc;
103   int oper;
104   UINT16 absolut;
105   oldpc&=0xffff;
106   pc=oldpc;
107   oper=oprom[pc++ - oldpc];
108
109   switch(oper&0xf0) {
110   case 0:
111      if (oper==0) {
112         sprintf(buffer,"%-5s",table[oper].mnemonic);
113      } else {
114         sprintf(buffer,"%-5sR%.1x",table[(oper&0xf0)|1].mnemonic, oper&0x0f);
115      }
116      break;
117   case 0xd0:
118      flags = DASMFLAG_STEP_OVER;
119      /* fall through */
120   case 0x10:
121   case 0x20:
122   case 0x40:
123   case 0x50:
124   case 0x80:
125   case 0x90:
126   case 0xa0:
127   case 0xb0:
128   case 0xe0:
129      sprintf(buffer,"%-5sR%.1x",table[oper&0xf0].mnemonic, oper&0x0f);
130      break;
131   default:
132      switch(oper&0xf8) {
133      case 0x60:
134         if (oper==0x60) {
135            sprintf(buffer,"%-5s",table[oper].mnemonic);
136         } else {
137            sprintf(buffer,"%-5s%d",table[(oper&0xf8)|1].mnemonic, oper&0x7);
138         }
139         break;
140      case 0x68:
141         sprintf(buffer,"%-5s%d",table[(oper&0xf8)|1].mnemonic, oper&0x7);
142         break;
143      default:
144         switch (table[oper].adr) {
145         case Imp:
146            sprintf(buffer,"%-5s",table[oper].mnemonic);
147            if (oper == 0x70 || oper == 0x71)
148               flags = DASMFLAG_STEP_OUT;
149            break;
150         case Imm:
151            sprintf(buffer,"%-5s#%.2x",table[oper].mnemonic,oprom[pc++ - oldpc]);
152            break;
153         case Low:
154            absolut=oprom[pc++ - oldpc];
155            absolut|=pc&0xff00;
156            sprintf(buffer,"%-5s%.4x",table[oper].mnemonic,absolut);
157            break;
158         case Abs:
159            absolut=oprom[pc++ - oldpc]<<8;
160            absolut|=oprom[pc++ - oldpc];
161            sprintf(buffer,"%-5s%.4x",table[oper].mnemonic,absolut);
162            break;
163         default:
164            sprintf(buffer,"%-5s%.2x","ill",oper);
165            break;
166         }
167         break;
168      }
169      break;
170   }
171
172   return (pc-oldpc) | flags | DASMFLAG_SUPPORTED;
173}
src/emu/cpu/cosmac/cosmac.h
r0r9381
1/**********************************************************************
2
3    RCA "COSMAC" CPU emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                            _____   _____
10                 CLOCK   1 |*    \_/     | 40  Vdd
11                 _WAIT   2 |             | 39  _XTAL
12                _CLEAR   3 |             | 38  _DMA IN
13                     Q   4 |             | 37  _DMA OUT
14                   SC1   5 |             | 36  _INTERRUPT
15                   SC0   6 |             | 35  _MWR
16                  _MRD   7 |             | 34  TPA
17                 BUS 7   8 |             | 33  TPB
18                 BUS 6   9 |   CDP1802   | 32  MA7
19                 BUS 5  10 |   CDP1803   | 31  MA6
20                 BUS 4  11 |   CDP1804   | 30  MA5
21                 BUS 3  12 |   CDP1805   | 29  MA4
22                 BUS 2  13 |   CDP1806   | 28  MA3
23                 BUS 1  14 |             | 27  MA2
24                 BUS 0  15 |             | 26  MA1
25                     *  16 |             | 25  MA0
26                    N2  17 |             | 24  _EF1
27                    N1  18 |             | 23  _EF2
28                    N0  19 |             | 22  _EF3
29                   Vss  20 |_____________| 21  _EF4
30
31
32   Type            Internal ROM    Internal RAM    Timer   Pin 16 (*)
33    ------------------------------------------------------------------
34    CDP1802         none            none            no         Vcc
35    CDP1803         ?               ?               ?         ?
36    CDP1804         2 KB            64 bytes        yes         ?
37    CDP1805         none            64 bytes        yes         _ME
38    CDP1806         none            none            yes         Vdd
39   
40**********************************************************************/
41
42#pragma once
43
44#ifndef __COSMAC_H__
45#define __COSMAC_H__
46
47
48//**************************************************************************
49//  ENUMERATIONS
50//**************************************************************************
51
52// registers
53enum
54{
55   COSMAC_P,
56   COSMAC_X,
57   COSMAC_D,
58   COSMAC_B,
59   COSMAC_T,
60   COSMAC_R0,
61   COSMAC_R1,
62   COSMAC_R2,
63   COSMAC_R3,
64   COSMAC_R4,
65   COSMAC_R5,
66   COSMAC_R6,
67   COSMAC_R7,
68   COSMAC_R8,
69   COSMAC_R9,
70   COSMAC_Ra,
71   COSMAC_Rb,
72   COSMAC_Rc,
73   COSMAC_Rd,
74   COSMAC_Re,
75   COSMAC_Rf,
76   COSMAC_DF,
77   COSMAC_IE,
78   COSMAC_Q,
79   COSMAC_N,
80   COSMAC_I,
81   COSMAC_SC
82};
83
84
85// input lines
86enum
87{
88   COSMAC_INPUT_LINE_INT = 0,
89   COSMAC_INPUT_LINE_DMAIN,
90   COSMAC_INPUT_LINE_DMAOUT,
91   COSMAC_INPUT_LINE_EF1,
92   COSMAC_INPUT_LINE_EF2,
93   COSMAC_INPUT_LINE_EF3,
94   COSMAC_INPUT_LINE_EF4,
95};
96
97
98// state codes
99enum cosmac_state_code
100{
101   COSMAC_STATE_CODE_S0_FETCH = 0,
102   COSMAC_STATE_CODE_S1_EXECUTE,
103   COSMAC_STATE_CODE_S2_DMA,
104   COSMAC_STATE_CODE_S3_INTERRUPT
105};
106
107
108// device type definition
109extern const device_type COSMAC;
110
111
112
113//**************************************************************************
114//  TYPE DEFINITIONS
115//**************************************************************************
116
117typedef void (*cosmac_out_sc_func)(running_device *device, cosmac_state_code sc);
118#define COSMAC_SC_WRITE(name) void name(running_device *device, cosmac_state_code sc)
119
120
121// ======================> cosmac_interface
122
123struct cosmac_interface
124{
125   devcb_read_line      m_in_wait_func;
126   devcb_read_line      m_in_clear_func;
127   devcb_read_line      m_in_ef1_func;
128   devcb_read_line      m_in_ef2_func;
129   devcb_read_line      m_in_ef3_func;
130   devcb_read_line      m_in_ef4_func;
131   devcb_write_line   m_out_q_func;
132   devcb_read8         m_in_dma_func;
133   devcb_write8      m_out_dma_func;
134   cosmac_out_sc_func   m_out_sc_func;
135   devcb_write_line   m_out_tpa_func;
136   devcb_write_line   m_out_tpb_func;
137};
138
139#define COSMAC_INTERFACE(name) \
140   const cosmac_interface (name) =
141
142
143// ======================> cosmac_device_config
144
145class cosmac_device_config :   public cpu_device_config,
146                                public cosmac_interface
147{
148   friend class cosmac_device;
149
150   // construction/destruction
151   cosmac_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
152
153public:
154   // allocators
155   static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
156   virtual device_t *alloc_device(running_machine &machine) const;
157
158protected:
159   // device_config overrides
160   virtual void device_config_complete();
161
162   // device_config_execute_interface overrides
163   virtual UINT32 execute_min_cycles() const;
164   virtual UINT32 execute_max_cycles() const;
165   virtual UINT32 execute_input_lines() const;
166
167   // device_config_memory_interface overrides
168   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
169
170   // device_config_disasm_interface overrides
171   virtual UINT32 disasm_min_opcode_bytes() const;
172   virtual UINT32 disasm_max_opcode_bytes() const;
173
174   // inline data
175   const address_space_config      m_program_config;
176   const address_space_config      m_io_config;
177};
178
179
180
181// ======================> cosmac_device
182
183class cosmac_device : public cpu_device
184{
185   friend class cosmac_device_config;
186
187   // construction/destruction
188   cosmac_device(running_machine &_machine, const cosmac_device_config &config);
189
190public:
191   // public interfaces
192
193protected:
194   // device-level overrides
195   virtual void device_start();
196   virtual void device_reset();
197
198   // device_execute_interface overrides
199   virtual void execute_run();
200   virtual void execute_set_input(int inputnum, int state);
201
202   // device_state_interface overrides
203   virtual void state_import(const device_state_entry &entry);
204   virtual void state_export(const device_state_entry &entry);
205   virtual void state_string_export(const device_state_entry &entry, astring &string);
206
207   // device_disasm_interface overrides
208   virtual offs_t disasm_disassemble(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram, UINT32 options);
209
210   // helpers
211   inline UINT8 read_opcode(offs_t pc);
212   inline UINT8 read_byte(offs_t address);
213   inline UINT8 read_io_byte(offs_t address);
214   inline void write_byte(offs_t address, UINT8 data);
215   inline void write_io_byte(offs_t address, UINT8 data);
216
217   // execution logic
218   inline void run();
219   inline void debug();
220   inline void reset();
221   inline void initialize();
222   inline void fetch_instruction();
223   inline void fetch_instruction_debug();
224   inline void execute_instruction();
225   inline void dma_input();
226   inline void dma_output();
227   inline void interrupt();
228   inline void sample_wait_clear();
229   inline void sample_ef_lines();
230   inline void output_state_code();
231   inline void set_q_flag(bool state);
232
233   // arithmetic handlers
234   void add(int left, int right);
235   void add_with_carry(int left, int right);
236   void subtract(int left, int right);
237   void subtract_with_borrow(int left, int right);
238
239   // condition handlers
240   void short_branch(bool taken);
241   void long_branch(bool taken);
242   void long_skip(bool taken);
243
244   // control handlers
245   void return_from_interrupt(bool ie);
246
247   // memory reference opcode handlers
248   void ldn();
249   void lda();
250   void ldx();
251   void ldxa();
252   void ldi();
253   void str();
254   void stxd();
255
256   // register operations opcode handlers
257   void inc();
258   void dec();
259   void irx();
260   void glo();
261   void plo();
262   void ghi();
263   void phi();
264
265   // logic operations opcode handlers
266   void _or();
267   void ori();
268   void _xor();
269   void xri();
270   void _and();
271   void ani();
272   void shr();
273   void shrc();
274   void shl();
275   void shlc();
276
277   // arithmetic operations opcode handlers
278   void add();
279   void adi();
280   void adc();
281   void adci();
282   void sd();
283   void sdi();
284   void sdb();
285   void sdbi();
286   void sm();
287   void smi();
288   void smb();
289   void smbi();
290
291   // short branch instructions opcode handlers
292   void br();
293   void nbr();
294   void bz();
295   void bnz();
296   void bdf();
297   void bnf();
298   void bq();
299   void bnq();
300   void b();
301   void bn();
302
303   // long branch instructions opcode handlers
304   void lbr();
305   void nlbr();
306   void lbz();
307   void lbnz();
308   void lbdf();
309   void lbnf();
310   void lbq();
311   void lbnq();
312
313   // skip instructions opcode handlers
314   void lsz();
315   void lsnz();
316   void lsdf();
317   void lsnf();
318   void lsq();
319   void lsnq();
320   void lsie();
321   
322   // control instructions opcode handlers
323   void idl();
324   void nop();
325   void sep();
326   void sex();
327   void seq();
328   void req();
329   void sav();
330   void mark();
331   void ret();
332   void dis();
333
334   // input/output byte transfer opcode handlers
335   void out();
336   void inp();
337
338   // device callbacks
339   devcb_resolved_read_line   m_in_wait_func;
340   devcb_resolved_read_line   m_in_clear_func;
341   devcb_resolved_read_line   m_in_ef_func[4];
342   devcb_resolved_write_line   m_out_q_func;
343   devcb_resolved_read8      m_in_dma_func;
344   devcb_resolved_write8      m_out_dma_func;
345   cosmac_out_sc_func         m_out_sc_func;
346   devcb_resolved_write_line   m_out_tpa_func;
347   devcb_resolved_write_line   m_out_tpb_func;
348     
349   // control modes
350   enum _cosmac_mode
351   {
352      COSMAC_MODE_LOAD = 0,
353      COSMAC_MODE_RESET,
354      COSMAC_MODE_PAUSE,
355      COSMAC_MODE_RUN
356   };
357   typedef enum _cosmac_mode cosmac_mode;
358
359   // execution states
360   enum _cosmac_state
361   {
362      COSMAC_STATE_0_FETCH = 0,
363      COSMAC_STATE_1_RESET,
364      COSMAC_STATE_1_INIT,
365      COSMAC_STATE_1_EXECUTE,
366      COSMAC_STATE_2_DMA_IN,
367      COSMAC_STATE_2_DMA_OUT,
368      COSMAC_STATE_3_INT
369   };
370   typedef enum _cosmac_state cosmac_state;
371
372   // internal state
373   UINT8            m_op;            // current opcode
374   UINT8            m_flagsio;         // flags storage for state saving
375   cosmac_state      m_state;         // state
376   cosmac_mode         m_mode;            // control mode
377   cosmac_mode         m_pmode;         // previous control mode
378   int               m_irq;            // interrupt request
379   int               m_dmain;         // DMA input request
380   int               m_dmaout;         // DMA output request
381   int               m_ef[4];         // external flags
382
383   // registers
384   UINT8            m_d;            // data register (accumulator)
385   UINT8            m_b;            // auxiliary holding register
386   UINT16            m_r[16];         // scratchpad registers
387   UINT8            m_p;            // designates which register is Program Counter
388   UINT8            m_x;            // designates which register is Data Pointer
389   UINT8            m_n;            // low-order instruction digit
390   UINT8            m_i;            // high-order instruction digit
391   UINT8            m_t;            // temporary register
392
393   // flags
394   bool            m_df;            // data flag (ALU carry)
395   bool            m_ie;            // interrupt enable
396   bool            m_q;            // output flip-flop
397
398   // internal stuff
399   int               m_icount;
400   address_space *      m_program;
401   address_space *      m_io;
402   direct_read_data *   m_direct;
403
404   // opcode/condition tables
405   typedef void (cosmac_device::*ophandler)();
406
407   static const ophandler s_opcodetable[256];
408
409   const cosmac_device_config &m_config;
410};
411
412
413
414#endif /* __COSMAC_H__ */
src/mess/includes/vip.h
r9380r9381
11#ifndef __VIP__
22#define __VIP__
33
4#include "cpu/cosmac/cosmac.h"
5#include "audio/vp550.h"
6#include "audio/vp595.h"
7
48#define SCREEN_TAG      "screen"
59#define CDP1802_TAG      "u1"
610#define CDP1861_TAG      "u2"
r9380r9381
1014
1115#define VP590_COLOR_RAM_SIZE   0x100
1216
13#define VIP_BANK_RAM         0
14#define VIP_BANK_ROM         1
17enum
18{
19   VIDEO_CDP1861 = 0,
20   VIDEO_CDP1862
21};
1522
16#define VIP_VIDEO_CDP1861      0
17#define VIP_VIDEO_CDP1862      1
23enum
24{
25   SOUND_SPEAKER = 0,
26   SOUND_VP595,
27   SOUND_VP550,
28   SOUND_VP551
29};
1830
19#define VIP_SOUND_SPEAKER      0
20#define VIP_SOUND_VP595         1
21#define VIP_SOUND_VP550         2
22#define VIP_SOUND_VP551         3
31enum
32{
33   KEYBOARD_KEYPAD = 0,
34   KEYBOARD_VP580,
35   KEYBOARD_DUAL_VP580,
36   KEYBOARD_VP601,
37   KEYBOARD_VP611
38};
2339
24#define VIP_KEYBOARD_KEYPAD      0
25#define VIP_KEYBOARD_VP580      1
26#define VIP_KEYBOARD_DUAL_VP580   2
27#define VIP_KEYBOARD_VP601      3
28#define VIP_KEYBOARD_VP611      4
40enum
41{
42   LED_POWER = 0,
43   LED_Q,
44   LED_TAPE
45};
2946
30#define VIP_LED_POWER         0
31#define VIP_LED_Q            1
32#define VIP_LED_TAPE         2
33
3447class vip_state : public driver_device
3548{
3649public:
3750   vip_state(running_machine &machine, const driver_device_config_base &config)
38      : driver_device(machine, config) { }
51      : driver_device(machine, config),
52        m_maincpu(*this, CDP1802_TAG),
53        m_vdc(*this, CDP1861_TAG),
54        m_cgc(*this, CDP1862_TAG),
55        m_cassette(*this, CASSETTE_TAG),
56        m_beeper(*this, DISCRETE_TAG),
57        m_vp595(*this, VP595_TAG),
58        m_vp550(*this, VP550_TAG),
59        m_vp551(*this, VP551_TAG),
60        m_ram(*this, "messram")
61   { }
3962
40   /* cpu state */
41   int reset;                  /* reset activated */
63   required_device<cosmac_device> m_maincpu;
64   required_device<running_device> m_vdc;
65   required_device<running_device> m_cgc;
66   required_device<running_device> m_cassette;
67   required_device<running_device> m_beeper;
68   required_device<running_device> m_vp595;
69   required_device<running_device> m_vp550;
70   required_device<running_device> m_vp551;
71   required_device<running_device> m_ram;
4272
73   virtual void machine_start();
74   virtual void machine_reset();
75
76   virtual bool video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
77
78   DECLARE_READ8_MEMBER(dispon_r);
79   DECLARE_WRITE8_MEMBER(dispoff_w);
80   DECLARE_WRITE8_MEMBER(keylatch_w);
81   DECLARE_WRITE8_MEMBER(bankswitch_w);
82   DECLARE_WRITE8_MEMBER(vip_colorram_w);
83
4384   /* video state */
44   int cdp1861_efx;            /* EFx */
45   int a12;                  /* latched address line 12 */
46   UINT8 *colorram;            /* CDP1862 color RAM */
47   UINT8 color;               /* color RAM data */
85   int m_a12;                  /* latched address line 12 */
86   UINT8 *m_colorram;            /* CDP1862 color RAM */
87   UINT8 m_color;               /* color RAM data */
4888
4989   /* keyboard state */
50   int keylatch;               /* key latch */
51
52   /* devices */
53   running_device *cdp1861;
54   running_device *cdp1862;
55   running_device *cdp1863;
56   running_device *cassette;
57   running_device *beeper;
58   running_device *vp595;
59   running_device *vp550;
60   running_device *vp551;
90   int m_keylatch;               /* key latch */
6191};
6292
6393#endif
src/mess/mess.mak
r9380r9381
131131CPUS += SCMP
132132#CPUS += MN10200
133133CPUS += UNSP
134CPUS += COSMAC
134135
135136#-------------------------------------------------
136137# specify available sound cores; some of these are
src/mess/drivers/vip.c
r9380r9381
217217
218218*/
219219
220#define ADDRESS_MAP_MODERN
221
220222#include "emu.h"
221223#include "includes/vip.h"
222#include "cpu/cdp1802/cdp1802.h"
224#include "cpu/cosmac/cosmac.h"
223225#include "devices/cassette.h"
224226#include "devices/snapquik.h"
225227#include "audio/vp550.h"
r9380r9381
232234#include "devices/messram.h"
233235
234236static QUICKLOAD_LOAD( vip );
235static MACHINE_RESET( vip );
236237
237238/* Sound */
238239
r9380r9381
251252
252253/* Read/Write Handlers */
253254
254static WRITE8_HANDLER( keylatch_w )
255WRITE8_MEMBER( vip_state::keylatch_w )
255256{
256   vip_state *state = space->machine->driver_data<vip_state>();
257
258   state->keylatch = data & 0x0f;
257   m_keylatch = data & 0x0f;
259258}
260259
261static WRITE8_HANDLER( bankswitch_w )
260WRITE8_MEMBER( vip_state::bankswitch_w )
262261{
263262   /* enable RAM */
263   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
264   UINT8 *ram = messram_get_ptr(m_ram);
264265
265   address_space *program = cputag_get_address_space(space->machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
266
267   memory_set_bank(space->machine, "bank1", VIP_BANK_RAM);
268
269   switch (messram_get_size(space->machine->device("messram")))
266   switch (messram_get_size(m_ram))
270267   {
271268   case 1 * 1024:
272      memory_install_readwrite_bank(program, 0x0000, 0x03ff, 0, 0x7c00, "bank1");
269      memory_install_ram(program, 0x0000, 0x03ff, 0, 0x7c00, ram);
273270      break;
274271
275272   case 2 * 1024:
276      memory_install_readwrite_bank(program, 0x0000, 0x07ff, 0, 0x7800, "bank1");
273      memory_install_ram(program, 0x0000, 0x07ff, 0, 0x7800, ram);
277274      break;
278275
279276   case 4 * 1024:
280      memory_install_readwrite_bank(program, 0x0000, 0x0fff, 0, 0x7000, "bank1");
277      memory_install_ram(program, 0x0000, 0x0fff, 0, 0x7000, ram);
281278      break;
282279
283280   case 32 * 1024:
284      memory_install_readwrite_bank(program, 0x0000, 0x7fff, 0, 0, "bank1");
281      memory_install_ram(program, 0x0000, 0x7fff, 0, 0, ram);
285282      break;
286283   }
287284}
288285
289static READ8_DEVICE_HANDLER( vip_cdp1861_dispon_r )
286READ8_MEMBER( vip_state::dispon_r )
290287{
291   cdp1861_dispon_w(device, 1);
292   cdp1861_dispon_w(device, 0);
288   cdp1861_dispon_w(m_vdc, 1);
289   cdp1861_dispon_w(m_vdc, 0);
293290
294291   return 0xff;
295292}
296293
297static WRITE8_DEVICE_HANDLER( vip_cdp1861_dispoff_w )
294WRITE8_MEMBER( vip_state::dispoff_w )
298295{
299   cdp1861_dispoff_w(device, 1);
300   cdp1861_dispoff_w(device, 0);
296   cdp1861_dispoff_w(m_vdc, 1);
297   cdp1861_dispoff_w(m_vdc, 0);
301298}
302299
303300/* Memory Maps */
304301
305static ADDRESS_MAP_START( vip_map, ADDRESS_SPACE_PROGRAM, 8 )
302static ADDRESS_MAP_START( vip_map, ADDRESS_SPACE_PROGRAM, 8, vip_state )
306303   ADDRESS_MAP_UNMAP_HIGH
307    AM_RANGE(0x0000, 0x7fff) AM_RAMBANK("bank1")
308   AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank2")
304   AM_RANGE(0x0000, 0x01ff) AM_MIRROR(0xfe00) AM_ROM AM_REGION(CDP1802_TAG, 0)
309305ADDRESS_MAP_END
310306
311static ADDRESS_MAP_START( vip_io_map, ADDRESS_SPACE_IO, 8 )
312   AM_RANGE(0x01, 0x01) AM_DEVREADWRITE(CDP1861_TAG, vip_cdp1861_dispon_r, vip_cdp1861_dispoff_w)
307static ADDRESS_MAP_START( vip_io_map, ADDRESS_SPACE_IO, 8, vip_state )
308   ADDRESS_MAP_UNMAP_HIGH
309   AM_RANGE(0x01, 0x01) AM_READWRITE(dispon_r, dispoff_w)
313310   AM_RANGE(0x02, 0x02) AM_WRITE(keylatch_w)
314//  AM_RANGE(0x03, 0x03) AM_DEVWRITE(CDP1863_TAG, cdp1863_str_w)
311//  AM_RANGE(0x03, 0x03) AM_DEVWRITE_LEGACY(CDP1863_TAG, cdp1863_str_w)
315312   AM_RANGE(0x04, 0x04) AM_WRITE(bankswitch_w)
316//  AM_RANGE(0x05, 0x05) AM_DEVWRITE(CDP1862_TAG, cdp1862_bkg_w)
313//  AM_RANGE(0x05, 0x05) AM_DEVWRITE_LEGACY(CDP1862_TAG, cdp1862_bkg_w)
317314ADDRESS_MAP_END
318315
319316/* Input Ports */
320317
318static INPUT_CHANGED( reset_w )
319{
320   vip_state *state = field->port->machine->driver_data<vip_state>();
321
322   if (oldval && !newval)
323   {
324      state->machine_reset();
325   }
326}
327
321328static INPUT_PORTS_START( vip )
322329   PORT_START("KEYPAD")
323330   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("0 MW") PORT_CODE(KEYCODE_0) PORT_CHAR('0')
r9380r9381
356363   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("VP-580 F") PORT_CODE(KEYCODE_L)
357364
358365   PORT_START("RUN")
359   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Run/Reset") PORT_CODE(KEYCODE_R) PORT_TOGGLE
366   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYPAD ) PORT_NAME("Run/Reset") PORT_CODE(KEYCODE_R) PORT_TOGGLE PORT_CHANGED(reset_w, 0)
360367
361368   PORT_START("KEYBOARD")
362   PORT_CONFNAME( 0x07, 0x00, "Keyboard")
363   PORT_CONFSETTING( 0x00, "Standard" )
364   PORT_CONFSETTING( 0x01, "VP-580 Expansion Keyboard" )
365   PORT_CONFSETTING( 0x02, "2x VP-580 Expansion Keyboard" )
366   PORT_CONFSETTING( 0x03, "VP-601 ASCII Keyboard" )
367   PORT_CONFSETTING( 0x04, "VP-611 ASCII/Numeric Keyboard" )
369   PORT_CONFNAME( 0x07, KEYBOARD_KEYPAD, "Keyboard")
370   PORT_CONFSETTING( KEYBOARD_KEYPAD, "Standard" )
371   PORT_CONFSETTING( KEYBOARD_VP580, "VP-580 Expansion Keyboard" )
372   PORT_CONFSETTING( KEYBOARD_DUAL_VP580, "2x VP-580 Expansion Keyboard" )
373   PORT_CONFSETTING( KEYBOARD_VP601, "VP-601 ASCII Keyboard" )
374   PORT_CONFSETTING( KEYBOARD_VP611, "VP-611 ASCII/Numeric Keyboard" )
368375
369376   PORT_START("VIDEO")
370   PORT_CONFNAME( 0x01, 0x00, "Video")
371   PORT_CONFSETTING( 0x00, "Standard" )
372   PORT_CONFSETTING( 0x01, "VP-590 Color Board" )
377   PORT_CONFNAME( 0x01, VIDEO_CDP1861, "Video")
378   PORT_CONFSETTING( VIDEO_CDP1861, "Standard" )
379   PORT_CONFSETTING( VIDEO_CDP1862, "VP-590 Color Board" )
373380
374381   PORT_START("SOUND")
375   PORT_CONFNAME( 0x03, 0x00, "Sound")
376   PORT_CONFSETTING( 0x00, "Standard" )
377   PORT_CONFSETTING( 0x01, "VP-595 Simple Sound Board" )
378   PORT_CONFSETTING( 0x02, "VP-550 Super Sound Board" )
379   PORT_CONFSETTING( 0x03, "VP-551 Super Sound Board" )
382   PORT_CONFNAME( 0x03, SOUND_SPEAKER, "Sound")
383   PORT_CONFSETTING( SOUND_SPEAKER, "Standard" )
384   PORT_CONFSETTING( SOUND_VP595, "VP-595 Simple Sound Board" )
385   PORT_CONFSETTING( SOUND_VP550, "VP-550 Super Sound Board" )
386   PORT_CONFSETTING( SOUND_VP551, "VP-551 Super Sound Board" )
380387INPUT_PORTS_END
381388
382389/* Video */
383390
384static WRITE_LINE_DEVICE_HANDLER( vip_efx_w )
385{
386   vip_state *driver_state = device->machine->driver_data<vip_state>();
387
388   driver_state->cdp1861_efx = state;
389}
390
391391static CDP1861_INTERFACE( vip_cdp1861_intf )
392392{
393393   CDP1802_TAG,
394394   SCREEN_TAG,
395   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_INT),
396   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT),
397   DEVCB_LINE(vip_efx_w)
395   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_INT),
396   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_DMAOUT),
397   DEVCB_CPU_INPUT_LINE(CDP1802_TAG, COSMAC_INPUT_LINE_EF1)
398398};
399399
400400static READ_LINE_DEVICE_HANDLER( rd_r )
401401{
402402   vip_state *state = device->machine->driver_data<vip_state>();
403403
404   return BIT(state->color, 1);
404   return BIT(state->m_color, 1);
405405}
406406
407407static READ_LINE_DEVICE_HANDLER( bd_r )
408408{
409409   vip_state *state = device->machine->driver_data<vip_state>();
410410
411   return BIT(state->color, 2);
411   return BIT(state->m_color, 2);
412412}
413413
414414static READ_LINE_DEVICE_HANDLER( gd_r )
415415{
416416   vip_state *state = device->machine->driver_data<vip_state>();
417417
418   return BIT(state->color, 3);
418   return BIT(state->m_color, 3);
419419}
420420
421421static CDP1862_INTERFACE( vip_cdp1862_intf )
r9380r9381
434434   RES_K(3.3)      /* R10 */
435435};
436436
437static WRITE8_HANDLER( vip_colorram_w )
437WRITE8_MEMBER( vip_state::vip_colorram_w )
438438{
439   vip_state *state = space->machine->driver_data<vip_state>();
440439   UINT8 mask = 0xff;
441440
442   state->a12 = (offset & 0x1000) ? 1 : 0;
441   m_a12 = (offset & 0x1000) ? 1 : 0;
443442
444   if (!state->a12)
443   if (!m_a12)
445444   {
446      /* mask out A4 and A3 */
445      // mask out A4 and A3
447446      mask = 0xe7;
448447   }
449448
450   /* write to CDP1822 */
451   state->colorram[offset & mask] = data << 1;
449   // write to CDP1822
450   m_colorram[offset & mask] = data << 1;
452451
453   cdp1862_con_w(state->cdp1862, 0);
452   cdp1862_con_w(m_cgc, 0);
454453}
455454
456static VIDEO_UPDATE( vip )
455bool vip_state::video_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
457456{
458   vip_state *state = screen->machine->driver_data<vip_state>();
459
460   switch (input_port_read(screen->machine, "VIDEO"))
457   switch (input_port_read(screen.machine, "VIDEO"))
461458   {
462   case VIP_VIDEO_CDP1861:
463      cdp1861_update(state->cdp1861, bitmap, cliprect);
459   case VIDEO_CDP1861:
460      cdp1861_update(m_vdc, &bitmap, &cliprect);
464461      break;
465462
466   case VIP_VIDEO_CDP1862:
467      cdp1862_update(state->cdp1862, bitmap, cliprect);
463   case VIDEO_CDP1862:
464      cdp1862_update(m_cgc, &bitmap, &cliprect);
468465      break;
469466   }
470467
r9380r9381
473470
474471/* CDP1802 Configuration */
475472
476static CDP1802_MODE_READ( vip_mode_r )
473static READ_LINE_DEVICE_HANDLER( clear_r )
477474{
478   vip_state *state = device->machine->driver_data<vip_state>();
475   return BIT(input_port_read(device->machine, "RUN"), 0);
476}
479477
480   if (input_port_read(device->machine, "RUN") & 0x01)
481   {
482      if (state->reset)
483      {
484         state->reset = 0;
485      }
478static READ_LINE_DEVICE_HANDLER( ef2_r )
479{
480   set_led_status(device->machine, LED_TAPE, (cassette_input(device) > 0));
486481
487      return CDP1802_MODE_RUN;
488   }
489   else
490   {
491      if (!state->reset)
492      {
493         running_machine *machine = device->machine;
494         MACHINE_RESET_CALL(vip);
482   return cassette_input(device) < 0;
483}
495484
496         state->reset = 1;
497      }
485static READ_LINE_DEVICE_HANDLER( ef3_r )
486{
487   vip_state *state = device->machine->driver_data<vip_state>();
498488
499      return CDP1802_MODE_RESET;
500   }
489   return BIT(input_port_read(device->machine, "KEYPAD"), state->m_keylatch);
501490}
502491
503static CDP1802_EF_READ( vip_ef_r )
492static READ_LINE_DEVICE_HANDLER( ef4_r )
504493{
505494   vip_state *state = device->machine->driver_data<vip_state>();
506495
507   UINT8 flags = 0x0f;
508
509   /*
510        EF1     CDP1861
511        EF2     tape in
512        EF3     keyboard
513        EF4     extended keyboard
514    */
515
516   /* CDP1861 */
517   if (state->cdp1861_efx) flags -= EF1;
518
519   /* tape input */
520   if (cassette_input(state->cassette) < 0) flags -= EF2;
521   set_led_status(device->machine, VIP_LED_TAPE, (cassette_input(state->cassette) > 0));
522
523   /* keyboard */
524   if (input_port_read(device->machine, "KEYPAD") & (1 << state->keylatch)) flags -= EF3;
525
526   /* extended keyboard */
527496   switch (input_port_read(device->machine, "KEYBOARD"))
528497   {
529   case VIP_KEYBOARD_VP580:
530      if (input_port_read(device->machine, "VP-580") & (1 << state->keylatch)) flags -= EF4;
531      break;
498   case KEYBOARD_VP580:
499      return BIT(input_port_read(device->machine, "VP-580"), state->m_keylatch);
532500   }
533501
534   return flags;
502   return 0;
535503}
536504
537static CDP1802_SC_WRITE( vip_sc_w )
505static COSMAC_SC_WRITE( vip_sc_w )
538506{
539//  vip_state *driver_state = device->machine->driver_data;
507   vip_state *state = device->machine->driver_data<vip_state>();
540508
541509   switch (input_port_read(device->machine, "SOUND"))
542510   {
543   case VIP_SOUND_VP550:
544   case VIP_SOUND_VP551:
545      vp550_sc1_w(device, sc1);
511   case SOUND_VP550:
512      vp550_sc1_w(device, BIT(sc, 1)); // device = CPU since the handler calls cpu_set_input_line on it!
546513      break;
514   
515   case SOUND_VP551:
516      vp550_sc1_w(device, BIT(sc, 1)); // device = CPU since the handler calls cpu_set_input_line on it!
517      break;
547518   }
548519}
549520
r9380r9381
551522{
552523   vip_state *driver_state = device->machine->driver_data<vip_state>();
553524
554   /* sound output */
555
525   // sound output
556526   switch (input_port_read(device->machine, "SOUND"))
557527   {
558   case VIP_SOUND_SPEAKER:
559      discrete_sound_w(driver_state->beeper, NODE_01, state);
560      vp595_q_w(driver_state->vp595, 0);
561      vp550_q_w(driver_state->vp550, 0);
528   case SOUND_SPEAKER:
529      discrete_sound_w(driver_state->m_beeper, NODE_01, state);
530      vp595_q_w(driver_state->m_vp595, 0);
531      vp550_q_w(driver_state->m_vp550, 0);
562532      break;
563533
564   case VIP_SOUND_VP595:
565      discrete_sound_w(driver_state->beeper, NODE_01, 0);
566      vp595_q_w(driver_state->vp595, state);
567      vp550_q_w(driver_state->vp550, 0);
534   case SOUND_VP595:
535      discrete_sound_w(driver_state->m_beeper, NODE_01, 0);
536      vp595_q_w(driver_state->m_vp595, state);
537      vp550_q_w(driver_state->m_vp550, 0);
568538      break;
569539
570   case VIP_SOUND_VP550:
571   case VIP_SOUND_VP551:
572      discrete_sound_w(driver_state->beeper, NODE_01, 0);
573      vp595_q_w(driver_state->vp595, 0);
574      vp550_q_w(driver_state->vp550, state);
540   case SOUND_VP550:
541   case SOUND_VP551:
542      discrete_sound_w(driver_state->m_beeper, NODE_01, 0);
543      vp595_q_w(driver_state->m_vp595, 0);
544      vp550_q_w(driver_state->m_vp550, state);
575545      break;
576546   }
577547
578   /* Q led */
579   set_led_status(device->machine, VIP_LED_Q, state);
548   // Q led
549   set_led_status(device->machine, LED_Q, state);
580550
581   /* tape output */
582   cassette_output(driver_state->cassette, state ? 1.0 : -1.0);
551   // tape output
552   cassette_output(driver_state->m_cassette, state ? 1.0 : -1.0);
583553}
584554
585555static WRITE8_DEVICE_HANDLER( vip_dma_w )
r9380r9381
588558
589559   switch (input_port_read(device->machine, "VIDEO"))
590560   {
591   case VIP_VIDEO_CDP1861:
592      cdp1861_dma_w(state->cdp1861, offset, data);
561   case VIDEO_CDP1861:
562      cdp1861_dma_w(state->m_vdc, offset, data);
593563      break;
594564
595   case VIP_VIDEO_CDP1862:
565   case VIDEO_CDP1862:
596566      {
597567         UINT8 mask = 0xff;
598568
599         if (!state->a12)
569         if (!state->m_a12)
600570         {
601            /* mask out A4 and A3 */
571            // mask out A4 and A3
602572            mask = 0xe7;
603573         }
604574
605         state->color = state->colorram[offset & mask];
575         state->m_color = state->m_colorram[offset & mask];
606576
607         cdp1862_dma_w(state->cdp1862, offset, data);
577         cdp1862_dma_w(state->m_cgc, offset, data);
608578      }
609579      break;
610580   }
611581}
612582
613static CDP1802_INTERFACE( vip_config )
583static COSMAC_INTERFACE( cosmac_intf )
614584{
615   vip_mode_r,
616   vip_ef_r,
617   vip_sc_w,
585   DEVCB_LINE_VCC,
586   DEVCB_LINE(clear_r),
587   DEVCB_NULL,
588   DEVCB_DEVICE_LINE(CASSETTE_TAG, ef2_r),
589   DEVCB_LINE(ef3_r),
590   DEVCB_LINE(ef4_r),
618591   DEVCB_LINE(vip_q_w),
619592   DEVCB_NULL,
620   DEVCB_HANDLER(vip_dma_w)
593   DEVCB_HANDLER(vip_dma_w),
594   vip_sc_w,
595   DEVCB_NULL,
596   DEVCB_NULL
621597};
622598
623599/* Machine Initialization */
624600
625static MACHINE_START( vip )
601void vip_state::machine_start()
626602{
627   vip_state *state = machine->driver_data<vip_state>();
603   UINT8 *ram = messram_get_ptr(m_ram);
628604
629   UINT8 *ram = memory_region(machine, CDP1802_TAG);
630   UINT16 addr;
631
632   /* RAM banking */
633   memory_configure_bank(machine, "bank1", 0, 2, memory_region(machine, CDP1802_TAG), 0x8000);
634
635   /* ROM banking */
636   memory_install_read_bank(cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x81ff, 0, 0x7e00, "bank2");
637   memory_unmap_write(cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM), 0x8000, 0x81ff, 0, 0x7e00);
638   memory_configure_bank(machine, "bank2", 0, 1, memory_region(machine, CDP1802_TAG) + 0x8000, 0);
639   memory_set_bank(machine, "bank2", 0);
640
641605   /* randomize RAM contents */
642   for (addr = 0; addr < messram_get_size(machine->device("messram")); addr++)
606   for (UINT16 addr = 0; addr < messram_get_size(m_ram); addr++)
643607   {
644608      ram[addr] = mame_rand(machine) & 0xff;
645609   }
646610
647611   /* allocate color RAM */
648   state->colorram = auto_alloc_array(machine, UINT8, VP590_COLOR_RAM_SIZE);
612   m_colorram = auto_alloc_array(machine, UINT8, VP590_COLOR_RAM_SIZE);
649613
650614   /* enable power LED */
651   set_led_status(machine, VIP_LED_POWER, 1);
615   set_led_status(machine, LED_POWER, 1);
652616
653   /* look up devices */
654   state->cdp1861 = machine->device(CDP1861_TAG);
655   state->cdp1862 = machine->device(CDP1862_TAG);
656   state->cassette = machine->device(CASSETTE_TAG);
657   state->beeper = machine->device(DISCRETE_TAG);
658   state->vp595 = machine->device(VP595_TAG);
659   state->vp550 = machine->device(VP550_TAG);
660   state->vp551 = machine->device(VP551_TAG);
661
662617   /* reset sound */
663   discrete_sound_w(state->beeper, NODE_01, 0);
664   vp595_q_w(state->vp595, 0);
665   vp550_q_w(state->vp550, 0);
666   vp550_q_w(state->vp551, 0);
618   discrete_sound_w(m_beeper, NODE_01, 0);
619   vp595_q_w(m_vp595, 0);
620   vp550_q_w(m_vp550, 0);
621   vp550_q_w(m_vp551, 0);
667622
668623   /* register for state saving */
669   state_save_register_global(machine, state->reset);
670   state_save_register_global_pointer(machine, state->colorram, VP590_COLOR_RAM_SIZE);
671   state_save_register_global(machine, state->cdp1861_efx);
672   state_save_register_global(machine, state->color);
673   state_save_register_global(machine, state->keylatch);
624   state_save_register_global_pointer(machine, m_colorram, VP590_COLOR_RAM_SIZE);
625   state_save_register_global(machine, m_color);
626   state_save_register_global(machine, m_keylatch);
674627}
675628
676static MACHINE_RESET( vip )
629void vip_state::machine_reset()
677630{
678   vip_state *state = machine->driver_data<vip_state>();
631   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
632   address_space *io = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_IO);
679633
680   address_space *program = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_PROGRAM);
681   address_space *io = cputag_get_address_space(machine, CDP1802_TAG, ADDRESS_SPACE_IO);
682
683634   /* reset auxiliary chips */
684   state->cdp1861->reset();
685   state->cdp1862->reset();
635   m_vdc->reset();
636   m_cgc->reset();
686637
687638   /* reset devices */
688   state->vp595->reset();
689   state->vp550->reset();
690   state->vp551->reset();
639   m_vp595->reset();
640   m_vp550->reset();
641   m_vp551->reset();
691642
692643   /* configure video */
693644   switch (input_port_read(machine, "VIDEO"))
694645   {
695   case VIP_VIDEO_CDP1861:
646   case VIDEO_CDP1861:
696647      memory_unmap_write(io, 0x05, 0x05, 0, 0);
697648      memory_unmap_write(program, 0xc000, 0xdfff, 0, 0);
698649      break;
699650
700   case VIP_VIDEO_CDP1862:
701      memory_install_write8_device_handler(io, state->cdp1862, 0x05, 0x05, 0, 0, cdp1862_bkg_w);
702      memory_install_write8_handler(program, 0xc000, 0xdfff, 0, 0, vip_colorram_w);
651   case VIDEO_CDP1862:
652      memory_install_write8_device_handler(io, m_cgc, 0x05, 0x05, 0, 0, cdp1862_bkg_w);
653//      memory_install_write8_handler(program, 0xc000, 0xdfff, 0, 0, vip_colorram_w);
703654      break;
704655   }
705656
706657   /* configure audio */
707658   switch (input_port_read(machine, "SOUND"))
708659   {
709   case VIP_SOUND_SPEAKER:
710      vp595_install_write_handlers(state->vp595, io, 0);
711      vp550_install_write_handlers(state->vp550, program, 0);
712      vp551_install_write_handlers(state->vp551, program, 0);
660   case SOUND_SPEAKER:
661      vp595_install_write_handlers(m_vp595, io, 0);
662      vp550_install_write_handlers(m_vp550, program, 0);
663      vp551_install_write_handlers(m_vp551, program, 0);
713664      break;
714665
715   case VIP_SOUND_VP595:
716      vp595_install_write_handlers(state->vp595, io, 1);
717      vp550_install_write_handlers(state->vp550, program, 0);
718      vp551_install_write_handlers(state->vp551, program, 0);
666   case SOUND_VP595:
667      vp550_install_write_handlers(m_vp550, program, 0);
668      vp551_install_write_handlers(m_vp551, program, 0);
669      vp595_install_write_handlers(m_vp595, io, 1);
719670      break;
720671
721   case VIP_SOUND_VP550:
722      vp595_install_write_handlers(state->vp595, io, 0);
723      vp550_install_write_handlers(state->vp550, program, 1);
724      vp551_install_write_handlers(state->vp551, program, 0);
672   case SOUND_VP550:
673      vp595_install_write_handlers(m_vp595, io, 0);
674      vp551_install_write_handlers(m_vp551, program, 0);
675      vp550_install_write_handlers(m_vp550, program, 1);
725676      break;
726677
727   case VIP_SOUND_VP551:
728      vp595_install_write_handlers(state->vp595, io, 0);
729      vp550_install_write_handlers(state->vp550, program, 0);
730      vp551_install_write_handlers(state->vp551, program, 1);
678   case SOUND_VP551:
679      vp595_install_write_handlers(m_vp595, io, 0);
680      vp550_install_write_handlers(m_vp550, program, 0);
681      vp551_install_write_handlers(m_vp551, program, 1);
731682      break;
732683   }
733684
734   /* enable ROM mirror at 0x0000 */
735   memory_install_read_bank(program, 0x0000, 0x01ff, 0, 0x7e00, "bank1");
736   memory_unmap_write(program, 0x0000, 0x01ff, 0, 0x7e00);
737   memory_set_bank(machine, "bank1", VIP_BANK_ROM);
685   /* enable ROM all thru address space */
686   memory_install_rom(program, 0x0000, 0x01ff, 0, 0xfe00, memory_region(&m_machine, CDP1802_TAG));
738687}
739688
740689/* Machine Drivers */
r9380r9381
748697};
749698
750699static MACHINE_CONFIG_START( vip, vip_state )
751
752700   /* basic machine hardware */
753   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, XTAL_3_52128MHz/2)
701   MDRV_CPU_ADD(CDP1802_TAG, COSMAC, XTAL_3_52128MHz/2)
754702   MDRV_CPU_PROGRAM_MAP(vip_map)
755703   MDRV_CPU_IO_MAP(vip_io_map)
756   MDRV_CPU_CONFIG(vip_config)
704   MDRV_CPU_CONFIG(cosmac_intf)
757705
758   MDRV_MACHINE_START(vip)
759   MDRV_MACHINE_RESET(vip)
760
761706    /* video hardware */
762707   MDRV_CDP1861_SCREEN_ADD(SCREEN_TAG, XTAL_3_52128MHz/2)
763708
764709   MDRV_PALETTE_LENGTH(16)
765710   MDRV_PALETTE_INIT(black_and_white)
766   MDRV_VIDEO_UPDATE(vip)
767711
768712   MDRV_CDP1861_ADD(CDP1861_TAG, XTAL_3_52128MHz, vip_cdp1861_intf)
769713   MDRV_CDP1862_ADD(CDP1862_TAG, CPD1862_CLOCK, vip_cdp1862_intf)
r9380r9381
790734MACHINE_CONFIG_END
791735
792736static MACHINE_CONFIG_DERIVED( vp111, vip )
793
794737   /* internal ram */
795738   MDRV_RAM_MODIFY("messram")
796739   MDRV_RAM_DEFAULT_SIZE("1K")
r9380r9381
800743/* ROMs */
801744
802745ROM_START( vip )
803   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
804   ROM_LOAD( "cdpr566.u10", 0x8000, 0x0200, CRC(5be0a51f) SHA1(40266e6d13e3340607f8b3dcc4e91d7584287c06) )
805   ROM_SYSTEM_BIOS( 0, "monitor", "Monitor" )
806   ROM_SYSTEM_BIOS( 1, "vp700", "VP-700 Tiny BASIC" )
807   ROMX_LOAD( "vp700.bin",    0x9000, 0x1000, NO_DUMP, ROM_BIOS(2) )
746   ROM_REGION( 0x200, CDP1802_TAG, 0 )
747   ROM_LOAD( "cdpr566.u10", 0x0000, 0x0200, CRC(5be0a51f) SHA1(40266e6d13e3340607f8b3dcc4e91d7584287c06) )
808748
749   ROM_REGION( 0x1000, "vp700", 0)
750   ROM_LOAD( "vp700.bin", 0x0000, 0x1000, NO_DUMP )
751
809752   ROM_REGION( 0x200, "chip8", 0 )
810753   ROM_LOAD( "chip8.bin", 0x0000, 0x0200, CRC(438ec5d5) SHA1(8aa634c239004ff041c9adbf9144bd315ab5fc77) )
811754
r9380r9381
849792   }
850793
851794   /* load image to RAM */
852   image.fread( ptr + chip8_size, size);
795   image.fread(ptr + chip8_size, size);
853796
854797   return IMAGE_INIT_PASS;
855798}
docs/messnew.txt
r9380r9381
7979
8080- [PSION] Added support for datapack images [Sandro Ronco]
8181
82- [VIP] Refactored driver to define ADDRESS_MAP_MODERN and use the new
83  RCA COSMAC CPU. [Curt Coder]
8284
8385
86
8487Imgtool Changes:
8588----------------
8689
r9380r9381
116119- Added call to fetch metadata (in cartslot.c) so correct PCB can be loaded.
117120  [tim lindner]
118121
122- Refactored the RCA CDP1802 CPU to a C++ device (COSMAC). [Curt Coder]
119123
124
125
1201260.139
121127
122128New System Drivers Supported:

Previous 15994 Revisions Next


© 1998-2018 The MESS Team