~ubuntu-branches/debian/sid/mame/sid

« back to all changes in this revision

Viewing changes to mess/src/mame/video/jack.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
 
  video/jack.c
4
 
 
5
 
  Functions to emulate the video hardware of the machine.
6
 
 
7
 
***************************************************************************/
8
 
 
9
 
#include "emu.h"
10
 
#include "includes/jack.h"
11
 
 
12
 
 
13
 
WRITE8_HANDLER( jack_videoram_w )
14
 
{
15
 
        jack_state *state = space->machine().driver_data<jack_state>();
16
 
        state->m_videoram[offset] = data;
17
 
        tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
18
 
}
19
 
 
20
 
WRITE8_HANDLER( jack_colorram_w )
21
 
{
22
 
        jack_state *state = space->machine().driver_data<jack_state>();
23
 
        state->m_colorram[offset] = data;
24
 
        tilemap_mark_tile_dirty(state->m_bg_tilemap, offset);
25
 
}
26
 
 
27
 
WRITE8_HANDLER( jack_paletteram_w )
28
 
{
29
 
        /* RGB output is inverted */
30
 
        paletteram_BBGGGRRR_w(space, offset, ~data);
31
 
}
32
 
 
33
 
READ8_HANDLER( jack_flipscreen_r )
34
 
{
35
 
        flip_screen_set(space->machine(), offset);
36
 
        return 0;
37
 
}
38
 
 
39
 
WRITE8_HANDLER( jack_flipscreen_w )
40
 
{
41
 
        flip_screen_set(space->machine(), offset);
42
 
}
43
 
 
44
 
static TILE_GET_INFO( get_bg_tile_info )
45
 
{
46
 
        jack_state *state = machine.driver_data<jack_state>();
47
 
        int code = state->m_videoram[tile_index] + ((state->m_colorram[tile_index] & 0x18) << 5);
48
 
        int color = state->m_colorram[tile_index] & 0x07;
49
 
 
50
 
        // striv: state->m_colorram[tile_index] & 0x80 ???
51
 
 
52
 
        SET_TILE_INFO(0, code, color, 0);
53
 
}
54
 
 
55
 
static UINT32 tilemap_scan_cols_flipy( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
56
 
{
57
 
        /* logical (col,row) -> memory offset */
58
 
        return (col * num_rows) + (num_rows - 1 - row);
59
 
}
60
 
 
61
 
VIDEO_START( jack )
62
 
{
63
 
        jack_state *state = machine.driver_data<jack_state>();
64
 
        state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols_flipy, 8, 8, 32, 32);
65
 
}
66
 
 
67
 
static void jack_draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
68
 
{
69
 
        jack_state *state = machine.driver_data<jack_state>();
70
 
        UINT8 *spriteram = state->m_spriteram;
71
 
        int offs;
72
 
 
73
 
        for (offs = state->m_spriteram_size - 4; offs >= 0; offs -= 4)
74
 
        {
75
 
                int sx, sy, num, color, flipx, flipy;
76
 
 
77
 
                sx    = spriteram[offs + 1];
78
 
                sy    = spriteram[offs];
79
 
                num   = spriteram[offs + 2] + ((spriteram[offs + 3] & 0x08) << 5);
80
 
                color = spriteram[offs + 3] & 0x07;
81
 
                flipx = (spriteram[offs + 3] & 0x80);
82
 
                flipy = (spriteram[offs + 3] & 0x40);
83
 
 
84
 
                if (flip_screen_get(machine))
85
 
                {
86
 
                        sx = 248 - sx;
87
 
                        sy = 248 - sy;
88
 
                        flipx = !flipx;
89
 
                        flipy = !flipy;
90
 
                }
91
 
 
92
 
                drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
93
 
                                num,
94
 
                                color,
95
 
                                flipx,flipy,
96
 
                                sx,sy,0);
97
 
        }
98
 
}
99
 
 
100
 
SCREEN_UPDATE( jack )
101
 
