Previous 15994 Revisions Next

r15884 Monday 13th August, 2012 at 20:03:12 UTC by Sandro Ronco
digel804: fixed user RAM banking and some cleanup. (nw)
[src/mess/drivers]digel804.c

src/mess/drivers/digel804.c
r15883r15884
5252
5353// port 47 write is tim0-tim7
5454
55// collated serial data sent to vfd
56#undef VFD_VERBOSE
5755
58
5956/* Core includes */
6057#include "emu.h"
6158#include "cpu/z80/z80.h"
r15883r15884
6461#include "machine/roc10937.h"
6562#include "machine/6551acia.h"
6663#include "machine/mm74c922.h"
64#include "machine/ram.h"
6765#include "digel804.lh"
6866
6967
r15883r15884
7775        m_speaker(*this, "speaker"),
7876        m_acia(*this, "acia"),
7977        m_vfd(*this, "vfd"),
80        m_kb(*this, "74c923")
78        m_kb(*this, "74c923"),
79        m_ram(*this, RAM_TAG)
8180      //, m_main_ram(*this, "main_ram")
8281      { }
8382
r15883r15884
8786   required_device<acia6551_device> m_acia;
8887   required_device<roc10937_t> m_vfd;
8988   required_device<mm74c922_device> m_kb;
89   required_device<ram_device> m_ram;
9090
9191   virtual void machine_reset();
92   DECLARE_DRIVER_INIT(digel804);
93   DECLARE_WRITE8_MEMBER( op00 );
9294   DECLARE_READ8_MEMBER( ip40 );
9395   DECLARE_WRITE8_MEMBER( op40 );
9496   DECLARE_WRITE8_MEMBER( op41 );
9597   DECLARE_WRITE8_MEMBER( op42 );
9698   DECLARE_READ8_MEMBER( ip43 );
9799   DECLARE_WRITE8_MEMBER( op43 );
100   DECLARE_WRITE8_MEMBER( op43_1_4 );
98101   DECLARE_WRITE8_MEMBER( op44 );
99102   DECLARE_WRITE8_MEMBER( op45 );
100103   DECLARE_READ8_MEMBER( ip46 );
r15883r15884
111114   DECLARE_WRITE_LINE_MEMBER( da_w );
112115   DECLARE_INPUT_CHANGED_MEMBER(mode_change);
113116   // vfd helper stuff for port 44, should be unnecessary after 10937 gets a proper device
114   UINT8 vfd_data;
115   UINT8 vfd_old;
116   UINT8 vfd_count;
117   UINT8 m_vfd_sclk;
117118   // current speaker state for port 45
118119   UINT8 m_speaker_state;
119120   // ram stuff for banking
r15883r15884
130131   UINT8 m_chipinsert_state;
131132   UINT8 m_keyen_state;
132133   UINT8 m_op41;
133   DECLARE_DRIVER_INIT(digel804);
134134};
135135
136136
r15883r15884
139139
140140DRIVER_INIT_MEMBER(digel804_state,digel804)
141141{
142   vfd_old = vfd_data = vfd_count = 0;
143142   m_speaker_state = 0;
144143   //port43_rtn = 0xEE;//0xB6;
145144   m_acia_intq = 1; // /INT source 1
r15883r15884
153152   m_ram_bank = 0;
154153   m_op41 = 0;
155154   m_keyen_state = 1; // /KEYEN
156   membank( "bankedram" )->set_base( memregion("user_ram")->base() + ( m_ram_bank * 0x10000 ));
155
156   membank( "bankedram" )->set_base(m_ram->pointer());
157157}
158158
159159void digel804_state::machine_reset()
160160{
161161   m_vfd->reset();
162   vfd_old = vfd_data = vfd_count = 0;
162   m_vfd_sclk = 0;
163163}
164164
165165READ8_MEMBER( digel804_state::ip40 ) // eprom data bus read
r15883r15884
178178{
179179   // TODO: would be nice to have a 'fake eprom' here
180180   logerror("Digel804: port 41, eprom address low/sim/memorybank had %02X written to it!\n", data);
181   fprintf(stderr,"op41 write of %02X, ram mapper bit is %d\n", data, (data&0x40)?1:0);
181   //fprintf(stderr,"op41 write of %02X, ram mapper bit is %d\n", data, (data&0x40)?1:0);
182182   m_op41 = data;
183183}
184184
r15883r15884
216216     0xFE 11111110
217217
218218    */
219   // HACK to dump display contents to stderr
220//  FIXME : not sure what to do here with the new device! 201207
221//  fprintf(stderr,"%s\n",ROC10937_get_string(0));
219
222220#ifdef PORT43_R_VERBOSE
223221   logerror("Digel804: returning %02X for port 43 status read\n", port43_rtn);
224222#endif
r15883r15884
233231
234232}
235233
234WRITE8_MEMBER( digel804_state::op00 )
235{
236   m_ram_bank = data;
237   membank( "bankedram" )->set_base(m_ram->pointer() + ((m_ram_bank * 0x8000) & m_ram->mask()));
238}
239
236240WRITE8_MEMBER( digel804_state::op43 )
237241{
238242   /* writes to 0x43 control the ram banking on firmware which supports it
r15883r15884
250254   m_ram_bank = data&7;
251255   if ((data&0xF8)!=0)
252256      logerror("Digel804: port 0x43 ram bank had unexpected data %02x written to it!\n", data);
253   membank( "bankedram" )->set_base( memregion("user_ram")->base() + ( m_ram_bank * 0x10000 ));
254257
258   membank( "bankedram" )->set_base(m_ram->pointer() + ((m_ram_bank * 0x8000) & m_ram->mask()));
255259}
256260
261WRITE8_MEMBER( digel804_state::op43_1_4 )
262{
263   m_overload_state = 0; // writes to port 43 clear overload state
264}
265
257266WRITE8_MEMBER( digel804_state::op44 ) // state write
258267{
259268   /* writes to 0x44 control the 10937 vfd chip, z80 power/busrq, eprom driving and some eprom power ctl lines
r15883r15884
275284   logerror("Digel804: port 0x44 vfd/state control had %02x written to it!\n", data);
276285#endif
277286   // latch vfd data on falling edge of clock only; this should really be part of the 10937 device, not here!
278   if ((vfd_old&1) && ((data&1)==0))
287   if (m_vfd_sclk && ((data&1)==0))
279288   {
280289      m_vfd->shift_data((data & 0x80) ? 0 : 1);
281
282      vfd_data <<= 1;
283      vfd_data |= (data&0x80)?1:0;
284      vfd_count++;
285      if (vfd_count == 8)
286      {
287#ifdef VFD_VERBOSE
288         logerror("Digel804: Full byte written to port 44 vfd: %02X '%c'\n", vfd_data, vfd_data);
289#endif
290         vfd_data = 0;
291         vfd_count = 0;
292      }
293290   }
294   vfd_old = data;
291   m_vfd_sclk = data & 1;
295292}
296293
297294WRITE8_MEMBER( digel804_state::op45 ) // speaker write
r15883r15884
337334#ifdef PORT46_W_VERBOSE
338335    logerror("Digel804: port 0x46 LED control had %02x written to it!\n", data);
339336#endif
340    popmessage("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF));
337    //popmessage("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF));
341338    //fprintf("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF));
342339
343340   output_set_value("input_led", BIT(data,7));
r15883r15884
457454   // d800-ffff is open bus in mapper, 7f
458455ADDRESS_MAP_END
459456
460static ADDRESS_MAP_START(z80_io, AS_IO, 8, digel804_state)
457static ADDRESS_MAP_START(z80_io_1_4, AS_IO, 8, digel804_state)
461458   ADDRESS_MAP_UNMAP_HIGH
462459   ADDRESS_MAP_GLOBAL_MASK(0xff)
463460   // io bits: x 1 x x x * * *
464461   // writes to 47, 4e, 57, 5e, 67, 6e, 77, 7e, c7, ce, d7, de, e7, ee, f7, fe all go to 47, same with reads
462   AM_RANGE(0x00, 0x00) AM_MIRROR(0xB8) AM_WRITE(op00) // W, banked ram
465463   AM_RANGE(0x40, 0x40) AM_MIRROR(0xB8) AM_READWRITE(ip40, op40) // RW, eprom socket data bus input/output value
466464   AM_RANGE(0x41, 0x41) AM_MIRROR(0xB8) AM_WRITE(op41) // W, eprom socket address low out
467465   AM_RANGE(0x42, 0x42) AM_MIRROR(0xB8) AM_WRITE(op42) // W, eprom socket address hi/control out
466   AM_RANGE(0x43, 0x43) AM_MIRROR(0xB8) AM_READWRITE(ip43, op43_1_4) // RW, mode and status register, also checks if keypad is pressed; write is unknown
467   AM_RANGE(0x44, 0x44) AM_MIRROR(0xB8) AM_WRITE(op44) // W, 10937 vfd controller, z80 power and state control reg
468   AM_RANGE(0x45, 0x45) AM_MIRROR(0xB8) AM_WRITE(op45) // W, speaker bit; every write inverts state
469   AM_RANGE(0x46, 0x46) AM_MIRROR(0xB8) AM_READWRITE(ip46, op46) // RW, reads keypad, writes controls the front panel leds.
470   AM_RANGE(0x47, 0x47) AM_MIRROR(0xB8) AM_WRITE(op47) // W eprom socket power and timing control
471   // io bits: 1 0 x x x * * *
472   // writes to 80, 88, 90, 98, a0, a8, b0, b8 all go to 80, same with reads
473   AM_RANGE(0x80, 0x80) AM_MIRROR(0x38) AM_WRITE(acia_txd_w) // (ACIA xmit reg)
474   AM_RANGE(0x81, 0x81) AM_MIRROR(0x38) AM_READ(acia_rxd_r) // (ACIA rcv reg)
475   AM_RANGE(0x82, 0x82) AM_MIRROR(0x38) AM_WRITE(acia_reset_w) // (ACIA reset reg)
476   AM_RANGE(0x83, 0x83) AM_MIRROR(0x38) AM_READ(acia_status_r) // (ACIA status reg)
477   AM_RANGE(0x84, 0x84) AM_MIRROR(0x38) AM_WRITE(acia_command_w) // (ACIA command reg)
478   AM_RANGE(0x85, 0x85) AM_MIRROR(0x38) AM_READ(acia_command_r) // (ACIA command reg)
479   AM_RANGE(0x86, 0x86) AM_MIRROR(0x38) AM_WRITE(acia_control_w) // (ACIA control reg)
480   AM_RANGE(0x87, 0x87) AM_MIRROR(0x38) AM_READ(acia_control_r) // (ACIA control reg)
481   //AM_RANGE(0x80,0x87) AM_MIRROR(0x38) AM_SHIFT(-1) AM_DEVREADWRITE("acia", acia6551_device, read, write) // this doesn't work since we lack an AM_SHIFT command
482
483ADDRESS_MAP_END
484
485static ADDRESS_MAP_START(z80_io_1_2, AS_IO, 8, digel804_state)
486   ADDRESS_MAP_UNMAP_HIGH
487   ADDRESS_MAP_GLOBAL_MASK(0xff)
488   // io bits: x 1 x x x * * *
489   // writes to 47, 4e, 57, 5e, 67, 6e, 77, 7e, c7, ce, d7, de, e7, ee, f7, fe all go to 47, same with reads
490   AM_RANGE(0x40, 0x40) AM_MIRROR(0xB8) AM_READWRITE(ip40, op40) // RW, eprom socket data bus input/output value
491   AM_RANGE(0x41, 0x41) AM_MIRROR(0xB8) AM_WRITE(op41) // W, eprom socket address low out
492   AM_RANGE(0x42, 0x42) AM_MIRROR(0xB8) AM_WRITE(op42) // W, eprom socket address hi/control out
468493   AM_RANGE(0x43, 0x43) AM_MIRROR(0xB8) AM_READWRITE(ip43, op43) // RW, mode and status register, also checks if keypad is pressed; write is unknown
469494   AM_RANGE(0x44, 0x44) AM_MIRROR(0xB8) AM_WRITE(op44) // W, 10937 vfd controller, z80 power and state control reg
470495   AM_RANGE(0x45, 0x45) AM_MIRROR(0xB8) AM_WRITE(op45) // W, speaker bit; every write inverts state
r15883r15884
564589   /* basic machine hardware */
565590   MCFG_CPU_ADD("maincpu", Z80, XTAL_3_6864MHz/2) /* Z80A, X1(aka E0 on schematics): 3.6864Mhz */
566591   MCFG_CPU_PROGRAM_MAP(z80_mem_804_1_4)
567   MCFG_CPU_IO_MAP(z80_io)
592   MCFG_CPU_IO_MAP(z80_io_1_4)
568593   MCFG_QUANTUM_TIME(attotime::from_hz(60))
569594
570595   MCFG_ROC10937_ADD("vfd",0,RIGHT_TO_LEFT)
r15883r15884
579604   /* acia */
580605   MCFG_ACIA6551_ADD("acia")
581606
607   MCFG_RAM_ADD(RAM_TAG)
608   MCFG_RAM_DEFAULT_SIZE("256K")
609   MCFG_RAM_EXTRA_OPTIONS("32K,64K,128K")
610
582611   /* sound hardware */
583612   MCFG_SPEAKER_STANDARD_MONO("mono")
584613   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
585614   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
586615MACHINE_CONFIG_END
587616
588/* TODO: make this copy the digel804 machine config and modify the program map! */
589static MACHINE_CONFIG_START( ep804, digel804_state )
617static MACHINE_CONFIG_DERIVED( ep804, digel804 )
590618   /* basic machine hardware */
591   MCFG_CPU_ADD("maincpu", Z80, XTAL_3_6864MHz/2) /* Z80, X1(aka E0 on schematics): 3.6864Mhz */
619   MCFG_CPU_MODIFY("maincpu")   /* Z80, X1(aka E0 on schematics): 3.6864Mhz */
592620   MCFG_CPU_PROGRAM_MAP(z80_mem_804_1_2)
593   MCFG_CPU_IO_MAP(z80_io)
594   MCFG_QUANTUM_TIME(attotime::from_hz(60))
621   MCFG_CPU_IO_MAP(z80_io_1_2)
595622
596   MCFG_ROC10937_ADD("vfd",0,RIGHT_TO_LEFT)
597
598   /* video hardware */
599   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf)
600
601   MCFG_DEFAULT_LAYOUT(layout_digel804)
602
603   MCFG_MM74C923_ADD("74c923", digel804_keypad_intf)
604
605   /* acia */
606   MCFG_ACIA6551_ADD("acia")
607
608   /* sound hardware */
609   MCFG_SPEAKER_STANDARD_MONO("mono")
610   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
611   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
623   MCFG_RAM_MODIFY(RAM_TAG)
624   MCFG_RAM_DEFAULT_SIZE("32K")
625   MCFG_RAM_EXTRA_OPTIONS("64K")
612626MACHINE_CONFIG_END
613627
614628
r15883r15884
660674*/
661675
662676ROM_START(digel804) // address mapper 804-1-4
663   ROM_REGION(0x80000, "user_ram", ROMREGION_ERASEFF)
664677   ROM_REGION(0x10000, "maincpu", 0)
665678   ROM_LOAD("1-04__76f1.27128.d41", 0x0000, 0x4000, CRC(61b50b61) SHA1(ad717fcbf3387b0a8fb0546025d3c527792eb3f0))
666679   // the second rom here is loaded bizarrely: the first 3/4 appears at e000-f7ff and the last 1/4 appears at d800-dfff
r15883r15884
671684ROM_END
672685
673686ROM_START(ep804) // address mapper 804-1-2
674   ROM_REGION(0x80000, "user_ram", ROMREGION_ERASEFF)
675687   ROM_REGION(0x10000, "maincpu", 0)
676688   ROM_DEFAULT_BIOS("ep804_v1.6")
677689   ROM_SYSTEM_BIOS( 0, "ep804_v1.6", "Wavetek/Digelec EP804 FWv1.6") // hardware 1.1

Previous 15994 Revisions Next


© 1998-2018 The MESS Team