Example #1
0
bool Tile_map::save()
{
    std::ofstream file(map_info.filename , std::ios_base::out | std::ios_base::binary );
    uint8_t * buffer = new uint8_t (8);
    buffer[0] = 0xA9;
    buffer[1] = 0xB2;
    buffer[2] = 0x18;
    buffer[3] = 0x04;
    buffer[4] = 0xE1;
    buffer[5] = 0x64;
    buffer[6] = 0xF5;
    buffer[7] = 0x9D;
    // initialize the map by checksum
    for(int a=0 ; a < 8 ; a++)
    {
        file<<buffer[a];
    }
    delete [] buffer;
    // save major and minor map version
    file<<map_info.major_version;
    file<<map_info.minor_version;
    // save map name
    file<<map_info.map_name<<'\n';
    file<<map_info.width<<' ';
    file<<map_info.height<<' ';
    if(player)
    {
        file<<Chunk_type::player<<' ';
        save_player(file);
    }
    for(auto & a : sets_of_tiles)
    {
        file<<Chunk_type::tile_set<<' ';
        save_tile_set(file,a);
    }
    for(auto & a : types_of_tile)
    {
        file<<Chunk_type::tile_type<<' ';
        save_tile_type(file,a);
    }
    for(auto & a : tiles)
    {
        file<<Chunk_type::tile<<' ';
        save_tile(file,a);
    }
    if(background)
    {
        file<<Chunk_type::background<<' ';
        save_background(file);
    }

    return true;
}
Example #2
0
File: scrdrv.c Project: m-labs/mtk
static void update_area(int x1, int y1, int x2, int y2)
{
	int dx;
	int dy;
	int v;
	int i, j;
	u16 *src, *dst;
	u32 *s, *d;
	int cursor_visible = 0;

	if ((curr_mx < x2) && (curr_mx + 16 > x1)
	 && (curr_my < y2) && (curr_my + 16 > y1)) {
		save_background(curr_mx, curr_my);
		draw_cursor(&bigmouse_trp, curr_mx, curr_my);
		cursor_visible = 1;
	}

	x1 &= ~3;
	x2 = (x2 | 3) + 1;

	/* apply clipping to specified area */
	if (x1 < (v = clip->get_x1())) x1 = v;
	if (y1 < (v = clip->get_y1())) y1 = v;
	if (x2 > (v = clip->get_x2())) x2 = v;
	if (y2 > (v = clip->get_y2())) y2 = v;

	dx = x2 - x1;
	dy = y2 - y1;

	if (dx >= 0 && dy >= 0) {

		/* determine offset of left top corner of the area to update */
		src = (u16 *)buf + y1*scr_width + x1;
		dst = (u16 *)scr + y1*scr_width + x1;

		for (j = dy + 1; j--; ) {

			/* copy line */
			d = (u32 *)dst; s = (u32 *)src;
			for (i = (dx>>1) + 2; i--; ) *(d++) = *(s++);

			src += scr_width;
			dst += scr_width;
		}