2024-01-07 16:20:37 -05:00
|
|
|
//
|
2024-01-14 21:59:13 -05:00
|
|
|
// Created by william on 6/1/24.
|
2024-01-07 16:20:37 -05:00
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef NESEMULATOR_MEMORY_VIEW_H
|
|
|
|
#define NESEMULATOR_MEMORY_VIEW_H
|
|
|
|
|
|
|
|
#include <panel.h>
|
|
|
|
#include "../include/types.h"
|
2024-01-14 21:59:13 -05:00
|
|
|
#include "cursor.h"
|
|
|
|
#include "window.h"
|
2024-01-07 16:20:37 -05:00
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
typedef struct memory_view {
|
2024-01-14 21:59:13 -05:00
|
|
|
InteractWindow *window;
|
2024-01-09 14:46:20 -05:00
|
|
|
byte *ram;
|
2024-01-07 16:20:37 -05:00
|
|
|
address base_address;
|
|
|
|
} 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-04-30 11:18:34 -04:00
|
|
|
void mv_init(InteractWindow *interact, ram ram, int x, int y);
|
2024-01-07 16:20:37 -05:00
|
|
|
|
2024-01-09 15:56:54 -05:00
|
|
|
/**
|
|
|
|
* Prints the RAM content from the viewer base address.
|
|
|
|
*
|
|
|
|
* @param view
|
|
|
|
*/
|
2024-04-30 11:18:34 -04:00
|
|
|
void mv_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-04-30 11:18:34 -04:00
|
|
|
void mv_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-04-30 11:18:34 -04:00
|
|
|
void mv_scroll(MemoryView *view, int direction);
|
2024-01-09 14:46:20 -05:00
|
|
|
|
2024-01-09 15:56:54 -05:00
|
|
|
/**
|
|
|
|
* Moves the cursor up, down, right or left.
|
|
|
|
*
|
|
|
|
* @param view
|
|
|
|
* @param horizontal
|
|
|
|
* @param vertical
|
|
|
|
*/
|
2024-04-30 11:18:34 -04:00
|
|
|
void mv_cursor_move(InteractWindow *window, int horizontal, int vertical);
|
2024-01-09 14:46:20 -05:00
|
|
|
|
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-04-30 11:18:34 -04:00
|
|
|
void mv_cursor_set_addr(MemoryView *view, address target);
|
2024-01-07 16:20:37 -05:00
|
|
|
|
|
|
|
#endif //NESEMULATOR_MEMORY_VIEW_H
|