annotate stateview.c @ 95:dd3c680c618c

Initial work on allowing dynamic branches and code in RAM plus a small fix to effective address decoding
author Mike Pavone <pavone@retrodev.com>
date Thu, 27 Dec 2012 21:19:58 -0800
parents 108e587165c0
children 8e2fa485c0f2
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);
75
108e587165c0 Implement DMA (untested)
Mike Pavone <pavone@retrodev.com>
parents: 43
diff changeset
41 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
42 render_init(width, height);
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
43 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
44 render_wait_quit(&context);
20
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
45 return 0;
f664eeb55cb4 Mostly broken VDP core and savestate viewer
Mike Pavone <pavone@retrodev.com>
parents:
diff changeset
46 }