Previous 15994 Revisions Next

r5932 Wednesday 30th September, 2009 at 23:40:58 UTC by Fabio Priuli
Run srcclean on devices/ and formats/ folders, and on a few drivers not actively worked on
[src/mess/devices]aescart.c aescart.h appldriv.c appldriv.h bitbngr.c bitbngr.h cartslot.c cartslot.h cassette.c cassette.h chd_cd.c chd_cd.h coco_232.c coco_fdc.c coco_pak.c coco_vhd.c coco_vhd.h cococart.c cococart.h flopdrv.c flopdrv.h harddriv.c harddriv.h kermit.c kermit.h messram.c microdrv.c multcart.c multcart.h orch90.c printer.c printer.h snapquik.c snapquik.h sonydriv.c sonydriv.h thomflop.c ti99cart.c ti99cart.h xmodem.c xmodem.h z80bin.c z80bin.h
[src/mess/drivers]c128.c c16.c c64.c c65.c genesis.c glasgow.c gmaster.c hp48.c mephisto.c nes.c pasogo.c ssystem3.c thomson.c vc20.c
[src/mess/formats]a26_cas.h adam_dsk.c adam_dsk.h ami_dsk.c ami_dsk.h ap2_dsk.c ap2_dsk.h ap_dsk35.c ap_dsk35.h atarist_dsk.c atarist_dsk.h basicdsk.c basicdsk.h cassimg.c cassimg.h cbm_tap.c cbm_tap.h coco_cas.c coco_cas.h coco_dsk.c coco_dsk.h cocopak.c comx35_dsk.c comx35_dsk.h cpis_dsk.c cpis_dsk.h cqm_dsk.c csw_cas.c csw_cas.h d88_dsk.c dim_dsk.c dim_dsk.h dsk_dsk.c flopimg.c flopimg.h fm7_cas.c fmsx_cas.h imd_dsk.c ioprocs.c ioprocs.h jupi_tap.c lviv_lvt.h mz_cas.c mz_cas.h orao_cas.c oric_dsk.c oric_dsk.h oric_tap.c oric_tap.h pc_dsk.c pc_dsk.h pmd_pmd.h primoptp.c primoptp.h rk_cas.c sord_cas.c sord_cas.h svi_cas.h thom_cas.c thom_dsk.c trd_dsk.c trd_dsk.h trs_dsk.h tzx_cas.c uef_cas.c uef_cas.h vt_cas.c vt_cas.h vt_dsk.c vt_dsk.h wavfile.c wavfile.h x1_tap.c x1_tap.h zx81_p.c zx81_p.h
[src/mess/machine]nes.c nes_mmc.c thomson.c

src/mess/machine/thomson.c
r5931r5932
10931093      /* joystick */
10941094      data = input_port_read(device->machine, "game_port_directions");
10951095      /* bit 0=0 => P1 up      bit 4=0 => P2 up
1096         bit 1=0 => P1 down    bit 5=0 => P2 down
1097         bit 2=0 => P1 left    bit 6=0 => P2 left
1098         bit 3=0 => P1 right   bit 7=0 => P2 right
1099      */
1096           bit 1=0 => P1 down    bit 5=0 => P2 down
1097           bit 2=0 => P1 left    bit 6=0 => P2 left
1098           bit 3=0 => P1 right   bit 7=0 => P2 right
1099        */
11001100      /* remove impossible combinations: up+down, left+right */
11011101      if ( ! ( data & 0x03 ) )
11021102         data |= 0x03;
r5931r5932
12031203      pia6821_cb1_w( game_pia, 0, (in & 0x08) ? 1 : 0 ); /* P2 action B */
12041204      pia6821_ca1_w( game_pia, 0, (in & 0x04) ? 1 : 0 ); /* P1 action B */
12051205      /* TODO:
1206         it seems that CM 90-112 behaves differently
1207         - ca1 is P1 action A, i.e., in & 0x40
1208         - ca2 is P2 action A, i.e., in & 0x80
1209         - cb1, cb2 are not connected (should not be a problem)
1210      */
1206           it seems that CM 90-112 behaves differently
1207           - ca1 is P1 action A, i.e., in & 0x40
1208           - ca2 is P2 action A, i.e., in & 0x80
1209           - cb1, cb2 are not connected (should not be a problem)
1210        */
12111211      /* Note: the MO6 & MO5NR have slightly different connections
1212         (see mo6_game_update_cb)
1213      */
1212           (see mo6_game_update_cb)
1213        */
12141214   }
12151215}
12161216
r5931r5932
28232823         port |= 1; /* shift & control */
28242824
28252825      /* TODO: correct handling of simultaneous keystokes:
2826         return the new key preferably & disable repeat
2827      */
2826           return the new key preferably & disable repeat
2827        */
28282828      for ( bit = 0; bit < 8; bit++ )
28292829      {
28302830         if ( ! (port & (1 << bit)) )
r5931r5932
32553255         port |= 1; /* shift & control */
32563256
32573257      /* TODO: correct handling of simultaneous keystokes:
3258         return the new key preferably & disable repeat
3259      */
3258           return the new key preferably & disable repeat
3259        */
32603260      for ( bit = 0; bit < 8; bit++ )
32613261      {
32623262         if ( ! (port & (1 << bit)) )
r5931r5932
33193319      /* key polling */
33203320      int k = to8_kbd_get_key(machine);
33213321      /* if not in transfer, send pulse from time to time
3322         (helps avoiding CPU lock)
3323      */
3322           (helps avoiding CPU lock)
3323        */
33243324      if ( ! to8_kbd_ack )
33253325         mc6846_set_input_cp1( devtag_get_device(machine, "mc6846"), 0 );
33263326      mc6846_set_input_cp1( devtag_get_device(machine, "mc6846"), 1 );
r5931r5932
35573557   }
35583558
35593559   /*  due to adressing distortion, the 16 KB banked memory space is
3560       split into two 8 KB spaces:
3561       - 0xa000-0xbfff maps to 0x2000-0x3fff in 16 KB bank
3562       - 0xc000-0xdfff maps to 0x0000-0x1fff in 16 KB bank
3563       this is important if we map a bank that is also reachable by another,
3564       undistorted space, such as cartridge, page 0 (video), or page 1
3565   */
3560        split into two 8 KB spaces:
3561        - 0xa000-0xbfff maps to 0x2000-0x3fff in 16 KB bank
3562        - 0xc000-0xdfff maps to 0x0000-0x1fff in 16 KB bank
3563        this is important if we map a bank that is also reachable by another,
3564        undistorted space, such as cartridge, page 0 (video), or page 1
3565    */
35663566   to8_data_vpage = bank;
35673567   if ( mess_ram_size == 512*1024 || to8_data_vpage < 16 )
35683568   {
src/mess/machine/nes.c
r5931r5932
450450   const char *filetype = image_filetype(image);
451451
452452   if (!mame_stricmp(filetype, "nes"))
453   {   
453   {
454454      /* Verify the file is in iNES format */
455455      memset(magic, '\0', sizeof(magic));
456456      image_fread(image, magic, 4);
r5931r5932
501501
502502         /* Read the second ROM option byte (offset 7) */
503503         image_fread(image, &m, 1);
504   
504
505505         /* Check for skanky headers */
506506         image_fread(image, &skank, 8);
507507
r5931r5932
516516            }
517517         }
518518         logerror("\n");
519   
519
520520         nes.mapper = nes.mapper | (m & 0xf0);
521521      }
522522
r5931r5932
525525      nes.trainer = local_options & 0x04;
526526      nes.four_screen_vram = local_options & 0x08;
527527
528      if (nes.battery)
528      if (nes.battery)
529529         logerror("-- Battery found\n");
530530
531      if (nes.trainer)
531      if (nes.trainer)
532532         logerror("-- Trainer found\n");
533533
534      if (nes.four_screen_vram)
534      if (nes.four_screen_vram)
535535         logerror("-- 4-screen VRAM\n");
536536
537537      /* Free the regions that were allocated by the ROM loader */
r5931r5932
586586      logerror("**\n");
587587      logerror("Mapper: %d\n", nes.mapper);
588588      logerror("PRG chunks: %02x, size: %06x\n", nes.prg_chunks, 0x4000 * nes.prg_chunks);
589//      printf("Mapper: %d\n", nes.mapper);
590//      printf("PRG chunks: %02x, size: %06x\n", nes.prg_chunks, 0x4000 * nes.prg_chunks);
589//      printf("Mapper: %d\n", nes.mapper);
590//      printf("PRG chunks: %02x, size: %06x\n", nes.prg_chunks, 0x4000 * nes.prg_chunks);
591591
592592      /* Read in any chr chunks */
593593      if (nes.chr_chunks > 0)
r5931r5932
617617
618618      logerror("CHR chunks: %02x, size: %06x\n", nes.chr_chunks, 0x4000 * nes.chr_chunks);
619619      logerror("**\n");
620//      printf("CHR chunks: %02x, size: %06x\n", nes.chr_chunks, 0x4000 * nes.chr_chunks);
621//      printf("**\n");
620//      printf("CHR chunks: %02x, size: %06x\n", nes.chr_chunks, 0x4000 * nes.chr_chunks);
621//      printf("**\n");
622622
623623      /* Attempt to load a battery file for this ROM. If successful, we */
624624      /* must wait until later to move it to the system memory. */
r5931r5932
685685            if (unif_board == NULL)
686686            {
687687               logerror("Unsupported UNIF board.\n");
688//               return INIT_FAIL;
688//                  return INIT_FAIL;
689689            }
690690         }
691691         else if ((magic2[0] == 'R') && (magic2[1] == 'E') && (magic2[2] == 'A') && (magic2[3] == 'D'))
src/mess/machine/nes_mmc.c
r5931r5932
66    MESS source file to handle various Multi-Memory Controllers (aka Mappers) used by NES carts.
77
88    Many information about the mappers below come from the wonderful doc written by Disch.
9    Current info (when used) are based on v0.6.1 of his docs.
9    Current info (when used) are based on v0.6.1 of his docs.
1010    You can find the latest version of the doc at http://www.romhacking.net/docs/362/
1111
1212
r5931r5932
1919    * 016 some graphics problem (e.g. Rokudenashi Blues misses some element of graphics)
2020    * 018 Pizza Pop and Plasma Ball shows graphics issues for this mapper
2121    * 024, 026, 085 Registers of the additional sound hardware are not emulated
22    * 032 Major League is not properly working: check missing windows or field graphics in top view screens
22    * 032 Major League is not properly working: check missing windows or field graphics in top view screens
2323          (it requires one hack to support both boards using this mapper)
2424    * 033 has still some graphics problem (e.g. missing text in Akira)
2525    * 034 Impossible Mission 2 is not working
r5931r5932
3737    * 072, 086, 092 lack samples support (maybe others as well)
3838    * 074 is only preliminar (no correct CHR swap)
3939    * 077 Requires 4-screen mirroring. Currently, it is very glitchy
40    * 078 Cosmo Carrier is not working (it requires one hack to support both boards using this mapper).
40    * 078 Cosmo Carrier is not working (it requires one hack to support both boards using this mapper).
4141          also, we lack NT mirroring
4242    * 082 has chr-rom banking problems. Also mapper is in the middle of sram, which is unemulated.
4343    * 083 has serious glitches
r5931r5932
153153static int mult1, mult2;
154154
155155/* common local variables */
156static UINT8 mmc_chr_source;            // this is set at init to CHRROM or CHRRAM. a few mappers can swap between
156static UINT8 mmc_chr_source;            // this is set at init to CHRROM or CHRRAM. a few mappers can swap between
157157                        // the two (this is done in the specific handlers)
158158static UINT8 mmc_cmd1, mmc_cmd2;         // these represent registers where the mapper writes important values
159159static UINT8 mmc_bank_latch1, mmc_bank_latch2;   // some mappers change banks by writing subsets of these bits
r5931r5932
659659   }
660660}
661661
662/*  Other custom mirroring helpers are defined below: Waixing games use waixing_set_mirror (which swaps
662/*  Other custom mirroring helpers are defined below: Waixing games use waixing_set_mirror (which swaps
663663    MIRROR_HIGH and MIRROR_LOW compared to the above) and Sachen games use sachen_set_mirror (which has
664664    a slightly different MIRROR_HIGH, with page 0 set to 0) */
665665
r5931r5932
672672    No need of additional MMC
673673
674674    Known Boards: NROM, FB02??, FB04??, Jaleco JF01, JF02, JF03, JF04
675    Games: Mario Bros., Super Mario Bros., Tennis and most of
676          the first generation games
675    Games: Mario Bros., Super Mario Bros., Tennis and most of
676          the first generation games
677677
678678    In MESS: Supported, no need of specific handlers or IRQ
679679
r5931r5932
683683
684684    Mapper 1
685685
686    Known Boards: MMC1 based Boards, i.e. SAROM, SBROM, SCROM,
686    Known Boards: MMC1 based Boards, i.e. SAROM, SBROM, SCROM,
687687          SEROM, SFROM, SGROM, SHROM, SJROM, SKROM, SLROM, SNROM,
688688          SOROM, SUROM, SXROM, WH??
689    Games: Faxanadu, Final Fantasy I & II, Kid Icarus, Legend
689    Games: Faxanadu, Final Fantasy I & II, Kid Icarus, Legend
690690          of Zelda, Metroid
691691
692692    In MESS: Supported
r5931r5932
941941
942942    Known Boards: CNROM, CXROM, X79B?, Bandai Aerobics Board,
943943          Tengen 800008, Bootleg Board by NTDEC (N715062)
944    Games: Adventure Island, Flipull, Friday 13th, GeGeGe no
945          Kitarou, Ghostbusters, Gradius, Hokuto no Ken, Milon's
944    Games: Adventure Island, Flipull, Friday 13th, GeGeGe no
945          Kitarou, Ghostbusters, Gradius, Hokuto no Ken, Milon's
946946          Secret Castle
947947
948948    In MESS: Supported
r5931r5932
958958
959959    Mapper 4
960960
961    Known Boards: MMC3 based Boards, i.e. HKROM, TEROM, TBROM,
962          TFROM, TGROM, TKROM, TLROM, TNROM, TR1ROM, TSROM,
961    Known Boards: MMC3 based Boards, i.e. HKROM, TEROM, TBROM,
962          TFROM, TGROM, TKROM, TLROM, TNROM, TR1ROM, TSROM,
963963          TVROM, TRXROM
964    Games: Final Fantasy III, MegaMan 3,4,5 & 6, Startropics,
965          Super Mario Bros. 2 & 3,
964    Games: Final Fantasy III, MegaMan 3,4,5 & 6, Startropics,
965          Super Mario Bros. 2 & 3,
966966
967967    In MESS: Supported
968968
r5931r5932
10151015
10161016      if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount)
10171017      {
1018         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
1018         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
10191019               video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)));
10201020         cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE);
10211021//          timer_adjust_oneshot(nes_irq_timer, cputag_clocks_to_attotime(device->machine, "maincpu", 4), 0);
r5931r5932
11231123
11241124    Mapper 5
11251125
1126    Known Boards:  MMC3 based Boards, i.e. ELROM, EKROM, ETROM,
1126    Known Boards:  MMC3 based Boards, i.e. ELROM, EKROM, ETROM,
11271127          EWROM and EXROM variants
11281128    Games: Castlevania III, Just Breed, many Koei titles
11291129
r5931r5932
17161716
17171717    Mapper 7
17181718
1719    Known Boards: AMROM, ANROM, AN1ROM, AOROM and unlicensed
1719    Known Boards: AMROM, ANROM, AN1ROM, AOROM and unlicensed
17201720          AxROM
17211721    Games: Arch Rivals, Battletoads, Cabal, Commando, Solstice
17221722
r5931r5932
19871987
19881988    Known Boards: Bandai LZ93D50 24C02
19891989    Games: Crayon Shin-Chan - Ora to Poi Poi, Dragon Ball Z Gaiden,
1990          Dragon Ball Z II & III, Rokudenashi Blues, SD Gundam
1990          Dragon Ball Z II & III, Rokudenashi Blues, SD Gundam
19911991          Gaiden - KGM2
19921992
19931993    In MESS: Supported
r5931r5932
21402140
21412141    Known Boards: Jaleco JF23, JF24, JF25, JF27, JF29, JF30, JF31,
21422142          JF32, JF33, JF34, JF35, JF36, JF37, JF38, JF40, JF41, SS88006
2143    Games: Lord of King, Magic John, Moe Pro '90, Ninja Jajamaru,
2143    Games: Lord of King, Magic John, Moe Pro '90, Ninja Jajamaru,
21442144          Pizza Pop, Plasma Ball
21452145
21462146    In MESS: Supported
r5931r5932
23962396    Mapper 19
23972397
23982398    Known Boards: Namcot 163 & 163S
2399    Games: Battle Fleet, Family Circuit '91, Famista '90, '91,
2399    Games: Battle Fleet, Family Circuit '91, Famista '90, '91,
24002400          '92 & '94, Megami Tensei II, Top Striker, Wagyan Land 2 & 3
24012401
24022402    In MESS: Supported
r5931r5932
26042604    Mapper 21 & 25
26052605
26062606    Known Boards: Konami VRC4A & VRC4C (21), VRC4B & VRC4D (25)
2607    Games: Ganbare Goemon Gaiden 2, Wai Wai World 2 (21), Bio
2607    Games: Ganbare Goemon Gaiden 2, Wai Wai World 2 (21), Bio
26082608          Miracle Bokutte Upa, Ganbare Goemon Gaiden, TMNT 1 & 2 Jpn (25)
26092609
26102610    In MESS: Supported
r5931r5932
27782778    Known Boards: Konami VRC2A
27792779    Games: Ganbare Pennant Race, Twin Bee 3
27802780
2781    In MESS: Supported.
2781    In MESS: Supported.
27822782
27832783*************************************************************/
27842784
r5931r5932
29432943
29442944   switch (offset & 0x7003)
29452945   {
2946      case 0x0000:
2947      case 0x0001:
2948      case 0x0002:
2946      case 0x0000:
2947      case 0x0001:
2948      case 0x0002:
29492949      case 0x0003:
29502950         /* Switch 16k bank at $8000 */
29512951         prg16_89ab(space->machine, data);
r5931r5932
29642964            case 0x0c: set_nt_mirroring(PPU_MIRROR_HIGH); break;
29652965         }
29662966         break;
2967      case 0x4000:
2968      case 0x4001:
2969      case 0x4002:
2967      case 0x4000:
2968      case 0x4001:
2969      case 0x4002:
29702970      case 0x4003:
29712971         /* Switch 8k bank at $c000 */
29722972         prg8_cd(space->machine, data);
r5931r5932
30803080    Known Boards: Unknown Bootleg Board
30813081    Games: World Hero
30823082
3083    In MESS: Unsupported.
3083    In MESS: Unsupported.
30843084
30853085*************************************************************/
30863086
r5931r5932
31333133    Mapper 32
31343134
31353135    Known Boards: Irem G101A & G101B
3136    Games: Ai Sensei no Oshiete, Image Fight, Kaiketsu
3136    Games: Ai Sensei no Oshiete, Image Fight, Kaiketsu
31373137          Yanchamaru 2, Maikyuu Shima, Paaman, Paaman 2
31383138
31393139    In MESS: Supported.
r5931r5932
31723172    Mapper 33
31733173
31743174    Known Boards: Taito TC0190FMC
3175    Games: Akira, Bakushou!! Jinsei Gekijou, Don Doko Don,
3176          Insector X, Operation Wolf, Power Blazer, Takeshi no
3175    Games: Akira, Bakushou!! Jinsei Gekijou, Don Doko Don,
3176          Insector X, Operation Wolf, Power Blazer, Takeshi no
31773177          Sengoku Fuuunji
31783178
31793179    In MESS: Supported.
r5931r5932
32193219    Mapper 34
32203220
32213221    Known Boards: BNROM, Unlicensed BxROM, NINA001, NINA002
3222    Games: Deadly Tower, Impossible Mission II, Titanic 1912,
3222    Games: Deadly Tower, Impossible Mission II, Titanic 1912,
32233223          Dance Xtreme
32243224
32253225    In MESS: Supported.
r5931r5932
32743274    Known Boards: Bootleg Board by TXC
32753275    Games: Strike Wolf (also Policeman?? according to Nestopia)
32763276
3277    In MESS: Supported.
3277    In MESS: Supported.
32783278
32793279*************************************************************/
32803280
r5931r5932
32983298
32993299    MMC3 clone
33003300
3301    In MESS: Unsupported.
3301    In MESS: Unsupported.
33023302
33033303*************************************************************/
33043304
r5931r5932
33093309    Known Boards: Discrete Logic Board
33103310    Games: Crime Busters
33113311
3312    In MESS: Supported.
3312    In MESS: Supported.
33133313
33143314*************************************************************/
33153315
r5931r5932
33283328    Known Boards: Bootleg Board by Subor
33293329    Games: Study n Game 32 in 1
33303330
3331    In MESS: Partially Supported.
3331    In MESS: Partially Supported.
33323332
33333333*************************************************************/
33343334
r5931r5932
36593659    Mapper 48
36603660
36613661    Known Boards: Taito TC0190FMC PAL16R4
3662    Games: Bakushou!! Jinsei Gekijou 3, Bubble Bobble 2,
3662    Games: Bakushou!! Jinsei Gekijou 3, Bubble Bobble 2,
36633663          Captain Saver, Don Doko Don 2, Flintstones, Jetsons
36643664
3665    In MESS: Unsupported.
3665    In MESS: Unsupported.
36663666
36673667*************************************************************/
36683668
r5931r5932
36993699    Known Boards: Unknown Bootleg Board
37003700    Games: Super Mario Bros. Pirate Alt. Levels
37013701
3702    In MESS: Unsupported.
3702    In MESS: Unsupported.
37033703
37043704*************************************************************/
37053705
r5931r5932
37613761
37623762    MMC3 clone
37633763
3764    In MESS: Unsupported.
3764    In MESS: Unsupported.
37653765
37663766*************************************************************/
37673767
r5931r5932
37723772    Known Boards: Unknown Multigame Bootleg Board
37733773    Games: Supervision 16 in 1
37743774
3775    In MESS: Unsupported.
3775    In MESS: Unsupported.
37763776
37773777*************************************************************/
37783778
r5931r5932
37833783    Known Boards: Unknown Multigame Bootleg Board
37843784    Games: [no games in nes.hsi]
37853785
3786    In MESS: Unsupported.
3786    In MESS: Unsupported.
37873787
37883788*************************************************************/
37893789
r5931r5932
37943794    Known Boards: Unknown Bootleg Board
37953795    Games: [no games in nes.hsi]
37963796
3797    In MESS: Unsupported.
3797    In MESS: Unsupported.
37983798
37993799*************************************************************/
38003800
r5931r5932
38053805    Known Boards: Bootleg Board by Kaiser (KS202)
38063806    Games: Super Mario Bros. 3 Pirate
38073807
3808    In MESS: Unsupported.
3808    In MESS: Unsupported.
38093809
38103810*************************************************************/
38113811
r5931r5932
38863886    Mapper 60
38873887
38883888    Known Boards: Unknown Multigame Bootleg Board
3889    Games: 4 in 1, 35 in 1
3889    Games: 4 in 1, 35 in 1
38903890
3891    In MESS: Unsupported.
3891    In MESS: Unsupported.
38923892
38933893*************************************************************/
38943894
r5931r5932
39013901
39023902    Simple Mapper: prg/chr/nt are swapped depending on the offset
39033903    of writes in 0x8000-0xffff. offset&0x80 set NT mirroring,
3904    when (offset&0x30) is 0,3 prg32 is set; when it is 1,2
3904    when (offset&0x30) is 0,3 prg32 is set; when it is 1,2
39053905    two 16k prg banks are set. See below for the values used in
39063906    these banks.
39073907
r5931r5932
39653965    Known Boards: Unknown Multigame Bootleg Board
39663966    Games: [no games in nes.hsi]
39673967
3968    In MESS: Unsupported.
3968    In MESS: Unsupported.
39693969
39703970*************************************************************/
39713971
r5931r5932
39743974    Mapper 64
39753975
39763976    Known Boards: Tengen 800032
3977    Games: Klax, Road Runner, Rolling Thunder, Shinobi, Skulls
3977    Games: Klax, Road Runner, Rolling Thunder, Shinobi, Skulls
39783978          & Croosbones, Xybots
39793979
39803980    In MESS: Supported. It also uses mapper4_irq.
r5931r5932
40854085    Mapper 65
40864086
40874087    Known Boards: Irem H3001
4088    Games: Daiku no Gen San 2 - Akage no Dan no Gyakushuu,
4088    Games: Daiku no Gen San 2 - Akage no Dan no Gyakushuu,
40894089          Kaiketsu Yanchamaru 3, Spartan X 2
40904090
40914091    In MESS: Supported.
r5931r5932
42644264
42654265   switch (m68_mirror)
42664266   {
4267      case 0x00:
4268         set_nt_mirroring(PPU_MIRROR_HORZ);
4267      case 0x00:
4268         set_nt_mirroring(PPU_MIRROR_HORZ);
42694269         break;
4270      case 0x01:
4271         set_nt_mirroring(PPU_MIRROR_VERT);
4270      case 0x01:
4271         set_nt_mirroring(PPU_MIRROR_VERT);
42724272         break;
4273      case 0x02:
4274         set_nt_mirroring(PPU_MIRROR_LOW);
4273      case 0x02:
4274         set_nt_mirroring(PPU_MIRROR_LOW);
42754275         break;
4276      case 0x03:
4277         set_nt_mirroring(PPU_MIRROR_HIGH);
4276      case 0x03:
4277         set_nt_mirroring(PPU_MIRROR_HIGH);
42784278         break;
42794279      case 0x10:
42804280         set_nt_page(0, ROM, m0 | 0x80, 0);   //(m0 << 10) + M68_OFFSET);
r5931r5932
43554355
43564356    Known Boards: JLROM, JSROM, Sunsoft 5B, Sunsoft FME7 and
43574357         Custom
4358    Games: Barcode World, Batman - Return of the Joker, Gimmick!,
4358    Games: Barcode World, Batman - Return of the Joker, Gimmick!,
43594359          Splatter House - Wanpaku Graffiti
43604360
43614361    In MESS: Supported.
r5931r5932
44504450    Mapper 70
44514451
44524452    Known Boards: Discrete Logic Board
4453    Games: Space Shadow, Family Trainer Manhattan Police,
4453    Games: Space Shadow, Family Trainer Manhattan Police,
44544454          Kamen Rider Club
44554455
44564456    Same board as mapper 152, but no NT mirroring
r5931r5932
44744474    Mapper 71
44754475
44764476    Known Boards: Camerica Boards (BF9093, BF9097, BF909X, ALGNV11)
4477    Games: Linus Spacehead's Cosmic Crusade, Micro Machines,
4477    Games: Linus Spacehead's Cosmic Crusade, Micro Machines,
44784478          Mig-29, Stunt Kids
44794479
4480    We currently do not emulate NT mirroring for BF9097 board
4480    We currently do not emulate NT mirroring for BF9097 board
44814481    (missing in BF9093). As a result Fire Hawk is broken.
44824482
44834483    In MESS: Partially Supported.
r5931r5932
45044504    Mapper 72
45054505
45064506    Known Boards: Jaleco JF17, JF26 and JF28
4507    Games: Moero!! Juudou Warriors, Moero!! Pro Tennis, Pinball
4507    Games: Moero!! Juudou Warriors, Moero!! Pro Tennis, Pinball
45084508          Quest Jpn
45094509
45104510    In MESS: Supported.
r5931r5932
45694569    Mapper 74
45704570
45714571    Known Boards: Type A by Waixing
4572    Games: Columbus - Ougon no Yoake (C), Ji Jia Zhan Shi,
4572    Games: Columbus - Ougon no Yoake (C), Ji Jia Zhan Shi,
45734573          Jia A Fung Yun, Wei Luo Chuan Qi
45744574
45754575    In MESS: Partially Supported, but we ignore accesses to 0x5000 / 0x6000 atm
4576   (is this the reason for missing graphics?)
4576    (is this the reason for missing graphics?)
45774577
45784578*************************************************************/
45794579
r5931r5932
47274727    Mapper 78
47284728
47294729    Known Boards: Jaleco JF16 and Irem
4730    Games: Holy Diver, Portopia Renzoku Satsujin Jiken,
4730    Games: Holy Diver, Portopia Renzoku Satsujin Jiken,
47314731          Uchuusen - Cosmo Carrier
47324732
47334733    In MESS: Partially Supported.
r5931r5932
47494749    Mapper 79
47504750
47514751    Known Boards: NINA03, NINA06 by AVE
4752    Games: Krazy Kreatures, Poke Block, Puzzle, Pyramid,
4752    Games: Krazy Kreatures, Poke Block, Puzzle, Pyramid,
47534753          Solitaire, Ultimate League Soccer
47544754
47554755    In MESS: Supported.
r5931r5932
47724772    Mapper 80
47734773
47744774    Known Boards: Taito X1-005 Ver. A
4775    Games: Bakushou!! Jinsei Gekijou 2, Kyonshiizu 2, Minelvaton
4775    Games: Bakushou!! Jinsei Gekijou 2, Kyonshiizu 2, Minelvaton
47764776          Saga, Taito Grand Prix
47774777
4778    Registers are at 0x7ef0-0x7eff. first six ones choose chr
4779    (2x2k + 4x1k) banks, the seventh sets NT mirroring, the
4778    Registers are at 0x7ef0-0x7eff. first six ones choose chr
4779    (2x2k + 4x1k) banks, the seventh sets NT mirroring, the
47804780    remaining ones chose prg banks.
47814781
47824782    In MESS: Supported.
r5931r5932
48164816      case 0x1ef6:
48174817         set_nt_mirroring((data & 0x01) ? PPU_MIRROR_VERT : PPU_MIRROR_HORZ);
48184818         break;
4819      case 0x1efa:
4819      case 0x1efa:
48204820      case 0x1efb:
48214821         /* Switch 8k ROM at $8000 */
48224822         prg8_89(space->machine, data);
48234823         break;
4824      case 0x1efc:
4824      case 0x1efc:
48254825      case 0x1efd:
48264826         /* Switch 8k ROM at $a000 */
48274827         prg8_ab(space->machine, data);
48284828         break;
4829      case 0x1efe:
4829      case 0x1efe:
48304830      case 0x1eff:
48314831         /* Switch 8k ROM at $c000 */
48324832         prg8_cd(space->machine, data);
r5931r5932
48534853    Mapper 82
48544854
48554855    Known Boards: Taito X1017
4856    Games: Kyuukyoku Harikiri Koushien, Kyuukyoku Harikiri
4856    Games: Kyuukyoku Harikiri Koushien, Kyuukyoku Harikiri
48574857          Stadium, SD Keiji - Blader
48584858
48594859    In MESS: Supported.
r5931r5932
49334933    Mapper 83
49344934
49354935    Known Boards: Unknown Multigame Bootleg Board
4936    Games: Dragon Ball Party, Fatal Fury 2, Street Blaster II
4936    Games: Dragon Ball Party, Fatal Fury 2, Street Blaster II
49374937          Pro, World Heroes 2
49384938
49394939    In MESS: Supported.
r5931r5932
50655065         /* Switch 8k bank at $8000 */
50665066         prg8_89(space->machine, data);
50675067         break;
5068      case 0x0008:
5069      case 0x0010:
5068      case 0x0008:
5069      case 0x0010:
50705070      case 0x0018:
50715071         /* Switch 8k bank at $a000 */
50725072         prg8_ab(space->machine, data);
r5931r5932
51655165
51665166    Mapper 87
51675167
5168    Known Boards: Jaleco JF05, JF06, JF07, JF08, JF09, JF10 and
5168    Known Boards: Jaleco JF05, JF06, JF07, JF08, JF09, JF10 and
51695169                 Discrete Logic Board
5170    Games: The Goonies, Hyper Olympics, Jajamaru no Daibouken,
5170    Games: The Goonies, Hyper Olympics, Jajamaru no Daibouken,
51715171          Legend of Kage, Twin Bee
51725172
51735173    In MESS: Supported.
r5931r5932
52515251    Known Boards: Type A by J.Y. Company
52525252    Games: Aladdin, Final Fight 3, Super Mario World, Tekken 2
52535253
5254    In MESS: Unsupported.
5254    In MESS: Unsupported.
52555255
52565256*************************************************************/
52575257
r5931r5932
52605260    Mapper 91
52615261
52625262    Known Boards: Unknown Bootleg Board
5263    Games: Mortal Kombat II, Street Fighter III, Super Mario
5263    Games: Mortal Kombat II, Street Fighter III, Super Mario
52645264          Kart Rider
52655265
52665266    In MESS: Partially supported.
r5931r5932
53655365    Known Boards: Namcot 3425
53665366    Games: Dragon Buster
53675367
5368    Quite similar to other Namco boards, but with a peculiar
5368    Quite similar to other Namco boards, but with a peculiar
53695369    NT mirroring.
53705370
53715371    In MESS: Supported.
r5931r5932
53895389      {
53905390         switch (mmc_cmd1 & 0x07)
53915391         {
5392            case 0:
5393            case 1:
5392            case 0:
5393            case 1:
53945394               chr2_x(space->machine, mmc_cmd1 ? 2 : 0, (data >> 1) & 0x1f, CHRROM);
53955395               break;
5396            case 2:
5397            case 3:
5398            case 4:
5399            case 5:
5396            case 2:
5397            case 3:
5398            case 4:
5399            case 5:
54005400               chr1_x(space->machine, 2 + mmc_cmd1, data & 0x1f, CHRROM);
54015401               map95_reg[mmc_cmd1 - 2] = data & 0x20;
54025402               if (!(mmc_cmd1 & 0x80))
r5931r5932
54095409               else
54105410                  set_nt_mirroring(PPU_MIRROR_HORZ);
54115411               break;
5412            case 6:
5413               prg8_89(space->machine,data & 0x1f);
5412            case 6:
5413               prg8_89(space->machine,data & 0x1f);
54145414               break;
5415            case 7:
5415            case 7:
54165416               prg8_ab(space->machine,data & 0x1f);
54175417               break;
54185418         }
r5931r5932
54265426    Mapper 96
54275427
54285428    Known Boards: Bandai Oeka Kids Board
5429    Games: Oeka Kids - Anpanman no Hiragana Daisuki, Oeka
5429    Games: Oeka Kids - Anpanman no Hiragana Daisuki, Oeka
54305430          Kids - Anpanman to Oekaki Shiyou!!
54315431
54325432    In MESS: Preliminary Support.
r5931r5932
55495549    Known Boards: Camerica Golden Five
55505550    Games: Pegasus 5 in 1
55515551
5552    In MESS: Supported.
5552    In MESS: Supported.
55535553
55545554*************************************************************/
55555555
r5931r5932
55655565         prg16_89ab(space->machine, mmc_bank_latch1);
55665566         prg16_cdef(space->machine, ((data & 0x07) << 4) | 0x0f);
55675567      }
5568         
5568
55695569   }
55705570   else
55715571   {
r5931r5932
55815581    Known Boards: Custom Board
55825582    Games: Nintendo World Championships 1990
55835583
5584    In MESS: Unsupported.
5584    In MESS: Unsupported.
55855585
55865586*************************************************************/
55875587
r5931r5932
55925592    Known Boards: Unknown Bootleg Board
55935593    Games: Super Mario Bros. 3 Pirate
55945594
5595    In MESS: Unsupported.
5595    In MESS: Unsupported.
55965596
55975597*************************************************************/
55985598
r5931r5932
56635663
56645664    No info avaliable
56655665
5666    In MESS: Unsupported.
5666    In MESS: Unsupported.
56675667
56685668*************************************************************/
56695669
r5931r5932
56725672    Mapper 112
56735673
56745674    Known Boards: Bootleg Board NTDEC ASDER
5675    Games: Cobra Mission, Fighting Hero III, Huang Di, Master
5675    Games: Cobra Mission, Fighting Hero III, Huang Di, Master
56765676          Shooter
56775677
56785678    In MESS: Supported.
r5931r5932
57325732    Mapper 113
57335733
57345734    Known Boards: Bootleg Board by HES (also used by others)
5735    Games: AV Hanafuda Club, AV Soccer, Papillon, Sidewinder,
5735    Games: AV Hanafuda Club, AV Soccer, Papillon, Sidewinder,
57365736          Total Funpack
57375737
57385738    In MESS: Supported.
r5931r5932
57595759
57605760    MMC3 clone
57615761
5762    In MESS: Unsupported.
5762    In MESS: Unsupported.
57635763
57645764*************************************************************/
57655765
r5931r5932
57675767
57685768    Mapper 115 (formerly 248)
57695769
5770    Known Boards: Unknown Bootleg Board by Kasing
5771    Games: AV Jiu Ji Mahjong, Bao Qing Tian, Thunderbolt 2,
5770    Known Boards: Unknown Bootleg Board by Kasing
5771    Games: AV Jiu Ji Mahjong, Bao Qing Tian, Thunderbolt 2,
57725772          Shisen Mahjong 2
57735773
57745774    MMC3 clone
r5931r5932
58715871
58725872      if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount)
58735873      {
5874         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
5874         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
58755875               video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)));
58765876         cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE);
58775877      }
r5931r5932
58855885    Known Boards: Unknown Bootleg Board (Someri?!?)
58865886    Games: AV Mei Shao Nv Zhan Shi, Chuugoku Taitei
58875887
5888    In MESS: Unsupported.
5888    In MESS: Unsupported.
58895889
58905890*************************************************************/
58915891
r5931r5932
58965896    Known Boards: Bootleg Board by Future Media
58975897    Games: Crayon Shin-chan (C), San Guo Zhi 4 - Chi Bi Feng Yun
58985898
5899    In MESS: Unsupported.
5899    In MESS: Unsupported.
59005900
59015901*************************************************************/
59025902
r5931r5932
59055905    Mapper 118
59065906
59075907    Known Boards: TKSROM, TLSROM
5908    Games: Armadillo, Play Action Football, Pro Hockey, RPG
5908    Games: Armadillo, Play Action Football, Pro Hockey, RPG
59095909          Jinsei Game, Y's 3
59105910
59115911    In MESS: Supported. It also uses mapper4_irq.
r5931r5932
61496149    Known Boards: Unknown Bootleg Board
61506150    Games: Tobidase Daisakusen (FDS Conversion)
61516151
6152    In MESS: Unsupported.
6152    In MESS: Unsupported.
61536153
61546154*************************************************************/
61556155
r5931r5932
61626162
61636163    MMC3 clone
61646164
6165    In MESS: Unsupported.
6165    In MESS: Unsupported.
61666166
61676167*************************************************************/
61686168
r5931r5932
61846184    Known Boards: Bootleg Board ???
61856185    Games: [no games in nes.hsi]
61866186
6187    In MESS: Unsupported.
6187    In MESS: Unsupported.
61886188
61896189*************************************************************/
61906190
r5931r5932
62176217    Known Boards: Unknown Multigame Bootleg Board
62186218    Games: [no games in nes.hsi]
62196219
6220    In MESS: Unsupported.
6220    In MESS: Unsupported.
62216221
62226222*************************************************************/
62236223
r5931r5932
62836283    Known Boards: Bootleg Board by TXC (T22211A)
62846284    Games: Creatom
62856285
6286    Info from NEStopia: this mapper features write to four
6287    registers (0x4100-0x4103). The third one is used to select
6286    Info from NEStopia: this mapper features write to four
6287    registers (0x4100-0x4103). The third one is used to select
62886288    PRG and CHR banks.
62896289
6290    In MESS: Supported.
6290    In MESS: Supported.
62916291
62926292*************************************************************/
62936293
r5931r5932
63086308   if (offset == 0x0000)
63096309      return (txc_reg[1] ^ txc_reg[2]) | 0x40;
63106310
6311   else
6311   else
63126312      return 0x00;
63136313}
63146314
r5931r5932
63486348
63496349    MMC3 clone
63506350
6351    In MESS: Unsupported.
6351    In MESS: Unsupported.
63526352
63536353*************************************************************/
63546354
r5931r5932
64356435{
64366436   LOG_MMC(("mapper137_l_w, offset: %04x, data: %02x\n", offset, data));
64376437
6438   /* write happens only if we are at 0x4100 + k * 0x200,
6439   but 0x4100 is offset = 0 */
6438   /* write happens only if we are at 0x4100 + k * 0x200,
6439    but 0x4100 is offset = 0 */
64406440   if (!(offset & 0x100))
64416441   {
64426442      if (!(offset & 0x01))
r5931r5932
64906490   UINT8 bank_helper1 = 0, bank_helper2 = 0;
64916491   LOG_MMC(("mapper138_l_w, offset: %04x, data: %02x\n", offset, data));
64926492
6493   /* write happens only if we are at 0x4100 + k * 0x200,
6494   but 0x4100 is offset = 0 */
6493   /* write happens only if we are at 0x4100 + k * 0x200,
6494    but 0x4100 is offset = 0 */
64956495   if (!(offset & 0x100))
64966496   {
64976497      if (!(offset & 0x01))
r5931r5932
64996499      else
65006500      {
65016501         sachen_regs[mmc_cmd1] = data;
6502   
6502
65036503         switch (mmc_cmd1)
65046504         {
65056505         case 0x05:
r5931r5932
65476547   UINT8 bank_helper1 = 0, bank_helper2 = 0;
65486548   LOG_MMC(("mapper139_l_w, offset: %04x, data: %02x\n", offset, data));
65496549
6550   /* write happens only if we are at 0x4100 + k * 0x200,
6551   but 0x4100 is offset = 0 */
6550   /* write happens only if we are at 0x4100 + k * 0x200,
6551    but 0x4100 is offset = 0 */
65526552   if (!(offset & 0x100))
65536553   {
65546554      if (!(offset & 0x01))
r5931r5932
65566556      else
65576557      {
65586558         sachen_regs[mmc_cmd1] = data;
6559   
6559
65606560         switch (mmc_cmd1)
65616561         {
65626562         case 0x05:
r5931r5932
65706570            {
65716571               bank_helper1 = sachen_regs[7] & 0x01;
65726572               bank_helper2 = (sachen_regs[4] & 0x07) << 3;
6573               chr2_0(space->machine, ((sachen_regs[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 2, CHRROM);   
6573               chr2_0(space->machine, ((sachen_regs[bank_helper1 ? 0 : 0] & 0x07) | bank_helper2) << 2, CHRROM);
65746574               chr2_2(space->machine, ((sachen_regs[bank_helper1 ? 0 : 1] & 0x07) | bank_helper2) << 2 | 0x01, CHRROM);
65756575               chr2_4(space->machine, ((sachen_regs[bank_helper1 ? 0 : 2] & 0x07) | bank_helper2) << 2 | 0x02, CHRROM)   ;
65766576               chr2_6(space->machine, ((sachen_regs[bank_helper1 ? 0 : 3] & 0x07) | bank_helper2) << 2 | 0x03, CHRROM);
r5931r5932
66126612    Mapper 141
66136613
66146614    Known Boards: Bootleg Board by Sachen (8259A)
6615    Games: Po Po Team, Poker Mahjong, Q Boy, Rockball,
6615    Games: Po Po Team, Poker Mahjong, Q Boy, Rockball,
66166616          Super Cartridge (several versions), Super Pang (1 & 2)
66176617
66186618    In MESS: Supported.
r5931r5932
66246624   UINT8 bank_helper1 = 0, bank_helper2 = 0;
66256625   LOG_MMC(("mapper141_l_w, offset: %04x, data: %02x\n", offset, data));
66266626
6627   /* write happens only if we are at 0x4100 + k * 0x200,
6628   but 0x4100 is offset = 0 */
6627   /* write happens only if we are at 0x4100 + k * 0x200,
6628    but 0x4100 is offset = 0 */
66296629   if (!(offset & 0x100))
66306630   {
66316631      if (!(offset & 0x01))
r5931r5932
66916691{
66926692   LOG_MMC(("mapper143_l_r, offset: %04x\n", offset));
66936693
6694   /* the address is read only if we are at 0x4100 + k * 0x200,
6695   but 0x4100 is offset = 0 */
6694   /* the address is read only if we are at 0x4100 + k * 0x200,
6695    but 0x4100 is offset = 0 */
66966696   if (!(offset & 0x100))
66976697      return (~offset & 0x3f) | 0x40;
66986698   else
r5931r5932
67066706    Known Boards: Bootleg Board by AGCI (50282)
67076707    Games: Death Race
67086708
6709    Just like mapper 11, except bit 0 taken from ROM and 0x8000
6709    Just like mapper 11, except bit 0 taken from ROM and 0x8000
67106710    ignored?
67116711
67126712    In MESS: Supported.
r5931r5932
67566756    Mapper 146
67576757
67586758    Known Boards: Bootleg Board by Sachen (SA0161M)
6759    Games: Galactic Crusader, Lucky 777, Metal Fighter,
6759    Games: Galactic Crusader, Lucky 777, Metal Fighter,
67606760          Millionaire, Pyramid II
67616761
67626762    This is basically the same as Nina-006 (Mapper 79)
r5931r5932
68106810    Known Boards: Bootleg Board by Sachen (SA0037)
68116811    Games: Mahjong World, Shisen Mahjong
68126812
6813    Very simple mapper: writes to 0x8000-0xffff set pgr32 and chr8
6813    Very simple mapper: writes to 0x8000-0xffff set pgr32 and chr8
68146814        banks
68156815
68166816    In MESS: Supported.
r5931r5932
68506850    Mapper 150
68516851
68526852    Known Boards: Bootleg Board by Sachen (74SL374B)
6853    Games: Chess Academy, Chinese Checkers Jpn, Mahjong Academy,
6853    Games: Chess Academy, Chinese Checkers Jpn, Mahjong Academy,
68546854          Olympic IQ, Poker II, Tasac
68556855
68566856    Still investigating this mapper...
r5931r5932
68636863{
68646864   LOG_MMC(("mapper150_l_w, offset: %04x, data: %02x\n", offset, data));
68656865
6866   /* write happens only if we are at 0x4100 + k * 0x200,
6867   but 0x4100 is offset = 0 */
6866   /* write happens only if we are at 0x4100 + k * 0x200,
6867    but 0x4100 is offset = 0 */
68686868   if (!(offset & 0x100))
68696869   {
68706870      if (!(offset & 0x01))
r5931r5932
69006900{
69016901   LOG_MMC(("mapper150_l_r, offset: %04x", offset));
69026902
6903   /* read  happens only if we are at 0x4100 + k * 0x200,
6904   but 0x4100 is offset = 0 */
6903   /* read  happens only if we are at 0x4100 + k * 0x200,
6904    but 0x4100 is offset = 0 */
69056905   if (!(offset & 0x100))
69066906      return (~mmc_cmd1 & 0x3f) /* ^ dips*/;   // we would need to check the Dips here
6907   else
6907   else
69086908      return 0;
69096909}
69106910
r5931r5932
69526952    Mapper 153
69536953
69546954    Known Boards: Bandai Board
6955    Games: Dragon Ball, Dragon Ball 3, Famicom Jump, Famicom
6955    Games: Dragon Ball, Dragon Ball 3, Famicom Jump, Famicom
69566956          Jump II
69576957
69586958    In MESS: Unsupported.
r5931r5932
70637063
70647064    Mapper 157
70657065
7066    Known Boards: Bandai Datach Board
7066    Known Boards: Bandai Datach Board
70677067    Games: Datach Games
70687068
70697069    In MESS: Unsupported. Needs reads from 0x6000-0x7fff for the
r5931r5932
71317131    Mapper 163
71327132
71337133    Known Boards: Bootleg Board by Nanjing
7134    Games: Diablo, Final Fantasy VII, Harvest Moon, He Xin Wei
7134    Games: Diablo, Final Fantasy VII, Harvest Moon, He Xin Wei
71357135          Ji, Yu-Gi-Oh, Zelda - Shen Qi De Mao Zi and other
71367136
71377137    In MESS: Unsupported.
r5931r5932
71437143    Mapper 164
71447144
71457145    Known Boards: Bootleg Board by Waixing
7146    Games: Darkseed, Digital Dragon, Final Fantasy V, Pocket
7146    Games: Darkseed, Digital Dragon, Final Fantasy V, Pocket
71477147          Monster Red
71487148
71497149    In MESS: Supported.
r5931r5932
74097409    Known Boards: Unknown Bootleg Board
74107410    Games: Shu Qi Yu - Zhi Li Xiao Zhuan Yuan
74117411
7412    Very simple mapper: writes to 0x5ff1 set prg32 (to data>>1),
7412    Very simple mapper: writes to 0x5ff1 set prg32 (to data>>1),
74137413    while writes to 0x5ff2 set chr8
74147414
74157415    In MESS: Supported.
r5931r5932
74367436    Mapper 177
74377437
74387438    Known Boards: Bootleg Board by Henggedianzi
7439    Games: Mei Guo Fu Hao, Shang Gu Shen Jian , Wang Zi Fu
7439    Games: Mei Guo Fu Hao, Shang Gu Shen Jian , Wang Zi Fu
74407440          Chou Ji, Xing He Zhan Shi
74417441
74427442    Writes to 0x8000-0xffff set prg32. Moreover, data&0x20 sets
r5931r5932
74597459    Mapper 178
74607460
74617461    Known Boards: Bootleg Board by Waixing
7462    Games: Fan Kong Jing Ying, San Guo Zhong Lie Zhuan, Xing
7462    Games: Fan Kong Jing Ying, San Guo Zhong Lie Zhuan, Xing
74637463          Ji Zheng Ba
74647464
74657465    In MESS: Supported.
r5931r5932
76217621
76227622      if (IRQ_enable && !blanked && (IRQ_count == 0) && priorCount)
76237623      {
7624         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
7624         LOG_MMC(("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline,
76257625               video_screen_get_vpos(device->machine->primary_screen), video_screen_get_hpos(device->machine->primary_screen)));
76267626         cputag_set_input_line(device->machine, "maincpu", M6502_IRQ_LINE, HOLD_LINE);
76277627      }
r5931r5932
76447644    Mapper 184
76457645
76467646    Known Boards: Sunsoft 1
7647    Games: Atlantis no Nazo, Kanshakudama Nage Kantarou no
7647    Games: Atlantis no Nazo, Kanshakudama Nage Kantarou no
76487648          Toukaidou Gojuusan Tsugi, Wing of Madoola
76497649
76507650    Very simple mapper: writes to 0x6000-0x7fff set chr banks
r5931r5932
78197819    Mapper 195
78207820
78217821    Known Boards: Type E by Waixing
7822    Games: Captain Tsubasa Vol. II (C), Chaos World, God
7822    Games: Captain Tsubasa Vol. II (C), Chaos World, God
78237823          Slayer (C), Zu Qiu Xiao Jiang
78247824
78257825    MMC3 clone
r5931r5932
78357835    Known Boards: Unknown Bootleg Board
78367836    Games: Super Mario Bros. 11, Super Mario Bros. 17
78377837
7838    This acts basically like a MMC3 with different use of write
7839    address.
7838    This acts basically like a MMC3 with different use of write
7839    address.
78407840
78417841    In MESS: Supported.
78427842
r5931r5932
79087908    Mapper 199
79097909
79107910    Known Boards: Type G by Waixing
7911    Games: San Guo Zhi 2, Dragon Ball Z Gaiden (C), Dragon
7911    Games: San Guo Zhi 2, Dragon Ball Z Gaiden (C), Dragon
79127912          Ball Z II (C)
79137913
79147914    MMC3 clone
r5931r5932
80438043
80448044    Mapper 206
80458045
8046    Known Boards: Namcot 34x3 boards, DEROM, DE1ROM, DRROM and
8046    Known Boards: Namcot 34x3 boards, DEROM, DE1ROM, DRROM and
80478047          Tengen 800002, 800004, 800030 boards
8048    Games: Babel no Tou, Dragon Buster II, Family Circuit,
8049          Family Tennis, Fantasy Zone, Gauntlet, Karnov,
8048    Games: Babel no Tou, Dragon Buster II, Family Circuit,
8049          Family Tennis, Fantasy Zone, Gauntlet, Karnov,
80508050          Mappy Land, Pac-Mania, R.B.I. Baseball, Super Sprint
80518051
80528052    In MESS: Supported.
r5931r5932
81098109         /* Switch 1k VROM at $1c00 */
81108110         chr1_7(space->machine, data, CHRROM);
81118111         break;
8112      case 0x1efa:
8112      case 0x1efa:
81138113      case 0x1efb:
81148114         /* Switch 8k ROM at $8000 */
81158115         prg8_89(space->machine, data);
81168116         break;
8117      case 0x1efc:
8117      case 0x1efc:
81188118      case 0x1efd:
81198119         /* Switch 8k ROM at $a000 */
81208120         prg8_ab(space->machine, data);
81218121         break;
8122      case 0x1efe:
8122      case 0x1efe:
81238123      case 0x1eff:
81248124         /* Switch 8k ROM at $c000 */
81258125         prg8_cd(space->machine, data);
r5931r5932
81488148    Mapper 209
81498149
81508150    Known Boards: Type B by J.Y. Company
8151    Games: Power Rangers 3, Power Rangers 4, Shin Samurai
8151    Games: Power Rangers 3, Power Rangers 4, Shin Samurai
81528152          Spirits 2
81538153
81548154    In MESS: Unsupported.
r5931r5932
83988398
83998399    MMC3 clone according to NEStopia
84008400
8401    In MESS: Unsupported.
8401    In MESS: Unsupported.
84028402
84038403*************************************************************/
84048404
r5931r5932
88208820    Known Boards: Bootleg Board by C&E
88218821    Games: Jing Ke Xin Zhuan, Sheng Huo Lie Zhuan
88228822
8823    Simple Mapper: writes to 0x4020-0x5fff sets prg32 to
8823    Simple Mapper: writes to 0x4020-0x5fff sets prg32 to
88248824         data>>4 and chr8 to data&f. We currently do not map
8825         writes to 0x4020-0x40ff (to do: verify if this produces
8825         writes to 0x4020-0x40ff (to do: verify if this produces
88268826         issues)
88278827
88288828    In MESS: Supported.
r5931r5932
88428842    Mapper 241
88438843
88448844    Known Boards: Bootleg Board by TXC
8845    Games: Commandos, Journey to the West, Ma Bu Mi Zhen &
8845    Games: Commandos, Journey to the West, Ma Bu Mi Zhen &
88468846           Qu Wei Cheng Yu Wu, Si Lu Chuan Qi
88478847
88488848    Simple Mapper: writes to 0x8000-0xffff sets the prg32 bank.
r5931r5932
88728872    Games: Wai Xing Zhan Shi, Dragon Quest VIII
88738873
88748874    Simple mapper: writes to 0x8000-0xffff sets prg32 banks to
8875        (offset>>3)&f. written data&3 sets the mirroring (with
8876        switched high/low compared to the standard one). However,
8877        a second variant DQ7 and requires no NT mirroring.
8875        (offset>>3)&f. written data&3 sets the mirroring (with
8876        switched high/low compared to the standard one). However,
8877        a second variant DQ7 and requires no NT mirroring.
88788878        Currently, we do not support this variant.
88798879
88808880    In MESS: Partial Support.
r5931r5932
89088908{
89098909   LOG_MMC(("mapper243_l_w, offset: %04x, data: %02x\n", offset, data));
89108910
8911   /* write happens only if we are at 0x4100 + k * 0x200,
8912   but 0x4100 is offset = 0 */
8911   /* write happens only if we are at 0x4100 + k * 0x200,
8912    but 0x4100 is offset = 0 */
89138913   if (!(offset & 0x100))
89148914   {
89158915      if (!(offset & 0x01))
r5931r5932
89968996    Games: Fong Shen Bang - Zhu Lu Zhi Zhan
89978997
89988998    Simple mapper: writes to 0x6000-0x67ff set PRG and CHR banks.
8999    Namely, 0x6000->0x6003 select resp. prg8_89, prg8_ab, prg8_cd
8999    Namely, 0x6000->0x6003 select resp. prg8_89, prg8_ab, prg8_cd
90009000    and prg8_ef. 0x6004->0x6007 select resp. crh2_0, chr2_2,
90019001    chr2_4 and chr2_6. In 0x6800-0x7fff lies WRAM.
90029002
r5931r5932
90709070
90719071    Known Boards: Waixing Security 0 & 1
90729072    Games: Duo Bao Xiao Ying Hao - Guang Ming yu An Hei Chuan Shuo,
9073           Myth Struggle, San Shi Liu Ji, Shui Hu Zhuan
9073           Myth Struggle, San Shi Liu Ji, Shui Hu Zhuan
90749074
90759075    MMC3 clone
90769076
r5931r5932
90839083    Mapper 250
90849084
90859085    Known Boards: Unknown Bootleg Board by Nitra
9086    Games: Time Diver Avenger
9086    Games: Time Diver Avenger
90879087
9088    This acts basically like a MMC3 with different use of write
9088    This acts basically like a MMC3 with different use of write
90899089    address. According to NEStopia, there is also a slightly
90909090    different way to set NT mirroring (see below).
90919091
r5931r5932
91139113    Mapper 251
91149114
91159115    Known Boards: Undocumented
9116    Games: Super 8-in-1 99 King Fighter
9116    Games: Super 8-in-1 99 King Fighter
91179117
91189118    In MESS: Unsupported.
91199119
r5931r5932
95759575         mmc_cmd1 = 0;
95769576         prg16_89ab(space->machine, 0);
95779577         prg16_cdef(space->machine, nes.prg_chunks - 1);
9578//         set_nt_mirroring(PPU_MIRROR_HIGH);   // this would be needed for Major League
9578//          set_nt_mirroring(PPU_MIRROR_HIGH);  // this would be needed for Major League
95799579         break;
95809580      case 24:
95819581      case 26:
src/mess/devices/multcart.h
r5931r5932
11/*********************************************************************
22
3   multcart.h
3    multcart.h
44
5   Multi-cartridge handling code
5    Multi-cartridge handling code
66
77*********************************************************************/
88
src/mess/devices/snapquik.h
r5931r5932
11/*********************************************************************
22
3   snapquik.h
3    snapquik.h
44
5   Snapshots and quickloads
5    Snapshots and quickloads
66
77*********************************************************************/
88
src/mess/devices/cococart.h
r5931r5932
11/*********************************************************************
22
3   cococart.h
3    cococart.h
44
5   CoCo/Dragon cartridge management
5    CoCo/Dragon cartridge management
66
77*********************************************************************/
88
src/mess/devices/harddriv.c
r5931r5932
11/*********************************************************************
22
3   Code to interface the MESS image code with MAME's harddisk core.
3    Code to interface the MESS image code with MAME's harddisk core.
44
5   We do not support diff files as it will involve some changes in
6   the MESS image code.  Additionally, the need for diff files comes
7   from MAME's need for "cannonical" hard drive images.
5    We do not support diff files as it will involve some changes in
6    the MESS image code.  Additionally, the need for diff files comes
7    from MAME's need for "cannonical" hard drive images.
88
9   Raphael Nabet 2003
9    Raphael Nabet 2003
1010
11   Update: 23-Feb-2004 - Unlike floppy disks, for which we support
12   myriad formats on many systems, it is my intention for MESS to
13   standardize on the CHD file format for hard drives so I made a few
14   changes to support this
11    Update: 23-Feb-2004 - Unlike floppy disks, for which we support
12    myriad formats on many systems, it is my intention for MESS to
13    standardize on the CHD file format for hard drives so I made a few
14    changes to support this
1515
1616*********************************************************************/
1717
r5931r5932
8888
8989/*************************************
9090 *
91 *   DEVICE_IMAGE_LOAD(mess_hd)
91 *  DEVICE_IMAGE_LOAD(mess_hd)
9292 *  DEVICE_IMAGE_CREATE(mess_hd)
9393 *
94 *   Device load and create
94 *  Device load and create
9595 *
9696 *************************************/
9797
r5931r5932
109109      err = chd_open_file(image_core_file(image), is_writeable ? CHD_OPEN_READWRITE : CHD_OPEN_READ, NULL, &harddisk->chd);
110110
111111      /* special case; if we get CHDERR_FILE_NOT_WRITEABLE, make the
112      * image read only and repeat */
112        * image read only and repeat */
113113      if (err == CHDERR_FILE_NOT_WRITEABLE)
114114         image_make_readonly(image);
115115   }
r5931r5932
195195
196196/*************************************
197197 *
198 *   DEVICE_IMAGE_UNLOAD(mess_hd)
198 *  DEVICE_IMAGE_UNLOAD(mess_hd)
199199 *
200 *   Device unload
200 *  Device unload
201201 *
202202 *************************************/
203203
r5931r5932
242242
243243/*************************************
244244 *
245 *   Get the MESS/MAME CHD file (from the src/chd.c core)
245 *  Get the MESS/MAME CHD file (from the src/chd.c core)
246246 *  after an image has been opened with the mess_hd core
247247 *
248248 *************************************/
r5931r5932
425425      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(mess_ide); break;
426426      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(mess_ide); break;
427427      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(mess_ide); break;
428//      case DEVINFO_FCT_IMAGE_VERIFY:            info->f = (genf *) ide_hd_validity_check; break;
428//      case DEVINFO_FCT_IMAGE_VERIFY:              info->f = (genf *) ide_hd_validity_check; break;
429429
430430      /* --- the following bits of info are returned as NULL-terminated strings --- */
431431      case DEVINFO_STR_NAME:                  strcpy(info->s, "IDE harddisk"); break;
src/mess/devices/orch90.c
r5931r5932
11/***************************************************************************
22
3   orch90.c
3    orch90.c
44
5   Code for emulating the CoCo Orch-90 (Orchestra 90) sound cartridge
5    Code for emulating the CoCo Orch-90 (Orchestra 90) sound cartridge
66
7   The Orch-90 was a simple sound cartridge; it had two 8-bit DACs
8   supporting stereo sound.  The left channel was at $FF7A, and the right
9   channel was at $FF7B
7    The Orch-90 was a simple sound cartridge; it had two 8-bit DACs
8    supporting stereo sound.  The left channel was at $FF7A, and the right
9    channel was at $FF7B
1010
1111***************************************************************************/
1212
r5931r5932
8585
8686/*-------------------------------------------------
8787    DEVICE_GET_INFO(coco_cartridge_pcb_orch90) -
88   get info function for the Orch-90
88    get info function for the Orch-90
8989-------------------------------------------------*/
9090
9191DEVICE_GET_INFO(coco_cartridge_pcb_orch90)
src/mess/devices/harddriv.h
r5931r5932
11/*********************************************************************
22
3   harddriv.h
3    harddriv.h
44
5   MESS interface to the MAME CHD code
5    MESS interface to the MAME CHD code
66
77*********************************************************************/
88
src/mess/devices/ti99cart.c
r5931r5932
11/**********************************************************************
22
3   ti99cart.c
3    ti99cart.c
44
5   TI99 family cartridge management
5    TI99 family cartridge management
66
7   Michael Zapf, 2009
8   
7    Michael Zapf, 2009
8
99*********************************************************************/
1010#include "driver.h"
1111#include "ti99cart.h"
r5931r5932
3939struct _ti99_multicart_t
4040{
4141   /* Reserves space for all cartridges. This is also used in the legacy
42      cartridge system, but only for slot 0. */
42       cartridge system, but only for slot 0. */
4343   cartridge_t cartridge[NUMBER_OF_CARTRIDGE_SLOTS];
4444
4545   /* Determines which slot is currently active. This value is changed when there
46   are accesses to other GROM base addresses. */
46    are accesses to other GROM base addresses. */
4747   int active_slot;
48   
49   /* Used in order to enforce a special slot. This value is retrieved
50      from the dipswitch setting. A value of -1 means automatic, that is,
51      the grom base switch is used. Values 0 .. max refer to the
52      respective slot. */
48
49   /* Used in order to enforce a special slot. This value is retrieved
50       from the dipswitch setting. A value of -1 means automatic, that is,
51       the grom base switch is used. Values 0 .. max refer to the
52       respective slot. */
5353   int fixed_slot;
5454
55   /* Holds the highest index of a cartridge being plugged in plus one.
56      If we only have one cartridge inserted, we don't want to get a
57      selection option, so we just mirror the memory contents. */
55   /* Holds the highest index of a cartridge being plugged in plus one.
56       If we only have one cartridge inserted, we don't want to get a
57       selection option, so we just mirror the memory contents. */
5858   int next_free_slot;
59   
60   /* Counts the number of slots which currently contain legacy format
61      cartridge images. */
59
60   /* Counts the number of slots which currently contain legacy format
61       cartridge images. */
6262   int legacy_slots;
6363
64   /* Counts the number of slots which currently contain new format
65      cartridge images. */
64   /* Counts the number of slots which currently contain new format
65       cartridge images. */
6666   int multi_slots;
6767
68   /* Legacy mode. Stores the slot number where the cartridge part is mounted.
69      Index is from slotc_type_t. */
68   /* Legacy mode. Stores the slot number where the cartridge part is mounted.
69       Index is from slotc_type_t. */
7070   int legacy_slotnumber[5];
7171};
7272typedef struct _ti99_multicart_t ti99_multicart_t;
7373
7474#define AUTO -1
7575
76typedef enum _slotc_type_t
77{
78   SLOTC_EMPTY = -1,
79   SLOTC_GROM = 0,
80   SLOTC_CROM = 1,
81   SLOTC_DROM = 2,
82   SLOTC_MINIMEM = 3,
83   SLOTC_MBX = 4
76typedef enum _slotc_type_t
77{
78   SLOTC_EMPTY = -1,
79   SLOTC_GROM = 0,
80   SLOTC_CROM = 1,
81   SLOTC_DROM = 2,
82   SLOTC_MINIMEM = 3,
83   SLOTC_MBX = 4
8484} slotc_type_t;
8585
8686/* Function declaration; the function itself is in the later part of this file. */
r5931r5932
9393{
9494   /* Read function for this cartridge. */
9595   read16_device_func read;
96   
96
9797   /* Write function for this cartridge. */
9898   write16_device_func write;
99   
99
100100   /* Read function for this cartridge, TI-99/8. */
101101   read8_device_func read8;
102   
102
103103   /* Write function for this cartridge, TI-99/8. */
104104   write8_device_func write8;
105105
106106   /* Read function for this cartridge, CRU. */
107107   read8_device_func cruread;
108   
108
109109   /* Write function for this cartridge, CRU. */
110110   write8_device_func cruwrite;
111   
111
112112   /* Link up to the cartridge structure which contains this pcb. */
113113   cartridge_t *cartridge;
114   
114
115115   /* Function to assemble this cartridge. */
116116   assmfct   *assemble;
117   
117
118118   /* Function to disassemble this cartridge. */
119119   assmfct   *disassemble;
120120};
r5931r5932
128128   return FALSE;
129129}
130130
131/*
132   Activates a slot in the multi-cartridge extender.
133   Setting the slot is done by accessing the GROM ports using a
134   specific address:
135   
136   slot n:  read data (read address, write data, write address)
137   
138   slot 0:  0x9800 (0x9802, 0x9c00, 0x9c02)   : cartridge1
139   slot 1:  0x9804 (0x9806, 0x9c04, 0x9c06)   : cartridge2
140   ...
141   slot 15: 0x983c (0x983e, 0x9c3c, 0x9c3e)   : cartridge16
131/*
132    Activates a slot in the multi-cartridge extender.
133    Setting the slot is done by accessing the GROM ports using a
134    specific address:
142135
143   The following addresses are theoretically available, but the
144   built-in OS does not use them; i.e. cartridges will not be
145   included in the selection list, and their features will not be
146   found by lookup, but they could be accessed directly by user
147   programs.
148   slot 16: 0x9840 (0x9842, 0x9c40, 0x9c42)
149   ...
150   slot 255:  0x9bfc (0x9bfe, 0x9ffc, 0x9ffe)
151   
152   Setting the GROM base should select one cartridge, but the ROMs in the
153   CPU space must also be switched. As there is no known special mechanism
154   we assume that by switching the GROM base, the ROM is automatically
155   switched.
156   
157   Caution: This means that cartridges which do not have at least one
158   GROM cannot be switched with this mechanism.
159   
160   We assume that the slot number is already calculated in the caller:
161   slotnumber>=0 && slotnumber<=255
162   
163   NOTE: The OS will stop searching when it finds slots 1 and 2 empty.
164   Interestingly, cartridge subroutines are found nevertheless, even when
165   the cartridge is plugged into a higher slot.
136    slot n:  read data (read address, write data, write address)
137
138    slot 0:  0x9800 (0x9802, 0x9c00, 0x9c02)   : cartridge1
139    slot 1:  0x9804 (0x9806, 0x9c04, 0x9c06)   : cartridge2
140    ...
141    slot 15: 0x983c (0x983e, 0x9c3c, 0x9c3e)   : cartridge16
142
143    The following addresses are theoretically available, but the
144    built-in OS does not use them; i.e. cartridges will not be
145    included in the selection list, and their features will not be
146    found by lookup, but they could be accessed directly by user
147    programs.
148    slot 16: 0x9840 (0x9842, 0x9c40, 0x9c42)
149    ...
150    slot 255:  0x9bfc (0x9bfe, 0x9ffc, 0x9ffe)
151
152    Setting the GROM base should select one cartridge, but the ROMs in the
153    CPU space must also be switched. As there is no known special mechanism
154    we assume that by switching the GROM base, the ROM is automatically
155    switched.
156
157    Caution: This means that cartridges which do not have at least one
158    GROM cannot be switched with this mechanism.
159
160    We assume that the slot number is already calculated in the caller:
161    slotnumber>=0 && slotnumber<=255
162
163    NOTE: The OS will stop searching when it finds slots 1 and 2 empty.
164    Interestingly, cartridge subroutines are found nevertheless, even when
165    the cartridge is plugged into a higher slot.
166166*/
167167void cartridge_slot_set(const device_config *cartsys, int slotnumber)
168168{
169169   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
170170   assert(slotnumber>=0 && slotnumber<=255);
171//   if (cartslots->active_slot != slotnumber) printf("Setting cartslot to %d\n", slotnumber);
171//  if (cartslots->active_slot != slotnumber) printf("Setting cartslot to %d\n", slotnumber);
172172   if (cartslots->fixed_slot==AUTO)
173173      cartslots->active_slot = slotnumber;
174174   else
r5931r5932
176176}
177177
178178/*
179   Allows to manually lock the cartslot system to a specific slot.
180   Called from the machine driver, taking the dipswitch setting.
181   We take slot numbers from 0 (automatic mode) to the maximum.
179    Allows to manually lock the cartslot system to a specific slot.
180    Called from the machine driver, taking the dipswitch setting.
181    We take slot numbers from 0 (automatic mode) to the maximum.
182182*/
183183void lock_cartridge_slot(const device_config *cartsys, int slotnumber)
184184{
r5931r5932
207207   cart = &cartslots->cartridge[slotnumber];
208208
209209   cart->rom_size = cart->ram_size = cart->grom_size = 0;
210   cart->rom_ptr = NULL;
211   cart->rom2_ptr = NULL;
210   cart->rom_ptr = NULL;
211   cart->rom2_ptr = NULL;
212212   cart->ram_ptr = NULL;
213   cart->grom_ptr = NULL;
213   cart->grom_ptr = NULL;
214214}
215215
216/*
217   GROM access. Accesses the GROMs in the cartridge. GROM memory is
218   accessed serially via a set of ports. The GRMWA port (bank 0: 0x9c02)
219   takes two consecutive byte writes which represent the high and low byte
220   of the memory address in the GROM space. Once set, bytes can be read
221   by repeated read accesses on the GRMRD port (bank 0: 0x9800). The
222   address pointer advances on each read. The pointer wraps at the end
223   of each GROM chip memory space, i.e. every 8KiB.
224   This function takes the current GROM address minus 0x6000 which is the
225   lowest address for cartridge GROMs. Lower addresses access GROMs in the
226   console only, which appear in all banks.
227   Note that the GROM access mechanism is identical for all cartridge
228   types.
216/*
217    GROM access. Accesses the GROMs in the cartridge. GROM memory is
218    accessed serially via a set of ports. The GRMWA port (bank 0: 0x9c02)
219    takes two consecutive byte writes which represent the high and low byte
220    of the memory address in the GROM space. Once set, bytes can be read
221    by repeated read accesses on the GRMRD port (bank 0: 0x9800). The
222    address pointer advances on each read. The pointer wraps at the end
223    of each GROM chip memory space, i.e. every 8KiB.
224    This function takes the current GROM address minus 0x6000 which is the
225    lowest address for cartridge GROMs. Lower addresses access GROMs in the
226    console only, which appear in all banks.
227    Note that the GROM access mechanism is identical for all cartridge
228    types.
229229*/
230UINT8 cartridge_grom_read(const device_config *device, int cart_offset)
230UINT8 cartridge_grom_read(const device_config *device, int cart_offset)
231231{
232232   UINT8 value;
233   int slot;
233   int slot;
234234   cartridge_t *cartridge;
235235   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
236   
236
237237   /* Handle the legacy mode. */
238238   if (in_legacy_mode(device))
239239      return cartridge_grom_read_legacy(device, cart_offset);
240   
240
241241   slot = cartslots->active_slot;
242242   /*
243      This fixes a minor issue: The selection mechanism of the console
244      concludes that there are multiple cartridges plugged in when it
245      checks the different GROM bases and finds different data. Empty
246      slots should return 0 at all addresses, but when we have only
247      one cartridge, this entails that the second cartridge is
248      different (all zeros), and so we get a meaningless selection
249      option between cartridge 1 and 1 and 1 ...
250     
251      So if next_free_slot==1, we have one cartridge in slot 0.
252      In that case we trick the OS to believe that the addressed
253      cartridge appears at all locations which causes it to assume a
254      standard single cartslot. 
255   */
243        This fixes a minor issue: The selection mechanism of the console
244        concludes that there are multiple cartridges plugged in when it
245        checks the different GROM bases and finds different data. Empty
246        slots should return 0 at all addresses, but when we have only
247        one cartridge, this entails that the second cartridge is
248        different (all zeros), and so we get a meaningless selection
249        option between cartridge 1 and 1 and 1 ...
250
251        So if next_free_slot==1, we have one cartridge in slot 0.
252        In that case we trick the OS to believe that the addressed
253        cartridge appears at all locations which causes it to assume a
254        standard single cartslot.
255    */
256256   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
257257      slot=0;
258258
259259   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
260260      value = 0;
261   else
261   else
262262   {
263263      cartridge = &cartslots->cartridge[slot];
264     
264
265265      if ((cartridge->grom_size>0) && (cartridge->pcb!=NULL))
266266      {
267         /* This is the reason why we need the image size: Read
268            access beyond the image size must be detected. */
269         if (cart_offset > cartridge->grom_size)
267         /* This is the reason why we need the image size: Read
268               access beyond the image size must be detected. */
269         if (cart_offset > cartridge->grom_size)
270270            return 0;
271271
272272         value = (UINT8)cartridge->grom_buffer;
r5931r5932
280280         logerror("Empty socket at address G(%d)>%04x\n", slot, 0x6000 + cart_offset);
281281      }
282282   }
283//   printf("grom access(port = %x, address = %04x) = %02x\n", slot,  0x6000 + cart_offset*2, value);
283//  printf("grom access(port = %x, address = %04x) = %02x\n", slot,  0x6000 + cart_offset*2, value);
284284   return value;
285285}
286286
287/*
288   Find the index of the cartridge name. We assume the format
289   <name><number>, i.e. the number is the longest string from the right
290   which can be interpreted as a number.
287/*
288    Find the index of the cartridge name. We assume the format
289    <name><number>, i.e. the number is the longest string from the right
290    which can be interpreted as a number.
291291*/
292292static int get_index_from_tagname(const device_config *image)
293293{
r5931r5932
295295   int maxlen = strlen(tag);
296296   int i;
297297   for (i=maxlen-1; i >=0; i--)
298      if (tag[i] < 48 || tag[i] > 57) break;
298      if (tag[i] < 48 || tag[i] > 57) break;
299299
300300   return atoi(tag+i+1);
301301}
302302
303303/*
304   Common routine to assemble cartridges from resources.
304    Common routine to assemble cartridges from resources.
305305*/
306306static cartridge_t *assemble_common(const device_config *cartslot)
307307{
r5931r5932
309309   cartridge_t *cartridge;
310310   const device_config *cartsys = cartslot->owner;
311311   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
312   
312
313313   void *socketcont;
314314   int reslength;
315315   int i;
r5931r5932
318318   assert(slotnumber>=0 && slotnumber<NUMBER_OF_CARTRIDGE_SLOTS);
319319
320320   /* There is a cartridge in this slot, check the maximum slot number. */
321   if (cartslots->next_free_slot <= slotnumber)
321   if (cartslots->next_free_slot <= slotnumber)
322322   {
323323      cartslots->next_free_slot = slotnumber+1;
324324   }
325325   cartridge = &cartslots->cartridge[slotnumber];
326326
327   /* Get the socket which is retrieved by the multicart instance in
328      the state of the cartslot instance. */
327   /* Get the socket which is retrieved by the multicart instance in
328       the state of the cartslot instance. */
329329   socketcont = cartslot_get_socket(cartslot, "grom_socket");
330330   reslength = cartslot_get_resource_length(cartslot, "grom_socket");
331331   if (socketcont != NULL)
r5931r5932
333333      cartridge->grom_ptr = (UINT8 *)socketcont;
334334      cartridge->grom_size = reslength;
335335   }
336   
336
337337   socketcont = cartslot_get_socket(cartslot, "rom_socket");
338338   reslength = cartslot_get_resource_length(cartslot, "rom_socket");
339339   if (socketcont != NULL)
r5931r5932
348348            cont16b[i] = BIG_ENDIANIZE_INT16(cont16b[i]);
349349      }
350350   }
351   
351
352352   socketcont = cartslot_get_socket(cartslot, "rom2_socket");
353//   reslength = cartslot_get_resource_length(cartslot, "rom2_socket");  /* cannot differ from rom_socket */
353//  reslength = cartslot_get_resource_length(cartslot, "rom2_socket");  /* cannot differ from rom_socket */
354354   if (socketcont != NULL)
355355   {
356356      cartridge->rom2_ptr = (UINT16 *)socketcont;
r5931r5932
383383
384384static void set_pointers(const device_config *pcb, int index)
385385{
386   const device_config *cartsys = pcb->owner->owner;
386   const device_config *cartsys = pcb->owner->owner;
387387   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
388388   ti99_pcb_t *pcb_def = (ti99_pcb_t *)pcb->token;
389389
r5931r5932
393393   pcb_def->write8 = (write8_device_func) device_get_info_fct(pcb, TI99CARTINFO_FCT_6000_W8);
394394   pcb_def->cruread = (read8_device_func) device_get_info_fct(pcb, TI99CARTINFO_FCT_CRU_R);
395395   pcb_def->cruwrite = (write8_device_func) device_get_info_fct(pcb, TI99CARTINFO_FCT_CRU_W);
396   
396
397397   pcb_def->assemble = (assmfct *)device_get_info_fct(pcb, TI99CART_FCT_ASSM);
398398   pcb_def->disassemble = (assmfct *)device_get_info_fct(pcb, TI99CART_FCT_DISASSM);
399   
399
400400   pcb_def->cartridge = &cartslots->cartridge[index];
401401   pcb_def->cartridge->pcb = pcb;
402402}
403403
404404/*****************************************************************************
405405  Cartridge type: None
406     This PCB device is just a pseudo device; the legacy mode is handled
407   by dedicated functions.
406    This PCB device is just a pseudo device; the legacy mode is handled
407    by dedicated functions.
408408******************************************************************************/
409409static DEVICE_START(ti99_pcb_none)
410410{
411411   /* device is ti99_cartslot:cartridge:pcb */
412//   printf("DEVICE_START(ti99_pcb_none), tag of device=%s\n", device->tag);
412//  printf("DEVICE_START(ti99_pcb_none), tag of device=%s\n", device->tag);
413413   set_pointers(device, get_index_from_tagname(device->owner)-1);
414414}
415415
416416/*****************************************************************************
417417  Cartridge type: Standard
418     Most cartridges are built in this type. Every cartridge may contain
419   GROM between 0 and 40 KiB, and ROM with 8 KiB length, no banking.
418    Most cartridges are built in this type. Every cartridge may contain
419    GROM between 0 and 40 KiB, and ROM with 8 KiB length, no banking.
420420******************************************************************************/
421421
422422static DEVICE_START(ti99_pcb_std)
423423{
424424   /* device is ti99_cartslot:cartridge:pcb */
425//   printf("DEVICE_START(ti99_pcb_std), tag of device=%s\n", device->tag);
425//  printf("DEVICE_START(ti99_pcb_std), tag of device=%s\n", device->tag);
426426   set_pointers(device, get_index_from_tagname(device->owner)-1);
427427}
428428
429/*   
430   Read handler for the CPU address space of the cartridge
431   Images for this area are found in the rom_sockets.
429/*
430    Read handler for the CPU address space of the cartridge
431    Images for this area are found in the rom_sockets.
432432*/
433433static READ16_DEVICE_HANDLER( read_cart_std )
434434{
r5931r5932
436436   UINT16 value;
437437   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
438438   cartridge_t *cartridge = pcb->cartridge;
439   
439
440440   if (cartridge->rom_ptr==NULL)
441441   {
442//      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
443//      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
442//      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
443//      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
444444      value = 0;
445445   }
446446   else
447447   {
448448      value = ((UINT16 *)cartridge->rom_ptr)[offset];
449//      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
449//      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
450450   }
451//    printf("accessed cartridge rom[%02x:%04x] = %04x\n", 0, 0x6000+offset*2, value);
451// printf("accessed cartridge rom[%02x:%04x] = %04x\n", 0, 0x6000+offset*2, value);
452452   return value;
453453}
454454
r5931r5932
458458}
459459
460460/*
461   TI-99/8 support:
462   Read handler for the CPU address space of the cartridge
463   Images for this area are found in the rom_sockets.
464   For comments see the READ16 handler.
461    TI-99/8 support:
462    Read handler for the CPU address space of the cartridge
463    Images for this area are found in the rom_sockets.
464    For comments see the READ16 handler.
465465*/
466466static READ8_DEVICE_HANDLER( read_cart_std8 )
467467{
468468   UINT8 value;
469469   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
470470   cartridge_t *cartridge = pcb->cartridge;
471   
471
472472   if (cartridge->rom_ptr==NULL)
473473      value = 0;
474474   else
r5931r5932
477477}
478478
479479/*
480   TI-99/8 support:
481   Write handler. No writes are allowed to standard cartridges.
480    TI-99/8 support:
481    Write handler. No writes are allowed to standard cartridges.
482482*/
483483static WRITE8_DEVICE_HANDLER( write_cart_std8 )
484484{
r5931r5932
486486}
487487
488488/*
489   The standard cartridge assemble routine. We just call the common
490   function here.
489    The standard cartridge assemble routine. We just call the common
490    function here.
491491*/
492492static int assemble_std(const device_config *image)
493493{
494494   cartridge_t *cart;
495//   printf("assemble_std, %s\n", image->tag);
495//  printf("assemble_std, %s\n", image->tag);
496496   cart = assemble_common(image);
497     
497
498498   return INIT_PASS;
499499}
500500
501501/*
502   Removes pointers and restores the state before plugging in the
503   cartridge.
504   The pointer to the location after the last cartridge is adjusted.
505   As it seems, we can use the same function for the disassembling of all
506   cartridge types.
502    Removes pointers and restores the state before plugging in the
503    cartridge.
504    The pointer to the location after the last cartridge is adjusted.
505    As it seems, we can use the same function for the disassembling of all
506    cartridge types.
507507*/
508508static int disassemble_std(const device_config *image)
509509{
r5931r5932
514514   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
515515
516516   slotnumber = get_index_from_tagname(image)-1;
517//   printf("Disassemble cartridge %d\n", slotnumber);
517//  printf("Disassemble cartridge %d\n", slotnumber);
518518
519519   /* Search the highest remaining cartridge. */
520520   cartslots->next_free_slot = 0;
521521   for (i=NUMBER_OF_CARTRIDGE_SLOTS-1; i >= 0; i--)
522522   {
523      if (i != slotnumber)
523      if (i != slotnumber)
524524      {
525525         if (!slot_is_empty(cartsys, i))
526526         {
527527            cartslots->next_free_slot = i+1;
528//            printf("Setting new next_free_slot to %d\n", cartslots->next_free_slot);
528//              printf("Setting new next_free_slot to %d\n", cartslots->next_free_slot);
529529            break;
530530         }
531531      }
532532   }
533   
533
534534   /* Do we have RAM? If so, swap the bytes (undo the BIG_ENDIANIZE) */
535535   cart = &cartslots->cartridge[slotnumber];
536536   if (!is_99_8())
r5931r5932
538538      for (i = 0; i < cart->ram_size/2; i++)
539539         ((UINT16 *)cart->ram_ptr)[i] = BIG_ENDIANIZE_INT16(((UINT16 *)cart->ram_ptr)[i]);
540540   }
541   
541
542542   clear_slot(cartsys, slotnumber);
543543
544544   return INIT_PASS;
r5931r5932
546546
547547/*****************************************************************************
548548  Cartridge type: Paged (Extended Basic)
549   This cartridge consists of GROM memory and 2 pages of standard ROM.
550   The page is set by writing any value to a location in
551   the address area, where an even word offset sets the page to 0 and an
552   odd word offset sets the page to 1 (e.g. 6000 = bank 0, and
553   6002 = bank 1).
549    This cartridge consists of GROM memory and 2 pages of standard ROM.
550    The page is set by writing any value to a location in
551    the address area, where an even word offset sets the page to 0 and an
552    odd word offset sets the page to 1 (e.g. 6000 = bank 0, and
553    6002 = bank 1).
554554******************************************************************************/
555555
556556static DEVICE_START(ti99_pcb_paged)
557557{
558558   /* device is ti99_cartslot:cartridge:pcb */
559//   printf("DEVICE_START(ti99_pcb_paged), tag of device=%s\n", device->tag);
559//  printf("DEVICE_START(ti99_pcb_paged), tag of device=%s\n", device->tag);
560560   set_pointers(device, get_index_from_tagname(device->owner)-1);
561561}
562562
563/*   
564   Read handler for the CPU address space of the cartridge
565   Images for this area are found in the rom_sockets.
563/*
564    Read handler for the CPU address space of the cartridge
565    Images for this area are found in the rom_sockets.
566566*/
567567static READ16_DEVICE_HANDLER( read_cart_paged )
568568{
r5931r5932
571571   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
572572   cartridge_t *cartridge = pcb->cartridge;
573573   UINT16 *rombank;
574   
574
575575   if (cartridge->rom_page==0)
576576      rombank = cartridge->rom_ptr;
577577   else
578578      rombank = cartridge->rom2_ptr;
579   
579
580580   if (rombank==NULL)
581581   {
582//      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
583//      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
582//      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
583//      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
584584      /* TODO: Check for consistency with the GROM memory handling. */
585585      value = 0;
586586   }
587587   else
588588   {
589589      value = rombank[offset];
590//      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
590//      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
591591   }
592//    printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
592// printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
593593   return value;
594594}
595595
596596
597/*
598   Handle paging. Extended Basic switches between ROM banks by
599   using the value of the LSB of the address where any value
600   is written to.
597/*
598    Handle paging. Extended Basic switches between ROM banks by
599    using the value of the LSB of the address where any value
600    is written to.
601601*/
602602static WRITE16_DEVICE_HANDLER( write_cart_paged )
603603{
604604   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
605605   cartridge_t *cartridge = pcb->cartridge;
606606   cartridge->rom_page = offset & 1;
607//   printf("setting rompage to %d\n", cartridge->rom_page);
607//  printf("setting rompage to %d\n", cartridge->rom_page);
608608}
609609
610/*   
611   TI-99/8 support:
612   Read handler for the CPU address space of the cartridge.
613   Images for this area are found in the rom_sockets.
610/*
611    TI-99/8 support:
612    Read handler for the CPU address space of the cartridge.
613    Images for this area are found in the rom_sockets.
614614*/
615615static READ8_DEVICE_HANDLER( read_cart_paged8 )
616616{
r5931r5932
618618   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
619619   cartridge_t *cartridge = pcb->cartridge;
620620   UINT8 *rombank;
621   
621
622622   if (cartridge->rom_page==0)
623623      rombank = cartridge->rom_ptr;
624624   else
625625      rombank = cartridge->rom2_ptr;
626   
626
627627   if (rombank==NULL)
628628      value = 0;
629629   else
r5931r5932
633633}
634634
635635
636/*
637   TI-99/8 support:
638   Handle paging. Extended Basic switches between ROM banks by
639   using the value of the LSB of the address where any value
640   is written to. This is the TI-99/8 support.
641   Note that we need to check whether offset/2 is even or odd.
642   
643   FIXME: Extended Basic crashes with TI-99/8 when changing the rom page.
644   This may be an incompatibility of Extended Basic and TI-99/8.
636/*
637    TI-99/8 support:
638    Handle paging. Extended Basic switches between ROM banks by
639    using the value of the LSB of the address where any value
640    is written to. This is the TI-99/8 support.
641    Note that we need to check whether offset/2 is even or odd.
642
643    FIXME: Extended Basic crashes with TI-99/8 when changing the rom page.
644    This may be an incompatibility of Extended Basic and TI-99/8.
645645*/
646646static WRITE8_DEVICE_HANDLER( write_cart_paged8 )
647647{
648648   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
649649   cartridge_t *cartridge = pcb->cartridge;
650//   printf("offset = %04x\n", offset);
650//  printf("offset = %04x\n", offset);
651651   cartridge->rom_page = (offset>>1) & 1;
652652}
653653
654654/*
655   We require paged modules to have at least those two rom banks.
655    We require paged modules to have at least those two rom banks.
656656*/
657657static int assemble_paged(const device_config *image)
658658{
659659   cartridge_t *cart;
660   
661//   printf("assemble_paged, %s\n", image->tag);
660
661//  printf("assemble_paged, %s\n", image->tag);
662662   cart = assemble_common(image);
663663   if (cart->rom_ptr==NULL)
664664   {
r5931r5932
676676
677677/*****************************************************************************
678678  Cartridge type: Mini Memory
679   GROM: 6 KiB (occupies G>6000 to G>7800)
680   ROM: 4 KiB (romfile is actually 8 K long, half with zeros, 0x6000-0x6fff)
681   persistent RAM: 4 KiB (0x7000-0x7fff)   
679    GROM: 6 KiB (occupies G>6000 to G>7800)
680    ROM: 4 KiB (romfile is actually 8 K long, half with zeros, 0x6000-0x6fff)
681    persistent RAM: 4 KiB (0x7000-0x7fff)
682682******************************************************************************/
683683
684684static DEVICE_START(ti99_pcb_minimem)
685685{
686//   printf("TI99 pcb minimem start\n");
686//  printf("TI99 pcb minimem start\n");
687687   set_pointers(device, get_index_from_tagname(device->owner)-1);
688688}
689689
r5931r5932
693693   UINT16 value;
694694   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
695695   cartridge_t *cartridge = pcb->cartridge;
696   
696
697697   if (offset < 0x800)
698698   {
699699      if (cartridge->rom_ptr==NULL)
700700      {
701         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
702         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
701         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
702         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
703703         value = 0;
704704      }
705705      else
706706      {
707707         value = ((UINT16 *)cartridge->rom_ptr)[offset];
708         //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
708         //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
709709      }
710      //    printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
710      // printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
711711   }
712   else
712   else
713713   {
714714      if (cartridge->ram_ptr==NULL)
715715      {
716         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
717         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
716         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
717         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
718718         value = 0;
719719      }
720720      else
721721      {
722722         value = ((UINT16 *)cartridge->ram_ptr)[offset-0x800];
723         //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
723         //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
724724      }
725      //    printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
725      // printf("accessed cartridge rom[%02x:%04x] = %04x\n", rompage, 0x6000+offset*2, value);
726726   }
727727   return value;
728728}
729729
730/*
731   Mini Memory cartridge write operation. RAM is located at offset + 4 KiB
730/*
731    Mini Memory cartridge write operation. RAM is located at offset + 4 KiB
732732*/
733733static WRITE16_DEVICE_HANDLER( write_cart_minimem )
734734{
735735   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
736736   cartridge_t *cartridge = pcb->cartridge;
737737   UINT16 *pos;
738   
738
739739   if (offset < 0x800)
740740   {
741741      logerror("Write access to cartridge ROM at address %04x ignored", 0x6000 + 2*offset);
742742   }
743   else
743   else
744744   {
745745      if (cartridge->ram_ptr==NULL)
746746      {
747747         logerror("No cartridge RAM at address %04x", 0x6000 + 2*offset);
748748
749         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
750         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
749         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
750         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
751751         /* TODO: Check for consistency with the GROM memory handling. */
752752      }
753753      else
r5931r5932
759759}
760760
761761/*
762   Read handler for MiniMemory in TI-99/8.
762    Read handler for MiniMemory in TI-99/8.
763763*/
764764static READ8_DEVICE_HANDLER( read_cart_minimem8 )
765765{
r5931r5932
767767   UINT8 value;
768768   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
769769   cartridge_t *cartridge = pcb->cartridge;
770   
770
771771   if (offset < 0x1000)
772772   {
773773      if (cartridge->rom_ptr==NULL)
r5931r5932
779779         value = ((UINT8 *)cartridge->rom_ptr)[offset];
780780      }
781781   }
782   else
782   else
783783   {
784784      if (cartridge->ram_ptr==NULL)
785785      {
r5931r5932
793793   return value;
794794}
795795
796/*
797   Mini Memory cartridge write operation. RAM is located at offset + 4 KiB.
798   This is the TI-99/8 support.
796/*
797    Mini Memory cartridge write operation. RAM is located at offset + 4 KiB.
798    This is the TI-99/8 support.
799799*/
800800static WRITE8_DEVICE_HANDLER( write_cart_minimem8 )
801801{
802802   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
803803   cartridge_t *cartridge = pcb->cartridge;
804   
804
805805   if (offset < 0x1000)
806806   {
807807      logerror("Write access to cartridge ROM at address %04x ignored", 0x6000 + offset);
808808   }
809   else
809   else
810810   {
811811      if (cartridge->ram_ptr==NULL)
812812      {
813813         logerror("No cartridge RAM at address %04x", 0x6000 + offset);
814814
815         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
816         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
815         //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
816         //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
817817         /* TODO: Check for consistency with the GROM memory handling. */
818818      }
819819      else
r5931r5932
828828{
829829   cartridge_t *cart;
830830
831//   printf("assemble_minimem, %s\n", image->tag);
831//  printf("assemble_minimem, %s\n", image->tag);
832832   cart = assemble_common(image);
833833   if (cart->grom_size==0)
834834   {
r5931r5932
845845      logerror("Missing RAM for Mini Memory");
846846      return INIT_FAIL;
847847   }
848   
848
849849   return INIT_PASS;
850850}
851851
852852
853853/*****************************************************************************
854854  Cartridge type: SuperSpace II
855   SuperSpace cartridge type. SuperSpace is intended as a user-definable
856   blank cartridge containing buffered RAM
857   It has an Editor/Assembler GROM which helps the user to load
858   the user program into the cartridge. If the user program has a suitable
859   header, the console recognizes the cartridge as runnable, and
860   assigns a number in the selection screen.
861   Switching the RAM banks in this cartridge is achieved by setting
862   CRU bits (the system serial interface).
855    SuperSpace cartridge type. SuperSpace is intended as a user-definable
856    blank cartridge containing buffered RAM
857    It has an Editor/Assembler GROM which helps the user to load
858    the user program into the cartridge. If the user program has a suitable
859    header, the console recognizes the cartridge as runnable, and
860    assigns a number in the selection screen.
861    Switching the RAM banks in this cartridge is achieved by setting
862    CRU bits (the system serial interface).
863863
864   GROM: Editor/Assembler GROM
865   ROM: none
866   persistent RAM: 32 KiB (0x6000-0x7fff, 4 banks)
867   Switching the bank is done via CRU write
864    GROM: Editor/Assembler GROM
865    ROM: none
866    persistent RAM: 32 KiB (0x6000-0x7fff, 4 banks)
867    Switching the bank is done via CRU write
868868******************************************************************************/
869869
870870static DEVICE_START(ti99_pcb_super)
871871{
872//   printf("TI99 pcb super start\n");
872//  printf("TI99 pcb super start\n");
873873   set_pointers(device, get_index_from_tagname(device->owner)-1);
874874}
875875
876876/*
877   The CRU read handler. The CRU is a serial interface in the console.
878   Using the CRU we can switch the banks in the SuperSpace cartridge.
877    The CRU read handler. The CRU is a serial interface in the console.
878    Using the CRU we can switch the banks in the SuperSpace cartridge.
879879*/
880880static READ8_DEVICE_HANDLER( read_cart_cru )
881881{
r5931r5932
886886        int reply = 0;
887887
888888   /* ram_page contains the bank number. We have a maximum of
889      4 banks; the Super Space II manual says:
890   
891   Banks are selected by writing a bit pattern to CRU address >0800:
892   
893   Bank #   Value
894   0        >02  = 0000 0010
895   1        >08  = 0000 1000
896   2        >20  = 0010 0000
897   3        >80  = 1000 0000
898   
899   With the bank number (0, 1, 2, or 3) in R0:
900   
901   BNKSW   LI    R12,>0800   Set CRU address
902      LI    R1,2        Load Shift Bit
903      SLA   R0,1        Align Bank Number
904      JEQ   BNKS1       Skip shift if Bank 0
905      SLA   R1,0        Align Shift Bit
906   BNKS1   LDCR  R1,0        Switch Banks
907      SRL   R0,1        Restore Bank Number (optional)
908      RT
909   */
889       4 banks; the Super Space II manual says:
890
891    Banks are selected by writing a bit pattern to CRU address >0800:
892
893    Bank #   Value
894    0        >02  = 0000 0010
895    1        >08  = 0000 1000
896    2        >20  = 0010 0000
897    3        >80  = 1000 0000
898
899    With the bank number (0, 1, 2, or 3) in R0:
900
901    BNKSW   LI    R12,>0800   Set CRU address
902        LI    R1,2        Load Shift Bit
903        SLA   R0,1        Align Bank Number
904        JEQ   BNKS1       Skip shift if Bank 0
905        SLA   R1,0        Align Shift Bit
906    BNKS1   LDCR  R1,0        Switch Banks
907        SRL   R0,1        Restore Bank Number (optional)
908        RT
909    */
910910   if ((offset & 1) == 0 || offset > 7)
911911      reply = 0;
912   
913   /* CRU addresses are only 1 bit wide. Bytes are transferred from LSB
914      to MSB. That is, 8 bit are eight consecutive addresses. */
912
913   /* CRU addresses are only 1 bit wide. Bytes are transferred from LSB
914       to MSB. That is, 8 bit are eight consecutive addresses. */
915915   reply = (cartridge->ram_page == (offset-1)/2);
916916
917917   return reply;
r5931r5932
931931}
932932
933933/*
934   SuperSpace RAM read operation. RAM is located at 0x6000 to 0x7fff
935   as 4 banks of 8 KiB each
934    SuperSpace RAM read operation. RAM is located at 0x6000 to 0x7fff
935    as 4 banks of 8 KiB each
936936*/
937937static READ16_DEVICE_HANDLER( read_cart_super )
938938{
r5931r5932
941941   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
942942   cartridge_t *cartridge = pcb->cartridge;
943943   offs_t boffset;
944   
944
945945   if (cartridge->ram_ptr==NULL)
946946   {
947      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
948      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
947      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
948      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
949949      value = 0;
950950   }
951951   else
952952   {
953      boffset = cartridge->ram_page * 0x1000 + offset;     
953      boffset = cartridge->ram_page * 0x1000 + offset;
954954      value = ((UINT16 *)cartridge->ram_ptr)[boffset];
955      //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
955      //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
956956   }
957   //    printf("accessed cartridge ram[%02x:%04x] = %04x\n", cartridge->ram_page, 0x6000+offset*2, value);
957   // printf("accessed cartridge ram[%02x:%04x] = %04x\n", cartridge->ram_page, 0x6000+offset*2, value);
958958   return value;
959959}
960960
961961/*
962   SuperSpace RAM write operation. RAM is located at 0x6000 to 0x7fff
963   as 4 banks of 8 KiB each
962    SuperSpace RAM write operation. RAM is located at 0x6000 to 0x7fff
963    as 4 banks of 8 KiB each
964964*/
965965static WRITE16_DEVICE_HANDLER( write_cart_super )
966966{
r5931r5932
968968   cartridge_t *cartridge = pcb->cartridge;
969969   UINT16 *pos;
970970   offs_t boffset;
971   
971
972972   if (cartridge->ram_ptr==NULL)
973973   {
974974      logerror("No cartridge RAM at address %04x", 0x6000 + 2*offset);
975     
976      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
977      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
975
976      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
977      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
978978   }
979979   else
980980   {
981      boffset = cartridge->ram_page * 0x1000 + offset;     
981      boffset = cartridge->ram_page * 0x1000 + offset;
982982      pos = ((UINT16 *)cartridge->ram_ptr) + boffset;
983983      COMBINE_DATA(pos);
984984   }
985985}
986986
987987/*
988   SuperSpace RAM read operation. RAM is located at 0x6000 to 0x7fff
989   as 4 banks of 8 KiB each. This is the TI-99/8 support.
988    SuperSpace RAM read operation. RAM is located at 0x6000 to 0x7fff
989    as 4 banks of 8 KiB each. This is the TI-99/8 support.
990990*/
991991static READ8_DEVICE_HANDLER( read_cart_super8 )
992992{
r5931r5932
995995   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
996996   cartridge_t *cartridge = pcb->cartridge;
997997   offs_t boffset;
998   
998
999999   if (cartridge->ram_ptr==NULL)
10001000   {
1001      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
1002      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
1001      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
1002      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
10031003      value = 0;
10041004   }
10051005   else
10061006   {
1007      boffset = cartridge->ram_page * 0x2000 + offset;     
1007      boffset = cartridge->ram_page * 0x2000 + offset;
10081008      value = ((UINT8 *)cartridge->ram_ptr)[boffset];
1009      //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
1009      //      printf("stdcart/read: %4x = %4x\n", 0x6000 + 2*offset, value);
10101010   }
1011   //    printf("accessed cartridge ram[%02x:%04x] = %04x\n", cartridge->ram_page, 0x6000+offset*2, value);
1011   // printf("accessed cartridge ram[%02x:%04x] = %04x\n", cartridge->ram_page, 0x6000+offset*2, value);
10121012   return value;
10131013}
10141014
10151015/*
1016   SuperSpace RAM write operation. RAM is located at 0x6000 to 0x7fff
1017   as 4 banks of 8 KiB each. This is the TI-99/8 support.
1016    SuperSpace RAM write operation. RAM is located at 0x6000 to 0x7fff
1017    as 4 banks of 8 KiB each. This is the TI-99/8 support.
10181018*/
10191019static WRITE8_DEVICE_HANDLER( write_cart_super8 )
10201020{
10211021   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
10221022   cartridge_t *cartridge = pcb->cartridge;
10231023   offs_t boffset;
1024   
1024
10251025   if (cartridge->ram_ptr==NULL)
10261026   {
10271027      logerror("No cartridge RAM at address %04x", 0x6000 + offset);
1028     
1029      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
1030      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
1028
1029      //      printf("No cartridge ROM in rompage=%d of bank %d\n", rompage, cartslots->active_slot);
1030      //      printf("Cartridge address = %lx\n", (long)pcb->cartridge);
10311031   }
10321032   else
10331033   {
1034      boffset = cartridge->ram_page * 0x2000 + offset;     
1034      boffset = cartridge->ram_page * 0x2000 + offset;
10351035      ((UINT8 *)cartridge->ram_ptr)[boffset] = data;
10361036   }
10371037}
r5931r5932
10401040static int assemble_super(const device_config *image)
10411041{
10421042   cartridge_t *cart;
1043//   printf("assemble_super, %s\n", image->tag);
1044   
1043//  printf("assemble_super, %s\n", image->tag);
1044
10451045   cart = assemble_common(image);
10461046   if (cart->ram_size==0)
10471047   {
r5931r5932
10531053
10541054/*****************************************************************************
10551055  Cartridge type: MBX
1056     GROM: up to 40 KiB
1057   ROM: up to 16 KiB (in up to 2 banks of 8KiB each)
1058   RAM: 1022 B (0x6c00-0x6ffd, overrides ROM in that area)
1059   ROM mapper: 6ffe
1056    GROM: up to 40 KiB
1057    ROM: up to 16 KiB (in up to 2 banks of 8KiB each)
1058    RAM: 1022 B (0x6c00-0x6ffd, overrides ROM in that area)
1059    ROM mapper: 6ffe
10601060******************************************************************************/
10611061
10621062static DEVICE_START(ti99_pcb_mbx)
10631063{
1064//   printf("TI99 pcb mbx start\n");
1064//  printf("TI99 pcb mbx start\n");
10651065   set_pointers(device, get_index_from_tagname(device->owner)-1);
10661066}
10671067
r5931r5932
10711071   UINT16 value = 0;
10721072   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
10731073   cartridge_t *cartridge = pcb->cartridge;
1074   
1074
10751075   if ((offset >= 0x0600) && (offset <= 0x07fe))
10761076   {
10771077      /* This is the RAM area which overrides any ROM. There is no
1078         known banking behavior for the RAM, so we must assume that
1079         there is only one bank. */
1078           known banking behavior for the RAM, so we must assume that
1079           there is only one bank. */
10801080      if (cartridge->ram_ptr != NULL)
10811081         value = ((UINT16 *)cartridge->ram_ptr)[offset - 0x0600];
10821082   }
r5931r5932
10881088   return value;
10891089}
10901090
1091/*
1092   MBX write operation.
1091/*
1092    MBX write operation.
10931093*/
10941094static WRITE16_DEVICE_HANDLER( write_cart_mbx )
10951095{
r5931r5932
10991099
11001100   if ((offset >= 0x0600) && (offset <= 0x07fe))
11011101   {
1102      if (cartridge->ram_ptr == NULL)
1102      if (cartridge->ram_ptr == NULL)
11031103         return;
11041104      pos = ((UINT16 *)cartridge->ram_ptr) + offset - 0x0600;
11051105      COMBINE_DATA(pos);
11061106   }
11071107   else if ((offset == 0x07ff) && ACCESSING_BITS_8_15)
11081108   {
1109      if (cartridge->rom_ptr==NULL)
1109      if (cartridge->rom_ptr==NULL)
11101110         return;
11111111      cartridge->rom_page = ((data >> 8) & 1);
11121112   }
11131113}
11141114
11151115/*
1116   TI-99/8 support
1116    TI-99/8 support
11171117*/
11181118static READ8_DEVICE_HANDLER( read_cart_mbx8 )
11191119{
r5931r5932
11211121   UINT8 value = 0;
11221122   ti99_pcb_t *pcb = (ti99_pcb_t *)device->token;
11231123   cartridge_t *cartridge = pcb->cartridge;
1124   
1124
11251125   if ((offset >= 0x0c00) && (offset <= 0x0ffd))
11261126   {
11271127      /* This is the RAM area which overrides any ROM. There is no
1128         known banking behavior for the RAM, so we must assume that
1129         there is only one bank. */
1128           known banking behavior for the RAM, so we must assume that
1129           there is only one bank. */
11301130      if (cartridge->ram_ptr != NULL)
11311131         value = ((UINT8 *)cartridge->ram_ptr)[offset - 0x0c00];
11321132   }
r5931r5932
11381138   return value;
11391139}
11401140
1141/*
1142   MBX write operation (TI-99/8)
1141/*
1142    MBX write operation (TI-99/8)
11431143*/
11441144static WRITE8_DEVICE_HANDLER( write_cart_mbx8 )
11451145{
r5931r5932
11481148
11491149   if ((offset >= 0x0c00) && (offset <= 0x0ffd))
11501150   {
1151      if (cartridge->ram_ptr == NULL)
1151      if (cartridge->ram_ptr == NULL)
11521152         return;
11531153      ((UINT8 *)cartridge->ram_ptr)[offset - 0x0c00] = data;
11541154   }
11551155   else if (offset == 0x0ffe || offset == 0x0fff)
11561156   {
1157      if (cartridge->rom_ptr==NULL)
1157      if (cartridge->rom_ptr==NULL)
11581158         return;
1159      cartridge->rom_page = (data & 1); /* TODO: Check */
1159      cartridge->rom_page = (data & 1); /* TODO: Check */
11601160   }
11611161}
11621162
r5931r5932
11651165{
11661166   cartridge_t *cart;
11671167
1168//   printf("assemble_mbx, %s\n", image->tag);
1169   cart = assemble_common(image);   
1168//  printf("assemble_mbx, %s\n", image->tag);
1169   cart = assemble_common(image);
11701170   return INIT_PASS;
11711171}
11721172
r5931r5932
12211221         break;
12221222
12231223      case TI99CART_FCT_ASSM:
1224         info->f = (genf *) assemble_std;
1224         info->f = (genf *) assemble_std;
12251225         break;
12261226
12271227      case TI99CART_FCT_DISASSM:
1228         info->f = (genf *) disassemble_std;
1228         info->f = (genf *) disassemble_std;
12291229         break;
1230         
1230
12311231      /* --- the following bits of info are returned as NULL-terminated strings --- */
12321232      case DEVINFO_STR_NAME:
12331233         strcpy(info->s, "TI99 standard cartridge pcb");
r5931r5932
12821282         info->f = (genf *) assemble_paged; break;
12831283
12841284      case TI99CARTINFO_FCT_6000_R:
1285         info->f = (genf *) read_cart_paged;
1285         info->f = (genf *) read_cart_paged;
12861286         break;
12871287
12881288      case TI99CARTINFO_FCT_6000_W:
1289         info->f = (genf *) write_cart_paged;
1289         info->f = (genf *) write_cart_paged;
12901290         break;
12911291
12921292      case TI99CARTINFO_FCT_6000_R8:
1293         info->f = (genf *) read_cart_paged8;
1293         info->f = (genf *) read_cart_paged8;
12941294         break;
12951295
12961296      case TI99CARTINFO_FCT_6000_W8:
1297         info->f = (genf *) write_cart_paged8;
1297         info->f = (genf *) write_cart_paged8;
12981298         break;
12991299
13001300      case DEVINFO_STR_NAME:
r5931r5932
13161316         break;
13171317
13181318      case TI99CART_FCT_ASSM:
1319         info->f = (genf *) assemble_minimem;
1319         info->f = (genf *) assemble_minimem;
13201320         break;
13211321      case TI99CARTINFO_FCT_6000_R:
1322         info->f = (genf *) read_cart_minimem;
1322         info->f = (genf *) read_cart_minimem;
13231323         break;
13241324      case TI99CARTINFO_FCT_6000_W:
1325         info->f = (genf *) write_cart_minimem;
1325         info->f = (genf *) write_cart_minimem;
13261326         break;
13271327      case TI99CARTINFO_FCT_6000_R8:
1328         info->f = (genf *) read_cart_minimem8;
1328         info->f = (genf *) read_cart_minimem8;
13291329         break;
13301330      case TI99CARTINFO_FCT_6000_W8:
1331         info->f = (genf *) write_cart_minimem8;
1331         info->f = (genf *) write_cart_minimem8;
13321332         break;
13331333
13341334      case DEVINFO_STR_NAME:
r5931r5932
13501350         break;
13511351
13521352      case TI99CART_FCT_ASSM:
1353         info->f = (genf *) assemble_super;
1353         info->f = (genf *) assemble_super;
13541354         break;
13551355      case TI99CARTINFO_FCT_6000_R:
1356         info->f = (genf *) read_cart_super;
1356         info->f = (genf *) read_cart_super;
13571357         break;
13581358      case TI99CARTINFO_FCT_6000_W:
1359         info->f = (genf *) write_cart_super;
1359         info->f = (genf *) write_cart_super;
13601360         break;
13611361      case TI99CARTINFO_FCT_6000_R8:
1362         info->f = (genf *) read_cart_super8;
1362         info->f = (genf *) read_cart_super8;
13631363         break;
13641364      case TI99CARTINFO_FCT_6000_W8:
1365         info->f = (genf *) write_cart_super8;
1365         info->f = (genf *) write_cart_super8;
13661366         break;
13671367      case TI99CARTINFO_FCT_CRU_R:
1368         info->f = (genf *) read_cart_cru;
1368         info->f = (genf *) read_cart_cru;
13691369         break;
13701370      case TI99CARTINFO_FCT_CRU_W:
1371         info->f = (genf *) write_cart_cru;
1371         info->f = (genf *) write_cart_cru;
13721372         break;
13731373
13741374      case DEVINFO_STR_NAME:
r5931r5932
13901390         break;
13911391
13921392      case TI99CART_FCT_ASSM:
1393         info->f = (genf *) assemble_mbx;
1393         info->f = (genf *) assemble_mbx;
13941394         break;
13951395      case TI99CARTINFO_FCT_6000_R:
1396         info->f = (genf *) read_cart_mbx;
1396         info->f = (genf *) read_cart_mbx;
13971397         break;
13981398      case TI99CARTINFO_FCT_6000_W:
1399         info->f = (genf *) write_cart_mbx;
1399         info->f = (genf *) write_cart_mbx;
14001400         break;
14011401      case TI99CARTINFO_FCT_6000_R8:
1402         info->f = (genf *) read_cart_mbx8;
1402         info->f = (genf *) read_cart_mbx8;
14031403         break;
14041404      case TI99CARTINFO_FCT_6000_W8:
1405         info->f = (genf *) write_cart_mbx8;
1405         info->f = (genf *) write_cart_mbx8;
14061406         break;
14071407
14081408
r5931r5932
14181418
14191419
14201420/*****************************************************************************
1421  The cartridge handling of the multi-cartridge system.
1421  The cartridge handling of the multi-cartridge system.
14221422  Every cartridge contains a PCB device. The memory handlers delegate the calls
14231423  to the respective handlers of the cartridges.
14241424******************************************************************************/
14251425/*
1426   Initialize a cartridge. Each cartridge contains a PCB device.
1426    Initialize a cartridge. Each cartridge contains a PCB device.
14271427*/
14281428static DEVICE_START( ti99_cartridge )
14291429{
14301430   cartslot_t *cart = device->token;
14311431   astring *tempstring = astring_alloc();
1432   
1432
14331433   /* find the PCB device */
14341434   cart->pcb_device = devtag_get_device(
14351435      device->machine,
r5931r5932
14381438}
14391439
14401440/*
1441   Load the cartridge image files. Apart from reading, we set pointers
1442   to the image files so that during runtime we do not need search
1443   operations.
1441    Load the cartridge image files. Apart from reading, we set pointers
1442    to the image files so that during runtime we do not need search
1443    operations.
14441444*/
14451445static DEVICE_IMAGE_LOAD( ti99_cartridge )
1446{   
1446{
14471447   const device_config *pcbdev = cartslot_get_pcb(image);
14481448   const device_config *cartsys = image->owner;
14491449   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
14501450
14511451   int result;
1452   
1452
14531453   result = load_legacy(image);
1454   
1454
14551455   if (result != INIT_FAIL)
14561456      cartslots->legacy_slots++;
1457   else
1457   else
14581458   {
14591459      if (pcbdev != NULL)
14601460      {
14611461         /* If we are here, we have a multicart. */
14621462         ti99_pcb_t *pcb = (ti99_pcb_t *)pcbdev->token;
14631463         cartslot_t *cart = (cartslot_t *)image->token;
1464         
1464
14651465         /* try opening this as a multicart */
14661466         /* This line requires that cartslot_t be included in cartslot.h,
1467         otherwise one cannot make use of multicart handling within such a
1468         custom LOAD function. */
1467            otherwise one cannot make use of multicart handling within such a
1468            custom LOAD function. */
14691469         multicart_open_error me = multicart_open(image_filename(image), image->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
1470         
1470
14711471         /* Now that we have loaded the image files, let the PCB put them all
1472         together. This means we put the images in a structure which allows
1473         for a quick access by the memory handlers. Every PCB defines an
1474         own assembly method. */
1472            together. This means we put the images in a structure which allows
1473            for a quick access by the memory handlers. Every PCB defines an
1474            own assembly method. */
14751475         if (me == MCERR_NONE)
14761476            result = pcb->assemble(image);
1477         else
1477         else
14781478            fatalerror("Error loading multicart: %s\n", mc_error_text(me));
1479         
1479
14801480         /* This is for legacy support. If we have no multicart left
1481         but there are still legacy dumps, we switch to legacy mode. */
1481            but there are still legacy dumps, we switch to legacy mode. */
14821482         if (result != INIT_FAIL)
14831483            cartslots->multi_slots++;
14841484      }
r5931r5932
14861486      {
14871487         fatalerror("Error loading multicart: no pcb found.\n");
14881488      }
1489   }   
1489   }
14901490   return result;
14911491}
14921492
14931493/*
1494   This is called when the cartridge is unplugged (or the emulator is
1495   stopped).
1494    This is called when the cartridge is unplugged (or the emulator is
1495    stopped).
14961496*/
14971497static DEVICE_IMAGE_UNLOAD( ti99_cartridge )
1498{   
1498{
14991499   const device_config *pcbdev;
15001500   ti99_multicart_t *cartslots = (ti99_multicart_t *)image->owner->token;
15011501
15021502   if (image->token == NULL)
15031503   {
1504      /* This means something went wrong during the pcb
1505         identification (e.g. one of the cartridge files was not
1506         found). We do not need to (and cannot) unload
1507         the cartridge. */
1504      /* This means something went wrong during the pcb
1505           identification (e.g. one of the cartridge files was not
1506           found). We do not need to (and cannot) unload
1507           the cartridge. */
15081508      return;
15091509   }
15101510   pcbdev = cartslot_get_pcb(image);
r5931r5932
15131513   {
15141514      ti99_pcb_t *pcb = (ti99_pcb_t *)pcbdev->token;
15151515      cartslot_t *cart = (cartslot_t *)image->token;
1516     
1517      //   printf("unload\n");
1516
1517      //  printf("unload\n");
15181518      if (cart->mc != NULL)
15191519      {
15201520         /* Remove pointers and de-big-endianize RAM contents. */
1521         pcb->disassemble(image);
1522         
1523         /* Close the multicart; all RAM resources will be
1524            written to disk */
1521         pcb->disassemble(image);
1522
1523         /* Close the multicart; all RAM resources will be
1524               written to disk */
15251525         multicart_close(cart->mc);
15261526         cart->mc = NULL;
1527         
1527
15281528         /* See above: Legacy support. */
15291529         cartslots->multi_slots--;
15301530      }
1531//      else
1532//         fatalerror("Lost pointer to multicart in cartridge. Report bug.\n");
1531//      else
1532//          fatalerror("Lost pointer to multicart in cartridge. Report bug.\n");
15331533   }
15341534   else
15351535   {
r5931r5932
15401540
15411541/*****************************************************************************
15421542  The legacy cartridge slot system.
1543 
1543
15441544  This is the system which was used for the TI family until MESS 0.130.
15451545  Here, plain ROM dumps were mounted on the slots, e.g. the GROM on slot 1,
15461546  ROM on slot 2. No multiple cartridges were supported.
1547 
1548  This functionality is deprecated.
1549 
1547
1548  This functionality is deprecated.
1549
15501550  In order to allow for a smooth transition, this feature is included in this
15511551  version. It is strongly recommmended to create suitable multicart packs.
1552 
1552
15531553  This implementation tolerates both cartridge systems in the following way:
15541554  - If there are only single ROM dumps, the system switched to legacy mode.
15551555  - If there is at least one multicart pack in any slot, the system switches
r5931r5932
15651565   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
15661566
15671567   UINT8 value;
1568   
1568
15691569   /* Get the GROM slot number. */
15701570   slot = cartslots->legacy_slotnumber[SLOTC_GROM];
15711571   if (slot<0)
r5931r5932
15731573      return 0;
15741574
15751575   cartridge = &cartslots->cartridge[slot];
1576   
1576
15771577   if (cartridge->grom_size>0)
15781578   {
1579      /* This is the reason why we need the image size: Read
1580      access beyond the image size must be detected. */
1581      if (cart_offset > cartridge->grom_size)
1579      /* This is the reason why we need the image size: Read
1580        access beyond the image size must be detected. */
1581      if (cart_offset > cartridge->grom_size)
15821582         return 0;
1583     
1583
15841584      value = (UINT8)cartridge->grom_buffer;
15851585      /* read ahead */
15861586      cartridge->grom_buffer = cartridge->grom_ptr[cart_offset];
r5931r5932
15921592      logerror("Empty socket at address G(%d)>%04x\n", slot, 0x6000 + cart_offset);
15931593   }
15941594
1595   //   printf("grom access(port = %x, address = %04x) = %02x\n", slot,  0x6000 + cart_offset*2, value);
1595   //  printf("grom access(port = %x, address = %04x) = %02x\n", slot,  0x6000 + cart_offset*2, value);
15961596   return value;
15971597}
15981598
15991599static READ16_DEVICE_HANDLER( ti99_cart_r_legacy )
16001600{
1601/*   if (hsgpl_crdena)
1602      return ti99_hsgpl_rom6_r(space, offset, mem_mask);
1601/*  if (hsgpl_crdena)
1602        return ti99_hsgpl_rom6_r(space, offset, mem_mask);
16031603*/
16041604   int slotmbx, slotmini, slotebr2, slotrom;
16051605   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
r5931r5932
16111611      /* We are in the RAM area of MBX cartridges. */
16121612      return ((UINT16 *)(cartslots->cartridge[slotmbx].ram_ptr))[offset-0x0600];
16131613   }
1614     
1614
16151615   slotmini = cartslots->legacy_slotnumber[SLOTC_MINIMEM];
16161616   if ((slotmini != -1) && (offset >= 0x0800) && (offset <= 0x0fff))
16171617   {
r5931r5932
16231623   slotrom = cartslots->legacy_slotnumber[SLOTC_CROM];
16241624   if (slotrom < 0)
16251625      return 0;
1626   
1626
16271627   slotebr2 = cartslots->legacy_slotnumber[SLOTC_DROM];
16281628   if (slotebr2 < 0)
16291629      return (((UINT16 *)cartslots->cartridge[slotrom].rom_ptr)[offset]);
r5931r5932
16401640
16411641static WRITE16_DEVICE_HANDLER( ti99_cart_w_legacy )
16421642{
1643   
1644/*   if (hsgpl_crdena)
1645      ti99_hsgpl_rom6_w(space, offset, data, mem_mask);
1646      return;
1647      */
1643
1644/*  if (hsgpl_crdena)
1645        ti99_hsgpl_rom6_w(space, offset, data, mem_mask);
1646        return;
1647        */
16481648   int slotmbx, slotmini, slotebr2, slotrom;
16491649   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
16501650
r5931r5932
16521652   slotrom = cartslots->legacy_slotnumber[SLOTC_CROM];
16531653   slotebr2 = cartslots->legacy_slotnumber[SLOTC_DROM];
16541654   slotmini = cartslots->legacy_slotnumber[SLOTC_MINIMEM];
1655   
1655
16561656   if (slotmbx != -1)
16571657   {
16581658      if ((offset >= 0x0600) && (offset <= 0x07fe))
r5931r5932
16611661         /* RAM in 0x6c00-0x6ffd (presumably non-paged) */
16621662         /* mapper at 0x6ffe */
16631663         COMBINE_DATA(((UINT16 *)cartslots->cartridge[slotmbx].ram_ptr) + offset - 0x0600);
1664      }         
1664      }
16651665      else
16661666      {
16671667         if ((offset == 0x07ff) && ACCESSING_BITS_8_15)
r5931r5932
16881688}
16891689
16901690/*
1691   TI-99/8 support.
1691    TI-99/8 support.
16921692*/
16931693static READ8_DEVICE_HANDLER( ti99_cart_r_legacy8 )
16941694{
1695/*   if (hsgpl_crdena)
1696      return ti99_hsgpl_rom6_r(space, offset, mem_mask);
1695/*  if (hsgpl_crdena)
1696        return ti99_hsgpl_rom6_r(space, offset, mem_mask);
16971697*/
16981698   int slotmbx, slotmini, slotebr2, slotrom;
16991699   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
r5931r5932
17051705      /* We are in the RAM area of MBX cartridges. */
17061706      return ((UINT8 *)(cartslots->cartridge[slotmbx].ram_ptr))[offset-0x0c00];
17071707   }
1708     
1708
17091709   slotmini = cartslots->legacy_slotnumber[SLOTC_MINIMEM];
17101710   if ((slotmini != -1) && (offset >= 0x1000) && (offset <= 0x1fff))
17111711   {
r5931r5932
17171717   slotrom = cartslots->legacy_slotnumber[SLOTC_CROM];
17181718   if (slotrom < 0)
17191719      return 0;
1720   
1720
17211721   slotebr2 = cartslots->legacy_slotnumber[SLOTC_DROM];
17221722   if (slotebr2 < 0)
17231723      return (((UINT8 *)cartslots->cartridge[slotrom].rom_ptr)[offset]);
r5931r5932
17331733}
17341734
17351735/*
1736   TI-99/8 support.
1736    TI-99/8 support.
17371737*/
17381738static WRITE8_DEVICE_HANDLER( ti99_cart_w_legacy8 )
17391739{
1740   
1741/*   if (hsgpl_crdena)
1742      ti99_hsgpl_rom6_w(space, offset, data, mem_mask);
1743      return;
1744      */
1740
1741/*  if (hsgpl_crdena)
1742        ti99_hsgpl_rom6_w(space, offset, data, mem_mask);
1743        return;
1744        */
17451745   int slotmbx, slotmini, slotebr2, slotrom;
17461746   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
17471747
r5931r5932
17491749   slotrom = cartslots->legacy_slotnumber[SLOTC_CROM];
17501750   slotebr2 = cartslots->legacy_slotnumber[SLOTC_DROM];
17511751   slotmini = cartslots->legacy_slotnumber[SLOTC_MINIMEM];
1752   
1752
17531753   if (slotmbx != -1)
17541754   {
17551755      if ((offset >= 0x0c00) && (offset <= 0x0ffd))
r5931r5932
17911791   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
17921792
17931793   /* Some comments originally in machine/ti99_4x.c */
1794     
1794
17951795   /* We identify file types according to their extension */
17961796   /* Note that if we do not recognize the extension, we revert to the slot location <-> type
1797   scheme. */
1798   int id = 0;   
1797    scheme. */
1798   int id = 0;
17991799   int i;
18001800   int filesize;
18011801   int maxrom = 0x2000;
18021802   slotc_type_t type;
18031803   int savembx;
1804   
1804
18051805   const char *ch, *ch2;
18061806   const char *name = image_filename(image);
18071807
r5931r5932
18131813
18141814   UINT16 *cartmbx;
18151815   UINT8 *cartmbx8;
1816   
1816
18171817   type = SLOTC_EMPTY;
1818   
1818
18191819   /* There is a circuitry in TI99/4(a) that resets the console when a
1820   cartridge is inserted or removed.  We emulate this instead of resetting the
1821   emulator (which is the default in MESS). */
1820    cartridge is inserted or removed.  We emulate this instead of resetting the
1821    emulator (which is the default in MESS). */
18221822   /*cpu_set_input_line(machine->firstcpu, INPUT_LINE_RESET, PULSE_LINE);
1823   tms9901_reset(0);
1824   if (! has_evpc)
1825      TMS9928A_reset();
1826   if (has_evpc)
1827      v9938_reset(0);*/
1823    tms9901_reset(0);
1824    if (! has_evpc)
1825        TMS9928A_reset();
1826    if (has_evpc)
1827        v9938_reset(0);*/
18281828
18291829   ch = strrchr(name, '.');
18301830   ch2 = (ch-1 >= name) ? ch-1 : "";
r5931r5932
18641864   }
18651865
18661866   id = get_index_from_tagname(image)-1;
1867   
1867
18681868   /* Remember where the cartridge part is plugged in. */
18691869   cartslots->legacy_slotnumber[type] = id;
1870   
1870
18711871   savembx = FALSE;
1872   
1872
18731873   /* We will use the already allocated buffers in the memory regions,
1874      and the pointers in the cartridge structure will point to them. */
1874       and the pointers in the cartridge structure will point to them. */
18751875   switch (type)
18761876   {
18771877      case SLOTC_EMPTY:
r5931r5932
18891889         if (cartslots->legacy_slotnumber[SLOTC_MINIMEM] != -1)
18901890         {
18911891            /* This means the NVRAM has already been loaded. So we just
1892            load 4K of ROM to avoid overwriting the NVRAM. */
1892                load 4K of ROM to avoid overwriting the NVRAM. */
18931893            maxrom = 0x1000;
18941894         }
18951895
18961896         if (cartslots->legacy_slotnumber[SLOTC_MBX] != -1)
18971897         {
18981898            /* This means the NVRAM has already been loaded.
1899            We need to temporarily save the RAM contents and
1900            write them back because the RAM overrides the
1901            ROM in an intermediate area. */
1899                We need to temporarily save the RAM contents and
1900                write them back because the RAM overrides the
1901                ROM in an intermediate area. */
19021902            savembx = TRUE;
19031903         }
19041904
r5931r5932
19341934            for (i = 0; i < maxrom/2; i++)
19351935               ((UINT16 *)cartrom)[i] = BIG_ENDIANIZE_INT16(((UINT16 *)cartrom)[i]);
19361936            cartslots->cartridge[id].rom_ptr = cartrom;
1937            cartslots->cartridge[id].rom_size = filesize;
1937            cartslots->cartridge[id].rom_size = filesize;
19381938         }
19391939         // printf("loaded ROM, size = %d\n", filesize);
19401940         break;
1941         
1941
19421942      case SLOTC_MINIMEM:
19431943         /* Load the NVRAM. Need to BIG_ENDIANIZE it.
1944         MiniMemory has only one cartridge page. */
1944            MiniMemory has only one cartridge page. */
19451945         if (is_99_8())
19461946         {
19471947            // printf("** is 99/8\n");
r5931r5932
19491949            cartslots->cartridge[id].ram_ptr = cart8rom +  0x1000;
19501950         }
19511951         else
1952         {           
1952         {
19531953            image_battery_load(image, cartrom+0x800,0x1000);
19541954            for (i = 0x800; i < 0x1000; i++)
19551955               cartrom[i] = BIG_ENDIANIZE_INT16(cartrom[i]);
19561956            cartslots->cartridge[id].ram_ptr = (UINT16 *)cartrom +  0x800;
19571957         }
1958         cartslots->cartridge[id].ram_size = 0x1000;
1958         cartslots->cartridge[id].ram_size = 0x1000;
19591959         // printf("loaded NVRAM\n");
19601960         break;
19611961
r5931r5932
19741974               cartrom[i] = BIG_ENDIANIZE_INT16(cartrom[i]);
19751975            cartslots->cartridge[id].ram_ptr = (UINT16 *)cartrom +  0x600;
19761976         }
1977         cartslots->cartridge[id].ram_size = 0x0400;
1977         cartslots->cartridge[id].ram_size = 0x0400;
19781978         // printf("loaded NVRAM\n");
19791979         break;
19801980
r5931r5932
19931993               cartrom2[i] = BIG_ENDIANIZE_INT16(cartrom2[i]);
19941994            cartslots->cartridge[id].rom2_ptr = cartrom2;
19951995         }
1996         cartslots->cartridge[id].rom_size = filesize;
1996         cartslots->cartridge[id].rom_size = filesize;
19971997         // printf("loaded second ROM, size = %d\n", filesize);
19981998         break;
19991999   }
r5931r5932
20072007
20082008   ti99_multicart_t *cartslots = (ti99_multicart_t *)cartsys->token;
20092009
2010   slotc_type_t type = SLOTC_EMPTY;
2010   slotc_type_t type = SLOTC_EMPTY;
20112011   int slot = get_index_from_tagname(image)-1;
2012   
2012
20132013   // printf("non-rpk unload\n");
2014   
2014
20152015   for (i=0; (i < 5) && (type==SLOTC_EMPTY); i++)
20162016   {
20172017      if (cartslots->legacy_slotnumber[i]==slot)
r5931r5932
20292029      case SLOTC_GROM:
20302030         memset(cartslots->cartridge[slot].grom_ptr, 0, 0xA000);
20312031         break;
2032         
2032
20332033      case SLOTC_MINIMEM:
2034         if (is_99_8())
2034         if (is_99_8())
20352035         {
20362036            // printf("** is 99/8\n");
2037            image_battery_save(image, cartslots->cartridge[slot].ram_ptr, 0x1000);
2037            image_battery_save(image, cartslots->cartridge[slot].ram_ptr, 0x1000);
20382038            memset(cartslots->cartridge[slot].ram_ptr, 0, 0x1000);
20392039         }
2040         else
2040         else
20412041         {
20422042            /* We BIG_ENDIANIZE before saving. This is consistent
2043            with the cartridge save format. */
2043                with the cartridge save format. */
20442044            UINT16 *ramcont = (UINT16 *)cartslots->cartridge[slot].ram_ptr;
20452045            for (i = 0; i < 0x0800; i++)
20462046               ramcont[i] = BIG_ENDIANIZE_INT16(ramcont[i]);
r5931r5932
20492049         }
20502050         break;
20512051      case SLOTC_MBX:
2052         if (is_99_8())
2052         if (is_99_8())
20532053         {
20542054            // printf("** is 99/8\n");
2055            image_battery_save(image, cartslots->cartridge[slot].ram_ptr, 0x0400);
2056            memset(cartslots->cartridge[slot].ram_ptr, 0, 0x0400);           
2055            image_battery_save(image, cartslots->cartridge[slot].ram_ptr, 0x0400);
2056            memset(cartslots->cartridge[slot].ram_ptr, 0, 0x0400);
20572057         }
2058         else
2058         else
20592059         {
20602060            /* We BIG_ENDIANIZE before saving. This is consistent
2061            with the cartridge save format. */
2061                with the cartridge save format. */
20622062            UINT16 *ramcont = (UINT16 *)cartslots->cartridge[slot].ram_ptr;
20632063            for (i = 0; i < 0x0200; i++)
20642064               ramcont[i] = BIG_ENDIANIZE_INT16(ramcont[i]);
20652065            image_battery_save(image, ramcont, 0x0400);
20662066            memset(ramcont, 0, 0x0400);
2067         }         
2067         }
20682068         break;
20692069      case SLOTC_CROM:
20702070         if (cartslots->legacy_slotnumber[SLOTC_MINIMEM]!=-1)
r5931r5932
20732073         else
20742074            memset(cartslots->cartridge[slot].rom_ptr, 0, 0x2000);
20752075         break;
2076         
2076
20772077      case SLOTC_DROM:
20782078         cartslots->cartridge[slot].rom_page = 0;
20792079         memset(cartslots->cartridge[slot].rom2_ptr, 0, 0x2000);
r5931r5932
20842084}
20852085
20862086/*****************************************************************************
2087  The overall multi-cartridge slot system. It contains instances of
2087  The overall multi-cartridge slot system. It contains instances of
20882088  cartridges which contain PCB devices. The memory handlers delegate the calls
20892089  to the respective handlers of the cartridges.
2090 
2090
20912091  Note that the term "multi-cartridge system" and "multicart" are not the same:
20922092  A "multicart" may contain multiple resources, organized on a PCB. The multi-
20932093  cart system may thus host multiple multicarts.
2094 
2094
20952095  Actually, the name of the device should be changed (however, the device name
20962096  length is limited)
20972097******************************************************************************/
20982098/*
2099   Instantiation of a multicart system for the TI family.
2099    Instantiation of a multicart system for the TI family.
21002100*/
21012101static DEVICE_START(ti99_multicart)
21022102{
21032103   int i;
2104//   printf("DEVICE_START(ti99_multicart)\n");
2104//  printf("DEVICE_START(ti99_multicart)\n");
21052105   ti99_multicart_t *cartslots = (ti99_multicart_t *)device->token;
21062106
21072107   /* Save this in the shortcut; we don't want to look for it each time
2108      that we have a memory access. And currently we do not plan for
2109      multiple multicart instances. */
2108       that we have a memory access. And currently we do not plan for
2109       multiple multicart instances. */
21102110   cartslots->active_slot = 0;
21112111   cartslots->next_free_slot = 0;
2112   
2112
21132113   for (i=0; i < NUMBER_OF_CARTRIDGE_SLOTS; i++)
21142114   {
21152115      cartslots->cartridge[i].pcb = NULL;
21162116      clear_slot(device, i);
21172117   }
2118   
2118
21192119   /* Initialize the legacy system. */
21202120   cartslots->legacy_slotnumber[SLOTC_GROM] = -1;
21212121   cartslots->legacy_slotnumber[SLOTC_CROM] = -1;
21222122   cartslots->legacy_slotnumber[SLOTC_DROM] = -1;
21232123   cartslots->legacy_slotnumber[SLOTC_MINIMEM] = -1;
21242124   cartslots->legacy_slotnumber[SLOTC_MBX] = -1;
2125   
2125
21262126   cartslots->legacy_slots = 0;
21272127   cartslots->multi_slots = 0;
2128   
2129   /* The cartslot system is initialized now. The cartridges themselves
2130      need to check whether their parts are available. */
2128
2129   /* The cartslot system is initialized now. The cartridges themselves
2130       need to check whether their parts are available. */
21312131}
2132   
2132
21332133static DEVICE_STOP(ti99_multicart)
21342134{
2135//   printf("DEVICE_STOP(ti99_multicart)\n");
2135//  printf("DEVICE_STOP(ti99_multicart)\n");
21362136}
21372137/*
2138   Accesses the ROM regions of the cartridge for reading.
2139   This is the area from 0x6000 to 0x7fff. Each cartridge is reponsible
2140   for all kinds of magic which is done inside this area, like swapping
2141   banks or doing other control actions. These activities beyond simple
2142   reading are cartridge-specific. Each kind of cartridge requires a
2143   new type.
2144   The currently set GROM bank determines which cartridge is actually
2145   accessed, also for ROM reads.
2138    Accesses the ROM regions of the cartridge for reading.
2139    This is the area from 0x6000 to 0x7fff. Each cartridge is reponsible
2140    for all kinds of magic which is done inside this area, like swapping
2141    banks or doing other control actions. These activities beyond simple
2142    reading are cartridge-specific. Each kind of cartridge requires a
2143    new type.
2144    The currently set GROM bank determines which cartridge is actually
2145    accessed, also for ROM reads.
21462146*/
21472147READ16_DEVICE_HANDLER( ti99_multicart_r )
21482148{
21492149   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
2150   int slot = cartslots->active_slot;
2150   int slot = cartslots->active_slot;
21512151   cartridge_t *cart;
2152     
2152
21532153   /* Sanity check. Higher slots are always empty. */
2154   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2154   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
21552155      return 0;
2156     
2156
21572157   /* Same as above (GROM read): If there is only one cartridge there
2158      is no use of trying other banks. There is one issue with the
2159      selection mechanism: When the console probes the GROM banks and
2160      we have a ROM-only cartridge plugged in, it checks bank 0 and bank 1,
2161      finds no GROM, and then fails to dummy-check bank 0 again which would
2162      have set our cartridge expander to slot 0. But in slot 1 there is no
2163      ROM cartridge, so nothing shows up in the selection list. We work
2164      around this with the following line. */
2158       is no use of trying other banks. There is one issue with the
2159       selection mechanism: When the console probes the GROM banks and
2160       we have a ROM-only cartridge plugged in, it checks bank 0 and bank 1,
2161       finds no GROM, and then fails to dummy-check bank 0 again which would
2162       have set our cartridge expander to slot 0. But in slot 1 there is no
2163       ROM cartridge, so nothing shows up in the selection list. We work
2164       around this with the following line. */
21652165   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
21662166      slot=0;
21672167
r5931r5932
21732173   // Alternatively:
21742174   // cpu_spinuntil_time(device->machine->firstcpu, ATTOTIME_IN_USEC(6));
21752175
2176//   printf("rpk = %d, bin = %d\n", cartslots->multi_slots,cartslots->legacy_slots);
2176//  printf("rpk = %d, bin = %d\n", cartslots->multi_slots,cartslots->legacy_slots);
21772177
21782178   /* Handle legacy mode. */
21792179   if (in_legacy_mode(device))
21802180   {
21812181      return ti99_cart_r_legacy(device, offset, mem_mask);
2182   }   
2183   
2182   }
2183
21842184   if (!slot_is_empty(device, slot))
21852185   {
2186//      printf("accessing cartridge in slot %d\n", slot);
2186//      printf("accessing cartridge in slot %d\n", slot);
21872187      ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token;
2188//      printf("address=%lx, offset=%lx\n", pcbdef, offset);
2188//      printf("address=%lx, offset=%lx\n", pcbdef, offset);
21892189      return (*pcbdef->read)(cart->pcb, offset, mem_mask);
21902190   }
2191   else
2191   else
21922192   {
2193//      printf("No cartridge in slot %d\n", slot);
2193//      printf("No cartridge in slot %d\n", slot);
21942194      return 0;
21952195   }
21962196}
21972197
21982198/*
2199   Accesses the ROM regions of the cartridge for writing.
2200   This is the area from 0x6000 to 0x7fff. Each cartridge is reponsible
2201   for all kinds of magic which is done inside this area. Specifically,
2202   writing is often used to swap banks for subsequent reads. The actual
2203   effect of writing (beyond setting values in a RAM chip) are
2204   cartridge-specific and must be handled within the cartridge pcb.
2205   The currently set GROM bank determines which cartridge is actually
2206   accessed, also for ROM reads.
2199    Accesses the ROM regions of the cartridge for writing.
2200    This is the area from 0x6000 to 0x7fff. Each cartridge is reponsible
2201    for all kinds of magic which is done inside this area. Specifically,
2202    writing is often used to swap banks for subsequent reads. The actual
2203    effect of writing (beyond setting values in a RAM chip) are
2204    cartridge-specific and must be handled within the cartridge pcb.
2205    The currently set GROM bank determines which cartridge is actually
2206    accessed, also for ROM reads.
22072207*/
22082208WRITE16_DEVICE_HANDLER( ti99_multicart_w )
22092209{
22102210   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
22112211   int slot = cartslots->active_slot;
22122212   cartridge_t *cart;
2213     
2213
22142214   /* Sanity check. Higher slots are always empty. */
2215   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2215   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
22162216      return;
2217     
2217
22182218   /* Same as above (READ16). */
22192219   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
22202220      slot=0;
22212221
22222222   cart = &cartslots->cartridge[slot];
2223   
2223
22242224   /* Idle the CPU */
22252225        cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4);
2226//   cpu_spinuntil_time(device->machine->firstcpu, ATTOTIME_IN_USEC(6));
2226//  cpu_spinuntil_time(device->machine->firstcpu, ATTOTIME_IN_USEC(6));
22272227
22282228   /* Handle legacy mode. */
22292229   if (in_legacy_mode(device))
22302230   {
22312231      ti99_cart_w_legacy(device, offset, data, mem_mask);
2232   }   
2233   else
2232   }
2233   else
22342234   {
22352235      if (!slot_is_empty(device, slot))
22362236      {
2237//         printf("writing to cartridge in slot %d\n", slot);
2237//          printf("writing to cartridge in slot %d\n", slot);
22382238         ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token;
22392239         (*pcbdef->write)(cart->pcb, offset, data, mem_mask);
22402240      }
r5931r5932
22502250{
22512251   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
22522252   cartridge_t *cart;
2253   
2253
22542254   int slot = cartslots->active_slot;
2255     
2255
22562256   /* Sanity check. Higher slots are always empty. */
2257   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2257   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
22582258      return 0;
2259     
2259
22602260   /* Same as above (READ16). */
22612261   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
22622262      slot=0;
22632263
22642264   cart = &cartslots->cartridge[slot];
2265   
2265
22662266   if (!slot_is_empty(device, slot))
22672267   {
22682268      ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token;
r5931r5932
22702270         return (*pcbdef->cruread)(cart->pcb, offset);
22712271   }
22722272   return 0;
2273}   
2274   
2273}
2274
22752275/*
22762276        Write cartridge mapper CRU interface (SuperSpace)
22772277*/
r5931r5932
22792279{
22802280   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
22812281   cartridge_t *cart;
2282   
2282
22832283   int slot = cartslots->active_slot;
2284     
2284
22852285   /* Sanity check. Higher slots are always empty. */
2286   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2286   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
22872287      return;
2288     
2288
22892289   /* Same as above (READ16). */
22902290   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
22912291      slot=0;
r5931r5932
23012301}
23022302
23032303/*
2304   TI-99/8 support. We have only 8 bit memory access, so we adapt all
2305   functions to this width.
2304    TI-99/8 support. We have only 8 bit memory access, so we adapt all
2305    functions to this width.
23062306*/
23072307READ8_DEVICE_HANDLER(ti99_multicart8_r)
23082308{
23092309   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
23102310   cartridge_t *cart;
2311   
2311
23122312   int slot = cartslots->active_slot;
2313     
2313
23142314   /* Sanity check. Higher slots are always empty. */
2315   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2315   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
23162316      return 0;
2317     
2317
23182318   /* Same as above (READ16). */
23192319   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
23202320      slot=0;
r5931r5932
23282328   if (in_legacy_mode(device))
23292329   {
23302330      return ti99_cart_r_legacy8(device, offset);
2331   }   
2332   
2331   }
2332
23332333   if (!slot_is_empty(device, slot))
23342334   {
2335//      printf("accessing cartridge in slot %d\n", slot);
2335//      printf("accessing cartridge in slot %d\n", slot);
23362336      ti99_pcb_t *pcbdef = (ti99_pcb_t *)cart->pcb->token;
23372337      return (*pcbdef->read8)(cart->pcb, offset);
23382338   }
2339   else
2339   else
23402340   {
2341//      printf("No cartridge in slot %d\n", slot);
2341//      printf("No cartridge in slot %d\n", slot);
23422342      return 0;
23432343   }
23442344}
r5931r5932
23472347{
23482348   ti99_multicart_t *cartslots = (ti99_multicart_t *) device->token;
23492349   cartridge_t *cart;
2350   
2350
23512351   int slot = cartslots->active_slot;
2352     
2352
23532353   /* Sanity check. Higher slots are always empty. */
2354   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
2354   if (slot >= NUMBER_OF_CARTRIDGE_SLOTS)
23552355      return;
2356     
2356
23572357   /* Same as above (READ16). */
23582358   if (cartslots->fixed_slot==AUTO && cartslots->next_free_slot==1)
23592359      slot=0;
r5931r5932
23622362
23632363   /* Idle the CPU. TODO: Check whether this is correct for this machine. */
23642364        cpu_adjust_icount(cputag_get_cpu(device->machine, "maincpu"),-4);
2365   
2365
23662366   /* Handle legacy mode. */
23672367   if (in_legacy_mode(device))
23682368   {
23692369      ti99_cart_w_legacy8(device, offset, data);
2370   }   
2371   else
2370   }
2371   else
23722372   {
23732373      if (!slot_is_empty(device, slot))
23742374      {
r5931r5932
23872387   MDRV_CARTSLOT_PCBTYPE(3, "minimem", TI99_CARTRIDGE_PCB_MINIMEM)
23882388   MDRV_CARTSLOT_PCBTYPE(4, "super", TI99_CARTRIDGE_PCB_SUPER)
23892389   MDRV_CARTSLOT_PCBTYPE(5, "mbx", TI99_CARTRIDGE_PCB_MBX)
2390   
2390
23912391   MDRV_CARTSLOT_START(ti99_cartridge)
23922392   MDRV_CARTSLOT_LOAD(ti99_cartridge)
23932393   MDRV_CARTSLOT_UNLOAD(ti99_cartridge)
2394   
2394
23952395   MDRV_CARTSLOT_ADD("cartridge2")
23962396   MDRV_CARTSLOT_EXTENSION_LIST("rpk,bin")
23972397   MDRV_CARTSLOT_PCBTYPE(0, "none", TI99_CARTRIDGE_PCB_NONE)
r5931r5932
24522452      case DEVINFO_INT_CLASS:
24532453         info->i = DEVICE_CLASS_PERIPHERAL;
24542454         break;
2455         
2455
24562456      case DEVINFO_STR_FAMILY:
24572457         strcpy(info->s, "Multi-cartridge system");
24582458         break;
src/mess/devices/z80bin.c
r5931r5932
11/*********************************************************************
22
3   z80bin.c
3    z80bin.c
44
5   A binary quickload format used by the Microbee, the Exidy Sorcerer
6   VZ200/300 and the Super 80
5    A binary quickload format used by the Microbee, the Exidy Sorcerer
6    VZ200/300 and the Super 80
77
88*********************************************************************/
99
r5931r5932
2323
2424/*-------------------------------------------------
2525    z80bin_load_file - load a z80bin file into
26   memory
26    memory
2727-------------------------------------------------*/
2828
2929static int z80bin_load_file(const device_config *image, const char *file_type, UINT16 *exec_addr, UINT16 *start_addr, UINT16 *end_addr )
r5931r5932
122122      else
123123      {
124124         if (autorun)
125            cpu_set_reg(cputag_get_cpu(image->machine, "maincpu"), REG_GENPC, exec_addr);   
125            cpu_set_reg(cputag_get_cpu(image->machine, "maincpu"), REG_GENPC, exec_addr);
126126      }
127127   }
128128
src/mess/devices/cassette.c
r5931r5932
11/*********************************************************************
22
3   cassette.c
3    cassette.c
44
5   MESS interface to the cassette image abstraction code
5    MESS interface to the cassette image abstraction code
66
77*********************************************************************/
88
r5931r5932
5656
5757
5858/*********************************************************************
59   cassette IO
59    cassette IO
6060*********************************************************************/
6161
6262INLINE int cassette_is_motor_on(const device_config *device)
r5931r5932
227227
228228
229229/*********************************************************************
230   cassette device init/load/unload/specify
230    cassette device init/load/unload/specify
231231*********************************************************************/
232232
233233static DEVICE_START( cassette )
r5931r5932
317317
318318
319319/*
320   display a small tape icon, with the current position in the tape image
320    display a small tape icon, with the current position in the tape image
321321*/
322322static void device_display_cassette(const device_config *image)
323323{
src/mess/devices/flopdrv.c
r5931r5932
3333struct _floppy_drive
3434{
3535   const floppy_config   *config;
36   
36
3737   /* flags */
3838   int flags;
3939   /* maximum track allowed */
r5931r5932
247247
248248/* this is called on device init */
249249void floppy_drive_init(const device_config *img)
250{   
250{
251251   floppy_drive *pDrive = get_safe_token( img );
252252
253253   /* initialise flags */
r5931r5932
268268   pDrive->rpm = 300;
269269
270270   pDrive->controller = NULL;
271   
271
272272   pDrive->custom_data = NULL;
273   
273
274274   pDrive->floppy_drive_type = FLOPPY_TYPE_REGULAR;
275275}
276276
r5931r5932
770770      case 0 : return devtag_get_device(machine,FLOPPY_0);
771771      case 1 : return devtag_get_device(machine,FLOPPY_1);
772772      case 2 : return devtag_get_device(machine,FLOPPY_2);
773      case 3 : return devtag_get_device(machine,FLOPPY_3);     
773      case 3 : return devtag_get_device(machine,FLOPPY_3);
774774   }
775775   return NULL;
776776}
r5931r5932
799799         }
800800         cnt++;
801801      }
802   }   
802   }
803803   return NULL;
804804}
805805
r5931r5932
822822         if (image==disk) {
823823            return drive;
824824         }
825         drive++;         
825         drive++;
826826      }
827   }     
827   }
828828   return drive;
829829}
830830
r5931r5932
834834   if (devtag_get_device(machine,FLOPPY_0)) cnt++;
835835    if (devtag_get_device(machine,FLOPPY_1)) cnt++;
836836    if (devtag_get_device(machine,FLOPPY_2)) cnt++;
837    if (devtag_get_device(machine,FLOPPY_3)) cnt++;   
837    if (devtag_get_device(machine,FLOPPY_3)) cnt++;
838838   return cnt;
839839}
840840
r5931r5932
863863      case DEVINFO_INT_IMAGE_TYPE:            info->i = IO_FLOPPY; break;
864864      case DEVINFO_INT_IMAGE_READABLE:         info->i = 1; break;
865865      case DEVINFO_INT_IMAGE_WRITEABLE:         info->i = 1; break;
866      case DEVINFO_INT_IMAGE_CREATABLE:   {     
866      case DEVINFO_INT_IMAGE_CREATABLE:   {
867867                                    int cnt = 0;
868868                                    if ( device && device->static_config )
869869                                    {
r5931r5932
871871                                       int   i;
872872                                       for ( i = 0; floppy_options[i].construct; i++ ) {
873873                                          if(floppy_options[i].param_guidelines) cnt++;
874                                       }                                       
875                                    }
874                                       }
875                                    }
876876                                    info->i = (cnt>0) ? 1 : 0;
877877                                 }
878878                                 break;
r5931r5932
884884      case DEVINFO_PTR_IMAGE_CREATE_OPTGUIDE:      info->p = (void *)floppy_option_guide; break;
885885      case DEVINFO_INT_IMAGE_CREATE_OPTCOUNT:      {
886886         const struct FloppyFormat *floppy_options = ((floppy_config*)device->static_config)->formats;
887         int count;         
887         int count;
888888         for (count = 0; floppy_options[count].construct; count++)
889889            ;
890890         info->i = count;
r5931r5932
895895      case DEVINFO_STR_NAME:                  strcpy(info->s, "Floppy Disk"); break;
896896      case DEVINFO_STR_FAMILY:               strcpy(info->s, "Floppy Disk"); break;
897897      case DEVINFO_STR_SOURCE_FILE:            strcpy(info->s, __FILE__); break;
898      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:         
898      case DEVINFO_STR_IMAGE_FILE_EXTENSIONS:
899899         if ( device && device->static_config )
900900         {
901901            const struct FloppyFormat *floppy_options = ((floppy_config*)device->static_config)->formats;
r5931r5932
906906               specify_extension( info->s, 256, floppy_options[i].extensions );
907907         }
908908         break;
909      default:
910         {     
909      default:
910         {
911911            if ( device && device->static_config )
912912            {
913913               const struct FloppyFormat *floppy_options = ((floppy_config*)device->static_config)->formats;
914914               if ((state >= DEVINFO_PTR_IMAGE_CREATE_OPTSPEC) && (state < DEVINFO_PTR_IMAGE_CREATE_OPTSPEC + DEVINFO_CREATE_OPTMAX)) {
915                  info->p = (void *) floppy_options[state - DEVINFO_PTR_IMAGE_CREATE_OPTSPEC].param_guidelines;         
915                  info->p = (void *) floppy_options[state - DEVINFO_PTR_IMAGE_CREATE_OPTSPEC].param_guidelines;
916916               } else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTNAME) && (state < DEVINFO_STR_IMAGE_CREATE_OPTNAME + DEVINFO_CREATE_OPTMAX)) {
917917                  safe_strcpy(info->s,floppy_options[state - DEVINFO_STR_IMAGE_CREATE_OPTNAME].name);
918               }
918               }
919919               else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTDESC) && (state < DEVINFO_STR_IMAGE_CREATE_OPTDESC + DEVINFO_CREATE_OPTMAX)) {
920920                  safe_strcpy(info->s,floppy_options[state - DEVINFO_STR_IMAGE_CREATE_OPTDESC].description);
921               }
921               }
922922               else if ((state >= DEVINFO_STR_IMAGE_CREATE_OPTEXTS) && (state < DEVINFO_STR_IMAGE_CREATE_OPTEXTS + DEVINFO_CREATE_OPTMAX)) {
923923                  safe_strcpy(info->s,floppy_options[state - DEVINFO_STR_IMAGE_CREATE_OPTEXTS].extensions);
924924               }
925925            }
926926         }
927         
928         break;                 
927
928         break;
929929   }
930930}
src/mess/devices/sonydriv.c
r5931r5932
11/*********************************************************************
22
3   sonydriv.c
3    sonydriv.c
44
5   Apple/Sony 3.5" floppy drive emulation (to be interfaced with iwm.c)
5    Apple/Sony 3.5" floppy drive emulation (to be interfaced with iwm.c)
66
7   Nate Woods, Raphael Nabet
7    Nate Woods, Raphael Nabet
88
9   This floppy drive was present in all variants of Lisa 2 (including Mac XL),
10   and in all Macintosh in production before 1988, when SIWM and superdrive
11   were introduced.
9    This floppy drive was present in all variants of Lisa 2 (including Mac XL),
10    and in all Macintosh in production before 1988, when SIWM and superdrive
11    were introduced.
1212
13   There were two variants :
14   - A single-sided 400k unit which was used on Lisa 2/Mac XL, and Macintosh
15     128k/512k.  This unit needs the computer to send the proper pulses to
16     control the drive motor rotation.  It can be connected to all early
17     Macintosh (but not Mac Classic?) as an external unit.
18   - A double-sided 800k unit which was used on Macintosh Plus, 512ke, and
19     early SE and II*.  This unit generates its own drive motor rotation
20     control signals.  It can be connected to earlier (and later) Macintosh as
21     an external or internal unit.  Some Lisa2/10 and Mac XL were upgraded to
22     use it, too, but a fdc ROM upgrade was required.
13    There were two variants :
14    - A single-sided 400k unit which was used on Lisa 2/Mac XL, and Macintosh
15      128k/512k.  This unit needs the computer to send the proper pulses to
16      control the drive motor rotation.  It can be connected to all early
17      Macintosh (but not Mac Classic?) as an external unit.
18    - A double-sided 800k unit which was used on Macintosh Plus, 512ke, and
19      early SE and II*.  This unit generates its own drive motor rotation
20      control signals.  It can be connected to earlier (and later) Macintosh as
21      an external or internal unit.  Some Lisa2/10 and Mac XL were upgraded to
22      use it, too, but a fdc ROM upgrade was required.
2323
24   * Note: I don't know for sure whether some Mac II were actually produced
25     with a Superdrive unit, though Apple did sell an upgrade kit, made of
26     a Superdrive unit, a SIWM controller and upgraded systems ROMs, which
27     added HD and MFM support to existing Macintosh II.
24    * Note: I don't know for sure whether some Mac II were actually produced
25      with a Superdrive unit, though Apple did sell an upgrade kit, made of
26      a Superdrive unit, a SIWM controller and upgraded systems ROMs, which
27      added HD and MFM support to existing Macintosh II.
2828
29   TODO :
30   * bare images are supposed to be in Macintosh format (look for formatByte
31     in sony_floppy_init(), and you will understand).  We need to support
32     Lisa, Apple II...
33   * support for other image formats?
34   * should we support more than 2 floppy disk units? (Mac SE *MAY* have
35     supported 3 drives)
29    TODO :
30    * bare images are supposed to be in Macintosh format (look for formatByte
31      in sony_floppy_init(), and you will understand).  We need to support
32      Lisa, Apple II...
33    * support for other image formats?
34    * should we support more than 2 floppy disk units? (Mac SE *MAY* have
35      supported 3 drives)
3636
3737*********************************************************************/
3838
r5931r5932
5252#endif
5353
5454/*
55   These lines are normally connected to the PHI0-PHI3 lines of the IWM
55    These lines are normally connected to the PHI0-PHI3 lines of the IWM
5656*/
5757enum
5858{
r5931r5932
7171static unsigned int rotation_speed;      /* drive rotation speed - ignored if ext_speed_control == 0 */
7272
7373/*
74   Structure that describes the state of a floppy drive, and the associated
75   disk image
74    Structure that describes the state of a floppy drive, and the associated
75    disk image
7676*/
7777typedef struct
7878{
r5931r5932
192192   int result = 0;
193193
194194   /*
195    * The Mac floppy controller was interesting in that its speed was adjusted
196    * while the thing was running.  On the tracks closer to the rim, it was
197    * sped up so that more data could be placed on it.  Hence, this function
198    * has different results depending on the track number
199    *
200    * The Mac Plus (and probably the other Macs that use the IWM) verify that
201    * the speed of the floppy drive is within a certain range depending on
202    * what track the floppy is at.  These RPM values are just guesses and are
203    * probably not fully accurate, but they are within the range that the Mac
204    * Plus expects and thus are probably in the right ballpark.
205    *
206    * Note - the timing values are the values returned by the Mac Plus routine
207    * that calculates the speed; I'm not sure what units they are in
208    */
195     * The Mac floppy controller was interesting in that its speed was adjusted
196     * while the thing was running.  On the tracks closer to the rim, it was
197     * sped up so that more data could be placed on it.  Hence, this function
198     * has different results depending on the track number
199     *
200     * The Mac Plus (and probably the other Macs that use the IWM) verify that
201     * the speed of the floppy drive is within a certain range depending on
202     * what track the floppy is at.  These RPM values are just guesses and are
203     * probably not fully accurate, but they are within the range that the Mac
204     * Plus expects and thus are probably in the right ballpark.
205     *
206     * Note - the timing values are the values returned by the Mac Plus routine
207     * that calculates the speed; I'm not sure what units they are in
208     */
209209
210210   if (f->ext_speed_control)
211211   {
r5931r5932
217217#if 1   /* Mac Plus */
218218      static const int speeds[] =
219219      {
220         500,   /* 00-15:   timing value 117B (acceptable range {1135-11E9} */
221         550,   /* 16-31:   timing value ???? (acceptable range {12C6-138A} */
222         600,   /* 32-47:   timing value ???? (acceptable range {14A7-157F} */
223         675,   /* 48-63:   timing value ???? (acceptable range {16F2-17E2} */
224         750      /* 64-79:   timing value ???? (acceptable range {19D0-1ADE} */
220         500,   /* 00-15:   timing value 117B (acceptable range {1135-11E9} */
221         550,   /* 16-31:   timing value ???? (acceptable range {12C6-138A} */
222         600,   /* 32-47:   timing value ???? (acceptable range {14A7-157F} */
223         675,   /* 48-63:   timing value ???? (acceptable range {16F2-17E2} */
224         750      /* 64-79:   timing value ???? (acceptable range {19D0-1ADE} */
225225      };
226226#else   /* Lisa 2 */
227227      /* 237 + 1.3*(256-reg) */
228228      static const int speeds[] =
229229      {
230         293,   /* 00-15:   timing value ???? (acceptable range {0330-0336} */
231         322,   /* 16-31:   timing value ???? (acceptable range {02ED-02F3} */
232         351,   /* 32-47:   timing value ???? (acceptable range {02A7-02AD} */
233         394,   /* 48-63:   timing value ???? (acceptable range {0262-0266} */
234         439      /* 64-79:   timing value ???? (acceptable range {021E-0222} */
230         293,   /* 00-15:   timing value ???? (acceptable range {0330-0336} */
231         322,   /* 16-31:   timing value ???? (acceptable range {02ED-02F3} */
232         351,   /* 32-47:   timing value ???? (acceptable range {02A7-02AD} */
233         394,   /* 48-63:   timing value ???? (acceptable range {0262-0266} */
234         439      /* 64-79:   timing value ???? (acceptable range {021E-0222} */
235235      };
236236#endif
237237      if (cur_image && image_exists(cur_image))
r5931r5932
321321         break;
322322      case 0x0d:   /* Unknown */
323323         /* I'm not sure what this one does, but the Mac Plus executes the
324          * following code that uses this status:
325          *
326          *   417E52: moveq   #$d, D0      ; Status 0x0d
327          *   417E54: bsr     4185fe      ; Query IWM status
328          *   417E58: bmi     417e82      ; If result=1, then skip
329          *
330          * This code is called in the Sony driver's open method, and
331          * _AddDrive does not get called if this status 0x0d returns 1.
332          * Hence, we are returning 0
333          */
324             * following code that uses this status:
325             *
326             *  417E52: moveq   #$d, D0     ; Status 0x0d
327             *  417E54: bsr     4185fe      ; Query IWM status
328             *  417E58: bmi     417e82      ; If result=1, then skip
329             *
330             * This code is called in the Sony driver's open method, and
331             * _AddDrive does not get called if this status 0x0d returns 1.
332             * Hence, we are returning 0
333             */
334334         result = 0;
335335         break;
336336      case 0x0e:   /* Tachometer */
r5931r5932
466466}
467467
468468static DEVICE_START( sonydriv_floppy )
469{   
469{
470470
471471   DEVICE_START_CALL(floppy);
472472   floppy_set_type(device,FLOPPY_TYPE_SONY);
r5931r5932
480480   /* locate the FDC */
481481   fdc = devtag_get_device(image->machine, "fdc");
482482
483   id = floppy_get_drive_by_type(image,FLOPPY_TYPE_SONY);   
483   id = floppy_get_drive_by_type(image,FLOPPY_TYPE_SONY);
484484   save_track_data(fdc, id);
485485   memset(&sony_floppy[id], 0, sizeof(sony_floppy[id]));
486486
487   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);   
487   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);
488488}
489489
490490DEVICE_GET_INFO( sonydriv )
src/mess/devices/ti99cart.h
r5931r5932
11/*********************************************************************
22
3   ti99cart.h
3    ti99cart.h
44
5   TI99 family cartridge management
5    TI99 family cartridge management
66
77*********************************************************************/
88
r5931r5932
2121#define TI99_CARTRIDGE_PCB_SUPER   DEVICE_GET_INFO_NAME(ti99_cartridge_pcb_super)
2222#define TI99_CARTRIDGE_PCB_MBX      DEVICE_GET_INFO_NAME(ti99_cartridge_pcb_mbx)
2323
24/* We set the number of slots to 8, although we may have up to 16. From a
24/* We set the number of slots to 8, although we may have up to 16. From a
2525   logical point of view we could have 256, but the operating system only checks
2626   the first 16 banks. */
2727#define NUMBER_OF_CARTRIDGE_SLOTS 8
r5931r5932
3636   /* GROM data buffer */
3737   UINT8 buf;
3838   /* internal flip-flops that are set after the first access to the GROM
39   address so that next access is mapped to the LSB, and cleared after each
40   data access */
39    address so that next access is mapped to the LSB, and cleared after each
40    data access */
4141   char raddr_LSB, waddr_LSB;
4242};
4343typedef struct _GROM_port_t GROM_port_t;
r5931r5932
4747{
4848   /* PCB device associated to this cartridge. If NULL, the slot is empty. */
4949   const device_config *pcb;
50   
50
5151        /* GROM buffer size. */
5252        int grom_size;
5353
r5931r5932
6767        /* GROM buffered data output. */
6868        UINT8 grom_buffer;
6969
70        /* ROM buffer. We are using this for both 16 bit (99/4a) and 8 bit
71      (99/8) access. */
70        /* ROM buffer. We are using this for both 16 bit (99/4a) and 8 bit
71       (99/8) access. */
7272        void *rom_ptr;
73   
74        /* ROM buffer for the second bank of paged cartridges. Other cartridges
75      usually store their ROM in one large file. */
73
74        /* ROM buffer for the second bank of paged cartridges. Other cartridges
75       usually store their ROM in one large file. */
7676        void *rom2_ptr;
7777
7878        /* RAM buffer. The persistence service is done by the cartridge system.
79      The RAM space is a consecutive space; all banks are in one buffer. */
79       The RAM space is a consecutive space; all banks are in one buffer. */
8080        void *ram_ptr;
8181};
8282typedef struct _cartridge_t cartridge_t;
src/mess/devices/coco_pak.c
r5931r5932
11/***************************************************************************
22
3   coco_pak.c
3    coco_pak.c
44
5   Code for emulating standard CoCo cartridges
5    Code for emulating standard CoCo cartridges
66
77***************************************************************************/
88
r5931r5932
6161{
6262   coco_pak_pcb_t *pak_pcb = get_token(device);
6363   cococart_line_value cart_line;
64   
64
6565   cart_line = input_port_read_safe(device->machine, "CARTAUTO", 0x01)
6666      ? COCOCART_LINE_VALUE_Q
6767      : COCOCART_LINE_VALUE_CLEAR;
r5931r5932
7676
7777/*-------------------------------------------------
7878    DEVICE_GET_INFO(coco_cartridge_pcb_pak) - get
79   info function for standard CoCo cartridges
79    info function for standard CoCo cartridges
8080-------------------------------------------------*/
8181
8282DEVICE_GET_INFO(coco_cartridge_pcb_pak)
r5931r5932
105105
106106
107107/***************************************************************************
108   BANKED CARTRIDGES
108    BANKED CARTRIDGES
109109***************************************************************************/
110110
111111/*-------------------------------------------------
r5931r5932
119119   UINT32 i;
120120   UINT8 *rom = memory_region(device->machine, "cart");
121121   UINT32 rom_length = memory_region_length(device->machine, "cart");
122   
122
123123   pos = (bank * 0x4000) % image_length(pak_pcb->cart);
124124
125125   for (i = 0; i < rom_length / 0x4000; i++)
r5931r5932
164164
165165/*-------------------------------------------------
166166    DEVICE_GET_INFO(coco_cartridge_pcb_pak_banked16k) -
167   get info function for banked CoCo cartridges
167    get info function for banked CoCo cartridges
168168-------------------------------------------------*/
169169
170170DEVICE_GET_INFO(coco_cartridge_pcb_pak_banked16k)
src/mess/devices/z80bin.h
r5931r5932
11/*********************************************************************
22
3   z80bin.h
3    z80bin.h
44
5   A binary quickload format used by the Microbee, the Exidy Sorcerer
6   VZ200/300 and the Super 80
5    A binary quickload format used by the Microbee, the Exidy Sorcerer
6    VZ200/300 and the Super 80
77
88*********************************************************************/
99
r5931r5932
3737struct _z80bin_config
3838{
3939   snapquick_config base;
40   z80bin_execute_func execute;
40   z80bin_execute_func execute;
4141};
4242
4343
src/mess/devices/cassette.h
r5931r5932
11/*********************************************************************
22
3   cassette.h
3    cassette.h
44
5   MESS interface to the cassette image abstraction code
5    MESS interface to the cassette image abstraction code
66
77*********************************************************************/
88
src/mess/devices/flopdrv.h
r5931r5932
3333{
3434   floppy_type floppy_type;
3535   const struct FloppyFormat *formats;
36   keep_geometry keep_drive_geometry;   
36   keep_geometry keep_drive_geometry;
3737};
3838
3939/* sector has a deleted data address mark */
r5931r5932
161161   MDRV_DEVICE_ADD(FLOPPY_2, FLOPPY, 0)      \
162162   MDRV_DEVICE_CONFIG(_config)   \
163163   MDRV_DEVICE_ADD(FLOPPY_3, FLOPPY, 0)      \
164   MDRV_DEVICE_CONFIG(_config)   
164   MDRV_DEVICE_CONFIG(_config)
165165
166166#define MDRV_FLOPPY_4_DRIVES_MODIFY(_config)    \
167167   MDRV_DEVICE_MODIFY(FLOPPY_0)      \
r5931r5932
171171   MDRV_DEVICE_MODIFY(FLOPPY_2)      \
172172   MDRV_DEVICE_CONFIG(_config)   \
173173   MDRV_DEVICE_MODIFY(FLOPPY_3)      \
174   MDRV_DEVICE_CONFIG(_config)   
174   MDRV_DEVICE_CONFIG(_config)
175175
176176#define MDRV_FLOPPY_4_DRIVES_REMOVE()    \
177177   MDRV_DEVICE_REMOVE(FLOPPY_0)      \
178178   MDRV_DEVICE_REMOVE(FLOPPY_1)      \
179179   MDRV_DEVICE_REMOVE(FLOPPY_2)      \
180   MDRV_DEVICE_REMOVE(FLOPPY_3)     
181   
180   MDRV_DEVICE_REMOVE(FLOPPY_3)
181
182182#define MDRV_FLOPPY_2_DRIVES_ADD(_config)    \
183183   MDRV_DEVICE_ADD(FLOPPY_0, FLOPPY, 0)      \
184184   MDRV_DEVICE_CONFIG(_config)   \
185185   MDRV_DEVICE_ADD(FLOPPY_1, FLOPPY, 0)      \
186   MDRV_DEVICE_CONFIG(_config)   
186   MDRV_DEVICE_CONFIG(_config)
187187
188188#define MDRV_FLOPPY_2_DRIVES_MODIFY(_config)    \
189189   MDRV_DEVICE_MODIFY(FLOPPY_0)      \
190190   MDRV_DEVICE_CONFIG(_config)   \
191191   MDRV_DEVICE_MODIFY(FLOPPY_1)      \
192   MDRV_DEVICE_CONFIG(_config)   
192   MDRV_DEVICE_CONFIG(_config)
193193
194194#define MDRV_FLOPPY_2_DRIVES_REMOVE()    \
195195   MDRV_DEVICE_REMOVE(FLOPPY_0)      \
196   MDRV_DEVICE_REMOVE(FLOPPY_1)     
197         
196   MDRV_DEVICE_REMOVE(FLOPPY_1)
197
198198#endif /* FLOPDRV_H */
src/mess/devices/sonydriv.h
r5931r5932
11/*********************************************************************
22
3   sonydriv.h
3    sonydriv.h
44
5   Apple/Sony 3.5" floppy drive emulation (to be interfaced with applefdc.c)
5    Apple/Sony 3.5" floppy drive emulation (to be interfaced with applefdc.c)
66
77*********************************************************************/
88
r5931r5932
1515
1616/*enum
1717{
18   SONY_FLOPPY_ALLOW400K         = 0x0001,
19   SONY_FLOPPY_ALLOW800K         = 0x0002,
18    SONY_FLOPPY_ALLOW400K           = 0x0001,
19    SONY_FLOPPY_ALLOW800K           = 0x0002,
2020
21   SONY_FLOPPY_SUPPORT2IMG         = 0x4000,
22   SONY_FLOPPY_EXT_SPEED_CONTROL   = 0x8000   // means the speed is controlled by computer
21    SONY_FLOPPY_SUPPORT2IMG         = 0x4000,
22    SONY_FLOPPY_EXT_SPEED_CONTROL   = 0x8000    // means the speed is controlled by computer
2323};
2424
2525*/
r5931r5932
4242   MDRV_DEVICE_ADD(FLOPPY_0, FLOPPY_SONY, 0)      \
4343   MDRV_DEVICE_CONFIG(_config)   \
4444   MDRV_DEVICE_ADD(FLOPPY_1, FLOPPY_SONY, 0)      \
45   MDRV_DEVICE_CONFIG(_config)   
45   MDRV_DEVICE_CONFIG(_config)
4646
4747#define MDRV_FLOPPY_SONY_2_DRIVES_ADDITIONAL_ADD(_config)    \
4848   MDRV_DEVICE_ADD(FLOPPY_2, FLOPPY_SONY, 0)      \
4949   MDRV_DEVICE_CONFIG(_config)   \
5050   MDRV_DEVICE_ADD(FLOPPY_3, FLOPPY_SONY, 0)      \
51   MDRV_DEVICE_CONFIG(_config)   
51   MDRV_DEVICE_CONFIG(_config)
5252
5353#define MDRV_FLOPPY_SONY_2_DRIVES_MODIFY(_config)    \
5454   MDRV_DEVICE_MODIFY(FLOPPY_0)      \
5555   MDRV_DEVICE_CONFIG(_config)   \
5656   MDRV_DEVICE_MODIFY(FLOPPY_1)      \
57   MDRV_DEVICE_CONFIG(_config)   
57   MDRV_DEVICE_CONFIG(_config)
5858
5959
6060
src/mess/devices/microdrv.c
r5931r5932
11/****************************************************************************
22
3   microdrv.c
3    microdrv.c
44
5   Code for handling Microdrive devices
5    Code for handling Microdrive devices
66
77****************************************************************************/
88
src/mess/devices/xmodem.c
r5931r5932
4444            <--   <ACK>
4545
4646   and packet is:  <SOH> <id> <0xff-id> <data0> ... <data127> <checksum>
47   
47
4848   <id> is 1 for the first packet, 2 for the 2d, etc...
4949   <checksum> is the sum of <data0> to <data127> modulo 256
5050
51   there are always 128 bytes of data in a packet, so, any file transfered is
51   there are always 128 bytes of data in a packet, so, any file transfered is
5252   rounded to a multiple of 128 bytes, using 0-filler
5353*/
5454
r5931r5932
6565   UINT32  id;                  /* block id, starting at 1 */
6666   UINT16  pos;                 /* position in block, including header */
6767   UINT8   state;               /* one of XMODEM_ */
68   
68
6969   const device_config* image;  /* underlying image */
7070
7171   emu_timer* timer;            /* used to send periodic NAKs */
r5931r5932
8888}
8989
9090/* fills state->block with the data for packet number state->id
91   returns != 0 if fail or end of file
91   returns != 0 if fail or end of file
9292*/
9393static int xmodem_make_send_block( xmodem* state )
9494{
r5931r5932
103103   return 0;
104104}
105105
106/* checks the received state->block packet and stores the data in the image
106/* checks the received state->block packet and stores the data in the image
107107   returns != 0 if fail (bad packet or bad image)
108108 */
109109static int xmodem_get_receive_block( xmodem* state )
r5931r5932
123123/* the outside (us) sends a byte to the emulated machine */
124124static void xmodem_send_byte( xmodem* state, UINT8 data )
125125{
126   if ( state->conf && state->conf->send )
126   if ( state->conf && state->conf->send )
127127   {
128128      state->conf->send( state->machine, data );
129129   }
r5931r5932
152152   state->id = 0;
153153   state->pos = 0;
154154        /* When idle, we send NAK periodically to tell the emulated machine that we are
155      always ready to receive.
156      The 2 sec start time is here so that the machine does not get NAK instead of
157      ACK or EOT as the last byte of a transfer.
158    */
155       always ready to receive.
156       The 2 sec start time is here so that the machine does not get NAK instead of
157       ACK or EOT as the last byte of a transfer.
158     */
159159   timer_adjust_periodic( state->timer, ATTOTIME_IN_SEC( 2 ), 0, ATTOTIME_IN_SEC( 2 ) );
160160}
161161
r5931r5932
277277            LOG(( "xmodem: packet is invalid, sending NAK\n" ));
278278            xmodem_send_byte( state, XMODEM_NAK );
279279         }
280         else
280         else
281281         {
282282            /* ok */
283283            LOG(( "xmodem: packet is valid, sending ACK\n" ));
src/mess/devices/cartslot.c
r5931r5932
22
33    cartslot.c
44
5   Cartridge device
5    Cartridge device
66
77**********************************************************************/
88
r5931r5932
150150         while(!ROMENTRY_ISREGIONEND(roment))
151151         {
152152            if (ROMENTRY_GETTYPE(roment) == ROMENTRYTYPE_CARTRIDGE)
153            {               
153            {
154154               if (strcmp(roment->_hashdata,image->tag)==0)
155               {                 
155               {
156156                  result = load_cartridge(image, romrgn, roment, mode);
157157                  if (!result)
158158                     return result;
r5931r5932
222222            break;
223223         }
224224      }
225      if (socket != NULL)
225      if (socket != NULL)
226226         result = socket->resource->length;
227227   }
228   else
228   else
229229      result = 0;
230230
231231   return result;
r5931r5932
248248      (*config->device_start)(device);
249249      goto done;
250250   }
251   
251
252252   /* find the PCB (if there is one) */
253253   cart->pcb_device = devtag_get_device(
254254      device->machine,
r5931r5932
264264-------------------------------------------------*/
265265
266266static DEVICE_IMAGE_LOAD( cartslot )
267{   
267{
268268   int result;
269269   cartslot_t *cart = get_token(image);
270270   const cartslot_config *config = get_config(image);
r5931r5932
355355            break;
356356         }
357357      }
358     
358
359359      /* check for unknown PCB type */
360360      if ((mc != NULL) && (pcb_type == NULL))
361361         fatalerror("Unknown PCB type \"%s\"\n", astring_c(pcb_name));
r5931r5932
400400-------------------------------------------------*/
401401
402402DEVICE_GET_INFO( cartslot )
403{   
403{
404404   switch(state)
405405   {
406406      /* --- the following bits of info are returned as 64-bit signed integers --- */
r5931r5932
413413      case DEVINFO_INT_IMAGE_CREATABLE:         info->i = 0; break;
414414      case DEVINFO_INT_IMAGE_RESET_ON_LOAD:      info->i = 1; break;
415415      case DEVINFO_INT_IMAGE_MUST_BE_LOADED:      if ( device && device->inline_config) {
416                                          info->i = get_config(device)->must_be_loaded;
416                                          info->i = get_config(device)->must_be_loaded;
417417                                       } else {
418                                          info->i = 0;
418                                          info->i = 0;
419419                                       }
420420                                       break;
421421
422422      /* --- the following bits of info are returned as pointers to functions --- */
423423      case DEVINFO_FCT_START:                  info->start = DEVICE_START_NAME(cartslot);               break;
424      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cartslot);      break;
425      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cartslot);      break;
424      case DEVINFO_FCT_IMAGE_LOAD:            info->f = (genf *) DEVICE_IMAGE_LOAD_NAME(cartslot);      break;
425      case DEVINFO_FCT_IMAGE_UNLOAD:            info->f = (genf *) DEVICE_IMAGE_UNLOAD_NAME(cartslot);      break;
426426      case DEVINFO_FCT_GET_IMAGE_DEVICES:         info->f = (genf *) DEVICE_GET_IMAGE_DEVICES_NAME(cartslot);   break;
427427      case DEVINFO_FCT_IMAGE_PARTIAL_HASH:      if ( device && device->inline_config && get_config(device)->device_partialhash) {
428                                          info->f = (genf *) get_config(device)->device_partialhash;
428                                          info->f = (genf *) get_config(device)->device_partialhash;
429429                                       } else {
430                                          info->f = NULL;
430                                          info->f = NULL;
431431                                       }
432                                       break;         
432                                       break;
433433
434434      /* --- the following bits of info are returned as NULL-terminated strings --- */
435435      case DEVINFO_STR_NAME:                  strcpy(info->s, "Cartslot"); break;
src/mess/devices/kermit.c
r5931r5932
8989   UINT16  posin;         /* position in pin */
9090   UINT16  posout;        /* position in pout */
9191   UINT16  nbout;         /* size of pout */
92   
92
9393   UINT8   state;         /* current protocol state */
9494   UINT8   retries;       /* packet retries remaining */
9595
r5931r5932
156156static void kermit_start_sending( kermit* state )
157157{
158158   int i;
159   
160   for (i=1;i<state->nbout;i++)
161      if (kermit_is_ctl(state->pout[i]))
159
160   for (i=1;i<state->nbout;i++)
161      if (kermit_is_ctl(state->pout[i]))
162162         logerror( "send: not char %i at pos %i\n", state->pout[i], i  );
163163
164164   if ( state->nbout <= 0 ) return;
r5931r5932
187187
188188static void kermit_resend( kermit* state )
189189{
190   if ( state->conf && state->conf->send )
190   if ( state->conf && state->conf->send )
191191   {
192192      /* retry */
193193      if ( state->nbout == 0 ) return;
r5931r5932
196196         kermit_reset( state );
197197         return;
198198      }
199   
199
200200      state->conf->send( state->machine, state->pout[ 0 ] );
201201
202202      state->posout = 1;
r5931r5932
229229      {
230230         /* escape control char */
231231         state->pout[ 2 + len ] = state->qctl;
232         len++;
232         len++;
233233         state->pout[ 2 + len ] = kermit_ctl( c );
234234      }
235235      else if ( (c & 0x7f) == state->qctl )
236236      {
237237         /* escape escape char */
238238         state->pout[ 2 + len ] = state->qctl;
239         len++;
239         len++;
240240         state->pout[ 2 + len ] = c;
241241      }
242242      else
r5931r5932
296296   if ( len >= 7 ) state->padc = kermit_ctl( state->pin[ 7 ] );
297297   if ( len >= 8 ) state->eol  = kermit_unchar( state->pin[ 8 ] );
298298   if ( len >= 9 ) state->qctl = state->pin[ 9 ];
299   
299
300300   LOG(( "kermit: get conf: len=%i, maxl=%i, npad=%i, padc=%i, eol=%i, qctl=%i\n",
301301         len, state->maxl, state->npad, state->padc, state->eol, state->qctl ));
302302
r5931r5932
389389   state->state   = KERMIT_IDLE;
390390   state->seq     = 0;
391391
392   if ( state->image )
392   if ( state->image )
393393   {
394394      image_fseek( state->image, SEEK_SET, 0 );
395395   }
r5931r5932
402402void kermit_receive_byte( const device_config *device, UINT8 data )
403403{
404404   kermit* state = (kermit*) device->token;
405   
405
406406   LOG(( "get %i %2x %c (%i)\n", data, data, data, state->posin ));
407
407
408408   /* get SOH */
409   if ( (data == KERMIT_SOH) && (state->posin <= 1) )
409   if ( (data == KERMIT_SOH) && (state->posin <= 1) )
410410   {
411411      state->pin[ 0 ] = data;
412      state->posin = 1;   
412      state->posin = 1;
413413   }
414414
415415   /* get packet contents */
416416   else if ( state->posin > 0 )
417417   {
418      if ( state->posin >= sizeof( state->pout ) )
418      if ( state->posin >= sizeof( state->pout ) )
419419      {
420420         LOG(( "kermit: too many bytes received\n" ));
421421         state->posin = 0;
r5931r5932
429429      state->pin[ state->posin ] = data;
430430      state->posin++;
431431
432      if ( state->posin > 5 )
432      if ( state->posin > 5 )
433433      {
434434         int len, seq, typ;
435         if ( !kermit_is_char( state->pin[1] ) ||
435         if ( !kermit_is_char( state->pin[1] ) ||
436436              (kermit_unchar( state->pin[1] ) < 3) ||
437437              (kermit_unchar( state->pin[1] ) > state->maxl) )
438438         {
r5931r5932
447447         {
448448            /* got packet! */
449449            state->posin = 0;
450            if ( kermit_validate_packet( state ) )
450            if ( kermit_validate_packet( state ) )
451451            {
452452               LOG(( "kermit: invalid packet\n" ));
453453               kermit_resend( state );
r5931r5932
540540                  /* send next packet */
541541
542542                  state->seq = state->seq + 1;
543                 
543
544544                  switch ( state->state )
545545                  {
546546                  case KERMIT_IDLE:
r5931r5932
549549                     kermit_send_string_packet( state, KERMIT_FILE, image_basename( state->image ) );
550550                     state->state = KERMIT_SEND_DATA;;
551551                     break;
552                     
552
553553                  case KERMIT_SEND_DATA:
554554                     /* send next data packet or EOF */
555555                     if ( image_feof( state->image ) )
r5931r5932
559559                     }
560560                     else
561561                     {
562                        kermit_send_data_packet( state );   
562                        kermit_send_data_packet( state );
563563                     }
564564                     break;
565                     
565
566566                  case KERMIT_SEND_EOF:
567567                           /* send EOT */
568568                     kermit_send_simple_packet( state, KERMIT_EOT );
569569                     state->state = KERMIT_SEND_EOT;
570570                     break;
571                     
571
572572                  case KERMIT_SEND_EOT:
573573                     /* reset */
574574                     kermit_reset( state );
575575                     state->state = KERMIT_RESET;
576576                     break;
577                     
577
578578                  }
579579               }
580580
r5931r5932
590590                  kermit_reset( state );
591591               }
592592               break;
593               
593
594594                                /* errors */
595595
596596            case KERMIT_ERR:
r5931r5932
599599               kermit_reset( state );
600600               break;
601601
602            default:
602            default:
603603               LOG(( "kermit: ignoring packet type %c\n", state->pin[ 3 ] ));
604604               /* no abort, just ignoring */
605605            }
src/mess/devices/xmodem.h
r5931r5932
1919
2020  /* called by XMODEM when it wants to send a byte to the emulated machine */
2121  void (*send)( running_machine *machine, UINT8 data );
22 
22
2323} xmodem_config;
2424
2525
src/mess/devices/coco_fdc.c
r5931r5932
11/*********************************************************************
22
3   coco_fdc.c
3    coco_fdc.c
44
5   CoCo/Dragon FDC
5    CoCo/Dragon FDC
66
7   The CoCo and Dragon both use the Western Digital floppy disk controllers.
8   The CoCo uses either the WD1793 or the WD1773, the Dragon uses the WD2797,
9    which mostly uses the same command set with some subtle differences, most
10    notably the 2797 handles disk side select internally. The Dragon Alpha also
11    uses the WD2797, however as this is a built in interface and not an external
12    cartrige, it is dealt with in the main coco.c file.
7    The CoCo and Dragon both use the Western Digital floppy disk controllers.
8    The CoCo uses either the WD1793 or the WD1773, the Dragon uses the WD2797,
9    which mostly uses the same command set with some subtle differences, most
10    notably the 2797 handles disk side select internally. The Dragon Alpha also
11    uses the WD2797, however as this is a built in interface and not an external
12    cartrige, it is dealt with in the main coco.c file.
1313
14   The wd's variables are mapped to $FF48-$FF4B on the CoCo and on $FF40-$FF43
15    on the Dragon.  In addition, there is another register
16   called DSKREG that controls the interface with the wd1793.  DSKREG is
17   detailed below:  But they appear to be
14    The wd's variables are mapped to $FF48-$FF4B on the CoCo and on $FF40-$FF43
15    on the Dragon.  In addition, there is another register
16    called DSKREG that controls the interface with the wd1793.  DSKREG is
17    detailed below:  But they appear to be
1818
19   References:
20      CoCo:   Disk Basic Unravelled
21      Dragon:   Inferences from the PC-Dragon source code
22               DragonDos Controller, Disk and File Formats by Graham E Kinns
19    References:
20        CoCo:   Disk Basic Unravelled
21        Dragon: Inferences from the PC-Dragon source code
22                DragonDos Controller, Disk and File Formats by Graham E Kinns
2323
24   ---------------------------------------------------------------------------
24    ---------------------------------------------------------------------------
2525
26   DSKREG - the control register
27   CoCo ($FF40)                                    Dragon ($FF48)
26    DSKREG - the control register
27    CoCo ($FF40)                                    Dragon ($FF48)
2828
29   Bit                                              Bit
30   7 halt enable flag                               7 not used
31   6 drive select #3                                6 not used
32   5 density (0=single, 1=double)                   5 NMI enable flag
33      and NMI enable flag
34   4 write precompensation                          4 write precompensation
35   3 drive motor activation                         3 single density enable
36   2 drive select #2                                2 drive motor activation
37   1 drive select #1                                1 drive select high bit
38   0 drive select #0                                0 drive select low bit
29    Bit                                              Bit
30    7 halt enable flag                               7 not used
31    6 drive select #3                                6 not used
32    5 density (0=single, 1=double)                   5 NMI enable flag
33        and NMI enable flag
34    4 write precompensation                          4 write precompensation
35    3 drive motor activation                         3 single density enable
36    2 drive select #2                                2 drive motor activation
37    1 drive select #1                                1 drive select high bit
38    0 drive select #0                                0 drive select low bit
3939
40   Reading from $FF48-$FF4F clears bit 7 of DSKREG ($FF40)
40    Reading from $FF48-$FF4F clears bit 7 of DSKREG ($FF40)
4141
42   ---------------------------------------------------------------------------
42    ---------------------------------------------------------------------------
4343
44   2007-02-22, P.Harvey-Smith
44    2007-02-22, P.Harvey-Smith
4545
46   Began implementing the Dragon Delta Dos controler, this was actually the first
47   Dragon disk controler to market, beating Dragon Data's by a couple of months,
48   it is based around the WD2791 FDC, which is compatible with the WD1793/WD2797 used
49   by the standard CoCo and Dragon disk controlers except that it used an inverted
50   data bus, which is the reason the read/write handlers invert the data. This
51   controler like, the DragonDos WD2797 is mapped at $FF40-$FF43, in the normal
52   register order.
46    Began implementing the Dragon Delta Dos controler, this was actually the first
47    Dragon disk controler to market, beating Dragon Data's by a couple of months,
48    it is based around the WD2791 FDC, which is compatible with the WD1793/WD2797 used
49    by the standard CoCo and Dragon disk controlers except that it used an inverted
50    data bus, which is the reason the read/write handlers invert the data. This
51    controler like, the DragonDos WD2797 is mapped at $FF40-$FF43, in the normal
52    register order.
5353
54   The Delta cart also has a register (74LS174 hex flipflop) at $FF44 encoded as
55   follows :-
54    The Delta cart also has a register (74LS174 hex flipflop) at $FF44 encoded as
55    follows :-
5656
57   Bit
58   7 not used
59   6 not used
60   5 not used
61   4 Single (0) / Double (1) density select
62   3 5.25"(0) / 8"(1) Clock select
63   2 Side select
64   1 Drive select ms bit
65   0 Drive select ls bit
57    Bit
58    7 not used
59    6 not used
60    5 not used
61    4 Single (0) / Double (1) density select
62    3 5.25"(0) / 8"(1) Clock select
63    2 Side select
64    1 Drive select ms bit
65    0 Drive select ls bit
6666
6767*********************************************************************/
6868
r5931r5932
178178{
179179   rtc_type_t result;
180180   fdc_t *fdc = get_token(device);
181   
181
182182   result = (int) input_port_read_safe(device->machine, "real_time_clock", RTC_NONE);
183183
184184   /* check to make sure we don't have any invalid values */
r5931r5932
291291
292292/*-------------------------------------------------
293293    fdc_coco_update_lines - CoCo specific disk
294   controller lines
294    controller lines
295295-------------------------------------------------*/
296296
297297static void fdc_coco_update_lines(const device_config *device)
r5931r5932
319319
320320/*-------------------------------------------------
321321    fdc_coco_dskreg_w - function to write to CoCo
322   dskreg
322    dskreg
323323-------------------------------------------------*/
324324
325325static void fdc_coco_dskreg_w(const device_config *device, UINT8 data)
r5931r5932
343343   }
344344
345345   /* An email from John Kowalski informed me that if the DS3 is
346    * high, and one of the other drive bits is selected (DS0-DS2), then the
347    * second side of DS0, DS1, or DS2 is selected.  If multiple bits are
348    * selected in other situations, then both drives are selected, and any
349    * read signals get yucky.
350    */
346     * high, and one of the other drive bits is selected (DS0-DS2), then the
347     * second side of DS0, DS1, or DS2 is selected.  If multiple bits are
348     * selected in other situations, then both drives are selected, and any
349     * read signals get yucky.
350     */
351351
352352   if (data & 0x04)
353353      drive = 2;
r5931r5932
470470
471471/*-------------------------------------------------
472472    DEVICE_GET_INFO(coco_cartridge_pcb_fdc_coco) -
473   get info function for the CoCo FDC
473    get info function for the CoCo FDC
474474-------------------------------------------------*/
475475
476476DEVICE_GET_INFO(coco_cartridge_pcb_fdc_coco)
r5931r5932
481481      MDRV_DS1315_ADD(CLOUD9_TAG)
482482   MACHINE_DRIVER_END
483483
484   static const fdc_hardware_type hwtype =
484   static const fdc_hardware_type hwtype =
485485   {
486486      "CoCo FDC",
487487      fdc_coco_update_lines,
r5931r5932
502502
503503/*-------------------------------------------------
504504    fdc_dragon_update_lines - Dragon specific disk
505   controller lines
505    controller lines
506506-------------------------------------------------*/
507507
508508static void fdc_dragon_update_lines(const device_config *device)
r5931r5932
525525
526526/*-------------------------------------------------
527527    fdc_dragon_dskreg_w - function to write to
528   Dragon dskreg
528    Dragon dskreg
529529-------------------------------------------------*/
530530
531531static void fdc_dragon_dskreg_w(const device_config *device, UINT8 data)
r5931r5932
622622
623623/*-------------------------------------------------
624624    DEVICE_GET_INFO(coco_cartridge_pcb_fdc_dragon) -
625   get info function for the CoCo FDC
625    get info function for the CoCo FDC
626626-------------------------------------------------*/
627627
628628DEVICE_GET_INFO(coco_cartridge_pcb_fdc_dragon)
r5931r5932
631631      MDRV_WD179X_ADD(WD_TAG, coco_wd17xx_interface)
632632   MACHINE_DRIVER_END
633633
634   static const fdc_hardware_type hwtype =
634   static const fdc_hardware_type hwtype =
635635   {
636636      "Dragon FDC",
637637      fdc_dragon_update_lines,
src/mess/devices/cartslot.h
r5931r5932
11/***************************************************************************
22
3   Cartrige loading
3    Cartrige loading
44
55***************************************************************************/
66
r5931r5932
5757   int                        must_be_loaded;
5858   device_start_func            device_start;
5959   device_image_load_func         device_load;
60   device_image_unload_func      device_unload;   
60   device_image_unload_func      device_unload;
6161   device_image_partialhash_func   device_partialhash;
6262   cartslot_pcb_type            pcb_types[8];
6363};
src/mess/devices/kermit.h
r5931r5932
1919
2020  /* called by Kermit when it wants to send a byte to the emulated machine */
2121  void (*send)( running_machine *machine, UINT8 data );
22 
22
2323} kermit_config;
2424
2525
src/mess/devices/chd_cd.c
r5931r5932
11/*********************************************************************
22
3   Code to interface the MESS image code with MAME's CHD-CD core.
3    Code to interface the MESS image code with MAME's CHD-CD core.
44
5   Based on harddriv.c by Raphael Nabet 2003
5    Based on harddriv.c by Raphael Nabet 2003
66
77*********************************************************************/
88
src/mess/devices/messram.c
r5931r5932
5353
5454/*-------------------------------------------------
5555    parse_string - convert a ram string to an
56   integer value
56    integer value
5757-------------------------------------------------*/
5858
5959static UINT32 parse_string(const char *s)
src/mess/devices/coco_232.c
r5931r5932
11/***************************************************************************
22
3   coco_232.c
3    coco_232.c
44
5   Code for emulating the CoCo RS-232 PAK
5    Code for emulating the CoCo RS-232 PAK
66
77***************************************************************************/
88
r5931r5932
7777
7878   if ((offset >= 0x28) && (offset <= 0x2F))
7979      result = acia_6551_r(pak_pcb->uart, offset - 0x28);
80   
80
8181   return result;
8282}
8383
src/mess/devices/chd_cd.h
r5931r5932
11/*********************************************************************
22
3   chd_cd.h
3    chd_cd.h
44
5   MESS interface to the MAME CHD CDROM code
5    MESS interface to the MAME CHD CDROM code
66
77*********************************************************************/
88
src/mess/devices/appldriv.c
r5931r5932
11/*********************************************************************
22
3   appldriv.c
3    appldriv.c
44
5   Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
5    Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
66
77*********************************************************************/
88#include "driver.h"
r5931r5932
141141    if (devtag_get_device(machine,FLOPPY_3)!=NULL && flopimg_get_custom_data(devtag_get_device(machine,FLOPPY_3))!=NULL) cnt++;
142142   return cnt;
143143}
144   
144
145145void apple525_set_lines(const device_config *device,UINT8 lines)
146146{
147147   int i, count;
r5931r5932
151151   for (i = 0; i < count; i++)
152152   {
153153      if (apple525_enable_mask & (1 << i))
154      {         
154      {
155155         image = floppy_get_device_by_type(device->machine, FLOPPY_TYPE_APPLE, i);
156156         if (image)
157157            apple525_disk_set_lines(device,image, lines);
r5931r5932
212212static const device_config *apple525_selected_image(running_machine *machine)
213213{
214214   int i,count;
215   
215
216216   count = apple525_get_count(machine);
217   
217
218218   for (i = 0; i < count; i++)
219219   {
220220      if (apple525_enable_mask & (1 << i))
r5931r5932
242242{
243243   int i, count, result = 0;
244244   const device_config *image;
245   
245
246246   count = apple525_get_count(device->machine);
247   
247
248248   for (i = 0; i < count; i++)
249249   {
250250      if (apple525_enable_mask & (1 << i))
r5931r5932
260260/* ----------------------------------------------------------------------- */
261261
262262static DEVICE_START( apple525_floppy )
263{   
263{
264264
265265   DEVICE_START_CALL(floppy);
266   flopimg_alloc_custom_data(device,auto_alloc_clear(device->machine,struct apple525_disk));   
266   flopimg_alloc_custom_data(device,auto_alloc_clear(device->machine,struct apple525_disk));
267267   floppy_set_type(device,FLOPPY_TYPE_APPLE);
268268}
269269
r5931r5932
279279{
280280   apple525_save_current_track(image, TRUE);
281281
282   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);   
282   DEVICE_IMAGE_UNLOAD_NAME(floppy)(image);
283283}
284284
285285DEVICE_GET_INFO( apple525 )
src/mess/devices/aescart.c
r5931r5932
11/**********************************************************************
22
3   aescart.c
3    aescart.c
44
5   Neo-Geo AES cartridge management
6   R. Belmont, 2009
5    Neo-Geo AES cartridge management
6    R. Belmont, 2009
77
8   Based on ti99cart.c by Michael Zapf
8    Based on ti99cart.c by Michael Zapf
99
10   We leave the support in place for multiple slots in case MAME
11   uses this at some future point for MVS multi-cart.
12   
10    We leave the support in place for multiple slots in case MAME
11    uses this at some future point for MVS multi-cart.
12
1313*********************************************************************/
1414#include "driver.h"
1515#include "aescart.h"
r5931r5932
2828struct _aes_multicart_t
2929{
3030   /* Reserves space for all cartridges. This is also used in the legacy
31      cartridge system, but only for slot 0. */
31       cartridge system, but only for slot 0. */
3232   aescartridge_t cartridge[AES_NUMBER_OF_CARTRIDGE_SLOTS];
3333
3434   /* Determines which slot is currently active. This value is changed when there
35   are accesses to other GROM base addresses. */
35    are accesses to other GROM base addresses. */
3636   int active_slot;
37   
38   /* Used in order to enforce a special slot. This value is retrieved
39      from the dipswitch setting. A value of -1 means automatic, that is,
40      the grom base switch is used. Values 0 .. max refer to the
41      respective slot. */
37
38   /* Used in order to enforce a special slot. This value is retrieved
39       from the dipswitch setting. A value of -1 means automatic, that is,
40       the grom base switch is used. Values 0 .. max refer to the
41       respective slot. */
4242   int fixed_slot;
4343
44   /* Holds the highest index of a cartridge being plugged in plus one.
45      If we only have one cartridge inserted, we don't want to get a
46      selection option, so we just mirror the memory contents. */
44   /* Holds the highest index of a cartridge being plugged in plus one.
45       If we only have one cartridge inserted, we don't want to get a
46       selection option, so we just mirror the memory contents. */
4747   int next_free_slot;
48   
49   /* Counts the number of slots which currently contain legacy format
50      cartridge images. */
48
49   /* Counts the number of slots which currently contain legacy format
50       cartridge images. */
5151   int legacy_slots;
5252
53   /* Counts the number of slots which currently contain new format
54      cartridge images. */
53   /* Counts the number of slots which currently contain new format
54       cartridge images. */
5555   int multi_slots;
5656};
5757typedef struct _aes_multicart_t aes_multicart_t;
r5931r5932
6363{
6464   /* Link up to the cartridge structure which contains this pcb. */
6565   aescartridge_t *cartridge;
66   
66
6767   /* Function to assemble this cartridge. */
6868   assmfct   *assemble;
69   
69
7070   /* Function to disassemble this cartridge. */
7171   assmfct   *disassemble;
7272};
7373typedef struct _aes_pcb_t aes_pcb_t;
7474
75/*
76   Find the index of the cartridge name. We assume the format
77   <name><number>, i.e. the number is the longest string from the right
78   which can be interpreted as a number.
75/*
76    Find the index of the cartridge name. We assume the format
77    <name><number>, i.e. the number is the longest string from the right
78    which can be interpreted as a number.
7979*/
8080static int get_index_from_tagname(const device_config *image)
8181{
r5931r5932
8383   int maxlen = strlen(tag);
8484   int i;
8585   for (i=maxlen-1; i >=0; i--)
86      if (tag[i] < 48 || tag[i] > 57) break;
86      if (tag[i] < 48 || tag[i] > 57) break;
8787
8888   return atoi(tag+i+1);
8989}
9090
9191/*
92   Common routine to assemble cartridges from resources.
92    Common routine to assemble cartridges from resources.
9393*/
9494static aescartridge_t *assemble_common(running_machine *machine, const device_config *cartslot)
9595{
r5931r5932
105105   assert(slotnumber>=0 && slotnumber<AES_NUMBER_OF_CARTRIDGE_SLOTS);
106106
107107   /* There is a cartridge in this slot, check the maximum slot number. */
108   if (cartslots->next_free_slot <= slotnumber)
108   if (cartslots->next_free_slot <= slotnumber)
109109   {
110110      cartslots->next_free_slot = slotnumber+1;
111111   }
112112   cartridge = &cartslots->cartridge[slotnumber];
113113
114114   // check for up to 4 program ROMs
115   romrgn = (UINT8 *)memory_region(machine, "maincpu");
115   romrgn = (UINT8 *)memory_region(machine, "maincpu");
116116   blockofs = 0;
117117   for (i = 0; i < 4; i++)
118118   {
r5931r5932
133133   reslength = cartslot_get_resource_length(cartslot, "m1");
134134   if (socketcont != NULL)
135135   {
136      romrgn = (UINT8 *)memory_region(machine, "audiocpu");
136      romrgn = (UINT8 *)memory_region(machine, "audiocpu");
137137
138138      memcpy(romrgn, socketcont, reslength);
139139      // mirror (how does this really work?)
r5931r5932
141141   }
142142
143143   // up to 8 YM sample ROMs
144   romrgn = (UINT8 *)memory_region(machine, "ym");
144   romrgn = (UINT8 *)memory_region(machine, "ym");
145145   blockofs = 0;
146146   for (i = 0; i < 8; i++)
147147   {
r5931r5932
158158   }
159159
160160   // up to 8 YM delta-T sample ROMs
161   romrgn = (UINT8 *)memory_region(machine, "ym.deltat");
161   romrgn = (UINT8 *)memory_region(machine, "ym.deltat");
162162   blockofs = 0;
163163   for (i = 0; i < 8; i++)
164164   {
r5931r5932
179179   reslength = cartslot_get_resource_length(cartslot, "s1");
180180   if (socketcont != NULL)
181181   {
182      romrgn = (UINT8 *)memory_region(machine, "fixed");
182      romrgn = (UINT8 *)memory_region(machine, "fixed");
183183
184184      memcpy(romrgn, socketcont, reslength);
185185   }
186186
187187   // up to 8 sprite ROMs in byte-interleaved pairs
188   romrgn = (UINT8 *)memory_region(machine, "sprites");
188   romrgn = (UINT8 *)memory_region(machine, "sprites");
189189   blockofs = 0;
190190   for (i = 0; i < 8; i+=2)
191191   {
r5931r5932
216216
217217static void set_pointers(const device_config *pcb, int index)
218218{
219   const device_config *cartsys = pcb->owner->owner;
219   const device_config *cartsys = pcb->owner->owner;
220220   aes_multicart_t *cartslots = (aes_multicart_t *)cartsys->token;
221221   aes_pcb_t *pcb_def = (aes_pcb_t *)pcb->token;
222222
223223   pcb_def->assemble = (assmfct *)device_get_info_fct(pcb, AESCART_FCT_ASSM);
224224   pcb_def->disassemble = (assmfct *)device_get_info_fct(pcb, AESCART_FCT_DISASSM);
225   
225
226226   pcb_def->cartridge = &cartslots->cartridge[index];
227227   pcb_def->cartridge->pcb = pcb;
228228}
229229
230230/*****************************************************************************
231231  Cartridge type: None
232     This PCB device is just a pseudo device; the legacy mode is handled
233   by dedicated functions.
232    This PCB device is just a pseudo device; the legacy mode is handled
233    by dedicated functions.
234234******************************************************************************/
235235static DEVICE_START(aes_pcb_none)
236236{
237237   /* device is aes_cartslot:cartridge:pcb */
238//   printf("DEVICE_START(aes_pcb_none), tag of device=%s\n", device->tag);
238//  printf("DEVICE_START(aes_pcb_none), tag of device=%s\n", device->tag);
239239   set_pointers(device, get_index_from_tagname(device->owner)-1);
240240}
241241
242242/*****************************************************************************
243243  Cartridge type: Standard
244     Most cartridges are built in this type. This includes word-swapped program,
245   z80 program, YM samples, delta-T samples, sprites, and sfix.
244    Most cartridges are built in this type. This includes word-swapped program,
245    z80 program, YM samples, delta-T samples, sprites, and sfix.
246246******************************************************************************/
247247
248248static DEVICE_START(aes_pcb_std)
249249{
250250   /* device is aes_cartslot:cartridge:pcb */
251//   printf("DEVICE_START(aes_pcb_std), tag of device=%s\n", device->tag);
251//  printf("DEVICE_START(aes_pcb_std), tag of device=%s\n", device->tag);
252252   set_pointers(device, get_index_from_tagname(device->owner)-1);
253253}
254254
255255/*
256   The standard cartridge assemble routine. We just call the common
257   function here.
256    The standard cartridge assemble routine. We just call the common
257    function here.
258258*/
259259static int assemble_std(running_machine *machine, const device_config *image)
260260{
261261   aescartridge_t *cart;
262//   printf("assemble_std, %s\n", image->tag);
262//  printf("assemble_std, %s\n", image->tag);
263263   cart = assemble_common(machine, image);
264     
264
265265   return INIT_PASS;
266266}
267267
268268/*
269   Removes pointers and restores the state before plugging in the
270   cartridge.
271   The pointer to the location after the last cartridge is adjusted.
272   As it seems, we can use the same function for the disassembling of all
273   cartridge types.
269    Removes pointers and restores the state before plugging in the
270    cartridge.
271    The pointer to the location after the last cartridge is adjusted.
272    As it seems, we can use the same function for the disassembling of all
273    cartridge types.
274274*/
275275static int disassemble_std(const device_config *image)
276276{
277277   int slotnumber;
278//   int i;
278//  int i;
279279   aescartridge_t *cart;
280280   const device_config *cartsys = image->owner;
281281   aes_multicart_t *cartslots = (aes_multicart_t *)cartsys->token;
282282
283283   slotnumber = get_index_from_tagname(image)-1;
284//   printf("Disassemble cartridge %d\n", slotnumber);
284//  printf("Disassemble cartridge %d\n", slotnumber);
285285#if 0
286286   /* Search the highest remaining cartridge. */
287287   cartslots->next_free_slot = 0;
288288   for (i=AES_NUMBER_OF_CARTRIDGE_SLOTS-1; i >= 0; i--)
289289   {
290      if (i != slotnumber)
290      if (i != slotnumber)
291291      {
292         if (0) //!slot_is_empty(cartsys, i))   (for future use?)
292         if (0) //!slot_is_empty(cartsys, i))    (for future use?)
293293         {
294294            cartslots->next_free_slot = i+1;
295//            printf("Setting new next_free_slot to %d\n", cartslots->next_free_slot);
295//              printf("Setting new next_free_slot to %d\n", cartslots->next_free_slot);
296296            break;
297297         }
298298      }
299299   }
300#endif   
300#endif
301301   /* Do we have RAM? If so, swap the bytes (undo the BIG_ENDIANIZE) */
302302   cart = &cartslots->cartridge[slotnumber];
303   
304//   clear_slot(cartsys, slotnumber);
305303
304//  clear_slot(cartsys, slotnumber);
305
306306   return INIT_PASS;
307307}
308308
r5931r5932
337337         break;
338338
339339      case AESCART_FCT_ASSM:
340         info->f = (genf *) assemble_std;
340         info->f = (genf *) assemble_std;
341341         break;
342342
343343      case AESCART_FCT_DISASSM:
344         info->f = (genf *) disassemble_std;
344         info->f = (genf *) disassemble_std;
345345         break;
346         
346
347347      /* --- the following bits of info are returned as NULL-terminated strings --- */
348348      case DEVINFO_STR_NAME:
349349         strcpy(info->s, "AES standard cartridge pcb");
r5931r5932
387387}
388388
389389/*****************************************************************************
390  The cartridge handling of the multi-cartridge system.
390  The cartridge handling of the multi-cartridge system.
391391  Every cartridge contains a PCB device. The memory handlers delegate the calls
392392  to the respective handlers of the cartridges.
393393******************************************************************************/
394394/*
395   Initialize a cartridge. Each cartridge contains a PCB device.
395    Initialize a cartridge. Each cartridge contains a PCB device.
396396*/
397397static DEVICE_START( aes_cartridge )
398398{
399399   cartslot_t *cart = device->token;
400400   astring *tempstring = astring_alloc();
401   
401
402402   /* find the PCB device */
403403   cart->pcb_device = devtag_get_device(
404404      device->machine,
r5931r5932
407407}
408408
409409/*
410   Load the cartridge image files. Apart from reading, we set pointers
411   to the image files so that during runtime we do not need search
412   operations.
410    Load the cartridge image files. Apart from reading, we set pointers
411    to the image files so that during runtime we do not need search
412    operations.
413413*/
414414static DEVICE_IMAGE_LOAD( aes_cartridge )
415{   
415{
416416   const device_config *pcbdev = cartslot_get_pcb(image);
417417   int result;
418   
418
419419   if (pcbdev != NULL)
420420   {
421421      /* If we are here, we have a multicart. */
422422      aes_pcb_t *pcb = (aes_pcb_t *)pcbdev->token;
423423      cartslot_t *cart = (cartslot_t *)image->token;
424     
424
425425      /* try opening this as a multicart */
426426      /* This line requires that cartslot_t be included in cartslot.h,
427      otherwise one cannot make use of multicart handling within such a
428      custom LOAD function. */
427        otherwise one cannot make use of multicart handling within such a
428        custom LOAD function. */
429429      multicart_open_error me = multicart_open(image_filename(image), image->machine->gamedrv->name, MULTICART_FLAGS_LOAD_RESOURCES, &cart->mc);
430     
430
431431      /* Now that we have loaded the image files, let the PCB put them all
432      together. This means we put the images in a structure which allows
433      for a quick access by the memory handlers. Every PCB defines an
434      own assembly method. */
432        together. This means we put the images in a structure which allows
433        for a quick access by the memory handlers. Every PCB defines an
434        own assembly method. */
435435      if (me == MCERR_NONE)
436436         result = pcb->assemble(pcbdev->machine, image);
437      else
437      else
438438         fatalerror("Error loading multicart: %s\n", mc_error_text(me));
439439   }
440440   else
r5931r5932
445445}
446446
447447/*
448   This is called when the cartridge is unplugged (or the emulator is
449   stopped).
448    This is called when the cartridge is unplugged (or the emulator is
449    stopped).
450450*/
451451static DEVICE_IMAGE_UNLOAD( aes_cartridge )
452{   
452{
453453   const device_config *pcbdev;
454454
455455   if (image->token == NULL)
456456   {
457      /* This means something went wrong during the pcb
458         identification (e.g. one of the cartridge files was not
459         found). We do not need to (and cannot) unload
460         the cartridge. */
457      /* This means something went wrong during the pcb
458           identification (e.g. one of the cartridge files was not
459           found). We do not need to (and cannot) unload
460           the cartridge. */
461461      return;
462462   }
463463   pcbdev = cartslot_get_pcb(image);
r5931r5932
466466   {
467467      aes_pcb_t *pcb = (aes_pcb_t *)pcbdev->token;
468468      cartslot_t *cart = (cartslot_t *)image->token;
469     
470      //   printf("unload\n");
469
470      //  printf("unload\n");
471471      if (cart->mc != NULL)
472472      {
473473         /* Remove pointers and de-big-endianize RAM contents. */
474         pcb->disassemble(pcbdev->machine, image);
475         
476         /* Close the multicart; all RAM resources will be
477            written to disk */
474         pcb->disassemble(pcbdev->machine, image);
475
476         /* Close the multicart; all RAM resources will be
477               written to disk */
478478         multicart_close(cart->mc);
479479         cart->mc = NULL;
480480      }
481//      else
482//         fatalerror("Lost pointer to multicart in cartridge. Report bug.\n");
481//      else
482//          fatalerror("Lost pointer to multicart in cartridge. Report bug.\n");
483483   }
484484}
485485
486486/*****************************************************************************
487  The overall multi-cartridge slot system. It contains instances of
487  The overall multi-cartridge slot system. It contains instances of
488488  cartridges which contain PCB devices. The memory handlers delegate the calls
489489  to the respective handlers of the cartridges.
490 
490
491491  Note that the term "multi-cartridge system" and "multicart" are not the same:
492492  A "multicart" may contain multiple resources, organized on a PCB. The multi-
493493  cart system may thus host multiple multicarts.
494 
494
495495  Actually, the name of the device should be changed (however, the device name
496496  length is limited)
497497******************************************************************************/
498498/*
499   Instantiation of a multicart system for the Neo Geo AES.
499    Instantiation of a multicart system for the Neo Geo AES.
500500*/
501501static DEVICE_START(aes_multicart)
502502{
503503   int i;
504//   printf("DEVICE_START(aes_multicart)\n");
504//  printf("DEVICE_START(aes_multicart)\n");
505505   aes_multicart_t *cartslots = (aes_multicart_t *)device->token;
506506
507507   /* Save this in the shortcut; we don't want to look for it each time
508      that we have a memory access. And currently we do not plan for
509      multiple multicart instances. */
508       that we have a memory access. And currently we do not plan for
509       multiple multicart instances. */
510510   cartslots->active_slot = 0;
511511   cartslots->next_free_slot = 0;
512   
512
513513   for (i=0; i < AES_NUMBER_OF_CARTRIDGE_SLOTS; i++)
514514   {
515515      cartslots->cartridge[i].pcb = NULL;
516516   }
517517
518518   cartslots->multi_slots = 0;
519   
520   /* The cartslot system is initialized now. The cartridges themselves
521      need to check whether their parts are available. */
519
520   /* The cartslot system is initialized now. The cartridges themselves
521       need to check whether their parts are available. */
522522}
523523
524524static DEVICE_STOP(aes_multicart)
525525{
526//   printf("DEVICE_STOP(aes_multicart)\n");
526//  printf("DEVICE_STOP(aes_multicart)\n");
527527}
528528
529529static MACHINE_DRIVER_START(aes_multicart)
r5931r5932
531531   MDRV_CARTSLOT_EXTENSION_LIST("rpk,bin")
532532   MDRV_CARTSLOT_PCBTYPE(0, "none", AES_CARTRIDGE_PCB_NONE)
533533   MDRV_CARTSLOT_PCBTYPE(1, "standard", AES_CARTRIDGE_PCB_STD)
534   
534
535535   MDRV_CARTSLOT_START(aes_cartridge)
536536   MDRV_CARTSLOT_LOAD(aes_cartridge)
537537   MDRV_CARTSLOT_UNLOAD(aes_cartridge)
r5931r5932
558558      case DEVINFO_INT_CLASS:
559559         info->i = DEVICE_CLASS_PERIPHERAL;
560560         break;
561         
561
562562      case DEVINFO_STR_FAMILY:
563563         strcpy(info->s, "Cartridge slot");
564564         break;
src/mess/devices/printer.c
r5931r5932
11/****************************************************************************
22
3   printer.c
3    printer.c
44
5   Code for handling printer devices
5    Code for handling printer devices
66
77****************************************************************************/
88
r5931r5932
1616***************************************************************************/
1717
1818/*-------------------------------------------------
19   printer_is_ready - checks to see if a printer
20   is ready
19    printer_is_ready - checks to see if a printer
20    is ready
2121-------------------------------------------------*/
2222
2323int printer_is_ready(const device_config *printer)
src/mess/devices/coco_vhd.c
r5931r5932
11/***************************************************************************
22
3   coco_vhd.c
3    coco_vhd.c
44
5   Color Computer Virtual Hard Drives
5    Color Computer Virtual Hard Drives
66
77****************************************************************************
88
9   Technical specs on the Virtual Hard Disk interface
9    Technical specs on the Virtual Hard Disk interface
1010
11   Address       Description
12   -------       -----------
13   FF80          Logical record number (high byte)
14   FF81          Logical record number (middle byte)
15   FF82          Logical record number (low byte)
16   FF83          Command/status register
17   FF84          Buffer address (high byte)
18   FF85          Buffer address (low byte)
11    Address       Description
12    -------       -----------
13    FF80          Logical record number (high byte)
14    FF81          Logical record number (middle byte)
15    FF82          Logical record number (low byte)
16    FF83          Command/status register
17    FF84          Buffer address (high byte)
18    FF85          Buffer address (low byte)
1919
20   Set the other registers, and then issue a command to FF83 as follows:
20    Set the other registers, and then issue a command to FF83 as follows:
2121
22    0 = read 256-byte sector at LRN
23    1 = write 256-byte sector at LRN
24    2 = flush write cache (Closes and then opens the image file)
22     0 = read 256-byte sector at LRN
23     1 = write 256-byte sector at LRN
24     2 = flush write cache (Closes and then opens the image file)
2525
26   Error values:
26    Error values:
2727
28    0 = no error
29   -1 = power-on state (before the first command is recieved)
30   -2 = invalid command
31    2 = VHD image does not exist
32    4 = Unable to open VHD image file
33    5 = access denied (may not be able to write to VHD image)
28     0 = no error
29    -1 = power-on state (before the first command is recieved)
30    -2 = invalid command
31     2 = VHD image does not exist
32     4 = Unable to open VHD image file
33     5 = access denied (may not be able to write to VHD image)
3434
35   IMPORTANT: The I/O buffer must NOT cross an 8K MMU bank boundary.
35    IMPORTANT: The I/O buffer must NOT cross an 8K MMU bank boundary.
3636
3737 ***************************************************************************/
3838
src/mess/devices/appldriv.h
r5931r5932
11/*********************************************************************
22
3   appldriv.h
3    appldriv.h
44
5   Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
5    Apple 5.25" floppy drive emulation (to be interfaced with applefdc.c)
66
77*********************************************************************/
88
r5931r5932
5757   MDRV_FLOPPY_APPLE_PARAMS(_dividend,_divisor) \
5858   MDRV_DEVICE_ADD(FLOPPY_3, FLOPPY_APPLE, 0)      \
5959   MDRV_DEVICE_CONFIG(_config)   \
60   MDRV_FLOPPY_APPLE_PARAMS(_dividend,_divisor)
60   MDRV_FLOPPY_APPLE_PARAMS(_dividend,_divisor)
6161
6262#define MDRV_FLOPPY_APPLE_2_DRIVES_REMOVE()    \
6363   MDRV_DEVICE_REMOVE(FLOPPY_0)      \
64   MDRV_DEVICE_REMOVE(FLOPPY_1)     
64   MDRV_DEVICE_REMOVE(FLOPPY_1)
6565
6666#endif /* APPLDRIV_H */
src/mess/devices/aescart.h
r5931r5932
11/*********************************************************************
22
3   aescart.h
3    aescart.h
44
5   AES cartridge management
5    AES cartridge management
66
77*********************************************************************/
88
src/mess/devices/bitbngr.c
r5931r5932
11/*********************************************************************
22
3   bitbngr.c
3    bitbngr.c
44
5   TRS style "bitbanger" serial port
5    TRS style "bitbanger" serial port
66
77*********************************************************************/
88
r5931r5932
186186
187187/*-------------------------------------------------
188188    bitbanger_output - outputs data to a bitbanger
189   port
189    port
190190-------------------------------------------------*/
191191
192192void bitbanger_output(const device_config *device, int value)
r5931r5932
225225
226226/*-------------------------------------------------
227227    DEVICE_GET_INFO(bitbanger) - device getinfo
228   function
228    function
229229-------------------------------------------------*/
230230
231231DEVICE_GET_INFO(bitbanger)
src/mess/devices/printer.h
r5931r5932
11/****************************************************************************
22
3   printer.h
3    printer.h
44
5   Code for handling printer devices
5    Code for handling printer devices
66
77****************************************************************************/
88
src/mess/devices/thomflop.c
r5931r5932
271271static READ8_HANDLER ( to7_5p14_r )
272272{
273273   const device_config *fdc = devtag_get_device(space->machine, "wd2793");
274   
274
275275   if ( offset < 4 )
276276      return wd17xx_r( fdc, offset );
277277   else if ( offset == 8 )
r5931r5932
14611461      }
14621462
14631463      /* in real life, to keep the motor running, it is sufficient to
1464         set motor to 1 every few seconds.
1465         instead of counting, we assume the motor is always running...
1466      */
1464           set motor to 1 every few seconds.
1465           instead of counting, we assume the motor is always running...
1466        */
14671467      floppy_drive_set_motor_state( img, 1 /* motor */ );
14681468   }
14691469   break;
src/mess/devices/coco_vhd.h
r5931r5932
11/***************************************************************************
22
3   coco_vhd.h
3    coco_vhd.h
44
5   Color Computer Virtual Hard Drives
5    Color Computer Virtual Hard Drives
66
77***************************************************************************/
88
r5931r5932
2020
2121#define MDRV_COCO_VHD_ADD(_tag) \
2222   MDRV_DEVICE_ADD(_tag, COCO_VHD, 0) \
23   
23
2424#endif /* COCOVHD_H */
src/mess/devices/multcart.c
r5931r5932
11/*********************************************************************
22
3   multcart.c
3    multcart.c
44
5   Multi-cartridge handling code
5    Multi-cartridge handling code
66
77*********************************************************************/
88
r5931r5932
3838   multicart_socket *      sockets;
3939};
4040
41static const char multicart_error_text[14][30] =
41static const char multicart_error_text[14][30] =
4242{
4343   "no error",
4444   "not a multicart",
r5931r5932
9595      {
9696         return header;
9797      }
98   }       
98   }
9999   return NULL;
100100}
101101
r5931r5932
220220   const char *ram_filename;
221221
222222   astring *ram_pathname;
223   
223
224224   /* locate the 'length' attribute */
225225   length_string = xml_get_attribute_string(resource_node, "length", NULL);
226226   if (length_string == NULL)
227227      return MCERR_MISSING_RAM_LENGTH;
228   
228
229229   /* ...and parse it */
230230   resource->length = ram_parse_string(length_string);
231231   if (resource->length <= 0)
232232      return MCERR_INVALID_RAM_SPEC;
233   
233
234234   /* allocate bytes for this resource */
235235   resource->ptr = pool_malloc(state->multicart->data->pool, resource->length);
236236   if (resource->ptr == NULL)
237237      return MCERR_OUT_OF_MEMORY;
238   
238
239239   /* Is this a persistent RAM resource? Then try to load it. */
240240   ram_type = xml_get_attribute_string(resource_node, "type", NULL);
241241   if (ram_type != NULL)
r5931r5932
246246         ram_filename = xml_get_attribute_string(resource_node, "file", NULL);
247247         if (ram_filename==NULL)
248248            return MCERR_XML_ERROR;
249         
249
250250         ram_pathname = astring_assemble_3(astring_alloc(), state->multicart->gamedrv_name, PATH_SEPARATOR, ram_filename);
251         
252         /* Save the file name so that we can write the contents on unloading.
253            If the RAM resource has no filename, we know that it was volatile only. */
251
252         /* Save the file name so that we can write the contents on unloading.
253               If the RAM resource has no filename, we know that it was volatile only. */
254254         resource->filename = pool_strdup(state->multicart->data->pool, astring_c(ram_pathname));
255255         if (resource->filename == NULL)
256256            return MCERR_OUT_OF_MEMORY;
257         
257
258258         astring_free(ram_pathname);
259         
259
260260         image_battery_load_by_name(resource->filename, resource->ptr, resource->length);
261261      }
262      /* else this type is volatile, in which case we just have
263         a memory expansion */
262      /* else this type is volatile, in which case we just have
263            a memory expansion */
264264   }
265265   return MCERR_NONE;
266266}
r5931r5932
310310         break;
311311
312312      default:
313         return MCERR_UNKNOWN_RESOURCE_TYPE;
313         return MCERR_UNKNOWN_RESOURCE_TYPE;
314314   }
315315
316316   /* append the resource */
r5931r5932
348348}
349349
350350/*-------------------------------------------------
351    save_ram_resources. This is important for persistent RAM. All
351    save_ram_resources. This is important for persistent RAM. All
352352    resources were allocated within the memory pool of this device and will
353353    be freed on multicart_close.
354354-------------------------------------------------*/
r5931r5932
356356static multicart_open_error save_ram_resources(multicart *cart)
357357{
358358   const multicart_resource *resource;
359   
359
360360   for (resource = cart->resources; resource != NULL; resource = resource->next)
361361   {
362362      if ((resource->type == MULTICART_RESOURCE_TYPE_RAM) && (resource->filename != NULL))
r5931r5932
560560      err = MCERR_OUT_OF_MEMORY;
561561      goto done;
562562   }
563   
563
564564   /* do we have to load resources? */
565565   if (load_flags & MULTICART_FLAGS_LOAD_RESOURCES)
566566   {
src/mess/devices/snapquik.c
r5931r5932
11/*********************************************************************
22
3   snapquik.h
3    snapquik.h
44
5   Snapshots and quickloads
5    Snapshots and quickloads
66
77*********************************************************************/
88
r5931r5932
3131
3232/*-------------------------------------------------
3333    assert_is_snapshot_or_quickload - asserts/confirms
34   that a given device is a snapshot or quickload
34    that a given device is a snapshot or quickload
3535-------------------------------------------------*/
3636
3737INLINE void assert_is_snapshot_or_quickload(const device_config *device)
r5931r5932
131131
132132/*-------------------------------------------------
133133    DEVICE_GET_INFO(snapquick) - device getinfo
134   function
134    function
135135-------------------------------------------------*/
136136
137137static DEVICE_GET_INFO(snapquick)
r5931r5932
161161
162162/*-------------------------------------------------
163163    DEVICE_GET_INFO(snapshot) - device getinfo
164   function
164    function
165165-------------------------------------------------*/
166166
167167DEVICE_GET_INFO(snapshot)
r5931r5932
183183
184184/*-------------------------------------------------
185185    DEVICE_GET_INFO(quickload) - device getinfo
186   function
186    function
187187-------------------------------------------------*/
188188
189189DEVICE_GET_INFO(quickload)
src/mess/devices/bitbngr.h
r5931r5932
11/*********************************************************************
22
3   bitbngr.h
3    bitbngr.h
44
5   TRS style "bitbanger" serial port
5    TRS style "bitbanger" serial port
66
77*********************************************************************/
88
src/mess/devices/cococart.c
r5931r5932
11/*********************************************************************
22
3   cococart.c
3    cococart.c
44
5   CoCo/Dragon cartridge management
5    CoCo/Dragon cartridge management
66
77*********************************************************************/
88
r5931r5932
8383{
8484   const device_config *cartslot;
8585   coco_cartridge_t *cococart = get_token(device);
86   const cococart_config *config = (const cococart_config *) device->inline_config;
86   const cococart_config *config = (const cococart_config *) device->inline_config;
8787   astring *tempstring = astring_alloc();
8888
8989   /* initialize */
r5931r5932
187187
188188      if (LOG_LINE)
189189         logerror("[%s]: set_line(): %s <= %s", cpuexec_describe_context(device->machine), line_name, line_value_string(value));
190     
190
191191      /* engage in a bit of gymnastics for this odious 'Q' value */
192192      switch(line->value)
193193      {
r5931r5932
249249
250250
251251/*-------------------------------------------------
252   set_line_timer()
252    set_line_timer()
253253-------------------------------------------------*/
254254
255255static void set_line_timer(const device_config *device, coco_cartridge_line *line, cococart_line_value value)
r5931r5932
279279
280280/*-------------------------------------------------
281281    coco_cartridge_twiddle_q_lines - hack to
282   support twiddling the Q line
282    support twiddling the Q line
283283-------------------------------------------------*/
284284
285285void coco_cartridge_twiddle_q_lines(const device_config *device)
r5931r5932
357357   MDRV_CARTSLOT_PCBTYPE(1, "banked_16k",   COCO_CARTRIDGE_PCB_PAK_BANKED16K)
358358   MDRV_CARTSLOT_PCBTYPE(2, "orch90",      COCO_CARTRIDGE_PCB_ORCH90)
359359   MDRV_CARTSLOT_PCBTYPE(3, "rs232",      COCO_CARTRIDGE_PCB_RS232)
360   //MDRV_CARTSLOT_PCBTYPE(4, "coco_ssc",   COCO_CARTRIDGE_PCB_SSC)
360   //MDRV_CARTSLOT_PCBTYPE(4, "coco_ssc",  COCO_CARTRIDGE_PCB_SSC)
361361   MDRV_CARTSLOT_PCBTYPE(4, "",         COCO_CARTRIDGE_PCB_PAK)
362362MACHINE_DRIVER_END
363363
src/mess/formats/adam_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/adam_dsk.c
3    formats/adam_dsk.c
44
5   Coleco Adam disk images
5    Coleco Adam disk images
66
77*********************************************************************/
88
src/mess/formats/d88_dsk.c
r5931r5932
11/*
22 *   D77 and D88 disk images
3 *
4 *
3 *
4 *
55 *   Header (total size = 0x2b0 bytes):
66 *     0x00 - Disk label
77 *     0x1a - Write protect (bit 3)
r5931r5932
1111 *
1212 *   Sectors (0x110 bytes each, typically)
1313 *     0x00 - Sector info
14 *          byte 0 - track number
15 *          byte 1 - side (0 or 1)
16 *          byte 2 - sector number
14 *          byte 0 - track number
15 *          byte 1 - side (0 or 1)
16 *          byte 2 - sector number
1717 *     0x10 - sector data
18 *
18 *
1919 *   Images can be concatenated together.
2020 *   Sectors can be in any order.
2121 *   Tracks are in the order:
22 *          Track 0 side 0
23 *          Track 0 side 1
24 *          Track 1 side 0
25 *          ...
26 *
27 *
22 *          Track 0 side 0
23 *          Track 0 side 1
24 *          Track 1 side 0
25 *          ...
26 *
27 *
2828 */
2929
3030#include "driver.h"
r5931r5932
5252   UINT32 offset;
5353   UINT8 sector_hdr[16];
5454   int x;
55   
56   offset = tag->trackoffset[(track*2)+head];
5755
56   offset = tag->trackoffset[(track*2)+head];
57
5858   if(offset == 0)
5959      return 0;
6060
r5931r5932
6969      floppy_image_read(floppy,sector_hdr,offset,16);
7070      x++;
7171   }
72   
72
7373   return sector_hdr[2];
7474}
7575
r5931r5932
8888   struct d88_tag* tag = get_d88_tag(floppy);
8989   UINT32 offset;
9090   UINT8 sector_hdr[16];
91   
91
9292   offset = tag->trackoffset[(track*2)+head];
9393
9494   floppy_image_read(floppy,sector_hdr,offset,16);
95   
95
9696   return sector_hdr[4];
9797}
98   
98
9999static floperr_t d88_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
100100{
101101   struct d88_tag* tag = get_d88_tag(floppy);
r5931r5932
103103   UINT8 sector_hdr[16];
104104   UINT32 len;
105105   int count,secs;
106   
106
107107   offset = tag->trackoffset[(track*2)+head];
108   
108
109109   floppy_image_read(floppy,sector_hdr,offset,16);
110110   secs = sector_hdr[4];
111   
111
112112   for(count=0;count<secs;count++)
113113   {
114114      floppy_image_read(floppy,sector_hdr,offset,16);
r5931r5932
128128
129129static floperr_t d88_read_track(floppy_image *floppy, int head, int track, UINT64 offset, void *buffer, size_t buflen)
130130{
131//   floperr_t err;
132   
131//  floperr_t err;
132
133133   return FLOPPY_ERROR_UNSUPPORTED;
134134}
135135
r5931r5932
141141   UINT32 len;
142142   UINT32 secs;
143143   int count;
144   
144
145145   // get offset of the beginning of the track
146146   offset = tag->trackoffset[(track*2)+head];
147147
148148   floppy_image_read(floppy,sector_hdr,offset,16);
149149   secs = sector_hdr[4];
150   
150
151151   for(count=0;count<secs;count++)
152152   {
153153      floppy_image_read(floppy,sector_hdr,offset,16);
r5931r5932
170170   UINT32 offset;
171171   UINT8 sector_hdr[16];
172172   int x;
173   
174   offset = tag->trackoffset[(track*2)+head];
175173
174   offset = tag->trackoffset[(track*2)+head];
175
176176   if(offset == 0)
177177      return FLOPPY_ERROR_SEEKERROR;
178   
179178
179
180180   floppy_image_read(floppy,sector_hdr,offset,16);
181181
182182   if(sector_index >= sector_hdr[4])
r5931r5932
191191      floppy_image_read(floppy,sector_hdr,offset,16);
192192      x++;
193193   }
194   
194
195195   if(offset > tag->image_size || offset == 0)
196196      return FLOPPY_ERROR_SEEKERROR;
197197
r5931r5932
205205      *sector = sector_hdr[2];
206206   if(flags)
207207      *flags = 0;
208   
208
209209   return FLOPPY_ERROR_SUCCESS;
210210}
211211
r5931r5932
213213{
214214   UINT64 offset;
215215   UINT32 sector_length;
216   
216
217217   offset = d88_get_sector_offset(floppy,head,track,sector);
218   
218
219219   if(d88_get_sector_length(floppy,head,track,sector,&sector_length) != FLOPPY_ERROR_SUCCESS)
220220      return FLOPPY_ERROR_SEEKERROR;
221     
221
222222   if(offset == 0)
223223      return FLOPPY_ERROR_SEEKERROR;
224     
224
225225   if(buflen > sector_length)
226226      return FLOPPY_ERROR_INTERNAL;
227   
227
228228   floppy_image_read(floppy,buffer,offset,sector_length);
229   
229
230230   return FLOPPY_ERROR_SUCCESS;
231231}
232232
233233static floperr_t d88_read_indexed_sector(floppy_image *floppy, int head, int track, int sector, void *buffer, size_t buffer_len)
234234{
235235   int sec;
236   
236
237237   sec = d88_get_sector_id(floppy,head,track,sector);
238238   return d88_read_sector(floppy,head,track,sec,buffer,buffer_len);
239239}
r5931r5932
242242{
243243   UINT8 header[D88_HEADER_LEN];
244244   int x,s;
245   
245
246246   floppy_image_read(floppy,header,0,D88_HEADER_LEN);
247247
248248   if(prot)
r5931r5932
275275FLOPPY_IDENTIFY(d88_dsk_identify)
276276{
277277   UINT32 size;
278   
279   d88_get_header(floppy,&size,NULL,NULL,NULL);   
280   
278
279   d88_get_header(floppy,&size,NULL,NULL,NULL);
280
281281   if(floppy_image_size(floppy) == size)
282282   {
283283      *vote = 100;
r5931r5932
298298   UINT8 prot,type = 0;
299299   UINT32 offs[164];
300300   int x;
301   
301
302302   if(params)
303303   {
304304      // create
r5931r5932
309309      // load
310310      d88_get_header(floppy,&size,&prot,&type,offs);
311311   }
312   
312
313313   tag = floppy_create_tag(floppy,"d88tag",sizeof(struct d88_tag));
314314   if (!tag)
315315      return FLOPPY_ERROR_OUTOFMEMORY;
316   
316
317317   tag->write_protect = prot;
318318   tag->disk_type = type;
319319   tag->image_size = size;
320320   for(x=0;x<164;x++)
321321      tag->trackoffset[x] = offs[x];
322     
322
323323   callbacks = floppy_callbacks(floppy);
324324   callbacks->read_track = d88_read_track;
325325   callbacks->get_heads_per_disk = d88_get_heads_per_disk;
r5931r5932
329329   callbacks->read_indexed_sector = d88_read_indexed_sector;
330330   callbacks->get_indexed_sector_info = d88_get_indexed_sector_info;
331331   callbacks->get_sectors_per_track = d88_get_sectors_per_track;
332   
333     
332
333
334334   return FLOPPY_ERROR_SUCCESS;
335335}
src/mess/formats/uef_cas.c
r5931r5932
2525static const UINT8 UEF_HEADER[10] = { 0x55, 0x45, 0x46, 0x20, 0x46, 0x69, 0x6c, 0x65, 0x21, 0x00 };
2626
2727/*
28   bytes are stored as
29   start bit   1 * 0
30   data bits   8 * X
31   stop bit   1 * 1
28    bytes are stored as
29    start bit   1 * 0
30    data bits   8 * X
31    stop bit    1 * 1
3232*/
3333
3434/* gzip flag byte */
r5931r5932
8181      int Exponent;
8282
8383      /* assume a four byte array named Float exists, where Float[0]
84      was the first byte read from the UEF, Float[1] the second, etc */
84        was the first byte read from the UEF, Float[1] the second, etc */
8585
8686      /* decode mantissa */
8787      Mantissa = Float[0] | (Float[1] << 8) | ((Float[2]&0x7f)|0x80) << 16;
src/mess/formats/ami_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/ami_dsk.c
3    formats/ami_dsk.c
44
5   Amiga disk images
5    Amiga disk images
66
77*********************************************************************/
88
r5931r5932
2323{
2424   UINT64 size;
2525   UINT8 header[4];
26   
26
2727   *vote = 100;
2828
2929   /* get first 4 bytes */
r5931r5932
4242   if (header[3] > 5)
4343      *vote = 0;
4444
45   return FLOPPY_ERROR_SUCCESS;   
45   return FLOPPY_ERROR_SUCCESS;
4646}
4747
4848
r5931r5932
5656   geometry.tracks = 80;
5757   geometry.first_sector_id = 0;
5858   geometry.sector_length = 512;
59   
59
6060   if (params)
6161   {
6262      /* create */
r5931r5932
6868      UINT64 size = floppy_image_size(floppy);
6969      geometry.sectors = size/512/80/2;
7070      if (geometry.sectors != 11 && geometry.sectors != 22)
71         return FLOPPY_ERROR_INVALIDIMAGE;     
71         return FLOPPY_ERROR_INVALIDIMAGE;
7272   }
73   
73
7474   return basicdsk_construct(floppy, &geometry);
7575}
7676
src/mess/formats/adam_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/adam_dsk.h
3    formats/adam_dsk.h
44
5   Coleco Adam disk images
5    Coleco Adam disk images
66
77*********************************************************************/
88
src/mess/formats/fmsx_cas.h
r5931r5932
11/*********************************************************************
22
3   fmsx_cas.h
3    fmsx_cas.h
44
5   Format code for MSX casette files
5    Format code for MSX casette files
66
77*********************************************************************/
88
src/mess/formats/uef_cas.h
r5931r5932
11/*
2   uef_cas.h
2    uef_cas.h
33
4   Format code for uef cassette files
4    Format code for uef cassette files
55*/
66
77#ifndef UEF_CAS_H
src/mess/formats/dim_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/dim_dsk.c
3    formats/dim_dsk.c
44
5   DIM disk images
5    DIM disk images
66
77*********************************************************************/
88
r5931r5932
3030   UINT8 format_tmp;
3131   int x;
3232   UINT16 temp;
33   
33
3434   if(params)
3535   {
3636      // create
r5931r5932
8282   // TODO: expand on this basic implementation
8383
8484   logerror("FDD: DIM image loaded - type %i, %i tracks, %i sectors per track, %i bytes per sector\n", format_tmp,tracks, sectors,sectorlen);
85   
85
8686   memset(&geometry, 0, sizeof(geometry));
8787   geometry.heads = heads;
8888   geometry.first_sector_id = firstsector;
r5931r5932
9090   geometry.tracks = tracks+1;
9191   geometry.sectors = sectors;
9292   geometry.offset = 0x100;
93   return basicdsk_construct(floppy, &geometry);   
93   return basicdsk_construct(floppy, &geometry);
9494}
9595
src/mess/formats/tzx_cas.c
r5931r5932
55TODO:
66    Add support for the remaining block types:
77        case 0x15:  Direct Recording
8      case 0x18:  CSW Recording
9      case 0x19:  Generalized Data Block
8        case 0x18:  CSW Recording
9        case 0x19:  Generalized Data Block
1010        case 0x21:  Group Start
1111        case 0x22:  Group End
1212        case 0x23:  Jump To Block
r5931r5932
1616        case 0x27:  Return From Sequence
1717        case 0x28:  Select Block
1818        case 0x2A:  Stop Tape if in 48K Mode
19      case 0x2B:  Set signal level
19        case 0x2B:  Set signal level
2020        case 0x5A:  Merge Block
2121    Add support for the deprecated block types? Only if there is some image which need them:
2222        case 0x16:  C64 ROM type data block
r5931r5932
6565static UINT8**   blocks;
6666static float t_scale = 1;  /* for scaling T-states to the 4MHz CPC */
6767
68static void toggle_wave_data(void)
68static void toggle_wave_data(void)
6969{
70   if (wave_data == WAVE_LOW)
70   if (wave_data == WAVE_LOW)
7171   {
7272      wave_data = WAVE_HIGH;
73   }
74   else
73   }
74   else
7575   {
7676      wave_data = WAVE_LOW;
7777   }
7878}
7979
80static void tzx_cas_get_blocks( const UINT8 *casdata, int caslen )
80static void tzx_cas_get_blocks( const UINT8 *casdata, int caslen )
8181{
8282   int pos = sizeof(TZX_HEADER) + 2;
8383   int max_block_count = INITIAL_MAX_BLOCK_COUNT;
r5931r5932
8585   blocks = alloc_array_clear_or_die(UINT8*, max_block_count);
8686   block_count = 0;
8787
88   while (pos < caslen)
88   while (pos < caslen)
8989   {
9090      UINT32 datasize;
9191      UINT8 blocktype = casdata[pos];
9292
93      if (block_count == max_block_count)
93      if (block_count == max_block_count)
9494      {
9595         void   *old_blocks = blocks;
9696         int   old_max_block_count = max_block_count;
r5931r5932
104104
105105      pos += 1;
106106
107      switch (blocktype)
107      switch (blocktype)
108108      {
109109      case 0x10:
110110         pos += 2;
r5931r5932
186186   free(blocks);
187187}
188188
189INLINE int millisec_to_samplecount( int millisec )
189INLINE int millisec_to_samplecount( int millisec )
190190{
191191   return (int) (millisec * ((double)TZX_WAV_FREQUENCY / 1000.0));
192192}
193193
194INLINE int tcycles_to_samplecount( int tcycles )
194INLINE int tcycles_to_samplecount( int tcycles )
195195{
196196   return (int) ((0.5 + (((double)TZX_WAV_FREQUENCY / 3500000) * (double)tcycles)) * t_scale);
197197}
198198
199static void tzx_output_wave( INT16 **buffer, int length )
199static void tzx_output_wave( INT16 **buffer, int length )
200200{
201   if (buffer == NULL)
201   if (buffer == NULL)
202202   {
203203      return;
204204   }
r5931r5932
210210   }
211211}
212212
213static int tzx_cas_handle_block( INT16 **buffer, const UINT8 *bytes, int pause, int data_size, int pilot, int pilot_length, int sync1, int sync2, int bit0, int bit1, int bits_in_last_byte )
213static int tzx_cas_handle_block( INT16 **buffer, const UINT8 *bytes, int pause, int data_size, int pilot, int pilot_length, int sync1, int sync2, int bit0, int bit1, int bits_in_last_byte )
214214{
215215   int pilot_samples = tcycles_to_samplecount(pilot);
216216   int sync1_samples = tcycles_to_samplecount(sync1);
r5931r5932
221221   int size = 0;
222222
223223   /* Uncomment this to include into error.log a fully detailed analysis of each block */
224//   logerror("tzx_cas_block_size: pilot_length = %d, pilot_samples = %d, sync1_samples = %d, sync2_samples = %d, bit0_samples = %d, bit1_samples = %d\n", pilot_length, pilot_samples, sync1_samples, sync2_samples, bit0_samples, bit1_samples);
224//  logerror("tzx_cas_block_size: pilot_length = %d, pilot_samples = %d, sync1_samples = %d, sync2_samples = %d, bit0_samples = %d, bit1_samples = %d\n", pilot_length, pilot_samples, sync1_samples, sync2_samples, bit0_samples, bit1_samples);
225225
226226   /* PILOT */
227   for ( ; pilot_length > 0; pilot_length--)
227   for ( ; pilot_length > 0; pilot_length--)
228228   {
229229      tzx_output_wave(buffer, pilot_samples);
230230      size += pilot_samples;
231231      toggle_wave_data();
232232   }
233233   /* SYNC1 */
234   if (sync1_samples > 0)
234   if (sync1_samples > 0)
235235   {
236236      tzx_output_wave(buffer, sync1_samples);
237237      size += sync1_samples;
238238      toggle_wave_data();
239239   }
240240   /* SYNC2 */
241   if (sync2_samples > 0)
241   if (sync2_samples > 0)
242242   {
243243      tzx_output_wave(buffer, sync2_samples);
244244      size += sync2_samples;
245245      toggle_wave_data();
246246   }
247247   /* data */
248   for (data_index = 0; data_index < data_size; data_index++)
248   for (data_index = 0; data_index < data_size; data_index++)
249249   {
250250      UINT8 byte = bytes[data_index];
251251      int   bits_to_go = (data_index == (data_size - 1)) ? bits_in_last_byte : 8;
252252
253      for ( ; bits_to_go > 0; byte <<= 1, bits_to_go--)
253      for ( ; bits_to_go > 0; byte <<= 1, bits_to_go--)
254254      {
255255         int   bit_samples = (byte & 0x80) ? bit1_samples : bit0_samples;
256256         tzx_output_wave(buffer, bit_samples);
r5931r5932
262262      }
263263   }
264264   /* pause */
265   if (pause > 0)
265   if (pause > 0)
266266   {
267267      int start_pause_samples = millisec_to_samplecount(1);
268268      int rest_pause_samples = millisec_to_samplecount(pause - 1);
r5931r5932
306306
307307/*  Will go through blocks and calculate number of samples needed.
308308If buffer is not NULL the sample data will also be written. */
309static int tzx_cas_do_work( INT16 **buffer )
309static int tzx_cas_do_work( INT16 **buffer )
310310{
311311   int   current_block = 0;
312312   int   size = 0;
r5931r5932
323323      UINT8 block_type = cur_block[0];
324324
325325   /* Uncomment this to include into error.log a list of the types each block */
326//      logerror("tzx_cas_fill_wave: block %d, block_type %02x\n", current_block, block_type);
326//      logerror("tzx_cas_fill_wave: block %d, block_type %02x\n", current_block, block_type);
327327
328328      switch (block_type)
329329      {
r5931r5932
354354         current_block++;
355355         break;
356356      case 0x13:   /* Sequence of Pulses of Different Lengths */
357         for (data_size = 0; data_size < cur_block[1]; data_size++)
357         for (data_size = 0; data_size < cur_block[1]; data_size++)
358358         {
359359            pilot = cur_block[2 + 2 * data_size] + (cur_block[3 + 2 * data_size] << 8);
360360            size += tzx_cas_handle_block(buffer, cur_block, 0, 0, pilot, 1, 0, 0, 0, 0, 0);
r5931r5932
372372         break;
373373      case 0x20:   /* Pause (Silence) or 'Stop the Tape' Command */
374374         pause_time = cur_block[1] + (cur_block[2] << 8);
375         if (pause_time == 0)
375         if (pause_time == 0)
376376         {
377            /* pause = 0 is used to let an emulator automagically stop the tape
378               in MESS we do not do that, so we insert a 5 second pause. */
377            /* pause = 0 is used to let an emulator automagically stop the tape
378                   in MESS we do not do that, so we insert a 5 second pause. */
379379            pause_time = 5000;
380380         }
381381         size += tzx_cas_handle_block(buffer, cur_block, pause_time, 0, 0, 0, 0, 0, 0, 0, 0);
r5931r5932
480480   return size;
481481}
482482
483static int tzx_cas_to_wav_size( const UINT8 *casdata, int caslen )
483static int tzx_cas_to_wav_size( const UINT8 *casdata, int caslen )
484484{
485485   int size = 0;
486486
487487   /* Header size plus major and minor version number */
488   if (caslen < 10)
488   if (caslen < 10)
489489   {
490490      logerror("tzx_cas_to_wav_size: cassette image too small\n");
491491      goto cleanup;
492492   }
493493
494494   /* Check for correct header */
495   if (memcmp(casdata, TZX_HEADER, sizeof(TZX_HEADER)))
495   if (memcmp(casdata, TZX_HEADER, sizeof(TZX_HEADER)))
496496   {
497497      logerror("tzx_cas_to_wav_size: cassette image has incompatible header\n");
498498      goto cleanup;
499499   }
500500
501501   /* Check major version number in header */
502   if (casdata[0x08] > SUPPORTED_VERSION_MAJOR)
502   if (casdata[0x08] > SUPPORTED_VERSION_MAJOR)
503503   {
504504      logerror("tzx_cas_to_wav_size: unsupported version\n");
505505      goto cleanup;
r5931r5932
509509
510510   logerror("tzx_cas_to_wav_size: %d blocks found\n", block_count);
511511
512   if (block_count == 0)
512   if (block_count == 0)
513513   {
514514      logerror("tzx_cas_to_wav_size: no blocks found!\n");
515515      goto cleanup;
r5931r5932
523523   return -1;
524524}
525525
526static int tzx_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
526static int tzx_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
527527{
528528   INT16 *p = buffer;
529529   int   size = 0;
r5931r5932
532532   return size;
533533}
534534
535static int cdt_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
535static int cdt_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
536536{
537537   INT16 *p = buffer;
538538   int   size = 0;
r5931r5932
541541   return size;
542542}
543543
544static int tap_cas_to_wav_size( const UINT8 *casdata, int caslen )
544static int tap_cas_to_wav_size( const UINT8 *casdata, int caslen )
545545{
546546   int size = 0;
547547   const UINT8 *p = casdata;
548548
549   while (p < casdata + caslen)
549   while (p < casdata + caslen)
550550   {
551551      int data_size = p[0] + (p[1] << 8);
552552      int pilot_length = (p[2] == 0x00) ? 8064 : 3220;   /* TZX specification */
553//      int pilot_length = (p[2] == 0x00) ? 8063 : 3223;   /* worldofspectrum */
553//      int pilot_length = (p[2] == 0x00) ? 8063 : 3223;    /* worldofspectrum */
554554      logerror("tap_cas_to_wav_size: Handling TAP block containing 0x%X bytes", data_size);
555555      p += 2;
556556      size += tzx_cas_handle_block(NULL, p, 1000, data_size, 2168, pilot_length, 667, 735, 855, 1710, 8);
r5931r5932
560560   return size;
561561}
562562
563static int tap_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
563static int tap_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
564564{
565565   INT16 *p = buffer;
566566   int size = 0;
567567
568   while (size < length)
568   while (size < length)
569569   {
570570      int data_size = bytes[0] + (bytes[1] << 8);
571571      int pilot_length = (bytes[2] == 0x00) ? 8064 : 3220;   /* TZX specification */
572//      int pilot_length = (bytes[2] == 0x00) ? 8063 : 3223;   /* worldofspectrum */
572//      int pilot_length = (bytes[2] == 0x00) ? 8063 : 3223;    /* worldofspectrum */
573573      logerror("tap_cas_fill_wave: Handling TAP block containing 0x%X bytes\n", data_size);
574574      bytes += 2;
575575      size += tzx_cas_handle_block(&p, bytes, 1000, data_size, 2168, pilot_length, 667, 735, 855, 1710, 8);
r5931r5932
578578   return size;
579579}
580580
581static const struct CassetteLegacyWaveFiller tzx_legacy_fill_wave =
581static const struct CassetteLegacyWaveFiller tzx_legacy_fill_wave =
582582{
583583   tzx_cas_fill_wave,         /* fill_wave */
584584   -1,               /* chunk_size */
r5931r5932
589589   0               /* trailer_samples */
590590};
591591
592static const struct CassetteLegacyWaveFiller tap_legacy_fill_wave =
592static const struct CassetteLegacyWaveFiller tap_legacy_fill_wave =
593593{
594594   tap_cas_fill_wave,         /* fill_wave */
595595   -1,               /* chunk_size */
r5931r5932
600600   0               /* trailer_samples */
601601};
602602
603static const struct CassetteLegacyWaveFiller cdt_legacy_fill_wave =
603static const struct CassetteLegacyWaveFiller cdt_legacy_fill_wave =
604604{
605605   cdt_cas_fill_wave,         /* fill_wave */
606606   -1,               /* chunk_size */
r5931r5932
611611   0               /* trailer_samples */
612612};
613613
614static casserr_t tzx_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
614static casserr_t tzx_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
615615{
616616   return cassette_legacy_identify(cassette, opts, &tzx_legacy_fill_wave);
617617}
618618
619static casserr_t tap_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
619static casserr_t tap_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
620620{
621621   return cassette_legacy_identify(cassette, opts, &tap_legacy_fill_wave);
622622}
623623
624static casserr_t cdt_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
624static casserr_t cdt_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
625625{
626626   return cassette_legacy_identify(cassette, opts, &cdt_legacy_fill_wave);
627627}
628628
629static casserr_t tzx_cassette_load( cassette_image *cassette )
629static casserr_t tzx_cassette_load( cassette_image *cassette )
630630{
631631   return cassette_legacy_construct(cassette, &tzx_legacy_fill_wave);
632632}
633633
634static casserr_t tap_cassette_load( cassette_image *cassette )
634static casserr_t tap_cassette_load( cassette_image *cassette )
635635{
636636   return cassette_legacy_construct(cassette, &tap_legacy_fill_wave);
637637}
638638
639static casserr_t cdt_cassette_load( cassette_image *cassette )
639static casserr_t cdt_cassette_load( cassette_image *cassette )
640640{
641641   return cassette_legacy_construct(cassette, &cdt_legacy_fill_wave);
642642}
643643
644static const struct CassetteFormat tzx_cassette_format =
644static const struct CassetteFormat tzx_cassette_format =
645645{
646646   "tzx",
647647   tzx_cassette_identify,
r5931r5932
649649   NULL
650650};
651651
652static const struct CassetteFormat tap_cassette_format =
652static const struct CassetteFormat tap_cassette_format =
653653{
654654   "tap",
655655   tap_cassette_identify,
r5931r5932
657657   NULL
658658};
659659
660static const struct CassetteFormat cdt_cassette_format =
660static const struct CassetteFormat cdt_cassette_format =
661661{
662662   "cdt",
663663   cdt_cassette_identify,
src/mess/formats/ami_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/ami_dsk.h
3    formats/ami_dsk.h
44
5   Amiga disk images
5    Amiga disk images
66
77*********************************************************************/
88
src/mess/formats/ioprocs.c
r5931r5932
55
66
77/*********************************************************************
8   ioprocs implementation on stdio
8    ioprocs implementation on stdio
99*********************************************************************/
1010
1111static void stdio_closeproc(void *file)
r5931r5932
6161
6262
6363/*********************************************************************
64   calls for accessing generic IO
64    calls for accessing generic IO
6565*********************************************************************/
6666
6767static void io_generic_seek(struct io_generic *generic, UINT64 offset)
src/mess/formats/trs_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/trs_dsk.h
3    formats/trs_dsk.h
44
5   TRS-80 disk images
5    TRS-80 disk images
66
77*********************************************************************/
88
src/mess/formats/fm7_cas.c
r5931r5932
1616   int sample_count = 0;
1717   int x = 0;
1818   int count = (data & 0x7fff);
19   
19
2020   if(data & 0x8000)
2121   {
2222      for(x=0;x<count;x++)
r5931r5932
3434      }
3535   }
3636
37   sample_count += count;   
37   sample_count += count;
3838   return sample_count;
3939}
4040
r5931r5932
4242{
4343   int sample_count = 0;
4444   int data_pos = 16;
45   
45
4646   if(memcmp(casdata, "XM7 TAPE IMAGE 0",16))  // header check
4747      return -1;
48   
48
4949   while(data_pos < cas_size)
5050   {
5151      sample_count += fm7_fill_wave(buffer,casdata[data_pos],casdata[data_pos+1],sample_count);
5252      data_pos+=2;
5353   }
54   
54
5555   return sample_count;
5656}
5757
r5931r5932
6161static int fm7_cas_to_wav_size (const UINT8 *casdata, int caslen)
6262{
6363   cas_size = caslen;
64   
64
6565   return fm7_handle_t77(NULL,casdata);
6666}
6767
src/mess/formats/dim_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/dim_dsk.h
3    formats/dim_dsk.h
44
5   DIM disk images
5    DIM disk images
66
77*********************************************************************/
88
src/mess/formats/cocopak.c
r5931r5932
55
66#include "formats/cocopak.h"
77
8/*   PAK files have the following format:
8/*  PAK files have the following format:
99 *
10 *   length      (two bytes, little endian)
11 *   base address (two bytes, little endian, typically 0xc000)
12 *   ...data... (size is length)
13 *   optional trailer
10 *  length      (two bytes, little endian)
11 *  base address (two bytes, little endian, typically 0xc000)
12 *  ...data... (size is length)
13 *  optional trailer
1414 *
15 *   The format for PAK files just plain bites - the extra info is snapshot info
16 *   and it is loaded with internal state specific to Jeff's emulator. What ever
17 *   happened to desiging clean file formats that don't need to be changed with
18 *   every version of ones program?
15 *  The format for PAK files just plain bites - the extra info is snapshot info
16 *  and it is loaded with internal state specific to Jeff's emulator. What ever
17 *  happened to desiging clean file formats that don't need to be changed with
18 *  every version of ones program?
1919 *
20 *   For alignment purposes, some 16 bit values are divided into two UINT8s
20 *  For alignment purposes, some 16 bit values are divided into two UINT8s
2121 *
22 *   The PAK file format's trailer defines the state of the machine other then
23 *   the core memory.  This trailer comes in many variations.  I have labeled
24 *   them in the following way (trailer sizes are in parentheses):
22 *  The PAK file format's trailer defines the state of the machine other then
23 *  the core memory.  This trailer comes in many variations.  I have labeled
24 *  them in the following way (trailer sizes are in parentheses):
2525 *
26 *      V12      - The version in JeffV's emulator version 1.2
27 *      V14      - The version in JeffV's emulator version 1.4   (457)
28 *      VOTHER   - From some "other" version of JeffV's emulator
29 *      VLITE   - From yet another version of JeffV's emulator   (35)
26 *      V12     - The version in JeffV's emulator version 1.2
27 *      V14     - The version in JeffV's emulator version 1.4   (457)
28 *      VOTHER  - From some "other" version of JeffV's emulator
29 *      VLITE   - From yet another version of JeffV's emulator  (35)
3030 *
31 *   The following table shows what segments appear in each trailer variant:
31 *  The following table shows what segments appear in each trailer variant:
3232 *
33 *   Trailer Segment      V12      V14      VOTHER   VLITE
34 *   ---------------      ---      ---      ------   -----
35 *   pak_trailer1      1      1      1      1
36 *   pak_trailer2      2
37 *   pak_trailer3      3      2      2      2
38 *   pak_trailer4      4      3      3
39 *   pak_trailer5      5
40 *   pak_trailer6      6      5      4
41 *   pak_trailer7      7            5
42 *   pak_trailer8            6
43 *   pak_trailer9      8      7      6
44 *   pak_trailer10      9      4      7
45 *   pak_trailer11      10      8      8
46 *   pak_trailer12            9
47 *   pak_trailer13      11            9
33 *  Trailer Segment     V12     V14     VOTHER  VLITE
34 *  ---------------     ---     ---     ------  -----
35 *  pak_trailer1        1       1       1       1
36 *  pak_trailer2        2
37 *  pak_trailer3        3       2       2       2
38 *  pak_trailer4        4       3       3
39 *  pak_trailer5        5
40 *  pak_trailer6        6       5       4
41 *  pak_trailer7        7               5
42 *  pak_trailer8                6
43 *  pak_trailer9        8       7       6
44 *  pak_trailer10       9       4       7
45 *  pak_trailer11       10      8       8
46 *  pak_trailer12               9
47 *  pak_trailer13       11              9
4848 */
4949
5050/* All versions */
r5931r5932
392392
393393   case PAK_VLITE_SIZE:
394394      /* This is a "lite" format that gives no trailer information except
395       * for the program counter... I have to set everything up as default
396       * including the stack pointer... arg this sucks...
397       */
395         * for the program counter... I have to set everything up as default
396         * including the stack pointer... arg this sucks...
397         */
398398      trailer->pia[2] = 0xff;
399399      trailer->pia[3] = 0x34;
400400      trailer->pia[6] = 0x00;
src/mess/formats/vt_cas.c
r5931r5932
11#include "formats/vt_cas.h"
22
33/*********************************************************************
4   vtech 1/2 agnostic
4    vtech 1/2 agnostic
55*********************************************************************/
66
77#define SILENCE 8000
r5931r5932
5353
5454
5555/*********************************************************************
56   vtech 1
56    vtech 1
5757*********************************************************************/
5858
5959#define V1_LO   -32768
r5931r5932
127127CASSETTE_FORMATLIST_END
128128
129129/*********************************************************************
130   vtech 2
130    vtech 2
131131*********************************************************************/
132132
133133#define VT2_LO   -20000
src/mess/formats/cqm_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/cqm_dsk.c
3    formats/cqm_dsk.c
44
5   CopyQM disk images
5    CopyQM disk images
66
77*********************************************************************/
88
r5931r5932
2323   int sector_base;
2424   int interleave;
2525   int skew;
26   
26
2727   UINT8* buf;
2828   UINT64 track_offsets[84*2]; /* offset within data for each track */
2929};
r5931r5932
7272   UINT8 data;
7373   INT16 len;
7474   int s;
75   
75
7676   if ((head < 0) || (head >= get_tag(floppy)->heads) || (track < 0) || (track >= get_tag(floppy)->tracks)
7777         || (sector < 0) )
7878      return FLOPPY_ERROR_SEEKERROR;
79   
80   pos = cqm_get_track_offset(floppy,head,track);   
79
80   pos = cqm_get_track_offset(floppy,head,track);
8181   s = 0;
82   do {           
82   do {
8383      floppy_image_read(floppy, &len, pos, 2);
8484      pos+=2;
85      if(len<0) {         
86         floppy_image_read(floppy, &data, pos, 1);         
87         memset(get_tag(floppy)->buf + s,data, -len);         
85      if(len<0) {
86         floppy_image_read(floppy, &data, pos, 1);
87         memset(get_tag(floppy)->buf + s,data, -len);
8888         pos++;
89         s += -len;   
89         s += -len;
9090      } else {
9191         floppy_image_read(floppy, get_tag(floppy)->buf + s, pos, len);
92         pos+=len;         
92         pos+=len;
9393         s += len;
9494      }
9595   } while(s<get_tag(floppy)->sector_size*get_tag(floppy)->sector_per_track);
r5931r5932
104104static floperr_t internal_cqm_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
105105{
106106   UINT64 offset;
107   floperr_t err;   
108   
107   floperr_t err;
108
109109   // take sector offset
110110   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
111111   if (err)
r5931r5932
132132   if (err)
133133      return err;
134134
135   if (sector_length) {     
135   if (sector_length) {
136136      *sector_length = get_tag(floppy)->sector_size;
137137   }
138138   return FLOPPY_ERROR_SUCCESS;
139139}
140140
141141static floperr_t cqm_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
142{   
142{
143143   if (sector_index >= get_tag(floppy)->sector_per_track) return FLOPPY_ERROR_SEEKERROR;
144     
144
145145   if (cylinder) {
146146      *cylinder = track;
147147   }
r5931r5932
164164   struct FloppyCallbacks *callbacks;
165165   struct cqmdsk_tag *tag;
166166   UINT8 header[CQM_HEADER_SIZE];
167   UINT64 pos = 0;   
167   UINT64 pos = 0;
168168   INT16 len;
169169   int head;
170170   int track;
r5931r5932
174174      // create
175175      return FLOPPY_ERROR_UNSUPPORTED;
176176   }
177   
177
178178   tag = (struct cqmdsk_tag *) floppy_create_tag(floppy, CQM_DSK_TAG, sizeof(struct cqmdsk_tag));
179179   if (!tag)
180180      return FLOPPY_ERROR_OUTOFMEMORY;
r5931r5932
184184   tag->sector_size      = (header[0x04] << 8) + header[0x03];
185185   tag->sector_per_track = header[0x10];
186186   tag->heads           = header[0x12];
187   tag->tracks           = header[0x5b];   
187   tag->tracks           = header[0x5b];
188188   tag->sector_base     = header[0x71] + 1;
189189   tag->interleave        = header[0x74];
190190   tag->skew           = header[0x75];
191   
191
192192   // header + comment size to position on first data block
193   
194   pos = CQM_HEADER_SIZE + (header[0x70] << 8) + header[0x6f];
193
194   pos = CQM_HEADER_SIZE + (header[0x70] << 8) + header[0x6f];
195195   track = 0;
196196   head = 0;
197197   tag->buf = malloc(tag->sector_size*tag->sector_per_track);
198198   do {
199199      tag->track_offsets[(track<<1) + head] = pos;
200200      s = 0;
201      do {           
201      do {
202202         floppy_image_read(floppy, &len, pos, 2);
203203         pos+=2;
204         if(len<0) {         
204         if(len<0) {
205205            pos++;
206            s += -len;   
206            s += -len;
207207         } else {
208208            pos+=len;
209209            s += len;
r5931r5932
216216         track++;
217217      }
218218   } while(pos < floppy_image_size(floppy));
219   
220   
219
220
221221   callbacks = floppy_callbacks(floppy);
222222   callbacks->read_sector = cqm_read_sector;
223223   callbacks->read_indexed_sector = cqm_read_indexed_sector;
src/mess/formats/csw_cas.c
r5931r5932
33----------
44Header Description
55
6Offset   Value   Type   Description
70x00   (note)   ASCII   22 bytes "Compressed Square Wave"  signature
80x16   0x1A   BYTE   Terminator code
90x17    0x02   BYTE    CSW major revision number
100x18   0x00    BYTE   CSW minor revision number
110x19         DWORD   Sample rate
120x1D         DWORD   Total number of pulses (after decompression)
130x21         BYTE   Compression type  0x01: RLE    0x02: Z-RLE
140x22         BYTE   Flags   b0: initial polarity: if set, the signal starts at logical high
150x23   HDR      BYTE   Header extension length in bytes (0x00)
160x24         ASCII   16 bytes free use
170x34         BYTE   Start of Header is HDR>0
6Offset  Value   Type    Description
70x00    (note)  ASCII   22 bytes "Compressed Square Wave"  signature
80x16    0x1A    BYTE    Terminator code
90x17    0x02    BYTE    CSW major revision number
100x18    0x00    BYTE    CSW minor revision number
110x19            DWORD   Sample rate
120x1D            DWORD   Total number of pulses (after decompression)
130x21            BYTE    Compression type  0x01: RLE    0x02: Z-RLE
140x22            BYTE    Flags   b0: initial polarity: if set, the signal starts at logical high
150x23    HDR     BYTE    Header extension length in bytes (0x00)
160x24            ASCII   16 bytes free use
170x34            BYTE    Start of Header is HDR>0
1818
1919
2020
src/mess/formats/ioprocs.h
r5931r5932
11/*********************************************************************
22
3   ioprocs.h
3    ioprocs.h
44
5   File IO abstraction layer
5    File IO abstraction layer
66
77*********************************************************************/
88
r5931r5932
1616
1717/***************************************************************************
1818
19   Type definitions
19    Type definitions
2020
2121***************************************************************************/
2222
r5931r5932
4141
4242/***************************************************************************
4343
44   Globals
44    Globals
4545
4646***************************************************************************/
4747
r5931r5932
5252
5353/***************************************************************************
5454
55   Prototypes
55    Prototypes
5656
5757***************************************************************************/
5858
src/mess/formats/coco_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/coco_dsk.c
3    formats/coco_dsk.c
44
5   Tandy Color Computer / Dragon disk images
5    Tandy Color Computer / Dragon disk images
66
77*********************************************************************/
88
r5931r5932
2020 *
2121 * Used by Jeff Vavasour's CoCo Emulators
2222 *
23 *   Documentation taken from Tim Linder's web site:
24 *      http://home.netcom.com/~tlindner/JVC.html
23 *  Documentation taken from Tim Linder's web site:
24 *      http://home.netcom.com/~tlindner/JVC.html
2525 *
26 *   A. Header length
27 *      The header length is determined by the file length modulo 256:
28 *         headerSize = fileLength % 256;
29 *      This means that the header is variable length and the minimum size
30 *      is zero bytes, and the maximum size of 255 bytes.
26 *  A. Header length
27 *      The header length is determined by the file length modulo 256:
28 *          headerSize = fileLength % 256;
29 *      This means that the header is variable length and the minimum size
30 *      is zero bytes, and the maximum size of 255 bytes.
3131 *
3232 * B. Header
33 *      Here is a description of the header bytes:
34 *         Byte Offset     Description            Default
35 *         -----------      -----------------      -------
36 *                   0     Sectors per track      18
33 *      Here is a description of the header bytes:
34 *          Byte Offset     Description            Default
35 *          -----------     -----------------      -------
36 *                    0     Sectors per track      18
3737 *                    1     Side count              1
3838 *                    2     Sector size code        1
3939 *                    3     First sector ID         1
r5931r5932
4242 *  If the sector attribute flag is zero then the track count is determined
4343 *  by the formula:
4444 *
45 *      (fileLength - headerSize) / (sectorsPerTrack * (128 <<
46 *         sectorSizeCode)) / sideCount
45 *      (fileLength - headerSize) / (sectorsPerTrack * (128 <<
46 *          sectorSizeCode)) / sideCount
4747 *
4848 *  If the sector attribute flag is non zero then the track count is
4949 *  determined by the more complex formula:
5050 *
51 *      (fileLength - headerSize) / (sectorsPerTrack * ((128 <<
52 *         sectorSizeCode) + 1) ) / sideCount
51 *      (fileLength - headerSize) / (sectorsPerTrack * ((128 <<
52 *          sectorSizeCode) + 1) ) / sideCount
5353 *
5454 *  If the length of the header is to short to contain the geometry desired,
5555 *  then the default values are assumed. If the header length is zero the all
r5931r5932
6161 *  is zero then the sector data is at the beginning file.
6262 *
6363 *  C. Sectors per track
64 *      This is the number of sectors per track (ones based). A value of 18
65 *      means there are 18 sectors per track
64 *      This is the number of sectors per track (ones based). A value of 18
65 *      means there are 18 sectors per track
6666 *
67 *   D. Side Count
68 *      This is the number of sides in the disk image. Values of 1 or 2 are
69 *      acceptable. If there are two sides then the tracks are interleaved.
70 *      The first track in the image file is track zero side 1, the second
71 *      track in the image file is track zero side 2.
67 *  D. Side Count
68 *      This is the number of sides in the disk image. Values of 1 or 2 are
69 *      acceptable. If there are two sides then the tracks are interleaved.
70 *      The first track in the image file is track zero side 1, the second
71 *      track in the image file is track zero side 2.
7272 *
73 *   E. Sector size
74 *      The is the same value that is stored in the wd179x ID field to
75 *      determine sector size:
73 *  E. Sector size
74 *      The is the same value that is stored in the wd179x ID field to
75 *      determine sector size:
7676 *
77 *         0x00       128 bytes
78 *         0x01       256 bytes
79 *         0x02       512 bytes
80 *         0x03      1024 bytes
77 *          0x00         128 bytes
78 *          0x01         256 bytes
79 *          0x02         512 bytes
80 *          0x03        1024 bytes
8181 *
82 *   Other values are undefined. Every sector in the disk image must be the
83 *   same size.
82 *  Other values are undefined. Every sector in the disk image must be the
83 *  same size.
8484 *
85 *   F. First sector ID
86 *      This determines the first sector ID for each track. Each successive
87 *      sector adds one to the previous ID. If the first sector ID is 1, then
88 *      the second sector has an ID of 2, and the third has an ID of 3.
85 *  F. First sector ID
86 *      This determines the first sector ID for each track. Each successive
87 *      sector adds one to the previous ID. If the first sector ID is 1, then
88 *      the second sector has an ID of 2, and the third has an ID of 3.
8989 *
90 *   G. Sector Attribute Flag
91 *      If this byte is non zero, then each sector contains an additional
92 *      byte prepended to the sector data. If the attribute flag is zero then
93 *      there are no extra bytes in front of the sector data.
90 *  G. Sector Attribute Flag
91 *      If this byte is non zero, then each sector contains an additional
92 *      byte prepended to the sector data. If the attribute flag is zero then
93 *      there are no extra bytes in front of the sector data.
9494 *
95 *   H. Sector attribute byte
96 *      This byte is put at the begining of every sector if the header flag
97 *      is turned on. The information this byte contains is the same as the
98 *      status register (of the wd179x) would contain when a 'Read Sector'
99 *      command was issued. The bit fields are defined as:
95 *  H. Sector attribute byte
96 *      This byte is put at the begining of every sector if the header flag
97 *      is turned on. The information this byte contains is the same as the
98 *      status register (of the wd179x) would contain when a 'Read Sector'
99 *      command was issued. The bit fields are defined as:
100100 *
101 *      Bit position:
102 *      ---------------
103 *      7 6 5 4 3 2 1 0
104 *      | | | | | | | |
105 *      | | | | | | | +--- Not used. Set to zero.
106 *      | | | | | | +----- Not used. Set to zero.
107 *      | | | | | +------- Not used. Set to zero.
108 *      | | | | +--------- Set on CRC error.
109 *      | | | +----------- Set if sector not found.
110 *      | | +------------- Record type: 1 - Deleted Data Mark, 0 - Data Mark.
111 *      | +--------------- Not Used. Set to zero.
112 *      +----------------- Not Used. Set to zero.
101 *      Bit position:
102 *      ---------------
103 *      7 6 5 4 3 2 1 0
104 *      | | | | | | | |
105 *      | | | | | | | +--- Not used. Set to zero.
106 *      | | | | | | +----- Not used. Set to zero.
107 *      | | | | | +------- Not used. Set to zero.
108 *      | | | | +--------- Set on CRC error.
109 *      | | | +----------- Set if sector not found.
110 *      | | +------------- Record type: 1 - Deleted Data Mark, 0 - Data Mark.
111 *      | +--------------- Not Used. Set to zero.
112 *      +----------------- Not Used. Set to zero.
113113 *
114114 * ----------------------------------------------------------------------- */
115115
r5931r5932
464464 *
465465 * Used by Paul Burgin's PC-Dragon emulator
466466 *
467 *   Offset   Bytes   Field         Description
468 *   ------  -----   ------------   -----------
469 *        0       1   magic1         Signature byte 1 ('d')
470 *        1       1   magic2         Signature byte 2 ('k')
471 *       2      2   header_len      Total header length (little endian)
472 *       4      1   ver_actual      Version of the VDK format (0x10)
473 *       5      1   ver_compat      Backwards compatibility version (0x10)
474 *       6      1   source_id      Identify of the file source
475 *       7      1   source_ver      Version of the file source
476 *       8      1   tracks         Number of tracks
477 *       9      1   sides         Number of sides (1-2)
478 *      10      1   flags         Various flags
479 *                                       bit 0: Write protect
480 *                                       bit 1: A Lock
481 *                                       bit 2: F Lock
482 *                                       bit 3: Disk set
483 *      11      1   compression      Compression flags (bits 0-2) and name length
467 *  Offset  Bytes   Field           Description
468 *  ------  -----   ------------    -----------
469 *       0      1   magic1          Signature byte 1 ('d')
470 *       1      1   magic2          Signature byte 2 ('k')
471 *       2      2   header_len      Total header length (little endian)
472 *       4      1   ver_actual      Version of the VDK format (0x10)
473 *       5      1   ver_compat      Backwards compatibility version (0x10)
474 *       6      1   source_id       Identify of the file source
475 *       7      1   source_ver      Version of the file source
476 *       8      1   tracks          Number of tracks
477 *       9      1   sides           Number of sides (1-2)
478 *      10      1   flags           Various flags
479 *                                      bit 0: Write protect
480 *                                      bit 1: A Lock
481 *                                      bit 2: F Lock
482 *                                      bit 3: Disk set
483 *      11      1   compression     Compression flags (bits 0-2) and name length
484484 * ----------------------------------------------------------------------- */
485485
486486
r5931r5932
586586 *
587587 *  HEADER DESCRIPTION:
588588 *
589 *   Offset   Bytes   Field         Description
590 *   ------  -----   ------------   -----------
591 *       0      1   write_prot      0xff = Writed Protected, 0x00 = R/W
589 *  Offset  Bytes   Field           Description
590 *  ------  -----   ------------    -----------
591 *       0      1   write_prot      0xff = Writed Protected, 0x00 = R/W
592592 *       1      1   tracks          Number of tracks
593593 *       2      2   track_length    Bytes per track (little endian)
594594 *       4      1   disk_options    Miscellaneous flags
595 *                                       bit 0-3:  Unused
596 *                                       bit   4:  1=single sided 0=dbl
597 *                                       bit   5:  Unused
598 *                                       bit   6:  Single density?
599 *                                       bit   6:  Ignore density flags?
595 *                                      bit 0-3:  Unused
596 *                                      bit   4:  1=single sided 0=dbl
597 *                                      bit   5:  Unused
598 *                                      bit   6:  Single density?
599 *                                      bit   6:  Ignore density flags?
600600 *       5      7   reserved        Reserved for future use
601601 *      12      4   real_disk_code  If this is 0x12345678 (little endian)
602602 *                                  then access a real disk drive
r5931r5932
604604 *
605605 * Each track begins with a track TOC, consisting of 64 little endian 16-bit
606606 * integers.  Each integer has the following format:
607 *      bit 0-13:   Offset from begining of track to 'FE' byte of IDAM
608 *               Note these are always sorted from first to last. All empty
609 *               entries are 0x00
610 *      bit 14:      Undefined (reserved)
611 *      bit 15:      Sector double density (0=SD 1=DD)
607 *      bit 0-13:   Offset from begining of track to 'FE' byte of IDAM
608 *                  Note these are always sorted from first to last. All empty
609 *                  entries are 0x00
610 *      bit 14:     Undefined (reserved)
611 *      bit 15:     Sector double density (0=SD 1=DD)
612612 * ----------------------------------------------------------------------- */
613613
614614struct dmk_tag
r5931r5932
917917         {
918918            /* check IDAM integrity and check for matching sector */
919919            if ((sector == dmk_idam_sector(&track_data[idam_offset]))
920/*               && (track == dmk_idam_track(&track_data[idam_offset]))   */
921/*               && (head == dmk_idam_side(&track_data[idam_offset]))   */
920/*                  && (track == dmk_idam_track(&track_data[idam_offset]))  */
921/*                  && (head == dmk_idam_side(&track_data[idam_offset]))    */
922922               )
923923               break;
924924         }
src/mess/formats/vt_cas.h
r5931r5932
11/*********************************************************************
22
3   vt_cas.h
3    vt_cas.h
44
5   Format code for VTech casette files
5    Format code for VTech casette files
66
77*********************************************************************/
88
src/mess/formats/orao_cas.c
r5931r5932
11/*
2   
3   Tape support for Orao  TAP format
4     
2
3    Tape support for Orao  TAP format
4
55*/
66#include "driver.h"
77#include "formats/orao_cas.h"
r5931r5932
3232static int orao_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
3333   int i,j,size;
3434   UINT8 b;
35   
35
3636   if (casdata == NULL) return -1;
3737   if (caslen <= ORAO_HEADER_SIZE) {
3838      return -1;
r5931r5932
4545            size += 2*ORAO_WAVE_ZERO;
4646         } else {
4747            size += 2*ORAO_WAVE_ONE;
48         }           
48         }
4949      }
50   }   
50   }
5151    len = caslen;
52   return size;   
52   return size;
5353}
5454
55static int orao_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {   
55static int orao_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
5656   int i,j,size;
5757   UINT8 b;
58   size = 0;   
58   size = 0;
5959   if (bytes == NULL) return -1;
6060   for (i=ORAO_HEADER_SIZE;i<len-ORAO_HEADER_SIZE;i++) {
6161      for (j=0;j<8;j++) {
6262         b = (bytes[i] >> j) & 1;
63         if (b==0) {           
63         if (b==0) {
6464            wave_data = WAVE_LOW;
6565            orao_output_wave(&buffer,ORAO_WAVE_ZERO);
6666            wave_data = WAVE_HIGH;
6767            orao_output_wave(&buffer,ORAO_WAVE_ZERO);
6868            size += 2 *ORAO_WAVE_ZERO;
69         } else {           
69         } else {
7070            wave_data = WAVE_LOW;
7171            orao_output_wave(&buffer,ORAO_WAVE_ONE);
7272            wave_data = WAVE_HIGH;
7373            orao_output_wave(&buffer,ORAO_WAVE_ONE);
7474            size += 2 * ORAO_WAVE_ONE;
75         }           
75         }
7676      }
77   }   
78     
77   }
78
7979   return size;
8080}
8181
src/mess/formats/csw_cas.h
r5931r5932
11/*
2   csw_cas.h
2    csw_cas.h
33
4   Format code for csw cassette files
4    Format code for csw cassette files
55*/
66
77#ifndef CSW_CAS_H
src/mess/formats/coco_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/coco_dsk.h
3    formats/coco_dsk.h
44
5   Tandy Color Computer / Dragon disk images
5    Tandy Color Computer / Dragon disk images
66
77*********************************************************************/
88
src/mess/formats/x1_tap.c
r5931r5932
11/*
2 *
2 *
33 *   Sharp X1 TAP image format
4 *
4 *
55 *   "New" header format:
66 *   0x00: Index - must be "TAPE" (4 bytes)
77 *   0x04: Image title. (null-terminated string, 17 bytes)
r5931r5932
1313 *   0x20: Tape data size, in bits (4 bytes)
1414 *   0x24: Tape position (4 bytes, usually 0)
1515 *   0x28: Tape data (data size / 8)
16 *
16 *
1717 *   "Old" header format:
1818 *   0x00: Sampling rate (4 bytes)
19 *
19 *
2020 */
2121
2222#include "driver.h"
r5931r5932
3232{
3333   int x;
3434   int sample_count = 0;
35   
35
3636   // one byte = 8 samples
3737   for(x=0;x<8;x++)
3838   {
3939      if(buffer)
40         buffer[sample_pos+x] = (data & (1 << (7-x))) ? WAVE_HIGH : WAVE_LOW;
40         buffer[sample_pos+x] = (data & (1 << (7-x))) ? WAVE_HIGH : WAVE_LOW;
4141      sample_count++;
4242   }
43   
43
4444   return sample_count;
4545}
4646
r5931r5932
5959      logerror("TAP: images that are not 8000Hz are not yet supported\n");
6060      return -1;
6161   }
62   
62
6363   while(sample_count < cas_size)
6464   {
6565      sample_count += x1_fill_wave(buffer,casdata[data_pos],sample_count);
6666      data_pos++;
6767   }
68   
68
6969   return sample_count;
7070}
7171
r5931r5932
7575static int x1_cas_to_wav_size (const UINT8 *casdata, int caslen)
7676{
7777   UINT32 ret;
78   
78
7979   ret = casdata[0x20] | (casdata[0x21] << 8) | (casdata[0x22] << 16) | (casdata[0x23] << 24);
8080   cas_size = ret;
8181
8282   samplerate = casdata[0x1c] | (casdata[0x1d] << 8) | (casdata[0x1e] << 16) | (casdata[0x1f] << 24);
83   
83
8484   return ret;
8585}
8686
src/mess/formats/wavfile.c
r5931r5932
11/*********************************************************************
22
3   wavfile.c
3    wavfile.c
44
5   Format code for wave (*.wav) files
5    Format code for wave (*.wav) files
66
77*********************************************************************/
88
r5931r5932
239239
240240
241241/*********************************************************************
242   wavfile_testload()
242    wavfile_testload()
243243
244   This is a hokey function used to test the cassette wave loading
245   system, specifically to test that when one loads a WAV file image
246   that the resulting info queried will be the same data in the WAV.
244    This is a hokey function used to test the cassette wave loading
245    system, specifically to test that when one loads a WAV file image
246    that the resulting info queried will be the same data in the WAV.
247247
248   This code has already identified some rounding errors
248    This code has already identified some rounding errors
249249*********************************************************************/
250250
251251#ifdef UNUSED_FUNCTION
src/mess/formats/flopimg.c
r5931r5932
11/*********************************************************************
22
3   flopimg.c
3    flopimg.c
44
5   Floppy disk image abstraction code
5    Floppy disk image abstraction code
66
77*********************************************************************/
88
r5931r5932
6666static void floppy_close_internal(floppy_image *floppy, int close_file);
6767
6868/*********************************************************************
69   opening, closing and creating of floppy images
69    opening, closing and creating of floppy images
7070*********************************************************************/
7171
7272/* basic floppy_image initialization common to floppy_open() and floppy_create() */
r5931r5932
320320      if (close_file)
321321         io_generic_close(&floppy->io);
322322      if (floppy->loaded_track_data)
323         free(floppy->loaded_track_data);     
323         free(floppy->loaded_track_data);
324324      tagpool_exit(&floppy->tags);
325325   }
326326
r5931r5932
337337
338338
339339/*********************************************************************
340   functions useful in format constructors
340    functions useful in format constructors
341341*********************************************************************/
342342
343343struct FloppyCallbacks *floppy_callbacks(floppy_image *floppy)
r5931r5932
378378
379379
380380/*********************************************************************
381   calls for accessing the raw disk image
381    calls for accessing the raw disk image
382382*********************************************************************/
383383
384384void floppy_image_read(floppy_image *floppy, void *buffer, UINT64 offset, size_t length)
r5931r5932
410410
411411
412412/*********************************************************************
413   calls for accessing disk image data
413    calls for accessing disk image data
414414*********************************************************************/
415415
416416static floperr_t floppy_readwrite_sector(floppy_image *floppy, int head, int track, int sector, int offset,
r5931r5932
475475         if ((offset > 0) || (buffer_len < sector_length))
476476         {
477477            /* we will be doing an partial read/write; in other words we
478            * will not be reading/writing a full sector */
478                * will not be reading/writing a full sector */
479479            new_alloc_buf = realloc(alloc_buf, sector_length);
480480            if (!new_alloc_buf)
481481            {
r5931r5932
809809
810810
811811/*********************************************************************
812   calls for track based IO
812    calls for track based IO
813813*********************************************************************/
814814
815815floperr_t floppy_load_track(floppy_image *floppy, int head, int track, int dirtify, void **track_data, size_t *track_length)
r5931r5932
881881
882882
883883/*********************************************************************
884   accessors for meta information about the image
884    accessors for meta information about the image
885885*********************************************************************/
886886
887887const char *floppy_format_description(floppy_image *floppy)
r5931r5932
892892
893893
894894/*********************************************************************
895   misc calls
895    misc calls
896896*********************************************************************/
897897
898898const char *floppy_error(floperr_t err)
src/mess/formats/x1_tap.h
r5931r5932
11/*
2 *
2 *
33 *   Sharp X1 TAP image format
4 *
4 *
55 */
66
77#ifndef X1_TAP_H_
src/mess/formats/wavfile.h
r5931r5932
11/*********************************************************************
22
3   wavfile.h
3    wavfile.h
44
5   Format code for wave (*.wav) files
5    Format code for wave (*.wav) files
66
77*********************************************************************/
88
src/mess/formats/flopimg.h
r5931r5932
11/*********************************************************************
22
3   flopimg.h
3    flopimg.h
44
5   Floppy disk image abstraction code
5    Floppy disk image abstraction code
66
77*********************************************************************/
88
r5931r5932
1515
1616/***************************************************************************
1717
18   Constants
18    Constants
1919
2020***************************************************************************/
2121
r5931r5932
2626
2727/***************************************************************************
2828
29   Type definitions
29    Type definitions
3030
3131***************************************************************************/
3232
r5931r5932
138138
139139/***************************************************************************
140140
141   Prototypes
141    Prototypes
142142
143143***************************************************************************/
144144
src/mess/formats/ap_dsk35.c
r5931r5932
11/*********************************************************************
22
3   ap_dsk35.c
3    ap_dsk35.c
44
5   Apple 3.5" disk images
5    Apple 3.5" disk images
66
7   This code supports 3.5" 400k/800k disks used in early Macintoshes
8   and the Apple IIgs.
7    This code supports 3.5" 400k/800k disks used in early Macintoshes
8    and the Apple IIgs.
99
10   These disks have the following properties:
10    These disks have the following properties:
1111
12      400k:   80 tracks, 1 head
13      800k:   80 tracks, 2 heads
12        400k:   80 tracks, 1 head
13        800k:   80 tracks, 2 heads
1414
15      Tracks  0-15 have 12 sectors each
16      Tracks 16-31 have 11 sectors each
17      Tracks 32-47 have 10 sectors each
18      Tracks 48-63 have  9 sectors each
19      Tracks 64-79 have  8 sectors each
15        Tracks  0-15 have 12 sectors each
16        Tracks 16-31 have 11 sectors each
17        Tracks 32-47 have 10 sectors each
18        Tracks 48-63 have  9 sectors each
19        Tracks 64-79 have  8 sectors each
2020
21      1440k disks are the exception; they are simply 80 tracks, 2 heads and
22      18 sectors per track.
21        1440k disks are the exception; they are simply 80 tracks, 2 heads and
22        18 sectors per track.
2323
24   Each sector has 524 bytes, 512 of which are really used by the Macintosh
24    Each sector has 524 bytes, 512 of which are really used by the Macintosh
2525
26   (80 tracks) * (avg of 10 sectors) * (512 bytes) * (2 sides) = 800 kB
26    (80 tracks) * (avg of 10 sectors) * (512 bytes) * (2 sides) = 800 kB
2727
28   Data is nibblized : 3 data bytes -> 4 bytes on disk.
28    Data is nibblized : 3 data bytes -> 4 bytes on disk.
2929
30   In addition to 512 logical bytes, each sector contains 800 physical
31   bytes.  Here is the layout of the physical sector:
30    In addition to 512 logical bytes, each sector contains 800 physical
31    bytes.  Here is the layout of the physical sector:
3232
33      Pos
34      0      0xFF (pad byte where head is turned on ???)
35      1-35   self synch 0xFFs (7*5) (42 bytes actually written to media)
36      36      0xD5
37      37      0xAA
38      38      0x96
39      39      diskbytes[(track number) & 0x3F]
40      40      diskbytes[(sector number)]
41      41      diskbytes[("side")]
42      42      diskbytes[("format byte")]
43      43      diskbytes[("sum")]
44      44      0xDE
45      45      0xAA
46      46      pad byte where head is turned off/on (0xFF here)
47      47-51   self synch 0xFFs (6 bytes actually written to media)
48      52      0xD5
49      53      0xAA
50      54      0xAD
51      55      spare byte, generally diskbytes[(sector number)]
52      56-754   "nibblized" sector data   ...
53      755-758   checksum
54      759      0xDE
55      760      0xAA
56      761      pad byte where head is turned off (0xFF here)
33        Pos
34        0       0xFF (pad byte where head is turned on ???)
35        1-35    self synch 0xFFs (7*5) (42 bytes actually written to media)
36        36      0xD5
37        37      0xAA
38        38      0x96
39        39      diskbytes[(track number) & 0x3F]
40        40      diskbytes[(sector number)]
41        41      diskbytes[("side")]
42        42      diskbytes[("format byte")]
43        43      diskbytes[("sum")]
44        44      0xDE
45        45      0xAA
46        46      pad byte where head is turned off/on (0xFF here)
47        47-51   self synch 0xFFs (6 bytes actually written to media)
48        52      0xD5
49        53      0xAA
50        54      0xAD
51        55      spare byte, generally diskbytes[(sector number)]
52        56-754  "nibblized" sector data ...
53        755-758 checksum
54        759     0xDE
55        760     0xAA
56        761     pad byte where head is turned off (0xFF here)
5757
58   Note : "Self synch refers to a technique whereby two zeroes are inserted
59   between each synch byte written to the disk.", i.e. "0xFF, 0xFF, 0xFF,
60   0xFF, 0xFF" is actually "0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF" on disk.
61   Since the IWM assumes the data transfer is complete when the MSBit of its
62   shift register is 1, we do read 4 0xFF, even though they are not
63   contiguous on the disk media.  Some reflexion shows that 4 synch bytes
64   allow the IWM to synchronize with the trailing data.
58    Note : "Self synch refers to a technique whereby two zeroes are inserted
59    between each synch byte written to the disk.", i.e. "0xFF, 0xFF, 0xFF,
60    0xFF, 0xFF" is actually "0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF" on disk.
61    Since the IWM assumes the data transfer is complete when the MSBit of its
62    shift register is 1, we do read 4 0xFF, even though they are not
63    contiguous on the disk media.  Some reflexion shows that 4 synch bytes
64    allow the IWM to synchronize with the trailing data.
6565
66   Format byte codes:
67      0x00   Apple II
68      0x01   Lisa
69      0x02   Mac MFS (single sided)?
70      0x22   Mac MFS (double sided)?
66    Format byte codes:
67        0x00    Apple II
68        0x01    Lisa
69        0x02    Mac MFS (single sided)?
70        0x22    Mac MFS (double sided)?
7171
7272*********************************************************************/
7373
r5931r5932
157157static const UINT8 blk1[] =
158158{
159159   /*0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
160   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
161   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
162   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
163   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
164   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
165   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
166   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
167   0xFF, 0xFF, 0xD5, 0xAA, 0x96*/
160    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
161    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
162    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
163    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
164    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
165    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
166    0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
167    0xFF, 0xFF, 0xD5, 0xAA, 0x96*/
168168   0xFF,
169169   0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF,
170170   0xFF, 0x3F, 0xCF, 0xF3, 0xFC, 0xFF,
r5931r5932
212212
213213
214214/*
215   converts data to its nibblized representation, and generate checksum
215    converts data to its nibblized representation, and generate checksum
216216
217   now handles 524-byte-long sectors
217    now handles 524-byte-long sectors
218218
219   tag data IS important, since it allows data recovery when the catalog is trashed
219    tag data IS important, since it allows data recovery when the catalog is trashed
220220*/
221221static void sony_nibblize35(const UINT8 *in, UINT8 *nib_ptr, UINT8 *csum)
222222{
r5931r5932
227227   UINT8 b1[175], b2[175], b3[175];
228228
229229   /* Copy from the user's buffer to our buffer, while computing
230    * the three-byte data checksum
231    */
230     * the three-byte data checksum
231     */
232232
233233   i = 0;
234234   j = 0;
r5931r5932
300300
301301
302302/*
303   does the reverse process of sony_nibblize35
303    does the reverse process of sony_nibblize35
304304*/
305305static void sony_denibblize35(UINT8 *out, const UINT8 *nib_ptr, UINT8 *checksum)
306306{
r5931r5932
325325   }
326326
327327   /* Copy from the user's buffer to our buffer, while computing
328    * the three-byte data checksum
329    */
328     * the three-byte data checksum
329     */
330330
331331   i = 0;
332332   j = 0;
r5931r5932
406406   while ((data & 0x80) == 0)
407407   {
408408      /* this code looks weird because it isn't simply rotating the new bit
409       * in, but for some reason it won't work if I rotate the bit in; I
410       * have to match the algorithm used by the old code */
409         * in, but for some reason it won't work if I rotate the bit in; I
410         * have to match the algorithm used by the old code */
411411      data <<= 1;
412412      data |= (buffer[*pos / 8] >> (8 - ((*pos % 8) + 1)));
413413      (*pos)++;
r5931r5932
857857   UINT8 disk_format;      /* 0 = 400K, 1 = 800K, 2 = 720K, 3 = 1440K  (other values reserved) */
858858   UINT8 format_byte;      /* should be $00 Apple II, $01 Lisa, $02 Mac MFS ??? */
859859                     /* $12 = 400K, $22 = >400K Macintosh (DiskCopy uses this value for
860                        all Apple II disks not 800K in size, and even for some of those),
861                        $24 = 800K Apple II disk */
860                               all Apple II disks not 800K in size, and even for some of those),
861                               $24 = 800K Apple II disk */
862862   UINT16 magic;         /* always $0100 (otherwise, the file may be in a different format. */
863863};
864864
src/mess/formats/mz_cas.c
r5931r5932
66#define VERBOSE 0
77#endif
88
9//#define LOG(N,M,A)   
10//   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(machine)), (const char*)M ); logerror A; }
9//#define LOG(N,M,A)
10//  if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time(machine)), (const char*)M ); logerror A; }
1111
1212#define LOG(N,M,A)   \
1313   if(VERBOSE>=N){ if( M )logerror("%-24s",(const char*)M ); logerror A; }
src/mess/formats/ap_dsk35.h
r5931r5932
11/*********************************************************************
22
3   ap_dsk35.h
3    ap_dsk35.h
44
5   Apple 3.5" disk images
5    Apple 3.5" disk images
66
77*********************************************************************/
88
src/mess/formats/comx35_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/comx35_dsk.c
3    formats/comx35_dsk.c
44
5   COMX35 disk images
5    COMX35 disk images
66
77*********************************************************************/
88
r5931r5932
2222   struct basicdsk_geometry geometry;
2323   UINT8 header[1];
2424   int heads =1;
25   int cylinders =35;   
26   
25   int cylinders =35;
26
2727   switch(floppy_image_size(floppy)) {
2828      case 35*1*16*128:
2929         heads = 1;
30         cylinders = 35;         
30         cylinders = 35;
3131         break;
3232
33      case 35*2*16*128:         
33      case 35*2*16*128:
3434         floppy_image_read( floppy, header, 0x12 , 1 );
3535         if (header[0] == 0x01)
36         {           
36         {
3737            heads = 1;
3838            cylinders = 70;
3939         }
r5931r5932
4242            heads = 2;
4343            cylinders = 35;
4444         }
45         break;     
45         break;
4646   }
47   
47
4848   memset(&geometry, 0, sizeof(geometry));
4949   geometry.heads = heads;
5050   geometry.first_sector_id = 0;
5151   geometry.sector_length = 128;
5252   geometry.tracks = cylinders;
5353   geometry.sectors = 16;
54   return basicdsk_construct(floppy, &geometry);   
54   return basicdsk_construct(floppy, &geometry);
5555}
5656
5757/* ----------------------------------------------------------------------- */
src/mess/formats/mz_cas.h
r5931r5932
11/*********************************************************************
22
3   mz_cas.h
3    mz_cas.h
44
5   Format code for MZ700 casette files
5    Format code for MZ700 casette files
66
77*********************************************************************/
88
src/mess/formats/ap2_dsk.c
r5931r5932
11/*********************************************************************
22
3   ap2_dsk.c
3    ap2_dsk.c
44
5   Apple II disk images
5    Apple II disk images
66
77*********************************************************************/
88
src/mess/formats/comx35_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/comx35_dsk.h
3    formats/comx35_dsk.h
44
5   COMX35 disk images
5    COMX35 disk images
66
77*********************************************************************/
88
src/mess/formats/ap2_dsk.h
r5931r5932
11/*********************************************************************
22
3   ap2_dsk.h
3    ap2_dsk.h
44
5   Apple II disk images
5    Apple II disk images
66
77*********************************************************************/
88
r5931r5932
1414
1515/***************************************************************************
1616
17   Constants
17    Constants
1818
1919***************************************************************************/
2020
src/mess/formats/trd_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/trd_dsk.c
3    formats/trd_dsk.c
44
5   TRD disk images
5    TRD disk images
66
77*********************************************************************/
88
r5931r5932
2525   UINT8 data[1];
2626   int heads;
2727   int cylinders;
28   
28
2929   floppy_image_read( floppy, data, 0x8e3 , 1 );
3030
3131     /* guess geometry of disk */
r5931r5932
3838   geometry.sector_length = 256;
3939   geometry.tracks = cylinders;
4040   geometry.sectors = 16;
41   return basicdsk_construct(floppy, &geometry);   
41   return basicdsk_construct(floppy, &geometry);
4242}
4343
4444
src/mess/formats/svi_cas.h
r5931r5932
11/*********************************************************************
22
3   svi_cas.h
3    svi_cas.h
44
5   Format code for SVI casette files
5    Format code for SVI casette files
66
77*********************************************************************/
88
src/mess/formats/sord_cas.c
r5931r5932
11/**************************************************************************
22
3   sord_cas.c
3    sord_cas.c
44
5   Format code for Sord M5 cassette files
5    Format code for Sord M5 cassette files
66
77**************************************************************************/
88
src/mess/formats/trd_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/trd_dsk.h
3    formats/trd_dsk.h
44
5   TRD disk images
5    TRD disk images
66
77*********************************************************************/
88
src/mess/formats/sord_cas.h
r5931r5932
11/*********************************************************************
22
3   sord_cas.h
3    sord_cas.h
44
5   Format code for Sord M5 cassette files
5    Format code for Sord M5 cassette files
66
77*********************************************************************/
88
src/mess/formats/rk_cas.c
r5931r5932
11/*
2   
3   Tape support for RK format
4     
2
3    Tape support for RK format
4
55*/
66#include "driver.h"
77#include "formats/rk_cas.h"
r5931r5932
3535   if (b)
3636   {
3737      p = rk_emit_level (p, bitsize, WAVE_HIGH);
38      p = rk_emit_level (p, bitsize, WAVE_LOW);                       
39   }   
38      p = rk_emit_level (p, bitsize, WAVE_LOW);
39   }
4040   else
4141   {
42      p = rk_emit_level (p, bitsize, WAVE_LOW);   
43      p = rk_emit_level (p, bitsize, WAVE_HIGH);           
44         
42      p = rk_emit_level (p, bitsize, WAVE_LOW);
43      p = rk_emit_level (p, bitsize, WAVE_HIGH);
44
4545   }
4646    return p;
4747}
r5931r5932
5656}
5757
5858
59static int rk20_cas_to_wav_size( const UINT8 *casdata, int caslen ) {   
59static int rk20_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
6060   data_size = caslen;
61   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_20;   
61   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_20;
6262}
6363
64static int rk22_cas_to_wav_size( const UINT8 *casdata, int caslen ) {   
64static int rk22_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
6565   data_size = caslen;
66   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_22;   
66   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_22;
6767}
6868
69static int rk60_cas_to_wav_size( const UINT8 *casdata, int caslen ) {   
69static int rk60_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
7070   data_size = caslen;
71   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_60;   
71   return  (RK_HEADER_LEN  * 8 * 2 +  8*2 + caslen * 8 * 2) * RK_SIZE_60;
7272}
7373
74static int gam_cas_to_wav_size( const UINT8 *casdata, int caslen ) {   
74static int gam_cas_to_wav_size( const UINT8 *casdata, int caslen ) {
7575   data_size = caslen;
76   return  (RK_HEADER_LEN  * 8 * 2 +  caslen * 8 * 2) * RK_SIZE_20;   
76   return  (RK_HEADER_LEN  * 8 * 2 +  caslen * 8 * 2) * RK_SIZE_20;
7777}
7878
79static int rk20_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {   
79static int rk20_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
8080   int i;
8181   INT16 * p = buffer;
82   
82
8383   for (i=0; i<RK_HEADER_LEN; i++) {
84      p = rk_output_byte (p, 0x00, RK_SIZE_20 );   
84      p = rk_output_byte (p, 0x00, RK_SIZE_20 );
8585   }
8686
87   p = rk_output_byte (p, 0xE6, RK_SIZE_20);   
88   
87   p = rk_output_byte (p, 0xE6, RK_SIZE_20);
88
8989   for (i=0; i<data_size; i++)
9090      p = rk_output_byte (p, bytes[i], RK_SIZE_20);
9191
9292   return p - buffer;
9393}
9494
95static int rk22_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {   
95static int rk22_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
9696   int i;
9797   INT16 * p = buffer;
98   
98
9999   for (i=0; i<RK_HEADER_LEN; i++) {
100      p = rk_output_byte (p, 0x00, RK_SIZE_22 );   
100      p = rk_output_byte (p, 0x00, RK_SIZE_22 );
101101   }
102102
103   p = rk_output_byte (p, 0xE6, RK_SIZE_22);   
104   
103   p = rk_output_byte (p, 0xE6, RK_SIZE_22);
104
105105   for (i=0; i<data_size; i++)
106106      p = rk_output_byte (p, bytes[i], RK_SIZE_22);
107107
108108   return p - buffer;
109109}
110110
111static int rk60_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {   
111static int rk60_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
112112   int i;
113113   INT16 * p = buffer;
114   
114
115115   for (i=0; i<RK_HEADER_LEN; i++) {
116      p = rk_output_byte (p, 0x00, RK_SIZE_60 );   
116      p = rk_output_byte (p, 0x00, RK_SIZE_60 );
117117   }
118118
119   p = rk_output_byte (p, 0xE6, RK_SIZE_60);   
120   
119   p = rk_output_byte (p, 0xE6, RK_SIZE_60);
120
121121   for (i=0; i<data_size; i++)
122122      p = rk_output_byte (p, bytes[i], RK_SIZE_60);
123123
124124   return p - buffer;
125125}
126126
127static int gam_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {   
127static int gam_cas_fill_wave( INT16 *buffer, int length, UINT8 *bytes ) {
128128   int i;
129129   INT16 * p = buffer;
130   
130
131131   for (i=0; i<RK_HEADER_LEN; i++) {
132      p = rk_output_byte (p, 0x00, RK_SIZE_20 );   
132      p = rk_output_byte (p, 0x00, RK_SIZE_20 );
133133   }
134   
134
135135   for (i=0; i<data_size; i++)
136136      p = rk_output_byte (p, bytes[i], RK_SIZE_20);
137137
src/mess/formats/pc_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/pc_dsk.c
3    formats/pc_dsk.c
44
5   PC disk images
5    PC disk images
66
77*********************************************************************/
88
r5931r5932
6060   if (size >= 0x1a)
6161   {
6262      /*
63       * get info from boot sector.
64       * not correct on all disks
65       */
63         * get info from boot sector.
64         * not correct on all disks
65         */
6666      UINT8 scl, spt, heads;
6767      floppy_image_read(floppy, &scl, 0x0c, 1);
6868      floppy_image_read(floppy, &spt, 0x18, 1);
src/mess/formats/atarist_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/atarist_dsk.c
3    formats/atarist_dsk.c
44
5   Atari ST disk images
5    Atari ST disk images
66
77*********************************************************************/
88
r5931r5932
2121{
2222   struct basicdsk_geometry geometry;
2323   int heads = 0;
24   int tracks = 0;   
24   int tracks = 0;
2525   int sectors = 0;
2626   UINT8 bootsector[512];
2727
r5931r5932
2929   sectors = bootsector[0x18];
3030   heads = bootsector[0x1a];
3131   tracks = (bootsector[0x13] | (bootsector[0x14] << 8)) / sectors / heads;
32   
32
3333   memset(&geometry, 0, sizeof(geometry));
3434   geometry.heads = heads;
3535   geometry.first_sector_id = 1;
3636   geometry.sector_length = 512;
3737   geometry.tracks = tracks;
3838   geometry.sectors = sectors;
39   return basicdsk_construct(floppy, &geometry);   
39   return basicdsk_construct(floppy, &geometry);
4040}
4141
4242/* ----------------------------------------------------------------------- */
src/mess/formats/pc_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/pc_dsk.h
3    formats/pc_dsk.h
44
5   PC disk images
5    PC disk images
66
77*********************************************************************/
88
src/mess/formats/thom_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/thom_dsk.c
3    formats/thom_dsk.c
44
5   Thomson disk images
6   
7   Based on work of  Antoine Mine'
5    Thomson disk images
86
7    Based on work of  Antoine Mine'
8
99*********************************************************************/
1010
1111#include <string.h>
r5931r5932
5050   char header[0x100];
5151   floppy_image_read(floppy, header, 1, sizeof(sap_header));
5252   if (!memcmp( header, sap_header, sizeof(sap_header) ) )
53   {     
53   {
5454      *vote= 100;
5555   } else {
5656      *vote = 0;
r5931r5932
8282      return FLOPPY_ERROR_SEEKERROR;
8383
8484   offs = 0x42 + track * ((get_tag(floppy)->sector_size + 6)* 16) + sector * (get_tag(floppy)->sector_size + 6) + 4;
85   if (offset)
85   if (offset)
8686      *offset = offs;
8787   return FLOPPY_ERROR_SUCCESS;
8888}
r5931r5932
9393{
9494   UINT64 offset;
9595   floperr_t err;
96   int i;   
96   int i;
9797   UINT8 *buf;
9898   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
9999   if (err)
r5931r5932
171171   UINT64 offset = 0;
172172   sector_index += 1;
173173   err = get_offset(floppy, head, track, sector_index, FALSE, &offset);
174   
174
175175   floppy_image_read(floppy, header, offset-4, 4);
176176   if (cylinder)
177177      *cylinder = header[2];
r5931r5932
214214   callbacks->get_heads_per_disk = sap_get_heads_per_disk;
215215   callbacks->get_tracks_per_disk = sap_get_tracks_per_disk;
216216   callbacks->get_indexed_sector_info = sap_get_indexed_sector_info;
217   
218   return FLOPPY_ERROR_SUCCESS;   
217
218   return FLOPPY_ERROR_SUCCESS;
219219}
220220
221221static FLOPPY_IDENTIFY(qdd_dsk_identify)
r5931r5932
225225}
226226
227227/* fixed interlacing map for QDDs */
228static int thom_qdd_map[400];
228static int thom_qdd_map[400];
229229
230230static int qdd_translate_sector(floppy_image *floppy, int sector)
231231{
r5931r5932
259259static FLOPPY_CONSTRUCT(qdd_dsk_construct)
260260{
261261   struct basicdsk_geometry geometry;
262   
262
263263   thom_qdd_compute_map();
264   
264
265265   memset(&geometry, 0, sizeof(geometry));
266266   geometry.heads = 1;
267267   geometry.first_sector_id = 1;
r5931r5932
269269   geometry.tracks = 1;
270270   geometry.sectors = 400;
271271   geometry.translate_sector =  qdd_translate_sector;
272   return basicdsk_construct(floppy, &geometry);   
272   return basicdsk_construct(floppy, &geometry);
273273}
274274
275275
276276/* ----------------------------------------------------------------------- */
277277
278278FLOPPY_OPTIONS_START(thomson)
279   FLOPPY_OPTION(qdd,"qd", "Thomson QDD floppy disk image",   qdd_dsk_identify, qdd_dsk_construct,
279   FLOPPY_OPTION(qdd,"qd", "Thomson QDD floppy disk image",   qdd_dsk_identify, qdd_dsk_construct,
280280      HEADS([1])
281281      TRACKS([1])
282282      SECTORS([400])
src/mess/formats/coco_cas.c
r5931r5932
11/**************************************************************************
22
3   coco_cas.c
3    coco_cas.c
44
5   Format code for CoCo CAS (*.cas) files
5    Format code for CoCo CAS (*.cas) files
66
7   This is the actual code that processes the CAS data.  CAS files are   a
8   problem because they are a legacy of previous CoCo emulators, and most
9   of these emulators patch the system as a shortcut.  Thus, the ones and
10   zeroes in the file do not truly represent modulated pulses in the
11   waveform, but what the BIOS reads and writes.
7    This is the actual code that processes the CAS data.  CAS files are a
8    problem because they are a legacy of previous CoCo emulators, and most
9    of these emulators patch the system as a shortcut.  Thus, the ones and
10    zeroes in the file do not truly represent modulated pulses in the
11    waveform, but what the BIOS reads and writes.
1212
13   In doing so, they make the CoCo more tolerant of short headers and lack
14   of delays between blocks.  This legacy is reflected in most CAS files in
13    In doing so, they make the CoCo more tolerant of short headers and lack
14    of delays between blocks.  This legacy is reflected in most CAS files in
1515    use, and thus presents a problem for a pure hardware emulation like MESS.
1616
17   One alternative is to preprocess the data on the CAS, file by file, but
18   this proves to be problematic because in the process, legitimate data
19   that is unrecognized by the preprocessor may get dropped.
17    One alternative is to preprocess the data on the CAS, file by file, but
18    this proves to be problematic because in the process, legitimate data
19    that is unrecognized by the preprocessor may get dropped.
2020
21   The approach taken here is a hybrid approach - it retrieves the data
22   block by block until an error occurs; be it the end of the CAS or a
23   corrupt (?!) block.  When "legitimate" blocks are done processing, the
24   remainder of the data is added to the waveform in a traditional manner.
25   The result has proven to work quite well.
21    The approach taken here is a hybrid approach - it retrieves the data
22    block by block until an error occurs; be it the end of the CAS or a
23    corrupt (?!) block.  When "legitimate" blocks are done processing, the
24    remainder of the data is added to the waveform in a traditional manner.
25    The result has proven to work quite well.
2626
27   2005-May-04, P.Harvey-Smith, improved handling of some "copy protected"
28   Dragon games that have odd blocks in odd places, this has slightly
29   increased loading time but does mean games like "Rommel's Revenge" will
30   now load.
27    2005-May-04, P.Harvey-Smith, improved handling of some "copy protected"
28    Dragon games that have odd blocks in odd places, this has slightly
29    increased loading time but does mean games like "Rommel's Revenge" will
30    now load.
3131
3232**************************************************************************/
3333
src/mess/formats/lviv_lvt.h
r5931r5932
11/*********************************************************************
22
3   lviv_lvt.h
3    lviv_lvt.h
44
5   Format code for Lviv casette files
5    Format code for Lviv casette files
66
77*********************************************************************/
88
src/mess/formats/imd_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/imd_dsk.c
3    formats/imd_dsk.c
44
5   IMD disk images
5    IMD disk images
66
77*********************************************************************/
88
r5931r5932
6565   UINT8 header[5];
6666   UINT8 sector_num;
6767   int i;
68   
69   
68
69
7070   if ((head < 0) || (head >= get_tag(floppy)->heads) || (track < 0) || (track >= get_tag(floppy)->tracks)
7171         || (sector < 0) )
7272      return FLOPPY_ERROR_SEEKERROR;
73   
73
7474   offs = imd_get_track_offset(floppy,head,track);
7575   floppy_image_read(floppy, header, offs, 5);
7676
r5931r5932
7979   if(header[2] & 0x80) offs += sector_num; // skip cylinder numbering map
8080   if(header[2] & 0x40) offs += sector_num; // skip head numbering map
8181   get_tag(floppy)->sector_size = 1 << (header[4] + 7);
82   for(i=0;i<sector;i++) {   
82   for(i=0;i<sector;i++) {
8383      floppy_image_read(floppy, header, offs, 1); // take sector data type
8484      switch(header[0]) {
8585         case 0: offs++; break;
r5931r5932
8888         case 5:
8989         case 7: offs += get_tag(floppy)->sector_size + 1; break;
9090         default: offs += 2;
91      }         
92   }     
91      }
92   }
9393   if (offset)
9494      *offset = offs;
9595   return FLOPPY_ERROR_SUCCESS;
r5931r5932
100100static floperr_t internal_imd_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
101101{
102102   UINT64 offset;
103   floperr_t err;   
103   floperr_t err;
104104   UINT8 header[1];
105   
105
106106   // take sector offset
107107   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
108108   if (err)
109109      return err;
110   
111   floppy_image_read(floppy, header, offset, 1);   
110
111   floppy_image_read(floppy, header, offset, 1);
112112   switch(header[0]) {
113113      case 0: break;
114114      case 1:
115115      case 3:
116116      case 5:
117      case 7:
117      case 7:
118118            floppy_image_read(floppy, buffer, offset+1, buflen);
119119            break;
120         
120
121121      default: // all data same
122122            floppy_image_read(floppy, header, offset+1, 1);
123123            memset(buffer,header[0],buflen);
124124            break;
125   }         
126   
125   }
126
127127   return FLOPPY_ERROR_SUCCESS;
128128}
129129
r5931r5932
145145   if (err)
146146      return err;
147147
148   if (sector_length) {     
148   if (sector_length) {
149149      *sector_length = get_tag(floppy)->sector_size;
150150   }
151151   return FLOPPY_ERROR_SUCCESS;
r5931r5932
159159   UINT8 tr;
160160   UINT32 sector_size;
161161   UINT8 sector_num;
162   
162
163163   offset = imd_get_track_offset(floppy,head,track);
164164   floppy_image_read(floppy, header, offset, 5);
165165   tr = header[1];
r5931r5932
196196   }
197197   if (flags) {
198198      UINT8 skip;
199      if (head & 0x40) {         
199      if (head & 0x40) {
200200         if (head & 0x80) {
201            skip = 3;           
201            skip = 3;
202202         } else {
203203            skip = 2;
204         }         
204         }
205205      } else {
206206         skip = 1;
207      }     
207      }
208208      floppy_image_read(floppy, header, offset + 5 + skip * sector_num, 1);
209209      *flags = 0;
210210      if ((header[0]-1) & 0x02) *flags |= ID_FLAG_DELETED_DATA;
211      if ((header[0]-1) & 0x04) *flags |= ID_FLAG_CRC_ERROR_IN_DATA_FIELD;     
211      if ((header[0]-1) & 0x04) *flags |= ID_FLAG_CRC_ERROR_IN_DATA_FIELD;
212212   }
213213   return FLOPPY_ERROR_SUCCESS;
214214}
r5931r5932
219219   struct FloppyCallbacks *callbacks;
220220   struct imddsk_tag *tag;
221221   UINT8 header[0x100];
222   UINT64 pos = 0;   
222   UINT64 pos = 0;
223223   int sector_size = 0;
224224   int sector_num;
225225   int i;
r5931r5932
228228      // create
229229      return FLOPPY_ERROR_UNSUPPORTED;
230230   }
231   
231
232232   tag = (struct imddsk_tag *) floppy_create_tag(floppy, IMD_DSK_TAG, sizeof(struct imddsk_tag));
233233   if (!tag)
234234      return FLOPPY_ERROR_OUTOFMEMORY;
r5931r5932
249249      if(header[2] & 0x80) pos += sector_num; // skip cylinder numbering map
250250      if(header[2] & 0x40) pos += sector_num; // skip head numbering map
251251      sector_size = 1 << (header[4] + 7);
252      for(i=0;i<sector_num;i++) {   
252      for(i=0;i<sector_num;i++) {
253253         floppy_image_read(floppy, header, pos, 1); // take sector data type
254254         switch(header[0]) {
255255            case 0: pos++; break;
r5931r5932
258258            case 5:
259259            case 7: pos += sector_size + 1; break;
260260            default: pos += 2;break;
261         }         
262      }   
263      tag->tracks += 1;   
261         }
262      }
263      tag->tracks += 1;
264264   } while(pos < floppy_image_size(floppy));
265   
265
266266   callbacks = floppy_callbacks(floppy);
267267   callbacks->read_sector = imd_read_sector;
268268   callbacks->read_indexed_sector = imd_read_indexed_sector;
src/mess/formats/primoptp.c
r5931r5932
1616#define PRIMO_BIT_1_LENGTH      (PRIMO_BIT_1_PERIOD*PRIMO_WAV_FREQUENCY)
1717#define PRIMO_BIT_0_LENGTH      (PRIMO_BIT_0_PERIOD*PRIMO_WAV_FREQUENCY)
1818/*
19#define PRIMO_BIT_1_LENGTH      6
20#define PRIMO_BIT_0_LENGTH      16
19#define PRIMO_BIT_1_LENGTH      6
20#define PRIMO_BIT_0_LENGTH      16
2121*/
2222#define PRIMO_PAUSE_LENGTH      2000
2323#define PRIMO_FILE_PILOT_LENGTH      ((4*PRIMO_BIT_1_LENGTH + 4*PRIMO_BIT_0_LENGTH)*512)
r5931r5932
102102      logerror ("File size (with header): %d\n", file_size);
103103
104104      /* b is now set on the first data byte of file
105         it means first byte (type) of block */
105           it means first byte (type) of block */
106106
107107      j = 0;
108108      while (j < file_size-3)
r5931r5932
173173      logerror ("File size: %d\n", file_size);
174174
175175      /* b is now set on the first data byte of file
176         it means first byte (block type) of block header */
176           it means first byte (block type) of block header */
177177
178178      j = 0;
179179      while (j < file_size-3)
src/mess/formats/atarist_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/atarist_dsk.h
3    formats/atarist_dsk.h
44
5   atarist disk images
5    atarist disk images
66
77*********************************************************************/
88
src/mess/formats/coco_cas.h
r5931r5932
11/*********************************************************************
22
3   coco_cas.h
3    coco_cas.h
44
5   Format code for CoCo CAS (*.cas) files
5    Format code for CoCo CAS (*.cas) files
66
77*********************************************************************/
88
src/mess/formats/primoptp.h
r5931r5932
11/*********************************************************************
22
3   primoptp.h
3    primoptp.h
44
5   Format code for Primo casette files
5    Format code for Primo casette files
66
77*********************************************************************/
88
src/mess/formats/dsk_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/dsk_dsk.c
3    formats/dsk_dsk.c
44
5   DSK disk images
5    DSK disk images
66
77*********************************************************************/
88
src/mess/formats/pmd_pmd.h
r5931r5932
11/*********************************************************************
22
3   pmd_pmd.h
3    pmd_pmd.h
44
5   Format code for PMD-85 casette files
5    Format code for PMD-85 casette files
66
77*********************************************************************/
88
src/mess/formats/cassimg.c
r5931r5932
11/*********************************************************************
22
3   cassimg.c
3    cassimg.c
44
5   Cassette tape image abstraction code
5    Cassette tape image abstraction code
66
77*********************************************************************/
88
r5931r5932
2929
3030
3131/*********************************************************************
32   helper code
32    helper code
3333*********************************************************************/
3434
3535static double map_double(double d, UINT64 low, UINT64 high, UINT64 value)
r5931r5932
5252
5353
5454/*********************************************************************
55   extrapolation and interpolation
55    extrapolation and interpolation
5656*********************************************************************/
5757
5858static INT32 extrapolate8(INT8 value)
r5931r5932
7878
7979
8080/*********************************************************************
81   initialization and termination
81    initialization and termination
8282*********************************************************************/
8383
8484static cassette_image *cassette_init(running_machine *machine,const struct CassetteFormat *format, void *file, const struct io_procs *procs, int flags)
r5931r5932
301301
302302
303303/*********************************************************************
304   calls for accessing the raw cassette image
304    calls for accessing the raw cassette image
305305*********************************************************************/
306306
307307void cassette_image_read(cassette_image *cassette, void *buffer, UINT64 offset, size_t length)
r5931r5932
326326
327327
328328/*********************************************************************
329   waveform accesses
329    waveform accesses
330330*********************************************************************/
331331
332332struct manipulation_ranges
r5931r5932
433433
434434
435435/*********************************************************************
436   waveform accesses
436    waveform accesses
437437*********************************************************************/
438438
439439casserr_t cassette_get_samples(cassette_image *cassette, int channel,
r5931r5932
598598
599599
600600/*********************************************************************
601   waveform accesses to/from the raw image
601    waveform accesses to/from the raw image
602602*********************************************************************/
603603
604604casserr_t cassette_read_samples(cassette_image *cassette, int channels, double time_index,
r5931r5932
682682
683683
684684/*********************************************************************
685   waveform accesses to/from the raw image
685    waveform accesses to/from the raw image
686686*********************************************************************/
687687
688688static const INT8 *choose_wave(const struct CassetteModulation *modulation, size_t *wave_bytes_length)
r5931r5932
868868
869869
870870/*********************************************************************
871   waveform accesses to/from the raw image
871    waveform accesses to/from the raw image
872872*********************************************************************/
873873
874874casserr_t cassette_legacy_identify(cassette_image *cassette, struct CassetteOptions *opts,
r5931r5932
10231023
10241024
10251025/*********************************************************************
1026   cassette_dump
1026    cassette_dump
10271027
1028   A debugging call to dump a casette image to a disk based wave file
1028    A debugging call to dump a casette image to a disk based wave file
10291029*********************************************************************/
10301030
10311031void cassette_dump(cassette_image *image, const char *filename)
src/mess/formats/zx81_p.c
r5931r5932
211211static casserr_t zx81_p_load(cassette_image *cassette)
212212{
213213   /* The filename of the file is used to create the wave stream for the emulated machine. Why is this information not
214      part of the image file itself?
215      Hardcoding this to "cassette".
216   */
214       part of the image file itself?
215       Hardcoding this to "cassette".
216    */
217217   zx81_fill_file_name ("cassette" /*image_basename_noext(device_list_find_by_tag( Machine->config->devicelist, CASSETTE, "cassette" ))*/ );
218218   return cassette_legacy_construct(cassette, &zx81_legacy_fill_wave);
219219}
src/mess/formats/vt_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/vt_dsk.c
3    formats/vt_dsk.c
44
5   VTech Laser/VZ disk images
5    VTech Laser/VZ disk images
66
77*********************************************************************/
88
src/mess/formats/cassimg.h
r5931r5932
11/*********************************************************************
22
3   cassimg.h
3    cassimg.h
44
5   Cassette tape image abstraction code
5    Cassette tape image abstraction code
66
77*********************************************************************/
88
r5931r5932
1414
1515/***************************************************************************
1616
17   Constants
17    Constants
1818
1919***************************************************************************/
2020
r5931r5932
4949
5050/***************************************************************************
5151
52   Type definitions
52    Type definitions
5353
5454***************************************************************************/
5555
r5931r5932
9898   struct sample_block *blocks;
9999   size_t block_count;
100100   size_t sample_count;
101   
101
102102   running_machine *machine;
103103};
104104
r5931r5932
159159
160160/***************************************************************************
161161
162   Prototypes
162    Prototypes
163163
164164***************************************************************************/
165165
src/mess/formats/oric_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/oric_dsk.c
3    formats/oric_dsk.c
44
5   Oric disk images
5    Oric disk images
66
77*********************************************************************/
88
r5931r5932
3333   int heads;
3434   int geometry;
3535   int tracksize;
36   int num_sectors;   
36   int num_sectors;
3737   struct mfm_disk_sector_info   sector_data[32];
3838};
3939
r5931r5932
4949static FLOPPY_IDENTIFY(oric_dsk_identify)
5050{
5151   UINT8 header[mfm_disk_header_size];
52   
52
5353   floppy_image_read(floppy, header, 0, mfm_disk_header_size);
54   if ( memcmp( header, MFM_ID, 8 ) ==0) {     
54   if ( memcmp( header, MFM_ID, 8 ) ==0) {
5555      int heads  = pick_integer_le(header, 8, 4);
5656      int tracks = pick_integer_le(header, 12, 4);
57           
57
5858      if (floppy_image_size(floppy)==((tracks*heads*TRACK_SIZE_MFM)+mfm_disk_header_size)) {
5959         *vote = 100;
6060      } else {
r5931r5932
6565   }
6666   return FLOPPY_ERROR_SUCCESS;
6767}
68static int oric_get_track_offset(floppy_image *floppy,int track, int head)
68static int oric_get_track_offset(floppy_image *floppy,int track, int head)
6969{
70   if (get_tag(floppy)->geometry==1) {     
70   if (get_tag(floppy)->geometry==1) {
7171      return mfm_disk_header_size + (get_tag(floppy)->tracksize * track) + (head * get_tag(floppy)->tracksize * get_tag(floppy)->tracks);
7272   } else {
7373      return mfm_disk_header_size + (get_tag(floppy)->tracksize*((track * get_tag(floppy)->heads)+head));
r5931r5932
8787static void mfm_info_cache_sector_info(floppy_image *floppy,int track,int head)
8888{
8989   UINT8 track_data[TRACK_SIZE_MFM];
90   
90
9191   /* initialise these with single density values if single density */
9292   UINT8 IdMark = 0x0fe;
9393   UINT8 DataMark = 0x0fb;
r5931r5932
100100   int track_offset = oric_get_track_offset(floppy,track,head);
101101   floppy_image_read(floppy, track_data, track_offset, TRACK_SIZE_MFM);
102102   SectorCount = 0;
103   
103
104104   do
105105   {
106106      switch (SearchCode)
r5931r5932
160160            break;
161161      }
162162   }
163   while (ptr < TRACK_SIZE_MFM);   
163   while (ptr < TRACK_SIZE_MFM);
164164   get_tag(floppy)->num_sectors = SectorCount;
165165
166166}
r5931r5932
168168static floperr_t get_offset(floppy_image *floppy, int head, int track, int sector, int sector_is_index, UINT64 *offset)
169169{
170170   UINT64 offs;
171   
171
172172   /* translate the sector to a raw sector */
173173   if (!sector_is_index)
174174   {
175175      sector -= 1;
176176   }
177177   mfm_info_cache_sector_info(floppy,track,head);
178   
178
179179   /* check to see if we are out of range */
180180   if ((head < 0) || (head >= get_tag(floppy)->heads) || (track < 0) || (track >= get_tag(floppy)->tracks)
181181         || (sector < 0) || (sector >=get_tag(floppy)->num_sectors))
182182      return FLOPPY_ERROR_SEEKERROR;
183   
183
184184   offs = get_tag(floppy)->sector_data[sector].data_ptr;
185185   if (offset)
186186      *offset = offs;
r5931r5932
192192static floperr_t internal_oric_read_sector(floppy_image *floppy, int head, int track, int sector, int sector_is_index, void *buffer, size_t buflen)
193193{
194194   UINT64 offset;
195   floperr_t err;   
195   floperr_t err;
196196   err = get_offset(floppy, head, track, sector, sector_is_index, &offset);
197197   if (err)
198198      return err;
r5931r5932
239239
240240static floperr_t oric_get_sector_length(floppy_image *floppy, int head, int track, int sector, UINT32 *sector_length)
241241{
242   floperr_t err;   
242   floperr_t err;
243243   err = get_offset(floppy, head, track, sector, FALSE, NULL);
244244   if (err)
245245      return err;
r5931r5932
255255static floperr_t oric_get_indexed_sector_info(floppy_image *floppy, int head, int track, int sector_index, int *cylinder, int *side, int *sector, UINT32 *sector_length, unsigned long *flags)
256256{
257257   floperr_t retVal;
258   
258
259259   sector_index += 1;
260   
260
261261   retVal = oric_get_sector_length(floppy, head, track, sector_index, sector_length);
262   if (sector_length!=NULL) {   
262   if (sector_length!=NULL) {
263263      *sector_length =  get_tag(floppy)->sector_data[sector_index-1].sector_size;
264264   }
265265   if (cylinder)
r5931r5932
267267   if (side)
268268      *side = head;
269269   if (sector)
270      *sector = sector_index;   
270      *sector = sector_index;
271271   if (flags)
272272      *flags = get_tag(floppy)->sector_data[sector_index].ddam;
273273   return retVal;
r5931r5932
279279   struct FloppyCallbacks *callbacks;
280280   struct oricdsk_tag *tag;
281281   UINT8 header[mfm_disk_header_size];
282   
282
283283   floppy_image_read(floppy, header, 0, mfm_disk_header_size);
284   
284
285285   tag = (struct oricdsk_tag *) floppy_create_tag(floppy, ORICDSK_TAG, sizeof(struct oricdsk_tag));
286286   if (!tag)
287287      return FLOPPY_ERROR_OUTOFMEMORY;
288     
288
289289   tag->heads   = pick_integer_le(header, 8, 4);
290290   tag->tracks  = pick_integer_le(header, 12, 4);
291291   tag->geometry = pick_integer_le(header, 16, 4);
292292   tag->tracksize = TRACK_SIZE_MFM;
293293   memset(tag->sector_data,0,sizeof(tag->sector_data));
294         
294
295295   callbacks = floppy_callbacks(floppy);
296296   callbacks->read_sector = oric_read_sector;
297297   callbacks->write_sector = oric_write_sector;
r5931r5932
300300   callbacks->get_sector_length = oric_get_sector_length;
301301   callbacks->get_heads_per_disk = oric_get_heads_per_disk;
302302   callbacks->get_tracks_per_disk = oric_get_tracks_per_disk;
303   callbacks->get_indexed_sector_info = oric_get_indexed_sector_info;   
304   return FLOPPY_ERROR_SUCCESS;   
303   callbacks->get_indexed_sector_info = oric_get_indexed_sector_info;
304   return FLOPPY_ERROR_SUCCESS;
305305}
306306/* ----------------------------------------------------------------------- */
307307
src/mess/formats/zx81_p.h
r5931r5932
11/*********************************************************************
22
3   zx81_p.h
3    zx81_p.h
44
5   Format code for ZX-81 casette files
5    Format code for ZX-81 casette files
66
77*********************************************************************/
88
src/mess/formats/cpis_dsk.c
r5931r5932
11/*********************************************************************
22
3   formats/cpis_dsk.c
3    formats/cpis_dsk.c
44
5   Telenova Compis disk images
5    Telenova Compis disk images
66
77*********************************************************************/
88
src/mess/formats/vt_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/vt_dsk.h
3    formats/vt_dsk.h
44
5   Tandy Color Computer / Dragon disk images
5    Tandy Color Computer / Dragon disk images
66
77*********************************************************************/
88
src/mess/formats/oric_tap.c
r5931r5932
8888}
8989
9090
91/*   each byte on cassette is stored as:
91/*  each byte on cassette is stored as:
9292
93   start bit      0 * 1
94   data bits      8 * x (x is 0 or 1, and depends on data-bit value)
95   parity bit      1 * x (x is 0 or 1, and depends on the parity of the data bits)
96   stop bits      1 * 3
93    start bit       0 * 1
94    data bits       8 * x (x is 0 or 1, and depends on data-bit value)
95    parity bit      1 * x (x is 0 or 1, and depends on the parity of the data bits)
96    stop bits       1 * 3
9797
98   if data has even parity, parity bit will be 1.
99   if data has odd parity, parity bit will be 0.
98    if data has even parity, parity bit will be 1.
99    if data has odd parity, parity bit will be 0.
100100*/
101101
102102/*
103   512 * data byte 0x016      -> leader
104   1   * data byte 0x024      -> sync byte
105   9   * data byte          -> header
106   delay (of last pulse written)
107   x   * data byte         -> length
103    512 * data byte 0x016       -> leader
104    1   * data byte 0x024       -> sync byte
105    9   * data byte             -> header
106    delay (of last pulse written)
107    x   * data byte         -> length
108108
109109
110   header structure:
111   3   * ?         ->      ???
112   1   * ?         ->      ???
113   1   * x         ->      end address high byte
114   1   * x         ->      end address low byte
115   1   * x         ->      start address high byte
116   1   * x         ->      start address low byte
117   1   * ?         ->      ???
110    header structure:
111    3   * ?         ->      ???
112    1   * ?         ->      ???
113    1   * x         ->      end address high byte
114    1   * x         ->      end address low byte
115    1   * x         ->      start address high byte
116    1   * x         ->      start address low byte
117    1   * ?         ->      ???
118118*/
119119
120120static int oric_calculate_byte_size_in_samples(UINT8 byte)
r5931r5932
361361
362362   /* header and trailer act as pauses */
363363   /* the trailer is required so that the via sees the last bit of the last
364      byte */
364        byte */
365365    if (bytes == CODE_HEADER) {
366366        for (i = 0; i < ORIC_WAVESAMPLES_HEADER; i++)
367367            *(p++) = WAVEENTRY_NULL;
r5931r5932
449449               logerror("got end of filename\n");
450450
451451               /* oric includes a small delay, but I don't see
452               it being 1 bits */
452                    it being 1 bits */
453453               for (i=0; i<100; i++)
454454               {
455455                                            p = oric_output_bit(p,1);
src/mess/formats/oric_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/oric_dsk.h
3    formats/oric_dsk.h
44
5   Oric disk images
5    Oric disk images
66
77*********************************************************************/
88
src/mess/formats/cpis_dsk.h
r5931r5932
11/*********************************************************************
22
3   formats/cpis_dsk.h
3    formats/cpis_dsk.h
44
5   Telenova Compis disk images
5    Telenova Compis disk images
66
77*********************************************************************/
88
src/mess/formats/cbm_tap.c
r5931r5932
11/*
2   
3   Tape support for C16 / C64 / VIC20 TAP format
42
3    Tape support for C16 / C64 / VIC20 TAP format
54
6   Credits to:
7   
8      - Peter Schepers for the informations on C64 formats
9      - Vice Team for the source of their very complete emulator
10      - Attila G. for tap2wav (both the source and the actual tool)
115
12   
13   TODO:
14   * to verify and fix (if needed) support for .TAP v2
15   * to implement reading (and logging) the remaining part of the header
16   * to verify if it is more accurate to use a different HIGH_WAVE value
17     when the pulse corresponds to a 0x00 in the .TAP file
18   (...)
19   * (far away in the future) can this code be merged with TZX code?
6    Credits to:
207
8        - Peter Schepers for the informations on C64 formats
9        - Vice Team for the source of their very complete emulator
10        - Attila G. for tap2wav (both the source and the actual tool)
11
12
13    TODO:
14    * to verify and fix (if needed) support for .TAP v2
15    * to implement reading (and logging) the remaining part of the header
16    * to verify if it is more accurate to use a different HIGH_WAVE value
17      when the pulse corresponds to a 0x00 in the .TAP file
18    (...)
19    * (far away in the future) can this code be merged with TZX code?
20
2121*/
2222
23/* Info based on http://ist.uwaterloo.ca/~schepers/formats/TAP.TXT       */
24/* Please refer to the webpage for the latest version and for a very
25   complete listing of various cart types and their bankswitch tricks    */
23/* Info based on http://ist.uwaterloo.ca/~schepers/formats/TAP.TXT      */
24/* Please refer to the webpage for the latest version and for a very
25   complete listing of various cart types and their bankswitch tricks   */
2626/*
2727
2828  Designed by Per Hakan Sundell (author of the CCS64 C64 emulator) in 1997,
r5931r5932
8686[ Additional notes on v.2:
8787
8888  I found no documents about this around, but it seems an expansion of the
89format specifically thought for C16 tapes. In a .TAP version 2, each byte
89format specifically thought for C16 tapes. In a .TAP version 2, each byte
9090only stores informations on half of the wave...
9191Unfortunately, I have no such a .tap file to test, so my implementation
9292below could be not working.  FP ]
r5931r5932
132132
133133
134134/* This in fact gives the number of samples for half of the pulse */
135INLINE int tap_data_to_samplecount(int data, int frequency)
135INLINE int tap_data_to_samplecount(int data, int frequency)
136136{
137//   return (int) (0.5 * (0.5 + (((double)CBM_WAV_FREQUENCY / frequency) * (double)data)));      // MESS TZX formula
137//  return (int) (0.5 * (0.5 + (((double)CBM_WAV_FREQUENCY / frequency) * (double)data)));      // MESS TZX formula
138138   return (int) (0.5 * (((double)CBM_WAV_FREQUENCY / frequency) * (double)((data) + 0.5)));   // tap2wav formula
139139}
140140
141141/* The version with parameters could be handy if we decide to implement a
142142different values for byte == 0x00 below (the WAVE_PAUSE) as tap2wav does. */
143143#if 0
144static void toggle_wave_data(int low, int high)
144static void toggle_wave_data(int low, int high)
145145{
146146   wave_data = (wave_data == low) ? high : low;
147147}
148148#endif
149149
150static void toggle_wave_data(void )
150static void toggle_wave_data(void )
151151{
152152   wave_data = (wave_data == WAVE_HIGH) ? WAVE_LOW : WAVE_HIGH;
153153}
154154
155static void cbm_output_wave( INT16 **buffer, int length )
155static void cbm_output_wave( INT16 **buffer, int length )
156156{
157   if (buffer == NULL)
157   if (buffer == NULL)
158158      return;
159   
160   for( ; length > 0; length-- )
159
160   for( ; length > 0; length-- )
161161   {
162162      **buffer = wave_data;
163163      *buffer = *buffer + 1;
r5931r5932
167167
168168static int cbm_tap_do_work( INT16 **buffer, int length, const UINT8 *data )
169169{
170   int i, j = 0;
170   int i, j = 0;
171171   int size = 0;
172172
173173   int version = data[0x0c];
r5931r5932
178178   int byte_samples = 0;
179179   UINT8 over_pulse_bytes[3] = {0 , 0, 0 };
180180   int over_pulse_length = 0;
181   /* These waveamp_* values are currently stored but not used.
182     Further investigations are needed to find real pulse amplitude
183     in Commodore tapes. Implementation here would follow */
181   /* These waveamp_* values are currently stored but not used.
182      Further investigations are needed to find real pulse amplitude
183      in Commodore tapes. Implementation here would follow */
184184   /* int waveamp_high, waveamp_low; */
185185
186186   /* Log .TAP info but only once */
r5931r5932
188188   {
189189      logerror("TAP version    : %d\n", version);
190190      logerror("Machine type   : %d\n", system);
191      logerror("Video standard : %d\n", video_standard);   
191      logerror("Video standard : %d\n", video_standard);
192192      logerror("Tape frequency : %d\n", (tap_frequency) << 3);
193193   }
194194
r5931r5932
223223    }
224224
225225
226   for (i = CBM_HEADER_SIZE; i < length; i++)
226   for (i = CBM_HEADER_SIZE; i < length; i++)
227227   {
228228      UINT8 byte = data[i];
229229
230230      /* .TAP v0 */
231      /* Here is simple:
232        if byte is != 0 -> length = byte
233        otherwise -> length =  0x100 (i.e. 0xff + 1) */
231      /* Here is simple:
232          if byte is != 0 -> length = byte
233          otherwise -> length =  0x100 (i.e. 0xff + 1) */
234234      if (!version)
235235      {
236         if (byte != 0x00)
236         if (byte != 0x00)
237237         {
238238            byte_samples = tap_data_to_samplecount(byte, tap_frequency);
239239            /* waveamp_high = WAVE_HIGH; */
240         }
241         else
240         }
241         else
242242         {
243243            byte_samples = tap_data_to_samplecount(PAUSE, tap_frequency);   // tap2wav value
244//            byte_samples = tap_data_to_samplecount(0x100, tap_frequency);   // vice value         
244//              byte_samples = tap_data_to_samplecount(0x100, tap_frequency);   // vice value
245245            /* waveamp_high = WAVE_PAUSE; */
246246         }
247247         /* waveamp_low = WAVE_LOW; */
r5931r5932
249249
250250      /* .TAP v1 & v2 */
251251      /* Here is a bit more complicate:
252        if byte is != 0 -> length = byte
253        otherwise -> the length of the pulse is stored as a 24bit value in the 3 bytes after the 0.
254        See below for comments on the implementation of this mechanism */
252          if byte is != 0 -> length = byte
253          otherwise -> the length of the pulse is stored as a 24bit value in the 3 bytes after the 0.
254          See below for comments on the implementation of this mechanism */
255255      if (version)
256256      {
257257         if ((byte != 0x00) && !j)
258258         {
259259            byte_samples = tap_data_to_samplecount(byte, tap_frequency);
260260            /* waveamp_high = WAVE_HIGH; */
261         }
262         else
261         }
262         else
263263         {
264            /* If we have a long pulse close to the end of the .TAP, check that bytes still
265              to be read are enough to complete it. */
264            /* If we have a long pulse close to the end of the .TAP, check that bytes still
265                  to be read are enough to complete it. */
266266            if (length - i + j >= 4)
267            {   
267            {
268268               /* Here we read the 3 following bytes, using an index j
269                 j = 0 -> The 0x00 byte: we simply skip everything and go on
270                 j = 1,2 -> The 1st and 2nd bytes after 0x00: we store them and go on
271                 j = 3 -> The final byte of the pulse length: we store it,
272                 and then we pass to finally output the wave */
269                      j = 0 -> The 0x00 byte: we simply skip everything and go on
270                      j = 1,2 -> The 1st and 2nd bytes after 0x00: we store them and go on
271                      j = 3 -> The final byte of the pulse length: we store it,
272                      and then we pass to finally output the wave */
273273               if (j > 0)
274274               {
275275                  over_pulse_bytes[j-1] = byte;
r5931r5932
286286               else
287287               {
288288                  j += 1;
289                  logerror("Found a 00 byte close to the end of the .tap file.\n");
289                  logerror("Found a 00 byte close to the end of the .tap file.\n");
290290                  logerror("This is not allowed by the format specs. \n");
291291                  logerror("Check if your .tap file got corrupted when you created it!\n");
292292               }
r5931r5932
300300      {
301301         cbm_output_wave( buffer, byte_samples );
302302         size += byte_samples;
303//         toggle_wave_data(waveamp_low, waveamp_high);
303//          toggle_wave_data(waveamp_low, waveamp_high);
304304         toggle_wave_data();
305305         if (version < 2)
306306         {
307307            cbm_output_wave( buffer, byte_samples );
308308            size += byte_samples;
309//            toggle_wave_data(waveamp_low, waveamp_high);
309//              toggle_wave_data(waveamp_low, waveamp_high);
310310            toggle_wave_data();
311311         }
312312      }
r5931r5932
316316}
317317
318318
319static int cbm_tap_to_wav_size( const UINT8 *tapdata, int taplen )
319static int cbm_tap_to_wav_size( const UINT8 *tapdata, int taplen )
320320{
321321   int size = cbm_tap_do_work(NULL, taplen, tapdata);
322322   len = taplen;
323   
323
324324   return size;
325325}
326326
327static int cbm_tap_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
328{   
327static int cbm_tap_fill_wave( INT16 *buffer, int length, UINT8 *bytes )
328{
329329   INT16 *p = buffer;
330330
331331   return cbm_tap_do_work(&p, len, (const UINT8 *)bytes);
r5931r5932
345345};
346346
347347
348static casserr_t cbm_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
348static casserr_t cbm_cassette_identify( cassette_image *cassette, struct CassetteOptions *opts )
349349{
350350   return cassette_legacy_identify( cassette, opts, &cbm_legacy_fill_wave );
351351}
352352
353353
354static casserr_t cbm_cassette_load( cassette_image *cassette )
354static casserr_t cbm_cassette_load( cassette_image *cassette )
355355{
356356   return cassette_legacy_construct( cassette, &cbm_legacy_fill_wave );
357357}
src/mess/formats/oric_tap.h
r5931r5932
11/*********************************************************************
22
3   oric_tap.h
3    oric_tap.h
44
5   Format code for Oric TAP (*.tap) files
5    Format code for Oric TAP (*.tap) files
66
77*********************************************************************/
88
src/mess/formats/cbm_tap.h
r5931r5932
11/*********************************************************************
22
3   cbm_tap.h
3    cbm_tap.h
44
5   Format code for CBM .tap files
5    Format code for CBM .tap files
66
77*********************************************************************/
88
src/mess/formats/jupi_tap.c
r5931r5932
9898      /* Handle a block of tape data */
9999      block_size = casdata[data_pos] + ( casdata[data_pos + 1] << 8 );
100100      data_pos += 2;
101     
101
102102      /* Make sure there are enough bytes left */
103103      if ( data_pos > cas_size )
104104         return -1;
src/mess/formats/basicdsk.c
r5931r5932
11/*********************************************************************
22
3   formats/basicdsk.c
3    formats/basicdsk.c
44
5   Floppy format code for basic disks
5    Floppy format code for basic disks
66
77*********************************************************************/
88
r5931r5932
248248{
249249   const struct basicdsk_geometry *geom;
250250   geom = get_geometry(floppy);
251   
251
252252   sector_index += get_geometry(floppy)->first_sector_id;
253253   if (cylinder)
254254      *cylinder = track;
r5931r5932
260260      /* TODO: read DAM or DDAM and determine flags */
261261      *flags = 0;
262262      if (geom->get_ddam)
263         *flags = geom->get_ddam(floppy, geom, track, head, sector_index);     
263         *flags = geom->get_ddam(floppy, geom, track, head, sector_index);
264264   }
265265   return basicdsk_get_sector_length(floppy, head, track, sector_index, sector_length);
266266}
src/mess/formats/a26_cas.h
r5931r5932
11/*
2   a26_cas.h
2    a26_cas.h
33
4   Format code for a2600 SuperCharger cassette files
4    Format code for a2600 SuperCharger cassette files
55*/
66
77#ifndef A26_CAS_H
src/mess/formats/basicdsk.h
r5931r5932
11/*********************************************************************
22
3   formats/basicdsk.h
3    formats/basicdsk.h
44
5   Floppy format code for basic disks
5    Floppy format code for basic disks
66
77*********************************************************************/
88
src/mess/formats/thom_cas.c
r5931r5932
243243      {
244244         cassette_image_read( cass, &in, pos, 1 );
245245         /* actually, we are bit laxist and treat as 0xff bytes with at least
246            5 bits out of 8 set to 1
247         */
246               5 bits out of 8 set to 1
247            */
248248         for ( i = 0; in; in >>= 1 )
249249            i += (in & 1);
250250         if ( i < 5 )
r5931r5932
313313   }
314314
315315   /* trailing data with invalid block structure
316      => dump it in a raw form, but stay alert for hidden block starts
317   */
316       => dump it in a raw form, but stay alert for hidden block starts
317    */
318318   if ( pos < size )
319319   {
320320      invalid++;
src/mess/drivers/hp48.c
r5931r5932
2525   - some bits I/O RAM not implemented
2626   - printer
2727   - more accurate timing (accurate SATURN cycles, speedup when screen is off)
28   - save-state: figure what RAM to store & where (currently, when exiting,
29   base RAM is saved as nvram, RAM in expansion ports is saved as image,
30   IO RAM is & CPU state are discarded; save-state saves base & IO RAM,
28   - save-state: figure what RAM to store & where (currently, when exiting,
29   base RAM is saved as nvram, RAM in expansion ports is saved as image,
30   IO RAM is & CPU state are discarded; save-state saves base & IO RAM,
3131   CPU state, but not expansion port RAM)
3232   - more accurate IRQ, NMI, sleep and wake-up handling
3333*/
r5931r5932
6969  - clock speed: 2 MHz
7070  - 256 KB ROM (various revisions, identical in S and SX)
7171
72  - S model specific:
72  - S model specific:
7373    + Codename: Shorty
7474    + 32 KB RAM base, not expandable (in theory)
7575    + no expansion port
r5931r5932
9292
9393  - GX model specific:
9494    + Codename: Hammer
95    + 128 KB base RAM, expandable up to 4 MB (banked)
95    + 128 KB base RAM, expandable up to 4 MB (banked)
9696    + 2 expansion ports
9797      . port 1: up to 128 KB RAM, can be merged with base RAM
9898      . port 2: up to   4 MB RAM, in 32 banks of 128 KB, cannot be merged
r5931r5932
105105*/
106106
107107
108/*
108/*
109109   More about memory.
110110
111   The base RAM is treated as NVRAM: stored in a .nv file in your nvram
111   The base RAM is treated as NVRAM: stored in a .nv file in your nvram
112112   directory.
113113   When first starting the emulator, or after nvram file has been deleted,
114114   you'll get a "Try to recover memory?". This is expected.
r5931r5932
116116   system-reserved RAM part correctly.
117117   If the emulator is shut down properly (i.e., when the calculator is
118118   not busy), the message should not appear next time it is run.
119   All the variables and port 0 should be conserved (in the .nv file),
119   All the variables and port 0 should be conserved (in the .nv file),
120120   but not the stack.
121   Stopping and restarting the emulator loosely corresponds to hitting the
121   Stopping and restarting the emulator loosely corresponds to hitting the
122122   reset button.
123123
124124   Expansion RAMs are treated as images, not NVRAM.
r5931r5932
136136  kermit communication program (xmodem is also allowed for the G/GX).
137137  We emulate both the serial link and the communication program.
138138  Thus, the emulated HP48 can directly upload/download image files.
139  The -k image option corresponds to the kermit protocol (SEND and RECV
139  The -k image option corresponds to the kermit protocol (SEND and RECV
140140  commands on the HP48).
141  The -x image option corresponds to the xmodem protocol (XSEND and XRECV
141  The -x image option corresponds to the xmodem protocol (XSEND and XRECV
142142  commands on the HP48).
143143*/
144144
r5931r5932
148148
149149  References:
150150
151  - Voyage au centre de la HP48 S/SX, by Paul Courbis & Sébastien Lalande
152    (English version: HP48 machine language - a journey to the center
151  - Voyage au centre de la HP48 S/SX, by Paul Courbis & S?bastien Lalande
152    (English version: HP48 machine language - a journey to the center
153153     of the HP48 s/sx)
154154    available at http://www.courbis.com
155155
r5931r5932
177177    keyboard layout (all models)
178178
179179   -------------------------------------------------
180   |   A   |   B   |   C   |   D   |   E   |   F   |
180   |   A   |   B   |   C   |   D   |   E   |   F   |
181181   |-------+-------+-------+-------+-------+-------|
182   |  MTH  |  PRG  |  CST  |  VAR  |   up  |  NXT  |
182   |  MTH  |  PRG  |  CST  |  VAR  |   up  |  NXT  |
183183   |-------+-------+-------+-------+-------+-------|
184   |   '   |  STO  |  EVAL |  left | down  | right |
184   |   '   |  STO  |  EVAL |  left | down  | right |
185185   |-------+-------+-------+-------+-------+-------|
186   |  SIN  |  COS  |  TAN  |  sqrt |  y^x  |  1/x  |
186   |  SIN  |  COS  |  TAN  |  sqrt |  y^x  |  1/x  |
187187   |---------------+-------+-------+-------+-------|
188   |     ENTER     |  +/-  |  EEX  |  DEL  |  <=   |
188   |     ENTER     |  +/-  |  EEX  |  DEL  |  <=   |
189189   |-----------------------------------------------|
190   |  alpha  |   7    |    8   |    9    |    /    |
190   |  alpha  |   7    |    8   |    9    |    /    |
191191   |---------+--------+--------+---------+---------|
192   |   red   |   4    |    5   |    6    |    *    |
192   |   red   |   4    |    5   |    6    |    *    |
193193   |---------+--------+--------+---------+---------|
194   |  green  |   1    |    2   |    3    |    -    |
194   |  green  |   1    |    2   |    3    |    -    |
195195   |---------+--------+--------+---------+---------|
196   |   ON    |   0    |    .   |   SPC   |    +    |
196   |   ON    |   0    |    .   |   SPC   |    +    |
197197   -------------------------------------------------
198198
199199   * 49 keys
r5931r5932
203203     - a  white alpha key (lower right)
204204
205205   Difference between G and S series: a few red and blue shifted keys.
206
206
207207*/
208208
209209/* S/SX */
r5931r5932
903903
904904/* In memory, nibbles are unpacked: one nibble at each address.
905905   This is due to the way the SATURN emulation is done.
906   As a consequence only the 4 lower bits of each byte is used, the 4 higher
906   As a consequence only the 4 lower bits of each byte is used, the 4 higher
907907   bits being zeros.
908908   Another consequence is that ROMs must be unpacked before use.
909909
910   Because of the complex memory manager, actual address mapping is done at
910   Because of the complex memory manager, actual address mapping is done at
911911   run-time.
912912 */
913913
914914static ADDRESS_MAP_START ( hp48, ADDRESS_SPACE_PROGRAM, 8 )
915 
915
916916   AM_RANGE( 0x00000, 0xfffff ) AM_NOP /* configured at run-time */
917917
918918ADDRESS_MAP_END
r5931r5932
925925{
926926   hp48_reg_out, hp48_reg_in,
927927   hp48_mem_reset, hp48_mem_config, hp48_mem_unconfig, hp48_mem_id,
928   hp48_mem_crc,
928   hp48_mem_crc,
929929   hp48_rsi
930930};
931931
r5931r5932
949949   MDRV_CPU_ADD ( "maincpu", SATURN, 3937007 ) /* almost 4 MHz */
950950   MDRV_CPU_PROGRAM_MAP ( hp48)
951951   MDRV_CPU_CONFIG( hp48_config )
952
952
953953   /* memory */
954954   MDRV_NVRAM_HANDLER( generic_0fill )
955955
r5931r5932
978978   /* expansion ports */
979979   MDRV_HP48_PORT_ADD ( "port1", hp48gx_port1_config )
980980   MDRV_HP48_PORT_ADD ( "port2", hp48gx_port2_config )
981     
981
982982   /* serial I/O */
983983   MDRV_XMODEM_ADD( "rs232_x", hp48_xmodem_rs232_conf )
984984   MDRV_KERMIT_ADD( "rs232_k", hp48_kermit_rs232_conf )
src/mess/drivers/c65.c
r5931r5932
1010
1111/*
1212
132008 - Driver Updates
132008 - Driver Updates
1414---------------------
1515
1616(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
r5931r5932
2020
2121* Commodore 65 (1989)
2222
23Also known as C64 DX at early stages of the project. It was cancelled
24around 1990-1991. Only few units survive (they were sold after Commodore
23Also known as C64 DX at early stages of the project. It was cancelled
24around 1990-1991. Only few units survive (they were sold after Commodore
2525liquidation in 1994).
2626
2727CPU: CSG 4510 (3.54 MHz)
2828RAM: 128 kilobytes, expandable to 8 megabytes
2929ROM: 128 kilobytes
30Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to
31   1280x400; 80 columns text; Palette of 4096 colors)
32Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound
33   capabilities)
34Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER'
35   port; CBM Monitor port; Power and reset switches; C65 bus drive
36   port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65
37   expansion port)
30Video: CSG 4569 "VIC-III" (6 Video modes; Resolutions from 320x200 to
31    1280x400; 80 columns text; Palette of 4096 colors)
32Sound: CSG 8580 "SID" x2 (6 voice stereo synthesizer/digital sound
33    capabilities)
34Ports: CSG 4510 (2 Joystick/Mouse ports; CBM Serial port; CBM 'USER'
35    port; CBM Monitor port; Power and reset switches; C65 bus drive
36    port; RGBI video port; 2 RCA audio ports; RAM expansion port; C65
37    expansion port)
3838Keyboard: Full-sized 77 key QWERTY (12 programmable function keys;
39   4 direction cursor-pad)
39    4 direction cursor-pad)
4040Additional Hardware: Built in 3.5" DD disk drive (1581 compatible)
4141Miscellaneous: Partially implemented Commodore 64 emulation
4242
4343[Notes]
4444
45The datasette port was removed here. C65 supports an additional "dumb"
46drive externally. It also features, in addition to the standard CBM
47bus serial (available in all modes), a Fast and a Burst serial bus
45The datasette port was removed here. C65 supports an additional "dumb"
46drive externally. It also features, in addition to the standard CBM
47bus serial (available in all modes), a Fast and a Burst serial bus
4848(both available in C65 mode only)
4949
5050*/
r5931r5932
115115   PORT_INCLUDE( common_cbm_keyboard )      /* ROW0 -> ROW7 */
116116
117117   PORT_START("FUNCT")
118   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1)     
119   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11)   
120   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10)   
121   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9)   
122   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12)     
118   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ESC") PORT_CODE(KEYCODE_F1)
119   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F13 F14") PORT_CODE(KEYCODE_F11)
120   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F11 F12") PORT_CODE(KEYCODE_F10)
121   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("F9 F10") PORT_CODE(KEYCODE_F9)
122   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("HELP") PORT_CODE(KEYCODE_F12)
123123   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("ALT") PORT_CODE(KEYCODE_F2)      /* non blocking */
124124   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("TAB") PORT_CODE(KEYCODE_TAB)
125125   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("NO SCRL") PORT_CODE(KEYCODE_F4)
r5931r5932
132132
133133static INPUT_PORTS_START( c65ger )
134134   PORT_INCLUDE( c65 )
135   
135
136136   PORT_MODIFY( "ROW1" )
137137   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Z  { Y }") PORT_CODE(KEYCODE_Z)               PORT_CHAR('Z')
138138   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("3  #  { 3  Paragraph }") PORT_CODE(KEYCODE_3)      PORT_CHAR('3') PORT_CHAR('#')
r5931r5932
242242   /* cia */
243243   MDRV_CIA6526_ADD("cia_0", CIA6526R1, 3500000, c65_ntsc_cia0)
244244   MDRV_CIA6526_ADD("cia_1", CIA6526R1, 3500000, c65_ntsc_cia1)
245   
245
246246   /* floppy from serial bus */
247247   MDRV_IMPORT_FROM(simulated_drive)
248248
src/mess/drivers/glasgow.c
r5931r5932
9393{
9494   UINT8 lcd_data = data >> 8;
9595
96   if (led7 == 0)
96   if (led7 == 0)
9797      output_set_digit_value(lcd_shift_counter, lcd_data);
9898
9999   lcd_shift_counter--;
100100   lcd_shift_counter &= 3;
101//   logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
101//  logerror("LCD Offset = %d Data low = %x \n", offset, lcd_data);
102102}
103103
104104static WRITE16_HANDLER( write_beeper )
r5931r5932
107107
108108   lcd_invert = 1;
109109   beep_flag = data >> 8;
110//   if ((beep_flag & 02) == 0) key_selector = 0; else key_selector = 1;
110//  if ((beep_flag & 02) == 0) key_selector = 0; else key_selector = 1;
111111   logerror("Write Beeper = %x \n", data);
112112   beeper = data;
113113}
r5931r5932
128128   lcd_invert = 0;
129129   lcd_flag=data >> 8;
130130   //beep_set_state(0, lcd_flag & 1 ? 1 : 0);
131   if (lcd_flag == 0)
131   if (lcd_flag == 0)
132132      key_selector = 1;
133133
134134 // The key function in the rom expects after writing to
135135 // the  a value from the second key row;
136   if (lcd_flag != 0)
136   if (lcd_flag != 0)
137137      led7 = 255;
138   else
138   else
139139      led7 = 0;
140140
141141   logerror("LCD Flag 16 = %x \n", data);
r5931r5932
148148
149149   beep_set_state(speaker, lcd_flag & 1 ? 1 : 0);
150150
151   if (lcd_flag == 0)
151   if (lcd_flag == 0)
152152      key_selector = 1;
153153
154   if (lcd_flag != 0)
154   if (lcd_flag != 0)
155155      led7 = 255;
156   else
156   else
157157      led7 = 0;
158158
159//   logerror("LCD Flag gg = %x \n", lcd_flag);
159//  logerror("LCD Flag gg = %x \n", lcd_flag);
160160}
161161
162162static WRITE16_HANDLER( write_keys )
163163{
164164   key_select = data >> 8;
165//   logerror("Write Key = %x \n", data);
165//  logerror("Write Key = %x \n", data);
166166}
167167
168168static READ16_HANDLER( read_board )
r5931r5932
176176
177177   board_value = board;
178178
179   if (board == 0xff)
179   if (board == 0xff)
180180      key_selector = 0;
181//   The key function in the rom expects after writing to
182//   the chess board a value from  the first key row;
181//  The key function in the rom expects after writing to
182//  the chess board a value from  the first key row;
183183   logerror("Write Board = %x \n", data >> 8);
184184}
185185
r5931r5932
241241{
242242   UINT16 data;
243243
244   if (key_selector == 0)
244   if (key_selector == 0)
245245      data = input_port_read(space->machine, "LINE0");
246   else
246   else
247247      data = input_port_read(space->machine, "LINE1");
248248
249249   logerror("read Keyboard Offset = %x Data = %x Select = %x \n", offset, data, key_selector);
r5931r5932
274274   read_board_flag = TRUE;
275275   logerror("read_board_data = %x \n", data);
276276
277//   return 0xff00;   // Mephisto need it for working
277//  return 0xff00;   // Mephisto need it for working
278278
279279   return data;
280280}
r5931r5932
286286   UINT16 LineAH = 0;
287287   UINT8 LED;
288288
289//   logerror("Write Board   = %x \n  ",data);
289//  logerror("Write Board   = %x \n  ",data);
290290
291291   LineAH = data >> 8;
292292
293293   if (LineAH && Line18_LED)
294294   {
295//   logerror("Line18_LED   = %x \n  ",Line18_LED);
296//   logerror("LineAH   = %x \n  ",LineAH);
295//  logerror("Line18_LED   = %x \n  ",Line18_LED);
296//  logerror("LineAH   = %x \n  ",LineAH);
297297
298298      for (i_AH = 0; i_AH < 8; i_AH++)
299299      {
r5931r5932
303303            {
304304               if (!(Line18_LED & (1 << i_18)))
305305               {
306//                  logerror("i_18   = %d \n  ",i_18);
307//                  logerror("i_AH   = %d \n  ",i_AH);
308//                  logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
306//                      logerror("i_18   = %d \n  ",i_18);
307//                      logerror("i_AH   = %d \n  ",i_AH);
308//                      logerror("LED an:   = %d \n  ",m_board[i_18][i_AH]);
309309
310310                  LED = m_board[i_18][i_AH].field;
311311                  output_set_led_value(LED, 1);
r5931r5932
366366
367367   lcd_invert = 0;
368368
369   if (lcd_flag == 0)
369   if (lcd_flag == 0)
370370      key_selector = 1;
371371
372372   logerror("LCD Flag 32 = %x \n", lcd_flag);
373373   //beep_set_state(0, lcd_flag & 1 ? 1 : 0);
374374
375   if (lcd_flag != 0)
375   if (lcd_flag != 0)
376376      led7 = 255;
377   else
377   else
378378      led7 = 0;
379379}
380380
r5931r5932
390390{
391391   UINT32 data;
392392
393   if (key_selector == 0)
393   if (key_selector == 0)
394394      data = input_port_read(space->machine, "LINE0");
395   else
395   else
396396      data = input_port_read(space->machine, "LINE1");
397397   //if (key_selector == 1) data = input_port_read(machine, "LINE0"); else data = 0;
398398   logerror("read Keyboard Offset = %x Data = %x\n", offset, data);
r5931r5932
418418{
419419   UINT8 board;
420420   board = data >> 24;
421   if (board == 0xff)
421   if (board == 0xff)
422422      key_selector = 0;
423423   logerror("Write Board = %x \n", data);
424424}
r5931r5932
571571
572572   /* video hardware */
573573   MDRV_DEFAULT_LAYOUT(layout_glasgow)
574   
574
575575   MDRV_SPEAKER_STANDARD_MONO("mono")
576576   MDRV_SOUND_ADD("beep", BEEP, 0)
577577   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
src/mess/drivers/thomson.c
r5931r5932
644644
645645/* ------------ config ------------ */
646646
647static SYSTEM_CONFIG_START ( to )     
647static SYSTEM_CONFIG_START ( to )
648648     CONFIG_DEVICE ( thom_serial_getinfo )
649649SYSTEM_CONFIG_END
650650
r5931r5932
725725    MDRV_ACIA6850_ADD( "acia6850", to7_modem )
726726
727727    MDRV_WD2793_ADD("wd2793", default_wd17xx_interface )
728   
728
729729   MDRV_FLOPPY_4_DRIVES_ADD(thomson_floppy_config)
730730
731731   /* cartridge */
r5931r5932
10911091
10921092/* ------------ config ------------ */
10931093
1094static SYSTEM_CONFIG_START ( mo )     
1094static SYSTEM_CONFIG_START ( mo )
10951095     CONFIG_DEVICE ( thom_serial_getinfo )
10961096SYSTEM_CONFIG_END
10971097
src/mess/drivers/c128.c
r5931r5932
1010
1111/*
1212
132008 - Driver Updates
132008 - Driver Updates
1414---------------------
1515
1616(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
r5931r5932
2323CPU: CSG 8502 (1 or 2 MHz), Z80 (~3 MHz)
2424RAM: 128 kilobytes
2525ROM: 72 kilobytes expandable
26Video: MOS 8564 "VIC-IIE", MOS 8563 "VDC" CTRC (40/80 columns text; Palette of 16
27   colors; Hires modes 320 x 200, 640 x 200, 16k of dedicated VDC RAM)
28Sound: MOS 8580 "SID" (3 voice stereo synthesizer/digital sound
29   capabilities)
30Ports: MOS 6526 CIA x2 (2 Joystick/Mouse ports; CBM Serial port; CBM
31   Datasette port; parallel programmable "User" port; CBM Monitor port;
32   C64 expansion port; Warm reset switch; Keyboard port; Power switch)
33Keyboard: Full-sized 93 key QWERTY (14 key numeric keypad; 8 programmable
34   function keys + HELP; 4 direction 4-key cursor-pad)
26Video: MOS 8564 "VIC-IIE", MOS 8563 "VDC" CTRC (40/80 columns text; Palette of 16
27    colors; Hires modes 320 x 200, 640 x 200, 16k of dedicated VDC RAM)
28Sound: MOS 8580 "SID" (3 voice stereo synthesizer/digital sound
29    capabilities)
30Ports: MOS 6526 CIA x2 (2 Joystick/Mouse ports; CBM Serial port; CBM
31    Datasette port; parallel programmable "User" port; CBM Monitor port;
32    C64 expansion port; Warm reset switch; Keyboard port; Power switch)
33Keyboard: Full-sized 93 key QWERTY (14 key numeric keypad; 8 programmable
34    function keys + HELP; 4 direction 4-key cursor-pad)
3535
3636Upgrade kits were sold to upgrade the VDC RAM to 64k using a passthrough board
3737that the VDC sat in.
r5931r5932
4040* Commodore 128CR (prototype from June, 1986)
4141
4242  Basically, a C128 in a redesigned board to reduce production costs. It's
43not clear when it's been produced, nor if it has ever been produced on
43not clear when it's been produced, nor if it has ever been produced on
4444large scale. Its BIOS is an intermediate revision between rev. 0 and rev. 1
4545in the main C128.
4646A picture of the PCB can be found here:
r5931r5932
5353
5454* Commodore 128D (1985)
5555
56  Designed in the US, but only sold in Europe, it is a C128 in a desktop
56  Designed in the US, but only sold in Europe, it is a C128 in a desktop
5757case, with built-in 1571 disk drive (upgraded with a special software to
5858discourage pirating software). Some NTSC prototypes exist.
5959
6060CPU: CSG 8502 (1 or 2 MHz), Z80 (~3 MHz), 6502 (co-processor for disk
61   drive)
61    drive)
6262RAM: 128 kilobytes
6363ROM: 72 kilobytes expandable
64Video: MOS 8564 "VIC-IIE", MOS 8563 "VDC" CTRC (40/80 columns text; Palette of 16
65   colors; Hires modes 320 x 200, 640 x 200, 64k of dedicated VDC RAM)
66Sound: MOS 8580 "SID" (3 voice stereo synthesizer/digital sound
67   capabilities)
68Ports: MOS 6526 CIA x2 (2 Joystick/Mouse ports; CBM Serial port; CBM
69   Datasette port; parallel programmable "User" port; CBM Monitor port;
70   C64 expansion port; Warm reset switch; Keyboard port; Power switch)
71Keyboard: Full-sized 93 key QWERTY (14 key numeric keypad; 8 programmable
72   function keys + HELP; 4 direction 4-key cursor-pad)
73Additional Hardware: Internal 1571 disk drive (Double sided/Double Density
74   360k; capable of reading GCR and MFM formats)
64Video: MOS 8564 "VIC-IIE", MOS 8563 "VDC" CTRC (40/80 columns text; Palette of 16
65    colors; Hires modes 320 x 200, 640 x 200, 64k of dedicated VDC RAM)
66Sound: MOS 8580 "SID" (3 voice stereo synthesizer/digital sound
67    capabilities)
68Ports: MOS 6526 CIA x2 (2 Joystick/Mouse ports; CBM Serial port; CBM
69    Datasette port; parallel programmable "User" port; CBM Monitor port;
70    C64 expansion port; Warm reset switch; Keyboard port; Power switch)
71Keyboard: Full-sized 93 key QWERTY (14 key numeric keypad; 8 programmable
72    function keys + HELP; 4 direction 4-key cursor-pad)
73Additional Hardware: Internal 1571 disk drive (Double sided/Double Density
74    360k; capable of reading GCR and MFM formats)
7575
7676
7777* Commodore 128DCR (1986)
7878
7979  Basically, a C128D in a redesigned board to reduce production costs. It's
80the only model sold in the US, but it's quite possible that it came later
80the only model sold in the US, but it's quite possible that it came later
8181in Europe as well (being cheaper to produce).
8282
8383
r5931r5932
8686  NTSC prototype for an improved version of C128D, featuring a built-in 1581
8787disk drive in place of the 1571 used in C128D / C128DCR. The prototype has no
8888given name, so C128D/81 is just a reasonable way to indicate it. The case is
89from a PAL C128D and the board is a heavily modified PAL board with hand
89from a PAL C128D and the board is a heavily modified PAL board with hand
9090soldered connections to make it NTSC.
9191
9292
r5931r5932
104104
105105* C128 Mode
106106
107  Various missing features (e.g. no cpu clock doubling; no internal function
108rom; serial bus doesn't support printer or other devices; no C128 cart
107  Various missing features (e.g. no cpu clock doubling; no internal function
108rom; serial bus doesn't support printer or other devices; no C128 cart
109109expansions are supported; no userport; no rs232/v.24 interface)
110110
111111* Informations / BIOS / Supported Sets:
112112
113113- Was C128D using rev. 1 BIOS in 4 ROMs? I guessed so because the board has the
114same desing as a C128, and later C128DCR still used rev. 1 BIOS (only contained
114same desing as a C128, and later C128DCR still used rev. 1 BIOS (only contained
115115in two ROMs)
116116
117117- Is it possible to track down and dump properly C128 PAL BIOSes? Current sets
118are mostly tagged as bad dumps because obtained by extracting the content in
118are mostly tagged as bad dumps because obtained by extracting the content in
119119pieces. I'd like to have confirmation that the common parts are really the same
120120before removing the flag.
121121
122- PAL BIOSes are from C128? C128D? or C128DCR? Were there differences in the
123contents between them, except for being splitted in 2 or 4 parts? Were all
122- PAL BIOSes are from C128? C128D? or C128DCR? Were there differences in the
123contents between them, except for being splitted in 2 or 4 parts? Were all
124124versions sold in each country? Right now we choose to support the following sets
125125(more to be added if BIOS content confirmed):
126126
r5931r5932
128128we support c128drde, c128drit and c128drsw.
129129
130130+ We also have a dump of the German C128, therefore we support the c128ger, even
131if it's not clear which BASIC version it was shipped with. We assumed the older
132kernal to be shipped with rev. 0 and the newer with rev. 1.
131if it's not clear which BASIC version it was shipped with. We assumed the older
132kernal to be shipped with rev. 0 and the newer with rev. 1.
133133
134+ The Finnish, French and Norwegian dumps came with no notes (or these have been
135lost). Therefore we support only the c128 for these, i.e. c128fin, c128fre and
134+ The Finnish, French and Norwegian dumps came with no notes (or these have been
135lost). Therefore we support only the c128 for these, i.e. c128fin, c128fre and
136136c128nor.
137137
138138+ Character ROM for Belgium, Italy and French was the same (I/F/B on the label,
r5931r5932
148148
149149c128 / c128d
150150
151   U18       (read compatible 2764?) 8kB c64 character rom, c128 character rom
152   U32 23128 (read compatible 27128?) 16kB c64 Basic, c64 Kernel
153   U33 23128 (read compatible 27128?) 16kB c128 Basic at 0x4000
154   U34 23128 (read compatible 27128?) 16kB c128 Basic at 0x8000
155   U35   23128 (read compatible 27128?) 16kB c128 Editor, Z80BIOS, c128 Kernel
151    U18       (read compatible 2764?) 8kB c64 character rom, c128 character rom
152    U32 23128 (read compatible 27128?) 16kB c64 Basic, c64 Kernel
153    U33 23128 (read compatible 27128?) 16kB c128 Basic at 0x4000
154    U34 23128 (read compatible 27128?) 16kB c128 Basic at 0x8000
155    U35 23128 (read compatible 27128?) 16kB c128 Editor, Z80BIOS, c128 Kernel
156156
157157c128cr / c128dcr
158158
159   U18       (read compatible 2764?) 8kB c64 character rom, c128 character rom
160   U32 23256 (read compatible 27256?) 32kB c64 Basic + Kernel, c128 Editor, Z80BIOS, c128 Kernel
161   U34 23256 (read compatible 27256?) 32kB c128 Basic
159    U18       (read compatible 2764?) 8kB c64 character rom, c128 character rom
160    U32 23256 (read compatible 27256?) 32kB c64 Basic + Kernel, c128 Editor, Z80BIOS, c128 Kernel
161    U34 23256 (read compatible 27256?) 32kB c128 Basic
162162
163163c128d / c128dcr also need:
164164
165   U102 23256 (read compatible 27256?) 32kB 1571 system rom
165    U102 23256 (read compatible 27256?) 32kB 1571 system rom
166166
167167
168It would be also possible to dump the BIOS in monitor, but it would be preferable
168It would be also possible to dump the BIOS in monitor, but it would be preferable
169169to use an EEPROM reader, in order to obtain a dump of the whole content.
170170*/
171171
r5931r5932
321321   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_DEL_PAD)         PORT_CHAR(UCHAR_MAMEKEY(DEL_PAD))
322322   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0_PAD)          PORT_CHAR(UCHAR_MAMEKEY(0_PAD))
323323   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Alt") PORT_CODE(KEYCODE_F6) PORT_CHAR(UCHAR_MAMEKEY(LALT))
324   
324
325325   PORT_INCLUDE( c128_special )         /* SPECIAL */
326326
327327   PORT_INCLUDE( c64_controls )         /* CTRLSEL, JOY0, JOY1, PADDLE0 -> PADDLE3, TRACKX, TRACKY, LIGHTX, LIGHTY, OTHER */
r5931r5932
634634   /* cia */
635635   MDRV_CIA6526_ADD("cia_0", CIA6526R1, VIC6567_CLOCK, c128_ntsc_cia0)
636636   MDRV_CIA6526_ADD("cia_1", CIA6526R1, VIC6567_CLOCK, c128_ntsc_cia1)
637   
637
638638   /* floppy from serial bus */
639639   MDRV_IMPORT_FROM(simulated_drive)
640640
r5931r5932
730730
731731ROM_START( c128cr )
732732   /* C128CR prototype, owned by Bo Zimmers
733      PCB markings: "COMMODORE 128CR REV.3 // PCB NO.252270" and "PCB ASSY NO.250783"
733       PCB markings: "COMMODORE 128CR REV.3 // PCB NO.252270" and "PCB ASSY NO.250783"
734734           Sticker on rom cart shield: "C128CR  No.2 // ENG. SAMPLE // Jun/9/'86   KNT"
735      3 ROMs (combined basic, combined c64/kernal, plain character rom)
736      6526A-1 CIAs
737      ?prototype? 2568R1X VDC w/ 1186 datecode
738   */
735       3 ROMs (combined basic, combined c64/kernal, plain character rom)
736       6526A-1 CIAs
737       ?prototype? 2568R1X VDC w/ 1186 datecode
738    */
739739   ROM_REGION( 0x132800, "maincpu", 0 )
740   ROM_LOAD( "252343-03.u34", 0x100000, 0x8000, CRC(bc07ed87) SHA1(0eec437994a3f2212343a712847213a8a39f4a7b) )         // BASIC lo + hi, "252343-03 // U34"
741   ROM_LOAD( "252343-04.u32", 0x108000, 0x8000, CRC(cc6bdb69) SHA1(36286b2e8bea79f7767639fd85e12c5447c7041b) )         // C64 OS ROM + Kernal, "252343-04 // US // U32"
740   ROM_LOAD( "252343-03.u34", 0x100000, 0x8000, CRC(bc07ed87) SHA1(0eec437994a3f2212343a712847213a8a39f4a7b) )         // BASIC lo + hi, "252343-03 // U34"
741   ROM_LOAD( "252343-04.u32", 0x108000, 0x8000, CRC(cc6bdb69) SHA1(36286b2e8bea79f7767639fd85e12c5447c7041b) )         // C64 OS ROM + Kernal, "252343-04 // US // U32"
742742   ROM_LOAD( "390059-01.u18", 0x120000, 0x2000, CRC(6aaaafe6) SHA1(29ed066d513f2d5c09ff26d9166ba23c2afb2b3f) )         // Character, "MOS // (C)1985 CBM // 390059-01 // M468613 8547H"
743743
744744   ROM_REGION( 0x10000, "m8502", ROMREGION_ERASEFF )
src/mess/drivers/c16.c
r5931r5932
1010
1111/*
1212
132008 - Driver Updates
132008 - Driver Updates
1414---------------------
1515
1616(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
r5931r5932
2828RAM: 16 kilobytes (expandable to 64k internally)
2929ROM: 32 kilobytes
3030Video: MOS Technology 7360 "TED" (5 Video modes; Max. Resolution 320x200;
31   40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
32Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
33Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
34   Port and switch; CBM Monitor port; Power and reset switches; Power
35   connector)
36Keyboard: QWERTY 62 key "membrane" (8 programmable function keys; 4 direction
37   cursor-pad)
31    40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
32Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
33Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
34    Port and switch; CBM Monitor port; Power and reset switches; Power
35    connector)
36Keyboard: QWERTY 62 key "membrane" (8 programmable function keys; 4 direction
37    cursor-pad)
3838
3939
4040* Commodore 16 (1984)
4141
42  Redesigned version of the C116, with a different case and a different
42  Redesigned version of the C116, with a different case and a different
4343keyboard.
4444
4545CPU: MOS Technology 7501 (variable clock rate, with max 1.76 MHz)
4646RAM: 16 kilobytes (expandable to 64k internally)
4747ROM: 32 kilobytes
4848Video: MOS Technology 7360 "TED" (5 Video modes; Max. Resolution 320x200;
49   40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
50Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
51Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
52   Port and switch; CBM Monitor port; Power and reset switches; Power
53   connector)
49    40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
50Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
51Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
52    Port and switch; CBM Monitor port; Power and reset switches; Power
53    connector)
5454Keyboard: QWERTY 66 key typewriter style (8 programmable function keys;
55   4 direction cursor-pad)
55    4 direction cursor-pad)
5656
5757
5858* Commodore Plus/4 (1984)
5959
6060  This system became the middle tier of the Commodore 264 family, replacing
6161the original Commodore 264. The Plus/4 is basically the same as the C264,
62but the name refers to the four built-in programs which came with the
62but the name refers to the four built-in programs which came with the
6363machine: Word Processing, Spreadsheet, Database software, Graphing package.
6464
6565CPU: MOS Technology 7501 (variable clock rate, with max 1.76 MHz)
6666RAM: 64 kilobytes (expandable to 64k internally)
6767ROM: 64 kilobytes
6868Video: MOS Technology 7360 "TED" (5 Video modes; Max. Resolution 320x200;
69   40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
70Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
71Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
72   Port and switch; CBM Monitor port; Power and reset switches; Power
73   connector)
69    40 columns text; Palette of 16 colors in 8 shades, for 128 colors)
70Sound: MOS Technology 7360 "TED" (2 voice tone-generating sound capabilities)
71Ports: MOS 7360 (2 Joystick/Mouse ports; CBM Serial port; 'TED' port; "TV"
72    Port and switch; CBM Monitor port; Power and reset switches; Power
73    connector)
7474Keyboard: Full-sized QWERTY 67 key (8 programmable function keys;
75   4 direction cursor-pad)
75    4 direction cursor-pad)
7676
7777
7878* Commodore 232 (1984, Prototype)
7979
80  This system never reached the production and only few units exist. It is
80  This system never reached the production and only few units exist. It is
8181in between the C16 and the C264, with its 32 kilobytes of RAM.
8282
8383
r5931r5932
8989* Commodore V364 (1984, Prototype)
9090
9191  This system was supposed to become the high-end system of the family,
92featuring 64 kilobytes of RAM, the same technology of the Plus/4, a
92featuring 64 kilobytes of RAM, the same technology of the Plus/4, a
9393keyboard with numeric keypad and built in voice synthesis capabilities.
9494
9595[TO DO]
r5931r5932
268268
269269   PORT_MODIFY("ROW1")
270270   /* Both Shift keys were mapped to the same bit */
271   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left & Right)") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)   
271   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("Shift (Left & Right)") PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT)
272272
273273   PORT_MODIFY("ROW4")
274274   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_NAME("0  \xE2\x86\x91") PORT_CODE(KEYCODE_0)      PORT_CHAR('0') PORT_CHAR(0x2191)
r5931r5932
303303   PORT_INCLUDE( c16 )
304304
305305   /* no real floppy */
306   
306
307307   PORT_MODIFY( "ROW0" )
308308   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)               PORT_CHAR(0xA3)
309309   PORT_MODIFY( "ROW5" )
r5931r5932
329329   PORT_INCLUDE( plus4 )
330330
331331   /* no real floppy */
332   
332
333333   PORT_MODIFY("CFG1")
334334   PORT_BIT( 0x10, 0x10, IPT_UNUSED )         /* ntsc */
335335   PORT_BIT( 0x0c, 0x08, IPT_UNUSED )         /* 364 */
r5931r5932
374374   c1551_0_write_handshake,
375375   NULL,
376376   NULL,
377   NULL   
377   NULL
378378};
379379
380380static const tpi6525_interface c16_tpi6525_tpi_2_c1551_intf =
r5931r5932
400400   c1551_1_write_handshake,
401401   NULL,
402402   NULL,
403   NULL   
403   NULL
404404};
405405
406406static const m6502_interface c16_m7501_interface =
r5931r5932
462462static MACHINE_DRIVER_START( c16c )
463463   MDRV_IMPORT_FROM( c16 )
464464
465   /* c16c uses 'real' floppy drive emulation from machine/vc1541.c...
466   still in progress, atm */
465   /* c16c uses 'real' floppy drive emulation from machine/vc1541.c...
466    still in progress, atm */
467467   MDRV_DEVICE_REMOVE("tpi6535_tpi_2")
468468   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_c1551_intf)
469469
r5931r5932
512512static MACHINE_DRIVER_START( plus4c )
513513   MDRV_IMPORT_FROM( plus4 )
514514
515   /* plus4c uses 'real' floppy drive emulation from machine/vc1541.c...
516   still in progress, atm */
515   /* plus4c uses 'real' floppy drive emulation from machine/vc1541.c...
516    still in progress, atm */
517517   MDRV_DEVICE_REMOVE("tpi6535_tpi_2")
518518   MDRV_TPI6525_ADD("tpi6535_tpi_2", c16_tpi6525_tpi_2_c1551_intf)
519519
src/mess/drivers/gmaster.c
r5931r5932
103103   04 b9 1a
104104   04 b9 22
105105   02 bb 12
106   4000 e0
107   rr w rr w rr w rr w rr w rr w rr w rr w
108   4000 ee
106    4000 e0
107    rr w rr w rr w rr w rr w rr w rr w rr w
108    4000 ee
109109*/
110110         break;
111111      default:
r5931r5932
116116
117117static READ8_HANDLER( gmaster_port_r )
118118{
119//   UINT8 data = gmaster.ports[offset];
119//  UINT8 data = gmaster.ports[offset];
120120    UINT8 data = 0xff;
121121    switch (offset)
122122   {
r5931r5932
189189static VIDEO_UPDATE( gmaster )
190190{
191191    int x,y;
192//   plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0); //xmess rounds up to 64 pixel
192//  plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0); //xmess rounds up to 64 pixel
193193    for (y = 0; y < ARRAY_LENGTH(gmaster_video.pixels); y++)
194194   {
195195      for (x = 0; x < ARRAY_LENGTH(gmaster_video.pixels[0]); x++)
r5931r5932
224224}
225225
226226static const UPD7810_CONFIG config = {
227//   TYPE_78C10, // 78c11 in handheld
227//  TYPE_78C10, // 78c11 in handheld
228228   TYPE_7801, // temporarily until 7810 core fixes synchronized
229229   gmaster_io_callback
230230};
r5931r5932
257257ROM_START(gmaster)
258258   ROM_REGION(0x10000,"maincpu", 0)
259259   ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) )
260//   ROM_CART_LOAD(0, "bin", 0x8000, 0x7f00, 0)
260//  ROM_CART_LOAD(0, "bin", 0x8000, 0x7f00, 0)
261261   ROM_CART_LOAD("cart", 0x8000, 0x8000, 0)
262262ROM_END
263263
r5931r5932
297297      osd_fclose(cartfile);
298298      return 1;
299299   }
300//   memcpy(rom+0x0000, rom+0x8000, 0x4000);
300//  memcpy(rom+0x0000, rom+0x8000, 0x4000);
301301   osd_fclose(cartfile);
302302   return 0;
303303}
304304#endif
305305
306306/*    YEAR      NAME            PARENT  MACHINE   INPUT     INIT
307     COMPANY                 FULLNAME */
307      COMPANY                 FULLNAME */
308308CONS( 1990, gmaster,       0,          0, gmaster,  gmaster,    gmaster,   0, "Hartung", "Game Master", GAME_IMPERFECT_SOUND)
src/mess/drivers/ssystem3.c
r5931r5932
9999    playfield.time=t;
100100
101101    //    logerror("%.4x playfield %d lowtime %s hightime %s\n",(int)activecpu_get_pc(), playfield.count,
102    //        attotime_string(playfield.low_time, 7), attotime_string(playfield.high_time,7) );
102    //       attotime_string(playfield.low_time, 7), attotime_string(playfield.high_time,7) );
103103
104104    if (playfield.started) {
105105      // 0 twice as long low
106106      // 1 twice as long high
107107      if (attotime_compare(playfield.low_time,playfield.high_time)>0) d=TRUE;
108     
108
109109      playfield.data&=~(1<<(playfield.bit^7));
110110      if (d) playfield.data|=1<<(playfield.bit^7);
111111      playfield.bit++;
r5931r5932
199199    bit 6: input clocks!?
200200
201201  port a:
202   bit 7: input low x/$37 2 
202   bit 7: input low x/$37 2
203203   bit 6: input low x/$37 3
204204   bit 5: input low x/$37 4 (else 1)
205205
r5931r5932
253253   AM_RANGE( 0x0000, 0x03ff) AM_RAM
254254              /*
25525567-de playfield ($40 means white, $80 black)
256               */
256                   */
257257//  AM_RANGE( 0x4000, 0x40ff) AM_NOP
258258/*
259  probably zusatzgerät memory (battery powered ram 256x4? at 0x4000)
259  probably zusatzger??t memory (battery powered ram 256x4? at 0x4000)
260260  $40ff low nibble ram if playfield module (else init with normal playfield)
261261 */
262262   AM_RANGE( 0x6000, 0x600f) AM_DEVREADWRITE("via6522_0", via_r, via_w)
r5931r5932
278278
279279  PORT_START( "Switches" )
280280//PORT_BIT(0x001, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("NEW GAME") PORT_CODE(KEYCODE_F3) // seems to be direct wired to reset
281//   PORT_BIT(0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?CLEAR") PORT_CODE(KEYCODE_F1)
282//   PORT_BIT(0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?ENTER") PORT_CODE(KEYCODE_ENTER)
281//  PORT_BIT(0x002, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?CLEAR") PORT_CODE(KEYCODE_F1)
282//  PORT_BIT(0x004, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("?ENTER") PORT_CODE(KEYCODE_ENTER)
283283  PORT_START( "matrix1" )
284284     PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?1") PORT_CODE(KEYCODE_1_PAD)
285285     PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9   C SQ     EP") PORT_CODE(KEYCODE_9)
r5931r5932
348348ROM_START(ssystem3)
349349   ROM_REGION(0x10000,"maincpu",0)
350350   ROM_LOAD("ss3lrom", 0xc000, 0x1000, CRC(9ea46ed3) SHA1(34eef85b356efbea6ddac1d1705b104fc8e2731a) )
351//   ROM_RELOAD(0xe000, 0x1000)
351//  ROM_RELOAD(0xe000, 0x1000)
352352   ROM_LOAD("ss3hrom", 0xf000, 0x1000, CRC(52741e0b) SHA1(2a7b950f9810c5a14a1b9d5e6b2bd93da621662e) )
353353   ROM_RELOAD(0xd000, 0x1000)
354354ROM_END
src/mess/drivers/nes.c
r5931r5932
216216   MDRV_SOUND_ADD("nessound", NES, NTSC_CLOCK)
217217   MDRV_SOUND_CONFIG(nes_apu_interface)
218218   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.90)
219   
219
220220   MDRV_CARTSLOT_ADD("cart")
221221   MDRV_CARTSLOT_EXTENSION_LIST("nes,unf")
222222   MDRV_CARTSLOT_MANDATORY
r5931r5932
268268
269269static MACHINE_DRIVER_START( famicom )
270270   MDRV_IMPORT_FROM( nes )
271   
271
272272   MDRV_CARTSLOT_MODIFY("cart")
273273   MDRV_CARTSLOT_EXTENSION_LIST("nes,unf")
274274   MDRV_CARTSLOT_NOT_MANDATORY
r5931r5932
350350// and http://www.disgruntleddesigner.com/chrisc/drpcjr/DrPCJrMemMap.txt
351351ROM_START( drpcjr )
352352   ROM_REGION( 0x18000, "maincpu", 0 )  /* Main RAM + program banks */
353   /* 4 banks to be mapped in 0xe000-0xffff (or 8 banks to be mapped in 0xe000-0xefff & 0xf000-0xffff).
354   Banks selected by writing at 0x4180 */
353   /* 4 banks to be mapped in 0xe000-0xffff (or 8 banks to be mapped in 0xe000-0xefff & 0xf000-0xffff).
354    Banks selected by writing at 0x4180 */
355355   ROM_LOAD("drpcjr_bios.bin", 0x10000, 0x8000, CRC(c8fbef89) SHA1(2cb0a817b31400cdf27817d09bae7e69f41b062b) )   // bios vers. 1.0a
356356   // Not sure if we should support this: hacked version 1.5a by Chris Covell with bugfixes and GameGenie support
357//   ROM_LOAD("drpcjr_v1_5_gg.bin", 0x10000, 0x8000, CRC(98f2033b) SHA1(93c114da787a19279d1a46667c2f69b49e25d4f1) )
357//  ROM_LOAD("drpcjr_v1_5_gg.bin", 0x10000, 0x8000, CRC(98f2033b) SHA1(93c114da787a19279d1a46667c2f69b49e25d4f1) )
358358
359359   ROM_REGION( 0x2000,  "gfx1", 0 )  /* VROM */
360360   ROM_FILL( 0x0000, 0x2000, 0x00 )
r5931r5932
402402   }
403403}
404404
405static SYSTEM_CONFIG_START(famicom)   
405static SYSTEM_CONFIG_START(famicom)
406406   CONFIG_DEVICE(famicom_floppy_getinfo)
407407SYSTEM_CONFIG_END
408408
src/mess/drivers/pasogo.c
r5931r5932
4646   {
4747      vg230.rtc.seconds=00;
4848      vg230.rtc.minutes+=1;
49      if (vg230.rtc.minutes>=60)
49      if (vg230.rtc.minutes>=60)
5050      {
5151         vg230.rtc.minutes=0;
5252         vg230.rtc.hours+=1;
53         if (vg230.rtc.hours>=24)
53         if (vg230.rtc.hours>=24)
5454         {
5555            vg230.rtc.hours=0;
5656            vg230.rtc.days=(vg230.rtc.days+1)&0xfff;
r5931r5932
6161   if (vg230.rtc.seconds==vg230.rtc.alarm_seconds
6262      && vg230.rtc.minutes==vg230.rtc.alarm_minutes
6363      && vg230.rtc.hours==vg230.rtc.alarm_hours
64      && (vg230.rtc.days&0x1f)==vg230.rtc.alarm_hours)
64      && (vg230.rtc.days&0x1f)==vg230.rtc.alarm_hours)
6565   {
6666      // generate alarm
6767   }
r5931r5932
7777
7878
7979   mame_get_base_datetime(machine, &systime);
80 
80
8181   vg230.rtc.seconds= systime.local_time.second;
8282   vg230.rtc.minutes= systime.local_time.minute;
8383   vg230.rtc.hours = systime.local_time.hour;
r5931r5932
9797   int log=TRUE;
9898   UINT8 data=0;
9999   vg230.bios_timer.data+=0x100; //HACK
100   if (offset&1)
100   if (offset&1)
101101   {
102102      data=vg230.data[vg230.index];
103      switch (vg230.index)
103      switch (vg230.index)
104104      {
105105         case 0x09: break;
106106         case 0x0a:
107            if (vg230.data[9]&1)
107            if (vg230.data[9]&1)
108108            {
109109               data=input_port_read(space->machine, "JOY");
110110            }
111            else
111            else
112112            {
113113               data=0xff;
114114            }
r5931r5932
145145
146146      if (log)
147147         logerror("%.5x vg230 %02x read %.2x\n",(int) cpu_get_pc(space->cpu),vg230.index,data);
148      //   data=memory_region(machine, "maincpu")[0x4000+offset];
149   }
150   else
151   {     
148      //    data=memory_region(machine, "maincpu")[0x4000+offset];
149   }
150   else
151   {
152152      data=vg230.index;
153153    }
154154   return data;
r5931r5932
157157static WRITE8_HANDLER( vg230_io_w )
158158{
159159   int log=TRUE;
160   if (offset&1)
160   if (offset&1)
161161   {
162      //   memory_region(machine, "maincpu")[0x4000+offset]=data;
162      //  memory_region(machine, "maincpu")[0x4000+offset]=data;
163163      vg230.data[vg230.index]=data;
164      switch (vg230.index)
164      switch (vg230.index)
165165      {
166166         case 0x09: break;
167167         case 0x70: vg230.rtc.seconds=data&0x3f; break;
r5931r5932
180180            break;
181181
182182         case 0x7a:
183            if (data&2)
184            {
185               vg230.rtc.alarm_interrupt_request=FALSE; vg230.rtc.onehertz_interrupt_request=FALSE; /* update interrupt */
183            if (data&2)
184            {
185               vg230.rtc.alarm_interrupt_request=FALSE; vg230.rtc.onehertz_interrupt_request=FALSE; /* update interrupt */
186186            }
187187            break;
188188      }
189     
189
190190      if (log)
191191         logerror("%.5x vg230 %02x write %.2x\n",(int)cpu_get_pc(space->cpu),vg230.index,data);
192   }
193   else
192   }
193   else
194194   {
195195      vg230.index=data;
196196   }
r5931r5932
210210static READ8_HANDLER( ems_r )
211211{
212212   UINT8 data=0;
213   switch (offset)
213   switch (offset)
214214   {
215215      case 0: data=ems.data; break;
216216      case 2: case 3: data=ems.mapper[ems.index].data[offset&1]; break;
r5931r5932
220220
221221static WRITE8_HANDLER( ems_w )
222222{
223   switch (offset)
223   switch (offset)
224224   {
225225   case 0:
226226      ems.data=data;
227      switch (data&~3)
227      switch (data&~3)
228228      {
229229      case 0x80: ems.index=0; break;
230230      case 0x84: ems.index=1; break;
r5931r5932
256256      case 0xec: ems.index=25; break;
257257      }
258258      break;
259   
259
260260   case 2:
261261   case 3:
262262      ems.mapper[ems.index].data[offset&1]=data;
r5931r5932
265265      ems.mapper[ems.index].type=(ems.mapper[ems.index].data[1]&0x70)>>4;
266266      logerror("%.5x ems mapper %d(%05x)on:%d type:%d address:%07x\n",(int)cpu_get_pc(space->cpu),ems.index, ems.data<<12,
267267         ems.mapper[ems.index].on, ems.mapper[ems.index].type, ems.mapper[ems.index].address );
268      switch (ems.mapper[ems.index].type)
268      switch (ems.mapper[ems.index].type)
269269      {
270      case 0: /*external*/
270      case 0: /*external*/
271271      case 1: /*ram*/
272272      memory_set_bankptr( space->machine, ems.index+1, memory_region(space->machine, "maincpu") + (ems.mapper[ems.index].address&0xfffff) );
273273      break;
r5931r5932
285285}
286286
287287static ADDRESS_MAP_START( pasogo_mem, ADDRESS_SPACE_PROGRAM, 8 )
288//   AM_RANGE(0x00000, 0xfffff) AM_UNMAP AM_MASK(0xfffff)
289//   AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w)
288//  AM_RANGE(0x00000, 0xfffff) AM_UNMAP AM_MASK(0xfffff)
289//  AM_RANGE( 0x4000, 0x7fff) AM_READWRITE(gmaster_io_r, gmaster_io_w)
290290   ADDRESS_MAP_GLOBAL_MASK(0xffFFF)
291291   AM_RANGE(0x00000, 0x7ffff) AM_RAM
292292   AM_RANGE(0x80000, 0x83fff) AM_RAMBANK(1)
r5931r5932
303303   AM_RANGE(0xac000, 0xaffff) AM_RAMBANK(12)
304304   AM_RANGE(0xb0000, 0xb3fff) AM_RAMBANK(13)
305305   AM_RANGE(0xb4000, 0xb7fff) AM_RAMBANK(14)
306//   AM_RANGE(0xb8000, 0xbffff) AM_RAM
306//  AM_RANGE(0xb8000, 0xbffff) AM_RAM
307307   AM_RANGE(0xb8000, 0xbffff) AM_RAMBANK(28)
308308   AM_RANGE(0xc0000, 0xc3fff) AM_RAMBANK(15)
309309   AM_RANGE(0xc4000, 0xc7fff) AM_RAMBANK(16)
r5931r5932
322322ADDRESS_MAP_END
323323
324324static ADDRESS_MAP_START(pasogo_io, ADDRESS_SPACE_IO, 8)
325//   ADDRESS_MAP_GLOBAL_MASK(0xfFFF)
325//  ADDRESS_MAP_GLOBAL_MASK(0xfFFF)
326326   AM_RANGE(0x0020, 0x0021) AM_DEVREADWRITE("pic8259", pic8259_r, pic8259_w)
327327   AM_RANGE(0x26, 0x27) AM_READWRITE(vg230_io_r, vg230_io_w )
328328   AM_RANGE(0x0040, 0x0043) AM_DEVREADWRITE("pit8254", pit8253_r, pit8253_w)
r5931r5932
331331
332332static INPUT_PORTS_START( pasogo )
333333PORT_START("JOY")
334//   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT)  PORT_NAME("select")
335//   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("start")
334//  PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SELECT)  PORT_NAME("select")
335//  PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START) PORT_NAME("start")
336336   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1) PORT_NAME("O") /*?*/
337337   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2) PORT_NAME("X") /*?*/
338338   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP   )
r5931r5932
356356{
357357   int i;
358358
359   for ( i = 0; i < ARRAY_LENGTH(pasogo_palette); i++ )
359   for ( i = 0; i < ARRAY_LENGTH(pasogo_palette); i++ )
360360   {
361361      palette_set_color_rgb(machine, i, pasogo_palette[i][0], pasogo_palette[i][1], pasogo_palette[i][2]);
362362   }
r5931r5932
368368   UINT8 *rom = memory_region(screen->machine, "maincpu")+0xb8000;
369369   UINT16 c[]={ 3, 0 };
370370   int x,y;
371//   plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0);
371//  plot_box(bitmap, 0, 0, 64/*bitmap->width*/, bitmap->height, 0);
372372   int w=640;
373373   int h=240;
374   if (0)
374   if (0)
375375   {
376376      w=320;
377377      h=240;
378      for (y=0;y<h; y++)
378      for (y=0;y<h; y++)
379379      {
380         for (x=0;x<w;x+=4)
380         for (x=0;x<w;x+=4)
381381         {
382382            int a=(y&1)*0x2000;
383383            UINT8 d=rom[a+(y&~1)*80/2+x/4];
r5931r5932
388388            *line++=(d>>0)&3;
389389         }
390390      }
391   }
392   else
391   }
392   else
393393   {
394      for (y=0;y<h; y++)
394      for (y=0;y<h; y++)
395395      {
396         for (x=0;x<w;x+=8)
396         for (x=0;x<w;x+=8)
397397         {
398398            int a=(y&3)*0x2000;
399399            UINT8 d=rom[a+(y&~3)*80/4+x/8];
r5931r5932
409409         }
410410      }
411411   }
412   if (w!=width || h!=height)
412   if (w!=width || h!=height)
413413   {
414414      width=w; height=h;
415//      video_screen_set_visarea(machine->primary_screen, 0, width-1, 0, height-1);
415//      video_screen_set_visarea(machine->primary_screen, 0, width-1, 0, height-1);
416416      video_screen_set_visarea(screen, 0, width-1, 0, height-1);
417417   }
418418   return 0;
r5931r5932
420420
421421static INTERRUPT_GEN( pasogo_interrupt )
422422{
423//   cputag_set_input_line(machine, "maincpu", UPD7810_INTFE1, PULSE_LINE);
423//  cputag_set_input_line(machine, "maincpu", UPD7810_INTFE1, PULSE_LINE);
424424}
425425
426426static IRQ_CALLBACK(pasogo_irq_callback)
r5931r5932
457457};
458458
459459
460static PIC8259_SET_INT_LINE( pasogo_pic8259_set_int_line )
460static PIC8259_SET_INT_LINE( pasogo_pic8259_set_int_line )
461461{
462462   cputag_set_input_line(device->machine, "maincpu", 0, interrupt ? HOLD_LINE : CLEAR_LINE);
463463}
r5931r5932
487487   MDRV_CPU_PROGRAM_MAP(pasogo_mem)
488488   MDRV_CPU_IO_MAP( pasogo_io)
489489   MDRV_CPU_VBLANK_INT("screen", pasogo_interrupt)
490//   MDRV_CPU_CONFIG(i86_address_mask)
490//  MDRV_CPU_CONFIG(i86_address_mask)
491491   MDRV_MACHINE_RESET( pasogo )
492492
493493   MDRV_PIT8254_ADD( "pit8254", pc_pit8254_config )
r5931r5932
518518
519519ROM_START(pasogo)
520520   ROM_REGION(0x100000,"maincpu", ROMREGION_ERASEFF) // 1 megabyte dram?
521//   ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) )
522//   ROM_CART_LOAD(0, "bin", 0x8000, 0x8000, 0)
521//  ROM_LOAD("gmaster.bin", 0x0000, 0x1000, CRC(05cc45e5) SHA1(05d73638dea9657ccc2791c0202d9074a4782c1e) )
522//  ROM_CART_LOAD(0, "bin", 0x8000, 0x8000, 0)
523523   ROM_REGION(0x100000,"user1", ROMREGION_ERASEFF)
524524ROM_END
525525
r5931r5932
532532   memory_set_bankptr( machine, 28, memory_region(machine, "maincpu") + 0xb8000/*?*/ );
533533}
534534
535/*    YEAR      NAME            PARENT  MACHINE   INPUT     INIT               
536     COMPANY                 FULLNAME */
535/*    YEAR      NAME            PARENT  MACHINE   INPUT     INIT
536      COMPANY                 FULLNAME */
537537CONS( 1996, pasogo,       0,          0, pasogo,  pasogo,    pasogo,   0, "KOEI", "PasoGo", GAME_NO_SOUND|GAME_NOT_WORKING)
538538
src/mess/drivers/vc20.c
r5931r5932
1111
1212/*
1313
142008 - Driver Updates
142008 - Driver Updates
1515---------------------
1616
1717(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
r5931r5932
2828CPU: MOS Technology 6502 (1.01 MHz)
2929RAM: 5 kilobytes (Expanded to 21k though an external 16k unit)
3030ROM: 20 kilobytes
31Video: MOS Technology 6560 "VIC"(Text: 22 columns, 23 rows; Hires: 176x184
31Video: MOS Technology 6560 "VIC"(Text: 22 columns, 23 rows; Hires: 176x184
3232pixels bitmapped; 8 text colors, 16 background colors)
3333Sound: MOS Technology 6560 "VIC" (3 voices -square wave-, noise and volume)
3434Ports: 6522 VIA x2 (1 Joystick/Mouse port; CBM Serial port; 'Cartridge /
35   Game / Expansion' port; CBM Monitor port; CBM 'USER' port; Power and
36   reset switches; Power connector)
37Keyboard: Full-sized QWERTY 66 key (8 programmable function keys; 2 sets of
38   Keyboardable graphic characters; 2 key direction cursor-pad)
39 
35    Game / Expansion' port; CBM Monitor port; CBM 'USER' port; Power and
36    reset switches; Power connector)
37Keyboard: Full-sized QWERTY 66 key (8 programmable function keys; 2 sets of
38    Keyboardable graphic characters; 2 key direction cursor-pad)
4039
40
4141* VIC 20 (1981)
4242
43  This system was the first computer to sell more than one million units
44worldwide. It was sold both in Europe and in the US. In Germany the
43  This system was the first computer to sell more than one million units
44worldwide. It was sold both in Europe and in the US. In Germany the
4545computer was renamed as VC 20 (apparently, it stands for 'VolksComputer'
4646
4747CPU: MOS Technology 6502A (1.01 MHz)
4848RAM: 5 kilobytes (Expanded to 32k)
4949ROM: 20 kilobytes
50Video: MOS Technology 6560 "VIC"(Text: 22 columns, 23 rows; Hires: 176x184
50Video: MOS Technology 6560 "VIC"(Text: 22 columns, 23 rows; Hires: 176x184
5151pixels bitmapped; 8 text colors, 16 background colors)
5252Sound: MOS Technology 6560 "VIC" (3 voices -square wave-, noise and volume)
5353Ports: 6522 VIA x2 (1 Joystick/Mouse port; CBM Serial port; 'Cartridge /
54   Game / Expansion' port; CBM Monitor port; CBM 'USER' port; Power and
55   reset switches; Power connector)
56Keyboard: Full-sized QWERTY 66 key (8 programmable function keys; 2 sets of
57   Keyboardable graphic characters; 2 key direction cursor-pad)
54    Game / Expansion' port; CBM Monitor port; CBM 'USER' port; Power and
55    reset switches; Power connector)
56Keyboard: Full-sized QWERTY 66 key (8 programmable function keys; 2 sets of
57    Keyboardable graphic characters; 2 key direction cursor-pad)
5858
5959
6060* VIC 21 (1983)
6161
62  It consists of a VIC 20 with built-in RAM expansion, to reach a RAM
62  It consists of a VIC 20 with built-in RAM expansion, to reach a RAM
6363  capability of 21 kilobytes.
6464
6565
r5931r5932
7676
7777* Timer system only 98% accurate
7878
79* No support for printer or other devices; no userport; no rs232/v.24
79* No support for printer or other devices; no userport; no rs232/v.24
8080interface; no special expansion modules like ieee488 interface
81
81
8282*/
8383
8484
r5931r5932
152152 *
153153 *************************************/
154154
155/* 2008-05 FP: These lightpen input ports, would better
156fit machine/cbmipt.c but PORT_MINMAX requires vic6560.c
155/* 2008-05 FP: These lightpen input ports, would better
156fit machine/cbmipt.c but PORT_MINMAX requires vic6560.c
157157constants. Therefore, they will stay here, atm    */
158158
159159static INPUT_PORTS_START( vic_lightpen_6560 )
r5931r5932
180180   PORT_INCLUDE( vic_special )         /* SPECIAL */
181181
182182   PORT_INCLUDE( vic_controls )      /* JOY, PADDLE0, PADDLE1 */
183   
183
184184   /* Lightpen 6560 */
185185   PORT_INCLUDE( vic_lightpen_6560 )   /* LIGHTX, LIGHTY */
186186
r5931r5932
202202   PORT_INCLUDE( vic_special )         /* SPECIAL */
203203
204204   PORT_INCLUDE( vic_controls )      /* JOY, PADDLE0, PADDLE1 */
205     
205
206206   /* Lightpen 6561 */
207207   PORT_INCLUDE( vic_lightpen_6561 )   /* LIGHTX, LIGHTY */
208208
r5931r5932
217217   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_BACKSLASH2)      PORT_CHAR(':') PORT_CHAR('*')
218218   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_MINUS)         PORT_CHAR('-')
219219   PORT_MODIFY( "ROW1" )
220   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)      PORT_CHAR('@')   
220   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_CLOSEBRACE)      PORT_CHAR('@')
221221   PORT_MODIFY( "ROW2" )
222222   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_QUOTE)         PORT_CHAR(0x00C4)
223223   PORT_MODIFY( "ROW5" )
r5931r5932
300300   MDRV_VIA6522_ADD("via6522_1", 0, vc20_via1)
301301   MDRV_VIA6522_ADD("via6522_2", 0, vc20_via2)
302302   MDRV_VIA6522_ADD("via6522_3", 0, vc20_via3)
303   
303
304304   MDRV_IMPORT_FROM(vic20_cartslot)
305305MACHINE_DRIVER_END
306306
src/mess/drivers/mephisto.c
r5931r5932
258258
259259/***************************************************************************
260260
261   Game driver(s)
261    Game driver(s)
262262
263263***************************************************************************/
264264
src/mess/drivers/c64.c
r5931r5932
99
1010/*
1111
122008 - Driver Updates
122008 - Driver Updates
1313---------------------
1414
1515(most of the informations are taken from http://www.zimmers.net/cbmpics/ )
r5931r5932
1919
2020* Commodore Max Machine (1982, Japan)
2121
22  The Max Machine was produced by Commodore Japan and was released along
23with the C64 in Japan. Also known as "UltiMax" (in North America ads)
24or "VC-10 / VIC-10" (in some European advertising), it was designed to be a
25game console. It has no internal kernel and no BASIC, everything must be
26supplied by the cart. A Mini BASIC and a BASIC carts were produced (the
27latter with support for LOAD/SAVE commands as well). The character rom
22  The Max Machine was produced by Commodore Japan and was released along
23with the C64 in Japan. Also known as "UltiMax" (in North America ads)
24or "VC-10 / VIC-10" (in some European advertising), it was designed to be a
25game console. It has no internal kernel and no BASIC, everything must be
26supplied by the cart. A Mini BASIC and a BASIC carts were produced (the
27latter with support for LOAD/SAVE commands as well). The character rom
2828is not present either and its content was, again, in the cart. Max Machine
2929carts can be run by both C64 and C128.
3030
3131CPU: MOS Technology 6510 (1 MHz)
3232RAM: 4 kilobytes (2 kilobytes?)
3333ROM: none
34Video: MOS 6566 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
35   colors)
36Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
37   capabilities)
38Ports: 6526 CIA (Power switch; 2 Commodore "Joystick" ports; 'EXPANSION'
39   port; "TV" port; CBM Datasette port)
34Video: MOS 6566 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
35    colors)
36Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
37    capabilities)
38Ports: 6526 CIA (Power switch; 2 Commodore "Joystick" ports; 'EXPANSION'
39    port; "TV" port; CBM Datasette port)
4040Keyboard: Full-sized QWERTY "Contact-Pad"
4141
4242
4343* Commodore 64 (1982)
4444
45  Released in August 1982 in the US and marketed as a lower end home
45  Released in August 1982 in the US and marketed as a lower end home
4646computer, the C64 dominated the home computer market for a few years,
4747outselling competitors like Apple computers, IBM PCs and TRS-80s.
48During the early stages of the project it was called VIC-40, but the
48During the early stages of the project it was called VIC-40, but the
4949named was changed in the end probably to fit the name scheme used at
5050time for business product (letter + memory size: P128 & B256).
5151It was also advertised as VC 64 in Germany, and as VIC 64S in Sweden
r5931r5932
5454CPU: CSG 6510 (1 MHz)
5555RAM: 64 kilobytes
5656ROM: 20 kilobytes
57Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
58   colors)
59Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
60   capabilities)
61Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
62   CBM Serial port; CBM Datasette port; parallel programmable "User"
63   port; CBM Monitor port; C64 expansion port)
57Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
58    colors)
59Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
60    capabilities)
61Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
62    CBM Serial port; CBM Datasette port; parallel programmable "User"
63    port; CBM Monitor port; C64 expansion port)
6464Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
65   cursor keys, 2 directions each)
65    cursor keys, 2 directions each)
6666
6767BIOS:
68   kernal.901227-02.bin
69   basic.901226-01.bin
70   characters.901225-01.bin
68    kernal.901227-02.bin
69    basic.901226-01.bin
70    characters.901225-01.bin
7171
7272
7373* Commodore 64 (1982, Japan)
7474
75  Released in Japan at the same time as Max Machine, in the hope to repeat
76the success of the VIC-1001, this system was a flop. Technically it is the
75  Released in Japan at the same time as Max Machine, in the hope to repeat
76the success of the VIC-1001, this system was a flop. Technically it is the
7777same as the C64, but it has native support for the Katakana character set.
7878
79Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
80   colors)
79Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
80    colors)
8181Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
82   cursor keys, 2 directions each; Katakana characters accessible through
83   C= key)
82    cursor keys, 2 directions each; Katakana characters accessible through
83    C= key)
8484
8585BIOS
86   kernal.906145-02.bin
87   basic.901226-01.bin
88   characters.906143-02.bin
86    kernal.906145-02.bin
87    basic.901226-01.bin
88    characters.906143-02.bin
8989
9090
9191* PET 64 (1983)
9292
93  Also known as CBM 4064, it was a C64 fitted in a PET case and with a PET
93  Also known as CBM 4064, it was a C64 fitted in a PET case and with a PET
9494monochrome screen. Exactly like the C64, it features a VIC-II video chip,
95a SID sound chip, 2 x CIA 6526, 64K of memory and BASIC 2.0. Being forced
96to display on a monochrome screen, color codes were removed from the front
97of number keys. The kernel itself was modified to output only white
98characters on a black background. A plate with BASIC commands and other hints
95a SID sound chip, 2 x CIA 6526, 64K of memory and BASIC 2.0. Being forced
96to display on a monochrome screen, color codes were removed from the front
97of number keys. The kernel itself was modified to output only white
98characters on a black background. A plate with BASIC commands and other hints
9999was put above the keyboard.
100100
101Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
102   colors, monochrome 14" monitor support)
103Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
104   capabilities; Internal speaker)
101Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
102    colors, monochrome 14" monitor support)
103Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
104    capabilities; Internal speaker)
105105Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
106   cursor keys, 2 directions each; complete BASIC reference on keyboard
107   panel )
106    cursor keys, 2 directions each; complete BASIC reference on keyboard
107    panel )
108108
109109BIOS
110   kernal.4064.901246-01.bin
111   basic.901226-01.bin
112   characters.901225-01.bin
110    kernal.4064.901246-01.bin
111    basic.901226-01.bin
112    characters.901225-01.bin
113113
114114
115115* Educator 64 (1983)
116116
117 Basically the same as the PET 64, but it uses a standard C64 kernel,
118allowing  to 'explore' all shades of green the monitor was capable of. Also
119the BASIC plate is slightly different. There could have been an earlier
120version, already called Educator 64, which came with no monitor and in a
117 Basically the same as the PET 64, but it uses a standard C64 kernel,
118allowing  to 'explore' all shades of green the monitor was capable of. Also
119the BASIC plate is slightly different. There could have been an earlier
120version, already called Educator 64, which came with no monitor and in a
121121C64 case.
122122
123123Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
124   cursor keys, 2 directions each; complete BASIC reference on keyboard
125   panel )
124    cursor keys, 2 directions each; complete BASIC reference on keyboard
125    panel )
126126
127127BIOS
128   kernal.901227-02.bin
129   basic.901226-01.bin
130   characters.901225-01.bin
128    kernal.901227-02.bin
129    basic.901226-01.bin
130    characters.901225-01.bin
131131
132132
133133* SX-64 Executive Computer (1984)
134134
135  Portable color computer based on the C64 hardware. The unit is heavy, with
136its metal case, features a built-in disk driver (mostly 1541 compatible) and
137has a large handle to carry the computer around. The detachable keyboard can
135  Portable color computer based on the C64 hardware. The unit is heavy, with
136its metal case, features a built-in disk driver (mostly 1541 compatible) and
137has a large handle to carry the computer around. The detachable keyboard can
138138be used as protective front plate. The SX-64 had a 4" full color screen and a
139built-in speaker. The only differences between the C64 and the SX-64 are in
139built-in speaker. The only differences between the C64 and the SX-64 are in
140140the start up colors and in the SX-64 better support for the internal floppy
141141drive. The tape drive support was removed in the portable system.
142142
143143CPU: MOS 6510 (1 MHz)
144144RAM: 64 kilobytes (68 with the 1541)
145145ROM: 20 kilobytes (36 with the 1541)
146Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
147   colors, 4" Full-color screen)
148Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
149   capabilities; Internal MONO speaker)
150Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
151   CBM Serial port; CBM Datasette port; parallel programmable "User"
152   port; CBM Monitor port; C64 expansion port)
146Video: MOS 6569 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
147    colors, 4" Full-color screen)
148Sound: MOS 6581 "SID" (3 voice stereo synthesizer/digital sound
149    capabilities; Internal MONO speaker)
150Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
151    CBM Serial port; CBM Datasette port; parallel programmable "User"
152    port; CBM Monitor port; C64 expansion port)
153153Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
154   cursor keys, 2 directions each; detachable)
154    cursor keys, 2 directions each; detachable)
155155Additional hardware: Commodore 1541 Disk Drive (5.25" 170K SS SD Floppy)
156156
157157BIOS:
158   kernal.sx.251104-04.bin
159   basic.901226-01.bin
160   characters.901225-01.bin
158    kernal.sx.251104-04.bin
159    basic.901226-01.bin
160    characters.901225-01.bin
161161
162162
163163* DX-64 (198?)
r5931r5932
169169* Commodore 64C (1986)
170170
171171  Redesigned version of the C64, released with slightly upgraded versions
172of chips and peripherals. It came often bundled with GEOS, GUI based OS
172of chips and peripherals. It came often bundled with GEOS, GUI based OS
173173by Berkeley Softworks (it was stored on floppy disks). It's also known as
174174C64-II but the name doesn't seems to have ever been official (only used
175by magazines at early stage of ad & review). Another redesign, in a slightly
176larger case (closer to the original C64) is known as Commodore 64G, because
177mainly sold in Germany. Other repackaged versions followed, built around the
175by magazines at early stage of ad & review). Another redesign, in a slightly
176larger case (closer to the original C64) is known as Commodore 64G, because
177mainly sold in Germany. Other repackaged versions followed, built around the
178178same kernel and chips.
179179
180180CPU: CSG 8500 (1 MHz; 6510 compatible)
181181RAM: 64 kilobytes
182182ROM: 20 kilobytes
183Video: MOS 8565 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
184   colors)
185Sound: CSG 8580 "SID" (3 voice stereo synthesizer/digital sound
186   capabilities)
187Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
188   CBM Serial port; CBM Datasette port; parallel programmable "User"
189   port; CBM Monitor port; C64 expansion port)
183Video: MOS 8565 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
184    colors)
185Sound: CSG 8580 "SID" (3 voice stereo synthesizer/digital sound
186    capabilities)
187Ports: MOS 6526 CIA x2 (Power switch; 2 Commodore Joystick/Mouse ports;
188    CBM Serial port; CBM Datasette port; parallel programmable "User"
189    port; CBM Monitor port; C64 expansion port)
190190Keyboard: Full-sized 62 key QWERTY (8 programmable function keys; 2
191   cursor keys, 2 directions each)
191    cursor keys, 2 directions each)
192192
193193BIOS:
194   64c.251913-01.bin
195   characters.901225-01.bin
194    64c.251913-01.bin
195    characters.901225-01.bin
196196
197197
198198* Commodore 64 Games System (1990)
r5931r5932
203203CPU: CSG 6510 (1 MHz)
204204RAM: 64 kilobytes
205205ROM: 16 kilobytes
206Video: MOS 8565 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
207   colors)
208Sound: CSG 8580 "SID" (3 voice stereo synthesizer/digital sound
209   capabilities)
210Ports: MOS 6526 CIA (Power switch; 2 Commodore Joystick/Mouse ports;
211   CBM Monitor port; C64 expansion port)
206Video: MOS 8565 "VIC-II" (320 x 200 Hi-Resolution, 40 columns text, 16
207    colors)
208Sound: CSG 8580 "SID" (3 voice stereo synthesizer/digital sound
209    capabilities)
210Ports: MOS 6526 CIA (Power switch; 2 Commodore Joystick/Mouse ports;
211    CBM Monitor port; C64 expansion port)
212212
213213BIOS:
214   64gs.390852-01.bin
215   characters.901225-01.bin
214    64gs.390852-01.bin
215    characters.901225-01.bin
216216
217217* Commodore 64 "Gold" (1984, US - 1986, Germany)
218218
219  Commemorative version released to celebrate the one millionth Commodore 64
220sold in the country. The whole case is golden colored. It is also reasonable
221to assume that the US version is based on the original C64, while the German
219  Commemorative version released to celebrate the one millionth Commodore 64
220sold in the country. The whole case is golden colored. It is also reasonable
221to assume that the US version is based on the original C64, while the German
222222version is based on the C64C.
223223
224224
r5931r5932
231231
232232[Known Fake / Unofficial BIOS]
233233
234Max Machine - These are BASIC V2.0 and kernel contained in the MAX BASIC
235cart, not a real Max BIOS. 
236   basic.901230-01.bin
237   kernal.901231-01.bin
238   
234Max Machine - These are BASIC V2.0 and kernel contained in the MAX BASIC
235cart, not a real Max BIOS.
236    basic.901230-01.bin
237    kernal.901231-01.bin
238
239239Character roms
240   c64-german.bin - amateur hack
241   c64-hungarian.bin - amateur hack
242   kauno.bin - calligraphic font for the C64, data saved from a 1985 tape
240    c64-german.bin - amateur hack
241    c64-hungarian.bin - amateur hack
242    kauno.bin - calligraphic font for the C64, data saved from a 1985 tape
243243
244244[Peripherals]
245245
r5931r5932
259259- Commodore Joysticks
260260- Commodore Paddles
261261- Commodore 1350 / 1351 Mouse
262- CMD SmartMouse
262- CMD SmartMouse
263263- Inkwell Light Pen
264264- Koala Pad
265265- Commodore Music Maker overlay
266266- External music keyboard (to be plugged into the Sound Expander)
267267
268268- Commodore REU: REU stands for RAM Expansion Unit for C64 & C128. Three
269models 1700 (128 KB) and 1750 (512 KB), and later the 1764 (256 KB, for the
269models 1700 (128 KB) and 1750 (512 KB), and later the 1764 (256 KB, for the
270270C64)
271271- Commodore Sound Expander Cart
272272- Commodore Sound Sampler Cart
r5931r5932
274274- Schnedler Systems Turbo Master CPU
275275- Creative Micro Designs (CMD) RAMDrive, RAMLink and Super CPU Accelerator
276276- CMD SID symphony cartridge
277- Commodore Universal Btx Decoder: Same design of the REU, it's a decoder
277- Commodore Universal Btx Decoder: Same design of the REU, it's a decoder
278278for the Bildschirmtext, a sort of videotext online service similar to the
279279French Minitel. It allowed the C64 + Decoder to replace the very expensive
280280standalone decoder.
281281
282Freezer Carts: Datel "Action Replay", Freeze Frame MK III B, Trilogic
282Freezer Carts: Datel "Action Replay", Freeze Frame MK III B, Trilogic
283283"Expert", "The Final Cartridge III", "Retro Replay"
284284Kernal Replacement: SpeedDOS, DolphinDOS, JiffyDOS etc.
285285
r5931r5932
292292
293293* Cartridges:
294294
295- Currently only Type 0 hardware is supported (check cart code in
295- Currently only Type 0 hardware is supported (check cart code in
296296machine/c64.c for more notes). Other Types may load but not work.
297297
298298* Datasette:
299299
300- Currently, .t64 images are supported as Quickload device. This only works
301if the file contains a single entry with a start address of $0801. This
302covers most of the existing files, but the format is desinged to be much
300- Currently, .t64 images are supported as Quickload device. This only works
301if the file contains a single entry with a start address of $0801. This
302covers most of the existing files, but the format is desinged to be much
303303more flexible and it could be implemented as a real tape format.
304304
305305* Other Peripherals:
r5931r5932
312312
313313* Informations / BIOS / Supported Sets:
314314
315- Find out if C64 was sold both as VIC 64S and C64 in Sweden, and which
315- Find out if C64 was sold both as VIC 64S and C64 in Sweden, and which
316316were inner/outer differences. For sure advertising was using the VIC 64S
317317name.
318318- Was it really sold as VC 64 in Germany, or was it just a nickname used
319319at launch to indicate standard C64 units?
320- What's the difference between Educator 64-1 and Educator 64-2? My guess
321is that Edu64-1 was a standard PET64/CBMB4064 with a different name, while
320- What's the difference between Educator 64-1 and Educator 64-2? My guess
321is that Edu64-1 was a standard PET64/CBMB4064 with a different name, while
322322the Edu64-1 used the full C64 BIOS. Confirmations are needed, anyway.
323323 */
324324
r5931r5932
382382
383383static INPUT_PORTS_START (c64gs)
384384   PORT_INCLUDE( c64 )
385   
385
386386   /* 2008 FP: This has to be cleaned up later */
387387   /* C64gs should simply not scan these inputs */
388388   /* as a temporary solution, we keep PeT IPT_UNUSED shortcut */
r5931r5932
561561   /* cia */
562562   MDRV_CIA6526_ADD("cia_0", CIA6526R1, VIC6569_CLOCK, c64_pal_cia0)
563563   MDRV_CIA6526_ADD("cia_1", CIA6526R1, VIC6569_CLOCK, c64_pal_cia1)
564   
564
565565   /* floppy from serial bus */
566566   MDRV_IMPORT_FROM(simulated_drive)
567567
r5931r5932
577577   MDRV_SOUND_REPLACE("sid6581", SID6581, VIC6567_CLOCK)
578578   MDRV_SOUND_CONFIG(c64_sound_interface)
579579   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
580   
580
581581   MDRV_DEVICE_REMOVE("serial_bus")   // in the current code, serial bus device is tied to the floppy drive
582582   MDRV_DEVICE_REMOVE("cart1")
583583   MDRV_DEVICE_REMOVE("cart2")
src/mess/drivers/genesis.c
r5931r5932
9090/* They're needed to give the users the choice between different controllers */
9191static UINT8 mess_md_io_read_data_port(running_machine *machine, int portnum)
9292{
93   static const char *const pad6names[2][4] = {{ "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" },
93   static const char *const pad6names[2][4] = {{ "PAD1_6B", "PAD2_6B", "UNUSED", "UNUSED" },
9494                                    { "EXTRA1", "EXTRA2", "UNUSED", "UNUSED" }};
9595   static const char *const pad3names[4] = { "PAD1_3B", "PAD2_3B", "UNUSED", "UNUSED" };
9696
97   UINT8 retdata;
97   UINT8 retdata;
9898   int controller;
9999   UINT8 helper_6b = (megadrive_io_ctrl_regs[portnum] & 0x3f) | 0xc0; // bits 6 & 7 always come from megadrive_io_data_regs
100100   UINT8 helper_3b = (megadrive_io_ctrl_regs[portnum] & 0x7f) | 0x80; // bit 7 always comes from megadrive_io_data_regs
r5931r5932
122122         if (mess_io_stage[portnum] == 2)
123123         {
124124            /* here we read B, C & the additional buttons */
125            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
126                     (((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x30) |
125            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
126                     (((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x30) |
127127                        (input_port_read_safe(machine, pad6names[1][portnum], 0) & 0x0f)) & ~helper_6b);
128128         }
129129         else
130130         {
131131            /* here we read B, C & the directional buttons */
132            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
132            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
133133                     ((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x3f) & ~helper_6b);
134134         }
135135      }
r5931r5932
138138         if (mess_io_stage[portnum] == 1)
139139         {
140140            /* here we read ((Start & A) >> 2) | 0x00 */
141            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
141            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
142142                     (((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) & ~helper_6b);
143143         }
144144         else if (mess_io_stage[portnum]==2)
145145         {
146146            /* here we read ((Start & A) >> 2) | 0x0f */
147            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
147            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
148148                     ((((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) | 0x0f) & ~helper_6b);
149149         }
150150         else
151151         {
152152            /* here we read ((Start & A) >> 2) | Up and Down */
153            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
154                     ((((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) |
153            retdata = (megadrive_io_data_regs[portnum] & helper_6b) |
154                     ((((input_port_read_safe(machine, pad6names[0][portnum], 0) & 0xc0) >> 2) |
155155                        (input_port_read_safe(machine, pad6names[0][portnum], 0) & 0x03)) & ~helper_6b);
156156         }
157157      }
r5931r5932
166166      if (megadrive_io_data_regs[portnum] & 0x40)
167167      {
168168         /* here we read B, C & the directional buttons */
169         retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
169         retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
170170                  (((input_port_read_safe(machine, pad3names[portnum], 0) & 0x3f) | 0x40) & ~helper_3b);
171171      }
172172      else
173173      {
174174         /* here we read ((Start & A) >> 2) | Up and Down */
175         retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
176                  ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) |
175         retdata = (megadrive_io_data_regs[portnum] & helper_3b) |
176                  ((((input_port_read_safe(machine, pad3names[portnum], 0) & 0xc0) >> 2) |
177177                     (input_port_read_safe(machine, pad3names[portnum], 0) & 0x03) | 0x40) & ~helper_3b);
178178      }
179179   }
r5931r5932
230230   PORT_CATEGORY_CLASS( 0x0f, 0x00, "Player 1 Controller" )
231231   PORT_CATEGORY_ITEM( 0x00, "Joystick 3 Buttons", 10 )
232232   PORT_CATEGORY_ITEM( 0x01, "Joystick 6 Buttons", 11 )
233//   PORT_CATEGORY_ITEM( 0x02, "Sega Mouse", 12 )
233//  PORT_CATEGORY_ITEM( 0x02, "Sega Mouse", 12 )
234234/* there exists both a 2 buttons version of the Mouse (Jpn ver, to be used with RPGs, it
235   can aslo be used as trackball) and a 3 buttons version (US ver, no trackball feats.) */
236//   PORT_CATEGORY_ITEM( 0x03, "Sega Menacer", 13 )
237//   PORT_CATEGORY_ITEM( 0x04, "Konami Justifier", 14 )
238//   PORT_CATEGORY_ITEM( 0x05, "Team Player (Sega Multitap)", 15 )
239//   PORT_CATEGORY_ITEM( 0x06, "4-Play (EA Multitap)", 16 )
240//   PORT_CATEGORY_ITEM( 0x07, "J-Cart", 17 )
235    can aslo be used as trackball) and a 3 buttons version (US ver, no trackball feats.) */
236//  PORT_CATEGORY_ITEM( 0x03, "Sega Menacer", 13 )
237//  PORT_CATEGORY_ITEM( 0x04, "Konami Justifier", 14 )
238//  PORT_CATEGORY_ITEM( 0x05, "Team Player (Sega Multitap)", 15 )
239//  PORT_CATEGORY_ITEM( 0x06, "4-Play (EA Multitap)", 16 )
240//  PORT_CATEGORY_ITEM( 0x07, "J-Cart", 17 )
241241   PORT_CATEGORY_CLASS( 0xf0, 0x00, "Player 2 Controller" )
242242   PORT_CATEGORY_ITEM( 0x00, "Joystick 3 Buttons", 20 )
243243   PORT_CATEGORY_ITEM( 0x10, "Joystick 6 Buttons", 21 )
r5931r5932
300300
301301
302302/* MegaDrive inputs + Fake Region Selection */
303/* We need this as long as we only have the US version of the SVP add-on, otherwise we could not play
304   Non-US Virtua Racing versions. It is also handy to develop add-ons emulation without adding each
303/* We need this as long as we only have the US version of the SVP add-on, otherwise we could not play
304   Non-US Virtua Racing versions. It is also handy to develop add-ons emulation without adding each
305305   region variants, while they do not even work. Once emulation is working this must disappear.  */
306306static INPUT_PORTS_START( md_sel )
307307   PORT_INCLUDE( md )
r5931r5932
326326{
327327   MACHINE_RESET_CALL( megadriv );
328328   MACHINE_RESET_CALL( md_mappers );
329   
329
330330   mess_init_6buttons_pad(machine);
331331}
332332
r5931r5932
334334   MDRV_IMPORT_FROM(megadriv)
335335
336336   MDRV_MACHINE_RESET( ms_megadriv )
337   
337
338338   MDRV_IMPORT_FROM( genesis_cartslot )
339339MACHINE_DRIVER_END
340340
r5931r5932
342342   MDRV_IMPORT_FROM(megadpal)
343343
344344   MDRV_MACHINE_RESET( ms_megadriv )
345   
345
346346   MDRV_IMPORT_FROM( genesis_cartslot )
347347MACHINE_DRIVER_END
348348
r5931r5932
660660       break;
661661
662662       /*
663          Still notes from notaz for the pen :
663           Still notes from notaz for the pen :
664664
665          The pen can be used to 'draw' either on the drawing pad or on the storyware
666          itself. Both storyware and drawing pad are mapped on single virtual plane, where
667          coordinates range:
665           The pen can be used to 'draw' either on the drawing pad or on the storyware
666           itself. Both storyware and drawing pad are mapped on single virtual plane, where
667           coordinates range:
668668
669          x: 0x03c - 0x17c
670          y: 0x1fc - 0x2f7 (drawing pad)
671             0x2f8 - 0x3f3 (storyware)
672        */
669           x: 0x03c - 0x17c
670           y: 0x1fc - 0x2f7 (drawing pad)
671              0x2f8 - 0x3f3 (storyware)
672         */
673673     case 2:
674674       retdata = pico_read_penpos(space->machine, PICO_PENX) >> 8;
675675       break;
r5931r5932
684684       break;
685685     case 6:
686686       /* Page register :
687          00 - storyware closed
688          01, 03, 07, 0f, 1f, 3f - pages 1-6
689          either page 5 or page 6 is often unused.
690       */
687           00 - storyware closed
688           01, 03, 07, 0f, 1f, 3f - pages 1-6
689           either page 5 or page 6 is often unused.
690        */
691691       {
692692         UINT8 tmp;
693693
r5931r5932
708708       break;
709709     case 8:
710710       /*
711          For reads, if bit 15 is cleared, it means PCM is 'busy' or
712          something like that, as games sometimes wait for it to become 1.
713       */
711           For reads, if bit 15 is cleared, it means PCM is 'busy' or
712           something like that, as games sometimes wait for it to become 1.
713        */
714714       retdata = 0x00;
715715     }
716716   return retdata | retdata <<8;
r5931r5932
771771   MDRV_DEVICE_REMOVE("genesis_snd_z80")
772772
773773   MDRV_MACHINE_RESET( ms_megadriv )
774   
774
775775   MDRV_IMPORT_FROM( pico_cartslot )
776776MACHINE_DRIVER_END
777777
r5931r5932
784784   MDRV_DEVICE_REMOVE("genesis_snd_z80")
785785
786786   MDRV_MACHINE_RESET( ms_megadriv )
787   
787
788788   MDRV_IMPORT_FROM( pico_cartslot )
789789MACHINE_DRIVER_END
790790

Previous 15994 Revisions Next


© 1998-2018 The MESS Team