Previous 15994 Revisions Next

r2458 Thursday 24th April, 2008 at 18:56:31 UTC by Stefano Priore
[LISA] Fixes serial number read (Gilles Fetis)
[src/mess/machine]lisa.c

src/mess/machine/lisa.c
r2457r2458
277277   if (VTIR != value)
278278   {
279279      VTIR = value;
280      lisa_field_interrupts(machine);
280      if (VTIR==1)
281         lisa_field_interrupts(machine);
281282   }
282283}
283284
r2457r2458
337338{
338339   if ((! hold_COPS_data) && fifo_size && (! COPS_Ready))
339340   {
340      /*logerror("Pushing one byte of data to VIA\n");*/
341      logerror("Pushing one byte of data to VIA\n");
341342
342343      via_set_input_a(0, fifo_data[fifo_head]);   /* output data */
343344      if (fifo_head == mouse_data_offset)
r2457r2458
366367#endif
367368
368369   {
369      /*logerror("Adding %d bytes of data to FIFO\n", len);*/
370      logerror("Adding %d bytes of data to FIFO\n", len);
370371
371372      while (len--)
372373      {
r2457r2458
390391/* keyboard matrix to detect transition */
391392static int key_matrix[8];
392393
393static void scan_keyboard(running_machine *machine)
394static void scan_keyboard( void )
394395{
395396   int i, j;
396397   int keybuf;
r2457r2458
399400   if (! COPS_force_unplug)
400401      for (i=0; i<8; i++)
401402      {
402         keybuf = input_port_read_indexed(machine, i+2);
403         keybuf = readinputport(i+2);
403404
404405         if (keybuf != key_matrix[i])
405406         {   /* if state has changed, find first bit which has changed */
r2457r2458
444445   /*if (COPS_force_unplug)
445446      return;*/   /* ???? */
446447
447   new_mx = input_port_read_indexed(machine, 0);
448   new_my = input_port_read_indexed(machine, 1);
448   new_mx = readinputport(0);
449   new_my = readinputport(1);
449450
450451   /* see if it moved in the x coord */
451452   if (new_mx != last_mx)
r2457r2458
915916   for (y = 0; y < resy; y++)
916917   {
917918      for (x = 0; x < resx; x++)
918         line_buffer[x] = (v[(x+y*resx)>>4] & (0x8000 >> ((x+y*resx) & 0xf))) ? 0 : 1;
919//         line_buffer[x] = (v[(x+y*resx)>>4] & (0x8000 >> ((x+y*resx) & 0xf))) ? 0 : 1;
920         line_buffer[x] = (v[(x+y*resx)>>4] & (0x8000 >> (x & 0xf))) ? 0 : 1;
919921      draw_scanline8(bitmap, 0, y, resx, line_buffer, screen->machine->pens, -1);
920922   }
921923   return 0;
r2457r2458
937939   {
938940      if (address & 0x004000)
939941      {
940         the_seg = 0;   /* correct ??? */
942//         the_seg = 0;   /* correct ??? */
941943      }
942944      else
943945      {
r2457r2458
12971299   /* set VBI */
12981300   if (VTMSK)
12991301      set_VTIR(machine, 1);
1300
1302   else
1303      set_VTIR(machine, 0);
1304   
13011305   /* do keyboard scan */
1302   scan_keyboard(machine);
1306   scan_keyboard();
13031307}
13041308
13051309/*
r2457r2458
14871491   {   /* special setup mode */
14881492      if (offset & 0x002000)
14891493      {
1490         the_seg = 0;   /* correct ??? */
1494//         the_seg = 0;   /* correct ??? */
14911495      }
14921496      else
14931497      {
r2457r2458
15881592            /* problem : due to collisions with video, timings of the LISA CPU
15891593            are slightly different from timings of a bare 68k */
15901594            /* so we use a kludge... */
1591#if 0
1592            /* theory - probably partially wrong, anyway */
1593            int time_in_frame = cpu_getcurrentcycles();
1594            int videoROM_address;
1595
1596            videoROM_address = (time_in_frame / 4) & 0x7f;
1597
1598            if ((time_in_frame >= 70000) || (time_in_frame <= 74000))   /* these values are approximative */
1599            {   /* if VSyncing, read ROM 2nd half ? */
1600               videoROM_address |= 0x80;
1601            }
1602#else
1603            /* kludge */
1604            /* this code assumes the program always tries to read consecutive bytes */
1605#if 0
1606            int time_in_frame = cpu_getcurrentcycles();
1607            static int videoROM_address = 0;
1608
1609            videoROM_address = (videoROM_address + 1) & 0x7f;
1610            /* the BOOT ROM only reads 56 bits, so there must be some wrap-around for
1611            videoROM_address <= 56 */
1612            /* pixel clock 20MHz, memory access rate 1.25MHz, horizontal clock 22.7kHz
1613            according to Apple, which must stand for 1.25MHz/55 = 22727kHz, vertical
1614            clock approximately 60Hz, which means there are about 380 lines, including VBlank */
1615            if (videoROM_address == 55)
1616               videoROM_address = 0;
1617
1618            if ((time_in_frame >= 70000) && (time_in_frame <= 74000))   /* these values are approximative */
1619            {   /* if VSyncing, read ROM 2nd half ? */
1620               videoROM_address |= 0x80;
1621            }
1622#else
16231595            int time_in_frame = video_screen_get_vpos(machine->primary_screen);
16241596            static int videoROM_address = 0;
16251597
1626            videoROM_address = (videoROM_address + 1) & 0x7f;
16271598            /* the BOOT ROM only reads 56 bits, so there must be some wrap-around for
16281599            videoROM_address <= 56 */
16291600            /* pixel clock 20MHz, memory access rate 1.25MHz, horizontal clock 22.7kHz
r2457r2458
16311602            clock approximately 60Hz, which means there are about 380 lines, including VBlank */
16321603            /* The values are different on the Mac XL, and I don't know the correct values
16331604            for sure. */
1634            if (videoROM_address == ((lisa_features.has_mac_xl_video) ? 48/* ??? */ : 55))
1635               videoROM_address = 0;
16361605
16371606            /* Something appears to be wrong with the timings, since we expect to read the
16381607            2nd half when v-syncing, i.e. for lines beyond the 431th or 364th one (provided
r2457r2458
16421611            if (lisa_features.has_mac_xl_video)
16431612            {
16441613               if ((time_in_frame >= 374) && (time_in_frame <= 392))   /* these values have not been tested */
1645               {   /* if VSyncing, read ROM 2nd half ? */
1646                  videoROM_address |= 0x80;
1647               }
1614                  answer = videoROM_ptr[videoROM_address|0x80] << 8;
1615               else
1616                  answer = videoROM_ptr[videoROM_address] << 8;
16481617            }
16491618            else
16501619            {
1651               if ((time_in_frame >= 319) && (time_in_frame <= 338))   /* these values are approximative */
1652               {   /* if VSyncing, read ROM 2nd half ? */
1653                  videoROM_address |= 0x80;
1620               if ((time_in_frame >= 364) && (time_in_frame <= 375))
1621               {
1622                  answer = videoROM_ptr[videoROM_address|0x80] << 8;
1623              logerror("reading1 %06X=%04x PC=%06x time=%d\n", address, answer,safe_activecpu_get_pc(),time_in_frame);
16541624               }
1625               else
1626               {
1627                  answer = videoROM_ptr[videoROM_address] << 8;
1628              logerror("reading2 %06X=%04x PC=%06x time=%d\n", address, answer,safe_activecpu_get_pc(),time_in_frame);
1629               }
16551630            }
1656#endif
16571631
1658#endif
16591632
1660            answer = videoROM_ptr[videoROM_address] << 8;
1633            videoROM_address = (videoROM_address + 1) & 0x7f;
1634            if (videoROM_address == ((lisa_features.has_mac_xl_video) ? 48 : 56)) {
1635                logerror("loop %d\n", videoROM_address);
1636               videoROM_address = 0;
1637            }
16611638
1662            /*logerror("%X %X\n", videoROM_address, answer);*/
16631639         }
16641640         break;
16651641      }
r2457r2458
16831659   {
16841660      if (offset & 0x002000)
16851661      {
1686         the_seg = 0;   /* correct ??? */
1662//         the_seg = 0;   /* correct ??? */
16871663      }
16881664      else
16891665      {
16901666         if (offset & 0x004000)
16911667         {   /* write to MMU register */
1692            /*logerror("write to segment registers (%X:%X) ", the_seg, segment);*/
1668            logerror("write to segment registers (%X:%X) ", the_seg, segment);
16931669            if (offset & 0x000004)
16941670            {   /* sorg register */
1695               /*logerror("sorg, data = %X\n", data);*/
1696               real_mmu_regs[the_seg][segment].sorg = data;
1671               logerror("sorg, data = %X\n", data);
1672               real_mmu_regs[the_seg][segment].sorg = data & 0xFFF;
16971673               mmu_regs[the_seg][segment].sorg = (data & 0x0fff) << 9;
16981674            }
16991675            else
17001676            {   /* slim register */
1701               /*logerror("slim, data = %X\n", data);*/
1702               real_mmu_regs[the_seg][segment].slim = data;
1677               logerror("slim, data = %X\n", data);
1678               real_mmu_regs[the_seg][segment].slim = data & 0xFFF;
17031679               mmu_regs[the_seg][segment].slim = (~ (data << 9)) & 0x01ffff;
17041680               switch ((data & 0x0f00) >> 8)
17051681               {
r2457r2458
17291705                  mmu_regs[the_seg][segment].type = invalid;
17301706                  break;
17311707               case 0xF:
1732                  /*logerror("type : special I/O\n");*/
1708                  logerror("type : special I/O\n");
17331709                  mmu_regs[the_seg][segment].type = special_IO;
17341710                  break;
17351711               default:   /* "unpredictable results" */
1736                  /*logerror("type : unknown\n");*/
1712                  logerror("type : unknown\n");
17371713                  mmu_regs[the_seg][segment].type = invalid;
17381714                  break;
17391715               }
r2457r2458
17701746         COMBINE_DATA((UINT16 *) (lisa_ram_ptr + address));
17711747         if (diag2)
17721748         {
1773            if ((ACCESSING_BITS_0_7)
1749            if ((ACCESSING_LSB)
17741750               && ! (bad_parity_table[address >> 3] & (0x1 << (address & 0x7))))
17751751            {
17761752               bad_parity_table[address >> 3] |= 0x1 << (address & 0x7);
17771753               bad_parity_count++;
17781754            }
1779            if ((ACCESSING_BITS_8_15)
1755            if ((ACCESSING_MSB)
17801756               && ! (bad_parity_table[address >> 3] & (0x2 << (address & 0x7))))
17811757            {
17821758               bad_parity_table[address >> 3] |= 0x2 << (address & 0x7);
r2457r2458
17851761         }
17861762         else if (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))
17871763         {
1788            if ((ACCESSING_BITS_0_7)
1764            if ((ACCESSING_LSB)
17891765               && (bad_parity_table[address >> 3] & (0x1 << (address & 0x7))))
17901766            {
17911767               bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7));
17921768               bad_parity_count--;
17931769            }
1794            if ((ACCESSING_BITS_8_15)
1770            if ((ACCESSING_MSB)
17951771               && (bad_parity_table[address >> 3] & (0x2 << (address & 0x7))))
17961772            {
17971773               bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7));
r2457r2458
18091785         COMBINE_DATA((UINT16 *) (lisa_ram_ptr + address));
18101786         if (diag2)
18111787         {
1812            if ((ACCESSING_BITS_0_7)
1788            if ((ACCESSING_LSB)
18131789               && ! (bad_parity_table[address >> 3] & (0x1 << (address & 0x7))))
18141790            {
18151791               bad_parity_table[address >> 3] |= 0x1 << (address & 0x7);
18161792               bad_parity_count++;
18171793            }
1818            if ((ACCESSING_BITS_8_15)
1794            if ((ACCESSING_MSB)
18191795               && ! (bad_parity_table[address >> 3] & (0x2 << (address & 0x7))))
18201796            {
18211797               bad_parity_table[address >> 3] |= 0x2 << (address & 0x7);
r2457r2458
18241800         }
18251801         else if (bad_parity_table[address >> 3] & (0x3 << (address & 0x7)))
18261802         {
1827            if ((ACCESSING_BITS_0_7)
1803            if ((ACCESSING_LSB)
18281804               && (bad_parity_table[address >> 3] & (0x1 << (address & 0x7))))
18291805            {
18301806               bad_parity_table[address >> 3] &= ~ (0x1 << (address & 0x7));
18311807               bad_parity_count--;
18321808            }
1833            if ((ACCESSING_BITS_8_15)
1809            if ((ACCESSING_MSB)
18341810               && (bad_parity_table[address >> 3] & (0x2 << (address & 0x7))))
18351811            {
18361812               bad_parity_table[address >> 3] &= ~ (0x2 << (address & 0x7));
r2457r2458
19091885      seg &= ~2;
19101886      break;
19111887   case 0x0010:   /* SETUP register SET */
1888       logerror("setup SET PC=%x\n", safe_activecpu_get_pc());
19121889      setup = 1;
19131890      break;
19141891   case 0x0012:   /* SETUP register RESET */
1892       logerror("setup UNSET PC=%x\n", safe_activecpu_get_pc());
19151893      setup = 0;
19161894      break;
19171895   case 0x001A:   /* Enable Vertical Retrace Interrupt */
1896       logerror("enable retrace PC=%x\n", safe_activecpu_get_pc());
19181897      VTMSK = 1;
19191898      break;
19201899   case 0x0018:   /* Disable Vertical Retrace Interrupt */
1900       logerror("disable retrace PC=%x\n", safe_activecpu_get_pc());
19211901      VTMSK = 0;
1922      set_VTIR(machine, 0);
1902      set_VTIR(machine, 2);
19231903      break;
19241904   case 0x0016:   /* Enable Soft Error Detect. */
19251905   case 0x0014:   /* Disable Soft Error Detect. */
r2457r2458
19691949      {
19701950         if (! (offset & 0x400))
19711951         {
1972            /*if (ACCESSING_BITS_0_7)*/   /* Geez, who cares ? */
1952            /*if (ACCESSING_LSB)*/   /* Geez, who cares ? */
19731953               answer = lisa_fdc_ram[offset & 0x03ff] & 0xff;   /* right ??? */
19741954         }
19751955      }
r2457r2458
19861966
19871967         case 2:   /* parallel port */
19881968            /* 1 VIA located at 0xD901 */
1989            if (ACCESSING_BITS_0_7)
1969            if (ACCESSING_LSB)
19901970               return via_read(1, (offset >> 2) & 0xf);
19911971            break;
19921972
19931973         case 3:   /* keyboard/mouse cops via */
19941974            /* 1 VIA located at 0xDD81 */
1995            if (ACCESSING_BITS_0_7)
1975            if (ACCESSING_LSB)
19961976               return via_read(0, offset & 0xf);
19971977            break;
19981978         }
r2457r2458
20191999         answer = 0;
20202000         if (! parity_error_pending)
20212001            answer |= 0x02;
2022         if (! VTIR)
2023            answer |= 0x04;
2002         if (VTIR<=1)
2003// GFE : needs to be in phase with Serial NUM
2004         {
2005            int time_in_frame = video_screen_get_vpos(machine->primary_screen);
2006            if (lisa_features.has_mac_xl_video)
2007            {
2008               if ((time_in_frame >= 374) && (time_in_frame <= 392))   /* these values have not been tested */
2009               {   /* if VSyncing, read ROM 2nd half ? */
2010               }
2011               else
2012               {
2013                  VTIR=0;
2014                  answer |= 0x04;
2015               }
2016            }
2017            else
2018            {
2019              logerror("read status time=%x\n", time_in_frame);
2020               if ((time_in_frame >= 364) && (time_in_frame <= 383))   /* these values are approximative */
2021               {   /* if VSyncing, read ROM 2nd half ? */
2022               }
2023               else
2024               {
2025                  VTIR=0;
2026                  answer |= 0x04;
2027               }
2028            }
2029
2030         }
2031         else
2032                  answer |= 0x04;
20242033         /* huh... we need to emulate some other bits */
2034          logerror("read status PC=%x val=%x\n", safe_activecpu_get_pc(),answer);
2035
20252036         break;
20262037      }
20272038      break;
r2457r2458
20642075         /* Floppy Disk Controller shared RAM */
20652076         if (! (offset & 0x0400))
20662077         {
2067            if (ACCESSING_BITS_0_7)
2078            if (ACCESSING_LSB)
20682079               lisa_fdc_ram[offset & 0x03ff] = data & 0xff;
20692080         }
20702081      }
r2457r2458
20772088            break;
20782089
20792090         case 2:   /* paralel port */
2080            if (ACCESSING_BITS_0_7)
2091            if (ACCESSING_LSB)
20812092               via_write(1, (offset >> 2) & 0xf, data & 0xff);
20822093            break;
20832094
20842095         case 3:   /* keyboard/mouse cops via */
2085            if (ACCESSING_BITS_0_7)
2096            if (ACCESSING_LSB)
20862097               via_write(0, offset & 0xf, data & 0xff);
20872098            break;
20882099         }

Previous 15994 Revisions Next


© 1998-2018 The MESS Team