Previous 15994 Revisions Next

r9664 Friday 26th November, 2010 at 02:49:12 UTC by Curt Coder
[TANDY2K] Video WIP.
[src/mess/drivers]tandy2k.c
[src/mess/video]crt9007.c crt9007.h

src/mess/video/crt9007.c
r9663r9664
1111
1212    TODO:
1313
14   - cursor timer
1415    - interrupts
15    - status register
16    - reset
16      - light pen
17      - frame timer
1718   - non-DMA mode
1819    - DMA mode
1920    - cursor/blank skew
r9663r9664
8283   (((m_reg[0x08] << 3) & 0x0700) | m_reg[0x09])
8384
8485#define DMA_BURST_COUNT \
85   (m_reg[0x0a] & 0x0f)
86   ((m_reg[0x0a] & 0x0f) + 1)
8687
8788#define DMA_BURST_DELAY \
88   ((m_reg[0x0a] >> 4) & 0x07)
89   ((((m_reg[0x0a] >> 4) & 0x07) + 1) % 8)
8990
9091#define DMA_DISABLE \
9192   BIT(m_reg[0x0a], 7)
r9663r9664
144145#define HORIZONTAL_CURSOR \
145146   m_reg[0x19]
146147
148#define INTERRUPT_ENABLE \
149   m_reg[0x1a]
150
147151#define FRAME_TIMER \
148152   BIT(m_reg[0x1a], 0)
149153
r9663r9664
172176// operation modes
173177enum
174178{
175   OPERATION_MODE_REPETITIVE_MEMORY_ADDRESSING = 0,
176   OPERATION_MODE_DOUBLE_ROW_BUFFER,
177   OPERATION_MODE_SINGLE_ROW_BUFFER = 4,
178   OPERATION_MODE_ATTRIBUTE_ASSEMBLE = 7
179   OPERATION_MODE_REPETITIVE_MEMORY_ADDRESSING = 0,   // not implemented
180   OPERATION_MODE_DOUBLE_ROW_BUFFER = 1,
181   OPERATION_MODE_SINGLE_ROW_BUFFER = 4,            // not implemented
182   OPERATION_MODE_ATTRIBUTE_ASSEMBLE = 7            // not implemented
179183};
180184
181185
r9663r9664
183187enum
184188{
185189   ADDRESS_MODE_SEQUENTIAL_ADDRESSING = 0,
186   ADDRESS_MODE_SEQUENTIAL_ROLL_ADDRESSING,
187   ADDRESS_MODE_CONTIGUOUS_ROW_TABLE,
188   ADDRESS_MODE_LINKED_LIST_ROW_TABLE
190   ADDRESS_MODE_SEQUENTIAL_ROLL_ADDRESSING,         // not implemented
191   ADDRESS_MODE_CONTIGUOUS_ROW_TABLE,               // not implemented
192   ADDRESS_MODE_LINKED_LIST_ROW_TABLE               // not implemented
189193};
190194
191195
196// interrupt enable register bits
197const int IE_VERTICAL_RETRACE         = 0x40;
198const int IE_LIGHT_PEN               = 0x20;
199const int IE_FRAME_TIMER            = 0x01;
200
192201// status register bits
193202const int STATUS_INTERRUPT_PENDING      = 0x80;
194203const int STATUS_VERTICAL_RETRACE      = 0x40;
r9663r9664
284293      memset(&out_vlt_func, 0, sizeof(out_vlt_func));
285294      memset(&out_curs_func, 0, sizeof(out_curs_func));
286295      memset(&out_drb_func, 0, sizeof(out_drb_func));
296      memset(&out_cblank_func, 0, sizeof(out_cblank_func));
287297      memset(&out_slg_func, 0, sizeof(out_slg_func));
288298      memset(&out_sld_func, 0, sizeof(out_sld_func));
289299   }
r9663r9664
306316
307317
308318//-------------------------------------------------
319//  trigger_interrupt -
320//-------------------------------------------------
321
322inline void crt9007_device::trigger_interrupt(int line)
323{
324   if (INTERRUPT_ENABLE & line)
325   {
326      int status = m_status;
327
328      m_status |= STATUS_INTERRUPT_PENDING | line;
329
330      if (!(status & STATUS_INTERRUPT_PENDING))
331      {
332         if (LOG) logerror("CRT9007 '%s' INT 1\n", tag());
333         devcb_call_write_line(&m_out_int_func, ASSERT_LINE);
334      }
335   }
336}
337
338
339//-------------------------------------------------
340//  update_cblank_line -
341//-------------------------------------------------
342
343inline void crt9007_device::update_cblank_line()
344{
345   int x = m_screen->hpos();
346   int y = m_screen->vpos();
347
348   // composite blank
349   int cblank = !(m_hs & m_vs);
350     
351   if (m_cblank != cblank)
352   {
353      m_cblank = cblank;
354         
355      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CBLANK %u\n", tag(), y, x, m_cblank);
356         
357      devcb_call_write_line(&m_out_cblank_func, m_cblank);
358   }
359}
360
361
362//-------------------------------------------------
309363//  update_hsync_timer -
310364//-------------------------------------------------
311365
r9663r9664
314368   int y = m_screen->vpos();
315369
316370   int next_x = state ? m_hsync_start : m_hsync_end;
317   int next_y = (y + 1) % SCAN_LINES_PER_FRAME;
371   int next_y = state ? (y + 1) % SCAN_LINES_PER_FRAME : y;
318372
319373   attotime duration = m_screen->time_until_pos(next_y, next_x);
320374
r9663r9664
342396
343397inline void crt9007_device::update_vlt_timer(int state)
344398{
345   // TODO
399   // this signal is active during all visible scan lines and during the horizontal trace at vertical retrace
400   int y = m_screen->vpos();
401
402   int next_x = state ? m_vlt_end : m_vlt_start;
403   int next_y = state ? y : ((y == m_vlt_bottom) ? 0 : (y + 1));
404
405   attotime duration = m_screen->time_until_pos(next_y, next_x);
406
407   timer_adjust_oneshot(m_vlt_timer, duration, !state);
346408}
347409
348410
r9663r9664
352414
353415inline void crt9007_device::update_curs_timer(int state)
354416{
417   // this signal is active for 1 character time for all scanlines within the data row
355418   // TODO
356419}
357420
r9663r9664
362425
363426inline void crt9007_device::update_drb_timer(int state)
364427{
428   // this signal is active for 1 full scan line (VLT edge to edge) at the top scan line of each new row
429   // there is 1 extra DRB signal during the 1st scanline of the vertical retrace interval
430   int y = m_screen->vpos();
431
432   int next_x = m_vlt_end;
433   int next_y = y ? y + 1 : y;
434
435   if (state)
436   {
437      if (y == 0)
438      {
439         next_y = VERTICAL_DELAY - 1;
440      }
441      else if (y == m_drb_bottom)
442      {
443         next_x = 0;
444         next_y = 0;
445      }
446      else
447      {
448         next_y = y + SCAN_LINES_PER_DATA_ROW - 1;
449      }
450   }
451
452   attotime duration = m_screen->time_until_pos(next_y, next_x);
453
454   timer_adjust_oneshot(m_drb_timer, duration, !state);
455}
456
457
458//-------------------------------------------------
459//  update_dma_timer -
460//-------------------------------------------------
461
462inline void crt9007_device::update_dma_timer()
463{
365464   // TODO
366465}
367466
r9663r9664
375474   // check that necessary registers have been loaded
376475   if (!HAS_VALID_PARAMETERS) return;
377476
477   // screen dimensions
378478   int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * m_hpixels_per_column;
379479   int vert_pix_total = SCAN_LINES_PER_FRAME;
380480
481   // refresh rate
381482   attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * horiz_pix_total * vert_pix_total;
382483
383   m_hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_SYNC_WIDTH) * m_hpixels_per_column;
384   m_hsync_end = 0;
385   m_hfp = (HORIZONTAL_DELAY - HORIZONTAL_SYNC_WIDTH) * m_hpixels_per_column;
484   // horizontal sync
485   m_hsync_start = 0;
486   m_hsync_end = HORIZONTAL_SYNC_WIDTH * m_hpixels_per_column;
386487
387   m_vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH;
388   m_vsync_end = 0;
389   m_vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH;
488   // visible line time
489   m_vlt_start = HORIZONTAL_DELAY * m_hpixels_per_column;
490   m_vlt_end = (HORIZONTAL_DELAY + CHARACTERS_PER_DATA_ROW) * m_hpixels_per_column;
491   m_vlt_bottom = VERTICAL_DELAY + (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW) - 1;
390492
493   // data row boundary
494   m_drb_bottom = VERTICAL_DELAY + (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW) - SCAN_LINES_PER_DATA_ROW;
495
496   // vertical sync
497   m_vsync_start = 0;
498   m_vsync_end = VERTICAL_SYNC_WIDTH;
499
500   // visible area
391501   rectangle visarea;
392502
393503   visarea.min_x = m_hsync_end;
394   visarea.max_x = m_hsync_start - 1;
504   visarea.max_x = horiz_pix_total - 1;
395505
396506   visarea.min_y = m_vsync_end;
397   visarea.max_y = m_vsync_start - 1;
507   visarea.max_y = vert_pix_total - 1;
398508
399509   if (LOG)
400510   {
r9663r9664
404514
405515   m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
406516
407   update_hsync_timer(1);
408   update_vsync_timer(1);
409   update_vlt_timer(1);
410   update_curs_timer(1);
411   update_drb_timer(1);
517   timer_adjust_oneshot(m_hsync_timer, m_screen->time_until_pos(0, 0), 0);
518   timer_adjust_oneshot(m_vsync_timer, m_screen->time_until_pos(0, 0), 0);
519   timer_adjust_oneshot(m_vlt_timer, m_screen->time_until_pos(0, m_vlt_start), 1);
520   timer_adjust_oneshot(m_drb_timer, m_screen->time_until_pos(0, 0), 0);
412521}
413522
414523
r9663r9664
442551   m_vlt_timer = device_timer_alloc(*this, TIMER_VLT);
443552   m_curs_timer = device_timer_alloc(*this, TIMER_CURS);
444553   m_drb_timer = device_timer_alloc(*this, TIMER_DRB);
554   m_dma_timer = device_timer_alloc(*this, TIMER_DMA);
445555
446556   // resolve callbacks
447557   devcb_resolve_write_line(&m_out_int_func, &m_config.out_int_func, this);
r9663r9664
451561   devcb_resolve_write_line(&m_out_vlt_func, &m_config.out_vlt_func, this);
452562   devcb_resolve_write_line(&m_out_curs_func, &m_config.out_curs_func, this);
453563   devcb_resolve_write_line(&m_out_drb_func, &m_config.out_drb_func, this);
564   devcb_resolve_write_line(&m_out_cblank_func, &m_config.out_cblank_func, this);
565   devcb_resolve_write_line(&m_out_slg_func, &m_config.out_slg_func, this);
566   devcb_resolve_write_line(&m_out_sld_func, &m_config.out_sld_func, this);
454567
455568   // get the screen device
456569   m_screen = machine->device<screen_device>(m_config.screen_tag);
r9663r9664
479592   devcb_call_write_line(&m_out_vs_func, 1);
480593
481594   // CBLANK = 1
482//   devcb_call_write_line(&m_out_cblank_func, 0);
595   devcb_call_write_line(&m_out_cblank_func, 0);
483596
484597   // CURS = 0
485598   devcb_call_write_line(&m_out_curs_func, 0);
r9663r9664
499612   // 29 (WBEN) = 0
500613
501614   // 30 (SLG) = 0
502//   devcb_call_write_line(&m_out_slg_func, 0);
615   devcb_call_write_line(&m_out_slg_func, 0);
503616
504617   // 31 (SLD) = 0
505//   devcb_call_write_line(&m_out_sld_func, 0);
618   devcb_call_write_line(&m_out_sld_func, 0);
506619
507620   // 32 (LPSTB) = 0
508621}
r9663r9664
524637
525638void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
526639{
640   int x = m_screen->hpos();
641   int y = m_screen->vpos();
642
527643   switch (id)
528644   {
529645   case TIMER_HSYNC:
530      devcb_call_write_line(&m_out_hs_func, param);
646      m_hs = param;
647
648      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : HS %u\n", tag(), y, x, m_hs);
649
650      devcb_call_write_line(&m_out_hs_func, m_hs);
651
652      update_cblank_line();
653
531654      update_hsync_timer(param);
532655      break;
533656
534657   case TIMER_VSYNC:
658      m_vs = param;
659
660      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VS %u\n", tag(), y, x, m_vs);
661
535662      devcb_call_write_line(&m_out_vs_func, param);
663
664      if (m_vs)
665      {
666         // reset all other bits except Light Pen Update to logic 0
667         m_status &= STATUS_LIGHT_PEN_UPDATE;
668      }
669      else
670      {
671         trigger_interrupt(IE_VERTICAL_RETRACE);
672
673         update_cblank_line();
674      }
675
536676      update_vsync_timer(param);
537677      break;
538678
539679   case TIMER_VLT:
680      m_vlt = param;
681
682      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : VLT %u\n", tag(), y, x, m_vlt);
683
540684      devcb_call_write_line(&m_out_vlt_func, param);
685
541686      update_vlt_timer(param);
542687      break;
543688
544689   case TIMER_CURS:
690      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : CURS %u\n", tag(), y, x, param);
691
545692      devcb_call_write_line(&m_out_curs_func, param);
693
546694      update_curs_timer(param);
547695      break;
548696
549697   case TIMER_DRB:
698      m_drb = param;
699
700      if (LOG) logerror("CRT9007 '%s' y %03u x %04u : DRB %u\n", tag(), y, x, m_drb);
701
550702      devcb_call_write_line(&m_out_drb_func, param);
703
704      if (!m_drb && !DMA_DISABLE)
705      {
706         // start DMA burst sequence
707         m_dma_count = CHARACTERS_PER_DATA_ROW;
708         m_dma_burst = DMA_BURST_COUNT ? (DMA_BURST_COUNT * 4) : CHARACTERS_PER_DATA_ROW;
709         m_dma_delay = DMA_BURST_DELAY;
710         m_dmar = 1;
711
712         if (LOG) logerror("CRT9007 '%s' DMAR 1\n", tag());
713         devcb_call_write_line(&m_out_dmar_func, ASSERT_LINE);
714      }
715
551716      update_drb_timer(param);
552717      break;
718
719   case TIMER_DMA:
720      readbyte(AUXILIARY_ADDRESS_2);
721
722      update_dma_timer();
723      break;
553724   }
554725}
555726
r9663r9664
584755
585756   case 0x3a:
586757      data = m_status;
758
759      // reset interrupt pending bit
760      m_status &= ~STATUS_INTERRUPT_PENDING;
761      if (LOG) logerror("CRT9007 '%s' INT 0\n", tag());
762      devcb_call_write_line(&m_out_int_func, CLEAR_LINE);
587763      break;
588764
589765   case 0x3b:
r9663r9664
592768
593769   case 0x3c:
594770      data = HORIZONTAL_LIGHT_PEN;
771
772      // reset light pen update bit
773      m_status &= ~STATUS_LIGHT_PEN_UPDATE;
595774      break;
596775
597776   default:
r9663r9664
778957
779958WRITE_LINE_MEMBER( crt9007_device::ack_w )
780959{
781   // TODO
960   if (LOG) logerror("CRT9007 '%s' ACK: %u\n", tag(), state);
961
962   if (m_dmar && !m_ack && state)
963   {
964      // start DMA transfer
965      timer_adjust_oneshot(m_dma_timer, ATTOTIME_IN_HZ(clock()), 0);
966   }
967
968   m_ack = state;
782969}
783970
784971
r9663r9664
788975
789976WRITE_LINE_MEMBER( crt9007_device::lpstb_w )
790977{
791   // TODO
978   if (LOG) logerror("CRT9007 '%s' LPSTB: %u\n", tag(), state);
979
980   if (!m_lpstb && state)
981   {
982      // TODO latch current row/column position
983   }
984
985   m_lpstb = state;
792986}
793987
794988
src/mess/video/crt9007.h
r9663r9664
8282   devcb_write_line        out_vlt_func;
8383    devcb_write_line        out_curs_func;
8484    devcb_write_line        out_drb_func;
85    devcb_write_line        out_cblank_func;
8586
8687   devcb_write_line        out_slg_func;
8788   devcb_write_line        out_sld_func;
r9663r9664
151152   static const device_timer_id TIMER_VLT = 2;
152153   static const device_timer_id TIMER_CURS = 3;
153154   static const device_timer_id TIMER_DRB = 4;
155   static const device_timer_id TIMER_DMA = 5;
154156
155157   inline UINT8 readbyte(offs_t address);
156158
159   inline void trigger_interrupt(int line);
160   inline void update_cblank_line();
157161   inline void update_hsync_timer(int state);
158162   inline void update_vsync_timer(int state);
159163   inline void update_vlt_timer(int state);
160164   inline void update_curs_timer(int state);
161165   inline void update_drb_timer(int state);
166   inline void update_dma_timer();
162167
163168   inline void recompute_parameters();
164169
r9663r9664
169174   devcb_resolved_write_line   m_out_vlt_func;
170175   devcb_resolved_write_line   m_out_curs_func;
171176   devcb_resolved_write_line   m_out_drb_func;
177   devcb_resolved_write_line   m_out_cblank_func;
178   devcb_resolved_write_line   m_out_slg_func;
179   devcb_resolved_write_line   m_out_sld_func;
172180
173181   screen_device *m_screen;
174182
r9663r9664
182190   // runtime variables, do not state save
183191   int m_vsync_start;
184192   int m_vsync_end;
185   int m_vfp;
186193   int m_hsync_start;
187194   int m_hsync_end;
188   int m_hfp;
195   int m_vlt_start;
196   int m_vlt_end;
197   int m_vlt_bottom;
198   int m_drb_bottom;
199   int m_hs;
200   int m_vs;
201   int m_cblank;
189202   int m_vlt;
203   int m_drb;
190204   int m_wben;
205   int m_slg;
206   int m_sld;
207   int m_lpstb;
191208
209   // DMA
210   int m_dmar;
211   int m_ack;
212   int m_dma_count;
213   int m_dma_burst;
214   int m_dma_delay;
215
192216   // timers
193217   emu_timer *m_vsync_timer;
194218   emu_timer *m_hsync_timer;
195219   emu_timer *m_vlt_timer;
196220   emu_timer *m_curs_timer;
197221   emu_timer *m_drb_timer;
222   emu_timer *m_dma_timer;
198223
199224   const crt9007_device_config &m_config;
200225};
src/mess/drivers/tandy2k.c
r9663r9664
330330   AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8_LEGACY(I8259A_0_TAG, pic8259_r, pic8259_w, 0x00ff)
331331   AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8_LEGACY(I8259A_1_TAG, pic8259_r, pic8259_w, 0x00ff)
332332   AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8_LEGACY(I8272A_TAG, upd765_dack_r, upd765_dack_w, 0x00ff)
333   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_device, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
333   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_device, read, write, 0x00ff)// AM_WRITE8(addr_ctrl_w, 0xff00)
334334//  AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff)
335335//  AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w)
336336//  AM_RANGE(0x001a0, 0x001a0) AM_READ8(hires_plane_w, 0x00ff)
r9663r9664
538538   DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_vlt_w), // VLT
539539   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, cursor_w), // CURS
540540   DEVCB_DRIVER_LINE_MEMBER(tandy2k_state, vpac_drb_w), // DRB
541   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, retbl_w), // CBLANK
541542   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, slg_w), // SLG
542543   DEVCB_DEVICE_LINE_MEMBER(CRT9021B_TAG, crt9021_device, sld_w) // SLD
543544};

Previous 15994 Revisions Next


© 1998-2018 The MESS Team