void TileCallback::post_render_tile( const asr::Frame* frame, const size_t tile_x, const size_t tile_y) { const asf::Image& image = frame->image(); const asf::CanvasProperties& props = image.properties(); DbgAssert(props.m_canvas_width == m_bitmap->Width()); DbgAssert(props.m_canvas_height == m_bitmap->Height()); DbgAssert(props.m_channel_count == 4); // Blit the tile to the destination bitmap. blit_tile(*frame, tile_x, tile_y); // Partially refresh the display window. const asf::Tile& tile = image.tile(tile_x, tile_y); const size_t x = tile_x * props.m_tile_width; const size_t y = tile_y * props.m_tile_height; RECT rect = make_rect(x, y, tile.get_width(), tile.get_height()); m_bitmap->RefreshWindow(&rect); // Keep track of the number of rendered tiles. asf::atomic_inc(m_rendered_tile_count); }
int map_draw(struct lua_State *L) { struct Map *M = luaL_checkudata(L, 1, META); luaL_argcheck(L, M, 1, "Expected a map"); luaL_argcheck(L, lua_isnumber(L, 2), 3, "Expected an x world origin"); luaL_argcheck(L, lua_isnumber(L, 3), 3, "Expected a y world origin"); Sint16 wx = lua_tonumber(L, 2) - SM_x(width/2, height/2); Sint16 wy = lua_tonumber(L, 3) - SM_y(width/2, height/2); Sint16 sx=0, sy=0; Uint8 *w = NULL; LX=wx+SCALE; LY=wy; /* SAVE THESE. (+W to avoid jaggies on the left.)*/ sx = -MS_x(SUB(wx), SUB(wy), 0)-W; /* sub-tile scroll */ sy = -MS_y(SUB(wx), SUB(wy), 0); /* adjustment */ wx /= SCALE; wy /= SCALE; Uint32 q = ~0; lua_pop(L, 3); if(lua_gettop(L)) debug_lua_stack(L, "bmap>"); lua_getfield(L, LUA_GLOBALSINDEX, "sprites"); Sint8 x=0, y=0, z=0; Sint16 xl, yl, zf; xl = SM_x(width, 0) / SCALE + 2; /* +2,+3 to avoid jaggies */ yl = SM_y( 0, 2*height) / SCALE + M->zs + 3; for ( z = 0 ; z < M->zs; z++) { /* bottom to top */ for ( y = 0 ; y < yl ; y++) { /* far to near */ for ( x = 0 ; x < xl ; x++) { /* left to right */ Uint16 mx, my, qx, qy; mx = wx+x+(y/2)+(y&1); my = wy-x+(y/2); w = raw_ref(M, mx, my, z); qx = sx+64*x+(32*(y&1)); qy = sy+16*y-16*z; if(w != NULL && *w > 5) blit_tile(qx, qy, *w); do_sprites(GLOM(mx, my, z), qx+32, qy+16); /* offset 'cos of jaggie-adj */ } } } /* for for for */ lua_pop(L, 1); if(lua_gettop(L)) debug_lua_stack(L, "bmap<"); return 0; }
void TileCallback::post_render( const asr::Frame* frame) { const asf::CanvasProperties& props = frame->image().properties(); DbgAssert(props.m_canvas_width == m_bitmap->Width()); DbgAssert(props.m_canvas_height == m_bitmap->Height()); DbgAssert(props.m_channel_count == 4); // Blit all tiles. for (size_t y = 0; y < props.m_tile_count_y; ++y) { for (size_t x = 0; x < props.m_tile_count_x; ++x) blit_tile(*frame, x, y); } // Refresh the entire display window. m_bitmap->RefreshWindow(); }