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

« back to all changes in this revision

Viewing changes to mess/src/mame/video/yunsun16.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
 
                          -= Yun Sung 16 Bit Games =-
4
 
 
5
 
                    driver by   Luca Elia (l.elia@tin.it)
6
 
 
7
 
 
8
 
    [ 2 Scrolling Layers ]
9
 
 
10
 
    Tiles are 16 x 16 x 8. The layout of the tilemap is a bit weird:
11
 
    16 consecutive tile codes define a vertical column.
12
 
    16 columns form a page (256 x 256).
13
 
    The tilemap is made of 4 x 4 pages (1024 x 1024)
14
 
 
15
 
    [ 512? Sprites ]
16
 
 
17
 
    Sprites are 16 x 16 x 4 in size. There's RAM for 512, but
18
 
    the game just copies 384 entries.
19
 
 
20
 
 
21
 
***************************************************************************/
22
 
 
23
 
#include "emu.h"
24
 
#include "includes/yunsun16.h"
25
 
 
26
 
 
27
 
/***************************************************************************
28
 
 
29
 
 
30
 
                                    Tilemaps
31
 
 
32
 
 
33
 
***************************************************************************/
34
 
 
35
 
#define TMAP_GFX                        (0)
36
 
#define TILES_PER_PAGE_X        (0x10)
37
 
#define TILES_PER_PAGE_Y        (0x10)
38
 
#define PAGES_PER_TMAP_X        (0x4)
39
 
#define PAGES_PER_TMAP_Y        (0x4)
40
 
 
41
 
static TILEMAP_MAPPER( yunsun16_tilemap_scan_pages )
42
 
{
43
 
        return  (row / TILES_PER_PAGE_Y) * TILES_PER_PAGE_X * TILES_PER_PAGE_Y * PAGES_PER_TMAP_X +
44
 
                        (row % TILES_PER_PAGE_Y) +
45
 
 
46
 
                        (col / TILES_PER_PAGE_X) * TILES_PER_PAGE_X * TILES_PER_PAGE_Y +
47
 
                        (col % TILES_PER_PAGE_X) * TILES_PER_PAGE_Y;
48
 
}
49
 
 
50
 
static TILE_GET_INFO( get_tile_info_0 )
51
 
{
52
 
        yunsun16_state *state = machine.driver_data<yunsun16_state>();
53
 
        UINT16 code = state->m_vram_0[2 * tile_index + 0];
54
 
        UINT16 attr = state->m_vram_0[2 * tile_index + 1];
55
 
        SET_TILE_INFO(
56
 
                        TMAP_GFX,
57
 
                        code,
58
 
                        attr & 0xf,
59
 
                        (attr & 0x20) ? TILE_FLIPX : 0);
60
 
}
61
 
 
62
 
static TILE_GET_INFO( get_tile_info_1 )
63
 
{
64
 
        yunsun16_state *state = machine.driver_data<yunsun16_state>();
65
 
        UINT16 code = state->m_vram_1[2 * tile_index + 0];
66
 
        UINT16 attr = state->m_vram_1[2 * tile_index + 1];
67
 
        SET_TILE_INFO(
68
 
                        TMAP_GFX,
69
 
                        code,
70
 
                        attr & 0xf,
71
 
                        (attr & 0x20) ? TILE_FLIPX : 0);
72
 
}
73
 
 
74
 
WRITE16_HANDLER( yunsun16_vram_0_w )
75
 
{
76
 
        yunsun16_state *state = space->machine().driver_data<yunsun16_state>();
77
 
 
78
 
        COMBINE_DATA(&state->m_vram_0[offset]);
79
 
        tilemap_mark_tile_dirty(state->m_tilemap_0, offset / 2);
80
 
}
81
 
 
82
 
WRITE16_HANDLER( yunsun16_vram_1_w )
83
 
{
84
 
        yunsun16_state *state = space->machine().driver_data<yunsun16_state>();
85
 
 
86
 
        COMBINE_DATA(&state->m_vram_1[offset]);
87
 
        tilemap_mark_tile_dirty(state->m_tilemap_1, offset / 2);
88
 
}
89
 
 
90
 
 
91
 
/***************************************************************************
92
 
 
93
 
 
94
 
                            Video Hardware Init
95
 
 
96
 
 
97
 
***************************************************************************/
98
 
 
99
 
VIDEO_START( yunsun16 )
100
 
{
101
 
        yunsun16_state *state = machine.driver_data<yunsun16_state>();
102
 
 
103
 
        state->m_tilemap_0 = tilemap_create(machine, get_tile_info_0,yunsun16_tilemap_scan_pages,
104
 
                                                                16,16, TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y);
105
 
        state->m_tilemap_1 = tilemap_create(machine, get_tile_info_1,yunsun16_tilemap_scan_pages,
106
 
                                                                16,16, TILES_PER_PAGE_X*PAGES_PER_TMAP_X,TILES_PER_PAGE_Y*PAGES_PER_TMAP_Y);
107
 
 
108
 
        tilemap_set_scrolldx(state->m_tilemap_0, -0x34, 0);
109
 
        tilemap_set_scrolldx(state->m_tilemap_1, -0x38, 0);
110
 
 
111
 
        tilemap_set_scrolldy(state->m_tilemap_0, -0x10, 0);
112
 
        tilemap_set_scrolldy(state->m_tilemap_1, -0x10, 0);
113
 
 
114
 
        tilemap_set_transparent_pen(state->m_tilemap_0, 0xff);
115
 
        tilemap_set_transparent_pen(state->m_tilemap_1, 0xff);
116
 
}
117
 
 
118
 
 
119
 
