diff --git a/res/sprite/redsplode.png b/res/sprite/redsplode.png new file mode 100644 index 00000000..d65b0ab0 Binary files /dev/null and b/res/sprite/redsplode.png differ diff --git a/src/dma.c b/src/dma.c index d2404ff9..be9a85c1 100644 --- a/src/dma.c +++ b/src/dma.c @@ -35,7 +35,8 @@ void DMA_init(uint16_t size, uint16_t capacity) if (dmaQueues) MEM_free(dmaQueues); // allocate DMA queue dmaQueues = MEM_alloc(queueSize * sizeof(DMAOpInfo)); - + if (!dmaQueues) SYS_die("Out of memory creating DMA queue!"); + // clear queue DMA_clearQueue(); } diff --git a/src/entity.c b/src/entity.c index c98a1ba1..3c2ed1a3 100644 --- a/src/entity.c +++ b/src/entity.c @@ -817,12 +817,9 @@ Entity *entity_create(int32_t x, int32_t y, uint16_t type, uint16_t flags) { // Allocate memory and start applying values uint8_t sprite_count = npc_info[type].sprite_count; Entity *e = MEM_alloc(sizeof(Entity) + sizeof(VDPSprite) * sprite_count); - if(!e) { - // If the allocation failed, stop with a meaningful message - // instead of leaving the game crash later - SYS_die("Not enough memory to create new entity!"); - } + if(!e) SYS_die("Out of memory creating new entity!"); memset(e, 0, sizeof(Entity) + sizeof(VDPSprite) * sprite_count); + e->x = x; e->y = y; e->sprite_count = sprite_count; diff --git a/src/stage.c b/src/stage.c index c7c4d06f..56da4b7e 100644 --- a/src/stage.c +++ b/src/stage.c @@ -65,7 +65,7 @@ void stage_load(uint16_t id) { VDP_setEnable(FALSE); // Prevents an issue where a column of the previous map would get drawn over the new one - DMA_flushQueue(); + DMA_clearQueue(); input_update(); // Prevent menu from opening after loading save stageID = id; @@ -279,9 +279,11 @@ void stage_load_blocks() { stageHeight = PXM[6] + (PXM[7] << 8); PXM += 8; stageBlocks = MEM_alloc(stageWidth * stageHeight); + if(!stageBlocks) SYS_die("Out of memory loading stage layout!"); memcpy(stageBlocks, PXM, stageWidth * stageHeight); // Multiplication table for stage rows stageTable = MEM_alloc(stageHeight * 2); + if(!stageTable) SYS_die("Out of memory creating stage table!"); uint16_t blockTotal = 0; for(uint16_t y = 0; y < stageHeight; y++) { stageTable[y] = blockTotal;