z: more improvements from qkumba

This commit is contained in:
Vince Weaver 2021-08-05 01:09:06 -04:00
parent ee6dd84d9f
commit fc62455f69
3 changed files with 79 additions and 14 deletions

View File

@ -1,2 +1,2 @@
0CALL2225"\Q29QQVX6/:.T?PVQ_*bN2\.23*G.3*b6MOWGbM-
1"),G;aE`6]N4`U0b5$38aU/b5_&&W`U/)(`6.QJ(W`U/)(`V?`6`F,;_6`V`%`V?$8`%)a5a%#8a%C7[$?CX/b&b7\#?DW/b%b8[#@U%_^A9&7\#?c5bW\O4"******GRASCDEFPOP!i\DEL0GRRETURN}i\F0jjjjjjjF0jFORLOGASCsONERR0::=VALpRNDlo
0CALL2225"\Y:AYY^`>7B6\GX^Yg2jV:d6:;2O6;2j>UW_OjU5
1"),G;aE`6]N4`U0b5$38aU/b5_&&W`U/)(`6.QJ(W`U/)(`V?`6`F,;_6`V`%`V?$8`%)a5a%#8a%C7[$?CX/b&b7\#?DW/b%b8[#@U%_^A9&7\#?c5bW\O4"******GRASCDEFITa!DEL0GR)@I\q}F0jjjjjjjF0jFORLOGASCsONERR0)}=LENpPOSlo

View File

@ -1,5 +1,3 @@
/* by qkumba */
#include <fcntl.h>
//#include <io.h>
#include <stdio.h>
@ -11,10 +9,10 @@
#define O_TEXT 0
#endif
static unsigned char decoder[] = "\"******GRASCDEFPOP!i\\DEL0GRRETURN}i\\F0jjjjjjjF0jFORLOGASCsONERR0::=VALpRNDlo";
int main(int argc, char **argv) {
static unsigned char decoder[] = "\"******GRASCDEFITa!DEL0GR)@I\\q}F0jjjjjjjF0jFORLOGASCsONERR0)}=LENpPOSlo";
void main(int argc, char *argv[])
{
int i, l, j, b2, b6;
unsigned char b[150];
unsigned char bb2[150];
@ -39,9 +37,10 @@ int main(int argc, char **argv) {
c = ((((b[j + 0] >> 6) & 2) + (b[j + 0] & 1)) << 0)
+ ((((b[j + 1] >> 6) & 2) + (b[j + 1] & 1)) << 2)
+ ((((b[j + 2] >> 6) & 2) + (b[j + 2] & 1)) << 4)
+ 0x23;
+ 0x2b
- (7 * (int) !j);
bb2[b2++] = c + (int) !j;
bb2[b2++] = c;
}
c = ((b[j] >> 1) & 0x3f) + 0x23 + (int) !(j % 3);
@ -51,14 +50,12 @@ int main(int argc, char **argv) {
while (++j < l);
sprintf(call, "0CALL%d\"", 2049+10+b2+6+(int)sizeof(bb6)-b6+1);
i = open("out", O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0666);
i = open("out", O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0x80);
write(i, call, strlen(call));
write(i, bb2, b2);
write(i, "\r\n1\"", sizeof("\r\n1\"")-1);
write(i, "\n1\"", sizeof("\n1\"")-1);
write(i, bb6 + b6, sizeof(bb6) - b6);
write(i, decoder, sizeof(decoder)-1);
write(i,"\n",1);
write(i, "\n",1);
close(i);
return 0;
}

68
basic/z/z_65c02.c Normal file
View File

@ -0,0 +1,68 @@
/* by qkumba */
#include <fcntl.h>
//#include <io.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#ifndef O_BINARY
#define O_BINARY 0
#define O_TEXT 0
#endif
static unsigned char decoder[] = "\"******GRASCDEFPOP!i\\DEL0GRRETURN}i\\F0jjjjjjjF0jFORLOGASCsONERR0::=VALpRNDlo";
int main(int argc, char **argv) {
int i, l, j, b2, b6;
unsigned char b[150];
unsigned char bb2[150];
unsigned char bb6[150];
char call[32];
memset(b, 0, sizeof(b));
i = open(argv[1], O_RDONLY | O_BINARY);
l = read(i, b, sizeof(b));
close(i);
j = 0;
b2 = 0;
b6 = sizeof(bb6);
do
{
unsigned char c;
if (!(j % 3))
{
c = ((((b[j + 0] >> 6) & 2) + (b[j + 0] & 1)) << 0)
+ ((((b[j + 1] >> 6) & 2) + (b[j + 1] & 1)) << 2)
+ ((((b[j + 2] >> 6) & 2) + (b[j + 2] & 1)) << 4)
+ 0x23;
bb2[b2++] = c + (int) !j;
}
c = ((b[j] >> 1) & 0x3f) + 0x23 + (int) !(j % 3);
bb6[--b6] = c;
}
while (++j < l);
sprintf(call, "0CALL%d\"", 2049+ // $801 (basic loads here)
10+ // point to quote after CALL
b2+ // point past 6encoded
6+ // ??
(int)sizeof(bb6)-b6+1); // backwards code
i = open("out", O_WRONLY | O_BINARY | O_CREAT | O_TRUNC, 0666);
write(i, call, strlen(call));
write(i, bb2, b2);
write(i, "\r\n1\"", sizeof("\r\n1\"")-1);
write(i, bb6 + b6, sizeof(bb6) - b6);
write(i, decoder, sizeof(decoder)-1);
write(i,"\n",1);
close(i);
return 0;
}