git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4344 c06c8d41-db1a-0410-9941-cceddc491573
MQOL2SN2EYBCAVVJ7NPCXEV6C4NPBNMC6QD2AOTZPIAZB243JQ7QC
LDBTCT5WIPLJPZWXS2RUQ26QKISCUUTLO77M464WOE6VSYSNPKYAC
25CH7HH4LKXFIZ75YNMXS3TSXO6O27DYSOPLOD45K4OCNFWLS4LQC
LP5EK64IEM7AHNYQID4GGKOQJQNZLKY4DCCZN47SIUZ6IXAXH5UAC
O6ZMFKDI3XO2SWPNEYHIPYFDWJR4TVDP5BAATK6LVCVETQID6E7AC
ZWVXM43CBKDWRFNZ432Z6G6J7DBA2GKRRGCSZQCRQS2M4YX53ETQC
JXAB5WYRDGBLKOBEQJLZKIE7YHQ2ZI6LKWEFSNF2TGAHPNUI3SBQC
5B5DP5S6A6LQMKZYVLQAEMHQZWFWYDHPCKQGRNSCNNYIBQYZ6BIQC
U6ILMKBXTQZYT62IGD2CALYNU4VQGRSTHN6QBFBU7BVUBHWYOEQQC
5FA5IEAXTMXYS2VUBVDKBKHPKAIOY4GN5SXYJORBYWQIGHVW3FFQC
4SUUJM2DQUEWHDG3UKJUDZABLHFVF2CFUX5GVAWKT7BBBGR2ISTQC
ZNUMGZOGREVG6RNSM4RGHG2Y6NYL7O2U642V6F3HJAXMTC5JXJHAC
HBHQQDULNVWISJ75XIL6R6BFEDYRNY22NX3ZTFVNP5ZWJGJSKOEQC
RNRDGY5JBFBHF7IDQ6LDV2GULR4ILNJ7UHYNGIWZIPLN6IJYX2PQC
QON6K747RDVN55UTIJWNGIIGSDS7IHKB24JMHWSIMAQ572D7C3NAC
3ICSXUKO2RWAARVKXTV3MGIB6G7UQHIHN5I4JNBLXIFEQA4H462QC
D5EMJEEIJSSULF236DUM26QHHNDLH7FXAOBHFDAYI65KCKTDTDYQC
const int tcache_wx_normal[TCACHE_KIND_NORMAL] = {TILE_X};
const int tcache_wy_normal[TCACHE_KIND_NORMAL] = {TILE_Y};
const int tcache_ox_normal[TCACHE_KIND_NORMAL] = {0};
const int tcache_oy_normal[TCACHE_KIND_NORMAL] = {0};
const int tcache_nlayer_normal[TCACHE_KIND_NORMAL] = {1};
const int tcache_wx_normal = TILE_X;
const int tcache_wy_normal = TILE_Y;
const int tcache_ox_normal = 0;
const int tcache_oy_normal = 0;
const int tcache_nlayer_normal = 1;
#define TREGION_0_NORMAL 0
const int region_sx_normal[1] = {0};
const int region_sy_normal[1] = {0};
const int region_wx_normal[1] = {TILE_X};
const int region_wy_normal[1] = {TILE_Y};
const int region_sx_normal = 0;
const int region_sy_normal = 0;
const int region_wx_normal = TILE_X;
const int region_wy_normal = TILE_Y;
screen_tcach_idx = (int **)malloc(sizeof(int *) * tcache_kind);
tcache = (tile_cache **)malloc(sizeof(tile_cache *)*tcache_kind);
tcache_head = (int *)malloc(sizeof(int)*tcache_kind*tc_hash);
for (k = 0; k < tcache_kind; k++)
{
screen_tcach_idx[k] = (int *)malloc(sizeof(int)* tile_xmax * tile_ymax);
tcache[k] = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache);
for (x = 0; x < tile_xmax * tile_ymax; x++)
screen_tcach_idx[k][x] = -1;
}
screen_tcache_idx = (int *)malloc(sizeof(int)* tile_xmax * tile_ymax);
tcache = (tile_cache *)malloc(sizeof(tile_cache)*max_tcache);
for (int x = 0; x < tile_xmax * tile_ymax; x++)
screen_tcache_idx[x] = -1;
for (k = 0; k < tcache_kind; k++)
{
free(screen_tcach_idx[k]);
screen_tcach_idx[k] = (int *)malloc(sizeof(int)* tile_xmax * tile_ymax);
free(screen_tcache_idx);
screen_tcache_idx = (int *)malloc(sizeof(int)* tile_xmax * tile_ymax);
for (int k = 0; k < tcache_kind; k++)
{
tile_cache *tc = tcache[k];
// Decompose pointer string tcache[k] into tc_hash segments
for (int h = 0; h < tc_hash; h++)
{
int i_start = (max_tcache*h)/tc_hash;
int i_end = (max_tcache*(h+1))/tc_hash - 1;
tcache_head[k*tc_hash + h] = i_start;
tcache_head = 0;
for (int i = i_start; i <= i_end; i++)
{
tc[i].id[1] = tc[i].id[0] = 0;
tc[i].idx = i;
if (i == i_start)
tc[i].prev = NULL;
else
tc[i].prev = &tc[i-1];
for (int i = 0; i < max_tcache; i++)
{
tcache[i].id[1] = tcache[i].id[0] = 0;
tcache[i].idx = i;
if (i == 0)
tcache[i].prev = NULL;
else
tcache[i].prev = &tcache[i-1];
if (i == i_end)
tc[i].next = NULL;
else
tc[i].next = &tc[i+1];
}
}
if (i == max_tcache - 1)
tcache[i].next = NULL;
else
tcache[i].next = &tcache[i+1];
tcache_image = (img_type *)malloc(sizeof(img_type)*tcache_kind);
for (k = 0; k < tcache_kind; k++)
{
int wx = tcache_wx_normal[k];
int wy = tcache_wy_normal[k];
tcache_image[k] = ImgCreateSimple(wx, max_tcache*wy);
}
tcache_image = ImgCreateSimple(tcache_wx_normal,
max_tcache*tcache_wy_normal);
int kind_n_hash = kind * tc_hash + hash;
int head_old=tcache_head[kind_n_hash];
tile_cache *tc = tcache[kind];
tile_cache *p = tc[ix].prev;
tile_cache *n = tc[ix].next;
int head_old = tcache_head;
tile_cache *p = tcache[ix].prev;
tile_cache *n = tcache[ix].next;
int hash = 0; // Don't use hash
int kind_n_hash = kind * tc_hash + hash;
tile_cache *tc = tcache[kind];
tile_cache *tc0 = &tc[tcache_head[kind_n_hash]];
tile_cache *tc0 = &tcache[tcache_head];
int sx = region_sx_normal[region] + shift_left;
int sy = region_sy_normal[region];
int wx = region_wx_normal[region] - shift_left;
int wy = region_wy_normal[region];
int sx = region_sx_normal + shift_left;
int sy = region_sy_normal;
int wx = region_wx_normal - shift_left;
int wy = region_wy_normal;
int x_dest = tcache_ox_normal[kind]+xx* TILE_UX_NORMAL;
int y_dest = tcache_oy_normal[kind]+yy* TILE_UY_NORMAL;
int wx = tcache_wx_normal[kind];
int wy = tcache_wy_normal[kind];
ImgCopy(tcache_image[kind],
0, ix*wy, wx, wy, ScrBufImg, x_dest, y_dest, 1);
int x_dest = tcache_ox_normal+xx* TILE_UX_NORMAL;
int y_dest = tcache_oy_normal+yy* TILE_UY_NORMAL;
int wx = tcache_wx_normal;
int wy = tcache_wy_normal;
ImgCopy(tcache_image, 0, ix*wy, wx, wy, ScrBufImg, x_dest, y_dest, 1);
int fg = tcache[kind][idx].id[0];
int bg = tcache[kind][idx].id[1];
if ((fg & TILE_FLAG_MASK) == tile
|| (bg & TILE_FLAG_MASK) == tile)
{
_tcache_compose_normal(idx, &fg, &bg);
}
_tcache_compose_normal(idx, &fg, &bg);
_register_tile_mask(sink, TREGION_0_NORMAL, &flag, sink_mask);
_tcache_overlay(tc_img, ix, fg0, TREGION_0_NORMAL, &c, sink_mask);
_register_tile_mask(sink, &flag, sink_mask);
_tcache_overlay(tcache_image, ix, fg0, &c, sink_mask);
for (kind = 0; kind < tcache_kind; kind++)
{
for (x = 0; x < tile_xmax; x++)
{
for (y = 0; y < tile_ymax; y++)
_tile_draw_grid(kind, x, y);
}
}
for (int x = 0; x < crawl_view.viewsz.x; x++)
for (int y = 0; y < crawl_view.viewsz.y; y++)
_tile_draw_grid(x, y);