Mercurial > hg > forks > multipaint-js
changeset 85:db97aef4e159
Clean up mpImportFormat() a bit.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Thu, 05 Jul 2018 23:55:18 +0300 |
parents | 025efefd1704 |
children | 6e5b619861c8 |
files | exporters.pde |
diffstat | 1 files changed, 92 insertions(+), 102 deletions(-) [+] |
line wrap: on
line diff
--- a/exporters.pde Thu Jul 05 23:43:28 2018 +0300 +++ b/exporters.pde Thu Jul 05 23:55:18 2018 +0300 @@ -46,16 +46,15 @@ { int x, y, x2, y2, y3, head, xx, yy, yp, ad, valu; int p1, p2, p3; + + g_template = fdata; head = 0; - g_template = fhd; - if (machine == SPECTRUM) //SCR=SCREEN$ { // 32*24*8 bytes of bitmap // 32*24 bytes of attributes if (g_template.length < 6912) { - message("FALSE"); return false; } for (y = 0; y < 3; y++) @@ -69,35 +68,35 @@ head++; } - for (y = 0; y <= 23; y++) { - for (x = 0; x <= 31; x++) { - ad = 65536 + x + y * (32 * 8); - valu = g_template[head]; - int ink = valu & 7; - int pap = valu & 56; - pap = pap >> 3; - int bri = valu & 64; - bri = bri >> 6; - ink = ink + bri * 8; - pap = pap + bri * 8; - if (pap == 8) { - pap = 0; - } - for (y2 = 0; y2 <= 7; y2++) { - g_map[ad + y2 * 32] = byte(ink); - g_map[ad + y2 * 32 + MX * MY * 8] = byte(pap); - } - head++; + for (y = 0; y < 24; y++) + for (x = 0; x < 32; x++) + { + ad = 65536 + x + y * (32 * 8); + valu = g_template[head]; + int ink = valu & 7; + int pap = valu & 56; + pap = pap >> 3; + int bri = valu & 64; + bri = bri >> 6; + ink = ink + bri * 8; + pap = pap + bri * 8; + if (pap == 8) { + pap = 0; } + for (y2 = 0; y2 <= 7; y2++) + { + g_map[ad + y2 * 32] = byte(ink); + g_map[ad + y2 * 32 + MX * MY * 8] = byte(pap); + } + head++; } } - + else if (machine == C64) { //0x0002->bitmap //0x1f42->colormap //0x232a=border (take the lower nybble) if (g_template.length < 9006) { - message("FALSE "+ str(g_template.length)); return false; } if (g_template.length >= 0x232a) { @@ -117,38 +116,35 @@ g_map[65536 + MX * MY * 8 + x + y * 40 * 8 + y2 * 40] = byte(p1); } } - + else if (machine == PLUS4) { // Botticelli //g.hires.prg = botticelli //2 - luminance 40*25 //1026 - colors 40*25 //2050 - bitmappi 40*25*8 if (g_template.length < 10050) { - message("FALSE"); return false; } int l1, l2; - for (y = 0; y < 25; y++) { - for (x = 0; x < 40; x++) { - for (y2 = 0; y2 <= 7; y2++) { - head = 2050 + x * 8 + y * (40 * 8) + y2; - ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; - mpSetByte(ad, head); + for (y = 0; y < 25; y++) + for (x = 0; x < 40; x++) + for (y2 = 0; y2 <= 7; y2++) + { + head = 2050 + x * 8 + y * (40 * 8) + y2; + ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; + mpSetByte(ad, head); - p1 = g_template[1026 + x + y * 40] & 0x0f; - p2 = g_template[1026 + x + y * 40] & 0xf0; - p2 = p2 >> 4; - l1 = g_template[2 + x + y * 40] & 0x0f; - l2 = g_template[2 + x + y * 40] & 0xf0; - l2 = l2 >> 4; - g_map[65536 + x + y * 40 * 8 + y2 * 40] = byte(convertlumi(l1, p2)); - g_map[65536 + MX * MY * 8 + x + y * 40 * 8 + y2 * 40] = byte(convertlumi(l2, p1)); - } - } + p1 = g_template[1026 + x + y * 40] & 0x0f; + p2 = g_template[1026 + x + y * 40] & 0xf0; + p2 = p2 >> 4; + l1 = g_template[2 + x + y * 40] & 0x0f; + l2 = g_template[2 + x + y * 40] & 0xf0; + l2 = l2 >> 4; + g_map[65536 + x + y * 40 * 8 + y2 * 40] = byte(convertluminance(l1, p2)); + g_map[65536 + MX * MY * 8 + x + y * 40 * 8 + y2 * 40] = byte(convertluminance(l2, p1)); } - } - + else if (machine == PLUS4M) { // Multi Botticelli //m.multi.prg = multi botticelli //2- lumins 40*25 @@ -157,38 +153,37 @@ //1026 - colors 40*25 //2050 - bitmap 40*25*8 if (g_template.length < 10050) { - message("FALSE"); return false; } int l1, l2; - for (y = 0; y < 25; y++) { - for (x = 0; x < 40; x++) { - for (y2 = 0; y2 <= 7; y2++) { - head = 2050 + x * 8 + y * (40 * 8) + y2; - ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; - mpSetByte(ad, head); + for (y = 0; y < 25; y++) + for (x = 0; x < 40; x++) + for (y2 = 0; y2 <= 7; y2++) + { + head = 2050 + x * 8 + y * (40 * 8) + y2; + ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; + mpSetByte(ad, head); - p1 = g_template[1026 + x + y * 40] & 0x0f; - p2 = g_template[1026 + x + y * 40] & 0xf0; - p2 = p2 >> 4; - l1 = g_template[2 + x + y * 40] & 0x0f; - l2 = g_template[2 + x + y * 40] & 0xf0; - l2 = l2 >> 4; - g_map[65536 + x + y * 40 + 1000] = byte(convertlumi(l1, p2)); - g_map[65536 + x + y * 40 + 0000] = byte(convertlumi(l2, p1)); - } - } + p1 = g_template[1026 + x + y * 40] & 0x0f; + p2 = g_template[1026 + x + y * 40] & 0xf0; + p2 = p2 >> 4; + l1 = g_template[2 + x + y * 40] & 0x0f; + l2 = g_template[2 + x + y * 40] & 0xf0; + l2 = l2 >> 4; + g_map[65536 + x + y * 40 + 1000] = byte(convertluminance(l1, p2)); + g_map[65536 + x + y * 40 + 0000] = byte(convertluminance(l2, p1)); } + p1 = int(g_template[1025]) & 0xf0; l1 = int(g_template[1025]) & 0x0f; p1 = p1 >> 4; - g_map[1] = byte(convertlumi(l1, p1)); + g_map[1] = byte(convertluminance(l1, p1)); p1 = int(g_template[1024]) & 0xf0; l1 = int(g_template[1024]) & 0x0f; p1 = p1 >> 4; - g_map[2] = byte(convertlumi(l1, p1)); + g_map[2] = byte(convertluminance(l1, p1)); } - + else if (machine == C64M) { //advanced art studio //adv. art studio (=multicolor) 10018 bytes //0x0002 bitmap (40*25*8) @@ -197,62 +192,57 @@ //0x232b background //0x233a colors2 (40*25) if (g_template.length < 10018) { - message("FALSE "+ str(g_template.length)); return false; } - for (y = 0; y < 25; y++) { - for (x = 0; x < 40; x++) { - for (y2 = 0; y2 < 8; y2++) { - ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; - - head = 2 + x * 8 + y * (40 * 8) + y2; - mpSetByte(ad, head); + for (y = 0; y < 25; y++) + for (x = 0; x < 40; x++) + for (y2 = 0; y2 < 8; y2++) + { + ad = 1024 + x * 8 + y * (320 * 8) + y2 * 320; - p1 = g_template[0x1f42 + x + y * 40] & 0x0f; - p2 = (g_template[0x1f42 + x + y * 40] >> 4) & 0x0f; - p3 = g_template[0x233a + x + y * 40] & 0x0f; + head = 2 + x * 8 + y * (40 * 8) + y2; + mpSetByte(ad, head); - g_map[65536 + x + y * 40] = byte(p1); - g_map[65536 + x + y * 40 + 1000] = byte(p2); - g_map[65536 + x + y * 40 + 2000] = byte(p3); - } - } + p1 = g_template[0x1f42 + x + y * 40] & 0x0f; + p2 = (g_template[0x1f42 + x + y * 40] >> 4) & 0x0f; + p3 = g_template[0x233a + x + y * 40] & 0x0f; + + g_map[65536 + x + y * 40] = byte(p1); + g_map[65536 + x + y * 40 + 1000] = byte(p2); + g_map[65536 + x + y * 40 + 2000] = byte(p3); } g_map[0] = byte(g_template[0x232a] & 0x0f); //bord g_map[1] = byte(g_template[0x232b] & 0x0f); //baku } - + else if (machine == MSX) { // sc2 // 7=bitmap 32*24*8 // 7+(32*24*8)=colormap 32*24 if (g_template.length < 14343) { - message("FALSE"); return false; } - for (y = 0; y < 24; y++) { - for (x = 0; x < 32; x++) { - for (y2 = 0; y2 <= 7; y2++) { - head = 7 + x * 8 + y * (32 * 8) + y2; - ad = 1024 + x * 8 + y * (256 * 8) + y2 * 256; - mpSetByte(ad, head); - p1 = g_template[(8199) + x * 8 + ((y * 8 * 32) + y2)] & 0x0f; - p2 = g_template[(8199) + x * 8 + ((y * 8 * 32) + y2)] & 0xf0; - p2 = p2 >> 4; - if (p1 == 0) { - p1 = 1; - } - if (p2 == 0) { - p2 = 1; - } - g_map[65536 + x + y * 32 * 8 + y2 * 32] = byte(p2); - g_map[65536 + MX * MY * 8 + x + y * 32 * 8 + y2 * 32] = byte(p1); - } + for (y = 0; y < 24; y++) + for (x = 0; x < 32; x++) + for (y2 = 0; y2 <= 7; y2++) + { + head = 7 + x * 8 + y * (32 * 8) + y2; + ad = 1024 + x * 8 + y * (256 * 8) + y2 * 256; + mpSetByte(ad, head); + p1 = g_template[(8199) + x * 8 + ((y * 8 * 32) + y2)] & 0x0f; + p2 = g_template[(8199) + x * 8 + ((y * 8 * 32) + y2)] & 0xf0; + p2 = p2 >> 4; + if (p1 == 0) { + p1 = 1; } + if (p2 == 0) { + p2 = 1; + } + g_map[65536 + x + y * 32 * 8 + y2 * 32] = byte(p2); + g_map[65536 + MX * MY * 8 + x + y * 32 * 8 + y2 * 32] = byte(p1); } } - + else if (machine == CPC) { // a studio? - message("Not|Working"); return false; }