Mercurial > repos > blastem
comparison blastem.c @ 211:464513050c85
Small bit of cleanup
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 16 Apr 2013 09:31:21 -0700 |
parents | 209a37eed3e7 |
children | 2b1c2c28b261 |
comparison
equal
deleted
inserted
replaced
210:4beaad3a9a50 | 211:464513050c85 |
---|---|
794 } | 794 } |
795 } | 795 } |
796 return context; | 796 return context; |
797 } | 797 } |
798 | 798 |
799 int main(int argc, char ** argv) | 799 void init_run_cpu(vdp_context * vcontext, int debug, FILE * address_log) |
800 { | 800 { |
801 if (argc < 2) { | 801 m68k_context context; |
802 fputs("Usage: blastem FILENAME\n", stderr); | |
803 return 1; | |
804 } | |
805 if(!load_rom(argv[1])) { | |
806 fprintf(stderr, "Failed to open %s for reading\n", argv[1]); | |
807 return 1; | |
808 } | |
809 int width = -1; | |
810 int height = -1; | |
811 int debug = 0; | |
812 FILE *address_log = NULL; | |
813 for (int i = 2; i < argc; i++) { | |
814 if (argv[i][0] == '-') { | |
815 switch(argv[i][1]) { | |
816 case 'd': | |
817 debug = 1; | |
818 break; | |
819 case 'l': | |
820 address_log = fopen("address.log", "w"); | |
821 break; | |
822 default: | |
823 fprintf(stderr, "Unrecognized switch %s\n", argv[i]); | |
824 return 1; | |
825 } | |
826 } else if (width < 0) { | |
827 width = atoi(argv[i]); | |
828 } else if (height < 0) { | |
829 height = atoi(argv[i]); | |
830 } | |
831 } | |
832 width = width < 320 ? 320 : width; | |
833 height = height < 240 ? (width/320) * 240 : height; | |
834 render_init(width, height); | |
835 | |
836 x86_68k_options opts; | 802 x86_68k_options opts; |
837 m68k_context context; | |
838 vdp_context v_context; | |
839 | |
840 init_x86_68k_opts(&opts); | 803 init_x86_68k_opts(&opts); |
841 opts.address_log = address_log; | 804 opts.address_log = address_log; |
842 init_68k_context(&context, opts.native_code_map, &opts); | 805 init_68k_context(&context, opts.native_code_map, &opts); |
843 init_vdp_context(&v_context); | 806 |
844 context.next_context = &v_context; | 807 context.next_context = vcontext; |
845 //cartridge ROM | 808 //cartridge ROM |
846 context.mem_pointers[0] = cart; | 809 context.mem_pointers[0] = cart; |
847 context.target_cycle = context.sync_cycle = MCLKS_PER_FRAME/MCLKS_PER_68K; | 810 context.target_cycle = context.sync_cycle = MCLKS_PER_FRAME/MCLKS_PER_68K; |
848 //work RAM | 811 //work RAM |
849 context.mem_pointers[1] = ram; | 812 context.mem_pointers[1] = ram; |
858 translate_m68k_stream(address, &context); | 821 translate_m68k_stream(address, &context); |
859 if (debug) { | 822 if (debug) { |
860 insert_breakpoint(&context, address, (uint8_t *)debugger); | 823 insert_breakpoint(&context, address, (uint8_t *)debugger); |
861 } | 824 } |
862 m68k_reset(&context); | 825 m68k_reset(&context); |
826 } | |
827 | |
828 int main(int argc, char ** argv) | |
829 { | |
830 if (argc < 2) { | |
831 fputs("Usage: blastem FILENAME\n", stderr); | |
832 return 1; | |
833 } | |
834 if(!load_rom(argv[1])) { | |
835 fprintf(stderr, "Failed to open %s for reading\n", argv[1]); | |
836 return 1; | |
837 } | |
838 int width = -1; | |
839 int height = -1; | |
840 int debug = 0; | |
841 FILE *address_log = NULL; | |
842 for (int i = 2; i < argc; i++) { | |
843 if (argv[i][0] == '-') { | |
844 switch(argv[i][1]) { | |
845 case 'd': | |
846 debug = 1; | |
847 break; | |
848 case 'l': | |
849 address_log = fopen("address.log", "w"); | |
850 break; | |
851 default: | |
852 fprintf(stderr, "Unrecognized switch %s\n", argv[i]); | |
853 return 1; | |
854 } | |
855 } else if (width < 0) { | |
856 width = atoi(argv[i]); | |
857 } else if (height < 0) { | |
858 height = atoi(argv[i]); | |
859 } | |
860 } | |
861 width = width < 320 ? 320 : width; | |
862 height = height < 240 ? (width/320) * 240 : height; | |
863 render_init(width, height); | |
864 vdp_context v_context; | |
865 | |
866 init_vdp_context(&v_context); | |
867 init_run_cpu(&v_context, debug, address_log); | |
863 return 0; | 868 return 0; |
864 } | 869 } |