no message

This commit is contained in:
BADIM-PC\Vadim 2017-12-10 12:55:45 +03:00
parent be7151386d
commit 8f060245df
12 changed files with 89 additions and 104 deletions

View File

@ -357,15 +357,16 @@ static bool onConsoleLoadSectionCommand(Console* console, const char* param)
loadCart(console->tic, cart, data, size, true); loadCart(console->tic, cart, data, size, true);
tic_mem* tic = console->tic; tic_mem* tic = console->tic;
// TODO: should load to the currena bank
switch(i) switch(i)
{ {
case 0: memcpy(&tic->cart.tiles, &cart->tiles, sizeof cart->tiles + sizeof cart->sprites); break; case 0: memcpy(&tic->cart.banks[0].tiles, &cart->banks[0].tiles, sizeof(tic_tiles)*2); break;
case 1: memcpy(&tic->cart.map, &cart->map, sizeof cart->map); break; case 1: memcpy(&tic->cart.banks[0].map, &cart->banks[0].map, sizeof(tic_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.sfx, &cart->sfx, sizeof cart->sfx); break; case 4: memcpy(&tic->cart.banks[0].sfx, &cart->banks[0].sfx, sizeof(tic_sfx)); break;
case 5: memcpy(&tic->cart.music, &cart->music, sizeof cart->music); break; case 5: memcpy(&tic->cart.banks[0].music, &cart->banks[0].music, sizeof(tic_music)); break;
case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof cart->palette); break; case 6: memcpy(&tic->cart.palette, &cart->palette, sizeof(tic_palette)); break;
} }
studioRomLoaded(); studioRomLoaded();
@ -602,14 +603,15 @@ static char* saveBinarySection(char* ptr, const char* comment, const char* tag,
typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySection; typedef struct {char* tag; s32 count; s32 offset; s32 size; bool flip;} BinarySection;
static const BinarySection BinarySections[] = static const BinarySection BinarySections[] =
{ {
// TODO: fix banks loading here
{"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, tiles), sizeof(tic_tile), true}, {"TILES", TIC_BANK_SPRITES, offsetof(tic_cartridge, banks->tiles), sizeof(tic_tile), true},
{"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, sprites), sizeof(tic_tile), true}, {"SPRITES", TIC_BANK_SPRITES, offsetof(tic_cartridge, banks->sprites), sizeof(tic_tile), true},
{"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, map), TIC_MAP_WIDTH, true}, {"MAP", TIC_MAP_HEIGHT, offsetof(tic_cartridge, banks->map), TIC_MAP_WIDTH, true},
{"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge, sfx.waveform.envelopes), sizeof(tic_waveform), true}, {"WAVES", ENVELOPES_COUNT, offsetof(tic_cartridge, banks->sfx.waveform.envelopes), sizeof(tic_waveform), true},
{"SFX", SFX_COUNT, offsetof(tic_cartridge, sfx.data), sizeof(tic_sound_effect), true}, {"SFX", SFX_COUNT, offsetof(tic_cartridge, banks->sfx.data), sizeof(tic_sound_effect), true},
{"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, music.patterns), sizeof(tic_track_pattern), true}, {"PATTERNS", MUSIC_PATTERNS, offsetof(tic_cartridge, banks->music.patterns), sizeof(tic_track_pattern), true},
{"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, music.tracks), sizeof(tic_track), true}, {"TRACKS", MUSIC_TRACKS, offsetof(tic_cartridge, banks->music.tracks), sizeof(tic_track), true},
}; };
static s32 saveProject(Console* console, void* buffer, const char* comment) static s32 saveProject(Console* console, void* buffer, const char* comment)
@ -1330,7 +1332,8 @@ 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.tiles.data, x, y, color); // TODO: should be current bank
setSpritePixel(console->tic->cart.banks[0].tiles.data, x, y, color);
} }
gif_close(image); gif_close(image);
@ -1352,8 +1355,9 @@ 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.map, 0, Size); // TODO: should be current bank
SDL_memcpy(&console->tic->cart.map, buffer, SDL_min(size, Size)); SDL_memset(&console->tic->cart.banks[0].map, 0, Size);
SDL_memcpy(&console->tic->cart.banks[0].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 +1457,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.tiles.data, x, y); data[x + y * Width] = getSpritePixel(console->tic->cart.banks[0].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 +1497,7 @@ static void exportMap(Console* console)
if(buffer) if(buffer)
{ {
SDL_memcpy(buffer, console->tic->cart.map.data, Size); SDL_memcpy(buffer, console->tic->cart.banks[0].map.data, Size);
fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console); fsGetFileData(onMapExported, "world.map", buffer, Size, DEFAULT_CHMOD, console);
} }
} }
@ -2764,7 +2768,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.tiles.data, x, y, color); setSpritePixel(embed.file.banks[0].tiles.data, x, y, color);
} }
gif_close(image); gif_close(image);

