Allow to load a map of tiles of any length, not only 32kb #412
This commit is contained in:
parent
3e79600b0d
commit
3e183219ab
|
@ -1349,15 +1349,21 @@ static void onImportSprites(const char* name, const void* buffer, size_t size, v
|
||||||
commandDone(console);
|
commandDone(console);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void injectMap(Console* console, const void* buffer, s32 size)
|
||||||
|
{
|
||||||
|
enum {Size = sizeof(tic_map)};
|
||||||
|
|
||||||
|
SDL_memset(&console->tic->cart.gfx.map, 0, Size);
|
||||||
|
SDL_memcpy(&console->tic->cart.gfx.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)
|
||||||
{
|
{
|
||||||
Console* console = (Console*)data;
|
Console* console = (Console*)data;
|
||||||
|
|
||||||
enum {Size = sizeof(tic_map)};
|
if(name && buffer && size <= sizeof(tic_map))
|
||||||
|
|
||||||
if(name && buffer && size == Size)
|
|
||||||
{
|
{
|
||||||
memcpy(&console->tic->cart.gfx.map, buffer, size);
|
injectMap(console, buffer, size);
|
||||||
|
|
||||||
printLine(console);
|
printLine(console);
|
||||||
printBack(console, "map successfully imported");
|
printBack(console, "map successfully imported");
|
||||||
|
@ -2761,9 +2767,9 @@ static void cmdInjectMap(Console* console, const char* param, const char* name)
|
||||||
|
|
||||||
if(map)
|
if(map)
|
||||||
{
|
{
|
||||||
if(size == sizeof(tic_map))
|
if(size <= sizeof(tic_map))
|
||||||
{
|
{
|
||||||
SDL_memcpy(embed.file.gfx.map.data, map, size);
|
injectMap(console, map, size);
|
||||||
|
|
||||||
embed.yes = true;
|
embed.yes = true;
|
||||||
embed.fast = true;
|
embed.fast = true;
|
||||||
|
|
Loading…
Reference in New Issue