// // Created by william on 1/6/24. // #ifndef NESEMULATOR_MEMORY_VIEW_H #define NESEMULATOR_MEMORY_VIEW_H #include #include "../include/types.h" #define MEMORY_VIEW_HEIGHT 19 #define MEMORY_VIEW_WIDTH 56 #define MEMORY_VIEW_LINE_COUNT 0xf #define MEMORY_VIEW_LINE_BYTE_COUNT 0xf #define MEMORY_VIEW_BYTE_COUNT 0xff #define MEMORY_VIEW_DIRECTION_UP 1 #define MEMORY_VIEW_DIRECTION_DOWN (-1) #define MEMORY_VIEW_DIRECTION_RIGHT 1 #define MEMORY_VIEW_DIRECTION_LEFT (-1) typedef struct memory_view { PANEL *panel; byte *ram; address base_address; char cursor_x; char cursor_y; } MemoryView; /** * Initializes a memory view for a system RAM. * The viewer base address will be set to 0x0000, and the cursor (0, 0). * The content of the memory will be printed on a new curses window. * @param view A pointer to the view to initialize * @param ram A pointer to the RAM */ void memory_view_init(MemoryView *view, ram ram, int x, int y); /** * Prints the RAM content from the viewer base address. * * @param view */ void memory_view_print(MemoryView *view); /** * Sets the viewer base address to the target address page (the first byte) and prints the RAM. * * @param view * @param target The target address to print */ void memory_view_goto(MemoryView *view, address target); /** * Scrolls the base address up or down by steps of 0x10. * * @param view * @param direction The scroll direction */ void memory_view_scroll(MemoryView *view, char direction); /** * Moves the cursor up, down, right or left. * * @param view * @param horizontal * @param vertical */ void memory_view_move_cursor(MemoryView *view, char horizontal, char vertical); /** * Moves the cursor to a specific memory address. * The view will not be scrolled if the target address is not displayed. * * @param view * @param target */ void memory_view_set_cursor_addr(MemoryView *view, address target); #endif //NESEMULATOR_MEMORY_VIEW_H