Previous 199869 Revisions Next

r26516 Friday 6th December, 2013 at 04:26:55 UTC by R. Belmont
(MESS) itt3030: preliminary bankswitching setup using bankdev [R. Belmont]
[src/mess/drivers]itt3030.c

trunk/src/mess/drivers/itt3030.c
r26515r26516
193193#include "cpu/z80/z80.h"
194194#include "machine/wd_fdc.h"
195195#include "machine/bankdev.h"
196#include "machine/ram.h"
196197#include "formats/itt3030_dsk.h"
197198#include "video/tms9927.h"         //Display hardware
198199#include "sound/beep.h"
r26515r26516
207208   itt3030_state(const machine_config &mconfig, device_type type, const char *tag)
208209      : driver_device(mconfig, type, tag)
209210      , m_maincpu(*this, "maincpu")
211      , m_ram(*this, "mainram")
210212      , m_crtc(*this, "crt5027")
213      , m_48kbank(*this, "lowerbank")
211214      , m_fdc (*this, "fdc")
212215      , m_floppy0(*this, "fdc:0")
213216      , m_floppy1(*this, "fdc:1")
214217      , m_beep(*this, "beeper")
218      , m_vram(*this, "vram")
215219   { }
216220
217221   // devices
218222   required_device<cpu_device> m_maincpu;
223   required_device<ram_device> m_ram;
219224   required_device<crt5027_device> m_crtc;
225   required_device<address_map_bank_device> m_48kbank;
220226   required_device<fd1791_t> m_fdc;
221227   required_device<floppy_connector> m_floppy0;
222228   required_device<floppy_connector> m_floppy1;
223229   required_device<beep_device> m_beep;
224230
231   // shared pointers
232   required_shared_ptr<UINT8> m_vram;
233
225234   // screen updates
226235   UINT32 screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect);
227236
r26515r26516
236245   DECLARE_READ8_MEMBER(vsync_r);
237246   DECLARE_READ8_MEMBER(unk2_r);
238247   DECLARE_WRITE8_MEMBER( beep_w );
248   DECLARE_WRITE8_MEMBER(bank_w);
249   DECLARE_READ8_MEMBER(bankl_r);
250   DECLARE_WRITE8_MEMBER(bankl_w);
251   DECLARE_READ8_MEMBER(bankh_r);
252   DECLARE_WRITE8_MEMBER(bankh_w);
239253   DECLARE_FLOPPY_FORMATS(itt3030_floppy_formats);
240254private:
241255   UINT8 m_unk;
256   UINT8 m_bank;
242257   floppy_image_device *m_floppy;
243   
244258};
245259
246260void itt3030_state::video_start()
r26515r26516
263277   m_beep->set_state(data&0x32);
264278}
265279
280WRITE8_MEMBER(itt3030_state::bank_w)
281{
282   int bank;
283   m_bank = data>>4;
284
285   if (data & 1)   // bank 8
286   {
287      bank = 8;
288   }
289   else
290   {
291      bank = m_bank >> 1;
292   }
293
294//   printf("bank_w: new value %02x, m_bank %x, bank %x\n", data, m_bank, bank);
295
296   m_48kbank->set_bank(bank);
297}
298
299READ8_MEMBER(itt3030_state::bankl_r)
300{
301   return m_ram->read(offset);
302}
303
304WRITE8_MEMBER(itt3030_state::bankl_w)
305{
306   m_ram->write(offset, data);
307}
308
309READ8_MEMBER(itt3030_state::bankh_r)
310{
311   return m_ram->read(((m_bank>>1)*0x10000) + offset + 0xc000);
312}
313
314WRITE8_MEMBER(itt3030_state::bankh_w)
315{
316   m_ram->write(((m_bank>>1)*0x10000) + offset + 0xc000, data);
317}
318
266319UINT32 itt3030_state::screen_update( screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
267320{
268321   address_space &space = m_maincpu->space(AS_PROGRAM);
r26515r26516
271324   {
272325      for(int x = 0; x < 80; x++ )
273326      {
274         UINT8 code = space.read_byte(0x3000 + x + y*128);
327         UINT8 code = m_vram[0x3000 + x + y*128];
275328         drawgfx_opaque(bitmap, cliprect, machine().gfx[0],  code , 0, 0,0, x*8,y*16);
276329      }
277330   }
r26515r26516
279332   return 0;
280333}
281334
335
336// The lower 48K is switchable among the first 48K of each of 8 64K banks numbered 0-7 or "bank 8" which is the internal ROM and VRAM
337// The upper 16K is always the top 16K of the selected bank 0-7, which allows bank/bank copies and such
338// Port F6 bits 7-5 select banks 0-7, bit 4 enables bank 8
339
282340static ADDRESS_MAP_START( itt3030_map, AS_PROGRAM, 8, itt3030_state )
283   AM_RANGE(0x0000, 0x07ff) AM_ROM AM_REGION("maincpu", 0)
284   AM_RANGE(0x0800, 0x0fff) AM_ROM AM_REGION("maincpu", 0)
285   AM_RANGE(0x1000, 0xffff) AM_RAM
341   AM_RANGE(0x0000, 0xbfff) AM_DEVICE("lowerbank", address_map_bank_device, amap8)
342   AM_RANGE(0xc000, 0xffff) AM_READWRITE(bankh_r, bankh_w)
286343ADDRESS_MAP_END
287344
345static ADDRESS_MAP_START( lower48_map, AS_PROGRAM, 8, itt3030_state )
346   AM_RANGE(0x00000, 0x7ffff) AM_READWRITE(bankl_r, bankl_w)   // pages 0-7
347//  AM_RANGE(0x00000, 0x7ffff) AM_DEVREADWRITE("mainram", ram_device, read, write)   // should work in theory, but compiler blows up spectacularly?
348   AM_RANGE(0x80000, 0x807ff) AM_ROM AM_REGION("maincpu", 0)   // begin "page 8"
349   AM_RANGE(0x80800, 0x80fff) AM_ROM AM_REGION("maincpu", 0)
350   AM_RANGE(0x81000, 0x810ff) AM_RAM AM_MIRROR(0x100)   // only 256 bytes, but ROM also clears 11xx?
351   AM_RANGE(0x83000, 0x83fff) AM_RAM AM_SHARE("vram")
352ADDRESS_MAP_END
288353
289354static ADDRESS_MAP_START( itt3030_io, AS_IO, 8, itt3030_state )
290355   ADDRESS_MAP_GLOBAL_MASK(0xff)
r26515r26516
293358   AM_RANGE(0x32, 0x32) AM_WRITE(beep_w)
294359   AM_RANGE(0x35, 0x35) AM_READ(vsync_r)
295360   AM_RANGE(0x50, 0x55) AM_DEVREADWRITE("fdc", fd1791_t, read, write)
296   
361   AM_RANGE(0xf6, 0xf6) AM_WRITE(bank_w)
297362ADDRESS_MAP_END
298363
299364static INPUT_PORTS_START( itt3030 )
r26515r26516
322387
323388void itt3030_state::machine_reset()
324389{
390   m_bank = 1;
391   m_48kbank->set_bank(8);
325392}
326393
327394FLOPPY_FORMATS_MEMBER( itt3030_state::itt3030_floppy_formats )
r26515r26516
356423   MCFG_SCREEN_VISIBLE_AREA(0, 80*8-1, 0, 24*16-1)
357424   
358425   /* devices */
426   MCFG_DEVICE_ADD("lowerbank", ADDRESS_MAP_BANK, 0)
427   MCFG_DEVICE_PROGRAM_MAP(lower48_map)
428   MCFG_ADDRESS_MAP_BANK_ENDIANNESS(ENDIANNESS_LITTLE)
429   MCFG_ADDRESS_MAP_BANK_DATABUS_WIDTH(8)
430   MCFG_ADDRESS_MAP_BANK_STRIDE(0x10000)
359431   MCFG_DEVICE_ADD("crt5027", CRT5027, XTAL_6MHz)
360432   MCFG_DEVICE_CONFIG(crtc_intf)
361433   MCFG_FD1791x_ADD("fdc", XTAL_20MHz / 20)
r26515r26516
368440   MCFG_PALETTE_LENGTH(2)
369441   MCFG_PALETTE_INIT_OVERRIDE(driver_device, black_and_white)
370442
443   /* internal ram */
444   MCFG_RAM_ADD("mainram")
445   MCFG_RAM_DEFAULT_SIZE("512K")
446
371447   /* sound hardware */
372448   MCFG_SPEAKER_STANDARD_MONO( "mono" )
373449   MCFG_SOUND_ADD( "beeper", BEEP, 0 )

Previous 199869 Revisions Next


© 1997-2024 The MAME Team