Previous 15994 Revisions Next

r6364 Thursday 12th November, 2009 at 11:55:16 UTC by Curt Coder
[PC8001] Implemented screen drawing, does not work without i8257 changes which are not yet included.
[src/mess/drivers]pc8001.c
[src/mess/includes]pc8001.h
[src/mess/video]upd3301.c upd3301.h

src/mess/video/upd3301.c
r6363r6364
1111 
1212   TODO:
1313 
14   - FIFO
15   - screen display
16   - set_drq
17   - dack_w
18   - interrupts
14   - attributes
15   - N interrupt
1916   - light pen
2017   - reset counters
18   - proper DMA timing (now the whole screen is transferred at the end of the frame, 
19      accurate timing requires CCLK timer which kills performance)
2120 
2221*/
2322 
r6363r6364
3433#define UPD3301_COMMAND_RESET               0x00
3534#define UPD3301_COMMAND_START_DISPLAY         0x20
3635#define UPD3301_COMMAND_SET_INTERRUPT_MASK      0x40
37#define UPD3301_COMMAND_READ_LIGHT_PEN         0x60
36#define UPD3301_COMMAND_READ_LIGHT_PEN         0x60   /* not supported */
3837#define UPD3301_COMMAND_LOAD_CURSOR_POSITION   0x80
3938#define UPD3301_COMMAND_RESET_INTERRUPT         0xa0
40#define UPD3301_COMMAND_RESET_COUNTERS         0xc0
39#define UPD3301_COMMAND_RESET_COUNTERS         0xc0   /* not supported */
4140 
4241#define UPD3301_STATUS_VE                  0x10
4342#define UPD3301_STATUS_U                  0x08   /* not supported */
r6363r6364
6160typedef struct _upd3301_t upd3301_t;
6261struct _upd3301_t
6362{
64   devcb_resolved_write_line   out_int_func;
65   devcb_resolved_write_line   out_drq_func;
66   devcb_resolved_write_line   out_hrtc_func;
67   devcb_resolved_write_line   out_vrtc_func;
63   /* callbacks */
64   devcb_resolved_write_line      out_int_func;
65   devcb_resolved_write_line      out_drq_func;
66   devcb_resolved_write_line      out_hrtc_func;
67   devcb_resolved_write_line      out_vrtc_func;
68   upd3301_display_pixels_func      display_func;
6869 
70   /* screen drawing */
6971   const device_config *screen;   /* screen */
70   int width;                  /* character width */
72   bitmap_t *bitmap;            /* bitmap */
73   int y;                     /* current scanline */
7174 
72   int mode;
73   UINT8 status;
74   int param_count;
75   /* live state */
76   int mode;                  /* command mode */
77   UINT8 status;               /* status register */
78   int param_count;            /* parameter count */
7579 
76   UINT8 row_buffer[80][2];      /* row buffer */
77   UINT8 fifo[20][2];            /* FIFO */
80   /* FIFOs */
81   UINT8 data_fifo[80][2];         /* row data FIFO */
82   UINT8 attr_fifo[40][2];         /* attribute FIFO */
83   int data_fifo_pos;            /* row data FIFO position */
84   int attr_fifo_pos;            /* attribute FIFO position */
85   int input_fifo;               /* which FIFO is in input mode */
7886 
87   /* interrupts */
88   int mn;                     /* disable special character interrupt */
89   int me;                     /* disable end of screen interrupt */
7990   int dma_mode;               /* DMA mode */
91 
92   /* screen geometry */
93   int width;                  /* character width */
8094   int h;                     /* characters per line */
8195   int b;                     /* cursor blink time */
8296   int l;                     /* lines per screen */
r6363r6364
8599   int r;                     /* lines per character */
86100   int v;                     /* vertical blanking height */
87101   int z;                     /* horizontal blanking width */
102 
103   /* attributes */
88104   int at1;                  /*  */
89105   int at0;                  /*  */
90106   int sc;                     /*  */
91107   int a;                     /* attributes per row */
92   int mn;                     /* disable special character interrupt */
93   int me;                     /* disable end of screen interrupt */
108   int attr_blink;               /* attribute blink */
109   int attr_frame;               /* attribute blink frame counter */
110 
111   /* cursor */
94112   int cm;                     /* cursor visible */
95113   int cx;                     /* cursor column */
96114   int cy;                     /* cursor row */
115   int cursor_blink;            /* cursor blink */
116   int cursor_frame;            /* cursor blink frame counter */
97117 
98118   /* timers */
99119   emu_timer *vrtc_timer;         /* vertical sync timer */
r6363r6364
142162}
143163 
144164/*-------------------------------------------------
165    set_drq - set data request line state
166-------------------------------------------------*/
167 
168static void set_drq(const device_config *device, int state)
169{
170   upd3301_t *upd3301 = get_safe_token(device);
171 
172   if (LOG) logerror("UPD3301 '%s' DRQ: %u\n", device->tag, state);
173 
174   devcb_call_write_line(&upd3301->out_drq_func, state);
175}
176 
177/*-------------------------------------------------
145178    set_display - set display state
146179-------------------------------------------------*/
147180 
r6363r6364
166199static void reset_counters(const device_config *device)
167200{
168201   set_interrupt(device, 0);
202   set_drq(device, 0);
169203}
170204 
171205/*-------------------------------------------------
172    update_hrtc_timer -
206    update_hrtc_timer - update horizontal retrace
207   timer
173208-------------------------------------------------*/
174209 
175210static void update_hrtc_timer(upd3301_t *upd3301, int state)
r6363r6364
185220}
186221 
187222/*-------------------------------------------------
188    update_vrtc_timer -
223    update_vrtc_timer - update vertical retrace
224   timer
189225-------------------------------------------------*/
190226 
191227static void update_vrtc_timer(upd3301_t *upd3301, int state)
r6363r6364
198234}
199235 
200236/*-------------------------------------------------
201    recompute_parameters -
237    recompute_parameters - recompute screen
238   geometry parameters
202239-------------------------------------------------*/
203240 
204241static void recompute_parameters(const device_config *device)
r6363r6364
283320 
284321   case 1: /* status */
285322      data = upd3301->status;
323      upd3301->status &= ~(UPD3301_STATUS_LP | UPD3301_STATUS_E |UPD3301_STATUS_N | UPD3301_STATUS_U);
286324      break;
287325   }
288326 
r6363r6364
423461 
424462      case UPD3301_COMMAND_RESET_COUNTERS:
425463         if (LOG) logerror("UPD3301 '%s' Reset Counters\n", device->tag);
464         upd3301->mode = MODE_RESET_COUNTERS;
426465         reset_counters(device);
427466         break;
428467      }
r6363r6364
439478}
440479 
441480/*-------------------------------------------------
481    draw_row - draw character row
482-------------------------------------------------*/
483 
484static void draw_row(const device_config *device, bitmap_t *bitmap)
485{
486   upd3301_t *upd3301 = get_safe_token(device);
487   int sx, lc;
488 
489   for (lc = 0; lc < upd3301->r; lc++)
490   {
491      for (sx = 0; sx < upd3301->h; sx++)
492      {
493         int y = upd3301->y + lc;
494         UINT8 cc = upd3301->data_fifo[sx][!upd3301->input_fifo];
495         int hlgt = 0;
496         int rvv = 0;
497         int vsp = 0;
498         int sl0 = 0;
499         int sl12 = 0;
500         int csr = upd3301->cm && upd3301->cursor_blink && ((y / upd3301->r) == upd3301->cy) && (sx == upd3301->cx);
501         int gpa = 0;
502 
503         upd3301->display_func(device, bitmap, y, sx, cc, lc, hlgt, rvv, vsp, sl0, sl12, csr, gpa);
504      }
505   }
506 
507   upd3301->y += upd3301->r;
508}
509 
510/*-------------------------------------------------
442511    upd3301_dack_w - DMA acknowledge write
443512-------------------------------------------------*/
444513 
445514WRITE8_DEVICE_HANDLER( upd3301_dack_w )
446515{
447   logerror("DMA WRITE %02x\n", data);
516   upd3301_t *upd3301 = get_safe_token(device);
517 
518   if (upd3301->data_fifo_pos < upd3301->h)
519   {
520      upd3301->data_fifo[upd3301->data_fifo_pos][upd3301->input_fifo] = data;
521      upd3301->data_fifo_pos++;
522   }
523   else
524   {
525      upd3301->attr_fifo[upd3301->attr_fifo_pos][upd3301->input_fifo] = data;
526      upd3301->attr_fifo_pos++;
527   }
528 
529   if ((upd3301->data_fifo_pos == upd3301->h) && (upd3301->attr_fifo_pos == (upd3301->a << 1)))
530   {
531      upd3301->input_fifo = !upd3301->input_fifo;
532      upd3301->data_fifo_pos = 0;
533      upd3301->attr_fifo_pos = 0;
534      draw_row(device, upd3301->bitmap);
535   }
536 
537   if (upd3301->y == (upd3301->l * upd3301->r))
538   {
539      /* end DMA transfer */
540      set_drq(device, 0);
541   }
448542}
449543 
450544/*-------------------------------------------------
r6363r6364
457551 
458552   if (upd3301->status & UPD3301_STATUS_VE)
459553   {
554      upd3301->y = 0;
555      upd3301->bitmap = bitmap;
556      upd3301->data_fifo_pos = 0;
557      upd3301->attr_fifo_pos = 0;
558 
559      upd3301->cursor_frame++;
560 
561      if (upd3301->cursor_frame == upd3301->b)
562      {
563         upd3301->cursor_frame = 0;
564         upd3301->cursor_blink = !upd3301->cursor_blink;
565      }
566 
567      upd3301->attr_frame++;
568 
569      if (upd3301->attr_frame == (upd3301->b << 1))
570      {
571         upd3301->attr_frame = 0;
572         upd3301->attr_blink = !upd3301->attr_blink;
573      }
574 
460575      /* start DMA transfer */
461      //devcb_call_write_line(&upd3301->out_drq_func, 1);
576      set_drq(device, 1);
462577   }
463578   else
464579   {
r6363r6364
486601   assert(upd3301->screen != NULL);
487602 
488603   /* get character width */
604   upd3301->display_func = intf->display_func;
489605   upd3301->width = intf->width;
490606 
491607   /* create the timers */
r6363r6364
510626   upd3301->r = 10;
511627   upd3301->v = 6;
512628   upd3301->z = 32;
629   upd3301->status = 0;
513630 
631   set_interrupt(device, 0);
632   set_drq(device, 0);
633 
514634   recompute_parameters(device);
515635}
516636 
src/mess/video/upd3301.h
r6363r6364
5252    TYPE DEFINITIONS
5353***************************************************************************/
5454 
55typedef void (*upd3301_display_pixels_func)(const device_config *device, bitmap_t *bitmap, int y, int x, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa);
56#define UPD3301_DISPLAY_PIXELS(name) void name(const device_config *device, bitmap_t *bitmap, int y, int x, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa)
55typedef void (*upd3301_display_pixels_func)(const device_config *device, bitmap_t *bitmap, int y, int sx, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa);
56#define UPD3301_DISPLAY_PIXELS(name) void name(const device_config *device, bitmap_t *bitmap, int y, int sx, UINT8 cc, UINT8 lc, int hlgt, int rvv, int vsp, int sl0, int sl12, int csr, int gpa)
5757 
5858typedef struct _upd3301_interface upd3301_interface;
5959struct _upd3301_interface
src/mess/includes/pc8001.h
r6363r6364
2121   /* video state */
2222   UINT8 *char_rom;
2323   int vrtc;
24   int width80;
25   int color;
2426 
2527   /* printer state */
2628   int ack;
src/mess/drivers/pc8001.c
r6363r6364
22
33   http://www2.odn.ne.jp/~haf09260/Pc80/EnrPc.htm
44   http://home1.catvmics.ne.jp/~kanemoto/n80/inside.html
5   http://www.geocities.jp/retro_zzz/machines/nec/8001/index.html
56
67*/
78
r6363r6364
910
1011   TODO:
1112
13   - 8257dma has write modes flipped (should be 1=r, 2=w)
1214   - uPD3301
1315   - PCG1000
1416   - Intel 8251
r6363r6364
8486
8587   pc8001_state *state = space->machine->driver_data;
8688
89   /* characters per line */
90   state->width80 = BIT(data, 0);
91
92   /* color mode */
93   state->color = BIT(data, 1);
94
8795   /* cassette motor */
8896   cassette_change_state(state->cassette, BIT(data, 3) ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR);
8997}
r6363r6364
382390{
383391   pc8001_state *state = device->machine->driver_data;
384392
385   UINT8 data = state->char_rom[(cc << 4) | lc];
393   UINT8 data = state->char_rom[(cc << 3) | lc];
386394   int i;
387395
388   for (i = 0; i < 8; i++)
396   if (lc >= 8) return;
397   if (csr) data = 0xff;
398
399   if (state->width80)
389400   {
390      int color = BIT(data, i);
401      for (i = 0; i < 8; i++)
402      {
403         int color = BIT(data, 7) ^ rvv;
391404
392      *BITMAP_ADDR16(tmpbitmap, y, x + i) = color;
405         *BITMAP_ADDR16(bitmap, y, (sx * 8) + i) = color;
406
407         data <<= 1;
408      }
393409   }
410   else
411   {
412      if (sx % 2) return;
413
414      for (i = 0; i < 8; i++)
415      {
416         int color = BIT(data, 7) ^ rvv;
417
418         *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2)) = color;
419         *BITMAP_ADDR16(bitmap, y, (sx/2 * 16) + (i * 2) + 1) = color;
420
421         data <<= 1;
422      }
423   }
394424}
395425
396426static WRITE_LINE_DEVICE_HANDLER( pc8001_vrtc_w )
r6363r6364
612642
613643ROM_START( pc8001 )
614644   ROM_REGION( 0x6000, "n80", 0 )
615   ROM_SYSTEM_BIOS( 0, "v101", "N80-BASIC v1.01" )
645   ROM_SYSTEM_BIOS( 0, "v101", "N-BASIC v1.01" )
616646   ROMX_LOAD( "n80v101.rom", 0x00000, 0x6000, CRC(a2cc9f22) SHA1(6d2d838de7fea20ddf6601660d0525d5b17bf8a3), ROM_BIOS(1) )
617   ROM_SYSTEM_BIOS( 1, "v102", "N80-BASIC v1.02" )
647   ROM_SYSTEM_BIOS( 1, "v102", "N-BASIC v1.02" )
618648   ROMX_LOAD( "n80v102.rom", 0x00000, 0x6000, CRC(ed01ca3f) SHA1(b34a98941499d5baf79e7c0e5578b81dbede4a58), ROM_BIOS(2) )
619   ROM_SYSTEM_BIOS( 2, "v110", "N80-BASIC v1.10" )
649   ROM_SYSTEM_BIOS( 2, "v110", "N-BASIC v1.10" )
620650   ROMX_LOAD( "n80v110.rom", 0x00000, 0x6000, CRC(1e02d93f) SHA1(4603cdb7a3833e7feb257b29d8052c872369e713), ROM_BIOS(3) )
621651
622652   ROM_REGION( 0x800, "chargen", 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team