Skip to content

Commit

Permalink
Fix background image bug
Browse files Browse the repository at this point in the history
The bug was caused by a text buffer allocation problem that would, sometimes, cause a memory leak.
Merge pull request #100 from haroldo-ok/fix-background-image-bug
This fixes #89
  • Loading branch information
haroldo-ok committed Jan 9, 2023
2 parents 21d4eb5 + ec709d5 commit 6c281cc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions base/src/vn_engine.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ void VN_init() {

VN_windowDefault();
window.cursor = NULL;
bufferResize(window.w, window.h);

SPR_init(0, 0, 0);

Expand All @@ -209,18 +210,16 @@ void VN_init() {
XGM_setForceDelayDMA(TRUE);

VDP_setTextPalette(TEXT_PAL);
VDP_drawText("choice4genesis v0.13.1", 17, 27);
VDP_drawText("choice4genesis v0.13.2", 17, 27);
}


void VN_showImage(const Image *image, VDPPlane plane, u16 palNum, u16 x, u16 y) {
VDP_loadTileSet(image->tileset, imageInfo.tileNumber, DMA);
TileMap *tmap = unpackTileMap(image->tilemap, NULL);
VDP_setTileMapEx(plane, tmap, TILE_ATTR_FULL(palNum, FALSE, FALSE, FALSE, imageInfo.tileNumber),
x, y, 0, 0, tmap->w, tmap->h, CPU);
VDP_loadTileSet(image->tileset, imageInfo.tileNumber, DMA);
VDP_setTileMapEx(plane, image->tilemap, TILE_ATTR_FULL(palNum, FALSE, FALSE, FALSE, imageInfo.tileNumber),
x, y, 0, 0, image->tilemap->w, image->tilemap->h, CPU);
VDP_setPalette(palNum, (u16*)image->palette->data);
imageInfo.tileNumber += image->tileset->numTile;
free(tmap);
}

void VN_background(const Image *image) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "choice4genesis",
"version": "0.13.1",
"version": "0.13.2",
"description": "A ChoiceScript clone that generates SGDK-compatible C source for the Sega Genesis ",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 6c281cc

Please sign in to comment.