summaryrefslogblamecommitdiffstatshomepage
path: root/src/mame/video/aztarac.cpp
blob: ed2176115b3ccbba08b9c4ad90ac01082c2aea72 (plain) (tree)
1
2
3
4
5
6
7
8
9

                                      





                                                                          
                
                             
 

                                                                                        
 
 
 





                                                                   
                                                                                                
 




                                               

 
                                       
 


                                                        

                                                          

                                                                              
                                       


                         
                                                                                     







                                                           
                                                                 
 
                                                                                     





                                                                   
                                                                                  


                                                          
                                                                                                 
                                                                      
                                                                                                 
                                                    
                                                                                                             







                                                                              
                                                                                                 
                                                                                          
                                                                                                  




                                         


 
                                 
 
                                                            
 



                                 
 

                                            
 
// license:BSD-3-Clause
// copyright-holders:Mathis Rosenhauer
/*************************************************************************

    Centuri Aztarac hardware

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

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

#define AVECTOR(x, y, color, intensity) \
m_vector->add_point (m_xcenter + ((x) << 16), m_ycenter - ((y) << 16), color, intensity)



WRITE_LINE_MEMBER(aztarac_state::video_interrupt)
{
	if (state)
		m_maincpu->set_input_line(M68K_IRQ_4, ASSERT_LINE);
}

inline void aztarac_state::read_vectorram(uint16_t *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;
}

void aztarac_state::ubr_w(uint8_t data)
{
	int x, y, c, intensity, xoffset, yoffset, color;
	int defaddr, objaddr=0, ndefs;

	m_maincpu->set_input_line(M68K_IRQ_4, CLEAR_LINE);

	if (data) /* data is the global intensity (always 0xff in Aztarac). */
	{
		m_vector->clear_list();

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

			if (c & 0x4000)
				break;

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

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

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


void aztarac_state::video_start()
{
	const rectangle &visarea = m_screen->visible_area();

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

	m_xcenter=((xmax + xmin) / 2) << 16;
	m_ycenter=((ymax + ymin) / 2) << 16;
}