Previous 15994 Revisions Next

r6354 Tuesday 10th November, 2009 at 21:59:00 UTC by Barry Rodewald
[FMTOWNS] Various updates:
* Implemented VRAM page selection
* Implemented FDC IRQ mask
* Added FDC disk density select
* Implemented TVRAM selection and display
* Re-worked VRAM to read/write correctly in low memory. High memory mirror is now correct, and allows the startup logo to display correctly on the Marty/Car Marty.
* Fixed ANK CG ROM enable.
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r6353r6354
2222
2323    16/5/09:  Skeleton driver.
2424
25    Issues: BIOS requires 386 protected mode.
25    Issues: requires 386 protected mode.
2626
2727*/
2828
r6353r6354
5050 * 0x00b0-bf: DMA controller 2 (uPD71071)
5151 * 0x0200-0f: Floppy controller (MB8877A)
5252 * 0x0400   : Video / CRTC (unknown)
53 * 0x0404   : Enable whole first MB of RAM (disable VRAM, CMOS, BIOS ROM)
53 * 0x0404   : Disable VRAM, CMOS, memory-mapped I/O (everything in low memory except the BIOS)
5454 * 0x0440-5f: Video / CRTC (unknown)
5555 * 0x0480 RW: bit 1 = disable BIOS ROM
56 * 0x04c0-cf: CD-ROM controller (unknown? SCSI?)
56 * 0x04c0-cf: CD-ROM controller (unknown)
5757 * 0x04d5   : Sound mute
5858 * 0x04d8   : YM3438 control port A / status
5959 * 0x04da   : YM3438 data port A / status
r6353r6354
135135static UINT8* towns_txtvram;
136136static UINT8 towns_vram_wplane;
137137static UINT8 towns_vram_rplane;
138static UINT8 towns_vram_page_sel;
138139static UINT8 towns_palette_select;
139140static UINT8 towns_palette_r[256];
140141static UINT8 towns_palette_g[256];
r6353r6354
144145static UINT8 towns_kanji_code_h;
145146static UINT8 towns_kanji_code_l;
146147static int towns_selected_drive;
148static UINT8 towns_fdc_irq6mask;
147149static UINT8* towns_serial_rom;
148150static int towns_srom_position;
149151static UINT8 towns_srom_clk;
r6353r6354
155157static UINT8 towns_timer_mask;
156158static UINT8 towns_crtc_mix;
157159static UINT16 towns_machine_id;  // default is 0x0101
160static UINT8 towns_kb_status;
161static UINT8 towns_kb_irq1_enable;
162static UINT8 towns_kb_output;  // key output
163static UINT8 towns_crtc_sel;  // selected CRTC register
164static UINT16 towns_crtc_reg[32];
165static UINT8 towns_tvram_enable;
158166
159
160167static void towns_update_video_banks(const address_space* space);
161168static PIC8259_SET_INT_LINE( towns_pic_irq );
162169
r6353r6354
342349 *  Floppy Disc Controller (MB8877A)
343350 */
344351
352static WRITE_LINE_DEVICE_HANDLER( towns_mb8877a_irq_w )
353{
354   if(towns_fdc_irq6mask == 0)
355      state = 0;
356   pic8259_set_irq_line(device,6,state);  // IRQ6 = FDC
357}
358
345359static WRITE_LINE_DEVICE_HANDLER( towns_mb8877a_drq_w )
346360{
347361   upd71071_dmarq(device, state, 0);
r6353r6354
373387      default:
374388         logerror("FDC: read from invalid or unimplemented register %02x\n",offset);
375389   }
376   return 0x00;
390   return 0xff;
377391}
378392
379393static WRITE8_HANDLER(towns_floppy_w)
r6353r6354
401415         break;
402416      case 0x08:
403417         // bit 5 - CLKSEL
404         if(data & 0x10)
418         if(towns_selected_drive != 0 && towns_selected_drive < 2)
405419         {
406            if(towns_selected_drive != 0 && towns_selected_drive < 2)
407            {
408               floppy_drive_set_motor_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10);
409               floppy_drive_set_ready_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10,0);
410            }
420            floppy_drive_set_motor_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10);
421            floppy_drive_set_ready_state(floppy_get_device(space->machine, towns_selected_drive-1), data & 0x10,0);
411422         }
412423         wd17xx_set_side(fdc,(data & 0x04)>>2);
413         // bit 1 - DDEN
414         // bit 0 - IRQMSK
424         wd17xx_set_density(fdc,(data & 0x02)>>1);
425         towns_fdc_irq6mask = data & 0x01;
415426         logerror("FDC: write %02x to offset 0x08\n",data);
416427         break;
417428      case 0x0c:  // drive select
r6353r6354
456467   wd17xx_data_w(fdc,0,data);
457468}
458469
470/*
471 *  port 0x440-0x443 - CRTC
472 *       0x440 = register select
473 *       0x442/3 = register data (16-bit)
474 *
475 */
459476static READ8_HANDLER(towns_video_440_r)
460477{
461   logerror("VID: read port %04x\n",offset+0x440);
478   switch(offset)
479   {
480      case 0x00:
481         return towns_crtc_sel;
482      case 0x02:
483         logerror("CRTC: reading register %i (0x442) [%04x]\n",towns_crtc_sel,towns_crtc_reg[towns_crtc_sel]);
484         return towns_crtc_reg[towns_crtc_sel] & 0x00ff;
485      case 0x03:
486         logerror("CRTC: reading register %i (0x443) [%04x]\n",towns_crtc_sel,towns_crtc_reg[towns_crtc_sel]);
487         return (towns_crtc_reg[towns_crtc_sel] & 0xff00) >> 8;
488      default:
489         logerror("VID: read port %04x\n",offset+0x440);
490   }
462491   return 0x00;
463492}
464493
465494static WRITE8_HANDLER(towns_video_440_w)
466495{
467   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x440);
496   switch(offset)
497   {
498      case 0x00:
499         towns_crtc_sel = data;
500         break;
501      case 0x02:
502         logerror("CRTC: writing register %i (0x442) [%02x]\n",towns_crtc_sel,data);
503         towns_crtc_reg[towns_crtc_sel] =
504            (towns_crtc_reg[towns_crtc_sel] & 0xff00) | data;
505         break;
506      case 0x03:
507         logerror("CRTC: writing register %i (0x443) [%02x]\n",towns_crtc_sel,data);
508         towns_crtc_reg[towns_crtc_sel] =
509            (towns_crtc_reg[towns_crtc_sel] & 0x00ff) | (data << 8);
510         break;
511      default:
512         logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x440);
513   }
468514}
469515
470516static READ8_HANDLER(towns_video_5c8_r)
471517{
472518   logerror("VID: read port %04x\n",offset+0x5c8);
519   switch(offset)
520   {
521      case 0x00:  // 0x5c8 - disable TVRAM?
522      if(towns_tvram_enable != 0)
523      {
524         towns_tvram_enable = 0;
525         return 0x80;
526      }
527      else
528         return 0x00;
529   }
473530   return 0x00;
474531}
475532
476533static WRITE8_HANDLER(towns_video_5c8_w)
477534{
535   const device_config* dev = devtag_get_device(space->machine,"pic8259_slave");
536   switch(offset)
537   {
538      case 0x02:  // 0x5ca - VSync clear?
539         pic8259_set_irq_line(dev,3,0);
540         break;
541   }
478542   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x5c8);
479543}
480544
r6353r6354
540604   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90);
541605}
542606
607/*
608 *  Port 0x600-0x607 - Keyboard controller (8042 MCU)
609 *
610 */
543611static READ8_HANDLER(towns_keyboard_r)
544612{
545   logerror("KB: read offset %02x\n",offset);
613   switch(offset)
614   {
615      case 0:  // scancode output
616         logerror("KB: read keyboard output port, returning %02x\n",towns_kb_output);
617         towns_kb_status &= ~0x01;
618         return towns_kb_output;
619      case 1:  // status
620         logerror("KB: read status port, returning %02x\n",towns_kb_status);
621         return towns_kb_status;
622      default:
623         logerror("KB: read offset %02x\n",offset);
624   }
546625   return 0x00;
547626}
548627
549628static WRITE8_HANDLER(towns_keyboard_w)
550629{
551   logerror("KB: wrote 0x%02x to offset %02x\n",data,offset);
630   const device_config* dev = devtag_get_device(space->machine,"pic8259_master");
631
632   switch(offset)
633   {
634      case 0:  // command input
635         towns_kb_status &= ~0x08;
636         towns_kb_status |= 0x01;
637         break;
638      case 1:  // control
639         towns_kb_status |= 0x08;
640         break;
641      case 2:  // IRQ1 enable
642         towns_kb_irq1_enable = data & 0x01;
643         pic8259_set_irq_line(dev,1,1);
644         pic8259_set_irq_line(dev,1,0);
645         break;
646      default:
647         logerror("KB: wrote 0x%02x to offset %02x\n",data,offset);
648   }
552649}
553650
554651/*
r6353r6354
673770   towns_cmos[offset] = data;
674771}
675772
773static READ8_HANDLER( towns_gfx_r )
774{
775   if(towns_mainmem_enable != 0)
776      return messram_get_ptr(devtag_get_device(space->machine, "messram"))[offset+0xc0000];
777
778   if(towns_vram_page_sel != 0)
779      offset += 0x20000;
780
781   return 0;
782}
783
676784static WRITE8_HANDLER( towns_gfx_w )
677785{
678786   if(towns_mainmem_enable != 0)
r6353r6354
680788      messram_get_ptr(devtag_get_device(space->machine, "messram"))[offset+0xc0000] = data;
681789      return;
682790   }
791   offset = offset << 2;
792   if(towns_vram_page_sel != 0)
793      offset += 0x20000;
794   if(towns_vram_wplane & 0x08)
795   {
796      towns_gfxvram[offset] &= ~0x88;
797      towns_gfxvram[offset] |= ((data & 0x80) >> 4) | ((data & 0x40) << 1);
798      towns_gfxvram[offset + 1] &= ~0x88;
799      towns_gfxvram[offset + 1] |= ((data & 0x20) >> 2) | ((data & 0x10) << 3);
800      towns_gfxvram[offset + 2] &= ~0x88;
801      towns_gfxvram[offset + 2] |= ((data & 0x08)) | ((data & 0x04) << 5);
802      towns_gfxvram[offset + 3] &= ~0x88;
803      towns_gfxvram[offset + 3] |= ((data & 0x02) << 2) | ((data & 0x01) << 7);
804   }
805   if(towns_vram_wplane & 0x04)
806   {
807      towns_gfxvram[offset] &= ~0x44;
808      towns_gfxvram[offset] |= ((data & 0x80) >> 5) | ((data & 0x40));
809      towns_gfxvram[offset + 1] &= ~0x44;
810      towns_gfxvram[offset + 1] |= ((data & 0x20) >> 3) | ((data & 0x10) << 2);
811      towns_gfxvram[offset + 2] &= ~0x44;
812      towns_gfxvram[offset + 2] |= ((data & 0x08) >> 1) | ((data & 0x04) << 4);
813      towns_gfxvram[offset + 3] &= ~0x44;
814      towns_gfxvram[offset + 3] |= ((data & 0x02) << 1) | ((data & 0x01) << 6);
815   }
816   if(towns_vram_wplane & 0x02)
817   {
818      towns_gfxvram[offset] &= ~0x22;
819      towns_gfxvram[offset] |= ((data & 0x80) >> 6) | ((data & 0x40) >> 1);
820      towns_gfxvram[offset + 1] &= ~0x22;
821      towns_gfxvram[offset + 1] |= ((data & 0x20) >> 4) | ((data & 0x10) << 1);
822      towns_gfxvram[offset + 2] &= ~0x22;
823      towns_gfxvram[offset + 2] |= ((data & 0x08) >> 2) | ((data & 0x04) << 3);
824      towns_gfxvram[offset + 3] &= ~0x22;
825      towns_gfxvram[offset + 3] |= ((data & 0x02)) | ((data & 0x01) << 5);
826   }
683827   if(towns_vram_wplane & 0x01)
684      towns_gfxvram[offset] = data;
685   if(towns_vram_wplane & 0x02)
686      towns_gfxvram[offset + 0x8000] = data;
687   if(towns_vram_wplane & 0x04)
688      towns_gfxvram[offset + 0x10000] = data;
689   if(towns_vram_wplane & 0x08)
690      towns_gfxvram[offset + 0x18000] = data;
828   {
829      towns_gfxvram[offset] &= ~0x11;
830      towns_gfxvram[offset] |= ((data & 0x80) >> 7) | ((data & 0x40) >> 2);
831      towns_gfxvram[offset + 1] &= ~0x11;
832      towns_gfxvram[offset + 1] |= ((data & 0x20) >> 5) | ((data & 0x10));
833      towns_gfxvram[offset + 2] &= ~0x11;
834      towns_gfxvram[offset + 2] |= ((data & 0x08) >> 3) | ((data & 0x04) << 2);
835      towns_gfxvram[offset + 3] &= ~0x11;
836      towns_gfxvram[offset + 3] |= ((data & 0x02) >> 1) | ((data & 0x01) << 4);
837   }
691838}
692839
693840static READ8_HANDLER( towns_video_cff80_r )
r6353r6354
702849         return towns_crtc_mix;
703850      case 0x01:  // read/write plane select (bit 0-3 write, bit 6-7 read)
704851         return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane;
852      case 0x03:  // VRAM page select (bit 5)
853         if(towns_vram_page_sel != 0)
854            return 0x10;
855         else
856            return 0x00;
705857      case 0x16:  // Kanji character data
706858         return ROM[(towns_kanji_offset << 1) + 0x180000];
707859      case 0x17:  // Kanji character data
r6353r6354
737889         towns_update_video_banks(space);
738890         logerror("VGA: VRAM wplane select = 0x%02x\n",towns_vram_wplane);
739891         break;
892      case 0x03:  // VRAM page select (bit 5)
893         towns_vram_page_sel = data & 0x10;
894         break;
740895      case 0x14:  // Kanji offset (high)
741896         towns_kanji_code_h = data & 0x7f;
742897         break;
r6353r6354
768923         }
769924         break;
770925      case 0x19:  // ANK CG ROM
771         towns_ankcg_enable = data & 0x00000100;
926         towns_ankcg_enable = data & 0x01;
772927         towns_update_video_banks(space);
773928         break;
774929      default:
r6353r6354
784939   {
785940      ROM = memory_region(space->machine,"user");
786941
787      memory_set_bankptr(space->machine,1,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc0000);
788      memory_set_bankptr(space->machine,2,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc8000);
789      memory_set_bankptr(space->machine,3,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc9000);
790      memory_set_bankptr(space->machine,4,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca000);
791      memory_set_bankptr(space->machine,5,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca000);
792      memory_set_bankptr(space->machine,10,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca800);
942//      memory_set_bankptr(space->machine,1,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc0000);
943//      memory_set_bankptr(space->machine,2,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc8000);
944//      memory_set_bankptr(space->machine,3,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc9000);
945//      memory_set_bankptr(space->machine,4,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca000);
946//      memory_set_bankptr(space->machine,5,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca000);
947//      memory_set_bankptr(space->machine,10,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca800);
793948      memory_set_bankptr(space->machine,6,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xcb000);
794949      memory_set_bankptr(space->machine,7,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xcb000);
795950      memory_set_bankptr(space->machine,8,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xcc000);
r6353r6354
804959   {
805960      ROM = memory_region(space->machine,"user");
806961
807      memory_set_bankptr(space->machine,1,towns_gfxvram+(towns_vram_rplane*0x8000));
808      memory_set_bankptr(space->machine,2,towns_txtvram);
809      memory_set_bankptr(space->machine,3,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc9000);
810      if(towns_ankcg_enable == 0)
811         memory_set_bankptr(space->machine,4,ROM+0x180000+0x3d000);  // ANK CG 8x8
812      else
813         memory_set_bankptr(space->machine,4,towns_txtvram+0x2000);
814      memory_set_bankptr(space->machine,5,towns_txtvram+0x2000);
815      memory_set_bankptr(space->machine,10,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca800);
816      if(towns_ankcg_enable == 0)
962//      memory_set_bankptr(space->machine,1,towns_gfxvram+(towns_vram_rplane*0x8000));
963//      memory_set_bankptr(space->machine,2,towns_txtvram);
964//      memory_set_bankptr(space->machine,3,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xc9000);
965//      if(towns_ankcg_enable != 0)
966//         memory_set_bankptr(space->machine,4,ROM+0x180000+0x3d000);  // ANK CG 8x8
967//      else
968//         memory_set_bankptr(space->machine,4,towns_txtvram+0x2000);
969//      memory_set_bankptr(space->machine,5,towns_txtvram+0x2000);
970//      memory_set_bankptr(space->machine,10,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xca800);
971      if(towns_ankcg_enable != 0)
817972         memory_set_bankptr(space->machine,6,ROM+0x180000+0x3d800);  // ANK CG 8x16
818973      else
819974         memory_set_bankptr(space->machine,6,messram_get_ptr(devtag_get_device(space->machine, "messram"))+0xcb000);
r6353r6354
8641019
8651020static READ32_HANDLER( towns_video_404_r )
8661021{
867   if(towns_mainmem_enable != 0)
868      return 0x00000080;
869
1022   if(ACCESSING_BITS_0_7)
1023   {
1024      if(towns_mainmem_enable != 0)
1025         return 0x00000080;
1026   }
8701027   return 0;
8711028}
8721029
r6353r6354
9081065   }
9091066}
9101067
1068
1069/*
1070 *  Sprite RAM, low memory
1071 *  Writing to 0xc8xxx or 0xcaxxx activates TVRAM mode
1072 *  Writing to I/O port 0x5c8 disables TVRAM mode
1073 *     (bit 7 returns high is TVRAM mode was previously active)
1074 *
1075 *  In TVRAM mode:
1076 *    0xc8000-0xc8fff: ASCII text (2 bytes each: ISO646 code, then attribute)
1077 *    0xca000-0xcafff: JIS code
1078 */
1079static READ8_HANDLER(towns_spriteram_low_r)
1080{
1081   UINT8* RAM = messram_get_ptr(devtag_get_device(space->machine, "messram"));
1082   UINT8* ROM = memory_region(space->machine,"user");
1083   
1084   if(offset < 0x1000)
1085   {  // 0xc8000-0xc8fff
1086      if(towns_mainmem_enable == 0)
1087         return towns_txtvram[offset];
1088      else
1089         return RAM[offset + 0xc8000];
1090   }
1091   if(offset >= 0x1000 && offset < 0x2000)
1092   {  // 0xc9000-0xc9fff
1093      return RAM[offset + 0xc9000];
1094   }
1095   if(offset >= 0x2000 && offset < 0x3000)
1096   {  // 0xca000-0xcafff
1097      if(towns_mainmem_enable == 0)
1098      {
1099         if(towns_ankcg_enable != 0 && offset < 0x2800)
1100            return ROM[0x180000 + 0x3d000 + (offset-0x2000)];
1101         return towns_txtvram[offset];
1102      }
1103      else
1104         return RAM[offset + 0xca000];
1105   }
1106   return 0x00;
1107}
1108
1109static WRITE8_HANDLER(towns_spriteram_low_w)
1110{
1111   UINT8* RAM = messram_get_ptr(devtag_get_device(space->machine, "messram"));
1112   if(offset < 0x1000)
1113   {  // 0xc8000-0xc8fff
1114      towns_tvram_enable = 1;
1115      if(towns_mainmem_enable == 0)
1116         towns_txtvram[offset] = data;
1117      else
1118         RAM[offset + 0xc8000] = data;
1119   }
1120   if(offset >= 0x1000 && offset < 0x2000)
1121   {
1122      RAM[offset + 0xc9000] = data;
1123   }
1124   if(offset >= 0x2000 && offset < 0x3000)
1125   {  // 0xca000-0xcafff
1126      towns_tvram_enable = 1;
1127      if(towns_mainmem_enable == 0)
1128         towns_txtvram[offset] = data;
1129      else
1130         RAM[offset + 0xca000] = data;
1131   }
1132}
1133
1134
9111135/* CMOS RTC
9121136 * 0x70: Data port
9131137 * 0x80: Register select
r6353r6354
10131237static PIC8259_SET_INT_LINE( towns_pic_irq )
10141238{
10151239   cputag_set_input_line(device->machine,"maincpu",0,interrupt ? HOLD_LINE : CLEAR_LINE);
1016   logerror("PIC#1: set IRQ line to %i\n",interrupt);
1240//   logerror("PIC#1: set IRQ line to %i\n",interrupt);
10171241}
10181242
10191243static PIC8259_SET_INT_LINE( towns_slave_pic_irq )
r6353r6354
10211245   const device_config* dev = devtag_get_device(device->machine,"pic8259_master");
10221246
10231247   pic8259_set_irq_line(dev,7,interrupt);
1024   logerror("PIC#2: set IRQ line to %i\n",interrupt);
1248//   logerror("PIC#2: set IRQ line to %i\n",interrupt);
10251249}
10261250
10271251static PIT8253_OUTPUT_CHANGED( towns_pit_out0_changed )
r6353r6354
10361260
10371261static PIT8253_OUTPUT_CHANGED( towns_pit_out1_changed )
10381262{
1039   const device_config* dev = devtag_get_device(device->machine,"pic8259_master");
1263//   const device_config* dev = devtag_get_device(device->machine,"pic8259_master");
10401264   
10411265   if(towns_timer_mask & 0x02)
10421266   {
1043      pic8259_set_irq_line(dev,0,state);
1267   //   pic8259_set_irq_line(dev,0,state);
10441268   }
10451269}
10461270
r6353r6354
10481272  // memory map based on FM-Towns/Bochs (Bochs modified to emulate the FM-Towns)
10491273  // may not be (and probably is not) correct
10501274  AM_RANGE(0x00000000, 0x000bffff) AM_RAM
1051  AM_RANGE(0x000c0000, 0x000c7fff) AM_READ(SMH_BANK(1))
1052  AM_RANGE(0x000c0000, 0x000c7fff) AM_WRITE8(towns_gfx_w,0xffffffff)
1275  AM_RANGE(0x000c0000, 0x000c7fff) AM_READWRITE8(towns_gfx_r,towns_gfx_w,0xffffffff)
1276//  AM_RANGE(0x000c8000, 0x000c8fff) AM_READWRITE(SMH_BANK(2),SMH_BANK(2))
1277//  AM_RANGE(0x000c9000, 0x000c9fff) AM_READWRITE(SMH_BANK(3),SMH_BANK(3))
1278//  AM_RANGE(0x000ca000, 0x000ca7ff) AM_READWRITE(SMH_BANK(4),SMH_BANK(5))
1279//  AM_RANGE(0x000ca800, 0x000cafff) AM_READWRITE(SMH_BANK(10),SMH_BANK(10))
1280  AM_RANGE(0x000c8000, 0x000cafff) AM_READWRITE8(towns_spriteram_low_r,towns_spriteram_low_w,0xffffffff)
1281  AM_RANGE(0x000cb000, 0x000cbfff) AM_READWRITE(SMH_BANK(6),SMH_BANK(7))
1282  AM_RANGE(0x000cc000, 0x000cff7f) AM_READWRITE(SMH_BANK(8),SMH_BANK(8))
1283  AM_RANGE(0x000cff80, 0x000cffff) AM_READWRITE8(towns_video_cff80_r,towns_video_cff80_w,0xffffffff)
1284  AM_RANGE(0x000d0000, 0x000d7fff) AM_RAM
1285  AM_RANGE(0x000d8000, 0x000d9fff) AM_READWRITE8(towns_cmos_low_r,towns_cmos_low_w,0xffffffff) // CMOS? RAM
1286  AM_RANGE(0x000da000, 0x000effff) AM_RAM //READWRITE(SMH_BANK(11),SMH_BANK(11))
1287  AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM //READWRITE(SMH_BANK(12),SMH_BANK(12))
1288  AM_RANGE(0x000f8000, 0x000fffff) AM_READWRITE(SMH_BANK(11),SMH_BANK(12))
1289  AM_RANGE(0x00100000, 0x005fffff) AM_RAM  // some extra RAM - seems to be needed to boot
1290  AM_RANGE(0x80000000, 0x8003ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
1291  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM  // Sprite RAM
1292  AM_RANGE(0xc2000000, 0xc207ffff) AM_ROM AM_REGION("user",0x000000)  // OS ROM
1293  AM_RANGE(0xc2080000, 0xc20fffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM
1294  AM_RANGE(0xc2100000, 0xc213ffff) AM_ROM AM_REGION("user",0x180000)  // FONT ROM
1295  AM_RANGE(0xc2140000, 0xc2141fff) AM_READWRITE8(towns_cmos_r,towns_cmos_w,0xffffffff) // CMOS (mirror?)
1296  AM_RANGE(0xc2180000, 0xc21fffff) AM_ROM AM_REGION("user",0x080000)  // F20 ROM
1297  AM_RANGE(0xc2200000, 0xc2200fff) AM_NOP  // WAVE RAM
1298  AM_RANGE(0xfffc0000, 0xffffffff) AM_ROM AM_REGION("user",0x200000)  // SYSTEM ROM
1299ADDRESS_MAP_END
1300
1301static ADDRESS_MAP_START(marty_mem, ADDRESS_SPACE_PROGRAM, 32)
1302  AM_RANGE(0x00000000, 0x000bffff) AM_RAM
1303  AM_RANGE(0x000c0000, 0x000c7fff) AM_READWRITE8(towns_gfx_r,towns_gfx_w,0xffffffff)
10531304  AM_RANGE(0x000c8000, 0x000c8fff) AM_READWRITE(SMH_BANK(2),SMH_BANK(2))
10541305  AM_RANGE(0x000c9000, 0x000c9fff) AM_READWRITE(SMH_BANK(3),SMH_BANK(3))
10551306  AM_RANGE(0x000ca000, 0x000ca7ff) AM_READWRITE(SMH_BANK(4),SMH_BANK(5))
r6353r6354
10631314  AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM //READWRITE(SMH_BANK(12),SMH_BANK(12))
10641315  AM_RANGE(0x000f8000, 0x000fffff) AM_READWRITE(SMH_BANK(11),SMH_BANK(12))
10651316  AM_RANGE(0x00100000, 0x005fffff) AM_RAM  // some extra RAM - seems to be needed to boot
1317  AM_RANGE(0x00600000, 0x0067ffff) AM_ROM AM_REGION("user",0x000000)  // OS
1318  AM_RANGE(0x00680000, 0x0087ffff) AM_ROM AM_REGION("user",0x280000)  // EX ROM
1319  AM_RANGE(0x00a00000, 0x00a3ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
1320  AM_RANGE(0x00e80000, 0x00efffff) AM_ROM AM_REGION("user",0x100000)  // DIC ROM
1321  AM_RANGE(0x00f00000, 0x00f7ffff) AM_ROM AM_REGION("user",0x180000)  // FONT
1322  AM_RANGE(0x00fc0000, 0x00ffffff) AM_ROM AM_REGION("user",0x200000)  // SYSTEM ROM
10661323  AM_RANGE(0x80000000, 0x8003ffff) AM_READWRITE8(towns_gfx_high_r,towns_gfx_high_w,0xffffffff) AM_MIRROR(0x1c0000) // VRAM
10671324  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM  // Sprite RAM
10681325  AM_RANGE(0xc2000000, 0xc207ffff) AM_ROM AM_REGION("user",0x000000)  // OS ROM
r6353r6354
11321389static INPUT_PORTS_START( towns )
11331390INPUT_PORTS_END
11341391
1392static INTERRUPT_GEN( towns_vsync_irq )
1393{
1394   const device_config* dev = devtag_get_device(device->machine,"pic8259_slave");
1395   pic8259_set_irq_line(dev,3,1);  // IRQ11 = VSync
1396}
1397
11351398static DRIVER_INIT( towns )
11361399{
11371400   towns_vram = auto_alloc_array(machine,UINT32,0x20000);
11381401   towns_cmos = auto_alloc_array(machine,UINT8,0x2000);
11391402   towns_gfxvram = auto_alloc_array(machine,UINT8,0x40000);
1140   towns_txtvram = auto_alloc_array(machine,UINT8,0x8000);
1403   towns_txtvram = auto_alloc_array(machine,UINT8,0x20000);
11411404   towns_serial_rom = auto_alloc_array(machine,UINT8,256/8);
11421405   towns_init_serial_rom(machine);
11431406   towns_init_rtc();
r6353r6354
11621425   towns_ram_enable = 0x00;
11631426   towns_update_video_banks(cpu_get_address_space(cputag_get_cpu(machine,"maincpu"),ADDRESS_SPACE_PROGRAM));
11641427   towns_vram_wplane = 0x00;
1428   towns_kb_status = 0x18;
1429   towns_kb_irq1_enable = 0;
11651430   timer_adjust_periodic(towns_rtc_timer,attotime_zero,0,ATTOTIME_IN_HZ(1));
11661431}
11671432
r6353r6354
11721437static VIDEO_UPDATE( towns )
11731438{
11741439   int x,y;
1175   UINT8 dat1,dat2,dat3,dat4;
1176   int bit;
11771440   UINT8 colour;
1178
1441   UINT8 row;  // JIS row number
1442   UINT16 code;
1443   int off = 0;
1444   
1445   if(towns_vram_page_sel != 0)
1446      off = 0x20000;
11791447   for(y=0;y<480;y++)
11801448   {
1181      for(x=0;x<640;x++)
1449//      off = 0x50 * y;
1450      for(x=0;x<640;x+=2)
11821451      {
1183         bit = 7 - (x & 0x07);
1184         dat1 = towns_gfxvram[(x/8) + (y*0x50)];
1185         dat2 = towns_gfxvram[(x/8) + (y*0x50) + 0x8000];
1186         dat3 = towns_gfxvram[(x/8) + (y*0x50) + 0x10000];
1187         dat4 = towns_gfxvram[(x/8) + (y*0x50) + 0x18000];
1188         colour = (dat1 & (1 << bit) ? 1 : 0)
1189            | (dat2 & (1 << bit) ? 2 : 0)
1190            | (dat3 & (1 << bit) ? 4 : 0)
1191            | (dat4 & (1 << bit) ? 8 : 0);
1452         colour = towns_gfxvram[off] >> 4;
1453         *BITMAP_ADDR32(bitmap,y,x+1) =
1454            (towns_palette_r[colour] << 16)
1455            | (towns_palette_g[colour] << 8)
1456            | (towns_palette_b[colour]);
1457         colour = towns_gfxvram[off] & 0x0f;
11921458         *BITMAP_ADDR32(bitmap,y,x) =
11931459            (towns_palette_r[colour] << 16)
11941460            | (towns_palette_g[colour] << 8)
11951461            | (towns_palette_b[colour]);
1462         off++;
11961463      }
1464   }   
1465   
1466   // draw text layer
1467   if(towns_tvram_enable != 0)
1468   {
1469      for(y=0;y<40;y++)
1470      {
1471         off = 160 * y;
1472         for(x=0;x<80;x++)
1473         {
1474            colour = towns_txtvram[off+1] & 0x0f;
1475            if((towns_txtvram[off+1] & 0xc0) != 0)
1476            {   // double width
1477               // TODO: work out exactly how these map to the font ROM
1478               // Numbers are tiles 0x70-0x79
1479               // lowercase characters are from tile 0x160
1480               // uppercase characters are from tile 0x260
1481               if(towns_txtvram[off+1] & 0x40)
1482               {
1483                  row = (towns_txtvram[off+0x2000] - 32);
1484                  code = 0;
1485                  if(row <= 8)
1486                  {
1487                     code = (row & 0x07) * 0x20;
1488                     code += ((towns_txtvram[off+0x2001]-32) & 0x1f)
1489                           | (((towns_txtvram[off+0x2001]-32) & 0x40) << 2)
1490                           | (((towns_txtvram[off+0x2001]-32) & 0x20) << 4);
1491                  }
1492                  if(row >= 16)  // Kanji
1493                  {
1494                     code = 0x400;
1495                     code += ((towns_txtvram[off+0x2001]) & 0x1f)
1496                           + (((towns_txtvram[off+0x2001]-32) & 0x60) << 4)
1497                           + ((row & 0x0f) << 5)
1498                           + (((row-16) & 0x70) * 0x60);
1499                  }
1500                  drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[1],code,
1501                     (towns_palette_r[colour] << 16)
1502                     | (towns_palette_g[colour] << 8)
1503                     | (towns_palette_b[colour]),
1504                     0,0,x*8,y*16,0);
1505               }
1506            }
1507            else
1508            {
1509               drawgfx_transpen_raw(bitmap,cliprect,screen->machine->gfx[0],towns_txtvram[off],
1510                  (towns_palette_r[colour] << 16)
1511                  | (towns_palette_g[colour] << 8)
1512                  | (towns_palette_b[colour]),
1513                  0,0,x*8,y*16,0);
1514            }
1515            off += 2;
1516         }
1517      }
11971518   }
1198
1519     
11991520    return 0;
12001521}
12011522
r6353r6354
12301551
12311552static const wd17xx_interface towns_mb8877a_interface =
12321553{
1233   DEVCB_NULL,
1554   DEVCB_DEVICE_LINE("pic8259_master",towns_mb8877a_irq_w),
12341555   DEVCB_DEVICE_LINE("dma_1", towns_mb8877a_drq_w),
1235   {FLOPPY_0,FLOPPY_1,FLOPPY_2,FLOPPY_3}
1556   {FLOPPY_0,FLOPPY_1,0,0}
12361557};
12371558
12381559static FLOPPY_OPTIONS_START( towns )
r6353r6354
12651586};
12661587
12671588// for debugging
1268static const gfx_layout x1_chars_16x16 =
1589static const gfx_layout fnt_chars_16x16 =
12691590{
12701591   16,16,
12711592   RGN_FRAC(1,1),
r6353r6354
12761597   16*16
12771598};
12781599
1600static const gfx_layout text_chars =
1601{
1602   8,16,
1603   RGN_FRAC(1,1),
1604   1,
1605   { 0 },
1606   { 0, 1, 2, 3, 4, 5, 6, 7, },
1607   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 ,8*8, 9*8, 10*8, 11*8, 12*8, 13*8, 14*8, 15*8 },
1608   8*16
1609};
1610
12791611/* decoded for debugging purpose, this will be nuked in the end... */
12801612static GFXDECODE_START( towns )
1281   GFXDECODE_ENTRY( "user",   0x180000, x1_chars_16x16,  0, 0x100 ) //needs to be checked when the ROM will be redumped
1613   GFXDECODE_ENTRY( "user",   0x180000 + 0x3d800, text_chars,  0, 16 )
1614   GFXDECODE_ENTRY( "user",   0x180000, fnt_chars_16x16,  0, 16 )
12821615GFXDECODE_END
12831616
12841617static MACHINE_DRIVER_START( towns )
r6353r6354
12861619    MDRV_CPU_ADD("maincpu",I386, 16000000)
12871620    MDRV_CPU_PROGRAM_MAP(towns_mem)
12881621    MDRV_CPU_IO_MAP(towns_io)
1622   MDRV_CPU_VBLANK_INT("screen", towns_vsync_irq)
12891623
12901624    MDRV_MACHINE_RESET(towns)
12911625
r6353r6354
12931627    MDRV_SCREEN_ADD("screen", RASTER)
12941628    MDRV_SCREEN_REFRESH_RATE(60)
12951629    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
1630   
12961631    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
12971632    MDRV_SCREEN_SIZE(640, 480)
12981633    MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
r6353r6354
13271662   MDRV_RAM_DEFAULT_SIZE("6M")
13281663MACHINE_DRIVER_END
13291664
1665static MACHINE_DRIVER_START( marty )
1666   MDRV_IMPORT_FROM(towns)
1667   
1668   MDRV_CPU_REPLACE("maincpu",I386, 16000000)
1669   MDRV_CPU_PROGRAM_MAP(marty_mem)
1670   MDRV_CPU_IO_MAP(towns_io)
1671MACHINE_DRIVER_END
1672
13301673/* ROM definitions */
13311674ROM_START( fmtowns )
13321675  ROM_REGION32_LE( 0x280000, "user", 0)
r6353r6354
13471690ROM_END
13481691
13491692ROM_START( fmtmarty )
1350  ROM_REGION32_LE( 0x400000, "user", 0)
1351   ROM_LOAD("mrom.m36",  0x000000, 0x200000, CRC(9c0c060c) SHA1(5721c5f9657c570638352fa9acac57fa8d0b94bd) )
1352   ROM_LOAD("mrom.m37",  0x200000, 0x180000, CRC(fb66bb56) SHA1(e273b5fa618373bdf7536495cd53c8aac1cce9a5) )
1693  ROM_REGION32_LE( 0x480000, "user", 0)
1694   ROM_LOAD("mrom.m36",  0x000000, 0x080000, CRC(9c0c060c) SHA1(5721c5f9657c570638352fa9acac57fa8d0b94bd) )
1695   ROM_CONTINUE(0x280000,0x180000)
1696   ROM_LOAD("mrom.m37",  0x400000, 0x080000, CRC(fb66bb56) SHA1(e273b5fa618373bdf7536495cd53c8aac1cce9a5) )
1697   ROM_CONTINUE(0x80000,0x100000)
13531698   ROM_CONTINUE(0x180000,0x40000)
13541699   ROM_CONTINUE(0x200000,0x40000)
13551700ROM_END
r6353r6354
13731718/*    YEAR  NAME    PARENT  COMPAT     MACHINE     INPUT    INIT    CONFIG COMPANY      FULLNAME            FLAGS */
13741719COMP( 1989, fmtowns,  0,       0,       towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns",       GAME_NOT_WORKING)
13751720COMP( 1989, fmtownsa, fmtowns,   0,       towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns (alternate)", GAME_NOT_WORKING)
1376CONS( 1993, fmtmarty, 0,       0,       towns,       towns,     marty,      0,     "Fujitsu",   "FM-Towns Marty",    GAME_NOT_WORKING)
1377CONS( 1994, carmarty, fmtmarty,   0,       towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns Car Marty",    GAME_NOT_WORKING)
1721CONS( 1993, fmtmarty, 0,       0,       marty,       towns,     marty,      0,     "Fujitsu",   "FM-Towns Marty",    GAME_NOT_WORKING)
1722CONS( 1994, carmarty, fmtmarty,   0,       marty,       towns,     towns,      0,     "Fujitsu",   "FM-Towns Car Marty",    GAME_NOT_WORKING)
13781723

Previous 15994 Revisions Next


© 1998-2018 The MESS Team