some more optimizations

This commit is contained in:
Luxferre
2026-01-09 13:32:22 +02:00
parent d33009f8d4
commit 02acab7289
+15 -17
View File
@@ -86,8 +86,8 @@ void colorxy(unsigned char x, unsigned char y, unsigned char palette) {
} }
void game_startup() { void game_startup() {
unsigned int entropy, i, j; unsigned int entropy;
unsigned char joy; unsigned char joy, i, j;
#ifdef _randomize #ifdef _randomize
_randomize(); _randomize();
#endif #endif
@@ -148,16 +148,14 @@ void win_screen(int score) {
for(j=0;j<12;j+=4) for(j=0;j<12;j+=4)
for(i=3;i<32;i+=4) for(i=3;i<32;i+=4)
colorxy(i, j, 1 + (rand() % 3)); colorxy(i, j, 1 + (rand() % 3));
gotoxy(0, 3); cputsxy(0, 3, " ___ ___ ___ ______ \r\n" \
cputs(" ___ ___ ___ ______ \r\n" \
" | Y | | _ \\ \r\n" \ " | Y | | _ \\ \r\n" \
" |. | |. |. | |\r\n" \ " |. | |. |. | |\r\n" \
" |. / \\ |. |. | |\r\n" \ " |. / \\ |. |. | |\r\n" \
" |: |: |: | |\r\n" \ " |: |: |: | |\r\n" \
" |::.|:. |::.|::.| |\r\n" \ " |::.|:. |::.|::.| |\r\n" \
" `--- ---`---`--- ---'"); " `--- ---`---`--- ---'");
gotoxy(0, 12); cputsxy(0, 12, " Congratulations! You made it\r\n through the dangerous\r\n dungeon alive!\r\n\r\n");
cputs(" Congratulations! You made it\r\n through the dangerous\r\n dungeon alive!\r\n\r\n");
cprintf(" Your score: %d\r\n\r\n", score); cprintf(" Your score: %d\r\n\r\n", score);
chlinexy(0, 17, SCREEN_WIDTH); chlinexy(0, 17, SCREEN_WIDTH);
cputs("Created by Luxferre in 2026\r\nReleased into public domain\r\n"); cputs("Created by Luxferre in 2026\r\nReleased into public domain\r\n");
@@ -275,13 +273,13 @@ void render_room_item(short i, short v) {
/* Render main game screen */ /* Render main game screen */
void render_main_scene() { void render_main_scene() {
short i, deck_count = 0, statbase = 17; unsigned char i, deck_count = 0, statbase = 17,
short room_start_x = 1, room_start_x = 1,
room_start_y = 1, room_start_y = 1,
room_end_x = statbase - 8, room_end_x = statbase - 8,
room_end_y = SCREEN_HEIGHT - 4, room_end_y = SCREEN_HEIGHT - 4,
room_mid_x = room_start_x + ((room_end_x - room_start_x)>>1) - 1, room_mid_x = room_start_x + ((room_end_x - room_start_x)>>1) - 1,
room_mid_y = room_start_y + ((room_end_y - room_start_y)>>1) - 1; room_mid_y = room_start_y + ((room_end_y - room_start_y)>>1) - 1;
for(i=0;i<sizeof(deck);i++) for(i=0;i<sizeof(deck);i++)
if(deck[i]) deck_count++; if(deck[i]) deck_count++;
clrscr(); clrscr();
@@ -317,8 +315,8 @@ void render_main_scene() {
} }
/* Confirmation method */ /* Confirmation method */
short confirm(char *prompt) { unsigned char confirm(char *prompt) {
short res = 2, statbase = SCREEN_WIDTH - 7; unsigned char res = 2, statbase = SCREEN_WIDTH - 7;
snprintf(status_msg, sizeof(status_msg), "%s", prompt); snprintf(status_msg, sizeof(status_msg), "%s", prompt);
render_main_scene(); render_main_scene();
gotoxy(statbase, SCREEN_HEIGHT-5); gotoxy(statbase, SCREEN_HEIGHT-5);
@@ -344,7 +342,7 @@ void print_msg(char *s) {
} }
/* Array shuffle method */ /* Array shuffle method */
void shuffle(char *array, size_t n) { void shuffle(char *array, unsigned int n) {
unsigned int i, j, t; unsigned int i, j, t;
if(n > 1) { if(n > 1) {
for(i=n-1;i>0;i--) { for(i=n-1;i>0;i--) {
@@ -386,7 +384,7 @@ void handle_weapon(int val) {
durability = 14; /* reset durability to max limit */ durability = 14; /* reset durability to max limit */
} }
void handle_potion(int val) { void handle_potion(unsigned char val) {
if(potion_drank) { if(potion_drank) {
print_msg("Already drank a potion here."); print_msg("Already drank a potion here.");
} else { } else {