Previous 15994 Revisions Next

r15716 Thursday 2nd August, 2012 at 16:54:52 UTC by Angelo Salese
PC-8801: first pass in adding CRTC related features
[src/mess/drivers]pc8801.c

src/mess/drivers/pc8801.c
r15715r15716
317317
318318};
319319
320
321static void pc8801_dynamic_res_change(running_machine &machine);
322
320323/*
321324CRTC command params:
3223250. CRTC reset
323326
327[0] *--- ---- <unknown>
324328[0] -xxx xxxx screen columns (+2)
329
325330[1] xx-- ---- blink speed (in frame unit) (+1, << 3)
326331[1] --xx xxxx screen lines (+1)
332
327333[2] x--- ---- "skip line"
328334[2] -x-- ---- cursor style (reverse on / underscore off)
329335[2] --x- ---- cursor blink on/off
336[2] ---x xxxx lines per character (+1)
330337
338[3] xxx- ---- Vertical Retrace (+1)
339[3] ---x xxxx Horizontal Retrace (+2)
340
331341[4] x--- ---- attribute not separate flag
332342[4] -x-- ---- attribute color flag
333343[4] --x- ---- attribute not special flag (invalidates next register)
334344[4] ---x xxxx attribute size (+1)
335345*/
336346
347#define screen_width ((state->m_crtc.param[0][0] & 0x7f) + 2) * 8
348
337349#define blink_speed ((((state->m_crtc.param[0][1] & 0xc0) >> 6) + 1) << 3)
350#define screen_height ((state->m_crtc.param[0][1] & 0x3f) + 1)
351
352#define lines_per_char ((state->m_crtc.param[0][2] & 0x1f) + 1)
353
354#define vretrace (((state->m_crtc.param[0][3] & 0xe0) >> 5) + 1)
355#define hretrace ((state->m_crtc.param[0][3] & 0x1f) + 2)
356
338357#define text_color_flag (state->m_crtc.param[0][4] & 0x40)
339#define monitor_24KHz ((state->m_gfx_ctrl & 0x19) == 0x08)
358#define monitor_24KHz ((state->m_gfx_ctrl & 0x19) == 0x08) /* TODO: this is most likely to be WRONG */
340359
341360static VIDEO_START( pc8801 )
342361{
343362
344363}
345364
346static void draw_bitmap_3bpp(running_machine &machine, bitmap_ind16 &bitmap)
365static void draw_bitmap_3bpp(running_machine &machine, bitmap_ind16 &bitmap,const rectangle &cliprect)
347366{
367   pc8801_state *state = machine.driver_data<pc8801_state>();
348368   int x,y,xi;
349369   UINT32 count;
350370   UINT8 *gvram = machine.root_device().memregion("gvram")->base();
371   UINT16 y_size;
372   UINT16 y_double;
351373
352374   count = 0;
353375
354   for(y=0;y<200;y++)
376   y_double = ((lines_per_char & 0x10) >> 4); // TODO: true condition of this?
377   y_size = (y_double+1) * 200;
378
379   for(y=0;y<y_size;y+=(y_double+1))
355380   {
356381      for(x=0;x<640;x+=8)
357382      {
r15715r15716
366391            pen |= ((gvram[count+0x4000] >> (7-xi)) & 1) << 1;
367392            pen |= ((gvram[count+0x8000] >> (7-xi)) & 1) << 2;
368393
369            bitmap.pix16(y, x+xi) = machine.pens[pen & 7];
394            if(y_double)
395            {
396               if(cliprect.contains(x+xi, y+0))
397                  bitmap.pix16(y+0, x+xi) = machine.pens[pen & 7];
398
399               if(cliprect.contains(x+xi, y+1))
400                  bitmap.pix16(y+1, x+xi) = machine.pens[pen & 7];
401            }
402            else
403            {
404               if(cliprect.contains(x+xi, y+0))
405                  bitmap.pix16(y, x+xi) = machine.pens[pen & 7];
406            }
370407         }
371408
372409         count++;
r15715r15716
490527   pc8801_state *state = machine.driver_data<pc8801_state>();
491528   int xi,yi;
492529   UINT8 *vram = state->memregion("wram")->base();
530   UINT8 *gfx_rom = machine.root_device().memregion("gfx1")->base();
493531   UINT8 is_cursor;
494   UINT8 y_height;
532   UINT8 y_height, y_double;
495533
496   y_height = y_size == 20 ? 10 : 8;
534   y_height = lines_per_char;
535   y_double = (lines_per_char & 0x10) >> 4; // TODO: find correct condition
497536
498537   for(yi=0;yi<y_height;yi++)
499538   {
r15715r15716
511550            res_x = x*8+xi*(width+1);
512551            res_y = y*y_height*(height+1)+yi*(height+1);
513552
553            if(!machine.primary_screen->visible_area().contains(res_x, res_y))
554               continue;
555
514556            if(gfx_mode)
515557            {
516558               UINT8 mask;
r15715r15716
522564            else
523565            {
524566               UINT8 char_data;
525               UINT8 *gfx_rom = machine.root_device().memregion("gfx1")->base();
526567
527               if(yi >= 8 || secret)
528                  char_data = 0;
568               if(y_double)
569               {
570                  if(yi >= 16 || secret)
571                     char_data = 0;
572                  else
573                     char_data = (gfx_rom[tile*8+(yi >> 1)] >> (7-xi)) & 1;
574               }
529575               else
530                  char_data = (gfx_rom[tile*8+yi] >> (7-xi)) & 1;
576               {
577                  if(yi >= 8 || secret)
578                     char_data = 0;
579                  else
580                     char_data = (gfx_rom[tile*8+yi] >> (7-xi)) & 1;
581               }
531582
532583               if(yi == 0 && upper)
533584                  char_data = 1;
r15715r15716
541592                  color = char_data ? pal : -1;
542593            }
543594
544            if(!machine.primary_screen->visible_area().contains(res_x, res_y))
545               continue;
546
547595            if(color != -1)
548596               bitmap.pix16(res_y, res_x) = machine.pens[color];
549597
r15715r15716
635683   if(state->m_gfx_ctrl & 8)
636684   {
637685      if(state->m_gfx_ctrl & 0x10)
638         draw_bitmap_3bpp(screen.machine(),bitmap);
686         draw_bitmap_3bpp(screen.machine(),bitmap,cliprect);
639687      else
640688         draw_bitmap_1bpp(screen.machine(),bitmap);
641689   }
r15715r15716
10041052{
10051053   pc8801_state *state = machine.driver_data<pc8801_state>();
10061054   rectangle visarea;
1055   int xsize,ysize;
10071056
1008   visarea.set(0, 640 - 1, 0, ((monitor_24KHz) ? 400 : 200) - 1);
1057   //printf("H %d V %d (%d x %d) HR %d VR %d (%d %d)\n",screen_width,screen_height * lines_per_char,screen_height,lines_per_char,
1058   //                                                   hretrace,vretrace, screen_width + hretrace,screen_height * lines_per_char + vretrace * lines_per_char);
1059   //printf("%02x %02x dyn res\n",monitor_24KHz,state->m_gfx_ctrl);
10091060
1061   xsize = screen_width;
1062   ysize = screen_height * lines_per_char;
1063
1064   visarea.set(0, xsize - 1, 0, ysize - 1);
1065
10101066   machine.primary_screen->configure(640, 480, visarea, machine.primary_screen->frame_period().attoseconds);
10111067}
10121068
r15715r15716
11741230   if(m_crtc.param_count < 5)
11751231   {
11761232      m_crtc.param[m_crtc.cmd][m_crtc.param_count] = data;
1233      if(m_crtc.cmd == 0)
1234         pc8801_dynamic_res_change(machine());
1235
11771236      m_crtc.param_count++;
11781237   }
11791238}

Previous 15994 Revisions Next


© 1998-2018 The MESS Team