summaryrefslogtreecommitdiffstatshomepage
path: root/src/mess/video/nc.c
blob: b381e8523e60aaef2b75548598569ccd08bfae99 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/***************************************************************************

  nc.c

  Functions to emulate the video hardware of the Amstrad PCW.

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

#include "emu.h"
#include "includes/nc.h"
#include "machine/ram.h"

/***************************************************************************
  Start the video hardware emulation.
***************************************************************************/

void nc_state::video_start()
{
}

/* two colours */
static const unsigned short nc_colour_table[NC_NUM_COLOURS] =
{
	0, 1,2,3
};

/* black/white */
static const rgb_t nc_palette[NC_NUM_COLOURS] =
{
	MAKE_RGB(0x060, 0x060, 0x060),
	MAKE_RGB(0x000, 0x000, 0x000),
	MAKE_RGB(0x080, 0x0a0, 0x060),
    MAKE_RGB(0x000, 0x000, 0x000)
};


/* Initialise the palette */
void nc_state::palette_init()
{
	palette_set_colors(machine(), 0, nc_palette, ARRAY_LENGTH(nc_palette));
}


void nc200_video_set_backlight(running_machine &machine, int state)
{
	nc_state *drvstate = machine.driver_data<nc_state>();
	drvstate->m_nc200_backlight = state;
}


/***************************************************************************
  Draw the game screen in the given bitmap_ind16.
  Do NOT call osd_update_display() from this function,
  it will be called by the main emulation engine.
***************************************************************************/
UINT32 nc_state::screen_update_nc(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	int y;
	int b;
	int x;
	int height, width;
	int pens[2];

    if (m_type==NC_TYPE_200)
    {
        height = NC200_SCREEN_HEIGHT;
        width = NC200_SCREEN_WIDTH;

		if (m_nc200_backlight)
		{
			pens[0] = 2;
			pens[1] = 3;
		}
		else
		{
			pens[0] = 0;
			pens[1] = 1;
		}
    }
    else
    {
		height = NC_SCREEN_HEIGHT;
		width = NC_SCREEN_WIDTH;
		pens[0] = 2;
		pens[1] = 3;
	}


    for (y=0; y<height; y++)
    {
		int by;
		/* 64 bytes per line */
		char *line_ptr = ((char*)machine().device<ram_device>(RAM_TAG)->pointer()) + m_display_memory_start + (y<<6);

		x = 0;
		for (by=0; by<width>>3; by++)
		{
			int px;
			unsigned char byte;

			byte = line_ptr[0];

			px = x;
			for (b=0; b<8; b++)
			{
				bitmap.pix16(y, px) = pens[(byte>>7) & 0x01];
				byte = byte<<1;
				px++;
			}

			x = px;

			line_ptr = line_ptr+1;
		}
	}
	return 0;
}