Previous 15994 Revisions Next

r14742 Sunday 11th March, 2012 at 10:02:01 UTC by Sandro Ronco
z88: Added cartridge slot interface. [Sandro Ronco]
[src/mess]mess.mak
[src/mess/drivers]z88.c
[src/mess/includes]z88.h
[src/mess/machine]upd65031.c upd65031.h z88_ram.c* z88_ram.h* z88_rom.c* z88_rom.h* z88cart.c* z88cart.h*
[src/mess/video]z88.c

src/mess/machine/z88cart.c
r0r14742
1/*********************************************************************
2
3    z88cart.c
4
5    Z88 cartridge slots emulation
6
7*********************************************************************/
8
9#include "emu.h"
10#include "z88cart.h"
11#include "emuopts.h"
12
13
14/***************************************************************************
15    PARAMETERS
16***************************************************************************/
17
18#define CLOSE_FLAP_TIME      attotime::from_msec(200)
19
20//**************************************************************************
21//  GLOBAL VARIABLES
22//**************************************************************************
23
24const device_type Z88CART_SLOT = &device_creator<z88cart_slot_device>;
25
26
27//**************************************************************************
28//    Z88 cartridges Interface
29//**************************************************************************
30
31//-------------------------------------------------
32//  device_z88cart_interface - constructor
33//-------------------------------------------------
34
35device_z88cart_interface::device_z88cart_interface(const machine_config &mconfig, device_t &device)
36   : device_slot_card_interface(mconfig, device)
37{
38}
39
40
41//-------------------------------------------------
42//  ~device_z88cart_interface - destructor
43//-------------------------------------------------
44
45device_z88cart_interface::~device_z88cart_interface()
46{
47}
48
49
50//**************************************************************************
51//  LIVE DEVICE
52//**************************************************************************
53
54//-------------------------------------------------
55//  z88cart_slot_device - constructor
56//-------------------------------------------------
57z88cart_slot_device::z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) :
58        device_t(mconfig, Z88CART_SLOT, "Z88 Cartridge Slot", tag, owner, clock),
59      device_image_interface(mconfig, *this),
60      device_slot_interface(mconfig, *this)
61{
62}
63
64//-------------------------------------------------
65//  z88cart_slot_device - destructor
66//-------------------------------------------------
67
68z88cart_slot_device::~z88cart_slot_device()
69{
70}
71
72//-------------------------------------------------
73//  device_start - device-specific startup
74//-------------------------------------------------
75
76void z88cart_slot_device::device_start()
77{
78   m_cart = dynamic_cast<device_z88cart_interface *>(get_card_device());
79
80   // resolve callbacks
81   m_out_flp_func.resolve(m_out_flp_cb, *this);
82
83   m_flp_timer = timer_alloc(TIMER_FLP_CLEAR);
84   m_flp_timer->reset();
85}
86
87//-------------------------------------------------
88//  device_config_complete - perform any
89//  operations now that the configuration is
90//  complete
91//-------------------------------------------------
92
93void z88cart_slot_device::device_config_complete()
94{
95   // inherit a copy of the static data
96   const z88cart_interface *intf = reinterpret_cast<const z88cart_interface *>(static_config());
97   if (intf != NULL)
98   {
99      *static_cast<z88cart_interface *>(this) = *intf;
100   }
101
102   // or initialize to defaults if none provided
103   else
104   {
105       memset(&m_out_flp_cb, 0, sizeof(m_out_flp_cb));
106   }
107
108   // set brief and instance name
109   update_names();
110}
111
112
113//-------------------------------------------------
114//  device_timer - handler timer events
115//-------------------------------------------------
116
117void z88cart_slot_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
118{
119   if (id == TIMER_FLP_CLEAR)
120   {
121      // close the flap
122      m_out_flp_func(CLEAR_LINE);
123   }
124}
125
126/*-------------------------------------------------
127    call load
128-------------------------------------------------*/
129
130bool z88cart_slot_device::call_load()
131{
132   if (m_cart)
133   {
134      offs_t read_length = 0;
135      UINT8 *cart_base = m_cart->get_cart_base();
136
137      if (cart_base != NULL)
138      {
139         if (software_entry() == NULL)
140         {
141            read_length = length();
142            fread(cart_base + (m_cart->get_cart_size() - read_length), read_length);
143         }
144         else
145         {
146            read_length = get_software_region_length("rom");
147            memcpy(cart_base + (m_cart->get_cart_size() - read_length), get_software_region("rom"), read_length);
148         }
149      }
150      else
151         return IMAGE_INIT_FAIL;
152   }
153
154   // open the flap
155   m_out_flp_func(ASSERT_LINE);
156
157   // setup the timer for close the flap
158   m_flp_timer->adjust(CLOSE_FLAP_TIME);
159
160   return IMAGE_INIT_PASS;
161}
162
163
164/*-------------------------------------------------
165    call_unloadload
166-------------------------------------------------*/
167
168void z88cart_slot_device::call_unload()
169{
170   if (m_cart)
171      memset(m_cart->get_cart_base(), 0xff, m_cart->get_cart_size());
172
173   // open the flap
174   m_out_flp_func(ASSERT_LINE);
175
176   // setup the timer for close the flap
177   m_flp_timer->adjust(CLOSE_FLAP_TIME);
178}
179
180
181/*-------------------------------------------------
182    call softlist load
183-------------------------------------------------*/
184
185bool z88cart_slot_device::call_softlist_load(char *swlist, char *swname, rom_entry *start_entry)
186{
187   load_software_part_region(this, swlist, swname, start_entry );
188   return TRUE;
189}
190
191/*-------------------------------------------------
192    get default card software
193-------------------------------------------------*/
194
195const char * z88cart_slot_device::get_default_card_software(const machine_config &config, emu_options &options)
196{
197   return software_get_default_slot(config, options, this, "128krom");
198}
199
200
201/*-------------------------------------------------
202    read
203-------------------------------------------------*/
204
205READ8_MEMBER(z88cart_slot_device::read)
206{
207   if (m_cart)
208      return m_cart->read(space, offset);
209   else
210      return 0xff;
211}
212
213
214/*-------------------------------------------------
215    write
216-------------------------------------------------*/
217
218WRITE8_MEMBER(z88cart_slot_device::write)
219{
220   if (m_cart)
221      m_cart->write(space, offset, data);
222}
src/mess/machine/z88cart.h
r0r14742
1/*********************************************************************
2
3    z88cart.h
4
5    Z88 cartridge slots emulation
6
7**********************************************************************
8
9    pins    Slot 1  Slot 2  Slot 3
10
11    1       A16     A16     A16
12    2       A15     A15     A15
13    3       A12     A12     A12
14    4       A7      A7      A7
15    5       A6      A6      A6
16    6       A5      A5      A5
17    7       A4      A4      A4
18    8       A3      A3      A3
19    9       A2      A2      A2
20    10      A1      A1      A1
21    11      A0      A0      A0
22    12      D0      D0      D0
23    13      D1      D1      D1
24    14      D2      D2      D2
25    15      SNSL    SNSL    SNSL
26    16      GND     GND     GND
27    17      GND     GND     GND
28    18      A14     A14     A14
29    19      VCC     VCC     VPP
30    20      VCC     VCC     VCC
31    21      VCC     VCC     VCC
32    22      WEL     WEL     PGML
33    23      A13     A13     A13
34    24      A8      A8      A8
35    25      A9      A9      A9
36    26      A11     A11     A11
37    27      POE     POE     POE
38    28      ROE     ROE     EOE
39    29      A10     A10     A10
40    30      SE1     SE2     SE3
41    31      D7      D7      D7
42    32      D6      D6      D6
43    33      D3      D3      D3
44    34      D4      D4      D4
45    35      D5      D5      D5
46    36      A17     A17     A17
47    37      A18     A18     A18
48    38      A19     A19     A19
49
50*********************************************************************/
51
52#ifndef __Z88CART_H__
53#define __Z88CART_H__
54
55/***************************************************************************
56    TYPE DEFINITIONS
57***************************************************************************/
58
59// ======================> z88cart_interface
60
61struct z88cart_interface
62{
63    devcb_write_line            m_out_flp_cb;
64};
65
66
67// ======================> device_z88cart_interface
68
69class device_z88cart_interface : public device_slot_card_interface
70{
71public:
72   // construction/destruction
73   device_z88cart_interface(const machine_config &mconfig, device_t &device);
74   virtual ~device_z88cart_interface();
75
76   // reading and writing
77   virtual DECLARE_READ8_MEMBER(read) { return 0xff; }
78   virtual DECLARE_WRITE8_MEMBER(write) { }
79   virtual UINT8* get_cart_base() { return NULL; }
80   virtual int get_cart_size() { return 0; }
81};
82
83
84// ======================> z88cart_slot_device
85
86class z88cart_slot_device : public device_t,
87                      public z88cart_interface,
88                     public device_image_interface,
89                      public device_slot_interface
90{
91public:
92   // construction/destruction
93   z88cart_slot_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
94   virtual ~z88cart_slot_device();
95
96   // device-level overrides
97   virtual void device_start();
98   virtual void device_config_complete();
99   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
100
101   // image-level overrides
102   virtual bool call_load();
103   virtual void call_unload();
104   virtual bool call_softlist_load(char *swlist, char *swname, rom_entry *start_entry);
105
106   virtual iodevice_t image_type() const { return IO_CARTSLOT; }
107   virtual bool is_readable()  const { return 1; }
108   virtual bool is_writeable() const { return 1; }
109   virtual bool is_creatable() const { return 1; }
110   virtual bool must_be_loaded() const { return 0; }
111   virtual bool is_reset_on_load() const { return 0; }
112   virtual const char *image_interface() const { return "z88_cart"; }
113   virtual const char *file_extensions() const { return "epr,bin"; }
114   virtual const option_guide *create_option_guide() const { return NULL; }
115
116   // slot interface overrides
117   virtual const char * get_default_card_software(const machine_config &config, emu_options &options);
118
119   // reading and writing
120   virtual DECLARE_READ8_MEMBER(read);
121   virtual DECLARE_WRITE8_MEMBER(write);
122
123private:
124   static const device_timer_id TIMER_FLP_CLEAR = 0;
125
126   devcb_resolved_write_line      m_out_flp_func;
127   device_z88cart_interface*      m_cart;
128   emu_timer *                  m_flp_timer;
129};
130
131
132// device type definition
133extern const device_type Z88CART_SLOT;
134
135
136/***************************************************************************
137    DEVICE CONFIGURATION MACROS
138***************************************************************************/
139
140#define MCFG_Z88_CARTRIDGE_ADD(_tag,_config,_slot_intf,_def_slot,_def_inp) \
141   MCFG_DEVICE_ADD(_tag, Z88CART_SLOT, 0) \
142   MCFG_DEVICE_CONFIG(_config) \
143   MCFG_DEVICE_SLOT_INTERFACE(_slot_intf, _def_slot, _def_inp)
144
145#endif /* __Z88CART_H__ */
src/mess/machine/upd65031.c
r14741r14742
396396
397397UINT32 upd65031_device::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
398398{
399   if (m_screen_update_cb)
399   if (m_screen_update_cb && (m_com & COM_LCDON))
400400      (m_screen_update_cb)(*this, bitmap, m_lcd_regs[4], m_lcd_regs[2], m_lcd_regs[3], m_lcd_regs[0], m_lcd_regs[1], m_flash);
401   else
402      bitmap.fill(0, cliprect);
401403
402404   return 0;
403405}
r14741r14742
550552         if (LOG) logerror("uPD65031 '%s': ack w: %02x\n", tag(), data);
551553
552554         m_ack = data;
553         m_sta &= ~data;
555         m_sta &= ~(data & 0x7f);
554556
555557         // refresh ints
556558         interrupt_refresh();
r14741r14742
582584         break;
583585   }
584586}
587
588
589//-------------------------------------------------
590//  flp line
591//-------------------------------------------------
592
593WRITE_LINE_MEMBER( upd65031_device::flp_w )
594{
595   if (!(m_sta & STA_FLAPOPEN) && state)
596   {
597      // set interrupt on rising edge
598      m_sta |= STA_FLAP;
599
600      interrupt_refresh();
601   }
602
603   if (state)
604      m_sta |= STA_FLAPOPEN;
605   else
606      m_sta &= ~STA_FLAPOPEN;
607}
608
609//-------------------------------------------------
610//  battery low line
611//-------------------------------------------------
612
613WRITE_LINE_MEMBER( upd65031_device::btl_w )
614{
615   if (state)
616      m_sta |= STA_BTL;
617   else
618      m_sta &= ~STA_BTL;
619}
src/mess/machine/upd65031.h
r14741r14742
6060
6161   DECLARE_READ8_MEMBER( read );
6262   DECLARE_WRITE8_MEMBER( write );
63   DECLARE_WRITE_LINE_MEMBER( flp_w );
64   DECLARE_WRITE_LINE_MEMBER( btl_w );
6365   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
6466
6567protected:
src/mess/machine/z88_ram.c
r0r14742
1/***************************************************************************
2
3    z88_ram.c
4
5    Z88 RAM cartridges emulation
6
7***************************************************************************/
8
9#include "emu.h"
10#include "z88_ram.h"
11
12/***************************************************************************
13    IMPLEMENTATION
14***************************************************************************/
15
16//**************************************************************************
17//  GLOBAL VARIABLES
18//**************************************************************************
19
20const device_type Z88_32K_RAM =  &device_creator<z88_32k_ram_device>;
21const device_type Z88_128K_RAM = &device_creator<z88_128k_ram_device>;
22const device_type Z88_512K_RAM = &device_creator<z88_512k_ram_device>;
23const device_type Z88_1024K_RAM = &device_creator<z88_1024k_ram_device>;
24
25//**************************************************************************
26//  LIVE DEVICE
27//**************************************************************************
28
29//-------------------------------------------------
30//  z88_32k_ram_device - constructor
31//-------------------------------------------------
32
33z88_32k_ram_device::z88_32k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
34      : device_t(mconfig, Z88_32K_RAM, "Z88 32KB RAM", tag, owner, clock),
35      device_z88cart_interface( mconfig, *this )
36{
37}
38
39z88_32k_ram_device::z88_32k_ram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
40      : device_t(mconfig, type, name, tag, owner, clock),
41      device_z88cart_interface( mconfig, *this )
42{
43}
44
45//-------------------------------------------------
46//  z88_128k_ram_device - constructor
47//-------------------------------------------------
48
49z88_128k_ram_device::z88_128k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
50      : z88_32k_ram_device(mconfig, Z88_128K_RAM, "Z88 128KB RAM", tag, owner, clock)
51{
52}
53
54//-------------------------------------------------
55//  z88_512k_ram_device - constructor
56//-------------------------------------------------
57
58z88_512k_ram_device::z88_512k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
59      : z88_32k_ram_device(mconfig, Z88_512K_RAM, "Z88 512KB RAM", tag, owner, clock)
60{
61}
62
63//-------------------------------------------------
64//  z88_1024k_ram_device - constructor
65//-------------------------------------------------
66
67z88_1024k_ram_device::z88_1024k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
68      : z88_32k_ram_device(mconfig, Z88_1024K_RAM, "Z88 1024KB RAM", tag, owner, clock)
69{
70}
71
72
73//-------------------------------------------------
74//  device_start - device-specific startup
75//-------------------------------------------------
76
77void z88_32k_ram_device::device_start()
78{
79   m_ram = machine().region_alloc(tag(), get_cart_size(), 1, ENDIANNESS_LITTLE)->base();
80   memset(m_ram, 0, get_cart_size());
81}
82
83/*-------------------------------------------------
84    get_cart_base
85-------------------------------------------------*/
86
87UINT8* z88_32k_ram_device::get_cart_base()
88{
89   return m_ram;
90}
91
92/*-------------------------------------------------
93    read
94-------------------------------------------------*/
95
96READ8_MEMBER(z88_32k_ram_device::read)
97{
98   return m_ram[offset & (get_cart_size() - 1)];
99}
100
101/*-------------------------------------------------
102    write
103-------------------------------------------------*/
104
105WRITE8_MEMBER(z88_32k_ram_device::write)
106{
107   m_ram[offset & (get_cart_size() - 1)] = data;
108}
src/mess/machine/z88_ram.h
r0r14742
1#pragma once
2
3#ifndef __Z88_RAM_H__
4#define __Z88_RAM_H__
5
6#include "emu.h"
7#include "machine/z88cart.h"
8
9//**************************************************************************
10//  TYPE DEFINITIONS
11//**************************************************************************
12
13// ======================> z88_32k_ram_device
14
15class z88_32k_ram_device : public device_t,
16                     public device_z88cart_interface
17{
18public:
19   // construction/destruction
20   z88_32k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
21   z88_32k_ram_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
22
23protected:
24   // device-level overrides
25   virtual void device_start();
26   virtual void device_config_complete() { m_shortname = "z88_32k_ram"; }
27
28   // z88cart_interface overrides
29   virtual DECLARE_READ8_MEMBER(read);
30   virtual DECLARE_WRITE8_MEMBER(write);
31   virtual UINT8* get_cart_base();
32   virtual int get_cart_size() { return 0x8000; }
33
34protected:
35   // internal state
36   UINT8 *      m_ram;
37};
38
39// ======================> z88_128k_ram_device
40
41class z88_128k_ram_device : public z88_32k_ram_device
42{
43public:
44   // construction/destruction
45   z88_128k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
46
47protected:
48   // device-level overrides
49   virtual void device_config_complete() { m_shortname = "z88_128k_ram"; }
50
51   // z88cart_interface overrides
52   virtual int get_cart_size() { return 0x20000; }
53};
54
55// ======================> z88_512k_ram_device
56
57class z88_512k_ram_device : public z88_32k_ram_device
58{
59public:
60   // construction/destruction
61   z88_512k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
62
63protected:
64   // device-level overrides
65   virtual void device_config_complete() { m_shortname = "z88_512k_ram"; }
66
67   // z88cart_interface overrides
68   virtual int get_cart_size() { return 0x80000; }
69};
70
71// ======================> z88_1024k_ram_device
72
73class z88_1024k_ram_device : public z88_32k_ram_device
74{
75public:
76   // construction/destruction
77   z88_1024k_ram_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
78
79protected:
80   // device-level overrides
81   virtual void device_config_complete() { m_shortname = "z88_1024k_ram"; }
82
83   // z88cart_interface overrides
84   virtual int get_cart_size() { return 0x100000; }
85};
86
87// device type definition
88extern const device_type Z88_32K_RAM;
89extern const device_type Z88_128K_RAM;
90extern const device_type Z88_512K_RAM;
91extern const device_type Z88_1024K_RAM;
92
93#endif  /* __Z88_RAM_H__ */
src/mess/machine/z88_rom.c
r0r14742
1/***************************************************************************
2
3    z88_rom.c
4
5    Z88 ROM cartridges emulation
6
7***************************************************************************/
8
9#include "emu.h"
10#include "z88_rom.h"
11
12/***************************************************************************
13    IMPLEMENTATION
14***************************************************************************/
15
16//**************************************************************************
17//  GLOBAL VARIABLES
18//**************************************************************************
19
20const device_type Z88_32K_ROM = &device_creator<z88_32k_rom_device>;
21const device_type Z88_128K_ROM = &device_creator<z88_128k_rom_device>;
22const device_type Z88_256K_ROM = &device_creator<z88_256k_rom_device>;
23
24//**************************************************************************
25//  LIVE DEVICE
26//**************************************************************************
27
28//-------------------------------------------------
29//  z88_32k_rom_device - constructor
30//-------------------------------------------------
31
32z88_32k_rom_device::z88_32k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
33      : device_t(mconfig, Z88_32K_ROM, "Z88 32KB ROM", tag, owner, clock),
34      device_z88cart_interface( mconfig, *this )
35{
36}
37
38z88_32k_rom_device::z88_32k_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
39      : device_t(mconfig, type, name, tag, owner, clock),
40      device_z88cart_interface( mconfig, *this )
41{
42}
43
44//-------------------------------------------------
45//  z88_128k_rom_device - constructor
46//-------------------------------------------------
47
48z88_128k_rom_device::z88_128k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
49      : z88_32k_rom_device(mconfig, Z88_128K_ROM, "Z88 128KB ROM", tag, owner, clock)
50{
51}
52
53//-------------------------------------------------
54//  z88_256k_rom_device - constructor
55//-------------------------------------------------
56
57z88_256k_rom_device::z88_256k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
58      : z88_32k_rom_device(mconfig, Z88_256K_ROM, "Z88 256KB ROM", tag, owner, clock)
59{
60}
61
62//-------------------------------------------------
63//  device_start - device-specific startup
64//-------------------------------------------------
65
66void z88_32k_rom_device::device_start()
67{
68   m_rom = machine().region_alloc(tag(), get_cart_size(), 1, ENDIANNESS_LITTLE)->base();
69}
70
71/*-------------------------------------------------
72    get_cart_base
73-------------------------------------------------*/
74
75UINT8* z88_32k_rom_device::get_cart_base()
76{
77   return m_rom;
78}
79
80/*-------------------------------------------------
81    read
82-------------------------------------------------*/
83
84READ8_MEMBER(z88_32k_rom_device::read)
85{
86   return m_rom[offset & (get_cart_size() - 1)];
87}
88
src/mess/machine/z88_rom.h
r0r14742
1#pragma once
2
3#ifndef __Z88_ROM_H__
4#define __Z88_ROM_H__
5
6#include "emu.h"
7#include "machine/z88cart.h"
8
9//**************************************************************************
10//  TYPE DEFINITIONS
11//**************************************************************************
12
13// ======================> z88_32k_rom_device
14
15class z88_32k_rom_device : public device_t,
16                     public device_z88cart_interface
17{
18public:
19   // construction/destruction
20   z88_32k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
21   z88_32k_rom_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
22
23protected:
24   // device-level overrides
25   virtual void device_start();
26   virtual void device_config_complete() { m_shortname = "z88_32k_rom"; }
27
28   // z88cart_interface overrides
29   virtual DECLARE_READ8_MEMBER(read);
30   virtual UINT8* get_cart_base();
31   virtual int get_cart_size() { return 0x8000; }
32
33protected:
34   // internal state
35   UINT8 *      m_rom;
36};
37
38// ======================> z88_128k_rom_device
39
40class z88_128k_rom_device :   public z88_32k_rom_device
41{
42public:
43   // construction/destruction
44   z88_128k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
45
46protected:
47   // device-level overrides
48   virtual void device_config_complete() { m_shortname = "z88_128k_rom"; }
49
50   // z88cart_interface overrides
51   virtual int get_cart_size() { return 0x20000; }
52};
53
54// ======================> z88_256k_rom_device
55
56class z88_256k_rom_device : public z88_32k_rom_device
57{
58public:
59   // construction/destruction
60   z88_256k_rom_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
61
62protected:
63   // device-level overrides
64   virtual void device_config_complete() { m_shortname = "z88_256k_rom"; }
65
66   // z88cart_interface overrides
67   virtual int get_cart_size() { return 0x200000; }
68};
69
70// device type definition
71extern const device_type Z88_32K_ROM;
72extern const device_type Z88_128K_ROM;
73extern const device_type Z88_256K_ROM;
74
75#endif  /* __Z88_ROM_H__ */
src/mess/includes/z88.h
r14741r14742
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
1212#include "machine/upd65031.h"
13#include "machine/ram.h"
14#include "machine/z88cart.h"
15#include "machine/z88_ram.h"
16#include "machine/z88_rom.h"
1317#include "sound/speaker.h"
1418#include "rendlay.h"
1519
r14741r14742
3236   z88_state(const machine_config &mconfig, device_type type, const char *tag)
3337      : driver_device(mconfig, type, tag),
3438        m_maincpu(*this, "maincpu"),
35        m_speaker(*this, SPEAKER_TAG)
39        m_speaker(*this, SPEAKER_TAG),
40        m_ram(*this, RAM_TAG)
3641   { }
3742
3843   required_device<cpu_device> m_maincpu;
3944   required_device<device_t> m_speaker;
45   required_device<ram_device> m_ram;
4046
4147   virtual void machine_start();
4248   void bankswitch_update(int bank, UINT16 page, int rams);
4349   DECLARE_READ8_MEMBER(kb_r);
50   
51   // cartridges read/write
52   DECLARE_READ8_MEMBER(bank0_cart_r);
53   DECLARE_READ8_MEMBER(bank1_cart_r);
54   DECLARE_READ8_MEMBER(bank2_cart_r);
55   DECLARE_READ8_MEMBER(bank3_cart_r);
56   DECLARE_WRITE8_MEMBER(bank0_cart_w);
57   DECLARE_WRITE8_MEMBER(bank1_cart_w);
58   DECLARE_WRITE8_MEMBER(bank2_cart_w);
59   DECLARE_WRITE8_MEMBER(bank3_cart_w);
4460
4561   // defined in video/z88.c
4662   inline void plot_pixel(bitmap_ind16 &bitmap, int x, int y, UINT16 color);
r14741r14742
4965   void vh_render_6x8(bitmap_ind16 &bitmap, int x, int y, UINT16 pen0, UINT16 pen1, UINT8 *gfx);
5066   void vh_render_line(bitmap_ind16 &bitmap, int x, int y, UINT16 pen);
5167   void lcd_update(bitmap_ind16 &bitmap, UINT16 sbf, UINT16 hires0, UINT16 hires1, UINT16 lores0, UINT16 lores1, int flash);
68
69   struct
70   {
71      UINT8 slot;
72      UINT8 page;
73   } m_bank[4];
74
75   UINT8 *              m_bios;
76   UINT8 *              m_ram_base;
77   z88cart_slot_device * m_carts[4];
5278};
5379
5480
src/mess/video/z88.c
r14741r14742
1818// convert absolute offset into correct address to get data from
1919inline UINT8* z88_state::convert_address(UINT32 offset)
2020{
21   return machine().region("maincpu")->base() + offset;
21   return (offset < 0x80000 ? m_bios : m_ram_base) + (offset & 0x7ffff);
2222}
2323
2424/***************************************************************************
r14741r14742
150150               }
151151               else
152152               {
153                  ch &= 0x7f;
153                  ch &= 0xff;
154154                  char_gfx = convert_address(hires0<<13);
155155               }
156156
src/mess/drivers/z88.c
r14741r14742
4242
4343*/
4444
45// cartridges read
46READ8_MEMBER(z88_state::bank0_cart_r) { return m_carts[m_bank[0].slot]->read(space, (m_bank[0].page<<14) + offset); }
47READ8_MEMBER(z88_state::bank1_cart_r) { return m_carts[m_bank[1].slot]->read(space, (m_bank[1].page<<14) + offset); }
48READ8_MEMBER(z88_state::bank2_cart_r) { return m_carts[m_bank[2].slot]->read(space, (m_bank[2].page<<14) + offset); }
49READ8_MEMBER(z88_state::bank3_cart_r) { return m_carts[m_bank[3].slot]->read(space, (m_bank[3].page<<14) + offset); }
50
51// cartridges write
52WRITE8_MEMBER(z88_state::bank0_cart_w) { m_carts[m_bank[0].slot]->write(space, (m_bank[0].page<<14) + offset, data); }
53WRITE8_MEMBER(z88_state::bank1_cart_w) { m_carts[m_bank[1].slot]->write(space, (m_bank[1].page<<14) + offset, data); }
54WRITE8_MEMBER(z88_state::bank2_cart_w) { m_carts[m_bank[2].slot]->write(space, (m_bank[2].page<<14) + offset, data); }
55WRITE8_MEMBER(z88_state::bank3_cart_w) { m_carts[m_bank[3].slot]->write(space, (m_bank[3].page<<14) + offset, data); }
56
57
4558void z88_state::bankswitch_update(int bank, UINT16 page, int rams)
4659{
4760   char bank_tag[6];
r14741r14742
5063   // bank 0 is always even
5164   if (bank == 0)   page &= 0xfe;
5265
53   if (page < 0x40)   // internal memory
66   if (page < 0x20)   // internal ROM
5467   {
5568      // install read bank
5669      m_maincpu->memory().space(AS_PROGRAM)->install_read_bank(bank<<14, (bank<<14) + 0x3fff, bank_tag);
70      m_maincpu->memory().space(AS_PROGRAM)->unmap_write(bank<<14, (bank<<14) + 0x3fff);
5771
58      // install write bank
59      if (page > 0x1f)
72      memory_set_bank(machine(), bank_tag, page);
73   }
74   else if (page < 0x40)   // internal RAM
75   {
76      if((page & 0x1f) < (m_ram->size()>>14))
6077      {
61          // 512KB internal RAM
62         m_maincpu->memory().space(AS_PROGRAM)->install_write_bank(bank<<14, (bank<<14) + 0x3fff, bank_tag);
78         // install readwrite bank
79         m_maincpu->memory().space(AS_PROGRAM)->install_readwrite_bank(bank<<14, (bank<<14) + 0x3fff, bank_tag);
80
81         // set the bank
82         memory_set_bank(machine(), bank_tag, page);
6383      }
6484      else
6585      {
66         // internal ROM
67         m_maincpu->memory().space(AS_PROGRAM)->unmap_write(bank<<14, (bank<<14) + 0x3fff);
86         m_maincpu->memory().space(AS_PROGRAM)->unmap_readwrite(bank<<14, (bank<<14) + 0x3fff);
6887      }
69
70      // set the bank
71      memory_set_bank(machine(), bank_tag, page);
7288   }
73   else
89   else   // cartridges
7490   {
75      // TODO: expansion slots
76      m_maincpu->memory().space(AS_PROGRAM)->unmap_readwrite(bank<<14, (bank<<14) + 0x3fff);
91      m_bank[bank].slot = (page >> 6) & 3;
92      m_bank[bank].page = page & 0x3f;
93
94      switch (bank)
95      {
96         case 0:
97            m_maincpu->memory().space(AS_PROGRAM)->install_readwrite_handler(bank<<14, (bank<<14) + 0x3fff, 0, 0, read8_delegate(FUNC(z88_state::bank0_cart_r), this), write8_delegate(FUNC(z88_state::bank0_cart_w), this));
98            break;
99         case 1:
100            m_maincpu->memory().space(AS_PROGRAM)->install_readwrite_handler(bank<<14, (bank<<14) + 0x3fff, 0, 0, read8_delegate(FUNC(z88_state::bank1_cart_r), this), write8_delegate(FUNC(z88_state::bank1_cart_w), this));
101            break;
102         case 2:
103            m_maincpu->memory().space(AS_PROGRAM)->install_readwrite_handler(bank<<14, (bank<<14) + 0x3fff, 0, 0, read8_delegate(FUNC(z88_state::bank2_cart_r), this), write8_delegate(FUNC(z88_state::bank2_cart_w), this));
104            break;
105         case 3:
106            m_maincpu->memory().space(AS_PROGRAM)->install_readwrite_handler(bank<<14, (bank<<14) + 0x3fff, 0, 0, read8_delegate(FUNC(z88_state::bank3_cart_r), this), write8_delegate(FUNC(z88_state::bank3_cart_w), this));
107            break;
108      }
77109   }
78110
79111
r14741r14742
214246
215247void z88_state::machine_start()
216248{
249   m_bios = (UINT8*)machine().region("bios")->base();
250   m_ram_base = (UINT8*)m_ram->pointer();
251
217252   // configure the memory banks
218   memory_configure_bank(machine(), "bank1", 0, 1, machine().region("maincpu")->base(), 0);
219   memory_configure_bank(machine(), "bank1", 1, 1, machine().region("maincpu")->base() + (32<<14), 0);
220   memory_configure_bank(machine(), "bank2", 0, 64, machine().region("maincpu")->base(), 0x4000);
221   memory_configure_bank(machine(), "bank3", 0, 64, machine().region("maincpu")->base(), 0x4000);
222   memory_configure_bank(machine(), "bank4", 0, 64, machine().region("maincpu")->base(), 0x4000);
223   memory_configure_bank(machine(), "bank5", 0, 64, machine().region("maincpu")->base(), 0x4000);
253   memory_configure_bank(machine(), "bank1", 0, 1, m_bios, 0);
254   memory_configure_bank(machine(), "bank1", 1, 1, m_ram_base,  0);
255   memory_configure_bank(machine(), "bank2", 0, 32, m_bios, 0x4000);
256   memory_configure_bank(machine(), "bank3", 0, 32, m_bios, 0x4000);
257   memory_configure_bank(machine(), "bank4", 0, 32, m_bios, 0x4000);
258   memory_configure_bank(machine(), "bank5", 0, 32, m_bios, 0x4000);
259   memory_configure_bank(machine(), "bank2", 32, m_ram->size()>>14, m_ram_base, 0x4000);
260   memory_configure_bank(machine(), "bank3", 32, m_ram->size()>>14, m_ram_base, 0x4000);
261   memory_configure_bank(machine(), "bank4", 32, m_ram->size()>>14, m_ram_base, 0x4000);
262   memory_configure_bank(machine(), "bank5", 32, m_ram->size()>>14, m_ram_base, 0x4000);
263
264   m_carts[1] = machine().device<z88cart_slot_device>("slot1");
265   m_carts[2] = machine().device<z88cart_slot_device>("slot2");
266   m_carts[3] = machine().device<z88cart_slot_device>("slot3");
224267}
225268
226269READ8_MEMBER(z88_state::kb_r)
r14741r14742
276319   DEVCB_NULL                                    // Speaker line out
277320};
278321
322static const z88cart_interface z88_cart_interface =
323{
324   DEVCB_DEVICE_LINE_MEMBER("blink", upd65031_device, flp_w)
325};
279326
327static SLOT_INTERFACE_START(z88_cart)
328   SLOT_INTERFACE("32krom",  Z88_32K_ROM)         // 32KB ROM cart
329   SLOT_INTERFACE("128krom", Z88_128K_ROM)         // 128KB ROM cart
330   SLOT_INTERFACE("256krom", Z88_256K_ROM)         // 256KB ROM cart
331   SLOT_INTERFACE("32kram",  Z88_32K_RAM)         // 32KB RAM cart
332   SLOT_INTERFACE("128kram", Z88_128K_RAM)         // 128KB RAM cart
333   SLOT_INTERFACE("512kram", Z88_512K_RAM)         // 512KB RAM cart
334   SLOT_INTERFACE("1024kram",Z88_1024K_RAM)      // 1024KB RAM cart
335SLOT_INTERFACE_END
336
280337static MACHINE_CONFIG_START( z88, z88_state )
281338   /* basic machine hardware */
282339   MCFG_CPU_ADD("maincpu", Z80, XTAL_9_8304MHz/3)   // divided by 3 through the uPD65031
283340   MCFG_CPU_PROGRAM_MAP(z88_mem)
284341   MCFG_CPU_IO_MAP(z88_io)
285   //MCFG_QUANTUM_TIME(attotime::from_hz(60))
286342
287343   /* video hardware */
288344   MCFG_SCREEN_ADD("screen", LCD)
r14741r14742
303359   MCFG_SPEAKER_STANDARD_MONO("mono")
304360   MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0)
305361   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
362
363   // internal ram
364   MCFG_RAM_ADD(RAM_TAG)
365   MCFG_RAM_DEFAULT_SIZE("128K")
366   MCFG_RAM_EXTRA_OPTIONS("32K,64K,256K,512k")
367
368   // cartridges
369   MCFG_Z88_CARTRIDGE_ADD("slot1", z88_cart_interface, z88_cart, NULL, NULL)
370   MCFG_Z88_CARTRIDGE_ADD("slot2", z88_cart_interface, z88_cart, NULL, NULL)
371   MCFG_Z88_CARTRIDGE_ADD("slot3", z88_cart_interface, z88_cart, NULL, NULL)
306372MACHINE_CONFIG_END
307373
308374
r14741r14742
313379***************************************************************************/
314380
315381ROM_START(z88)
316   ROM_REGION(0x100000, "maincpu", ROMREGION_ERASE00)
382   ROM_REGION(0x80000, "bios", ROMREGION_ERASE00)
317383   ROM_DEFAULT_BIOS("v40uk")
318384   ROM_SYSTEM_BIOS( 0, "v220uk", "Version 2.20 UK")
319385   ROMX_LOAD("z88v220.rom", 0x00000, 0x20000, CRC(0ae7d0fc) SHA1(5d89e8d98d2cc0acb8cd42dbfca601b7bd09c51e), ROM_BIOS(1) )
src/mess/mess.mak
r14741r14742
570570   $(MESS_DRIVERS)/electron.o   \
571571   $(MESS_DRIVERS)/z88.o      \
572572   $(MESS_VIDEO)/z88.o         \
573   $(MESS_MACHINE)/z88cart.o   \
574   $(MESS_MACHINE)/z88_ram.o   \
575   $(MESS_MACHINE)/z88_rom.o   \
573576   $(MESS_MACHINE)/upd65031.o   \
574577
575578$(MESSOBJ)/act.a:            \

Previous 15994 Revisions Next


© 1998-2018 The MESS Team