38 lines
1.4 KiB
C
38 lines
1.4 KiB
C
//
|
|
// Created by william on 4/30/24.
|
|
//
|
|
|
|
#include <stdlib.h>
|
|
#include "cpu_view.h"
|
|
#include "../cpu/cpu.h"
|
|
|
|
void cv_print(CpuView *view) {
|
|
CPU *cpu_state = cpu_get_state();
|
|
window_print(view->window, 0, 0, "PC: $%04x", cpu_state->program_counter);
|
|
window_print(view->window, 0, 1, "SP: %02x", cpu_state->stack_pointer);
|
|
window_print(view->window, 0, 2, "A: %02x", cpu_state->accumulator);
|
|
window_print(view->window, 0, 3, "X: %02x", cpu_state->x);
|
|
window_print(view->window, 0, 4, "Y: %02x", cpu_state->y);
|
|
window_print(view->window, 0, 5, "C: %01x", cpu_get_flag(CPU_STATUS_CARRY_MASK));
|
|
window_print(view->window, 0, 6, "Z: %01x", cpu_get_flag(CPU_STATUS_ZERO_MASK));
|
|
window_print(view->window, 0, 7, "I: %01x", cpu_get_flag(CPU_STATUS_INTERRUPT_DISABLE_MASK));
|
|
window_print(view->window, 0, 8, "D: %01x", cpu_get_flag(CPU_STATUS_DECIMAL_MASK));
|
|
window_print(view->window, 0, 9, "B: %01x", cpu_get_flag(CPU_STATUS_B_MASK));
|
|
window_print(view->window, 0, 10, "O: %01x", cpu_get_flag(CPU_STATUS_OVERFLOW_MASK));
|
|
window_print(view->window, 0, 11, "N: %01x", cpu_get_flag(CPU_STATUS_NEGATIVE_MASK));
|
|
}
|
|
|
|
CpuView *cv_init(int x, int y) {
|
|
CpuView *view = malloc(sizeof(CpuView));
|
|
view->window = malloc(sizeof(Window));
|
|
|
|
window_init(view->window, x, y, CPU_VIEW_WIDTH, CPU_VIEW_HEIGHT, "CPU VIEW");
|
|
cv_print(view);
|
|
|
|
return view;
|
|
}
|
|
|
|
void cv_uninit(CpuView *view) {
|
|
free(view->window);
|
|
free(view);
|
|
} |