| 1 |
#include <fstream> |
| 2 |
#include <sstream> |
| 3 |
#include <string> |
| 4 |
|
| 5 |
#include <errno.h> |
| 6 |
#include <stdio.h> |
| 7 |
#include <stdlib.h> |
| 8 |
#include <string.h> |
| 9 |
#include <locale.h> |
| 10 |
|
| 11 |
#include "core_main.h" |
| 12 |
#include "core_globals.h" |
| 13 |
|
| 14 |
int main(int argc, char *argv[]) { |
| 15 |
if (argc != 2) { |
| 16 |
fprintf(stderr, "Usage: %s <raw-file>\nBuild date: %s\n", argv[0], __DATE__); |
| 17 |
return 1; |
| 18 |
} |
| 19 |
|
| 20 |
FILE *in = fopen(argv[1], "rb"); |
| 21 |
if (in == NULL) { |
| 22 |
fprintf(stderr, "Can't open input file: %s\n", strerror(errno)); |
| 23 |
return 1; |
| 24 |
} |
| 25 |
fclose(in); |
| 26 |
|
| 27 |
core_init(0, 0, NULL, 0); |
| 28 |
|
| 29 |
core_import_programs(0, argv[1]); |
| 30 |
|
| 31 |
int len = strlen(argv[1]); |
| 32 |
if (len >= 4 && strcasecmp(argv[1] + (len - 4), ".raw") == 0) |
| 33 |
len -= 4; |
| 34 |
std::string outname = std::string(argv[1], len) + ".txt"; |
| 35 |
|
| 36 |
FILE *out = fopen(outname.c_str(), "wb"); |
| 37 |
if (out == NULL) { |
| 38 |
fprintf(stderr, "Can't open output file: %s\n", strerror(errno)); |
| 39 |
return 1; |
| 40 |
} |
| 41 |
|
| 42 |
flags.f.prgm_mode = 1; |
| 43 |
for (int i = 0; i < prgms_count; i++) { |
| 44 |
current_prgm = i; |
| 45 |
char *txt = core_copy(); |
| 46 |
if (i > 0) |
| 47 |
fputs("\r\n", out); |
| 48 |
fputs(txt, out); |
| 49 |
free(txt); |
| 50 |
} |
| 51 |
fclose(out); |
| 52 |
|
| 53 |
return 0; |
| 54 |
} |
| 55 |
|
| 56 |
const char *shell_platform() { |
| 57 |
return NULL; |
| 58 |
} |
| 59 |
|
| 60 |
void shell_blitter(const char *bits, int bytesperline, int x, int y, |
| 61 |
int width, int height) { |
| 62 |
// |
| 63 |
} |
| 64 |
|
| 65 |
void shell_beeper(int tone) { |
| 66 |
// |
| 67 |
} |
| 68 |
|
| 69 |
void shell_annunciators(int updn, int shf, int prt, int run, int g, int rad) { |
| 70 |
// |
| 71 |
} |
| 72 |
|
| 73 |
bool shell_wants_cpu() { |
| 74 |
return false; |
| 75 |
} |
| 76 |
|
| 77 |
void shell_delay(int duration) { |
| 78 |
// |
| 79 |
} |
| 80 |
|
| 81 |
void shell_request_timeout3(int delay) { |
| 82 |
// |
| 83 |
} |
| 84 |
|
| 85 |
uint8 shell_get_mem() { |
| 86 |
return 0; |
| 87 |
} |
| 88 |
|
| 89 |
bool shell_low_battery() { |
| 90 |
return false; |
| 91 |
} |
| 92 |
|
| 93 |
void shell_powerdown() { |
| 94 |
// |
| 95 |
} |
| 96 |
|
| 97 |
int8 shell_random_seed() { |
| 98 |
return 0; |
| 99 |
} |
| 100 |
|
| 101 |
uint4 shell_milliseconds() { |
| 102 |
return 0; |
| 103 |
} |
| 104 |
|
| 105 |
const char *shell_number_format() { |
| 106 |
return localeconv()->decimal_point; |
| 107 |
} |
| 108 |
|
| 109 |
int shell_date_format() { |
| 110 |
return 0; |
| 111 |
} |
| 112 |
|
| 113 |
bool shell_clk24() { |
| 114 |
return false; |
| 115 |
} |
| 116 |
|
| 117 |
void shell_print(const char *text, int length, |
| 118 |
const char *bits, int bytesperline, |
| 119 |
int x, int y, int width, int height) { |
| 120 |
// |
| 121 |
} |
| 122 |
|
| 123 |
void shell_get_time_date(uint4 *time, uint4 *date, int *weekday) { |
| 124 |
*time = 0; |
| 125 |
*date = 15821015; |
| 126 |
*weekday = 5; |
| 127 |
} |
| 128 |
|
| 129 |
void shell_message(const char *message) { |
| 130 |
// |
| 131 |
} |
| 132 |
|
| 133 |
void shell_log(const char *message) { |
| 134 |
// |
| 135 |
} |