Previous 15994 Revisions Next

r9644 Tuesday 23rd November, 2010 at 10:46:21 UTC by Curt Coder
[TANDY2K] Video WIP.
[src/mess/drivers]tandy2k.c
[src/mess/includes]tandy2k.h
[src/mess/video]crt9007.c crt9007.h

src/mess/video/crt9007.c
r9643r9644
1414    - interrupts
1515    - status register
1616    - reset
17    - DMA mode (currently forcing to non-DMA mode)
17   - non-DMA mode
18    - DMA mode
1819    - cursor/blank skew
1920    - sequential breaks
2021    - interlaced mode
r9643r9644
3334#include "emu.h"
3435#include "crt9007.h"
3536
36/***************************************************************************
37    PARAMETERS
38***************************************************************************/
3937
38
39//**************************************************************************
40//   MACROS / CONSTANTS
41//**************************************************************************
42
4043#define LOG 1
4144
4245#define HAS_VALID_PARAMETERS \
43   (crt9007->reg[0x00] && crt9007->reg[0x01] && crt9007->reg[0x07] && crt9007->reg[0x08] && crt9007->reg[0x09])
46   (m_reg[0x00] && m_reg[0x01] && m_reg[0x07] && m_reg[0x08] && m_reg[0x09])
4447
4548#define CHARACTERS_PER_HORIZONTAL_PERIOD \
46   crt9007->reg[0x00]
49   m_reg[0x00]
4750
4851#define CHARACTERS_PER_DATA_ROW \
49   (crt9007->reg[0x01] + 1)
52   (m_reg[0x01] + 1)
5053
5154#define HORIZONTAL_DELAY \
52   crt9007->reg[0x02]
55   m_reg[0x02]
5356
5457#define HORIZONTAL_SYNC_WIDTH \
55   crt9007->reg[0x03]
58   m_reg[0x03]
5659
5760#define VERTICAL_SYNC_WIDTH \
58   crt9007->reg[0x04]
61   m_reg[0x04]
5962
6063#define VERTICAL_DELAY \
61   (crt9007->reg[0x05] - 1)
64   (m_reg[0x05] - 1)
6265
6366#define PIN_CONFIGURATION \
64   (crt9007->reg[0x06] >> 6)
67   (m_reg[0x06] >> 6)
6568
6669#define CURSOR_SKEW \
67   ((crt9007->reg[0x06] >> 3) & 0x07)
70   ((m_reg[0x06] >> 3) & 0x07)
6871
6972#define BLANK_SKEW \
70   (crt9007->reg[0x06] & 0x07)
73   (m_reg[0x06] & 0x07)
7174
7275#define VISIBLE_DATA_ROWS_PER_FRAME \
73   (crt9007->reg[0x07] + 1)
76   (m_reg[0x07] + 1)
7477
7578#define SCAN_LINES_PER_DATA_ROW \
76   ((crt9007->reg[0x08] & 0x1f) + 1)
79   ((m_reg[0x08] & 0x1f) + 1)
7780
7881#define SCAN_LINES_PER_FRAME \
79   (((crt9007->reg[0x08] << 3) & 0x0700) | crt9007->reg[0x09])
82   (((m_reg[0x08] << 3) & 0x0700) | m_reg[0x09])
8083
8184#define DMA_BURST_COUNT \
82   (crt9007->reg[0x0a] & 0x0f)
85   (m_reg[0x0a] & 0x0f)
8386
8487#define DMA_BURST_DELAY \
85   ((crt9007->reg[0x0a] >> 4) & 0x07)
88   ((m_reg[0x0a] >> 4) & 0x07)
8689
8790#define DMA_DISABLE \
88   BIT(crt9007->reg[0x0a], 7)
91   BIT(m_reg[0x0a], 7)
8992
9093#define SINGLE_HEIGHT_CURSOR \
91   BIT(crt9007->reg[0x0b], 0)
94   BIT(m_reg[0x0b], 0)
9295
9396#define OPERATION_MODE \
94   ((crt9007->reg[0x0b] >> 1) & 0x07)
97   ((m_reg[0x0b] >> 1) & 0x07)
9598
9699#define INTERLACE_MODE \
97   ((crt9007->reg[0x0b] >> 4) & 0x03)
100   ((m_reg[0x0b] >> 4) & 0x03)
98101
99102#define PAGE_BLANK \
100   BIT(crt9007->reg[0x0b], 6)
103   BIT(m_reg[0x0b], 6)
101104
102105#define TABLE_START \
103   (((crt9007->reg[0x0d] << 8) & 0x3f00) | crt9007->reg[0x0c])
106   (((m_reg[0x0d] << 8) & 0x3f00) | m_reg[0x0c])
104107
105108#define ADDRESS_MODE \
106   ((crt9007->reg[0x0d] >> 6) & 0x03)
109   ((m_reg[0x0d] >> 6) & 0x03)
107110
108111#define AUXILIARY_ADDRESS_1 \
109   (((crt9007->reg[0x0f] << 8) & 0x3f00) | crt9007->reg[0x0e])
112   (((m_reg[0x0f] << 8) & 0x3f00) | m_reg[0x0e])
110113
111114#define ROW_ATTRIBUTES_1 \
112   ((crt9007->reg[0x0f] >> 6) & 0x03)
115   ((m_reg[0x0f] >> 6) & 0x03)
113116
114117#define SEQUENTIAL_BREAK_1 \
115   crt9007->reg[0x10]
118   m_reg[0x10]
116119
117120#define SEQUENTIAL_BREAK_2 \
118   crt9007->reg[0x12]
121   m_reg[0x12]
119122
120123#define DATA_ROW_START \
121   crt9007->reg[0x11]
124   m_reg[0x11]
122125
123126#define DATA_ROW_END \
124   crt9007->reg[0x12]
127   m_reg[0x12]
125128
126129#define AUXILIARY_ADDRESS_2 \
127   (((crt9007->reg[0x14] << 8) & 0x3f00) | crt9007->reg[0x13])
130   (((m_reg[0x14] << 8) & 0x3f00) | m_reg[0x13])
128131
129132#define ROW_ATTRIBUTES_2 \
130   ((crt9007->reg[0x14] >> 6) & 0x03)
133   ((m_reg[0x14] >> 6) & 0x03)
131134
132135#define SMOOTH_SCROLL_OFFSET \
133   ((crt9007->reg[0x17] >> 1) & 0x3f)
136   ((m_reg[0x17] >> 1) & 0x3f)
134137
135138#define SMOOTH_SCROLL_OFFSET_OVERFLOW \
136   BIT(crt9007->reg[0x17], 7)
139   BIT(m_reg[0x17], 7)
137140
138141#define VERTICAL_CURSOR \
139   crt9007->reg[0x18]
142   m_reg[0x18]
140143
141144#define HORIZONTAL_CURSOR \
142   crt9007->reg[0x19]
145   m_reg[0x19]
143146
144147#define FRAME_TIMER \
145   BIT(crt9007->reg[0x1a], 0)
148   BIT(m_reg[0x1a], 0)
146149
147150#define LIGHT_PEN_INTERRUPT \
148   BIT(crt9007->reg[0x1a], 5)
151   BIT(m_reg[0x1a], 5)
149152
150153#define VERTICAL_RETRACE_INTERRUPT \
151   BIT(crt9007->reg[0x1a], 6)
154   BIT(m_reg[0x1a], 6)
152155
153156#define VERTICAL_LIGHT_PEN \
154   crt9007->reg[0x3b]
157   m_reg[0x3b]
155158
156159#define HORIZONTAL_LIGHT_PEN \
157   crt9007->reg[0x3c]
160   m_reg[0x3c]
158161
162
163// interlace
159164enum
160165{
161166   NON_INTERLACED = 0,
r9643r9644
163168   NORMAL_VIDEO_INTERFACE,
164169};
165170
171
172// operation modes
166173enum
167174{
168175   OPERATION_MODE_REPETITIVE_MEMORY_ADDRESSING = 0,
r9643r9644
171178   OPERATION_MODE_ATTRIBUTE_ASSEMBLE = 7
172179};
173180
181
182// addressing modes
174183enum
175184{
176185   ADDRESS_MODE_SEQUENTIAL_ADDRESSING = 0,
r9643r9644
179188   ADDRESS_MODE_LINKED_LIST_ROW_TABLE
180189};
181190
182#define STATUS_INTERRUPT_PENDING   0x80
183#define STATUS_VERTICAL_RETRACE      0x40
184#define STATUS_LIGHT_PEN_UPDATE      0x20
185#define STATUS_ODD_EVEN            0x04
186#define STATUS_FRAME_TIMER_OCCURRED   0x01
187191
188/***************************************************************************
189    TYPE DEFINITIONS
190***************************************************************************/
192// status register bits
193const int STATUS_INTERRUPT_PENDING      = 0x80;
194const int STATUS_VERTICAL_RETRACE      = 0x40;
195const int STATUS_LIGHT_PEN_UPDATE      = 0x20;
196const int STATUS_ODD_EVEN            = 0x04;
197const int STATUS_FRAME_TIMER_OCCURRED   = 0x01;
191198
192typedef struct _crt9007_t crt9007_t;
193struct _crt9007_t
194{
195   devcb_resolved_write_line   out_int_func;
196   devcb_resolved_write_line   out_dmar_func;
197   devcb_resolved_write_line   out_hs_func;
198   devcb_resolved_write_line   out_vs_func;
199   devcb_resolved_read8      in_vd_func;
200199
201   crt9007_draw_scanline_func   draw_scanline_func;
202200
203   screen_device *screen;         /* screen */
201//**************************************************************************
202//  GLOBAL VARIABLES
203//**************************************************************************
204204
205   /* registers */
206   UINT8 reg[0x3d];
207   UINT8 status;
205// devices
206const device_type CRT9007 = crt9007_device_config::static_alloc_device_config;
208207
209   int disp;
210   int hpixels_per_column;
211208
212   /* runtime variables, do not state save */
213   int vsync_start;
214   int vsync_end;
215   int vfp;
216   int hsync_start;
217   int hsync_end;
218   int hfp;
209// default address map
210static ADDRESS_MAP_START( crt9007, 0, 8 )
211   AM_RANGE(0x0000, 0x3fff) AM_RAM
212ADDRESS_MAP_END
219213
220   /* timers */
221   emu_timer *vsync_timer;         /* vertical sync timer */
222   emu_timer *hsync_timer;         /* horizontal sync timer */
223};
224214
225/***************************************************************************
226    INLINE FUNCTIONS
227***************************************************************************/
228215
229INLINE crt9007_t *get_safe_token(running_device *device)
216//**************************************************************************
217//  DEVICE CONFIGURATION
218//**************************************************************************
219
220//-------------------------------------------------
221//  crt9007_device_config - constructor
222//-------------------------------------------------
223
224crt9007_device_config::crt9007_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
225   : device_config(mconfig, static_alloc_device_config, "SMC CRT9007", tag, owner, clock),
226     device_config_memory_interface(mconfig, *this),
227     m_space_config("videoram", ENDIANNESS_LITTLE, 8, 14, 0, NULL, *ADDRESS_MAP_NAME(crt9007))
230228{
231   assert(device != NULL);
232   return (crt9007_t *)downcast<legacy_device_base *>(device)->token();
233229}
234230
235INLINE const crt9007_interface *get_interface(running_device *device)
231
232//-------------------------------------------------
233//  static_alloc_device_config - allocate a new
234//  configuration object
235//-------------------------------------------------
236
237device_config *crt9007_device_config::static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock)
236238{
237   assert(device != NULL);
238   assert(device->type() == CRT9007);
239   return (const crt9007_interface *) device->baseconfig().static_config();
239   return global_alloc(crt9007_device_config(mconfig, tag, owner, clock));
240240}
241241
242/***************************************************************************
243    IMPLEMENTATION
244***************************************************************************/
245242
246/*-------------------------------------------------
247    update_vsync_timer -
248-------------------------------------------------*/
243//-------------------------------------------------
244//  alloc_device - allocate a new device object
245//-------------------------------------------------
249246
250static void update_vsync_timer(crt9007_t *crt9007, int state)
247device_t *crt9007_device_config::alloc_device(running_machine &machine) const
251248{
252   int next_y = state ? crt9007->vsync_start : crt9007->vsync_end;
249   return auto_alloc(&machine, crt9007_device(machine, *this));
250}
253251
254   attotime duration = crt9007->screen->time_until_pos(next_y, 0);
255252
256   timer_adjust_oneshot(crt9007->vsync_timer, duration, !state);
253//-------------------------------------------------
254//  memory_space_config - return a description of
255//  any address spaces owned by this device
256//-------------------------------------------------
257
258const address_space_config *crt9007_device_config::memory_space_config(int spacenum) const
259{
260   return (spacenum == 0) ? &m_space_config : NULL;
257261}
258262
259/*-------------------------------------------------
260    TIMER_CALLBACK( vsync_tick )
261-------------------------------------------------*/
262263
263static TIMER_CALLBACK( vsync_tick )
264//-------------------------------------------------
265//  device_config_complete - perform any
266//  operations now that the configuration is
267//  complete
268//-------------------------------------------------
269
270void crt9007_device_config::device_config_complete()
264271{
265   running_device *device = (running_device *)ptr;
266   crt9007_t *crt9007 = get_safe_token(device);
272   // inherit a copy of the static data
273   const crt9007_interface *intf = reinterpret_cast<const crt9007_interface *>(static_config());
274   if (intf != NULL)
275      *static_cast<crt9007_interface *>(this) = *intf;
267276
268   devcb_call_write_line(&crt9007->out_vs_func, param);
277   // or initialize to defaults if none provided
278   else
279   {
280      memset(&out_int_func, 0, sizeof(out_int_func));
281      memset(&out_dmar_func, 0, sizeof(out_dmar_func));
282      memset(&out_vs_func, 0, sizeof(out_vs_func));
283      memset(&out_hs_func, 0, sizeof(out_hs_func));
284      memset(&out_vlt_func, 0, sizeof(out_vlt_func));
285      memset(&out_curs_func, 0, sizeof(out_curs_func));
286      memset(&out_drb_func, 0, sizeof(out_drb_func));
287      memset(&out_slg_func, 0, sizeof(out_slg_func));
288      memset(&out_sld_func, 0, sizeof(out_sld_func));
289   }
290}
269291
270   update_vsync_timer(crt9007, param);
292
293
294//**************************************************************************
295//  INLINE HELPERS
296//**************************************************************************
297
298//-------------------------------------------------
299//  readbyte - read a byte at the given address
300//-------------------------------------------------
301
302inline UINT8 crt9007_device::readbyte(offs_t address)
303{
304   return space()->read_byte(address);
271305}
272306
273/*-------------------------------------------------
274    update_hsync_timer -
275-------------------------------------------------*/
276307
277static void update_hsync_timer(crt9007_t *crt9007, int state)
308//-------------------------------------------------
309//  update_hsync_timer -
310//-------------------------------------------------
311
312inline void crt9007_device::update_hsync_timer(int state)
278313{
279   int y = crt9007->screen->vpos();
314   int y = m_screen->vpos();
280315
281   int next_x = state ? crt9007->hsync_start : crt9007->hsync_end;
316   int next_x = state ? m_hsync_start : m_hsync_end;
282317   int next_y = (y + 1) % SCAN_LINES_PER_FRAME;
283318
284   attotime duration = crt9007->screen->time_until_pos(next_y, next_x);
319   attotime duration = m_screen->time_until_pos(next_y, next_x);
285320
286   timer_adjust_oneshot(crt9007->hsync_timer, duration, !state);
321   timer_adjust_oneshot(m_hsync_timer, duration, !state);
287322}
288323
289/*-------------------------------------------------
290    TIMER_CALLBACK( hsync_tick )
291-------------------------------------------------*/
292324
293static TIMER_CALLBACK( hsync_tick )
325//-------------------------------------------------
326//  update_vsync_timer -
327//-------------------------------------------------
328
329inline void crt9007_device::update_vsync_timer(int state)
294330{
295   running_device *device = (running_device *)ptr;
296   crt9007_t *crt9007 = get_safe_token(device);
331   int next_y = state ? m_vsync_start : m_vsync_end;
297332
298   devcb_call_write_line(&crt9007->out_hs_func, param);
333   attotime duration = m_screen->time_until_pos(next_y, 0);
299334
300   update_hsync_timer(crt9007, param);
335   timer_adjust_oneshot(m_vsync_timer, duration, !state);
301336}
302337
303/*-------------------------------------------------
304    recompute_parameters -
305-------------------------------------------------*/
306338
307static void recompute_parameters(running_device *device)
339//-------------------------------------------------
340//  update_vlt_timer -
341//-------------------------------------------------
342
343inline void crt9007_device::update_vlt_timer(int state)
308344{
309   crt9007_t *crt9007 = get_safe_token(device);
345   // TODO
346}
310347
311   /* check that necessary registers have been loaded */
348
349//-------------------------------------------------
350//  update_curs_timer -
351//-------------------------------------------------
352
353inline void crt9007_device::update_curs_timer(int state)
354{
355   // TODO
356}
357
358
359//-------------------------------------------------
360//  update_drb_timer -
361//-------------------------------------------------
362
363inline void crt9007_device::update_drb_timer(int state)
364{
365   // TODO
366}
367
368
369//-------------------------------------------------
370//  recompute_parameters -
371//-------------------------------------------------
372
373inline void crt9007_device::recompute_parameters()
374{
375   // check that necessary registers have been loaded
312376   if (!HAS_VALID_PARAMETERS) return;
313377
314   int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * crt9007->hpixels_per_column;
378   int horiz_pix_total = CHARACTERS_PER_HORIZONTAL_PERIOD * m_hpixels_per_column;
315379   int vert_pix_total = SCAN_LINES_PER_FRAME;
316380
317   attoseconds_t refresh = HZ_TO_ATTOSECONDS(device->clock()) * horiz_pix_total * vert_pix_total;
381   attoseconds_t refresh = HZ_TO_ATTOSECONDS(clock()) * horiz_pix_total * vert_pix_total;
318382
319   crt9007->hsync_start = (CHARACTERS_PER_HORIZONTAL_PERIOD - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column;
320   crt9007->hsync_end = 0;
321   crt9007->hfp = (HORIZONTAL_DELAY - HORIZONTAL_SYNC_WIDTH) * crt9007->hpixels_per_column;
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;
322386
323   crt9007->vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH;
324   crt9007->vsync_end = 0;
325   crt9007->vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH;
387   m_vsync_start = SCAN_LINES_PER_FRAME - VERTICAL_SYNC_WIDTH;
388   m_vsync_end = 0;
389   m_vfp = VERTICAL_DELAY - VERTICAL_SYNC_WIDTH;
326390
327391   rectangle visarea;
328392
329   visarea.min_x = crt9007->hsync_end;
330   visarea.max_x = crt9007->hsync_start - 1;
393   visarea.min_x = m_hsync_end;
394   visarea.max_x = m_hsync_start - 1;
331395
332   visarea.min_y = crt9007->vsync_end;
333   visarea.max_y = crt9007->vsync_start - 1;
396   visarea.min_y = m_vsync_end;
397   visarea.max_y = m_vsync_start - 1;
334398
335399   if (LOG)
336400   {
337      logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", device->tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
338      logerror("CRT9007 '%s' Visible Area: (%u, %u) - (%u, %u)\n", device->tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
401      logerror("CRT9007 '%s' Screen: %u x %u @ %f Hz\n", tag(), horiz_pix_total, vert_pix_total, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
402      logerror("CRT9007 '%s' Visible Area: (%u, %u) - (%u, %u)\n", tag(), visarea.min_x, visarea.min_y, visarea.max_x, visarea.max_y);
339403   }
340404
341   crt9007->screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
405   m_screen->configure(horiz_pix_total, vert_pix_total, visarea, refresh);
342406
343   update_hsync_timer(crt9007, 1);
344   update_vsync_timer(crt9007, 1);
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);
345412}
346413
347/*-------------------------------------------------
348    crt9007_r - register read
349-------------------------------------------------*/
350414
351READ8_DEVICE_HANDLER( crt9007_r )
415//**************************************************************************
416//  LIVE DEVICE
417//**************************************************************************
418
419//-------------------------------------------------
420//  crt9007_device - constructor
421//-------------------------------------------------
422
423crt9007_device::crt9007_device(running_machine &_machine, const crt9007_device_config &config)
424    : device_t(_machine, config),
425     device_memory_interface(_machine, config, *this),
426      m_config(config)
352427{
353   crt9007_t *crt9007 = get_safe_token(device);
428   for (int i = 0; i < 0x3d; i++)
429      m_reg[i] = 0;
430}
354431
432
433//-------------------------------------------------
434//  device_start - device-specific startup
435//-------------------------------------------------
436
437void crt9007_device::device_start()
438{
439   // allocate timers
440   m_hsync_timer = device_timer_alloc(*this, TIMER_HSYNC);
441   m_vsync_timer = device_timer_alloc(*this, TIMER_VSYNC);
442   m_vlt_timer = device_timer_alloc(*this, TIMER_VLT);
443   m_curs_timer = device_timer_alloc(*this, TIMER_CURS);
444   m_drb_timer = device_timer_alloc(*this, TIMER_DRB);
445
446   // resolve callbacks
447   devcb_resolve_write_line(&m_out_int_func, &m_config.out_int_func, this);
448   devcb_resolve_write_line(&m_out_dmar_func, &m_config.out_dmar_func, this);
449   devcb_resolve_write_line(&m_out_hs_func, &m_config.out_hs_func, this);
450   devcb_resolve_write_line(&m_out_vs_func, &m_config.out_vs_func, this);
451   devcb_resolve_write_line(&m_out_vlt_func, &m_config.out_vlt_func, this);
452   devcb_resolve_write_line(&m_out_curs_func, &m_config.out_curs_func, this);
453   devcb_resolve_write_line(&m_out_drb_func, &m_config.out_drb_func, this);
454
455   // get the screen device
456   m_screen = machine->device<screen_device>(m_config.screen_tag);
457   assert(m_screen != NULL);
458
459   // set horizontal pixels per column
460   m_hpixels_per_column = m_config.hpixels_per_column;
461
462   // register for state saving
463//   state_save_register_device_item(this, 0, );
464}
465
466
467//-------------------------------------------------
468//  device_reset - device-specific reset
469//-------------------------------------------------
470
471void crt9007_device::device_reset()
472{
473   m_disp = 0;
474
475   // HS = 1
476   devcb_call_write_line(&m_out_hs_func, 1);
477
478   // VS = 1
479   devcb_call_write_line(&m_out_vs_func, 1);
480
481   // CBLANK = 1
482//   devcb_call_write_line(&m_out_cblank_func, 0);
483
484   // CURS = 0
485   devcb_call_write_line(&m_out_curs_func, 0);
486
487   // VLT = 0
488   devcb_call_write_line(&m_out_vlt_func, 0);
489
490   // DRB = 1
491   devcb_call_write_line(&m_out_drb_func, 1);
492
493   // INT = 0
494   devcb_call_write_line(&m_out_int_func, CLEAR_LINE);
495
496   // 28 (DMAR) = 0
497   devcb_call_write_line(&m_out_dmar_func, CLEAR_LINE);
498
499   // 29 (WBEN) = 0
500
501   // 30 (SLG) = 0
502//   devcb_call_write_line(&m_out_slg_func, 0);
503
504   // 31 (SLD) = 0
505//   devcb_call_write_line(&m_out_sld_func, 0);
506
507   // 32 (LPSTB) = 0
508}
509
510
511//-------------------------------------------------
512//  device_clock_changed - handle clock change
513//-------------------------------------------------
514
515void crt9007_device::device_clock_changed()
516{
517   recompute_parameters();
518}
519
520
521//-------------------------------------------------
522//  device_timer - handle timer events
523//-------------------------------------------------
524
525void crt9007_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
526{
527   switch (id)
528   {
529   case TIMER_HSYNC:
530      devcb_call_write_line(&m_out_hs_func, param);
531      update_hsync_timer(param);
532      break;
533
534   case TIMER_VSYNC:
535      devcb_call_write_line(&m_out_vs_func, param);
536      update_vsync_timer(param);
537      break;
538
539   case TIMER_VLT:
540      devcb_call_write_line(&m_out_vlt_func, param);
541      update_vlt_timer(param);
542      break;
543
544   case TIMER_CURS:
545      devcb_call_write_line(&m_out_curs_func, param);
546      update_curs_timer(param);
547      break;
548
549   case TIMER_DRB:
550      devcb_call_write_line(&m_out_drb_func, param);
551      update_drb_timer(param);
552      break;
553   }
554}
555
556
557//-------------------------------------------------
558//  read - register read
559//-------------------------------------------------
560
561READ8_MEMBER( crt9007_device::read )
562{
355563   UINT8 data = 0;
356564
357565   switch (offset)
358566   {
359567   case 0x15:
360      crt9007->disp = 1;
361      if (LOG) logerror("CRT9007 '%s' Start\n", device->tag());
568      if (LOG) logerror("CRT9007 '%s' Start\n", tag());
569      m_disp = 1;
362570      break;
363571
364572   case 0x16:
365      crt9007->disp = 0;
366      if (LOG) logerror("CRT9007 '%s' Reset\n", device->tag());
573      if (LOG) logerror("CRT9007 '%s' Reset\n", tag());
574      device_reset();
367575      break;
368576
369577   case 0x38:
r9643r9644
375583      break;
376584
377585   case 0x3a:
378      data = crt9007->status;
586      data = m_status;
379587      break;
380588
381589   case 0x3b:
r9643r9644
387595      break;
388596
389597   default:
390      logerror("CRT9007 '%s' Read from Invalid Register: %02x!\n", device->tag(), offset);
598      logerror("CRT9007 '%s' Read from Invalid Register: %02x!\n", tag(), offset);
391599   }
392600
393601   return data;
394602}
395603
396/*-------------------------------------------------
397    crt9007_w - register write
398-------------------------------------------------*/
399604
400WRITE8_DEVICE_HANDLER( crt9007_w )
605//-------------------------------------------------
606//  write - register write
607//-------------------------------------------------
608
609WRITE8_MEMBER( crt9007_device::write )
401610{
402   crt9007_t *crt9007 = get_safe_token(device);
611   m_reg[offset] = data;
403612
404   crt9007->reg[offset] = data;
405
406613   switch (offset)
407614   {
408615   case 0x00:
409      recompute_parameters(device);
410      if (LOG) logerror("CRT9007 '%s' Characters per Horizontal Period: %u\n", device->tag(), CHARACTERS_PER_HORIZONTAL_PERIOD);
616      recompute_parameters();
617      if (LOG) logerror("CRT9007 '%s' Characters per Horizontal Period: %u\n", tag(), CHARACTERS_PER_HORIZONTAL_PERIOD);
411618      break;
412619
413620   case 0x01:
414      recompute_parameters(device);
415      if (LOG) logerror("CRT9007 '%s' Characters per Data Row: %u\n", device->tag(), CHARACTERS_PER_DATA_ROW);
621      recompute_parameters();
622      if (LOG) logerror("CRT9007 '%s' Characters per Data Row: %u\n", tag(), CHARACTERS_PER_DATA_ROW);
416623      break;
417624
418625   case 0x02:
419      recompute_parameters(device);
420      if (LOG) logerror("CRT9007 '%s' Horizontal Delay: %u\n", device->tag(), HORIZONTAL_DELAY);
626      recompute_parameters();
627      if (LOG) logerror("CRT9007 '%s' Horizontal Delay: %u\n", tag(), HORIZONTAL_DELAY);
421628      break;
422629
423630   case 0x03:
424      recompute_parameters(device);
425      if (LOG) logerror("CRT9007 '%s' Horizontal Sync Width: %u\n", device->tag(), HORIZONTAL_SYNC_WIDTH);
631      recompute_parameters();
632      if (LOG) logerror("CRT9007 '%s' Horizontal Sync Width: %u\n", tag(), HORIZONTAL_SYNC_WIDTH);
426633      break;
427634
428635   case 0x04:
429      recompute_parameters(device);
430      if (LOG) logerror("CRT9007 '%s' Vertical Sync Width: %u\n", device->tag(), VERTICAL_SYNC_WIDTH);
636      recompute_parameters();
637      if (LOG) logerror("CRT9007 '%s' Vertical Sync Width: %u\n", tag(), VERTICAL_SYNC_WIDTH);
431638      break;
432639
433640   case 0x05:
434      recompute_parameters(device);
435      if (LOG) logerror("CRT9007 '%s' Vertical Delay: %u\n", device->tag(), VERTICAL_DELAY);
641      recompute_parameters();
642      if (LOG) logerror("CRT9007 '%s' Vertical Delay: %u\n", tag(), VERTICAL_DELAY);
436643      break;
437644
438645   case 0x06:
439      recompute_parameters(device);
646      recompute_parameters();
440647      if (LOG)
441648      {
442         logerror("CRT9007 '%s' Pin Configuration: %u\n", device->tag(), PIN_CONFIGURATION);
443         logerror("CRT9007 '%s' Cursor Skew: %u\n", device->tag(), CURSOR_SKEW);
444         logerror("CRT9007 '%s' Blank Skew: %u\n", device->tag(), BLANK_SKEW);
649         logerror("CRT9007 '%s' Pin Configuration: %u\n", tag(), PIN_CONFIGURATION);
650         logerror("CRT9007 '%s' Cursor Skew: %u\n", tag(), CURSOR_SKEW);
651         logerror("CRT9007 '%s' Blank Skew: %u\n", tag(), BLANK_SKEW);
445652      }
446653      break;
447654
448655   case 0x07:
449      recompute_parameters(device);
450      if (LOG) logerror("CRT9007 '%s' Visible Data Rows per Frame: %u\n", device->tag(), VISIBLE_DATA_ROWS_PER_FRAME);
656      recompute_parameters();
657      if (LOG) logerror("CRT9007 '%s' Visible Data Rows per Frame: %u\n", tag(), VISIBLE_DATA_ROWS_PER_FRAME);
451658      break;
452659
453660   case 0x08:
454      recompute_parameters(device);
455      if (LOG) logerror("CRT9007 '%s' Scan Lines per Data Row: %u\n", device->tag(), SCAN_LINES_PER_DATA_ROW);
661      recompute_parameters();
662      if (LOG) logerror("CRT9007 '%s' Scan Lines per Data Row: %u\n", tag(), SCAN_LINES_PER_DATA_ROW);
456663      break;
457664
458665   case 0x09:
459      recompute_parameters(device);
460      if (LOG) logerror("CRT9007 '%s' Scan Lines per Frame: %u\n", device->tag(), SCAN_LINES_PER_FRAME);
666      recompute_parameters();
667      if (LOG) logerror("CRT9007 '%s' Scan Lines per Frame: %u\n", tag(), SCAN_LINES_PER_FRAME);
461668      break;
462669
463670   case 0x0a:
464671      if (LOG)
465672      {
466         logerror("CRT9007 '%s' DMA Burst Count: %u\n", device->tag(), DMA_BURST_COUNT);
467         logerror("CRT9007 '%s' DMA Burst Delay: %u\n", device->tag(), DMA_BURST_DELAY);
468         logerror("CRT9007 '%s' DMA Disable: %u\n", device->tag(), DMA_DISABLE);
673         logerror("CRT9007 '%s' DMA Burst Count: %u\n", tag(), DMA_BURST_COUNT);
674         logerror("CRT9007 '%s' DMA Burst Delay: %u\n", tag(), DMA_BURST_DELAY);
675         logerror("CRT9007 '%s' DMA Disable: %u\n", tag(), DMA_DISABLE);
469676      }
470677      break;
471678
472679   case 0x0b:
473680      if (LOG)
474681      {
475         logerror("CRT9007 '%s' %s Height Cursor\n", device->tag(), SINGLE_HEIGHT_CURSOR ? "Single" : "Double");
476         logerror("CRT9007 '%s' Operation Mode: %u\n", device->tag(), OPERATION_MODE);
477         logerror("CRT9007 '%s' Interlace Mode: %u\n", device->tag(), INTERLACE_MODE);
478         logerror("CRT9007 '%s' %s Mechanism\n", device->tag(), PAGE_BLANK ? "Page Blank" : "Smooth Scroll");
682         logerror("CRT9007 '%s' %s Height Cursor\n", tag(), SINGLE_HEIGHT_CURSOR ? "Single" : "Double");
683         logerror("CRT9007 '%s' Operation Mode: %u\n", tag(), OPERATION_MODE);
684         logerror("CRT9007 '%s' Interlace Mode: %u\n", tag(), INTERLACE_MODE);
685         logerror("CRT9007 '%s' %s Mechanism\n", tag(), PAGE_BLANK ? "Page Blank" : "Smooth Scroll");
479686      }
480687      break;
481688
r9643r9644
485692   case 0x0d:
486693      if (LOG)
487694      {
488         logerror("CRT9007 '%s' Table Start Register: %04x\n", device->tag(), TABLE_START);
489         logerror("CRT9007 '%s' Address Mode: %u\n", device->tag(), ADDRESS_MODE);
695         logerror("CRT9007 '%s' Table Start Register: %04x\n", tag(), TABLE_START);
696         logerror("CRT9007 '%s' Address Mode: %u\n", tag(), ADDRESS_MODE);
490697      }
491698      break;
492699
r9643r9644
496703   case 0x0f:
497704      if (LOG)
498705      {
499         logerror("CRT9007 '%s' Auxialiary Address Register 1: %04x\n", device->tag(), AUXILIARY_ADDRESS_1);
500         logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag(), ROW_ATTRIBUTES_1);
706         logerror("CRT9007 '%s' Auxialiary Address Register 1: %04x\n", tag(), AUXILIARY_ADDRESS_1);
707         logerror("CRT9007 '%s' Row Attributes: %u\n", tag(), ROW_ATTRIBUTES_1);
501708      }
502709      break;
503710
504711   case 0x10:
505      if (LOG) logerror("CRT9007 '%s' Sequential Break Register 1: %u\n", device->tag(), SEQUENTIAL_BREAK_1);
712      if (LOG) logerror("CRT9007 '%s' Sequential Break Register 1: %u\n", tag(), SEQUENTIAL_BREAK_1);
506713      break;
507714
508715   case 0x11:
509      if (LOG) logerror("CRT9007 '%s' Data Row Start Register: %u\n", device->tag(), DATA_ROW_START);
716      if (LOG) logerror("CRT9007 '%s' Data Row Start Register: %u\n", tag(), DATA_ROW_START);
510717      break;
511718
512719   case 0x12:
513      if (LOG) logerror("CRT9007 '%s' Data Row End/Sequential Break Register 2: %u\n", device->tag(), SEQUENTIAL_BREAK_2);
720      if (LOG) logerror("CRT9007 '%s' Data Row End/Sequential Break Register 2: %u\n", tag(), SEQUENTIAL_BREAK_2);
514721      break;
515722
516723   case 0x13:
r9643r9644
519726   case 0x14:
520727      if (LOG)
521728      {
522         logerror("CRT9007 '%s' Auxiliary Address Register 2: %04x\n", device->tag(), AUXILIARY_ADDRESS_2);
523         logerror("CRT9007 '%s' Row Attributes: %u\n", device->tag(), ROW_ATTRIBUTES_2);
729         logerror("CRT9007 '%s' Auxiliary Address Register 2: %04x\n", tag(), AUXILIARY_ADDRESS_2);
730         logerror("CRT9007 '%s' Row Attributes: %u\n", tag(), ROW_ATTRIBUTES_2);
524731      }
525732      break;
526733
527734   case 0x15:
528      crt9007->disp = 1;
529      if (LOG) logerror("CRT9007 '%s' Start\n", device->tag());
735      if (LOG) logerror("CRT9007 '%s' Start\n", tag());
736      m_disp = 1;
530737      break;
531738
532739   case 0x16:
533      crt9007->disp = 0;
534      if (LOG) logerror("CRT9007 '%s' Reset\n", device->tag());
740      if (LOG) logerror("CRT9007 '%s' Reset\n", tag());
741      device_reset();
535742      break;
536743
537744   case 0x17:
538745      if (LOG)
539746      {
540         logerror("CRT9007 '%s' Smooth Scroll Offset: %u\n", device->tag(), SMOOTH_SCROLL_OFFSET);
541         logerror("CRT9007 '%s' Smooth Scroll Offset Overflow: %u\n", device->tag(), SMOOTH_SCROLL_OFFSET_OVERFLOW);
747         logerror("CRT9007 '%s' Smooth Scroll Offset: %u\n", tag(), SMOOTH_SCROLL_OFFSET);
748         logerror("CRT9007 '%s' Smooth Scroll Offset Overflow: %u\n", tag(), SMOOTH_SCROLL_OFFSET_OVERFLOW);
542749      }
543750      break;
544751
545752   case 0x18:
546      if (LOG) logerror("CRT9007 '%s' Vertical Cursor Register: %u\n", device->tag(), VERTICAL_CURSOR);
753      if (LOG) logerror("CRT9007 '%s' Vertical Cursor Register: %u\n", tag(), VERTICAL_CURSOR);
547754      break;
548755
549756   case 0x19:
550      if (LOG) logerror("CRT9007 '%s' Horizontal Cursor Register: %u\n", device->tag(), HORIZONTAL_CURSOR);
757      if (LOG) logerror("CRT9007 '%s' Horizontal Cursor Register: %u\n", tag(), HORIZONTAL_CURSOR);
551758      break;
552759
553760   case 0x1a:
554761      if (LOG)
555762      {
556         logerror("CRT9007 '%s' Frame Timer: %u\n", device->tag(), FRAME_TIMER);
557         logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", device->tag(), LIGHT_PEN_INTERRUPT);
558         logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", device->tag(), VERTICAL_RETRACE_INTERRUPT);
763         logerror("CRT9007 '%s' Frame Timer: %u\n", tag(), FRAME_TIMER);
764         logerror("CRT9007 '%s' Light Pen Interrupt: %u\n", tag(), LIGHT_PEN_INTERRUPT);
765         logerror("CRT9007 '%s' Vertical Retrace Interrupt: %u\n", tag(), VERTICAL_RETRACE_INTERRUPT);
559766      }
560767      break;
561768
562769   default:
563      logerror("CRT9007 '%s' Write to Invalid Register: %02x!\n", device->tag(), offset);
770      logerror("CRT9007 '%s' Write to Invalid Register: %02x!\n", tag(), offset);
564771   }
565772}
566773
567/*-------------------------------------------------
568    crt9007_ack_w - DMA acknowledge
569-------------------------------------------------*/
570774
571WRITE8_DEVICE_HANDLER( crt9007_ack_w )
572{
573}
775//-------------------------------------------------
776//  ack_w - DMA acknowledge
777//-------------------------------------------------
574778
575/*-------------------------------------------------
576    crt9007_lpstb_w - light pen strobe
577-------------------------------------------------*/
578
579WRITE_LINE_DEVICE_HANDLER( crt9007_lpstb_w )
779WRITE_LINE_MEMBER( crt9007_device::ack_w )
580780{
781   // TODO
581782}
582783
583/*-------------------------------------------------
584    crt9007_set_clock - set device clock
585-------------------------------------------------*/
586784
587void crt9007_set_clock(running_device *device, UINT32 clock)
588{
589   device->set_unscaled_clock(clock);
590   recompute_parameters(device);
591}
785//-------------------------------------------------
786//  lpstb_w - light pen strobe
787//-------------------------------------------------
592788
593/*-------------------------------------------------
594    crt9007_set_hpixels_per_column
595-------------------------------------------------*/
596
597void crt9007_set_hpixels_per_column(running_device *device, int hpixels_per_column)
789WRITE_LINE_MEMBER( crt9007_device::lpstb_w )
598790{
599   crt9007_t *crt9007 = get_safe_token(device);
600
601   crt9007->hpixels_per_column = hpixels_per_column;
602   recompute_parameters(device);
791   // TODO
603792}
604793
605/*-------------------------------------------------
606    crt9007_update - update screen
607-------------------------------------------------*/
608794
609void crt9007_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect)
610{
611   crt9007_t *crt9007 = get_safe_token(device);
795//-------------------------------------------------
796//  set_hpixels_per_column -
797//-------------------------------------------------
612798
613   if (crt9007->disp && HAS_VALID_PARAMETERS)
614   {
615      int min_y = crt9007->vfp;
616      int max_y = min_y + (VISIBLE_DATA_ROWS_PER_FRAME * SCAN_LINES_PER_DATA_ROW);
617
618      for (int y = min_y; y < max_y; y++)
619      {
620         int sl = (y - min_y) % SCAN_LINES_PER_DATA_ROW;
621         int sy = (y - min_y) / SCAN_LINES_PER_DATA_ROW;
622         int cursor_x = (sy == VERTICAL_CURSOR) ? HORIZONTAL_CURSOR : -1;
623         UINT16 addr = TABLE_START + (sy * CHARACTERS_PER_DATA_ROW);
624//          UINT8 data = devcb_call_read8(&crt9007->in_vd_func, addr);
625
626         crt9007->draw_scanline_func(device, bitmap, cliprect, addr, sl, 0, y, crt9007->hfp, CHARACTERS_PER_DATA_ROW, cursor_x);
627
628         addr++;
629      }
630   }
631   else
632   {
633      bitmap_fill(bitmap, cliprect, get_black_pen(device->machine));
634   }
635}
636
637/*-------------------------------------------------
638    DEVICE_START( crt9007 )
639-------------------------------------------------*/
640
641static DEVICE_START( crt9007 )
799void crt9007_device::set_hpixels_per_column(int hpixels_per_column)
642800{
643   crt9007_t *crt9007 = (crt9007_t *)downcast<legacy_device_base *>(device)->token();
644   const crt9007_interface *intf = get_interface(device);
645
646   /* resolve callbacks */
647   devcb_resolve_write_line(&crt9007->out_int_func, &intf->out_int_func, device);
648   devcb_resolve_write_line(&crt9007->out_dmar_func, &intf->out_dmar_func, device);
649   devcb_resolve_write_line(&crt9007->out_hs_func, &intf->out_hs_func, device);
650   devcb_resolve_write_line(&crt9007->out_vs_func, &intf->out_vs_func, device);
651   devcb_resolve_read8(&crt9007->in_vd_func, &intf->in_vd_func, device);
652
653   crt9007->draw_scanline_func = intf->draw_scanline_func;
654   assert(crt9007->draw_scanline_func != NULL);
655
656   /* get the screen device */
657   crt9007->screen = device->machine->device<screen_device>(intf->screen_tag);
658   assert(crt9007->screen != NULL);
659
660   /* set horizontal pixels per column */
661   crt9007->hpixels_per_column = intf->hpixels_per_column;
662
663   /* create the timers */
664   crt9007->vsync_timer = timer_alloc(device->machine, vsync_tick, (void *)device);
665   crt9007->hsync_timer = timer_alloc(device->machine, hsync_tick, (void *)device);
666
667   /* register for state saving */
668//  state_save_register_device_item(device, 0, crt9007->);
801   m_hpixels_per_column = hpixels_per_column;
802   recompute_parameters();
669803}
670
671/*-------------------------------------------------
672    DEVICE_RESET( crt9007 )
673-------------------------------------------------*/
674
675static DEVICE_RESET( crt9007 )
676{
677//  crt9007_t *crt9007 = (crt9007_t *)downcast<legacy_device_base *>(device)->token();
678}
679
680/*-------------------------------------------------
681    DEVICE_GET_INFO( crt9007 )
682-------------------------------------------------*/
683
684DEVICE_GET_INFO( crt9007 )
685{
686   switch (state)
687   {
688      /* --- the following bits of info are returned as 64-bit signed integers --- */
689      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
690      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(crt9007_t);            break;
691
692      /* --- the following bits of info are returned as pointers to data or functions --- */
693      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(crt9007);   break;
694      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
695      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(crt9007);   break;
696
697      /* --- the following bits of info are returned as NULL-terminated strings --- */
698      case DEVINFO_STR_NAME:                     strcpy(info->s, "SMC CRT9007");            break;
699      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "SMC CRT9007");            break;
700      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
701      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
702      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");   break;
703   }
704}
705
706DEFINE_LEGACY_DEVICE(CRT9007, crt9007);
src/mess/video/crt9007.h
r9643r9644
3030
3131**********************************************************************/
3232
33#pragma once
34
3335#ifndef __CRT9007__
3436#define __CRT9007__
3537
3638#include "emu.h"
3739
38/***************************************************************************
39    MACROS / CONSTANTS
40***************************************************************************/
4140
42DECLARE_LEGACY_DEVICE(CRT9007, crt9007);
4341
44#define MDRV_CRT9007_ADD(_tag, _clock, _config) \
45   MDRV_DEVICE_ADD((_tag), CRT9007, _clock)   \
46   MDRV_DEVICE_CONFIG(_config)
42//**************************************************************************
43//   MACROS / CONSTANTS
44//**************************************************************************
4745
46
47
48
49//**************************************************************************
50//  INTERFACE CONFIGURATION MACROS
51//**************************************************************************
52
53#define MDRV_CRT9007_ADD(_tag, _clock, _config, _map) \
54   MDRV_DEVICE_ADD(_tag, CRT9007, _clock) \
55   MDRV_DEVICE_CONFIG(_config) \
56   MDRV_DEVICE_ADDRESS_MAP(0, _map)
57
58
4859#define CRT9007_INTERFACE(name) \
4960   const crt9007_interface (name) =
5061
51/***************************************************************************
52    TYPE DEFINITIONS
53***************************************************************************/
5462
55typedef void (*crt9007_draw_scanline_func)(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, UINT16 va, UINT8 sl, UINT8 data, int y, int x, int x_count, int cursor_x);
56#define CRT9007_DRAW_SCANLINE(name) void name(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, UINT16 va, UINT8 sl, UINT8 data, int y, int x, int x_count, int cursor_x)
5763
58typedef struct _crt9007_interface crt9007_interface;
59struct _crt9007_interface
64//**************************************************************************
65//   TYPE DEFINITIONS
66//**************************************************************************
67
68
69// ======================> crt9007_interface
70
71struct crt9007_interface
6072{
6173   const char *screen_tag;      /* screen we are acting on */
6274   int hpixels_per_column;      /* number of pixels per video memory address */
6375
64   crt9007_draw_scanline_func   draw_scanline_func;
65
6676   devcb_write_line      out_int_func;
6777   devcb_write_line      out_dmar_func;
6878
79   devcb_write_line      out_vs_func;
6980   devcb_write_line      out_hs_func;
70   devcb_write_line      out_vs_func;
71/*
72    devcb_write_line        out_cblank_func;
73    devcb_write_line        out_vblank_func;
7481
75    devcb_write_line        out_vlt_func;
82   devcb_write_line        out_vlt_func;
7683    devcb_write_line        out_curs_func;
7784    devcb_write_line        out_drb_func;
7885
79    devcb_write_line        out_slg_func;
80    devcb_write_line        out_sld_func;
81*/
82   devcb_read8            in_vd_func;
83   devcb_write8         out_vd_func;
86   devcb_write_line        out_slg_func;
87   devcb_write_line        out_sld_func;
8488};
8589
86/***************************************************************************
87    PROTOTYPES
88***************************************************************************/
8990
90/* register access */
91READ8_DEVICE_HANDLER( crt9007_r );
92WRITE8_DEVICE_HANDLER( crt9007_w );
9391
94/* DMA acknowledge */
95WRITE8_DEVICE_HANDLER( crt9007_ack_w );
92// ======================> crt9007_device_config
9693
97/* light pen strobe */
98WRITE_LINE_DEVICE_HANDLER( crt9007_lpstb_w );
94class crt9007_device_config :   public device_config,
95                        public device_config_memory_interface,
96                                public crt9007_interface
97{
98    friend class crt9007_device;
9999
100/* set the clock of the chip */
101void crt9007_set_clock(running_device *device, UINT32 clock);
100    // construction/destruction
101    crt9007_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
102102
103/* set number of pixels per video memory address */
104void crt9007_set_hpixels_per_column(running_device *device, int hpixels_per_column);
103public:
104    // allocators
105    static device_config *static_alloc_device_config(const machine_config &mconfig, const char *tag, const device_config *owner, UINT32 clock);
106    virtual device_t *alloc_device(running_machine &machine) const;
105107
106/* screen update */
107void crt9007_update(running_device *device, bitmap_t *bitmap, const rectangle *cliprect);
108protected:
109   // device_config overrides
110   virtual void device_config_complete();
108111
112   // device_config_memory_interface overrides
113   virtual const address_space_config *memory_space_config(int spacenum = 0) const;
114
115    // address space configurations
116   const address_space_config      m_space_config;
117};
118
119
120
121// ======================> crt9007_device
122
123class crt9007_device :   public device_t,
124                  public device_memory_interface
125{
126    friend class crt9007_device_config;
127
128    // construction/destruction
129    crt9007_device(running_machine &_machine, const crt9007_device_config &_config);
130
131public:
132    DECLARE_READ8_MEMBER( read );
133    DECLARE_WRITE8_MEMBER( write );
134   DECLARE_WRITE_LINE_MEMBER( ack_w );
135   DECLARE_WRITE_LINE_MEMBER( lpstb_w );
136
137   void set_hpixels_per_column(int hpixels_per_column);
138
139protected:
140    // device-level overrides
141    virtual void device_start();
142    virtual void device_reset();
143   virtual void device_clock_changed();
144   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
145
146private:
147   static const device_timer_id TIMER_HSYNC = 0;
148   static const device_timer_id TIMER_VSYNC = 1;
149   static const device_timer_id TIMER_VLT = 2;
150   static const device_timer_id TIMER_CURS = 3;
151   static const device_timer_id TIMER_DRB = 4;
152
153   inline UINT8 readbyte(offs_t address);
154
155   inline void update_hsync_timer(int state);
156   inline void update_vsync_timer(int state);
157   inline void update_vlt_timer(int state);
158   inline void update_curs_timer(int state);
159   inline void update_drb_timer(int state);
160
161   inline void recompute_parameters();
162
163   devcb_resolved_write_line   m_out_int_func;
164   devcb_resolved_write_line   m_out_dmar_func;
165   devcb_resolved_write_line   m_out_hs_func;
166   devcb_resolved_write_line   m_out_vs_func;
167   devcb_resolved_write_line   m_out_vlt_func;
168   devcb_resolved_write_line   m_out_curs_func;
169   devcb_resolved_write_line   m_out_drb_func;
170
171   screen_device *m_screen;
172
173   // registers
174   UINT8 m_reg[0x3d];
175   UINT8 m_status;
176
177   int m_disp;
178   int m_hpixels_per_column;
179
180   // runtime variables, do not state save
181   int m_vsync_start;
182   int m_vsync_end;
183   int m_vfp;
184   int m_hsync_start;
185   int m_hsync_end;
186   int m_hfp;
187
188   // timers
189   emu_timer *m_vsync_timer;
190   emu_timer *m_hsync_timer;
191   emu_timer *m_vlt_timer;
192   emu_timer *m_curs_timer;
193   emu_timer *m_drb_timer;
194
195   const crt9007_device_config &m_config;
196};
197
198
199// device type definition
200extern const device_type CRT9007;
201
202
203
109204#endif
src/mess/includes/tandy2k.h
r9643r9644
1111#define I8259A_1_TAG   "u43"
1212#define I8272A_TAG      "u121"
1313#define CRT9007_TAG      "u16"
14#define CRT9021_TAG      "u14"
14#define CRT9212_0_TAG   "u55"
15#define CRT9212_1_TAG   "u15"
16#define CRT9021B_TAG   "u14"
1517#define WD1010_TAG      "u18"
1618#define SPEAKER_TAG      "speaker"
1719#define CENTRONICS_TAG   "centronics"
r9643r9644
4143   required_device<running_device> m_fdc;
4244   required_device<running_device> m_pic0;
4345   required_device<running_device> m_pic1;
44   required_device<running_device> m_vpac;
46   required_device<crt9007_device> m_vpac;
47//   required_device<crt9212_device> m_drb0;
48//   required_device<crt9212_device> m_drb1;
49//   required_device<crt9201_device> m_vag;
4550   required_device<running_device> m_centronics;
4651   required_device<running_device> m_speaker;
4752   required_device<running_device> m_ram;
r9643r9644
5560   void speaker_update();
5661   void dma_request(int line, int state);
5762
63   DECLARE_READ8_MEMBER( videoram_r );
5864   DECLARE_READ8_MEMBER( enable_r );
5965   DECLARE_WRITE8_MEMBER( enable_w );
6066   DECLARE_WRITE8_MEMBER( dma_mux_w );
r9643r9644
8894   UINT16 *m_char_ram;
8995   UINT16 *m_hires_ram;
9096   UINT16 m_palette[16];
91   UINT32 m_vram_base;
97   UINT8 m_vram_base;
9298   int m_vidouts;
9399   int m_clkspd;
94100   int m_clkcnt;
src/mess/drivers/tandy2k.c
r9643r9644
1010
1111    TODO:
1212
13    - CRT9007
14   - CRT9212 Double Row Buffer
15   - CRT9021B Attribute Generator
1316    - 80186
14    - CRT9007
1517    - keyboard ROM
1618    - hires graphics board
1719    - floppy 720K DSQD
r9643r9644
5355   speaker_level_w(m_speaker, level);
5456}
5557
58READ8_MEMBER( tandy2k_state::videoram_r )
59{
60   address_space *program = cpu_get_address_space(m_maincpu, ADDRESS_SPACE_PROGRAM);
61   
62   offs_t addr = (m_vram_base << 15) | (offset << 1);
63   UINT16 data = program->read_word(addr);
64
65   // character
66//   m_drb0->write(data & 0xff);
67
68   // attributes
69//   m_drb1->write(data >> 8);
70
71   return data & 0xff;
72}
73
5674READ8_MEMBER( tandy2k_state::enable_r )
5775{
5876   /*
r9643r9644
182200    */
183201
184202   /* video access */
185   m_vram_base = data << 15;
203   m_vram_base = data & 0x1f;
186204
187205   /* video clock speed */
188206   if (m_clkspd != BIT(data, 5))
189207   {
190      crt9007_set_clock(m_vpac, BIT(data, 5) ? XTAL_16MHz*28/16 : XTAL_16MHz*28/20);
208      m_vpac->set_unscaled_clock(BIT(data, 5) ? XTAL_16MHz*28/16 : XTAL_16MHz*28/20);
191209      m_clkspd = BIT(data, 5);
192210   }
193211
194212   /* dots per char */
195213   if (m_clkcnt != BIT(data, 6))
196214   {
197      crt9007_set_hpixels_per_column(m_vpac, BIT(data, 6) ? 8 : 10);
215      m_vpac->set_hpixels_per_column(BIT(data, 6) ? 8 : 10);
198216      m_clkcnt = BIT(data, 6);
199217   }
200218
r9643r9644
304322   AM_RANGE(0x00060, 0x00063) AM_DEVREADWRITE8_LEGACY(I8259A_0_TAG, pic8259_r, pic8259_w, 0x00ff)
305323   AM_RANGE(0x00070, 0x00073) AM_DEVREADWRITE8_LEGACY(I8259A_1_TAG, pic8259_r, pic8259_w, 0x00ff)
306324   AM_RANGE(0x00080, 0x00081) AM_DEVREADWRITE8_LEGACY(I8272A_TAG, upd765_dack_r, upd765_dack_w, 0x00ff)
307   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8_LEGACY(CRT9007_TAG, crt9007_r, crt9007_w, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
325   AM_RANGE(0x00100, 0x0017f) AM_DEVREADWRITE8(CRT9007_TAG, crt9007_device, read, write, 0x00ff) AM_WRITE8(addr_ctrl_w, 0xff00)
308326//  AM_RANGE(0x00180, 0x00180) AM_READ8(hires_status_r, 0x00ff)
309327//  AM_RANGE(0x00180, 0x001bf) AM_WRITE(hires_palette_w)
310328//  AM_RANGE(0x001a0, 0x001a0) AM_READ8(hires_plane_w, 0x00ff)
r9643r9644
318336//  AM_RANGE(0x0026e, 0x0027f) AM_DEVREADWRITE8_LEGACY(WD1010_TAG, wd1010_r, wd1010_w, 0x00ff)
319337ADDRESS_MAP_END
320338
339static ADDRESS_MAP_START( vpac_mem, 0, 8, tandy2k_state )
340   AM_RANGE(0x0000, 0x3fff) AM_READ(videoram_r)
341ADDRESS_MAP_END
342
321343static ADDRESS_MAP_START( keyboard_io, ADDRESS_SPACE_IO, 8, tandy2k_state )
322344  AM_RANGE(MCS48_PORT_P1, MCS48_PORT_P1) AM_WRITE(keyboard_y0_w)
323345  AM_RANGE(MCS48_PORT_P2, MCS48_PORT_P2) AM_WRITE(keyboard_y8_w)
r9643r9644
454476{
455477   if (m_vidouts)
456478   {
457      crt9007_update(m_vpac, &bitmap, &cliprect);
479      //m_vag->update_screen(&bitmap, &cliprect);
458480   }
459481
460482   return 0;
461483}
462
484/*
463485static CRT9007_DRAW_SCANLINE( tandy2k_crt9007_display_pixels )
464486{
465487   tandy2k_state *state = device->machine->driver_data<tandy2k_state>();
r9643r9644
467489
468490   for (int sx = 0; sx < x_count; sx++)
469491   {
470      UINT32 videoram_addr = (state->m_vram_base | (va << 1)) + sx;
492      UINT32 videoram_addr = ((state->m_vram_base << 15) | (va << 1)) + sx;
471493      UINT8 videoram_data = program->read_word(videoram_addr);
472494      UINT16 charram_addr = (videoram_data << 4) | sl;
473495      UINT8 charram_data = state->m_char_ram[charram_addr] & 0xff;
r9643r9644
483505      }
484506   }
485507}
486
508*/
487509static CRT9007_INTERFACE( crt9007_intf )
488510{
489511   SCREEN_TAG,
490512   10,
491   tandy2k_crt9007_display_pixels,
492513   DEVCB_DEVICE_LINE(I8259A_1_TAG, pic8259_ir1_w),
493   DEVCB_NULL,
494   DEVCB_NULL,
495   DEVCB_NULL,
496   DEVCB_NULL,
497   DEVCB_NULL
514   DEVCB_NULL,   // DMAR      80186 HOLD
515   DEVCB_NULL,   // VS      CRT9021B U14 VSYNC
516   DEVCB_NULL,   // HS
517   DEVCB_NULL,   // VLT      CRT9212 U55/U15 _CLRCNT
518   DEVCB_NULL,   // CURS      CRT9021B U14 CURSOR
519   DEVCB_NULL,   // DRB      CRT9212 U55/U15 TOG
520   DEVCB_NULL,   // SLG      CRT9021B U14 _SLG
521   DEVCB_NULL   // SLD      CRT9021B U14 SLD
498522};
499523
500524/* Intel 8251A Interface */
r9643r9644
651675
652676static I8255A_INTERFACE( i8255_intf )
653677{
654   DEVCB_NULL,                     // Port A read
655   DEVCB_DRIVER_MEMBER(tandy2k_state, ppi_pb_r),         // Port B write
656   DEVCB_NULL,                     // Port C read
657   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w),   /* port A write callback */
658   DEVCB_NULL,                     // Port B write
678   DEVCB_NULL,                                       // Port A read
679   DEVCB_DRIVER_MEMBER(tandy2k_state, ppi_pb_r),            // Port B write
680   DEVCB_NULL,                                       // Port C read
681   DEVCB_DEVICE_HANDLER(CENTRONICS_TAG, centronics_data_w),   // Port A write
682   DEVCB_NULL,                                       // Port B write
659683   DEVCB_DRIVER_MEMBER(tandy2k_state, ppi_pc_w)            // Port C write
660684};
661685
r9643r9644
791815   MDRV_PALETTE_LENGTH(2)
792816    MDRV_PALETTE_INIT(black_and_white)
793817
794   MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, crt9007_intf)
818   MDRV_CRT9007_ADD(CRT9007_TAG, XTAL_16MHz*28/16, crt9007_intf, vpac_mem)
795819
796820   /* sound hardware */
797821   MDRV_SPEAKER_STANDARD_MONO("mono")

Previous 15994 Revisions Next


© 1998-2018 The MESS Team