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

« back to all changes in this revision

Viewing changes to mess/src/mame/video/m10.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.c
4
 
 
5
 
  Functions to emulate the video hardware of the machine.
6
 
 
7
 
  (c) 12/2/1998 Lee Taylor
8
 
 
9
 
  2006 - major rewrite by couriersud
10
 
 
11
 
***************************************************************************/
12
 
 
13
 
#include "emu.h"
14
 
#include "includes/m10.h"
15
 
 
16
 
static const UINT32 extyoffs[] =
17
 
{
18
 
        STEP256(0, 8)
19
 
};
20
 
 
21
 
 
22
 
static const gfx_layout backlayout =
23
 
{
24
 
        8,8*32, /* 8*(8*32) characters */
25
 
        4,              /* 4 characters */
26
 
        1,              /* 1 bit per pixel */
27
 
        { 0 },
28
 
        { 0, 1, 2, 3, 4, 5, 6, 7 },
29
 
        EXTENDED_YOFFS,
30
 
        32*8*8, /* every char takes 8 consecutive bytes */
31
 
        NULL, extyoffs
32
 
};
33
 
 
34
 
static const gfx_layout charlayout =
35
 
{
36
 
        8,8,    /* 8*8 characters */
37
 
        256,    /* 256 characters */
38
 
        1,              /* 1 bit per pixel */
39
 
        { 0 },
40
 
        { 0, 1, 2, 3, 4, 5, 6, 7 },
41
 
        { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
42
 
        8*8     /* every char takes 8 consecutive bytes */
43
 
};
44
 
 
45
 
static UINT32 tilemap_scan( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
46
 
{
47
 
        return (31 - col) * 32 + row;
48
 
}
49
 
 
50
 
 
51
 
static void get_tile_info( running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param )
52
 
{
53
 
        m10_state *state = machine.driver_data<m10_state>();
54
 
 
55
 
        SET_TILE_INFO(0, state->m_videoram[tile_index], state->m_colorram[tile_index] & 0x07, 0);
56
 
}
57
 
 
58
 
 
59
 
WRITE8_HANDLER( m10_colorram_w )
60
 
{
61
 
        m10_state *state = space->machine().driver_data<m10_state>();
62
 
 
63
 
        if (state->m_colorram[offset] != data)
64
 
        {
65
 
                tilemap_mark_tile_dirty(state->m_tx_tilemap, offset);
66
 
                state->m_colorram[offset] = data;
67
 
        }
68
 
}
69
 
 
70
 
 
71
 
WRITE8_HANDLER( m10_chargen_w )
72
 
{
73
 
        m10_state *state = space->machine().driver_data<m10_state>();
74
 
 
75
 
        if (state->m_chargen[offset] != data)
76
 
        {
77
 
                state->m_chargen[offset] = data;
78
 
                gfx_element_mark_dirty(state->m_back_gfx, offset >> (3 + 5));
79
 
        }
80
 
}
81
 
 
82
 
 
83
 
WRITE8_HANDLER( m15_chargen_w )
84
 
{
85
 
        m10_state *state = space->machine().driver_data<m10_state>();
86
 
 
87
 
        if (state->m_chargen[offset] != data)
88
 
        {
89
 
                state->m_chargen[offset] = data;
90
 
                gfx_element_mark_dirty(space->machine().gfx[0], offset >> 3);
91
 
        }
92
 
}
93
 
 
94
 
 
95
 
INLINE void plot_pixel_m10( running_machine &machine, bitmap_t *bm, int x, int y, int col )
96
 
{
97
 
        m10_state *state = machine.driver_data<m10_state>();
98
 
 
99
 
        if (!state->m_flip)
100
 
                *BITMAP_ADDR16(bm, y, x) = col;
101
 
        else
102
 
                *BITMAP_ADDR16(bm, (IREMM10_VBSTART - 1) - (y - IREMM10_VBEND) + 6,
103
 
                                (IREMM10_HBSTART - 1) - (x - IREMM10_HBEND)) = col; // only when flip_screen(?)
104
 
}
105
 
 
106
 
VIDEO_START( m10 )
107
 
{
108
 
        m10_state *state = machine.driver_data<m10_state>();
109
 
 
110
 
        state->m_tx_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan, 8, 8, 32, 32);
111
 
        tilemap_set_transparent_pen(state->m_tx_tilemap, 0);
112
 
        tilemap_set_scrolldx(state->m_tx_tilemap, 0, 62);
113
 
        tilemap_set_scrolldy(state->m_tx_tilemap, 0, 0);
114
 
 
115
 
        state->m_back_gfx = gfx_element_alloc(machine, &backlayout, state->m_chargen, 8, 0);
116
 
 
117
 
        machine.gfx[1] = state->m_back_gfx;
118
 
        return ;
119
 
}
120
 
 
121
 
VIDEO_START( m15 )
122
 
{
123
 
        m10_state *state = machine.driver_data<m10_state>();
124
 
 
125
 
        machine.gfx[0] = gfx_element_alloc(machine, &charlayout, state->m_chargen, 8, 0);
126
 
 
127
 
        state->m_tx_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan, 8, 8, 32, 32);
128
 
        tilemap_set_scrolldx(state->m_tx_tilemap, 0, 116);
129
 
        tilemap_set_scrolldy(state->m_tx_tilemap, 0, 0);
130
 
 
131
 
        return ;
132
 
}
133
 
 
134
 
