make new charset

This commit is contained in:
sfja 2025-03-31 15:23:07 +02:00
parent db6e20b4b1
commit ab55a9ff16
2 changed files with 72 additions and 29 deletions

View File

@ -195,6 +195,8 @@ static inline uint16_t linety_arithm_ins(LineTy ty);
void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
{
bool debug = false;
uint16_t ip = 0;
typedef struct {
@ -218,8 +220,11 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
out[ip++] = 0; \
}
if (debug) {
printf("assembling...\n");
printf("ip op n data...\n");
}
for (size_t i = 0; i < lines_size; ++i) {
bool is_label = false;
bool is_data = false;
@ -474,6 +479,7 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
}
}
if (debug) {
if (!is_label) {
printf("%02x %-5s %d",
ins_ip * 2,
@ -489,9 +495,12 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
printf("\n");
}
}
}
if (debug) {
printf("resolving...\n");
printf(" l ip v data\n");
}
for (size_t i = 0; i < unres_labels_size; ++i) {
bool found = false;
for (size_t j = 0; j < res_labels_size; ++j) {
@ -499,7 +508,9 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
out[unres_labels[i].ptr] = res_labels[j].ip;
found = true;
printf("%2d %02x %02x %02x %c%c%c%c %c%c%c%c %02x %c%c%c%c "
if (debug) {
printf(
"%2d %02x %02x %02x %c%c%c%c %c%c%c%c %02x %c%c%c%c "
"%c%c%c%c\n",
res_labels[j].label,
unres_labels[i].ptr * 2,
@ -508,6 +519,7 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
fmt_binary(out[unres_labels[i].ptr] & 0xff),
out[unres_labels[i].ptr] >> 8,
fmt_binary(out[unres_labels[i].ptr] >> 8));
}
break;
}
}
@ -517,8 +529,10 @@ void assemble_to_binary(uint16_t* out, const Line* lines, size_t lines_size)
unres_labels[i].label);
}
}
if (debug) {
printf("done!\n");
}
}
static inline void add_dst_reg(uint32_t* ins, uint16_t reg)
{

View File

@ -184,6 +184,7 @@ void sdldevice_destroy(SdlDevice* device)
}
extern const bool charset[][ch_height][ch_width];
extern const uint64_t charset_2[];
void sdldevice_set_char(IODevice* io_device, uint16_t offset, uint8_t value)
{
@ -207,7 +208,9 @@ void sdldevice_set_char(IODevice* io_device, uint16_t offset, uint8_t value)
for (int ch_y = 0; ch_y < ch_height; ++ch_y) {
for (int ch_x = 0; ch_x < ch_width; ++ch_x) {
bool ch = charset[value][ch_y][ch_x];
bool ch
= charset_2[value] >> (ch_y * ch_width + (ch_width - ch_x - 1))
& 1;
for (int px_y = 0; px_y < px_height; ++px_y) {
for (int px_x = 0; px_x < px_width; ++px_x) {
@ -475,14 +478,14 @@ int main(void)
for (int y = 0; y < ch_height; ++y) {
for (int x = 0; x < ch_width; ++x) {
if (charset[i][y][x]) {
ch |= 1 << (y * ch_width + (ch_height - x - 1));
ch |= 1ul << (y * ch_width + (ch_height - x - 1));
}
}
}
printf("['%c'] = 0x%lX,\n", i, ch);
}
return 0;
// return 0;
MemDrive drive;
memdrive_construct(&drive, (uint64_t*)program, 512);
@ -505,6 +508,32 @@ const char* __asan_default_options(void)
const uint64_t charset_2[] = {
[' '] = 0x0000000000000000,
['A'] = 0x66667E66667E1800,
['B'] = 0x7C7E667C667E7800,
['C'] = 0x3C7E6060607E3C00,
['D'] = 0x7C7E6666667E7C00,
['E'] = 0x7E7E607E607E7E00,
['F'] = 0x60607878607E7E00,
['G'] = 0x7E7E666E607E7E00,
['H'] = 0x6666667E7E666600,
['I'] = 0x7E7E1818187E7E00,
['J'] = 0x3C7E6606067E7E00,
['K'] = 0x666E7C7C6E666600,
['L'] = 0x7E7E606060606000,
['M'] = 0xC3C3C3C3DBFFE700,
['N'] = 0x6666666E7E766600,
['O'] = 0x3C66666666663C00,
['P'] = 0x60607C7E667C7C00,
['Q'] = 0x3F7E6E66667E3C00,
['R'] = 0x666C7C7E667E7C00,
['S'] = 0x3C66063C60663C00,
['T'] = 0x18181818187E7E00,
['U'] = 0x3C7E666666666600,
['V'] = 0x183C7E6666666600,
['W'] = 0xE7FFDBDBC3C3C300,
['X'] = 0x6666663C3C666600,
['Y'] = 0x181818183C666600,
['Z'] = 0x7E7E30180C7E7E00,
};
#define _ false,