Skip to content

Commit

Permalink
Clean up PaletteT interface and use cases (backported from 6498094)
Browse files Browse the repository at this point in the history
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent 445c236 commit feb97ba
Show file tree
Hide file tree
Showing 71 changed files with 176 additions and 198 deletions.
1 change: 1 addition & 0 deletions effects/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ SUBDIRS := \
tilezoomer \
transparency \
twister-rgb \
turmite \
uvlight \
uvmap \
uvmap-rgb \
Expand Down
2 changes: 1 addition & 1 deletion effects/anim/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TOPDIR := $(realpath ../..)

CLEAN-FILES := data/running.c data/running-pal.c

PNG2C.running-pal := --palette running_pal,16
PNG2C.running-pal := --palette running,16

include $(TOPDIR)/build/effect.mk

Expand Down
2 changes: 1 addition & 1 deletion effects/anim/anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static void Init(void) {
BitmapClear(screen);

SetupPlayfield(MODE_LORES, DEPTH, X(0), Y(0), WIDTH, HEIGHT);
LoadPalette(&running_pal, 0);
LoadColors(running_colors, 0);

cp = NewCopList(100);
bplptr = CopSetupBitplanes(cp, screen, DEPTH);
Expand Down
4 changes: 2 additions & 2 deletions effects/ball/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ TOPDIR := $(realpath ../..)

CLEAN-FILES := data/dragon-bg.c data/texture-15.c data/ball.c

PNG2C.dragon-bg := --bitmap background,320x256x4 --palette background_pal,16
PNG2C.texture-15 := --pixmap texture,128x128x4 --palette texture_pal,16
PNG2C.dragon-bg := --bitmap background,320x256x4 --palette background,16
PNG2C.texture-15 := --pixmap texture,128x128x4 --palette texture,16

include $(TOPDIR)/build/effect.mk

Expand Down
4 changes: 2 additions & 2 deletions effects/ball/ball.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ static void Init(void) {
}

SetupPlayfield(MODE_LORES, S_DEPTH, X(0), Y(0), S_WIDTH, S_HEIGHT);
LoadPalette(&background_pal, 0);
LoadPalette(&texture_pal, 16);
LoadColors(background_colors, 0);
LoadColors(texture_colors, 16);

cp[0] = MakeCopperList(0);
cp[1] = MakeCopperList(1);
Expand Down
4 changes: 2 additions & 2 deletions effects/blurred/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TOPDIR := $(realpath ../..)
CLEAN-FILES := data/blurred-pal-1.c data/blurred-pal-2.c data/blurred-clip.c

PNG2C.blurred-clip := --bitmap clip,160x128x4
PNG2C.blurred-pal-1 := --palette blurred_1_pal,32
PNG2C.blurred-pal-2 := --palette blurred_2_pal,32
PNG2C.blurred-pal-1 := --palette blurred_1,32
PNG2C.blurred-pal-2 := --palette blurred_2,32

include $(TOPDIR)/build/effect.mk
13 changes: 5 additions & 8 deletions effects/blurred/blurred.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,15 @@ static CopListT *MakeCopperList(void) {

bplptr[0] = CopSetupBitplanes(cp, screen[active], DEPTH);
CopWait(cp, Y(-18), 0);
CopLoadPal(cp, &blurred_1_pal, 0);
CopLoadColors(cp, blurred_1_colors, 0);
CopWait(cp, Y(127), 0);
CopMove16(cp, dmacon, DMAF_RASTER);
CopLoadPal(cp, &blurred_2_pal, 0);
CopLoadColors(cp, blurred_2_colors, 0);
CopWait(cp, Y(128), 0);
CopMove16(cp, dmacon, DMAF_SETCLR | DMAF_RASTER);
for (i = 0; i < DEPTH; i++) {
CopInsPairT *ins =
CopMove32(cp, bplpt[i], screen[0]->planes[i] - WIDTH / 16);
if (bplptr[1])
bplptr[1] = ins;
}
bplptr[1] = CopInsPtr(cp);
for (i = 0; i < DEPTH; i++)
CopMove32(cp, bplpt[i], screen[0]->planes[i] - WIDTH / 16);
return CopListFinish(cp);
}

Expand Down
2 changes: 1 addition & 1 deletion effects/bobs3d/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CLEAN-FILES := data/flares32.c data/pilka.c data/potato.c

LIBS := lib3d

PNG2C.flares32 := --bitmap bobs,512x32x3,+interleaved --palette bobs_pal,8
PNG2C.flares32 := --bitmap bobs,512x32x3,+interleaved --palette bobs,8
LWO2C.pilka := --scale 50.0

include $(TOPDIR)/build/effect.mk
2 changes: 1 addition & 1 deletion effects/bobs3d/bobs3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static void Init(void) {
screen[1] = NewBitmap(WIDTH, HEIGHT, DEPTH, BM_CLEAR|BM_INTERLEAVED);

SetupPlayfield(MODE_LORES, DEPTH, X(32), Y(0), WIDTH, HEIGHT);
LoadPalette(&bobs_pal, 0);
LoadColors(bobs_colors, 0);

cp = MakeCopperList();
CopListActivate(cp);
Expand Down
2 changes: 1 addition & 1 deletion effects/bumpmap-rgb/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TOPDIR := $(realpath ../..)

CLEAN-FILES := data/bumpmap.c data/light.c data/dragon.c

PNG2C.dragon := --pixmap dragon,80x64x8 --palette dragon_pal,97
PNG2C.dragon := --pixmap dragon,80x64x8 --palette dragon,97

include $(TOPDIR)/build/effect.mk

Expand Down
8 changes: 4 additions & 4 deletions effects/bumpmap-rgb/bumpmap-rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ static void Load(void) {
*dst++ = *src++ << 6;
}

shademap = MemAlloc(32 * sizeof(u_short) * dragon_pal.count, MEMF_PUBLIC);
shademap = MemAlloc(32 * sizeof(u_short) * dragon_colors_count, MEMF_PUBLIC);
{
u_short *cp = dragon_pal.colors;
const u_short *cp = dragon_colors;
u_short *dst = shademap;
short n = dragon_pal.count;
short n = dragon_colors_count;
short i;

/*
Expand All @@ -120,7 +120,7 @@ static void Load(void) {
}
}

DataScramble(shademap, dragon_pal.count * 32);
DataScramble(shademap, dragon_colors_count * 32);

{
short n = WIDTH * HEIGHT;
Expand Down
4 changes: 2 additions & 2 deletions effects/butterfly-gears/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ CLEAN-FILES := \
data/texture_butterfly2.c \
data/textureloop-generated.asm

PNG2C.gears_testscreen := --bitmap testscreen,320x280x5 --palette testscreen_pal,32,+store_unused
PNG2C.gears_testscreen_debug := --bitmap testscreen,320x280x5 --palette testscreen_pal,32,+store_unused
PNG2C.gears_testscreen := --bitmap testscreen,320x280x5 --palette testscreen,32,+store_unused
PNG2C.gears_testscreen_debug := --bitmap testscreen,320x280x5 --palette testscreen,32,+store_unused
PNG2C.texture_butterfly := --pixmap texture_butterfly,128x128x12
PNG2C.texture_butterfly2 := --pixmap texture_butterfly2,128x128x12

Expand Down
2 changes: 1 addition & 1 deletion effects/butterfly-gears/butterfly-gears.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static void InitCopperListBall(CopListT *cp, int y, int yInc) {
static void MakeBallCopperList(BallCopListT *ballCp) {
CopListT *cp = NewCopList(INSTRUCTIONS_PER_BALL * 2 + 100);
CopMove16(cp, dmacon, DMAF_SETCLR | DMAF_RASTER);
CopLoadPal(cp, &testscreen_pal, 0);
CopLoadColors(cp, testscreen_colors, 0);
CopSetupBitplanes(cp, &testscreen, testscreen.depth);

ballCp->upperBallCopper = cp->curr;
Expand Down
10 changes: 5 additions & 5 deletions effects/credits/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ CLEAN-FILES := \
data/txt_jazz.c \
data/txt_slay.c

PNG2C.credits_logo := --bitmap logo,256x64x4 --palette logo_pal,16
PNG2C.discoball := --bitmap disco,64x64x4 --palette disco_pal,15
PNG2C.floor := --bitmap floor,288x112x3 --palette floor_pal,8
PNG2C.01_cahir := --bitmap cahir,160x112x3 --palette dance_pal,8
PNG2C.credits_logo := --bitmap logo,256x64x4 --palette logo,16
PNG2C.discoball := --bitmap disco,64x64x4 --palette disco,15
PNG2C.floor := --bitmap floor,288x112x3 --palette floor,8
PNG2C.01_cahir := --bitmap cahir,160x112x3 --palette dance,8
PNG2C.02_slayer := --bitmap slayer,160x112x3
PNG2C.03_jazzcat := --bitmap jazzcat,160x112x3
PNG2C.04_dkl := --bitmap dkl,160x112x3
PNG2C.05_dance1 := --bitmap dance1,160x112x3
PNG2C.06_dance2 := --bitmap dance2,160x112x3
PNG2C.07_dance3 := --bitmap dance3,160x112x3
PNG2C.08_dance4 := --bitmap dance4,160x112x3
PNG2C.txt_cahir := --bitmap txt_cahir,128x64x4 --palette member_pal,15
PNG2C.txt_cahir := --bitmap txt_cahir,128x64x4 --palette member,15
PNG2C.txt_codi := --bitmap txt_codi,160x64x4
PNG2C.txt_dkl := --bitmap txt_dkl,192x64x4
PNG2C.txt_jazz := --bitmap txt_jazz,176x64x4
Expand Down
22 changes: 11 additions & 11 deletions effects/credits/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
static BitmapT *foreground;
static CopListT *cp[2];
static const BitmapT *lower;
static const PaletteT *lower_pal;
static u_short *lower_pal;
static Point2D lower_pos;
static Area2D lower_area;
static short active = 0;
Expand Down Expand Up @@ -60,7 +60,7 @@ static void MakeCopperList(CopListT *cp) {

/* Display disco ball. */
CopWaitSafe(cp, DISCO_Y - 1, 0);
CopLoadPal(cp, &disco_pal, 0);
CopLoadColors(cp, disco_colors, 0);
CopSetupMode(cp, MODE_LORES, disco.depth);
CopSetupBitplanes(cp, &disco, disco.depth);
CopSetupBitplaneFetch(cp, MODE_LORES, DISCO_X, disco.width);
Expand All @@ -72,8 +72,8 @@ static void MakeCopperList(CopListT *cp) {

/* Display logo & credits. */
CopWaitSafe(cp, FLOOR_Y - 1, 0);
CopLoadPal(cp, &floor_pal, 0);
CopLoadPal(cp, &dance_pal, 8);
CopLoadColors(cp, floor_colors, 0);
CopLoadColors(cp, dance_colors, 8);
CopSetupMode(cp, MODE_DUALPF, 6);
{
void **planes0 = floor.planes;
Expand Down Expand Up @@ -102,7 +102,7 @@ static void MakeCopperList(CopListT *cp) {
* I found 'X(56) / 2' to be the least working horizontal position,
* but I cannot provide any sound explanation why is it so? */
CopWaitSafe(cp, LOGO_Y - 1, X(56) / 2);
CopLoadPal(cp, lower_pal, 0);
CopLoadColorArray(cp, lower_pal, logo_colors_count, 0);
CopSetupMode(cp, MODE_LORES, lower->depth);
CopSetupBitplaneArea(cp, MODE_LORES, lower->depth,
lower, X(lower_pos.x), Y(lower_pos.y), &lower_area);
Expand Down Expand Up @@ -141,27 +141,27 @@ static void Render(void) {
if (frameCount > 600) {
short i = div16(frameCount - 250, 8) & 3;
lower = &logo;
lower_pal = &logo_pal;
lower_pal = logo_colors;
BitmapCopy(foreground, 80, 0, dance[i + 4]);
} else if (frameCount > 500) {
lower = member[4];
lower_pal = &member_pal;
lower_pal = member_colors;
BitmapCopy(foreground, 80, 0, dance[4]);
} else if (frameCount > 400) {
lower = member[3];
lower_pal = &member_pal;
lower_pal = member_colors;
BitmapCopy(foreground, 80, 0, dance[3]);
} else if (frameCount > 300) {
lower = member[2];
lower_pal = &member_pal;
lower_pal = member_colors;
BitmapCopy(foreground, 80, 0, dance[2]);
} else if (frameCount > 200) {
lower = member[1];
lower_pal = &member_pal;
lower_pal = member_colors;
BitmapCopy(foreground, 80, 0, dance[1]);
} else if (frameCount > 100) {
lower = member[0];
lower_pal = &member_pal;
lower_pal = member_colors;
BitmapCopy(foreground, 80, 0, dance[0]);
} else {
lower = NULL;
Expand Down
2 changes: 1 addition & 1 deletion effects/flatshade-convex/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CLEAN-FILES := data/flatshade-pal.c data/ball.c data/pilka.c

LIBS := lib3d

PNG2C.flatshade-pal := --palette flatshade_pal,16
PNG2C.flatshade-pal := --palette flatshade,16
LWO2C.ball := --scale 110.0
LWO2C.pilka := --scale 65.0

Expand Down
2 changes: 1 addition & 1 deletion effects/flatshade-convex/flatshade-convex.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ static void Init(void) {
screen[1] = NewBitmap(WIDTH, HEIGHT, DEPTH, BM_CLEAR);

SetupPlayfield(MODE_LORES, DEPTH, X(32), Y(0), WIDTH, HEIGHT);
LoadPalette(&flatshade_pal, 0);
LoadColors(flatshade_colors, 0);

cp = NewCopList(80);
bplptr = CopSetupBitplanes(cp, screen[0], DEPTH);
Expand Down
2 changes: 1 addition & 1 deletion effects/flatshade/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CLEAN-FILES := data/flatshade-pal.c data/codi.c data/pilka.c

LIBS := lib3d

PNG2C.flatshade-pal := --palette flatshade_pal,16
PNG2C.flatshade-pal := --palette flatshade,16
LWO2C.codi := --scale 488.0
LWO2C.pilka := --scale 65.0

Expand Down
2 changes: 1 addition & 1 deletion effects/flatshade/flatshade.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ static void Init(void) {
buffer = NewBitmap(WIDTH, HEIGHT, 1, 0);

SetupPlayfield(MODE_LORES, DEPTH, X(32), Y(0), WIDTH, HEIGHT);
LoadPalette(&flatshade_pal, 0);
LoadColors(flatshade_colors, 0);

cp = NewCopList(80);
bplptr = CopSetupBitplanes(cp, screen[0], DEPTH);
Expand Down
2 changes: 1 addition & 1 deletion effects/floor/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ TOPDIR := $(realpath ../..)

CLEAN-FILES := data/stripes.c data/floor.c

PNG2C.stripes := --palette stripes_pal,16
PNG2C.stripes := --palette stripes,16
PNG2C.floor := --bitmap floor,336x257x4

include $(TOPDIR)/build/effect.mk
2 changes: 1 addition & 1 deletion effects/floor/floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ static void InitStripes(void) {

while (--n >= 0) {
s->step = -16 * (random() & 7);
s->orig = stripes_pal.colors[random() & 3];
s->orig = stripes_colors[random() & 3];
/* Every stripe starts black */
s->color = 0;
s++;
Expand Down
42 changes: 19 additions & 23 deletions effects/game-of-life/game-of-life.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,27 +117,23 @@ static u_short wireworld_step = 0;

static const GameDefinitionT* current_game;

static PaletteT palette = {
.count = 16,
.colors =
{
0x000, // 0000
0x006, // 0001
0x026, // 0010
0x026, // 0011
0x05B, // 0100
0x05B, // 0101
0x05B, // 0110
0x05B, // 0111
0x09F, // 1000
0x09F, // 1001
0x09F, // 1010
0x09F, // 1011
0x09F, // 1100
0x09F, // 1101
0x09F, // 1110
0x09F, // 1111
},
static const u_short palette_colors[16] = {
0x000, // 0000
0x006, // 0001
0x026, // 0010
0x026, // 0011
0x05B, // 0100
0x05B, // 0101
0x05B, // 0110
0x05B, // 0111
0x09F, // 1000
0x09F, // 1001
0x09F, // 1010
0x09F, // 1011
0x09F, // 1100
0x09F, // 1101
0x09F, // 1110
0x09F, // 1111
};

// Used by CPU to quickly transform 1x1 pixels into 2x1 pixels.
Expand Down Expand Up @@ -322,7 +318,7 @@ static CopListT *MakeCopperList(void) {
for (i = 0; i < DISP_DEPTH; i++)
CopMove32(cp, bplpt[i], prev_states[i]->planes[0]);

palptr = CopLoadPal(cp, &palette, 0);
palptr = CopLoadColors(cp, palette_colors, 0);

for (i = 1; i <= DISP_HEIGHT; i += 2) {
// vertical pixel doubling
Expand Down Expand Up @@ -405,7 +401,7 @@ static void Init(void) {
BitmapCopy(boards[11], EXT_WIDTH_LEFT, EXT_HEIGHT_TOP, &logo);

SetupPlayfield(MODE_LORES, DISP_DEPTH, X(0), Y(0), DISP_WIDTH, DISP_HEIGHT);
LoadPalette(&palette, 0);
LoadColors(palette_colors, 0);
EnableDMA(DMAF_BLITTER);

for (i = 0; i < PREV_STATES_DEPTH; i++) {
Expand Down
2 changes: 1 addition & 1 deletion effects/gui/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LIBS := libgui

PNG2C.toggle_0 := --bitmap toggle_0,16x16x1
PNG2C.toggle_1 := --bitmap toggle_1,16x16x1
PNG2C.pointer := --sprite pointer,16,1 --palette pointer_pal,4
PNG2C.pointer := --sprite pointer,16,1 --palette pointer,4
PSF2C.koi8r.8x8 := --name font --type gui

include $(TOPDIR)/build/effect.mk
2 changes: 1 addition & 1 deletion effects/gui/gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ static void Init(void) {
SetColor(UI_FRAME_OUT, 0xeee);
SetColor(UI_FG_INACTIVE, 0x24a);
SetColor(UI_FG_ACTIVE, 0x46e);
LoadPalette(&pointer_pal, 16);
LoadColors(pointer_colors, 16);

cp = MakeCopperList();
CopListActivate(cp);
Expand Down
10 changes: 5 additions & 5 deletions effects/highway/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ CLEAN-FILES := data/car-left-2.c data/car-right-2.c \
data/lane.c data/sprite.c

PNG2C.lane := --bitmap lane_bg,320x40x4
PNG2C.city-top-2 := --bitmap city_top,320x70x4 --palette city_top_pal,16
PNG2C.city-bottom-2 := --bitmap city_bottom,320x70x4 --palette city_bottom_pal,16
PNG2C.car-left-2 := --bitmap car_left,32x10x4 --palette car_left_pal,16
PNG2C.car-right-2 := --bitmap car_right,32x10x4 --palette car_right_pal,16
PNG2C.sprite := --sprite sprite,24,8 --palette sprite_pal,4
PNG2C.city-top-2 := --bitmap city_top,320x70x4 --palette city_top,16
PNG2C.city-bottom-2 := --bitmap city_bottom,320x70x4 --palette city_bottom,16
PNG2C.car-left-2 := --bitmap car_left,32x10x4 --palette car_left,16
PNG2C.car-right-2 := --bitmap car_right,32x10x4 --palette car_right,16
PNG2C.sprite := --sprite sprite,24,8 --palette sprite,4

include $(TOPDIR)/build/effect.mk
Loading

0 comments on commit feb97ba

Please sign in to comment.