242 lines
9.7 KiB
C
242 lines
9.7 KiB
C
#include "game.h"
|
|
|
|
/* These are good first things to change! Colors use numbers from 0 to 31. */
|
|
TEST_INTERNAL const u16 shirt = RGB(5, 14, 29);
|
|
|
|
TEST_INTERNAL const char *const creature_art[] = {
|
|
"..11........11..",
|
|
".1221......1221.",
|
|
".1231......1321.",
|
|
"..123111111321..",
|
|
"..123333333321..",
|
|
".12344444443321.",
|
|
".12341334143321.",
|
|
".12341534153321.",
|
|
".12643333443621.",
|
|
"..123337733321..",
|
|
"...1233333321...",
|
|
"...1234444321...",
|
|
"..123444444321..",
|
|
"..123344443321..",
|
|
"...1223113221...",
|
|
"....111..111...."
|
|
};
|
|
|
|
static void creature(void)
|
|
{
|
|
static const u16 palette[] = {
|
|
0, RGB(9, 8, 6), RGB(23, 15, 5), RGB(30, 23, 7),
|
|
RGB(31, 28, 14), RGB(31, 31, 28), RGB(29, 13, 10), RGB(17, 8, 7)
|
|
};
|
|
rectangle(175, 102, 14, 3, RGB(8, 16, 7));
|
|
sprite(174, 88, creature_art, 16, palette, 0);
|
|
}
|
|
|
|
void scaled_creature(int x, int y, int scale, const u16 *palette)
|
|
{
|
|
rectangle(x - 7 * scale, y, 14 * scale, 2 * scale,
|
|
indoors() ? RGB(15, 11, 8) : current_room == BEACH ? RGB(22, 20, 12) : RGB(8, 16, 7));
|
|
blit_sprite(x - 8 * scale, y - 16 * scale, creature_art, 16, 16, palette, scale, 0);
|
|
}
|
|
|
|
#include "wild_creatures.h"
|
|
|
|
/* Downsample route artwork to the same 16-pixel follower footprint as Sprout. */
|
|
void draw_member(int member, int x, int y, int small)
|
|
{
|
|
static const u16 gold[] = {
|
|
0, RGB(9, 8, 6), RGB(23, 15, 5), RGB(30, 23, 7),
|
|
RGB(31, 28, 14), RGB(31, 31, 28), RGB(29, 13, 10), RGB(17, 8, 7)
|
|
};
|
|
if (!member) { draw_sprout(x, y, small ? 1 : 3); return; }
|
|
enum Species kind = (enum Species)caught_species[member - 1];
|
|
if (kind == GOLDEN) { scaled_creature(x, y, small ? 1 : 3, gold); return; }
|
|
if (!small) { draw_wild_creature(kind, x, y); return; }
|
|
static char pixels[4][16][17];
|
|
static const char *rows[4][16];
|
|
static int ready;
|
|
if (!ready) {
|
|
for (int k = 0; k < 4; ++k)
|
|
for (int row = 0; row < 16; ++row) {
|
|
rows[k][row] = pixels[k][row];
|
|
for (int col = 0; col < 16; ++col)
|
|
pixels[k][row][col] = wild_art[k].rows[row * 3 / 2][col * 3 / 2];
|
|
}
|
|
ready = 1;
|
|
}
|
|
rectangle(x - 7, y, 14, 2, indoors() ? RGB(15, 11, 8) :
|
|
current_room == BEACH ? RGB(22, 20, 12) : RGB(8, 16, 7));
|
|
sprite(x - 8, y - 16, rows[kind - FERNFOX], 16, wild_art[kind - FERNFOX].palette, 0);
|
|
}
|
|
|
|
void draw_wild_creature(enum Species enemy, int x, int y)
|
|
{
|
|
const struct WildArt *art = &wild_art[enemy - FERNFOX];
|
|
rectangle(x - 20, y, 40, 3, RGB(8, 16, 7));
|
|
blit_sprite(x - 24, y - 48, art->rows, 24, 24, art->palette, 2, 0);
|
|
}
|
|
|
|
void draw_sprout(int x, int y, int scale)
|
|
{
|
|
static const u16 palette[] = {
|
|
0, RGB(5, 10, 7), RGB(6, 16, 8), RGB(12, 24, 10),
|
|
RGB(24, 30, 14), RGB(31, 31, 28), RGB(30, 17, 12), RGB(12, 9, 7)
|
|
};
|
|
scaled_creature(x, y, scale, palette);
|
|
rectangle(x - scale, y - 16 * scale, 2 * scale, 3 * scale, RGB(5, 17, 8));
|
|
rectangle(x, y - 17 * scale, 4 * scale, 2 * scale, RGB(13, 24, 9));
|
|
rectangle(x + scale, y - 17 * scale, 2 * scale, scale, RGB(24, 30, 14));
|
|
}
|
|
|
|
TEST_INTERNAL const char *const person_art[] = {
|
|
".....111111.....",
|
|
"....12222221....",
|
|
"...1223333221...",
|
|
"...1233333321...",
|
|
"...1222222221...",
|
|
"..111111111111..",
|
|
"...1444444441...",
|
|
"...1466666641...",
|
|
"....16166161....",
|
|
"....16677661....",
|
|
".....166661.....",
|
|
"....11888811....",
|
|
"...1888998881...",
|
|
"..161889988161..",
|
|
"..161888888161..",
|
|
"..166188881661..",
|
|
"...1111111111...",
|
|
"....1AA11AA1....",
|
|
"....1AA11AA1....",
|
|
"....111..111...."
|
|
};
|
|
|
|
TEST_INTERNAL const char *const person_back_art[] = {
|
|
".....111111.....", "....12222221....", "...1223333221...", "...1233333321...",
|
|
"...1233333321...", "...1222222221...", "...1444444441...", "....14444441....",
|
|
"....14444441....", ".....166661.....", "....11888811....", "...1888888881...",
|
|
"..1618BBBB8161..", "..1618BCCB8161..", "..1618BCCB8161..", "..1668BBBB8661..",
|
|
"...1111111111...", "....1AA11AA1....", "....1AA11AA1....", "....111..111...."
|
|
};
|
|
|
|
TEST_INTERNAL const char *const person_side_art[] = {
|
|
"......11111.....", ".....1222221....", "....123333321...", "....123333321...",
|
|
"....1222222221..", "....1111111111..", "....144466661...", "....144661661...",
|
|
".....14666661...", ".....1467761....", "......16661.....", ".....188881.....",
|
|
"....1BB88881....", "....1BC81661....", "....1BB81661....", ".....188161.....",
|
|
".....111111.....", ".....1AA1A1.....", ".....1AA1A1.....", ".....111111....."
|
|
};
|
|
|
|
/* Distinct long-haired girl silhouette, with front, back, and side views. */
|
|
TEST_INTERNAL const char *const girl_art[] = {
|
|
".....111111.....", "....14444441....", "...1434444341...", "...1444444441...",
|
|
"..144444444441..", "..144666666441..", "..144616616441..", "..144666666441..",
|
|
"...1466776641...", "...1446666441...", "...1441881441...", "...1418998141...",
|
|
"...1168998611...", "..161889988161..", "..161888888161..", "...1618888161...",
|
|
"....18888881....", "....1AA11AA1....", "....1AA11AA1....", "....111..111...."
|
|
};
|
|
|
|
TEST_INTERNAL const char *const girl_back_art[] = {
|
|
".....111111.....", "....14444441....", "...1434444341...", "...1444444441...",
|
|
"...1444444441...", "...1444444441...", "...1244444421...", "...1244444421...",
|
|
"...1444444441...", "....14444441....", "....18444481....", "...1881441881...",
|
|
"..1618BBBB8161..", "..1618BCCB8161..", "..1618BCCB8161..", "..1668BBBB8661..",
|
|
"...1111111111...", "....1AA11AA1....", "....1AA11AA1....", "....111..111...."
|
|
};
|
|
|
|
TEST_INTERNAL const char *const girl_side_art[] = {
|
|
"......11111.....", ".....1444441....", "....143444441...", "....144444441...",
|
|
"...1444444441...", "..14444466661...", "..14444461661...", "..14444466661...",
|
|
"..14444167761...", "...144411661....", "...14441881.....", "....14418881....",
|
|
"....14188881....", ".....1881661....", ".....1881661....", ".....188161.....",
|
|
".....111111.....", ".....1AA1A1.....", ".....1AA1A1.....", ".....111111....."
|
|
};
|
|
|
|
static u16 lighter(u16 color)
|
|
{
|
|
int r = color & 31, g = (color >> 5) & 31, b = (color >> 10) & 31;
|
|
return RGB(r + (31 - r) / 3, g + (31 - g) / 3, b + (31 - b) / 3);
|
|
}
|
|
|
|
static u16 darker(u16 color)
|
|
{
|
|
return RGB((color & 31) * 2 / 3, ((color >> 5) & 31) * 2 / 3,
|
|
((color >> 10) & 31) * 2 / 3);
|
|
}
|
|
|
|
/* x and y mark the feet. The art fits inside the original erase area. */
|
|
TEST_INTERNAL void styled_person(int x, int y, int step, u16 clothes, u16 hair_or_hat,
|
|
enum Facing facing, enum CharacterStyle style)
|
|
{
|
|
u16 palette[] = {
|
|
0, RGB(5, 7, 9), darker(hair_or_hat),
|
|
style == GIRL_STYLE ? lighter(hair_or_hat) : hair_or_hat,
|
|
style == GIRL_STYLE ? hair_or_hat : RGB(11, 8, 7),
|
|
RGB(24, 16, 12), RGB(31, 25, 19), RGB(25, 13, 12),
|
|
clothes, lighter(clothes), RGB(9, 12, 17), RGB(24, 17, 8), RGB(30, 24, 12)
|
|
};
|
|
rectangle(x - 7, y - 1, 15, 3,
|
|
indoors() ? RGB(15, 11, 8) : current_room == BEACH ? RGB(22, 20, 12) : RGB(8, 16, 7));
|
|
const char *const *art;
|
|
if (style == GIRL_STYLE)
|
|
art = facing == FACING_UP ? girl_back_art : facing == FACING_DOWN ? girl_art : girl_side_art;
|
|
else
|
|
art = facing == FACING_UP ? person_back_art : facing == FACING_DOWN ? person_art : person_side_art;
|
|
sprite(x - 8, y - 19, art, 20, palette, facing == FACING_LEFT);
|
|
rectangle(x - 4, y, 3, 2 - step, palette[1]);
|
|
rectangle(x + 1, y, 3, 1 + step, palette[1]);
|
|
}
|
|
|
|
TEST_INTERNAL void person(int x, int y, int step, u16 clothes, u16 hat, enum Facing facing)
|
|
{
|
|
styled_person(x, y, step, clothes, hat, facing, BOY_STYLE);
|
|
}
|
|
|
|
static void player(int x, int y, int step)
|
|
{
|
|
person(x, y, step, shirt, RGB(28, 8, 9), player_facing);
|
|
}
|
|
|
|
void actors(int x, int y, int step)
|
|
{
|
|
enum { HERO, SPROUT, MILA, GOLDEN_ACTOR, PROFESSOR, RANGER, FISHER };
|
|
struct Actor { int x, y, kind; } list[4];
|
|
int count = 0;
|
|
if (partner_owned && follower_ready)
|
|
list[count++] = (struct Actor){follower_x, follower_y, SPROUT};
|
|
list[count++] = (struct Actor){x, y, HERO};
|
|
if (current_room == MELLON_HOUSE) {
|
|
list[count++] = (struct Actor){PROF_X, PROF_Y, PROFESSOR};
|
|
}
|
|
if (current_room == OUTSIDE) {
|
|
if (!has_caught(GOLDEN)) list[count++] = (struct Actor){182, 104, GOLDEN_ACTOR};
|
|
list[count++] = (struct Actor){NPC_X, NPC_Y, MILA};
|
|
}
|
|
if (current_room == ROUTE) list[count++] = (struct Actor){RANGER_X, RANGER_Y, RANGER};
|
|
if (current_room == BEACH) list[count++] = (struct Actor){FISHER_X, FISHER_Y, FISHER};
|
|
/* Stable depth ordering keeps Sprout behind the hero on equal feet. */
|
|
for (int i = 1; i < count; ++i) {
|
|
struct Actor actor = list[i];
|
|
int j = i;
|
|
while (j > 0 && list[j - 1].y > actor.y) {
|
|
list[j] = list[j - 1];
|
|
--j;
|
|
}
|
|
list[j] = actor;
|
|
}
|
|
for (int i = 0; i < count; ++i) {
|
|
struct Actor actor = list[i];
|
|
if (actor.kind == HERO) player(actor.x, actor.y, step);
|
|
else if (actor.kind == SPROUT) draw_member(active_member, actor.x, actor.y, 1);
|
|
else if (actor.kind == GOLDEN_ACTOR) creature();
|
|
else if (actor.kind == MILA)
|
|
styled_person(actor.x, actor.y, 0, RGB(4, 21, 13), RGB(12, 7, 4), FACING_DOWN, GIRL_STYLE);
|
|
else if (actor.kind == RANGER)
|
|
person(actor.x, actor.y, 0, RGB(27, 16, 7), RGB(6, 15, 11), FACING_DOWN);
|
|
else if (actor.kind == FISHER)
|
|
styled_person(actor.x, actor.y, 0, RGB(5, 23, 26), RGB(26, 12, 7), FACING_DOWN, GIRL_STYLE);
|
|
else styled_person(actor.x, actor.y, 0, RGB(29, 30, 27), RGB(20, 21, 19),
|
|
FACING_DOWN, GIRL_STYLE);
|
|
}
|
|
}
|