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

« back to all changes in this revision

Viewing changes to mess/src/mame/video/battlex.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 emulation for Omori Battle Cross
4
 
 
5
 
***************************************************************************/
6
 
 
7
 
#include "emu.h"
8
 
#include "includes/battlex.h"
9
 
 
10
 
 
11
 
WRITE8_HANDLER( battlex_palette_w )
12
 
{
13
 
        palette_set_color_rgb(space->machine(), offset, pal1bit(data >> 0), pal1bit(data >> 2), pal1bit(data >> 1));
14
 
}
15
 
 
16
 
WRITE8_HANDLER( battlex_scroll_x_lsb_w )
17
 
{
18
 
        battlex_state *state = space->machine().driver_data<battlex_state>();
19
 
        state->m_scroll_lsb = data;
20
 
}
21
 
 
22
 
WRITE8_HANDLER( battlex_scroll_x_msb_w )
23
 
{
24
 
        battlex_state *state = space->machine().driver_data<battlex_state>();
25
 
        state->m_scroll_msb = data;
26
 
}
27
 
 
28
 
WRITE8_HANDLER( battlex_scroll_starfield_w )
29
 
{
30
 
}
31
 
 
32
 
WRITE8_HANDLER( battlex_videoram_w )
33
 
{
34
 
        battlex_state *state = space->machine().driver_data<battlex_state>();
35
 
        state->m_videoram[offset] = data;
36
 
        tilemap_mark_tile_dirty(state->m_bg_tilemap, offset / 2);
37
 
}
38
 
 
39
 
WRITE8_HANDLER( battlex_flipscreen_w )
40
 
{
41
 
        battlex_state *state = space->machine().driver_data<battlex_state>();
42
 
        state->m_starfield_enabled = data & 0x10;
43
 
 
44
 
        if (flip_screen_get(space->machine()) != (data >> 7))
45
 
        {
46
 
                flip_screen_set(space->machine(), data & 0x80);
47
 
                tilemap_mark_all_tiles_dirty_all(space->machine());
48
 
        }
49
 
}
50
 
 
51
 
 
52
 
static TILE_GET_INFO( get_bg_tile_info )
53
 
{
54
 
        battlex_state *state = machine.driver_data<battlex_state>();
55
 
        int tile = state->m_videoram[tile_index * 2] | (((state->m_videoram[tile_index * 2 + 1] & 0x01)) << 8);
56
 
        int color = (state->m_videoram[tile_index * 2 + 1] & 0x0e) >> 1; // high bits unused
57
 
 
58
 
        SET_TILE_INFO(0, tile, color, 0);
59
 
}
60
 
 
61
 
VIDEO_START( battlex )
62
 
{
63
 
        battlex_state *state = machine.driver_data<battlex_state>();
64
 
        state->m_bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
65
 
}
66
 
 
67
 
static void draw_sprites( running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect )
68
 
{
69
 
        battlex_state *state = machine.driver_data<battlex_state>();
70
 
        const gfx_element *gfx = machine.gfx[1];
71
 
        UINT8 *source = state->m_spriteram;
72
 
        UINT8 *finish = state->m_spriteram + 0x200;
73
 
 
74
 
        while (source < finish)
75
 
        {
76
 
                int sx = (source[0] & 0x7f) * 2 - (source[0] & 0x80) * 2;
77
 
                int sy = source[3];
78
 
                int tile = source[2] & 0x7f;
79
 
                int color = source[1] & 0x07;   /* bits 3,4,5 also used during explosions */
80
 
                int flipy = source[1] & 0x80;
81
 
                int flipx = source[1] & 0x40;
82
 
 
83
 
                if (flip_screen_get(machine))
84
 
                {
85
 
                        sx = 240 - sx;
86
 
                        sy = 240 - sy;
87
 
                        flipx = !flipx;
88
 
                        flipy = !flipy;
89
 
                }
90
 
 
91
 
                drawgfx_transpen(bitmap, cliprect, gfx, tile, color, flipx, flipy, sx, sy, 0);
92
 
                source += 4;
93
 
        }
94
 
 
95
 
}
96
 
 
97
 
 
98
 
SCREEN_UPDATE(battlex)
99
 
{
100
 
        battlex_state *state = screen->machine().driver_data<battlex_state>();
101
 
 
102
 
        tilemap_set_scrollx(state->m_bg_tilemap, 0, state->m_scroll_lsb | (state->m_scroll_msb << 8));
103
 
        tilemap_draw(bitmap, cliprect, state->m_bg_tilemap, 0, 0);
104
 
        draw_sprites(screen->machine(), bitmap, cliprect);
105
 
 
106
 
        return 0;
107
 
}