Added some colorization and UI revamp
This commit is contained in:
+87
-44
@@ -25,6 +25,11 @@
|
|||||||
#define KEY_SL 7
|
#define KEY_SL 7
|
||||||
#define KEY_ST 8
|
#define KEY_ST 8
|
||||||
|
|
||||||
|
#define GAME_WHITE 0
|
||||||
|
#define GAME_RED 1
|
||||||
|
#define GAME_YELLOW 2
|
||||||
|
#define GAME_GREEN 3
|
||||||
|
|
||||||
int joy_input_wait() {
|
int joy_input_wait() {
|
||||||
unsigned char last_joy = 0, joy, pressed;
|
unsigned char last_joy = 0, joy, pressed;
|
||||||
/* wait until the previous key is released */
|
/* wait until the previous key is released */
|
||||||
@@ -46,19 +51,47 @@ int joy_input_wait() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* palette loader */
|
||||||
|
void init_palette() {
|
||||||
|
unsigned char i;
|
||||||
|
const unsigned char my_palette[16] = {
|
||||||
|
0x0f, 0, 0, 0x30, /* white */
|
||||||
|
0x0f, 0, 0, 0x15, /* red */
|
||||||
|
0x0f, 0, 0, 0x28, /* yellow */
|
||||||
|
0x0f, 0, 0, 0x2A /* green */
|
||||||
|
};
|
||||||
|
PPU.vram.address = 0x3F;
|
||||||
|
PPU.vram.address = 0;
|
||||||
|
for(i=0; i<16; i++) PPU.vram.data = my_palette[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 4x4 char block colorization method (palette is 0 to 3) */
|
||||||
|
void colorxy(unsigned char x, unsigned char y, unsigned char palette) {
|
||||||
|
unsigned int addr;
|
||||||
|
unsigned char attr_byte;
|
||||||
|
addr = 0x23C0 + ((y >> 2) << 3) + (x >> 2);
|
||||||
|
attr_byte = palette | (palette << 2) | (palette << 4) | (palette << 6);
|
||||||
|
waitvsync();
|
||||||
|
PPU.vram.address = (unsigned char) (addr >> 8);
|
||||||
|
PPU.vram.address = (unsigned char) (addr & 255);
|
||||||
|
PPU.vram.data = attr_byte;
|
||||||
|
}
|
||||||
|
|
||||||
void game_startup() {
|
void game_startup() {
|
||||||
unsigned int entropy;
|
unsigned int entropy, i, j;
|
||||||
unsigned char joy;
|
unsigned char joy;
|
||||||
#ifdef _randomize
|
#ifdef _randomize
|
||||||
_randomize();
|
_randomize();
|
||||||
#endif
|
#endif
|
||||||
entropy = rand();
|
entropy = rand();
|
||||||
clrscr();
|
|
||||||
bgcolor(COLOR_BLACK);
|
bgcolor(COLOR_BLACK);
|
||||||
textcolor(0);
|
textcolor(0);
|
||||||
gotoxy(7, 2);
|
init_palette();
|
||||||
cputs("Luxferre presents");
|
clrscr();
|
||||||
gotoxy(0, 3);
|
for(j=0;j<24;j+=4)
|
||||||
|
for(i=3;i<32;i+=4)
|
||||||
|
colorxy(i, j, 1 + ((++entropy) % 3));
|
||||||
|
gotoxy(0, 2);
|
||||||
cputs( \
|
cputs( \
|
||||||
" _______ _______ _______ \r\n" \
|
" _______ _______ _______ \r\n" \
|
||||||
" | _ | _ | _ |\r\n" \
|
" | _ | _ | _ |\r\n" \
|
||||||
@@ -83,13 +116,12 @@ void game_startup() {
|
|||||||
" |: | |: 1 |: 1 |\r\n" \
|
" |: | |: 1 |: 1 |\r\n" \
|
||||||
" |::.|:. |::.. . |::.. . |\r\n" \
|
" |::.|:. |::.. . |::.. . |\r\n" \
|
||||||
" `--- ---`-------`-------'");
|
" `--- ---`-------`-------'");
|
||||||
gotoxy(SCREEN_CENTER_X - 6, SCREEN_HEIGHT - 3);
|
cputsxy(SCREEN_CENTER_X - 6, SCREEN_HEIGHT - 4, "Press Start");
|
||||||
cputs("Press Start");
|
cputsxy(1, SCREEN_HEIGHT - 2, "Luxferre");
|
||||||
gotoxy(SCREEN_WIDTH-5, SCREEN_HEIGHT - 2);
|
cputsxy(SCREEN_WIDTH-5, SCREEN_HEIGHT - 2, "2026");
|
||||||
cputs("2026");
|
|
||||||
joy_install(joy_static_stddrv);
|
joy_install(joy_static_stddrv);
|
||||||
while(1) {
|
while(1) {
|
||||||
entropy++;
|
++entropy;
|
||||||
joy = joy_read(JOY_1);
|
joy = joy_read(JOY_1);
|
||||||
if(JOY_START(joy)) break;
|
if(JOY_START(joy)) break;
|
||||||
waitvsync();
|
waitvsync();
|
||||||
@@ -100,7 +132,11 @@ void game_startup() {
|
|||||||
|
|
||||||
/* Win screen display */
|
/* Win screen display */
|
||||||
void win_screen(int score) {
|
void win_screen(int score) {
|
||||||
|
unsigned char i, j;
|
||||||
clrscr();
|
clrscr();
|
||||||
|
for(j=0;j<12;j+=4)
|
||||||
|
for(i=3;i<32;i+=4)
|
||||||
|
colorxy(i, j, 1 + (rand() % 3));
|
||||||
gotoxy(0, 3);
|
gotoxy(0, 3);
|
||||||
cputs(" ___ ___ ___ ______ \r\n" \
|
cputs(" ___ ___ ___ ______ \r\n" \
|
||||||
" | Y | | _ \\ \r\n" \
|
" | Y | | _ \\ \r\n" \
|
||||||
@@ -169,22 +205,23 @@ char get_choice() {
|
|||||||
|
|
||||||
/* Draw a room character according to the index and value */
|
/* Draw a room character according to the index and value */
|
||||||
void render_room_item(short i, short v) {
|
void render_room_item(short i, short v) {
|
||||||
short topleft_x, topleft_y,
|
unsigned char color,
|
||||||
|
topleft_x, topleft_y,
|
||||||
topright_x, bottomleft_y,
|
topright_x, bottomleft_y,
|
||||||
text_x, text_y, cheight=7, cwidth=8, left_offset = 9;
|
text_x, text_y, cheight=7, cwidth=8, left_offset = 9;
|
||||||
|
|
||||||
if(i == 0) {
|
if(i == 0) {
|
||||||
topleft_x = 8;
|
topleft_x = 8;
|
||||||
topleft_y = 3;
|
topleft_y = 0;
|
||||||
} else if(i == 1) {
|
} else if(i == 1) {
|
||||||
topleft_x = 1;
|
topleft_x = 0;
|
||||||
topleft_y = 9;
|
topleft_y = 8;
|
||||||
} else if(i == 2) {
|
} else if(i == 2) {
|
||||||
topleft_x = 15;
|
topleft_x = 16;
|
||||||
topleft_y = 9;
|
topleft_y = 8;
|
||||||
} else if(i == 3) {
|
} else if(i == 3) {
|
||||||
topleft_x = 8;
|
topleft_x = 8;
|
||||||
topleft_y = 15;
|
topleft_y = 16;
|
||||||
}
|
}
|
||||||
topright_x = topleft_x + cwidth - 1;
|
topright_x = topleft_x + cwidth - 1;
|
||||||
bottomleft_y = topleft_y + cheight - 1;
|
bottomleft_y = topleft_y + cheight - 1;
|
||||||
@@ -192,6 +229,17 @@ void render_room_item(short i, short v) {
|
|||||||
text_y = topleft_y + 2;
|
text_y = topleft_y + 2;
|
||||||
if(v == 0) {} /* don't render anything */
|
if(v == 0) {} /* don't render anything */
|
||||||
else {
|
else {
|
||||||
|
if(v < 14) {
|
||||||
|
color = GAME_RED;
|
||||||
|
} else if(v < 23) {
|
||||||
|
color = GAME_YELLOW;
|
||||||
|
} else {
|
||||||
|
color = GAME_GREEN;
|
||||||
|
}
|
||||||
|
colorxy(topleft_x, topleft_y, color);
|
||||||
|
colorxy(topleft_x+4, topleft_y, color);
|
||||||
|
colorxy(topleft_x, topleft_y+4, color);
|
||||||
|
colorxy(topleft_x+4, topleft_y+4, color);
|
||||||
/* draw the rectangle */
|
/* draw the rectangle */
|
||||||
chlinexy(topleft_x + 1, topleft_y, cwidth - 2);
|
chlinexy(topleft_x + 1, topleft_y, cwidth - 2);
|
||||||
chlinexy(topleft_x + 1, bottomleft_y, cwidth - 2);
|
chlinexy(topleft_x + 1, bottomleft_y, cwidth - 2);
|
||||||
@@ -199,9 +247,13 @@ void render_room_item(short i, short v) {
|
|||||||
cvlinexy(topright_x, topleft_y + 1, cheight - 2);
|
cvlinexy(topright_x, topleft_y + 1, cheight - 2);
|
||||||
/* draw text */
|
/* draw text */
|
||||||
gotoxy(text_x, text_y);
|
gotoxy(text_x, text_y);
|
||||||
if(v < 14) cputs("ENEMY ");
|
if(v < 14) {
|
||||||
else if(v < 23) cputs("WEAPON");
|
cputs("ENEMY ");
|
||||||
else cputs("POTION");
|
} else if(v < 23) {
|
||||||
|
cputs("WEAPON");
|
||||||
|
} else {
|
||||||
|
cputs("POTION");
|
||||||
|
}
|
||||||
gotoxy(text_x, text_y+2);
|
gotoxy(text_x, text_y+2);
|
||||||
if(v < 14) cprintf("LVL %02d", v + 1);
|
if(v < 14) cprintf("LVL %02d", v + 1);
|
||||||
else if(v < 23) cprintf("LVL %02d", v - 12);
|
else if(v < 23) cprintf("LVL %02d", v - 12);
|
||||||
@@ -222,37 +274,28 @@ void render_main_scene() {
|
|||||||
if(deck[i]) deck_count++;
|
if(deck[i]) deck_count++;
|
||||||
clrscr();
|
clrscr();
|
||||||
/* render the frames */
|
/* render the frames */
|
||||||
cvlinexy(0,0,SCREEN_HEIGHT);
|
chlinexy(0,SCREEN_HEIGHT-1,SCREEN_WIDTH);
|
||||||
cvlinexy(SCREEN_WIDTH-1,0,SCREEN_HEIGHT);
|
chlinexy(0,SCREEN_HEIGHT-3,SCREEN_WIDTH);
|
||||||
chlinexy(1,0,SCREEN_WIDTH-2);
|
|
||||||
chlinexy(1,SCREEN_HEIGHT-1,SCREEN_WIDTH-2);
|
|
||||||
chlinexy(1,SCREEN_HEIGHT-3,SCREEN_WIDTH-2);
|
|
||||||
cputsxy(9, 0, "SCOUNDREL-2026");
|
|
||||||
cputsxy(2, SCREEN_HEIGHT-5,"D-Pad to select item");
|
|
||||||
/* render the room */
|
/* render the room */
|
||||||
for(i=0;i<4;i++) render_room_item(i, room[i]);
|
for(i=0;i<4;i++) render_room_item(i, room[i]);
|
||||||
cputsxy(10, 12, "ROOM");
|
cputsxy(10, 10, "DECK");
|
||||||
|
gotoxy(11, 12);
|
||||||
|
cprintf("%02d", deck_count);
|
||||||
|
cvlinexy(9, 10, 3);
|
||||||
|
cvlinexy(14, 10, 3);
|
||||||
|
chlinexy(10, 9, 4);
|
||||||
|
chlinexy(10, 13, 4);
|
||||||
/* render stats */
|
/* render stats */
|
||||||
gotoxy(statbase, 5);
|
gotoxy(statbase, 1);
|
||||||
cprintf("Health %02d", hp);
|
cprintf("Health %02d", hp);
|
||||||
gotoxy(statbase, 6);
|
gotoxy(statbase, 3);
|
||||||
cprintf("Weapon %02d", weapon);
|
cprintf("Weapon %02d", weapon);
|
||||||
gotoxy(statbase, 7);
|
gotoxy(statbase, 5);
|
||||||
cprintf("Durability %02d", durability);
|
cprintf("Durability %02d", durability);
|
||||||
gotoxy(statbase, 17);
|
cputsxy(statbase, 17, "Choose: D-Pad");
|
||||||
cprintf("Deck cards %02d", deck_count);
|
cputsxy(statbase, 19, can_run ? "Run: A/B/SELECT" : "Cannot run!");
|
||||||
gotoxy(statbase, 19);
|
gotoxy(statbase, 21);
|
||||||
cprintf("Rooms clrd %02d", rooms_cleared);
|
cprintf("Rooms clrd %02d", rooms_cleared);
|
||||||
|
|
||||||
/* render controls info */
|
|
||||||
if(can_run) {
|
|
||||||
cputsxy(24, 10, "Run:");
|
|
||||||
cputsxy(24, 12, "A/B or");
|
|
||||||
cputsxy(24, 14, "SELECT");
|
|
||||||
} else {
|
|
||||||
cputsxy(24, 11, "Cannot");
|
|
||||||
cputsxy(24, 13, " run!");
|
|
||||||
}
|
|
||||||
/* render status message */
|
/* render status message */
|
||||||
gotoxy(1, SCREEN_HEIGHT-2);
|
gotoxy(1, SCREEN_HEIGHT-2);
|
||||||
cprintf("%s", status_msg);
|
cprintf("%s", status_msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user