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

« back to all changes in this revision

Viewing changes to mess/src/mame/video/targeth.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
 
  Target Hits Video Hardware
4
 
 
5
 
  Functions to emulate the video hardware of the machine
6
 
 
7
 
***************************************************************************/
8
 
 
9
 
#include "emu.h"
10
 
#include "includes/targeth.h"
11
 
 
12
 
 
13
 
/***************************************************************************
14
 
 
15
 
    Callbacks for the TileMap code
16
 
 
17
 
***************************************************************************/
18
 
 
19
 
/*
20
 
    Tile format
21
 
    -----------
22
 
 
23
 
    Screen 0 & 1: (64*32, 16x16 tiles)
24
 
 
25
 
    Word | Bit(s)            | Description
26
 
    -----+-FEDCBA98-76543210-+--------------------------
27
 
      0  | --xxxxxx xxxxxxxx | code
28
 
      0  | xx------ -------- | not used?
29
 
      1  | -------- ---xxxxx | color (uses 1st half of the palette)
30
 
      1  | -------- --x----- | flip y
31
 
      1  | -------- -x------ | flip x
32
 
      1  | xxxxxxxx x------- | not used?
33
 
*/
34
 
 
35
 
static TILE_GET_INFO( get_tile_info_targeth_screen0 )
36
 
{
37
 
        targeth_state *state = machine.driver_data<targeth_state>();
38
 
        int data = state->m_videoram[tile_index << 1];
39
 
        int data2 = state->m_videoram[(tile_index << 1) + 1];
40
 
        int code = data & 0x3fff;
41
 
 
42
 
        SET_TILE_INFO(0, code, data2 & 0x1f, TILE_FLIPXY((data2 >> 5) & 0x03));
43
 
}
44
 
 
45
 
static TILE_GET_INFO( get_tile_info_targeth_screen1 )
46
 
{
47
 
        targeth_state *state = machine.driver_data<targeth_state>();
48
 
        int data = state->m_videoram[(0x2000/2) + (tile_index << 1)];
49
 
        int data2 = state->m_videoram[(0x2000/2) + (tile_index << 1) + 1];
50
 
        int code = data & 0x3fff;
51
 
 
52
 
        SET_TILE_INFO(0, code, data2 & 0x1f, TILE_FLIPXY((data2 >> 5) & 0x03));
53
 
}
54
 
 
55
 
/***************************************************************************
56
 
 
57
 
    Memory Handlers
58
 
 
59
 
***************************************************************************/
60
 
 
61
 
WRITE16_HANDLER( targeth_vram_w )
62
 
{
63
 
        targeth_state *state = space->machine().driver_data<targeth_state>();
64
 
        state->m_videoram[offset] = data;
65
 
        tilemap_mark_tile_dirty(state->m_pant[(offset & 0x1fff) >> 12], ((offset << 1) & 0x1fff) >> 2);
66
 
}
67
 
 
68
 
 
69
 
/***************************************************************************
70
 
 
71
 
    Start/Stop the video hardware emulation.
72
 
 
73
 
***************************************************************************/
74
 
 
75
 
VIDEO_START( targeth )
76
 
{
77
 
        targeth_state *state = machine.driver_data<targeth_state>();
78
 
        state->m_pant[0] = tilemap_create(machine, get_tile_info_targeth_screen0,tilemap_scan_rows,16,16,64,32);
79
 
        state->m_pant[1] = tilemap_create(machine, get_tile_info_targeth_screen1,tilemap_scan_rows,16,16,64,32);
80
 
 
81
 
        tilemap_set_transparent_pen(state->m_pant[0],0);
82
 
}
83
 
 
84
 
 
85
 
/***************************************************************************
86
 
 
87
 
    Sprites
88
 
 
89
 
***************************************************************************/
90
 
 
91
 
/*
92
 
    Sprite Format
93
 
    -------------
94
 
 
95
 
    Word | Bit(s)            | Description
96
 
    -----+-FEDCBA98-76543210-+--------------------------
97
 
      0  | -------- xxxxxxxx | y position
98
 
      0  | --xxxxxx -------- | not used?
99
 
      0  | -x------ -------- | flipx
100
 
      0  | x------- -------- | flipy
101
 
      1  | xxxxxxxx xxxxxxxx | not used?
102
 
      2  | ------xx xxxxxxxx | x position
103
 
      2  | -xxxxx-- -------- | sprite color (uses 2nd half of the palette)
104
 
      3  | --xxxxxx xxxxxxxx | sprite code
105
 
      3  | xx------ -------- | not used?
106
 
*/
107
 
 
108
 
static void draw_sprites(running_machine &machine, bitmap_t *bitmap, const rectangle *cliprect)
109
 
{
110
 
        targeth_state *state = machine.driver_data<targeth_state>();
111
 
        int i;
112
 
        const gfx_element *gfx = machine.gfx[0];
113
 
 
114
 
        for (i = 3; i < (0x1000 - 6)/2; i += 4){
115
 
                int sx = state->m_spriteram[i+2] & 0x03ff;
116
 
                int sy = (240 - (state->m_spriteram[i] & 0x00ff)) & 0x00ff;
117
 
                int number = state->m_spriteram[i+3] & 0x3fff;
118
 
                int color = (state->m_spriteram[i+2] & 0x7c00) >> 10;
119
 
                int attr = (state->m_spriteram[i] & 0xfe00) >> 9;
120
 
 
121
 
                int xflip = attr & 0x20;
122
 
                int yflip = attr & 0x40;
123
 
 
124
 
                drawgfx_transpen(bitmap,cliprect,gfx,number,
125
 
                                0x20 + color,xflip,yflip,
126
 
                                sx - 0x0f,sy,0);
127
 
        }
128
 
}
129
 
 
130
 
/***************************************************************************
131
 
 
132
 
    Display Refresh
133
 
 
134
 
***************************************************************************/
135
 
 
136
 
SCREEN_UPDATE( targeth )
137
 
{
138
 
        targeth_state *state = screen->machine().driver_data<targeth_state>();
139
 
        /* set scroll registers */
140
 
        tilemap_set_scrolly(state->m_pant[0], 0, state->m_vregs[0]);
141
 
        tilemap_set_scrollx(state->m_pant[0], 0, state->m_vregs[1] + 0x04);
142
 
        tilemap_set_scrolly(state->m_pant[1], 0, state->m_vregs[2]);
143
 
        tilemap_set_scrollx(state->m_pant[1], 0, state->m_vregs[3]);
144
 
 
145
 
        tilemap_draw(bitmap,cliprect,state->m_pant[1],0,0);
146
 
        tilemap_draw(bitmap,cliprect,state->m_pant[0],0,0);
147
 
        draw_sprites(screen->machine(), bitmap,cliprect);
148
 
 
149
 
        return 0;
150
 
}