This commit is contained in:
FyloZ 2024-01-11 16:02:53 -05:00
parent b7ed82cf09
commit 7d04e3eb3c
Signed by: william
GPG Key ID: 835378AE9AF4AE97
9 changed files with 428 additions and 61 deletions

View File

@ -25,15 +25,13 @@
</configurations>
</component>
<component name="ChangeListManager">
<list default="true" id="0c3b231e-0637-4ac1-8964-c60fc9e9e691" name="Changes" comment="Finished read-only memory debugger">
<change afterPath="$PROJECT_DIR$/cpu/decoding.c" afterDir="false" />
<change afterPath="$PROJECT_DIR$/cpu/decoding.h" afterDir="false" />
<list default="true" id="0c3b231e-0637-4ac1-8964-c60fc9e9e691" name="Changes" comment="gitignore">
<change afterPath="$PROJECT_DIR$/debugger/program_view.c" afterDir="false" />
<change afterPath="$PROJECT_DIR$/debugger/program_view.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpu/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/cpu/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpu/cpu.c" beforeDir="false" afterPath="$PROJECT_DIR$/cpu/cpu.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpu/cpu.h" beforeDir="false" afterPath="$PROJECT_DIR$/cpu/cpu.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpu/op.c" beforeDir="false" afterPath="$PROJECT_DIR$/cpu/op.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/cpu/op.h" beforeDir="false" afterPath="$PROJECT_DIR$/cpu/op.h" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debugger/CMakeLists.txt" beforeDir="false" afterPath="$PROJECT_DIR$/debugger/CMakeLists.txt" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debugger/debugger.c" beforeDir="false" afterPath="$PROJECT_DIR$/debugger/debugger.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debugger/memory_view.c" beforeDir="false" afterPath="$PROJECT_DIR$/debugger/memory_view.c" afterDir="false" />
<change beforePath="$PROJECT_DIR$/debugger/memory_view.h" beforeDir="false" afterPath="$PROJECT_DIR$/debugger/memory_view.h" afterDir="false" />
@ -76,32 +74,34 @@
<component name="ProjectViewState">
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent"><![CDATA[{
"keyToString": {
"ASKED_ADD_EXTERNAL_FILES": "true",
"RunOnceActivity.OpenProjectViewOnStart": "true",
"RunOnceActivity.ShowReadmeOnStart": "true",
"RunOnceActivity.cidr.known.project.marker": "true",
"RunOnceActivity.readMode.enableVisualFormatting": "true",
"WebServerToolWindowFactoryState": "false",
"cf.first.check.clang-format": "false",
"cidr.known.project.marker": "true",
"com.jfrog.conanplugin.addconansupport": "true",
"com.jfrog.conanplugin.automanage.cmake.advanced.settings": "true",
"com.jfrog.conanplugin.conanexecutable": "conan",
"com.jfrog.conanplugin.hasbeensetup": "true",
"git-widget-placeholder": "master",
"last_opened_file_path": "/home/william/Dev/ETS/LOG710/Lab2/CMakeLists.txt",
"node.js.detected.package.eslint": "true",
"node.js.detected.package.tslint": "true",
"node.js.selected.package.eslint": "(autodetect)",
"node.js.selected.package.tslint": "(autodetect)",
"nodejs_package_manager_path": "npm",
"settings.editor.selected.configurable": "preferences.pluginManager",
"structure.view.defaults.are.configured": "true",
"vue.rearranger.settings.migration": "true"
<component name="PropertiesComponent">{
&quot;keyToString&quot;: {
&quot;ASKED_ADD_EXTERNAL_FILES&quot;: &quot;true&quot;,
&quot;CMake Application.NESEmulator (Term).executor&quot;: &quot;Run&quot;,
&quot;CMake Application.NESEmulator.executor&quot;: &quot;Run&quot;,
&quot;RunOnceActivity.OpenProjectViewOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.ShowReadmeOnStart&quot;: &quot;true&quot;,
&quot;RunOnceActivity.cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;RunOnceActivity.readMode.enableVisualFormatting&quot;: &quot;true&quot;,
&quot;WebServerToolWindowFactoryState&quot;: &quot;false&quot;,
&quot;cf.first.check.clang-format&quot;: &quot;false&quot;,
&quot;cidr.known.project.marker&quot;: &quot;true&quot;,
&quot;com.jfrog.conanplugin.addconansupport&quot;: &quot;true&quot;,
&quot;com.jfrog.conanplugin.automanage.cmake.advanced.settings&quot;: &quot;true&quot;,
&quot;com.jfrog.conanplugin.conanexecutable&quot;: &quot;conan&quot;,
&quot;com.jfrog.conanplugin.hasbeensetup&quot;: &quot;true&quot;,
&quot;git-widget-placeholder&quot;: &quot;master&quot;,
&quot;last_opened_file_path&quot;: &quot;/home/william/Dev/ETS/LOG710/Lab2/CMakeLists.txt&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
&quot;node.js.selected.package.eslint&quot;: &quot;(autodetect)&quot;,
&quot;node.js.selected.package.tslint&quot;: &quot;(autodetect)&quot;,
&quot;nodejs_package_manager_path&quot;: &quot;npm&quot;,
&quot;settings.editor.selected.configurable&quot;: &quot;configurable.group.editor&quot;,
&quot;structure.view.defaults.are.configured&quot;: &quot;true&quot;,
&quot;vue.rearranger.settings.migration&quot;: &quot;true&quot;
}
}]]></component>
}</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$/include" />
@ -114,6 +114,7 @@
<component name="RunManager" selected="CMake Application.NESEmulator">
<configuration default="true" type="PythonConfigurationType" factoryName="Python">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
@ -135,6 +136,7 @@
</configuration>
<configuration default="true" type="Tox" factoryName="Tox">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -146,6 +148,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="Autodetect">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -160,6 +163,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="Doctests">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -178,6 +182,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="Nosetests">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -193,6 +198,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="Twisted Trial">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -207,6 +213,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="Unittests">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -221,6 +228,7 @@
</configuration>
<configuration default="true" type="tests" factoryName="py.test">
<module name="nesemu" />
<option name="ENV_FILES" value="" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
@ -235,11 +243,6 @@
<option name="_new_targetType" value="&quot;PATH&quot;" />
<method v="2" />
</configuration>
<configuration default="true" type="CLionExternalRunConfiguration" factoryName="Application" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" EMULATE_TERMINAL="false" PASS_PARENT_ENVS_2="true">
<method v="2">
<option name="CLION.EXTERNAL.BUILD" enabled="true" />
</method>
</configuration>
<configuration name="NESEmulator" type="CMakeListConfigurationType" factoryName="CMakeListConfigurationFactory" temporary="true">
<method v="2" />
</configuration>
@ -423,15 +426,15 @@
<method v="2" />
</configuration>
<list>
<item itemvalue="CMake Debug.NESEmulator" />
<item itemvalue="CMake Application.CPU" />
<item itemvalue="CMake Application.DEBUG" />
<item itemvalue="CMake Application.Mappers" />
<item itemvalue="CMake Application.NESEmulator (GDB Server)" />
<item itemvalue="CMake Application.NESEmulator (Term)" />
<item itemvalue="CMake Application.NESEmulator" />
<item itemvalue="CMake Application.PPU" />
<item itemvalue="CMake Application.ROM" />
<item itemvalue="CMake Application.NESEmulator (GDB Server)" />
<item itemvalue="CMake Application.NESEmulator" />
<item itemvalue="CMake Application.NESEmulator (Term)" />
<item itemvalue="CMake Debug.NESEmulator" />
</list>
<recent_temporary>
<list>
@ -471,6 +474,8 @@
<workItem from="1704569084127" duration="8903000" />
<workItem from="1704582152049" duration="7863000" />
<workItem from="1704660072645" duration="19497000" />
<workItem from="1704934699461" duration="5989000" />
<workItem from="1705006965034" duration="2000" />
</task>
<task id="LOCAL-00001" summary="Cpu opcodes implementation">
<option name="closed" value="true" />
@ -520,17 +525,24 @@
<option name="project" value="LOCAL" />
<updated>1704829582042</updated>
</task>
<option name="localTasksCounter" value="7" />
<task id="LOCAL-00007" summary="gitignore">
<option name="closed" value="true" />
<created>1704903354414</created>
<option name="number" value="00007" />
<option name="presentableId" value="LOCAL-00007" />
<option name="project" value="LOCAL" />
<updated>1704903354414</updated>
</task>
<option name="localTasksCounter" value="8" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="VCPKGProject">
<isAutomaticEditVcpkgJson value="false" />
<isAutomaticCheckingOnLaunch value="false" />
<isAutomaticFoundErrors value="true" />
<isAutomaticFoundErrors value="true" />
<isAutomaticReloadCMake value="true" />
</component>
<component name="VcsManagerConfiguration">
<option name="ADD_EXTERNAL_FILES_SILENTLY" value="true" />
@ -540,7 +552,8 @@
<MESSAGE value="Things" />
<MESSAGE value="Memory debugger" />
<MESSAGE value="Finished read-only memory debugger" />
<option name="LAST_COMMIT_MESSAGE" value="Finished read-only memory debugger" />
<MESSAGE value="gitignore" />
<option name="LAST_COMMIT_MESSAGE" value="gitignore" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>

