예제 #1
0
void SDLWrapper::createWindow(std::string windowtitle, int x, int y, int width, int height){
    _window = SDL_CreateWindow(windowtitle.c_str(), x, y, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
    if (_window == nullptr){
        _logerror(std::cout, "SDL_CreateWindow");
    }
    _renderer = SDL_CreateRenderer(_window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);
    if (_renderer == nullptr){
        _logerror(std::cout, "SDL_CreateRenderer");
    }
}
예제 #2
0
SDLWrapper::SDLWrapper()
{
    if (SDL_Init(SDL_INIT_EVERYTHING) != 0){
        _logerror(std::cout, "SDL_Init");
        _sdlwrapperfailedtoinit = 0;
    }
    if (TTF_Init() != 0){
        _logerror(std::cout, "TTF_Init");
        _sdlwrapperfailedtoinit = 1;
    }
}
예제 #3
0
SDL_Texture* SDLWrapper::_rendertext(const std::string &message, SDL_Color color){
    SDL_Surface *surface = TTF_RenderText_Blended(_font, message.c_str(), color);
    if (surface == nullptr){
        _logerror(std::cout, "TTF_RenderText");
        return nullptr;
    }
    SDL_Texture *texture = SDL_CreateTextureFromSurface(_renderer, surface);
    if (texture == nullptr){
        _logerror(std::cout, "CreateTextureFromSurface");
    }
    SDL_FreeSurface(surface);
    return texture;
}
예제 #4
0
void pcf8593_device::device_start()
{
	_logerror( 0, ("pcf8593_init\n"));
	memset(m_register, 0, sizeof(m_register));
	m_timer = timer_alloc(TIMER_UPDATE_COUNTER);
	m_timer->adjust(attotime::from_seconds(1), 0, attotime::from_seconds(1));
}
예제 #5
0
void cybiko_state::cybiko_rs232_pin_sck( int data )
{
	_logerror( 3, ("cybiko_rs232_pin_sck (%d)\n", data));
	// clock high-to-low
	if ((m_rs232.pin.sck == 1) && (data == 0))
	{
		// transmit
		if (m_rs232.pin.txd) m_rs232.tx_byte = m_rs232.tx_byte | (1 << m_rs232.tx_bits);
		m_rs232.tx_bits++;
		if (m_rs232.tx_bits == 8)
		{
			m_rs232.tx_bits = 0;
			cybiko_rs232_write_byte(m_rs232.tx_byte);
			m_rs232.tx_byte = 0;
		}
		// receive
		m_rs232.pin.rxd = (m_rs232.rx_byte >> m_rs232.rx_bits) & 1;
		m_rs232.rx_bits++;
		if (m_rs232.rx_bits == 8)
		{
			m_rs232.rx_bits = 0;
			m_rs232.rx_byte = 0;
		}
	}
	// save sck
	m_rs232.pin.sck = data;
}
예제 #6
0
파일: cybiko.c 프로젝트: cdenix/psmame
static void cybiko_rs232_pin_sck(cybiko_state *state, int data)
{
	_logerror( 3, ("cybiko_rs232_pin_sck (%d)\n", data));
	// clock high-to-low
	if ((state->m_rs232.pin.sck == 1) && (data == 0))
	{
		// transmit
		if (state->m_rs232.pin.txd) state->m_rs232.tx_byte = state->m_rs232.tx_byte | (1 << state->m_rs232.tx_bits);
		state->m_rs232.tx_bits++;
		if (state->m_rs232.tx_bits == 8)
		{
			state->m_rs232.tx_bits = 0;
			cybiko_rs232_write_byte( state->m_rs232.tx_byte);
			state->m_rs232.tx_byte = 0;
		}
		// receive
		state->m_rs232.pin.rxd = (state->m_rs232.rx_byte >> state->m_rs232.rx_bits) & 1;
		state->m_rs232.rx_bits++;
		if (state->m_rs232.rx_bits == 8)
		{
			state->m_rs232.rx_bits = 0;
			state->m_rs232.rx_byte = 0;
		}
	}
	// save sck
	state->m_rs232.pin.sck = data;
}
예제 #7
0
파일: cybiko.c 프로젝트: cdenix/psmame
static void cybiko_rs232_init(running_machine &machine)
{
	cybiko_state *state = machine.driver_data<cybiko_state>();
	_logerror( 0, ("cybiko_rs232_init\n"));
	memset( &state->m_rs232, 0, sizeof( state->m_rs232));
//  machine.scheduler().timer_pulse(TIME_IN_HZ( 10), FUNC(rs232_timer_callback));
}
예제 #8
0
SDL_Texture* SDLWrapper::_loadtexture(const std::string &file, SDL_Renderer *renderer){
    SDL_Texture *texture = IMG_LoadTexture(renderer, file.c_str());
    if (texture == nullptr){
        _logerror(std::cout, "LoadTexture");
    }
    return texture;
}
예제 #9
0
파일: cybiko.c 프로젝트: cdenix/psmame
static WRITE8_HANDLER( cybiko_io_reg_w )
{
	cybiko_state *state = space->machine().driver_data<cybiko_state>();
	device_t *rtc = space->machine().device("rtc");
	device_t *speaker = space->machine().device("speaker");

	_logerror( 2, ("cybiko_io_reg_w (%08X/%02X)\n", offset, data));
	switch (offset)
	{
		// speaker
		case H8S_IO_P1DR : speaker_level_w( speaker, (data & H8S_P1_TIOCB1) ? 1 : 0); break;
		// serial dataflash
		case H8S_IO_P3DR :
		{
			device_t *device = space->machine().device("flash1");
			at45dbxx_pin_cs ( device, (data & H8S_P3_SCK0) ? 0 : 1);
			at45dbxx_pin_si ( device, (data & H8S_P3_TXD1) ? 1 : 0);
			at45dbxx_pin_sck( device, (data & H8S_P3_SCK1) ? 1 : 0);
		}
		break;
		// state->m_rs232
		case H8S_IO_P5DR :
		{
			cybiko_rs232_pin_txd(state, (data & H8S_P5_TXD2) ? 1 : 0);
			cybiko_rs232_pin_sck(state, (data & H8S_P5_SCK2) ? 1 : 0);
		}
		break;
		// real-time clock
		case H8S_IO_PFDR  : pcf8593_pin_scl(rtc, (data & H8S_PF_PF1) ? 1 : 0); break;
		case H8S_IO_PFDDR : pcf8593_pin_sda_w(rtc, (data & H8S_PF_PF0) ? 0 : 1); break;
	}
}
예제 #10
0
void cybiko_state::machine_start()
{
	_logerror( 0, ("machine_start_cybikov1\n"));
	// serial port
	cybiko_rs232_init();
	// other
	machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybiko),this));
}
예제 #11
0
void sst39vfx_load(device_t *device, emu_file *file)
{
	sst39vfx_t *flash = get_token(device);

	_logerror( 0, ("sst39vfx_load (%p)\n", file));
	file->read(flash->data, flash->size);
	if (flash->swap) sst39vfx_swap(device);
}
예제 #12
0
void pcf8593_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
{
	switch(id)
	{
		case TIMER_UPDATE_COUNTER:
			_logerror( 2, ("pcf8593_timer_callback (%d)\n", param));
			// check if counting is enabled
			if (!(m_data[0] & 0x80))
				advance_seconds();
			break;
	}
}
예제 #13
0
void pcf8593_device::device_reset()
{
	_logerror( 0, ("pcf8593_reset\n"));
	m_pin_scl = 1;
	m_pin_sda = 1;
	m_active  = FALSE;
	m_inp     = 0;
	m_mode    = RTC_MODE_RECV;
	m_bits    = 0;
	m_pos     = 0;
	clear_buffer_rx();
	set_time(true, RTC_GET_DATE_YEAR, RTC_GET_DATE_MONTH, RTC_GET_DATE_DAY, 0, RTC_GET_TIME_HOUR, RTC_GET_TIME_MINUTE, RTC_GET_TIME_SECOND);
}
예제 #14
0
파일: cybiko.c 프로젝트: NULUSIOS/mame
int cybiko_state::cybiko_key_r( offs_t offset, int mem_mask)
{
	UINT16 data = 0xFFFF;
	for (UINT8 i = 0; i < 15; i++)
	{
		if (m_input[i] && !BIT(offset, i))
			data &= ~m_input[i]->read();
	}
	if (data != 0xFFFF)
	{
		_logerror( 1, ("cybiko_key_r (%08X/%04X) %04X\n", offset, mem_mask, data));
	}
	return data;
}
예제 #15
0
int cybiko_state::cybiko_key_r( offs_t offset, int mem_mask)
{
	static const char *const keynames[] = { "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15" };
	UINT16 data = 0xFFFF;
	for (UINT8 i = 0; i < 15; i++)
	{
		if (!BIT(offset, i))
			data &= ~ioport(keynames[i])->read_safe(0);
	}
	if (data != 0xFFFF)
	{
		_logerror( 1, ("cybiko_key_r (%08X/%04X) %04X\n", offset, mem_mask, data));
	}
	return data;
}
예제 #16
0
파일: cybiko.c 프로젝트: NULUSIOS/mame
void cybiko_state::machine_start()
{
	_logerror( 0, ("machine_start_cybikov1\n"));
	// serial port
	cybiko_rs232_init();
	// other
	machine().add_notifier(MACHINE_NOTIFY_EXIT, machine_notify_delegate(FUNC(cybiko_state::machine_stop_cybiko),this));

	int nvram_size = RAMDISK_SIZE;

	if (m_ram->size() < nvram_size)
	{
		nvram_size = m_ram->size();
	}

	m_nvram->set_base(m_ram->pointer(), nvram_size);
}
예제 #17
0
UINT32 hd66421_device::update_screen(screen_device &screen, bitmap_ind16 &bitmap, const rectangle &cliprect)
{
	pen_t pen[4];

	_logerror( 1, ("video_update_hd66421\n"));

	// update palette
	for (int i = 0; i < 4; i++)
	{
		double bright;
		int temp;
		temp = 31 - (m_reg[LCD_REG_COLOR_1 + i] - m_reg[LCD_REG_CONTRAST] + 0x03);
		if (temp <  0) temp =  0;
		if (temp > 31) temp = 31;
		bright = 1.0 * temp / 31;
		pen[i] = i;
		#ifdef HD66421_BRIGHTNESS_DOES_NOT_WORK
		palette_set_color(machine(), pen[i], 255 * bright, 255 * bright, 255 * bright);
		#else
		palette_set_pen_contrast(machine(), pen[i], bright);
		#endif
	}

	// draw bitmap (bottom to top)
	if (m_reg[0] & LCD_R0_DISP)
	{
		int x, y;
		x = 0;
		y = HD66421_HEIGHT - 1;

		for (int i = 0; i < HD66421_RAM_SIZE; i++)
		{
			plot_pixel(bitmap, x++, y, pen[(readbyte(i) >> 6) & 3]);
			plot_pixel(bitmap, x++, y, pen[(readbyte(i) >> 4) & 3]);
			plot_pixel(bitmap, x++, y, pen[(readbyte(i) >> 2) & 3]);
			plot_pixel(bitmap, x++, y, pen[(readbyte(i) >> 0) & 3]);
			if (x >= HD66421_WIDTH)
			{
				x = 0;
				y = y - 1;
			}
		}
	}
예제 #18
0
파일: cybiko.c 프로젝트: cdenix/psmame
static READ8_HANDLER( cybiko_io_reg_r )
{
	cybiko_state *state = space->machine().driver_data<cybiko_state>();
	UINT8 data = 0;
	_logerror( 2, ("cybiko_io_reg_r (%08X)\n", offset));
	switch (offset)
	{
		// keyboard
		case H8S_IO_PORT1 :
		{
			//if (input_port_read(space->machine(), "A1") & 0x02) data = data | 0x08; else data = data & (~0x08); // "esc" key
			data = data | 0x08;
		}
		break;
		// serial dataflash
		case H8S_IO_PORT3 :
		{
				device_t *device = space->machine().device("flash1");
				if (at45dbxx_pin_so(device)) data = data | H8S_P3_RXD1;
		}
		break;

		// state->m_rs232
		case H8S_IO_PORT5 : if (cybiko_rs232_pin_rxd(state)) data = data | H8S_P5_RXD2; break;
		// real-time clock
		case H8S_IO_PORTF :
		{
			device_t *device = space->machine().device("rtc");
			data = H8S_PF_PF2;
			if (pcf8593_pin_sda_r(device)) data |= H8S_PF_PF0;
		}
		break;
		// serial 2
		case H8S_IO_SSR2 :
		{
			if (cybiko_rs232_rx_queue()) data = data | H8S_SSR_RDRF;
		}
		break;
	}
	return data;
}
예제 #19
0
static void common_start(device_t *device, int device_type)
{
	sst39vfx_t *flash = get_token(device);
	const sst39vfx_config *config = get_config(device);

	_logerror( 0, ("sst39vfx_init (%d)\n", device_type));
	memset(flash, 0, sizeof(sst39vfx_t));
	switch (device_type)
	{
		case TYPE_SST39VF020  : flash->size = 256 * 1024; break;
		case TYPE_SST39VF400A : flash->size = 512 * 1024; break;
	}
	flash->data = auto_alloc_array(device->machine(), UINT8, flash->size);
#ifdef LSB_FIRST
	if (config->cpu_endianess != ENDIANNESS_LITTLE) flash->swap = config->cpu_datawidth / 8; else flash->swap = 0;
#else
	if (config->cpu_endianess != ENDIANNESS_BIG) flash->swap = config->cpu_datawidth / 8; else flash->swap = 0;
#endif

	state_save_register_item_pointer(device->machine(), "sst39vfx", device->tag(), 0, flash->data, flash->size);
	state_save_register_item(device->machine(), "sst39vfx", device->tag(), 0, flash->swap);
}
예제 #20
0
파일: cybiko.c 프로젝트: cdenix/psmame
static READ8_HANDLER( cybiko_key_r_byte )
{
	UINT8 data = 0xFF;
	int i;
	static const char *const keynames[] = { "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9" };

	_logerror( 2, ("cybiko_key_r_byte (%08X)\n", offset));
	// A11
	if (!(offset & (1 << 11)))
		data &= 0xFE;
	// A1 .. A9
	for (i=1; i<10; i++)
	{
		if (!(offset & (1 << i)))
			data &= input_port_read(space->machine(), keynames[i-1]);
	}
	// A0
	if (!(offset & (1 <<  0)))
		data |= 0xFF;
	//
	return data;
}
예제 #21
0
파일: cybiko.c 프로젝트: cdenix/psmame
static void cybiko_rs232_pin_txd(cybiko_state *state, int data)
{
	_logerror( 3, ("cybiko_rs232_pin_txd (%d)\n", data));
	state->m_rs232.pin.txd = data;
}
예제 #22
0
파일: cybiko.c 프로젝트: cdenix/psmame
static int cybiko_rs232_pin_rxd(cybiko_state *state)
{
	_logerror( 3, ("cybiko_rs232_pin_rxd\n"));
	return state->m_rs232.pin.rxd;
}
예제 #23
0
void cybiko_state::machine_reset()
{
	_logerror( 0, ("machine_reset_cybikov1\n"));
	cybiko_rs232_reset();
}
예제 #24
0
void cybiko_state::machine_stop_cybiko()
{
	_logerror( 0, ("machine_stop_cybikov1\n"));
	// serial port
	cybiko_rs232_exit();
}
예제 #25
0
DRIVER_INIT_MEMBER(cybiko_state,cybikoxt)
{
	_logerror( 0, ("init_cybikoxt\n"));
	m_maincpu->space(AS_PROGRAM).install_ram(0x400000, 0x400000 + m_ram->size() - 1, 0, 0x200000 - m_ram->size(), m_ram->pointer());
}
예제 #26
0
void cybiko_state::cybiko_rs232_init()
{
	_logerror( 0, ("cybiko_rs232_init\n"));
	memset( &m_rs232, 0, sizeof(m_rs232));
//  machine().scheduler().timer_pulse(TIME_IN_HZ( 10), FUNC(rs232_timer_callback));
}
예제 #27
0
int cybiko_state::cybiko_rs232_pin_rxd()
{
	_logerror( 3, ("cybiko_rs232_pin_rxd\n"));
	return m_rs232.pin.rxd;
}
예제 #28
0
void cybiko_state::cybiko_rs232_pin_txd( int data )
{
	_logerror( 3, ("cybiko_rs232_pin_txd (%d)\n", data));
	m_rs232.pin.txd = data;
}
예제 #29
0
void cybiko_state::cybiko_rs232_reset()
{
	_logerror( 0, ("cybiko_rs232_reset\n"));
}
예제 #30
0
void cybiko_state::cybiko_rs232_exit()
{
	_logerror( 0, ("cybiko_rs232_exit\n"));
}