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

« back to all changes in this revision

Viewing changes to src/mame/video/portrait.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:
8
8
#include "emu.h"
9
9
#include "includes/portrait.h"
10
10
 
11
 
int portrait_scroll;
12
 
UINT8 *portrait_bgvideoram, *portrait_fgvideoram;
13
 
static tilemap_t *foreground, *background;
14
11
 
15
12
WRITE8_HANDLER( portrait_bgvideo_write )
16
13
{
17
 
        tilemap_mark_tile_dirty(background,offset/2);
18
 
        portrait_bgvideoram[offset] = data;
 
14
        portrait_state *state = space->machine().driver_data<portrait_state>();
 
15
        tilemap_mark_tile_dirty(state->m_background,offset/2);
 
16
        state->m_bgvideoram[offset] = data;
19
17
}
20
18
 
21
19
WRITE8_HANDLER( portrait_fgvideo_write )
22
20
{
23
 
        tilemap_mark_tile_dirty(foreground,offset/2);
24
 
        portrait_fgvideoram[offset] = data;
 
21
        portrait_state *state = space->machine().driver_data<portrait_state>();
 
22
        tilemap_mark_tile_dirty(state->m_foreground,offset/2);
 
23
        state->m_fgvideoram[offset] = data;
25
24
}
26
25
 
27
 
INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, const UINT8 *source )
 
26
INLINE void get_tile_info( running_machine &machine, tile_data *tileinfo, int tile_index, const UINT8 *source )
28
27
{
29
28
        int attr    = source[tile_index*2+0];
30
29
        int tilenum = source[tile_index*2+1];
57
56
 
58
57
static TILE_GET_INFO( get_bg_tile_info )
59
58
{
60
 
        get_tile_info( machine, tileinfo, tile_index, portrait_bgvideoram );
 
59
        portrait_state *state = machine.driver_data<portrait_state>();
 
60
        get_tile_info( machine, tileinfo, tile_index, state->m_bgvideoram );
61
61
}
62
62
 
63
63
static TILE_GET_INFO( get_fg_tile_info )
64
64
{
65
 
        get_tile_info( machine, tileinfo, tile_index, portrait_fgvideoram );
 
65
        portrait_state *state = machine.driver_data<portrait_state>();
 
66
        get_tile_info( machine, tileinfo, tile_index, state->m_fgvideoram );
66
67
}
67
68
 
68
69
VIDEO_START( portrait )
69
70
{
70
 
        background = tilemap_create( machine, get_bg_tile_info, tilemap_scan_rows,       16, 16, 32, 32 );
71
 
        foreground = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows,  16, 16, 32, 32 );
 
71
        portrait_state *state = machine.driver_data<portrait_state>();
 
72
        state->m_background = tilemap_create( machine, get_bg_tile_info, tilemap_scan_rows,       16, 16, 32, 32 );
 
73
        state->m_foreground = tilemap_create( machine, get_fg_tile_info, tilemap_scan_rows,  16, 16, 32, 32 );
72
74
 
73
 
        tilemap_set_transparent_pen( foreground, 7 );
 
75
        tilemap_set_transparent_pen( state->m_foreground, 7 );
74
76
}
75
77
 
76
78
 
