Skip to content

Commit

Permalink
Merge pull request #3 from patricksurry/sdk2_1-compat
Browse files Browse the repository at this point in the history
[wip] pico-sdk 2.1 compatibility
  • Loading branch information
codaris authored Dec 31, 2024
2 parents c72a8a9 + 3e4bbb1 commit 8dc07c1
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 145 deletions.
20 changes: 7 additions & 13 deletions examples/vga_ants/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int NewCard()
{
// unlinear randomness - cards with low number will be most plentiful
int card = (int)(pow((RandFloat()*0.99f), 1.6f) * CARDTYPES);

// change organization of card order - 3 groups from weakest to strongest cards
card = (card/3) + (card % 3)*10;
return card;
Expand Down Expand Up @@ -163,7 +163,7 @@ char NumBuf[20];
// display state of one player
void DispState1(int player)
{
int i, k;
int i;
sPlayer* p;
p = &Players[player];

Expand Down Expand Up @@ -248,12 +248,8 @@ void DispFlag()
{
int t = ((int)(time_us_64()/200000)) & 3;
int player;
int i, k;
sPlayer* p;
for (player = 0; player < 2; player++)
{
p = &Players[player];

// get castle height
int h = Players[player].par[PAR_CASTLE]; // h is in range 0..100
if (h > CASTLEMAX) h = CASTLEMAX;
Expand Down Expand Up @@ -551,8 +547,6 @@ void WinGame(int player)
EndGame = player;

// prepare castle height
sPlayer* p = &Players[player];

// get castle height
int h = Players[player].par[PAR_CASTLE]; // h is in range 0..100
if (h > CASTLEMAX) h = CASTLEMAX;
Expand Down Expand Up @@ -598,9 +592,9 @@ void WinGame(int player)

// save background
DrawImg(&Save4Canvas, &Canvas, 0, 0, x, y, 128, 32);

// draw image
DrawBlit(&Canvas, &WinCanvas, x, y, player*4*128
DrawBlit(&Canvas, &WinCanvas, x, y, player*4*128
+ (anim>>2)*128, 0, 128, 32, TRANSCOL);
anim++;
if (anim >= 16) anim = 0;
Expand Down Expand Up @@ -716,7 +710,7 @@ void PutCard(int pos, Bool discard)
{
// ruin castle
snd = RuinCastleSnd;
sndlen = sizeof(RuinCastleSnd);
sndlen = sizeof(RuinCastleSnd);
}
break;

Expand Down Expand Up @@ -796,7 +790,7 @@ void PutCard(int pos, Bool discard)
snd = BuildCastleSnd;
sndlen = sizeof(BuildCastleSnd);
break;

// saboteur (enemy stocks -4)
case 16:
p = &Players[Player ^ 1];
Expand Down Expand Up @@ -1003,7 +997,7 @@ int FindCard()
}
}

// enabled card not found - find card for discard
// enabled card not found - find card for discard
// (discard expensive cards, they cannot be use for a long time)
if (foundinx < 0)
{
Expand Down
29 changes: 16 additions & 13 deletions examples/vga_balloons/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,17 +150,20 @@ void VideoInit()
for (j = 0; j < i; j++)
{
spr2 = &BalloonSprites[j+lay*BALLOON_NUM];
if ((spr->x < spr2->x + BALLOONW) &&
(spr->x + BALLOONW > spr2->x) &&

((spr->y < spr2->y + BALLOONH) &&
(spr->y + BALLOONH > spr2->y)) ||

((spr->y < spr2->y + HEIGHT + 2*BALLOONH) &&
(spr->y + BALLOONH > spr2->y + HEIGHT + BALLOONH)) ||

((spr->y + HEIGHT + BALLOONH < spr2->y + BALLOONH) &&
(spr->y + HEIGHT + 2*BALLOONH > spr2->y)))
if (
(
(spr->x < spr2->x + BALLOONW) &&
(spr->x + BALLOONW > spr2->x) &&
(spr->y < spr2->y + BALLOONH) &&
(spr->y + BALLOONH > spr2->y)
) || (
(spr->y < spr2->y + HEIGHT + 2*BALLOONH) &&
(spr->y + BALLOONH > spr2->y + HEIGHT + BALLOONH)
) || (
(spr->y + HEIGHT + BALLOONH < spr2->y + BALLOONH) &&
(spr->y + HEIGHT + 2*BALLOONH > spr2->y)
)
)
break;
}
} while (j < i);
Expand Down Expand Up @@ -233,7 +236,7 @@ int main()
}

if (x > WIDTH - HOTAIRW)
{
{
x = WIDTH - HOTAIRW;
HotairDX[i] = -RandU8MinMax(HOTAIR_MINSPEED, HOTAIR_MAXSPEED);
}
Expand All @@ -247,7 +250,7 @@ int main()
}

if (y > HEIGHT - HOTAIRH)
{
{
y = HEIGHT - HOTAIRH;
HotairDY[i] = -RandU8MinMax(HOTAIR_MINSPEED, HOTAIR_MAXSPEED);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/vga_levelmeter/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void VideoInit()

int main()
{
int i, j, off;
int i, j;
int a, b;

// copy images
Expand Down Expand Up @@ -150,7 +150,7 @@ int main()
{
// membranes update (by sound offset)
int off = (SNDLEN - SoundCnt) % BEATINT;
off = (off < BEATON) ? MEMBOFF : 0;
off = (off < (int)BEATON) ? MEMBOFF : 0;
LayerSetX(MEMB1LAYER, REPRO1X+MEMB1X+off);
LayerSetY(MEMB1LAYER, MEMBY+off);
LayerSetX(MEMB2LAYER, REPRO2X+MEMB2X+off);
Expand Down
5 changes: 2 additions & 3 deletions examples/vga_life/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ void Run()
b = *s++;

// 3 -> new cell
if (b == 3)
if (b == 3)
*d = TILE_FULL;

// 2 -> unchanged
Expand Down Expand Up @@ -343,7 +343,6 @@ void InitSlot()

int main()
{
int i;
char ch;

// copy tiles images to RAM buffer (flash would be too slow)
Expand Down Expand Up @@ -419,7 +418,7 @@ int main()
if (CurY < 0) CurY = MAPH-1;
CurOn(); // set cursor on
break;

// toggle
case ' ':
CurFlip(); // flip cursor
Expand Down
2 changes: 1 addition & 1 deletion examples/vga_lines/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void VideoInit()
*/
int main()
{
int i, j, k, rr, gg, bb;
int i, j, rr, gg, bb;
sLine* line;

// initialize random number generator
Expand Down
5 changes: 2 additions & 3 deletions examples/vga_matrixrain/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ void NewDrop(int i)
int main()
{
int i, x, y;
u8* s;
u8* d;

// initialize random number generator
Expand Down Expand Up @@ -140,10 +139,10 @@ int main()
for (x = 0; x < TEXTW; x++)
{
i = (int)((Off[x] - y)/Len[x]*PALLEN + 0.5f);
if ((i < 0) || (i >= PALLEN))
if ((i < 0) || (i >= (int)PALLEN))
*d = COL_BLACK;
else
*d = Pal[i];
*d = Pal[i];
d += 2;
}
}
Expand Down
8 changes: 2 additions & 6 deletions examples/vga_monoscope/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,8 @@ void MonoList()

// print modes
int i;
sMono* mono;
for (i = 0; i < MONO_NUM; i++)
for (i = 0; i < (int)MONO_NUM; i++)
{
mono = &Mono[i];

// prepare videomode configuration
MonoCfg(i);

Expand Down Expand Up @@ -239,7 +236,7 @@ void MonoList()
int vert = (int)(k/Vmode.htot/Vmode.vtot + 0.5f); // vertical frequency
printf("%4u |", vert);

// system frequency
// system frequency
printf("%7u", Vmode.freq);

// current videomode
Expand All @@ -258,7 +255,6 @@ void MonoList()
int main()
{
char c;
int i;

// run VGA core
StartVgaCore();
Expand Down
11 changes: 5 additions & 6 deletions examples/vga_pacman/src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void DispStatus()
DrawImg(&Canvas, &StatusCanvas, i*BOTTOMH+2*BOTTOMH, 0, 0, 0, BOTTOMH, BOTTOMH);
else
DrawRect(&Canvas, i*BOTTOMH+2*BOTTOMH, 0, BOTTOMH, BOTTOMH, COL_BLACK);
}
}

// level
j = 0;
Expand All @@ -119,7 +119,7 @@ void DispStatus()
else
DrawRect(&Canvas, WIDTH-3*BOTTOMH-i*BOTTOMH, 0, BOTTOMH, BOTTOMH, COL_BLACK);
j++;
}
}
}

// add (and display) score
Expand All @@ -143,7 +143,6 @@ void AddScore(int score)
void BlinkPellets()
{
u8 b = Blink + 1;
int i;
u8* s;

if (b == 3)
Expand Down Expand Up @@ -234,7 +233,7 @@ Bool Move()
{
// check distance to ghost
ch2 = &Chars[j];
if (((ch2->x - ch->x)*(ch2->x - ch->x) +
if (((ch2->x - ch->x)*(ch2->x - ch->x) +
(ch2->y - ch->y)*(ch2->y - ch->y)) < SPRITEW*SPRITEH)
{
// eat ghost
Expand Down Expand Up @@ -310,7 +309,7 @@ Bool Move()
}

// collect bonus fruit
else if ((FruitCnt > 0) &&
else if ((FruitCnt > 0) &&
(((ch->x - FruitSprite.x)*(ch->x - FruitSprite.x) +
((ch->y - FruitSprite.y)*(ch->y - FruitSprite.y))) < SPRITEW*SPRITEH))
{
Expand Down Expand Up @@ -525,7 +524,7 @@ Bool Move()
break;
}
}

// find best next tile
bestdist = 100*100;
bestdir = dir;
Expand Down
3 changes: 0 additions & 3 deletions examples/vga_pacman/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,6 @@ void FlushChar()

int main()
{
int i;
char ch;

// initialize random number generator
RandInitSeed();

Expand Down
2 changes: 1 addition & 1 deletion examples/vga_pi/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ int main()
u32* s = &Acu[1];
u32 n;
Bool ok = True;
u8 ch, ch2;
u8 ch;
int k = 2;
int ii = LEN-2;
if (ii > (TEXTSIZE-NUMBEG)/8) ii = (TEXTSIZE-NUMBEG)/8;
Expand Down
9 changes: 3 additions & 6 deletions examples/vga_raytrace/src/render.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ V3 BackCol((real)0.4, (real)0.6, 1); // background color in horizon
void Trace(V3* rgb, V3 &orig, V3 &dir, int depth, Sphere* disable)
{
// find nearest intersection
real t1best = TOOFAR, t2best = TOOFAR;
real t1best = TOOFAR;
Sphere* sbest = NULL;
real t1, t2;
uint i;
Expand All @@ -48,7 +48,6 @@ void Trace(V3* rgb, V3 &orig, V3 &dir, int depth, Sphere* disable)
if (t1 < t1best)
{
t1best = t1;
t2best = t2;
sbest = &Spheres[i];
}
}
Expand Down Expand Up @@ -87,10 +86,8 @@ void Trace(V3* rgb, V3 &orig, V3 &dir, int depth, Sphere* disable)
}

// if normal and ray direction are not opposited, we are inside sphere, then reverse normal
bool inside = false;
if (dir.Dot(norm) > 0)
{
inside = true;
norm.Inv();
}

Expand Down Expand Up @@ -191,7 +188,7 @@ void Render3DFast()
if (green > 255) green = 255;
if (green < 0) green = 0;
green &= 0xe0;

blue += (k<<1) + RandS8MinMax(-3, 4);
if (blue > 255) blue = 255;
if (blue < 0) blue = 0;
Expand Down Expand Up @@ -295,7 +292,7 @@ void Render3D(Bool useaa)
if (green > 255) green = 255;
if (green < 0) green = 0;
green &= 0xe0;

blue += (k<<1) + RandS8MinMax(-6, 10);
if (blue > 255) blue = 255;
if (blue < 0) blue = 0;
Expand Down
2 changes: 1 addition & 1 deletion examples/vga_sokoban/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void VideoInit()
// initialize base layer 0 to tiles
ScreenClear(pScreen);
sStrip* t = ScreenAddStrip(pScreen, HEIGHT);
sSegm* g = ScreenAddSegm(t, WIDTH);
(void)ScreenAddSegm(t, WIDTH);

// setup layer 1 with player image
memset(&LayerScreen[1], 0, sizeof(sLayer));
Expand Down
3 changes: 0 additions & 3 deletions examples/vga_sokoban/src/select.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ Bool AuthorSelect()

// select
char c;
int j;
for (;;)
{
c = WaitChar();
Expand Down Expand Up @@ -323,7 +322,6 @@ Bool CollSelect()

// select
char c;
int j;
for (;;)
{
c = WaitChar();
Expand Down Expand Up @@ -458,7 +456,6 @@ Bool LevSelect()

// select
char c;
int j;
for (;;)
{
c = WaitChar();
Expand Down
Loading

0 comments on commit 8dc07c1

Please sign in to comment.