Annotation of researchv10no/cmd/pico/builtins.c, revision 1.1

1.1     ! root        1: #include <stdio.h>
        !             2: #include <math.h>
        !             3: #include <ctype.h>
        !             4: #include "pico.h"
        !             5: 
        !             6: extern struct  SRC src[MANY];
        !             7: extern short   CURSCRATCH, CUROLD;
        !             8: extern char    frameb, metheus;
        !             9: extern int     DEF_LL, DEF_NL;
        !            10: extern float   fsqrt();
        !            11: 
        !            12: println(s, aa)
        !            13:        char *s;
        !            14:        long aa;
        !            15: {
        !            16:        char c, *t = s;
        !            17:        int argc=1;
        !            18:        long *aaa = &aa;
        !            19: 
        !            20:        for (;;)
        !            21:        switch (c = *t++) {
        !            22:        case '\0': return argc;
        !            23:        case  '%': switch (c = *t++) {
        !            24:                   case '\0': putc('%', stderr); return argc;
        !            25:                   case  'd': fprintf(stderr, "%d", (int)*aaa);
        !            26:                              aaa++; argc++; break;
        !            27:                   case  's': fprintf(stderr, "%s", (char *)*aaa);
        !            28:                              aaa++; argc++; break;
        !            29:                   case  '%': putc('%', stderr); break;
        !            30:                   default  : putc('%', stderr); putc(c, stderr); break;
        !            31:                   }
        !            32:                   break;
        !            33:        default  : putc(c, stderr); break;
        !            34:        }
        !            35: }
        !            36: 
        !            37: Clamp(a){ return ((a < 0)?0:((a>=DEF_LL)?(DEF_LL-1):a)); }
        !            38: Abs(a) { return ((a<0)?(-a):a); }
        !            39: 
        !            40: int Midx = 256, Midy = 256;
        !            41: 
        !            42: setmid()
        !            43: {
        !            44:        Midx = (Old->sx + (Old->ex - Old->sx)/2);
        !            45:        Midy = (Old->sy + (Old->ey - Old->sy)/2);
        !            46: }
        !            47: 
        !            48: r_polar(x, y)
        !            49: {      register float dx = (float) (x - Midx);
        !            50:        register float dy = (float) (y - Midy);
        !            51: 
        !            52:        return (int) fsqrt(dx*dx + dy*dy);
        !            53: }
        !            54: 
        !            55: a_polar(x, y)
        !            56: {
        !            57:        return patan2(x-Midx, y-Midy);
        !            58: }
        !            59: A_polar(x, y)
        !            60: {
        !            61:        return Patan2(x-Midx, y-Midy);
        !            62: }
        !            63: 
        !            64: Y_cart(r, a)
        !            65: {
        !            66:        return Midy+(r*Psin(a)/10000);
        !            67: }
        !            68: y_cart(r, a)
        !            69: {      int b = Midy+(r*psin(a)/10000);
        !            70:        return (b >= 0 && b < DEF_NL)?b:0;
        !            71: }
        !            72: 
        !            73: X_cart(r, a)
        !            74: {
        !            75:        return Midx+(r*Pcos(a)/10000);
        !            76: }
        !            77: x_cart(r, a)
        !            78: {      int b = Midx+(r*pcos(a)/10000);
        !            79:        return (b >= 0 && b < DEF_LL)?b:0;
        !            80: }
        !            81: 
        !            82: setzmap(i, z)
        !            83: {
        !            84:        redcmap(i, z);
        !            85:        grncmap(i, z);
        !            86:        blucmap(i, z);
        !            87:        return z;
        !            88: }
        !            89: 
        !            90: setcmap(i, r,g,b)
        !            91: {
        !            92:        redcmap(i, r);
        !            93:        grncmap(i, g);
        !            94:        blucmap(i, b);
        !            95:        return r;
        !            96: }
        !            97: 
        !            98: putframe(n)
        !            99: {      char nr[128];
        !           100:        int i;
        !           101: 
        !           102:        sprintf(nr, "frame.%6d", n);
        !           103:        for (i = 11; i > 5; i--)
        !           104:                if (nr[i] == ' ') nr[i] = '0';
        !           105:        i = CUROLD; CUROLD = CURSCRATCH; CURSCRATCH = i;
        !           106:        putdpix(nr, 0);
        !           107:        i = CUROLD; CUROLD = CURSCRATCH; CURSCRATCH = i;
        !           108:        return 1;
        !           109: }
        !           110: 
        !           111: swap()
        !           112: {
        !           113:        setscratch(Scratch, Old);
        !           114:        return 1;
        !           115: }
        !           116: 
        !           117: getframe(n)
        !           118: {      char nr[128];
        !           119:        int i;
        !           120: 
        !           121:        sprintf(nr, "frame.%6d", n);
        !           122:        for (i = 11; i > 5; i--)
        !           123:                if (nr[i] == ' ') nr[i] = '0';
        !           124:        return newscreen(nr);
        !           125: }
        !           126: 
        !           127: yank(x, y)
        !           128: {      if (frameb) fbyank(x, y);
        !           129:        else if (metheus) metyank(x,y);
        !           130: }
        !           131: 
        !           132: intexp(a) int a; {     return (int) exp((double) a); }
        !           133: intlog(a) int a; {     return (int) 1024*log((double) a); }
        !           134: intlog10(a) int a; {   return (int) 1024*log10((double) a); }
        !           135: intsqrt(a) int a; {    return (int) sqrt((double) a); }
        !           136: intpow(a, b) int a,b; {        return (int) pow((double) a, (double) b); }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.