View File

@ -170,7 +170,7 @@ static void drawDialog(Dialog* dlg)
{ {
u8 chromakey = 14; u8 chromakey = 14;
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); tic->api.sprite_ex(tic, &tic->config.banks[0].tiles, 2, rect.x+6, rect.y-4, 2, 2, &chromakey, 1, 1, tic_no_flip, tic_no_rotate);
} }
{ {

View File

@ -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.map, tx, ty); index = map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].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.tiles, index, x + i, y + j, NULL, 0); map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].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.map, (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.banks[0].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.tiles, (sx+i) + (sy+j) * SHEET_COLS, tx, ty, NULL, 0); map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].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.map, tx, ty); s32 index = map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].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.map, (mx+i)%TIC_MAP_WIDTH, (my+j)%TIC_MAP_HEIGHT, data[i + j * w]); map->tic->api.map_set(map->tic, &map->tic->cart.banks[0].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.tiles, data[i + j * w], mx + i*TIC_SPRITESIZE, my + j*TIC_SPRITESIZE, NULL, 0); map->tic->api.sprite(map->tic, &map->tic->cart.banks[0].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.map, x+i, y+j, (mx+i) + (my+j) * SHEET_COLS); map->tic->api.map_set(map->tic, &map->tic->cart.banks[0].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.map, nx+i, ny+j) != tile) if(map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].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.map, tx, ty)); fillMap(map, tx, ty, map->tic->api.map_get(map->tic, &map->tic->cart.banks[0].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.map, &map->tic->cart.tiles, map->scroll.x / TIC_SPRITESIZE, map->scroll.y / TIC_SPRITESIZE, map->tic->api.map(map->tic, &map->tic->cart.banks[0].map, &map->tic->cart.banks[0].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.map.data[index]; *ptr++ = map->tic->cart.banks[0].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.map.data[index] = 0; map->tic->cart.banks[0].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.map, sizeof tic->cart.map), .history = history_create(&tic->cart.banks[0].map, sizeof(tic_map)),
.event = onStudioEvent, .event = onStudioEvent,
.overlap = overlap, .overlap = overlap,
}; };

View File

@ -124,7 +124,7 @@ static void drawDialog(Menu* menu)
{ {
u8 chromakey = 14; u8 chromakey = 14;
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); tic->api.sprite_ex(tic, &tic->config.banks[0].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.tiles, 8+i, rect.x, rect.y, 1, 1, &chromakey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &tic->config.banks[0].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];

View File

@ -215,7 +215,7 @@ static void drawSwitch(Music* music, s32 x, s32 y, const char* label, s32 value,
static tic_track* getTrack(Music* music) static tic_track* getTrack(Music* music)
{ {
return &music->tic->cart.music.tracks.data[music->track]; return &music->tic->cart.banks[0].music.tracks.data[music->track];
} }
static s32 getRows(Music* music) static s32 getRows(Music* music)
@ -368,7 +368,7 @@ static tic_track_pattern* getPattern(Music* music, s32 channel)
{ {
s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel); s32 patternId = tic_tool_get_pattern_id(getTrack(music), music->tracker.frame, channel);
return patternId ? &music->tic->cart.music.patterns.data[patternId - PATTERN_START] : NULL; return patternId ? &music->tic->cart.banks[0].music.patterns.data[patternId - PATTERN_START] : NULL;
} }
static tic_track_pattern* getChannelPattern(Music* music) static tic_track_pattern* getChannelPattern(Music* music)
@ -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.tiles, music->tracker.patterns[index] ? On : Off, x, y, &color, 1); tic->api.sprite(tic, &tic->config.banks[0].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)
@ -1643,7 +1643,7 @@ void initMusic(Music* music, tic_mem* tic)
}, },
.tab = MUSIC_TRACKER_TAB, .tab = MUSIC_TRACKER_TAB,
.history = history_create(&tic->cart.music, sizeof(tic_music)), .history = history_create(&tic->cart.banks[0].music, sizeof(tic_music)),
.event = onStudioEvent, .event = onStudioEvent,
}; };

