Previous 15994 Revisions Next

r5581 Friday 4th September, 2009 at 16:34:54 UTC by Angelo Salese
[X1]: Fixed a bunch of color bugs
[src/mess/drivers]x1.c

src/mess/drivers/x1.c
r5580r5581
22
33   Sharp X1 (c) 1983 Sharp Corporation
44
5   preliminary driver by Angelo Salese
5   driver by Angelo Salese & Barry Rodewald
66
77   TODO:
88   - Understand how keyboard works and decap/dump the keyboard MCU if possible;
r5580r5581
1010   - Implement tape commands;
1111   - Sort out / redump the BIOS gfx roms;
1212   - Implement the interrupts (uses IM 2), basically used by the keyboard.
13   - Implement DMA (X1Turbo only?)
13   - Implement DMA,CTC and SIO, they are X1Turbo only features.
1414   - clean-ups!
1515   - x1turbo: understand how irq generation works for the ym-2151;
1616   - There are various unclear video things, these are:
1717      - Understand why some games still doesn't upload the proper PCG index;
18      - Support the alternative PCG upload mode;
1918      - Implement PCG reading, used by Maison Ikkoku, Mule and Gyajiko for kanji reading;
20      - Implement the scrn params;
19      - Implement the scrn regs;
2120      - Interlace mode?
2221      - Some colors are still way wrong (check 1942 or Dialide), needs update_partial perhaps?
2322      - Maybe the colorram/videoram stuff is actually a converter for the BRG framebuffer in
2423        the end?
24      - Implement the new features of the x1turbo, namely the 4096 color feature amongst other
25        things
2526      - (anything else?)
2627
2728   per-game specific TODO:
2829   - Bosconian: title screen background is completely white because it reverts the pen used
2930     (it's gray in the Arcade version),could be either flickering for pseudo-alpha effect or it's
3031     a btanb;
31   - Dragon Slayer: colors aren't 100% and for whatever reason it doesn't clear the screen on the
32     gameplay.
3332   - Super Mario Bros. SP: background color is black, should be blue. DMA issue?
33   - Mappy (New Version): has color issues, should be identical to the Arcade version, sets PLY reg == 0xe;
34   - Gradius: PCG tiles should be 16 colors or use the entire 8 color range, it's sure that the current palette
35     bank isn't right (it's ok for the bitmaps only)
3436
3537   Notes:
3638   - An interesting feature of the Sharp X-1 is the extended i/o bank. When the ppi port c bit 5
r5580r5581
166168{
167169   UINT8 gfx_bank;
168170   UINT8 pcg_mode;
171   UINT8 blackclip; // x1 turbo specific
169172}scrn_reg;
173
170174static UINT8 pcg_write_addr;
171175
172176
r5580r5581
232236                  if(color & 8) //revert the used color pen
233237                     pcg_pen^=7;
234238
239                  if((scrn_reg.blackclip & 8) && (color == (scrn_reg.blackclip & 7)))
240                     pcg_pen = 8; // clip the pen to black
241
235242                  if((res_x+xi)>video_screen_get_visible_area(machine->primary_screen)->max_x && (res_y+yi)>video_screen_get_visible_area(machine->primary_screen)->max_y)
236243                     continue;
237244
r5580r5581
365372{
366373   UINT8 val = 0xe0;
367374   val |= input_port_read(machine,"key_modifiers") & 0x1f;
368   
375
369376   if(check_keyboard_press(machine) != 0)
370377      val &= ~0x40;
371378
r5580r5581
376383{
377384   static int sub_val_ptr;
378385   UINT8 ret;
379   
386
380387   if(sub_obf)
381388      return 0xff;
382389
r5580r5581
413420   // E9 06 - APSS(?) Rewind
414421   // E9 0A - Record
415422   cmt_current_cmd = cmd;
416   
423
417424   switch(cmd)
418425   {
419426      case 0x01:  // Stop
r5580r5581
779786{
780787   scrn_reg.pcg_mode = (data & 0x20)>>5;
781788   scrn_reg.gfx_bank = 0;//(data & 0x10)>>4;
789   printf("SCRN = %02x\n",data);
782790}
783791
784792static WRITE8_HANDLER( x1_ply_w )
785793{
794   printf("PLY = %02x\n",data);
786795}
787796
788797static WRITE8_HANDLER( x1_6845_w )
r5580r5581
808817
809818static WRITE8_HANDLER( x1_dma_w )
810819{
811   printf("%02x %02x\n",offset,data);
820   //printf("%02x %02x\n",offset,data);
812821   //if(data)
813822   //   fatalerror("Data written to the DMA space");
814823}
815824
825static READ8_HANDLER( x1_blackclip_r )
826{
827   return scrn_reg.blackclip;
828}
816829
830static WRITE8_HANDLER( x1_blackclip_w )
831{
832   scrn_reg.blackclip = data;
833}
834
835static WRITE8_HANDLER( x1turbo_pal_w )
836{
837   printf("TURBO PAL %02x\n",data);
838}
839
840static WRITE8_HANDLER( x1turbo_txpal_w )
841{
842   printf("TURBO TEXT PAL %02x\n",data);
843}
844
845static WRITE8_HANDLER( x1turbo_txdisp_w )
846{
847   printf("TURBO TEXT DISPLAY %02x\n",data);
848}
849
850static WRITE8_HANDLER( x1turbo_gfxpal_w )
851{
852   printf("TURBO GFX PAL %02x\n",data);
853}
854
817855/*************************************
818856 *
819857 *  Memory maps
r5580r5581
835873   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); }
836874   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); }
837875//   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); }
876   else if(offset == 0x1fe0)                  { return x1_blackclip_r(space,0); }
838877   else if(offset >= 0x2000 && offset <= 0x2fff)   { return colorram[offset-0x2000]; }
839878   else if(offset >= 0x3000 && offset <= 0x3fff)   { return videoram[offset-0x3000]; }
840879   else if(offset >= 0x4000 && offset <= 0xffff)   { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; }
r5580r5581
869908//   else if(offset >= 0x1f90 && offset <= 0x1f93)   { x1_sio_w(space->machine,(offset-0x1f90) & 3),data; }
870909   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa3,data); }
871910   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa8,data); }
911   else if(offset == 0x1fb0)                  { x1turbo_pal_w(space,0,data); }
912   else if(offset >= 0x1fb9 && offset <= 0x1fbf)   { x1turbo_txpal_w(space,offset-0x1fb9,data); }
913   else if(offset == 0x1fc0)                  { x1turbo_txdisp_w(space,0,data); }
914   else if(offset == 0x1fc5)                  { x1turbo_gfxpal_w(space,0,data); }
872915   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
916   else if(offset == 0x1fe0)                  { x1_blackclip_w(space,0,data); }
873917   else if(offset >= 0x2000 && offset <= 0x2fff)   { colorram[offset-0x2000] = data; }
874918   else if(offset >= 0x3000 && offset <= 0x3fff)   { videoram[offset-0x3000] = pcg_write_addr = data; }
875919   else if(offset >= 0x4000 && offset <= 0xffff)   { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; }
r5580r5581
895939   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa3); }
896940   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { return z80ctc_r(devtag_get_device(space->machine, "ctc"), offset-0x1fa8); }
897941//   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { return x1_scrn_r(space,offset-0x1fd0); }
942   else if(offset == 0x1fe0)                  { return x1_blackclip_r(space,0); }
898943   else if(offset >= 0x2000 && offset <= 0x2fff)   { return colorram[offset-0x2000]; }
899944   else if(offset >= 0x3000 && offset <= 0x3fff)   { return videoram[offset-0x3000]; }
900945   else if(offset >= 0x4000 && offset <= 0xffff)   { return gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)]; }
r5580r5581
930975//   else if(offset >= 0x1f90 && offset <= 0x1f93)   { x1_sio_w(space->machine,(offset-0x1f90) & 3),data; }
931976   else if(offset >= 0x1fa0 && offset <= 0x1fa3)   { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa3,data); }
932977   else if(offset >= 0x1fa8 && offset <= 0x1fab)   { z80ctc_w(devtag_get_device(space->machine, "ctc"), offset-0x1fa8,data); }
978   else if(offset == 0x1fb0)                  { x1turbo_pal_w(space,0,data); }
979   else if(offset >= 0x1fb9 && offset <= 0x1fbf)   { x1turbo_txpal_w(space,offset-0x1fb9,data); }
980   else if(offset == 0x1fc0)                  { x1turbo_txdisp_w(space,0,data); }
981   else if(offset == 0x1fc5)                  { x1turbo_gfxpal_w(space,0,data); }
933982   else if(offset >= 0x1fd0 && offset <= 0x1fdf)   { x1_scrn_w(space,0,data); }
983   else if(offset == 0x1fe0)                  { x1_blackclip_w(space,0,data); }
934984   else if(offset >= 0x2000 && offset <= 0x2fff)   { colorram[offset-0x2000] = data; }
935985   else if(offset >= 0x3000 && offset <= 0x3fff)   { videoram[offset-0x3000] = pcg_write_addr = data; }
936986   else if(offset >= 0x4000 && offset <= 0xffff)   { gfx_bitmap_ram[offset-0x4000+(scrn_reg.gfx_bank*0xc000)] = data; }
r5580r5581
9851035   */
9861036   UINT8 dat = 0;
9871037   dat = (input_port_read(device->machine, "SYSTEM") & ~0x68) | sub_obf;
988   
1038
9891039   if((dat & 0x80) == 0)
9901040      dat |= 0x04;  // VSync (todo: proper implementation of vsync)
991   
1041
9921042   if(cassette_input(devtag_get_device(device->machine,"cass")) > 0.03)
9931043      dat |= 0x02;
9941044
9951045   if(cassette_get_state(devtag_get_device(device->machine,"cass")) & CASSETTE_MOTOR_DISABLED)
9961046      dat |= 0x02;
997     
1047
9981048   return dat;
9991049}
10001050
r5580r5581
10291079
10301080   io_switch = data & 0x20;
10311081   io_sys = data & 0xff;
1032   
1082
10331083   cassette_output(devtag_get_device(device->machine,"cass"),(data & 0x01) ? +1.0 : -1.0);
10341084}
10351085
r5580r5581
15161566      gfx_element_mark_dirty(machine->gfx[7], i);
15171567   }
15181568
1569   /* X1 Turbo specific */
1570   scrn_reg.blackclip = 0;
1571
15191572   io_bank_mode = 0;
15201573   pcg_index[0] = pcg_index[1] = pcg_index[2] = 0;
15211574
15221575   cpu_set_irq_callback(cputag_get_cpu(machine, "maincpu"), x1_irq_callback);
15231576   timer_pulse(machine, ATTOTIME_IN_HZ(240), NULL, 0, keyboard_callback);
1524   
1577
15251578   cmt_current_cmd = 0;
15261579   cassette_change_state(devtag_get_device(machine, "cass" ),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
15271580}
r5580r5581
15531606   /* TODO: fix this */
15541607   for(i=0;i<8;i++)
15551608   {
1556      palette_set_color_rgb(machine, i+0x000, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0));
1557      palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 2), pal1bit(i >> 1), pal1bit(i >> 0));
1609      palette_set_color_rgb(machine, i+0x000, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0));
1610      palette_set_color_rgb(machine, i+0x100, pal1bit(i >> 1), pal1bit(i >> 2), pal1bit(i >> 0));
15581611   }
15591612}
15601613

Previous 15994 Revisions Next


© 1998-2018 The MESS Team