From c6a155f544e60f9f2ee4e80aa0a3b981e99d34f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20DEL=20NERO?= Date: Tue, 1 Dec 2015 21:29:42 +0100 Subject: [PATCH 1/2] Clear screen, Screen scanning command added. Palette support added. --- src/devices/video/ef9365.cpp | 106 ++++++++++++++++++++++++++--------- src/devices/video/ef9365.h | 6 +- 2 files changed, 84 insertions(+), 28 deletions(-) diff --git a/src/devices/video/ef9365.cpp b/src/devices/video/ef9365.cpp index 2638b665254..403638a1697 100644 --- a/src/devices/video/ef9365.cpp +++ b/src/devices/video/ef9365.cpp @@ -19,11 +19,12 @@ const device_type EF9365 = &device_creator; // default address map +// Up to 4 bitplans @ 256*256 static ADDRESS_MAP_START( ef9365, AS_0, 8, ef9365_device ) - AM_RANGE(0x0000, 0x1fff) AM_RAM // BLUE - AM_RANGE(0x2000, 0x3fff) AM_RAM // GREEN - AM_RANGE(0x4000, 0x5fff) AM_RAM // RED - AM_RANGE(0x6000, 0x7fff) AM_RAM // INTENSITY + AM_RANGE(0x0000, 0x1fff) AM_RAM + AM_RANGE(0x2000, 0x3fff) AM_RAM + AM_RANGE(0x4000, 0x5fff) AM_RAM + AM_RANGE(0x6000, 0x7fff) AM_RAM ADDRESS_MAP_END //------------------------------------------------- @@ -78,18 +79,40 @@ void ef9365_device::static_set_color_filler( UINT8 color ) m_current_color = color; } +//------------------------------------------------- +// static_set_color_entry: Set the color value +// into the palette +//------------------------------------------------- + +void ef9365_device::static_set_color_entry( int index, UINT8 r, UINT8 g, UINT8 b ) +{ + if( index < 16 ) + { + palette[index] = rgb_t(r, g, b); + } +} + //------------------------------------------------- // device_start - device-specific startup //------------------------------------------------- void ef9365_device::device_start() { + int i; + m_busy_timer = timer_alloc(BUSY_TIMER); m_videoram = &space(0); m_charset = region(); m_current_color = 0x0F; + // Default palette : Black and white + palette[0] = rgb_t(0, 0, 0); + for( i = 1; i < 16 ; i++ ) + { + palette[i] = rgb_t(255, 255, 255); + } + m_screen_out.allocate(496, m_screen->height()); save_item(NAME(m_border)); @@ -162,7 +185,7 @@ void ef9365_device::draw_character( unsigned char c ) { int x_char,y_char; int char_base,char_pix; - unsigned int x, y; + unsigned int x, y, p; x = ( (m_registers[EF9365_REG_X_MSB]<<8) | m_registers[EF9365_REG_X_LSB]); y = ( (m_registers[EF9365_REG_Y_MSB]<<8) | m_registers[EF9365_REG_Y_LSB]); @@ -182,17 +205,13 @@ void ef9365_device::draw_character( unsigned char c ) { if ( m_charset->u8(char_base + (char_pix>>3) ) & ( 0x80 >> (char_pix&7))) { - if( m_current_color & 0x01) - m_videoram->write_byte ( 0x0000 + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( 0x0000 + ((((y_char+y)*256) + (x_char+x))>>3)) | (0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); - - if( m_current_color & 0x02) - m_videoram->write_byte ( 0x2000 + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( 0x2000 + ((((y_char+y)*256) + (x_char+x))>>3)) | (0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); - - if( m_current_color & 0x04) - m_videoram->write_byte ( 0x4000 + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( 0x4000 + ((((y_char+y)*256) + (x_char+x))>>3)) | (0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); - - if( m_current_color & 0x08) - m_videoram->write_byte ( 0x6000 + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( 0x6000 + ((((y_char+y)*256) + (x_char+x))>>3)) | (0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); + for(p = 0 ; p < 4 ; p++) + { + if( m_current_color & (0x01 << p) ) + m_videoram->write_byte ( (0x2000*p) + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( (0x2000*p) + ((((y_char+y)*256) + (x_char+x))>>3)) | (0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); + else + m_videoram->write_byte ( (0x2000*p) + ((((y_char+y)*256) + (x_char+x))>>3), m_videoram->read_byte( (0x2000*p) + ((((y_char+y)*256) + (x_char+x))>>3)) & ~(0x80 >> ((((y_char+y)*256) + (x_char+x))&7) ) ); + } } char_pix++; @@ -207,6 +226,41 @@ void ef9365_device::draw_character( unsigned char c ) } } +void ef9365_device::screen_scanning( int force_clear ) +{ + int x,y,p; + + if( (m_registers[EF9365_REG_CTRL1] & 0x02) && !force_clear ) + { + for( y = 0; y < 256; y++ ) + { + for( x = 0; x < 256; x++ ) + { + for( p = 0 ; p < 4 ; p++ ) + { + if( m_current_color & (0x01 << p) ) + m_videoram->write_byte ( (0x2000*p) + (((y*256) + x)>>3), m_videoram->read_byte( (0x2000*p) + (((y*256) + x)>>3)) | (0x80 >> (((y*256) + x)&7) ) ); + else + m_videoram->write_byte ( (0x2000*p) + (((y*256) + x)>>3), m_videoram->read_byte( (0x2000*p) + (((y*256) + x)>>3)) & ~(0x80 >> (((y*256) + x)&7) ) ); + } + } + } + } + else + { + for( y = 0; y < 256; y++) + { + for( x = 0; x < 256; x++) + { + for( p = 0 ; p < 4 ; p++ ) + { + m_videoram->write_byte ( (0x2000*p) + (((y*256) + x)>>3), m_videoram->read_byte( (0x2000*p) + (((y*256) + x)>>3)) & ~(0x80 >> (((y*256) + x)&7) ) ); + } + } + } + } +} + // Execute EF9365 command void ef9365_device::ef9365_exec(UINT8 cmd) { @@ -246,6 +300,7 @@ void ef9365_device::ef9365_exec(UINT8 cmd) #ifdef DBGMODE printf("Clear screen\n"); #endif + screen_scanning(1); break; case 0x5: // X and Y registers reset to 0 #ifdef DBGMODE @@ -271,6 +326,7 @@ void ef9365_device::ef9365_exec(UINT8 cmd) #ifdef DBGMODE printf("Clear screen, set CSIZE to code \"minsize\". All other registers reset to 0\n"); #endif + screen_scanning(1); break; case 0x8: // Light-pen initialization (/White forced low) #ifdef DBGMODE @@ -296,6 +352,7 @@ void ef9365_device::ef9365_exec(UINT8 cmd) #ifdef DBGMODE printf("Screen scanning : pen or Eraser as defined by CTRL1\n"); #endif + screen_scanning(0); break; case 0xD: // X reset to 0 #ifdef DBGMODE @@ -368,37 +425,36 @@ void ef9365_device::ef9365_exec(UINT8 cmd) UINT32 ef9365_device::screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect) { int i,j,k; - unsigned long r,v,b; + unsigned char color_index; + k = 0; for(i=0;i<256;i++) { for(j=0;j<256;j++) { - r = v = b = 0; + color_index = 0x00; if( m_videoram->read_byte(0x0000 + (k>>3)) & (0x80>>(k&7))) { - b = 0xFF; + color_index |= 0x01; } if( m_videoram->read_byte(0x2000 + (k>>3)) & (0x80>>(k&7))) { - v = 0xFF; + color_index |= 0x02; } if( m_videoram->read_byte(0x4000 + (k>>3)) & (0x80>>(k&7))) { - r = 0xFF; + color_index |= 0x04; } if( m_videoram->read_byte(0x6000 + (k>>3)) & (0x80>>(k&7))) { - r = r / 2; - v = v / 2; - b = b / 2; + color_index |= 0x08; } - m_screen_out.pix32(i, j) = ( r<<16 ) | ( v<<8 ) | b; + m_screen_out.pix32(i, j) = palette[ color_index&0xF ]; k++; } diff --git a/src/devices/video/ef9365.h b/src/devices/video/ef9365.h index 60da13c7e21..fde027e22c3 100644 --- a/src/devices/video/ef9365.h +++ b/src/devices/video/ef9365.h @@ -40,6 +40,7 @@ public: void update_scanline(UINT16 scanline); void static_set_color_filler( UINT8 color ); + void static_set_color_entry( int index, UINT8 r, UINT8 g, UINT8 b ); UINT32 screen_update(screen_device &screen, bitmap_rgb32 &bitmap, const rectangle &cliprect); protected: @@ -58,6 +59,7 @@ protected: private: void draw_character( unsigned char c ); + void screen_scanning( int force_clear ); void set_busy_flag(int period); void set_video_mode(void); void draw_border(UINT16 line); @@ -74,6 +76,7 @@ private: UINT8 m_registers[0x10]; //registers UINT8 m_state; //status register UINT8 m_border[80]; //border color + rgb_t palette[16]; bitmap_rgb32 m_screen_out; @@ -100,7 +103,4 @@ extern const device_type EF9365; #define EF9365_REG_XLP 0x0C #define EF9365_REG_YLP 0x0D -#define EF9365_REG_CTRL1 0x01 -#define EF9365_REG_CTRL1 0x01 - #endif From 2e1f98eeb67326d83df66f33cdb480f7f8896e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20DEL=20NERO?= Date: Tue, 1 Dec 2015 21:35:08 +0100 Subject: [PATCH 2/2] Charset ROM corrected. Color Palette corrected. --- src/mame/drivers/squale.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/mame/drivers/squale.cpp b/src/mame/drivers/squale.cpp index 735d1e003f8..b9484a20bea 100644 --- a/src/mame/drivers/squale.cpp +++ b/src/mame/drivers/squale.cpp @@ -136,9 +136,22 @@ INPUT_PORTS_END void squale_state::machine_start() { + int i; + membank("rom_bank")->configure_entry(0, memregion("maincpu")->base() + 0x100); membank("rom_bank")->configure_entry(1, memregion("maincpu")->base() + 0x1100); membank("rom_bank")->set_entry( 0 ); + + // Generate Squale hardware palette + for(i=0;i<8;i++) + { + m_ef9365->static_set_color_entry(i,(((i&4)>>2)^1) * 255,(((i&2)>>1)^1) * 255, ((i&1)^1) * 255 ); + } + + for(i=0;i<8;i++) + { + m_ef9365->static_set_color_entry(i + 8,(((i&4)>>2)^1) * 127,(((i&2)>>1)^1) * 127, ((i&1)^1) * 127 ); + } } void squale_state::machine_reset() @@ -174,7 +187,7 @@ static MACHINE_CONFIG_START( squale, squale_state ) MCFG_SCREEN_SIZE(336, 270) MCFG_SCREEN_VISIBLE_AREA(00, 336-1, 00, 270-1) - MCFG_PALETTE_ADD("palette", 8) + MCFG_PALETTE_ADD("palette", 16) MCFG_DEVICE_ADD("ef9365", EF9365, 0) MCFG_EF9365_PALETTE("palette") @@ -193,7 +206,7 @@ ROM_START( squale ) // place ROM v1.2 signature here. ROM_REGION( 0x1E0, "ef9365", 0 ) - ROM_LOAD( "charset_ef9365.rom", 0x0000, 0x01E0, CRC(22BE2908) SHA1(3920ee887b8ca2887b3e0471bea7c1045a87fc10) ) + ROM_LOAD( "charset_ef9365.rom", 0x0000, 0x01E0, CRC(8d3053be) SHA1(0f9a64d217a0f7f04ee0720d49c5b680ad0ae359) ) ROM_END /* Driver */