comparison testgst.c @ 451:b7c3b2d22858

Added support for saving savestates. Added gst savestate format test harness
author Mike Pavone <pavone@retrodev.com>
date Fri, 26 Jul 2013 19:55:04 -0700
parents
children 140af5509ce7
comparison
equal deleted inserted replaced
448:e85a107e6ec0 451:b7c3b2d22858
1 #include "gst.h"
2 #include <string.h>
3 #include <stdlib.h>
4
5 uint8_t busreq;
6 uint8_t reset;
7
8 int32_t color_map[1 << 12];
9
10 void latch_mode(vdp_context * context)
11 {
12 }
13 void ym_data_write(ym2612_context * context, uint8_t value)
14 {
15 if (context->selected_reg >= YM_REG_END) {
16 return;
17 }
18 if (context->selected_part) {
19 if (context->selected_reg < YM_PART2_START) {
20 return;
21 }
22 context->part2_regs[context->selected_reg - YM_PART2_START] = value;
23 } else {
24 if (context->selected_reg < YM_PART1_START) {
25 return;
26 }
27 context->part1_regs[context->selected_reg - YM_PART1_START] = value;
28 }
29 }
30
31 void ym_address_write_part1(ym2612_context * context, uint8_t address)
32 {
33 //printf("address_write_part1: %X\n", address);
34 context->selected_reg = address;
35 context->selected_part = 0;
36 }
37
38 void ym_address_write_part2(ym2612_context * context, uint8_t address)
39 {
40 //printf("address_write_part2: %X\n", address);
41 context->selected_reg = address;
42 context->selected_part = 1;
43 }
44
45 uint16_t ram[64*1024];
46 uint8_t zram[8*1024];
47
48
49 int main(int argc, char ** argv)
50 {
51 vdp_context vdp;
52 ym2612_context ym;
53 psg_context psg;
54 m68k_context m68k;
55 z80_context z80;
56 genesis_context gen;
57 if (argc < 3) {
58 fputs("Usage: testgst infile outfile\n", stderr);
59 return 1;
60 }
61 memset(&gen, 0, sizeof(gen));
62 memset(&m68k, 0, sizeof(m68k));
63 memset(&z80, 0, sizeof(z80));
64 memset(&ym, 0, sizeof(ym));
65 memset(&vdp, 0, sizeof(vdp));
66 memset(&psg, 0, sizeof(psg));
67 m68k.mem_pointers[1] = ram;
68 z80.mem_pointers[0] = zram;
69 vdp.vdpmem = malloc(VRAM_SIZE);
70 gen.vdp = &vdp;
71 gen.ym = &ym;
72 gen.psg = &psg;
73 gen.m68k = &m68k;
74 gen.z80 = &z80;
75 uint32_t pc = load_gst(&gen, argv[1]);
76 save_gst(&gen, argv[2], pc);
77 return 0;
78 }