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