mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Remove vmult lookup tables
There's really no need to put the y-multiplication in a lookup table. The compiler will optimize the multiplication better than putting it in a lookup table will. To improve readability and to hardcode things less, the new SCREEN_WIDTH_TILES and SCREEN_HEIGHT_TILES constant names are used, as well as adding a new TILE_IDX macro to calculate the index of a tile in a concatenated-rows (row-major in formal parlance) array. Also, tile numbers are stored in a temporary variable to improve readability as well (no more copy-pasting `contents[i + vmult[j]]` over and over again).
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
#include <utf8/unchecked.h>
|
||||
|
||||
#include "Constants.h"
|
||||
#include "CustomLevels.h"
|
||||
#include "Entity.h"
|
||||
#include "Exit.h"
|
||||
@@ -2641,7 +2642,8 @@ void Graphics::drawmap(void)
|
||||
{
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
if(map.contents[i + map.vmult[j]]>0) drawforetile(i * 8, j * 8, map.contents[i + map.vmult[j]]);
|
||||
const int tile = map.contents[TILE_IDX(i, j)];
|
||||
if(tile>0) drawforetile(i * 8, j * 8, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2651,7 +2653,8 @@ void Graphics::drawmap(void)
|
||||
{
|
||||
for (int it = 0; it < 40; it++)
|
||||
{
|
||||
if(map.contents[it + map.vmult[jt]]>0) drawforetile2(it * 8, jt * 8, map.contents[it + map.vmult[jt]]);
|
||||
const int tile = map.contents[TILE_IDX(it, jt)];
|
||||
if(tile>0) drawforetile2(it * 8, jt * 8, tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2661,7 +2664,8 @@ void Graphics::drawmap(void)
|
||||
{
|
||||
for (int i = 0; i < 40; i++)
|
||||
{
|
||||
if(map.contents[i + map.vmult[j]]>0) drawforetile3(i * 8, j * 8, map.contents[i + map.vmult[j]],map.rcol);
|
||||
const int tile = map.contents[TILE_IDX(i, j)];
|
||||
if(tile>0) drawforetile3(i * 8, j * 8, tile,map.rcol);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2678,14 +2682,14 @@ void Graphics::drawfinalmap(void)
|
||||
if(map.tileset==0){
|
||||
for (int j = 0; j < 30; j++) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
if((map.contents[i + map.vmult[j]])>0)
|
||||
if((map.contents[TILE_IDX(i, j)])>0)
|
||||
drawforetile(i * 8, j * 8, map.finalat(i,j));
|
||||
}
|
||||
}
|
||||
}else if (map.tileset == 1) {
|
||||
for (int j = 0; j < 30; j++) {
|
||||
for (int i = 0; i < 40; i++) {
|
||||
if((map.contents[i + map.vmult[j]])>0)
|
||||
if((map.contents[TILE_IDX(i, j)])>0)
|
||||
drawforetile2(i * 8, j * 8, map.finalat(i,j));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user