Previous 15994 Revisions Next

r11283 Sunday 24th April, 2011 at 19:18:16 UTC by Sandro Ronco
[REX6000] Convert the driver to use the intelfsh device. [Sandro Ronco]

(out of whatsnew)
dumps are the same as before, just split into 1MB blocks
[src/mess/drivers]rex6000.c

src/mess/drivers/rex6000.c
r11282r11283
2222#include "cpu/z80/z80.h"
2323#include "machine/rp5c01.h"
2424#include "machine/ram.h"
25#include "machine/intelfsh.h"
2526#include "imagedev/snapquik.h"
2627#include "sound/beep.h"
2728#include "rendlay.h"
r11282r11283
3738#define   IRQ_FLAG_IRQ1      0x40
3839#define   IRQ_FLAG_EVENT      0x80
3940
41//memory bank types
42#define BANK_FLASH0_B0      0x00
43#define BANK_FLASH0_B1      0x01
44#define BANK_FLASH1_B0      0x02
45#define BANK_FLASH1_B1      0x03
46#define BANK_RAM         0x10
47#define BANK_UNKNOWN      0xff
48
4049#define TC8521_TAG   "rtc"
4150
4251class rex6000_state : public driver_device
r11282r11283
5261   required_device<cpu_device> m_maincpu;
5362   required_device<device_t> m_ram;
5463   required_device<device_t> m_beep;
64   fujitsu_29dl16x_device *m_flash[4];
5565
5666   UINT8 m_bank[4];
5767   UINT8 m_beep_io[5];
r11282r11283
5969   UINT8 m_touchscreen[0x10];
6070   UINT8 m_lcd_enabled;
6171   UINT8 m_lcd_cmd;
72   UINT8 *m_ram_base;
6273
63   UINT32 m_lcd_addr;
6474   UINT8 m_irq_mask;
6575   UINT8 m_irq_flag;
6676   UINT8 m_port6;
6777   UINT8 m_beep_mode;
6878
69   UINT8* get_bank_ptr(running_machine &machine, UINT32 bank);
79   struct
80   {
81      UINT8 type;
82      UINT16 page;
83   } m_banks[2];
7084
85   virtual void machine_start();
7186   virtual void machine_reset();
7287   bool screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect);
7388
r11282r11283
8398   DECLARE_WRITE8_MEMBER( irq_w );
8499   DECLARE_READ8_MEMBER( touchscreen_r );
85100   DECLARE_WRITE8_MEMBER( touchscreen_w );
101
102   DECLARE_READ8_MEMBER( flash_0x0000_r );
103   DECLARE_WRITE8_MEMBER( flash_0x0000_w );
104   DECLARE_READ8_MEMBER( flash_0x8000_r );
105   DECLARE_WRITE8_MEMBER( flash_0x8000_w );
106   DECLARE_READ8_MEMBER( flash_0xa000_r );
107   DECLARE_WRITE8_MEMBER( flash_0xa000_w );
108
109   UINT8 identify_bank_type(UINT32 bank);
86110};
87111
88112
89UINT8* rex6000_state::get_bank_ptr(running_machine &machine, UINT32 bank)
113UINT8 rex6000_state::identify_bank_type(UINT32 bank)
90114{
91   if (bank < 0x100)
115   if (bank < 0x080)
92116   {
93      return (UINT8*)machine.region("flash0")->base() + ((bank&0xff)<<13);
117      return BANK_FLASH0_B0;
94118   }
95   else if ((bank >= 0xb00 && bank < 0xc00) || (bank >= 0x600 && bank < 0x700))
119   else if (bank >= 0x080 && bank < 0x100)
96120   {
97      return (UINT8*)machine.region("flash1")->base() + ((bank&0xff)<<13);
121      return BANK_FLASH0_B1;
98122   }
123   else if ((bank >= 0xb00 && bank < 0xb80) || (bank >= 0x600 && bank < 0x680))
124   {
125      return BANK_FLASH1_B0;
126   }
127   else if ((bank >= 0xb80 && bank < 0xc00) || (bank >= 0x680 && bank < 0x700))
128   {
129      return BANK_FLASH1_B1;
130   }
99131   else if (bank >= 0x1000 && bank < 0x1004)
100132   {
101      return (UINT8*)ram_get_ptr(m_ram) + ((bank&0x03)<<13);
133      return BANK_RAM;
102134   }
103135   else
104136   {
105      logerror("%04x: unkonwn memory bank %x\n", cpu_get_pc(m_maincpu), bank);
106      return NULL;
137      //logerror("%04x: unkonwn memory bank %x\n", cpu_get_pc(m_maincpu), bank);
138      return BANK_UNKNOWN;
107139   }
108140}
109141
r11282r11283
114146
115147WRITE8_MEMBER( rex6000_state::bankswitch_w )
116148{
117   address_space *program = m_maincpu->memory().space(AS_PROGRAM);
149   address_space* program = m_maincpu->memory().space(AS_PROGRAM);
150
118151   m_bank[offset&3] = data;
119152
120153   switch (offset)
r11282r11283
123156      case 1:      //bank 1 high
124157      {
125158         //bank 1 start at 0x8000
126         UINT8 *bank_base = get_bank_ptr(machine(), MAKE_BANK(m_bank[0], m_bank[1]&0x0f) + 4);
159         m_banks[0].page = (MAKE_BANK(m_bank[0], m_bank[1]&0x0f) + 4);
160         m_banks[0].type = identify_bank_type(m_banks[0].page);
127161
128         if (bank_base != NULL)
162         if (m_banks[0].type != BANK_UNKNOWN)
129163         {
130            program->install_readwrite_bank(0x8000, 0x9fff, "bank1");
131            memory_set_bankptr(machine(), "bank1", bank_base);
164            program->install_readwrite_handler(0x8000, 0x9fff, 0, 0, read8_delegate(FUNC(rex6000_state::flash_0x8000_r), this), write8_delegate(FUNC(rex6000_state::flash_0x8000_w), this));
132165         }
133166         else
134167         {
r11282r11283
140173      case 2:      //bank 2 low
141174      case 3:      //bank 2 high
142175      {
143         UINT8 *bank_base = get_bank_ptr(machine(), MAKE_BANK(m_bank[2], m_bank[3]&0x1f));
176         m_banks[1].page = MAKE_BANK(m_bank[2], m_bank[3]&0x1f);
177         m_banks[1].type = identify_bank_type(m_banks[1].page);
144178
145         if (bank_base != NULL)
179         if (m_banks[1].type == BANK_RAM)
146180         {
147            program->install_readwrite_bank(0xa000, 0xbfff, "bank2");
148            memory_set_bankptr(machine(), "bank2", bank_base);
181            program->install_ram(0xa000, 0xbfff, m_ram_base + ((m_banks[1].page & 0x03)<<13));
149182         }
183         else if (m_banks[1].type != BANK_UNKNOWN)
184         {
185            program->install_readwrite_handler(0xa000, 0xbfff, 0, 0, read8_delegate(FUNC(rex6000_state::flash_0xa000_r), this), write8_delegate(FUNC(rex6000_state::flash_0xa000_w), this));
186         }
150187         else
151188         {
152189            program->unmap_readwrite(0xa000, 0xbfff);
r11282r11283
192229         }
193230         break;
194231      case 4:      //select alarm/tone mode
232         if (m_beep_mode != BIT(data, 0))
233            beep_set_state(m_beep, 0);      //turned off when mode changes
234
195235         m_beep_mode = BIT(data, 0);
196236         break;
197237      break;
r11282r11283
208248WRITE8_MEMBER( rex6000_state::lcd_base_w )
209249{
210250   m_lcd_base[offset&1] = data;
211   m_lcd_addr = MAKE_BANK(m_lcd_base[0], m_lcd_base[1]&0x1f);
212251}
213252
214253READ8_MEMBER( rex6000_state::lcd_io_r )
r11282r11283
308347   m_touchscreen[offset&0x0f] = data;
309348}
310349
350READ8_MEMBER( rex6000_state::flash_0x0000_r )
351{
352   return m_flash[0]->read(offset);
353}
354
355WRITE8_MEMBER( rex6000_state::flash_0x0000_w )
356{
357   m_flash[0]->write(offset, data);
358}
359
360READ8_MEMBER( rex6000_state::flash_0x8000_r )
361{
362   return m_flash[m_banks[0].type]->read(((m_banks[0].page & 0x7f)<<13) | offset);
363}
364
365WRITE8_MEMBER( rex6000_state::flash_0x8000_w )
366{
367   m_flash[m_banks[0].type]->write(((m_banks[0].page & 0x7f)<<13) | offset, data);
368}
369
370READ8_MEMBER( rex6000_state::flash_0xa000_r )
371{
372   return m_flash[m_banks[1].type]->read(((m_banks[1].page & 0x7f)<<13) | offset);
373}
374
375WRITE8_MEMBER( rex6000_state::flash_0xa000_w )
376{
377   m_flash[m_banks[1].type]->write(((m_banks[1].page & 0x7f)<<13) | offset, data);
378}
379
380
311381static ADDRESS_MAP_START(rex6000_mem, AS_PROGRAM, 8, rex6000_state)
312382   ADDRESS_MAP_UNMAP_HIGH
313   AM_RANGE( 0x0000, 0x7fff ) AM_ROM   AM_REGION("flash0", 0)
314   AM_RANGE( 0x8000, 0x9fff ) AM_RAMBANK("bank1")
315   AM_RANGE( 0xa000, 0xbfff ) AM_RAMBANK("bank2")
383   AM_RANGE( 0x0000, 0x7fff ) AM_READWRITE(flash_0x0000_r, flash_0x0000_w)
384   AM_RANGE( 0x8000, 0x9fff ) AM_READWRITE(flash_0x8000_r, flash_0x8000_w)
385   AM_RANGE( 0xa000, 0xbfff ) AM_READWRITE(flash_0xa000_r, flash_0xa000_w)
316386   AM_RANGE( 0xc000, 0xffff ) AM_RAMBANK("ram")         //system RAM
317387ADDRESS_MAP_END
318388
r11282r11283
365435   PORT_BIT(0x3ff, 0x00, IPT_LIGHTGUN_Y) PORT_NAME("Pen Y") PORT_CROSSHAIR(Y, 1, 0, 0) PORT_SENSITIVITY(50) PORT_KEYDELTA(10) PORT_INVERT
366436INPUT_PORTS_END
367437
438void rex6000_state::machine_start()
439{
440   m_flash[0] = machine().device<fujitsu_29dl16x_device>("flash0a");
441   m_flash[1] = machine().device<fujitsu_29dl16x_device>("flash0b");
442   m_flash[2] = machine().device<fujitsu_29dl16x_device>("flash1a");
443   m_flash[3] = machine().device<fujitsu_29dl16x_device>("flash1b");
444
445   m_ram_base = ram_get_ptr(m_ram);
446   memory_set_bankptr(machine(), "ram", m_ram_base + 0x4000);
447}
368448void rex6000_state::machine_reset()
369449{
370   UINT8 *ram = ram_get_ptr(m_ram);
450   address_space* program = m_maincpu->memory().space(AS_PROGRAM);
371451
372   memory_set_bankptr(machine(), "bank1", (UINT8*)machine().region("flash0")->base() + 0x8000);
373   memory_set_bankptr(machine(), "bank2", (UINT8*)machine().region("flash0")->base());
374   memory_set_bankptr(machine(), "ram", ram + 0x4000);
452   program->install_readwrite_handler(0x8000, 0x9fff, 0, 0, read8_delegate(FUNC(rex6000_state::flash_0x8000_r), this), write8_delegate(FUNC(rex6000_state::flash_0x8000_w), this));
453   program->install_readwrite_handler(0xa000, 0xbfff, 0, 0, read8_delegate(FUNC(rex6000_state::flash_0xa000_r), this), write8_delegate(FUNC(rex6000_state::flash_0xa000_w), this));
375454
376   memset(ram, 0, ram_get_size(m_ram));
455   m_banks[0].type = 0x04;
456   m_banks[0].type = 0;
457   m_banks[1].type = 0x00;
458   m_banks[1].type = 0;
459
460   memset(m_ram_base, 0, ram_get_size(m_ram));
377461   memset(m_bank, 0, sizeof(m_bank));
378462   memset(m_beep_io, 0, sizeof(m_beep_io));
379463   memset(m_lcd_base, 0, sizeof(m_lcd_base));
380464   memset(m_touchscreen, 0, sizeof(m_touchscreen));
381465   m_lcd_enabled = 0;
382466   m_lcd_cmd = 0;
383   m_lcd_addr = 0;
384467   m_irq_mask = 0;
385468   m_irq_flag = 0;
386469   m_port6 = 0;
r11282r11283
389472
390473bool rex6000_state::screen_update(screen_device &screen, bitmap_t &bitmap, const rectangle &cliprect)
391474{
392   UINT8 *lcd_base = get_bank_ptr(machine(), m_lcd_addr);
475   UINT16 lcd_bank = MAKE_BANK(m_lcd_base[0], m_lcd_base[1]&0x1f);
476   UINT8 mem_type = identify_bank_type(lcd_bank);
393477
394   if (m_lcd_enabled && lcd_base != NULL)
478   if (m_lcd_enabled && mem_type != BANK_UNKNOWN)
395479   {
396480      for (int y=0; y<120; y++)
397481         for (int x=0; x<30; x++)
398482         {
399            UINT8 data = lcd_base[y*30 + x];
483            UINT8 data = 0;
400484
485            if (mem_type == BANK_RAM)
486            {
487               data = (m_ram_base + ((lcd_bank & 0x03)<<13))[y*30 + x];
488            }
489            else
490            {
491               data =  m_flash[mem_type]->memory().space(0)->read_byte(((lcd_bank & 0x7f)<<13) | (y*30 + x));
492            }
493
494
401495            for (int b=0; b<8; b++)
402496            {
403497               *BITMAP_ADDR16(&bitmap, y, (x * 8) + b) = BIT(data, 7);
r11282r11283
461555{
462556   static const char magic[] = "ApplicationName:Addin";
463557   running_machine &machine = image.device().machine();
558   address_space* flash = machine.device("flash0b")->memory().space(0);
464559   UINT32 img_start = 0;
465560   UINT8 *data;
466561
r11282r11283
473568   img_start = strlen((const char*)data) + 5;
474569   img_start += 0xa0;   //skip the icon (40x32 pixel)
475570
476   memcpy((UINT8*)machine.region("flash0")->base() + 0x100000, data + img_start, image.length() - img_start);
571   for (int i=0; i<image.length() - img_start ;i++)
572      flash->write_byte(i, data[img_start + i]);
573
477574   auto_free(machine, data);
478575
479576   return IMAGE_INIT_PASS;
r11282r11283
521618};
522619
523620static GFXDECODE_START( rex6000 )
524   GFXDECODE_ENTRY( "flash0", 0x0f0000, rex6000_bold_charlayout,  0, 0 )   //normal
525   GFXDECODE_ENTRY( "flash0", 0x0f2000, rex6000_bold_charlayout,  0, 0 )   //bold
526   GFXDECODE_ENTRY( "flash0", 0x0f4000, rex6000_tiny_charlayout,  0, 0 )   //tiny
527   GFXDECODE_ENTRY( "flash0", 0x0f6000, rex6000_graph_charlayout, 0, 0 )   //graphic
621   GFXDECODE_ENTRY( "flash0a", 0x0f0000, rex6000_bold_charlayout,  0, 0 )   //normal
622   GFXDECODE_ENTRY( "flash0a", 0x0f2000, rex6000_bold_charlayout,  0, 0 )   //bold
623   GFXDECODE_ENTRY( "flash0a", 0x0f4000, rex6000_tiny_charlayout,  0, 0 )   //tiny
624   GFXDECODE_ENTRY( "flash0a", 0x0f6000, rex6000_graph_charlayout, 0, 0 )   //graphic
528625GFXDECODE_END
529626
530627
r11282r11283
560657
561658   MCFG_RP5C01_ADD(TC8521_TAG, XTAL_32_768kHz, rtc_intf)
562659
660   /*
661    Fujitsu 29DL16X have feature which is capability of reading data from one
662    bank of memory while a program or erase operation is in progress in the
663    other bank of memory (simultaneous operation). This is not supported yet
664    by the flash emulation and I have splitted every bank into a separate
665    device for have a similar behavior.
666    */
667   MCFG_FUJITSU_29DL16X_ADD("flash0a")   //bank 0 of first flash
668   MCFG_FUJITSU_29DL16X_ADD("flash0b")   //bank 1 of first flash
669   MCFG_FUJITSU_29DL16X_ADD("flash1a")   //bank 0 of second flash
670   MCFG_FUJITSU_29DL16X_ADD("flash1b")   //bank 1 of second flash
671
563672   /* internal ram */
564673   MCFG_RAM_ADD(RAM_TAG)
565674   MCFG_RAM_DEFAULT_SIZE("32K")
r11282r11283
572681
573682/* ROM definition */
574683ROM_START( rex6000 )
575    ROM_REGION( 0x200000, "flash0", ROMREGION_ERASE )
576   ROM_LOAD( "rex6000.dat", 0x0000, 0x200000, CRC(b476f7e0) SHA1(46a56634576408a5b0dca80aea08513e856c3bb1))
684    ROM_REGION( 0x200000, "flash0a", ROMREGION_ERASE )
685   ROM_LOAD( "rex6000_0.dat", 0x0000, 0x100000, BAD_DUMP CRC(e7a7324f) SHA1(01adcd469c93984438cbd4bf6e5a46e74da500d0))
577686
578    ROM_REGION( 0x200000, "flash1", ROMREGION_ERASE )
579   ROM_LOAD( "rex6000_1.dat", 0x0000, 0x200000, NO_DUMP)
687    ROM_REGION( 0x200000, "flash0b", ROMREGION_ERASE )
688   ROM_LOAD( "rex6000_1.dat", 0x0000, 0x100000, BAD_DUMP CRC(cc4b51db) SHA1(73b655e21ece30e8dc60f2f09719bc446492cc0f))
689
690    ROM_REGION( 0x200000, "flash1a", ROMREGION_ERASE )
691   ROM_LOAD( "rex6000_2.dat", 0x0000, 0x100000, NO_DUMP)
692
693    ROM_REGION( 0x200000, "flash1b", ROMREGION_ERASE )
694   ROM_LOAD( "rex6000_3.dat", 0x0000, 0x100000, NO_DUMP)
580695ROM_END
581696
582697ROM_START( ds2 )
583    ROM_REGION( 0x200000, "flash0", ROMREGION_ERASE )
584   ROM_LOAD( "ds2.dat", 0x0000, 0x200000, BAD_DUMP CRC(67d675b3) SHA1(fcdc6a736cfbc83103b6613ab7fac96dbbda4948))
698    ROM_REGION( 0x200000, "flash0a", ROMREGION_ERASE )
699   ROM_LOAD( "ds2_0.dat", 0x0000, 0x100000, BAD_DUMP CRC(3197bed3) SHA1(9f826fd6d23ced797daae666d88ced14d24b64c3))
585700
586   ROM_REGION( 0x200000, "flash1", ROMREGION_ERASE )
587   ROM_LOAD( "ds2_1.dat", 0x0000, 0x200000, NO_DUMP)
701   ROM_REGION( 0x200000, "flash0b", ROMREGION_ERASE )
702   ROM_LOAD( "ds2_1.dat", 0x0000, 0x100000, BAD_DUMP CRC(a909b755) SHA1(4db8a44539b9f94d418c33bbd794afb9bacbbadd))
703
704    ROM_REGION( 0x200000, "flash1a", ROMREGION_ERASE )
705   ROM_LOAD( "ds2_2.dat", 0x0000, 0x100000, NO_DUMP)
706
707    ROM_REGION( 0x200000, "flash1b", ROMREGION_ERASE )
708   ROM_LOAD( "ds2_3.dat", 0x0000, 0x100000, NO_DUMP)
588709ROM_END
589710
590711/* Driver */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team