Added LCD window

This commit is contained in:
Daniele Verducci 2025-02-18 08:48:25 +01:00
parent 64d57bdb31
commit bf91ff680d

View File

@ -29,6 +29,7 @@ typedef struct {
Z80 cpu; Z80 cpu;
WINDOW *terminal_win; WINDOW *terminal_win;
WINDOW *status_win; WINDOW *status_win;
WINDOW *lcd_win;
} Machine; } Machine;
@ -106,6 +107,7 @@ static zuint8 machine_cpu_in(Machine *self, zuint16 port) {
refresh(); refresh();
wrefresh(self->terminal_win); wrefresh(self->terminal_win);
wrefresh(self->status_win); wrefresh(self->status_win);
wrefresh(self->lcd_win);
} }
@ -123,8 +125,8 @@ static void machine_cpu_out(Machine *self, zuint16 port, zuint8 value) {
// Port 1 (0x20 to 0x3F): sound card (sn76489) // Port 1 (0x20 to 0x3F): sound card (sn76489)
wprintw(self->status_win, "sound_cmd[%#04x]\n", value); wprintw(self->status_win, "sound_cmd[%#04x]\n", value);
} else if (decoded <= 0x5F) { } else if (decoded <= 0x5F) {
// Port 2 (0x40 to 0x5F) // Port 2 (0x40 to 0x5F): lcd display 40x4 (mod. TM404A, based on 2 KS0066 chips, each one controlling 2 rows)
wprintw(self->status_win, "IO_ERROR_OUT: No device at port 2\n"); wprintw(self->lcd_win, "%c", value);
} else if (decoded <= 0x7F) { } else if (decoded <= 0x7F) {
// Port 3 (0x60 to 0x7F) // Port 3 (0x60 to 0x7F)
wprintw(self->status_win, "IO_ERROR_OUT: No device at port 3\n"); wprintw(self->status_win, "IO_ERROR_OUT: No device at port 3\n");
@ -148,6 +150,7 @@ static void machine_cpu_out(Machine *self, zuint16 port, zuint8 value) {
refresh(); refresh();
wrefresh(self->terminal_win); wrefresh(self->terminal_win);
wrefresh(self->status_win); wrefresh(self->status_win);
wrefresh(self->lcd_win);
} }
@ -210,6 +213,7 @@ int main(int argc, char *argv[]) {
start_color(); // Use colors start_color(); // Use colors
init_pair(1, COLOR_WHITE, COLOR_BLUE); // Terminal window color init_pair(1, COLOR_WHITE, COLOR_BLUE); // Terminal window color
init_pair(2, COLOR_YELLOW, COLOR_BLACK); // Status window color init_pair(2, COLOR_YELLOW, COLOR_BLACK); // Status window color
init_pair(3, COLOR_BLACK, COLOR_GREEN); // LCD window color
int x,y; int x,y;
getmaxyx(stdscr, y,x); getmaxyx(stdscr, y,x);
@ -219,13 +223,16 @@ int main(int argc, char *argv[]) {
/*zusize*/ .cycles = 0, /*zusize*/ .cycles = 0,
/*Z80*/ .cpu = pat80Cpu, /*Z80*/ .cpu = pat80Cpu,
.terminal_win = newwin(TERMINAL_HEIGHT, TERMINAL_WIDTH, INSTRUCTION_WINDOW_HEIGHT, 0), .terminal_win = newwin(TERMINAL_HEIGHT, TERMINAL_WIDTH, INSTRUCTION_WINDOW_HEIGHT, 0),
.status_win = newwin(y, x - TERMINAL_WIDTH - SPACING_BETWEEN_WINDOWS, INSTRUCTION_WINDOW_HEIGHT, TERMINAL_WIDTH + SPACING_BETWEEN_WINDOWS) .status_win = newwin(y, x - TERMINAL_WIDTH - SPACING_BETWEEN_WINDOWS, INSTRUCTION_WINDOW_HEIGHT, TERMINAL_WIDTH + SPACING_BETWEEN_WINDOWS), // To right of terminal window
.lcd_win = newwin(4, 40, INSTRUCTION_WINDOW_HEIGHT + TERMINAL_HEIGHT + SPACING_BETWEEN_WINDOWS, 0) // Below terminal window
}; };
wbkgd(pat80.terminal_win, COLOR_PAIR(1)); // Ncurses: set terminal window color wbkgd(pat80.terminal_win, COLOR_PAIR(1)); // Ncurses: set terminal window color
wbkgd(pat80.status_win, COLOR_PAIR(2)); wbkgd(pat80.status_win, COLOR_PAIR(2));
wbkgd(pat80.lcd_win, COLOR_PAIR(3));
scrollok(pat80.terminal_win, TRUE); // Ncurses: Allow scrolling when reached end of window scrollok(pat80.terminal_win, TRUE); // Ncurses: Allow scrolling when reached end of window
scrollok(pat80.status_win, TRUE); scrollok(pat80.status_win, TRUE);
scrollok(pat80.lcd_win, FALSE);
attron(A_BOLD); // Print instructions attron(A_BOLD); // Print instructions
printw("Emulator commands\n"); printw("Emulator commands\n");
attroff(A_BOLD); attroff(A_BOLD);
@ -251,6 +258,7 @@ int main(int argc, char *argv[]) {
// Stop ncurses // Stop ncurses
delwin(pat80.terminal_win); delwin(pat80.terminal_win);
delwin(pat80.status_win); delwin(pat80.status_win);
delwin(pat80.lcd_win);
endwin(); endwin();
return 0; return 0;
} }