Mercurial > hg > dmlib
diff tools/64vw.c @ 2126:cffadb745484
Fix character ROM data handling.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 27 May 2019 10:47:46 +0300 |
parents | 56d4dc81774b |
children | 903effcd616b |
line wrap: on
line diff
--- a/tools/64vw.c Mon May 27 08:35:35 2019 +0300 +++ b/tools/64vw.c Mon May 27 10:47:46 2019 +0300 @@ -220,6 +220,7 @@ SDL_Surface *surf, const DMC64ImageConvSpec *spec) { DMImage bmap; + BOOL charDataSet; int ret; memset(&bmap, 0, sizeof(bmap)); @@ -232,16 +233,21 @@ if ((ret = dmSetDefaultC64Palette(&bmap)) != DMERR_OK) return ret; - if (cimage->charData->data == NULL) - cimage->charData = &setCharROM; + if (cimage->charData[0].data == NULL) + { + memcpy(&cimage->charData[0], &setCharROM, sizeof(DMC64MemBlock)); + charDataSet = TRUE; + } + else + charDataSet = FALSE; if (fmt->format->convertFrom != NULL) ret = fmt->format->convertFrom(&bmap, cimage, fmt, spec); else ret = dmC64ConvertGenericBMP2Image(&bmap, cimage, fmt, spec); - if (cimage->charData == &setCharROM) - cimage->charData = NULL; + if (charDataSet) + memset(&cimage->charData[0], 0, sizeof(DMC64MemBlock)); SDL_SetPaletteColors(surf->format->palette, (SDL_Color *) bmap.pal->colors, 0, bmap.pal->ncolors); @@ -344,7 +350,8 @@ dmMsg(1, "Using character ROM file '%s'.\n", optCharROMFilename); - if ((ret = dmReadDataFile(NULL, optCharROMFilename, &setCharROM.data, &setCharROM.size)) != DMERR_OK) + if ((ret = dmReadDataFile(NULL, optCharROMFilename, + &setCharROM.data, &setCharROM.size)) != DMERR_OK) { dmErrorMsg("Could not read character ROM from '%s'.\n", optCharROMFilename);