Previous 199869 Revisions Next

r32494 Thursday 2nd October, 2014 at 12:09:37 UTC by Fabio Priuli
(MESS) converted ibmpcjr and studio2 to use generic cart slot for
their carts. nw.
[hash]ibmpcjr_cart.xml studio2.xml
[src/mess/drivers]ibmpcjr.c studio2.c
[src/mess/includes]studio2.h

trunk/src/mess/includes/studio2.h
r32493r32494
1// license:BSD-3-Clause
2// copyright-holders:Curt Coder
3#pragma once
4
5#ifndef __STUDIO2__
6#define __STUDIO2__
7
8
9#include "emu.h"
10#include "cpu/cosmac/cosmac.h"
11#include "imagedev/cartslot.h"
12#include "sound/beep.h"
13#include "sound/cdp1864.h"
14#include "sound/discrete.h"
15#include "video/cdp1861.h"
16
17#define CDP1802_TAG     "ic1"
18#define CDP1861_TAG     "ic2"
19#define CDP1864_TAG     "cdp1864"
20#define SCREEN_TAG      "screen"
21
22class studio2_state : public driver_device
23{
24public:
25   enum
26   {
27      TIMER_SETUP_BEEP
28   };
29
30   studio2_state(const machine_config &mconfig, device_type type, const char *tag)
31      : driver_device(mconfig, type, tag),
32         m_maincpu(*this, CDP1802_TAG),
33         m_beeper(*this, "beeper"),
34         m_vdc(*this, CDP1861_TAG),
35         m_clear(*this, "CLEAR"),
36         m_a(*this, "A"),
37         m_b(*this, "B"),
38         m_screen(*this, "screen")
39   { }
40
41   required_device<cosmac_device> m_maincpu;
42   required_device<beep_device> m_beeper;
43   optional_device<cdp1861_device> m_vdc;
44   required_ioport m_clear;
45   required_ioport m_a;
46   required_ioport m_b;
47   required_device<screen_device> m_screen;
48
49   virtual void machine_start();
50   virtual void machine_reset();
51
52   DECLARE_READ8_MEMBER( dispon_r );
53   DECLARE_WRITE8_MEMBER( keylatch_w );
54   DECLARE_WRITE8_MEMBER( dispon_w );
55   DECLARE_READ_LINE_MEMBER( clear_r );
56   DECLARE_READ_LINE_MEMBER( ef3_r );
57   DECLARE_READ_LINE_MEMBER( ef4_r );
58   DECLARE_WRITE_LINE_MEMBER( q_w );
59   DECLARE_INPUT_CHANGED_MEMBER( reset_w );
60   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( st2_cartslot_load );
61   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( studio2_cart_load );
62
63   /* keyboard state */
64   UINT8 m_keylatch;
65   DECLARE_DRIVER_INIT(studio2);
66
67protected:
68   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
69};
70
71class visicom_state : public studio2_state
72{
73public:
74   visicom_state(const machine_config &mconfig, device_type type, const char *tag)
75      : studio2_state(mconfig, type, tag),
76         m_color0_ram(*this, "color0_ram"),
77         m_color1_ram(*this, "color1_ram")
78   { }
79
80   virtual UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
81
82   required_shared_ptr<UINT8> m_color0_ram;
83   required_shared_ptr<UINT8> m_color1_ram;
84
85   DECLARE_WRITE8_MEMBER( dma_w );
86
87   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( visicom_cart_load );
88};
89
90class mpt02_state : public studio2_state
91{
92public:
93   mpt02_state(const machine_config &mconfig, device_type type, const char *tag)
94      : studio2_state(mconfig, type, tag),
95         m_cti(*this, CDP1864_TAG),
96         m_color_ram(*this, "color_ram")
97   { }
98
99   required_device<cdp1864_device> m_cti;
100
101   virtual void machine_reset();
102
103   DECLARE_WRITE8_MEMBER( dma_w );
104   DECLARE_READ_LINE_MEMBER( rdata_r );
105   DECLARE_READ_LINE_MEMBER( bdata_r );
106   DECLARE_READ_LINE_MEMBER( gdata_r );
107
108   /* video state */
109   required_shared_ptr<UINT8> m_color_ram;
110   UINT8 m_color;
111};
112
113#endif
trunk/src/mess/drivers/ibmpcjr.c
r32493r32494
1616#include "bus/pc_joy/pc_joy.h"
1717#include "bus/isa/fdc.h"
1818#include "imagedev/cassette.h"
19#include "imagedev/cartslot.h"
2019
20#include "bus/generic/slot.h"
21#include "bus/generic/carts.h"
22
2123class pcjr_state : public driver_device
2224{
2325public:
r32493r32494
2830      m_pit8253(*this, "pit8253"),
2931      m_speaker(*this, "speaker"),
3032      m_cassette(*this, "cassette"),
33      m_cart1(*this, "cartslot1"),
34      m_cart2(*this, "cartslot2"),
3135      m_ram(*this, RAM_TAG),
3236      m_fdc(*this, "fdc"),
3337      m_keyboard(*this, "pc_keyboard")
r32493r32494
3842   required_device<pit8253_device> m_pit8253;
3943   required_device<speaker_sound_device> m_speaker;
4044   required_device<cassette_image_device> m_cassette;
45   required_device<generic_slot_device> m_cart1;
46   required_device<generic_slot_device> m_cart2;
4147   required_device<ram_device> m_ram;
4248   required_device<upd765a_device> m_fdc;
4349   required_device<pc_keyboard_device> m_keyboard;
r32493r32494
5763   DECLARE_WRITE8_MEMBER(pcjx_port_1ff_w);
5864   void pcjx_set_bank(int unk1, int unk2, int unk3);
5965
60   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( pcjr_cartridge );
66   int load_cart(device_image_interface &image, generic_slot_device *slot);
67   DECLARE_DEVICE_IMAGE_LOAD_MEMBER(pcjr_cart1) { return load_cart(image, m_cart1); }
68   DECLARE_DEVICE_IMAGE_LOAD_MEMBER(pcjr_cart2) { return load_cart(image, m_cart2); }
6169   void pc_speaker_set_spkrdata(UINT8 data);
6270
6371   UINT8 m_pc_spkrdata;
r32493r32494
424432   return 0x60; // expansion?
425433}
426434
427DEVICE_IMAGE_LOAD_MEMBER( pcjr_state, pcjr_cartridge )
435int pcjr_state::load_cart(device_image_interface &image, generic_slot_device *slot)
428436{
429   UINT32  address;
430   UINT32  size;
437   UINT32 size = slot->common_get_size("rom");
438   bool imagic_hack = false;
431439
432   address = (!strcmp(":cart2", image.device().tag())) ? 0xd0000 : 0xe0000;
433
434   if ( image.software_entry() )
440   if (image.software_entry() == NULL)
435441   {
436      UINT8 *cart = image.get_software_region( "rom" );
442      int header_size = 0;
437443
438      size = image.get_software_region_length("rom" );
439
440      memcpy( memregion("maincpu")->base() + address, cart, size );
441   }
442   else
443   {
444      UINT8   header[0x200];
445
446      unsigned header_size = 0;
447      unsigned image_size = image.length();
448      bool imagic_hack = false;
449
450      /* Check for supported header sizes */
451      switch( image_size & 0x3ff )
444      // Check for supported header sizes
445      switch (size & 0x3ff)
452446      {
453      case 0x80:
454         header_size = 0x80;
455         break;
456      case 0x200:
457         header_size = 0x200;
458         break;
459      default:
460         image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid header size" );
461         return IMAGE_INIT_FAIL;
447         case 0x80:
448            header_size = 0x80;
449            break;
450         case 0x200:
451            header_size = 0x200;
452            break;
453         default:
454            image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid header size" );
455            return IMAGE_INIT_FAIL;
462456      }
463
464      /* Check for supported image sizes */
465      switch( image_size - header_size )
457      if (size - header_size == 0xa000)
466458      {
467      case 0xa000:
459         // alloc 64K for the imagic carts, so to handle the necessary mirroring
460         size += 0x6000;
468461         imagic_hack = true;
469      case 0x2000:
470      case 0x4000:
471      case 0x8000:
472      case 0x10000:
473         break;
474      default:
475         image.seterror(IMAGE_ERROR_UNSUPPORTED, "Invalid rom file size" );
476         return IMAGE_INIT_FAIL;
477462      }
478463
479      /* Read and verify the header */
480      if ( header_size != image.fread( header, header_size ) )
481      {
482         image.seterror(IMAGE_ERROR_UNSUPPORTED, "Unable to read header" );
483         return IMAGE_INIT_FAIL;
484      }
464      size -= header_size;
465      image.fseek(header_size, SEEK_SET);
466   }
467   
468   slot->rom_alloc(size, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
469   slot->common_load_rom(slot->get_rom_base(), size, "rom");
485470
486      /* Read the cartridge contents */
487      if ( ( image_size - header_size ) != image.fread(memregion("maincpu")->base() + address, image_size - header_size ) )
488      {
489         image.seterror(IMAGE_ERROR_UNSUPPORTED, "Unable to read cartridge contents" );
490         return IMAGE_INIT_FAIL;
491      }
471   if (imagic_hack)
472   {
473      // in this case the image consists of 2x8K chunks
474      // the first chunk is unique, the second is repeated 4 times up to 0xa000 size
492475
493      if (imagic_hack)
494      {
495         UINT8 *cart_area = memregion("maincpu")->base() + address;
496
497         memcpy( cart_area + 0xe000, cart_area + 0x2000, 0x2000 );
498         memcpy( cart_area + 0xc000, cart_area + 0x2000, 0x2000 );
499         memcpy( cart_area + 0xa000, cart_area + 0x2000, 0x2000 );
500         memcpy( cart_area + 0x8000, cart_area + 0x2000, 0x2000 );
501         memcpy( cart_area + 0x6000, cart_area, 0x2000 );
502         memcpy( cart_area + 0x4000, cart_area, 0x2000 );
503         memcpy( cart_area + 0x2000, cart_area, 0x2000 );
504      }
476      // mirroring
477      UINT8 *ROM = slot->get_rom_base();
478      memcpy(ROM + 0xe000, ROM + 0x2000, 0x2000);
479      memcpy(ROM + 0xc000, ROM + 0x2000, 0x2000);
480      memcpy(ROM + 0xa000, ROM + 0x2000, 0x2000);
481      memcpy(ROM + 0x8000, ROM + 0x2000, 0x2000);
482      memcpy(ROM + 0x6000, ROM, 0x2000);
483      memcpy(ROM + 0x4000, ROM, 0x2000);
484      memcpy(ROM + 0x2000, ROM, 0x2000);
505485   }
506
507486   return IMAGE_INIT_PASS;
508487}
509488
489
510490static SLOT_INTERFACE_START( pcjr_floppies )
511491   SLOT_INTERFACE( "525dd", FLOPPY_525_DD )
512492   SLOT_INTERFACE( "35dd", FLOPPY_35_DD )
r32493r32494
556536   AM_RANGE(0xc0000, 0xc7fff) AM_NOP
557537   AM_RANGE(0xc8000, 0xc9fff) AM_ROM
558538   AM_RANGE(0xca000, 0xcffff) AM_NOP
559   AM_RANGE(0xd0000, 0xdffff) AM_ROM
560   AM_RANGE(0xe0000, 0xeffff) AM_ROM
539   AM_RANGE(0xd0000, 0xdffff) AM_DEVREAD("cartslot2", generic_slot_device, read_rom)
540   AM_RANGE(0xe0000, 0xeffff) AM_DEVREAD("cartslot1", generic_slot_device, read_rom)
561541   AM_RANGE(0xf0000, 0xfffff) AM_ROM
562542ADDRESS_MAP_END
563543
r32493r32494
655635   MCFG_PC_KEYB_ADD("pc_keyboard", WRITELINE(pcjr_state, keyb_interrupt))
656636
657637   /* cartridge */
658   MCFG_CARTSLOT_ADD("cart1")
659   MCFG_CARTSLOT_INTERFACE("ibmpcjr_cart")
660   MCFG_CARTSLOT_EXTENSION_LIST("jrc")
661   MCFG_CARTSLOT_NOT_MANDATORY
662   MCFG_CARTSLOT_LOAD(pcjr_state,pcjr_cartridge)
663   MCFG_CARTSLOT_ADD("cart2")
664   MCFG_CARTSLOT_INTERFACE("ibmpcjr_cart")
665   MCFG_CARTSLOT_EXTENSION_LIST("jrc")
666   MCFG_CARTSLOT_NOT_MANDATORY
667   MCFG_CARTSLOT_LOAD(pcjr_state,pcjr_cartridge)
638   MCFG_GENERIC_CARTSLOT_ADD("cartslot1", generic_plain_slot, "ibmpcjr_cart")
639   MCFG_GENERIC_EXTENSIONS("bin,jrc")
640   MCFG_GENERIC_LOAD(pcjr_state, pcjr_cart1)
668641
642   MCFG_GENERIC_CARTSLOT_ADD("cartslot2", generic_plain_slot, "ibmpcjr_cart")
643   MCFG_GENERIC_EXTENSIONS("bin,jrc")
644   MCFG_GENERIC_LOAD(pcjr_state, pcjr_cart2)
645
669646   /* internal ram */
670647   MCFG_RAM_ADD(RAM_TAG)
671648   MCFG_RAM_DEFAULT_SIZE("640K")
trunk/src/mess/drivers/studio2.c
r32493r32494
183183
184184*/
185185
186#include "includes/studio2.h"
186#include "emu.h"
187#include "cpu/cosmac/cosmac.h"
188#include "sound/beep.h"
189#include "sound/cdp1864.h"
190#include "sound/discrete.h"
191#include "video/cdp1861.h"
187192
188/***************************************************************************
189    PARAMETERS
190***************************************************************************/
193#include "bus/generic/slot.h"
194#include "bus/generic/carts.h"
191195
192#define LOG 0
196#define CDP1802_TAG     "ic1"
197#define CDP1861_TAG     "ic2"
198#define CDP1864_TAG     "cdp1864"
199#define SCREEN_TAG      "screen"
193200
194#define ST2_BLOCK_SIZE 256
201class studio2_state : public driver_device
202{
203public:
204   
205   studio2_state(const machine_config &mconfig, device_type type, const char *tag)
206      : driver_device(mconfig, type, tag),
207         m_maincpu(*this, CDP1802_TAG),
208         m_beeper(*this, "beeper"),
209         m_vdc(*this, CDP1861_TAG),
210         m_cart(*this, "cartslot"),
211         m_clear(*this, "CLEAR"),
212         m_a(*this, "A"),
213         m_b(*this, "B"),
214         m_screen(*this, "screen")
215   { }
216   
217   required_device<cosmac_device> m_maincpu;
218   required_device<beep_device> m_beeper;
219   optional_device<cdp1861_device> m_vdc;
220   required_device<generic_slot_device> m_cart;
221   required_ioport m_clear;
222   required_ioport m_a;
223   required_ioport m_b;
224   required_device<screen_device> m_screen;
225   
226   virtual void machine_start();
227   virtual void machine_reset();
228   
229   DECLARE_READ8_MEMBER( cart_400 );
230   DECLARE_READ8_MEMBER( cart_a00 );
231   DECLARE_READ8_MEMBER( cart_e00 );
232   DECLARE_READ8_MEMBER( dispon_r );
233   DECLARE_WRITE8_MEMBER( keylatch_w );
234   DECLARE_WRITE8_MEMBER( dispon_w );
235   DECLARE_READ_LINE_MEMBER( clear_r );
236   DECLARE_READ_LINE_MEMBER( ef3_r );
237   DECLARE_READ_LINE_MEMBER( ef4_r );
238   DECLARE_WRITE_LINE_MEMBER( q_w );
239   DECLARE_INPUT_CHANGED_MEMBER( reset_w );
240   DECLARE_DEVICE_IMAGE_LOAD_MEMBER( studio2_cart_load );
241   
242   /* keyboard state */
243   UINT8 m_keylatch;
244   DECLARE_DRIVER_INIT(studio2);
245};
195246
196/***************************************************************************
197    TYPE DEFINITIONS
198***************************************************************************/
247class visicom_state : public studio2_state
248{
249public:
250   visicom_state(const machine_config &mconfig, device_type type, const char *tag)
251      : studio2_state(mconfig, type, tag),
252         m_color0_ram(*this, "color0_ram"),
253         m_color1_ram(*this, "color1_ram")
254   { }
255   
256   virtual UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect);
257   
258   required_shared_ptr<UINT8> m_color0_ram;
259   required_shared_ptr<UINT8> m_color1_ram;
260   
261   DECLARE_WRITE8_MEMBER( dma_w );
262};
199263
200struct st2_header
264class mpt02_state : public studio2_state
201265{
202   UINT8 header[4];            /* "RCA2" in ASCII code */
203   UINT8 blocks;               /* Total number of 256 byte blocks in file (including this one) */
204   UINT8 format;               /* Format Code (this is format number 1) */
205   UINT8 video;                /* If non-zero uses a special video driver, and programs cannot assume that it uses the standard Studio 2 one (top of screen at $0900+RB.0). A value of '1' here indicates the RAM is used normally, but scrolling is not (e.g. the top of the page is always at $900) */
206   UINT8 reserved0;
207   UINT8 author[2];            /* 2 byte ASCII code indicating the identity of the program coder */
208   UINT8 dumper[2];            /* 2 byte ASCII code indicating the identity of the ROM Source */
209   UINT8 reserved1[4];
210   UINT8 catalogue[10];        /* RCA Catalogue Code as ASCIIZ string. If a homebrew ROM, may contain any identifying code you wish */
211   UINT8 reserved2[6];
212   UINT8 title[32];            /* Cartridge Program Title as ASCIIZ string */
213   UINT8 page[64];             /* Contain the page addresses for each 256 byte block. The first byte at 64, contains the target address of the data at offset 256, the second byte contains the target address of the data at offset 512, and so on. Unused block bytes should be filled with $00 (an invalid page address). So, if byte 64 contains $1C, the ROM is paged into memory from $1C00-$1CFF */
214   UINT8 reserved3[128];
266public:
267   mpt02_state(const machine_config &mconfig, device_type type, const char *tag)
268      : studio2_state(mconfig, type, tag),
269         m_cti(*this, CDP1864_TAG),
270         m_color_ram(*this, "color_ram")
271   { }
272   
273   required_device<cdp1864_device> m_cti;
274   
275   virtual void machine_start();
276   virtual void machine_reset();
277   
278   DECLARE_READ8_MEMBER( cart_c00 );
279   DECLARE_WRITE8_MEMBER( dma_w );
280   DECLARE_READ_LINE_MEMBER( rdata_r );
281   DECLARE_READ_LINE_MEMBER( bdata_r );
282   DECLARE_READ_LINE_MEMBER( gdata_r );
283   
284   /* video state */
285   required_shared_ptr<UINT8> m_color_ram;
286   UINT8 m_color;
215287};
216288
289
217290/***************************************************************************
218    IMPLEMENTATION
291    PARAMETERS
219292***************************************************************************/
220293
221/*-------------------------------------------------
222    DEVICE_IMAGE_LOAD_MEMBER( studio2_state, st2_cartslot_load )
223-------------------------------------------------*/
294#define LOG 0
224295
225DEVICE_IMAGE_LOAD_MEMBER( studio2_state, st2_cartslot_load )
226{
227   st2_header header;
296/***************************************************************************
297    IMPLEMENTATION
298***************************************************************************/
228299
229   /* check file size */
230   int filesize = image.length();
231
232   if (filesize <= ST2_BLOCK_SIZE) {
233      logerror("Error loading cartridge: Invalid ROM file: %s.\n", image.filename());
234      return IMAGE_INIT_FAIL;
235   }
236
237   /* read ST2 header */
238   if (image.fread( &header, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
239      logerror("Error loading cartridge: Unable to read header from file: %s.\n", image.filename());
240      return IMAGE_INIT_FAIL;
241   }
242
243   if (LOG) logerror("ST2 Catalogue: %s\n", header.catalogue);
244   if (LOG) logerror("ST2 Title: %s\n", header.title);
245
246   /* read ST2 cartridge into memory */
247   for (int block = 0; block < (header.blocks - 1); block++)
248   {
249      UINT16 offset = header.page[block] << 8;
250      UINT8 *ptr = ((UINT8 *) memregion(CDP1802_TAG)->base()) + offset;
251
252      if (LOG) logerror("ST2 Reading block %u to %04x\n", block, offset);
253
254      if (image.fread( ptr, ST2_BLOCK_SIZE) != ST2_BLOCK_SIZE) {
255         logerror("Error loading cartridge: Unable to read contents from file: %s.\n", image.filename());
256         return IMAGE_INIT_FAIL;
257      }
258   }
259
260   return IMAGE_INIT_PASS;
261}
262
263
264300/* Read/Write Handlers */
265301
266302WRITE8_MEMBER( studio2_state::keylatch_w )
r32493r32494
297333ADDRESS_MAP_END
298334
299335static ADDRESS_MAP_START( visicom_map, AS_PROGRAM, 8, visicom_state )
300   AM_RANGE(0x0000, 0x0fff) AM_ROM
336   AM_RANGE(0x0000, 0x07ff) AM_ROM
337   AM_RANGE(0x0800, 0x0fff) AM_DEVREAD("cartslot", generic_slot_device, read_rom)
301338   AM_RANGE(0x1000, 0x10ff) AM_RAM
302339   AM_RANGE(0x1100, 0x11ff) AM_RAM AM_SHARE("color0_ram")
303340   AM_RANGE(0x1300, 0x13ff) AM_RAM AM_SHARE("color1_ram")
r32493r32494
446483
447484/* Machine Initialization */
448485
486// trampolines to cartridge
487READ8_MEMBER( studio2_state::cart_400 ) { return m_cart->read_rom(space, offset); }
488READ8_MEMBER( studio2_state::cart_a00 ) { return m_cart->read_rom(space, offset + 0x600); }
489READ8_MEMBER( studio2_state::cart_e00 ) { return m_cart->read_rom(space, offset + 0xa00); }
490READ8_MEMBER( mpt02_state::cart_c00 ) { return m_cart->read_rom(space, offset + 0x800); }
491
449492void studio2_state::machine_start()
450493{
494   if (m_cart->exists())
495   {
496      // these have to be installed only if a cart is present, because they partially overlap the built-in game
497      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0400, 0x07ff, read8_delegate(FUNC(studio2_state::cart_400), this));
498      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0a00, 0x0bff, read8_delegate(FUNC(studio2_state::cart_a00), this));
499      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0e00, 0x0fff, read8_delegate(FUNC(studio2_state::cart_e00), this));
500   }
501
451502   // register for state saving
452503   save_item(NAME(m_keylatch));
453504}
454505
506void mpt02_state::machine_start()
507{
508   if (m_cart->exists())
509   {
510      // these have to be installed only if a cart is present, because they partially overlap the built-in game
511      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0400, 0x07ff, read8_delegate(FUNC(studio2_state::cart_400), this));
512      m_maincpu->space(AS_PROGRAM).install_read_handler(0x0c00, 0x0fff, read8_delegate(FUNC(mpt02_state::cart_c00), this));
513   }
514   
515   // register for state saving
516   save_item(NAME(m_keylatch));
517}
518
455519void studio2_state::machine_reset()
456520{
457521   m_vdc->reset();
r32493r32494
464528
465529DEVICE_IMAGE_LOAD_MEMBER( studio2_state, studio2_cart_load )
466530{
531   UINT32 size;
532   
533   // always alloc 3K, even if range $400-$600 is not read by the system (RAM is present there)
534   m_cart->rom_alloc(0xc00, GENERIC_ROM8_WIDTH, ENDIANNESS_LITTLE);
535   
467536   if (image.software_entry() == NULL)
468537   {
469538      if (!strcmp(image.filetype(), "st2"))
470539      {
471         return DEVICE_IMAGE_LOAD_MEMBER_NAME(st2_cartslot_load)(image);
540         UINT8 header[0x100];
541         UINT8 catalogue[10], title[32], pages[64];
542         UINT8 blocks;
543     
544         if (image.length() <= 0x100)
545         {
546            image.seterror(IMAGE_ERROR_UNSPECIFIED, "Invalid ROM file");
547            return IMAGE_INIT_FAIL;
548         }
549
550         image.fread(&header, 0x100);
551
552         // validate
553         if (strncmp((const char *)header, "RCA2", 4))
554         {
555            image.seterror(IMAGE_ERROR_UNSPECIFIED, "Not an .ST2 file");
556            return IMAGE_INIT_FAIL;
557         }
558
559         blocks = header[4];
560         memcpy(&catalogue, &header[16], 10);
561         memcpy(&title, &header[32], 32);
562         memcpy(&pages, &header[64], 64);
563         
564         /* read ST2 cartridge into memory */
565         for (int block = 0; block < (blocks - 1); block++)
566         {
567            if (pages[block] < 4)
568               logerror("ST2 invalid block %u to %04x\n", block, pages[block] << 8);
569            else
570            {
571               UINT16 offset = (pages[block] << 8) - 0x400;
572               logerror("ST2 Reading block %u to %04x\n", block, offset);
573               image.fread(m_cart->get_rom_base() + offset, 0x100);
574            }
575         }
576
577         logerror("ST2 Catalogue: %s\n", catalogue);
578         logerror("ST2 Title: %s\n", title);
472579      }
473580      else
474581      {
475         UINT8 *ptr = memregion(CDP1802_TAG)->base() + 0x400;
476         size_t size = image.length();
477         image.fread(ptr, size);
582         size = image.length();
583         if (size > 0x400)
584         {
585            image.seterror(IMAGE_ERROR_UNSPECIFIED, "Unsupported cartridge size");
586            return IMAGE_INIT_FAIL;
587         }
588         else
589            image.fread(m_cart->get_rom_base(), size);
478590      }
479591   }
480592   else
481593   {
482      UINT8 *ptr = memregion(CDP1802_TAG)->base();
483
484      size_t size = image.get_software_region_length("rom_400");
485      if (size) memcpy(ptr + 0x400, image.get_software_region("rom_400"), size);
486
487      size = image.get_software_region_length("rom_800");
488      if (size) memcpy(ptr + 0x800, image.get_software_region("rom_800"), size);
489
490      size = image.get_software_region_length("rom_c00");
491      if (size) memcpy(ptr + 0xc00, image.get_software_region("rom_c00"), size);
594      // Studio II carts might map their data at $400-$7ff, $a00-$bff and $e00-$fff
595      // MPT-2 carts might map their data at $400-$7ff and $c00-$fff
596      if (image.get_software_region("rom_400"))
597         memcpy(m_cart->get_rom_base() + 0x000, image.get_software_region("rom_400"), image.get_software_region_length("rom_400"));
598      if (image.get_software_region("rom_a00"))
599         memcpy(m_cart->get_rom_base() + 0x600, image.get_software_region("rom_a00"), image.get_software_region_length("rom_a00"));
600      if (image.get_software_region("rom_c00"))
601         memcpy(m_cart->get_rom_base() + 0x800, image.get_software_region("rom_c00"), image.get_software_region_length("rom_c00"));
602      if (image.get_software_region("rom_e00"))
603         memcpy(m_cart->get_rom_base() + 0xa00, image.get_software_region("rom_e00"), image.get_software_region_length("rom_e00"));
492604   }
493605
494606   return IMAGE_INIT_PASS;
495607}
496608
497DEVICE_IMAGE_LOAD_MEMBER( visicom_state, visicom_cart_load )
498{
499   UINT8 *ptr = memregion(CDP1802_TAG)->base() + 0x800;
500609
501   if (image.software_entry() == NULL)
502   {
503      size_t size = image.length();
504      image.fread(ptr, MAX(size, 0x800));
505   }
506   else
507   {
508      size_t size = image.get_software_region_length("rom");
509      if (size) memcpy(ptr, image.get_software_region("rom"), MAX(size, 0x800));
510   }
511
512   return IMAGE_INIT_PASS;
513}
514
515610/* Machine Drivers */
516611
517612static MACHINE_CONFIG_FRAGMENT( studio2_cartslot )
518   MCFG_CARTSLOT_ADD("cart")
519   MCFG_CARTSLOT_EXTENSION_LIST("st2,bin,rom")
520   MCFG_CARTSLOT_NOT_MANDATORY
521   MCFG_CARTSLOT_LOAD(studio2_state,studio2_cart_load)
522   MCFG_CARTSLOT_INTERFACE("studio2_cart")
613   MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "studio2_cart")
614   MCFG_GENERIC_EXTENSIONS("st2,bin,rom")
615   MCFG_GENERIC_LOAD(studio2_state, studio2_cart_load)
523616
524617   /* software lists */
525618   MCFG_SOFTWARE_LIST_ADD("cart_list", "studio2")
r32493r32494
577670   MCFG_SOUND_ADD("beeper", BEEP, 0)
578671   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
579672
580   MCFG_CARTSLOT_ADD("cart")
581   MCFG_CARTSLOT_EXTENSION_LIST("bin,rom")
582   MCFG_CARTSLOT_NOT_MANDATORY
583   MCFG_CARTSLOT_LOAD(visicom_state, visicom_cart_load)
584   MCFG_CARTSLOT_INTERFACE("visicom_cart")
673   MCFG_GENERIC_CARTSLOT_ADD("cartslot", generic_plain_slot, "visicom_cart")
674   MCFG_GENERIC_EXTENSIONS("bin,rom")
585675
586676   /* software lists */
587677   MCFG_SOFTWARE_LIST_ADD("cart_list", "visicom")
r32493r32494
650740
651741/* Driver Initialization */
652742
653void studio2_state::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
654{
655   switch (id)
656   {
657   case TIMER_SETUP_BEEP:
658      m_beeper->set_state(0);
659      m_beeper->set_frequency(300);
660      break;
661   default:
662      assert_always(FALSE, "Unknown id in studio2_state::device_timer");
663   }
664}
665
666743DRIVER_INIT_MEMBER(studio2_state,studio2)
667744{
668   timer_set(attotime::zero, TIMER_SETUP_BEEP);
745   m_beeper->set_state(0);
746   m_beeper->set_frequency(300);
669747}
670748
671749/* Game Drivers */
trunk/hash/ibmpcjr_cart.xml
r32493r32494
7171      </part>
7272   </software>
7373
74   <software name="demonatk" supported="no">
75      <description>Demon Attack</description>
76      <year>1983</year>
77      <publisher>Imagic</publisher>
78      <part name="cart" interface="ibmpcjr_cart">
79         <dataarea name="rom" size="65536">
80            <rom name="demon01.bin" size="8192" crc="9aa1599b" sha1="0ff6309d8c6fc6163ac08f028d83805b0dcd2a67" offset="0x0000" />
81            <rom size="8192" offset="0x2000" loadflag="reload" />
82            <rom size="8192" offset="0x4000" loadflag="reload" />
83            <rom size="8192" offset="0x6000" loadflag="reload" />
84            <rom name="demon02.bin" size="8192" crc="85c373c3" sha1="a786a43815b72bc20ce95392235ca02d4f0ee3f6" offset="0x8000" />
85            <rom size="8192" offset="0xa000" loadflag="reload" />
86            <rom size="8192" offset="0xc000" loadflag="reload" />
87            <rom size="8192" offset="0xe000" loadflag="reload" />
88         </dataarea>
89      </part>
90   </software>
91
7492   <software name="lotus123">
7593      <description>Lotus 123jr</description>
7694      <year>1984</year>
r32493r32494
89107      </part>
90108   </software>
91109
110   <software name="msurg" supported="no">
111      <description>Microsurgeon</description>
112      <year>1983</year>
113      <publisher>Imagic</publisher>
114      <part name="cart" interface="ibmpcjr_cart">
115         <dataarea name="rom" size="65536">
116            <rom name="msurg01.bin" size="8192" crc="b05cd784" sha1="f354b7ce9471324dab944cc499203e027b88dd85" offset="0x0000" />
117            <rom size="8192" offset="0x2000" loadflag="reload" />
118            <rom size="8192" offset="0x4000" loadflag="reload" />
119            <rom size="8192" offset="0x6000" loadflag="reload" />
120            <rom name="msurg02.bin" size="8192" crc="c541759c" sha1="5add9d325550f2018304931a40f132aa6ba90ef3" offset="0x8000" />
121            <rom size="8192" offset="0xa000" loadflag="reload" />
122            <rom size="8192" offset="0xc000" loadflag="reload" />
123            <rom size="8192" offset="0xe000" loadflag="reload" />
124         </dataarea>
125      </part>
126   </software>
127
92128   <software name="mineshft">
93129      <description>Mine Shaft</description>
94130      <year>1983</year>
trunk/hash/studio2.xml
r32493r32494
193193      <year>1978</year>
194194      <publisher>Hanimex</publisher>
195195      <info name="serial" value="MG-200" />
196      <info name="usage" value="Works only on the MPT-02" />
196197
197198      <part name="cart" interface="studio2_cart">
198199         <dataarea name="rom_400" size="0x400">

Previous 199869 Revisions Next


© 1997-2024 The MAME Team