textri command #317

minor fixes
This commit is contained in:
BADIM-PC\Vadim 2017-09-28 23:46:27 +03:00
parent 1ec8406ee8
commit 403a26482d
2 changed files with 7 additions and 4 deletions

View File

@ -904,7 +904,7 @@ static void api_textri(tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, s32 x3,
s32 iu = (s32)u % MapWidth;
s32 iv = (s32)v % MapHeight;
u8 tile = map[(iv>>3) * TIC_MAP_WIDTH + (iu>>3)];
const u8 *buffer = &ptr[tile << 5];
u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3));
@ -913,8 +913,10 @@ static void api_textri(tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, s32 x3,
}
else
{
s32 iu = (s32)(u) & 127;
s32 iv = (s32)(v) & 255;
enum{SheetWidth = TIC_SPRITESHEET_SIZE, SheetHeight = TIC_SPRITESHEET_SIZE * TIC_SPRITE_BANKS};
s32 iu = (s32)(u) & (SheetWidth - 1);
s32 iv = (s32)(v) & (SheetHeight - 1);
const u8 *buffer = &ptr[((iu >> 3) + ((iv >> 3) << 4)) << 5];
u8 color = tic_tool_peek4(buffer, (iu & 7) + ((iv & 7) << 3));
if (color != chroma)

View File

@ -57,7 +57,8 @@
#define BITS_IN_BYTE 8
#define TIC_BANK_SPRITES (1 << BITS_IN_BYTE)
#define TIC_SPRITES (TIC_BANK_SPRITES * 2)
#define TIC_SPRITE_BANKS 2
#define TIC_SPRITES (TIC_BANK_SPRITES * TIC_SPRITE_BANKS)
#define TIC_SPRITESHEET_SIZE 128