Mercurial > repos > blastem
annotate stateview.c @ 1645:84ef1eb2c96a
Added code for actually saving new controller bindings to an appropriate key in the config file
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Fri, 30 Nov 2018 00:35:05 -0800 |
parents | 3602f3b20072 |
children | c9695252eff4 |
rev | line source |
---|---|
467
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
465
diff
changeset
|
1 /* |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
465
diff
changeset
|
2 Copyright 2013 Michael Pavone |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
465
diff
changeset
|
3 This file is part of BlastEm. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
465
diff
changeset
|
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. |
140af5509ce7
Added copyright notice to source files and added GPL license text in COPYING
Mike Pavone <pavone@retrodev.com>
parents:
465
diff
changeset
|
5 */ |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
6 #include <stdlib.h> |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
7 #include <stdio.h> |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
8 #include "vdp.h" |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
9 #include "render.h" |
793
9aff36a172b2
Fix missing includes of util.h
Michael Pavone <pavone@retrodev.com>
parents:
792
diff
changeset
|
10 #include "util.h" |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1101
diff
changeset
|
11 #include "genesis.h" |
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1101
diff
changeset
|
12 #include "config.h" |
75 | 13 |
783
e64975fc5f98
Fix stateview build and fix Makefile to use /bin/echo since builtin echo does not always support -e
Michael Pavone <pavone@retrodev.com>
parents:
719
diff
changeset
|
14 |
75 | 15 uint16_t read_dma_value(uint32_t address) |
16 { | |
17 return 0; | |
18 } | |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
19 |
962
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
20 m68k_context *m68k_handle_code_write(uint32_t address, m68k_context *context) |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
21 { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
22 return NULL; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
23 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
24 |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
25 z80_context *z80_handle_code_write(uint32_t address, z80_context *context) |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
26 { |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
27 return NULL; |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
28 } |
f52cb02a1466
Fixed loading save states from menu
Michael Pavone <pavone@retrodev.com>
parents:
959
diff
changeset
|
29 |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
30 void ym_data_write(ym2612_context * context, uint8_t value) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
31 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
32 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
33 |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
34 void ym_address_write_part1(ym2612_context * context, uint8_t address) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
35 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
36 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
37 |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
38 void ym_address_write_part2(ym2612_context * context, uint8_t address) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
39 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
40 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
41 |
1028
56b1748a8473
Initial stab at Saturn keyboard support
Michael Pavone <pavone@retrodev.com>
parents:
982
diff
changeset
|
42 void handle_keydown(int keycode, uint8_t scancode) |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
43 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
44 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
45 |
1028
56b1748a8473
Initial stab at Saturn keyboard support
Michael Pavone <pavone@retrodev.com>
parents:
982
diff
changeset
|
46 void handle_keyup(int keycode, uint8_t scancode) |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
47 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
48 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
49 |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
50 void handle_joydown(int joystick, int button) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
51 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
52 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
53 |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
54 void handle_joyup(int joystick, int button) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
55 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
56 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
57 |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
58 void handle_joy_dpad(int joystick, int dpadnum, uint8_t value) |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
59 { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
60 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
61 |
1210
c95893007a83
Fix vgmplay and stateview targets
Michael Pavone <pavone@retrodev.com>
parents:
1196
diff
changeset
|
62 void handle_joy_axis(int joystick, int axis, int16_t value) |
c95893007a83
Fix vgmplay and stateview targets
Michael Pavone <pavone@retrodev.com>
parents:
1196
diff
changeset
|
63 { |
c95893007a83
Fix vgmplay and stateview targets
Michael Pavone <pavone@retrodev.com>
parents:
1196
diff
changeset
|
64 } |
c95893007a83
Fix vgmplay and stateview targets
Michael Pavone <pavone@retrodev.com>
parents:
1196
diff
changeset
|
65 |
1196
74e77aec9004
Fix stateview and vgmplay targets
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
66 void handle_joy_added(int joystick) |
74e77aec9004
Fix stateview and vgmplay targets
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
67 { |
74e77aec9004
Fix stateview and vgmplay targets
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
68 } |
74e77aec9004
Fix stateview and vgmplay targets
Michael Pavone <pavone@retrodev.com>
parents:
1117
diff
changeset
|
69 |
959
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
70 void handle_mousedown(int mouse, int button) |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
71 { |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
72 } |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
73 |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
74 void handle_mouseup(int mouse, int button) |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
75 { |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
76 } |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
77 |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
78 void handle_mouse_moved(int mouse, uint16_t x, uint16_t y, int16_t deltax, int16_t deltay) |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
79 { |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
80 } |
3b270fc43ed4
Get stateview building again
Michael Pavone <pavone@retrodev.com>
parents:
931
diff
changeset
|
81 |
1607
0174759e559f
Fix a couple of default targets
Michael Pavone <pavone@retrodev.com>
parents:
1317
diff
changeset
|
82 void controller_add_mappings() |
0174759e559f
Fix a couple of default targets
Michael Pavone <pavone@retrodev.com>
parents:
1317
diff
changeset
|
83 { |
0174759e559f
Fix a couple of default targets
Michael Pavone <pavone@retrodev.com>
parents:
1317
diff
changeset
|
84 } |
0174759e559f
Fix a couple of default targets
Michael Pavone <pavone@retrodev.com>
parents:
1317
diff
changeset
|
85 |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
86 tern_node * config; |
703
6e751a8f46aa
Get save state viewer compiling again
Michael Pavone <pavone@retrodev.com>
parents:
467
diff
changeset
|
87 int headless = 0; |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
88 |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
89 int main(int argc, char ** argv) |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
90 { |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
91 if (argc < 2) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
783
diff
changeset
|
92 fatal_error("Usage: stateview FILENAME\n"); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
93 } |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
94 FILE * state_file = fopen(argv[1], "rb"); |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
95 if (!state_file) { |
792
724bbec47f86
Use a new fatal_error function instead of calling fprintf and exit for fatal errors. This new function more gracefully handles the case in which BlastEm was not started from a terminal or disconnected from ther terminal (Windows).
Michael Pavone <pavone@retrodev.com>
parents:
783
diff
changeset
|
96 fatal_error("Failed to open %s\n", argv[1]); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
97 } |
812
574495372d1c
Finish OS X support in build_release script. Fix a name conflict in vgmplay on OS X. Call set_exe_str in vgmplay and stateview
Michael Pavone <pavone@retrodev.com>
parents:
793
diff
changeset
|
98 set_exe_str(argv[0]); |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
99 config = load_config(argv[0]); |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
100 int width = -1; |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
101 int height = -1; |
33
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
102 if (argc > 2) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
103 width = atoi(argv[2]); |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
104 if (argc > 3) { |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
105 height = atoi(argv[3]); |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
106 } |
2e15fa26fe58
Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents:
20
diff
changeset
|
107 } |
465
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
108 int def_width = 0; |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
109 char *config_width = tern_find_ptr(config, "videowidth"); |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
110 if (config_width) { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
111 def_width = atoi(config_width); |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
112 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
113 if (!def_width) { |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
114 def_width = 640; |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
115 } |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
116 width = width < 320 ? def_width : width; |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
117 height = height < 240 ? (width/320) * 240 : height; |
dc322bc77ea2
Fix stateview. Update "all" target in Makefile.
Mike Pavone <pavone@retrodev.com>
parents:
424
diff
changeset
|
118 |
1103
22e87b739ad6
WIP split of ROM loading/argument parsing from Genesis emulation code. Compiles and doesn't crash, but nothing works. Still a few too many globals as well.
Michael Pavone <pavone@retrodev.com>
parents:
1101
diff
changeset
|
119 render_init(width, height, "GST State Viewer", 0); |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
120 vdp_context *context = init_vdp_context(0); |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
121 vdp_load_gst(context, state_file); |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
122 vdp_run_to_vblank(context); |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
123 vdp_print_sprite_table(context); |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
124 printf("Display %s\n", (context->regs[REG_MODE_2] & DISPLAY_ENABLE) ? "enabled" : "disabled"); |
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
125 if (!(context->regs[REG_MODE_2] & DISPLAY_ENABLE)) { |
1317
32e95d6733a6
Force display on in stateview if given a save state with the display off
Michael Pavone <pavone@retrodev.com>
parents:
1210
diff
changeset
|
126 puts("Forcing display on"); |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
127 vdp_control_port_write(context, 0x8000 | REG_MODE_2 << 8 | context->regs[REG_MODE_2] | DISPLAY_ENABLE); |
1317
32e95d6733a6
Force display on in stateview if given a save state with the display off
Michael Pavone <pavone@retrodev.com>
parents:
1210
diff
changeset
|
128 } |
1640
3602f3b20072
Small cleanup of vdp_context struct layout and removal of separately allocated buffers
Michael Pavone <pavone@retrodev.com>
parents:
1607
diff
changeset
|
129 render_wait_quit(context); |
20
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
130 return 0; |
f664eeb55cb4
Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
131 } |