File: vchar.c

package info (click to toggle)
vftool 2.0alpha-2
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 376 kB
  • ctags: 770
  • sloc: ansic: 2,748; makefile: 186; sh: 79
file content (72 lines) | stat: -rw-r--r-- 1,322 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include	<stdio.h>
#include	"vchar.h"

struct vchar vchar[256];
int depthratio;
int rdisp, ddisp, vdisp;

#define	LEN	256

readvchar(fn)
char *fn;
{
    FILE *f;
    char buf[LEN];
    int cc, jf, jc;
    struct vchar *vc;

    if ((f = fopen(fn, "r")) == NULL) {
	fprintf(stderr, "cannot open %s\n", fn);
	exit(1);
    }
    fgets(buf, LEN, f);
    depthratio = UNIT*atoi(buf)/1000;
    rdisp = UNIT-depthratio;
    ddisp = UNIT/2;
    vdisp = (UNIT/2)-depthratio;
    for (vc = vchar; fgets(buf, LEN, f) != NULL; vc++) {
	sscanf(buf, "%X", &cc);
	jf = cc>>8;
	jc = cc&0x7f;
	if (jf == 0x21) {
	    vc->f = VSY;
	    vc->c = jc-0x20;
	} else if (jf == 0x22) {
	    vc->f = VSY;
	    vc->c = jc-0x20+100;
	} else if (jf == 0x24) {
	    vc->f = VHIRA;
	    vc->c = jc-0x20;
	} else if (jf == 0x25) {
	    vc->f = VKATA;
	    vc->c = jc-0x20;
	} else {
	    fprintf(stderr, "vchar %X ignored\n", cc);
	    continue;
	}
	vc->cc = cc;
	vgetop(buf+4, vc);
    }
    vc->cc = 0;
}

vgetop(p, vc)
char *p;
struct vchar *vc;
{
    for (; *p == ' '; p++)
	;
    if (isdigit(*p)) {
	vc->op = vop_shift;
	vc->x = strtol(p, &p, 10)*UNIT/1000;
	vc->y = strtol(p, &p, 10)*UNIT/1000;
    } else if (*p == 'r') {
	vc->op = vop_rot;
	vc->x = 0;
	vc->y = 0;
    } else if (*p == 'm') {
	vc->op = vop_mirror;
	vc->x = 0;
	vc->y = 0;
    }
}