comparison lunalcd/common.c @ 65:cdf2c99e5025

lunalcd project started
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 19 Mar 2020 01:31:05 +0000
parents
children
comparison
equal deleted inserted replaced
64:6d02f30e35ad 65:cdf2c99e5025
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <string.h>
4 #include <strings.h>
5
6 static enum {
7 MODE_L8,
8 MODE_U8,
9 MODE_16,
10 MODE_USB
11 } mode;
12
13 set_output_mode(kw)
14 char *kw;
15 {
16 if (!strcmp(kw, "l8"))
17 mode = MODE_L8;
18 else if (!strcmp(kw, "u8"))
19 mode = MODE_U8;
20 else if (!strcmp(kw, "16"))
21 mode = MODE_16;
22 else if (!strcmp(kw, "usb"))
23 mode = MODE_USB;
24 else {
25 fprintf(stderr, "error: mode \"%s\" not understood\n", kw);
26 exit(1);
27 }
28 }
29
30 write_ir(val16)
31 unsigned val16;
32 {
33 if (mode != MODE_USB)
34 printf("w16 fffe4802 200\n");
35 switch (mode) {
36 case MODE_L8:
37 printf("w16 02000000 %02x\n", val16 >> 8);
38 printf("w16 02000000 %02x\n", val16 & 0xFF);
39 break;
40 case MODE_U8:
41 printf("w16 02000000 %02x00\n", val16 >> 8);
42 printf("w16 02000000 %02x00\n", val16 & 0xFF);
43 break;
44 case MODE_16:
45 printf("w16 02000000 %04x\n", val16);
46 break;
47 case MODE_USB:
48 printf("wi %04x\n", val16);
49 }
50 }
51
52 write_dr(val16)
53 unsigned val16;
54 {
55 if (mode != MODE_USB)
56 printf("w16 fffe4802 600\n");
57 switch (mode) {
58 case MODE_L8:
59 printf("w16 02000002 %02x\n", val16 >> 8);
60 printf("w16 02000002 %02x\n", val16 & 0xFF);
61 break;
62 case MODE_U8:
63 printf("w16 02000002 %02x00\n", val16 >> 8);
64 printf("w16 02000002 %02x00\n", val16 & 0xFF);
65 break;
66 case MODE_16:
67 printf("w16 02000002 %04x\n", val16);
68 break;
69 case MODE_USB:
70 printf("wd %04x\n", val16);
71 }
72 }
73
74 bulk_wd_prep()
75 {
76 if (mode != MODE_USB)
77 printf("w16 fffe4802 600\n");
78 }
79
80 bulk_wd(val16)
81 unsigned val16;
82 {
83 switch (mode) {
84 case MODE_L8:
85 printf("w16 02000002 %02x\n", val16 >> 8);
86 printf("w16 02000002 %02x\n", val16 & 0xFF);
87 break;
88 case MODE_U8:
89 printf("w16 02000002 %02x00\n", val16 >> 8);
90 printf("w16 02000002 %02x00\n", val16 & 0xFF);
91 break;
92 case MODE_16:
93 printf("w16 02000002 %04x\n", val16);
94 break;
95 case MODE_USB:
96 printf("wd %04x\n", val16);
97 }
98 }