View File

@ -106,7 +106,7 @@ static void drawSwitch(Sfx* sfx, s32 x, s32 y, const char* label, s32 value, voi
static tic_sound_effect* getEffect(Sfx* sfx) static tic_sound_effect* getEffect(Sfx* sfx)
{ {
return sfx->tic->cart.sfx.data + sfx->index; return sfx->tic->cart.banks[0].sfx.data + sfx->index;
} }
static void setIndex(Sfx* sfx, s32 delta) static void setIndex(Sfx* sfx, s32 delta)
@ -169,7 +169,7 @@ static void drawLoopPanel(Sfx* sfx, s32 x, s32 y)
static tic_waveform* getWaveformById(Sfx* sfx, s32 i) static tic_waveform* getWaveformById(Sfx* sfx, s32 i)
{ {
return &sfx->tic->cart.sfx.waveform.envelopes[i]; return &sfx->tic->cart.banks[0].sfx.waveform.envelopes[i];
} }
static tic_waveform* getWaveform(Sfx* sfx) static tic_waveform* getWaveform(Sfx* sfx)
@ -1058,8 +1058,8 @@ void initSfx(Sfx* sfx, tic_mem* tic)
.tab = SFX_ENVELOPES_TAB, .tab = SFX_ENVELOPES_TAB,
.history = .history =
{ {
.envelope = history_create(&tic->cart.sfx.data, sizeof tic->cart.sfx.data), .envelope = history_create(&tic->cart.banks[0].sfx.data, sizeof tic->cart.banks[0].sfx.data),
.waveform = history_create(&tic->cart.sfx.waveform, sizeof tic->cart.sfx.waveform), .waveform = history_create(&tic->cart.banks[0].sfx.waveform, sizeof tic->cart.banks[0].sfx.waveform),
}, },
.event = onStudioEvent, .event = onStudioEvent,
}; };

View File

@ -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.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y); return getSpritePixel(sprite->tic->cart.banks[0].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.tiles.data, x, sprite->index >= TIC_BANK_SPRITES ? y + TIC_SPRITESHEET_SIZE: y, color); setSpritePixel(sprite->tic->cart.banks[0].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.tiles, index, x + i, y + j, NULL, 0); sprite->tic->api.sprite(sprite->tic, &sprite->tic->cart.banks[0].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.tiles, TIC_SPRITES * sizeof(tic_tile)), .history = history_create(&tic->cart.banks[0].tiles, TIC_SPRITES * sizeof(tic_tile)),
.event = onStudioEvent, .event = onStudioEvent,
.overlap = overlap, .overlap = overlap,
}; };

View File