{
102
 
        jack_state *state = screen->machine().driver_data<jack_state>();
103
 
        tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
104
 
        jack_draw_sprites(screen->machine(), bitmap, cliprect);
105
 
        return 0;
106
 
}
107
 
 
108
 
/*
109
 
   Joinem has a bit different video hardware with proms based palette,
110
 
   3bpp gfx and different banking / colors bits
111
 
*/
112
 
 
113
 
PALETTE_INIT( joinem )
114
 
{
115
 
        int i;
116
 
 
117
 
        for (i = 0; i < machine.total_colors(); i++)
118
 
        {
119
 
                int bit0, bit1, bit2, r, g, b;
120
 
                bit0 = (color_prom[i] >> 0) & 0x01;
121
 
                bit1 = (color_prom[i] >> 1) & 0x01;
122
 
                bit2 = (color_prom[i] >> 2) & 0x01;
123
 
                r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
124
 
                bit0 = (color_prom[i] >> 3) & 0x01;
125
 
                bit1 = (color_prom[i] >> 4) & 0x01;
126
 
                bit2 = (color_prom[i] >> 5) & 0x01;
127
 
                g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
128
 
                bit0 = 0;
129
 
                bit1 = (color_prom[i] >> 6) & 0x01;
130
 
                bit2 = (color_prom[i] >> 7) & 0x01;
131
 
                b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
132
 
 
133
 
                palette_set_color(machine, i, MAKE_RGB(r,g,b));
134
 
        }
135
 
}
136
 
 
137
 
static TILE_GET_INFO( joinem_get_bg_tile_info )
138
 
{
139
 
        jack_state *state = machine.driver_data<jack_state>();
140
 
        int code = state->m_videoram[tile_index] + ((state->m_colorram[tile_index] & 0x03) << 8);
141
 
        int color = (state->m_colorram[tile_index] & 0x38) >> 3;
142
 
 
143
 
        SET_TILE_INFO(0, code, color, 0);
144
 
}
145
 
 
146
 
VIDEO_START( joinem )
147
 
{
148
 
        jack_state *state = machine.driver_data<jack_state>();
149
 
        state->m_bg_tilemap = tilemap_create(machine, joinem_get_bg_tile_info, tilemap_scan_cols_flipy, 8, 8, 32, 32);
150
 
}
151
 
 
152
 
static void joinem_draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
153
 
{
154
 
        jack_state *state = machine.driver_data<jack_state>();
155
 
        UINT8 *spriteram = state->m_spriteram;
156
 
        int offs;
157
 
 
158
 
        for (offs = state->m_spriteram_size - 4; offs >= 0; offs -= 4)
159
 
        {
160
 
                int sx, sy, num, color, flipx, flipy;
161
 
 
162
 
                sx    = spriteram[offs + 1];
163
 
                sy    = spriteram[offs];
164
 
                num   = spriteram[offs + 2] + ((spriteram[offs + 3] & 0x01) << 8);
165
 
                color = (spriteram[offs + 3] & 0x38) >> 3;
166
 
                flipx = (spriteram[offs + 3] & 0x80);
167
 
                flipy = (spriteram[offs + 3] & 0x40);
168
 
 
169
 
                if (flip_screen_get(machine))
170
 
                {
171
 
                        sx = 248 - sx;
172
 
                        sy = 248 - sy;
173
 
                        flipx = !flipx;
174
 
                        flipy = !flipy;
175
 
                }
176
 
 
177
 
                drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
178
 
                                num,
179
 
                                color,
180
 
                                flipx,flipy,
181
 
                                sx,sy,0);
182
 
        }
183
 
}
184
 
 
185
 
SCREEN_UPDATE( joinem )
186
 
{
187
 
        jack_state *state = screen->machine().driver_data<jack_state>();
188
 
        tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
189
 
        joinem_draw_sprites(screen->machine(), bitmap, cliprect);
190
 
        return 0;
191
 
}