78
80
PALETTE_INIT( portrait )
79
81
{
80
82
        int i;
81
 
        UINT8* lookup = machine->region("tileattr")->base();
 
83
        UINT8* lookup = machine.region("tileattr")->base();
82
84
 
83
85
        /* allocate the colortable */
84
 
        machine->colortable = colortable_alloc(machine, 0x40);
 
86
        machine.colortable = colortable_alloc(machine, 0x40);
85
87
 
86
88
/*
87
89
    for (i = 0;i < 0x40;i++)
94
96
        g = (data >> 3) & 0x3;
95
97
        b = (data >> 5) & 0x7;
96
98
 
97
 
        colortable_palette_set_color(machine->colortable, i, MAKE_RGB(pal3bit(r), pal2bit(g), pal3bit(b)));
 
99
        colortable_palette_set_color(machine.colortable, i, MAKE_RGB(pal3bit(r), pal2bit(g), pal3bit(b)));
98
100
 
99
101
        color_prom++;
100
102
    }
109
111
                g = (data >> 5) & 0x1f;
110
112
                b = (data >> 10) & 0x1f;
111
113
 
112
 
                colortable_palette_set_color(machine->colortable, i, MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)));
 
114
                colortable_palette_set_color(machine.colortable, i, MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b)));
113
115
 
114
116
                // ?? the lookup seems to reference 0x3f colours, unless 1 bit is priority or similar?
115
 
                colortable_palette_set_color(machine->colortable, i+0x20, MAKE_RGB(pal5bit(r>>1), pal5bit(g>>1), pal5bit(b>>1)));
 
117
                colortable_palette_set_color(machine.colortable, i+0x20, MAKE_RGB(pal5bit(r>>1), pal5bit(g>>1), pal5bit(b>>1)));
116
118
 
117
119
                color_prom++;
118
120
        }
122
124
        for (i = 0;i < 0x800;i++)
123
125
        {
124
126
                UINT8 ctabentry = lookup[i]&0x3f;
125
 
                colortable_entry_set_value(machine->colortable, i, ctabentry);
 
127
                colortable_entry_set_value(machine.colortable, i, ctabentry);
126
128
        }
127
129
}
128
130
 
129
131
 
130
 
static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
 
132
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
131
133
{
132
 
        UINT8 *source = machine->generic.spriteram.u8;
 
134
        portrait_state *state = machine.driver_data<portrait_state>();
 
135
        UINT8 *source = state->m_spriteram;
133
136
        UINT8 *finish = source + 0x200;
134
137
 
135
138
        while( source < finish )
152
155
 
153
156
                if(attr & 0x08) sy |= 0x100;
154
157
 
155
 
                sx += (source - machine->generic.spriteram.u8) - 8;
 
158
                sx += (source - state->m_spriteram) - 8;
156
159
                sx &= 0x1ff;
157
160
 
158
161
                sy = (512 - 64) - sy;
164
167
                        break;
165
168
 
166
169
                case 0x40:
167
 
                        sy -= portrait_scroll;
 
170
                        sy -= state->m_scroll;
168
171
                        break;
169
172
 
170
173
                case 0x80:
171
 
                        sy -= portrait_scroll;
 
174
                        sy -= state->m_scroll;
172
175
                        break;
173
176
 
174
177
                case 0xc0:
176
179
 
177
180
                }
178
181
 
179
 
                drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
 
182
                drawgfx_transpen(bitmap,cliprect,machine.gfx[0],
180
183
                                tilenum,color,
181
184
                                0,fy,
182
185
                                sx,sy,7);
185
188
        }
186
189
}
187
190
 
188
 
VIDEO_UPDATE( portrait )
 
191
SCREEN_UPDATE( portrait )
189
192
{
 
193
        portrait_state *state = screen->machine().driver_data<portrait_state>();
190
194
        rectangle cliprect_scroll, cliprect_no_scroll;
191
195
 
192
196
        cliprect_scroll = cliprect_no_scroll = *cliprect;
194
198
        cliprect_no_scroll.min_x = cliprect_no_scroll.max_x - 111;
195
199
        cliprect_scroll.max_x    = cliprect_scroll.min_x    + 319;
196
200
 
197
 
        tilemap_set_scrolly(background, 0, 0);
198
 
        tilemap_set_scrolly(foreground, 0, 0);
199
 
        tilemap_draw(bitmap, &cliprect_no_scroll, background, 0, 0);
200
 
        tilemap_draw(bitmap, &cliprect_no_scroll, foreground, 0, 0);
201
 
 
202
 
        tilemap_set_scrolly(background, 0, portrait_scroll);
203
 
        tilemap_set_scrolly(foreground, 0, portrait_scroll);
204
 
        tilemap_draw(bitmap, &cliprect_scroll, background, 0, 0);
205
 
        tilemap_draw(bitmap, &cliprect_scroll, foreground, 0, 0);
206
 
 
207
 
        draw_sprites(screen->machine, bitmap,cliprect);
 
201
        tilemap_set_scrolly(state->m_background, 0, 0);
 
202
        tilemap_set_scrolly(state->m_foreground, 0, 0);
 
203
        tilemap_draw(bitmap, &cliprect_no_scroll, state->m_background, 0, 0);
 
204
        tilemap_draw(bitmap, &cliprect_no_scroll, state->m_foreground, 0, 0);
 
205
 
 
206
        tilemap_set_scrolly(state->m_background, 0, state->m_scroll);
 
207
        tilemap_set_scrolly(state->m_foreground, 0, state->m_scroll);
 
208
        tilemap_draw(bitmap, &cliprect_scroll, state->m_background, 0, 0);
 
209
        tilemap_draw(bitmap, &cliprect_scroll, state->m_foreground, 0, 0);
 
210
 
 
211
        draw_sprites(screen->machine(), bitmap,cliprect);
208
212
        return 0;
209
213
}