Mercurial > repos > blastem
annotate stateview.c @ 354:15dd6418fe67
Initial PSG support. Mostly works, noise channel is borked though.
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Thu, 23 May 2013 23:42:42 -0700 |
parents | 8e2fa485c0f2 |
children | 7e8e179116af |
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 | 5 #include "blastem.h" |
6 | |
7 //not used, but referenced by the renderer since it handles input | |
8 io_port gamepad_1; | |
9 io_port gamepad_2; | |
10 | |
11 uint16_t read_dma_value(uint32_t address) | |
12 { | |
13 return 0; | |
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 | 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 } |