@ -278,7 +278,7 @@ static struct
void playSystemSfx(s32 id) void playSystemSfx(s32 id)
{ {
const tic_sound_effect* effect = &studio.tic->config.sfx.data[id]; const tic_sound_effect* effect = &studio.tic->config.banks[0].sfx.data[id];
studio.tic->api.sfx_ex(studio.tic, id, effect->note, effect->octave, -1, 0, MAX_VOLUME, 0); studio.tic->api.sfx_ex(studio.tic, id, effect->note, effect->octave, -1, 0, MAX_VOLUME, 0);
} }
@ -2049,7 +2049,7 @@ static void renderCursor()
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.tiles.data[getConfig()->theme.cursor.sprite].data); blitCursor(studio.tic->config.banks[0].tiles.data[getConfig()->theme.cursor.sprite].data);
} }
static void useSystemPalette() static void useSystemPalette()
@ -2104,12 +2104,12 @@ static void renderStudio()
case TIC_DIALOG_MODE: case TIC_DIALOG_MODE:
case TIC_MENU_MODE: case TIC_MENU_MODE:
case TIC_SURF_MODE: case TIC_SURF_MODE:
sfx = &studio.tic->config.sfx; sfx = &studio.tic->config.banks[0].sfx;
music = &studio.tic->config.music; music = &studio.tic->config.banks[0].music;
break; break;
default: default:
sfx = &studio.tic->cart.sfx; sfx = &studio.tic->cart.banks[0].sfx;
music = &studio.tic->cart.music; music = &studio.tic->cart.banks[0].music;
} }
studio.tic->api.tick_start(studio.tic, sfx, music); studio.tic->api.tick_start(studio.tic, sfx, music);
@ -2283,7 +2283,7 @@ static void initTouchGamepad()
if (!studio.renderer) if (!studio.renderer)
return; return;
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); studio.tic->api.map(studio.tic, &studio.tic->config.banks[0].map, &studio.tic->config.banks[0].tiles, 0, 0, TIC_MAP_SCREEN_WIDTH, TIC_MAP_SCREEN_HEIGHT, 0, 0, -1, 1);
if(!studio.gamepad.texture) if(!studio.gamepad.texture)
{ {
@ -2310,7 +2310,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.sprites.data[i], TIC_SPRITESIZE*(y+1) - x-1)) if(tic_tool_peek4(&studio.tic->config.banks[0].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;
} }
@ -2335,7 +2335,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.tiles.data, i/Scale, j/Scale); u8 color = getSpritePixel(studio.tic->config.banks[0].tiles.data, i/Scale, j/Scale);
pixels[index] = color == ColorKey ? 0 : pal[color]; pixels[index] = color == ColorKey ? 0 : pal[color];
} }

View File

@ -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.tiles, 12, TipX, y+1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &tic->config.banks[0].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.tiles, 13, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &tic->config.banks[0].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.tiles, 15, TipX + SelectWidth, y + 1, 1, 1, &colorkey, 1, 1, tic_no_flip, tic_no_rotate); tic->api.sprite_ex(tic, &tic->config.banks[0].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.tiles, 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.banks[0].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)

View File

