Previous 15994 Revisions Next

r9400 Sunday 17th October, 2010 at 04:31:08 UTC by Robbbert
[MBEE] cleanup of sy6545 code closer to completion. Edasm keyboard no longer locks up. 128k monitor works. Fixed small characters showing when they shouldn't.
[src/mess/drivers]mbee.c
[src/mess/video]mbee.c

src/mess/video/mbee.c
r9399r9400
2020
2121    TODO:
2222
23    1. Above test 3 doesn't work. EDASM calls Basic to get keys, but
24    it just gets stuck (you can see it in the debugger) for no reason
25    whatsoever. Yet if you single-step the debugger, supplying values
26    as necessary, it works. g a428 to test.
27
28    2. mbeeppc keyboard response is quite slow. You need to hold each
23    1. mbeeppc keyboard response is quite slow. You need to hold each
2924    key until it responds. It works much better if you overclock the cpu.
3025
3126****************************************************************************/
r9399r9400
3328#include "emu.h"
3429#include "includes/mbee.h"
3530
36typedef struct {       // CRTC 6545
37   UINT8 horizontal_total;
38    UINT8 horizontal_displayed;
39    UINT8 horizontal_sync_pos;
40    UINT8 horizontal_length;
41    UINT8 vertical_total;
42    UINT8 vertical_adjust;
43    UINT8 vertical_displayed;
44    UINT8 vertical_sync_pos;
45    UINT8 crt_mode;
46    UINT8 scan_lines;
47    UINT8 cursor_top;
48    UINT8 cursor_bottom;
49    UINT8 screen_address_hi;
50    UINT8 screen_address_lo;
51    UINT8 cursor_address_hi;
52    UINT8 cursor_address_lo;
53   UINT8 lpen_hi;
54   UINT8 lpen_lo;
55   UINT8 transp_hi;
56   UINT8 transp_lo;
57    UINT8 idx;
58   UINT8 cursor_visible;
59   UINT8 cursor_phase;
60   UINT8 lpen_strobe;
61   UINT8 update_strobe;
62} CRTC6545;
63
64static CRTC6545 crt;
6531static UINT8 framecnt = 0;
66
6732static UINT8 *gfxram;
6833static UINT8 *colorram;
6934static UINT8 *videoram;
r9399r9400
7237static UINT8 mbee_0b;
7338static UINT8 mbee_1c;
7439static UINT8 is_premium;
75static UINT8 mc6845_cursor[16];            // cursor shape
76static void mc6845_cursor_configure(void);
77static void mc6845_screen_configure(running_machine *machine);
40static UINT8 sy6545_cursor[16];
41static UINT8 sy6545_status = 0;
42static void sy6545_cursor_configure(void);
7843static running_device *mc6845;
7944static UINT8 speed,flash;
8045static UINT16 cursor;
46static UINT8 sy6545_reg[20];            /* registers */
47static UINT8 sy6545_ind;            /* register index */
48static const UINT8 sy6545_mask[32]={0xff,0xff,0xff,0x0f,0x7f,0x1f,0x7f,0x7f,3,0x1f,0x7f,0x1f,0x3f,0xff,0x3f,0xff,0,0,0x3f,0xff};
8149
8250
51
8352/***********************************************************
8453
8554    Handlers of video, colour, and attribute RAM
r9399r9400
259228
260229   if( data )
261230   {
262      crt.lpen_lo = offs;
263      crt.lpen_hi = (offs >> 8) & 0x3f;
264      crt.lpen_strobe = 1;
231      sy6545_reg[17] = offs;
232      sy6545_reg[16] = (offs >> 8) & 0x3f;
233      sy6545_status |= 0x40; //lpen_strobe
265234   }
266235}
267236
r9399r9400
285254   screen_device *screen = screen_first(*space->machine);
286255   const rectangle &visarea = screen->visible_area();
287256
288   int data = 0, y = space->machine->primary_screen->vpos();
257   UINT8 data = sy6545_status;
258   int y = space->machine->primary_screen->vpos();
289259
290   if( y < visarea.min_y ||
291      y > visarea.max_y )
260   if( y < visarea.min_y || y > visarea.max_y )
292261      data |= 0x20;   /* vertical blanking */
293   if( crt.lpen_strobe )
294      data |= 0x40;   /* lpen register full */
295   if( crt.update_strobe )
296      data |= 0x80;   /* update strobe has occured */
297262
298263   return data;
299264}
r9399r9400
302267{
303268   int addr, data = 0;
304269
305   switch( crt.idx )
270   switch( sy6545_ind )
306271   {
307/* These are write only on a Rockwell 6545 */
308#if 0
309   case 0:
310      return crt.horizontal_total;
311   case 1:
312      return crt.horizontal_displayed;
313   case 2:
314      return crt.horizontal_sync_pos;
315   case 3:
316      return crt.horizontal_length;
317   case 4:
318      return crt.vertical_total;
319   case 5:
320      return crt.vertical_adjust;
321   case 6:
322      return crt.vertical_displayed;
323   case 7:
324      return crt.vertical_sync_pos;
325   case 8:
326      return crt.crt_mode;
327   case 9:
328      return crt.scan_lines;
329   case 10:
330      return crt.cursor_top;
331   case 11:
332      return crt.cursor_bottom;
333   case 12:
334      return crt.screen_address_hi;
335   case 13:
336      return crt.screen_address_lo;
337#endif
338   case 14:
339      data = crt.cursor_address_hi;
340      break;
341   case 15:
342      data = crt.cursor_address_lo;
343      break;
344272   case 16:
345      crt.lpen_strobe = 0;
346      data = crt.lpen_hi;
347      break;
348273   case 17:
349      crt.lpen_strobe = 0;
350      data = crt.lpen_lo;
274      sy6545_status &= 0x80; // turn off lpen_strobe
351275      break;
352   case 18:
353      data = crt.transp_hi;
354      break;
355   case 19:
356      data = crt.transp_lo;
357      break;
358276   case 31:
359277      /* This firstly pushes the contents of the transparent registers onto the MA lines,
360      then increments the address, then sets strobe on. */
361      addr = (crt.transp_hi << 8) | crt.transp_lo;
278      then increments the address, then sets update strobe on. */
279      addr = (sy6545_reg[18] << 8) | sy6545_reg[19];
362280      keyboard_matrix_r(space->machine, addr);
363      crt.transp_lo++;
364      if (!crt.transp_lo) crt.transp_hi++;
365      crt.update_strobe = 1;
281      sy6545_reg[19]++;
282      if (!sy6545_reg[19]) sy6545_reg[18]++;
283      sy6545_status |= 0x80; // update_strobe
366284      break;
367   default:
368      logerror("6545 read unmapped port $%X\n", crt.idx);
369285   }
370286   return data;
371287}
372288
373289WRITE8_HANDLER ( m6545_index_w )
374290{
375   crt.idx = data & 0x1f;
376291   data &= 0x1f;
377//   mc6845_ind = data;
292   sy6545_ind = data;
378293   mc6845_address_w( mc6845, 0, data );
379294}
380295
381296WRITE8_HANDLER ( m6545_data_w )
382297{
383   int addr;
298   int addr = 0;
384299
385   switch( crt.idx )
300   switch( sy6545_ind )
386301   {
387   case 0:
388      if( crt.horizontal_total == data )
389         break;
390      crt.horizontal_total = data;
391      break;
392   case 1:
393      crt.horizontal_displayed = data;
394      mc6845_screen_configure(space->machine);
395      break;
396   case 2:
397      if( crt.horizontal_sync_pos == data )
398         break;
399      crt.horizontal_sync_pos = data;
400      break;
401   case 3:
402      crt.horizontal_length = data;
403      break;
404   case 4:
405      if( crt.vertical_total == data )
406         break;
407      crt.vertical_total = data;
408      break;
409   case 5:
410      if( crt.vertical_adjust == data )
411         break;
412      crt.vertical_adjust = data;
413      break;
414   case 6:
415      crt.vertical_displayed = data;
416      mc6845_screen_configure(space->machine);
417      break;
418   case 7:
419      if( crt.vertical_sync_pos == data )
420         break;
421      crt.vertical_sync_pos = data;
422      break;
423   case 8:
424      crt.crt_mode = data;
425
426      {
427         logerror("6545 mode_w $%02X\n", data);
428         logerror("     interlace          %d\n", data & 3);
429         logerror("     addr mode          %d\n", (data >> 2) & 1);
430         logerror("     refresh RAM        %s\n", ((data >> 3) & 1) ? "transparent" : "shared");
431         logerror("     disp enb, skew     %d\n", (data >> 4) & 3);
432         logerror("     pin 34             %s\n", ((data >> 6) & 1) ? "update strobe" : "RA4");
433         logerror("     update read mode   %s\n", ((data >> 7) & 1) ? "interleaved" : "during h/v-blank");
434      }
435      break;
436   case 9:
437      data &= 15;
438      if( crt.scan_lines == data )
439         break;
440      crt.scan_lines = data;
441      mc6845_screen_configure(space->machine);
442      mc6845_cursor_configure();
443      break;
444   case 10:
445      crt.cursor_top = data;
446      mc6845_cursor_configure();
447      break;
448   case 11:
449      crt.cursor_bottom = data;
450      mc6845_cursor_configure();
451      break;
452302   case 12:
453303      data &= 0x3f;
454      if( crt.screen_address_hi == data )
455         break;
456      crt.screen_address_hi = data;
457      memcpy(gfxram, memory_region(space->machine, "gfx") + ((data & 32) << 6), 0x800);
304      if( sy6545_reg[12] != data )
305         memcpy(gfxram, memory_region(space->machine, "gfx") + (((data & 0x30) == 0x20) << 11), 0x800);
458306      break;
459   case 13:
460      crt.screen_address_lo = data;
461      break;
462   case 14:
463      crt.cursor_address_hi = data & 0x3f;
464      break;
465   case 15:
466      crt.cursor_address_lo = data;
467      break;
468   case 16:
469      /* lpen hi is read only */
470      break;
471   case 17:
472      /* lpen lo is read only */
473      break;
474   case 18:
475      data &= 63;
476      crt.transp_hi = data;
477      break;
478   case 19:
479      crt.transp_lo = data;
480      break;
481307   case 31:
482308      /* This firstly pushes the contents of the transparent registers onto the MA lines,
483      then increments the address, then sets strobe on. */
484      addr = (crt.transp_hi << 8) | crt.transp_lo;
309      then increments the address, then sets update strobe on. */
310      addr = (sy6545_reg[18] << 8) | sy6545_reg[19];
485311      keyboard_matrix_r(space->machine, addr);
486      crt.transp_lo++;
487      if (!crt.transp_lo) crt.transp_hi++;
488      crt.update_strobe = 1;
312      sy6545_reg[19]++;
313      if (!sy6545_reg[19]) sy6545_reg[18]++;
314      sy6545_status |= 0x80; // update_strobe
489315      break;
490   default:
491      logerror("6545 write unmapped port $%X <- $%02X\n", crt.idx, data);
492316   }
493//   if (mc6845_ind < 16) mc6845_reg[mc6845_ind] = data & mc6845_mask[mc6845_ind];   /* save data in register */
494//   if ((mc6845_ind == 1) || (mc6845_ind == 6) || (mc6845_ind == 9)) mc6845_screen_configure(space->machine); /* adjust screen size */
495//   if ((mc6845_ind > 8) && (mc6845_ind < 12)) mc6845_cursor_configure();      /* adjust cursor shape - remove when mame fixed */
317   sy6545_reg[sy6545_ind] = data & sy6545_mask[sy6545_ind];   /* save data in register */
496318   mc6845_register_w( mc6845, 0, data );
319   if ((sy6545_ind > 8) && (sy6545_ind < 12)) sy6545_cursor_configure();      /* adjust cursor shape - remove when mame fixed */
497320}
498321
499322
r9399r9400
507330
508331************************************************************/
509332
510static void mc6845_cursor_configure(void)
333static void sy6545_cursor_configure(void)
511334{
512335   UINT8 i,curs_type=0,r9,r10,r11;
513336
r9399r9400
517340        2 = full cursor
518341        3 = two-part cursor (has a part at the top and bottom with the middle blank) */
519342
520   for ( i = 0; i < ARRAY_LENGTH(mc6845_cursor); i++) mc6845_cursor[i] = 0;      // prepare cursor by erasing old one
343   for ( i = 0; i < ARRAY_LENGTH(sy6545_cursor); i++) sy6545_cursor[i] = 0;      // prepare cursor by erasing old one
521344
522   r9  = crt.scan_lines;               // number of scan lines - 1
523   r10 = crt.cursor_top & 0x1f;            // cursor start line = last 5 bits
524   r11 = crt.cursor_bottom+1;            // cursor end line incremented to suit for-loops below
345   r9  = sy6545_reg[9];               // number of scan lines - 1
346   r10 = sy6545_reg[10] & 0x1f;            // cursor start line = last 5 bits
347   r11 = sy6545_reg[11]+1;               // cursor end line incremented to suit for-loops below
525348
526349   /* decide the curs_type by examining the registers */
527350   if (r10 < r11) curs_type=1;            // start less than end, show start to end
r9399r9400
534357   if (r11 > 16) r11=16;               // truncate 5-bit register to fit our 4-bit hardware
535358
536359   /* create the new cursor */
537   if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(mc6845_cursor);i++) mc6845_cursor[i]=0xff; // turn on full cursor
360   if (curs_type > 1) for (i = 0;i < ARRAY_LENGTH(sy6545_cursor);i++) sy6545_cursor[i]=0xff; // turn on full cursor
538361
539   if (curs_type == 1) for (i = r10;i < r11;i++) mc6845_cursor[i]=0xff; // for each line that should show, turn on that scan line
362   if (curs_type == 1) for (i = r10;i < r11;i++) sy6545_cursor[i]=0xff; // for each line that should show, turn on that scan line
540363
541   if (curs_type == 3) for (i = r11; i < r10;i++) mc6845_cursor[i]=0; // now take a bite out of the middle
364   if (curs_type == 3) for (i = r11; i < r10;i++) sy6545_cursor[i]=0; // now take a bite out of the middle
542365}
543366
544367
545368
546/***********************************************************
547369
548    Resize the screen within the limits of the hardware.
549    Expand the image to fill the screen area.
550
551************************************************************/
552
553static void mc6845_screen_configure(running_machine *machine)
554{
555   rectangle visarea;
556
557   UINT16 width = crt.horizontal_displayed*8-1;                     // width in pixels
558   UINT16 height = crt.vertical_displayed*(crt.scan_lines+1)-1;               // height in pixels
559   UINT16 bytes = crt.horizontal_displayed*crt.vertical_displayed-1;            // video ram needed
560
561   if (width > 0x27f) width=0x27f;
562   if (height > 0x10f) height=0x10f;
563
564   /* Resize the screen */
565   visarea.min_x = 0;
566   visarea.max_x = width-1;
567   visarea.min_y = 0;
568   visarea.max_y = height-1;
569   if (bytes < 0x800) machine->primary_screen->set_visible_area(0, width, 0, height);
570}
571
572
573
574370/***********************************************************
575371
576372    Video
r9399r9400
607403VIDEO_UPDATE( mbee )
608404{
609405   framecnt++;
610   cursor = (crt.cursor_address_hi<<8) | crt.cursor_address_lo;         // get cursor position
611   speed = crt.cursor_top&0x20, flash = crt.cursor_top&0x40;            // cursor modes
406   speed = sy6545_reg[10]&0x20, flash = sy6545_reg[10]&0x40;         // cursor modes
407   cursor = (sy6545_reg[14]<<8) | sy6545_reg[15];               // get cursor position
612408   mc6845_update(mc6845, bitmap, cliprect);
613409   return 0;
614410}
r9399r9400
645441         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
646442         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
647443         (mem == cursor))               // displaying at cursor position?
648            inv ^= mc6845_cursor[ra];         // cursor scan row
444            inv ^= sy6545_cursor[ra];         // cursor scan row
649445
650446      /* get pattern of pixels for that character scanline */
651447      gfx = gfxram[(chr<<4) | ra] ^ inv;
r9399r9400
684480         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
685481         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
686482         (mem == cursor))               // displaying at cursor position?
687            inv ^= mc6845_cursor[ra];         // cursor scan row
483            inv ^= sy6545_cursor[ra];         // cursor scan row
688484
689485      /* get pattern of pixels for that character scanline */
690486      gfx = gfxram[(chr<<4) | ra] ^ inv;
r9399r9400
739535         ((flash) && (speed) && (framecnt & 0x10)) ||      // (5,6)=(1,1) = cycle per 32 frames
740536         ((flash) && (!speed) && (framecnt & 8))) &&      // (5,6)=(0,1) = cycle per 16 frames
741537         (mem == cursor))               // displaying at cursor position?
742            inv ^= mc6845_cursor[ra];         // cursor scan row
538            inv ^= sy6545_cursor[ra];         // cursor scan row
743539
744540      /* get pattern of pixels for that character scanline */
745541      gfx = gfxram[(chr<<4) | ra] ^ inv;
src/mess/drivers/mbee.c
r9399r9400
8282    - Most early models have a clock in Telcom, and in the menu. It doesn't
8383      work.
8484
85    - The Monitor program on 128k and 256TC crashes the system. This appears
85    - The Monitor program on 256TC crashes the system. This appears
8686      to be a MAME core bug involving the z80pio.
8787
88    - Keyboard on EDASM on bankswitched models locks up. This also is
89      suspected to be a core bug, since the identical edasm works on the
90      non-bankswitch model.
9188
9289***************************************************************************/
9390

Previous 15994 Revisions Next


© 1998-2018 The MESS Team