Fix a bug in sdl_setPalette()

It called SDL_SetPaletteColors() with wrong arguments when `first` was
not zero. PP command was affected by this.
This commit is contained in:
kichikuou
2022-07-31 13:53:37 +09:00
parent cee18a572e
commit fa44889047
2 changed files with 8 additions and 12 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ extern void sdl_updateAll(MyRectangle *view_rect);
extern void sdl_updateScreen(void);
/* パレット関係 */
extern void sdl_setPalette(Palette256 *pal, int src, int cnt);
extern void sdl_setPalette(Palette256 *pal, int first, int count);
/* 描画関係 */
extern void sdl_drawRectangle(int x, int y, int w, int h, BYTE c);
+7 -11
View File
@@ -118,18 +118,14 @@ void sdl_updateAll(MyRectangle *view_rect) {
}
/* Color の複数個指定 */
void sdl_setPalette(Palette256 *pal, int src, int cnt) {
int i;
for (i = 0; i < cnt; i++) {
sdl_col[src + i].r = pal->red [src + i];
sdl_col[src + i].g = pal->green[src + i];
sdl_col[src + i].b = pal->blue [src + i];
}
if (sdl_dib->format->BitsPerPixel == 8) {
SDL_SetPaletteColors(sdl_dib->format->palette, sdl_col, src, cnt);
void sdl_setPalette(Palette256 *pal, int first, int count) {
for (int i = 0; i < count; i++) {
sdl_col[first + i].r = pal->red [first + i];
sdl_col[first + i].g = pal->green[first + i];
sdl_col[first + i].b = pal->blue [first + i];
}
if (sdl_dib->format->BitsPerPixel == 8)
SDL_SetPaletteColors(sdl_dib->format->palette, &sdl_col[first], first, count);
}
/* 矩形の描画 */