annotate stateview.c @ 338:5c34a9c39394

Re-enable frame limit, but add a command line flag to disable it
author Mike Pavone <pavone@retrodev.com>
date Wed, 15 May 2013 22:37:25 -0700
parents 8e2fa485c0f2
children 7e8e179116af
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
1 #include <stdlib.h>
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
2 #include <stdio.h>
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
3 #include "vdp.h"
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
4 #include "render.h"
75
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
5 #include "blastem.h"
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
6
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
7 //not used, but referenced by the renderer since it handles input
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
8 io_port gamepad_1;
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
9 io_port gamepad_2;
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
10
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
11 uint16_t read_dma_value(uint32_t address)
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
12 {
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
13 return 0;
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
14 }
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
15
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
16 int main(int argc, char ** argv)
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
17 {
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
18 if (argc < 2) {
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
19 fprintf(stderr, "Usage: stateview FILENAME\n");
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
20 exit(1);
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
21 }
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
22 FILE * state_file = fopen(argv[1], "rb");
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
23 if (!state_file) {
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
24 fprintf(stderr, "Failed to open %s\n", argv[1]);
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
25 exit(1);
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
26 }
33
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
27 int width = 320;
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
28 int height = 240;
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
29 if (argc > 2) {
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
30 width = atoi(argv[2]);
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
31 if (argc > 3) {
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
32 height = atoi(argv[3]);
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
33 } else {
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
34 height = (width/320) * 240;
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
35 }
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
36 }
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
37 vdp_context context;
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
38 init_vdp_context(&context);
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
39 vdp_load_savestate(&context, state_file);
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
40 vdp_run_to_vblank(&context);
322
8e2fa485c0f2 Remove z80_ram reference in SDL renderer to get stateview compiling again. Print out the sprite list in stateview.
Mike Pavone <pavone@retrodev.com>
parents: 75
diff changeset
41 vdp_print_sprite_table(&context);
75
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
42 printf("Display %s\n", (context.regs[REG_MODE_2] & DISPLAY_ENABLE) ? "enabled" : "disabled");
33
2e15fa26fe58 Add support for simple resolution scaling
Mike Pavone <pavone@retrodev.com>
parents: 20
diff changeset
43 render_init(width, height);
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
44 render_context(&context);
43
3fc57e1a2c56 Add debug render mode and fix vertical flip bit for bg tiles
Mike Pavone <pavone@retrodev.com>
parents: 33
diff changeset
45 render_wait_quit(&context);
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 return 0;
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
47 }