nesemu/debugger/memory_view.h

81 lines
1.9 KiB
C
Raw Normal View History

2024-01-07 16:20:37 -05:00
//
// Created by william on 1/6/24.
//
#ifndef NESEMULATOR_MEMORY_VIEW_H
#define NESEMULATOR_MEMORY_VIEW_H
#include <panel.h>
#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
2024-01-09 14:46:20 -05:00
#define MEMORY_VIEW_DIRECTION_DOWN (-1)
2024-01-09 15:56:54 -05:00
#define MEMORY_VIEW_DIRECTION_RIGHT 1
#define MEMORY_VIEW_DIRECTION_LEFT (-1)
2024-01-07 16:20:37 -05:00
typedef struct memory_view {
PANEL *panel;
2024-01-09 14:46:20 -05:00
byte *ram;
2024-01-07 16:20:37 -05:00
address base_address;
2024-01-09 14:46:20 -05:00
char cursor_x;
char cursor_y;
2024-01-07 16:20:37 -05:00
} MemoryView;
2024-01-09 15:56:54 -05:00
/**
* 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
*/
2024-01-07 16:20:37 -05:00
void memory_view_init(MemoryView *view, ram ram);
2024-01-09 15:56:54 -05:00
/**
* Prints the RAM content from the viewer base address.
*
* @param view
*/
2024-01-09 14:46:20 -05:00
void memory_view_print(MemoryView *view);
2024-01-07 16:20:37 -05:00
2024-01-09 15:56:54 -05:00
/**
* 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
*/
2024-01-09 14:46:20 -05:00
void memory_view_goto(MemoryView *view, address target);
2024-01-07 16:20:37 -05:00
2024-01-09 15:56:54 -05:00
/**
* Scrolls the base address up or down by steps of 0x10.
*
* @param view
* @param direction The scroll direction
*/
2024-01-09 14:46:20 -05:00
void memory_view_scroll(MemoryView *view, char direction);
2024-01-09 15:56:54 -05:00
/**
* Moves the cursor up, down, right or left.
*
* @param view
* @param horizontal
* @param vertical
*/
2024-01-09 14:46:20 -05:00
void memory_view_move_cursor(MemoryView *view, char horizontal, char vertical);
2024-01-09 15:56:54 -05:00
/**
* 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
*/
2024-01-09 14:46:20 -05:00
void memory_view_set_cursor_addr(MemoryView *view, address target);
2024-01-07 16:20:37 -05:00
#endif //NESEMULATOR_MEMORY_VIEW_H