1
/***************************************************************************
3
-= Yun Sung 16 Bit Games =-
5
driver by Luca Elia (l.elia@tin.it)
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)
17
Sprites are 16 x 16 x 4 in size. There's RAM for 512, but
18
the game just copies 384 entries.
21
***************************************************************************/
24
#include "includes/yunsun16.h"
27
/***************************************************************************
33
***************************************************************************/
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)
41
static TILEMAP_MAPPER( yunsun16_tilemap_scan_pages )
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) +
46
(col / TILES_PER_PAGE_X) * TILES_PER_PAGE_X * TILES_PER_PAGE_Y +
47
(col % TILES_PER_PAGE_X) * TILES_PER_PAGE_Y;
50
static TILE_GET_INFO( get_tile_info_0 )
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];
59
(attr & 0x20) ? TILE_FLIPX : 0);
62
static TILE_GET_INFO( get_tile_info_1 )
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];
71
(attr & 0x20) ? TILE_FLIPX : 0);
74
WRITE16_HANDLER( yunsun16_vram_0_w )
76
yunsun16_state *state = space->machine().driver_data<yunsun16_state>();
78
COMBINE_DATA(&state->m_vram_0[offset]);
79
tilemap_mark_tile_dirty(state->m_tilemap_0, offset / 2);
82
WRITE16_HANDLER( yunsun16_vram_1_w )
84
yunsun16_state *state = space->machine().driver_data<yunsun16_state>();
86
COMBINE_DATA(&state->m_vram_1[offset]);
87
tilemap_mark_tile_dirty(state->m_tilemap_1, offset / 2);
91
/***************************************************************************
97
***************************************************************************/
99
VIDEO_START( yunsun16 )
101
yunsun16_state *state = machine.driver_data<yunsun16_state>();
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);
108
tilemap_set_scrolldx(state->m_tilemap_0, -0x34, 0);
109
tilemap_set_scrolldx(state->m_tilemap_1, -0x38, 0);
111
tilemap_set_scrolldy(state->m_tilemap_0, -0x10, 0);
112
tilemap_set_scrolldy(state->m_tilemap_1, -0x10, 0);
114
tilemap_set_transparent_pen(state->m_tilemap_0, 0xff);
115
tilemap_set_transparent_pen(state->m_tilemap_1, 0xff);
119
/***************************************************************************
131
6.w fedc ba98 7--- ----
132
---- ---- -6-- ---- Flip Y
133
---- ---- --5- ---- Flip X
134
---- ---- ---4 3210 Color
137
***************************************************************************/
139
static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
141
yunsun16_state *state = machine.driver_data<yunsun16_state>();
143
const rectangle &visarea = machine.primary_screen->visible_area();
145
int max_x = visarea.max_x + 1;
146
int max_y = visarea.max_y + 1;
148
int pri = *state->m_priorityram & 3;
154
pri_mask = (1 << 1) | (1 << 2) | (1 << 3);
157
pri_mask = (1 << 2) | (1 << 3);
165
for (offs = (state->m_spriteram_size - 8) / 2 ; offs >= 0; offs -= 8 / 2)
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;
174
x += state->m_sprites_scrolldx;
175
y += state->m_sprites_scrolldy;
177
if (flip_screen_get(machine)) // not used?
179
flipx = !flipx; x = max_x - x - 16;
180
flipy = !flipy; y = max_y - y - 16;
183
pdrawgfx_transpen(bitmap,cliprect,machine.gfx[1],
188
machine.priority_bitmap,
194
/***************************************************************************
200
***************************************************************************/
203
SCREEN_UPDATE( yunsun16 )
205
yunsun16_state *state = screen->machine().driver_data<yunsun16_state>();
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]);
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]);
213
//popmessage("%04X", *state->m_priorityram);
215
bitmap_fill(screen->machine().priority_bitmap, cliprect, 0);
217
if ((*state->m_priorityram & 0x0c) == 4)
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);
224
else if ((*state->m_priorityram & 0x0c) == 8)
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);
232
draw_sprites(screen->machine(), bitmap, cliprect);