main
stateview.c
1/*
2 Copyright 2013 Michael Pavone
3 This file is part of BlastEm.
4 BlastEm is free software distributed under the terms of the GNU General Public License version 3 or greater. See COPYING for full license text.
5*/
6#include <stdlib.h>
7#include <stdio.h>
8#include "vdp.h"
9#include "render.h"
10#include "util.h"
11#include "genesis.h"
12#include "config.h"
13
14
15uint16_t read_dma_value(uint32_t address)
16{
17 return 0;
18}
19
20m68k_context *m68k_handle_code_write(uint32_t address, m68k_context *context)
21{
22 return NULL;
23}
24
25z80_context *z80_handle_code_write(uint32_t address, z80_context *context)
26{
27 return NULL;
28}
29
30void ym_data_write(ym2612_context * context, uint8_t value)
31{
32}
33
34void ym_address_write_part1(ym2612_context * context, uint8_t address)
35{
36}
37
38void ym_address_write_part2(ym2612_context * context, uint8_t address)
39{
40}
41
42void handle_keydown(int keycode, uint8_t scancode)
43{
44}
45
46void handle_keyup(int keycode, uint8_t scancode)
47{
48}
49
50void handle_joydown(int joystick, int button)
51{
52}
53
54void handle_joyup(int joystick, int button)
55{
56}
57
58void handle_joy_dpad(int joystick, int dpadnum, uint8_t value)
59{
60}
61
62void handle_joy_axis(int joystick, int axis, int16_t value)
63{
64}
65
66void handle_joy_added(int joystick)
67{
68}
69
70void handle_mousedown(int mouse, int button)
71{
72}
73
74void handle_mouseup(int mouse, int button)
75{
76}
77
78void handle_mouse_moved(int mouse, uint16_t x, uint16_t y, int16_t deltax, int16_t deltay)
79{
80}
81
82tern_node * config;
83int headless = 0;
84
85int main(int argc, char ** argv)
86{
87 if (argc < 2) {
88 fatal_error("Usage: stateview FILENAME\n");
89 }
90 FILE * state_file = fopen(argv[1], "rb");
91 if (!state_file) {
92 fatal_error("Failed to open %s\n", argv[1]);
93 }
94 set_exe_str(argv[0]);
95 config = load_config(argv[0]);
96 int width = -1;
97 int height = -1;
98 if (argc > 2) {
99 width = atoi(argv[2]);
100 if (argc > 3) {
101 height = atoi(argv[3]);
102 }
103 }
104 int def_width = 0;
105 char *config_width = tern_find_ptr(config, "videowidth");
106 if (config_width) {
107 def_width = atoi(config_width);
108 }
109 if (!def_width) {
110 def_width = 640;
111 }
112 width = width < 320 ? def_width : width;
113 height = height < 240 ? (width/320) * 240 : height;
114
115 render_init(width, height, "GST State Viewer", 0);
116 vdp_context *context = init_vdp_context(0);
117 vdp_load_gst(context, state_file);
118 vdp_run_to_vblank(context);
119 vdp_print_sprite_table(context);
120 printf("Display %s\n", (context->regs[REG_MODE_2] & DISPLAY_ENABLE) ? "enabled" : "disabled");
121 if (!(context->regs[REG_MODE_2] & DISPLAY_ENABLE)) {
122 puts("Forcing display on");
123 vdp_control_port_write(context, 0x8000 | REG_MODE_2 << 8 | context->regs[REG_MODE_2] | DISPLAY_ENABLE);
124 }
125 render_wait_quit(context);
126 return 0;
127}