summaryrefslogtreecommitdiffstatshomepage
path: root/src/mame/video/aztarac.c
blob: 44a8bfe5040bd9937e68bb5cda61afe2876725ea (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
/*************************************************************************

    Centuri Aztarac hardware

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

#include "emu.h"
#include "video/vector.h"
#include "includes/aztarac.h"

#define AVECTOR(m, x, y, color, intensity) \
vector_add_point (m, state->m_xcenter + ((x) << 16), state->m_ycenter - ((y) << 16), color, intensity)



INLINE void read_vectorram(UINT16 *vectorram, int addr, int *x, int *y, int *c)
{
    *c = vectorram[addr] & 0xffff;
    *x = vectorram[addr + 0x800] & 0x03ff;
    *y = vectorram[addr + 0x1000] & 0x03ff;
    if (*x & 0x200) *x |= 0xfffffc00;
    if (*y & 0x200) *y |= 0xfffffc00;
}

WRITE16_HANDLER( aztarac_ubr_w )
{
    aztarac_state *state = space->machine().driver_data<aztarac_state>();
    UINT16 *vectorram = state->m_vectorram;
    int x, y, c, intensity, xoffset, yoffset, color;
    int defaddr, objaddr=0, ndefs;

    if (data) /* data is the global intensity (always 0xff in Aztarac). */
    {
        vector_clear_list();

        while (1)
        {
            read_vectorram(vectorram, objaddr, &xoffset, &yoffset, &c);
            objaddr++;

            if (c & 0x4000)
                break;

            if ((c & 0x2000) == 0)
            {
                defaddr = (c >> 1) & 0x7ff;
                AVECTOR (space->machine(), xoffset, yoffset, 0, 0);

                read_vectorram(vectorram, defaddr, &x, &ndefs, &c);
                ndefs++;

                if (c & 0xff00)
                {
                    /* latch color only once */
                    intensity = (c >> 8);
                    color = VECTOR_COLOR222(c & 0x3f);
                    while (ndefs--)
                    {
                        defaddr++;
                        read_vectorram(vectorram, defaddr, &x, &y, &c);
                        if ((c & 0xff00) == 0)
                            AVECTOR (space->machine(), x + xoffset, y + yoffset, 0, 0);
                        else
                            AVECTOR (space->machine(), x + xoffset, y + yoffset, color, intensity);
                    }
                }
                else
                {
                    /* latch color for every definition */
                    while (ndefs--)
                    {
                        defaddr++;
                        read_vectorram(vectorram, defaddr, &x, &y, &c);
                        color = VECTOR_COLOR222(c & 0x3f);
                        AVECTOR (space->machine(), x + xoffset, y + yoffset, color, c >> 8);
                    }
                }
            }
        }
    }
}


VIDEO_START( aztarac )
{
	aztarac_state *state = machine.driver_data<aztarac_state>();
	const rectangle &visarea = machine.primary_screen->visible_area();

	int xmin = visarea.min_x;
	int ymin = visarea.min_y;
	int xmax = visarea.max_x;
	int ymax = visarea.max_y;

	state->m_xcenter=((xmax + xmin) / 2) << 16;
	state->m_ycenter=((ymax + ymin) / 2) << 16;

	VIDEO_START_CALL(vector);
}