Rev 2246 | Details | Compare with Previous | Last modification | View Log
Rev | Author | Line No. | Line |
---|---|---|---|
2242 | lvd | 1 | #include <stdint.h> |
2 | #include <stdio.h> |
||
3 | #include <stdlib.h> |
||
2243 | lvd | 4 | #include <string.h> |
2242 | lvd | 5 | |
6 | #include "zetaZ80/Z80_lite.h" |
||
7 | |||
8 | #include "z80-wrap.h" |
||
9 | |||
2246 | lvd | 10 | #define MAX_Z80_CLOCKS (50000000000ULL) |
11 | |||
2254 | lvd | 12 | struct type_detect type_list[] = |
13 | { |
||
14 | {"--cpm", SYS_CPM}, |
||
15 | {"--nedoos", SYS_NEDOOS}, |
||
16 | {"--zx", SYS_ZX}, |
||
17 | {NULL, 0} |
||
18 | }; |
||
19 | |||
2242 | lvd | 20 | int main(int argc, char ** argv) |
21 | { |
||
2254 | lvd | 22 | int sys_type = (-1); |
23 | |||
24 | if( argc>1 ) |
||
2242 | lvd | 25 | { |
2254 | lvd | 26 | struct type_detect * ptr = type_list; |
27 | |||
28 | while( ptr->argument_name ) |
||
29 | { |
||
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 ) |
||
40 | { |
||
2243 | lvd | 41 | fprintf(stderr,"There must be exactly two arguments!\n"); |
2254 | lvd | 42 | fprintf(stderr," First: either --cpm, --zx or --nedoos\n"); |
2243 | lvd | 43 | fprintf(stderr," Second: filename to load\n"); |
2242 | lvd | 44 | exit(1); |
45 | } |
||
46 | |||
2254 | lvd | 47 | struct z80_context * z80 = z80_init(argv[2],sys_type); |
2246 | lvd | 48 | if( !z80 ) |
2242 | lvd | 49 | { |
2246 | lvd | 50 | fprintf(stderr,"Can't init z80 struct!\n"); |
51 | exit(1); |
||
2242 | lvd | 52 | } |
53 | |||
2254 | lvd | 54 | z80_exec(z80,MAX_Z80_CLOCKS); |
2242 | lvd | 55 | |
2246 | lvd | 56 | fprintf(stderr,"Max clocks of %llu exceeded, probably a lock-up!",MAX_Z80_CLOCKS); |
57 | exit(1); |
||
58 | |||
2242 | lvd | 59 | return 0; |
60 | } |
||
61 |