// calls malloc, please free result // returns NULL on error uint8_t *hex_decode(const char* word, size_t *hex_size) { if (!word) { return NULL; } size_t wlen = strlen(word); if (wlen == 0) { return NULL; } if (wlen%2 != 0) { // 2 chars per octet return NULL; } size_t ret_size = wlen / 2; uint8_t *ret = (uint8_t*)malloc(ret_size); for (size_t i=0; i<ret_size; i++) { ret[i] = (hchar(word[2*i]) << 4) | hchar(word[2*i + 1]); } if (hex_size) { *hex_size = ret_size; } return ret; }
static void hlist(int aflag) { list(aflag, 1); printf("erase kill werase rprnt flush lnext " "susp intr quit stop eof\n"); hchar(ts.c_cc[VERASE]&0377, EOF, 1); hchar(ts.c_cc[VKILL]&0377, EOF, 1); #ifdef VWERASE hchar(ts.c_cc[VWERASE]&0377, EOF, 1); #else hchar(vdis, EOF, 1); #endif #ifdef VREPRINT hchar(ts.c_cc[VREPRINT]&0377, EOF, 1); #else hchar(vdis, EOF, 1); #endif #ifdef VDISCARD hchar(ts.c_cc[VDISCARD]&0377, EOF, 1); #else hchar(vdis, EOF, 1); #endif hchar(ts.c_cc[VLNEXT]&0377, EOF, 1); hchar(ts.c_cc[VSUSP]&0377, EOF, 1); hchar(ts.c_cc[VINTR]&0377, EOF, 1); hchar(ts.c_cc[VQUIT]&0377, EOF, 1); hchar(ts.c_cc[VSTOP]&0377, ts.c_cc[VSTART]&0377, 1); hchar(ts.c_cc[VEOF]&0377, EOF, 1); putchar('\n'); }
void drawLaby(void) { char l=0,lg; char *ptr; // 1000 HIRES:INK EENC(VIL):POKE#26A,PEEK(#26A) AND 254 hires(); ink(eencre[ville-1]); ptr = (char*)0x26a; *ptr = *ptr & 254; // Vire le curseur // 1020 CURSET40,30,3:DRAW160,0,1:DRAW0,150,1 CurrentPixelX=40; CurrentPixelY=30; OtherPixelX=40+160; OtherPixelY=30; DrawLine8(); CurrentPixelX=40+160; CurrentPixelY=30; OtherPixelX=40+160; OtherPixelY=30+150; DrawLine8(); // 1030 DRAW-160,0,1:DRAW0,-150,1 CurrentPixelX=40+160; CurrentPixelY=30+150; OtherPixelX=40; OtherPixelY=30+150; DrawLine8(); CurrentPixelX=40; CurrentPixelY=30+150; OtherPixelX=40; OtherPixelY=30; DrawLine8(); // 1035 IF BS=1 THEN GOSUB 2800 // 1040 L=1 for(l=0;l<3;l++) { // 1400 REM DESSINS DES BLOCS // 1070 IF G(L)>0 AND G(L)<7 THEN ON L GOSUB 1500,1550,1600 if(g[l]>0&&g[l]<7) { switch(l) { case 0: // 1500 CURSET 40,30,3:DRAW20,20,1:DRAW0,110,1:DRAW-20,20,1 CurrentPixelX=40; CurrentPixelY=30; OtherPixelX=40+20; OtherPixelY=30+20; DrawLine8(); CurrentPixelX=40+20; CurrentPixelY=30+20; OtherPixelX=40+20; OtherPixelY=30+20+110; DrawLine8(); CurrentPixelX=40+20; CurrentPixelY=30+20+110; OtherPixelX=40; OtherPixelY=30+20+110+20; DrawLine8(); break; case 1: // 1550 CURSET60,50,1:DRAW25,25,1:DRAW0,60,1:DRAW-25,25,1 CurrentPixelX=60; CurrentPixelY=50; OtherPixelX=60+25; OtherPixelY=50+25; DrawLine8(); CurrentPixelX=60+25; CurrentPixelY=50+25; OtherPixelX=60+25; OtherPixelY=50+25+60; DrawLine8(); CurrentPixelX=60+25; CurrentPixelY=50+25+60; OtherPixelX=60; OtherPixelY=50+25+60+25; DrawLine8(); // 1570 IF G(1)=0 OR G(1)>6 THEN CURSET 40,50,1:DRAW20,0,1:DRAW 0,110,1:DRAW -20,0,1 if(g[0]==0 || g[0]>6) { CurrentPixelX=40; CurrentPixelY=50; OtherPixelX=40+20; OtherPixelY=50; DrawLine8(); CurrentPixelX=40+20; CurrentPixelY=50; OtherPixelX=40+20; OtherPixelY=50+110; DrawLine8(); CurrentPixelX=40+20; CurrentPixelY=50+110; OtherPixelX=40; OtherPixelY=50+110; DrawLine8(); } break; case 2: // 1600 CURSET85,75,1:DRAW10,10,1:DRAW0,40,1:DRAW-10,10,1 CurrentPixelX=85; CurrentPixelY=75; OtherPixelX=85+10; OtherPixelY=75+10; DrawLine8(); CurrentPixelX=85+10; CurrentPixelY=75+10; OtherPixelX=85+10; OtherPixelY=75+10+40; DrawLine8(); CurrentPixelX=85+10; CurrentPixelY=75+10+40; OtherPixelX=85; OtherPixelY=75+10+40+10; DrawLine8(); // 1620 IF G(2)>0 AND G(2)<7 THEN GOTO 1650 if(!(g[1]>0&&g[1]<7)) { char t; // 1630 IF G(1)=0 OR G(1)>6 THEN T=45 ELSE T=25 if(g[0]==0 || g[0]>6) t=45; else t=25; // 1640 CURSET85,75,1:DRAW0,60,1:DRAW-T,0,1:CURSET85,75,1:DRAW-T,0,1 CurrentPixelX=85; CurrentPixelY=75; OtherPixelX=85; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=85; CurrentPixelY=75+60; OtherPixelX=85-t; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=85; CurrentPixelY=75; OtherPixelX=85-t; OtherPixelY=75; DrawLine8(); } break; } // 1650 IF G(L)<2 OR G(L)>6 THEN RETURN if (!(g[l]<2 || g[l]>6)) { // 1670 ON L GOSUB 1700,1750,1800 switch(l) { case 0: // 1700 CURSET 48,172,1:DRAW0,-125,1:DRAW -7,-7,1:RETURN CurrentPixelX=48; CurrentPixelY=172; OtherPixelX=48; OtherPixelY=172-125; DrawLine8(); CurrentPixelX=48; CurrentPixelY=172-125; OtherPixelX=48-7; OtherPixelY=172-125-7; DrawLine8(); break; case 1: // 1750 CURSET65,155,1:DRAW0,-95,1:DRAW 15,15,1:DRAW0,65,1 CurrentPixelX=65; CurrentPixelY=155; OtherPixelX=65; OtherPixelY=155-95; DrawLine8(); CurrentPixelX=65; CurrentPixelY=155-95; OtherPixelX=65+15; OtherPixelY=155-95+15; DrawLine8(); CurrentPixelX=65+15; CurrentPixelY=155-95+15; OtherPixelX=65+15; OtherPixelY=155-95+15+65; DrawLine8(); // 1770 CURSET67,105,3:CIRCLE1,1:RETURN curset(67,105,3); circle(1,1); break; case 2: // 1800 CURSET 88,132,1:DRAW0,-49,1:DRAW5,5,1:DRAW0,38,1 CurrentPixelX=88; CurrentPixelY=132; OtherPixelX=88; OtherPixelY=132-49; DrawLine8(); CurrentPixelX=88; CurrentPixelY=132-49; OtherPixelX=88+5; OtherPixelY=132-49+5; DrawLine8(); CurrentPixelX=88+5; CurrentPixelY=132-49+5; OtherPixelX=88+5; OtherPixelY=132-49+5+38; DrawLine8(); // 1820 CURSET 89,105,1 curset(89,105,1); break; } } } // 1080 IF D(L)>0 AND D(L)<7 THEN ON L GOSUB 1900,1950,2000 if(d[l]>0&&d[l]<7) { switch(l) { case 0: // 1900 CURSET200,30,3:DRAW-20,20,1:DRAW0,110,1:DRAW20,20,1 CurrentPixelX=200; CurrentPixelY=30; OtherPixelX=200-20; OtherPixelY=30+20; DrawLine8(); CurrentPixelX=200-20; CurrentPixelY=30+20; OtherPixelX=200-20; OtherPixelY=30+20+110; DrawLine8(); CurrentPixelX=200-20; CurrentPixelY=30+20+110; OtherPixelX=200; OtherPixelY=30+20+110+20; DrawLine8(); // 1920 GOTO 2050 break; case 1: // 1950 CURSET180,50,3:DRAW-25,25,1:DRAW0,60,1:DRAW25,25,1 CurrentPixelX=180; CurrentPixelY=50; OtherPixelX=180-25; OtherPixelY=50+25; DrawLine8(); CurrentPixelX=180-25; CurrentPixelY=50+25; OtherPixelX=180-25; OtherPixelY=50+25+60; DrawLine8(); CurrentPixelX=180-25; CurrentPixelY=50+25+60; OtherPixelX=180; OtherPixelY=50+25+60+25; DrawLine8(); // 1970 IF D(1)=0 OR D(1)>6 THEN CURSET 200,50,1:DRAW-20,0,1:DRAW 0,110,1:DRAW20,0,1 if(d[0]==0 || d[0]>6) { CurrentPixelX=200; CurrentPixelY=50; OtherPixelX=200-20; OtherPixelY=50; DrawLine8(); CurrentPixelX=200-20; CurrentPixelY=50; OtherPixelX=200-20; OtherPixelY=50+110; DrawLine8(); CurrentPixelX=200-20; CurrentPixelY=50+110; OtherPixelX=200; OtherPixelY=50+110; DrawLine8(); } // 1980 GOTO 2050 break; case 2: // 2000 CURSET155,75,1:DRAW-10,10,1:DRAW0,40,1:DRAW10,10,1 CurrentPixelX=155; CurrentPixelY=75; OtherPixelX=155-10; OtherPixelY=75+10; DrawLine8(); CurrentPixelX=155-10; CurrentPixelY=75+10; OtherPixelX=155-10; OtherPixelY=75+10+40; DrawLine8(); CurrentPixelX=155-10; CurrentPixelY=75+10+40; OtherPixelX=155; OtherPixelY=75+10+40+10; DrawLine8(); // 2020 IF D(2)>0 AND D(2)<7 THEN GOTO 2050 if(!(d[1]>0 && d[1]<7)) { char t; // 2030 IF D(1)=0 OR D(1)>6 THEN T=45 ELSE T=25 if(d[0]==0 || d[0]>6) t=45; else t=25; // 2040 CURSET155,75,1:DRAW0,60,1:DRAWT,0,1:CURSET 155,75,1:DRAWT,0,1 CurrentPixelX=155; CurrentPixelY=75; OtherPixelX=155; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=155; CurrentPixelY=75+60; OtherPixelX=155+t; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=155; CurrentPixelY=75; OtherPixelX=155+t; OtherPixelY=75; DrawLine8(); } break; } // 2050 IF D(L)<2 OR D(L)>6 THEN RETURN if(!(d[l]<2 || d[l]>6)) { // 2070 ON L GOSUB 2100,2150,2200 switch(l) { case 0: // 2100 CURSET193,172,1:DRAW0,-125,1:DRAW 7,-7,1 CurrentPixelX=193; CurrentPixelY=172; OtherPixelX=193; OtherPixelY=172-125; DrawLine8(); CurrentPixelX=193; CurrentPixelY=172-125; OtherPixelX=193+7; OtherPixelY=172-125-7; DrawLine8(); break; case 1: // 2150 CURSET175,155,1:DRAW0,-95,1:DRAW-15,15,1:DRAW0,65,1 CurrentPixelX=175; CurrentPixelY=155; OtherPixelX=175; OtherPixelY=155-95; DrawLine8(); CurrentPixelX=175; CurrentPixelY=155-95; OtherPixelX=175-15; OtherPixelY=155-95+15; DrawLine8(); CurrentPixelX=175-15; CurrentPixelY=155-95+15; OtherPixelX=175-15; OtherPixelY=155-95+15+65; DrawLine8(); // 2170 CURSET162,105,3:CIRCLE1,1:RETURN curset(162,105,3); circle(1,1); break; case 2: // 2200 CURSET 152,132,1:DRAW0,-49,1:DRAW-5,5,1:DRAW0,38,1 CurrentPixelX=152; CurrentPixelY=132; OtherPixelX=152; OtherPixelY=132-49; DrawLine8(); CurrentPixelX=152; CurrentPixelY=132-49; OtherPixelX=152-5; OtherPixelY=132-49+5; DrawLine8(); CurrentPixelX=152-5; CurrentPixelY=132-49+5; OtherPixelX=152-5; OtherPixelY=132-49+5+38; DrawLine8(); // 2220 CURSET 148,105,1 curset(148,105,1); break; } // 2080 RETURN } } // 1090 IF F(L)>0 AND F(L)<7 THEN ON L GOSUB 2300,2400 if(f[l]>0 && f[l]<7) { switch(l) { case 0: // 2300 CURSET 60,50,1:DRAW120,0,1:DRAW0,110,1:DRAW-120,0,1:DRAW0,-110,1 CurrentPixelX=60; CurrentPixelY=50; OtherPixelX=60+120; OtherPixelY=50; DrawLine8(); CurrentPixelX=60+120; CurrentPixelY=50; OtherPixelX=60+120; OtherPixelY=50+110; DrawLine8(); CurrentPixelX=60+120; CurrentPixelY=50+110; OtherPixelX=60; OtherPixelY=50+110; DrawLine8(); CurrentPixelX=60; CurrentPixelY=50+110; OtherPixelX=60; OtherPixelY=50; DrawLine8(); // 2320 IF (G(1)=0 OR G(1)>6) AND (G(2)>0 AND G(2)<7) THEN if((g[0]==0||g[0]>6)&&(g[1]>0&&g[1]<7)) { // DRAW-20,0,1:CURSET60,160,1:DRAW-20,0,1 CurrentPixelX=60; CurrentPixelY=50; OtherPixelX=60-20; OtherPixelY=50; DrawLine8(); CurrentPixelX=60; CurrentPixelY=160; OtherPixelX=60-20; OtherPixelY=160; DrawLine8(); } // 2340 IF (D(1)=0 OR D(1)>6) AND (D(2)>0 AND D(2)<7) THEN if((d[0]==0||d[0]>6)&&(d[1]>0&&d[1]<7)) { // CURSET180,50,3:DRAW 20,0,1:CURSET 180,160,1:DRAW20,0,1 CurrentPixelX=180; CurrentPixelY=50; OtherPixelX=180+20; OtherPixelY=50; DrawLine8(); CurrentPixelX=180; CurrentPixelY=160; OtherPixelX=180+20; OtherPixelY=160; DrawLine8(); } // 2350 GOTO 2500 break; case 1: // 2400 CURSET 85,75,1:DRAW 70,0,1:DRAW 0,60,1:DRAW-70,0,1:DRAW0,-60,1 CurrentPixelX=85; CurrentPixelY=75; OtherPixelX=85+70; OtherPixelY=75; DrawLine8(); CurrentPixelX=85+70; CurrentPixelY=75; OtherPixelX=85+70; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=85+70; CurrentPixelY=75+60; OtherPixelX=85; OtherPixelY=75+60; DrawLine8(); CurrentPixelX=85; CurrentPixelY=75+60; OtherPixelX=85; OtherPixelY=75; DrawLine8(); { char tg, td; // 2415 IF G(1)=0 OR G(1)>6 THEN TG=45 ELSE TG=25 if(g[0]==0||g[0]>6) tg=45; else tg=25; // 2416 IF D(1)=0 OR D(1)>6 THEN TD=45 ELSE TD=25 if(d[0]==0||d[0]>6) td=45; else td=25; // 2420 IF (G(2)=0 OR G(2)>6) AND (G(3)>0 AND G(3)<7) THEN if((g[1]==0||g[1]>6)&&(g[2]>0&&g[2]<7)) { // DRAW-TG,0,1:CURSET85,135,1:DRAW-TG,0,1 CurrentPixelX=85; CurrentPixelY=75; OtherPixelX=85-tg; OtherPixelY=75; DrawLine8(); CurrentPixelX=85; CurrentPixelY=135; OtherPixelX=85-tg; OtherPixelY=135; DrawLine8(); } // 2430 IF (D(2)=0 OR D(2)>6) AND (D(3)>0 AND D(3)<7) THEN if((d[1]==0||d[1]>6)&&(d[2]>0&&d[2]<7)) { // CURSET155,75,3:DRAW TD,0,1:CURSET 155,135,1:DRAWTD,0,1 CurrentPixelX=155; CurrentPixelY=75; OtherPixelX=155+td; OtherPixelY=75; DrawLine8(); CurrentPixelX=155; CurrentPixelY=135; OtherPixelX=155+td; OtherPixelY=135; DrawLine8(); } } break; } // 2500 IF F(L)>1 AND F(L)<7 THEN ON L GOSUB 2550,2580 if(f[l]>1&&f[l]<7) { switch(l) { case 0: // 2550 CURSET 80,160,1:DRAW0,-100,1:DRAW85,0,1:DRAW0,100,1:CURSET 83,115,1:CIRCLE 2,1 CurrentPixelX=80; CurrentPixelY=160; OtherPixelX=80; OtherPixelY=60; DrawLine8(); CurrentPixelX=80; CurrentPixelY=60; OtherPixelX=80+85; OtherPixelY=60; DrawLine8(); CurrentPixelX=80+85; CurrentPixelY=60; OtherPixelX=80+85; OtherPixelY=60+100; DrawLine8(); curset(83,115,1); circle(2,1); // 2560 PS=F(L): IF PS>2 AND PS<7 THEN GOSUB 2650 if(f[l]>2 && f[l]<7) { unsigned char p,i,t; char *texte; if(f[l]==5 || f[l]==6) { char g=105,nb=5,h=35,br=25; p=3; // Grille // New version Max DEBUG if(ville==9 && f[l]==6) { nb=7;g=96;br=75;h=53; } CurrentPixelX=g; CurrentPixelY=75; OtherPixelX=g+h; OtherPixelY=75; DrawLine8(); CurrentPixelX=g+h; CurrentPixelY=75; OtherPixelX=g+h; OtherPixelY=75+br; DrawLine8(); CurrentPixelX=g+h; CurrentPixelY=75+br; OtherPixelX=g; OtherPixelY=75+br; DrawLine8(); CurrentPixelX=g; CurrentPixelY=75+br; OtherPixelX=g; OtherPixelY=75; DrawLine8(); // 2720 FORI=1TO3:CURSETG,75,1:DRAW0,25,1:G=G+9:NEXTI for(i=0;i<nb;i++) { CurrentPixelX=g; CurrentPixelY=75; OtherPixelX=g; OtherPixelY=75+br; DrawLine8(); g+=9; } } //printf("texte"); // 2760 FORI=1TOLEN(S$):CURSET T,65,3:CHAR ASC(MID$(S$,I,1)),0,1:T=T+6:NEXTI t=(ville-1)*4+(f[l]-3); // pour la porte 6 de Winterfell if(ville==9 && f[l]==6) { // si on regarde vers le nord on écrit NORD if (s==1) t+=2; // si on regarde vers le sud ou l'ouest on écrit SUD else if(s==3 || s==4) t+=1; // sinon (on regarde vers l'est) // et si on est dedans on affiche pas else if(TestBit(&dedans,3)) break; } else { // si on est dedans on affiche pas if(f[l]-3<=3 && TestBit(&dedans,f[l]-3)) break; } texte = portes[t]; lg = strlen(texte); t=124-lg*3; //printf("v:%d,f[l]:%d,i:%d,lg:%d,t:%d,de:%x\n", // ville, f[l], (f[l]-3), lg, t, dedans); for(i=0;i<lg;i++) { curset(t,65,3); hchar(texte[i],0,1); //printf("%c",texte[i]); t+=6; } //printf("\n"); // 2790 RETURN } // 2565 RETURN break; case 1: // 2580 CURSET95,135,1:DRAW0,-50,1:DRAW50,0,1:DRAW0,50,1:CURSET 96,115,1:RETURN CurrentPixelX=95; CurrentPixelY=135; OtherPixelX=95; OtherPixelY=135-50; DrawLine8(); CurrentPixelX=95; CurrentPixelY=135-50; OtherPixelX=95+50; OtherPixelY=135-50; DrawLine8(); CurrentPixelX=95+50; CurrentPixelY=135-50; OtherPixelX=95+50; OtherPixelY=135; DrawLine8(); curset(96,115,1); break; } } // 2520 RETURN // 1095 IF F(L)>0 AND F(L)<7 THEN GOTO 1200 // stop looping break; } } // boussole if(boussole){ char dir; switch(s) { // 2800 IF S=1 THEN DIR=78 case 0: dir=78; break; // 2820 IF S=2 THEN DIR=69 case 1: dir=69; break; // 2830 IF S=3 THEN DIR=83 case 2: dir=83; break; // 2840 IF S=4 THEN DIR=79 case 3: dir=79; break; } // 2850 CURSET 220,10,1:CHAR DIR,0,1:CURMOV 2,8,1 curset(220,10,0);hchar(dir,0,1); // 2860 DRAW 3,15,1:DRAW -3,15,1:DRAW -3,-15,1:DRAW 3,-15,1 curset(222,18,1); CurrentPixelX=220+2; CurrentPixelY=10+8; OtherPixelX=220+2+3; OtherPixelY=10+8+15; DrawLine8(); CurrentPixelX=220+2+3; CurrentPixelY=10+8+15; OtherPixelX=220+2; OtherPixelY=10+8+15+15; DrawLine8(); CurrentPixelX=220+2; CurrentPixelY=10+8+15+15; OtherPixelX=220+2-3; OtherPixelY=10+8+15; DrawLine8(); CurrentPixelX=220+2-3; CurrentPixelY=10+8+15; OtherPixelX=220+2; OtherPixelY=10+8; DrawLine8(); // 2870 CURMOV2,12,1:DRAW 13,3,1:DRAW -13,3,1 curset(224,30,1); CurrentPixelX=220+2+2; CurrentPixelY=10+8+12; OtherPixelX=220+2+2+13; OtherPixelY=10+8+12+3; DrawLine8(); CurrentPixelX=220+2+2+13; CurrentPixelY=10+8+12+3; OtherPixelX=220+2+2; OtherPixelY=10+8+12+3+3; DrawLine8(); // 2880 CURSET 220,30,1:DRAW -13,3,1:DRAW 13,3,1 curset(220,30,1); CurrentPixelX=220; CurrentPixelY=30; OtherPixelX=220-13; OtherPixelY=30+3; DrawLine8(); CurrentPixelX=220-13; CurrentPixelY=30+3; OtherPixelX=220; OtherPixelY=30+3+3; DrawLine8(); // 2900 RETURN } }