Added test suite. Fixed bugs in opcodes. Fixed font encoding.

This commit is contained in:
Maurizio Porrato 2020-04-27 07:41:02 +01:00
parent 9cb338f83e
commit 07b5b504ae
7 changed files with 275 additions and 187 deletions

View File

@ -9,13 +9,13 @@ def convert(filename, subset=range(0,128)):
img = Image.open(filename)
print("""#include <stdint.h>
uint16_t font[] = {""")
uint16_t default_font[] = {""")
grid = (img.size[0] // FONT_SIZE[0], img.size[1] // FONT_SIZE[1])
ch = 0
for r in range(grid[1]):
for c in range(grid[0]):
v = 0
for x in range(FONT_SIZE[0]-1, -1, -1):
for x in range(FONT_SIZE[0]):
for y in range(FONT_SIZE[1]-1, -1, -1):
v <<= 1
if img.getpixel((c*FONT_SIZE[0]+x,r*FONT_SIZE[1]+y)):
@ -27,7 +27,7 @@ uint16_t font[] = {""")
else:
d = ''
if ch in subset:
print(f"\t0x{l:04x}, 0x{h:04x},\t/* {ch:3d} 0x{ch:02x} {d}*/")
print(f"\t0x{h:04x}, 0x{l:04x},\t/* {ch:3d} 0x{ch:02x} {d}*/")
ch += 1
print("};")

View File

