Skip to content

Commit

Permalink
Pair of CopInsT to store 32-bit pointers (backported from 3f01af7)
Browse files Browse the repository at this point in the history
* Introduce CopInsPairT to express 32-bit pointer stores.
* multipipe: put all cop insns per line into single structure
* prisms: similar trick as for multipipe
* Fix effects in intro directory.
  • Loading branch information
cahirwpz committed Dec 16, 2023
1 parent 963eb7b commit bc7ca92
Show file tree
Hide file tree
Showing 53 changed files with 259 additions and 235 deletions.
6 changes: 3 additions & 3 deletions effects/anim-polygons/anim-polygons.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#define DEPTH 4

static BitmapT *screen;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static CopListT *cp;
static short active = 0;
static short maybeSkipFrame = 0;
Expand All @@ -27,7 +27,7 @@ static short current_frame = 0;

static void MakeCopperList(CopListT *cp) {
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen, DEPTH);
bplptr = CopSetupBitplanes(cp, screen, DEPTH);
{
short *pixels = gradient.pixels;
short i, j;
Expand Down Expand Up @@ -127,7 +127,7 @@ static void Render(void) {
while (--n >= 0) {
short i = mod16(active + n + 1 - DEPTH, DEPTH + 1);
if (i < 0) i += DEPTH + 1;
CopInsSet32(bplptr[n], screen->planes[i]);
CopInsSet32(&bplptr[n], screen->planes[i]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions effects/anim/anim.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define DEPTH 4

static BitmapT *screen;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static CopListT *cp;
static short active = 0;

Expand Down Expand Up @@ -43,7 +43,7 @@ static void Init(void) {

cp = NewCopList(100);
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen, DEPTH);
bplptr = CopSetupBitplanes(cp, screen, DEPTH);
CopEnd(cp);

CopListActivate(cp);
Expand Down Expand Up @@ -100,7 +100,7 @@ static void Render(void) {
short i = (active + n + 1 - DEPTH) % (DEPTH + 1);
if (i < 0)
i += DEPTH + 1;
CopInsSet32(bplptr[n], screen->planes[i]);
CopInsSet32(&bplptr[n], screen->planes[i]);
}
}

Expand Down
14 changes: 7 additions & 7 deletions effects/ball/ball.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static PixmapT *chunky;
static BitmapT *bitmap;
static SprDataT *sprdat;
static SpriteT sprite[2][8];
static CopInsT *sprptr[8];
static CopInsPairT *sprptr;

#include "data/dragon-bg.c"
#include "data/texture-15.c"
Expand Down Expand Up @@ -81,15 +81,15 @@ static void MakeUVMapRenderCode(void) {

static void MakeCopperList(CopListT *cp) {
CopInit(cp);
CopSetupBitplanes(cp, NULL, &background, S_DEPTH);
CopSetupSprites(cp, sprptr);
CopSetupBitplanes(cp, &background, S_DEPTH);
sprptr = CopSetupSprites(cp);
CopEnd(cp);

{
short i;

for (i = 0; i < 8; i++)
CopInsSetSprite(sprptr[i], &sprite[active][i]);
CopInsSetSprite(&sprptr[i], &sprite[active][i]);
}
}

Expand Down Expand Up @@ -308,7 +308,7 @@ static void BitmapToSprite(BitmapT *input, SpriteT sprite[8]) {
static void PositionSprite(SpriteT sprite[8], short xo, short yo) {
short x = X((S_WIDTH - WIDTH) / 2) + xo;
short y = Y((S_HEIGHT - HEIGHT) / 2) + yo;
CopInsT **ptr = sprptr;
CopInsPairT *ptr = sprptr;
short n = 4;

while (--n >= 0) {
Expand All @@ -318,8 +318,8 @@ static void PositionSprite(SpriteT sprite[8], short xo, short yo) {
SpriteUpdatePos(spr0, x, y);
SpriteUpdatePos(spr1, x, y);

CopInsSetSprite(*ptr++, spr0);
CopInsSetSprite(*ptr++, spr1);
CopInsSetSprite(ptr++, spr0);
CopInsSetSprite(ptr++, spr1);

x += 16;
}
Expand Down
16 changes: 10 additions & 6 deletions effects/blurred/blurred.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static u_short active = 0;

static BitmapT *carry;
static BitmapT *buffer;
static CopInsT *bplptr[2][DEPTH];
static CopInsPairT *bplptr[2];
static CopListT *cp;

#include "data/blurred-pal-1.c"
Expand All @@ -39,16 +39,20 @@ static void MakeCopperList(CopListT *cp) {
short i;

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

Expand Down Expand Up @@ -132,8 +136,8 @@ static void Render(void) {


ITER(i, 0, DEPTH - 1, {
CopInsSet32(bplptr[0][i], screen[active]->planes[i]);
CopInsSet32(bplptr[1][i], screen[active]->planes[i] - WIDTH / 16);
CopInsSet32(&bplptr[0][i], screen[active]->planes[i]);
CopInsSet32(&bplptr[1][i], screen[active]->planes[i] - WIDTH / 16);
});

TaskWaitVBlank();
Expand Down
6 changes: 3 additions & 3 deletions effects/blurred3d/blurred3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

static Object3D *cube;
static CopListT *cp;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static BitmapT *screen0, *screen1;
static BitmapT *scratchpad;
static BitmapT *carry;
Expand All @@ -36,7 +36,7 @@ static void UnLoad(void) {

static void MakeCopperList(CopListT *cp) {
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen0, DEPTH);
bplptr = CopSetupBitplanes(cp, screen0, DEPTH);

{
short *pixels = gradient.pixels;
Expand Down Expand Up @@ -488,7 +488,7 @@ static void Render(void) {
short n = DEPTH;

while (--n >= 0)
CopInsSet32(bplptr[n], screen0->planes[n]);
CopInsSet32(&bplptr[n], screen0->planes[n]);
}

TaskWaitVBlank();
Expand Down
4 changes: 2 additions & 2 deletions effects/bobs3d/bobs3d.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
static Object3D *cube;
static CopListT *cp;
static BitmapT *screen0, *screen1;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;

#include "data/flares32.c"
#include "data/pilka.c"
Expand All @@ -23,7 +23,7 @@ static Mesh3D *mesh = &pilka;
static void MakeCopperList(CopListT *cp) {
CopInit(cp);
CopWait(cp, Y(-1), 0);
CopSetupBitplanes(cp, bplptr, screen1, DEPTH);
bplptr = CopSetupBitplanes(cp, screen1, DEPTH);
CopEnd(cp);
}

Expand Down
12 changes: 6 additions & 6 deletions effects/bumpmap-rgb/bumpmap-rgb.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static u_short *shademap;
static u_short *colormap;
static u_short *chunky[2];
static CopListT *cp;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;

#include "data/dragon.c"
#include "data/light.c"
Expand Down Expand Up @@ -250,10 +250,10 @@ static void ChunkyToPlanar(void) {
break;

case 12:
CopInsSet32(bplptr[0], bpl[3]);
CopInsSet32(bplptr[1], bpl[2]);
CopInsSet32(bplptr[2], bpl[1]);
CopInsSet32(bplptr[3], bpl[0]);
CopInsSet32(&bplptr[0], bpl[3]);
CopInsSet32(&bplptr[1], bpl[2]);
CopInsSet32(&bplptr[2], bpl[1]);
CopInsSet32(&bplptr[3], bpl[0]);
break;

default:
Expand All @@ -269,7 +269,7 @@ static void MakeCopperList(CopListT *cp) {
short i;

CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen[active], DEPTH);
bplptr = CopSetupBitplanes(cp, screen[active], DEPTH);
CopLoadColor(cp, 0, 15, 0);
for (i = 0; i < HEIGHT * 4; i++) {
CopWaitSafe(cp, Y(i), 0);
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 @@ -106,7 +106,7 @@ static void MakeBallCopperList(BallCopListT *ballCp) {
CopInit(cp);
CopMove16(cp, dmacon, DMAF_SETCLR | DMAF_RASTER);
CopLoadPal(cp, &testscreen_pal, 0);
CopSetupBitplanes(cp, NULL, &testscreen, testscreen.depth);
CopSetupBitplanes(cp, &testscreen, testscreen.depth);

ballCp->upperBallCopper = cp->curr;
InitCopperListBall(cp, Y0 + 2, 2);
Expand Down
2 changes: 1 addition & 1 deletion effects/circles/circles.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ static void Init(void) {
SetColor(1, 0xfff);

CopInit(cp);
CopSetupBitplanes(cp, NULL, screen, DEPTH);
CopSetupBitplanes(cp, screen, DEPTH);
CopEnd(cp);

CopListActivate(cp);
Expand Down
2 changes: 1 addition & 1 deletion effects/credits/credits.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ static void MakeCopperList(CopListT *cp) {
CopWaitSafe(cp, DISCO_Y - 1, 0);
CopLoadPal(cp, &disco_pal, 0);
CopSetupMode(cp, MODE_LORES, disco.depth);
CopSetupBitplanes(cp, NULL, &disco, disco.depth);
CopSetupBitplanes(cp, &disco, disco.depth);
CopSetupBitplaneFetch(cp, MODE_LORES, DISCO_X, disco.width);

CopWaitSafe(cp, DISCO_Y, 0);
Expand Down
4 changes: 2 additions & 2 deletions effects/flatshade-convex/flatshade-convex.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

static Object3D *cube;
static CopListT *cp;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static BitmapT *screen[2];
static short active;

Expand Down Expand Up @@ -42,7 +42,7 @@ static void Init(void) {

cp = NewCopList(80);
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen[0], DEPTH);
bplptr = CopSetupBitplanes(cp, screen[0], DEPTH);
CopEnd(cp);
CopListActivate(cp);
EnableDMA(DMAF_BLITTER | DMAF_RASTER | DMAF_BLITHOG);
Expand Down
4 changes: 2 additions & 2 deletions effects/flatshade/flatshade.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

static Object3D *cube;
static CopListT *cp;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static BitmapT *screen0, *screen1;
static BitmapT *buffer;

Expand Down Expand Up @@ -40,7 +40,7 @@ static void Init(void) {

cp = NewCopList(80);
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen0, DEPTH);
bplptr = CopSetupBitplanes(cp, screen0, DEPTH);
CopEnd(cp);
CopListActivate(cp);
EnableDMA(DMAF_BLITTER | DMAF_RASTER | DMAF_BLITHOG);
Expand Down
2 changes: 1 addition & 1 deletion effects/floor-old/floor-old.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ static void MakeCopperList(CopListT *cp, short num) {
short i, j;

CopInit(cp);
CopSetupBitplanes(cp, NULL, screen[num], DEPTH);
CopSetupBitplanes(cp, screen[num], DEPTH);
CopLoadColor(cp, 0, 3, 0);

for (i = 0; i < FAR_Y; i++) {
Expand Down
2 changes: 1 addition & 1 deletion effects/floor/floor.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void MakeCopperList(CopListT *cp, short n) {
short i;

CopInit(cp);
CopSetupBitplanes(cp, NULL, &floor, DEPTH);
CopSetupBitplanes(cp, &floor, DEPTH);

for (i = 0; i < HEIGHT; i++) {
CopWait(cp, Y(i), 0);
Expand Down
19 changes: 9 additions & 10 deletions effects/game-of-life/game-of-life.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ static BitmapT *current_board;
static BitmapT *boards[BOARD_COUNT];

// pointers to copper instructions, for rewriting bitplane pointers
static CopInsT *bplptr[DISP_DEPTH];
static CopInsPairT *bplptr;

// pointers to copper instructions, for setting colors
static CopInsT *palptr[COLORS];
static CopInsT *palptr;

// circular buffer of previous game states as they would be rendered (with
// horizontally doubled pixels)
Expand Down Expand Up @@ -305,25 +305,24 @@ static void ChangePalette(const u_short* pal) {
{
u_short next_i = i << 1;
for (j = i; j < next_i; j++)
CopInsSet16(palptr[j], *pal);
CopInsSet16(&palptr[j], *pal);
i = next_i;
pal++;
}
}

static void MakeCopperList(CopListT *cp) {
u_short i;
u_short* color = palette.colors;
short i;

CopInit(cp);
// initially previous states are empty
// save addresses of these instructions to change bitplane
// order when new state gets generated
for (i = 0; i < DISP_DEPTH; i++)
bplptr[i] = CopMove32(cp, bplpt[i], prev_states[i]->planes[0]);
bplptr = CopInsPtr(cp);
for (i = 0; i < DISP_DEPTH; i++)
CopMove32(cp, bplpt[i], prev_states[i]->planes[0]);

for (i = 0; i < COLORS; i++)
palptr[i] = CopSetColor(cp, i, *color++);
palptr = CopLoadPal(cp, &palette, 0);

for (i = 1; i <= DISP_HEIGHT; i += 2) {
// vertical pixel doubling
Expand All @@ -347,7 +346,7 @@ static void UpdateBitplanePointers(void) {
// state) to newest game state, so 0th bitplane displays the oldest+1 state
// and (PREV_STATES_DEPTH-1)'th bitplane displays the newest state
cur = prev_states[(states_head + i + 1) % PREV_STATES_DEPTH];
CopInsSet32(bplptr[i - 1], cur->planes[0]);
CopInsSet32(&bplptr[i - 1], cur->planes[0]);
}
}

Expand Down
6 changes: 3 additions & 3 deletions effects/glitch/glitch.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

static BitmapT *screen[2];
static short active = 0;
static CopInsT *bplptr[DEPTH];
static CopInsPairT *bplptr;
static CopListT *cp;
static CopInsT *line[HEIGHT];

Expand Down Expand Up @@ -65,7 +65,7 @@ static void Init(void) {

cp = NewCopList(100 + HEIGHT * 2);
CopInit(cp);
CopSetupBitplanes(cp, bplptr, screen[active], DEPTH);
bplptr = CopSetupBitplanes(cp, screen[active], DEPTH);
for (i = 0; i < HEIGHT; i++) {
CopWait(cp, Y(YSTART + i), 0);
/* Alternating shift by one for bitplane data. */
Expand Down Expand Up @@ -128,7 +128,7 @@ static void Render(void) {

ProfilerStop(RenderGlitch);

ITER(i, 0, DEPTH - 1, CopInsSet32(bplptr[i], screen[active]->planes[i]));
ITER(i, 0, DEPTH - 1, CopInsSet32(&bplptr[i], screen[active]->planes[i]));
TaskWaitVBlank();
active ^= 1;
}
Expand Down
Loading

0 comments on commit bc7ca92

Please sign in to comment.