38 lines
1.5 KiB
C
38 lines
1.5 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) {
|
|
window_print(view->window, 0, 0, "PC: $%04x", view->cpu->program_counter);
|
|
window_print(view->window, 0, 1, "SP: %02x", view->cpu->stack_pointer);
|
|
window_print(view->window, 0, 2, "A: %02x", view->cpu->accumulator);
|
|
window_print(view->window, 0, 3, "X: %02x", view->cpu->x);
|
|
window_print(view->window, 0, 4, "Y: %02x", view->cpu->y);
|
|
window_print(view->window, 0, 5, "C: %01x", cpu_get_flag(view->cpu, CPU_STATUS_CARRY_MASK));
|
|
window_print(view->window, 0, 6, "Z: %01x", cpu_get_flag(view->cpu, CPU_STATUS_ZERO_MASK));
|
|
window_print(view->window, 0, 7, "I: %01x", cpu_get_flag(view->cpu, CPU_STATUS_INTERRUPT_DISABLE_MASK));
|
|
window_print(view->window, 0, 8, "D: %01x", cpu_get_flag(view->cpu, CPU_STATUS_DECIMAL_MASK));
|
|
window_print(view->window, 0, 9, "B: %01x", cpu_get_flag(view->cpu, CPU_STATUS_B_MASK));
|
|
window_print(view->window, 0, 10, "O: %01x", cpu_get_flag(view->cpu, CPU_STATUS_OVERFLOW_MASK));
|
|
window_print(view->window, 0, 11, "N: %01x", cpu_get_flag(view->cpu, CPU_STATUS_NEGATIVE_MASK));
|
|
}
|
|
|
|
CpuView *cv_init(CPU *cpu, int x, int y) {
|
|
CpuView *view = malloc(sizeof(CpuView));
|
|
view->window = malloc(sizeof(Window));
|
|
view->cpu = cpu;
|
|
|
|
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);
|
|
} |