Previous 15994 Revisions Next

r14819 Wednesday 28th March, 2012 at 17:30:14 UTC by Curt Coder
[C64] Cleaned up cartridge handling, added CMD HD and FD-2000 skeletons. (nw)
[src/mess]mess.mak
[src/mess/formats]cbm_crt.c cbm_crt.h
[src/mess/machine]c64_std.c c64exp.c c64exp.h cbmipt.c cbmipt.h cmdhd.c* cmdhd.h* fd2000.c* fd2000.h* vic10exp.c vic10exp.h vic10std.c vic10std.h vic20exp.c

src/mess/machine/cbmipt.c
r14818r14819
11041104   SLOT_INTERFACE("c1570", C1570)
11051105   SLOT_INTERFACE("c1571", C1571)
11061106   SLOT_INTERFACE("c1581", C1581)
1107   SLOT_INTERFACE("cmdhd", CMD_HD)
1108   SLOT_INTERFACE("fd2000", FD2000)
11071109   SLOT_INTERFACE("interpod", INTERPOD)
11081110   SLOT_INTERFACE("minichief", MINI_CHIEF)
11091111   SLOT_INTERFACE("serialbox", SERIAL_BOX)
src/mess/machine/cbmipt.h
r14818r14819
5858#include "machine/c2040.h"
5959#include "machine/c8280.h"
6060#include "machine/d9060.h"
61#include "machine/cmdhd.h"
62#include "machine/fd2000.h"
6163#include "machine/interpod.h"
6264#include "machine/serialbox.h"
6365#include "machine/softbox.h"
src/mess/machine/vic20exp.c
r14818r14819
2222#define LOG 0
2323
2424
25// slot names for the VIC-20 cartridge types
26const char *CRT_VIC20_SLOT_NAMES[_CRT_VIC20_COUNT] =
27{
28   UNSUPPORTED,
29   "standard",
30   UNSUPPORTED,
31   UNSUPPORTED,
32   UNSUPPORTED
33};
3425
35
36
3726//**************************************************************************
3827//  GLOBAL VARIABLES
3928//**************************************************************************
src/mess/machine/cmdhd.c
r0r14819
1/**********************************************************************
2
3    CMD HD hard drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "cmdhd.h"
11
12
13
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17
18#define M6502_TAG      "m6502"
19#define M6522_1_TAG      "m6522_1"
20#define M6522_2_TAG      "m6522_2"
21#define I8255A_TAG      "i8255a"
22
23
24
25//**************************************************************************
26//  DEVICE DEFINITIONS
27//**************************************************************************
28
29const device_type CMD_HD = &device_creator<cmd_hd_device>;
30
31
32//-------------------------------------------------
33//  ROM( cmd_hd )
34//-------------------------------------------------
35
36ROM_START( cmd_hd )
37   ROM_REGION( 0x8000, M6502_TAG, 0 )
38   ROM_LOAD( "cmd_hd_bootrom_v280.bin", 0x0000, 0x8000, CRC(da68435d) SHA1(defd8bc04a52904b8a3560f11c82126619513a10) )
39ROM_END
40
41
42//-------------------------------------------------
43//  rom_region - device-specific ROM region
44//-------------------------------------------------
45
46const rom_entry *cmd_hd_device::device_rom_region() const
47{
48   return ROM_NAME( cmd_hd );
49}
50
51
52//-------------------------------------------------
53//  ADDRESS_MAP( cmd_hd_mem )
54//-------------------------------------------------
55
56static ADDRESS_MAP_START( cmd_hd_mem, AS_PROGRAM, 8, cmd_hd_device )
57   AM_RANGE(0x0000, 0x7fff) AM_RAM
58   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION(M6502_TAG, 0)
59   //AM_RANGE() AM_DEVREADWRITE(M6522_1_TAG, via6522_device, read, write)
60   //AM_RANGE() AM_DEVREADWRITE(M6522_2_TAG, via6522_device, read, write)
61ADDRESS_MAP_END
62
63
64//-------------------------------------------------
65//  via6522_interface via1_intf
66//-------------------------------------------------
67
68static const via6522_interface via1_intf =
69{
70   DEVCB_NULL,
71   DEVCB_NULL,
72   DEVCB_NULL,
73   DEVCB_NULL,
74   DEVCB_NULL,
75   DEVCB_NULL,
76
77   DEVCB_NULL,
78   DEVCB_NULL,
79   DEVCB_NULL,
80   DEVCB_NULL,
81   DEVCB_NULL,
82   DEVCB_NULL,
83
84   DEVCB_NULL
85};
86
87
88//-------------------------------------------------
89//  via6522_interface via2_intf
90//-------------------------------------------------
91
92static const via6522_interface via2_intf =
93{
94   DEVCB_NULL,
95   DEVCB_NULL,
96   DEVCB_NULL,
97   DEVCB_NULL,
98   DEVCB_NULL,
99   DEVCB_NULL,
100
101   DEVCB_NULL,
102   DEVCB_NULL,
103   DEVCB_NULL,
104   DEVCB_NULL,
105   DEVCB_NULL,
106   DEVCB_NULL,
107
108   DEVCB_NULL
109};
110
111
112//-------------------------------------------------
113//  I8255A_INTERFACE( ppi_intf )
114//-------------------------------------------------
115
116static I8255A_INTERFACE( ppi_intf )
117{
118   DEVCB_NULL,
119   DEVCB_NULL,
120   DEVCB_NULL,
121   DEVCB_NULL,
122   DEVCB_NULL,
123   DEVCB_NULL
124};
125
126
127//-------------------------------------------------
128//  MACHINE_DRIVER( cmd_hd )
129//-------------------------------------------------
130
131static MACHINE_CONFIG_FRAGMENT( cmd_hd )
132   MCFG_CPU_ADD(M6502_TAG, M6502, 2000000)
133   MCFG_CPU_PROGRAM_MAP(cmd_hd_mem)
134
135   MCFG_VIA6522_ADD(M6522_1_TAG, 2000000, via1_intf)
136   MCFG_VIA6522_ADD(M6522_2_TAG, 2000000, via2_intf)
137   MCFG_I8255A_ADD(I8255A_TAG, ppi_intf)
138
139   MCFG_HARDDISK_ADD("harddisk0")
140MACHINE_CONFIG_END
141
142
143//-------------------------------------------------
144//  machine_config_additions - device-specific
145//  machine configurations
146//-------------------------------------------------
147
148machine_config_constructor cmd_hd_device::device_mconfig_additions() const
149{
150   return MACHINE_CONFIG_NAME( cmd_hd );
151}
152
153
154
155//**************************************************************************
156//  LIVE DEVICE
157//**************************************************************************
158
159//-------------------------------------------------
160//  cmd_hd_device - constructor
161//-------------------------------------------------
162
163cmd_hd_device::cmd_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
164    : device_t(mconfig, CMD_HD, "HD", tag, owner, clock),
165     device_cbm_iec_interface(mconfig, *this),
166     m_maincpu(*this, M6502_TAG)
167{
168}
169
170
171//-------------------------------------------------
172//  device_start - device-specific startup
173//-------------------------------------------------
174
175void cmd_hd_device::device_start()
176{
177}
178
179
180//-------------------------------------------------
181//  device_reset - device-specific reset
182//-------------------------------------------------
183
184void cmd_hd_device::device_reset()
185{
186}
187
188
189//-------------------------------------------------
190//  cbm_iec_srq -
191//-------------------------------------------------
192
193void cmd_hd_device::cbm_iec_srq(int state)
194{
195}
196
197
198//-------------------------------------------------
199//  cbm_iec_atn -
200//-------------------------------------------------
201
202void cmd_hd_device::cbm_iec_atn(int state)
203{
204}
205
206
207//-------------------------------------------------
208//  cbm_iec_data -
209//-------------------------------------------------
210
211void cmd_hd_device::cbm_iec_data(int state)
212{
213}
214
215
216//-------------------------------------------------
217//  cbm_iec_reset -
218//-------------------------------------------------
219
220void cmd_hd_device::cbm_iec_reset(int state)
221{
222   if (!state)
223   {
224      device_reset();
225   }
226}
src/mess/machine/cmdhd.h
r0r14819
1/**********************************************************************
2
3    CMD HD disk drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __CMD_HD__
13#define __CMD_HD__
14
15#define ADDRESS_MAP_MODERN
16
17#include "emu.h"
18#include "cpu/m6502/m6502.h"
19#include "imagedev/harddriv.h"
20#include "machine/6522via.h"
21#include "machine/cbmiec.h"
22#include "machine/i8255.h"
23
24
25
26//**************************************************************************
27//  MACROS / CONSTANTS
28//**************************************************************************
29
30#define CMD_HD_TAG         "cmdhd"
31
32
33
34//**************************************************************************
35//  TYPE DEFINITIONS
36//**************************************************************************
37
38// ======================> cmd_hd_device
39
40class cmd_hd_device :  public device_t,
41                  public device_cbm_iec_interface
42{
43
44public:
45    // construction/destruction
46    cmd_hd_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
47
48   // optional information overrides
49   virtual const rom_entry *device_rom_region() const;
50   virtual machine_config_constructor device_mconfig_additions() const;
51
52protected:
53    // device-level overrides
54    virtual void device_start();
55   virtual void device_reset();
56    virtual void device_config_complete() { m_shortname = "cmdhd"; }
57
58   // device_cbm_iec_interface overrides
59   void cbm_iec_srq(int state);
60   void cbm_iec_atn(int state);
61   void cbm_iec_data(int state);
62   void cbm_iec_reset(int state);
63
64   required_device<cpu_device> m_maincpu;
65};
66
67
68// device type definition
69extern const device_type CMD_HD;
70
71
72
73#endif
src/mess/machine/fd2000.c
r0r14819
1/**********************************************************************
2
3    CMD FD2000 disk drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#include "fd2000.h"
11
12
13
14//**************************************************************************
15//  MACROS / CONSTANTS
16//**************************************************************************
17
18#define M6502_TAG      "m6502"
19#define M6522_TAG      "m6522"
20#define DP8473_TAG      "dp8473"
21#define PC8477AV1_TAG   "pc8477av1"
22
23
24
25//**************************************************************************
26//  DEVICE DEFINITIONS
27//**************************************************************************
28
29const device_type FD2000 = &device_creator<fd2000_device>;
30
31
32//-------------------------------------------------
33//  ROM( fd2000 )
34//-------------------------------------------------
35
36ROM_START( fd2000 )
37   ROM_REGION( 0x8000, M6502_TAG, 0 )
38   ROM_LOAD( "cmd_fd-2000_dos_v1.40_cs_33cc6f.bin", 0x0000, 0x8000, CRC(4e6ca15c) SHA1(0c61ba58269baf2b8aadf3bbc4648c7a5a6d2128) )
39ROM_END
40
41
42//-------------------------------------------------
43//  rom_region - device-specific ROM region
44//-------------------------------------------------
45
46const rom_entry *fd2000_device::device_rom_region() const
47{
48   return ROM_NAME( fd2000 );
49}
50
51
52//-------------------------------------------------
53//  ADDRESS_MAP( fd2000_mem )
54//-------------------------------------------------
55
56static ADDRESS_MAP_START( fd2000_mem, AS_PROGRAM, 8, fd2000_device )
57   AM_RANGE(0x0000, 0x7fff) AM_RAM
58   AM_RANGE(0x8000, 0xffff) AM_ROM AM_REGION(M6502_TAG, 0)
59   //AM_RANGE() AM_DEVREADWRITE(M6522_TAG, via6522_device, read, write)
60   //AM_RANGE() AM_DEVREAD_LEGACY(DP8473_TAG, upd765_status_r)
61   //AM_RANGE() AM_DEVREADWRITE_LEGACY(DP8473_TAG, upd765_data_r, upd765_data_w)
62ADDRESS_MAP_END
63
64
65//-------------------------------------------------
66//  via6522_interface via1_intf
67//-------------------------------------------------
68
69static const via6522_interface via_intf =
70{
71   DEVCB_NULL,
72   DEVCB_NULL,
73   DEVCB_NULL,
74   DEVCB_NULL,
75   DEVCB_NULL,
76   DEVCB_NULL,
77
78   DEVCB_NULL,
79   DEVCB_NULL,
80   DEVCB_NULL,
81   DEVCB_NULL,
82   DEVCB_NULL,
83   DEVCB_NULL,
84
85   DEVCB_NULL
86};
87
88
89//-------------------------------------------------
90//  LEGACY_FLOPPY_OPTIONS( fd2000 )
91//-------------------------------------------------
92
93static LEGACY_FLOPPY_OPTIONS_START( fd2000 )
94   LEGACY_FLOPPY_OPTION( fd2000, "d81", "Commodore 1581 Disk Image", d81_dsk_identify, d81_dsk_construct, NULL, NULL )
95   //LEGACY_FLOPPY_OPTION( fd2000, "d2m", "CMD FD-2000 Disk Image", d2m_dsk_identify, d2m_dsk_construct, NULL, NULL )
96LEGACY_FLOPPY_OPTIONS_END
97
98
99//-------------------------------------------------
100//  floppy_interface fd2000_floppy_interface
101//-------------------------------------------------
102
103static const floppy_interface fd2000_floppy_interface =
104{
105   DEVCB_NULL,
106   DEVCB_NULL,
107   DEVCB_NULL,
108   DEVCB_NULL,
109   DEVCB_NULL,
110   FLOPPY_STANDARD_3_5_DSDD,
111   LEGACY_FLOPPY_OPTIONS_NAME(fd2000),
112   "floppy_3_5",
113   NULL
114};
115
116
117//-------------------------------------------------
118//  upd765_interface fdc_intf
119//-------------------------------------------------
120
121static const struct upd765_interface fdc_intf =
122{
123   DEVCB_NULL,
124   DEVCB_NULL,
125   NULL,
126   UPD765_RDY_PIN_CONNECTED,
127   { FLOPPY_0, NULL, NULL, NULL }
128};
129
130
131//-------------------------------------------------
132//  MACHINE_DRIVER( fd2000 )
133//-------------------------------------------------
134
135static MACHINE_CONFIG_FRAGMENT( fd2000 )
136   MCFG_CPU_ADD(M6502_TAG, M65C02, 2000000)
137   MCFG_CPU_PROGRAM_MAP(fd2000_mem)
138
139   MCFG_VIA6522_ADD(M6522_TAG, 2000000, via_intf)
140   MCFG_UPD765A_ADD(DP8473_TAG, fdc_intf)
141
142   MCFG_LEGACY_FLOPPY_DRIVE_ADD(FLOPPY_0, fd2000_floppy_interface)
143MACHINE_CONFIG_END
144
145
146//-------------------------------------------------
147//  machine_config_additions - device-specific
148//  machine configurations
149//-------------------------------------------------
150
151machine_config_constructor fd2000_device::device_mconfig_additions() const
152{
153   return MACHINE_CONFIG_NAME( fd2000 );
154}
155
156
157
158//**************************************************************************
159//  LIVE DEVICE
160//**************************************************************************
161
162//-------------------------------------------------
163//  fd2000_device - constructor
164//-------------------------------------------------
165
166fd2000_device::fd2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
167    : device_t(mconfig, FD2000, "FD-2000", tag, owner, clock),
168     device_cbm_iec_interface(mconfig, *this),
169     m_maincpu(*this, M6502_TAG)
170{
171}
172
173
174//-------------------------------------------------
175//  device_start - device-specific startup
176//-------------------------------------------------
177
178void fd2000_device::device_start()
179{
180}
181
182
183//-------------------------------------------------
184//  device_reset - device-specific reset
185//-------------------------------------------------
186
187void fd2000_device::device_reset()
188{
189}
190
191
192//-------------------------------------------------
193//  cbm_iec_srq -
194//-------------------------------------------------
195
196void fd2000_device::cbm_iec_srq(int state)
197{
198}
199
200
201//-------------------------------------------------
202//  cbm_iec_atn -
203//-------------------------------------------------
204
205void fd2000_device::cbm_iec_atn(int state)
206{
207}
208
209
210//-------------------------------------------------
211//  cbm_iec_data -
212//-------------------------------------------------
213
214void fd2000_device::cbm_iec_data(int state)
215{
216}
217
218
219//-------------------------------------------------
220//  cbm_iec_reset -
221//-------------------------------------------------
222
223void fd2000_device::cbm_iec_reset(int state)
224{
225   if (!state)
226   {
227      device_reset();
228   }
229}
src/mess/machine/fd2000.h
r0r14819
1/**********************************************************************
2
3    CMD FD2000 disk drive emulation
4
5    Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************/
9
10#pragma once
11
12#ifndef __FD2000__
13#define __FD2000__
14
15#define ADDRESS_MAP_MODERN
16
17#include "emu.h"
18#include "cpu/m6502/m6502.h"
19#include "imagedev/flopdrv.h"
20#include "formats/d81_dsk.h"
21#include "machine/6522via.h"
22#include "machine/cbmiec.h"
23#include "machine/upd765.h"
24
25
26
27//**************************************************************************
28//  MACROS / CONSTANTS
29//**************************************************************************
30
31#define FD2000_TAG         "fd2000"
32
33
34
35//**************************************************************************
36//  TYPE DEFINITIONS
37//**************************************************************************
38
39// ======================> fd2000_device
40
41class fd2000_device :  public device_t,
42                     public device_cbm_iec_interface
43{
44
45public:
46    // construction/destruction
47    fd2000_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
48
49   // optional information overrides
50   virtual const rom_entry *device_rom_region() const;
51   virtual machine_config_constructor device_mconfig_additions() const;
52
53protected:
54    // device-level overrides
55    virtual void device_start();
56   virtual void device_reset();
57    virtual void device_config_complete() { m_shortname = "fd2000"; }
58
59   // device_cbm_iec_interface overrides
60   void cbm_iec_srq(int state);
61   void cbm_iec_atn(int state);
62   void cbm_iec_data(int state);
63   void cbm_iec_reset(int state);
64
65   required_device<cpu_device> m_maincpu;
66};
67
68
69// device type definition
70extern const device_type FD2000;
71
72
73
74#endif
src/mess/machine/vic10std.c
r14818r14819
2929 
3030vic10_standard_cartridge_device::vic10_standard_cartridge_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
3131    : device_t(mconfig, VIC10_STD, "VIC-10 Standard Cartridge", tag, owner, clock),
32     device_vic10_expansion_card_interface(mconfig, *this),
33     m_exram(NULL),
34     m_lorom(NULL),
35     m_uprom(NULL)
32     device_vic10_expansion_card_interface(mconfig, *this)
3633{
3734}
3835 
r14818r14819
4744 
4845 
4946//-------------------------------------------------
50//  vic10_exram_pointer - get expanded RAM pointer
51//-------------------------------------------------
52 
53UINT8* vic10_standard_cartridge_device::vic10_exram_pointer()
54{
55   if (m_exram == NULL)
56   {
57      m_exram = auto_alloc_array(machine(), UINT8, 0x800);
58   }
59 
60   return m_exram;
61}
62 
63 
64//-------------------------------------------------
6547//  vic10_exram_r - expanded RAM read
6648//-------------------------------------------------
6749 
r14818r14819
9274 
9375 
9476//-------------------------------------------------
95//  vic10_lorom_pointer - get lower ROM pointer
96//-------------------------------------------------
97 
98UINT8* vic10_standard_cartridge_device::vic10_lorom_pointer()
99{
100   if (m_lorom == NULL)
101   {
102      m_lorom = auto_alloc_array(machine(), UINT8, 0x2000);
103   }
104 
105   return m_lorom;
106}
107 
108 
109//-------------------------------------------------
11077//  vic10_lorom_r - lower ROM read
11178//-------------------------------------------------
11279 
r14818r14819
12491 
12592 
12693//-------------------------------------------------
127//  vic10_uprom_pointer - get upper ROM pointer
128//-------------------------------------------------
129 
130UINT8* vic10_standard_cartridge_device::vic10_uprom_pointer()
131{
132   if (m_uprom == NULL)
133   {
134      m_uprom = auto_alloc_array(machine(), UINT8, 0x2000);
135   }
136 
137   return m_uprom;
138}
139 
140 
141//-------------------------------------------------
14294//  vic10_uprom_r - upper ROM read
14395//-------------------------------------------------
14496 
src/mess/machine/vic10std.h
r14818r14819
4242   virtual void vic10_exram_w(address_space &space, offs_t offset, UINT8 data);
4343   virtual UINT8 vic10_lorom_r(address_space &space, offs_t offset);
4444   virtual UINT8 vic10_uprom_r(address_space &space, offs_t offset);
45   virtual UINT8* vic10_lorom_pointer();
46   virtual UINT8* vic10_uprom_pointer();
47   virtual UINT8* vic10_exram_pointer();
48 
49private:
50   UINT8 *m_exram;
51   UINT8 *m_lorom;
52   UINT8 *m_uprom;
5345};
5446 
5547 
src/mess/machine/c64_std.c
r14818r14819
5151{
5252   UINT8 data = 0;
5353
54   if (!roml)
54   if (!roml && m_roml_mask)
5555   {
5656      data = m_roml[offset & 0x1fff];
5757   }
src/mess/machine/c64exp.c
r14818r14819
77
88**********************************************************************/
99
10#include "emu.h"
1110#include "machine/c64exp.h"
12#include "formats/cbm_crt.h"
13#include "formats/imageutl.h"
1411
1512
1613
r14818r14819
2118#define LOG 0
2219
2320
24// slot names for the C64 cartridge types
25const char *CRT_C64_SLOT_NAMES[_CRT_C64_COUNT] =
26{
27   "standard",
28   UNSUPPORTED,
29   UNSUPPORTED,
30   UNSUPPORTED,
31   "simons_basic",
32   "ocean",
33   UNSUPPORTED,
34   "fun_play",
35   "super_games",
36   UNSUPPORTED,
37   "epyxfastload",
38   "westermann",
39   "rex",
40   UNSUPPORTED,
41   "magic_formel",
42   "system3",
43   "warp_speed",
44   "dinamic",
45   "zaxxon",
46   "magic desk",
47   UNSUPPORTED,
48   "comal80",
49   "struct_basic",
50   "ross",
51   "ep64",
52   "ep7x8",
53   "dela_ep256",
54   "rex_ep256",
55   "mikroasm",
56   UNSUPPORTED,
57   UNSUPPORTED,
58   "stardos",
59   UNSUPPORTED,
60   UNSUPPORTED,
61   UNSUPPORTED,
62   UNSUPPORTED,
63   UNSUPPORTED,
64   UNSUPPORTED,
65   UNSUPPORTED,
66   UNSUPPORTED,
67   UNSUPPORTED,
68   "ieee488",
69   UNSUPPORTED,
70   UNSUPPORTED,
71   "exos",
72   UNSUPPORTED,
73   UNSUPPORTED,
74   UNSUPPORTED,
75   "super_explode",
76   UNSUPPORTED,
77   UNSUPPORTED,
78   "mach5",
79   UNSUPPORTED,
80   "pagefox",
81   UNSUPPORTED,
82   "silverrock"
83};
8421
85
86
8722//**************************************************************************
8823//  DEVICE DEFINITIONS
8924//**************************************************************************
r14818r14819
286221         }
287222         else if (!mame_stricmp(filetype(), "crt"))
288223         {
289            // read the header
290            cbm_crt_header header;
291            fread(&header, CRT_HEADER_LENGTH);
292
293            if (memcmp(header.signature, CRT_SIGNATURE, 16) != 0)
294               return IMAGE_INIT_FAIL;
295
296            UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
297
298            if (LOG)
299            {
300               logerror("Name: %s\n", header.name);
301               logerror("Hardware: %04x\n", hardware);
302               logerror("Slot device: %s\n", CRT_C64_SLOT_NAMES[hardware]);
303               logerror("EXROM: %u\n", header.exrom);
304               logerror("GAME: %u\n", header.game);
305            }
306
307            // determine ROM region lengths
308224            size_t roml_size = 0;
309225            size_t romh_size = 0;
226            int exrom = 1;
227            int game = 1;
310228
311            while (!image_feof())
229            if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game))
312230            {
313               cbm_crt_chip chip;
314               fread(&chip, CRT_CHIP_LENGTH);
231               UINT8 *roml = NULL;
232               UINT8 *romh = NULL;
315233
316               UINT16 address = pick_integer_be(chip.start_address, 0, 2);
317               UINT16 size = pick_integer_be(chip.image_size, 0, 2);
318               UINT16 type = pick_integer_be(chip.chip_type, 0, 2);
234               if (roml_size) roml = m_cart->c64_roml_pointer(machine(), roml_size);
235               if (romh_size) romh = m_cart->c64_romh_pointer(machine(), romh_size);
319236
320               if (LOG)
321               {
322                  logerror("CHIP Address: %04x\n", address);
323                  logerror("CHIP Size: %04x\n", size);
324                  logerror("CHIP Type: %04x\n", type);
325               }
326
327               switch (address)
328               {
329               case 0x8000: roml_size += size; break;
330               case 0xa000: romh_size += size; break;
331               case 0xe000: romh_size += size; break;
332               default: logerror("Invalid CHIP loading address!\n"); break;
333               }
334
335               fseek(size, SEEK_CUR);
237               cbm_crt_read_data(m_file, roml, romh);
336238            }
337239
338            // allocate cartridge memory
339            UINT8 *roml = NULL;
340            UINT8 *romh = NULL;
341
342            if (roml_size) roml = m_cart->c64_roml_pointer(machine(), roml_size);
343            if (romh_size) romh = m_cart->c64_romh_pointer(machine(), romh_size);
344
345            // read the data
346            offs_t roml_offset = 0;
347            offs_t romh_offset = 0;
348
349            fseek(CRT_HEADER_LENGTH, SEEK_SET);
350
351            while (!image_feof())
352            {
353               cbm_crt_chip chip;
354               fread(&chip, CRT_CHIP_LENGTH);
355
356               UINT16 address = pick_integer_be(chip.start_address, 0, 2);
357               UINT16 size = pick_integer_be(chip.image_size, 0, 2);
358
359               switch (address)
360               {
361               case 0x8000: fread(roml + roml_offset, size); roml_offset += size; break;
362               case 0xa000: fread(romh + romh_offset, size); romh_offset += size; break;
363               case 0xe000: fread(romh + romh_offset, size); romh_offset += size; break;
364               }
365            }
366
367            m_cart->c64_exrom_w(header.exrom);
368            m_cart->c64_game_w(header.game);
240            m_cart->c64_exrom_w(exrom);
241            m_cart->c64_game_w(game);
369242         }
370243      }
371244      else
372245      {
373         size = get_software_region_length("roml");
374         if (size) memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
246         size = get_software_region_length("uprom");
247     
248         if (size)
249         {
250            // Ultimax (VIC-10) cartridge
251            memcpy(m_cart->c64_romh_pointer(machine(), size), get_software_region("uprom"), size);
375252
376         size = get_software_region_length("romh");
377         if (size) memcpy(m_cart->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
253            size = get_software_region_length("lorom");
254            if (size) memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("lorom"), size);
378255
379         size = get_software_region_length("ram");
380         if (size) memset(m_cart->c64_ram_pointer(machine(), size), 0, size);
256            m_cart->c64_exrom_w(1);
257            m_cart->c64_game_w(0);
258         }
259         else
260         {
261            // Commodore 64/128 cartridge
262            size = get_software_region_length("roml");
263            if (size) memcpy(m_cart->c64_roml_pointer(machine(), size), get_software_region("roml"), size);
381264
382         m_cart->c64_exrom_w(atol(get_feature("exrom")));
383         m_cart->c64_game_w(atol(get_feature("game")));
265            size = get_software_region_length("romh");
266            if (size) memcpy(m_cart->c64_romh_pointer(machine(), size), get_software_region("romh"), size);
267
268            size = get_software_region_length("ram");
269            if (size) memset(m_cart->c64_ram_pointer(machine(), size), 0, size);
270
271            m_cart->c64_exrom_w(atol(get_feature("exrom")));
272            m_cart->c64_game_w(atol(get_feature("game")));
273         }
384274      }
385275   }
386276
r14818r14819
410300   {
411301      if (!mame_stricmp(filetype(), "crt"))
412302      {
413         // read the header
414         cbm_crt_header header;
415         fread(&header, CRT_HEADER_LENGTH);
416
417         if (memcmp(header.signature, CRT_SIGNATURE, 16) == 0)
418         {
419            UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
420            return CRT_C64_SLOT_NAMES[hardware];
421         }
303         return cbm_crt_get_card(m_file);
422304      }
305
423306      clear();
424307   }
308
425309   return software_get_default_slot(config, options, this, "standard");
426310}
427311
src/mess/machine/c64exp.h
r14818r14819
3838#define __C64_EXPANSION_SLOT__
3939
4040#include "emu.h"
41#include "formats/cbm_crt.h"
4142
4243
4344
src/mess/machine/vic10exp.c
r14818r14819
1010#include "emu.h"
1111#include "emuopts.h"
1212#include "machine/vic10exp.h"
13#include "formats/cbm_crt.h"
14#include "formats/imageutl.h"
1315 
1416 
17 
1518//**************************************************************************
1619//  GLOBAL VARIABLES
1720//**************************************************************************
r14818r14819
1922const device_type VIC10_EXPANSION_SLOT = &device_creator<vic10_expansion_slot_device>;
2023 
2124 
25 
2226//**************************************************************************
2327//  DEVICE VIC10_EXPANSION CARD INTERFACE
2428//**************************************************************************
r14818r14819
2832//-------------------------------------------------
2933 
3034device_vic10_expansion_card_interface::device_vic10_expansion_card_interface(const machine_config &mconfig, device_t &device)
31   : device_slot_card_interface(mconfig,device)
35   : device_slot_card_interface(mconfig,device),
36     m_exram(NULL),
37     m_lorom(NULL),
38     m_uprom(NULL)
3239{
3340   m_slot = dynamic_cast<vic10_expansion_slot_device *>(device.owner());
3441}
r14818r14819
4451 
4552 
4653 
54//-------------------------------------------------
55//  vic10_lorom_pointer - get lower ROM pointer
56//-------------------------------------------------
57 
58UINT8* device_vic10_expansion_card_interface::vic10_lorom_pointer(running_machine &machine, size_t size)
59{
60   if (m_lorom == NULL)
61   {
62      m_lorom = auto_alloc_array(machine, UINT8, size);
63   }
64 
65   return m_lorom;
66}
67 
68 
69//-------------------------------------------------
70//  vic10_uprom_pointer - get upper ROM pointer
71//-------------------------------------------------
72 
73UINT8* device_vic10_expansion_card_interface::vic10_uprom_pointer(running_machine &machine, size_t size)
74{
75   if (m_uprom == NULL)
76   {
77      m_uprom = auto_alloc_array(machine, UINT8, size);
78   }
79 
80   return m_uprom;
81}
82 
83 
84//-------------------------------------------------
85//  vic10_exram_pointer - get expanded RAM pointer
86//-------------------------------------------------
87 
88UINT8* device_vic10_expansion_card_interface::vic10_exram_pointer(running_machine &machine, size_t size)
89{
90   if (m_exram == NULL)
91   {
92      m_exram = auto_alloc_array(machine, UINT8, size);
93   }
94 
95   return m_exram;
96}
97 
98 
99 
47100//**************************************************************************
48101//  LIVE DEVICE
49102//**************************************************************************
r14818r14819
130183 
131184         if (!mame_stricmp(filetype(), "80"))
132185         {
133            fread(m_cart->vic10_lorom_pointer(), 0x2000);
186            fread(m_cart->vic10_lorom_pointer(machine(), 0x2000), 0x2000);
134187 
135188            if (size == 0x4000)
136189            {
137               fread(m_cart->vic10_uprom_pointer(), 0x2000);
190               fread(m_cart->vic10_uprom_pointer(machine(), 0x2000), 0x2000);
138191            }
139192         }
140         else if (!mame_stricmp(filetype(), "e0")) fread(m_cart->vic10_uprom_pointer(), size);
193         else if (!mame_stricmp(filetype(), "e0")) fread(m_cart->vic10_uprom_pointer(machine(), size), size);
194         else if (!mame_stricmp(filetype(), "crt"))
195         {
196            size_t roml_size = 0;
197            size_t romh_size = 0;
198            int exrom = 1;
199            int game = 1;
200 
201            if (cbm_crt_read_header(m_file, &roml_size, &romh_size, &exrom, &game))
202            {
203               UINT8 *roml = NULL;
204               UINT8 *romh = NULL;
205 
206               if (roml_size) roml = m_cart->vic10_lorom_pointer(machine(), roml_size);
207               if (romh_size) romh = m_cart->vic10_uprom_pointer(machine(), romh_size);
208 
209               cbm_crt_read_data(m_file, roml, romh);
210            }
211         }
141212      }
142213      else
143214      {
144215         size = get_software_region_length("lorom");
145         if (size) memcpy(m_cart->vic10_lorom_pointer(), get_software_region("lorom"), size);
216         if (size) memcpy(m_cart->vic10_lorom_pointer(machine(), size), get_software_region("lorom"), size);
146217 
147218         size = get_software_region_length("uprom");
148         if (size) memcpy(m_cart->vic10_uprom_pointer(), get_software_region("uprom"), size);
219         if (size) memcpy(m_cart->vic10_uprom_pointer(machine(), size), get_software_region("uprom"), size);
149220 
150221         size = get_software_region_length("exram");
151         if (size) m_cart->vic10_exram_pointer();
222         if (size) m_cart->vic10_exram_pointer(machine(), size);
152223      }
153224   }
154225 
r14818r14819
174245 
175246const char * vic10_expansion_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
176247{
248   if (open_image_file(options))
249   {
250      if (!mame_stricmp(filetype(), "crt"))
251      {
252         return cbm_crt_get_card(m_file);
253      }
254 
255      clear();
256   }
257   
177258   return software_get_default_slot(config, options, this, "standard");
178259}
179260 
src/mess/machine/vic10exp.h
r14818r14819
3838#define __VIC10_EXPANSION_SLOT__
3939 
4040#include "emu.h"
41#include "formats/cbm_crt.h"
4142 
4243 
4344 
r14818r14819
153154   virtual ~device_vic10_expansion_card_interface();
154155 
155156   // RAM
156   virtual UINT8* vic10_exram_pointer() { return NULL; }
157   virtual UINT8* vic10_exram_pointer(running_machine &machine, size_t size);
157158   virtual UINT8 vic10_exram_r(address_space &space, offs_t offset) { return 0; };
158159   virtual void vic10_exram_w(address_space &space, offs_t offset, UINT8 data) { };
159160 
160161   // ROM
161   virtual UINT8* vic10_lorom_pointer() { return NULL; }
162   virtual UINT8* vic10_lorom_pointer(running_machine &machine, size_t size);
162163   virtual UINT8 vic10_lorom_r(address_space &space, offs_t offset) { return 0; };
163164   virtual void vic10_lorom_w(address_space &space, offs_t offset, UINT8 data) { };
164165 
165   virtual UINT8* vic10_uprom_pointer() { return NULL; }
166   virtual UINT8* vic10_uprom_pointer(running_machine &machine, size_t size);
166167   virtual UINT8 vic10_uprom_r(address_space &space, offs_t offset) { return 0; };
167168   virtual void vic10_uprom_w(address_space &space, offs_t offset, UINT8 data) { };
168169 
r14818r14819
177178 
178179protected:
179180   vic10_expansion_slot_device *m_slot;
181 
182   UINT8 *m_exram;
183   UINT8 *m_lorom;
184   UINT8 *m_uprom;
180185};
181186 
182187 
src/mess/formats/cbm_crt.c
r14818r14819
77*********************************************************************/
88 
99#include "formats/cbm_crt.h"
10 
11 
12 
13//**************************************************************************
14//  MACROS/CONSTANTS
15//**************************************************************************
16 
17#define LOG 0
18 
19 
20// slot names for the C64 cartridge types
21static const char * CRT_C64_SLOT_NAMES[_CRT_C64_COUNT] =
22{
23   "standard",
24   UNSUPPORTED,
25   UNSUPPORTED,
26   UNSUPPORTED,
27   "simons_basic",
28   "ocean",
29   UNSUPPORTED,
30   "fun_play",
31   "super_games",
32   UNSUPPORTED,
33   "epyxfastload",
34   "westermann",
35   "rex",
36   UNSUPPORTED,
37   "magic_formel",
38   "system3",
39   "warp_speed",
40   "dinamic",
41   "zaxxon",
42   "magic_desk",
43   UNSUPPORTED,
44   "comal80",
45   "struct_basic",
46   "ross",
47   "ep64",
48   "ep7x8",
49   "dela_ep256",
50   "rex_ep256",
51   "mikroasm",
52   UNSUPPORTED,
53   UNSUPPORTED,
54   "stardos",
55   UNSUPPORTED,
56   UNSUPPORTED,
57   UNSUPPORTED,
58   UNSUPPORTED,
59   UNSUPPORTED,
60   UNSUPPORTED,
61   UNSUPPORTED,
62   UNSUPPORTED,
63   UNSUPPORTED,
64   "ieee488",
65   UNSUPPORTED,
66   UNSUPPORTED,
67   "exos",
68   UNSUPPORTED,
69   UNSUPPORTED,
70   UNSUPPORTED,
71   "super_explode",
72   UNSUPPORTED,
73   UNSUPPORTED,
74   "mach5",
75   UNSUPPORTED,
76   "pagefox",
77   UNSUPPORTED,
78   "silverrock"
79};
80 
81 
82 
83//**************************************************************************
84//  IMPLEMENTATION
85//**************************************************************************
86 
87//-------------------------------------------------
88//  cbm_crt_get_card - get slot interface card
89//-------------------------------------------------
90 
91const char * cbm_crt_get_card(core_file *file)
92{
93   // read the header
94   cbm_crt_header header;
95   core_fread(file, &header, CRT_HEADER_LENGTH);
96 
97   if (memcmp(header.signature, CRT_SIGNATURE, 16) == 0)
98   {
99      UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
100 
101      return CRT_C64_SLOT_NAMES[hardware];
102   }
103 
104   return NULL;
105}
106 
107 
108//-------------------------------------------------
109//  cbm_crt_read_header - read cartridge header
110//-------------------------------------------------
111 
112bool cbm_crt_read_header(core_file* file, size_t *roml_size, size_t *romh_size, int *exrom, int *game)
113{
114   // read the header
115   cbm_crt_header header;
116   core_fread(file, &header, CRT_HEADER_LENGTH);
117 
118   if (memcmp(header.signature, CRT_SIGNATURE, 16) != 0)
119      return false;
120 
121   UINT16 hardware = pick_integer_be(header.hardware, 0, 2);
122   *exrom = header.exrom;
123   *game = header.game;
124 
125   if (LOG)
126   {
127      logerror("Name: %s\n", header.name);
128      logerror("Hardware: %04x\n", hardware);
129      logerror("Slot device: %s\n", CRT_C64_SLOT_NAMES[hardware]);
130      logerror("EXROM: %u\n", header.exrom);
131      logerror("GAME: %u\n", header.game);
132   }
133 
134   // determine ROM region lengths
135   while (!core_feof(file))
136   {
137      cbm_crt_chip chip;
138      core_fread(file, &chip, CRT_CHIP_LENGTH);
139 
140      UINT16 address = pick_integer_be(chip.start_address, 0, 2);
141      UINT16 size = pick_integer_be(chip.image_size, 0, 2);
142      UINT16 type = pick_integer_be(chip.chip_type, 0, 2);
143 
144      if (LOG)
145      {
146         logerror("CHIP Address: %04x\n", address);
147         logerror("CHIP Size: %04x\n", size);
148         logerror("CHIP Type: %04x\n", type);
149      }
150 
151      switch (address)
152      {
153      case 0x8000: *roml_size += size; break;
154      case 0xa000: *romh_size += size; break;
155      case 0xe000: *romh_size += size; break;
156      default: logerror("Invalid CHIP loading address!\n"); break;
157      }
158 
159      core_fseek(file, size, SEEK_CUR);
160   }
161 
162   return true;
163}
164 
165 
166//-------------------------------------------------
167//  cbm_crt_read_data - read cartridge data
168//-------------------------------------------------
169 
170bool cbm_crt_read_data(core_file* file, UINT8 *roml, UINT8 *romh)
171{
172   offs_t roml_offset = 0;
173   offs_t romh_offset = 0;
174 
175   core_fseek(file, CRT_HEADER_LENGTH, SEEK_SET);
176 
177   while (!core_feof(file))
178   {
179      cbm_crt_chip chip;
180      core_fread(file, &chip, CRT_CHIP_LENGTH);
181 
182      UINT16 address = pick_integer_be(chip.start_address, 0, 2);
183      UINT16 size = pick_integer_be(chip.image_size, 0, 2);
184 
185      switch (address)
186      {
187      case 0x8000: core_fread(file, roml + roml_offset, size); roml_offset += size; break;
188      case 0xa000: core_fread(file, romh + romh_offset, size); romh_offset += size; break;
189      case 0xe000: core_fread(file, romh + romh_offset, size); romh_offset += size; break;
190      }
191   }
192 
193   return true;
194}
src/mess/formats/cbm_crt.h
r14818r14819
1212#define __CBM_CRT__
1313 
1414#include "emu.h"
15#include "formats/imageutl.h"
1516 
1617 
1718 
r14818r14819
141142};
142143 
143144 
145 
146//**************************************************************************
147//  FUNCTION PROTOTYPES
148//**************************************************************************
149 
150const char * cbm_crt_get_card(core_file *file);
151bool cbm_crt_read_header(core_file* file, size_t *roml_size, size_t *romh_size, int *exrom, int *game);
152bool cbm_crt_read_data(core_file* file, UINT8 *roml, UINT8 *romh);
153 
154 
144155#endif
src/mess/mess.mak
r14818r14819
854854   $(MESS_MACHINE)/d9060.o      \
855855   $(MESS_MACHINE)/softbox.o   \
856856   $(MESS_MACHINE)/serialbox.o   \
857   $(MESS_MACHINE)/cmdhd.o   \
858   $(MESS_MACHINE)/fd2000.o   \
857859   $(MESS_DRIVERS)/clcd.o      \
858860   $(MESS_MACHINE)/cbm.o      \
859861   $(MESS_MACHINE)/cbmipt.o   \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team