summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/tutankhm.cpp
blob: 8cd1a5a4bf62b3720695a9a12beaaee08decda9d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// license:BSD-3-Clause
// copyright-holders:Mirko Buffoni
/***************************************************************************

  video.c

  Functions to emulate the video hardware of the machine.

***************************************************************************/

#include "emu.h"
#include "includes/tutankhm.h"


/*************************************
 *
 *  Write handlers
 *
 *************************************/

WRITE_LINE_MEMBER(tutankhm_state::flip_screen_x_w)
{
	m_flip_x = state;
}


WRITE_LINE_MEMBER(tutankhm_state::flip_screen_y_w)
{
	m_flip_y = state;
}


/*************************************
 *
 *  Video update
 *
 *************************************/

uint32_t tutankhm_state::screen_update_tutankhm(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect)
{
	int xorx = m_flip_x ? 255 : 0;
	int xory = m_flip_y ? 255 : 0;

	for (int y = cliprect.min_y; y <= cliprect.max_y; y++)
	{
		uint32_t *dst = &bitmap.pix32(y);

		for (int x = cliprect.min_x; x <= cliprect.max_x; x++)
		{
			uint8_t effx = x ^ xorx;
			uint8_t yscroll = (effx < 192 && m_scroll.found()) ? *m_scroll : 0;
			uint8_t effy = (y ^ xory) + yscroll;
			uint8_t vrambyte = m_videoram[effy * 128 + effx / 2];
			uint8_t shifted = vrambyte >> (4 * (effx % 2));
			dst[x] = m_palette->pen_color(shifted & 0x0f);
		}
	}

	return 0;
}