1
/***************************************************************************
5
Functions to emulate the video hardware of the machine.
7
(c) 12/2/1998 Lee Taylor
9
2006 - major rewrite by couriersud
11
***************************************************************************/
14
#include "includes/m10.h"
16
static const UINT32 extyoffs[] =
22
static const gfx_layout backlayout =
24
8,8*32, /* 8*(8*32) characters */
26
1, /* 1 bit per pixel */
28
{ 0, 1, 2, 3, 4, 5, 6, 7 },
30
32*8*8, /* every char takes 8 consecutive bytes */
34
static const gfx_layout charlayout =
36
8,8, /* 8*8 characters */
37
256, /* 256 characters */
38
1, /* 1 bit per pixel */
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 */
45
static UINT32 tilemap_scan( UINT32 col, UINT32 row, UINT32 num_cols, UINT32 num_rows )
47
return (31 - col) * 32 + row;
51
static void get_tile_info( running_machine &machine, tile_data *tileinfo, tilemap_memory_index tile_index, void *param )
53
m10_state *state = machine.driver_data<m10_state>();
55
SET_TILE_INFO(0, state->m_videoram[tile_index], state->m_colorram[tile_index] & 0x07, 0);
59
WRITE8_HANDLER( m10_colorram_w )
61
m10_state *state = space->machine().driver_data<m10_state>();
63
if (state->m_colorram[offset] != data)
65
tilemap_mark_tile_dirty(state->m_tx_tilemap, offset);
66
state->m_colorram[offset] = data;
71
WRITE8_HANDLER( m10_chargen_w )
73
m10_state *state = space->machine().driver_data<m10_state>();
75
if (state->m_chargen[offset] != data)
77
state->m_chargen[offset] = data;
78
gfx_element_mark_dirty(state->m_back_gfx, offset >> (3 + 5));
83
WRITE8_HANDLER( m15_chargen_w )
85
m10_state *state = space->machine().driver_data<m10_state>();
87
if (state->m_chargen[offset] != data)
89
state->m_chargen[offset] = data;
90
gfx_element_mark_dirty(space->machine().gfx[0], offset >> 3);
95
INLINE void plot_pixel_m10( running_machine &machine, bitmap_t *bm, int x, int y, int col )
97
m10_state *state = machine.driver_data<m10_state>();
100
*BITMAP_ADDR16(bm, y, x) = col;
102
*BITMAP_ADDR16(bm, (IREMM10_VBSTART - 1) - (y - IREMM10_VBEND) + 6,
103
(IREMM10_HBSTART - 1) - (x - IREMM10_HBEND)) = col; // only when flip_screen(?)
108
m10_state *state = machine.driver_data<m10_state>();
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);
115
state->m_back_gfx = gfx_element_alloc(machine, &backlayout, state->m_chargen, 8, 0);
117
machine.gfx[1] = state->m_back_gfx;
123
m10_state *state = machine.driver_data<m10_state>();
125
machine.gfx[0] = gfx_element_alloc(machine, &charlayout, state->m_chargen, 8, 0);
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);
134
/***************************************************************************
136
Draw the game screen in the given bitmap_t.
138
***************************************************************************/
142
m10_state *state = screen->machine().driver_data<m10_state>();
144
static const int color[4]= { 3, 3, 5, 5 };
145
static const int xpos[4] = { 4*8, 26*8, 7*8, 6*8};
148
bitmap_fill(bitmap, cliprect, 0);
150
for (i = 0; i < 4; i++)
152
drawgfx_opaque(bitmap, cliprect, state->m_back_gfx, i, color[i], 1, 1, 31 * 8 - xpos[i], 6);
154
drawgfx_opaque(bitmap, cliprect, state->m_back_gfx, i, color[i], 0, 0, xpos[i], 0);
156
if (state->m_bottomline)
160
for (y = IREMM10_VBEND; y < IREMM10_VBSTART; y++)
161
plot_pixel_m10(screen->machine(), bitmap, 16, y, 1);
164
for (offs = state->m_videoram_size - 1; offs >= 0; offs--)
165
tilemap_mark_tile_dirty(state->m_tx_tilemap, offs);
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);
174
/***************************************************************************
176
Draw the game screen in the given bitmap_t.
178
***************************************************************************/
182
m10_state *state = screen->machine().driver_data<m10_state>();
185
for (offs = state->m_videoram_size - 1; offs >= 0; offs--)
186
tilemap_mark_tile_dirty(state->m_tx_tilemap, offs);
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);