Previous 15994 Revisions Next

r3785 Monday 8th December, 2008 at 16:41:22 UTC by Curt Coder
[STUDIO2] Moved variables to driver state.
[src/mess/drivers]studio2.c
[src/mess/includes]studio2.h*

src/mess/includes/studio2.h
r0r3785
1#ifndef __STUDIO2__
2#define __STUDIO2__
3 
4#include "cpu/cdp1802/cdp1802.h"
5 
6#define SCREEN_TAG "main"
7#define CDP1802_TAG "cdp1802"
8#define CDP1861_TAG "cdp1861"
9#define CDP1864_TAG "cdp1864"
10 
11#define ST2_HEADER_SIZE      256
12 
13typedef struct _studio2_state studio2_state;
14struct _studio2_state
15{
16   /* cpu state */
17   cdp1802_control_mode cdp1802_mode;
18 
19   /* keyboard state */
20   UINT8 keylatch;
21 
22   /* video state */
23   int cdp1861_efx;
24   int cdp1864_efx;
25   UINT8 *color_ram;
26 
27   /* devices */
28   const device_config *cdp1861;
29   const device_config *cdp1864;
30};
31 
32#endif
src/mess/drivers/studio2.c
r3784r3785
145145*/
146146
147147#include "driver.h"
148#include "includes/studio2.h"
148149#include "cpu/cdp1802/cdp1802.h"
149150#include "video/cdp1861.h"
150151#include "video/cdp1864.h"
r3784r3785
152153#include "sound/beep.h"
153154#include "sound/discrete.h"
154155
155#define SCREEN_TAG "main"
156#define CDP1861_TAG "cdp1861"
157#define CDP1864_TAG "cdp1864"
158
159156/* Read/Write Handlers */
160157
161static UINT8 keylatch;
162
163158static WRITE8_HANDLER( keylatch_w )
164159{
165   keylatch = data & 0x0f;
160   studio2_state *state = space->machine->driver_data;
161
162   state->keylatch = data & 0x0f;
166163}
167164
168165/* Memory Maps */
r3784r3785
181178   AM_RANGE(0x0000, 0x07ff) AM_ROM
182179   AM_RANGE(0x0800, 0x09ff) AM_RAM
183180   AM_RANGE(0x0a00, 0x0dff) AM_ROM
184   AM_RANGE(0x0e00, 0x0eff) AM_RAM AM_BASE(&colorram)
181   AM_RANGE(0x0e00, 0x0eff) AM_RAM AM_BASE_MEMBER(studio2_state, color_ram)
185182ADDRESS_MAP_END
186183
187184static ADDRESS_MAP_START( mpt02_io_map, ADDRESS_SPACE_IO, 8 )
r3784r3785
220217
221218/* Video */
222219
223static int cdp1861_efx;
224
225220static CDP1861_ON_INT_CHANGED( studio2_int_w )
226221{
227   cpu_set_input_line(device->machine->cpu[0], CDP1802_INPUT_LINE_INT, level);
222   cputag_set_input_line(device->machine, CDP1802_TAG, CDP1802_INPUT_LINE_INT, level);
228223}
229224
230225static CDP1861_ON_DMAO_CHANGED( studio2_dmao_w )
231226{
232   cpu_set_input_line(device->machine->cpu[0], CDP1802_INPUT_LINE_DMAOUT, level);
227   cputag_set_input_line(device->machine, CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT, level);
233228}
234229
235230static CDP1861_ON_EFX_CHANGED( studio2_efx_w )
236231{
237   cdp1861_efx = level;
232   studio2_state *state = device->machine->driver_data;
233
234   state->cdp1861_efx = level;
238235}
239236
240237static CDP1861_INTERFACE( studio2_cdp1861_intf )
r3784r3785
248245
249246static VIDEO_UPDATE( studio2 )
250247{
251   const device_config *cdp1861 = devtag_get_device(screen->machine, CDP1861, CDP1861_TAG);
248   studio2_state *state = screen->machine->driver_data;
252249
253   cdp1861_update(cdp1861, bitmap, cliprect);
250   cdp1861_update(state->cdp1861, bitmap, cliprect);
254251
255252   return 0;
256253}
257254
258static int cdp1864_efx;
259
260255static CDP1864_ON_INT_CHANGED( mpt02_int_w )
261256{
262   cpu_set_input_line(device->machine->cpu[0], CDP1802_INPUT_LINE_INT, level);
257   cputag_set_input_line(device->machine, CDP1802_TAG, CDP1802_INPUT_LINE_INT, level);
263258}
264259
265260static CDP1864_ON_DMAO_CHANGED( mpt02_dmao_w )
266261{
267   cpu_set_input_line(device->machine->cpu[0], CDP1802_INPUT_LINE_DMAOUT, level);
262   cputag_set_input_line(device->machine, CDP1802_TAG, CDP1802_INPUT_LINE_DMAOUT, level);
268263}
269264
270265static CDP1864_ON_EFX_CHANGED( mpt02_efx_w )
271266{
272   cdp1864_efx = level;
267   studio2_state *state = device->machine->driver_data;
268
269   state->cdp1864_efx = level;
273270}
274271
275272static CDP1864_INTERFACE( mpt02_cdp1864_intf )
r3784r3785
288285
289286static VIDEO_UPDATE( mpt02 )
290287{
291   const device_config *cdp1864 = devtag_get_device(screen->machine, CDP1864, CDP1864_TAG);
288   studio2_state *state = screen->machine->driver_data;
292289
293   cdp1864_update(cdp1864, bitmap, cliprect);
290   cdp1864_update(state->cdp1864, bitmap, cliprect);
294291
295292   return 0;
296293}
297294
298295/* CDP1802 Configuration */
299296
300static int cdp1802_mode = CDP1802_MODE_RESET;
301
302297static CDP1802_MODE_READ( studio2_mode_r )
303298{
304   return cdp1802_mode;
299   studio2_state *state = device->machine->driver_data;
300
301   return state->cdp1802_mode;
305302}
306303
307304static CDP1802_EF_READ( studio2_ef_r )
308305{
306   studio2_state *state = device->machine->driver_data;
307
309308   int ef = 0x0f;
310309
311   if (cdp1861_efx) ef -= EF1;
310   if (state->cdp1861_efx) ef -= EF1;
312311
313   if (input_port_read(device->machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
314   if (input_port_read(device->machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
312   if (input_port_read(device->machine, "KEYPAD_L") & (1 << state->keylatch)) ef -= EF3;
313   if (input_port_read(device->machine, "KEYPAD_R") & (1 << state->keylatch)) ef -= EF4;
315314
316315   return ef;
317316}
r3784r3785
323322
324323static CDP1802_DMA_WRITE( studio2_dma_w )
325324{
326   const device_config *cdp1861 = devtag_get_device(device->machine, CDP1861, CDP1861_TAG);
325   studio2_state *state = device->machine->driver_data;
327326
328   cdp1861_dma_w(cdp1861, data);
327   cdp1861_dma_w(state->cdp1861, data);
329328}
330329
331330static CDP1802_INTERFACE( studio2_config )
r3784r3785
340339
341340static CDP1802_EF_READ( mpt02_ef_r )
342341{
342   studio2_state *state = device->machine->driver_data;
343
343344   int ef = 0x0f;
344345
345   if (cdp1864_efx) ef -= EF1;
346   if (state->cdp1864_efx) ef -= EF1;
346347
347   if (input_port_read(device->machine, "KEYPAD_L") & (1 << keylatch)) ef -= EF3;
348   if (input_port_read(device->machine, "KEYPAD_R") & (1 << keylatch)) ef -= EF4;
348   if (input_port_read(device->machine, "KEYPAD_L") & (1 << state->keylatch)) ef -= EF3;
349   if (input_port_read(device->machine, "KEYPAD_R") & (1 << state->keylatch)) ef -= EF4;
349350
350351   return ef;
351352}
352353
353354static CDP1802_DMA_WRITE( mpt02_dma_w )
354355{
355   const device_config *cdp1864 = devtag_get_device(device->machine, CDP1864, CDP1864_TAG);
356   studio2_state *state = device->machine->driver_data;
356357
357   UINT8 color = colorram[ma / 4]; // 0x04 = R, 0x02 = B, 0x01 = G
358   UINT8 color = state->color_ram[ma / 4]; // 0x04 = R, 0x02 = B, 0x01 = G
358359
359360   int rdata = BIT(color, 2);
360361   int gdata = BIT(color, 0);
361362   int bdata = BIT(color, 1);
362363
363   cdp1864_dma_w(cdp1864, data, ASSERT_LINE, rdata, gdata, bdata);
364   cdp1864_dma_w(state->cdp1864, data, ASSERT_LINE, rdata, gdata, bdata);
364365}
365366
366367static CDP1802_INTERFACE( mpt02_config )
r3784r3785
375376
376377/* Machine Initialization */
377378
379static TIMER_CALLBACK( set_cpu_mode )
380{
381   studio2_state *state = machine->driver_data;
382
383   state->cdp1802_mode = CDP1802_MODE_RUN;
384}
385
378386static MACHINE_START( studio2 )
379387{
380   state_save_register_global(machine, cdp1861_efx);
381   state_save_register_global(machine, cdp1802_mode);
382   state_save_register_global(machine, keylatch);
388   studio2_state *state = machine->driver_data;
389
390   /* find devices */
391   state->cdp1861 = devtag_get_device(machine, CDP1861, CDP1861_TAG);
392
393   /* register for state saving */
394   state_save_register_global(machine, state->cdp1802_mode);
395   state_save_register_global(machine, state->keylatch);
396   state_save_register_global(machine, state->cdp1861_efx);
383397}
384398
385399static MACHINE_RESET( studio2 )
386400{
387   const device_config *cdp1861 = devtag_get_device(machine, CDP1861, CDP1861_TAG);
388   
389   cdp1861->reset(cdp1861);
401   studio2_state *state = machine->driver_data;
402
403   /* reset CPU */
404   state->cdp1802_mode = CDP1802_MODE_RESET;
405   timer_set(machine, ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
406
407   /* reset CDP1861 */
408   device_reset(state->cdp1861);
390409}
391410
392411static MACHINE_START( mpt02 )
393412{
394   state_save_register_global(machine, cdp1864_efx);
395   state_save_register_global(machine, cdp1802_mode);
396   state_save_register_global(machine, keylatch);
413   studio2_state *state = machine->driver_data;
414
415   /* find devices */
416   state->cdp1864 = devtag_get_device(machine, CDP1864, CDP1864_TAG);
417   
418   /* register for state saving */
419   state_save_register_global(machine, state->cdp1802_mode);
420   state_save_register_global(machine, state->keylatch);
421   state_save_register_global(machine, state->cdp1864_efx);
397422}
398423
399424static MACHINE_RESET( mpt02 )
400425{
401   const device_config *cdp1864 = devtag_get_device(machine, CDP1864, CDP1864_TAG);
402   
403   cdp1864->reset(cdp1864);
426   studio2_state *state = machine->driver_data;
404427
405   cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, PULSE_LINE);
428   /* reset CPU */
429   state->cdp1802_mode = CDP1802_MODE_RESET;
430   timer_set(machine, ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
431
432   /* reset CDP1864 */
433   device_reset(state->cdp1864);
406434}
407435
408/* machine Drivers */
436/* Machine Drivers */
409437
410438static MACHINE_DRIVER_START( studio2 )
439   MDRV_DRIVER_DATA(studio2_state)
440
411441   // basic machine hardware
412442
413   MDRV_CPU_ADD("main", CDP1802, 3579545/2) // the real clock is derived from an oscillator circuit
443   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, 3579545/2) // the real clock is derived from an oscillator circuit
414444   MDRV_CPU_PROGRAM_MAP(studio2_map, 0)
415445   MDRV_CPU_IO_MAP(studio2_io_map, 0)
416446   MDRV_CPU_CONFIG(studio2_config)
r3784r3785
439469MACHINE_DRIVER_END
440470
441471static MACHINE_DRIVER_START( visicom )
472   MDRV_DRIVER_DATA(studio2_state)
473
442474   // basic machine hardware
443475
444   MDRV_CPU_ADD("main", CDP1802, 3579545/2) // ???
476   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, 3579545/2) // ???
445477   MDRV_CPU_PROGRAM_MAP(studio2_map, 0)
446478   MDRV_CPU_IO_MAP(studio2_io_map, 0)
447479   MDRV_CPU_CONFIG(studio2_config)
r3784r3785
470502MACHINE_DRIVER_END
471503
472504static MACHINE_DRIVER_START( mpt02 )
505   MDRV_DRIVER_DATA(studio2_state)
506
473507   // basic machine hardware
474508
475   MDRV_CPU_ADD("main", CDP1802, CDP1864_CLOCK)
509   MDRV_CPU_ADD(CDP1802_TAG, CDP1802, CDP1864_CLOCK)
476510   MDRV_CPU_PROGRAM_MAP(mpt02_map, 0)
477511   MDRV_CPU_IO_MAP(mpt02_io_map, 0)
478512   MDRV_CPU_CONFIG(mpt02_config)
r3784r3785
482516
483517    // video hardware
484518
485   MDRV_SCREEN_ADD("main", RASTER)
519   MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
486520   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
487521   MDRV_SCREEN_RAW_PARAMS(CDP1864_CLOCK, CDP1864_SCREEN_WIDTH, CDP1864_HBLANK_END, CDP1864_HBLANK_START, CDP1864_TOTAL_SCANLINES, CDP1864_SCANLINE_VBLANK_END, CDP1864_SCANLINE_VBLANK_START)
488522
r3784r3785
502536/* ROMs */
503537
504538ROM_START( studio2 )
505   ROM_REGION( 0x10000, "main", 0 )
539   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
506540   ROM_LOAD( "84932", 0x0000, 0x0200, NO_DUMP )
507541   ROM_LOAD( "84933", 0x0200, 0x0200, NO_DUMP )
508542   ROM_LOAD( "85456", 0x0400, 0x0200, NO_DUMP )
r3784r3785
511545ROM_END
512546
513547ROM_START( mtc9016 )
514   ROM_REGION( 0x10000, "main", 0 )
548   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
515549   ROM_LOAD( "86676.ic13",  0x0000, 0x0400, NO_DUMP )
516550   ROM_LOAD( "86677b.ic14", 0x0400, 0x0400, NO_DUMP )
517551   ROM_LOAD( "87201.ic12",  0x0a00, 0x0400, NO_DUMP )
518552ROM_END
519553
520554ROM_START( shmc1200 )
521   ROM_REGION( 0x10000, "main", 0 )
555   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
522556   ROM_LOAD( "shmc1200.bin",  0x0000, 0x0800, NO_DUMP )
523557ROM_END
524558
525559ROM_START( mpt02s )
526   ROM_REGION( 0x10000, "main", 0 )
560   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
527561ROM_END
528562
529563ROM_START( mpt02h )
530   ROM_REGION( 0x10000, "main", 0 )
564   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
531565ROM_END
532566
533567ROM_START( visicom )
534   ROM_REGION( 0x10000, "main", 0 )
568   ROM_REGION( 0x10000, CDP1802_TAG, 0 )
535569   ROM_LOAD( "visicom.bin",  0x0000, 0x0800, NO_DUMP )
536570ROM_END
537571
572/* Driver Initialization */
573
574static TIMER_CALLBACK( setup_beep )
575{
576   beep_set_state(0, 0);
577   beep_set_frequency(0, 300);
578}
579
580static DRIVER_INIT( studio2 )
581{
582   timer_set(machine, attotime_zero, NULL, 0, setup_beep);
583}
584
538585/* System Configuration */
539586
540#define ST2_HEADER_SIZE      256
541
542587static DEVICE_IMAGE_LOAD( studio2_cart )
543588{
544589   UINT8   *ptr = NULL;
r3784r3785
558603   }
559604   filesize -= ST2_HEADER_SIZE;
560605   /* Read ST2 cartridge contents */
561   ptr = ((UINT8 *)memory_region(image->machine,  "main" ) ) + 0x0400;
606   ptr = ((UINT8 *)memory_region(image->machine,  CDP1802_TAG ) ) + 0x0400;
562607   if ( image_fread(image, ptr, filesize ) != filesize ) {
563608      logerror( "Error loading cartridge: Unable to read contents from file: %s.\n", image_filename( image ) );
564609      return INIT_FAIL;
r3784r3785
588633   CONFIG_DEVICE( studio2_cartslot_getinfo )
589634SYSTEM_CONFIG_END
590635
591/* Driver Initialization */
592
593static TIMER_CALLBACK(set_cpu_mode)
594{
595   cdp1802_mode = CDP1802_MODE_RUN;
596}
597
598static TIMER_CALLBACK(setup_beep)
599{
600   beep_set_state(0, 0);
601   beep_set_frequency(0, 300);
602}
603
604static DRIVER_INIT( studio2 )
605{
606   timer_set(machine, attotime_zero, NULL, 0, setup_beep);
607   timer_set(machine, ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
608}
609
610static TIMER_CALLBACK(mpt02_setup_beep)
611{
612   beep_set_state( 0, 0 );
613   beep_set_frequency( 0, 0 );
614}
615
616static DRIVER_INIT( mpt02 )
617{
618   timer_set(machine, attotime_zero, NULL, 0, mpt02_setup_beep);
619   timer_set(machine, ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
620}
621
622static DRIVER_INIT( visicom )
623{
624   timer_set(machine, attotime_zero, NULL, 0, setup_beep);
625   timer_set(machine, ATTOTIME_IN_MSEC(200), NULL, 0, set_cpu_mode);
626}
627
628636/* Game Drivers */
629637
630638/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        CONFIG      COMPANY   FULLNAME */
631639CONS( 1977,   studio2,   0,      0,      studio2,   studio2,   studio2,   studio2,   "RCA",      "Studio II", GAME_SUPPORTS_SAVE )
632CONS( 1978, visicom,   studio2,0,      visicom,   studio2,   visicom,   studio2,   "Toshiba",   "Visicom (Japan)", GAME_NOT_WORKING )
633CONS( 1978,   mpt02s,      studio2,0,      mpt02,      studio2,   mpt02,      studio2,   "Soundic",   "MPT-02 Victory Home TV Programmer (Austria)", GAME_NOT_WORKING )
634CONS( 1978,   mpt02h,      studio2,0,      mpt02,      studio2,   mpt02,      studio2,   "Hanimex",   "MPT-02 Jeu TV Programmable (France)", GAME_NOT_WORKING )
635CONS( 1978,   mtc9016,   studio2,0,      mpt02,      studio2,   mpt02,      studio2,   "Mustang",   "9016 Telespiel Computer (Germany)", GAME_NOT_WORKING )
636CONS( 1978, shmc1200,   studio2,0,      mpt02,      studio2,   mpt02,      studio2,   "Sheen",   "1200 Micro Computer (Australia)", GAME_NOT_WORKING )
640CONS( 1978, visicom,   studio2,0,      visicom,   studio2,   studio2,   studio2,   "Toshiba",   "Visicom (Japan)", GAME_NOT_WORKING )
641CONS( 1978,   mpt02s,      studio2,0,      mpt02,      studio2,   studio2,   studio2,   "Soundic",   "MPT-02 Victory Home TV Programmer (Austria)", GAME_NOT_WORKING )
642CONS( 1978,   mpt02h,      studio2,0,      mpt02,      studio2,   studio2,   studio2,   "Hanimex",   "MPT-02 Jeu TV Programmable (France)", GAME_NOT_WORKING )
643CONS( 1978,   mtc9016,   studio2,0,      mpt02,      studio2,   studio2,   studio2,   "Mustang",   "9016 Telespiel Computer (Germany)", GAME_NOT_WORKING )
644CONS( 1978, shmc1200,   studio2,0,      mpt02,      studio2,   studio2,   studio2,   "Sheen",   "1200 Micro Computer (Australia)", GAME_NOT_WORKING )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team