Previous 15994 Revisions Next

r10134 Saturday 22nd January, 2011 at 18:09:44 UTC by Angelo Salese
[X1]: Wrote down several notes, courtesy of Fujix
[src/mess/drivers]x1.c

src/mess/drivers/x1.c
r10133r10134
55    driver by Angelo Salese & Barry Rodewald
66
77    TODO:
8    - Understand how keyboard works and decap/dump the keyboard MCU if possible;
8    - Rewrite keyboard input hook-up and decap/dump the keyboard MCU if possible;
9    - x1turbo keyboard inputs are currently broken;
10   - Fix palette stuff, make it a lot cleaner;
11   - Implement proper PCG index hooks by beam positions;
912    - Hook-up remaining .tap image formats;
1013    - Implement .rom format support (needs an image for it);
1114    - Implement tape commands;
1215    - Sort out / redump the BIOS gfx roms;
1316    - X1Turbo: Implement SIO.
1417    - X1Twin: Hook-up the PC Engine part (actually needs his own driver?);
18    - Implement SASI HDD interface;
1519    - clean-ups!
1620    - There are various unclear video things, these are:
17        - Understand why some games still doesn't upload the proper PCG index;
1821        - Implement the remaining scrn regs;
19        - Interlace mode?
22        - Interlace mode
2023        - Implement the new features of the x1turbo, namely the 4096 color feature amongst other
2124          things
2225        - (anything else?)
r10133r10134
230233   state->gfx_bitmap_ram = auto_alloc_array(machine, UINT8, 0xc000*2);
231234}
232235
236static void x1_draw_pixel(running_machine *machine, bitmap_t *bitmap,int y,int x,UINT16   pen)
237{
238   if((x)>machine->primary_screen->visible_area().max_x || (y)>machine->primary_screen->visible_area().max_y)
239      return;
240
241   *BITMAP_ADDR16(bitmap, y, x) = machine->pens[pen];
242}
243
233244static void draw_fgtilemap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int w)
234245{
235246   x1_state *state = machine->driver_data<x1_state>();
r10133r10134
286297                  if((state->scrn_reg.blackclip & 8) && (color == (state->scrn_reg.blackclip & 7)))
287298                     pcg_pen = 0; // clip the pen to black
288299
289                  if((res_x+xi)>machine->primary_screen->visible_area().max_x && (res_y+yi)>machine->primary_screen->visible_area().max_y)
290                     continue;
291
292300                  if(state->scrn_reg.v400_mode)
293301                  {
294                     *BITMAP_ADDR16(bitmap, (res_y+yi)*2+0, res_x+xi) = machine->pens[pcg_pen];
295                     *BITMAP_ADDR16(bitmap, (res_y+yi)*2+1, res_x+xi) = machine->pens[pcg_pen];
302                     x1_draw_pixel(machine,bitmap,(res_y+yi)*2+0,res_x+xi,pcg_pen);
303                     x1_draw_pixel(machine,bitmap,(res_y+yi)*2+1,res_x+xi,pcg_pen);
296304                     if(width)
297305                     {
298                        *BITMAP_ADDR16(bitmap, (res_y+yi)*2+0, res_x+xi+1) = machine->pens[pcg_pen];
299                        *BITMAP_ADDR16(bitmap, (res_y+yi)*2+1, res_x+xi+1) = machine->pens[pcg_pen];
306                        x1_draw_pixel(machine,bitmap,(res_y+yi)*2+0,res_x+xi+1,pcg_pen);
307                        x1_draw_pixel(machine,bitmap,(res_y+yi)*2+1,res_x+xi+1,pcg_pen);
300308                     }
301309                     if(height)
302310                     {
303                        *BITMAP_ADDR16(bitmap, (res_y+yi+1)*2+0, res_x+xi) = machine->pens[pcg_pen];
304                        *BITMAP_ADDR16(bitmap, (res_y+yi+1)*2+1, res_x+xi) = machine->pens[pcg_pen];
311                        x1_draw_pixel(machine,bitmap,(res_y+yi+1)*2+0,res_x+xi,pcg_pen);
312                        x1_draw_pixel(machine,bitmap,(res_y+yi+1)*2+1,res_x+xi,pcg_pen);
305313                     }
306314                     if(width && height)
307315                     {
308                        *BITMAP_ADDR16(bitmap, (res_y+yi+1)*2+0, res_x+xi+1) = machine->pens[pcg_pen];
309                        *BITMAP_ADDR16(bitmap, (res_y+yi+1)*2+1, res_x+xi+1) = machine->pens[pcg_pen];
316                        x1_draw_pixel(machine,bitmap,(res_y+yi+1)*2+0,res_x+xi+1,pcg_pen);
317                        x1_draw_pixel(machine,bitmap,(res_y+yi+1)*2+1,res_x+xi+1,pcg_pen);
310318                     }
311319                  }
312320                  else
313321                  {
314                     *BITMAP_ADDR16(bitmap, res_y+yi, res_x+xi) = machine->pens[pcg_pen];
322                     x1_draw_pixel(machine,bitmap,res_y+yi,res_x+xi,pcg_pen);
315323                     if(width)
316                        *BITMAP_ADDR16(bitmap, res_y+yi, res_x+xi+1) = machine->pens[pcg_pen];
324                        x1_draw_pixel(machine,bitmap,res_y+yi,res_x+xi+1,pcg_pen);
317325                     if(height)
318                        *BITMAP_ADDR16(bitmap, res_y+yi+1, res_x+xi) = machine->pens[pcg_pen];
326                        x1_draw_pixel(machine,bitmap,res_y+yi+1,res_x+xi,pcg_pen);
319327                     if(width && height)
320                        *BITMAP_ADDR16(bitmap, res_y+yi+1, res_x+xi+1) = machine->pens[pcg_pen];
328                        x1_draw_pixel(machine,bitmap,res_y+yi+1,res_x+xi+1,pcg_pen);
321329                  }
322330               }
323331            }
r10133r10134
327335}
328336
329337/*
330 * Priority Mixer Calculation (PLY)
338 * Priority Mixer Calculation (pri)
331339 *
332 * If ply is 0xff then the bitmap entirely covers the tilemap, if it's 0x00 then
340 * If pri is 0xff then the bitmap entirely covers the tilemap, if it's 0x00 then
333341 * the tilemap priority is entirely above the bitmap. Any other value mixes the
334342 * bitmap and the tilemap priorities based on the pen value, bit 0 = entry 0 <-> bit 7 = entry 7
335343 * of the bitmap.
336344 *
337345 */
338static int priority_mixer_ply(running_machine *machine,int color)
346static int priority_mixer_pri(running_machine *machine,int color)
339347{
340348   int pri_i,pri_mask_calc;
341349
r10133r10134
375383
376384               color =  pen_g<<2 | pen_r<<1 | pen_b<<0;
377385
378               pri_mask_val = priority_mixer_ply(machine,color);
386               pri_mask_val = priority_mixer_pri(machine,color);
379387               if(pri_mask_val & pri) continue;
380388
381389               if(state->scrn_reg.v400_mode)
382390               {
383                  if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(state->tile_height+1)+yi)*2+0)<=machine->primary_screen->visible_area().max_y)
384                     *BITMAP_ADDR16(bitmap, ( y*(state->tile_height+1)+yi)*2+0, x*8+xi) = machine->pens[color+0x100];
385                  if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (( y*(state->tile_height+1)+yi)*2+1)<=machine->primary_screen->visible_area().max_y)
386                     *BITMAP_ADDR16(bitmap, ( y*(state->tile_height+1)+yi)*2+1, x*8+xi) = machine->pens[color+0x100];
391                  x1_draw_pixel(machine,bitmap,(y*(state->tile_height+1)+yi)*2+0,x*8+xi,color);
392                  x1_draw_pixel(machine,bitmap,(y*(state->tile_height+1)+yi)*2+1,x*8+xi,color);
387393               }
388394               else
389               {
390                  if((x*8+xi)<=machine->primary_screen->visible_area().max_x && (y*(state->tile_height+1)+yi)<=machine->primary_screen->visible_area().max_y)
391                     *BITMAP_ADDR16(bitmap, y*(state->tile_height+1)+yi, x*8+xi) = machine->pens[color+0x100];
392               }
393            }
394         }
395      }
396   }
397}
395                  x1_draw_pixel(machine,bitmap,y*(state->tile_height+1)+yi,x*8+xi,color);
398396
399#if 0
400/* Old code for reference, to be removed soon */
401static void draw_gfxbitmap(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int w,int plane,int pri)
402{
403   x1_state *state = machine->driver_data<x1_state>();
404   int count,xi,yi,x,y;
405   int pen_r,pen_g,pen_b,color;
406   int yi_size;
407   int pri_mask_val;
408
409   count = state->crtc_start_addr;
410
411   yi_size = (w == 1) ? 16 : 8;
412
413   for(yi=0;yi<yi_size;yi++)
414   {
415      for(y=0;y<200;y+=8)
416      {
417         for(x=0;x<(320*w);x+=8)
418         {
419            for(xi=0;xi<8;xi++)
420            {
421               pen_b = (state->gfx_bitmap_ram[count+0x0000+plane*0xc000]>>(7-xi)) & 1;
422               pen_r = (state->gfx_bitmap_ram[count+0x4000+plane*0xc000]>>(7-xi)) & 1;
423               pen_g = (state->gfx_bitmap_ram[count+0x8000+plane*0xc000]>>(7-xi)) & 1;
424
425               color =  pen_g<<2 | pen_r<<1 | pen_b<<0;
426
427               pri_mask_val = priority_mixer_ply(machine,color);
428               if(pri_mask_val & pri) continue;
429
430               if(w == 1)
431               {
432                  if(yi & 1)
433                     continue;
434
435                  if(state->scrn_reg.v400_mode)
436                  {
437                     if((x+xi)<=machine->primary_screen->visible_area().max_x && (y+(yi >> 1)*2+0)<=machine->primary_screen->visible_area().max_y)
438                        *BITMAP_ADDR16(bitmap, (y+(yi >> 1))*2+0, x+xi) = machine->pens[color+0x100];
439                     if((x+xi)<=machine->primary_screen->visible_area().max_x && (y+(yi >> 1)*2+1)<=machine->primary_screen->visible_area().max_y)
440                        *BITMAP_ADDR16(bitmap, (y+(yi >> 1))*2+1, x+xi) = machine->pens[color+0x100];
441                  }
442                  else
443                  {
444                     if((x+xi)<=machine->primary_screen->visible_area().max_x && (y+(yi >> 1))<=machine->primary_screen->visible_area().max_y)
445                        *BITMAP_ADDR16(bitmap, y+(yi >> 1), x+xi) = machine->pens[color+0x100];
446                  }
447               }
448               else
449               {
450                  if(state->scrn_reg.v400_mode)
451                  {
452                     if((x+xi)<=machine->primary_screen->visible_area().max_x && ((y+yi)*2+0)<=machine->primary_screen->visible_area().max_y)
453                        *BITMAP_ADDR16(bitmap, (y+yi)*2+0, x+xi) = machine->pens[color+0x100];
454                     if((x+xi)<=machine->primary_screen->visible_area().max_x && ((y+yi)*2+1)<=machine->primary_screen->visible_area().max_y)
455                        *BITMAP_ADDR16(bitmap, (y+yi)*2+1, x+xi) = machine->pens[color+0x100];
456                  }
457                  else
458                  {
459                     if((x+xi)<=machine->primary_screen->visible_area().max_x && (y+yi)<=machine->primary_screen->visible_area().max_y)
460                        *BITMAP_ADDR16(bitmap, y+yi, x+xi) = machine->pens[color+0x100];
461                  }
462               }
463397            }
464            count++;
465398         }
466399      }
467      count+= (w == 2) ? 48 : 24;
468      count&=0x3fff;
469400   }
470401}
471#endif
472402
473403static VIDEO_UPDATE( x1 )
474404{
r10133r10134
479409
480410   bitmap_fill(bitmap, cliprect, MAKE_ARGB(0xff,0x00,0x00,0x00));
481411
482   draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.ply);
412   draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.pri);
483413   draw_fgtilemap(screen->machine,bitmap,cliprect,w);
484   draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.ply^0xff);
414   draw_gfxbitmap(screen->machine,bitmap,cliprect,w,state->scrn_reg.disp_bank,state->scrn_reg.pri^0xff);
485415   /* Y's uses the following as a normal buffer/work ram without anything reasonable to draw */
486416//  draw_gfxbitmap(screen->machine,bitmap,cliprect,w,1);
487417
r10133r10134
563493static UINT8 check_keyboard_shift(running_machine *machine)
564494{
565495   UINT8 val = 0xe0;
496   /*
497   all of those are active low
498   x--- ---- TEN: Numpad, Function key, special input key
499   -x-- ---- KIN: Valid key
500   --x- ---- REP: Key repeat
501   ---x ---- GRAPH key ON
502   ---- x--- CAPS lock ON
503   ---- -x-- KANA lock ON
504   ---- --x- SHIFT ON
505   ---- ---x CTRL ON
506   */
507
566508   val |= input_port_read(machine,"key_modifiers") & 0x1f;
567509
568510   if(check_keyboard_press(machine) != 0)
r10133r10134
742684static WRITE8_HANDLER( sub_io_w )
743685{
744686   x1_state *state = space->machine->driver_data<x1_state>();
745   /* TODO: check sub-routine at $10e */
746   /* $17a -> floppy? */
747   /* $094 -> ROM */
748   /* $0c0 -> timer*/
749   /* $052 -> cmt */
750   /* $0f5 -> reload sub-routine? */
687   /* sub-routine at $10e sends to these sub-routines when a keyboard input is triggered:
688    $17a -> floppy
689    $094 -> ROM
690    $0c0 -> timer
691    $052 -> cmt
692    $0f5 -> reload sub-routine? */
751693
752694   if(state->sub_cmd == 0xe4)
753695   {
r10133r10134
758700   if(state->sub_cmd == 0xe9)
759701      cmt_command(space->machine,data);
760702
761   if((data & 0xf0) == 0xd0) //reads here tv recording timer data.
703   if((data & 0xf0) == 0xd0) //reads here tv recording timer data. (Timer set (0xd0) / Timer readout (0xd8))
762704   {
705      /*
706         xx-- ---- mode
707         --xx xxxx interval
708      */
763709      state->sub_val[0] = 0;
710      /*
711         xxxx xxxx command code:
712         00 timer disabled
713         01 TV command
714         10 interrupt
715         11 Cassette deck
716      */
764717      state->sub_val[1] = 0;
718      /*
719         ---x xxxx minute
720      */
765721      state->sub_val[2] = 0;
722      /*
723         ---- xxxx hour
724      */
766725      state->sub_val[3] = 0;
726      /*
727         xxxx ---- month
728         ---- -xxx day of the week
729      */
767730      state->sub_val[4] = 0;
731      /*
732         --xx xxxx day
733      */
768734      state->sub_val[5] = 0;
769735      state->sub_cmd_length = 6;
770736   }
771737
772738   switch(data)
773739   {
774      case 0xe3:
740      case 0xe3: //game key obtaining
775741         state->sub_cmd_length = 3;
776742         state->sub_val[0] = get_game_key(space->machine,0);
777743         state->sub_val[1] = get_game_key(space->machine,1);
778744         state->sub_val[2] = get_game_key(space->machine,2);
779745         break;
780      case 0xe6:
746      case 0xe4: //irq vector setting
747         break;
748      //case 0xe5: //timer irq clear
749      //   break;
750      case 0xe6: //key data readout
781751         state->sub_val[0] = check_keyboard_shift(space->machine);
782752         state->sub_val[1] = check_keyboard_press(space->machine);
783753         state->sub_cmd_length = 2;
784754         break;
785      case 0xe8:
755//      case 0xe7: // TV Control
756//         break;
757      case 0xe8: // TV Control read-out
786758         state->sub_val[0] = state->sub_cmd;
787759         state->sub_cmd_length = 1;
788760         break;
761      case 0xe9: // CMT Control
762         break;
789763      case 0xea:  // CMT Control status
790764         state->sub_val[0] = state->cmt_current_cmd;
791765         state->sub_cmd_length = 1;
r10133r10134
794768      case 0xeb:  // CMT Tape status
795769                  // bit 0 = tape end (0=end of tape)
796770               // bit 1 = tape inserted
797               // bit 2 = record status (1=OK, 0=write protect?)
771               // bit 2 = record status (1=OK, 0=write protect)
798772         state->sub_val[0] = 0x05;
799773         if(cassette_get_image(space->machine->device("cass")) != NULL)
800774            state->sub_val[0] |= 0x02;
801775         state->sub_cmd_length = 1;
802776         logerror("CMT: Command 0xEB received, returning 0x%02x.\n",state->sub_val[0]);
803777         break;
778//      case 0xec: //set date
779//         break;
804780      case 0xed: //get date
805781         state->sub_val[0] = state->rtc.day;
806782         state->sub_val[1] = (state->rtc.month<<4) | (state->rtc.wday & 0xf);
807783         state->sub_val[2] = state->rtc.year;
808784         state->sub_cmd_length = 3;
809785         break;
786//      case 0xee: //set time
787//         break;
810788      case 0xef: //get time
811789         state->sub_val[0] = state->rtc.hour;
812790         state->sub_val[1] = state->rtc.min;
813791         state->sub_val[2] = state->rtc.sec;
814792         state->sub_cmd_length = 3;
815793         break;
816      #if 0
817      default:
818      {
819         if(data > 0xe3 && data <= 0xef)
820            printf("%02x CMD\n",data);
821      }
822      #endif
823794   }
824795
825796   state->sub_cmd = data;
826797
827798   state->sub_obf = (state->sub_cmd_length) ? 0x00 : 0x20;
828   logerror("SUB: Command byte 0x%02x\n",data);
799
800   if(data != 0xe6)
801      logerror("SUB: Command byte 0x%02x\n",data);
829802}
830803
831804/*************************************
r10133r10134
900873      case 0x0ffb:
901874         return wd17xx_data_r(dev,offset);
902875      case 0x0ffc:
876         printf("FDC: read FM type\n");
877         return 0xff;
903878      case 0x0ffd:
879         printf("FDC: read MFM typex\n");
880         return 0xff;
904881      case 0x0ffe:
882         printf("FDC: read 1.6M type\n");
883         return 0xff;
905884      case 0x0fff:
906         logerror("FDC: read from %04x\n",offset+0xff8);
885         printf("FDC: switching between 500k/1M\n");
907886         return 0xff;
908887   }
909888
r10133r10134
937916      case 0x0ffd:
938917      case 0x0ffe:
939918      case 0x0fff:
940         logerror("FDC: write to %04x = %02x\n",offset+0xff8,data);
919         logerror("FDC: invalid write to %04x = %02x\n",offset+0xff8,data);
941920         break;
942921   }
943922}
r10133r10134
11091088 *************************************/
11101089
11111090/* for bitmap mode */
1112
11131091static void set_current_palette(running_machine *machine)
11141092{
11151093   x1_state *state = machine->driver_data<x1_state>();
r10133r10134
11251103   }
11261104}
11271105
1106/* Note: docs claims that reading the palette ports makes the value to change somehow in X1 mode ...
1107         In 4096 color mode, it's used for reading the value back. */
11281108static WRITE8_HANDLER( x1_pal_r_w )
11291109{
11301110   x1_state *state = space->machine->driver_data<x1_state>();
11311111   state->x_r = data;
11321112   set_current_palette(space->machine);
1113
1114   /* TODO: 4096 mode for x1turboz */
11331115}
11341116
11351117static WRITE8_HANDLER( x1_pal_g_w )
r10133r10134
11371119   x1_state *state = space->machine->driver_data<x1_state>();
11381120   state->x_g = data;
11391121   set_current_palette(space->machine);
1122
1123   /* TODO: 4096 mode for x1turboz */
11401124}
11411125
11421126static WRITE8_HANDLER( x1_pal_b_w )
r10133r10134
11441128   x1_state *state = space->machine->driver_data<x1_state>();
11451129   state->x_b = data;
11461130   set_current_palette(space->machine);
1131
1132   /* TODO: 4096 mode for x1turboz */
11471133}
11481134
11491135static WRITE8_HANDLER( x1_ex_gfxram_w )
r10133r10134
11641150/*
11651151    SCRN flags
11661152
1167    d0(01) = 0:low res            1:high res
1168    d1(02) = 0:1 raster           1:2 raster  <- 0=400-line mode, legal when 'd0=1'
1169    d2(04) = 0:25(20) lines       1:12(10) lines
1170    d3(08) = 0:bank 0             0:bank 1    <- display
1171    d4(10) = 0:bank 0             0:bank 1    <- access
1172    d5(20) = 0:compatibility      1:high speed  <- define PCG mode
1173    d6(40) = 0:8-raster graphics  1:16-raster graphics
1174    d7(80) = 0:don't display      1:display  <- underline (when 1, graphics are not displayed)
1175
1176    The value output by the X1turbo's IOCS at 0x1fd*
1177    is stored in memory at 0xf8d6
1153    d0(01) = 0:low resolution (15KHz) 1: high resolution (24KHz)
1154    d1(02) = 0:1 raster / pixel       1:2 raster / pixel
1155    d2(04) = 0:8 rasters / CHR        1:16 rasters / CHR
1156    d3(08) = 0:bank 0                 0:bank 1    <- display
1157    d4(10) = 0:bank 0                 0:bank 1    <- access
1158    d5(20) = 0:compatibility          1:high speed  <- define PCG mode
1159    d6(40) = 0:8-raster graphics      1:16-raster graphics
1160    d7(80) = 0:don't display          1:display  <- underline (when 1, graphics are not displayed)
11781161*/
11791162static WRITE8_HANDLER( x1_scrn_w )
11801163{
r10133r10134
11851168   state->scrn_reg.v400_mode = ((data & 0x03) == 3) ? 1 : 0;
11861169   if(data & 0xc4)
11871170      printf("SCRN = %02x\n",data & 0xc4);
1171   if((data & 0x03) == 1)
1172      printf("SCRN sets true 400 lines mode\n");
11881173}
11891174
1190static WRITE8_HANDLER( x1_ply_w )
1175static WRITE8_HANDLER( x1_pri_w )
11911176{
11921177   x1_state *state = space->machine->driver_data<x1_state>();
1193   state->scrn_reg.ply = data;
1194//  printf("PLY = %02x\n",data);
1178   state->scrn_reg.pri = data;
1179//  printf("PRI = %02x\n",data);
11951180}
11961181
11971182static WRITE8_HANDLER( x1_6845_w )
r10133r10134
12221207static READ8_HANDLER( x1_blackclip_r )
12231208{
12241209   x1_state *state = space->machine->driver_data<x1_state>();
1210   /*  TODO: this returns only on x1turboz */
12251211   return state->scrn_reg.blackclip;
12261212}
12271213
r10133r10134
12291215{
12301216   x1_state *state = space->machine->driver_data<x1_state>();
12311217   state->scrn_reg.blackclip = data;
1218   if(data & 0xf0)
1219      printf("Blackclip data access %02x\n",data);
12321220}
12331221
12341222static READ8_HANDLER( x1turbo_pal_r )
r10133r10134
12961284
12971285
12981286/*
1299 *  FIXME: this makes no sense atm, the only game that uses this function so far is Hyper Olympics '84 disk version
1287 *  FIXME: this is still wrong, the only game that uses this function so far is Hyper Olympics '84 disk version. Perhaps it's the source ROM that isn't correct ...
13001288 */
13011289static READ8_HANDLER( x1_kanji_r )
13021290{
r10133r10134
13051293   UINT8 res;
13061294
13071295   //res = 0;
1296   res = kanji_rom[state->kanji_addr*2+offset];
13081297
1309   printf("%08x\n",state->kanji_addr*0x20+state->kanji_count);
1298   if(offset == 1)
1299      state->kanji_addr_latch++;
13101300
1311   res = kanji_rom[(state->kanji_addr*0x20)+(state->kanji_count)];
1312   state->kanji_count++;
1313   state->kanji_count&=0x1f;
1314
1315   //printf("%04x R\n",offset);
1316
13171301   return res;
13181302}
13191303
r10133r10134
13211305{
13221306   x1_state *state = space->machine->driver_data<x1_state>();
13231307//  if(offset < 2)
1324      printf("%04x %02x W\n",offset,data);
13251308
13261309   switch(offset)
13271310   {
1328      case 0: state->kanji_addr_l = (data & 0xff); break;
1329      case 1: state->kanji_addr_h = (data & 0xff); state->kanji_count = 0; break;
1311      case 0: state->kanji_addr_latch = (data & 0xff)|(state->kanji_addr_latch&0xff00); break;
1312      case 1: state->kanji_addr_latch = (data<<8)|(state->kanji_addr_latch&0x00ff); break;
13301313      case 2:
1331         if(data)
1314      {
1315         /* 0 -> selects Expanded EEPROM */
1316         /* 1 -> selects Kanji ROM */
1317         /* 0 -> 1 -> latches Kanji ROM data */
1318
1319         if(((state->kanji_eksel & 1) == 0) && ((data & 1) == 1))
13321320         {
1333            state->kanji_addr = (state->kanji_addr_h<<8) | (state->kanji_addr_l);
1321            state->kanji_addr = (state->kanji_addr_latch);
13341322            //state->kanji_addr &= 0x3fff; //<- temp kludge until the rom is redumped.
13351323            //printf("%08x\n",state->kanji_addr);
13361324            //state->kanji_addr+= state->kanji_count;
13371325         }
1338         break;
1326         state->kanji_eksel = data & 1;
1327      }
1328      break;
13391329   }
13401330}
13411331
r10133r10134
13511341   UINT8 *videoram = state->videoram;
13521342   state->io_bank_mode = 0; //any read disables the extended mode.
13531343
1344   if(offset == 0x0e03)                          { return x1_rom_r(space, 0); }
1345   // TODO: user could install ym2151 on plain X1 too
1346   //0x700, 0x701
13541347   //if(offset >= 0x0704 && offset <= 0x0707)      { return z80ctc_r(space->machine->device("ctc"), offset-0x0704); }
1355   if(offset == 0x0e03)                          { return x1_rom_r(space, 0); }
13561348   else if(offset >= 0x0ff8 && offset <= 0x0fff)   { return x1_fdc_r(space, offset-0xff8); }
13571349   else if(offset >= 0x1400 && offset <= 0x17ff)   { return x1_pcg_r(space, offset-0x1400); }
13581350   else if(offset >= 0x1900 && offset <= 0x19ff)   { return sub_io_r(space, 0); }
r10133r10134
13801372   x1_state *state = space->machine->driver_data<x1_state>();
13811373   UINT8 *videoram = state->videoram;
13821374   if(state->io_bank_mode == 1)                          { x1_ex_gfxram_w(space, offset, data); }
1375   // TODO: user could install ym2151 on plain X1 too
1376   //0x700, 0x701
13831377//  else if(offset >= 0x0704 && offset <= 0x0707)   { z80ctc_w(space->machine->device("ctc"), offset-0x0704,data); }
13841378//  else if(offset >= 0x0c00 && offset <= 0x0cff)   { x1_rs232c_w(space->machine, 0, data); }
13851379   else if(offset >= 0x0e00 && offset <= 0x0e02)   { x1_rom_w(space, offset-0xe00,data); }
r10133r10134
13881382   else if(offset >= 0x1000 && offset <= 0x10ff)   { x1_pal_b_w(space, 0,data); }
13891383   else if(offset >= 0x1100 && offset <= 0x11ff)   { x1_pal_r_w(space, 0,data); }
13901384   else if(offset >= 0x1200 && offset <= 0x12ff)   { x1_pal_g_w(space, 0,data); }
1391   else if(offset >= 0x1300 && offset <= 0x13ff)   { x1_ply_w(space, 0,data); }
1385   else if(offset >= 0x1300 && offset <= 0x13ff)   { x1_pri_w(space, 0,data); }
13921386   else if(offset >= 0x1400 && offset <= 0x17ff)   { x1_pcg_w(space, offset-0x1400,data); }
13931387   else if(offset == 0x1800 || offset == 0x1801)   { x1_6845_w(space, offset-0x1800, data); }
13941388   else if(offset >= 0x1900 && offset <= 0x19ff)   { sub_io_w(space, 0,data); }
r10133r10134
14061400//  else if(offset >= 0x1fb9 && offset <= 0x1fbf)   { x1turbo_txpal_w(space,offset-0x1fb9,data); }
14071401//  else if(offset == 0x1fc0)                       { x1turbo_txdisp_w(space,0,data); }
14081402//  else if(offset == 0x1fc5)                       { x1turbo_gfxpal_w(space,0,data); }
1409   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
1403//   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
14101404//  else if(offset == 0x1fe0)                       { x1_blackclip_w(space,0,data); }
14111405   else if(offset >= 0x2000 && offset <= 0x2fff)   { state->colorram[offset-0x2000] = data; }
14121406   else if(offset >= 0x3000 && offset <= 0x3fff)   { videoram[offset-0x3000] = state->pcg_write_addr = data; }
r10133r10134
14171411   }
14181412}
14191413
1414/* TODO: I should actually simplify this, by just overwriting X1 Turbo specifics here, and call plain X1 functions otherwise */
1415// * at the end states devices used on plain X1 too
14201416static READ8_HANDLER( x1turbo_io_r )
14211417{
14221418   x1_state *state = space->machine->driver_data<x1_state>();
r10133r10134
14251421
14261422   if(offset == 0x0700)                     { return (ym2151_r(space->machine->device("ym"), offset-0x0700) & 0x7f) | (input_port_read(space->machine, "SOUND_SW") & 0x80); }
14271423   else if(offset == 0x0701)                      { return ym2151_r(space->machine->device("ym"), offset-0x0700); }
1424   //0x704 is FM sound detection port on X1 turboZ
14281425   else if(offset >= 0x0704 && offset <= 0x0707)   { return z80ctc_r(space->machine->device("ctc"), offset-0x0704); }
1426   else if(offset == 0x0801)                  { printf("Color image board read\n"); return 0xff; } // *
1427   else if(offset == 0x0803)                  { printf("Color image board 2 read\n"); return 0xff; } // *
1428   else if(offset >= 0x0a00 && offset <= 0x0a07)   { printf("Stereoscopic board read %04x\n",offset); return 0xff; } // *
1429   else if(offset == 0x0b00)                  { printf("Bank memory switch read\n"); return 0xff; }
1430   else if(offset >= 0x0c00 && offset <= 0x0cff)   { printf("RS-232C read %04x\n",offset); return 0xff; } // *
1431   else if(offset >= 0x0d00 && offset <= 0x0dff)   { printf("EMM read %04x\n",offset); return 0xff; } // *
14291432   else if(offset == 0x0e03)                      { return x1_rom_r(space, 0); }
1430   else if(offset >= 0x0e80 && offset <= 0x0e83)   { return x1_kanji_r(space, offset-0xe80); }
1433   else if(offset >= 0x0e80 && offset <= 0x0e81)   { return x1_kanji_r(space, offset-0xe80); }
1434   else if(offset >= 0x0fd0 && offset <= 0x0fd3)   { /* printf("SASI HDD read %04x\n",offset); */ return 0xff; } // *
1435   else if(offset >= 0x0fe8 && offset <= 0x0fef)   { printf("8-inch FD read %04x\n",offset); return 0xff; } // *
14311436   else if(offset >= 0x0ff8 && offset <= 0x0fff)   { return x1_fdc_r(space, offset-0xff8); }
14321437   else if(offset >= 0x1400 && offset <= 0x17ff)   { return x1_pcg_r(space, offset-0x1400); }
14331438   else if(offset >= 0x1900 && offset <= 0x19ff)   { return sub_io_r(space, 0); }
r10133r10134
14361441   else if(offset >= 0x1f80 && offset <= 0x1f8f)   { return z80dma_r(space->machine->device("dma"), 0); }
14371442   else if(offset >= 0x1f90 && offset <= 0x1f91)   { return z80sio_c_r(space->machine->device("sio"), (offset-0x1f90) & 1); }
14381443   else if(offset >= 0x1f92 && offset <= 0x1f93)   { return z80sio_d_r(space->machine->device("sio"), (offset-0x1f92) & 1); }
1444   else if(offset >= 0x1f98 && offset <= 0x1f9f)   { printf("Extended SIO/CTC read %04x\n",offset); return 0xff; }
14391445   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { return z80ctc_r(space->machine->device("ctc"), offset-0x1fa0); }
14401446   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { return z80ctc_r(space->machine->device("ctc"), offset-0x1fa8); }
1441   else if(offset == 0x1fb0)                  { return x1turbo_pal_r(space,0); }
1442   else if(offset >= 0x1fb8 && offset <= 0x1fbf)   { return x1turbo_txpal_r(space,offset-0x1fb8); }
1443   else if(offset == 0x1fc0)                  { return x1turbo_txdisp_r(space,0); }
1444   else if(offset == 0x1fc5)                  { return x1turbo_gfxpal_r(space,0); }
1445//  else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); }
1447   else if(offset == 0x1fb0)                  { return x1turbo_pal_r(space,0); } // Z only!
1448   else if(offset >= 0x1fb8 && offset <= 0x1fbf)   { return x1turbo_txpal_r(space,offset-0x1fb8); } //Z only!
1449   else if(offset == 0x1fc0)                  { return x1turbo_txdisp_r(space,0); } // Z only!
1450   else if(offset == 0x1fc5)                  { return x1turbo_gfxpal_r(space,0); } // Z only!
1451//  else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); } //Z only
14461452   else if(offset == 0x1fe0)                  { return x1_blackclip_r(space,0); }
1453   else if(offset == 0x1ff0)                   { return input_port_read(space->machine, "X1TURBO_DSW"); }
14471454   else if(offset >= 0x2000 && offset <= 0x2fff)   { return state->colorram[offset-0x2000]; }
14481455   else if(offset >= 0x3000 && offset <= 0x3fff)   { return videoram[offset-0x3000]; }
14491456   else if(offset >= 0x4000 && offset <= 0xffff)   { return state->gfx_bitmap_ram[offset-0x4000+(state->scrn_reg.gfx_bank*0xc000)]; }
14501457   else
14511458   {
1452      //0xfd0-0xfd7: FDC extended area?
1453      //0x1ff0: if 0, game screen is interlaced
14541459      logerror("(PC=%06x) Read i/o address %04x\n",cpu_get_pc(space->cpu),offset);
14551460   }
14561461   return 0xff;
r10133r10134
14601465{
14611466   x1_state *state = space->machine->driver_data<x1_state>();
14621467   UINT8 *videoram = state->videoram;
1463   if(state->io_bank_mode == 1)                          { x1_ex_gfxram_w(space, offset, data); }
1468   if(state->io_bank_mode == 1)                    { x1_ex_gfxram_w(space, offset, data); }
14641469   else if(offset == 0x0700 || offset == 0x0701)   { ym2151_w(space->machine->device("ym"), offset-0x0700,data); }
1470   //0x704 is FM sound detection port on X1 turboZ
14651471   else if(offset >= 0x0704 && offset <= 0x0707)   { z80ctc_w(space->machine->device("ctc"), offset-0x0704,data); }
1466//  else if(offset >= 0x0c00 && offset <= 0x0cff)   { x1_rs232c_w(space->machine, 0, data); }
1472   else if(offset == 0x0800)                  { printf("Color image board write %02x\n",data); } // *
1473   else if(offset == 0x0802)                  { printf("Color image board 2 write %02x\n",data); } // *
1474   else if(offset >= 0x0a00 && offset <= 0x0a07)   { printf("Stereoscopic board write %04x %02x\n",offset,data); } // *
1475   else if(offset == 0x0b00)                  { printf("Bank memory switch write %02x\n",data); }
1476   else if(offset >= 0x0c00 && offset <= 0x0cff)   { printf("RS-232C write %04x %02x\n",offset,data); } // *
1477   else if(offset >= 0x0d00 && offset <= 0x0dff)   { printf("EMM write %04x %02x\n",offset,data); } // *
14671478   else if(offset >= 0x0e00 && offset <= 0x0e02)   { x1_rom_w(space, offset-0xe00,data); }
14681479   else if(offset >= 0x0e80 && offset <= 0x0e83)   { x1_kanji_w(space, offset-0xe80,data); }
1480   else if(offset >= 0x0fd0 && offset <= 0x0fd3)   { printf("SASI HDD write %04x %02x\n",offset,data); } // *
1481   else if(offset >= 0x0fe8 && offset <= 0x0fef)   { printf("8-inch FD write %04x %02x\n",offset,data); } // *
14691482   else if(offset >= 0x0ff8 && offset <= 0x0fff)   { x1_fdc_w(space, offset-0xff8,data); }
14701483   else if(offset >= 0x1000 && offset <= 0x10ff)   { x1_pal_b_w(space, 0,data); }
14711484   else if(offset >= 0x1100 && offset <= 0x11ff)   { x1_pal_r_w(space, 0,data); }
14721485   else if(offset >= 0x1200 && offset <= 0x12ff)   { x1_pal_g_w(space, 0,data); }
1473   else if(offset >= 0x1300 && offset <= 0x13ff)   { x1_ply_w(space, 0,data); }
1486   else if(offset >= 0x1300 && offset <= 0x13ff)   { x1_pri_w(space, 0,data); }
14741487   else if(offset >= 0x1400 && offset <= 0x17ff)   { x1_pcg_w(space, offset-0x1400,data); }
14751488   else if(offset == 0x1800 || offset == 0x1801)   { x1_6845_w(space, offset-0x1800, data); }
14761489   else if(offset >= 0x1900 && offset <= 0x19ff)   { sub_io_w(space, 0,data); }
r10133r10134
14821495   else if(offset >= 0x1f80 && offset <= 0x1f8f)   { z80dma_w(space->machine->device("dma"), 0,data); }
14831496   else if(offset >= 0x1f90 && offset <= 0x1f91)   { z80sio_c_w(space->machine->device("sio"), (offset-0x1f90) & 1,data); }
14841497   else if(offset >= 0x1f92 && offset <= 0x1f93)   { z80sio_d_w(space->machine->device("sio"), (offset-0x1f92) & 1,data); }
1498   else if(offset >= 0x1f98 && offset <= 0x1f9f)   { printf("Extended SIO/CTC write %04x %02x\n",offset,data); }
14851499   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { z80ctc_w(space->machine->device("ctc"), offset-0x1fa0,data); }
14861500   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { z80ctc_w(space->machine->device("ctc"), offset-0x1fa8,data); }
1487   else if(offset == 0x1fb0)                  { x1turbo_pal_w(space,0,data); }
1488   else if(offset >= 0x1fb8 && offset <= 0x1fbf)   { x1turbo_txpal_w(space,offset-0x1fb8,data); }
1489   else if(offset == 0x1fc0)                  { x1turbo_txdisp_w(space,0,data); }
1490   else if(offset == 0x1fc5)                  { x1turbo_gfxpal_w(space,0,data); }
1501   else if(offset == 0x1fb0)                  { x1turbo_pal_w(space,0,data); } // Z only!
1502   else if(offset >= 0x1fb8 && offset <= 0x1fbf)   { x1turbo_txpal_w(space,offset-0x1fb8,data); } //Z only!
1503   else if(offset == 0x1fc0)                  { x1turbo_txdisp_w(space,0,data); } //Z only!
1504   else if(offset == 0x1fc1)                  { printf("Z image capturing access %02x\n",data); } // Z only!
1505   else if(offset == 0x1fc2)                  { printf("Z mosaic effect access %02x\n",data); } // Z only!
1506   else if(offset == 0x1fc3)                  { printf("Z Chroma key access %02x\n",data); } // Z only!
1507   else if(offset == 0x1fc4)                  { printf("Z Extra scroll config access %02x\n",data); } // Z only!
1508   else if(offset == 0x1fc5)                  { x1turbo_gfxpal_w(space,0,data); } // Z only!
14911509   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
14921510   else if(offset == 0x1fe0)                  { x1_blackclip_w(space,0,data); }
14931511   else if(offset >= 0x2000 && offset <= 0x2fff)   { state->colorram[offset-0x2000] = data; }
r10133r10134
15381556    -x-- ---- "sub cpu ibf"
15391557    --x- ---- "sub cpu obf"
15401558    ---x ---- ROM/RAM flag (0=ROM, 1=RAM)
1541    ---- x--- "busy"
1559    ---- x--- "busy" <- allow printer data output
15421560    ---- -x-- "v sync"
15431561    ---- --x- "cmt read"
1544    ---- ---x "cmt test" (active low)
1562    ---- ---x "cmt test" (active low) <- actually this is "Sub CPU detected BREAK"
15451563    */
15461564   UINT8 dat = 0;
15471565   state->vdisp = (device->machine->primary_screen->vpos() < 200) ? 0x80 : 0x00;
r10133r10134
15711589   x1_state *state = device->machine->driver_data<x1_state>();
15721590   //printf("PPI Port C read\n");
15731591   /*
1574    x--x xxxx <unknown>
1592    x--- ---- Printer port output
15751593    -x-- ---- 320 mode (r/w)
15761594    --x- ---- i/o mode (r/w)
1595    ---x ---- smooth scroll enabled (?)
1596   ---- ---x cassette output data
15771597    */
15781598   return (state->io_sys & 0x9f) | state->hres_320 | ~state->io_switch;
15791599}
r10133r10134
19121932   #endif
19131933INPUT_PORTS_END
19141934
1935INPUT_PORTS_START( x1turbo )
1936   PORT_INCLUDE( x1 )
1937
1938   PORT_START("X1TURBO_DSW")
1939   PORT_DIPNAME( 0x01, 0x01, "Interlace mode" )
1940   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1941   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1942   PORT_DIPNAME( 0x0e, 0x00, "Default Boot Device" ) // this selects what kind of device is loaded at start-up
1943   PORT_DIPSETTING(    0x00, "5/3-inch 2D" )
1944   PORT_DIPSETTING(    0x02, "5/3-inch 2DD" )
1945   PORT_DIPSETTING(    0x04, "5/3-inch 2HD" )
1946   PORT_DIPSETTING(    0x06, "5/3-inch 2DD (IBM)" )
1947   PORT_DIPSETTING(    0x08, "8-inch 2D256" )
1948   PORT_DIPSETTING(    0x0a, "8-inch 2D256 (IBM)" )
1949   PORT_DIPSETTING(    0x0c, "8-inch 1S128 (IBM)" )
1950   PORT_DIPSETTING(    0x0e, "SASI HDD" )
1951   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
1952   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1953   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1954   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) //this is a port conditional of some sort ...
1955   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1956   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1957   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
1958   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1959   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1960   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
1961   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1962   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1963INPUT_PORTS_END
1964
19151965/*************************************
19161966 *
19171967 *  GFX decoding
r10133r10134
24622512}
24632513
24642514
2465/*    YEAR  NAME       PARENT  COMPAT   MACHINE  INPUT  INIT  COMPANY   FULLNAME      FLAGS */
2466COMP( 1982, x1,        0,      0,       x1,      x1,    0,    "Sharp",  "X1 (CZ-800C)",         0)
2467COMP( 1986, x1twin,    x1,     0,       x1,     x1,    kanji,"Sharp",  "X1 Twin (CZ-830C)",    GAME_NOT_WORKING)
2468COMP( 1984, x1turbo,   x1,     0,       x1turbo, x1,    kanji,"Sharp",  "X1 Turbo (CZ-850C)",   GAME_NOT_WORKING) //model 10
2469COMP( 1985, x1turbo40, x1,     0,       x1turbo, x1,    kanji,"Sharp",  "X1 Turbo (CZ-862C)",   GAME_NOT_WORKING) //model 40
2515/*    YEAR  NAME       PARENT  COMPAT   MACHINE  INPUT       INIT   COMPANY   FULLNAME      FLAGS */
2516COMP( 1982, x1,        0,      0,       x1,      x1,         0,    "Sharp",  "X1 (CZ-800C)",         0)
2517COMP( 1986, x1twin,    x1,     0,       x1,     x1,         kanji,"Sharp",  "X1 Twin (CZ-830C)",    GAME_NOT_WORKING)
2518COMP( 1984, x1turbo,   x1,     0,       x1turbo, x1turbo,    kanji,"Sharp",  "X1 Turbo (CZ-850C)",   GAME_NOT_WORKING) //model 10
2519COMP( 1985, x1turbo40, x1,     0,       x1turbo, x1turbo,    kanji,"Sharp",  "X1 Turbo (CZ-862C)",   GAME_NOT_WORKING) //model 40
24702520// x1turboz  /* 1986 Sharp X1 TurboZ  */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team