Previous 15994 Revisions Next

r5938 Friday 2nd October, 2009 at 03:27:05 UTC by Barry Rodewald
[FMTOWNS] Improved memory map, added some RAM/ROM banking, and very basic video output. Displays logo, and parent set performs RAM tests (set less RAM than expected to avoid invalid opcode error on parent set).
[src/mess/drivers]fmtowns.c

src/mess/drivers/fmtowns.c
r5937r5938
8383static UINT8 nmi_mask;
8484static UINT8 compat_mode;
8585static UINT8 towns_system_port;
86static UINT32 towns_ankcg_enable;
87static UINT32 towns_mainmem_enable;
88static UINT32 towns_ram_enable;
8689static UINT32* towns_vram;
8790static UINT32* towns_cmos;
88static UINT32* towns_gfxvram;
89static UINT32* towns_txtvram;
91static UINT8* towns_gfxvram;
92static UINT8* towns_txtvram;
93static UINT8 towns_vram_wplane;
94static UINT8 towns_vram_rplane;
95static UINT8 towns_palette_select;
96static UINT8 towns_palette_r[256];
97static UINT8 towns_palette_g[256];
98static UINT8 towns_palette_b[256];
99static UINT8 towns_degipal[8];
90100
101static void towns_update_video_banks(const address_space* space);
102
91103static READ8_HANDLER(towns_system_r)
92104{
93105   switch(offset)
r5937r5938
209221   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0x5c8);
210222}
211223
224/* Video/CRTC
225 *
226 * 0xfd90 - palette colour select
227 * 0xfd92/4/6 - BRG value
228 * 0xfd98-9f  - degipal(?)
229 */
212230static READ8_HANDLER(towns_video_fd90_r)
213231{
214   logerror("VID: read port %04x\n",offset+0xfd90);
232   switch(offset)
233   {
234      case 0x00:
235         return towns_palette_select;
236      case 0x02:
237         return towns_palette_r[towns_palette_select];
238      case 0x04:
239         return towns_palette_g[towns_palette_select];
240      case 0x06:
241         return towns_palette_b[towns_palette_select];
242      case 0x08:
243      case 0x09:
244      case 0x0a:
245      case 0x0b:
246      case 0x0c:
247      case 0x0d:
248      case 0x0e:
249      case 0x0f:
250         return towns_degipal[offset-0x08];
251   }
252//   logerror("VID: read port %04x\n",offset+0xfd90);
215253   return 0x00;
216254}
217255
218256static WRITE8_HANDLER(towns_video_fd90_w)
219257{
220   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90);
258   switch(offset)
259   {
260      case 0x00:
261         towns_palette_select = data;
262         break;
263      case 0x02:
264         towns_palette_r[towns_palette_select] = data;
265         break;
266      case 0x04:
267         towns_palette_g[towns_palette_select] = data;
268         break;
269      case 0x06:
270         towns_palette_b[towns_palette_select] = data;
271         break;
272      case 0x08:
273      case 0x09:
274      case 0x0a:
275      case 0x0b:
276      case 0x0c:
277      case 0x0d:
278      case 0x0e:
279      case 0x0f:
280         towns_degipal[offset-0x08] = data;
281         break;
282   }
283//   logerror("VID: wrote 0x%02x to port %04x\n",data,offset+0xfd90);
221284}
222285
223static READ8_HANDLER(towns_video_ff81_r)
224{
225   logerror("VID: read port ff81\n");
226   return 0x00;
227}
228
229static WRITE8_HANDLER(towns_video_ff81_w)
230{
231   logerror("VID: wrote 0x%02x to port ff81\n",data);
232}
233
234286static READ8_HANDLER(towns_keyboard_r)
235287{
236288   logerror("KB: read offset %02x\n",offset);
r5937r5938
268320         if(ACCESSING_BITS_0_7)
269321         {
270322            logerror("SYS: read RAM size port\n");
271            return 0x06;  // 6MB is standard for the Marty
323            return 0x08;  // 6MB is standard for the Marty
272324         }
273325         break;
274326      case 0x01:
r5937r5938
334386   COMBINE_DATA(towns_cmos+offset);
335387}
336388
389static WRITE8_HANDLER( towns_gfx_w )
390{
391   if(towns_mainmem_enable != 0)
392   {
393      mess_ram[offset+0xc0000] = data;
394      return;
395   }
396   if(towns_vram_wplane & 0x01)
397      towns_gfxvram[offset] = data;
398   if(towns_vram_wplane & 0x02)
399      towns_gfxvram[offset + 0x8000] = data;
400   if(towns_vram_wplane & 0x04)
401      towns_gfxvram[offset + 0x10000] = data;
402   if(towns_vram_wplane & 0x08)
403      towns_gfxvram[offset + 0x18000] = data;
404}
405
406static READ8_HANDLER( towns_video_cff80_r )
407{
408   if(towns_mainmem_enable != 0)
409      return mess_ram[offset+0xcff80];
410   
411   switch(offset)
412   {
413      case 0x01:  // read/write plane select (bit 0-3 write, bit 6-7 read)
414         return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane;
415      case 0x19:  // ANK CG ROM
416         if(towns_ankcg_enable != 0)
417            return 0x01;
418         else
419            return 0x00;
420      default:
421         logerror("VGA: read from invalid or unimplemented memory-mapped port %05x\n",0xcff80+offset*4);
422   }
423   
424   return 0;
425}
426
427static WRITE8_HANDLER( towns_video_cff80_w )
428{
429   if(towns_mainmem_enable != 0)
430   {
431      mess_ram[offset+0xcff80] = data;
432      return;
433   }
434
435   switch(offset)
436   {
437      case 0x01:  // read/write plane select (bit 0-3 write, bit 6-7 read)
438         towns_vram_wplane = data & 0x0f;
439         towns_vram_rplane = (data & 0xc0) >> 6;
440         towns_update_video_banks(space);
441         logerror("VGA: VRAM wplane select = 0x%02x\n",towns_vram_wplane);
442         break;
443      case 0x19:  // ANK CG ROM
444         towns_ankcg_enable = data & 0x00000100;
445         towns_update_video_banks(space);
446         break;
447      default:
448         logerror("VGA: write %08x to invalid or unimplemented memory-mapped port %05x\n",data,0xcff80+offset);
449   }
450}
451
452static void towns_update_video_banks(const address_space* space)
453{
454   UINT8* ROM;
455   
456   if(towns_mainmem_enable != 0)  // first MB is RAM
457   {
458      memory_set_bankptr(space->machine,1,mess_ram+0xc0000);
459      memory_set_bankptr(space->machine,2,mess_ram+0xc8000);
460      memory_set_bankptr(space->machine,3,mess_ram+0xc9000);
461      memory_set_bankptr(space->machine,4,mess_ram+0xca000);
462      memory_set_bankptr(space->machine,5,mess_ram+0xca000);
463      memory_set_bankptr(space->machine,10,mess_ram+0xca800);
464      memory_set_bankptr(space->machine,6,mess_ram+0xcb000);
465      memory_set_bankptr(space->machine,7,mess_ram+0xcb000);
466      memory_set_bankptr(space->machine,8,mess_ram+0xcc000);
467      memory_set_bankptr(space->machine,11,mess_ram+0xf8000);
468      memory_set_bankptr(space->machine,12,mess_ram+0xf8000);
469      return;
470   }
471   else  // enable I/O ports and VRAM
472   {
473      ROM = memory_region(space->machine,"user");
474
475      memory_set_bankptr(space->machine,1,towns_gfxvram+(towns_vram_rplane*0x8000));
476      memory_set_bankptr(space->machine,2,towns_txtvram);
477      memory_set_bankptr(space->machine,3,mess_ram+0xc9000);
478      if(towns_ankcg_enable == 0)
479         memory_set_bankptr(space->machine,4,ROM+0x180000+0x3d000);  // ANK CG 8x8
480      else
481         memory_set_bankptr(space->machine,4,towns_txtvram+0x2000);
482      memory_set_bankptr(space->machine,5,towns_txtvram+0x2000);
483      memory_set_bankptr(space->machine,10,mess_ram+0xca800);
484      if(towns_ankcg_enable == 0)
485         memory_set_bankptr(space->machine,6,ROM+0x180000+0x3d800);  // ANK CG 8x16
486      else
487         memory_set_bankptr(space->machine,6,mess_ram+0xcb000);
488      memory_set_bankptr(space->machine,7,mess_ram+0xcb000);
489      memory_set_bankptr(space->machine,8,mess_ram+0xcc000);
490      memory_set_bankptr(space->machine,11,ROM+0x238000);
491      memory_set_bankptr(space->machine,12,mess_ram+0xf8000);
492      return;
493   }
494}
495
337496static READ8_HANDLER( towns_sys480_r )
338497{
339498   if(towns_system_port & 0x02)
r5937r5938
345504static WRITE8_HANDLER( towns_sys480_w )
346505{
347506   towns_system_port = data;
507   towns_ram_enable = data & 0x02;
508   towns_update_video_banks(space);
348509}
349510
511static WRITE32_HANDLER( towns_video_404_w )
512{
513   if(ACCESSING_BITS_0_7)
514   {
515      towns_mainmem_enable = data & 0x80;
516      towns_update_video_banks(space);
517   }
518}
519
520static READ32_HANDLER( towns_video_404_r )
521{
522   if(towns_mainmem_enable != 0)
523      return 0x00000080;
524   
525   return 0;
526}
527
528static READ8_HANDLER(towns_video_ff81_r)
529{
530   return ((towns_vram_rplane << 6) & 0xc0) | towns_vram_wplane;
531}
532
533static WRITE8_HANDLER(towns_video_ff81_w)
534{
535   towns_vram_wplane = data & 0x0f;
536   towns_vram_rplane = (data & 0xc0) >> 6;
537   towns_update_video_banks(space);
538   logerror("VGA: VRAM wplane select (I/O) = 0x%02x\n",towns_vram_wplane);
539}
540
350541static ADDRESS_MAP_START(towns_mem, ADDRESS_SPACE_PROGRAM, 32)
351542  // memory map based on FM-Towns/Bochs (Bochs modified to emulate the FM-Towns)
352543  // may not be (and probably is not) correct
353544  AM_RANGE(0x00000000, 0x000bffff) AM_RAM
354  AM_RANGE(0x000c0000, 0x000c7fff) AM_RAM AM_BASE(&towns_gfxvram)  // GVRAM
355  AM_RANGE(0x000c8000, 0x000cffff) AM_RAM AM_BASE(&towns_txtvram) // TVRAM
356//  AM_RANGE(0x000ca000, 0x000cafff) AM_RAM AM_BASE(&towns_txtvram) // TVRAM
545  AM_RANGE(0x000c0000, 0x000c7fff) AM_READ(SMH_BANK(1))
546  AM_RANGE(0x000c0000, 0x000c7fff) AM_WRITE8(towns_gfx_w,0xffffffff)
547  AM_RANGE(0x000c8000, 0x000c8fff) AM_READWRITE(SMH_BANK(2),SMH_BANK(2))
548  AM_RANGE(0x000c9000, 0x000c9fff) AM_READWRITE(SMH_BANK(3),SMH_BANK(3))
549  AM_RANGE(0x000ca000, 0x000ca7ff) AM_READWRITE(SMH_BANK(4),SMH_BANK(5))
550  AM_RANGE(0x000ca800, 0x000cafff) AM_READWRITE(SMH_BANK(10),SMH_BANK(10))
551  AM_RANGE(0x000cb000, 0x000cbfff) AM_READWRITE(SMH_BANK(6),SMH_BANK(7))
552  AM_RANGE(0x000cc000, 0x000cff7f) AM_READWRITE(SMH_BANK(8),SMH_BANK(8))
553  AM_RANGE(0x000cff80, 0x000cffff) AM_READWRITE8(towns_video_cff80_r,towns_video_cff80_w,0xffffffff)
357554  AM_RANGE(0x000d0000, 0x000d7fff) AM_RAM
358555  AM_RANGE(0x000d8000, 0x000d9fff) AM_READWRITE(towns_cmos_r,towns_cmos_w) // CMOS? RAM
359  AM_RANGE(0x000da000, 0x000effff) AM_RAM
360  AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM
361  AM_RANGE(0x000f8000, 0x000fffff) AM_RAM AM_REGION("user",0x238000)  // BOOT (SYSTEM) ROM
556  AM_RANGE(0x000da000, 0x000effff) AM_RAM //READWRITE(SMH_BANK(11),SMH_BANK(11))
557  AM_RANGE(0x000f0000, 0x000f7fff) AM_RAM //READWRITE(SMH_BANK(12),SMH_BANK(12))
558  AM_RANGE(0x000f8000, 0x000fffff) AM_READWRITE(SMH_BANK(11),SMH_BANK(12))
362559  AM_RANGE(0x00100000, 0x005fffff) AM_RAM  // some extra RAM - seems to be needed to boot
363560  AM_RANGE(0x80000000, 0x8003ffff) AM_RAM AM_MIRROR(0x1c0000) AM_BASE(&towns_vram) // VRAM
364561  AM_RANGE(0x81000000, 0x8101ffff) AM_RAM  // Sprite RAM
r5937r5938
387584  AM_RANGE(0x0200,0x020f) AM_READWRITE8(towns_floppy_r, towns_floppy_w, 0xffffffff)
388585  // CRTC / Video
389586  AM_RANGE(0x0400,0x0403) AM_NOP  // R/O (0x400)
390  AM_RANGE(0x0404,0x0407) AM_NOP  // R/W (0x404)
587  AM_RANGE(0x0404,0x0407) AM_READWRITE(towns_video_404_r, towns_video_404_w)  // R/W (0x404)
391588  AM_RANGE(0x0440,0x045f) AM_READWRITE8(towns_video_440_r, towns_video_440_w, 0xffffffff)
392589  // System port
393590  AM_RANGE(0x0480,0x0483) AM_READWRITE8(towns_sys480_r,towns_sys480_w,0xff000000)  // R/W (0x480)
r5937r5938
426623{
427624   towns_vram = auto_alloc_array(machine,UINT32,0x20000);
428625   towns_cmos = auto_alloc_array(machine,UINT32,0x2000/(sizeof(UINT32)));
429   towns_gfxvram = auto_alloc_array(machine,UINT32,0x8000/(sizeof(UINT32)));
430   towns_txtvram = auto_alloc_array(machine,UINT32,0x8000/(sizeof(UINT32)));
626   towns_gfxvram = auto_alloc_array(machine,UINT8,0x200000);
627   towns_txtvram = auto_alloc_array(machine,UINT8,0x8000);
431628}
432629
433630static MACHINE_RESET( towns )
r5937r5938
435632   ftimer = 0x00;
436633   nmi_mask = 0x00;
437634   compat_mode = 0x00;
635   towns_ankcg_enable = 0x00;
636   towns_mainmem_enable = 0x00;
637   towns_ram_enable = 0x00;
638   towns_update_video_banks(cpu_get_address_space(cputag_get_cpu(machine,"maincpu"),ADDRESS_SPACE_PROGRAM));
639   towns_vram_wplane = 0x00;
438640}
439641
440642static VIDEO_START( towns )
r5937r5938
444646static VIDEO_UPDATE( towns )
445647{
446648   int x,y;
447   int pixel = 0;
649   UINT8 dat1,dat2,dat3,dat4;
650   int bit;
651   UINT8 colour;
448652
449653   for(y=0;y<480;y++)
450654   {
451655      for(x=0;x<640;x++)
452656      {
453         *BITMAP_ADDR32(bitmap,y,x) = towns_vram[pixel++];
454         if(pixel >= 0x20000)
455            pixel = 0;
657         bit = 7 - (x & 0x07);
658         dat1 = towns_gfxvram[(x/8) + (y*0x50)];
659         dat2 = towns_gfxvram[(x/8) + (y*0x50) + 0x8000];
660         dat3 = towns_gfxvram[(x/8) + (y*0x50) + 0x10000];
661         dat4 = towns_gfxvram[(x/8) + (y*0x50) + 0x18000];
662         colour = (dat1 & (1 << bit) ? 8 : 0)
663            | (dat2 & (1 << bit) ? 4 : 0)
664            | (dat3 & (1 << bit) ? 2 : 0)
665            | (dat4 & (1 << bit) ? 1 : 0);
666         *BITMAP_ADDR32(bitmap,y,x) =
667            (towns_palette_r[colour] << 16)
668            | (towns_palette_g[colour] << 8)
669            | (towns_palette_b[colour]);
456670      }
457671   }
458672
r5937r5938
488702   NULL
489703};
490704
705static SYSTEM_CONFIG_START(towns)
706   CONFIG_RAM_DEFAULT(0x6000000)  // 6MB will do to start, standard amount for the Marty
707SYSTEM_CONFIG_END
708
491709static MACHINE_DRIVER_START( towns )
492710    /* basic machine hardware */
493711    MDRV_CPU_ADD("maincpu",I386, 16000000)
r5937r5938
551769/* Driver */
552770
553771/*    YEAR  NAME    PARENT  COMPAT  MACHINE     INPUT    INIT    CONFIG COMPANY      FULLNAME            FLAGS */
554COMP( 1989, fmtowns,  0,    0,       towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns",       GAME_NOT_WORKING)
555COMP( 1989, fmtownsa, fmtowns, 0,    towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns (alternate)", GAME_NOT_WORKING)
556CONS( 1993, fmtmarty, 0,    0,       towns,       towns,     towns,      0,     "Fujitsu",   "FM-Towns Marty",    GAME_NOT_WORKING)
772COMP( 1989, fmtowns,  0,    0,       towns,       towns,     towns,      towns,     "Fujitsu",   "FM-Towns",       GAME_NOT_WORKING)
773COMP( 1989, fmtownsa, fmtowns, 0,    towns,       towns,     towns,      towns,     "Fujitsu",   "FM-Towns (alternate)", GAME_NOT_WORKING)
774CONS( 1993, fmtmarty, 0,    0,       towns,       towns,     towns,      towns,     "Fujitsu",   "FM-Towns Marty",    GAME_NOT_WORKING)
557775

Previous 15994 Revisions Next


© 1998-2018 The MESS Team