@ -1325,12 +1325,12 @@ static void initCover(tic_mem* tic)
static void cart2ram(tic_mem* memory) static void cart2ram(tic_mem* memory)
{ {
memcpy(&memory->ram.tiles, &memory->cart.tiles, sizeof(tic_tiles)); memcpy(&memory->ram.tiles, &memory->cart.banks[0].tiles, sizeof(tic_tiles));
memcpy(&memory->ram.sprites, &memory->cart.sprites, sizeof(tic_tiles)); memcpy(&memory->ram.sprites, &memory->cart.banks[0].sprites, sizeof(tic_tiles));
memcpy(&memory->ram.map, &memory->cart.map, sizeof(tic_tiles)); memcpy(&memory->ram.map, &memory->cart.banks[0].map, sizeof(tic_tiles));
memcpy(&memory->ram.sfx, &memory->cart.sfx, sizeof(tic_sfx)); memcpy(&memory->ram.sfx, &memory->cart.banks[0].sfx, sizeof(tic_sfx));
memcpy(&memory->ram.music, &memory->cart.music, sizeof(tic_music)); memcpy(&memory->ram.music, &memory->cart.banks[0].music, sizeof(tic_music));
initCover(memory); initCover(memory);
} }
@ -1595,14 +1595,14 @@ 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->tiles); break; case CHUNK_TILES: LOAD_CHUNK(cart->banks[0].tiles); break;
case CHUNK_SPRITES: LOAD_CHUNK(cart->sprites); break; case CHUNK_SPRITES: LOAD_CHUNK(cart->banks[0].sprites); break;
case CHUNK_MAP: LOAD_CHUNK(cart->map); break; case CHUNK_MAP: LOAD_CHUNK(cart->banks[0].map); break;
case CHUNK_CODE: LOAD_CHUNK(cart->code); break; case CHUNK_CODE: LOAD_CHUNK(cart->code); break;
case CHUNK_SOUND: LOAD_CHUNK(cart->sfx.data); break; case CHUNK_SOUND: LOAD_CHUNK(cart->banks[0].sfx.data); break;
case CHUNK_WAVEFORM: LOAD_CHUNK(cart->sfx.waveform); break; case CHUNK_WAVEFORM: LOAD_CHUNK(cart->banks[0].sfx.waveform); break;
case CHUNK_MUSIC: LOAD_CHUNK(cart->music.tracks.data); break; case CHUNK_MUSIC: LOAD_CHUNK(cart->banks[0].music.tracks.data); break;
case CHUNK_PATTERNS: LOAD_CHUNK(cart->music.patterns.data); break; case CHUNK_PATTERNS: LOAD_CHUNK(cart->banks[0].music.patterns.data); break;
case CHUNK_PALETTE: case CHUNK_PALETTE:
if(palette) if(palette)
LOAD_CHUNK(cart->palette); LOAD_CHUNK(cart->palette);
@ -1664,14 +1664,14 @@ 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->tiles); buffer = SAVE_CHUNK(CHUNK_TILES, cart->banks[0].tiles);
buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->sprites); buffer = SAVE_CHUNK(CHUNK_SPRITES, cart->banks[0].sprites);
buffer = SAVE_CHUNK(CHUNK_MAP, cart->map); buffer = SAVE_CHUNK(CHUNK_MAP, cart->banks[0].map);
buffer = SAVE_CHUNK(CHUNK_CODE, cart->code); buffer = SAVE_CHUNK(CHUNK_CODE, cart->code);
buffer = SAVE_CHUNK(CHUNK_SOUND, cart->sfx.data); buffer = SAVE_CHUNK(CHUNK_SOUND, cart->banks[0].sfx.data);
buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->sfx.waveform); buffer = SAVE_CHUNK(CHUNK_WAVEFORM, cart->banks[0].sfx.waveform);
buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->music.patterns.data); buffer = SAVE_CHUNK(CHUNK_PATTERNS, cart->banks[0].music.patterns.data);
buffer = SAVE_CHUNK(CHUNK_MUSIC, cart->music.tracks.data); buffer = SAVE_CHUNK(CHUNK_MUSIC, cart->banks[0].music.tracks.data);
buffer = SAVE_CHUNK(CHUNK_PALETTE, cart->palette); buffer = SAVE_CHUNK(CHUNK_PALETTE, cart->palette);
buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size); buffer = saveFixedChunk(buffer, CHUNK_COVER, cart->cover.data, cart->cover.size);

View File

@ -321,12 +321,6 @@ typedef union
u8 data[TIC_PALETTE_SIZE * sizeof(tic_rgb)]; u8 data[TIC_PALETTE_SIZE * sizeof(tic_rgb)];
} tic_palette; } tic_palette;
// typedef struct
// {
// tic_sfx sfx;
// tic_music music;
// } tic_sound;
typedef struct typedef struct
{ {
tic_tile data[TIC_BANK_SPRITES]; tic_tile data[TIC_BANK_SPRITES];
@ -343,20 +337,7 @@ typedef struct
typedef struct typedef struct
{ {
union
{
struct
{
tic_tiles tiles;
tic_tiles sprites;
tic_map map;
tic_sfx sfx;
tic_music music;
};
tic_bank banks[TIC_BANKS]; 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;

View File

@ -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.map.data[i]; u8 index = tic->cart.banks[0].map.data[i];
if(index) if(index)
{ {
SDL_memset(colors, 0, sizeof colors); SDL_memset(colors, 0, sizeof colors);
tic_tile* tile = &tic->cart.tiles.data[index]; tic_tile* tile = &tic->cart.banks[0].tiles.data[index];
for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++) for(s32 p = 0; p < TIC_SPRITESIZE * TIC_SPRITESIZE; p++)
{ {