#include "post_mus.h"

/* point sizes for blobs etc */
#define SON_PS1	18

/* clefs, hooks */
#define SON_PS2 20

/* widths for clefs */
#define CLEF_WIDTH 18

float   scale_ht;
char   *splines = "spline";
char   *text_sharp =
        "\\h'0.1m'\\v'-0.30m'\\s+2\\(sh\\s-2\\v'0.30m'\\h'0.1m'";
char   *text_flat =
        "\\h'0.1m'\\v'-0.30m'\\s+2\\(ft\\s-2\\v'0.30m'\\h'0.1m'";
char   *text_natural =
        "\\h'0.1m'\\v'-0.20m'\\s+2\\(na\\s-2\\v'0.20m'";

putrck () {
    putatom (DDOT);
}

putckr () {
    int     x = x_now,
            y = y_now;
    absmove (x + atom[KNLINE].a_width + 1, y);
    putatom (DDOT);
}

putrckr () {
    int     x = x_now,
            y = y_now;
    putatom (DDOT);
    absmove (x + atom[DDOT].a_width + atom[NKNLINE].a_width, y);
    putatom (DDOT);
}

struct atoms    atom[] = {
/* pic commands, 4 args, height, width, postmove,
			1 for vertical centre, proc to execute * / 
/* SHARP sharp	     */
    "\"\\s%d\\(sh\\s0\" at %d,%d.5 ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    10, 6, 6, 0, 0,

/* FLAT flat		   */
    "\"\\s%d\\(ft\\s0\" at %d,%d ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    10, 5, 5, 0, 0,

/* NATURAL natural     */
    "\"\\s%d\\(na\\s0\" at %d,%d.25 ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    10, 5, 5, 0, 0,

/* HOLLOW hollow note */
    "\"\\s%d\\(bo\\s0\" at %d.75,%d.25 ljust",
    S, SON_PS1, X, -1, Y, 3, 0, 0,
    6, 6, 6, 0, 0,

/* SOLID solid note */
    "\"\\s%d\\(bf\\s0\" at %d.75,%d.5 ljust",
    S, SON_PS1, X, -1, Y, 3, 0, 0,
    6, 6, 6, 0, 0,

/* barline BARLINE */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 2, 2, 1, 0,

/* double line DBARLINE */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 5, 5, 1, 0,

/* REPEAT repeat */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 11, 11, 1, putrck,

/* DOT dot */
    "move right 2.5; circle radius 0.5; move left 1.25; right;circle radius 1;",
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 4, 0, 0, 0,

/* stick unused except for its length (i.e. height) */
    "stick",
    0, 0, 0, 0, 0, 0, 0, 0,
    HALFSTAVE + 5, 1, 1, 0, 0,

/* timesig unused except for width */
    "box \"T\"",
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 10, 0, 0, 0,

/* treble clef */
    "\"\\s%d\\(tc\\s0\" at %d,%d ljust",
    S, SON_PS2, X, 2, Y, -9, 0, 0,
    FULLSTAVE, CLEF_WIDTH, 1, 1, 0,

/* top hook    */
    "\"\\s%d\\(th\\s0\" at %d.5,%d ljust",
    S, SON_PS2, X, -7, Y, -16, 0, 0,
    4, 5, 5, 0, 0,

/* bottom hook */
    "\"\\s%d\\(bh\\s0\" at %d.5, %d.5 ljust",
    S, SON_PS2, X, -1, Y, 20, 0, 0,
    4, 5, 5, 0, 0,

/* bass clef */
    "\"\\s%d\\(bc\\s0\" at %d,%d.75 ljust",
    S, SON_PS2, X, 2, Y, -9, 0, 0,
    FULLSTAVE, CLEF_WIDTH, 1, 1, 0,

/* ledger line */
    "move left 2; line right 10; move left 8 down 6",
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 0, 0, 0, 0,

/* thin and thick vertical line for ends */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 7, 7, 1, 0,

/* double dot */
    "move right 3; move up 2; circle radius 1; move down 0.5; circle radius 0.5;\
move down 5; circle radius 0.5; move down 0.5; up; circle radius 1;\
move up 2 right 3\n",
    0, 0, 0, 0, 0, 0, 0, 0,
    8, 5, 5, 0, 0,

/* breve */
    "right; circle radius 2.5; move left 2.5; right; circle radius 2.5",
    0, 0, 0, 0, 0, 0, 0, 0,
    5, 8, 0, 0, 0,

/* updot UPDOT */
    "move up 2.5; move right 2.5; \
circle radius 0.5; move left 1.25; right;circle radius 1;\
move down 2.5; right",
    0, 0, 0, 0, 0, 0, 0, 0,
    1, 4, 0, 0, 0,

/* semibreve rest below middle line */
    "move down 2.5; # semibreve rest\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8;\n",
    X, 0, Y, -2, 0, 0, 0, 0, 8, 8, 0, 2, 0,

/* SBRREST semibreve rest below 2nd line */
    "move up 3.5; # semibreve rest\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8;\n",
    X, 0, Y, 4, 0, 0, 0, 0, 8, 8, 0, 2, 0,

/* MINREST minim rest above middle line */
    "move up 0.5; # minim rest\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8; move up 0.5; line left 8; move up 0.5;\n\
line right 8;\n",
    X, 0, Y, 0, 0, 0, 0, 0, 8, 8, 0, 2, 0,

/* CROREST crochet rest */
    "\"\\s%d\\(CR\\s0\" at %d,%d.5 ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    6, 6, 6, 1, 0,

/* QUAREST quaver rest */
    "\"\\s%d\\(QR\\s0\" at %d,%d ljust",
    S, SON_PS1, X, 0, Y, 7, 0, 0,
    6, 6, 6, 1, 0,

/* semi-quaver rest */
    "\"\\s%d\\(SR\\s0\" at %d,%d ljust",
    S, SON_PS1, X, 0, Y, 5, 0, 0,
    6, 6, 6, 1, 0,

/* demi-semi-quaver rest */
    "\"\\s%d\\(DR\\s0\" at %d,%d ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    6, 6, 6, 1, 0,

/* semibreve note */
    "\"\\s%d\\(wn\\s0\" at %d,%d.25 ljust",
    S, SON_PS1, X, 0, Y, 3, 0, 0,
    5, 5, 5, 0, 0,

/* soprano clef */
    "\"\\s%d\\(cc\\s0\" at %d,%d.5 ljust",
    S, SON_PS2, X, 2, Y, -21, 0, 0,
    FULLSTAVE, CLEF_WIDTH, 1, 1, 0,

/* alto clef */
    "\"\\s%d\\(cc\\s0\" at %d,%d.5 ljust",
    S, SON_PS2, X, 2, Y, -9, 0, 0,
    FULLSTAVE, CLEF_WIDTH, 1, 1, 0,

/* tenor clef */
    "\"\\s%d\\(cc\\s0\" at %d,%d.5 ljust",
    S, SON_PS2, X, 2, Y, -3, 0, 0,
    FULLSTAVE, CLEF_WIDTH, 1, 1, 0,

/* thick vertical line for ends */
    "move right 2; move down 12; \
line up 24; move right 0.5; line down 24; move right 0.5;\
line up 24; move right 0.5; line down 24; move right 0.5;\
line up 24; move down 12;",
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 4, 4, 1, 0,

/* barline thick thin */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 7, 7, 1, 0,

/* barline thin thick thin */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 10, 10, 1, 0,

/* barline rept start */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 11, 11, 1, putckr,

/* barline repeat both */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 18, 18, 1, putrckr,

/* hashed barline */
    0,
    0, 0, 0, 0, 0, 0, 0, 0,
    FULLSTAVE, 1, 1, 1, 0,

};


struct clefs    clef[] = {
/* pitch offset of middle line, atom no, character */
     /* dummy   */ 0, 0, 't',
     /* treble  */ 43, TCLEF, 't',
     /* bass	   */ 31, BCLEF, 'b',
     /* soprano */ 41, SCLEF, 's',
     /* altno   */ 37, ACLEF, 'a',
     /* tenor   */ 35, NCLEF, 'n',
};

struct notes    notev[NNOTES];	/* the notes */

struct bars barv[NBARS];	/* the bars */

struct staves   stavev[NSTAVES],
               *stavep;		/* the staves */

struct pieces   piecev;		/* the piece */

struct parts	partv[NPARTS];		/* the parts */


int     put_monitor = 0;
int     set_monitor = 0;
int     get_monitor = 0;
int     x_now,
        y_now;

char   *textp,
        textv[MAXTEXT];
int     atom_monitor = -1,
        up_down_border = 1;
float   totalheight = 0.0;

