| 217 | } |
| 218 | |
| 219 | void DrawNameTable(int scanline, int ntnum, bool invalidateCache) { |
| 220 | |
| 221 | NTCache &c = cache[ntnum]; |
| 222 | uint8 *bitmap = c.bitmap, *tablecache = c.cache; |
| 223 | |
| 224 | uint8 *table = vnapage[ntnum]; |
| 225 | if(table == NULL) |
| 226 | table = vnapage[ntnum&1]; |
| 227 | |
| 228 | int a, ptable=0; |
| 229 | uint8 *pbitmap = bitmap; |
| 230 | |
| 231 | if(PPU[0]&0x10){ //use the correct pattern table based on this bit |
| 232 | ptable=0x1000; |
| 233 | } |
| 234 | |
| 235 | bool invalid = invalidateCache; |
| 236 | //if we werent asked to invalidate the cache, maybe we need to invalidate it anyway due to vnapage changing |
| 237 | if(!invalid) |
| 238 | invalid = (c.curr_vnapage != vnapage[ntnum]); |
| 239 | c.curr_vnapage = vnapage[ntnum]; |
| 240 | |
| 241 | //HACK: never cache anything |
| 242 | invalid = true; |
| 243 | |
| 244 | pbitmap = bitmap; |
| 245 | for(int y=0;y<30;y++){ |
| 246 | for(int x=0;x<32;x++){ |
| 247 | int ntaddr = (y*32)+x; |
| 248 | int attraddr = 0x3C0+((y>>2)<<3)+(x>>2); |
| 249 | if(invalid |
| 250 | || (table[ntaddr] != tablecache[ntaddr]) |
| 251 | || (table[attraddr] != tablecache[attraddr])) { |
| 252 | redrawtables = true; |
| 253 | int temp = (((y&2)<<1)+(x&2)); |
| 254 | a = (table[attraddr] & (3<<temp)) >> temp; |
| 255 | |
| 256 | //the commented out code below is all allegedly equivalent to the single line above: |
| 257 | //tmpx = x>>2; |
| 258 | //tmpy = y>>2; |
| 259 | //a = 0x3C0+(tmpy*8)+tmpx; |
| 260 | //if((((x>>1)&1) == 0) && (((y>>1)&1) == 0)) a = table[a]&0x3; |
| 261 | //if((((x>>1)&1) == 1) && (((y>>1)&1) == 0)) a = (table[a]&0xC)>>2; |
| 262 | //if((((x>>1)&1) == 0) && (((y>>1)&1) == 1)) a = (table[a]&0x30)>>4; |
| 263 | //if((((x>>1)&1) == 1) && (((y>>1)&1) == 1)) a = (table[a]&0xC0)>>6; |
| 264 | |
| 265 | int chr = table[ntaddr]*16; |
| 266 | |
| 267 | extern int FCEUPPU_GetAttr(int ntnum, int xt, int yt); |
| 268 | |
| 269 | //test.. instead of pretending that the nametable is a screen at 0,0 we pretend that it is at the current xscroll and yscroll |
| 270 | //int xpos = ((RefreshAddr & 0x400) >> 2) | ((RefreshAddr & 0x1F) << 3) | XOffset; |
| 271 | //int ypos = ((RefreshAddr & 0x3E0) >> 2) | ((RefreshAddr & 0x7000) >> 12); |
| 272 | //if(RefreshAddr & 0x800) ypos += 240; |
| 273 | //int refreshaddr = (xpos/8+x)+(ypos/8+y)*32; |
| 274 | |
| 275 | int refreshaddr = (x)+(y)*32; |
| 276 |
no test coverage detected