~ubuntu-branches/debian/wheezy/mame/wheezy

« back to all changes in this revision

Viewing changes to src/mame/video/wiz.c

  • Committer: Bazaar Package Importer
  • Author(s): Jordi Mallach, Emmanuel Kasper, Félix Arreola Rodríguez, Jordi Mallach
  • Date: 2011-05-11 21:06:50 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20110511210650-jizvh8a6x117y9hr
Tags: 0.142-1
[ Emmanuel Kasper ]
* New upstream release
* Set NOWERROR=1 to allow compiling with gcc-4.6
* Remove fix_powerpc_build.patch, as upstream has taken it in this release
* Add gnome-video-arcade front end as a suggested package

[ Félix Arreola Rodríguez ]
* Add kfreebsd-build.patch to quilt series, to fix build on kfreebsd

[ Jordi Mallach ]
* Remove unneeded and bogus addition of --with-quilt to the dh invocation.
* Add Cesare Falco (long time Ubuntu maintainer) to Uploaders, and wrap
  them into multiple lines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
        2*8, 30*8-1
23
23
};
24
24
 
25
 
UINT8 *wiz_videoram2;
26
 
UINT8 *wiz_colorram2;
27
 
UINT8 *wiz_attributesram;
28
 
UINT8 *wiz_attributesram2;
29
 
 
30
 
static INT32 flipx, flipy;
31
 
static INT32 bgpen;
32
 
 
33
 
UINT8 *wiz_sprite_bank;
34
 
static UINT8 char_bank[2];
35
 
static UINT8 palbank[2];
36
 
static int palette_bank;
37
 
 
38
25
 
39
26
VIDEO_START( wiz )
40
27
{
41
 
        state_save_register_global_array(machine, char_bank);
42
 
        state_save_register_global_array(machine, palbank);
43
 
        state_save_register_global(machine, flipx);
44
 
        state_save_register_global(machine, flipy);
45
 
        state_save_register_global(machine, bgpen);
 
28
        wiz_state *state = machine.driver_data<wiz_state>();
 
29
        state_save_register_global_array(machine, state->m_char_bank);
 
30
        state_save_register_global_array(machine, state->m_palbank);
 
31
        state_save_register_global(machine, state->m_flipx);
 
32
        state_save_register_global(machine, state->m_flipy);
 
33
        state_save_register_global(machine, state->m_bgpen);
46
34
}
47
35
 