278
cpu/op.c
View File

@ -1,6 +1,5 @@
#include <stdbool.h>
#include <assert.h>
#include <log.h>
#include "op.h"
#include "cpu.h"
@ -960,7 +959,7 @@ void process_op_code(System *system, byte op) {
IS_OP_CODE_MODE(JSR, 0x20, ABSOLUTE)
IS_OP_CODE_MODE(BIT, 0x24, ZERO_PAGE)
IS_OP_CODE_MODE(BIT, 0x2c, ABSOLUTE)
IS_OP_CODE_MODE(JMP, 0x4c, ABSOLUTE_JUMP)
IS_OP_CODE_MODE(JMP, 0x4c, ABSOLUTE)
IS_OP_CODE_MODE(JMP, 0x6c, INDIRECT_JUMP)
IS_OP_CODE_MODE(STY, 0x84, ZERO_PAGE)
IS_OP_CODE_MODE(STY, 0x8c, ABSOLUTE)
@ -1107,3 +1106,278 @@ void process_op_code(System *system, byte op) {
assert(false);
}
}
AddressingMode get_op_addr_mode(byte op_code) {
switch (op_code) {
case 0x0c:
case 0x0d:
case 0x0e:
case 0x0f:
case 0x20:
case 0x2c:
case 0x2d:
case 0x2e:
case 0x2f:
case 0x4c:
case 0x4d:
case 0x4e:
case 0x4f:
case 0x6d:
case 0x6e:
case 0x6f:
case 0x8c:
case 0x8d:
case 0x8e:
case 0x8f:
case 0xac:
case 0xad:
case 0xae:
case 0xaf:
case 0xcc:
case 0xcd:
case 0xce:
case 0xcf:
case 0xec:
case 0xed:
case 0xee:
case 0xef:
return ADDR_MODE_ABSOLUTE;
case 0x1c:
case 0x1d:
case 0x1e:
case 0x1f:
case 0x3c:
case 0x3d:
case 0x3e:
case 0x3f:
case 0x5c:
case 0x5d:
case 0x5e:
case 0x5f:
case 0x7c:
case 0x7d:
case 0x7e:
case 0x7f:
case 0x9c:
case 0x9d:
case 0xbc:
case 0xbd:
case 0xdc:
case 0xdd:
case 0xde:
case 0xdf:
case 0xfc:
case 0xfd:
case 0xfe:
case 0xff:
return ADDR_MODE_ABSOLUTE_INDEXED_X;
case 0x19:
case 0x1b:
case 0x39:
case 0x3b:
case 0x59:
case 0x5b:
case 0x79:
case 0x7b:
case 0x99:
case 0x9b:
case 0x9e:
case 0x9f:
case 0xb9:
case 0xbb:
case 0xbe:
case 0xbf:
case 0xd9:
case 0xdb:
case 0xf9:
case 0xfb:
return ADDR_MODE_ABSOLUTE_INDEXED_Y;
case 0x0a:
case 0x2a:
case 0x4a:
case 0x6a:
return ADDR_MODE_ACCUMULATOR;
case 0x09:
case 0x0b:
case 0x29:
case 0x2b:
case 0x49:
case 0x4b:
case 0x69:
case 0x6b:
case 0x80:
case 0x82:
case 0x89:
case 0x8b:
case 0xa0:
case 0xa2:
case 0xa9:
case 0xab:
case 0xc0:
case 0xc2:
case 0xc9:
case 0xcb:
case 0xe0:
case 0xe2:
case 0xe9:
case 0xeb:
return ADDR_MODE_IMMEDIATE;
case 0x00:
case 0x02:
case 0x08:
case 0x12:
case 0x18:
case 0x1a:
case 0x22:
case 0x28:
case 0x32:
case 0x3a:
case 0x40:
case 0x42:
case 0x48:
case 0x52:
case 0x58:
case 0x5a:
case 0x60:
case 0x62:
case 0x68:
case 0x72:
case 0x78:
case 0x7a:
case 0x88:
case 0x8a:
case 0x92:
case 0x98:
case 0x9a:
case 0xa8:
case 0xaa:
case 0xb2:
case 0xb8:
case 0xba:
case 0xc8:
case 0xca:
case 0xd2:
case 0xd8:
case 0xda:
case 0xe8:
case 0xea:
case 0xf2:
case 0xf8:
case 0xfa:
return ADDR_MODE_IMPLICIT;
case 0x01:
case 0x03:
case 0x21:
case 0x23:
case 0x41:
case 0x43:
case 0x61:
case 0x63:
case 0x81:
case 0x83:
case 0xa1:
case 0xa3:
case 0xc1:
case 0xc3:
case 0xe1:
case 0xe3:
return ADDR_MODE_INDIRECT_X;
case 0x6c:
return ADDR_MODE_INDIRECT_JUMP;
case 0x11:
case 0x13:
case 0x31:
case 0x33:
case 0x51:
case 0x53:
case 0x71:
case 0x73:
case 0x91:
case 0x93:
case 0xb1:
case 0xb3:
case 0xd1:
case 0xd3:
case 0xf1:
case 0xf3:
return ADDR_MODE_INDIRECT_Y;
case 0x10:
case 0x30:
case 0x50:
case 0x70:
case 0x90:
case 0xb0:
case 0xd0:
case 0xf0:
return ADDR_MODE_RELATIVE;
case 0x04:
case 0x05:
case 0x06:
case 0x07:
case 0x24:
case 0x25:
case 0x26:
case 0x27:
case 0x44:
case 0x45:
case 0x46:
case 0x47:
case 0x64:
case 0x65:
case 0x66:
case 0x67:
case 0x84:
case 0x85:
case 0x86:
case 0x87:
case 0xa4:
case 0xa5:
case 0xa6:
case 0xa7:
case 0xc4:
case 0xc5:
case 0xc6:
case 0xc7:
case 0xe4:
case 0xe5:
case 0xe6:
case 0xe7:
return ADDR_MODE_ZERO_PAGE;
case 0x14:
case 0x15:
case 0x16:
case 0x17:
case 0x34:
case 0x35:
case 0x36:
case 0x37:
case 0x54:
case 0x55:
case 0x56:
case 0x57:
case 0x74:
case 0x75:
case 0x76:
case 0x77:
case 0x94:
case 0x95:
case 0xb4:
case 0xb5:
case 0xd4:
case 0xd5:
case 0xd6:
case 0xd7:
case 0xf4:
case 0xf5:
case 0xf6:
case 0xf7:
return ADDR_MODE_ZERO_PAGE_INDEXED_X;
case 0x96:
case 0x97:
case 0xb6:
case 0xb7:
return ADDR_MODE_ZERO_PAGE_INDEXED_Y;
default:
assert(false);
}
}