/***************************************************************************
135
 
 
136
 
  Draw the game screen in the given bitmap_t.
137
 
 
138
 
***************************************************************************/
139
 
 
140
 
SCREEN_UPDATE( m10 )
141
 
{
142
 
        m10_state *state = screen->machine().driver_data<m10_state>();
143
 
        int offs;
144
 
        static const int color[4]= { 3, 3, 5, 5 };
145
 
        static const int xpos[4] = { 4*8, 26*8, 7*8, 6*8};
146
 
        int i;
147
 
 
148
 
        bitmap_fill(bitmap, cliprect, 0);
149
 
 
150
 
        for (i = 0; i < 4; i++)
151
 
                if (state->m_flip)
152
 
                        drawgfx_opaque(bitmap, cliprect, state->m_back_gfx, i, color[i], 1, 1, 31 * 8 - xpos[i], 6);
153
 
                else
154
 
                        drawgfx_opaque(bitmap, cliprect, state->m_back_gfx, i, color[i], 0, 0, xpos[i], 0);
155
 
 
156
 
        if (state->m_bottomline)
157
 
        {
158
 
                int y;
159
 
 
160
 
                for (y = IREMM10_VBEND; y < IREMM10_VBSTART; y++)
161
 
                        plot_pixel_m10(screen->machine(), bitmap, 16, y, 1);
162
 
        }
163
 
 
164
 
        for (offs = state->m_videoram_size - 1; offs >= 0; offs--)
165
 
                tilemap_mark_tile_dirty(state->m_tx_tilemap, offs);
166
 
 
167
 
        tilemap_set_flip(state->m_tx_tilemap, state->m_flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
168
 
        tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0);
169
 
 
170
 
        return 0;
171
 
}
172
 
 
173
 
 
174
 
/***************************************************************************
175
 
 
176
 
  Draw the game screen in the given bitmap_t.
177
 
 
178
 
***************************************************************************/
179
 
 
180
 
SCREEN_UPDATE( m15 )
181
 
{
182
 
        m10_state *state = screen->machine().driver_data<m10_state>();
183
 
        int offs;
184
 
 
185
 
        for (offs = state->m_videoram_size - 1; offs >= 0; offs--)
186
 
                tilemap_mark_tile_dirty(state->m_tx_tilemap, offs);
187
 
 
188
 
        //tilemap_mark_all_tiles_dirty(state->m_tx_tilemap);
189
 
        tilemap_set_flip(state->m_tx_tilemap, state->m_flip ? TILEMAP_FLIPX | TILEMAP_FLIPY : 0);
190
 
        tilemap_draw(bitmap, cliprect, state->m_tx_tilemap, 0, 0);
191
 
 
192
 
        return 0;
193
 
}