I just wanted to check you lot to ask if you can see anything obviously wrong with this code? I think it has a memory leak but I can't find where!
Code: Select all
int drawMap() {
    int DrawMapStatus = FALSE;
    u16 palette[32];
    int static DrawMapCurrentStage = 0;
    int static ItemTemp = 0;
    int static I = 0;
    int static Y = 0;
    int static X = 0;
    switch(DrawMapCurrentStage) {
    case 0:
        SYS_disableInts();
        VDP_setPalette(PAL0, palette_black);
        VDP_setPalette(PAL1, palette_black);
        SYS_enableInts();
        memcpy(&palette[0], layout_image.palette->data, 16 * 2);
        memcpy(&palette[16], map_tileset.palette->data, 16 * 2);
        strclr(CurrentGame.Global.MessageBoxLineStr1);
        sprintf(CurrentGame.Global.MessageBoxLineStr1, "%s %d", DraculasTombLevelStr, CurrentGame.User.Level);
        strclr(CurrentGame.Global.MessageBoxLineStr2);
        if (CurrentGame.User.Level > 0) {
            ItemTemp = CurrentGame.Global.RoomArray[CurrentGame.User.CurrentRoom];
            CurrentGame.Global.RoomArray[CurrentGame.User.CurrentRoom] = 1; // YOUR POSITION
            sprintf(CurrentGame.Global.MessageBoxLineStr2, "%s %s", YouLastMovedStr, Directions[CurrentGame.User.Moving]);
        } else {
            sprintf(CurrentGame.Global.MessageBoxLineStr2, "%s", StudyCarefullyStr);
        }
        CurrentGame.Global.TileIndex = TILE_USERINDEX;
        SYS_disableInts();
        
        VDP_loadTileSet(map_tileset.tileset, CurrentGame.Global.TileIndex, 1);
        CurrentGame.Global.TileIndex += map_tileset.tileset->numTile;
        
        VDP_drawText(CurrentGame.Global.MessageBoxLineStr1, 7, 2);
        VDP_drawText(CurrentGame.Global.MessageBoxLineStr2, 11, 24);
        
        for (X = 0; X <= 21; X++) {
            VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, CurrentGame.Global.TileIndex-10), X+9, 5);
            VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, CurrentGame.Global.TileIndex-10), X+9, 21);
        }
        
        for (Y = 0; Y <= 16; Y++) {             
            VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, CurrentGame.Global.TileIndex-10), 9, Y+5);
            VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, CurrentGame.Global.TileIndex-10), 30, Y+5);
        }
        
        if (CurrentGame.User.CurrentRoom == 0) {
            VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, CurrentGame.Global.TileIndex-3), 19, 21);
        }
        
        VDP_fadeIn(0, (2 * 16) - 1, palette, 30, FALSE);
        
        SYS_enableInts();
        
        strclr(CurrentGame.Global.MessageBoxLineStr1);
        
        strclr(CurrentGame.Global.MessageBoxLineStr2);
        Y = 20;
        X = 29;
        DrawMapCurrentStage = 1;
        break;
    case 1:
        if (Y >= 6) {
            if (X >= 10) {
                SYS_disableInts();
                VDP_setTileMapXY(PLAN_B, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, mapItemLookupInt(CurrentGame.Global.RoomArray[I])), X, Y);
                SYS_enableInts();
                X--;
                I++;
            } else {
                X = 29;
                Y--;
            }
        } else {
            Y = 20;
            X = 29;
            I = 0;
            CurrentGame.Global.RoomArray[CurrentGame.User.CurrentRoom] = ItemTemp;
            DrawMapCurrentStage = 2;
        }
        break;
    case 2:
        if (pause(MAP_TIMER) == TRUE) {
            DrawMapCurrentStage = 0;
            DrawMapStatus = TRUE;
            SYS_enableInts();
            VDP_fadeOut(0, (2 * 16) - 1, 30, FALSE);
            VDP_clearPlan(PLAN_B, 1);
            SYS_enableInts();
        }
        break;
    }
    return DrawMapStatus;
}

 How would I go about checking? Strclr in the SGDK seems to just assign a zero to position 0 in the array.
 How would I go about checking? Strclr in the SGDK seems to just assign a zero to position 0 in the array. Would there be a better one? In Gens the tile addresses I use range from 0x002E to 0x0271.
 Would there be a better one? In Gens the tile addresses I use range from 0x002E to 0x0271.
 They don't all even need to be 360 degrees, some could be 270.
 They don't all even need to be 360 degrees, some could be 270.