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"); } }
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; } }
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; }
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)); }
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; }
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; }
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)); }
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; }
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; } }
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)); }
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); }
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; } }
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); }
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; }
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; }
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); }
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; } } }
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; }
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); }
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; }
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; }
static int cybiko_rs232_pin_rxd(cybiko_state *state) { _logerror( 3, ("cybiko_rs232_pin_rxd\n")); return state->m_rs232.pin.rxd; }
void cybiko_state::machine_reset() { _logerror( 0, ("machine_reset_cybikov1\n")); cybiko_rs232_reset(); }
void cybiko_state::machine_stop_cybiko() { _logerror( 0, ("machine_stop_cybikov1\n")); // serial port cybiko_rs232_exit(); }
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()); }
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)); }
int cybiko_state::cybiko_rs232_pin_rxd() { _logerror( 3, ("cybiko_rs232_pin_rxd\n")); return m_rs232.pin.rxd; }
void cybiko_state::cybiko_rs232_pin_txd( int data ) { _logerror( 3, ("cybiko_rs232_pin_txd (%d)\n", data)); m_rs232.pin.txd = data; }
void cybiko_state::cybiko_rs232_reset() { _logerror( 0, ("cybiko_rs232_reset\n")); }
void cybiko_state::cybiko_rs232_exit() { _logerror( 0, ("cybiko_rs232_exit\n")); }