Previous 15994 Revisions Next

r12980 Tuesday 4th October, 2011 at 02:49:36 UTC by Robbbert
POLGAR - modernised.
[src/mess/drivers]polgar.c

src/mess/drivers/polgar.c
r12979r12980
3232
3333
3434*/
35#define ADDRESS_MAP_MODERN
3536
3637#include "emu.h"
3738#include "cpu/m6502/m6502.h"
3839#include "sound/beep.h"
3940// #include "milano.lh"
4041#include "video/hd44780.h"
41// #include "render.h"
42// #include "rendlay.h"
4342// #include "uiinput.h"
4443#include "machine/mboard.h"
4544#include "rendlay.h"
r12979r12980
4847{
4948public:
5049   polgar_state(const machine_config &mconfig, device_type type, const char *tag)
51      : driver_device(mconfig, type, tag) { }
50      : driver_device(mconfig, type, tag),
51   m_maincpu(*this, "maincpu"),
52   m_beep(*this, BEEPER_TAG),
53   m_lcdc(*this, "hd44780")
54   { }
5255
56   required_device<cpu_device> m_maincpu;
57   required_device<device_t> m_beep;
58   required_device<hd44780_device> m_lcdc;
59   DECLARE_WRITE8_MEMBER(write_io);
60   DECLARE_WRITE8_MEMBER(write_lcd);
61   DECLARE_WRITE8_MEMBER(milano_write_led);
62   DECLARE_WRITE8_MEMBER(write_led);
63   DECLARE_WRITE8_MEMBER(milano_write_board);
64   DECLARE_READ8_MEMBER(milano_read_board);
65   DECLARE_READ8_MEMBER(read_keys);
5366   UINT8 m_led_status;
5467   UINT8 m_lcd_char;
5568   UINT8 m_led7;
r12979r12980
102115   return NOT_VALID;
103116}
104117
105static WRITE8_HANDLER ( write_io )
118WRITE8_MEMBER( polgar_state::write_io )
106119{
107   polgar_state *state = space->machine().driver_data<polgar_state>();
108   int i;
109   hd44780_device * hd44780 = space->machine().device<hd44780_device>("hd44780");
110   device_t *speaker = space->machine().device(BEEPER_TAG);
120   UINT8 i;
111121
112   if (BIT(data,1)) {
113      if (BIT(data,0)) {
114         hd44780->data_write(*space, 128, state->m_lcd_char);
115      } else {
116         hd44780->control_write(*space, 128, state->m_lcd_char);
117      }
122   if (BIT(data,1))
123   {
124      if (BIT(data,0))
125         m_lcdc->data_write(space, 128, m_lcd_char);
126      else
127         m_lcdc->control_write(space, 128, m_lcd_char);
118128   }
119129
120   if (BIT(data,2) || BIT(data,3)) beep_set_state(speaker,1); else beep_set_state(speaker,0);
130   if (BIT(data,2) || BIT(data,3))
131      beep_set_state(m_beep, 1);
132   else
133      beep_set_state(m_beep, 0);
121134
122135   if (BIT(data,7) && BIT(data, 4))
123136   {
124137      for (i=0;i<8;i++)
125      output_set_led_value(i,!BIT(state->m_latch_data,i));
138      output_set_led_value(i,!BIT(m_latch_data,i));
126139   }
127   else if (BIT(data,6) && BIT(data,5))
140   else
141   if (BIT(data,6) && BIT(data,5))
128142   {
129143      for (i=0;i<8;i++)
130      output_set_led_value(10+i,!BIT(state->m_latch_data,7-i));
144      output_set_led_value(10+i,!BIT(m_latch_data,7-i));
131145   }
132   else if (!data && (!strcmp(space->machine().system().name,"milano")))
146   else
147   if (!data && (!strcmp(machine().system().name,"milano")))
148   {
133149      for (i=0;i<8;i++)
134150      {
135         output_set_led_value(i,!BIT(state->m_latch_data,i));
136         output_set_led_value(10+i,!BIT(state->m_latch_data,7-i));
151         output_set_led_value(i,!BIT(m_latch_data,i));
152         output_set_led_value(10+i,!BIT(m_latch_data,7-i));
137153      }
154   }
138155
139
140156   //logerror("LCD Status  Data = %d\n",data);
141
142
143157}
144158
145static WRITE8_HANDLER ( write_lcd )
159WRITE8_MEMBER( polgar_state::write_lcd )
146160{
147   polgar_state *state = space->machine().driver_data<polgar_state>();
161   m_lcd_char=data;
148162
149   state->m_lcd_char=data;
150
151163   //logerror("LCD Data = %d [%c]\n",data,(data&0xff));
152164
153165}
154166
155static WRITE8_HANDLER ( milano_write_led )
167WRITE8_MEMBER( polgar_state::milano_write_led )
156168{
157169   UINT8 LED_offset=100;
158170   if (data==0xff)
r12979r12980
163175//  logerror("milano_write_led Offset = %d Data = %d\n",offset,data);
164176}
165177
166static WRITE8_HANDLER ( write_led )
178WRITE8_MEMBER( polgar_state::write_led )
167179{
168   polgar_state *state = space->machine().driver_data<polgar_state>();
169180   UINT8 LED_offset=100;
170181   data &= 0x80;
171182
172   if (data==0)state->m_led_status &= 255-(1<<offset) ; else state->m_led_status|=1<<offset;
173   if (offset<6)output_set_led_value(LED_offset+offset, state->m_led_status&1<<offset?1:0);
174   if (offset==7) state->m_led7=data& 0x80 ? 0x00 :0xff;
183   if (data==0)m_led_status &= 255-(1<<offset) ; else m_led_status|=1<<offset;
184   if (offset<6)output_set_led_value(LED_offset+offset, m_led_status&1<<offset?1:0);
185   if (offset==7) m_led7=data& 0x80 ? 0x00 :0xff;
175186   logerror("LEDs  Offset = %d Data = %d\n",offset,data);
176187}
177188
178189#if 0
179static WRITE8_HANDLER ( write_led )
190WRITE8_MEMBER( polgar_state::write_led )
180191{
181   polgar_state *state = space->machine().driver_data<polgar_state>();
182192   UINT8 LED_offset=100;
183193   if (data==0xff)
184194      output_set_led_value(LED_offset+offset,1);
185195   else
186196      output_set_led_value(LED_offset+offset,0);
187   if (data==0)state->m_led_status &= 255-(1<<offset) ; else state->m_led_status|=1<<offset;
188   if (offset<6)output_set_led_value(LED_offset+offset, state->m_led_status&1<<offset?1:0);
189   if (offset==7) state->m_led7=data& 0x80 ? 0x00 :0xff;
197   if (data==0)m_led_status &= 255-(1<<offset) ; else m_led_status|=1<<offset;
198   if (offset<6)output_set_led_value(LED_offset+offset, m_led_status&1<<offset?1:0);
199   if (offset==7) m_led7=data& 0x80 ? 0x00 :0xff;
190200
191201
192202   logerror("LEDs  Offset = %d Data = %d\n",offset,data);
193203}
194204#endif
195205
196static WRITE8_HANDLER ( milano_write_board )
206WRITE8_MEMBER( polgar_state::milano_write_board )
197207{
198   polgar_state *state = space->machine().driver_data<polgar_state>();
199
200   state->m_latch_data=data;
208   m_latch_data=data;
201209}
202210
203static READ8_HANDLER(milano_read_board)
211READ8_MEMBER( polgar_state::milano_read_board )
204212{
205213   int line;
206   polgar_state *state = space->machine().driver_data<polgar_state>();
207214   static const char *const board_lines[8] =
208215         { "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", "LINE8", "LINE9" };
209216
210217   UINT8 data=0x00;
211218   UINT8 tmp=0xff;
212219
213   if (state->m_latch_data)
220   if (m_latch_data)
214221   {
215      line=get_first_cleared_bit(state->m_latch_data);
216      tmp=input_port_read(space->machine(),  board_lines[line]);
222      line=get_first_cleared_bit(m_latch_data);
223      tmp=input_port_read(machine(),  board_lines[line]);
217224
218225      if (tmp != 0xff)
219226         data=convert_imputmask(tmp);
r12979r12980
224231
225232}
226233
227static READ8_HANDLER(read_keys)
234READ8_MEMBER( polgar_state::read_keys )
228235{
229   //polgar_state *state = space->machine().driver_data<polgar_state>();
230236   UINT8 data;
231   static const char *const keynames[2][8] =
232         {
233            { "KEY1_0", "KEY1_1", "KEY1_2", "KEY1_3", "KEY1_4", "KEY1_5", "KEY1_6", "KEY1_7" },
234            { "KEY2_0", "KEY2_1", "KEY2_2", "KEY2_3", "KEY2_4", "KEY2_5", "KEY2_6", "KEY2_7" }
235         };
237   static const char *const keynames[8] =
238         { "KEY1_0", "KEY1_1", "KEY1_2", "KEY1_3", "KEY1_4", "KEY1_5", "KEY1_6", "KEY1_7" };
236239
237   data = 0xff;
238240#if 0
239   if (((state->m_led_status & 0x80) == 0x00))
240      data=input_port_read(space->machine(), keynames[0][offset]);
241   if (((m_led_status & 0x80) == 0x00))
242      data=input_port_read(machine(), keynames[0][offset]);
241243   else
242      data=input_port_read(space->machine(), keynames[1][offset]);
244      data=input_port_read(machine(), keynames[1][offset]);
243245#endif
244   data=input_port_read(space->machine(), keynames[0][offset]);
246   data=input_port_read(machine(), keynames[offset]);
245247
246   // logerror("Keyboard Port = %s Data = %d\n  ", ((state->m_led_status & 0x80) == 0x00) ? keynames[0][offset] : keynames[1][offset], data);
247248   return data | 0x7f;
248249}
249250
r12979r12980
284285GFXDECODE_END
285286
286287
287static ADDRESS_MAP_START(polgar_mem , AS_PROGRAM, 8)
288static ADDRESS_MAP_START( polgar_mem, AS_PROGRAM, 8, polgar_state )
288289   AM_RANGE( 0x0000, 0x1fff) AM_RAM
289   AM_RANGE( 0x2400, 0x2407) AM_WRITE ( mboard_write_LED_8 )      // Chessboard
290   AM_RANGE( 0x2800, 0x2800) AM_WRITE ( mboard_write_board_8)      // Chessboard
291   AM_RANGE( 0x3000, 0x3000) AM_READ( mboard_read_board_8 )      // Chessboard
292   AM_RANGE( 0x3400, 0x3405) AM_WRITE( write_led)   // Function LEDs 3400 TRN 3401
293   AM_RANGE( 0x2c00, 0x2c07) AM_READ( read_keys)   // CL Key
294   AM_RANGE( 0x2004, 0x2004) AM_WRITE( write_io)   // LCD Instr. Reg + Beeper
295   AM_RANGE( 0x2000, 0x2000) AM_WRITE( write_lcd)   // LCD Char Reg.
290   AM_RANGE( 0x2000, 0x2000) AM_WRITE(write_lcd)   // LCD Char Reg.
291   AM_RANGE( 0x2004, 0x2004) AM_WRITE(write_io)   // LCD Instr. Reg + Beeper
292   AM_RANGE( 0x2400, 0x2407) AM_WRITE_LEGACY(mboard_write_LED_8 )      // Chessboard
293   AM_RANGE( 0x2800, 0x2800) AM_WRITE_LEGACY(mboard_write_board_8)      // Chessboard
294   AM_RANGE( 0x2c00, 0x2c07) AM_READ(read_keys)   // CL Key
295   AM_RANGE( 0x3000, 0x3000) AM_READ_LEGACY(mboard_read_board_8 )      // Chessboard
296   AM_RANGE( 0x3400, 0x3405) AM_WRITE(write_led)   // Function LEDs 3400 TRN 3401
296297   AM_RANGE( 0x4000, 0xffff) AM_ROM
297298ADDRESS_MAP_END
298299
299300
300static ADDRESS_MAP_START(milano_mem , AS_PROGRAM, 8)
301static ADDRESS_MAP_START( milano_mem, AS_PROGRAM, 8, polgar_state )
301302   AM_RANGE( 0x0000, 0x1f9f) AM_RAM
302   AM_RANGE( 0x1fd0, 0x1fd0) AM_WRITE ( milano_write_board)   // Chessboard
303   AM_RANGE( 0x1fe0, 0x1fe0) AM_READ( milano_read_board )      // Chessboard
304   AM_RANGE( 0x1fe8, 0x1fed) AM_WRITE( milano_write_led )   // Function LEDs 3400 TRN 3401
305   AM_RANGE( 0x1fd8, 0x1fdf) AM_READ( read_keys)   // CL Key
306   AM_RANGE( 0x1ff0, 0x1ff0) AM_WRITE( write_io)   // IO control
307   AM_RANGE( 0x1fc0, 0x1fc0) AM_WRITE( write_lcd)   // LCD Char Reg. (latched)
303   AM_RANGE( 0x1fc0, 0x1fc0) AM_WRITE(write_lcd)   // LCD Char Reg. (latched)
304   AM_RANGE( 0x1fd0, 0x1fd0) AM_WRITE(milano_write_board)   // Chessboard
305   AM_RANGE( 0x1fe0, 0x1fe0) AM_READ(milano_read_board)      // Chessboard
306   AM_RANGE( 0x1fe8, 0x1fed) AM_WRITE(milano_write_led)   // Function LEDs 3400 TRN 3401
307   AM_RANGE( 0x1fd8, 0x1fdf) AM_READ(read_keys)   // CL Key
308   AM_RANGE( 0x1ff0, 0x1ff0) AM_WRITE(write_io)   // IO control
308309   AM_RANGE( 0x2000, 0xffff) AM_ROM
309310ADDRESS_MAP_END
310311
r12979r12980
409410INPUT_PORTS_END
410411
411412static INPUT_PORTS_START( polgar )
412  PORT_INCLUDE( board )
413   PORT_INCLUDE( board )
413414   PORT_START("KEY1_0") //Port $2c00
414415   PORT_BIT(0x080, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Trn") PORT_CODE(KEYCODE_F1)
415416   PORT_START("KEY1_1") //Port $2c01
r12979r12980
461462   MCFG_MACHINE_RESET( polgar )
462463
463464   /* video hardware */
464   // MCFG_DEFAULT_LAYOUT(layout_milano)
465465   MCFG_SCREEN_ADD("screen", LCD)
466466   MCFG_SCREEN_REFRESH_RATE(50)
467467   MCFG_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
468468   MCFG_SCREEN_SIZE(100, 20)
469469   MCFG_SCREEN_VISIBLE_AREA(0, 100-1, 0, 20-1)
470   MCFG_VIDEO_START(polgar)
470471   MCFG_SCREEN_UPDATE(polgar)
471
472472   MCFG_PALETTE_LENGTH(2)
473473   MCFG_PALETTE_INIT(polgar)
474
475474   MCFG_GFXDECODE(polgar)
476475
477476   MCFG_HD44780_ADD("hd44780", polgar_display)
478477
479   MCFG_VIDEO_START(polgar)
480
481
482   //MCFG_DEFAULT_LAYOUT(layout_van16)
483478   MCFG_DEFAULT_LAYOUT(layout_lcd)
479   //MCFG_DEFAULT_LAYOUT(layout_van16)
480   // MCFG_DEFAULT_LAYOUT(layout_milano)
484481
485
486482   /* sound hardware */
487483   MCFG_SPEAKER_STANDARD_MONO("mono")
488484   MCFG_SOUND_ADD(BEEPER_TAG, BEEP, 0)
489   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
485   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
490486
491487   //MCFG_TIMER_ADD_PERIODIC("led_timer", update_leds, attotime::from_hz(60))
492488   MCFG_TIMER_ADD_PERIODIC("nmi_timer", update_nmi, attotime::from_hz(600))
r12979r12980
503499MACHINE_CONFIG_END
504500
505501ROM_START(milano)
506   ROM_REGION(0x10000,"maincpu",0)
502   ROM_REGION( 0x10000, "maincpu", 0 )
507503   ROM_LOAD("milano.bin", 0x0000, 0x10000, CRC(0e9c8fe1) SHA1(e9176f42d86fe57e382185c703c7eff7e63ca711))
508   ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
509   ROM_LOAD( "44780a00.bin", 0x0000, 0x0860,  BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
504   ROM_REGION( 0x0860, "hd44780", 0 )
505   ROM_LOAD("44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
510506ROM_END
511507
512
513
514ROM_START(polgar) //polgar
515   ROM_REGION(0x10000,"maincpu",0)
508ROM_START(polgar)
509   ROM_REGION( 0x10000, "maincpu", 0 )
516510   ROM_LOAD("polgar.bin", 0x0000, 0x10000, CRC(88d55c0f) SHA1(e86d088ec3ac68deaf90f6b3b97e3e31b1515913))
517   ROM_REGION( 0x0860, "hd44780", ROMREGION_ERASE )
518   ROM_LOAD( "44780a00.bin", 0x0000, 0x0860,  BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
511   ROM_REGION( 0x0860, "hd44780", 0 )
512   ROM_LOAD("44780a00.bin", 0x0000, 0x0860, BAD_DUMP CRC(3a89024c) SHA1(5a87b68422a916d1b37b5be1f7ad0b3fb3af5a8d))
519513ROM_END
520514
521515
r12979r12980
532526***************************************************************************/
533527
534528/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        COMPANY             FULLNAME                            FLAGS */
535//CONS( 1983, mephisto,   0,      0,      mephisto,   mephisto,   mephisto, "Hegener & Glaser", "Mephisto Polgar Computer",        GAME_NOT_WORKING )
529//CONS( 1983, mephisto,   0,      0,      mephisto,   mephisto, mephisto, "Hegener & Glaser", "Mephisto Polgar Computer", GAME_NOT_WORKING )
536530CONS( 1986, polgar,     0,      0,      polgar,     polgar,   polgar,   "Hegener & Glaser", "Mephisto Polgar Schach Computer", 0 )
537CONS( 1986, milano,     polgar,      0,      milano,     polgar,   polgar,   "Hegener & Glaser", "Mephisto Milano Schach Computer", 0 )
531CONS( 1986, milano,     polgar, 0,      milano,     polgar,   polgar,   "Hegener & Glaser", "Mephisto Milano Schach Computer", 0 )
538532// milano to be added to supercon.c driver - no current messdriv.c entry
539533// second design sold (same computer/program?)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team