no message
This commit is contained in:
parent
86a320e9ad
commit
694a016334
|
@ -359,8 +359,8 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param)
|
||||||
|
|
||||||
switch(i)
|
switch(i)
|
||||||
{
|
{
|
||||||
case 0: memcpy(&tic->cart.gfx.tiles, &cart->gfx.tiles, sizeof cart->gfx.tiles + sizeof cart->gfx.sprites); break;
|
case 0: memcpy(&tic->cart.tiles, &cart->tiles, sizeof cart->tiles + sizeof cart->sprites); break;
|
||||||
case 1: memcpy(&tic->cart.gfx.map, &cart->gfx.map, sizeof cart->gfx.map); break;
|
case 1: memcpy(&tic->cart.map, &cart->map, sizeof cart->map); break;
|
||||||
case 2: memcpy(&tic->cart.cover, &cart->cover, sizeof cart->cover); break;
|
case 2: memcpy(&tic->cart.cover, &cart->cover, sizeof cart->cover); break;
|
||||||
case 3: memcpy(&tic->cart.code, &cart->code, sizeof cart->code); break;
|
case 3: memcpy(&tic->cart.code, &cart->code, sizeof cart->code); break;
|
||||||
case 4: memcpy(&tic->cart.sound.sfx, &cart->sound.sfx, sizeof cart->sound.sfx); break;
|
case 4: memcpy(&tic->cart.sound.sfx, &cart->sound.sfx, sizeof cart->sound.sfx); break;
|
||||||
|
@ -603,9 +603,9 @@ typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySe
|
||||||
static const BinarySection BinarySections[] =
|
static const BinarySection BinarySections[] =
|
||||||
{
|
{
|
||||||
{"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false},
|
{"PALETTE", 1, offsetof(tic_cartridge, palette.data), sizeof(tic_palette), false},
|
||||||
{"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.tiles), sizeof(tic_tile), true},
|
{"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, tiles), sizeof(tic_tile), true},
|
||||||
{"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, gfx.sprites), sizeof(tic_tile), true},
|
{"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, sprites), sizeof(tic_tile), true},
|
||||||
{"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, gfx.map), TIC_MAP_WIDTH, true},
|
{"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, map), TIC_MAP_WIDTH, true},
|
||||||
{"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge,sound.sfx.waveform.envelopes), sizeof(tic_waveform), true},
|
{"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge,sound.sfx.waveform.envelopes), sizeof(tic_waveform), true},
|
||||||
{"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true},
|
{"SFX", SFX_COUNT, offsetof(tic_cartridge, sound.sfx.data), sizeof(tic_sound_effect), true},
|
||||||
{"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true},
|
{"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, sound.music.patterns), sizeof(tic_track_pattern), true},
|
||||||
|
@ -1330,7 +1330,7 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
|
||||||
tic_rgb rgb = {c->r, c->g, c->b};
|
tic_rgb rgb = {c->r, c->g, c->b};
|
||||||
u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb);
|
u8 color = tic_tool_find_closest_color(console->tic->cart.palette.colors, &rgb);
|
||||||
|
|
||||||
setSpritePixel(console->tic->cart.gfx.tiles, x, y, color);
|
setSpritePixel(console->tic->cart.tiles.data, x, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
gif_close(image);
|
gif_close(image);
|
||||||
|
@ -1352,8 +1352,8 @@ static void injectMap(Console* console, const void* buffer, s32 size)
|
||||||
{
|
{
|
||||||
enum {Size = sizeof(tic_map)};
|
enum {Size = sizeof(tic_map)};
|
||||||
|
|
||||||
SDL_memset(&console->tic->cart.gfx.map, 0, Size);
|
SDL_memset(&console->tic->cart.map, 0, Size);
|
||||||
SDL_memcpy(&console->tic->cart.gfx.map, buffer, SDL_min(size, Size));
|
SDL_memcpy(&console->tic->cart.map, buffer, SDL_min(size, Size));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void onImportMap(const char* name, const void* buffer, size_t size, void* data)
|
static void onImportMap(const char* name, const void* buffer, size_t size, void* data)
|
||||||
|
@ -1453,7 +1453,7 @@ static void exportSprites(Console* console)
|
||||||
{
|
{
|
||||||
for (s32 y = 0; y < Height; y++)
|
for (s32 y = 0; y < Height; y++)
|
||||||
for (s32 x = 0; x < Width; x++)
|
for (s32 x = 0; x < Width; x++)
|
||||||
data[x + y * Width] = getSpritePixel(console->tic->cart.gfx.tiles, x, y);
|
data[x + y * Width] = getSpritePixel(console->tic->cart.tiles.data, x, y);
|
||||||
|
|
||||||
s32 size = 0;
|
s32 size = 0;
|
||||||
if((size = writeGifData(console->tic, buffer, data, Width, Height)))
|
if((size = writeGifData(console->tic, buffer, data, Width, Height)))
|
||||||
|
@ -1493,7 +1493,7 @@ static void exportMap(Console* console)
|
||||||
|
|
||||||
if(buffer)
|
if(buffer)
|
||||||
{
|
{
|
||||||
SDL_memcpy(buffer, console->tic->cart.gfx.map.data, Size);
|
SDL_memcpy(buffer, console->tic->cart.map.data, Size);
|
||||||
fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console);
|
fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2136,8 +2136,9 @@ static void onConsoleRamCommand(Console* console, const char* param)
|
||||||
{offsetof(tic_ram, vram.vars.mask), "GAMEPAD MASK"},
|
{offsetof(tic_ram, vram.vars.mask), "GAMEPAD MASK"},
|
||||||
{offsetof(tic_ram, vram.input.gamepad), "GAMEPAD"},
|
{offsetof(tic_ram, vram.input.gamepad), "GAMEPAD"},
|
||||||
{offsetof(tic_ram, vram.input.reserved), "..."},
|
{offsetof(tic_ram, vram.input.reserved), "..."},
|
||||||
{offsetof(tic_ram, gfx.tiles), "SPRITES"},
|
{offsetof(tic_ram, tiles), "TILES"},
|
||||||
{offsetof(tic_ram, gfx.map), "MAP"},
|
{offsetof(tic_ram, sprites), "SPRITES"},
|
||||||
|
{offsetof(tic_ram, map), "MAP"},
|
||||||
{offsetof(tic_ram, persistent), "PERSISTENT MEMORY"},
|
{offsetof(tic_ram, persistent), "PERSISTENT MEMORY"},
|
||||||
{offsetof(tic_ram, registers), "SOUND REGISTERS"},
|
{offsetof(tic_ram, registers), "SOUND REGISTERS"},
|
||||||
{offsetof(tic_ram, sound.sfx.waveform), "WAVEFORMS"},
|
{offsetof(tic_ram, sound.sfx.waveform), "WAVEFORMS"},
|
||||||
|
@ -2763,7 +2764,7 @@ static bool cmdInjectSprites(Console* console, const char* param, const char* na
|
||||||
tic_rgb rgb = {c->r, c->g, c->b};
|
tic_rgb rgb = {c->r, c->g, c->b};
|
||||||
u8 color = tic_tool_find_closest_color(embed.file.palette.colors, &rgb);
|
u8 color = tic_tool_find_closest_color(embed.file.palette.colors, &rgb);
|
||||||
|
|
||||||
setSpritePixel(embed.file.gfx.tiles, x, y, color);
|
setSpritePixel(embed.file.tiles.data, x, y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
gif_close(image);
|
gif_close(image);
|
||||||
|
|
|
@ -170,7 +170,7 @@ static void drawDialog(Dialog* dlg)
|
||||||
|
|
||||||
{
|
{
|
||||||
u8 chromakey = 14;
|
u8 chromakey = 14;
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 2, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 2, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
10
src/jsapi.c
10
src/jsapi.c
|
@ -182,7 +182,7 @@ static duk_ret_t duk_spr(duk_context* duk)
|
||||||
s32 h = duk_is_null_or_undefined(duk, 8) ? 1 : duk_to_int(duk, 8);
|
s32 h = duk_is_null_or_undefined(duk, 8) ? 1 : duk_to_int(duk, 8);
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
||||||
memory->api.sprite_ex(memory, &memory->ram.gfx, index, x, y, w, h, colors, count, scale, flip, rotate);
|
memory->api.sprite_ex(memory, &memory->ram.tiles, index, x, y, w, h, colors, count, scale, flip, rotate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -361,14 +361,14 @@ static duk_ret_t duk_map(duk_context* duk)
|
||||||
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
||||||
|
|
||||||
if (duk_is_null_or_undefined(duk, 8))
|
if (duk_is_null_or_undefined(duk, 8))
|
||||||
memory->api.map(memory, &memory->ram.gfx, x, y, w, h, sx, sy, chromakey, scale);
|
memory->api.map(memory, &memory->ram.map, &memory->ram.tiles, x, y, w, h, sx, sy, chromakey, scale);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
void* remap = duk_get_heapptr(duk, 8);
|
void* remap = duk_get_heapptr(duk, 8);
|
||||||
|
|
||||||
RemapData data = {duk, remap};
|
RemapData data = {duk, remap};
|
||||||
|
|
||||||
memory->api.remap((tic_mem*)getDukMachine(duk), &memory->ram.gfx, x, y, w, h, sx, sy, chromakey, scale, remapCallback, &data);
|
memory->api.remap((tic_mem*)getDukMachine(duk), &memory->ram.map, &memory->ram.tiles, x, y, w, h, sx, sy, chromakey, scale, remapCallback, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -381,7 +381,7 @@ static duk_ret_t duk_mget(duk_context* duk)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
||||||
|
|
||||||
u8 value = memory->api.map_get(memory, &memory->ram.gfx, x, y);
|
u8 value = memory->api.map_get(memory, &memory->ram.map, x, y);
|
||||||
duk_push_uint(duk, value);
|
duk_push_uint(duk, value);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -394,7 +394,7 @@ static duk_ret_t duk_mset(duk_context* duk)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
tic_mem* memory = (tic_mem*)getDukMachine(duk);
|
||||||
|
|
||||||
memory->api.map_set(memory, &memory->ram.gfx, x, y, value);
|
memory->api.map_set(memory, &memory->ram.map, x, y, value);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
10
src/luaapi.c
10
src/luaapi.c
|
@ -490,7 +490,7 @@ static s32 lua_spr(lua_State* lua)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
||||||
|
|
||||||
memory->api.sprite_ex(memory, &memory->ram.gfx, index, x, y, w, h, colors, count, scale, flip, rotate);
|
memory->api.sprite_ex(memory, &memory->ram.tiles, index, x, y, w, h, colors, count, scale, flip, rotate);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +506,7 @@ static s32 lua_mget(lua_State* lua)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
||||||
|
|
||||||
u8 value = memory->api.map_get(memory, &memory->ram.gfx, x, y);
|
u8 value = memory->api.map_get(memory, &memory->ram.map, x, y);
|
||||||
lua_pushinteger(lua, value);
|
lua_pushinteger(lua, value);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -527,7 +527,7 @@ static s32 lua_mset(lua_State* lua)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
||||||
|
|
||||||
memory->api.map_set(memory, &memory->ram.gfx, x, y, val);
|
memory->api.map_set(memory, &memory->ram.map, x, y, val);
|
||||||
}
|
}
|
||||||
else luaL_error(lua, "invalid params, mget(x,y)\n");
|
else luaL_error(lua, "invalid params, mget(x,y)\n");
|
||||||
|
|
||||||
|
@ -602,7 +602,7 @@ static s32 lua_map(lua_State* lua)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
||||||
|
|
||||||
memory->api.remap(memory, &memory->ram.gfx, x, y, w, h, sx, sy, chromakey, scale, remapCallback, &data);
|
memory->api.remap(memory, &memory->ram.map, &memory->ram.tiles, x, y, w, h, sx, sy, chromakey, scale, remapCallback, &data);
|
||||||
|
|
||||||
luaL_unref(lua, LUA_REGISTRYINDEX, data.reg);
|
luaL_unref(lua, LUA_REGISTRYINDEX, data.reg);
|
||||||
|
|
||||||
|
@ -617,7 +617,7 @@ static s32 lua_map(lua_State* lua)
|
||||||
|
|
||||||
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
tic_mem* memory = (tic_mem*)getLuaMachine(lua);
|
||||||
|
|
||||||
memory->api.map((tic_mem*)getLuaMachine(lua), &memory->ram.gfx, x, y, w, h, sx, sy, chromakey, scale);
|
memory->api.map((tic_mem*)getLuaMachine(lua), &memory->ram.map, &memory->ram.tiles, x, y, w, h, sx, sy, chromakey, scale);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
28
src/map.c
28
src/map.c
|
@ -314,7 +314,7 @@ static void drawTileIndex(Map* map, s32 x, s32 y)
|
||||||
{
|
{
|
||||||
s32 tx = 0, ty = 0;
|
s32 tx = 0, ty = 0;
|
||||||
getMouseMap(map, &tx, &ty);
|
getMouseMap(map, &tx, &ty);
|
||||||
index = map->tic->api.map_get(map->tic, &map->tic->cart.gfx, tx, ty);
|
index = map->tic->api.map_get(map->tic, &map->tic->cart.map, tx, ty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +397,7 @@ static void drawSheetOvr(Map* map, s32 x, s32 y)
|
||||||
|
|
||||||
for(s32 j = 0, index = 0; j < rect.h; j += TIC_SPRITESIZE)
|
for(s32 j = 0, index = 0; j < rect.h; j += TIC_SPRITESIZE)
|
||||||
for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++)
|
for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++)
|
||||||
map->tic->api.sprite(map->tic, &map->tic->cart.gfx, index, x + i, y + j, NULL, 0);
|
map->tic->api.sprite(map->tic, &map->tic->cart.tiles, index, x + i, y + j, NULL, 0);
|
||||||
|
|
||||||
{
|
{
|
||||||
s32 bx = map->sheet.rect.x * TIC_SPRITESIZE - 1 + x;
|
s32 bx = map->sheet.rect.x * TIC_SPRITESIZE - 1 + x;
|
||||||
|
@ -437,7 +437,7 @@ static void setMapSprite(Map* map, s32 x, s32 y)
|
||||||
|
|
||||||
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
||||||
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
||||||
map->tic->api.map_set(map->tic, &map->tic->cart.gfx, (x+i)%TIC_MAP_WIDTH, (y+j)%TIC_MAP_HEIGHT, (mx+i) + (my+j) * SHEET_COLS);
|
map->tic->api.map_set(map->tic, &map->tic->cart.map, (x+i)%TIC_MAP_WIDTH, (y+j)%TIC_MAP_HEIGHT, (mx+i) + (my+j) * SHEET_COLS);
|
||||||
|
|
||||||
history_add(map->history);
|
history_add(map->history);
|
||||||
}
|
}
|
||||||
|
@ -470,7 +470,7 @@ static void drawTileCursor(Map* map)
|
||||||
|
|
||||||
for(s32 j = 0, ty=my; j < map->sheet.rect.h; j++, ty+=TIC_SPRITESIZE)
|
for(s32 j = 0, ty=my; j < map->sheet.rect.h; j++, ty+=TIC_SPRITESIZE)
|
||||||
for(s32 i = 0, tx=mx; i < map->sheet.rect.w; i++, tx+=TIC_SPRITESIZE)
|
for(s32 i = 0, tx=mx; i < map->sheet.rect.w; i++, tx+=TIC_SPRITESIZE)
|
||||||
map->tic->api.sprite(map->tic, &map->tic->cart.gfx, (sx+i) + (sy+j) * SHEET_COLS, tx, ty, NULL, 0);
|
map->tic->api.sprite(map->tic, &map->tic->cart.tiles, (sx+i) + (sy+j) * SHEET_COLS, tx, ty, NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
drawCursorPos(map, mx, my);
|
drawCursorPos(map, mx, my);
|
||||||
|
@ -512,7 +512,7 @@ static void processMouseDrawMode(Map* map)
|
||||||
{
|
{
|
||||||
s32 tx = 0, ty = 0;
|
s32 tx = 0, ty = 0;
|
||||||
getMouseMap(map, &tx, &ty);
|
getMouseMap(map, &tx, &ty);
|
||||||
s32 index = map->tic->api.map_get(map->tic, &map->tic->cart.gfx, tx, ty);
|
s32 index = map->tic->api.map_get(map->tic, &map->tic->cart.map, tx, ty);
|
||||||
|
|
||||||
map->sheet.rect = (SDL_Rect){index % SHEET_COLS, index / SHEET_COLS, 1, 1};
|
map->sheet.rect = (SDL_Rect){index % SHEET_COLS, index / SHEET_COLS, 1, 1};
|
||||||
}
|
}
|
||||||
|
@ -593,7 +593,7 @@ static void drawPasteData(Map* map)
|
||||||
|
|
||||||
for(s32 j = 0; j < h; j++)
|
for(s32 j = 0; j < h; j++)
|
||||||
for(s32 i = 0; i < w; i++)
|
for(s32 i = 0; i < w; i++)
|
||||||
map->tic->api.map_set(map->tic, &map->tic->cart.gfx, (mx+i)%TIC_MAP_WIDTH, (my+j)%TIC_MAP_HEIGHT, data[i + j * w]);
|
map->tic->api.map_set(map->tic, &map->tic->cart.map, (mx+i)%TIC_MAP_WIDTH, (my+j)%TIC_MAP_HEIGHT, data[i + j * w]);
|
||||||
|
|
||||||
history_add(map->history);
|
history_add(map->history);
|
||||||
|
|
||||||
|
@ -612,7 +612,7 @@ static void drawPasteData(Map* map)
|
||||||
|
|
||||||
for(s32 j = 0; j < h; j++)
|
for(s32 j = 0; j < h; j++)
|
||||||
for(s32 i = 0; i < w; i++)
|
for(s32 i = 0; i < w; i++)
|
||||||
map->tic->api.sprite(map->tic, &map->tic->cart.gfx, data[i + j * w], mx + i*TIC_SPRITESIZE, my + j*TIC_SPRITESIZE, NULL, 0);
|
map->tic->api.sprite(map->tic, &map->tic->cart.tiles, data[i + j * w], mx + i*TIC_SPRITESIZE, my + j*TIC_SPRITESIZE, NULL, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -764,7 +764,7 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile)
|
||||||
{
|
{
|
||||||
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
||||||
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
||||||
map->tic->api.map_set(map->tic, &map->tic->cart.gfx, x+i, y+j, (mx+i) + (my+j) * SHEET_COLS);
|
map->tic->api.map_set(map->tic, &map->tic->cart.map, x+i, y+j, (mx+i) + (my+j) * SHEET_COLS);
|
||||||
|
|
||||||
for(s32 i = 0; i < COUNT_OF(dx); i++)
|
for(s32 i = 0; i < COUNT_OF(dx); i++)
|
||||||
{
|
{
|
||||||
|
@ -776,7 +776,7 @@ static void fillMap(Map* map, s32 x, s32 y, u8 tile)
|
||||||
bool match = true;
|
bool match = true;
|
||||||
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
for(s32 j = 0; j < map->sheet.rect.h; j++)
|
||||||
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
for(s32 i = 0; i < map->sheet.rect.w; i++)
|
||||||
if(map->tic->api.map_get(map->tic, &map->tic->cart.gfx, nx+i, ny+j) != tile)
|
if(map->tic->api.map_get(map->tic, &map->tic->cart.map, nx+i, ny+j) != tile)
|
||||||
match = false;
|
match = false;
|
||||||
|
|
||||||
if(match)
|
if(match)
|
||||||
|
@ -801,7 +801,7 @@ static void processMouseFillMode(Map* map)
|
||||||
s32 tx = 0, ty = 0;
|
s32 tx = 0, ty = 0;
|
||||||
getMouseMap(map, &tx, &ty);
|
getMouseMap(map, &tx, &ty);
|
||||||
|
|
||||||
fillMap(map, tx, ty, map->tic->api.map_get(map->tic, &map->tic->cart.gfx, tx, ty));
|
fillMap(map, tx, ty, map->tic->api.map_get(map->tic, &map->tic->cart.map, tx, ty));
|
||||||
history_add(map->history);
|
history_add(map->history);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,7 +864,7 @@ static void drawMapOvr(Map* map)
|
||||||
s32 scrollX = map->scroll.x % TIC_SPRITESIZE;
|
s32 scrollX = map->scroll.x % TIC_SPRITESIZE;
|
||||||
s32 scrollY = map->scroll.y % TIC_SPRITESIZE;
|
s32 scrollY = map->scroll.y % TIC_SPRITESIZE;
|
||||||
|
|
||||||
map->tic->api.map(map->tic, &map->tic->cart.gfx, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE,
|
map->tic->api.map(map->tic, &map->tic->cart.map, &map->tic->cart.tiles, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE,
|
||||||
TIC_MAP_SCREEN_WIDTH + 1, TIC_MAP_SCREEN_HEIGHT + 1, -scrollX, -scrollY, -1, 1);
|
TIC_MAP_SCREEN_WIDTH + 1, TIC_MAP_SCREEN_HEIGHT + 1, -scrollX, -scrollY, -1, 1);
|
||||||
|
|
||||||
if(map->canvas.grid || map->scroll.active)
|
if(map->canvas.grid || map->scroll.active)
|
||||||
|
@ -950,7 +950,7 @@ static void copySelectionToClipboard(Map* map)
|
||||||
normalizeMapRect(&x, &y);
|
normalizeMapRect(&x, &y);
|
||||||
|
|
||||||
s32 index = x + y * TIC_MAP_WIDTH;
|
s32 index = x + y * TIC_MAP_WIDTH;
|
||||||
*ptr++ = map->tic->cart.gfx.map.data[index];
|
*ptr++ = map->tic->cart.map.data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
toClipboard(buffer, size, true);
|
toClipboard(buffer, size, true);
|
||||||
|
@ -978,7 +978,7 @@ static void deleteSelection(Map* map)
|
||||||
normalizeMapRect(&x, &y);
|
normalizeMapRect(&x, &y);
|
||||||
|
|
||||||
s32 index = x + y * TIC_MAP_WIDTH;
|
s32 index = x + y * TIC_MAP_WIDTH;
|
||||||
map->tic->cart.gfx.map.data[index] = 0;
|
map->tic->cart.map.data[index] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
history_add(map->history);
|
history_add(map->history);
|
||||||
|
@ -1185,7 +1185,7 @@ void initMap(Map* map, tic_mem* tic)
|
||||||
.gesture = false,
|
.gesture = false,
|
||||||
.start = {0, 0},
|
.start = {0, 0},
|
||||||
},
|
},
|
||||||
.history = history_create(&tic->cart.gfx.map, sizeof tic->cart.gfx.map),
|
.history = history_create(&tic->cart.map, sizeof tic->cart.map),
|
||||||
.event = onStudioEvent,
|
.event = onStudioEvent,
|
||||||
.overlap = overlap,
|
.overlap = overlap,
|
||||||
};
|
};
|
||||||
|
|
|
@ -124,7 +124,7 @@ static void drawDialog(Menu* menu)
|
||||||
|
|
||||||
{
|
{
|
||||||
u8 chromakey = 14;
|
u8 chromakey = 14;
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 0, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 0, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +209,7 @@ static void drawPlayerButtons(Menu* menu, s32 x, s32 y)
|
||||||
if(menu->gamepad.selected == index && menu->ticks % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
if(menu->gamepad.selected == index && menu->ticks % TIC_FRAMERATE < TIC_FRAMERATE / 2)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
|
|
||||||
s32 code = codes[index];
|
s32 code = codes[index];
|
||||||
char label[32];
|
char label[32];
|
||||||
|
|
|
@ -1327,7 +1327,7 @@ static void drawTumbler(Music* music, s32 x, s32 y, s32 index)
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 color = Chroma;
|
u8 color = Chroma;
|
||||||
tic->api.sprite(tic, &tic->config.gfx, music->tracker.patterns[index] ? On : Off, x, y, &color, 1);
|
tic->api.sprite(tic, &tic->config.tiles, music->tracker.patterns[index] ? On : Off, x, y, &color, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawTracker(Music* music, s32 x, s32 y)
|
static void drawTracker(Music* music, s32 x, s32 y)
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
|
|
||||||
static u8 getSheetPixel(Sprite* sprite, s32 x, s32 y)
|
static u8 getSheetPixel(Sprite* sprite, s32 x, s32 y)
|
||||||
{
|
{
|
||||||
return getSpritePixel(sprite->tic->cart.gfx.tiles, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y);
|
return getSpritePixel(sprite->tic->cart.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void setSheetPixel(Sprite* sprite, s32 x, s32 y, u8 color)
|
static void setSheetPixel(Sprite* sprite, s32 x, s32 y, u8 color)
|
||||||
{
|
{
|
||||||
setSpritePixel(sprite->tic->cart.gfx.tiles, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y, color);
|
setSpritePixel(sprite->tic->cart.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
static s32 getIndexPosX(Sprite* sprite)
|
static s32 getIndexPosX(Sprite* sprite)
|
||||||
|
@ -940,7 +940,7 @@ static void drawSheetOvr(Sprite* sprite, s32 x, s32 y)
|
||||||
|
|
||||||
for(s32 j = 0, index = (sprite->index - sprite->index % TIC_BANK_SPRITES); j < rect.h; j += TIC_SPRITESIZE)
|
for(s32 j = 0, index = (sprite->index - sprite->index % TIC_BANK_SPRITES); j < rect.h; j += TIC_SPRITESIZE)
|
||||||
for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++)
|
for(s32 i = 0; i < rect.w; i += TIC_SPRITESIZE, index++)
|
||||||
sprite->tic->api.sprite(sprite->tic, &sprite->tic->cart.gfx, index, x + i, y + j, NULL, 0);
|
sprite->tic->api.sprite(sprite->tic, &sprite->tic->cart.tiles, index, x + i, y + j, NULL, 0);
|
||||||
{
|
{
|
||||||
s32 bx = getIndexPosX(sprite) + x - 1;
|
s32 bx = getIndexPosX(sprite) + x - 1;
|
||||||
s32 by = getIndexPosY(sprite) + y - 1;
|
s32 by = getIndexPosY(sprite) + y - 1;
|
||||||
|
@ -1551,7 +1551,7 @@ void initSprite(Sprite* sprite, tic_mem* tic)
|
||||||
.front = sprite->select.front,
|
.front = sprite->select.front,
|
||||||
},
|
},
|
||||||
.mode = SPRITE_DRAW_MODE,
|
.mode = SPRITE_DRAW_MODE,
|
||||||
.history = history_create(tic->cart.gfx.tiles, TIC_SPRITES * sizeof(tic_tile)),
|
.history = history_create(&tic->cart.tiles, TIC_SPRITES * sizeof(tic_tile)),
|
||||||
.event = onStudioEvent,
|
.event = onStudioEvent,
|
||||||
.overlap = overlap,
|
.overlap = overlap,
|
||||||
};
|
};
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
|
|
||||||
static void reset(Start* start)
|
static void reset(Start* start)
|
||||||
{
|
{
|
||||||
u8* tile = (u8*)start->tic->ram.gfx.tiles;
|
u8* tile = (u8*)start->tic->ram.tiles.data;
|
||||||
|
|
||||||
start->tic->api.clear(start->tic, (tic_color_black));
|
start->tic->api.clear(start->tic, (tic_color_black));
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ static void reset(Start* start)
|
||||||
|
|
||||||
for(s32 i = 0; i < sizeof(tic_tile); i++) tile[i] = val;
|
for(s32 i = 0; i < sizeof(tic_tile); i++) tile[i] = val;
|
||||||
|
|
||||||
start->tic->api.map(start->tic, &start->tic->ram.gfx, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT + (TIC80_HEIGHT % TIC_SPRITESIZE ? 1 : 0), 0, 0, -1, 1);
|
start->tic->api.map(start->tic, &start->tic->ram.map, &start->tic->ram.tiles, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT + (TIC80_HEIGHT % TIC_SPRITESIZE ? 1 : 0), 0, 0, -1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawHeader(Start* start)
|
static void drawHeader(Start* start)
|
||||||
|
|
10
src/studio.c
10
src/studio.c
|
@ -2042,14 +2042,14 @@ static void renderCursor()
|
||||||
studio.tic->ram.vram.vars.cursor)
|
studio.tic->ram.vram.vars.cursor)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
blitCursor(studio.tic->ram.gfx.sprites[studio.tic->ram.vram.vars.cursor].data);
|
blitCursor(studio.tic->ram.sprites.data[studio.tic->ram.vram.vars.cursor].data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_ShowCursor(getConfig()->theme.cursor.sprite >= 0 ? SDL_DISABLE : SDL_ENABLE);
|
SDL_ShowCursor(getConfig()->theme.cursor.sprite >= 0 ? SDL_DISABLE : SDL_ENABLE);
|
||||||
|
|
||||||
if(getConfig()->theme.cursor.sprite >= 0)
|
if(getConfig()->theme.cursor.sprite >= 0)
|
||||||
blitCursor(studio.tic->config.gfx.tiles[getConfig()->theme.cursor.sprite].data);
|
blitCursor(studio.tic->config.tiles.data[getConfig()->theme.cursor.sprite].data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void useSystemPalette()
|
static void useSystemPalette()
|
||||||
|
@ -2279,7 +2279,7 @@ static void initTouchGamepad()
|
||||||
if (!studio.renderer)
|
if (!studio.renderer)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
studio.tic->api.map(studio.tic, &studio.tic->config.gfx, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, -1, 1);
|
studio.tic->api.map(studio.tic, &studio.tic->config.map, &studio.tic->config.tiles, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, -1, 1);
|
||||||
|
|
||||||
if(!studio.gamepad.texture)
|
if(!studio.gamepad.texture)
|
||||||
{
|
{
|
||||||
|
@ -2306,7 +2306,7 @@ static void updateSystemFont()
|
||||||
for(s32 i = 0; i < TIC_FONT_CHARS; i++)
|
for(s32 i = 0; i < TIC_FONT_CHARS; i++)
|
||||||
for(s32 y = 0; y < TIC_SPRITESIZE; y++)
|
for(s32 y = 0; y < TIC_SPRITESIZE; y++)
|
||||||
for(s32 x = 0; x < TIC_SPRITESIZE; x++)
|
for(s32 x = 0; x < TIC_SPRITESIZE; x++)
|
||||||
if(tic_tool_peek4(&studio.tic->config.gfx.sprites[i], TIC_SPRITESIZE*(y+1) - x-1))
|
if(tic_tool_peek4(&studio.tic->config.sprites.data[i], TIC_SPRITESIZE*(y+1) - x-1))
|
||||||
studio.tic->font.data[i*BITS_IN_BYTE+y] |= 1 << x;
|
studio.tic->font.data[i*BITS_IN_BYTE+y] |= 1 << x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2331,7 +2331,7 @@ static void setWindowIcon()
|
||||||
for(s32 j = 0, index = 0; j < Size; j++)
|
for(s32 j = 0, index = 0; j < Size; j++)
|
||||||
for(s32 i = 0; i < Size; i++, index++)
|
for(s32 i = 0; i < Size; i++, index++)
|
||||||
{
|
{
|
||||||
u8 color = getSpritePixel(studio.tic->config.gfx.tiles, i/Scale, j/Scale);
|
u8 color = getSpritePixel(studio.tic->config.tiles.data, i/Scale, j/Scale);
|
||||||
pixels[index] = color == ColorKey ? 0 : pal[color];
|
pixels[index] = color == ColorKey ? 0 : pal[color];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -202,14 +202,14 @@ static void drawTopToolbar(Surf* surf, s32 x, s32 y)
|
||||||
enum{Gap = 10, TipX = 150, SelectWidth = 54};
|
enum{Gap = 10, TipX = 150, SelectWidth = 54};
|
||||||
|
|
||||||
u8 colorkey = 0;
|
u8 colorkey = 0;
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
{
|
{
|
||||||
static const char Label[] = "SELECT";
|
static const char Label[] = "SELECT";
|
||||||
tic->api.text(tic, Label, TipX + Gap, y+3, tic_color_black);
|
tic->api.text(tic, Label, TipX + Gap, y+3, tic_color_black);
|
||||||
tic->api.text(tic, Label, TipX + Gap, y+2, tic_color_white);
|
tic->api.text(tic, Label, TipX + Gap, y+2, tic_color_white);
|
||||||
}
|
}
|
||||||
|
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
{
|
{
|
||||||
static const char Label[] = "BACK";
|
static const char Label[] = "BACK";
|
||||||
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black);
|
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black);
|
||||||
|
@ -244,7 +244,7 @@ static void drawBottomToolbar(Surf* surf, s32 x, s32 y)
|
||||||
|
|
||||||
u8 colorkey = 0;
|
u8 colorkey = 0;
|
||||||
|
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate);
|
||||||
{
|
{
|
||||||
static const char Label[] = "WEBSITE";
|
static const char Label[] = "WEBSITE";
|
||||||
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black);
|
tic->api.text(tic, Label, TipX + Gap + SelectWidth, y +3, tic_color_black);
|
||||||
|
@ -355,7 +355,7 @@ static void drawBG(Surf* surf)
|
||||||
for(s32 j = 0; j < Height + 1; j++)
|
for(s32 j = 0; j < Height + 1; j++)
|
||||||
for(s32 i = 0; i < Width + 1; i++)
|
for(s32 i = 0; i < Width + 1; i++)
|
||||||
if(counter++ % 2)
|
if(counter++ % 2)
|
||||||
tic->api.sprite_ex(tic, &tic->config.gfx, 34, i*Size - offset, j*Size - offset, 2, 2, 0, 0, 1, tic_no_flip, tic_no_rotate);
|
tic->api.sprite_ex(tic, &tic->config.tiles, 34, i*Size - offset, j*Size - offset, 2, 2, 0, 0, 1, tic_no_flip, tic_no_rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void replace(char* src, const char* what, const char* with)
|
static void replace(char* src, const char* what, const char* with)
|
||||||
|
|
76
src/tic.c
76
src/tic.c
|
@ -316,7 +316,7 @@ static void drawTile(tic_machine* machine, const tic_tile* buffer, s32 x, s32 y,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawMap(tic_machine* machine, const tic_gfx* src, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data)
|
static void drawMap(tic_machine* machine, const tic_map* src, const tic_tiles* tiles, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data)
|
||||||
{
|
{
|
||||||
const s32 size = TIC_SPRITESIZE * scale;
|
const s32 size = TIC_SPRITESIZE * scale;
|
||||||
|
|
||||||
|
@ -332,12 +332,12 @@ static void drawMap(tic_machine* machine, const tic_gfx* src, s32 x, s32 y, s32
|
||||||
while(mj >= TIC_MAP_HEIGHT) mj -= TIC_MAP_HEIGHT;
|
while(mj >= TIC_MAP_HEIGHT) mj -= TIC_MAP_HEIGHT;
|
||||||
|
|
||||||
s32 index = mi + mj * TIC_MAP_WIDTH;
|
s32 index = mi + mj * TIC_MAP_WIDTH;
|
||||||
RemapResult tile = { *(src->map.data + index), tic_no_flip, tic_no_rotate };
|
RemapResult tile = { *(src->data + index), tic_no_flip, tic_no_rotate };
|
||||||
|
|
||||||
if (remap)
|
if (remap)
|
||||||
remap(data, mi, mj, &tile);
|
remap(data, mi, mj, &tile);
|
||||||
|
|
||||||
drawTile(machine, src->tiles + tile.index, ii, jj, &chromakey, 1, scale, tile.flip, tile.rotate);
|
drawTile(machine, tiles->data + tile.index, ii, jj, &chromakey, 1, scale, tile.flip, tile.rotate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -651,13 +651,13 @@ static s32 api_text_ex(tic_mem* memory, const char* text, s32 x, s32 y, u8 color
|
||||||
return drawText(memory, text, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, scale, fixed ? drawChar : drawNonFixedChar);
|
return drawText(memory, text, x, y, TIC_FONT_WIDTH, TIC_FONT_HEIGHT, color, scale, fixed ? drawChar : drawNonFixedChar);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void drawSprite(tic_mem* memory, const tic_gfx* src, s32 index, s32 x, s32 y, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate)
|
static void drawSprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate)
|
||||||
{
|
{
|
||||||
if(index < TIC_SPRITES)
|
if(index < TIC_SPRITES)
|
||||||
drawTile((tic_machine*)memory, src->tiles + index, x, y, colors, count, scale, flip, rotate);
|
drawTile((tic_machine*)memory, src->data + index, x, y, colors, count, scale, flip, rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void api_sprite_ex(tic_mem* memory, const tic_gfx* src, s32 index, s32 x, s32 y, s32 w, s32 h, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate)
|
static void api_sprite_ex(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, s32 w, s32 h, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate)
|
||||||
{
|
{
|
||||||
s32 step = TIC_SPRITESIZE * scale;
|
s32 step = TIC_SPRITESIZE * scale;
|
||||||
|
|
||||||
|
@ -701,14 +701,14 @@ static void api_sprite_ex(tic_mem* memory, const tic_gfx* src, s32 index, s32 x,
|
||||||
|
|
||||||
s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale)
|
s32 drawSpriteFont(tic_mem* memory, u8 symbol, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale)
|
||||||
{
|
{
|
||||||
api_sprite_ex(memory, &memory->ram.gfx, symbol + TIC_BANK_SPRITES, x, y, 1, 1, &chromakey, 1, scale, tic_no_flip, tic_no_rotate);
|
api_sprite_ex(memory, &memory->ram.sprites, symbol, x, y, 1, 1, &chromakey, 1, scale, tic_no_flip, tic_no_rotate);
|
||||||
|
|
||||||
return width * scale;
|
return width * scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale)
|
s32 drawFixedSpriteFont(tic_mem* memory, u8 index, s32 x, s32 y, s32 width, s32 height, u8 chromakey, s32 scale)
|
||||||
{
|
{
|
||||||
const u8* ptr = memory->ram.gfx.sprites[index].data;
|
const u8* ptr = memory->ram.sprites.data[index].data;
|
||||||
|
|
||||||
enum {Size = TIC_SPRITESIZE};
|
enum {Size = TIC_SPRITESIZE};
|
||||||
|
|
||||||
|
@ -935,8 +935,8 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
|
||||||
{
|
{
|
||||||
tic_machine* machine = (tic_machine*)memory;
|
tic_machine* machine = (tic_machine*)memory;
|
||||||
TexVert V0, V1, V2;
|
TexVert V0, V1, V2;
|
||||||
const u8* ptr = memory->ram.gfx.tiles[0].data;
|
const u8* ptr = memory->ram.tiles.data[0].data;
|
||||||
const u8* map = memory->ram.gfx.map.data;
|
const u8* map = memory->ram.map.data;
|
||||||
|
|
||||||
V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1;
|
V0.x = (float)x1; V0.y = (float)y1; V0.u = (float)u1; V0.v = (float)v1;
|
||||||
V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2;
|
V1.x = (float)x2; V1.y = (float)y2; V1.u = (float)u2; V1.v = (float)v2;
|
||||||
|
@ -996,33 +996,33 @@ static void api_textri(tic_mem* memory, float x1, float y1, float x2, float y2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void api_sprite(tic_mem* memory, const tic_gfx* src, s32 index, s32 x, s32 y, u8* colors, s32 count)
|
static void api_sprite(tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count)
|
||||||
{
|
{
|
||||||
drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate);
|
drawSprite(memory, src, index, x, y, colors, count, 1, tic_no_flip, tic_no_rotate);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void api_map(tic_mem* memory, const tic_gfx* src, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale)
|
static void api_map(tic_mem* memory, const tic_map* src, const tic_tiles* tiles, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale)
|
||||||
{
|
{
|
||||||
drawMap((tic_machine*)memory, src, x, y, width, height, sx, sy, chromakey, scale, NULL, NULL);
|
drawMap((tic_machine*)memory, src, tiles, x, y, width, height, sx, sy, chromakey, scale, NULL, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void api_remap(tic_mem* memory, const tic_gfx* src, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data)
|
static void api_remap(tic_mem* memory, const tic_map* src, const tic_tiles* tiles, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data)
|
||||||
{
|
{
|
||||||
drawMap((tic_machine*)memory, src, x, y, width, height, sx, sy, chromakey, scale, remap, data);
|
drawMap((tic_machine*)memory, src, tiles, x, y, width, height, sx, sy, chromakey, scale, remap, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void api_map_set(tic_mem* memory, tic_gfx* src, s32 x, s32 y, u8 value)
|
static void api_map_set(tic_mem* memory, tic_map* src, s32 x, s32 y, u8 value)
|
||||||
{
|
{
|
||||||
if(x < 0 || x >= TIC_MAP_WIDTH || y < 0 || y >= TIC_MAP_HEIGHT) return;
|
if(x < 0 || x >= TIC_MAP_WIDTH || y < 0 || y >= TIC_MAP_HEIGHT) return;
|
||||||
|
|
||||||
*(src->map.data + y * TIC_MAP_WIDTH + x) = value;
|
*(src->data + y * TIC_MAP_WIDTH + x) = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u8 api_map_get(tic_mem* memory, const tic_gfx* src, s32 x, s32 y)
|
static u8 api_map_get(tic_mem* memory, const tic_map* src, s32 x, s32 y)
|
||||||
{
|
{
|
||||||
if(x < 0 || x >= TIC_MAP_WIDTH || y < 0 || y >= TIC_MAP_HEIGHT) return 0;
|
if(x < 0 || x >= TIC_MAP_WIDTH || y < 0 || y >= TIC_MAP_HEIGHT) return 0;
|
||||||
|
|
||||||
return *(src->map.data + y * TIC_MAP_WIDTH + x);
|
return *(src->data + y * TIC_MAP_WIDTH + x);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void api_line(tic_mem* memory, s32 x0, s32 y0, s32 x1, s32 y1, u8 color)
|
static void api_line(tic_mem* memory, s32 x0, s32 y0, s32 x1, s32 y1, u8 color)
|
||||||
|
@ -1324,7 +1324,10 @@ static void initCover(tic_mem* tic)
|
||||||
|
|
||||||
static void cart2ram(tic_mem* memory)
|
static void cart2ram(tic_mem* memory)
|
||||||
{
|
{
|
||||||
memcpy(&memory->ram.gfx, &memory->cart.gfx, sizeof memory->ram.gfx);
|
memcpy(&memory->ram.tiles, &memory->cart.tiles, sizeof(tic_tiles));
|
||||||
|
memcpy(&memory->ram.sprites, &memory->cart.sprites, sizeof(tic_tiles));
|
||||||
|
memcpy(&memory->ram.map, &memory->cart.map, sizeof(tic_tiles));
|
||||||
|
|
||||||
memcpy(&memory->ram.sound, &memory->cart.sound, sizeof memory->ram.sound);
|
memcpy(&memory->ram.sound, &memory->cart.sound, sizeof memory->ram.sound);
|
||||||
|
|
||||||
initCover(memory);
|
initCover(memory);
|
||||||
|
@ -1534,16 +1537,17 @@ static double api_time(tic_mem* memory)
|
||||||
|
|
||||||
static void api_sync(tic_mem* tic, bool toCart)
|
static void api_sync(tic_mem* tic, bool toCart)
|
||||||
{
|
{
|
||||||
if(toCart)
|
// TODO: fix this
|
||||||
{
|
// if(toCart)
|
||||||
memcpy(&tic->cart.gfx, &tic->ram.gfx, sizeof tic->cart.gfx);
|
// {
|
||||||
memcpy(&tic->cart.sound, &tic->ram.sound, sizeof tic->cart.sound);
|
// memcpy(&tic->cart.gfx, &tic->ram.gfx, sizeof tic->cart.gfx);
|
||||||
}
|
// memcpy(&tic->cart.sound, &tic->ram.sound, sizeof tic->cart.sound);
|
||||||
else
|
// }
|
||||||
{
|
// else
|
||||||
memcpy(&tic->ram.gfx, &tic->cart.gfx, sizeof tic->cart.gfx);
|
// {
|
||||||
memcpy(&tic->ram.sound, &tic->cart.sound, sizeof tic->cart.sound);
|
// memcpy(&tic->ram.gfx, &tic->cart.gfx, sizeof tic->cart.gfx);
|
||||||
}
|
// memcpy(&tic->ram.sound, &tic->cart.sound, sizeof tic->cart.sound);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)
|
static u32 api_btnp(tic_mem* tic, s32 index, s32 hold, s32 period)
|
||||||
|
@ -1589,9 +1593,9 @@ static void api_load(tic_cartridge* cart, const u8* buffer, s32 size, bool palet
|
||||||
|
|
||||||
switch(chunk.type)
|
switch(chunk.type)
|
||||||
{
|
{
|
||||||
case CHUNK_TILES: LOAD_CHUNK(cart->gfx.tiles); break;
|
case CHUNK_TILES: LOAD_CHUNK(cart->tiles); break;
|
||||||
case CHUNK_SPRITES: LOAD_CHUNK(cart->gfx.sprites); break;
|
case CHUNK_SPRITES: LOAD_CHUNK(cart->sprites); break;
|
||||||
case CHUNK_MAP: LOAD_CHUNK(cart->gfx.map); break;
|
case CHUNK_MAP: LOAD_CHUNK(cart->map); break;
|
||||||
case CHUNK_CODE: LOAD_CHUNK(cart->code); break;
|
case CHUNK_CODE: LOAD_CHUNK(cart->code); break;
|
||||||
case CHUNK_SOUND: LOAD_CHUNK(cart->sound.sfx.data); break;
|
case CHUNK_SOUND: LOAD_CHUNK(cart->sound.sfx.data); break;
|
||||||
case CHUNK_WAVEFORM: LOAD_CHUNK(cart->sound.sfx.waveform); break;
|
case CHUNK_WAVEFORM: LOAD_CHUNK(cart->sound.sfx.waveform); break;
|
||||||
|
@ -1658,9 +1662,9 @@ static s32 api_save(const tic_cartridge* cart, u8* buffer)
|
||||||
|
|
||||||
#define SAVE_CHUNK(id, from) saveChunk(buffer, id, &from, sizeof(from))
|
#define SAVE_CHUNK(id, from) saveChunk(buffer, id, &from, sizeof(from))
|
||||||
|
|
||||||
buffer = SAVE_CHUNK(CHUNK_TILES, cart->gfx.tiles);
|
buffer = SAVE_CHUNK(CHUNK_TILES, cart->tiles);
|
||||||
buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->gfx.sprites);
|
buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->sprites);
|
||||||
buffer = SAVE_CHUNK(CHUNK_MAP, cart->gfx.map);
|
buffer = SAVE_CHUNK(CHUNK_MAP, cart->map);
|
||||||
buffer = SAVE_CHUNK(CHUNK_CODE, cart->code);
|
buffer = SAVE_CHUNK(CHUNK_CODE, cart->code);
|
||||||
buffer = SAVE_CHUNK(CHUNK_SOUND, cart->sound.sfx.data);
|
buffer = SAVE_CHUNK(CHUNK_SOUND, cart->sound.sfx.data);
|
||||||
buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->sound.sfx.waveform);
|
buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->sound.sfx.waveform);
|
||||||
|
|
40
src/tic.h
40
src/tic.h
|
@ -107,6 +107,8 @@
|
||||||
|
|
||||||
#define TIC_CODE_SIZE (0x10000)
|
#define TIC_CODE_SIZE (0x10000)
|
||||||
|
|
||||||
|
#define TIC_BANKS 4
|
||||||
|
|
||||||
#define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"}
|
#define SFX_NOTES {"C-", "C#", "D-", "D#", "E-", "F-", "F#", "G-", "G#", "A-", "A#", "B-"}
|
||||||
|
|
||||||
#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
|
#define API_KEYWORDS {"TIC", "scanline", "OVR", "print", "cls", "pix", "line", "rect", "rectb", \
|
||||||
|
@ -294,13 +296,6 @@ typedef struct
|
||||||
u8 data[TIC_SPRITESIZE * TIC_SPRITESIZE * TIC_PALETTE_BPP / BITS_IN_BYTE];
|
u8 data[TIC_SPRITESIZE * TIC_SPRITESIZE * TIC_PALETTE_BPP / BITS_IN_BYTE];
|
||||||
} tic_tile;
|
} tic_tile;
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
tic_tile tiles[TIC_BANK_SPRITES];
|
|
||||||
tic_tile sprites[TIC_BANK_SPRITES];
|
|
||||||
tic_map map;
|
|
||||||
} tic_gfx;
|
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char data[TIC_CODE_SIZE];
|
char data[TIC_CODE_SIZE];
|
||||||
|
@ -334,8 +329,33 @@ typedef struct
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
tic_gfx gfx;
|
tic_tile data[TIC_BANK_SPRITES];
|
||||||
|
} tic_tiles;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
tic_tiles tiles;
|
||||||
|
tic_tiles sprites;
|
||||||
|
tic_map map;
|
||||||
|
tic_sfx sfx;
|
||||||
|
tic_music music;
|
||||||
|
} tic_bank;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
tic_tiles tiles;
|
||||||
|
tic_tiles sprites;
|
||||||
|
tic_map map;
|
||||||
tic_sound sound;
|
tic_sound sound;
|
||||||
|
};
|
||||||
|
|
||||||
|
tic_bank banks[TIC_BANKS];
|
||||||
|
};
|
||||||
|
|
||||||
tic_code code;
|
tic_code code;
|
||||||
tic_cover_image cover;
|
tic_cover_image cover;
|
||||||
tic_palette palette;
|
tic_palette palette;
|
||||||
|
@ -405,7 +425,9 @@ typedef union
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
tic_vram vram;
|
tic_vram vram;
|
||||||
tic_gfx gfx;
|
tic_tiles tiles;
|
||||||
|
tic_tiles sprites;
|
||||||
|
tic_map map;
|
||||||
tic_persistent persistent;
|
tic_persistent persistent;
|
||||||
tic_sound_register registers[TIC_SOUND_CHANNELS];
|
tic_sound_register registers[TIC_SOUND_CHANNELS];
|
||||||
tic_sound sound;
|
tic_sound sound;
|
||||||
|
|
12
src/ticapi.h
12
src/ticapi.h
|
@ -77,12 +77,12 @@ typedef struct
|
||||||
void (*line) (tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, u8 color);
|
void (*line) (tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, u8 color);
|
||||||
void (*rect) (tic_mem* memory, s32 x, s32 y, s32 width, s32 height, u8 color);
|
void (*rect) (tic_mem* memory, s32 x, s32 y, s32 width, s32 height, u8 color);
|
||||||
void (*rect_border) (tic_mem* memory, s32 x, s32 y, s32 width, s32 height, u8 color);
|
void (*rect_border) (tic_mem* memory, s32 x, s32 y, s32 width, s32 height, u8 color);
|
||||||
void (*sprite) (tic_mem* memory, const tic_gfx* src, s32 index, s32 x, s32 y, u8* colors, s32 count);
|
void (*sprite) (tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, u8* colors, s32 count);
|
||||||
void (*sprite_ex) (tic_mem* memory, const tic_gfx* src, s32 index, s32 x, s32 y, s32 w, s32 h, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate);
|
void (*sprite_ex) (tic_mem* memory, const tic_tiles* src, s32 index, s32 x, s32 y, s32 w, s32 h, u8* colors, s32 count, s32 scale, tic_flip flip, tic_rotate rotate);
|
||||||
void (*map) (tic_mem* memory, const tic_gfx* src, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale);
|
void (*map) (tic_mem* memory, const tic_map* src, const tic_tiles* tiles, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale);
|
||||||
void (*remap) (tic_mem* memory, const tic_gfx* src, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data);
|
void (*remap) (tic_mem* memory, const tic_map* src, const tic_tiles* tiles, s32 x, s32 y, s32 width, s32 height, s32 sx, s32 sy, u8 chromakey, s32 scale, RemapFunc remap, void* data);
|
||||||
void (*map_set) (tic_mem* memory, tic_gfx* src, s32 x, s32 y, u8 value);
|
void (*map_set) (tic_mem* memory, tic_map* src, s32 x, s32 y, u8 value);
|
||||||
u8 (*map_get) (tic_mem* memory, const tic_gfx* src, s32 x, s32 y);
|
u8 (*map_get) (tic_mem* memory, const tic_map* src, s32 x, s32 y);
|
||||||
void (*circle) (tic_mem* memory, s32 x, s32 y, u32 radius, u8 color);
|
void (*circle) (tic_mem* memory, s32 x, s32 y, u32 radius, u8 color);
|
||||||
void (*circle_border) (tic_mem* memory, s32 x, s32 y, u32 radius, u8 color);
|
void (*circle_border) (tic_mem* memory, s32 x, s32 y, u32 radius, u8 color);
|
||||||
void (*tri) (tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, s32 x3, s32 y3, u8 color);
|
void (*tri) (tic_mem* memory, s32 x1, s32 y1, s32 x2, s32 y2, s32 x3, s32 y3, u8 color);
|
||||||
|
|
|
@ -105,13 +105,13 @@ void initWorld(World* world, tic_mem* tic, Map* map)
|
||||||
|
|
||||||
for(s32 i = 0; i < TIC80_WIDTH * TIC80_HEIGHT; i++)
|
for(s32 i = 0; i < TIC80_WIDTH * TIC80_HEIGHT; i++)
|
||||||
{
|
{
|
||||||
u8 index = tic->cart.gfx.map.data[i];
|
u8 index = tic->cart.map.data[i];
|
||||||
|
|
||||||
if(index)
|
if(index)
|
||||||
{
|
{
|
||||||
SDL_memset(colors, 0, sizeof colors);
|
SDL_memset(colors, 0, sizeof colors);
|
||||||
|
|
||||||
tic_tile* tile = &tic->cart.gfx.tiles[index];
|
tic_tile* tile = &tic->cart.tiles.data[index];
|
||||||
|
|
||||||
for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++)
|
for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue