Previous 199869 Revisions Next

r19313 Tuesday 4th December, 2012 at 19:44:08 UTC by Angelo Salese
Preliminary PCG support
[src/mess/drivers]pc9801.c

trunk/src/mess/drivers/pc9801.c
r19312r19313
276276#define UPD1990A_TAG "upd1990a"
277277#define UPD8251_TAG  "upd8251"
278278
279#define DEBUG_PCG   1
280
281279class pc9801_state : public driver_device
282280{
283281public:
r19312r19313
555553   // find memory regions
556554   m_char_rom = memregion("chargen")->base();
557555   m_kanji_rom = memregion("kanji")->base();
556
557   m_pcg_ram = auto_alloc_array(machine(), UINT8, 0x200000);
558
559   state_save_register_global_pointer(machine(), m_pcg_ram, 0x200000);
558560}
559561
560562UINT32 pc9801_state::screen_update(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
r19312r19313
564566   /* graphics */
565567   m_hgdc2->screen_update(screen, bitmap, cliprect);
566568   m_hgdc1->screen_update(screen, bitmap, cliprect);
567
568569   return 0;
569570}
570571
r19312r19313
614615   UINT8 char_size,interlace_on;
615616   UINT8 kanji_on;
616617   UINT16 tile;
618   UINT8 pcg_sel, pcg_lr;
617619
618620   if(state->m_video_ff[DISPLAY_REG] == 0) //screen is off
619621      return;
r19312r19313
636638      if(kanji_on)
637639         kanji_on--;
638640
641      pcg_sel = 0;
642      pcg_lr = 0;
643
639644      if(kanji_on == 0)
640645      {
641646         tile = state->m_video_ram_1[(tile_addr*2) & 0x1fff] & 0x00ff;
642         knj_tile = state->m_video_ram_1[(tile_addr*2+1) & 0x1fff] & 0x7f;
643         if((tile & 0xe0) == 0 && knj_tile) // kanji select
647         knj_tile = state->m_video_ram_1[(tile_addr*2+1) & 0x1fff] & 0xff;
648         if((tile & 0xe0) == 0 && knj_tile) // kanji select, TODO
644649         {
645650            tile <<= 8;
646            tile |= knj_tile;
651            tile |= (knj_tile & 0x7f);
647652            /* annoying kanji bit-swap applied on the address bus ... */
648653            tile = BITSWAP16(tile,7,15,14,13,12,11,6,5,10,9,8,4,3,2,1,0);
649654            tile &= 0x1fff;
650655            kanji_on = 2;
651656         }
657         else if(tile == 0x56 && knj_tile)
658         {
659            pcg_sel = 1;
660            tile = knj_tile & 0x7f;
661            pcg_lr = (knj_tile & 0x80) >> 7;
662         }
652663      }
653664      attr = (state->m_video_ram_1[(tile_addr*2 & 0x1fff) | 0x2000] & 0x00ff);
654665
r19312r19313
671682            if(res_x > 640 || res_y > char_size*25) //TODO
672683               continue;
673684
674            if(kanji_on)
685            tile_data = 0;
686
687            if(!secret)
675688            {
676               tile_data = secret ? 0 : (state->m_kanji_rom[tile*0x20+yi*2+(kanji_on & 1)]);
689               if(kanji_on)
690                  tile_data = (state->m_kanji_rom[tile*0x20+yi*2+(kanji_on & 1)]);
691               else if(pcg_sel)
692                  tile_data = (state->m_pcg_ram[0xac000*2+tile*0x40+yi*2+pcg_lr]);
693               else
694                  tile_data = (state->m_char_rom[tile*char_size+interlace_on*0x800+yi]);
677695            }
678            else
679               tile_data = secret ? 0 : (state->m_char_rom[tile*char_size+interlace_on*0x800+yi]);
680696
681697            if(reverse) { tile_data^=0xff; }
682698            if(u_line && yi == 7) { tile_data = 0xff; }
r19312r19313
687703
688704            if(yi >= char_size)
689705               pen = 0;
706            else if(pcg_sel)
707            {
708               pen = 0;
709               if(color & 1) pen |= ((tile_data >> (7-xi) & 1) ? 1 : 0);
710               if(color & 2) pen |= ((tile_data >> (7-xi) & 1) ? 2 : 0);
711               if(color & 4) pen |= ((tile_data >> (7-xi) & 1) ? 4 : 0);
712            }
690713            else
691714               pen = (tile_data >> (7-xi) & 1) ? color : 0;
692715
r19312r19313
11061129      switch((offset & 0xe) + 1)
11071130      {
11081131         case 0x09://cg window font read
1109            return m_pcg_ram[((m_font_addr & 0x7f7f) << 4) | m_font_lr | (m_font_line & 0x0f)];
1132         {
1133            UINT32 pcg_offset;
1134
1135            pcg_offset = m_font_addr << 6;
1136            pcg_offset|= m_font_line;
1137            pcg_offset|= m_font_lr;
1138            return m_pcg_ram[pcg_offset];
1139         }
11101140      }
11111141
11121142      printf("Read to undefined port [%02x]\n",offset+0xa0);
r19312r19313
11651195            return;
11661196         case 0x05:
11671197            //printf("%02x\n",data);
1168            m_font_line = data & 0x1f;
1169            m_font_lr = data & 0x20 ? 0x000 : 0x800;
1198            m_font_line = ((data & 0x1f) << 1);
1199            m_font_lr = ((data & 0x20) >> 5) ^ 1;
11701200            return;
11711201         case 0x09: //cg window font write
11721202         {
1173            //printf("W\n");
1174            m_pcg_ram[((m_font_addr & 0x7f7f) << 4) | m_font_lr | m_font_line] = data;
1203            UINT32 pcg_offset;
1204
1205            pcg_offset = m_font_addr << 6;
1206            pcg_offset|= m_font_line;
1207            pcg_offset|= m_font_lr;
1208            //printf("%04x %02x %02x %08x\n",m_font_addr,m_font_line,m_font_lr,pcg_offset);
1209            m_pcg_ram[pcg_offset] = data;
11751210            return;
11761211         }
11771212      }
r19312r19313
29012936   m_rtc->oe_w(1);
29022937
29032938   m_ipl_rom = memregion("ipl")->base();
2904   m_pcg_ram = auto_alloc_array(machine(), UINT8, 0x80000);
2905
2906   state_save_register_global_pointer(machine(), m_pcg_ram, 0x80000);
29072939}
29082940
29092941MACHINE_START_MEMBER(pc9801_state,pc9801f)

Previous 199869 Revisions Next


© 1997-2024 The MAME Team