48
36
/***************************************************************************
63
51
        int i;
64
52
 
65
53
 
66
 
        for (i = 0;i < machine->total_colors();i++)
 
54
        for (i = 0;i < machine.total_colors();i++)
67
55
        {
68
56
                int bit0,bit1,bit2,bit3,r,g,b;
69
57
 
73
61
                bit2 = (color_prom[0] >> 2) & 0x01;
74
62
                bit3 = (color_prom[0] >> 3) & 0x01;
75
63
                r = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
76
 
                bit0 = (color_prom[machine->total_colors()] >> 0) & 0x01;
77
 
                bit1 = (color_prom[machine->total_colors()] >> 1) & 0x01;
78
 
                bit2 = (color_prom[machine->total_colors()] >> 2) & 0x01;
79
 
                bit3 = (color_prom[machine->total_colors()] >> 3) & 0x01;
 
64
                bit0 = (color_prom[machine.total_colors()] >> 0) & 0x01;
 
65
                bit1 = (color_prom[machine.total_colors()] >> 1) & 0x01;
 
66
                bit2 = (color_prom[machine.total_colors()] >> 2) & 0x01;
 
67
                bit3 = (color_prom[machine.total_colors()] >> 3) & 0x01;
80
68
                g = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
81
 
                bit0 = (color_prom[2*machine->total_colors()] >> 0) & 0x01;
82
 
                bit1 = (color_prom[2*machine->total_colors()] >> 1) & 0x01;
83
 
                bit2 = (color_prom[2*machine->total_colors()] >> 2) & 0x01;
84
 
                bit3 = (color_prom[2*machine->total_colors()] >> 3) & 0x01;
 
69
                bit0 = (color_prom[2*machine.total_colors()] >> 0) & 0x01;
 
70
                bit1 = (color_prom[2*machine.total_colors()] >> 1) & 0x01;
 
71
                bit2 = (color_prom[2*machine.total_colors()] >> 2) & 0x01;
 
72
                bit3 = (color_prom[2*machine.total_colors()] >> 3) & 0x01;
85
73
                b = 0x0e * bit0 + 0x1f * bit1 + 0x42 * bit2 + 0x90 * bit3;
86
74
 
87
75
                palette_set_color(machine,i,MAKE_RGB(r,g,b));
92
80
 
93
81
WRITE8_HANDLER( wiz_palettebank_w )
94
82
{
95
 
        palbank[offset] = data & 1;
96
 
        palette_bank = palbank[0] + 2 * palbank[1];
 
83
        wiz_state *state = space->machine().driver_data<wiz_state>();
 
84
        state->m_palbank[offset] = data & 1;
 
85
        state->m_palette_bank = state->m_palbank[0] + 2 * state->m_palbank[1];
97
86
}
98
87
 
99
88
WRITE8_HANDLER( wiz_bgcolor_w )
100
89
{
101
 
        bgpen = data;
 
90
        wiz_state *state = space->machine().driver_data<wiz_state>();
 
91
        state->m_bgpen = data;
102
92
}
103
93
 
104
94
WRITE8_HANDLER( wiz_char_bank_select_w )
105
95
{
106
 
        char_bank[offset] = data & 1;
 
96
        wiz_state *state = space->machine().driver_data<wiz_state>();
 
97
        state->m_char_bank[offset] = data & 1;
107
98
}
108
99
 
109
100
WRITE8_HANDLER( wiz_flipx_w )
110
101
{
111
 
        flipx = data;
 
102
        wiz_state *state = space->machine().driver_data<wiz_state>();
 
103
        state->m_flipx = data;
112
104
}
113
105
 
114
106
 
115
107
WRITE8_HANDLER( wiz_flipy_w )
116
108
{
117
 
        flipy = data;
 
109
        wiz_state *state = space->machine().driver_data<wiz_state>();
 
110
        state->m_flipy = data;
118
111
}
119
112
 
120
 
static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int bank, int colortype)
 
113
static void draw_background(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int bank, int colortype)
121
114
{
122
 
        wiz_state *state = machine->driver_data<wiz_state>();
123
 
        UINT8 *videoram = state->videoram;
 
115
        wiz_state *state = machine.driver_data<wiz_state>();
 
116
        UINT8 *videoram = state->m_videoram;
124
117
        int offs;
125
118
 
126
119
        /* for every character in the Video RAM, check if it has been modified */
135
128
 
136
129
                if (colortype)
137
130
                {
138
 
                        col = (wiz_attributesram[2 * sx + 1] & 0x07);
 
131
                        col = (state->m_attributesram[2 * sx + 1] & 0x07);
139
132
                }
140
133
                else
141
134
                {
142
 
                        col = (wiz_attributesram[2 * (offs % 32) + 1] & 0x04) + (videoram[offs] & 3);
 
135
                        col = (state->m_attributesram[2 * (offs % 32) + 1] & 0x04) + (videoram[offs] & 3);
143
136
                }
144
137
 
145
 
                scroll = (8*sy + 256 - wiz_attributesram[2 * sx]) % 256;
146
 
                if (flipy)
 
138
                scroll = (8*sy + 256 - state->m_attributesram[2 * sx]) % 256;
 
139
                if (state->m_flipy)
147
140
                {
148
141
                   scroll = (248 - scroll) % 256;
149
142
                }
150
 
                if (flipx) sx = 31 - sx;
