Example #1
0
void k052109_device::device_start()
{
	if (m_screen_tag != nullptr)
	{
		// make sure our screen is started
		screen_device *screen = m_owner->subdevice<screen_device>(m_screen_tag);
		if (!screen->started())
			throw device_missing_dependencies();

		// and register a callback for vblank state
		screen->register_vblank_callback(vblank_state_delegate(FUNC(k052109_device::vblank_callback), this));
	}

	if (region() != nullptr)
	{
		m_char_rom = region()->base();
		m_char_size = region()->bytes();
	}

	decode_gfx();
	gfx(0)->set_colors(palette().entries() / gfx(0)->depth());

	m_ram = make_unique_clear<UINT8[]>(0x6000);

	m_colorram_F = &m_ram[0x0000];
	m_colorram_A = &m_ram[0x0800];
	m_colorram_B = &m_ram[0x1000];
	m_videoram_F = &m_ram[0x2000];
	m_videoram_A = &m_ram[0x2800];
	m_videoram_B = &m_ram[0x3000];
	m_videoram2_F = &m_ram[0x4000];
	m_videoram2_A = &m_ram[0x4800];
	m_videoram2_B = &m_ram[0x5000];

	m_tilemap[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
	m_tilemap[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info1),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
	m_tilemap[2] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info2),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);

	m_tilemap[0]->set_transparent_pen(0);
	m_tilemap[1]->set_transparent_pen(0);
	m_tilemap[2]->set_transparent_pen(0);

	// bind callbacks
	m_k052109_cb.bind_relative_to(*owner());

	// resolve callbacks
	m_irq_handler.resolve_safe();
	m_firq_handler.resolve_safe();
	m_nmi_handler.resolve_safe();

	save_pointer(NAME(m_ram.get()), 0x6000);
	save_item(NAME(m_rmrd_line));
	save_item(NAME(m_romsubbank));
	save_item(NAME(m_scrollctrl));
	save_item(NAME(m_irq_enabled));
	save_item(NAME(m_charrombank));
	save_item(NAME(m_charrombank_2));
	save_item(NAME(m_has_extra_video_ram));
	machine().save().register_postload(save_prepost_delegate(FUNC(k052109_device::tileflip_reset), this));
}
Example #2
0
void tc0100scn_device::ram_w(offs_t offset, u16 data, u16 mem_mask)
{
	COMBINE_DATA(&m_ram[offset]);
	/* Double-width tilemaps have a different memory map */
	if (offset < 0x2000)
	{
		m_tilemap[0][0]->mark_tile_dirty(offset / 2);
		m_tilemap[0][1]->mark_tile_dirty(offset / 2);
	}
	else if (offset < 0x3000)
	{
		m_tilemap[2][0]->mark_tile_dirty((offset & 0x0fff));
		m_tilemap[0][1]->mark_tile_dirty(offset / 2);
	}
	else if (offset < 0x3800)
	{
		gfx(0)->mark_dirty((offset - 0x3000) / 8);
		m_tilemap[0][1]->mark_tile_dirty(offset / 2);
	}
	else if (offset < 0x4000)
		m_tilemap[0][1]->mark_tile_dirty(offset / 2);
	else if (offset < 0x6000)
	{
		m_tilemap[1][0]->mark_tile_dirty((offset & 0x1fff) / 2);
		m_tilemap[1][1]->mark_tile_dirty((offset & 0x3fff) / 2);
	}
	else if (offset < 0x8000)
		m_tilemap[1][1]->mark_tile_dirty((offset & 0x3fff) / 2);
	else if (offset >= 0x8800 && offset < 0x9000)
		gfx(1)->mark_dirty((offset - 0x8800) / 8);
	else if (offset >= 0x9000)
		m_tilemap[2][1]->mark_tile_dirty((offset & 0x0fff));

}
Example #3
0
void dooyong_rom_tilemap_device::device_start()
{
	if (!m_gfxdecode->started())
		throw device_missing_dependencies();

	m_tilemap = &machine().tilemap().create(
			*m_gfxdecode,
			tilemap_get_info_delegate(FUNC(dooyong_rom_tilemap_device::tile_info), this),
			TILEMAP_SCAN_COLS,
			gfx().width(),
			gfx().height(),
			1024 / gfx().width(),
			m_rows);
	if (~m_transparent_pen)
		m_tilemap->set_transparent_pen(m_transparent_pen);

	if (0 > m_tilerom_offset)
		m_tilerom_offset = m_tilerom.length() + m_tilerom_offset;

	std::fill(std::begin(m_registers), std::end(m_registers), 0U);
	m_palette_bank = 0U;

	save_item(NAME(m_registers));
	save_item(NAME(m_palette_bank));
}
Example #4
0
void k051316_device::device_start()
{
	decode_gfx();
	gfx(0)->set_colors(palette().entries() / gfx(0)->depth());

	m_tmap = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k051316_device::get_tile_info),this), TILEMAP_SCAN_ROWS, 16, 16, 32, 32);
	m_ram.resize(0x800);
	memset(&m_ram[0], 0, 0x800);

	if (m_layermask)
	{
		m_tmap->map_pens_to_layer(0, 0, 0, TILEMAP_PIXEL_LAYER1);
		m_tmap->map_pens_to_layer(0, m_layermask, m_layermask, TILEMAP_PIXEL_LAYER0);
	}
	else
		m_tmap->set_transparent_pen(0);

	// bind callbacks
	m_k051316_cb.bind_relative_to(*owner());

	save_item(NAME(m_ram));
	save_item(NAME(m_ctrlram));
	save_item(NAME(m_wrap));

}
Example #5
0
void k05324x_device::device_start()
{
	if (!palette().device().started())
		throw device_missing_dependencies();

	/* decode the graphics */
	decode_gfx();
	gfx(0)->set_colors(palette().entries() / gfx(0)->depth());

	if (VERBOSE && !(palette().shadows_enabled()))
		popmessage("driver should use VIDEO_HAS_SHADOWS");

	m_ramsize = 0x800;

	m_z_rejection = -1;
	m_ram = make_unique_clear<uint16_t[]>(m_ramsize / 2);
	m_buffer = make_unique_clear<uint16_t[]>(m_ramsize / 2);

	// bind callbacks
	m_k05324x_cb.bind_relative_to(*owner());

	save_pointer(NAME(m_ram), m_ramsize / 2);
	save_pointer(NAME(m_buffer), m_ramsize / 2);
	save_item(NAME(m_rombank));
	save_item(NAME(m_z_rejection));
	save_item(NAME(m_regs));
}
Example #6
0
void k052109_device::device_start()
{
	if (m_screen.found())
	{
		// make sure our screen is started
		if (!m_screen->started())
			throw device_missing_dependencies();

		// and register a callback for vblank state
		m_screen->register_vblank_callback(vblank_state_delegate(&k052109_device::vblank_callback, this));
	}

	decode_gfx();
	gfx(0)->set_colors(palette().entries() / gfx(0)->depth());

	m_ram = make_unique_clear<uint8_t[]>(0x6000);

	m_colorram_F = &m_ram[0x0000];
	m_colorram_A = &m_ram[0x0800];
	m_colorram_B = &m_ram[0x1000];
	m_videoram_F = &m_ram[0x2000];
	m_videoram_A = &m_ram[0x2800];
	m_videoram_B = &m_ram[0x3000];
	m_videoram2_F = &m_ram[0x4000];
	m_videoram2_A = &m_ram[0x4800];
	m_videoram2_B = &m_ram[0x5000];

	m_tilemap[0] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info0),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
	m_tilemap[1] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info1),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);
	m_tilemap[2] = &machine().tilemap().create(*this, tilemap_get_info_delegate(FUNC(k052109_device::get_tile_info2),this), TILEMAP_SCAN_ROWS, 8, 8, 64, 32);

	m_tilemap[0]->set_transparent_pen(0);
	m_tilemap[1]->set_transparent_pen(0);
	m_tilemap[2]->set_transparent_pen(0);

	// bind callbacks
	m_k052109_cb.bind_relative_to(*owner());

	// resolve callbacks
	m_irq_handler.resolve_safe();
	m_firq_handler.resolve_safe();
	m_nmi_handler.resolve_safe();

	save_pointer(NAME(m_ram), 0x6000);
	save_item(NAME(m_rmrd_line));
	save_item(NAME(m_romsubbank));
	save_item(NAME(m_scrollctrl));
	save_item(NAME(m_irq_enabled));
	save_item(NAME(m_charrombank));
	save_item(NAME(m_charrombank_2));
	save_item(NAME(m_has_extra_video_ram));
}
Example #7
0
//#define DEBUG
int main (int argc, char **argv)
{
    #ifdef DEBUG
    int xSize,ySize;
         struct winsize w;
            ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
            xSize=w.ws_col;
            ySize=w.ws_row;
            Ascii gfx(xSize,ySize);
        //ClosePointInterpolateGenerator generator=ClosePointInterpolateGenerator();
        PPMGenerator generator;
        gfx.doSomething();
        gfx.bitblit(&generator);
        return 0;
    #endif
    if(argc!=3&&argc!=5){
        printf("%s objFile format xSize ySize\nformat can be ppm,xpm,console,dither\n",argv[0]);
    }else{
        int xSize,ySize;
        if(argc==5){
            xSize=atoi(argv[3]);
            ySize=atoi(argv[4]);
        }else{
            struct winsize w;
            ioctl(STDOUT_FILENO, TIOCGWINSZ, &w);
            xSize=w.ws_col;
            ySize=w.ws_row;
        }
        Ascii gfx(xSize,ySize,argv[1]);
        gfx.doSomething();
        if(std::string(argv[2]).compare("console")==0){
            ClosePointInterpolateGenerator generator;
            while(true)gfx.bitblit(&generator);
        }else if(std::string(argv[2]).compare("dither")==0){
            ClosePointDitherGenerator generator;
            while(true)gfx.bitblit(&generator);
        }else if(std::string(argv[2]).compare("ppm")==0){
            PPMGenerator generator;
            gfx.bitblit(&generator);
        }else if(std::string(argv[2]).compare("xpm")==0){
            XPMGenerator generator;
            gfx.bitblit(&generator);
        }else{
            printf("bad format\n");
            return 0;
        }
    }
    return 0;
}
Example #8
0
void toaplan_scu_device::draw_sprites_to_tempbitmap(const rectangle &cliprect, uint16_t* spriteram, uint32_t bytes )
{
	int offs;
	m_temp_spritebitmap.fill(0,cliprect);

	for (offs = 0;offs < bytes/2;offs += 4)
	{
		int attribute,sx,sy,flipx,flipy;
		int sprite, color;

		attribute = spriteram[offs + 1];
		int priority = (attribute & 0x0c00)>>10;

		// are 0 priority really skipped, or can they still mask?
		if (!priority) continue;

		sy = spriteram[offs + 3] >> 7;
		if (sy != 0x0100) {     /* sx = 0x01a0 or 0x0040*/
			sprite = spriteram[offs] & 0x7ff;
			color  = attribute & 0x3f;
			color |= priority << 6; // encode colour

			sx = spriteram[offs + 2] >> 7;
			flipx = attribute & 0x100;
			if (flipx) sx -= m_xoffs_flipped;

			flipy = attribute & 0x200;
			gfx(0)->transpen_raw(m_temp_spritebitmap,cliprect,
				sprite,
				color << 4 /* << 4 because using _raw */ ,
				flipx,flipy,
				sx-m_xoffs,sy-16,0);
		}
	}
void GameOverState::load_gfx(CL_GraphicContext& gc, std::string skin)
{
	unload_gfx();

	// Getting skins resources
	CL_VirtualFileSystem vfs(skin, true);
	CL_VirtualDirectory vd(vfs, "./");	
	CL_ResourceManager gfx("menu_gameover.xml",vd);

	_dialog_gameover = CL_Sprite(gc, "menu_gameover/dialog_gameover", &gfx);
	_dialog_highscore = CL_Sprite(gc, "menu_gameover/dialog_highscore", &gfx);
	_score1_x = CL_Integer_to_int("menu_gameover/score1_left", &gfx);
	_score1_y = CL_Integer_to_int("menu_gameover/score1_top", &gfx);
	_score2_x = CL_Integer_to_int("menu_gameover/score2_left", &gfx);
	_score2_y = CL_Integer_to_int("menu_gameover/score2_top", &gfx);

	_quit_choice_item.set_gfx(gc, gfx, 
		"menu_gameover/new_game_question/yes/unselected",
		"menu_gameover/new_game_question/yes/selected",
		"menu_gameover/new_game_question/no/unselected",
		"menu_gameover/new_game_question/no/selected");

	_quit_choice_item.set_x(
		CL_Integer_to_int("menu_gameover/new_game_question/yes/left", &gfx));
	_quit_choice_item.set_x2(
		CL_Integer_to_int("menu_gameover/new_game_question/no/left", &gfx));
	_quit_choice_item.set_y(
		CL_Integer_to_int("menu_gameover/new_game_question/yes/top", &gfx));
	_quit_choice_item.set_y2(
		CL_Integer_to_int("menu_gameover/new_game_question/no/top", &gfx));
}
Example #10
0
    // Finds the index of the tab, which contains the given point.
    int IndexFromPoint(int x, int y, bool* inXbutton = nullptr) {
        Point point(x, y);
        Graphics gfx(hwnd);
        GraphicsPath shapes(data->Points, data->Types, data->Count);
        GraphicsPath shape;
        GraphicsPathIterator iterator(&shapes);
        iterator.NextMarker(&shape);

        ClientRect rClient(hwnd);
        REAL yPosTab = inTitlebar ? 0.0f : REAL(rClient.dy - height - 1);
        gfx.TranslateTransform(1.0f, yPosTab);
        for (int i = 0; i < Count(); i++) {
            Point pt(point);
            gfx.TransformPoints(CoordinateSpaceWorld, CoordinateSpaceDevice, &pt, 1);
            if (shape.IsVisible(pt, &gfx)) {
                iterator.NextMarker(&shape);
                if (inXbutton)
                    *inXbutton = shape.IsVisible(pt, &gfx) ? true : false;
                return i;
            }
            gfx.TranslateTransform(REAL(width + 1), 0.0f);
        }
        if (inXbutton)
            *inXbutton = false;
        return -1;
    }
Example #11
0
		void GDIPlusBuffered::End()
		{
			Gdiplus::Graphics gfx( m_hDC );
			gfx.DrawImage( m_Bitmap, 0, 0 );

			ReleaseDC( m_HWND, m_hDC );
			m_hDC = NULL;
		}
Example #12
0
Skin::Skin(std::string filename, CL_GraphicContext& gc)
{
	_filename = filename;
	_element = 3;

	// We load the logo sprite in the gfx ressources file
	CL_VirtualFileSystem vfs(filename, true);
	CL_VirtualDirectory vd(vfs, "./");
	CL_ResourceManager gfx("general.xml", vd);
	_logo = CL_Image(gc, "logo", &gfx);
}
Example #13
0
    // Invalidates the tab's region in the client area.
    void Invalidate(int index) {
        if (index < 0)
            return;

        Graphics gfx(hwnd);
        GraphicsPath shapes(data->Points, data->Types, data->Count);
        GraphicsPath shape;
        GraphicsPathIterator iterator(&shapes);
        iterator.NextMarker(&shape);
        Region region(&shape);

        ClientRect rClient(hwnd);
        REAL yPosTab = inTitlebar ? 0.0f : REAL(rClient.dy - height - 1);
        gfx.TranslateTransform(REAL((width + 1) * index) + 1.0f, yPosTab);
        HRGN hRgn = region.GetHRGN(&gfx);
        InvalidateRgn(hwnd, hRgn, FALSE);
        DeleteObject(hRgn);
    }
Example #14
0
int main(int argc, char **argv)
{

	pvr_init_defaults();
	initTXT(TEXT_ENC);
	initBG("/rd/bg2.png");

	if (initHDD())
		dbglog(DBG_DEBUG, "* Failed to Initialize HDD!\n");

	if (initFS("/hd"))
		dbglog(DBG_DEBUG, "* Failed to Initialize EXT2 FS!\n");

	while (1)
	{
		update();
		gfx();
	}

	return 0;
}
Example #15
0
		void GDIPlusBuffered::CreateBackbuffer()
		{
			// Check the Client Gwen::Rect size (of supplied HWND)
			// If it has changed, we need to recreate the backbuffer
			{
				RECT rect;
				GetClientRect( m_HWND, &rect );

				int width = rect.right - rect.left;
				int height = rect.bottom - rect.top;

				if ( m_iWidth != width ) DestroyBackbuffer();
				if ( m_iHeight != height ) DestroyBackbuffer();

				m_iWidth = width;
				m_iHeight = height;
			}

			if ( m_Bitmap ) return;

			Gdiplus::Graphics gfx( m_hDC );
			m_Bitmap = new Gdiplus::Bitmap( m_iWidth, m_iHeight, &gfx );
			graphics = Gdiplus::Graphics::FromImage( m_Bitmap );
		}
static void write_p3cf(Bitu port,Bitu val,Bitu iolen) {
	switch (gfx(index)) {
	case 0:	/* Set/Reset Register */
		gfx(set_reset)=val & 0x0f;
		vga.config.full_set_reset=FillTable[val & 0x0f];
		vga.config.full_enable_and_set_reset=vga.config.full_set_reset &
			vga.config.full_enable_set_reset;
		/*
			0	If in Write Mode 0 and bit 0 of 3CEh index 1 is set a write to
				display memory will set all the bits in plane 0 of the byte to this
				bit, if the corresponding bit is set in the Map Mask Register (3CEh
				index 8).
			1	Same for plane 1 and bit 1 of 3CEh index 1.
			2	Same for plane 2 and bit 2 of 3CEh index 1.
			3	Same for plane 3 and bit 3 of 3CEh index 1.
		*/
//		LOG_DEBUG("Set Reset = %2X",val);
		break;
	case 1: /* Enable Set/Reset Register */
		gfx(enable_set_reset)=val & 0x0f;
		vga.config.full_enable_set_reset=FillTable[val & 0x0f];
		vga.config.full_not_enable_set_reset=~vga.config.full_enable_set_reset;
		vga.config.full_enable_and_set_reset=vga.config.full_set_reset &
			vga.config.full_enable_set_reset;
//		if (gfx(enable_set_reset)) vga.config.mh_mask|=MH_SETRESET else vga.config.mh_mask&=~MH_SETRESET;
		break;
	case 2: /* Color Compare Register */
		gfx(color_compare)=val & 0x0f;
		/*
			0-3	In Read Mode 1 each pixel at the address of the byte read is compared
				to this color and the corresponding bit in the output set to 1 if
				they match, 0 if not. The Color Don't Care Register (3CEh index 7)
				can exclude bitplanes from the comparison.
		*/
		vga.config.color_compare=val & 0xf;
//		LOG_DEBUG("Color Compare = %2X",val);
		break;
	case 3: /* Data Rotate */
		gfx(data_rotate)=val;
		vga.config.data_rotate=val & 7;
//		if (val) vga.config.mh_mask|=MH_ROTATEOP else vga.config.mh_mask&=~MH_ROTATEOP;
		vga.config.raster_op=(val>>3) & 3;
		/* 
			0-2	Number of positions to rotate data right before it is written to
				display memory. Only active in Write Mode 0.
			3-4	In Write Mode 2 this field controls the relation between the data
				written from the CPU, the data latched from the previous read and the
				data written to display memory:
				0: CPU Data is written unmodified
				1: CPU data is ANDed with the latched data
				2: CPU data is ORed  with the latch data.
				3: CPU data is XORed with the latched data.
		*/
		break;
	case 4: /* Read Map Select Register */
		/*	0-1	number of the plane Read Mode 0 will read from */
		gfx(read_map_select)=val & 0x03;
		vga.config.read_map_select=val & 0x03;
//		LOG_DEBUG("Read Map %2X",val);
		break;
	case 5: /* Mode Register */
		if ((gfx(mode) ^ val) & 0xf0) {
		gfx(mode)=val;
			VGA_DetermineMode();
		} else gfx(mode)=val;
		vga.config.write_mode=val & 3;
		vga.config.read_mode=(val >> 3) & 1;
//		LOG_DEBUG("Write Mode %d Read Mode %d val %d",vga.config.write_mode,vga.config.read_mode,val);
		/*
			0-1	Write Mode: Controls how data from the CPU is transformed before
				being written to display memory:
				0:	Mode 0 works as a Read-Modify-Write operation.
					First a read access loads the data latches of the VGA with the
					value in video memory at the addressed location. Then a write
					access will provide the destination address and the CPU data
					byte. The data written is modified by the function code in the
					Data Rotate register (3CEh index 3) as a function of the CPU
					data and the latches, then data is rotated as specified by the
					same register.
				1:	Mode 1 is used for video to video transfers.
					A read access will load the data latches with the contents of
					the addressed byte of video memory. A write access will write
					the contents of the latches to the addressed byte. Thus a single
					MOVSB instruction can copy all pixels in the source address byte
					to the destination address.
				2:	Mode 2 writes a color to all pixels in the addressed byte of
					video memory. Bit 0 of the CPU data is written to plane 0 et
					cetera. Individual bits can be enabled or disabled through the
					Bit Mask register (3CEh index 8).
				3:	Mode 3 can be used to fill an area with a color and pattern. The
					CPU data is rotated according to 3CEh index 3 bits 0-2 and anded
					with the Bit Mask Register (3CEh index 8). For each bit in the
					result the corresponding pixel is set to the color in the
					Set/Reset Register (3CEh index 0 bits 0-3) if the bit is set and
					to the contents of the processor latch if the bit is clear.
			3	Read Mode
				0:	Data is read from one of 4 bit planes depending on the Read Map
					Select Register (3CEh index 4).
				1:	Data returned is a comparison between the 8 pixels occupying the
					read byte and the color in the Color Compare Register (3CEh
					index 2). A bit is set if the color of the corresponding pixel
					matches the register.
			4	Enables Odd/Even mode if set (See 3C4h index 4 bit 2).
			5	Enables CGA style 4 color pixels using even/odd bit pairs if set.
			6	Enables 256 color mode if set.	
		*/
		break;
	case 6: /* Miscellaneous Register */
		if ((gfx(miscellaneous) ^ val) & 0x0c) {
			gfx(miscellaneous)=val;
			VGA_DetermineMode();
		} else gfx(miscellaneous)=val;
		VGA_SetupHandlers();
		/*
			0	Indicates Graphics Mode if set, Alphanumeric mode else.
			1	Enables Odd/Even mode if set.
			2-3	Memory Mapping:
				0: use A000h-BFFFh
				1: use A000h-AFFFh   VGA Graphics modes
				2: use B000h-B7FFh   Monochrome modes
				3: use B800h-BFFFh   CGA modes
		*/
		break;
	case 7: /* Color Don't Care Register */
		gfx(color_dont_care)=val & 0x0f;
		/*
			0	Ignore bit plane 0 in Read mode 1 if clear.
			1	Ignore bit plane 1 in Read mode 1 if clear.
			2	Ignore bit plane 2 in Read mode 1 if clear.
			3	Ignore bit plane 3 in Read mode 1 if clear.
		*/
		vga.config.color_dont_care=val & 0xf;
//		LOG_DEBUG("Color don't care = %2X",val);
		break;
	case 8: /* Bit Mask Register */
		gfx(bit_mask)=val;
		vga.config.full_bit_mask=ExpandTable[val];
//		LOG_DEBUG("Bit mask %2X",val);
		/*
			0-7	Each bit if set enables writing to the corresponding bit of a byte in
				display memory.
		*/
		break;
	default:
		if (svga.write_p3cf) {
			svga.write_p3cf(gfx(index), val, iolen);
			break;
		}
		if (gfx(index) == 9 && !index9warned) {
			LOG(LOG_VGAMISC,LOG_NORMAL)("VGA:3CF:Write %2X to illegal index 9",val);
			index9warned=true;
			break;
		}
		LOG(LOG_VGAMISC,LOG_NORMAL)("VGA:3CF:Write %2X to illegal index %2X",val,gfx(index));
		break;
	}
}
static Bitu read_p3ce(Bitu port,Bitu iolen) {
	return gfx(index);
}
static void write_p3ce(Bitu port,Bitu val,Bitu iolen) {
	gfx(index)=val & 0x0f;
}
static Bitu read_p3cf(Bitu port,Bitu iolen) {
	switch (gfx(index)) {
	case 0:	/* Set/Reset Register */
		return gfx(set_reset);
	case 1: /* Enable Set/Reset Register */
		return gfx(enable_set_reset);
	case 2: /* Color Compare Register */
		return gfx(color_compare);
	case 3: /* Data Rotate */
		return gfx(data_rotate);
	case 4: /* Read Map Select Register */
		return gfx(read_map_select);
	case 5: /* Mode Register */
		return gfx(mode);
	case 6: /* Miscellaneous Register */
		return gfx(miscellaneous);
	case 7: /* Color Don't Care Register */
		return gfx(color_dont_care);
	case 8: /* Bit Mask Register */
		return gfx(bit_mask);
	default:
		if (svga.read_p3cf)
			return svga.read_p3cf(gfx(index), iolen);
		LOG(LOG_VGAMISC,LOG_NORMAL)("Reading from illegal index %2X in port %4X",static_cast<Bit32u>(gfx(index)),port);
		break;
	}
	return 0;	/* Compiler happy */
}
Example #20
0
awl::main::exit_code const
example_main(
	awl::main::function_context const &
)
try
{
	sge::systems::instance<
		boost::mpl::vector5<
			sge::systems::with_renderer<
				sge::systems::renderer_caps::ffp
			>,
			sge::systems::with_window,
			sge::systems::with_input<
				boost::mpl::vector2<
					sge::systems::focus_collector,
					sge::systems::keyboard_collector
				>
			>,
			sge::systems::with_image2d,
			sge::systems::with_font
		>
	> const sys(
		sge::systems::make_list
		(
			sge::systems::window(
				sge::systems::window_source(
					sge::systems::original_window(
						sge::window::title(
							FCPPT_TEXT("sge console test")
						)
					)
				)
			)
		)
		(
			sge::systems::renderer(
				sge::renderer::pixel_format::object(
					sge::renderer::pixel_format::color::depth32,
					sge::renderer::pixel_format::depth_stencil::off,
					sge::renderer::pixel_format::optional_multi_samples(),
					sge::renderer::pixel_format::srgb::no
				),
				sge::renderer::display_mode::parameters(
					sge::renderer::display_mode::vsync::on,
					sge::renderer::display_mode::optional_object()
				),
				sge::viewport::optional_resize_callback{
					sge::viewport::center_on_resize(
						sge::window::dim{
							1024u,
							768u
						}
					)
				}
			)
		)
		(
			sge::systems::input(
				sge::systems::cursor_option_field::null()
			)
		)
		(
			sge::systems::image2d(
				sge::media::optional_extension_set(
					sge::media::extension_set{
						sge::media::extension(
							FCPPT_TEXT("png")
						)
					}
				)
			)
		)
	);

	fcppt::signal::auto_connection const escape_connection(
		sge::systems::quit_on_escape(
			sys
		)
	);

	sge::console::object object(
		sge::console::prefix(
			SGE_FONT_LIT('/')
		)
	);

	fcppt::signal::auto_connection const c0(
		object.insert(
			sge::console::callback::convenience<
				void()
			>(
				[
					&sys
				]{
					sys.window_system().quit(
						awl::main::exit_success()
					);
				},
				sge::console::callback::name(
					SGE_FONT_LIT("quit")
				),
				sge::console::callback::short_description(
					SGE_FONT_LIT("Usage: /quit")
				)
			)
		)
	);

	fcppt::signal::auto_connection const c1(
		object.register_fallback(
			sge::console::fallback{
				[](
					sge::font::string const &_arg
				)
				{
					fcppt::io::cout()
						<< FCPPT_TEXT("fallback called with argument:")
						<< sge::font::to_fcppt_string(
							_arg
						)
						<< FCPPT_TEXT('\n');
				}
			}
		)
	);

	fcppt::signal::auto_connection const c2(
		object.insert(
			sge::console::callback::convenience<
				void(float)
			>(
				[
					&object
				](
					float const _value
				)
				{
					object.emit_message(
						SGE_FONT_LIT("New value is ")
						+
						fcppt::insert_to_string<
							sge::font::string
						>(
							_value
							+
							1.f
						)
					);
				},
				sge::console::callback::name(
					SGE_FONT_LIT("increment")
				),
				sge::console::callback::short_description(
					SGE_FONT_LIT("Usage: /increment <float-value>")
				)
			)
			.long_description(
				SGE_FONT_LIT("Increments the float value (extremely useful!)")
			)
		)
	);

	sge::texture::part_raw_ptr const tex_bg(
		sge::renderer::texture::create_planar_from_path(
			sge::config::media_path()
			/ FCPPT_TEXT("images")
			/ FCPPT_TEXT("grass.png"),
			sys.renderer_device_ffp(),
			sys.image_system(),
			sge::renderer::texture::mipmap::off(),
			sge::renderer::resource_flags_field::null(),
			sge::renderer::texture::emulate_srgb_from_caps(
				sys.renderer_device_ffp().caps()
			)
		)
	);

	sge::font::object_unique_ptr const font_object(
		sys.font_system().create_font(
			sge::font::parameters()
		)
	);

	sge::console::gfx::object gfx(
		object,
		sys.renderer_device_ffp(),
		sge::console::gfx::font_color(
			sge::image::color::predef::white()
		),
		*font_object,
		sys.focus_collector(),
		sge::font::rect{
			fcppt::math::vector::null<
				sge::font::rect::vector
			>(),
			sge::font::rect::dim{
				400,
				300
			}
		},
		sge::console::gfx::output_line_limit(
			100u
		)
	);

	sge::console::muxing_narrow_streambuf stdout_streambuf(
		std::cout,
		object,
		sge::console::muxing::enabled);

	std::cout << "Test for console muxer (cout).\n";
	std::cout << "You should see this message in the console and in the terminal (if available)\n";

	sge::console::muxing_narrow_streambuf stderr_streambuf(
		std::cerr,
		object,
		sge::console::muxing::disabled);

	std::cerr << "Test for console muxer (cerr).\n";
	std::cerr << "You should see this message _only_ in the console and _not_ in the terminal (if available)\n";

	gfx.active(
		true
	);

	while(
		sys.window_system().poll()
	)
	{
		sge::renderer::context::scoped_ffp const scoped_block(
			sys.renderer_device_ffp(),
			sys.renderer_device_ffp().onscreen_target()
		);

		scoped_block.get().clear(
			sge::renderer::clear::parameters()
			.back_buffer(
				sge::image::color::predef::black()
			)
		);

		gfx.render(
			scoped_block.get()
		);
	}

	return
		sys.window_system().exit_code();
}
catch(
	fcppt::exception const &_error
)
{
	fcppt::io::cerr()
		<< _error.string()
		<< FCPPT_TEXT('\n');

	return awl::main::exit_failure();
}
catch(
	std::exception const &_error
)
{
	std::cerr
		<< _error.what()
		<< '\n';

	return awl::main::exit_failure();
}
void uie_albumart::paint(HDC hdc)
{
    RECT wndrect_temp;
    if(GetClientRect(m_hWnd,&wndrect_temp))
    {
        Graphics gfx(hdc);
        Rect wndrect(
            wndrect_temp.left,
            wndrect_temp.top,
            wndrect_temp.right-wndrect_temp.left,
            wndrect_temp.bottom-wndrect_temp.top
            );

        Color bg;
        bg.SetFromCOLORREF((m_config.bg_enabled)
                           ?m_config.bgcol
                           :GetSysColor(COLOR_3DFACE));

        bool noimage = m_bufnew.is_empty();
        bool image_changed = !m_image_file_exists || m_bmpnew.is_valid();
        bool size_changed = m_bufnew.is_valid()
            ? (m_bufnew->GetWidth() != wndrect.Width || m_bufnew->GetHeight() != wndrect.Height)
            : true;
        if (noimage || image_changed || size_changed || m_config_changed || m_dragging)
        {
            if (!m_dragging)
            {
                m_pan_dx = m_pan_dy = 0;
            }
            else
            {
                m_bmpnew = m_bmp;
            }

            if (size_changed || noimage)
            {
                // create bitmaps with new size
                m_animating = false;
                m_bufold.release();
                m_bufanim.release();

                m_bufold = new Bitmap(wndrect.Width,wndrect.Height,&gfx);
                m_bufnew = new Bitmap(wndrect.Width,wndrect.Height,&gfx);

                // make sure currently displayed image is redrawn
                // during the resize
                m_bmpnew = m_bmp;
            }
            if (m_config.animtime == 0)
                m_bufanim.release();
            else if (m_bufanim.is_empty())
                m_bufanim=new Bitmap(wndrect.Width,wndrect.Height,&gfx);

            m_config_changed = false;

            Bitmap *temp = m_bufold.detach();
            m_bufold.set(m_bufnew.detach());
            m_bufnew.set(temp);

            Graphics bufgfx(m_bufnew.get_ptr());
            bufgfx.Clear(bg);

            if (m_bmpnew.is_valid())
            {
                // adjust for padding
                if(m_config.padding > 0)
                {
                    wndrect.Height-=2*m_config.padding;
                    wndrect.Width-=2*m_config.padding;
                    wndrect.X+=m_config.padding;
                    wndrect.Y+=m_config.padding;
                }

                Size bmp_dim(m_bmpnew->GetWidth(), m_bmpnew->GetHeight());

                // rectangle that will be drawn on the screen
                RectF rect(wndrect.X, wndrect.Y, bmp_dim.Width, bmp_dim.Height);

                // shrink album art
                if (m_config.shrinkalbum)
                {
                    if (bmp_dim.Width > wndrect.Width)
                        rect.Width = wndrect.Width;

                    if (bmp_dim.Height > wndrect.Height)
                        rect.Height = wndrect.Height;
                }

                // expand album art
                if (m_config.expandalbum)
                {
                    if (bmp_dim.Width < wndrect.Width)
                        rect.Width = wndrect.Width;

                    if (bmp_dim.Height < wndrect.Height)
                        rect.Height = wndrect.Height;
                }

                // correct aspect ratio
                if (m_config.aspectratio)
                {
                    REAL new_width = bmp_dim.Width*(rect.Height/bmp_dim.Height);
                    REAL new_height = bmp_dim.Height*(rect.Width/bmp_dim.Width);

                    if (m_config.expandalbum && !m_config.shrinkalbum)
                    {
                        // try to fill the entire window, even if parts of the
                        // image are cut off (enlarge image)
                        if (new_height >= wndrect.Height)
                        {
                            rect.Height = new_height;
                        }
                        else
                        {
                            if (new_width >= wndrect.Width)
                            {
                                rect.Width = new_width;
                            }
                        }
                    }
                    else
                    {
                        // do not cut off any part of the image while
                        // maintaining aspect ratio (shrink image)
                        if (new_height <= wndrect.Height)
                        {
                            rect.Height = new_height;
                        }
                        else
                        {
                            if (new_width <= wndrect.Width)
                            {
                                rect.Width = new_width;
                            }
                        }
                    }
                }

                // Center album
                // uses integers for the offsets because if the offset
                // is a fraction of a pixel, there's lowered quality
                if (m_config.centeralbum)
                {
                    int center_dx = (wndrect.GetRight() - rect.GetRight()) / 2;
                    int center_dy = (wndrect.GetBottom() - rect.GetBottom()) / 2;
                    rect.Offset((REAL)center_dx,
                                (REAL)center_dy);
                }

                if (m_config.draw_pixel_border)
                {
                    Gdiplus::Color border;
                    border.SetFromCOLORREF(m_config.bordercol);

                    rect.Width--;
                    rect.Height--;
                    bufgfx.DrawRectangle(& Pen(border),rect);
                    rect.X++;
                    rect.Y++;
                    rect.Width--;
                    rect.Height--;
                }

                m_panning_enabled = ((rect.Width > wndrect.Width) ||
                                     (rect.Height > wndrect.Height));

                // panning
                REAL dx = m_pan_dx;
                REAL dy = m_pan_dy;
                if (m_dragging)
                {
                    // Make sure the image doesn't pan out of bounds
                    if (m_panning_enabled)
                    {
                        if (rect.Width > wndrect.Width)
                        {
                            if ((rect.GetLeft()+dx) > wndrect.GetLeft())
                                dx = wndrect.GetLeft() - rect.GetLeft();
                            if ((rect.GetRight()+dx) < wndrect.GetRight())
                                dx = wndrect.GetRight() - rect.GetRight();
                        }

                        if (rect.Height > wndrect.Height)
                        {
                            if ((rect.GetTop()+dy) > wndrect.GetTop())
                                dy = wndrect.GetTop() - rect.GetTop();
                            if ((rect.GetBottom()+dy) < wndrect.GetBottom())
                                dy = wndrect.GetBottom() - rect.GetBottom();
                        }
                    }
                    else
                    {
                        dx = 0;
                        dy = 0;
                    }

                    if (rect.Width <= wndrect.Width) dx = 0;
                    if (rect.Height <= wndrect.Height) dy = 0;

                    m_pan_dx = dx;
                    m_pan_dy = dy;
                }
                rect.Offset(dx,dy);

                bufgfx.SetInterpolationMode(m_config.interpolationmode == RESIZE_HIGH
                    ? InterpolationModeHighQuality
                    : m_config.interpolationmode == RESIZE_MEDIUM
                        ? InterpolationModeDefault
                        : m_config.interpolationmode == RESIZE_LOW
                            ? InterpolationModeLowQuality
                            // m_config.interpolationmode == RESIZE_HIGHEST
                            : InterpolationModeHighQualityBicubic);

                if (m_dragging) bufgfx.SetInterpolationMode(InterpolationModeLowQuality);

                REAL srcWidth = m_bmpnew->GetWidth();
                REAL srcHeight = m_bmpnew->GetHeight();
                REAL srcX = 0;
                REAL srcY = 0;

                /*if (m_config.padding < 0)
                {
                    if(abs(m_config.padding) < m_bmpnew->GetWidth() &&
                       abs(m_config.padding) < m_bmpnew->GetHeight())
                    {
                        srcWidth+=2*m_config.padding;
                        srcHeight+=2*m_config.padding;
                        srcX-=m_config.padding;
                        srcY-=m_config.padding;
                    }
                }*/

                bufgfx.SetClip(wndrect);    // ensures that padding is respected
                bufgfx.DrawImage(
                    &(*m_bmpnew),
                    rect,         // destination rectangle
                    srcX, srcY,   // upper-left corner of source rectangle
                    srcWidth,     // width of source rectangle
                    srcHeight,    // height of source rectangle
                    UnitPixel);
            }

            // m_bufnew updated. time to fade in the changes.
            DWORD now = GetTickCount();
            if (m_config.animtime != 0 && !size_changed && (m_animshouldstart+700) > now)
            {
                m_animating = true;
                m_animstarted=GetTickCount();
                set_anim_timer();
            }
        }



        Rect dest(wndrect_temp.left,
            wndrect_temp.top,
            wndrect_temp.right-wndrect_temp.left,
            wndrect_temp.bottom-wndrect_temp.top);
        if (m_bufnew.is_valid() && !m_animating)
        {
            gfx.DrawImage(m_bufnew.get_ptr(), 0, 0);
        }
        else if (m_animating && m_bufnew.is_valid() && m_bufanim.is_valid())
        {
            float opacityold=0.0f;
            float opacitynew=1.0f;
            int doneness=GetTickCount();
            if (doneness > (m_animstarted+m_config.animtime))
            // animation complete
            {
                m_animating=false;
                opacityold=0.0f;
                opacitynew=1.0f;
            }
            else if (doneness >= m_animstarted && m_config.animtime != 0)
            {
                opacitynew=(float)(doneness-m_animstarted)/(float)m_config.animtime;
                opacityold=1.0f-0.0f;
            }
            {
                Graphics animbuf(m_bufanim.get_ptr());
                animbuf.Clear(bg);
                ColorMatrix cm;
                ZeroMemory(&cm,sizeof(ColorMatrix));
                cm.m[0][0] = 1.0f;
                cm.m[1][1] = 1.0f;
                cm.m[2][2] = 1.0f;
                cm.m[3][3] = opacityold;

                ImageAttributes ia;
                ia.SetColorMatrix(&cm);
                animbuf.DrawImage(m_bufold.get_ptr(),dest,0,0,dest.Width,dest.Height,UnitPixel,&ia);
                cm.m[3][3] = opacitynew;
                ia.SetColorMatrix(&cm);
                animbuf.DrawImage(m_bufnew.get_ptr(),dest,0,0,dest.Width,dest.Height,UnitPixel,&ia);
            }
            gfx.DrawImage(m_bufanim.get_ptr(), 0, 0);
            if (m_animating)
                set_anim_timer();
            else
                m_bufanim.release();
        }
        else gfx.Clear(bg);

        m_bmpnew.release();
    }
}
Example #22
0
    // Paints the tabs that intersect the window's update rectangle.
    void Paint(HDC hdc, RECT& rc) {
        IntersectClipRect(hdc, rc.left, rc.top, rc.right, rc.bottom);

// paint the background
#if 0
        bool isTranslucentMode = inTitlebar && dwm::IsCompositionEnabled();
        if (isTranslucentMode) {
            PaintParentBackground(hwnd, hdc);
        } else {
            // note: not sure what color should be used here and painting
            // background works fine
            /*HBRUSH brush = CreateSolidBrush(colors.bar);
            FillRect(hdc, &rc, brush);
            DeleteObject(brush);*/
        }
#else
        PaintParentBackground(hwnd, hdc);
#endif
        // TODO: GDI+ doesn't seem to cope well with SetWorldTransform
        XFORM ctm = {1.0, 0, 0, 1.0, 0, 0};
        SetWorldTransform(hdc, &ctm);

        Graphics gfx(hdc);
        gfx.SetCompositingMode(CompositingModeSourceCopy);
        gfx.SetCompositingQuality(CompositingQualityHighQuality);
        gfx.SetSmoothingMode(SmoothingModeHighQuality);
        gfx.SetTextRenderingHint(TextRenderingHintClearTypeGridFit);
        gfx.SetPageUnit(UnitPixel);
        GraphicsPath shapes(data->Points, data->Types, data->Count);
        GraphicsPath shape;
        GraphicsPathIterator iterator(&shapes);

        SolidBrush br(Color(0, 0, 0));
        Pen pen(&br, 2.0f);

        Font f(hdc, GetDefaultGuiFont());
        // TODO: adjust these constant values for DPI?
        RectF layout((REAL)DpiScaleX(hwnd, 3), 1.0f, REAL(width - DpiScaleX(hwnd, 20)), (REAL)height);
        StringFormat sf(StringFormat::GenericDefault());
        sf.SetFormatFlags(StringFormatFlagsNoWrap);
        sf.SetLineAlignment(StringAlignmentCenter);
        sf.SetTrimming(StringTrimmingEllipsisCharacter);

        REAL yPosTab = inTitlebar ? 0.0f : REAL(ClientRect(hwnd).dy - height - 1);
        for (int i = 0; i < Count(); i++) {
            gfx.ResetTransform();
            gfx.TranslateTransform(1.f + (REAL)(width + 1) * i - (REAL)rc.left, yPosTab - (REAL)rc.top);

            if (!gfx.IsVisible(0, 0, width + 1, height + 1))
                continue;

            // Get the correct colors based on the state and the current theme
            COLORREF bgCol = GetAppColor(AppColor::TabBackgroundBg);
            COLORREF textCol = GetAppColor(AppColor::TabBackgroundText);
            COLORREF xColor = GetAppColor(AppColor::TabBackgroundCloseX);
            COLORREF circleColor = GetAppColor(AppColor::TabBackgroundCloseCircle);

            if (selectedTabIdx == i) {
                bgCol = GetAppColor(AppColor::TabSelectedBg);
                textCol = GetAppColor(AppColor::TabSelectedText);
                xColor = GetAppColor(AppColor::TabSelectedCloseX);
                circleColor = GetAppColor(AppColor::TabSelectedCloseCircle);
            } else if (highlighted == i) {
                bgCol = GetAppColor(AppColor::TabHighlightedBg);
                textCol = GetAppColor(AppColor::TabHighlightedText);
                xColor = GetAppColor(AppColor::TabHighlightedCloseX);
                circleColor = GetAppColor(AppColor::TabHighlightedCloseCircle);
            }
            if (xHighlighted == i) {
                xColor = GetAppColor(AppColor::TabHoveredCloseX);
                circleColor = GetAppColor(AppColor::TabHoveredCloseCircle);
            }
            if (xClicked == i) {
                xColor = GetAppColor(AppColor::TabClickedCloseX);
                circleColor = GetAppColor(AppColor::TabClickedCloseCircle);
            }

            // paint tab's body
            gfx.SetCompositingMode(CompositingModeSourceCopy);
            iterator.NextMarker(&shape);
            br.SetColor(ToColor(bgCol));
            Point points[4];
            shape.GetPathPoints(points, 4);
            Rect body(points[0].X, points[0].Y, points[2].X - points[0].X, points[2].Y - points[0].Y);
            body.Inflate(0, 0);
            gfx.SetClip(body);
            body.Inflate(5, 5);
            gfx.FillRectangle(&br, body);
            gfx.ResetClip();

            // draw tab's text
            gfx.SetCompositingMode(CompositingModeSourceOver);
            br.SetColor(ToColor(textCol));
            gfx.DrawString(text.at(i), -1, &f, layout, &sf, &br);

            // paint "x"'s circle
            iterator.NextMarker(&shape);
            bool closeCircleEnabled = true;
            if ((xClicked == i || xHighlighted == i) && closeCircleEnabled) {
                br.SetColor(ToColor(circleColor));
                gfx.FillPath(&br, &shape);
            }

            // paint "x"
            iterator.NextMarker(&shape);
            pen.SetColor(ToColor(xColor));
            gfx.DrawPath(&pen, &shape);
            iterator.Rewind();
        }
    }
Example #23
0
void Building::draw() const {
    GfxState gfx(0x333333, 0);
    gfx.drawRect(position, size);
}
Example #24
0
void tc0100scn_device::device_start()
{
	// bind callbacks
	m_tc0100scn_cb.bind_relative_to(*owner());

	static const gfx_layout charlayout =
	{
	8,8,    /* 8*8 characters */
	256,    /* 256 characters */
	2,  /* 2 bits per pixel */
	{ 0, 8 },
	{ 0, 1, 2, 3, 4, 5, 6, 7 },
	{ 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16 },
	16*8    /* every sprite takes 16 consecutive bytes */
	};

	if(!m_gfxdecode->started())
		throw device_missing_dependencies();

	int xd, yd;

	/* Set up clipping for multi-TC0100SCN games. We assume
	   this code won't ever affect single screen games:
	   Thundfox is the only one of those with two chips, and
	   we're safe as it uses single width tilemaps. */

	/* Single width versions */
	m_tilemap[0][0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x00000, 0>, "bg0_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
	m_tilemap[1][0] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x04000, 1>, "bg1_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);
	m_tilemap[2][0] = &machine().tilemap().create(*this,        tilemap_get_info_delegate(&tc0100scn_device::get_tx_tile_info<0x02000, 0>, "txt_std", this), TILEMAP_SCAN_ROWS, 8, 8, 64, 64);

	/* Double width versions */
	m_tilemap[0][1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x00000, 0>, "bg0_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64);
	m_tilemap[1][1] = &machine().tilemap().create(*m_gfxdecode, tilemap_get_info_delegate(&tc0100scn_device::get_bg_tile_info<0x04000, 1>, "bg1_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 64);
	m_tilemap[2][1] = &machine().tilemap().create(*this,        tilemap_get_info_delegate(&tc0100scn_device::get_tx_tile_info<0x09000, 1>, "txt_wide", this), TILEMAP_SCAN_ROWS, 8, 8, 128, 32);

	m_tilemap[0][0]->set_transparent_pen(0);
	m_tilemap[1][0]->set_transparent_pen(0);
	m_tilemap[2][0]->set_transparent_pen(0);

	m_tilemap[0][1]->set_transparent_pen(0);
	m_tilemap[1][1]->set_transparent_pen(0);
	m_tilemap[2][1]->set_transparent_pen(0);

	/* Standard width tilemaps. I'm setting the optional chip #2
	   7 bits higher and 2 pixels to the left than chip #1 because
	   that's how thundfox wants it. */

	xd = (m_multiscrn_hack == 0) ?  (-m_x_offset) : (-m_x_offset - 2);
	yd = (m_multiscrn_hack == 0) ?  (8 - m_y_offset) : (1 - m_y_offset);

	m_tilemap[0][0]->set_scrolldx(xd - 16, -m_flip_xoffs - xd - 16);
	m_tilemap[0][0]->set_scrolldy(yd,      -m_flip_yoffs - yd);
	m_tilemap[1][0]->set_scrolldx(xd - 16, -m_flip_xoffs - xd - 16);
	m_tilemap[1][0]->set_scrolldy(yd,      -m_flip_yoffs - yd);
	m_tilemap[2][0]->set_scrolldx(xd - 16, -m_flip_text_xoffs - xd - 16 - 7);
	m_tilemap[2][0]->set_scrolldy(yd,      -m_flip_text_yoffs - yd);

	/* Double width tilemaps. We must correct offsets for
	   extra chips, as MAME sees offsets from LHS of whole
	   display not from the edges of individual screens.
	   NB flipscreen tilemap offsets are based on Cameltry */

	xd = -m_x_offset - m_multiscrn_xoffs;
	yd = 8 - m_y_offset;

	m_tilemap[0][1]->set_scrolldx(xd - 16, -m_flip_xoffs - xd - 16);
	m_tilemap[0][1]->set_scrolldy(yd,      -m_flip_yoffs - yd);
	m_tilemap[1][1]->set_scrolldx(xd - 16, -m_flip_xoffs - xd - 16);
	m_tilemap[1][1]->set_scrolldy(yd,      -m_flip_yoffs - yd);
	m_tilemap[2][1]->set_scrolldx(xd - 16, -m_flip_text_xoffs - xd - 16 - 7);
	m_tilemap[2][1]->set_scrolldy(yd,      -m_flip_text_yoffs - yd);

	m_tilemap[0][0]->set_scroll_rows(512);
	m_tilemap[1][0]->set_scroll_rows(512);
	m_tilemap[0][1]->set_scroll_rows(512);
	m_tilemap[1][1]->set_scroll_rows(512);

	m_ram = make_unique_clear<u16[]>(TC0100SCN_RAM_SIZE / 2);

	set_layer_ptrs();

	/* create the char set (gfx will then be updated dynamically from RAM) */
	set_gfx(0, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x6000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 256, 0));
	set_gfx(1, std::make_unique<gfx_element>(&palette(), charlayout, (u8 *)&m_ram[0x11000 / 2], NATIVE_ENDIAN_VALUE_LE_BE(8,0), 256, 0));

	gfx_element *bg_gfx = m_gfxdecode->gfx(m_gfxnum);
	gfx_element *txt0 = gfx(0);
	gfx_element *txt1 = gfx(1);

	if (bg_gfx->granularity() == 2)    /* Yuyugogo, Yesnoj */
		bg_gfx->set_granularity(16);

	txt0->set_granularity(bg_gfx->granularity());
	txt1->set_granularity(bg_gfx->granularity());

	set_colbanks(0, 0, 0);  /* standard values, only Wgp & multiscreen games change them */
									/* we call this here, so that they can be modified at video_start*/

	save_pointer(NAME(m_ram), TC0100SCN_RAM_SIZE / 2);
	save_item(NAME(m_ctrl));
	save_item(NAME(m_dblwidth));
}