diff options
Diffstat (limited to 'src/devices/video/ef9365.cpp')
-rw-r--r-- | src/devices/video/ef9365.cpp | 887 |
1 files changed, 413 insertions, 474 deletions
diff --git a/src/devices/video/ef9365.cpp b/src/devices/video/ef9365.cpp index 7a8bd5cc63b..249282a819f 100644 --- a/src/devices/video/ef9365.cpp +++ b/src/devices/video/ef9365.cpp @@ -3,16 +3,16 @@ /********************************************************************* - ef9365.c + ef9365.cpp - Thomson EF9365/EF9366 video controller emulator code + Thomson EF9365/EF9366/EF9367 video controller emulator code - The EF9365/EF9366 is a video controller driving a frame buffer + The EF9365/EF9366/EF9367 is a video controller driving a frame buffer and having built-in vectors and characters drawing engines. This is natively a "black and white" chip (1 bitplane), but it is possible to add more bitplanes to have colors with a hardware trick. The system don't have direct access to the video - memory, but indirect access is possible through the 0x0F command + memory, but indirect access is possible through the 0x0f command and some hardware glue logics. The current implementation emulate the main functions : @@ -39,7 +39,7 @@ - Clear Screen - Fill Screen - Clear X & Y registers - - Video RAM readback supported (Command 0x0F) + - Video RAM readback supported (Command 0x0f) What is NOT yet currently implemented: - Light pen support @@ -51,10 +51,6 @@ for this chip. So i add the interrupt line support, but bug(s) is possible. - The needed charset file charset_ef9365.rom (CRC 8d3053be) is available - there : http://hxc2001.free.fr/Squale/rom/charset_ef9365.zip - This ROM charset is into the EF9365/EF9366. - To see how to use this driver, have a look to the Squale machine driver (squale.cpp). If you have any question, don't hesitate to contact me at the email @@ -69,7 +65,7 @@ #include "screen.h" -//#define VERBOSE 1 +#define VERBOSE 0 #include "logmacro.h" @@ -84,10 +80,10 @@ namespace { #define EF936X_REG_DELTAY 0x07 #define EF936X_REG_X_MSB 0x08 #define EF936X_REG_X_LSB 0x09 -#define EF936X_REG_Y_MSB 0x0A -#define EF936X_REG_Y_LSB 0x0B -#define EF936X_REG_XLP 0x0C -#define EF936X_REG_YLP 0x0D +#define EF936X_REG_Y_MSB 0x0a +#define EF936X_REG_Y_LSB 0x0b +#define EF936X_REG_XLP 0x0c +#define EF936X_REG_YLP 0x0d //------------------------------------------------- @@ -148,8 +144,8 @@ const char *const commands_names[]= DEFINE_DEVICE_TYPE(EF9365, ef9365_device, "ef9365", "Thomson EF9365") ROM_START( ef9365 ) - ROM_REGION( 0x1E0, "ef9365", 0 ) - ROM_LOAD( "charset_ef9365.rom", 0x0000, 0x01E0, CRC(8d3053be) SHA1(0f9a64d217a0f7f04ee0720d49c5b680ad0ae359) ) + ROM_REGION( 0x1e0, "ef9365", 0 ) + ROM_LOAD( "charset_ef9365.rom", 0x0000, 0x01e0, CRC(8d3053be) SHA1(0f9a64d217a0f7f04ee0720d49c5b680ad0ae359) ) ROM_END //------------------------------------------------- @@ -166,7 +162,8 @@ const tiny_rom_entry *ef9365_device::device_rom_region() const // default address map // Up to 512*512 per bitplane, 8 bitplanes max. //------------------------------------------------- -void ef9365_device::ef9365(address_map &map) + +void ef9365_device::ef9365_map(address_map &map) { if (!has_configured_map(0)) map(0x00000, ef9365_device::BITPLANE_MAX_SIZE * ef9365_device::MAX_BITPLANES - 1).ram(); @@ -201,24 +198,27 @@ ef9365_device::ef9365_device(const machine_config &mconfig, const char *tag, dev device_t(mconfig, EF9365, tag, owner, clock), device_memory_interface(mconfig, *this), device_video_interface(mconfig, *this), - m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, address_map_constructor(FUNC(ef9365_device::ef9365), this)), + m_space_config("videoram", ENDIANNESS_LITTLE, 8, 18, 0, address_map_constructor(FUNC(ef9365_device::ef9365_map), this)), m_charset(*this, "ef9365"), m_palette(*this, finder_base::DUMMY_TAG), - m_irq_handler(*this) + m_irq_handler(*this), + m_write_msl(*this) { - clock_freq = clock; + set_display_mode(DISPLAY_MODE_256x256); + set_nb_bitplanes(1); + set_color_filler(0); } //------------------------------------------------- -// set_nb_of_bitplanes: Set the number of bitplanes +// set_nb_bitplanes: Set the number of bitplanes //------------------------------------------------- void ef9365_device::set_nb_bitplanes(int nb_bitplanes) { - if( nb_bitplanes > 0 && nb_bitplanes <= 8 ) + if (nb_bitplanes > 0 && nb_bitplanes <= 8) { - nb_of_bitplanes = nb_bitplanes; - nb_of_colors = pow(2, nb_bitplanes); + m_nb_of_bitplanes = nb_bitplanes; + m_nb_of_colors = 1 << nb_bitplanes; } } @@ -231,47 +231,50 @@ void ef9365_device::set_display_mode(int display_mode) switch(display_mode) { case DISPLAY_MODE_256x256: - bitplane_xres = 256; - bitplane_yres = 256; - vsync_scanline_pos = 250; - overflow_mask_x = 0xFF00; - overflow_mask_y = 0xFF00; + m_bitplane_xres = 256; + m_bitplane_yres = 256; + m_vsync_scanline_pos = 250; + m_overflow_mask_x = 0xff00; + m_overflow_mask_y = 0xff00; break; case DISPLAY_MODE_512x512: - bitplane_xres = 512; - bitplane_yres = 512; - vsync_scanline_pos = 506; - overflow_mask_x = 0xFE00; - overflow_mask_y = 0xFE00; + m_bitplane_xres = 512; + m_bitplane_yres = 512; + m_vsync_scanline_pos = 506; + m_overflow_mask_x = 0xfe00; + m_overflow_mask_y = 0xfe00; break; case DISPLAY_MODE_512x256: - bitplane_xres = 512; - bitplane_yres = 256; - vsync_scanline_pos = 250; - overflow_mask_x = 0xFE00; - overflow_mask_y = 0xFF00; + m_bitplane_xres = 512; + m_bitplane_yres = 256; + m_vsync_scanline_pos = 250; + m_overflow_mask_x = 0xfe00; + m_overflow_mask_y = 0xff00; break; case DISPLAY_MODE_128x128: - bitplane_xres = 128; - bitplane_yres = 128; - vsync_scanline_pos = 124; - overflow_mask_x = 0xFF80; - overflow_mask_y = 0xFF80; + m_bitplane_xres = 128; + m_bitplane_yres = 128; + m_vsync_scanline_pos = 124; + m_overflow_mask_x = 0xff80; + m_overflow_mask_y = 0xff80; break; case DISPLAY_MODE_64x64: - bitplane_xres = 64; - bitplane_yres = 64; - vsync_scanline_pos = 62; - overflow_mask_x = 0xFFC0; - overflow_mask_y = 0xFFC0; + m_bitplane_xres = 64; + m_bitplane_yres = 64; + m_vsync_scanline_pos = 62; + m_overflow_mask_x = 0xffc0; + m_overflow_mask_y = 0xffc0; + break; + case DISPLAY_MODE_1024x512: + m_bitplane_xres = 1024; + m_bitplane_yres = 512; + m_vsync_scanline_pos = 506; + m_overflow_mask_x = 0xfc00; + m_overflow_mask_y = 0xfe00; break; default: logerror("Invalid EF9365 Display mode: %02x\n", display_mode); - bitplane_xres = 256; - bitplane_yres = 256; - vsync_scanline_pos = 250; - overflow_mask_x = 0xFF00; - overflow_mask_y = 0xFF00; + set_display_mode(DISPLAY_MODE_256x256); break; } } @@ -281,9 +284,9 @@ void ef9365_device::set_display_mode(int display_mode) // into the palette //------------------------------------------------- -void ef9365_device::set_color_entry( int index, uint8_t r, uint8_t g, uint8_t b ) +void ef9365_device::set_color_entry(int index, uint8_t r, uint8_t g, uint8_t b) { - if( index < nb_of_colors ) + if (index < m_nb_of_colors) { m_palette->set_pen_color(index, rgb_t(r, g, b)); } @@ -298,7 +301,7 @@ void ef9365_device::set_color_entry( int index, uint8_t r, uint8_t g, uint8_t b // used by the chip to draw/fill the memory //------------------------------------------------- -void ef9365_device::set_color_filler( uint8_t color ) +void ef9365_device::set_color_filler(uint8_t color) { m_current_color = color; } @@ -309,30 +312,31 @@ void ef9365_device::set_color_filler( uint8_t color ) void ef9365_device::device_start() { - m_irq_handler.resolve_safe(); - - m_busy_timer = timer_alloc(BUSY_TIMER); + m_busy_timer = timer_alloc(FUNC(ef9365_device::clear_busy_flag), this); m_videoram = &space(0); - m_current_color = 0x00; m_irq_vb = 0; m_irq_lb = 0; m_irq_rdy = 0; m_irq_state = 0; - m_screen_out.allocate( bitplane_xres, screen().height() ); - - save_item(NAME(m_border)); - save_item(NAME(m_registers)); - save_item(NAME(m_bf)); - save_item(NAME(m_state)); + m_screen_out.allocate(m_bitplane_xres, screen().height()); save_item(NAME(m_irq_state)); save_item(NAME(m_irq_vb)); save_item(NAME(m_irq_lb)); save_item(NAME(m_irq_rdy)); + save_item(NAME(m_current_color)); + save_item(NAME(m_bf)); + save_item(NAME(m_registers)); + save_item(NAME(m_state)); + save_item(NAME(m_border)); + + save_item(NAME(m_readback_latch)); + save_item(NAME(m_readback_latch_pix_offset)); + save_item(NAME(m_screen_out)); } @@ -342,17 +346,19 @@ void ef9365_device::device_start() void ef9365_device::device_reset() { - m_state = 0; - - m_bf = 0; m_irq_state = 0; m_irq_vb = 0; m_irq_lb = 0; m_irq_rdy = 0; + m_bf = 0; + m_state = 0; memset(m_registers, 0, sizeof(m_registers)); memset(m_border, 0, sizeof(m_border)); + memset(m_readback_latch, 0, sizeof(m_readback_latch)); + m_readback_latch_pix_offset = 0; + m_screen_out.fill(0); set_video_mode(); @@ -366,9 +372,9 @@ void ef9365_device::device_reset() //------------------------------------------------- void ef9365_device::update_interrupts() { - int new_state = ( m_irq_vb && (m_registers[EF936X_REG_CTRL1] & 0x20) ) - || ( m_irq_rdy && (m_registers[EF936X_REG_CTRL1] & 0x40) ) - || ( m_irq_lb && (m_registers[EF936X_REG_CTRL1] & 0x10) ); + int new_state = (m_irq_vb && (m_registers[EF936X_REG_CTRL1] & 0x20)) + || (m_irq_rdy && (m_registers[EF936X_REG_CTRL1] & 0x40)) + || (m_irq_lb && (m_registers[EF936X_REG_CTRL1] & 0x10)); if (new_state != m_irq_state) { @@ -378,25 +384,19 @@ void ef9365_device::update_interrupts() } //------------------------------------------------- -// device_timer - handler timer events +// clear_busy_flag - //------------------------------------------------- -void ef9365_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr) +TIMER_CALLBACK_MEMBER(ef9365_device::clear_busy_flag) { - switch(id) - { - case BUSY_TIMER: - m_bf = 0; - - if( m_registers[EF936X_REG_CTRL1] & 0x40 ) - { - m_irq_rdy = 1; - } - - update_interrupts(); + m_bf = 0; - break; + if (m_registers[EF936X_REG_CTRL1] & 0x40) + { + m_irq_rdy = 1; } + + update_interrupts(); } //------------------------------------------------- @@ -404,10 +404,10 @@ void ef9365_device::device_timer(emu_timer &timer, device_timer_id id, int param // timer to clear it //------------------------------------------------- -void ef9365_device::set_busy_flag(int period) +void ef9365_device::set_busy_flag(int cycles) { m_bf = 1; - m_busy_timer->adjust(attotime::from_usec(period)); + m_busy_timer->adjust(attotime::from_ticks(cycles, clock())); } //------------------------------------------------- @@ -416,7 +416,7 @@ void ef9365_device::set_busy_flag(int period) uint16_t ef9365_device::get_x_reg() { - return ((m_registers[EF936X_REG_X_MSB] & 0x0F)<<8) | m_registers[EF936X_REG_X_LSB]; + return ((m_registers[EF936X_REG_X_MSB] & 0x0f) << 8) | m_registers[EF936X_REG_X_LSB]; } //------------------------------------------------- @@ -425,7 +425,7 @@ uint16_t ef9365_device::get_x_reg() uint16_t ef9365_device::get_y_reg() { - return ((m_registers[EF936X_REG_Y_MSB] & 0x0F)<<8) | m_registers[EF936X_REG_Y_LSB]; + return ((m_registers[EF936X_REG_Y_MSB] & 0x0f) << 8) | m_registers[EF936X_REG_Y_LSB]; } //------------------------------------------------- @@ -434,8 +434,8 @@ uint16_t ef9365_device::get_y_reg() void ef9365_device::set_x_reg(uint16_t x) { - m_registers[EF936X_REG_X_MSB] = ( x >> 8 ) & 0x0F; - m_registers[EF936X_REG_X_LSB] = x & 0xFF; + m_registers[EF936X_REG_X_MSB] = (x >> 8) & 0x0f; + m_registers[EF936X_REG_X_LSB] = x & 0xff; } //------------------------------------------------- @@ -444,8 +444,18 @@ void ef9365_device::set_x_reg(uint16_t x) void ef9365_device::set_y_reg(uint16_t y) { - m_registers[EF936X_REG_Y_MSB] = ( y >> 8 ) & 0x0F; - m_registers[EF936X_REG_Y_LSB] = y & 0xFF; + m_registers[EF936X_REG_Y_MSB] = (y >> 8) & 0x0f; + m_registers[EF936X_REG_Y_LSB] = y & 0xff; +} + +//------------------------------------------------- +// set_msl_pins: Set the MSL pins +//------------------------------------------------- + +void ef9365_device::set_msl_pins(uint16_t x, uint16_t y) +{ + y = (m_bitplane_yres == 512) ? (y & 1) : 1; + m_write_msl((x & 7) | y << 3); } //------------------------------------------------- @@ -454,7 +464,7 @@ void ef9365_device::set_y_reg(uint16_t y) void ef9365_device::set_video_mode(void) { - uint16_t new_width = bitplane_xres; + uint16_t new_width = m_bitplane_xres; if (screen().width() != new_width) { @@ -464,7 +474,7 @@ void ef9365_device::set_video_mode(void) screen().configure(new_width, screen().height(), visarea, screen().frame_period().attoseconds()); } - //border color + // border color memset(m_border, 0, sizeof(m_border)); } @@ -473,12 +483,12 @@ void ef9365_device::set_video_mode(void) // bitplane words //------------------------------------------------- -uint8_t ef9365_device::get_last_readback_word(int bitplane_number, int * pixel_offset) +uint8_t ef9365_device::get_last_readback_word(int bitplane_number, int *pixel_offset) { - if( pixel_offset ) + if (pixel_offset) *pixel_offset = m_readback_latch_pix_offset; - if( bitplane_number < nb_of_bitplanes ) + if (bitplane_number < m_nb_of_bitplanes) { return m_readback_latch[bitplane_number]; } @@ -490,7 +500,7 @@ uint8_t ef9365_device::get_last_readback_word(int bitplane_number, int * pixel_o //------------------------------------------------- // draw_border: Draw the left and right borders -// ( No border for the moment ;) ) +// ( No border for the moment ) //------------------------------------------------- void ef9365_device::draw_border(uint16_t line) @@ -502,33 +512,37 @@ void ef9365_device::draw_border(uint16_t line) // at the x & y position with the m_current_color color //------------------------------------------------- -void ef9365_device::plot(int x_pos,int y_pos) +void ef9365_device::plot(int x_pos, int y_pos) { - int p; - - if( ( x_pos >= 0 && y_pos >= 0 ) && ( x_pos < bitplane_xres && y_pos < bitplane_yres ) ) + if ((x_pos >= 0 && y_pos >= 0) && (x_pos < m_bitplane_xres && y_pos < m_bitplane_yres)) { - if ( m_registers[EF936X_REG_CTRL1] & 0x01 ) + if (m_registers[EF936X_REG_CTRL1] & 0x01) { - y_pos = ( (bitplane_yres - 1) - y_pos ); + y_pos = (m_bitplane_yres - 1) - y_pos; + set_msl_pins(x_pos, y_pos); + uint8_t mask = 0x80 >> (x_pos & 7); - if( (m_registers[EF936X_REG_CTRL1] & 0x02) ) + if (m_registers[EF936X_REG_CTRL1] & 0x02) { // Pen - for( p = 0 ; p < nb_of_bitplanes ; p++ ) + for (int p = 0; p < m_nb_of_bitplanes; p++) { - if( m_current_color & (0x01 << p) ) - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3)) | (0x80 >> (((y_pos*bitplane_xres) + x_pos)&7) ) ); + offs_t offset = BITPLANE_MAX_SIZE * p + ((y_pos * m_bitplane_xres + x_pos) >> 3); + uint8_t current_pix = m_videoram->read_byte(offset); + if (BIT(m_current_color, p)) + m_videoram->write_byte(offset, current_pix | mask); else - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3)) & ~(0x80 >> (((y_pos*bitplane_xres) + x_pos)&7) ) ); + m_videoram->write_byte(offset, current_pix & ~mask); } } else { // Eraser - for( p = 0 ; p < nb_of_bitplanes ; p++ ) + for (int p = 0; p < m_nb_of_bitplanes; p++) { - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y_pos*bitplane_xres) + x_pos)>>3)) | (0x80 >> (((y_pos*bitplane_xres) + x_pos)&7) ) ); + offs_t offset = BITPLANE_MAX_SIZE * p + ((y_pos * m_bitplane_xres + x_pos) >> 3); + uint8_t current_pix = m_videoram->read_byte(offset); + m_videoram->write_byte(offset, current_pix | mask); } } } @@ -536,68 +550,46 @@ void ef9365_device::plot(int x_pos,int y_pos) } -const static unsigned int vectortype_code[][8] = +const static uint8_t vectortype_code[4][8] = { - {0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, // Continuous drawing - {0x82,0x02,0x00,0x00,0x00,0x00,0x00,0x00}, // Dotted - 2 dots on, 2 dots off - {0x84,0x04,0x00,0x00,0x00,0x00,0x00,0x00}, // Dashed - 4 dots on, 4 dots off - {0x8A,0x02,0x82,0x02,0x00,0x00,0x00,0x00} // Dotted-Dashed - 10 dots on, 2 dots off, 2 dots on, 2 dots off + { 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Continuous drawing + { 0x82, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Dotted - 2 dots on, 2 dots off + { 0x84, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, // Dashed - 4 dots on, 4 dots off + { 0x8a, 0x02, 0x82, 0x02, 0x00, 0x00, 0x00, 0x00 } // Dotted-Dashed - 10 dots on, 2 dots off, 2 dots on, 2 dots off }; //------------------------------------------------- // draw_vector: Vector drawing function -// from the start_x & start_y position to the start_x+delta_x & start_y+delta_y position -// with the m_current_color color +// from (start_x, start_y) to (start_x + delta_x, start_y + delta_y) +// with m_current_color // (Bresenham's line algorithm) //------------------------------------------------- -int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,short delta_y) +int ef9365_device::draw_vector(uint16_t start_x, uint16_t start_y, int16_t delta_x, int16_t delta_y) { - int dx; - int dy,t; - int e; - int x,y,dest_x,dest_y,end_x,end_y; - int incy; - int diago,horiz; - unsigned char c1; - - int pen_state; - unsigned int state_counter; - int dot_code_ptr; - int compute_cycles; + LOG("EF9365 draw_vector : Start=(%d,%d) End=(%d,%d)\n", start_x, start_y, start_x + delta_x, start_y + delta_y); - LOG("EF9365 draw_vector : Start=(%d,%d) End=(%d,%d)\n", start_x,start_y,start_x+delta_x,start_y+delta_y); + int compute_cycles = 0; - compute_cycles = 0; + int16_t dest_x = start_x + delta_x; + int16_t dest_y = start_y + delta_y; - dest_x = start_x + delta_x; - dest_y = start_y + delta_y; + int16_t end_x = dest_x; + int16_t end_y = dest_y; - end_x = dest_x; - end_y = dest_y; + uint8_t c1 = 0; + int16_t incy = 1; - c1=0; - incy=1; - - dot_code_ptr = 0; - state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 0x3][dot_code_ptr&7]; - if(state_counter&0x80) - pen_state = 1; - else - pen_state = 0; + uint8_t dot_code_ptr = 0; + uint8_t state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 3][dot_code_ptr & 7]; + uint8_t pen_state = BIT(state_counter, 7); state_counter &= ~0x80; - if( dest_x > start_x ) - dx = dest_x - start_x; - else - dx = start_x - dest_x; + int16_t dx = (dest_x > start_x) ? (dest_x - start_x) : (start_x - dest_x); + int16_t dy = (dest_y > start_y) ? (dest_y - start_y) : (start_y - dest_y); - if( dest_y > start_y ) - dy = dest_y - start_y; - else - dy = start_y - dest_y; - - if( dy > dx ) + int16_t t; + if (dy > dx) { t = dest_y; dest_y = dest_x; @@ -614,7 +606,7 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s c1 = 1; } - if( start_x > dest_x ) + if (start_x > dest_x) { t = dest_y; dest_y = start_y; @@ -625,24 +617,24 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s dest_x = t; } - horiz = dy<<1; - diago = ( dy - dx )<<1; - e = ( dy<<1 ) - dx; + int16_t horiz = dy << 1; + int16_t diago = (dy - dx) << 1; + int16_t e = (dy << 1) - dx; - if( start_y <= dest_y ) + if (start_y <= dest_y) incy = 1; else incy = -1; - x = start_x; - y = start_y; + int16_t x = start_x; + int16_t y = start_y; - if(c1) + if (c1) { do { - if(pen_state) - plot(y % bitplane_xres, x % bitplane_yres); + if (pen_state) + plot(y % m_bitplane_xres, x % m_bitplane_yres); compute_cycles++; @@ -651,31 +643,23 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s state_counter--; - if( !state_counter ) + if (!state_counter) { dot_code_ptr++; - state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 0x3][dot_code_ptr&7]; + state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 3][dot_code_ptr & 7]; - if(!state_counter) + if (!state_counter) { dot_code_ptr = 0; - state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 0x3][dot_code_ptr&7]; - } - - if( state_counter & 0x80 ) - { - pen_state = 1; - } - else - { - pen_state = 0; + state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 3][dot_code_ptr & 7]; } + pen_state = BIT(state_counter, 7); state_counter &= ~0x80; } - if( e > 0 ) + if (e > 0) { y = y + incy; e = e + diago; @@ -693,8 +677,8 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s { do { - if(pen_state) - plot(x % bitplane_xres, y % bitplane_yres); + if (pen_state) + plot(x % m_bitplane_xres, y % m_bitplane_yres); compute_cycles++; @@ -703,31 +687,23 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s state_counter--; - if( !state_counter ) + if (!state_counter) { dot_code_ptr++; - state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 0x3][dot_code_ptr&7]; + state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 3][dot_code_ptr&7]; - if(!state_counter) + if (!state_counter) { dot_code_ptr = 0; - state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 0x3][dot_code_ptr&7]; - } - - if( state_counter & 0x80 ) - { - pen_state = 1; - } - else - { - pen_state = 0; + state_counter = vectortype_code[m_registers[EF936X_REG_CTRL2] & 3][dot_code_ptr&7]; } + pen_state = BIT(state_counter, 7); state_counter &= ~0x80; } - if( e > 0 ) + if (e > 0) { y = y + incy; e = e + diago; @@ -753,18 +729,16 @@ int ef9365_device::draw_vector(uint16_t start_x,uint16_t start_y,short delta_x,s // from the charset. //------------------------------------------------- -int ef9365_device::get_char_pix( unsigned char c, int x, int y ) +int ef9365_device::get_char_pix(uint8_t c, int x, int y) { - int char_base,char_pix; - - if(c<96) + if (c < 96) { - if( x < 5 && y < 8 ) + if (x < 5 && y < 8) { - char_base = c * 5; - char_pix = ( y * 5 ) + x; + uint32_t char_base = c * 5; + uint32_t char_pix = (y * 5) + x; - if ( m_charset[char_base + (char_pix>>3)] & ( 0x80 >> (char_pix&7)) ) + if (BIT(m_charset[char_base + (char_pix >> 3)], ~char_pix & 7)) return 1; else return 0; @@ -780,87 +754,73 @@ int ef9365_device::get_char_pix( unsigned char c, int x, int y ) // Set block to draw a 5x8 block //------------------------------------------------- -int ef9365_device::draw_character( unsigned char c, int block, int smallblock ) +int ef9365_device::draw_character(uint8_t c, bool block, bool smallblock) { - int x_char,y_char; - unsigned int x, y; - int x_char_res,y_char_res; - int p_factor,q_factor,p,q; - int compute_cycles; + uint16_t x = get_x_reg(); + uint16_t y = get_y_reg(); - x = get_x_reg(); - y = get_y_reg(); + int x_char_res = 5; + int y_char_res = 8; - x_char_res = 5; - y_char_res = 8; - - if( smallblock ) + if (smallblock) { - block = 1; + block = true; x_char_res = 4; y_char_res = 4; } - p_factor = (m_registers[EF936X_REG_CSIZE] >> 4); - if(!p_factor) + uint8_t p_factor = m_registers[EF936X_REG_CSIZE] >> 4; + if (!p_factor) p_factor = 16; - q_factor = (m_registers[EF936X_REG_CSIZE] & 0xF); - if(!q_factor) + uint8_t q_factor = m_registers[EF936X_REG_CSIZE] & 0xf; + if (!q_factor) q_factor = 16; - compute_cycles = ( ( x_char_res + 1 ) * p_factor ) * ( y_char_res * q_factor ); + int compute_cycles = ((x_char_res + 1) * p_factor) * (y_char_res * q_factor); - if(c<96) + if (c < 0x60) { - for( x_char=0 ; x_char < x_char_res ; x_char++ ) + for (int x_char = 0; x_char < x_char_res; x_char++) { - for( y_char = y_char_res - 1 ; y_char >= 0 ; y_char-- ) + for (int y_char = y_char_res - 1; y_char >= 0; y_char--) { - if ( block || get_char_pix( c, x_char, ( (y_char_res - 1) - y_char ) ) ) + if (block || get_char_pix(c, x_char, ((y_char_res - 1) - y_char))) { - if( m_registers[EF936X_REG_CTRL2] & 0x04) // Tilted character + if (m_registers[EF936X_REG_CTRL2] & 0x04) // Oblique mode { - for(q = 0; q < q_factor; q++) + for (uint16_t q = 0; q < q_factor; q++) { - for(p = 0; p < p_factor; p++) + for (uint16_t p = 0; p < p_factor; p++) { - if( !(m_registers[EF936X_REG_CTRL2] & 0x08) ) - { // Tilted - Horizontal orientation - plot( - x + ( (y_char*q_factor) + q ) + ( (x_char*p_factor) + p ), - y + ( (y_char*q_factor) + q ) - ); + if (!(m_registers[EF936X_REG_CTRL2] & 0x08)) + { + // Oblique - Horizontal orientation + plot(x + ((y_char * q_factor) + q) + ((x_char * p_factor) + p), y + ((y_char * q_factor) + q)); } else - { // Tilted - Vertical orientation - plot( - x - ( (y_char*q_factor)+ q ), - y + ( (x_char*p_factor)+ p ) - ( ( ( (y_char_res - 1 ) - y_char) * q_factor ) + ( q_factor - q ) ) - ); + { + // Oblique - Vertical orientation + plot(x - ((y_char * q_factor) + q), y + ((x_char * p_factor) + p) - ((((y_char_res - 1) - y_char) * q_factor) + (q_factor - q))); } } } } else { - for(q = 0; q < q_factor; q++) + for (uint16_t q = 0; q < q_factor; q++) { - for(p = 0; p < p_factor; p++) + for (uint16_t p = 0; p < p_factor; p++) { - if( !(m_registers[EF936X_REG_CTRL2] & 0x08) ) - { // Normal - Horizontal orientation - plot( - x + ( (x_char*p_factor) + p ), - y + ( (y_char*q_factor) + q ) - ); + if (!(m_registers[EF936X_REG_CTRL2] & 0x08)) + { + // Normal - Horizontal orientation + plot(x + ((x_char * p_factor) + p), y + ((y_char * q_factor) + q)); } else - { // Normal - Vertical orientation - plot( - x - ( (y_char*q_factor) + q ), - y + ( (x_char*p_factor) + p ) - ); + { + // Normal - Vertical orientation + plot(x - ((y_char * q_factor) + q), y + ((x_char * p_factor) + p)); } } } @@ -868,32 +828,21 @@ int ef9365_device::draw_character( unsigned char c, int block, int smallblock ) } } } + } - if(!(m_registers[EF936X_REG_CTRL2] & 0x08)) - { - x = x + ( (x_char_res + 1 ) * p_factor ) ; - set_x_reg(x); - } - else - { - y = y + ( (x_char_res + 1 ) * p_factor ) ; - set_y_reg(y); - } + if (!(m_registers[EF936X_REG_CTRL2] & 0x08)) + { + set_x_reg(x + (x_char_res + 1) * p_factor); + } + else + { + set_y_reg(y + (x_char_res + 1) * p_factor); } return compute_cycles; } //------------------------------------------------- -// cycles_to_us: Convert a number of clock cycles to us -//------------------------------------------------- - -int ef9365_device::cycles_to_us(int cycles) -{ - return ( (float)cycles * ( (float)1000000 / (float)clock_freq ) ); -} - -//------------------------------------------------- // dump_bitplanes_word: Latch the bitplane words // pointed by the x & y registers // (Memory read back function) @@ -901,62 +850,62 @@ int ef9365_device::cycles_to_us(int cycles) void ef9365_device::dump_bitplanes_word() { - int p; - int pixel_ptr; - - pixel_ptr = ( ( ( ( bitplane_yres - 1 ) - ( get_y_reg() & ( bitplane_yres - 1 ) ) ) * bitplane_xres ) + ( get_x_reg() & ( bitplane_xres - 1 ) ) ); + int pixel_ptr = (((m_bitplane_yres - 1) - (get_y_reg() & (m_bitplane_yres - 1))) * m_bitplane_xres) + (get_x_reg() & (m_bitplane_xres - 1)); + m_readback_latch_pix_offset = pixel_ptr & 7; - LOG("dump : x = %d , y = %d\n", get_x_reg() ,get_y_reg()); + LOG("dump : x = %d , y = %d\n", get_x_reg(), get_y_reg()); - for( p = 0; p < nb_of_bitplanes ; p++ ) + for (int p = 0; p < m_nb_of_bitplanes; p++) { - if( pixel_ptr & 0x4 ) - { - m_readback_latch[p] = ( m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (pixel_ptr>>3) ) ) & 0xF ; - } + const uint8_t value = m_videoram->read_byte(BITPLANE_MAX_SIZE * p + (pixel_ptr >> 3)); + if (pixel_ptr & 0x4) + m_readback_latch[p] = value & 0xf; else - { - m_readback_latch[p] = ( m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (pixel_ptr>>3) ) >> 4 ) & 0xF ; - } - + m_readback_latch[p] = (value >> 4) & 0xf; } - - m_readback_latch_pix_offset = pixel_ptr & 0x3; } //------------------------------------------------- // screen_scanning: Fill / Clear framebuffer memory //------------------------------------------------- -void ef9365_device::screen_scanning( int force_clear ) +void ef9365_device::screen_scanning(bool force_clear) { - int x,y,p; - - if( (m_registers[EF936X_REG_CTRL1] & 0x02) && !force_clear ) + if ((m_registers[EF936X_REG_CTRL1] & 0x02) && !force_clear) { - for( y = 0; y < bitplane_yres; y++ ) + for (int y = 0; y < m_bitplane_yres; y++) { - for( x = 0; x < bitplane_xres; x++ ) + for (int x = 0; x < m_bitplane_xres; x++) { - for( p = 0 ; p < nb_of_bitplanes ; p++ ) + set_msl_pins(x, y); + uint8_t mask = 0x80 >> (x & 7); + + for (int p = 0; p < m_nb_of_bitplanes; p++) { - if( m_current_color & (0x01 << p) ) - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3)) | (0x80 >> (((y*bitplane_xres) + x)&7) ) ); + offs_t offset = BITPLANE_MAX_SIZE * p + ((y * m_bitplane_xres + x) >> 3); + uint8_t current_pix = m_videoram->read_byte(offset); + if (BIT(m_current_color, p)) + m_videoram->write_byte(offset, current_pix | mask); else - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3)) & ~(0x80 >> (((y*bitplane_xres) + x)&7) ) ); + m_videoram->write_byte(offset, current_pix & ~mask); } } } } else { - for( y = 0; y < bitplane_yres; y++) + for (int y = 0; y < m_bitplane_yres; y++) { - for( x = 0; x < bitplane_xres; x++) + for (int x = 0; x < m_bitplane_xres; x++) { - for( p = 0 ; p < nb_of_bitplanes ; p++ ) + set_msl_pins(x, y); + uint8_t mask = 0x80 >> (x & 7); + + for (int p = 0; p < m_nb_of_bitplanes; p++) { - m_videoram->write_byte ( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3), m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (((y*bitplane_xres) + x)>>3)) | (0x80 >> (((y*bitplane_xres) + x)&7) ) ); + offs_t offset = BITPLANE_MAX_SIZE * p + ((y * m_bitplane_xres + x) >> 3); + uint8_t current_pix = m_videoram->read_byte(offset); + m_videoram->write_byte(offset, current_pix | mask); } } } @@ -969,177 +918,177 @@ void ef9365_device::screen_scanning( int force_clear ) void ef9365_device::ef9365_exec(uint8_t cmd) { - int tmp_delta_x,tmp_delta_y; - int busy_cycles = 0; m_state = 0; - if( ( cmd>>4 ) == 0 ) + if ((cmd >> 4) == 0) { - LOG("EF9365 Command : %s\n", commands_names[cmd & 0xF]); + LOG("EF9365 Command : %s\n", commands_names[cmd & 0xf]); - switch(cmd & 0xF) + // All commands need time checked on the real hardware + int busy_cycles = 4; + switch(cmd & 0xf) { case 0x0: // Set bit 1 of CTRL1 : Pen Selection m_registers[EF936X_REG_CTRL1] |= 0x02; - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x1: // Clear bit 1 of CTRL1 : Eraser Selection m_registers[EF936X_REG_CTRL1] &= (~0x02); - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x2: // Set bit 0 of CTRL1 : Pen/Eraser down selection m_registers[EF936X_REG_CTRL1] |= 0x01; - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x3: // Clear bit 0 of CTRL1 : Pen/Eraser up selection m_registers[EF936X_REG_CTRL1] &= (~0x01); - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x4: // Clear screen screen_scanning(1); - set_busy_flag( cycles_to_us( bitplane_xres*bitplane_yres ) ); // Timing to check on the real hardware - break; + busy_cycles = m_bitplane_xres * m_bitplane_yres; + break; case 0x5: // X and Y registers reset to 0 set_x_reg(0); set_y_reg(0); - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x6: // X and Y registers reset to 0 and clear screen set_x_reg(0); set_y_reg(0); screen_scanning(1); - set_busy_flag( cycles_to_us( bitplane_xres*bitplane_yres ) ); // Timing to check on the real hardware - break; + busy_cycles = m_bitplane_xres * m_bitplane_yres; + break; case 0x7: // Clear screen, set CSIZE to code "minsize". All other registers reset to 0 m_registers[EF936X_REG_CSIZE] = 0x11; screen_scanning(1); - set_busy_flag( cycles_to_us( bitplane_xres*bitplane_yres ) ); // Timing to check on the real hardware - break; + busy_cycles = m_bitplane_xres * m_bitplane_yres; + break; case 0x8: // Light-pen initialization (/White forced low) - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; + break; case 0x9: // Light-pen initialization - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; - case 0xA: // 5x8 block drawing (size according to CSIZE) - busy_cycles = draw_character( 0x00 , 1 , 0 ); - set_busy_flag( cycles_to_us( busy_cycles ) ); - break; - case 0xB: // 4x4 block drawing (size according to CSIZE) - busy_cycles = draw_character( 0x00 , 1 , 1 ); - set_busy_flag( cycles_to_us( busy_cycles ) ); - break; - case 0xC: // Screen scanning : pen or Eraser as defined by CTRL1 + break; + case 0xa: // 5x8 block drawing (size according to CSIZE) + busy_cycles = draw_character(0x00, true, false); + break; + case 0xb: // 4x4 block drawing (size according to CSIZE) + busy_cycles = draw_character(0x00, true, true); + break; + case 0xc: // Screen scanning : pen or Eraser as defined by CTRL1 screen_scanning(0); - set_busy_flag( cycles_to_us( bitplane_xres*bitplane_yres ) ); // Timing to check on the real hardware - break; - case 0xD: // X reset to 0 + busy_cycles = m_bitplane_xres * m_bitplane_yres; + break; + case 0xd: // X reset to 0 set_x_reg(0); - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; - case 0xE: // Y reset to 0 + break; + case 0xe: // Y reset to 0 set_y_reg(0); - set_busy_flag( cycles_to_us( 4 ) ); // Timing to check on the real hardware - break; - case 0xF: // Direct image memory access request for the next free cycle. - set_busy_flag( cycles_to_us( 64 ) ); // Timing to check on the real hardware + break; + case 0xf: // Direct image memory access request for the next free cycle. + busy_cycles = 64; dump_bitplanes_word(); - break; + break; default: logerror("Unemulated EF9365 cmd: %02x\n", cmd); + busy_cycles = 0; + break; + } + + if (busy_cycles) + { + set_busy_flag(busy_cycles); } } else { - if ( ( cmd>>4 ) == 1 ) + if ((cmd >> 4) == 1) { - if( cmd & 0x08 ) + int busy_cycles = 0; + + if (cmd & 0x08) LOG("EF9365 Command : [0x%.2X] %s\n", cmd, commands_names[0x11]); else LOG("EF9365 Command : [0x%.2X] %s\n", cmd, commands_names[0x10]); - tmp_delta_x = m_registers[EF936X_REG_DELTAX]; - tmp_delta_y = m_registers[EF936X_REG_DELTAY]; + int tmp_delta_x = m_registers[EF936X_REG_DELTAX]; + int tmp_delta_y = m_registers[EF936X_REG_DELTAY]; - if( cmd & 0x08 ) + if (cmd & 0x08) { - if(tmp_delta_x > tmp_delta_y ) + if (tmp_delta_x > tmp_delta_y) tmp_delta_y = tmp_delta_x; - if(tmp_delta_y > tmp_delta_x ) + if (tmp_delta_y > tmp_delta_x) tmp_delta_y = tmp_delta_x; } // Vector / Special direction vector generation - switch ( cmd & 0x7 ) // Direction code + switch (cmd & 0x7) // Direction code { case 0x1: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, tmp_delta_y); + break; case 0x3: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, tmp_delta_y); + break; case 0x5: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, -tmp_delta_y); + break; case 0x7: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, -tmp_delta_y); + break; case 0x0: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, 0 ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, 0); + break; case 0x2: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), 0, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), 0, tmp_delta_y); + break; case 0x4: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), 0, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), 0, -tmp_delta_y); + break; case 0x6: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x , 0 ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, 0); + break; } - set_busy_flag( cycles_to_us( busy_cycles ) ); + set_busy_flag(busy_cycles); } else { - if( ( cmd>>4 ) >= 0x8 ) + if ((cmd >> 4) >= 0x8) { + int busy_cycles = 0; + LOG("EF9365 Command : [0x%.2X] %s\n", cmd, commands_names[0x13]); - tmp_delta_x = ( cmd >> 5 ) & 3; - tmp_delta_y = ( cmd >> 3 ) & 3; + int tmp_delta_x = (cmd >> 5) & 3; + int tmp_delta_y = (cmd >> 3) & 3; // Small vector. - switch ( cmd & 0x7 ) // Direction code + switch (cmd & 0x7) // Direction code { case 0x1: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, tmp_delta_y); + break; case 0x3: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, tmp_delta_y); + break; case 0x5: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, -tmp_delta_y); + break; case 0x7: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, -tmp_delta_y); + break; case 0x0: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), tmp_delta_x, 0 ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), tmp_delta_x, 0); + break; case 0x2: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), 0, tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), 0, tmp_delta_y); + break; case 0x4: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), 0, -tmp_delta_y ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), 0, -tmp_delta_y); + break; case 0x6: - busy_cycles = draw_vector ( get_x_reg(), get_y_reg(), -tmp_delta_x, 0 ); - break; + busy_cycles = draw_vector(get_x_reg(), get_y_reg(), -tmp_delta_x, 0); + break; } - set_busy_flag( cycles_to_us( busy_cycles ) ); + set_busy_flag(busy_cycles); } else { @@ -1147,8 +1096,8 @@ void ef9365_device::ef9365_exec(uint8_t cmd) LOG("EF9365 Command : [0x%.2X] %s\n", cmd, commands_names[0x12]); - busy_cycles = draw_character( cmd - 0x20, 0 , 0 ); - set_busy_flag( cycles_to_us( busy_cycles ) ); + int busy_cycles = draw_character(cmd - 0x20, false, false); + set_busy_flag(busy_cycles); } } } @@ -1160,26 +1109,23 @@ void ef9365_device::ef9365_exec(uint8_t cmd) uint32_t ef9365_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { - int i,j,ptr,p; - unsigned char color_index; - - for(j=0;j<bitplane_yres;j++) + for (int j = 0; j < m_bitplane_yres; j++) { - for(i=0;i<bitplane_xres;i++) + for (int i = 0; i < m_bitplane_xres; i++) { - color_index = 0x00; + uint8_t color_index = 0x00; - ptr = ( bitplane_xres * j ) + i; + int ptr = (m_bitplane_xres * j) + i; - for( p = 0; p < nb_of_bitplanes; p++) + for (int p = 0; p < m_nb_of_bitplanes; p++) { - if( m_videoram->read_byte( (BITPLANE_MAX_SIZE*p) + (ptr>>3)) & (0x80>>(ptr&7))) + if (BIT(m_videoram->read_byte(BITPLANE_MAX_SIZE * p + (ptr >> 3)), ~ptr & 7)) { - color_index |= (0x01<<p); + color_index |= 0x01 << p; } } - m_screen_out.pix32(j, i) = m_palette->pen( color_index ); + m_screen_out.pix(j, i) = m_palette->pen(color_index); } } @@ -1193,10 +1139,10 @@ uint32_t ef9365_device::screen_update(screen_device &screen, bitmap_rgb32 &bitma void ef9365_device::update_scanline(uint16_t scanline) { - if (scanline == vsync_scanline_pos) + if (scanline == m_vsync_scanline_pos) { - m_state |= (0x02); // vsync - if( m_registers[EF936X_REG_CTRL1] & 0x20 ) + m_state |= 0x02; // vsync + if (m_registers[EF936X_REG_CTRL1] & 0x20) { m_irq_vb = 1; } @@ -1206,7 +1152,7 @@ void ef9365_device::update_scanline(uint16_t scanline) if (scanline == 0) { - m_state &= (~0x02); + m_state &= ~0x02; draw_border(0); } } @@ -1217,87 +1163,80 @@ void ef9365_device::update_scanline(uint16_t scanline) uint8_t ef9365_device::data_r(offs_t offset) { - unsigned char return_value; + uint8_t return_value; - switch(offset & 0xF) + switch (offset & 0xf) { case EF936X_REG_STATUS: if (m_bf) - m_state &= (~0x04); + m_state &= ~0x04; else m_state |= 0x04; - if ( ( overflow_mask_x & get_x_reg() ) || ( overflow_mask_y & get_y_reg() ) ) - { + if ((m_overflow_mask_x & get_x_reg()) || (m_overflow_mask_y & get_y_reg())) m_state |= 0x08; - } - if( m_irq_vb || m_irq_lb || m_irq_rdy ) - { + if (m_irq_vb || m_irq_lb || m_irq_rdy) m_state |= 0x80; - } - if( m_irq_lb ) - { + if (m_irq_lb) m_state |= 0x10; - m_irq_lb = 0; - } - if( m_irq_vb ) - { + if (m_irq_vb) m_state |= 0x20; - m_irq_vb = 0; - } - if( m_irq_rdy ) - { + if (m_irq_rdy) m_state |= 0x40; + + if (!machine().side_effects_disabled()) + { + m_irq_lb = 0; + m_irq_vb = 0; m_irq_rdy = 0; + update_interrupts(); } - update_interrupts(); - return_value = m_state; - break; + break; case EF936X_REG_CTRL1: - return_value = m_registers[EF936X_REG_CTRL1] & 0x7F; - break; + return_value = m_registers[EF936X_REG_CTRL1] & 0x7f; + break; case EF936X_REG_CTRL2: - return_value = m_registers[EF936X_REG_CTRL2] & 0x0F; - break; + return_value = m_registers[EF936X_REG_CTRL2] & 0x0f; + break; case EF936X_REG_CSIZE: return_value = m_registers[EF936X_REG_CSIZE]; - break; + break; case EF936X_REG_DELTAX: return_value = m_registers[EF936X_REG_DELTAX]; - break; + break; case EF936X_REG_DELTAY: return_value = m_registers[EF936X_REG_DELTAY]; - break; + break; case EF936X_REG_X_MSB: - return_value = m_registers[EF936X_REG_X_MSB] & 0x0F; - break; + return_value = m_registers[EF936X_REG_X_MSB] & 0x0f; + break; case EF936X_REG_X_LSB: return_value = m_registers[EF936X_REG_X_LSB]; - break; + break; case EF936X_REG_Y_MSB: - return_value = m_registers[EF936X_REG_Y_MSB] & 0x0F; - break; + return_value = m_registers[EF936X_REG_Y_MSB] & 0x0f; + break; case EF936X_REG_Y_LSB: return_value = m_registers[EF936X_REG_Y_LSB]; - break; + break; case EF936X_REG_XLP: - return_value = m_registers[EF936X_REG_XLP] & 0xFD; - break; + return_value = m_registers[EF936X_REG_XLP] & 0xfd; + break; case EF936X_REG_YLP: return_value = m_registers[EF936X_REG_YLP]; - break; + break; default: - return_value = 0xFF; - break; + return_value = 0xff; + break; } - LOG("EF9365 [ %s ] RD> [ 0x%.2X ] - %s\n", register_names[offset&0xF],return_value, machine().describe_context() ); + LOG("EF9365 [ %s ] RD> [ 0x%.2X ] - %s\n", register_names[offset & 0xf], return_value, machine().describe_context()); return return_value; } @@ -1308,45 +1247,45 @@ uint8_t ef9365_device::data_r(offs_t offset) void ef9365_device::data_w(offs_t offset, uint8_t data) { - LOG("EF9365 [ %s ] <WR [ 0x%.2X ] - %s\n", register_names[offset&0xF],data, machine().describe_context() ); + LOG("EF9365 [ %s ] <WR [ 0x%.2X ] - %s\n", register_names[offset & 0xf], data, machine().describe_context()); - switch(offset & 0xF) + switch (offset & 0xf) { case EF936X_REG_CMD: - ef9365_exec( data & 0xff); - break; + ef9365_exec(data & 0xff); + break; case EF936X_REG_CTRL1: - m_registers[EF936X_REG_CTRL1] = data & 0x7F; - break; + m_registers[EF936X_REG_CTRL1] = data & 0x7f; + break; case EF936X_REG_CTRL2: - m_registers[EF936X_REG_CTRL2] = data & 0x0F; - break; + m_registers[EF936X_REG_CTRL2] = data & 0x0f; + break; case EF936X_REG_CSIZE: m_registers[EF936X_REG_CSIZE] = data; - break; + break; case EF936X_REG_DELTAX: m_registers[EF936X_REG_DELTAX] = data; - break; + break; case EF936X_REG_DELTAY: m_registers[EF936X_REG_DELTAY] = data; - break; + break; case EF936X_REG_X_MSB: - m_registers[EF936X_REG_X_MSB] = data & 0x0F; - break; + m_registers[EF936X_REG_X_MSB] = data & 0x0f; + break; case EF936X_REG_X_LSB: m_registers[EF936X_REG_X_LSB] = data; - break; + break; case EF936X_REG_Y_MSB: - m_registers[EF936X_REG_Y_MSB] = data & 0x0F; - break; + m_registers[EF936X_REG_Y_MSB] = data & 0x0f; + break; case EF936X_REG_Y_LSB: m_registers[EF936X_REG_Y_LSB] = data; - break; + break; case EF936X_REG_XLP: - break; + break; case EF936X_REG_YLP: - break; + break; default: - break; + break; } } |