1
/******************************************************************************
3
Video Hardware for Nichibutsu Mahjong series.
5
Driver by Takahiro Nogi 2000/06/07 -
7
******************************************************************************/
10
#include "includes/nb1413m3.h"
11
#include "includes/pastelg.h"
14
static void pastelg_vramflip(running_machine &machine);
15
static void pastelg_gfxdraw(running_machine &machine);
18
/******************************************************************************
21
******************************************************************************/
22
PALETTE_INIT( pastelg )
25
int bit0, bit1, bit2, bit3, r, g, b;
27
for (i = 0; i < machine.total_colors(); i++)
29
bit0 = (color_prom[0] >> 0) & 0x01;
30
bit1 = (color_prom[0] >> 1) & 0x01;
31
bit2 = (color_prom[0] >> 2) & 0x01;
32
bit3 = (color_prom[0] >> 3) & 0x01;
33
r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
34
bit0 = (color_prom[0] >> 4) & 0x01;
35
bit1 = (color_prom[0] >> 5) & 0x01;
36
bit2 = (color_prom[0] >> 6) & 0x01;
37
bit3 = (color_prom[0] >> 7) & 0x01;
38
g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
39
bit0 = (color_prom[machine.total_colors()] >> 0) & 0x01;
40
bit1 = (color_prom[machine.total_colors()] >> 1) & 0x01;
41
bit2 = (color_prom[machine.total_colors()] >> 2) & 0x01;
42
bit3 = (color_prom[machine.total_colors()] >> 3) & 0x01;
43
b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
45
palette_set_color(machine,i,MAKE_RGB(r,g,b));
50
WRITE8_HANDLER( pastelg_clut_w )
52
pastelg_state *state = space->machine().driver_data<pastelg_state>();
53
state->m_clut[offset] = data;
56
/******************************************************************************
59
******************************************************************************/
60
int pastelg_blitter_src_addr_r(address_space *space)
62
pastelg_state *state = space->machine().driver_data<pastelg_state>();
63
return state->m_blitter_src_addr;
66
WRITE8_HANDLER( pastelg_blitter_w )
68
pastelg_state *state = space->machine().driver_data<pastelg_state>();
71
case 0: state->m_blitter_src_addr = (state->m_blitter_src_addr & 0xff00) | data; break;
72
case 1: state->m_blitter_src_addr = (state->m_blitter_src_addr & 0x00ff) | (data << 8); break;
73
case 2: state->m_blitter_destx = data; break;
74
case 3: state->m_blitter_desty = data; break;
75
case 4: state->m_blitter_sizex = data; break;
76
case 5: state->m_blitter_sizey = data;
77
/* writing here also starts the blit */
78
pastelg_gfxdraw(space->machine());
80
case 6: state->m_blitter_direction_x = (data & 0x01) ? 1 : 0;
81
state->m_blitter_direction_y = (data & 0x02) ? 1 : 0;
82
state->m_flipscreen = (data & 0x04) ? 0 : 1;
83
state->m_dispflag = (data & 0x08) ? 0 : 1;
84
pastelg_vramflip(space->machine());
90
WRITE8_HANDLER( threeds_romsel_w )
92
pastelg_state *state = space->machine().driver_data<pastelg_state>();
93
if (data&0xfc) printf("%02x\n",data);
94
state->m_gfxrom = (data & 0x3);
97
WRITE8_HANDLER( threeds_output_w )
99
pastelg_state *state = space->machine().driver_data<pastelg_state>();
100
state->m_palbank = ((data & 0x10) >> 4);
104
READ8_HANDLER( threeds_rom_readback_r )
106
pastelg_state *state = space->machine().driver_data<pastelg_state>();
107
UINT8 *GFX = space->machine().region("gfx1")->base();
109
return GFX[(state->m_blitter_src_addr | (state->m_gfxrom << 16)) & 0x3ffff];
113
WRITE8_HANDLER( pastelg_romsel_w )
115
pastelg_state *state = space->machine().driver_data<pastelg_state>();
116
int gfxlen = space->machine().region("gfx1")->bytes();
117
state->m_gfxrom = ((data & 0xc0) >> 6);
118
state->m_palbank = ((data & 0x10) >> 4);
119
nb1413m3_sndrombank1_w(space, 0, data);
121
if ((state->m_gfxrom << 16) > (gfxlen - 1))
124
popmessage("GFXROM BANK OVER!!");
126
state->m_gfxrom &= (gfxlen / 0x20000 - 1);
130
/******************************************************************************
133
******************************************************************************/
134
static void pastelg_vramflip(running_machine &machine)
136
pastelg_state *state = machine.driver_data<pastelg_state>();
138
UINT8 color1, color2;
139
int width = machine.primary_screen->width();
140
int height = machine.primary_screen->height();
142
if (state->m_flipscreen == state->m_flipscreen_old) return;
144
for (y = 0; y < height; y++)
146
for (x = 0; x < width; x++)
148
color1 = state->m_videoram[(y * width) + x];
149
color2 = state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)];
150
state->m_videoram[(y * width) + x] = color2;
151
state->m_videoram[((y ^ 0xff) * width) + (x ^ 0xff)] = color1;
155
state->m_flipscreen_old = state->m_flipscreen;
158
static TIMER_CALLBACK( blitter_timer_callback )
160
nb1413m3_busyflag = 1;
163
static void pastelg_gfxdraw(running_machine &machine)
165
pastelg_state *state = machine.driver_data<pastelg_state>();
166
UINT8 *GFX = machine.region("gfx1")->base();
167
int width = machine.primary_screen->width();
180
nb1413m3_busyctr = 0;
182
startx = state->m_blitter_destx + state->m_blitter_sizex;
183
starty = state->m_blitter_desty + state->m_blitter_sizey;
186
if (state->m_blitter_direction_x)
188
if (state->m_blitter_sizex&0x80) sizex = 0xff-state->m_blitter_sizex;
189
else sizex=state->m_blitter_sizex;
194
sizex = state->m_blitter_sizex;
198
if (state->m_blitter_direction_y)
200
if (state->m_blitter_sizey&0x80) sizey = 0xff-state->m_blitter_sizey;
201
else sizey=state->m_blitter_sizey;
206
sizey = state->m_blitter_sizey;
210
gfxlen = machine.region("gfx1")->bytes();
211
gfxaddr = (state->m_gfxrom << 16) + state->m_blitter_src_addr;
218
for (ctry = sizey; ctry >= 0; ctry--)
222
for (ctrx = sizex; ctrx >= 0; ctrx--)
224
gfxaddr = (state->m_gfxrom << 16) + ((state->m_blitter_src_addr + count));
226
if ((gfxaddr > (gfxlen - 1)))
229
popmessage("GFXROM ADDRESS OVER!!");
234
color = GFX[gfxaddr];
239
if (state->m_flipscreen)
247
// 1st, 3rd, 5th, ... read
248
color = (color & 0x0f);
252
// 2nd, 4th, 6th, ... read
253
color = (color & 0xf0) >> 4;
259
if (state->m_clut[color] & 0xf0)
263
color = ((state->m_palbank * 0x10) + color);
264
state->m_videoram[(dy * width) + dx] = color;
269
if(state->m_clut[color] != 0)
271
color = ((state->m_palbank * 0x10) + state->m_clut[color]);
272
state->m_videoram[(dy * width) + dx] = color;
283
nb1413m3_busyflag = 0;
284
machine.scheduler().timer_set(attotime::from_hz(400000) * nb1413m3_busyctr, FUNC(blitter_timer_callback));
287
/******************************************************************************
290
******************************************************************************/
291
VIDEO_START( pastelg )
293
pastelg_state *state = machine.driver_data<pastelg_state>();
294
int width = machine.primary_screen->width();
295
int height = machine.primary_screen->height();
297
state->m_videoram = auto_alloc_array_clear(machine, UINT8, width * height);
298
state->m_clut = auto_alloc_array(machine, UINT8, 0x10);
301
/******************************************************************************
304
******************************************************************************/
305
SCREEN_UPDATE( pastelg )
307
pastelg_state *state = screen->machine().driver_data<pastelg_state>();
308
if (state->m_dispflag)
311
int width = screen->width();
312
int height = screen->height();
314
for (y = 0; y < height; y++)
315
for (x = 0; x < width; x++)
316
*BITMAP_ADDR16(bitmap, y, x) = state->m_videoram[(y * width) + x];
319
bitmap_fill(bitmap, cliprect, 0);