151
 
 
152
 
 
153
 
                drawgfx_transpen(bitmap,cliprect,machine->gfx[bank],
 
143
                if (state->m_flipx) sx = 31 - sx;
 
144
 
 
145
 
 
146
                drawgfx_transpen(bitmap,cliprect,machine.gfx[bank],
154
147
                        videoram[offs],
155
 
                        col + 8 * palette_bank,
156
 
                        flipx,flipy,
 
148
                        col + 8 * state->m_palette_bank,
 
149
                        state->m_flipx,state->m_flipy,
157
150
                        8*sx,scroll,0);
158
151
        }
159
152
}
160
153
 
161
 
static void draw_foreground(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int colortype)
 
154
static void draw_foreground(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect, int colortype)
162
155
{
 
156
        wiz_state *state = machine.driver_data<wiz_state>();
163
157
        int offs;
164
158
 
165
159
        /* draw the frontmost playfield. They are characters, but draw them as sprites. */
173
167
 
174
168
                if (colortype)
175
169
                {
176
 
                        col = (wiz_attributesram2[2 * sx + 1] & 0x07);
 
170
                        col = (state->m_attributesram2[2 * sx + 1] & 0x07);
177
171
                }
178
172
                else
179
173
                {
180
 
                        col = (wiz_colorram2[offs] & 0x07);
 
174
                        col = (state->m_colorram2[offs] & 0x07);
181
175
                }
182
176
 
183
 
                scroll = (8*sy + 256 - wiz_attributesram2[2 * sx]) % 256;
184
 
                if (flipy)
 
177
                scroll = (8*sy + 256 - state->m_attributesram2[2 * sx]) % 256;
 
178
                if (state->m_flipy)
185
179
                {
186
180
                   scroll = (248 - scroll) % 256;
187
181
                }
188
 
                if (flipx) sx = 31 - sx;
189
 
 
190
 
 
191
 
                drawgfx_transpen(bitmap,cliprect,machine->gfx[char_bank[1]],
192
 
                        wiz_videoram2[offs],
193
 
                        col + 8 * palette_bank,
194
 
                        flipx,flipy,
 
182
                if (state->m_flipx) sx = 31 - sx;
 
183
 
 
184
 
 
185
                drawgfx_transpen(bitmap,cliprect,machine.gfx[state->m_char_bank[1]],
 
186
                        state->m_videoram2[offs],
 
187
                        col + 8 * state->m_palette_bank,
 
188
                        state->m_flipx,state->m_flipy,
195
189
                        8*sx,scroll,0);
196
190
        }
197
191
}
198
192
 
199
 
static void draw_sprites(running_machine *machine, bitmap_t *bitmap,
 
193
static void draw_sprites(running_machine &machine, bitmap_t *bitmap,
200
194
                                                 const rectangle *cliprect, UINT8* sprite_ram,
201
195
                         int bank)
202
196
{
 
197
        wiz_state *state = machine.driver_data<wiz_state>();
203
198
        int offs;
204
199
 
205
 
        for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
 
200
        for (offs = state->m_spriteram_size - 4;offs >= 0;offs -= 4)
206
201
        {
207
202
                int sx,sy;
208
203
 
212
207
 
213
208
                if (!sx || !sy) continue;
214
209
 
215
 
                if ( flipx) sx = 240 - sx;
216
 
                if (!flipy) sy = 240 - sy;
 
210
                if ( state->m_flipx) sx = 240 - sx;
 
211
                if (!state->m_flipy) sy = 240 - sy;
217
212
 
218
 
                drawgfx_transpen(bitmap,cliprect,machine->gfx[bank],
 
213
                drawgfx_transpen(bitmap,cliprect,machine.gfx[bank],
219
214
                                sprite_ram[offs + 1],
220
 
                                (sprite_ram[offs + 2] & 0x07) + 8 * palette_bank,
221
 
                                flipx,flipy,
 
215
                                (sprite_ram[offs + 2] & 0x07) + 8 * state->m_palette_bank,
 
216
                                state->m_flipx,state->m_flipy,
222
217
                                sx,sy,0);
223
218
        }
224
219
}
225
220
 
226
221
 
227
 
VIDEO_UPDATE( kungfut )
 
222
SCREEN_UPDATE( kungfut )
228
223
{
229
 
        bitmap_fill(bitmap,cliprect,bgpen);
230
 
        draw_background(screen->machine, bitmap, cliprect, 2 + char_bank[0] , 0);
231
 
        draw_foreground(screen->machine, bitmap, cliprect, 0);
232
 
        draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram2.u8, 4);
233
 
        draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u8  , 5);
 
224
        wiz_state *state = screen->machine().driver_data<wiz_state>();
 
225
        bitmap_fill(bitmap,cliprect,state->m_bgpen);
 
226
        draw_background(screen->machine(), bitmap, cliprect, 2 + state->m_char_bank[0] , 0);
 
227
        draw_foreground(screen->machine(), bitmap, cliprect, 0);
 
228
        draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram2, 4);
 
