Changeset 7258c6a in buchla-68k for ram/tundsp.c


Ignore:
Timestamp:
07/09/2017 04:45:34 PM (7 years ago)
Author:
Thomas Lopatic <thomas@…>
Branches:
master
Children:
8618599
Parents:
0292fbb
Message:

Use standard integer types.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ram/tundsp.c

    r0292fbb r7258c6a  
    2121#define TUN_VAL 100             /* default value for tunval in cents */
    2222
    23 extern  short   stcrow, stccol, cxval, cyval;
    24 
    25 extern  short   curtun;         /* current tuning table */
    26 extern  short   submenu;        /* submenu cursor switch */
    27 extern  short   tunmod;         /* tuning table modified */
    28 extern  short   tunval;         /* tuning table generator value */
    29 extern  short   ttcmdsv;        /* tuning table editing state variable */
    30 extern  short   tdnamsw;        /* tuning editor displaying typewriter */
    31 
    32 extern  short   oldtun[];       /* previous tuning table for undo */
    33 extern  short   tuntab[];       /* current tuning table */
    34 extern  short   tunlib[][128];  /* tuning table library */
    35 
    36 extern  short   panlkey[];      /* local key tunings */
    37 extern  short   lclkmap[];      /* local key to MIDI key map */
    38 
    39 extern  char    tuncurn[];      /* current tuning table name */
    40 extern  char    tunname[][32];  /* tuning table names */
    41 extern  char    sfdsp[];
    42 
    43 extern  unsigned        *obj0, *obj2;
    44 
    45 extern  char    bfs[];
    46 extern  char    *tdbxlb[];
    47 
    48 extern  short   tdbox[][8];
    49 
    50 extern  unsigned        *tunob;
     23extern  int16_t stcrow, stccol, cxval, cyval;
     24
     25extern  int16_t curtun;         /* current tuning table */
     26extern  int16_t submenu;        /* submenu cursor switch */
     27extern  int16_t tunmod;         /* tuning table modified */
     28extern  int16_t tunval;         /* tuning table generator value */
     29extern  int16_t ttcmdsv;        /* tuning table editing state variable */
     30extern  int16_t tdnamsw;        /* tuning editor displaying typewriter */
     31
     32extern  int16_t oldtun[];       /* previous tuning table for undo */
     33extern  int16_t tuntab[];       /* current tuning table */
     34extern  int16_t tunlib[][128];  /* tuning table library */
     35
     36extern  int16_t panlkey[];      /* local key tunings */
     37extern  int16_t lclkmap[];      /* local key to MIDI key map */
     38
     39extern  int8_t  tuncurn[];      /* current tuning table name */
     40extern  int8_t  tunname[][32];  /* tuning table names */
     41extern  int8_t  sfdsp[];
     42
     43extern  uint16_t        *obj0, *obj2;
     44
     45extern  int8_t  bfs[];
     46extern  int8_t  *tdbxlb[];
     47
     48extern  int16_t tdbox[][8];
     49
     50extern  uint16_t        *tunob;
    5151
    5252extern  struct  octent  *tdoct;
     
    5656*/
    5757
    58 short   tunpal[16][3] = {       /* color palette */
     58int16_t tunpal[16][3] = {       /* color palette */
    5959
    6060        {0, 0, 0},      /* 0 */
     
    7777
    7878                        /*   12345678901234567890123456789012   */
    79 static  char    dfltnam[] = "Local 3rds + MIDI 12 tone scale ";
    80 
    81 char    *tdlabl[] = {
     79static  int8_t  dfltnam[] = "Local 3rds + MIDI 12 tone scale ";
     80
     81int8_t  *tdlabl[] = {
    8282
    8383        "C", "#", "D", "#", "E", "F", "#", "G",
     
    9696*/
    9797
    98 void gettun(short n)
     98void gettun(int16_t n)
    9999{
    100100        memcpyw(tuntab, tunlib[n], 128);
     
    110110*/
    111111
    112 void puttun(short n)
     112void puttun(int16_t n)
    113113{
    114114        memcpyw(tunlib[n], tuntab, 128);
     
    127127*/
    128128
    129 void inittt(short n)
    130 {
    131         register short i;
     129void inittt(int16_t n)
     130{
     131        register int16_t i;
    132132
    133133        for (i = 0; i < 128; i++)
     
    150150void inittl(void)
    151151{
    152         register short i;
     152        register int16_t i;
    153153
    154154        for (i = 0; i < NTUNS; i++)
     
    170170*/
    171171
    172 void tt_trcp(short start, short finish, short dest)
    173 {
    174         register short i;
    175         register long v;
     172void tt_trcp(int16_t start, int16_t finish, int16_t dest)
     173{
     174        register int16_t i;
     175        register int32_t v;
    176176
    177177        memcpyw(oldtun, tuntab, 128);   /* preserve old table for undo */
     
    183183                        /* reverse copy */
    184184
    185                         v = oldtun[i] + (long)tunval;   /* transpose */
    186 
    187                         if (v GT (long)PITCHMAX)        /* limit */
    188                                 v = (long)PITCHMAX;
    189                         else if (v LT (long)PITCHMIN)
    190                                 v = (long)PITCHMIN;
    191 
    192                         tuntab[dest++] = (short)v;      /* store the value */
     185                        v = oldtun[i] + (int32_t)tunval;        /* transpose */
     186
     187                        if (v GT (int32_t)PITCHMAX)     /* limit */
     188                                v = (int32_t)PITCHMAX;
     189                        else if (v LT (int32_t)PITCHMIN)
     190                                v = (int32_t)PITCHMIN;
     191
     192                        tuntab[dest++] = (int16_t)v;    /* store the value */
    193193                }
    194194
     
    199199                        /* forward copy */
    200200
    201                         v = oldtun[i] + (long)tunval;   /* transpose */
    202 
    203                         if (v GT (long)PITCHMAX)        /* limit */
    204                                 v = (long)PITCHMAX;
    205                         else if (v LT (long)PITCHMIN)
    206                                 v = (long)PITCHMIN;
    207 
    208                         tuntab[dest++] = (short)v;      /* store the value */
     201                        v = oldtun[i] + (int32_t)tunval;        /* transpose */
     202
     203                        if (v GT (int32_t)PITCHMAX)     /* limit */
     204                                v = (int32_t)PITCHMAX;
     205                        else if (v LT (int32_t)PITCHMIN)
     206                                v = (int32_t)PITCHMIN;
     207
     208                        tuntab[dest++] = (int16_t)v;    /* store the value */
    209209                }
    210210        }
     
    223223*/
    224224
    225 short tt_intp(short from, short to)
    226 {
    227         register short i, j, k, n;
    228         register long t;
     225int16_t tt_intp(int16_t from, int16_t to)
     226{
     227        register int16_t i, j, k, n;
     228        register int32_t t;
    229229
    230230        memcpyw(oldtun, tuntab, 128);   /* preserve old table for undo */
     
    243243
    244244        k = tuntab[from];
    245         t = (((long)tuntab[to] - (long)k) << 16) / n;
     245        t = (((int32_t)tuntab[to] - (int32_t)k) << 16) / n;
    246246        j = 1 + from;
    247247        n--;
    248248
    249249        for (i = 0; i < n ; i++)
    250                 tuntab[j++] = (short)((t * (1 + i)) >> 16) + k;
     250                tuntab[j++] = (int16_t)((t * (1 + i)) >> 16) + k;
    251251
    252252        tunmod = TRUE;
     
    263263*/
    264264
    265 short tt_incr(short from, short to)
    266 {
    267         register short i;
    268         register long v;
     265int16_t tt_incr(int16_t from, int16_t to)
     266{
     267        register int16_t i;
     268        register int32_t v;
    269269
    270270        memcpyw(oldtun, tuntab, 128);   /* preserve old table for undo */
     
    278278        }
    279279
    280         v = (long)oldtun[from];         /* initial value */
     280        v = (int32_t)oldtun[from];              /* initial value */
    281281
    282282        if (from++ EQ to)               /* interval has to be at least 1 */
     
    285285        for (i = from; i LE to; i++) {
    286286
    287                 v += (long)tunval;              /* increment */
    288 
    289                 if (v GT (long)PITCHMAX)        /* limit */
    290                         v = (long)PITCHMAX;
    291                 else if (v LT (long)PITCHMIN)
    292                         v = (long)PITCHMIN;
    293 
    294                 tuntab[i] = (short)v;           /* store the value */
     287                v += (int32_t)tunval;           /* increment */
     288
     289                if (v GT (int32_t)PITCHMAX)     /* limit */
     290                        v = (int32_t)PITCHMAX;
     291                else if (v LT (int32_t)PITCHMIN)
     292                        v = (int32_t)PITCHMIN;
     293
     294                tuntab[i] = (int16_t)v;         /* store the value */
    295295        }
    296296
     
    309309*/
    310310
    311 void td_trcp(short mode)
    312 {
    313         register unsigned cx;
     311void td_trcp(int16_t mode)
     312{
     313        register uint16_t cx;
    314314
    315315        cx = exp_c(mode ? TDSELD : tdbox[6][4]);
     
    325325*/
    326326
    327 void td_incr(short mode)
    328 {
    329         register unsigned cx;
     327void td_incr(int16_t mode)
     328{
     329        register uint16_t cx;
    330330
    331331        cx = exp_c(mode ? TDSELD : tdbox[6][4]);
     
    340340*/
    341341
    342 void td_intp(short mode)
    343 {
    344         register unsigned cx;
     342void td_intp(int16_t mode)
     343{
     344        register uint16_t cx;
    345345
    346346        cx = exp_c(mode ? TDSELD : tdbox[6][4]);
     
    361361void advtcur(void)
    362362{
    363         register short newcol;
     363        register int16_t newcol;
    364364
    365365        if (infield(stcrow, stccol, curfet))
     
    385385void bsptcur(void)
    386386{
    387         register short newcol;
     387        register int16_t newcol;
    388388
    389389        if (infield(stcrow, stccol, curfet))
     
    411411*/
    412412
    413 void dsttval(short row, short col, short val, unsigned fg, unsigned bg)
    414 {
    415         register unsigned cfg, cbg;
     413void dsttval(int16_t row, int16_t col, int16_t val, uint16_t fg, uint16_t bg)
     414{
     415        register uint16_t cfg, cbg;
    416416
    417417        cfg = exp_c(fg);
     
    441441*/
    442442
    443 void tdswin(short n)
    444 {
    445         register short cx, i, tv;
    446         char ts;
     443void tdswin(int16_t n)
     444{
     445        register int16_t cx, i, tv;
     446        int8_t ts;
    447447
    448448        cx = exp_c(tdbox[n][5]);
     
    589589void twins(void)
    590590{
    591         register short i;
     591        register int16_t i;
    592592
    593593        for (i = 0; i < 8; i++)
Note: See TracChangeset for help on using the changeset viewer.