introduced proper rectangular rendering

This commit is contained in:
Luxferre
2026-01-19 13:43:02 +02:00
parent 7c2a0b24ed
commit 12a5d39c54
2 changed files with 22 additions and 12 deletions
+18
View File
@@ -38,6 +38,11 @@
#define EZJOY_SL 7
#define EZJOY_ST 8
#define EZ_CORNER_UL (char) 20
#define EZ_CORNER_UR (char) 18
#define EZ_CORNER_DL (char) 17
#define EZ_CORNER_DR (char) 8
#define NES_BLACK 0x0F
#define NES_WHITE 0x30
#define NES_RED 0x15
@@ -213,5 +218,18 @@ void delay_cycles(u16 n) {
for(i=0;i<n;++i);
}
/* Draw a proper rectangle with corners */
void rect(u8 x, u8 y, u8 w, u8 h) {
u8 bl_y = y + h - 1, tr_x = x + w - 1;
cputcxy(x, y, EZ_CORNER_UL);
chlinexy(x + 1, y, w - 2);
cputcxy(tr_x, y, EZ_CORNER_UR);
chlinexy(x + 1, bl_y, w - 2);
cvlinexy(x, y + 1, h - 2);
cputcxy(x, bl_y, EZ_CORNER_DL);
cvlinexy(tr_x, y + 1, h - 2);
cputcxy(tr_x, bl_y, EZ_CORNER_DR);
}
#endif
+4 -12
View File
@@ -173,8 +173,8 @@ u8 get_choice() {
/* Draw a room character according to the index and value */
void render_room_item(u8 i, u8 v) {
u8 color, topleft_x, topleft_y, topright_x, bottomleft_y,
text_x, text_y, cheight=7, cwidth=8, left_offset = 9;
u8 color, topleft_x, topleft_y, text_x, text_y,
cheight=7, cwidth=8, left_offset = 9;
if(i == 0) {
topleft_x = 8;
topleft_y = 0;
@@ -188,8 +188,6 @@ void render_room_item(u8 i, u8 v) {
topleft_x = 8;
topleft_y = 16;
}
topright_x = topleft_x + cwidth - 1;
bottomleft_y = topleft_y + cheight - 1;
text_x = topleft_x + 1;
text_y = topleft_y + 2;
if(v == 0) {} /* don't render anything */
@@ -206,10 +204,7 @@ void render_room_item(u8 i, u8 v) {
colorxy(topleft_x, topleft_y+4, color);
colorxy(topleft_x+4, topleft_y+4, color);
/* draw the rectangle */
chlinexy(topleft_x + 1, topleft_y, cwidth - 2);
chlinexy(topleft_x + 1, bottomleft_y, cwidth - 2);
cvlinexy(topleft_x, topleft_y + 1, cheight - 2);
cvlinexy(topright_x, topleft_y + 1, cheight - 2);
rect(topleft_x, topleft_y, cwidth, cheight);
/* draw text */
gotoxy(text_x, text_y);
if(v < 14) {
@@ -244,13 +239,10 @@ void render_main_scene() {
chlinexy(0,SCREEN_HEIGHT-3,SCREEN_WIDTH);
/* render the room */
for(i=0;i<4;i++) render_room_item(i, room[i]);
rect(9, 9, 6, 5);
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 */
gotoxy(statbase, 1);
cprintf("Health %02d", hp);