mirror of
https://github.com/n64dev/cen64.git
synced 2024-06-23 14:33:13 -04:00
Add a -nointerface switch, remove spare '\t's.
This commit is contained in:
parent
71a126e425
commit
538e344442
|
@ -18,13 +18,13 @@ static void rotate_right(struct memory_map *, struct memory_map_node *);
|
|||
// Creates a new memory map.
|
||||
void create_memory_map(struct memory_map *map) {
|
||||
map->next_map_index = 1;
|
||||
map->nil = map->mappings;
|
||||
map->nil = map->mappings;
|
||||
map->root = map->nil;
|
||||
}
|
||||
|
||||
// Rebalances the tree after a node is inserted.
|
||||
void fixup(struct memory_map *map, struct memory_map_node *node) {
|
||||
struct memory_map_node *cur;
|
||||
struct memory_map_node *cur;
|
||||
|
||||
// Rebalance the whole tree as needed.
|
||||
while (node->parent->color == MEMORY_MAP_RED) {
|
||||
|
@ -91,10 +91,10 @@ int map_address_range(struct memory_map *map, uint32_t start, uint32_t length,
|
|||
void *instance, memory_rd_function on_read, memory_wr_function on_write) {
|
||||
struct memory_map_node *check = map->root;
|
||||
struct memory_map_node *cur = map->nil;
|
||||
uint32_t end = start + length - 1;
|
||||
uint32_t end = start + length - 1;
|
||||
|
||||
struct memory_map_node *new_node;
|
||||
struct memory_mapping mapping;
|
||||
struct memory_mapping mapping;
|
||||
|
||||
// Make sure we have enough space in the map.
|
||||
const unsigned num_mappings = sizeof(map->mappings) /
|
||||
|
@ -115,7 +115,7 @@ int map_address_range(struct memory_map *map, uint32_t start, uint32_t length,
|
|||
? check->left : check->right;
|
||||
}
|
||||
|
||||
// Insert the entry.
|
||||
// Insert the entry.
|
||||
if (cur == map->nil)
|
||||
map->root = new_node;
|
||||
|
||||
|
@ -128,20 +128,20 @@ int map_address_range(struct memory_map *map, uint32_t start, uint32_t length,
|
|||
new_node->right = map->nil;
|
||||
new_node->parent = cur;
|
||||
|
||||
// Initialize the entry.
|
||||
mapping.instance = instance;
|
||||
mapping.on_read = on_read;
|
||||
mapping.on_write = on_write;
|
||||
// Initialize the entry.
|
||||
mapping.instance = instance;
|
||||
mapping.on_read = on_read;
|
||||
mapping.on_write = on_write;
|
||||
|
||||
mapping.end = end;
|
||||
mapping.length = length;
|
||||
mapping.start = start;
|
||||
mapping.end = end;
|
||||
mapping.length = length;
|
||||
mapping.start = start;
|
||||
|
||||
new_node->mapping = mapping;
|
||||
new_node->mapping = mapping;
|
||||
|
||||
// Rebalance the tree.
|
||||
// Rebalance the tree.
|
||||
new_node->color = MEMORY_MAP_RED;
|
||||
fixup(map, new_node);
|
||||
fixup(map, new_node);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ struct memory_map_node {
|
|||
struct memory_map_node *parent;
|
||||
struct memory_map_node *right;
|
||||
|
||||
struct memory_mapping mapping;
|
||||
struct memory_mapping mapping;
|
||||
enum memory_map_color color;
|
||||
};
|
||||
|
||||
|
|
|
@ -16,14 +16,14 @@
|
|||
|
||||
// Writes a formatted string to standard output.
|
||||
int debug(const char *fmt, ...) {
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_list ap;
|
||||
int ret;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = vfprintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
va_start(ap, fmt);
|
||||
ret = vfprintf(stdout, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
return ret;
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -18,6 +18,7 @@ const struct cen64_options default_cen64_options = {
|
|||
false, // console
|
||||
#endif
|
||||
false, // extra_mode
|
||||
false, // no_interface
|
||||
};
|
||||
|
||||
// Parses the passed command line arguments.
|
||||
|
@ -33,7 +34,10 @@ int parse_options(struct cen64_options *options, int argc, const char *argv[]) {
|
|||
else
|
||||
#endif
|
||||
|
||||
if (!strcmp(argv[i], "-printsimstats"))
|
||||
if (!strcmp(argv[i], "-nointerface"))
|
||||
options->no_interface = true;
|
||||
|
||||
else if (!strcmp(argv[i], "-printsimstats"))
|
||||
options->extra_mode = true;
|
||||
|
||||
else
|
||||
|
@ -53,6 +57,7 @@ void print_command_line_usage(const char *invokation_string) {
|
|||
#ifdef _WIN32
|
||||
" -console : Creates/shows the system console.\n"
|
||||
#endif
|
||||
" -nointerface : Run simulator without a user interface.\n"
|
||||
" -printsimstats : Print simulation statistics at exit.\n",
|
||||
|
||||
invokation_string
|
||||
|
|
|
@ -13,13 +13,14 @@
|
|||
#include "common.h"
|
||||
|
||||
struct cen64_options {
|
||||
const char *pifrom_path;
|
||||
const char *cart_path;
|
||||
const char *pifrom_path;
|
||||
const char *cart_path;
|
||||
|
||||
#ifdef _WIN32
|
||||
bool console;
|
||||
#endif
|
||||
bool extra_mode;
|
||||
bool extra_mode;
|
||||
bool no_interface;
|
||||
};
|
||||
|
||||
extern const struct cen64_options default_cen64_options;
|
||||
|
|
|
@ -97,18 +97,23 @@ int os_main(struct cen64_options *options,
|
|||
|
||||
// Prevent debugging tools from raising warnings
|
||||
// about uninitialized memory being read, etc.
|
||||
device.vi.gl_window.window = &window;
|
||||
get_default_gl_window_hints(&hints);
|
||||
if (!options->no_interface) {
|
||||
device.vi.gl_window.window = &window;
|
||||
get_default_gl_window_hints(&hints);
|
||||
|
||||
if (create_gl_window(&device.bus, &device.vi.gl_window, &hints)) {
|
||||
printf("Failed to create a window.\n");
|
||||
if (create_gl_window(&device.bus, &device.vi.gl_window, &hints)) {
|
||||
printf("Failed to create a window.\n");
|
||||
|
||||
deallocate_ram(&hunk);
|
||||
return 1;
|
||||
deallocate_ram(&hunk);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
status = device_run(&device, options, ram, pifrom, cart);
|
||||
destroy_gl_window(&device.vi.gl_window);
|
||||
|
||||
if (!options->no_interface)
|
||||
destroy_gl_window(&device.vi.gl_window);
|
||||
|
||||
deallocate_ram(&hunk);
|
||||
return status;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ int WINAPI WinMain(HINSTANCE hInstance,
|
|||
|
||||
// Called when another simulation instance is desired.
|
||||
int cen64_win32_main(int argc, const char *argv[]) {
|
||||
struct cen64_options options = default_cen64_options;
|
||||
struct cen64_options options = default_cen64_options;
|
||||
struct rom_file pifrom, cart;
|
||||
int status;
|
||||
|
||||
|
|
|
@ -198,26 +198,26 @@ int get_matching_pixel_format(struct winapi_window *winapi_window,
|
|||
const struct gl_window_hints *hints) {
|
||||
GLuint pixel_format;
|
||||
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
32, // Color depth
|
||||
0, 0, 0, 0, 0, 0, // Color bits
|
||||
0, // Alpha buffer
|
||||
0, // Shift bit
|
||||
0, // Accumulation buffer
|
||||
0, 0, 0, 0, // Accumulation bits
|
||||
16, // Depth buffer
|
||||
0, // Stencil buffer
|
||||
0, // Auxiliary buffer
|
||||
PFD_MAIN_PLANE, // Drawing layer
|
||||
0, // Reserved
|
||||
0, 0, 0 // Layer masks
|
||||
};
|
||||
PIXELFORMATDESCRIPTOR pfd = {
|
||||
sizeof(PIXELFORMATDESCRIPTOR),
|
||||
1,
|
||||
PFD_DRAW_TO_WINDOW |
|
||||
PFD_SUPPORT_OPENGL |
|
||||
PFD_DOUBLEBUFFER,
|
||||
PFD_TYPE_RGBA,
|
||||
32, // Color depth
|
||||
0, 0, 0, 0, 0, 0, // Color bits
|
||||
0, // Alpha buffer
|
||||
0, // Shift bit
|
||||
0, // Accumulation buffer
|
||||
0, 0, 0, 0, // Accumulation bits
|
||||
16, // Depth buffer
|
||||
0, // Stencil buffer
|
||||
0, // Auxiliary buffer
|
||||
PFD_MAIN_PLANE, // Drawing layer
|
||||
0, // Reserved
|
||||
0, 0, 0 // Layer masks
|
||||
};
|
||||
|
||||
if (!(pixel_format = ChoosePixelFormat(winapi_window->h_dc, &pfd))) {
|
||||
debug("get_matching_pixel_format: No matching pixel formats found.\n");
|
||||
|
|
|
@ -66,11 +66,6 @@ void vi_cycle(struct vi_controller *vi) {
|
|||
offset = vi->regs[VI_ORIGIN_REG] & 0xFFFFFF;
|
||||
buffer = vi->bus->ri->ram + offset;
|
||||
|
||||
// We're at a vertical interrupt...
|
||||
// check if an exit was requested.
|
||||
if (os_exit_requested(&vi->gl_window))
|
||||
device_request_exit(vi->bus);
|
||||
|
||||
// Calculate the bounding positions.
|
||||
ra->x.start = vi->regs[VI_H_START_REG] >> 16 & 0x3FF;
|
||||
ra->x.end = vi->regs[VI_H_START_REG] & 0x3FF;
|
||||
|
@ -89,7 +84,13 @@ void vi_cycle(struct vi_controller *vi) {
|
|||
if (hres <= 0 || vres <= 0)
|
||||
type = 0;
|
||||
|
||||
os_render_frame(&vi->gl_window, buffer, hres, vres, hskip, type);
|
||||
// Interact with the user interface?
|
||||
if (likely(vi->gl_window.window)) {
|
||||
if (os_exit_requested(&vi->gl_window))
|
||||
device_request_exit(vi->bus);
|
||||
|
||||
os_render_frame(&vi->gl_window, buffer, hres, vres, hskip, type);
|
||||
}
|
||||
|
||||
// Raise an interrupt to indicate refresh.
|
||||
signal_rcp_interrupt(vi->bus->vr4300, MI_INTR_VI);
|
||||
|
|
Loading…
Reference in a new issue