229
        draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram  , 5);
234
230
        return 0;
235
231
}
236
232
 
237
 
VIDEO_UPDATE( wiz )
 
233
SCREEN_UPDATE( wiz )
238
234
{
 
235
        wiz_state *state = screen->machine().driver_data<wiz_state>();
239
236
        int bank;
240
237
        const rectangle* visible_area;
241
238
 
242
 
        bitmap_fill(bitmap,cliprect,bgpen);
243
 
        draw_background(screen->machine, bitmap, cliprect, 2 + ((char_bank[0] << 1) | char_bank[1]), 0);
244
 
        draw_foreground(screen->machine, bitmap, cliprect, 0);
245
 
 
246
 
        visible_area = flipx ? &spritevisibleareaflipx : &spritevisiblearea;
247
 
 
248
 
    bank = 7 + *wiz_sprite_bank;
249
 
 
250
 
        draw_sprites(screen->machine, bitmap, visible_area, screen->machine->generic.spriteram2.u8, 6);
251
 
        draw_sprites(screen->machine, bitmap, visible_area, screen->machine->generic.spriteram.u8  , bank);
 
239
        bitmap_fill(bitmap,cliprect,state->m_bgpen);
 
240
        draw_background(screen->machine(), bitmap, cliprect, 2 + ((state->m_char_bank[0] << 1) | state->m_char_bank[1]), 0);
 
241
        draw_foreground(screen->machine(), bitmap, cliprect, 0);
 
242
 
 
243
        visible_area = state->m_flipx ? &spritevisibleareaflipx : &spritevisiblearea;
 
244
 
 
245
        bank = 7 + *state->m_sprite_bank;
 
246
 
 
247
        draw_sprites(screen->machine(), bitmap, visible_area, state->m_spriteram2, 6);
 
248
        draw_sprites(screen->machine(), bitmap, visible_area, state->m_spriteram  , bank);
252
249
        return 0;
253
250
}
254
251
 
255
252
 
256
 
VIDEO_UPDATE( stinger )
 
253
SCREEN_UPDATE( stinger )
257
254
{
258
 
        bitmap_fill(bitmap,cliprect,bgpen);
259
 
        draw_background(screen->machine, bitmap, cliprect, 2 + char_bank[0], 1);
260
 
        draw_foreground(screen->machine, bitmap, cliprect, 1);
261
 
        draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram2.u8, 4);
262
 
        draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.spriteram.u8  , 5);
 
255
        wiz_state *state = screen->machine().driver_data<wiz_state>();
 
256
        bitmap_fill(bitmap,cliprect,state->m_bgpen);
 
257
        draw_background(screen->machine(), bitmap, cliprect, 2 + state->m_char_bank[0], 1);
 
258
        draw_foreground(screen->machine(), bitmap, cliprect, 1);
 
259
        draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram2, 4);
 
260
        draw_sprites(screen->machine(), bitmap, cliprect, state->m_spriteram  , 5);
263
261
        return 0;
264
262
}