Previous 15994 Revisions Next

r8660 Saturday 31st July, 2010 at 08:53:54 UTC by Angelo Salese
[BASIC MASTER LV3]: Improved keyboard polling
[src/mess/drivers]bml3.c

src/mess/drivers/bml3.c
r8659r8660
88   - no documentation, the entire driver is just a bunch of educated
99      guesses ...
1010   - keyboard shift key, necessary for some key commands
11   - understand how to load a tape
1112   - every time that you switch with NEW ON command, there's a "device i/o error" if
1213     the hres_reg bit 5 is active.
1314
r8659r8660
3435static UINT16 cursor_addr,cursor_raster;
3536static UINT8 attr_latch,io_latch;
3637static UINT8 hres_reg, vres_reg;
38static UINT8 keyb_press,keyb_press_flag;
3739
3840static VIDEO_START( bml3 )
3941{
r8659r8660
5254   width = (hres_reg & 0x80) ? 80 : 40;
5355   height = (vres_reg & 0x08) ? 1 : 0;
5456
55   popmessage("%02x %02x",hres_reg,vres_reg);
57//   popmessage("%02x %02x",hres_reg,vres_reg);
5658
5759   for(y=0;y<25;y++)
5860   {
r8659r8660
146148
147149static READ8_HANDLER( bml3_keyboard_r )
148150{
149   const char* portnames[3] = { "key1","key2","key3" };
150   int i,port_i,scancode;
151   scancode = 0;
152
153   for(port_i=0;port_i<3;port_i++)
151   if(keyb_press_flag)
154152   {
155      for(i=0;i<32;i++)
156      {
157         if((input_port_read(space->machine,portnames[port_i])>>i) & 1)
158            return scancode | 0x80;
159
160         scancode++;
161      }
153      int res;
154      res = keyb_press;
155      keyb_press = keyb_press_flag = 0;
156      return res | 0x80;
162157   }
163158
164159   return 0;
r8659r8660
171166
172167   if(offset == 0x19) return io_latch;
173168   if(offset == 0xc4) return 0xff; //some video modes wants this to be high
174//maybe 0xc4 is the status and 0xc5 the data? d7 and ea seems to be related too
169//   if(offset == 0xc5 || offset == 0xca) return mame_rand(space->machine); //tape related
175170   if(offset == 0xc8) return 0; //??? checks bit 7, scrolls vertically if active high
176171   if(offset == 0xc9) return 0x11; //0x01 put 320 x 200 mode, 0x07 = 640 x 375
177172
r8659r8660
241236static WRITE8_HANDLER( bml3_io_w )
242237{
243238   if(offset == 0x19)                      { io_latch = data; } //???
239//   else if(offset == 0xc4)                  { /* system latch, writes 0x53 -> 0x51 when a tape is loaded */}
244240   else if(offset == 0xc6 || offset == 0xc7)    { bml3_6845_w(space,offset-0xc6,data); }
245241   else if(offset == 0xd0)                  { bml3_hres_reg_w(space,0,data);  }
246242   else if(offset == 0xd3)                  { /* every time that the user presses a key, unknown purpose */ }
r8659r8660
376372   PORT_BIT(0xffe00000,IP_ACTIVE_HIGH,IPT_UNKNOWN)
377373INPUT_PORTS_END
378374
379static MACHINE_START(bml3)
380{
381   beep_set_frequency(machine->device("beeper"),300); //guesswork
382   beep_set_state(machine->device("beeper"),0);
383}
384
385static MACHINE_RESET(bml3)
386{
387}
388
389375static const mc6845_interface mc6845_intf =
390376{
391377   "screen",   /* screen we are acting on */
r8659r8660
400386   NULL      /* update address callback */
401387};
402388
389static TIMER_CALLBACK( keyboard_callback )
390{
391   const char* portnames[3] = { "key1","key2","key3" };
392   int i,port_i,scancode;
393   scancode = 0;
394
395   for(port_i=0;port_i<3;port_i++)
396   {
397      for(i=0;i<32;i++)
398      {
399         if((input_port_read(machine,portnames[port_i])>>i) & 1)
400         {
401            keyb_press = scancode;
402            keyb_press_flag = 1;
403            cputag_set_input_line(machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE);
404            return;
405         }
406
407         scancode++;
408      }
409   }
410}
411
412#if 0
403413static INTERRUPT_GEN( bml3_irq )
404414{
405415   cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE);
406416}
407417
408#if 0
409418static INTERRUPT_GEN( bml3_firq )
410419{
420   /* almost surely used to load the tapes */
411421   cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, HOLD_LINE);
412422}
413423#endif
r8659r8660
420430      palette_set_color_rgb(machine, i, pal1bit(i >> 1),pal1bit(i >> 2),pal1bit(i >> 0));
421431}
422432
433static MACHINE_START(bml3)
434{
435   timer_pulse(machine, ATTOTIME_IN_HZ(240/8), NULL, 0, keyboard_callback);
436   beep_set_frequency(machine->device("beeper"),300); //guesswork
437   beep_set_state(machine->device("beeper"),0);
438}
423439
440static MACHINE_RESET(bml3)
441{
442}
443
424444static MACHINE_DRIVER_START( bml3 )
425445    /* basic machine hardware */
426446   MDRV_CPU_ADD("maincpu",M6809, XTAL_1MHz)
427447   MDRV_CPU_PROGRAM_MAP(bml3_mem)
428   MDRV_CPU_VBLANK_INT("screen", bml3_irq )
448//   MDRV_CPU_VBLANK_INT("screen", bml3_irq )
429449//   MDRV_CPU_PERIODIC_INT(bml3_firq,45)
430450
431451   MDRV_MACHINE_START(bml3)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team