~ubuntu-branches/ubuntu/raring/mame/raring-proposed

« back to all changes in this revision

Viewing changes to mess/src/mame/video/gridlee.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach, Jordi Mallach, Emmanuel Kasper
  • Date: 2011-12-19 22:56:27 UTC
  • mfrom: (0.1.2)
  • Revision ID: package-import@ubuntu.com-20111219225627-ub5oga1oys4ogqzm
Tags: 0.144-1
[ Jordi Mallach ]
* Fix syntax errors in DEP5 copyright file (lintian).
* Use a versioned copyright Format specification field.
* Update Vcs-* URLs.
* Move transitional packages to the new metapackages section, and make
  them priority extra.
* Remove references to GNU/Linux and MESS sources from copyright.
* Add build variables for s390x.
* Use .xz tarballs as it cuts 4MB for the upstream sources.
* Add nplayers.ini as a patch. Update copyright file to add CC-BY-SA-3.0.

[ Emmanuel Kasper ]
* New upstream release. Closes: #651538.
* Add Free Desktop compliant png icons of various sizes taken from
  the hydroxygen iconset
* Mess is now built from a new source package, to avoid possible source
  incompatibilities between mame and the mess overlay.
* Mame-tools are not built from the mame source package anymore, but
  from the mess source package

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/***************************************************************************
2
 
 
3
 
    Videa Gridlee hardware
4
 
 
5
 
    driver by Aaron Giles
6
 
 
7
 
    Based on the Bally/Sente SAC system
8
 
 
9
 
***************************************************************************/
10
 
 
11
 
#include "emu.h"
12
 
#include "includes/gridlee.h"
13
 
 
14
 
 
15
 
/*************************************
16
 
 *
17
 
 *  Color PROM conversion
18
 
 *
19
 
 *************************************/
20
 
 
21
 
PALETTE_INIT( gridlee )
22
 
{
23
 
        int i;
24
 
 
25
 
        for (i = 0; i < machine.total_colors(); i++)
26
 
        {
27
 
                palette_set_color_rgb(machine,i,pal4bit(color_prom[0x0000]),pal4bit(color_prom[0x0800]),pal4bit(color_prom[0x1000]));
28
 
                color_prom++;
29
 
        }
30
 
}
31
 
 
32
 
 
33
 
 
34
 
/*************************************
35
 
 *
36
 
 *  Video system restart
37
 
 *
38
 
 *************************************/
39
 
 
40
 
static void expand_pixels(running_machine &machine)
41
 
{
42
 
        gridlee_state *state = machine.driver_data<gridlee_state>();
43
 
        UINT8 *videoram = state->m_videoram;
44
 
    int offset = 0;
45
 
 
46
 
    for(offset = 0; offset < 0x77ff; offset++)
47
 
    {
48
 
        state->m_local_videoram[offset * 2 + 0] = videoram[offset] >> 4;
49
 
        state->m_local_videoram[offset * 2 + 1] = videoram[offset] & 15;
50
 
    }
51
 
}
52
 
 
53
 
 
54
 
 
55
 
/*************************************
56
 
 *
57
 
 *  Video system start
58
 
 *
59
 
 *************************************/
60
 
 
61
 
VIDEO_START( gridlee )
62
 
{
63
 
        gridlee_state *state = machine.driver_data<gridlee_state>();
64
 
        /* allocate a local copy of video RAM */
65
 
        state->m_local_videoram = auto_alloc_array_clear(machine, UINT8, 256 * 256);
66
 
 
67
 
        /* reset the palette */
68
 
        state->m_palettebank_vis = 0;
69
 
 
70
 
    state_save_register_global(machine, state->m_cocktail_flip);
71
 
    state_save_register_global(machine, state->m_palettebank_vis);
72
 
    machine.save().register_postload(save_prepost_delegate(FUNC(expand_pixels), &machine));
73
 
}
74
 
 
75
 
 
76
 
 
77
 
/*************************************
78
 
 *
79
 
 *  Cocktail flip
80
 
 *
81
 
 *************************************/
82
 
 
83
 
WRITE8_HANDLER( gridlee_cocktail_flip_w )
84
 
{
85
 
        gridlee_state *state = space->machine().driver_data<gridlee_state>();
86
 
        state->m_cocktail_flip = data & 1;
87
 
}
88
 
 
89
 
 
90
 
 
91
 
/*************************************
92
 
 *
93
 
 *  Video RAM write
94
 
 *
95
 
 *************************************/
96
 
 
97
 
WRITE8_HANDLER( gridlee_videoram_w )
98
 
{
99
 
        gridlee_state *state = space->machine().driver_data<gridlee_state>();
100
 
        UINT8 *videoram = state->m_videoram;
101
 
        videoram[offset] = data;
102
 
 
103
 
        /* expand the two pixel values into two bytes */
104
 
        state->m_local_videoram[offset * 2 + 0] = data >> 4;
105
 
        state->m_local_videoram[offset * 2 + 1] = data & 15;
106
 
}
107
 
 
108
 
 
109
 
 
110
 