@ -33,7 +33,7 @@ void clock_tick()
if (jiffies >= clockdiv) {
jiffies = 0;
clock_ticks++;
printf("Tick!\n");
// printf("Tick!\n");
if (intmsg != 0) {
intq_push(intmsg);
}
@ -44,7 +44,7 @@ void clock_tick()
void clock_irqh()
{
printf("Clock: A=0x%04x B=0x%04x\n", ra, rb);
// printf("Clock: A=0x%04x B=0x%04x\n", ra, rb);
switch (ra) {
case 0:
clockdiv = rb;

View File

@ -74,18 +74,11 @@ void update_font()
printf("update_font()\n");
if (glyph_shapes == NULL) {
glyph_shapes = SDL_CreateRGBSurface(0, CHAR_W*128, CHAR_H*COLORS*COLORS, 8, 0, 0, 0, 0);
if (glyph_shapes == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
}
}
SDL_LockSurface(glyph_shapes);
raster = (uint8_t *)(glyph_shapes->pixels);
for (i=0; i<sizeof(default_font)/sizeof(default_font[0]); i++) {
for (j=0; j<16; j++) {
x = i*2+j/8;
x = i*2+(1-j/8);
y = j%8;
pixel = ((FONT(i)>>j) & 1) != 0;
// raster[x+y*glyph_shapes->w] = (pixel ? 1 : 0);
@ -107,8 +100,8 @@ void update_palette()
printf("update_palette()\n");
if (palette == NULL)
palette = SDL_AllocPalette(256);
// if (palette == NULL)
// palette = SDL_AllocPalette(256);
for (i=0; i<COLORS; i++) {
palette->colors[i].r = ((PALETTE(i)>>8)&0xf)*0xff/0xf;
@ -118,10 +111,6 @@ void update_palette()
// printf("%2d %02x%02x%02x\n", i, palette->colors[i].r, palette->colors[i].g, palette->colors[i].b);
}
if (glyph_tiles == NULL) {
glyph_tiles = SDL_CreateRGBSurface(0, glyph_shapes->w, glyph_shapes->h, 32, 0, 0, 0, 0);
}
update_glyph_tiles();
printf("update_palette() completed\n");
@ -134,6 +123,18 @@ void lem1802_init()
if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL could not initialize! SDL_Error: %s\n", SDL_GetError());
}
palette = SDL_AllocPalette(256);
glyph_shapes = SDL_CreateRGBSurface(0, CHAR_W*128, CHAR_H*COLORS*COLORS, 8, 0, 0, 0, 0);
if (glyph_shapes == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
}
// SDL_SetSurfacePalette(glyph_shapes, palette);
glyph_tiles = SDL_CreateRGBSurface(0, glyph_shapes->w, glyph_shapes->h, 32, 0, 0, 0, 0);
if (glyph_tiles == NULL) {
SDL_Log("SDL_CreateRGBSurface() failed: %s", SDL_GetError());
}
update_font();
update_palette();
}
void keyboard_init()
@ -150,6 +151,12 @@ void lem1802_free()
if (palette)
SDL_FreePalette(palette);
palette = NULL;
if (glyph_tiles)
SDL_FreeSurface(glyph_tiles);
glyph_tiles = NULL;
if (glyph_shapes)
SDL_FreeSurface(glyph_shapes);
glyph_shapes = NULL;
// SDL_Quit();
}
@ -159,6 +166,7 @@ void process_key(SDL_KeyboardEvent *ke)
if ((ke->keysym.sym >= 0x20) && (ke->keysym.sym <= 0x7f)) {
k = ke->keysym.sym;
// printf("sym=%d mod=%d\n", k, ke->keysym.mod);
} else {
switch (ke->keysym.sym) {
case SDLK_BACKSPACE:
@ -229,7 +237,10 @@ void lem1802_tick()
if (e.type == SDL_KEYDOWN) {
if (e.key.keysym.sym == SDLK_F12)
running = false;
else
else if (e.key.keysym.sym == SDLK_F11) {
update_font();
update_palette();
} else
process_key(&e.key);
}
}
@ -282,7 +293,7 @@ void lem1802_irqh()
if (screen_iptr == 0) {
if (rb != 0) {
/* LEM1802 power up */
gettimeofday(&poweron_time, NULL);
poweron_time.tv_sec = time.tv_sec; poweron_time.tv_usec = time.tv_usec;
window = SDL_CreateWindow("LEM1802", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, WINDOW_W, WINDOW_H, SDL_WINDOW_SHOWN);
if(window == NULL) {
printf("Window could not be created! SDL_Error: %s\n", SDL_GetError());
@ -290,8 +301,6 @@ void lem1802_irqh()
screenSurface = SDL_GetWindowSurface(window);
SDL_FillRect(screenSurface, NULL, SDL_MapRGB(screenSurface->format, 0x80, 0x80, 0x80));
SDL_UpdateWindowSurface(window);
update_font();
update_palette();
}
}
} else {
@ -304,25 +313,23 @@ void lem1802_irqh()
screen_iptr = rb;
break;
case 1: /* MEM_MAP_FONT */
if (rb != font_iptr) {
font_iptr = rb;
update_font();
}
font_iptr = rb;
update_font();
break;
case 2: /* MEM_MAP_PALETTE */
if (rb != palette_iptr) {
palette_iptr = rb;
update_palette();
}
palette_iptr = rb;
update_palette();
break;
case 3: /* SET_BORDER_COLOR */
border = rb;
break;
case 4: /* MEM_DUMP_FONT */
printf("Dumping default font to 0x%04x\n", rb);
for (i=0; i<sizeof(default_font)/sizeof(default_font[0]); i++)
ram[(rb+i)&0xffff] = default_font[i];
break;
case 5: /* MEM_DUMP_PALETTE */
printf("Dumping default palette to 0x%04x\n", rb);
for (i=0; i<sizeof(default_palette)/sizeof(default_palette[0]); i++)
ram[(rb+i)&0xffff] = default_palette[i];
break;

114
dsim.c
View File

@ -29,12 +29,19 @@ uint8_t intq_head;
uint16_t hwn;
struct timeval time;
extern void dumpregs();
void intq_push(uint16_t v)
{
if (ria == 0)
return;
if (intq_size < MAX_INTQ_SIZE) {
intq[intq_head] = v;
intq_head = (intq_head + 1) % MAX_INTQ_SIZE;
intq_size++;
} else {
printf("Halt and catch fire!\n");
running = false;
}
}
@ -117,35 +124,35 @@ uint16_t *val(int operand, bool is_a)
return &ram[rj];
case 0x10:
ticks++;
return &ram[ra+ram[rpc++]];
return &ram[(ra+ram[rpc++])&0xffff];
case 0x11:
ticks++;
return &ram[rb+ram[rpc++]];
return &ram[(rb+ram[rpc++])&0xffff];
case 0x12:
ticks++;
return &ram[rc+ram[rpc++]];
return &ram[(rc+ram[rpc++])&0xffff];
case 0x13:
ticks++;
return &ram[rx+ram[rpc++]];
return &ram[(rx+ram[rpc++])&0xffff];
case 0x14:
ticks++;
return &ram[ry+ram[rpc++]];
return &ram[(ry+ram[rpc++])&0xffff];
case 0x15:
ticks++;
return &ram[rz+ram[rpc++]];
return &ram[(rz+ram[rpc++])&0xffff];
case 0x16:
ticks++;
return &ram[ri+ram[rpc++]];
return &ram[(ri+ram[rpc++])&0xffff];
case 0x17:
ticks++;
return &ram[rj+ram[rpc++]];
return &ram[(rj+ram[rpc++])&0xffff];
case 0x18:
return (is_a ? &ram[rsp++] : &ram[--rsp]);
return (is_a ? &ram[(skip_next?rsp:rsp++)] : &ram[(skip_next?rsp-1:--rsp)]);
case 0x19:
return &ram[rsp];
case 0x1a:
ticks++;
return &ram[rsp+ram[rpc++]];
return &ram[(rsp+ram[rpc++])&0xffff];
case 0x1b:
return &rsp;
case 0x1c:
@ -185,10 +192,11 @@ void oADD(uint16_t *a, uint16_t *b)
void oSUB(uint16_t *a, uint16_t *b)
{
uint16_t pre = *b;
uint32_t t;
*b -= *a;
rex = (pre<*b ? 0xffff : 0x0000);
t = *b - *a;
*b = t;
rex = t >> 16;
ticks++;
}
@ -212,9 +220,13 @@ void oMLI(uint16_t *a, uint16_t *b)
void oDIV(uint16_t *a, uint16_t *b)
{
uint32_t wb, wt;
if (*a) {
rex = ((uint32_t)*b<<16) / *a;
*b /= *a;
wb = *b;
wt = (wb<<16) / *a;
rex = wt&0xffff;
*b = wt>>16;
} else {
*b = rex = 0;
}
@ -223,7 +235,7 @@ void oDIV(uint16_t *a, uint16_t *b)
void oDVI(uint16_t *a, uint16_t *b)
{
if (*a) {
rex = ((int32_t)*b<<16) / (int16_t)*a;
rex = ((int16_t)*b<<16) / (int16_t)*a;
*b = (int16_t)*b / (int16_t)*a;
} else {
*b = rex = 0;
@ -242,7 +254,7 @@ void oMOD(uint16_t *a, uint16_t *b)
void oMDI(uint16_t *a, uint16_t *b)
{
if (*a) {
*b = (int16_t)*b / (int16_t)*a;
*b = (int16_t)*b % (int16_t)*a;
} else {
*b = 0;
}
@ -265,32 +277,32 @@ void oXOR(uint16_t *a, uint16_t *b)
void oSHR(uint16_t *a, uint16_t *b)
{
uint16_t t;
uint32_t t;
t = (uint32_t)*b >> *a;
rex = ((uint64_t)*b << 16) >> *a;
*b = t;
t = (((uint32_t)*b) << 16) >> *a;
*b = t >> 16;
rex = t;
}
void oASR(uint16_t *a, uint16_t *b)
{
uint16_t t;
int32_t t;
t = *b >> *a;
rex = ((uint32_t)*b << 16) >> *a;
*b = t;
t = (((int32_t)*b) << 16) >> *a;
*b = t >> 16;
rex = t;
}
void oSHL(uint16_t *a, uint16_t *b)
{
uint16_t t;
uint32_t t;
t = *b << *a;
rex = ((uint64_t)*b << *a) >> 16;
t = ((uint32_t)*b) << *a;
rex = t >> 16;
*b = t;
}
#define DOIF(c) if (!(c)) skip_next = true
#define DOIF(c) if (!(c)) { skip_next = true; ticks++; }
void oIFB(uint16_t *a, uint16_t *b)
{
@ -386,6 +398,8 @@ void oIAG(uint16_t *a, uint16_t *b)
void oIAS(uint16_t *a, uint16_t *b)
{
ria = *a;
if (ria == 0)
intq_size = 0;
}
void oRFI(uint16_t *a, uint16_t *b)
@ -433,17 +447,17 @@ void oHWI(uint16_t *a, uint16_t *b)
typedef void (*op_t)(uint16_t *, uint16_t *);
const op_t ops[] = {
oNOP, oSET, oADD, oSUB, oMUL, oMLI, oDIV, oDVI, /* 00-07 */
NULL, oSET, oADD, oSUB, oMUL, oMLI, oDIV, oDVI, /* 00-07 */
oMOD, oMDI, oAND, oBOR, oXOR, oSHR, oASR, oSHL, /* 08-0f */
oIFB, oIFC, oIFE, oIFN, oIFG, oIFA, oIFL, oIFU, /* 10-17 */
oNOP, oNOP, oADX, oSBX, oNOP, oNOP, oSTI, oSTD /* 18-1f */
NULL, NULL, oADX, oSBX, NULL, NULL, oSTI, oSTD /* 18-1f */
};
const op_t sops[] = {
oNOP, oJSR, oNOP, oNOP, oNOP, oNOP, oNOP, oNOP, /* 00-07 */
oINT, oIAG, oIAS, oRFI, oIAQ, oNOP, oNOP, oNOP, /* 08-0f */
oHWN, oHWQ, oHWI, oNOP, oNOP, oNOP, oNOP, oNOP, /* 10-17 */
oNOP, oNOP, oNOP, oNOP, oNOP, oNOP, oNOP, oNOP /* 18-1f */
NULL, oJSR, NULL, NULL, NULL, NULL, NULL, NULL, /* 00-07 */
oINT, oIAG, oIAS, oRFI, oIAQ, NULL, NULL, NULL, /* 08-0f */
oHWN, oHWQ, oHWI, NULL, NULL, NULL, NULL, NULL, /* 10-17 */
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL /* 18-1f */
};
void next()
@ -456,6 +470,17 @@ void next()
gettimeofday(&time, NULL);
// if ((!intq_en) && (intq_size > 0) && (!skip_next)) {
// i = intq_pop();
// if (ria != 0) {
// printf("Firing interrupt with message 0x%04x\n", i);
// intq_en = true;
// ram[--rsp] = rpc;
// ram[--rsp] = ra;
// rpc = ria;
// ra = i;
// }
// }
if ((!intq_en) && (intq_size > 0) && (!skip_next)) {
i = intq_pop();
if (ria != 0) {
@ -471,6 +496,9 @@ void next()
if (trace)
dumpregs();
*/
// printf("PC: %04x\n", rpc);
// dumpregs();
ir = ram[rpc++];
opcode = ir & 0x001f;
@ -487,11 +515,27 @@ void next()
pb = val(b, false);
}
if (f == NULL) {
printf("Invalid opcode 0x%04x at 0x%04x (o=%02x, a=%02x, b=%02x)\n", ir, rpc-1, opcode, a, b);
running = false;
sleep(5);
return;
}
if (rpc == 0) {
printf("CRASH!\n");
}
if (!skip_next)
f(pa, pb);
else
skip_next = ((opcode & 0x18) == 0x10); /* Skip chained conditionals */
if (rpc == 0) {
sleep(5);
running = false;
}
for (i = 0; iodevs[i] != NULL; i++)
if (iodevs[i]->tick)
iodevs[i]->tick();

242
font.c
View File

@ -1,132 +1,132 @@
#include <stdint.h>
uint16_t default_font[] = {
0x9eb7, 0x8e38, /* 0 0x00 */
0x2c72, 0xf475, /* 1 0x01 */
0xbb19, 0x8f7f, /* 2 0x02 */
0xf985, 0x58b1, /* 3 0x03 */
0x2e24, 0x0024, /* 4 0x04 */
0x2a08, 0x0008, /* 5 0x05 */
0x0800, 0x0000, /* 6 0x06 */
0xb79e, 0x388e, /* 0 0x00 */
0x722c, 0x75f4, /* 1 0x01 */
0x19bb, 0x7f8f, /* 2 0x02 */
0x85f9, 0xb158, /* 3 0x03 */
0x242e, 0x2400, /* 4 0x04 */
0x082a, 0x0800, /* 5 0x05 */
0x0008, 0x0000, /* 6 0x06 */
0x0808, 0x0808, /* 7 0x07 */
0xff00, 0x0000, /* 8 0x08 */
0xf800, 0x0808, /* 9 0x09 */
0xf808, 0x0000, /* 10 0x0a */
0x0f08, 0x0000, /* 11 0x0b */
0x0f00, 0x0808, /* 12 0x0c */
0xff00, 0x0808, /* 13 0x0d */
0xf808, 0x0808, /* 14 0x0e */
0xff08, 0x0000, /* 15 0x0f */
0x0f08, 0x0808, /* 16 0x10 */
0xff08, 0x0808, /* 17 0x11 */
0x3366, 0xcc99, /* 18 0x12 */
0x3399, 0xcc66, /* 19 0x13 */
0xf8fe, 0x80e0, /* 20 0x14 */
0x1f7f, 0x0107, /* 21 0x15 */
0x0701, 0x7f1f, /* 22 0x16 */
0xe080, 0xfef8, /* 23 0x17 */
0x0055, 0x00aa, /* 24 0x18 */
0xaa55, 0xaa55, /* 25 0x19 */
0xaaff, 0x55ff, /* 26 0x1a */
0x00ff, 0x0000, /* 8 0x08 */
0x00f8, 0x0808, /* 9 0x09 */
0x08f8, 0x0000, /* 10 0x0a */
0x080f, 0x0000, /* 11 0x0b */
0x000f, 0x0808, /* 12 0x0c */
0x00ff, 0x0808, /* 13 0x0d */
0x08f8, 0x0808, /* 14 0x0e */
0x08ff, 0x0000, /* 15 0x0f */
0x080f, 0x0808, /* 16 0x10 */
0x08ff, 0x0808, /* 17 0x11 */
0x6633, 0x99cc, /* 18 0x12 */
0x9933, 0x66cc, /* 19 0x13 */
0xfef8, 0xe080, /* 20 0x14 */
0x7f1f, 0x0701, /* 21 0x15 */
0x0107, 0x1f7f, /* 22 0x16 */
0x80e0, 0xf8fe, /* 23 0x17 */
0x5500, 0xaa00, /* 24 0x18 */
0x55aa, 0x55aa, /* 25 0x19 */
0xffaa, 0xff55, /* 26 0x1a */
0x0f0f, 0x0f0f, /* 27 0x1b */
0xf0f0, 0xf0f0, /* 28 0x1c */
0x0000, 0xffff, /* 29 0x1d */
0xffff, 0x0000, /* 30 0x1e */
0xffff, 0xffff, /* 31 0x1f */
0x0000, 0x0000, /* 32 0x20 " " */
0x5f00, 0x0000, /* 33 0x21 "!" */
0x0003, 0x0003, /* 34 0x22 """ */
0x143e, 0x003e, /* 35 0x23 "#" */
0x6b26, 0x0032, /* 36 0x24 "$" */
0x1c61, 0x0043, /* 37 0x25 "%" */
0x2936, 0x5076, /* 38 0x26 "&" */
0x0200, 0x0001, /* 39 0x27 "'" */
0x221c, 0x0041, /* 40 0x28 "(" */
0x2241, 0x001c, /* 41 0x29 ")" */
0x0814, 0x0014, /* 42 0x2a "*" */
0x1c08, 0x0008, /* 43 0x2b "+" */
0x2040, 0x0000, /* 44 0x2c "," */
0x0808, 0x0008, /* 45 0x2d "-" */
0x4000, 0x0000, /* 46 0x2e "." */
0x1c60, 0x0003, /* 47 0x2f "/" */
0x493e, 0x003e, /* 48 0x30 "0" */
0x7f42, 0x0040, /* 49 0x31 "1" */
0x5962, 0x0046, /* 50 0x32 "2" */
0x4922, 0x0036, /* 51 0x33 "3" */
0x080f, 0x007f, /* 52 0x34 "4" */
0x4527, 0x0039, /* 53 0x35 "5" */
0x493e, 0x0032, /* 54 0x36 "6" */
0x1961, 0x0007, /* 55 0x37 "7" */
0x4936, 0x0036, /* 56 0x38 "8" */
0x4926, 0x003e, /* 57 0x39 "9" */
0x2400, 0x0000, /* 58 0x3a ":" */
0x2440, 0x0000, /* 59 0x3b ";" */
0x1408, 0x0022, /* 60 0x3c "<" */
0x1414, 0x0014, /* 61 0x3d "=" */
0x1422, 0x0008, /* 62 0x3e ">" */
0x5902, 0x0006, /* 63 0x3f "?" */
0x593e, 0x005e, /* 64 0x40 "@" */
0x097e, 0x007e, /* 65 0x41 "A" */
0x497f, 0x0036, /* 66 0x42 "B" */
0x413e, 0x0022, /* 67 0x43 "C" */
0x417f, 0x003e, /* 68 0x44 "D" */
0x497f, 0x0041, /* 69 0x45 "E" */
0x097f, 0x0001, /* 70 0x46 "F" */
0x413e, 0x007a, /* 71 0x47 "G" */
0x087f, 0x007f, /* 72 0x48 "H" */
0x7f41, 0x0041, /* 73 0x49 "I" */
0x4020, 0x003f, /* 74 0x4a "J" */
0x087f, 0x0077, /* 75 0x4b "K" */
0x407f, 0x0040, /* 76 0x4c "L" */
0x067f, 0x007f, /* 77 0x4d "M" */
0x017f, 0x007e, /* 78 0x4e "N" */
0x413e, 0x003e, /* 79 0x4f "O" */
0x097f, 0x0006, /* 80 0x50 "P" */
0x613e, 0x007e, /* 81 0x51 "Q" */
0x097f, 0x0076, /* 82 0x52 "R" */
0x4926, 0x0032, /* 83 0x53 "S" */
0x7f01, 0x0001, /* 84 0x54 "T" */
0x403f, 0x007f, /* 85 0x55 "U" */
0x601f, 0x001f, /* 86 0x56 "V" */
0x307f, 0x007f, /* 87 0x57 "W" */
0x0877, 0x0077, /* 88 0x58 "X" */
0x7807, 0x0007, /* 89 0x59 "Y" */
0x4971, 0x0047, /* 90 0x5a "Z" */
0x7f00, 0x0041, /* 91 0x5b "[" */
0x1c03, 0x0060, /* 92 0x5c "\" */
0x7f41, 0x0000, /* 93 0x5d "]" */
0x0102, 0x0002, /* 94 0x5e "^" */
0x8080, 0x0080, /* 95 0x5f "_" */
0x0100, 0x0002, /* 96 0x60 "`" */
0x5424, 0x0078, /* 97 0x61 "a" */
0x447f, 0x0038, /* 98 0x62 "b" */
0x4438, 0x0028, /* 99 0x63 "c" */
0x4438, 0x007f, /* 100 0x64 "d" */
0x5438, 0x0058, /* 101 0x65 "e" */
0x7e08, 0x0009, /* 102 0x66 "f" */
0x5448, 0x003c, /* 103 0x67 "g" */
0x047f, 0x0078, /* 104 0x68 "h" */
0x7d04, 0x0000, /* 105 0x69 "i" */
0x4020, 0x003d, /* 106 0x6a "j" */
0x107f, 0x006c, /* 107 0x6b "k" */
0x7f01, 0x0000, /* 108 0x6c "l" */
0x187c, 0x007c, /* 109 0x6d "m" */
0x047c, 0x0078, /* 110 0x6e "n" */
0x4438, 0x0038, /* 111 0x6f "o" */
0x147c, 0x0008, /* 112 0x70 "p" */
0x1408, 0x007c, /* 113 0x71 "q" */
0x047c, 0x0008, /* 114 0x72 "r" */
0x5448, 0x0024, /* 115 0x73 "s" */
0x3e04, 0x0044, /* 116 0x74 "t" */
0x403c, 0x007c, /* 117 0x75 "u" */
0x601c, 0x001c, /* 118 0x76 "v" */
0x307c, 0x007c, /* 119 0x77 "w" */
0x106c, 0x006c, /* 120 0x78 "x" */
0x504c, 0x003c, /* 121 0x79 "y" */
0x5464, 0x004c, /* 122 0x7a "z" */
0x3608, 0x0041, /* 123 0x7b "{" */
0x7700, 0x0000, /* 124 0x7c "|" */
0x3641, 0x0008, /* 125 0x7d "}" */
0x0102, 0x0102, /* 126 0x7e "~" */
0x0502, 0x0002, /* 127 0x7f */
0x005f, 0x0000, /* 33 0x21 "!" */
0x0300, 0x0300, /* 34 0x22 """ */
0x3e14, 0x3e00, /* 35 0x23 "#" */
0x266b, 0x3200, /* 36 0x24 "$" */
0x611c, 0x4300, /* 37 0x25 "%" */
0x3629, 0x7650, /* 38 0x26 "&" */
0x0002, 0x0100, /* 39 0x27 "'" */
0x1c22, 0x4100, /* 40 0x28 "(" */
0x4122, 0x1c00, /* 41 0x29 ")" */
0x1408, 0x1400, /* 42 0x2a "*" */
0x081c, 0x0800, /* 43 0x2b "+" */
0x4020, 0x0000, /* 44 0x2c "," */
0x0808, 0x0800, /* 45 0x2d "-" */
0x0040, 0x0000, /* 46 0x2e "." */
0x601c, 0x0300, /* 47 0x2f "/" */
0x3e49, 0x3e00, /* 48 0x30 "0" */
0x427f, 0x4000, /* 49 0x31 "1" */
0x6259, 0x4600, /* 50 0x32 "2" */
0x2249, 0x3600, /* 51 0x33 "3" */
0x0f08, 0x7f00, /* 52 0x34 "4" */
0x2745, 0x3900, /* 53 0x35 "5" */
0x3e49, 0x3200, /* 54 0x36 "6" */
0x6119, 0x0700, /* 55 0x37 "7" */
0x3649, 0x3600, /* 56 0x38 "8" */
0x2649, 0x3e00, /* 57 0x39 "9" */
0x0024, 0x0000, /* 58 0x3a ":" */
0x4024, 0x0000, /* 59 0x3b ";" */
0x0814, 0x2200, /* 60 0x3c "<" */
0x1414, 0x1400, /* 61 0x3d "=" */
0x2214, 0x0800, /* 62 0x3e ">" */
0x0259, 0x0600, /* 63 0x3f "?" */
0x3e59, 0x5e00, /* 64 0x40 "@" */
0x7e09, 0x7e00, /* 65 0x41 "A" */
0x7f49, 0x3600, /* 66 0x42 "B" */
0x3e41, 0x2200, /* 67 0x43 "C" */
0x7f41, 0x3e00, /* 68 0x44 "D" */
0x7f49, 0x4100, /* 69 0x45 "E" */
0x7f09, 0x0100, /* 70 0x46 "F" */
0x3e41, 0x7a00, /* 71 0x47 "G" */
0x7f08, 0x7f00, /* 72 0x48 "H" */
0x417f, 0x4100, /* 73 0x49 "I" */
0x2040, 0x3f00, /* 74 0x4a "J" */
0x7f08, 0x7700, /* 75 0x4b "K" */
0x7f40, 0x4000, /* 76 0x4c "L" */
0x7f06, 0x7f00, /* 77 0x4d "M" */
0x7f01, 0x7e00, /* 78 0x4e "N" */
0x3e41, 0x3e00, /* 79 0x4f "O" */
0x7f09, 0x0600, /* 80 0x50 "P" */
0x3e61, 0x7e00, /* 81 0x51 "Q" */
0x7f09, 0x7600, /* 82 0x52 "R" */
0x2649, 0x3200, /* 83 0x53 "S" */
0x017f, 0x0100, /* 84 0x54 "T" */
0x3f40, 0x7f00, /* 85 0x55 "U" */
0x1f60, 0x1f00, /* 86 0x56 "V" */
0x7f30, 0x7f00, /* 87 0x57 "W" */
0x7708, 0x7700, /* 88 0x58 "X" */
0x0778, 0x0700, /* 89 0x59 "Y" */
0x7149, 0x4700, /* 90 0x5a "Z" */
0x007f, 0x4100, /* 91 0x5b "[" */
0x031c, 0x6000, /* 92 0x5c "\" */
0x417f, 0x0000, /* 93 0x5d "]" */
0x0201, 0x0200, /* 94 0x5e "^" */
0x8080, 0x8000, /* 95 0x5f "_" */
0x0001, 0x0200, /* 96 0x60 "`" */
0x2454, 0x7800, /* 97 0x61 "a" */
0x7f44, 0x3800, /* 98 0x62 "b" */
0x3844, 0x2800, /* 99 0x63 "c" */
0x3844, 0x7f00, /* 100 0x64 "d" */
0x3854, 0x5800, /* 101 0x65 "e" */
0x087e, 0x0900, /* 102 0x66 "f" */
0x4854, 0x3c00, /* 103 0x67 "g" */
0x7f04, 0x7800, /* 104 0x68 "h" */
0x047d, 0x0000, /* 105 0x69 "i" */
0x2040, 0x3d00, /* 106 0x6a "j" */
0x7f10, 0x6c00, /* 107 0x6b "k" */
0x017f, 0x0000, /* 108 0x6c "l" */
0x7c18, 0x7c00, /* 109 0x6d "m" */
0x7c04, 0x7800, /* 110 0x6e "n" */
0x3844, 0x3800, /* 111 0x6f "o" */
0x7c14, 0x0800, /* 112 0x70 "p" */
0x0814, 0x7c00, /* 113 0x71 "q" */
0x7c04, 0x0800, /* 114 0x72 "r" */
0x4854, 0x2400, /* 115 0x73 "s" */
0x043e, 0x4400, /* 116 0x74 "t" */
0x3c40, 0x7c00, /* 117 0x75 "u" */
0x1c60, 0x1c00, /* 118 0x76 "v" */
0x7c30, 0x7c00, /* 119 0x77 "w" */
0x6c10, 0x6c00, /* 120 0x78 "x" */
0x4c50, 0x3c00, /* 121 0x79 "y" */
0x6454, 0x4c00, /* 122 0x7a "z" */
0x0836, 0x4100, /* 123 0x7b "{" */
0x0077, 0x0000, /* 124 0x7c "|" */
0x4136, 0x0800, /* 125 0x7d "}" */
0x0201, 0x0201, /* 126 0x7e "~" */
0x0205, 0x0200, /* 127 0x7f */
};

4
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
*.bin
*.dasm16
*.xxd
*.txt

33
tests/fetch.sh Executable file
View File

@ -0,0 +1,33 @@
#!/bin/bash
SITE=https://bisqwit.iki.fi/jutut/kuvat/programming_examples/dcpu16/
FILES=(
ins_test_v1_dat.dasm16
ins_test_v2.dasm16 ins_test_v2_dat.dasm16 ins_test_v2_doc.txt
ins_test_v3_dat.dasm16 ins_test_v3_doc.txt
ins_test_v4.dasm16 ins_test_v4_dat.dasm16 ins_test_v4_doc.txt
ins_test_v5.dasm16 ins_test_v5_dat.dasm16 ins_test_v5_doc.txt
)
for f in ${FILES[*]} ; do
if [ \! -f ${f} ] ; then
echo "Downloading ${f}"
wget -4 --quiet "${SITE}${f}"
fi
done
for f in *_dat.dasm16 ; do
hd="${f}.xxd"
if [ \! -f ${hd} ] ; then
echo "Creating ${hd}"
awk 'BEGIN {printf("%08d: ", 0)} {printf("%04x ", $2)} NR%8==0 {printf("\n%08x: ", 2*NR)} END {printf("\n")}' <${f} >${hd}
fi
done
for hd in *_dat.dasm16.xxd ; do
bin=$(echo "${hd}" | sed 's/_dat.dasm16.xxd$/.bin/')
if [ \! -f ${bin} ] ; then
echo "Creating ${bin}"
xxd -r <${hd} | dd if=/dev/stdin of=${bin} bs=2 conv=swab >${bin}
fi
done