/***************************************************************************
120
 
 
121
 
 
122
 
                                Sprites Drawing
123
 
 
124
 
 
125
 
        0.w                             X
126
 
 
127
 
        2.w                             Y
128
 
 
129
 
        4.w                             Code
130
 
 
131
 
        6.w     fedc ba98 7--- ----
132
 
                ---- ---- -6-- ----     Flip Y
133
 
                ---- ---- --5- ----     Flip X
134
 
                ---- ---- ---4 3210     Color
135
 
 
136
 
 
137
 
***************************************************************************/
138
 
 
139
 
static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
140
 
{
141
 
        yunsun16_state *state = machine.driver_data<yunsun16_state>();
142
 
        int offs;
143
 
        const rectangle &visarea = machine.primary_screen->visible_area();
144
 
 
145
 
        int max_x = visarea.max_x + 1;
146
 
        int max_y = visarea.max_y + 1;
147
 
 
148
 
        int pri = *state->m_priorityram & 3;
149
 
        int pri_mask;
150
 
 
151
 
        switch (pri)
152
 
        {
153
 
                case 1:
154
 
                        pri_mask = (1 << 1) | (1 << 2) | (1 << 3);
155
 
                        break;
156
 
                case 2:
157
 
                        pri_mask = (1 << 2) | (1 << 3);
158
 
                        break;
159
 
                case 3:
160
 
                default:
161
 
                        pri_mask = 0;
162
 
                        break;
163
 
        }
164
 
 
165
 
        for (offs = (state->m_spriteram_size - 8) / 2 ; offs >= 0; offs -= 8 / 2)
166
 
        {
167
 
                int x = state->m_spriteram[offs + 0];
168
 
                int y = state->m_spriteram[offs + 1];
169
 
                int code = state->m_spriteram[offs + 2];
170
 
                int attr = state->m_spriteram[offs + 3];
171
 
                int flipx = attr & 0x20;
172
 
                int flipy = attr & 0x40;
173
 
 
174
 
                x += state->m_sprites_scrolldx;
175
 
                y += state->m_sprites_scrolldy;
176
 
 
177
 
                if (flip_screen_get(machine))   // not used?
178
 
                {
179
 
                        flipx = !flipx;         x = max_x - x - 16;
180
 
                        flipy = !flipy;         y = max_y - y - 16;
181
 
                }
182
 
 
183
 
                pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
184
 
                                        code,
185
 
                                        attr & 0x1f,
186
 
                                        flipx, flipy,
187
 
                                        x,y,
188
 
                                        machine.priority_bitmap,
189
 
                                        pri_mask,15);
190
 
        }
191
 
}
192
 
 
193
 
 
194
 
/***************************************************************************
195
 
 
196
 
 
197
 
                                Screen Drawing
198
 
 
199
 
 
200
 
***************************************************************************/
201
 
 
202
 
 
203
 
SCREEN_UPDATE( yunsun16 )
204
 
{
205
 
        yunsun16_state *state = screen->machine().driver_data<yunsun16_state>();
206
 
 
207
 
        tilemap_set_scrollx(state->m_tilemap_0, 0, state->m_scrollram_0[0]);
208
 
        tilemap_set_scrolly(state->m_tilemap_0, 0, state->m_scrollram_0[1]);
209
 
 
210
 
        tilemap_set_scrollx(state->m_tilemap_1, 0, state->m_scrollram_1[0]);
211
 
        tilemap_set_scrolly(state->m_tilemap_1, 0, state->m_scrollram_1[1]);
212
 
 
213
 
        //popmessage("%04X", *state->m_priorityram);
214
 
 
215
 
        bitmap_fill(screen->machine().priority_bitmap, cliprect, 0);
216
 
 
217
 
        if ((*state->m_priorityram & 0x0c) == 4)
218
 
        {
219
 
                /* The color of the this layer's transparent pen goes below everything */
220
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_0, TILEMAP_DRAW_OPAQUE, 0);
221
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_0, 0, 1);
222
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_1, 0, 2);
223
 
        }
224
 
        else if ((*state->m_priorityram & 0x0c) == 8)
225
 
        {
226
 
                /* The color of the this layer's transparent pen goes below everything */
227
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_1, TILEMAP_DRAW_OPAQUE, 0);
228
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_1, 0, 1);
229
 
                tilemap_draw(bitmap, cliprect, state->m_tilemap_0, 0, 2);
230
 
        }
231
 
 
232
 
        draw_sprites(screen->machine(), bitmap, cliprect);
233
 
        return 0;
234
 
}