Previous 15994 Revisions Next

r9292 Friday 1st October, 2010 at 05:01:53 UTC by Curt Coder
[VIDBRAIN] Added even field Y interrupt.
[src/mess/drivers]vidbrain.c
[src/mess/includes]vidbrain.h
[src/mess/video]vidbrain.c

src/mess/video/vidbrain.c
r9291r9292
77   - screen size
88   - scanline based update
99
10   http://zone.ni.com/devzone/cda/tut/p/id/4750
11
1012*/
1113
1214#include "emu.h"
r9291r9292
4042#define RAM_Y_LO_A               0x50   // Y value low order list A
4143#define RAM_Y_LO_B               0x60   // Y value low order list B
4244#define RAM_XY_HI_A               0x70   // Y value high order and X order list A
43#define RAM_XY_HI_B               0x80   // Y value high order and Y order list B
45#define RAM_XY_HI_B               0x80   // Y value high order and X order list B
4446
4547// command register bits
4648#define COMMAND_YINT_H_O         0x80
r9291r9292
5759***************************************************************************/
5860
5961/*-------------------------------------------------
62    get_field_vpos - get scanline within field
63-------------------------------------------------*/
64
65static int get_field_vpos(screen_device *screen)
66{
67   int vpos = screen->vpos();
68   
69   if (vpos >= 262)
70   {
71      // even field
72      vpos -= 262;
73   }
74
75   return vpos;
76}
77
78/*-------------------------------------------------
79    get_field - get video field
80-------------------------------------------------*/
81
82static int get_field(screen_device *screen)
83{
84   return screen->vpos() < 262;
85}
86
87/*-------------------------------------------------
6088    vidbrain_vlsi_r - video VLSI read
6189-------------------------------------------------*/
6290
r9291r9292
6593   vidbrain_state *state = space->machine->driver_data<vidbrain_state>();
6694
6795   UINT8 data = 0xff;
68   int vpos = state->screen->vpos();
6996
70   if (vpos >= 262) vpos -= 262;
71
7297   switch (offset)
7398   {
7499   case REGISTER_X_FREEZE:
75100      data = state->freeze_x;
101
76102      if (LOG) logerror("X-Freeze %02x\n", data);
77103      break;
78104
79105   case REGISTER_Y_FREEZE_LOW:
80106      data = state->freeze_y & 0xff;
107
81108      if (LOG) logerror("Y-Freeze Low %02x\n", data);
82109      break;
83110
r9291r9292
97124
98125      */
99126
100      data = (state->field << 7) | (BIT(vpos, 8) << 1) | BIT(state->freeze_y, 8);
127      data = (get_field(state->screen) << 7) | (BIT(get_field_vpos(state->screen), 8) << 1) | BIT(state->freeze_y, 8);
128
101129      if (LOG) logerror("Y-Freeze High %02x\n", data);
102130      break;
103131
104132   case REGISTER_CURRENT_Y_LOW:
105      data = vpos & 0xff;
133      data = get_field_vpos(state->screen) & 0xff;
134
106135      if (LOG) logerror("Current-Y Low %02x\n", data);
107136      break;
108137
r9291r9292
124153{
125154   int scanline = ((state->cmd & COMMAND_YINT_H_O) << 1) | state->y_int;
126155
127   state->timer_y_int->adjust(state->screen->time_until_pos(scanline, 0), 0, state->screen->frame_period());
156   state->timer_y_odd->adjust(state->screen->time_until_pos(scanline, 0), 0, state->screen->frame_period());
157   state->timer_y_even->adjust(state->screen->time_until_pos(scanline + 262, 0), 0, state->screen->frame_period());
128158}
129159
130160/*-------------------------------------------------
r9291r9292
294324
295325   /* get the devices */
296326   state->screen = machine->device<screen_device>(SCREEN_TAG);
297   state->timer_y_int = machine->device<timer_device>(TIMER_Y_INT_TAG);
327   state->timer_y_odd = machine->device<timer_device>(TIMER_Y_ODD_TAG);
328   state->timer_y_even = machine->device<timer_device>(TIMER_Y_EVEN_TAG);
298329}
299330
300331/*-------------------------------------------------
r9291r9292
341372      if (LOG) logerror("Object %u rp %04x color %u dx %u dy %u xcopy %u x %u y %u xord %u\n", i, rp, color, dx, dy, xcopy, x, y, xord);
342373
343374      if (rp == 0) continue;
344      if (y > 255) continue;
375      if (y > 262) continue;
345376
346377      for (int sy = 0; sy < dy; sy++)
347378      {
r9291r9292
448479   }
449480}
450481
451/*-------------------------------------------------
452    TIMER_DEVICE_CALLBACK( field_tick )
453-------------------------------------------------*/
454
455static TIMER_DEVICE_CALLBACK( field_tick )
456{
457   vidbrain_state *state = timer.machine->driver_data<vidbrain_state>();
458
459   state->field = !state->field;
460}
461
462482/***************************************************************************
463483    MACHINE CONFIGURATION
464484***************************************************************************/
r9291r9292
470490MACHINE_CONFIG_FRAGMENT( vidbrain_video )
471491    /* video hardware */
472492    MDRV_SCREEN_ADD(SCREEN_TAG, RASTER)
473    MDRV_SCREEN_REFRESH_RATE(30)
474    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
475493    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
476    MDRV_SCREEN_SIZE(320, 525)
477    MDRV_SCREEN_VISIBLE_AREA(0, 240-1, 0, 240-1)
494   MDRV_SCREEN_RAW_PARAMS(XTAL_14_31818MHz, 455, 0, 320, 525, 0, 243)
495     
478496   MDRV_GFXDECODE(vidbrain)
497
479498    MDRV_PALETTE_LENGTH(32)
480499    MDRV_PALETTE_INIT(vidbrain)
481500
482501    MDRV_VIDEO_START(vidbrain)
483502    MDRV_VIDEO_UPDATE(vidbrain)
484503
485   MDRV_TIMER_ADD(TIMER_Y_INT_TAG, y_int_tick)
486   MDRV_TIMER_ADD_PERIODIC(TIMER_FIELD_TAG, field_tick, HZ(60))
504   MDRV_TIMER_ADD(TIMER_Y_ODD_TAG, y_int_tick)
505   MDRV_TIMER_ADD(TIMER_Y_EVEN_TAG, y_int_tick)
487506MACHINE_CONFIG_END
src/mess/includes/vidbrain.h
r9291r9292
33#ifndef __VIDBRAIN__
44#define __VIDBRAIN__
55
6#define F3850_TAG      "cd34"
7#define F3853_TAG      "cd5"
8#define SCREEN_TAG      "screen"
9#define DISCRETE_TAG   "discrete"
10#define TIMER_Y_INT_TAG   "y_int"
11#define TIMER_FIELD_TAG   "field"
12#define CASSETTE_TAG   "cassette"
6#define F3850_TAG         "cd34"
7#define F3853_TAG         "cd5"
8#define SCREEN_TAG         "screen"
9#define DISCRETE_TAG      "discrete"
10#define TIMER_Y_ODD_TAG      "odd"
11#define TIMER_Y_EVEN_TAG   "even"
12#define CASSETTE_TAG      "cassette"
1313
1414class vidbrain_state : public driver_device
1515{
r9291r9292
4343   /* devices */
4444   running_device *discrete;
4545   screen_device *screen;
46   timer_device *timer_y_int;
46   timer_device *timer_y_odd;
47   timer_device *timer_y_even;
4748};
4849
4950/*----------- defined in driver/vidbrain.c -----------*/
src/mess/drivers/vidbrain.c
r9291r9292
110110
111111        bit     description
112112
113        0
114        1
113        0      sound Q0
114        1      sound Q1
115115        2
116116        3
117117        4       sound clock

Previous 15994 Revisions Next


© 1998-2018 The MESS Team