/*************************************
111
 
 *
112
 
 *  Palette banking
113
 
 *
114
 
 *************************************/
115
 
 
116
 
WRITE8_HANDLER( gridlee_palette_select_w )
117
 
{
118
 
        gridlee_state *state = space->machine().driver_data<gridlee_state>();
119
 
        /* update the scanline palette */
120
 
        space->machine().primary_screen->update_partial(space->machine().primary_screen->vpos() - 1 + GRIDLEE_VBEND);
121
 
        state->m_palettebank_vis = data & 0x3f;
122
 
}
123
 
 
124
 
 
125
 
 
126
 
/*************************************
127
 
 *
128
 
 *  Main screen refresh
129
 
 *
130
 
 *************************************/
131
 
 
132
 
/* all the GRIDLEE_VBEND adjustments are needed because the hardware has a seperate counting chain
133
 
   to address the video memory instead of using the video chain directly */
134
 
 
135
 
SCREEN_UPDATE( gridlee )
136
 
{
137
 
        gridlee_state *state = screen->machine().driver_data<gridlee_state>();
138
 
        const pen_t *pens = &screen->machine().pens[state->m_palettebank_vis * 32];
139
 
        UINT8 *gfx;
140
 
        int x, y, i;
141
 
 
142
 
        /* draw scanlines from the VRAM directly */
143
 
        for (y = cliprect->min_y; y <= cliprect->max_y; y++)
144
 
        {
145
 
                /* non-flipped: draw directly from the bitmap */
146
 
                if (!state->m_cocktail_flip)
147
 
                        draw_scanline8(bitmap, 0, y, 256, &state->m_local_videoram[(y - GRIDLEE_VBEND) * 256], pens + 16);
148
 
 
149
 
                /* flipped: x-flip the scanline into a temp buffer and draw that */
150
 
                else
151
 
                {
152
 
                        int srcy = GRIDLEE_VBSTART - 1 - y;
153
 
                        UINT8 temp[256];
154
 
                        int xx;
155
 
 
156
 
                        for (xx = 0; xx < 256; xx++)
157
 
                                temp[xx] = state->m_local_videoram[srcy * 256 + 255 - xx];
158
 
                        draw_scanline8(bitmap, 0, y, 256, temp, pens + 16);
159
 
                }
160
 
        }
161
 
 
162
 
        /* draw the sprite images */
163
 
        gfx = screen->machine().region("gfx1")->base();
164
 
        for (i = 0; i < 32; i++)
165
 
        {
166
 
                UINT8 *sprite = state->m_spriteram + i * 4;
167
 
                UINT8 *src;
168
 
                int image = sprite[0];
169
 
                int ypos = sprite[2] + 17 + GRIDLEE_VBEND;
170
 
                int xpos = sprite[3];
171
 
 
172
 
                /* get a pointer to the source image */
173
 
                src = &gfx[64 * image];
174
 
 
175
 
                /* loop over y */
176
 
                for (y = 0; y < 16; y++, ypos = (ypos + 1) & 255)
177
 
                {
178
 
                        int currxor = 0;
179
 
 
180
 
                        /* adjust for flip */
181
 
                        if (state->m_cocktail_flip)
182
 
                        {
183
 
                                ypos = 271 - ypos;
184
 
                                currxor = 0xff;
185
 
                        }
186
 
 
187
 
                        if (ypos >= (16 + GRIDLEE_VBEND) && ypos >= cliprect->min_y && ypos <= cliprect->max_y)
188
 
                        {
189
 
                                int currx = xpos;
190
 
 
191
 
                                /* loop over x */
192
 
                                for (x = 0; x < 4; x++)
193
 
                                {
194
 
                                        int ipixel = *src++;
195
 
                                        int left = ipixel >> 4;
196
 
                                        int right = ipixel & 0x0f;
197
 
 
198
 
                                        /* left pixel */
199
 
                                        if (left && currx >= 0 && currx < 256)
200
 
                                                *BITMAP_ADDR16(bitmap, ypos, currx ^ currxor) = pens[left];
201
 
                                        currx++;
202
 
 
203
 
                                        /* right pixel */
204
 
                                        if (right && currx >= 0 && currx < 256)
205
 
                                                *BITMAP_ADDR16(bitmap, ypos, currx ^ currxor) = pens[right];
206
 
                                        currx++;
207
 
                                }
208
 
                        }
209
 
                        else
210
 
                                src += 4;
211
 
 
212
 
                        /* de-adjust for flip */
213
 
                        if (state->m_cocktail_flip)
214
 
                                ypos = 271 - ypos;
215
 
                }
216
 
        }
217
 
        return 0;
218
 
}