View File

@ -1,4 +1,5 @@
#include "../include/cpu.h"
#include "decoding.h"
#ifndef CPU_OP_H
#define CPU_OP_H
@ -18,4 +19,6 @@ enum op_code_base {
void process_op_code(System *system, byte op);
AddressingMode get_op_addr_mode(byte op_code);
#endif

View File

@ -1,7 +1,9 @@
add_library(DEBUG
debugger.c
memory_view.c
dialog.c)
dialog.c
program_view.c
program_view.h)
find_package(Curses)

View File

@ -8,12 +8,11 @@
#include "debugger.h"
#include "memory_view.h"
#include "dialog.h"
#include "program_view.h"
#define CTRL_KEY_EXIT 3
#define CTRL_KEY_G 103
MemoryView view;
void create_window() {
setenv("TERMINFO", "/usr/share/terminfo", 1);
setenv("TERM", "xterm", 1);
@ -26,9 +25,13 @@ void create_window() {
}
void start_debugger(System *system) {
MemoryView m_view;
ProgramView p_view;
create_window();
memory_view_init(&view, system->ram);
memory_view_init(&m_view, system->ram, 0, 0);
program_view_init(&p_view, MEMORY_VIEW_WIDTH, 0);
update_panels();
doupdate();
@ -36,19 +39,19 @@ void start_debugger(System *system) {
int keycode;
while ((keycode = getch()) != CTRL_KEY_EXIT) {
if (keycode == KEY_UP) {
memory_view_move_cursor(&view, 0, MEMORY_VIEW_DIRECTION_DOWN);
memory_view_move_cursor(&m_view, 0, MEMORY_VIEW_DIRECTION_DOWN);
}
if (keycode == KEY_DOWN) {
memory_view_move_cursor(&view, 0, MEMORY_VIEW_DIRECTION_UP);
memory_view_move_cursor(&m_view, 0, MEMORY_VIEW_DIRECTION_UP);
}
if (keycode == KEY_LEFT) {
memory_view_move_cursor(&view, MEMORY_VIEW_DIRECTION_LEFT, 0);
memory_view_move_cursor(&m_view, MEMORY_VIEW_DIRECTION_LEFT, 0);
}
if (keycode == KEY_RIGHT) {
memory_view_move_cursor(&view, MEMORY_VIEW_DIRECTION_RIGHT, 0);
memory_view_move_cursor(&m_view, MEMORY_VIEW_DIRECTION_RIGHT, 0);
}
if (keycode == CTRL_KEY_G) {
@ -59,8 +62,8 @@ void start_debugger(System *system) {
dialog_remove(&dialog);
if (!cancelled) {
memory_view_goto(&view, input);
memory_view_set_cursor_addr(&view, input);
memory_view_goto(&m_view, input);
memory_view_set_cursor_addr(&m_view, input);
}
}

View File

@ -30,7 +30,7 @@ void memory_view_set_cursor_pos(MemoryView *view, int x, int y) {
memory_view_highlight_cursor(view);
}
void write_line(WINDOW *window, int line, address base_address, byte *data) {
void memory_view_write_line(WINDOW *window, int line, address base_address, byte *data) {
mvwprintw(window, line + 2, 1, "[%04x]", base_address);
for (int i = 0; i <= MEMORY_VIEW_LINE_BYTE_COUNT; i++) {
@ -38,8 +38,8 @@ void write_line(WINDOW *window, int line, address base_address, byte *data) {
}
}
void memory_view_init(MemoryView *view, ram ram) {
WINDOW *window = newwin(MEMORY_VIEW_HEIGHT, MEMORY_VIEW_WIDTH, 0, 0);
void memory_view_init(MemoryView *view, ram ram, int x, int y) {
WINDOW *window = newwin(MEMORY_VIEW_HEIGHT, MEMORY_VIEW_WIDTH, y, x);
box(window, 0, 0);
mvwprintw(window, 0, 1, " MEMORY VIEW ");
@ -60,7 +60,7 @@ void memory_view_print(MemoryView *view) {
address line_address = view->base_address + line * (MEMORY_VIEW_LINE_BYTE_COUNT + 1);
byte *data = &view->ram[line_address];
write_line(view->panel->win, line, line_address, data);
memory_view_write_line(view->panel->win, line, line_address, data);
}
}
@ -101,6 +101,7 @@ void memory_view_move_cursor(MemoryView *view, char horizontal, char vertical) {
if (vertical == MEMORY_VIEW_DIRECTION_RIGHT && view->cursor_y == 0xf ||
vertical == MEMORY_VIEW_DIRECTION_LEFT && view->cursor_y == 0) {
memory_view_scroll(view, vertical);
memory_view_highlight_cursor(view);
return;
}

View File

@ -34,7 +34,7 @@ typedef struct memory_view {
* @param view A pointer to the view to initialize
* @param ram A pointer to the RAM
*/
void memory_view_init(MemoryView *view, ram ram);
void memory_view_init(MemoryView *view, ram ram, int x, int y);
/**
* Prints the RAM content from the viewer base address.

43
debugger/program_view.c Normal file
View File

@ -0,0 +1,43 @@
//
// Created by william on 10/01/24.
//
#include "program_view.h"
#include "../cpu/op.h"
void decode_operands(byte *ram, address start_addr) {
int pc = start_addr;
for (int i = 0; i < 10; i++) {
DebugOperand operand;
byte op_code = ram[pc];
operand.op_code = op_code;
operand.addr_mode = get_op_addr_mode(op_code);
}
}
void program_view_write_line(WINDOW *window, int line, address addr) {
mvwprintw(window, line + 1, 1, "%04x:", addr);
mvwprintw(window, line + 1, 7, "%s", "BRK");
}
void program_view_print(ProgramView *view) {
for (int line = 0; line <= 0xf; line++) {
address addr = 0x8000 + line;
program_view_write_line(view->panel->win, line, addr);
}
}
void program_view_init(ProgramView *view, ram ram, int x, int y) {
WINDOW *window = newwin(PROGRAM_VIEW_HEIGHT, PROGRAM_VIEW_WIDTH, y, x);
box(window, 0, 0);
mvwprintw(window, 0, 1, " PROGRAM VIEW ");
view->panel = new_panel(window);
view->ram = ram;
program_view_print(view);
}

28
debugger/program_view.h Normal file
View File

@ -0,0 +1,28 @@
//
// Created by william on 10/01/24.
//
#include <panel.h>
#include "../include/types.h"
#include "../cpu/decoding.h"
#ifndef NESEMULATOR_PROGRAM_VIEW_H
#define NESEMULATOR_PROGRAM_VIEW_H
#define PROGRAM_VIEW_HEIGHT 19
#define PROGRAM_VIEW_WIDTH 42
typedef struct program_view {
PANEL *panel;
byte *ram;
address base_address;
} ProgramView;
typedef struct debug_operand {
byte op_code;
AddressingMode addr_mode;
} DebugOperand;
void program_view_init(ProgramView *view, ram ram, int x, int y);
#endif //NESEMULATOR_PROGRAM_VIEW_H