Previous 15994 Revisions Next

r15537 Thursday 5th July, 2012 at 13:20:31 UTC by Antoine Mine
[THOMSON] Performance improvements and bug-fixes: more efficient bank switching, fixed video update (Mach 3, Sparce Racer, HCL), fixed game PIA port B, fixed side-effect in debugger, fixed MO6 cassette. [Fabrice Bellet]
[src/mess/drivers]thomson.c
[src/mess/machine]thomson.c
[src/mess/tools/castool]main.c
[src/mess/video]thomson.c

src/mess/tools/castool/main.c
r15536r15537
3939#include "formats/rk_cas.h"
4040#include "formats/sord_cas.h"
4141#include "formats/svi_cas.h"
42#include "formats/thom_cas.h"
4243#include "formats/trs_cas.h"
4344#include "formats/tvc_cas.h"
4445#include "formats/tzx_cas.h"
r15536r15537
8687   {"rkp", rkp_cassette_formats               ,"Partner"},
8788   {"sordm5", sordm5_cassette_formats         ,"Sord M5"},
8889   {"svi", svi_cassette_formats               ,"SVI"},
90   {"to7", to7_cassette_formats               ,"Thomson TO"},
91   {"mo5", mo5_cassette_formats               ,"Thomson MO"},
8992   {"trs80l2", trs80l2_cassette_formats       ,"TRS-80 Level 2"},
9093   {"tvc64", tvc64_cassette_formats           ,"Videoton TVC 64"},
9194   {"tzx", tzx_cassette_formats               ,"ZX Spectrum"},
src/mess/machine/thomson.c
r15536r15537
3737/* It must be set accordingly in formats/thom_cas.c */
3838#define K7_SPEED_HACK 0
3939
40/* bank logging */
40/* bank logging and optimisations */
4141static int old_cart_bank;
42static int old_cart_bank_was_read_only;
4243static int old_ram_bank;
4344static int old_floppy_bank;
4445
r15536r15537
451452   if ( thom_cart_nb_banks )
452453   {
453454      bank = thom_cart_bank % thom_cart_nb_banks;
454      space->install_legacy_read_handler(0x0000, 0x0003, FUNC(to7_cartridge_r) );
455      if ( bank != old_cart_bank && old_cart_bank < 0 )
456                {
457                        space->install_legacy_read_handler(0x0000, 0x0003, FUNC(to7_cartridge_r) );
458                }
455459   }
456
457   if ( bank != old_cart_bank )
460   if ( bank != old_cart_bank )
461        {
462      machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
463      old_cart_bank = bank;
458464      LOG_BANK(( "to7_update_cart_bank: CART is cartridge bank %i\n", bank ));
459
460   machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
461   old_cart_bank = bank;
465   }
462466}
463467
464468
r15536r15537
487491{
488492   UINT8* pos = space->machine().root_device().memregion( "maincpu" )->base() + 0x10000;
489493   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
490   thom_cart_bank = offset & 3;
491   to7_update_cart_bank(space->machine());
494   if ( !space->debugger_access() )
495        {
496      thom_cart_bank = offset & 3;
497      to7_update_cart_bank(space->machine());
498   }
492499   return data;
493500}
494501
r15536r15537
932939
933940READ8_HANDLER ( to7_modem_mea8000_r )
934941{
942   if ( space->debugger_access() )
943        {
944      return 0;
945        }
946
935947   if ( space->machine().root_device().ioport("mconfig")->read() & 1 )
936948   {
937949      device_t* device = space->machine().device("mea8000" );
r15536r15537
12811293
12821294   case 1: /* get input data */
12831295   {
1284      UINT8 data = chardev_in( to7_midi_chardev );
1285      to7_midi_status &= ~(ACIA_6850_irq | ACIA_6850_RDRF);
1286      if ( to7_midi_overrun )
1287         to7_midi_status |= ACIA_6850_OVRN;
1288      else
1289         to7_midi_status &= ~ACIA_6850_OVRN;
1290      to7_midi_overrun = 0;
1291      LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n",
1292           cpu_get_previouspc(space->machine().device("maincpu")), space->machine().time().as_double(), data ));
1293      to7_midi_update_irq( space->machine );
1294      return data;
1296                UINT8 data = chardev_in( to7_midi_chardev );
1297                if ( !space->debugger_access() )
1298                {
1299                        to7_midi_status &= ~(ACIA_6850_irq | ACIA_6850_RDRF);
1300                        if ( to7_midi_overrun )
1301                                to7_midi_status |= ACIA_6850_OVRN;
1302                        else
1303                                to7_midi_status &= ~ACIA_6850_OVRN;
1304                        to7_midi_overrun = 0;
1305                        LOG_MIDI(( "$%04x %f to7_midi_r: read data $%02X\n",
1306                                   cpu_get_previouspc(space->machine().device("maincpu")), space->machine().time().as_double(), data ));
1307                        to7_midi_update_irq( space->machine() );
1308                }
1309                return data;
12951310   }
12961311
12971312
r15536r15537
13421357                 (to7_midi_intr & 3) ? 1 : 0));
13431358         }
13441359      }
1345      to7_midi_update_irq( space->machine );
1360      to7_midi_update_irq( space->machine() );
13461361      break;
13471362
13481363
r15536r15537
13891404static void to7_midi_init( running_machine &machine )
13901405{
13911406   LOG (( "to7_midi_init\n" ));
1392   to7_midi_chardev = chardev_open( machine, "/dev/snd/midiC1D0", "/dev/snd/midiC1D1", &to7_midi_interface );
1407   to7_midi_chardev = chardev_open( &machine, "/dev/snd/midiC0D0", "/dev/snd/midiC0D1", &to7_midi_interface );
13931408   state_save_register_global( machine, to7_midi_status );
13941409   state_save_register_global( machine, to7_midi_overrun );
13951410   state_save_register_global( machine, to7_midi_intr );
r15536r15537
15771592      return;
15781593   }
15791594
1580   if ( bank != old_ram_bank )
1595   if ( bank != old_ram_bank )
1596        {
1597      if ( machine.device<ram_device>(RAM_TAG)->size() == 128*1024 || bank < 2 )
1598                {
1599         machine.root_device().membank( THOM_RAM_BANK )->set_entry( bank );
1600      }
1601                else
1602                {
1603         /* RAM size is 48 KB only and unavailable bank
1604          * requested */
1605         space->nop_readwrite(0xa000, 0xdfff);
1606      }
1607      old_ram_bank = bank;
15811608      LOG_BANK(( "to770_update_ram_bank: RAM bank change %i\n", bank ));
1582
1583   if ( machine.device<ram_device>(RAM_TAG)->size() == 128*1024 || bank < 2 )
1584   {
1585      machine.root_device().membank( THOM_RAM_BANK )->set_entry( bank );
1586      space->install_write_bank(0xa000, 0xdfff, THOM_RAM_BANK);
15871609   }
1588   else
1589   {
1590      space->unmap_write(0xa000, 0xdfff);
1591   }
1592
1593   old_ram_bank = bank;
15941610}
15951611
15961612
r15536r15537
19791995   address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
19801996   int rom_is_ram = mo5_reg_cart & 4;
19811997   int bank = 0;
1998   int bank_is_read_only = 0;
19821999
1983   space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
19842000
19852001   if ( rom_is_ram && thom_cart_nb_banks == 4 )
19862002   {
19872003      /* 64 KB ROM from "JANE" cartridge */
1988      space->nop_write( 0xb000, 0xefff);
19892004      bank = mo5_reg_cart & 3;
1990      if ( bank != old_cart_bank )
2005      if ( bank != old_cart_bank )
2006                {
2007         if ( old_cart_bank < 0 || old_cart_bank > 3 )
2008                        {
2009            space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
2010            space->nop_write( 0xb000, 0xefff);
2011         }
19912012         LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i (A7CB style)\n", bank ));
2013      }
19922014   }
19932015   else if ( rom_is_ram )
19942016   {
19952017      /* 64 KB RAM from network extension */
1996      int write_enable = mo5_reg_cart & 8;
19972018      bank = 4 + ( mo5_reg_cart & 3 );
1998      if (write_enable) {
1999         space->install_write_bank( 0xb000, 0xefff, THOM_CART_BANK);
2000      } else {
2001         space->nop_write( 0xb000, 0xefff);
2002      }
2003      if ( bank != old_cart_bank )
2004         LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (write-enable=%i)\n", mo5_reg_cart & 3, write_enable ? 1 : 0 ));
2019      bank_is_read_only = (( mo5_reg_cart & 8 ) == 0);
2020
2021      if ( bank != old_cart_bank || bank_is_read_only != old_cart_bank_was_read_only)
2022                {
2023                        if ( bank_is_read_only )
2024                        {
2025                                space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
2026                                space->nop_write( 0xb000, 0xefff );
2027                        }
2028                        else
2029                        {
2030                                space->install_readwrite_bank( 0xb000, 0xefff, THOM_CART_BANK);
2031                        }
2032                        LOG_BANK(( "mo5_update_cart_bank: CART is nanonetwork RAM bank %i (%s)\n",
2033                                   mo5_reg_cart & 3,
2034                                   bank_is_read_only ? "read-only":"read-write"));
2035                        old_cart_bank_was_read_only = bank_is_read_only;
2036                }
20052037   }
20062038   else
20072039   {
20082040      /* regular cartridge bank switch */
2009      space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo5_cartridge_w) );
20102041      if ( thom_cart_nb_banks )
20112042      {
20122043         bank = thom_cart_bank % thom_cart_nb_banks;
2013         space->install_legacy_read_handler( 0xbffc, 0xbfff, FUNC(mo5_cartridge_r) );
2014      }
2015      if ( bank != old_cart_bank )
2016         LOG_BANK(( "mo5_update_cart_bank: CART is internal / cartridge bank %i\n", thom_cart_bank ));
2044         if ( bank != old_cart_bank )
2045                        {
2046            if ( old_cart_bank < 0 )
2047                                {
2048               space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
2049               space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo5_cartridge_w) );
2050               space->install_legacy_read_handler( 0xbffc, 0xbfff, FUNC(mo5_cartridge_r) );
2051            }
2052            LOG_BANK(( "mo5_update_cart_bank: CART is cartridge bank %i\n", bank ));
2053         }
2054      } else
2055         /* internal ROM */
2056         if ( old_cart_bank != 0 )
2057                        {
2058            space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
2059            space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo5_cartridge_w) );
2060            LOG_BANK(( "mo5_update_cart_bank: CART is internal\n"));
2061         }
20172062   }
2018   machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
2019   old_cart_bank = bank;
2063   if ( bank != old_cart_bank )
2064        {
2065      machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
2066      old_cart_bank = bank;
2067   }
20202068}
20212069
20222070
r15536r15537
20452093{
20462094   UINT8* pos = space->machine().root_device().memregion( "maincpu" )->base() + 0x10000;
20472095   UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
2048   thom_cart_bank = offset & 3;
2049   mo5_update_cart_bank(space->machine());
2096   if ( !space->debugger_access() )
2097        {
2098      thom_cart_bank = offset & 3;
2099      mo5_update_cart_bank(space->machine());
2100   }
20502101   return data;
20512102}
20522103
r15536r15537
22642315   case 0: /* palette data */
22652316   {
22662317      UINT8 c =  to9_palette_data[ to9_palette_idx ];
2267      to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
2318      if ( !space->debugger_access() )
2319                {
2320         to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
2321                }
22682322      return c;
22692323   }
22702324
r15536r15537
23442398   int bank = 0;
23452399   int slot = ( mc6846_get_output_port(machine.device("mc6846")) >> 4 ) & 3; /* bits 4-5: ROM bank */
23462400
2347   /* reset cartridge read handler */
2348   space->install_read_bank( 0x0000, 0x0003, THOM_CART_BANK );
2349
23502401   switch ( slot )
23512402   {
23522403   case 0:
23532404      /* BASIC (64 KB) */
23542405      bank = 4 + to9_soft_bank;
23552406      if ( bank != old_cart_bank )
2407                {
2408         if ( old_cart_bank < 4)
2409                        {
2410            space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
2411                        }
23562412         LOG_BANK(( "to9_update_cart_bank: CART is BASIC bank %i\n", to9_soft_bank ));
2413      }
23572414      break;
23582415   case 1:
23592416      /* software 1 (32 KB) */
23602417      bank = 8 + (to9_soft_bank & 1);
2361      if ( bank != old_cart_bank )
2418      if ( bank != old_cart_bank )
2419                {
2420         if ( old_cart_bank < 4)
2421                        {
2422            space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
2423                        }
23622424         LOG_BANK(( "to9_update_cart_bank: CART is software 1 bank %i\n", to9_soft_bank ));
2425      }
23632426      break;
23642427   case 2:
23652428      /* software 2 (32 KB) */
23662429      bank = 10 + (to9_soft_bank & 1);
2367      if ( bank != old_cart_bank )
2430      if ( bank != old_cart_bank )
2431                {
2432         if ( old_cart_bank < 4)
2433                        {
2434            space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
2435                        }
23682436         LOG_BANK(( "to9_update_cart_bank: CART is software 2 bank %i\n", to9_soft_bank ));
2437      }
23692438      break;
23702439   case 3:
23712440      /* external cartridge */
23722441      if ( thom_cart_nb_banks )
23732442      {
23742443         bank = thom_cart_bank % thom_cart_nb_banks;
2375         space->install_legacy_read_handler( 0x0000, 0x0003, FUNC(to7_cartridge_r) );
2376      }
2377      if ( bank != old_cart_bank )
2378         LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n",  thom_cart_bank ));
2444         if ( bank != old_cart_bank )
2445                        {
2446            if ( old_cart_bank < 0 || old_cart_bank > 3 )
2447                                {
2448               space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
2449               space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to9_cartridge_w) );
2450               space->install_legacy_read_handler( 0x0000, 0x0003, FUNC(to9_cartridge_r) );
2451            }
2452            LOG_BANK(( "to9_update_cart_bank: CART is cartridge bank %i\n",  thom_cart_bank ));
2453         }
2454      } else
2455         if ( old_cart_bank != 0 )
2456                        {
2457            space->nop_read( 0x0000, 0x3fff);
2458            LOG_BANK(( "to9_update_cart_bank: CART is unmapped\n"));
2459         }
23792460      break;
23802461   }
2381
2382   machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
2383   old_cart_bank = bank;
2462   if ( bank != old_cart_bank )
2463        {
2464      machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
2465      old_cart_bank = bank;
2466   }
23842467}
23852468
23862469
r15536r15537
24142497{
24152498   UINT8* pos = space->machine().root_device().memregion( "maincpu" )->base() + 0x10000;
24162499   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
2417   thom_cart_bank = offset & 3;
2418   to9_update_cart_bank(space->machine());
2500   if ( !space->debugger_access() )
2501        {
2502      thom_cart_bank = offset & 3;
2503      to9_update_cart_bank(space->machine());
2504   }
24192505   return data;
24202506}
24212507
r15536r15537
24512537      return;
24522538   }
24532539
2454   if ( old_ram_bank != bank )
2540   if ( old_ram_bank != bank )
2541        {
2542      if ( machine.device<ram_device>(RAM_TAG)->size() == 192*1024 || bank < 6 )
2543                {
2544         machine.root_device().membank( THOM_RAM_BANK )->set_entry( bank );
2545                }
2546      else
2547                {
2548         space->nop_readwrite( 0xa000, 0xdfff);
2549                }
2550      old_ram_bank = bank;
24552551      LOG_BANK(( "to9_update_ram_bank: bank %i selected (pia=$%02X disk=%i)\n", bank, portb & 0xf8, disk ));
2456
2457   if ( machine.device<ram_device>(RAM_TAG)->size() == 192*1024 || bank < 6 )
2458   {
2459      machine.root_device().membank( THOM_RAM_BANK )->set_entry( bank );
2460      space->install_write_bank( 0xa000, 0xdfff, THOM_RAM_BANK);
24612552   }
2462   else
2463   {
2464      space->nop_write( 0xa000, 0xdfff);
2465   }
2466
2467   old_ram_bank = bank;
24682553}
24692554
24702555
r15536r15537
25922677      return to9_kbd_status;
25932678
25942679   case 1: /* get input data */
2595      to9_kbd_status &= ~(ACIA_6850_irq | ACIA_6850_PE);
2596      if ( to9_kbd_overrun )
2597         to9_kbd_status |= ACIA_6850_OVRN;
2598      else
2599         to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
2600      to9_kbd_overrun = 0;
2601      LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->machine().device("maincpu")), space->machine().time().as_double(), to9_kbd_in ));
2602      to9_kbd_update_irq(space->machine());
2680      if ( !space->debugger_access() )
2681      {
2682         to9_kbd_status &= ~(ACIA_6850_irq | ACIA_6850_PE);
2683         if ( to9_kbd_overrun )
2684            to9_kbd_status |= ACIA_6850_OVRN;
2685         else
2686            to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
2687         to9_kbd_overrun = 0;
2688         LOG_KBD(( "$%04x %f to9_kbd_r: read data $%02X\n", cpu_get_previouspc(space->machine().device("maincpu")), space->machine().time().as_double(), to9_kbd_in ));
2689         to9_kbd_update_irq(space->machine());
2690      }
26032691      return to9_kbd_in;
26042692
26052693   default:
r15536r15537
34643552   int bank = (to8_reg_sys1 & 0x80) ? to7_floppy_bank : (to8_bios_bank + TO7_NB_FLOP_BANK);
34653553
34663554   if ( bank != old_floppy_bank )
3555        {
34673556      LOG_BANK(( "to8_update_floppy_bank: floppy ROM is %s bank %i\n",
3468           (to8_reg_sys1 & 0x80) ? "external" : "internal",
3469           bank % TO7_NB_FLOP_BANK ));
3470   machine.root_device().membank( THOM_FLOP_BANK )->set_entry( bank );
3471   old_floppy_bank = bank;
3557                           (to8_reg_sys1 & 0x80) ? "external" : "internal",
3558                           bank % TO7_NB_FLOP_BANK ));
3559      machine.root_device().membank( THOM_FLOP_BANK )->set_entry( bank );
3560      old_floppy_bank = bank;
3561   }
34723562}
34733563
34743564
r15536r15537
34893579   if ( to8_reg_sys1 & 0x10 )
34903580   {
34913581      bank = to8_reg_ram & 31;
3492      if ( bank != to8_data_vpage )
3493         LOG_BANK(( "to8_update_ram_bank: select bank %i (new style)\n", bank ));
34943582   }
34953583   else
34963584   {
r15536r15537
35103598         logerror( "to8_update_ram_bank: unknown RAM bank=$%02X\n", portb & 0xf8 );
35113599         return;
35123600      }
3513      if ( bank != to8_data_vpage )
3514         LOG_BANK(( "to8_update_ram_bank: select bank %i (old style)\n", bank  ));
35153601   }
35163602
35173603   /*  due to addressing distortion, the 16 KB banked memory space is
r15536r15537
35213607        this is important if we map a bank that is also reachable by another,
35223608        undistorted space, such as cartridge, page 0 (video), or page 1
35233609    */
3524   to8_data_vpage = bank;
3525   if ( machine.device<ram_device>(RAM_TAG)->size() == 512*1024 || to8_data_vpage < 16 )
3526   {
3527      machine.root_device().membank( TO8_DATA_LO )->set_entry( to8_data_vpage );
3528      machine.root_device().membank( TO8_DATA_HI )->set_entry( to8_data_vpage );
3529
3530      if (to8_data_vpage <= 4) {
3531         space->install_legacy_write_handler( 0xa000, 0xbfff, FUNC(to8_data_lo_w));
3532         space->install_legacy_write_handler( 0xc000, 0xdfff, FUNC(to8_data_hi_w));
3533      } else {
3534         space->install_write_bank( 0xa000, 0xbfff, TO8_DATA_LO);
3535         space->install_write_bank( 0xc000, 0xdfff, TO8_DATA_HI);
3610   if ( bank != old_ram_bank)
3611        {
3612      if (machine.device<ram_device>(RAM_TAG)->size() == 512*1024 || to8_data_vpage < 16)
3613                {
3614         machine.root_device().membank( TO8_DATA_LO )->set_entry( bank );
3615         machine.root_device().membank( TO8_DATA_HI )->set_entry( bank );
3616      } else
3617                {
3618         /* RAM size is 256 KB only and unavailable
3619          * bank requested */
3620         space->nop_readwrite( 0xa000, 0xbfff);
3621         space->nop_readwrite( 0xc000, 0xdfff);
35363622      }
3623      to8_data_vpage = bank;
3624      old_ram_bank = bank;
3625      LOG_BANK(( "to8_update_ram_bank: select bank %i (%s style)\n", bank, (to8_reg_sys1 & 0x10) ? "new" : "old"));
35373626   }
3538   else
3539   {
3540      space->nop_write( 0xa000, 0xbfff);
3541      space->nop_write( 0xc000, 0xdfff);
3542   }
35433627}
35443628
35453629
r15536r15537
35553639{
35563640   address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
35573641   int bank = 0;
3642   int bank_is_read_only = 0;
35583643
3559   /* reset bank switch */
3560   space->install_read_bank( 0x0000, 0x0003, THOM_CART_BANK );
3561
35623644   if ( to8_reg_cart & 0x20 )
35633645   {
35643646      /* RAM space */
35653647      to8_cart_vpage = to8_reg_cart & 31;
35663648      bank = 8 + to8_cart_vpage;
3567      if ((to8_cart_vpage < 8 || machine.device<ram_device>(RAM_TAG)->size() == 512*1024) && (to8_reg_cart & 0x40)) {
3568         if (to8_cart_vpage <= 4) {
3569            space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_vcart_w));
3570         } else {
3571            space->install_write_bank( 0x0000, 0x3fff,THOM_CART_BANK);
3572         }
3573      } else {
3574         space->nop_write( 0x0000, 0x3fff);
3649      bank_is_read_only = (( to8_reg_cart & 0x40 ) == 0);
3650      if ( bank != old_cart_bank )
3651                {
3652         /* mapping to VRAM */
3653         if (machine.device<ram_device>(RAM_TAG)->size() == 512*1024 || to8_cart_vpage < 16)
3654                        {
3655            if (to8_cart_vpage < 4)
3656                                {
3657               if (old_cart_bank < 8 || old_cart_bank > 11)
3658                                        {
3659                  space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
3660                  if ( bank_is_read_only )
3661                                                {
3662                     space->nop_write( 0x0000, 0x3fff);
3663                                                }
3664                  else
3665                                                {
3666                     space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_vcart_w));
3667                                                }
3668               }
3669            }
3670                                else
3671                                {
3672               if (old_cart_bank < 12)
3673                                        {
3674                  if ( bank_is_read_only )
3675                                                {
3676                     space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
3677                     space->nop_write( 0x0000, 0x3fff);
3678                  }
3679                                                else
3680                                                {
3681                     space->install_readwrite_bank( 0x0000, 0x3fff,THOM_CART_BANK);
3682                                                }
3683                                        }
3684                                }
3685         }
3686                        else
3687                        {
3688            /* RAM size is 256 KB only and unavailable
3689             * bank requested */
3690            space->nop_readwrite( 0x0000, 0x3fff);
3691                        }
3692         LOG_BANK(( "to8_update_cart_bank: CART is RAM bank %i (%s)\n",
3693                                   to8_cart_vpage,
3694                                   bank_is_read_only ? "read-only":"read-write"));
35753695      }
3576      if ( bank != old_cart_bank )
3577         LOG_BANK(( "to8_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ));
3696      else
3697                {
3698                        if ( bank_is_read_only != old_cart_bank_was_read_only )
3699                        {
3700                                if ( bank_is_read_only )
3701                                {
3702                                        space->nop_write( 0x0000, 0x3fff);
3703                                }
3704                                else
3705                                {
3706                                        if (to8_cart_vpage < 4)
3707                                        {
3708                                                space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_vcart_w));
3709                                        }
3710                                        else
3711                                        {
3712                                                space->install_readwrite_bank( 0x0000, 0x3fff, THOM_CART_BANK );
3713                                        }
3714                                }
3715                                LOG_BANK(( "to8_update_cart_bank: update CART bank %i write status to %s\n",
3716                                           to8_cart_vpage,
3717                                           bank_is_read_only ? "read-only":"read-write"));
3718                        }
3719                }
3720      old_cart_bank_was_read_only = bank_is_read_only;
35783721   }
35793722   else
35803723   {
3581      space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_cartridge_w) );
35823724      if ( to8_soft_select )
35833725      {
35843726         /* internal software ROM space */
35853727         bank = 4 + to8_soft_bank;
3586         if ( bank != old_cart_bank )
3587            LOG_BANK(( "to8_update_cart_bank: CART is internal bank %i\n",
3588                 to8_soft_bank ));
3728         if ( bank != old_cart_bank )
3729                        {
3730            if ( old_cart_bank < 4 || old_cart_bank > 7 )
3731                                {
3732               space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
3733               space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_cartridge_w) );
3734            }
3735            LOG_BANK(( "to8_update_cart_bank: CART is internal bank %i\n", to8_soft_bank ));
3736         }
35893737      }
35903738      else
35913739      {
r15536r15537
35933741         if ( thom_cart_nb_banks )
35943742         {
35953743            bank = thom_cart_bank % thom_cart_nb_banks;
3596            space->install_legacy_read_handler( 0x0000, 0x0003, FUNC(to8_cartridge_r) );
3597
3598         }
3599
3600         if ( bank != old_cart_bank )
3601            LOG_BANK(( "to8_update_cart_bank: CART is external cartridge bank %i\n", thom_cart_bank ));
3602      }
3603   }
3604
3605   if ( machine.device<ram_device>(RAM_TAG)->size() == 512*1024 || bank < 16 )
3606   {
3744            if ( bank != old_cart_bank )
3745                                {
3746               if ( old_cart_bank < 0 || old_cart_bank > 3 )
3747                                        {
3748                  space->install_read_bank( 0x0000, 0x3fff, THOM_CART_BANK );
3749                  space->install_legacy_write_handler( 0x0000, 0x3fff, FUNC(to8_cartridge_w) );
3750                  space->install_legacy_read_handler( 0x0000, 0x0003, FUNC(to8_cartridge_r) );
3751               }
3752               LOG_BANK(( "to8_update_cart_bank: CART is external cartridge bank %i\n", bank ));
3753            }
3754         }
3755                        else
3756                        {
3757            if ( old_cart_bank != 0 )
3758                                {
3759               space->nop_read( 0x0000, 0x3fff);
3760               LOG_BANK(( "to8_update_cart_bank: CART is unmapped\n"));
3761            }
3762                        }
3763                }
3764        }
3765   if ( bank != old_cart_bank )
3766        {
36073767      machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
3768      old_cart_bank = bank;
36083769   }
3609
3610   old_cart_bank = bank;
36113770}
36123771
36133772
r15536r15537
36403799{
36413800   UINT8* pos = space->machine().root_device().memregion( "maincpu" )->base() + 0x10000;
36423801   UINT8 data = pos[offset + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
3643   thom_cart_bank = offset & 3;
3644   to8_update_cart_bank(space->machine());
3802   if ( !space->debugger_access() )
3803        {
3804      thom_cart_bank = offset & 3;
3805      to8_update_cart_bank(space->machine());
3806   }
36453807   return data;
36463808}
36473809
r15536r15537
36713833
36723834READ8_HANDLER ( to8_floppy_r )
36733835{
3836   if ( space->debugger_access() )
3837      return 0;
3838
36743839   if ( (to8_reg_sys1 & 0x80) && THOM_FLOPPY_EXT )
36753840      /* external controller */
36763841      return to7_floppy_r( space, offset );
r15536r15537
37283893   case 1: /* ram register / lightpen register 2 */
37293894      if ( to7_lightpen )
37303895      {
3731         thom_firq_2( space->machine(), 0 );
3732         to8_lightpen_intr = 0;
3896         if ( !space->debugger_access() )
3897         {
3898            thom_firq_2( space->machine(), 0 );
3899            to8_lightpen_intr = 0;
3900         }
37333901         res = count & 0xff;
37343902      }
37353903      else
r15536r15537
38113979   /* 0xe7dc from external floppy drive aliases the video gate-array */
38123980   if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) && ( to8_reg_sys1 & 0x80 ) )
38133981   {
3982      if ( space->debugger_access() )
3983         return 0;
3984
38143985      if ( THOM_FLOPPY_EXT )
38153986         return to7_floppy_r( space, 0xc );
38163987      else
r15536r15537
38233994   case 0: /* palette data */
38243995   {
38253996      UINT8 c =  to9_palette_data[ to9_palette_idx ];
3826      to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
3997      if ( !space->debugger_access() )
3998                {
3999         to9_palette_idx = ( to9_palette_idx + 1 ) & 31;
4000                }
38274001      return c;
38284002   }
38294003
r15536r15537
40434217   /* memory */
40444218   old_ram_bank = -1;
40454219   old_cart_bank = -1;
4220   old_cart_bank_was_read_only = 0;
40464221   old_floppy_bank = -1;
40474222   to8_cart_vpage = 0;
40484223   to8_data_vpage = 0;
r15536r15537
43014476   if ( to8_reg_sys1 & 0x10 )
43024477   {
43034478      bank = to8_reg_ram & 7; /* 128 KB RAM only = 8 pages */
4304      if ( bank != to8_data_vpage )
4305         LOG_BANK(( "mo6_update_ram_bank: select bank %i (new style)\n", bank ));
43064479   }
4307   to8_data_vpage = bank;
4308   machine.root_device().membank( TO8_DATA_LO )->set_entry( to8_data_vpage );
4309   machine.root_device().membank( TO8_DATA_HI )->set_entry( to8_data_vpage );
4480   if ( bank != to8_data_vpage ) {
4481      machine.root_device().membank( TO8_DATA_LO )->set_entry( bank );
4482      machine.root_device().membank( TO8_DATA_HI )->set_entry( bank );
4483      to8_data_vpage = bank;
4484      old_ram_bank = bank;
4485      LOG_BANK(( "mo6_update_ram_bank: select bank %i (new style)\n", bank ));
4486   }
43104487}
43114488
43124489
r15536r15537
43244501   address_space* space = machine.device("maincpu")->memory().space(AS_PROGRAM);
43254502   int b = (sys_pia->a_output() >> 5) & 1;
43264503   int bank = 0;
4504   int bank_is_read_only = 0;
43274505
4328   space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
4506   // space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
43294507
43304508   if ( ( ( to8_reg_sys1 & 0x40 ) && ( to8_reg_cart & 0x20 ) ) || ( ! ( to8_reg_sys1 & 0x40 ) && ( mo5_reg_cart & 4 ) ) )
43314509   {
r15536r15537
43354513         /* use a7e6 */
43364514         to8_cart_vpage = to8_reg_cart & 7; /* 128 KB RAM only = 8 pages */
43374515         bank = 8 + to8_cart_vpage;
4338         if (to8_reg_cart & 0x40)  {
4339            if (to8_cart_vpage <= 4) {
4340               space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(to8_vcart_w));
4341            } else {
4342               space->install_write_bank( 0xb000, 0xefff,THOM_CART_BANK);
4343            }
4344         } else {
4345            space->nop_write( 0xb000, 0xefff);
4516         bank_is_read_only = (( to8_reg_cart & 0x40 ) == 0);
4517         if ( bank != old_cart_bank )
4518                        {
4519            if (to8_cart_vpage < 4)
4520                                {
4521               if (old_cart_bank < 8 || old_cart_bank > 11)
4522                                        {
4523                  space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
4524                  if ( bank_is_read_only )
4525                                                {
4526                     space->nop_write( 0xb000, 0xefff);
4527                                                }
4528                  else
4529                                                {
4530                     space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(to8_vcart_w));
4531                                                }
4532               }
4533            }
4534                                else
4535                                {
4536
4537               if (old_cart_bank < 12)
4538                                        {
4539                  if ( bank_is_read_only )
4540                                                {
4541                     space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
4542                     space->nop_write( 0xb000, 0xefff);
4543                  }
4544                                                else
4545                                                {
4546                     space->install_readwrite_bank( 0xb000, 0xefff,THOM_CART_BANK);
4547                                                }
4548                                        }
4549                                }
4550            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (%s)\n",
4551               to8_cart_vpage,
4552               bank_is_read_only ? "read-only":"read-write"));
43464553         }
4347         if ( bank != old_cart_bank )
4348            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i)\n", to8_cart_vpage, (to8_reg_cart & 0x40) ? 1 : 0 ));
4554         else if ( bank_is_read_only != old_cart_bank_was_read_only )
4555                        {
4556            if ( bank_is_read_only )
4557                                {
4558               space->nop_write( 0xb000, 0xefff);
4559                                }
4560            else
4561                                {
4562               if (to8_cart_vpage < 4)
4563                                        {
4564                  space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(to8_vcart_w));
4565                                        }
4566               else
4567                                        {
4568                  space->install_readwrite_bank( 0xb000, 0xefff, THOM_CART_BANK );
4569                                        }
4570                                }
4571            LOG_BANK(( "mo6_update_cart_bank: update CART bank %i write status to %s\n",
4572                                           to8_cart_vpage,
4573                                           bank_is_read_only ? "read-only":"read-write"));
4574         }
4575         old_cart_bank_was_read_only = bank_is_read_only;
43494576      }
43504577      else if ( thom_cart_nb_banks == 4 )
43514578      {
43524579         /* "JANE"-style cartridge bank switching */
4353         space->nop_write( 0xb000, 0xefff);
43544580         bank = mo5_reg_cart & 3;
43554581         if ( bank != old_cart_bank )
4582                        {
4583            if ( old_cart_bank < 0 || old_cart_bank > 3 )
4584                                {
4585               space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
4586               space->nop_write( 0xb000, 0xefff);
4587            }
43564588            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i (A7CB style)\n", bank ));
4589         }
43574590      }
43584591      else
43594592      {
43604593         /* RAM from MO5 network extension */
4361         int write_enable = mo5_reg_cart & 8;
4594         int bank_is_read_only = (( mo5_reg_cart & 8 ) == 0);
43624595         to8_cart_vpage = (mo5_reg_cart & 3) | 4;
43634596         bank = 8 + to8_cart_vpage;
4364         if (write_enable) {
4365            space->install_write_bank( 0xb000, 0xefff, THOM_CART_BANK);
4366         } else {
4367            space->nop_write( 0xb000, 0xefff);
4597         if ( bank != old_cart_bank )
4598                        {
4599            if ( old_cart_bank < 12 )
4600                                {
4601               if ( bank_is_read_only )
4602                                        {
4603                  space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
4604                  space->nop_write( 0xb000, 0xefff);
4605               } else
4606                                        {
4607                  space->install_readwrite_bank( 0xb000, 0xefff, THOM_CART_BANK);
4608                                        }
4609            }
4610            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (MO5 compat.) (%s)\n",
4611                                           to8_cart_vpage,
4612                                           bank_is_read_only ? "read-only":"read-write"));
43684613         }
4369         if ( bank != old_cart_bank )
4370            LOG_BANK(( "mo6_update_cart_bank: CART is RAM bank %i (write-enable=%i) (MO5 compat.)\n", to8_cart_vpage, write_enable ? 1 : 0 ));
4614         else if ( bank_is_read_only != old_cart_bank_was_read_only )
4615                        {
4616            if ( bank_is_read_only )
4617                                {
4618               space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
4619               space->nop_write( 0xb000, 0xefff);
4620            }
4621                                else
4622                                {
4623               space->install_readwrite_bank( 0xb000, 0xefff, THOM_CART_BANK);
4624                                }
4625            LOG_BANK(( "mo5_update_cart_bank: update CART bank %i write status to %s\n",
4626                                           to8_cart_vpage,
4627                                           bank_is_read_only ? "read-only":"read-write"));
4628         }
4629         old_cart_bank_was_read_only = bank_is_read_only;
43714630      }
43724631   }
43734632   else
43744633   {
43754634      /* ROM space */
4376      space->nop_write( 0xb000, 0xefff);
43774635      if ( to8_reg_sys2 & 0x20 )
43784636      {
43794637         /* internal ROM */
43804638         if ( to8_reg_sys2 & 0x10)
4639                        {
43814640            bank = b + 6; /* BASIC 128 */
4641                        }
43824642         else
4643                        {
43834644            bank = b + 4;                      /* BASIC 1 */
4384         if ( bank != old_cart_bank )
4645                        }
4646         if ( bank != old_cart_bank )
4647                        {
4648            if ( old_cart_bank < 4 || old_cart_bank > 7 )
4649                                {
4650               space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK);
4651               space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo6_cartridge_w) );
4652            }
43854653            LOG_BANK(( "mo6_update_cart_bank: CART is internal ROM bank %i\n", b ));
4654         }
43864655      }
43874656      else
43884657      {
43894658         /* cartridge */
4390         space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo6_cartridge_w) );
43914659         if ( thom_cart_nb_banks )
43924660         {
43934661            bank = thom_cart_bank % thom_cart_nb_banks;
4394            space->install_legacy_read_handler( 0xbffc, 0xbfff, FUNC(mo6_cartridge_r) );
4395         }
4396         if ( bank != old_cart_bank )
4397            LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank ));
4662            if ( bank != old_cart_bank )
4663                                {
4664               if ( old_cart_bank < 0 || old_cart_bank > 3 )
4665                                        {
4666                  space->install_read_bank( 0xb000, 0xefff, THOM_CART_BANK );
4667                  space->install_legacy_write_handler( 0xb000, 0xefff, FUNC(mo6_cartridge_w) );
4668                  space->install_legacy_read_handler( 0xbffc, 0xbfff, FUNC(mo6_cartridge_r) );
4669               }
4670               LOG_BANK(( "mo6_update_cart_bank: CART is external cartridge bank %i\n", bank ));
4671            }
4672         }
4673                        else
4674                        {
4675            if ( old_cart_bank != 0 )
4676                                {
4677               space->nop_read( 0xb000, 0xefff );
4678               LOG_BANK(( "mo6_update_cart_bank: CART is unmapped\n"));
4679            }
4680                        }
43984681      }
43994682   }
4400
4401   old_cart_bank = bank;
4402   machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
4403   machine.root_device().membank( TO8_BIOS_BANK )->set_entry( b );
4683   if ( bank != old_cart_bank )
4684        {
4685      machine.root_device().membank( THOM_CART_BANK )->set_entry( bank );
4686      machine.root_device().membank( TO8_BIOS_BANK )->set_entry( b );
4687      old_cart_bank = bank;
4688   }
44044689}
44054690
44064691
r15536r15537
44294714{
44304715   UINT8* pos = space->machine().root_device().memregion( "maincpu" )->base() + 0x10000;
44314716   UINT8 data = pos[offset + 0xbffc + (thom_cart_bank % thom_cart_nb_banks) * 0x4000];
4432   thom_cart_bank = offset & 3;
4433   mo6_update_cart_bank(space->machine());
4717   if ( !space->debugger_access() )
4718        {
4719      thom_cart_bank = offset & 3;
4720      mo6_update_cart_bank(space->machine());
4721   }
44344722   return data;
44354723}
44364724
r15536r15537
46644952   case 1: /* ram register / lightpen register 2 */
46654953      if ( to7_lightpen )
46664954      {
4667         thom_firq_2( space->machine(), 0 );
4668         to8_lightpen_intr = 0;
4955         if ( !space->debugger_access() )
4956         {
4957            thom_firq_2( space->machine(), 0 );
4958            to8_lightpen_intr = 0;
4959         }
46694960         res =  count & 0xff;
46704961      }
46714962      else
r15536r15537
47435034{
47445035   /* 0xa7dc from external floppy drive aliases the video gate-array */
47455036   if ( ( offset == 3 ) && ( to8_reg_ram & 0x80 ) )
4746      return to7_floppy_r( space, 0xc );
5037        {
5038      if ( !space->debugger_access() )
5039         return to7_floppy_r( space, 0xc );
5040        }
47475041
47485042   switch ( offset )
47495043   {
r15536r15537
49195213
49205214READ8_HANDLER ( mo5nr_net_r )
49215215{
5216   if ( space->debugger_access() )
5217      return 0;
5218
49225219   if ( to7_controller_type )
49235220      return to7_floppy_r ( space, offset );
49245221
src/mess/video/thomson.c
r15536r15537
389389      LOG (( "thom_set_video_mode: %i at line %i, col %i\n", mode, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64 ));
390390      thom_vmode = mode;
391391      thom_gplinfo_changed( machine );
392      thom_vstate_dirty = 1;
392393      thom_hires_better |= thom_mode_is_hires( mode );
393394   }
394395}
r15536r15537
403404      LOG (( "thom_set_video_page: %i at line %i col %i\n", page, thom_video_elapsed( machine ) / 64, thom_video_elapsed( machine ) % 64  ));
404405      thom_vpage = page;
405406      thom_gplinfo_changed( machine );
407      thom_vstate_dirty = 1;
406408   }
407409}
408410
r15536r15537
806808         unsigned page = thom_vmodepage[x] & 0xff;
807809         assert( mode < THOM_VMODE_NB );
808810         assert( page < 4 );
809         do
810         {
811            xx++;
812         } while ( xx < 40 && thom_vmodepage[xx] == -1 );
811         if ( thom_vmodepage_changed )
812                        {
813                                do
814            {
815               xx++;
816            }
817                                while ( xx < 40 && thom_vmodepage[xx] == -1 );
818                        }
819         else
820                        {
821            xx = 40;
822                        }
813823         thom_scandraw_funcs[ mode ][ thom_hires ]
814824            ( machine,
815825              thom_vram + y * 40 + page * 0x4000,
r15536r15537
11231133   memset( thom_border_l, 0xff, sizeof( thom_border_l ) );
11241134   memset( thom_border_r, 0xff, sizeof( thom_border_r ) );
11251135   memset( thom_vbody, 0, sizeof( thom_vbody ) );
1126   memset( thom_vmodepage, 0, sizeof( thom_vmodepage ) );
1136   memset( thom_vmodepage, 0xffff, sizeof( thom_vmodepage ) );
11271137   memset( thom_vmem_dirty, 0, sizeof( thom_vmem_dirty ) );
11281138   thom_border_l[ 0 ] = 0;
11291139   thom_border_r[ 0 ] = 0;
1140   thom_vmodepage[ 0 ] = 0;
1141   thom_vmodepage_changed = 0;
11301142   thom_vmode = 0;
11311143   thom_vpage = 0;
11321144   thom_border_index = 0;
src/mess/drivers/thomson.c
r15536r15537
147147/* joysticks, SX 90-018 specific */
148148     PAD ( 0x04, 1, "Action B", BUTTON2, BUTTON2, LALT )
149149     PAD ( 0x08, 2, "Action B", BUTTON2, BUTTON2, RALT )
150     PORT_BIT  ( 0x30, IP_ACTIVE_LOW, IPT_UNUSED )
151     PORT_BIT  ( 0x03, IP_ACTIVE_LOW, IPT_UNUSED ) /* ? */
150     PORT_BIT  ( 0x30, IP_ACTIVE_HIGH, IPT_UNUSED )
151     PORT_BIT  ( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED ) /* ? */
152152
153153/* mouse, SX 90-018 specific */
154154     PORT_START ( "mouse_x" )
r15536r15537
20822082     MCFG_CPU_MODIFY( "maincpu" )
20832083     MCFG_CPU_PROGRAM_MAP ( mo6)
20842084
2085     MCFG_CASSETTE_MODIFY( CASSETTE_TAG, mo5_cassette_interface )
2086
20852087     MCFG_DEVICE_REMOVE( "mc6846" )
20862088
20872089   MCFG_PIA6821_MODIFY( THOM_PIA_SYS, mo6_pia6821_sys )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team