Previous 15994 Revisions Next

r10096 Tuesday 18th January, 2011 at 22:33:09 UTC by Angelo Salese
[PC-8801]: Implemented y height param for text layer and added width 40 support
[src/mess/drivers]pc8801.c

src/mess/drivers/pc8801.c
r10095r10096
99     later models at some point.
1010   - macros for the various rom / ram areas, it might require various attempts in order to finally get a reasonable arrangement ...
1111   - dipswitches are WRONG
12   - implement proper i8214 routing, also add irq latch mechanism.
12   - implement proper i8214 routing, also add irq latch mechanism;
13   - implement proper upd3301 / i8257 support;
1314   - below notes states that plain PC-8801 doesn't have a disk CPU, but the BIOS clearly checks the floppy ports. Wrong info?
1415   - joystick / mouse support;
1516   - cursor is 8 x 10, not 8 x 8 as current implementation.
r10095r10096
143144static UINT8 dmac_mode;
144145static UINT8 alu_ctrl1,alu_ctrl2;
145146static UINT8 extram_mode,extram_bank;
147static UINT8 txt_width, txt_color;
146148static int vblank_pos;
147149
148150static void pc8801_update_irq(running_machine *machine)
r10095r10096
202204
203205}
204206
205static UINT8 calc_cursor_pos(running_machine *machine,int x,int y,int yi)
206{
207   if(!(crtc.cursor_on)) // don't bother if cursor is off
208      return 0;
209
210   if(x == crtc.param[4][0] && y == crtc.param[4][1]) /* check if position matches */
211   {
212      /* don't pass through if we are using underscore */
213      if((!(crtc.param[0][2] & 0x40)) && yi != 7)
214         return 0;
215
216      /* finally check if blinking is currently active high */
217      if(!(crtc.param[0][2] & 0x20))
218         return 1;
219
220      if(((machine->primary_screen->frame_number() / blink_speed) & 1) == 0)
221         return 1;
222
223      return 0;
224   }
225
226   return 0;
227}
228
229207static void draw_bitmap_3bpp(running_machine *machine, bitmap_t *bitmap)
230208{
231209   int x,y,xi;
r10095r10096
270248      {
271249         for(xi=0;xi<8;xi++)
272250         {
273            int pen = 0;
251            int pen;
274252
253            pen = 0;
275254            /* TODO: dunno if layer_mask is correct here */
276255            if(!(layer_mask & 2)) { pen = ((gvram[count+0x0000] >> (7-xi)) & 1) << 0; }
277256
r10095r10096
292271         {
293272            for(xi=0;xi<8;xi++)
294273            {
295               int pen = 0;
274               int pen;
296275
276               pen = 0;
297277               /* TODO: dunno if layer_mask is correct here */
298278               if(!(layer_mask & 4)) { pen = ((gvram[count+0x4000] >> (7-xi)) & 1) << 0; }
299279
r10095r10096
306286   }
307287}
308288
309static VIDEO_UPDATE( pc8801 )
289static UINT8 calc_cursor_pos(running_machine *machine,int x,int y,int yi)
310290{
291   if(!(crtc.cursor_on)) // don't bother if cursor is off
292      return 0;
293
294   if(x == crtc.param[4][0] && y == crtc.param[4][1]) /* check if position matches */
295   {
296      /* don't pass through if we are using underscore */
297      if((!(crtc.param[0][2] & 0x40)) && yi != 7)
298         return 0;
299
300      /* finally check if blinking is currently active high */
301      if(!(crtc.param[0][2] & 0x20))
302         return 1;
303
304      if(((machine->primary_screen->frame_number() / blink_speed) & 1) == 0)
305         return 1;
306
307      return 0;
308   }
309
310   return 0;
311}
312
313static void draw_text_80(running_machine *machine, bitmap_t *bitmap,int y_size)
314{
311315   int x,y;
312316   int xi,yi;
313   UINT8 *vram = screen->machine->region("maincpu")->base() + WRAM_BASE;
317   UINT8 *vram = machine->region("maincpu")->base() + WRAM_BASE;
314318   UINT8 is_cursor;
315   bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
319   UINT8 y_height;
316320
317   if(gfx_ctrl & 8)
321   y_height = y_size == 20 ? 10 : 8;
322
323   for(y=0;y<y_size;y++)
318324   {
319      if(gfx_ctrl & 0x10)
320         draw_bitmap_3bpp(screen->machine,bitmap);
321      else
322         draw_bitmap_1bpp(screen->machine,bitmap);
325      for(x=0;x<80;x++)
326      {
327         for(yi=0;yi<8;yi++)
328         {
329            is_cursor = calc_cursor_pos(machine,x,y,yi);
330
331            for(xi=0;xi<8;xi++)
332            {
333               int res_x,res_y;
334               int tile;
335               int color;
336               UINT8 *gfx_data = machine->region("gfx1")->base();
337
338               tile = vram[x+(y*120)+dma_address[2]];
339
340               res_x = x*8+xi;
341               res_y = y*y_height+yi;
342
343               if(is_cursor)
344                  color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7;
345               else
346                  color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1;
347
348               if((res_x)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y)
349                  if(color != -1)
350                     *BITMAP_ADDR16(bitmap, res_y, res_x) = machine->pens[color];
351            }
352         }
353      }
323354   }
355}
324356
325   if(!(layer_mask & 1) && dmac_mode & 4 && crtc.status & 0x10 && crtc.irq_mask == 3)
357static void draw_text_40(running_machine *machine, bitmap_t *bitmap, int y_size)
358{
359   int x,y;
360   int xi,yi;
361   UINT8 *vram = machine->region("maincpu")->base() + WRAM_BASE;
362   UINT8 is_cursor;
363   UINT8 y_height;
364
365   y_height = y_size == 20 ? 10 : 8;
366
367   for(y=0;y<y_size;y++)
326368   {
327      for(y=0;y<25;y++)
369      for(x=0;x<80;x++)
328370      {
329         for(x=0;x<80;x++)
371         if(x & 1)
372            continue;
373
374         for(yi=0;yi<8;yi++)
330375         {
331            for(yi=0;yi<8;yi++)
376            is_cursor = calc_cursor_pos(machine,x,y,yi);
377
378            for(xi=0;xi<8;xi++)
332379            {
333               for(xi=0;xi<8;xi++)
334               {
335                  int res_x,res_y;
336                  int tile;
337                  int color;
338                  UINT8 *gfx_data = screen->machine->region("gfx1")->base();
380               int res_x,res_y;
381               int tile;
382               int color;
383               UINT8 *gfx_data = machine->region("gfx1")->base();
339384
340                  tile = vram[x+(y*120)+dma_address[2]];
385               tile = vram[x+(y*120)+dma_address[2]];
341386
342                  res_x = x*8+xi;
343                  res_y = y*8+yi;
387               res_x = (x*8)+xi*2;
388               res_y = (y*y_height)+yi;
344389
345                  is_cursor = calc_cursor_pos(screen->machine,x,y,yi);
390               if(is_cursor)
391                  color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7;
392               else
393                  color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1;
346394
347                  if(is_cursor)
348                     color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? -1 : 7;
349                  else
350                     color = ((gfx_data[tile*8+yi] >> (7-xi)) & 1) ? 7 : -1;
351
352                  if((res_x)<=screen->machine->primary_screen->visible_area().max_x && (res_y)<=screen->machine->primary_screen->visible_area().max_y)
353                     if(color != -1)
354                        *BITMAP_ADDR16(bitmap, res_y, res_x) = screen->machine->pens[color];
355               }
395               if((res_x)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y)
396                  if(color != -1)
397                     *BITMAP_ADDR16(bitmap, res_y, res_x) = machine->pens[color];
398               if((res_x+1)<=machine->primary_screen->visible_area().max_x && (res_y)<=machine->primary_screen->visible_area().max_y)
399                  if(color != -1)
400                     *BITMAP_ADDR16(bitmap, res_y, res_x+1) = machine->pens[color];
356401            }
357402         }
358403      }
359404   }
405}
360406
407static VIDEO_UPDATE( pc8801 )
408{
409   bitmap_fill(bitmap, cliprect, screen->machine->pens[0]);
410
411   if(gfx_ctrl & 8)
412   {
413      if(gfx_ctrl & 0x10)
414         draw_bitmap_3bpp(screen->machine,bitmap);
415      else
416         draw_bitmap_1bpp(screen->machine,bitmap);
417   }
418
419   if(!(layer_mask & 1) && dmac_mode & 4 && crtc.status & 0x10 && crtc.irq_mask == 3)
420   {
421      static int y_size;
422
423      y_size = (crtc.param[0][1] & 0x3f) + 1;
424
425      if(y_size < 20) y_size = 20;
426      if(y_size > 25) y_size = 25;
427
428      if(txt_width)
429         draw_text_80(screen->machine,bitmap,y_size);
430      else
431         draw_text_40(screen->machine,bitmap,y_size);
432   }
433
361434   return 0;
362435}
363436
r10095r10096
782855   rtc_irq_mask = data & 1;
783856   vrtc_irq_mask = data & 2;
784857
785   if(data & 4)
786      printf("IRQ mask %02x\n",data);
858   //if(data & 4)
859   //   printf("IRQ mask %02x\n",data);
787860}
788861
789862static READ8_HANDLER( pc8801_window_bank_r )
r10095r10096
10151088   return 0;
10161089}
10171090
1091static WRITE8_HANDLER( pc8801_txt_cmt_ctrl_w )
1092{
1093   /* bits 2 to 5 are cmt related */
1094
1095   txt_width = data & 1;
1096   txt_color = data & 2;
1097}
1098
10181099static ADDRESS_MAP_START( pc8801_io, ADDRESS_SPACE_IO, 8 )
10191100   ADDRESS_MAP_GLOBAL_MASK(0xff)
10201101   ADDRESS_MAP_UNMAP_HIGH
r10095r10096
10371118   AM_RANGE(0x00, 0x02) AM_WRITE(pc8801_pcg8100_w)
10381119//   AM_RANGE(0x10, 0x10) AM_WRITE(pc88_rtc_w)
10391120   AM_RANGE(0x21, 0x21) AM_READ(sio_status_r)                                /* RS-232C and cassette */
1040   AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") //AM_WRITE(pc88sr_outport_30)
1121   AM_RANGE(0x30, 0x30) AM_READ_PORT("DSW1") AM_WRITE(pc8801_txt_cmt_ctrl_w)
10411122   AM_RANGE(0x31, 0x31) AM_READ_PORT("DSW2") AM_WRITE(pc8801_gfx_ctrl_w)
10421123   AM_RANGE(0x32, 0x32) AM_READWRITE(pc8801_misc_ctrl_r, pc8801_misc_ctrl_w)
10431124   AM_RANGE(0x34, 0x34) AM_WRITE(pc8801_alu_ctrl1_w)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team