PPU debugger view
This commit is contained in:
parent
6565364bc9
commit
ae76160f11
|
@ -1,5 +1,5 @@
|
||||||
set(HEADERS cpu_view.h cursor.h debugger.h dialog.h keys.h memory_view.h program_view.h window.h)
|
set(HEADERS cpu_view.h cursor.h debugger.h dialog.h keys.h memory_view.h ppu_view.h program_view.h window.h)
|
||||||
set(SOURCE cpu_view.c cursor.c debugger.c dialog.c memory_view.c program_view.c window.c)
|
set(SOURCE cpu_view.c cursor.c debugger.c dialog.c memory_view.c ppu_view.c program_view.c window.c)
|
||||||
|
|
||||||
add_library(nes_debugger ${HEADERS} ${SOURCE})
|
add_library(nes_debugger ${HEADERS} ${SOURCE})
|
||||||
|
|
||||||
|
|
|
@ -2,13 +2,13 @@
|
||||||
// Created by william on 4/30/24.
|
// Created by william on 4/30/24.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef NESEMULATOR_CPU_VIEW_H
|
|
||||||
#define NESEMULATOR_CPU_VIEW_H
|
|
||||||
|
|
||||||
#include "window.h"
|
#include "window.h"
|
||||||
#include "../include/types.h"
|
#include "../include/types.h"
|
||||||
#include "../include/cpu.h"
|
#include "../include/cpu.h"
|
||||||
|
|
||||||
|
#ifndef NESEMULATOR_CPU_VIEW_H
|
||||||
|
#define NESEMULATOR_CPU_VIEW_H
|
||||||
|
|
||||||
#define CPU_VIEW_HEIGHT 14
|
#define CPU_VIEW_HEIGHT 14
|
||||||
#define CPU_VIEW_WIDTH 12
|
#define CPU_VIEW_WIDTH 12
|
||||||
|
|
||||||
|
@ -19,11 +19,6 @@ typedef struct cpu_view {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initializes a CPU view for a system RAM.
|
* Initializes a CPU view for a system RAM.
|
||||||
*
|
|
||||||
* @param interact
|
|
||||||
* @param ram
|
|
||||||
* @param x
|
|
||||||
* @param y
|
|
||||||
*/
|
*/
|
||||||
CpuView *cv_init(CPU *cpu, int x, int y);
|
CpuView *cv_init(CPU *cpu, int x, int y);
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "program_view.h"
|
#include "program_view.h"
|
||||||
#include "keys.h"
|
#include "keys.h"
|
||||||
#include "cpu_view.h"
|
#include "cpu_view.h"
|
||||||
|
#include "ppu_view.h"
|
||||||
|
|
||||||
void debugger_create_window() {
|
void debugger_create_window() {
|
||||||
setenv("TERMINFO", "/usr/share/terminfo", 1);
|
setenv("TERMINFO", "/usr/share/terminfo", 1);
|
||||||
|
@ -53,6 +54,7 @@ void debugger_uninit_interactive_windows(LinkedList *windows) {
|
||||||
|
|
||||||
void start_debugger(System *system) {
|
void start_debugger(System *system) {
|
||||||
CpuView *cpu_view;
|
CpuView *cpu_view;
|
||||||
|
PpuView *ppu_view;
|
||||||
LinkedList interactive_windows;
|
LinkedList interactive_windows;
|
||||||
InteractWindow *current_window;
|
InteractWindow *current_window;
|
||||||
|
|
||||||
|
@ -60,7 +62,8 @@ void start_debugger(System *system) {
|
||||||
|
|
||||||
interactive_windows = debugger_create_interactive_windows(system);
|
interactive_windows = debugger_create_interactive_windows(system);
|
||||||
current_window = interactive_windows.current->data;
|
current_window = interactive_windows.current->data;
|
||||||
cpu_view = cv_init(&system->cpu, MEMORY_VIEW_WIDTH + PROGRAM_VIEW_WIDTH, 0);
|
cpu_view = cv_init(&system->cpu, 0, MEMORY_VIEW_HEIGHT);
|
||||||
|
ppu_view = ppv_init(&system->ppu, CPU_VIEW_WIDTH, MEMORY_VIEW_HEIGHT);
|
||||||
|
|
||||||
cursor_enable(¤t_window->cursor);
|
cursor_enable(¤t_window->cursor);
|
||||||
|
|
||||||
|
@ -92,6 +95,7 @@ void start_debugger(System *system) {
|
||||||
|
|
||||||
debugger_uninit_interactive_windows(&interactive_windows);
|
debugger_uninit_interactive_windows(&interactive_windows);
|
||||||
cv_uninit(cpu_view);
|
cv_uninit(cpu_view);
|
||||||
|
ppv_uninit(ppu_view);
|
||||||
|
|
||||||
endwin();
|
endwin();
|
||||||
}
|
}
|
|
@ -0,0 +1,50 @@
|
||||||
|
//
|
||||||
|
// Created by william on 5/1/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include "ppu_view.h"
|
||||||
|
|
||||||
|
void ppv_print_line(PpuView *view, byte reg, int line, char *fmt) {
|
||||||
|
int reg_value = view->ppu->registers[reg];
|
||||||
|
window_print(view->window, 0, line, fmt);
|
||||||
|
|
||||||
|
for (int i = 0; i < 0x8; i++) {
|
||||||
|
byte mask = 0x80 >> i;
|
||||||
|
byte bit = (reg_value & mask) >> (8 - i - 1);
|
||||||
|
|
||||||
|
int print_offset = 10 + i;
|
||||||
|
if (i > 3) {
|
||||||
|
print_offset += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
window_print(view->window, print_offset, line, "%d", bit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ppv_print(PpuView *view) {
|
||||||
|
ppv_print_line(view, PPU_REGISTER_CTRL, 0, " CTRL:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_MASK, 1, " MASK:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_STATUS, 2, " STATUS:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_OAM_ADDR, 3, "OAM_ADDR:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_OAM_DATA, 4, "OAM_DATA:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_SCROLL, 5, " SCROLL:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_ADDR, 6, " ADDR:");
|
||||||
|
ppv_print_line(view, PPU_REGISTER_DATA, 7, " DATA:");
|
||||||
|
}
|
||||||
|
|
||||||
|
PpuView *ppv_init(PPU *ppu, int x, int y) {
|
||||||
|
PpuView *view = malloc(sizeof(PpuView));
|
||||||
|
view->window = malloc(sizeof(Window));
|
||||||
|
view->ppu = ppu;
|
||||||
|
|
||||||
|
window_init(view->window, x, y, PPU_VIEW_WIDTH, PPU_VIEW_HEIGHT, "PPU VIEW");
|
||||||
|
ppv_print(view);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ppv_uninit(PpuView *view) {
|
||||||
|
free(view->window);
|
||||||
|
free(view);
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
//
|
||||||
|
// Created by william on 5/1/24.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "../include/ppu.h"
|
||||||
|
#include "window.h"
|
||||||
|
|
||||||
|
#ifndef NES_EMULATOR_PPU_VIEW_H
|
||||||
|
#define NES_EMULATOR_PPU_VIEW_H
|
||||||
|
|
||||||
|
#define PPU_VIEW_HEIGHT 14
|
||||||
|
#define PPU_VIEW_WIDTH 22
|
||||||
|
|
||||||
|
typedef struct ppu_view {
|
||||||
|
Window *window;
|
||||||
|
PPU *ppu;
|
||||||
|
} PpuView;
|
||||||
|
|
||||||
|
PpuView *ppv_init(PPU *ppu, int x, int y);
|
||||||
|
|
||||||
|
void ppv_uninit(PpuView *ppu_view);
|
||||||
|
|
||||||
|
#endif //NES_EMULATOR_PPU_VIEW_H
|
Loading…
Reference in New Issue