Rev 2246 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log
Rev 2246 | Rev 2254 | ||
---|---|---|---|
Line 7... | Line 7... | ||
7 | 7 | ||
8 | #include "z80-wrap.h" |
8 | #include "z80-wrap.h" |
9 | 9 | ||
10 | #define MAX_Z80_CLOCKS (50000000000ULL) |
10 | #define MAX_Z80_CLOCKS (50000000000ULL) |
11 | 11 | ||
- | 12 | struct type_detect type_list[] = |
|
- | 13 | { |
|
- | 14 | {"--cpm", SYS_CPM}, |
|
- | 15 | {"--nedoos", SYS_NEDOOS}, |
|
- | 16 | {"--zx", SYS_ZX}, |
|
- | 17 | {NULL, 0} |
|
- | 18 | }; |
|
- | 19 | ||
12 | int main(int argc, char ** argv) |
20 | int main(int argc, char ** argv) |
13 | { |
21 | { |
- | 22 | int sys_type = (-1); |
|
- | 23 | ||
- | 24 | if( argc>1 ) |
|
- | 25 | { |
|
- | 26 | struct type_detect * ptr = type_list; |
|
- | 27 | ||
- | 28 | while( ptr->argument_name ) |
|
- | 29 | { |
|
14 | if( argc!=3 || (strcmp(argv[1],"--cpm") && strcmp(argv[1],"--nedoos")) ) |
30 | if( !strcmp(ptr->argument_name,argv[1]) ) |
- | 31 | { |
|
- | 32 | sys_type = ptr->sys_type; |
|
- | 33 | } |
|
- | 34 | ||
- | 35 | ptr++; |
|
- | 36 | } |
|
- | 37 | } |
|
- | 38 | ||
- | 39 | if( argc!=3 || sys_type<=0 ) |
|
15 | { |
40 | { |
16 | fprintf(stderr,"There must be exactly two arguments!\n"); |
41 | fprintf(stderr,"There must be exactly two arguments!\n"); |
17 | fprintf(stderr," First: either --cpm or --nedoos\n"); |
42 | fprintf(stderr," First: either --cpm, --zx or --nedoos\n"); |
18 | fprintf(stderr," Second: filename to load\n"); |
43 | fprintf(stderr," Second: filename to load\n"); |
19 | exit(1); |
44 | exit(1); |
20 | } |
45 | } |
21 | 46 | ||
22 | struct z80_context * z80 = z80_init(argv[2],strcmp(argv[1],"--cpm")); |
47 | struct z80_context * z80 = z80_init(argv[2],sys_type); |
23 | if( !z80 ) |
48 | if( !z80 ) |
24 | { |
49 | { |
25 | fprintf(stderr,"Can't init z80 struct!\n"); |
50 | fprintf(stderr,"Can't init z80 struct!\n"); |
26 | exit(1); |
51 | exit(1); |
27 | } |
52 | } |
28 | 53 | ||
29 | z80_exec(z80,MAX_Z80_CLOCKS,0x100); |
54 | z80_exec(z80,MAX_Z80_CLOCKS); |
30 | 55 | ||
31 | fprintf(stderr,"Max clocks of %llu exceeded, probably a lock-up!",MAX_Z80_CLOCKS); |
56 | fprintf(stderr,"Max clocks of %llu exceeded, probably a lock-up!",MAX_Z80_CLOCKS); |
32 | exit(1); |
57 | exit(1); |
33 | 58 | ||
34 | return 0; |
59 | return 0; |