mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-01-22 09:01:57 -05:00
Simplify fallback terrain loading
This commit is contained in:
parent
b45ac6630d
commit
d6c51983ac
4 changed files with 18 additions and 23 deletions
|
@ -7,6 +7,7 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
9A4D0C642BDD168800E1695D /* TouchUI.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A4D0C632BDD168800E1695D /* TouchUI.c */; };
|
||||
9A57ECEE2BCD1408006A89F0 /* AudioBackend.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A57ECED2BCD1408006A89F0 /* AudioBackend.c */; };
|
||||
9A57ECF02BCD1413006A89F0 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = 9A57ECEF2BCD1412006A89F0 /* main.c */; };
|
||||
9A62ADF5286D906F00E5E3DE /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9A62ADF4286D906F00E5E3DE /* Assets.xcassets */; };
|
||||
|
@ -92,6 +93,7 @@
|
|||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
9A4D0C632BDD168800E1695D /* TouchUI.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = TouchUI.c; sourceTree = "<group>"; };
|
||||
9A57ECED2BCD1408006A89F0 /* AudioBackend.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = AudioBackend.c; sourceTree = "<group>"; };
|
||||
9A57ECEF2BCD1412006A89F0 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = main.c; sourceTree = "<group>"; };
|
||||
9A62ADF4286D906F00E5E3DE /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Assets.xcassets; path = ClassiCube/Assets.xcassets; sourceTree = "<group>"; };
|
||||
|
@ -210,6 +212,7 @@
|
|||
9A89D37727F802F500FF3F80 /* src */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9A4D0C632BDD168800E1695D /* TouchUI.c */,
|
||||
9A57ECEF2BCD1412006A89F0 /* main.c */,
|
||||
9A57ECED2BCD1408006A89F0 /* AudioBackend.c */,
|
||||
9A7401DA2B7384060040E575 /* SSL.c */,
|
||||
|
@ -429,6 +432,7 @@
|
|||
9A89D56227F802F600FF3F80 /* _ftbase.c in Sources */,
|
||||
9A89D56B27F802F600FF3F80 /* Server.c in Sources */,
|
||||
9A89D50027F802F600FF3F80 /* _truetype.c in Sources */,
|
||||
9A4D0C642BDD168800E1695D /* TouchUI.c in Sources */,
|
||||
9AC5433E2AE2649F0086C85F /* SystemFonts.c in Sources */,
|
||||
9A89D57F27F802F600FF3F80 /* LWeb.c in Sources */,
|
||||
9A89D56627F802F600FF3F80 /* Drawer2D.c in Sources */,
|
||||
|
|
11
src/Bitmap.c
11
src/Bitmap.c
|
@ -334,7 +334,7 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
|
|||
cc_uint32 i;
|
||||
|
||||
/* idat state */
|
||||
cc_uint32 begY, rowY = 0, endY;
|
||||
cc_uint32 available = 0, rowY = 0;
|
||||
cc_uint8 buffer[PNG_PALETTE * 3];
|
||||
cc_uint32 read, bufferIdx = 0;
|
||||
cc_uint32 left, bufferLen = 0;
|
||||
|
@ -461,19 +461,18 @@ cc_result Png_Decode(struct Bitmap* bmp, struct Stream* stream) {
|
|||
|
||||
if (!bmp->scan0) return PNG_ERR_NO_DATA;
|
||||
if (rowY >= bmp->height) break;
|
||||
|
||||
begY = bufferIdx / scanlineBytes;
|
||||
left = bufferLen - bufferIdx;
|
||||
|
||||
res = compStream.Read(&compStream, &data[bufferIdx], left, &read);
|
||||
res = compStream.Read(&compStream, &data[bufferIdx], left, &read);
|
||||
if (res) return res;
|
||||
if (!read) break;
|
||||
|
||||
available += read;
|
||||
bufferIdx += read;
|
||||
endY = bufferIdx / scanlineBytes;
|
||||
|
||||
/* Process all of the scanline(s) that have been fully decompressed */
|
||||
/* NOTE: Need to check height too, in case IDAT is corrupted and has extra data */
|
||||
for (rowY = begY; rowY < endY && rowY < bmp->height; rowY++) {
|
||||
for (; available >= scanlineBytes && rowY < bmp->height; rowY++, available -= scanlineBytes) {
|
||||
cc_uint8* scanline = &data[rowY * scanlineBytes];
|
||||
if (scanline[0] > PNG_FILTER_PAETH) return PNG_ERR_INVALID_SCANLINE;
|
||||
|
||||
|
|
|
@ -45,26 +45,18 @@ static BitmapCol fallback_terrain[16 * 8] = {
|
|||
};
|
||||
|
||||
static void LoadFallbackAtlas(void) {
|
||||
struct Bitmap bmp;
|
||||
BitmapCol* dst;
|
||||
int x, y;
|
||||
struct Bitmap bmp, src;
|
||||
src.width = 16;
|
||||
src.height = 8;
|
||||
src.scan0 = fallback_terrain;
|
||||
|
||||
if (Gfx.MinTexWidth || Gfx.MinTexHeight) {
|
||||
Bitmap_Allocate(&bmp, 16 * Gfx.MinTexWidth, 8 * Gfx.MinTexHeight);
|
||||
dst = bmp.scan0;
|
||||
|
||||
/* Would be faster if upscaling was done instead, but this code isn't performance sensitive */
|
||||
for (y = 0; y < bmp.height; y++)
|
||||
for (x = 0; x < bmp.width; x++)
|
||||
{
|
||||
*dst++ = fallback_terrain[(y / Gfx.MinTexHeight) * 16 + (x / Gfx.MinTexWidth)];
|
||||
}
|
||||
Bitmap_Scale(&bmp, &src, 0, 0, 16, 8);
|
||||
Atlas_TryChange(&bmp);
|
||||
} else {
|
||||
bmp.width = 16;
|
||||
bmp.height = 8;
|
||||
bmp.scan0 = fallback_terrain;
|
||||
Atlas_TryChange(&src);
|
||||
}
|
||||
Atlas_TryChange(&bmp);
|
||||
}
|
||||
|
||||
/*########################################################################################################################*
|
||||
|
|
|
@ -114,7 +114,7 @@ static void consoleInit(void) {
|
|||
int bgId = bgInitSub(0, BgType_Text4bpp, BgSize_T_256x256, 14, 0);
|
||||
conFontBgMap = (u16*)bgGetMapPtr(bgId);
|
||||
|
||||
consoleLoadFont(u16*)bgGetGfxPtr(bgId));
|
||||
consoleLoadFont((u16*)bgGetGfxPtr(bgId));
|
||||
consoleClear();
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ struct _DisplayData DisplayInfo;
|
|||
struct _WindowData WindowInfo;
|
||||
|
||||
// Console and Keyboard combined need more than 32 kb of H VRAM bank
|
||||
// The simple solution is to allocate the C VRAM bank, but ClassiCube
|
||||
// The simple solution would be to allocate the C VRAM bank, but ClassiCube
|
||||
// needs as much VRAM as it can get for textures
|
||||
// So the solution is to share the H VRAM bank between console and keyboard
|
||||
static void ResetHBank(void) {
|
||||
|
|
Loading…
Reference in a new issue