... | ... |
@@ -12,13 +12,11 @@ clang-format -i src/devices/mpu.c |
12 | 12 |
clang-format -i src/uxnasm.c |
13 | 13 |
clang-format -i src/uxnemu.c |
14 | 14 |
clang-format -i src/uxncli.c |
15 |
-clang-format -i src/chr2img.c |
|
16 | 15 |
|
17 | 16 |
echo "Cleaning.." |
18 | 17 |
rm -f ./bin/uxnasm |
19 | 18 |
rm -f ./bin/uxnemu |
20 | 19 |
rm -f ./bin/uxncli |
21 |
-rm -f ./bin/chr2img |
|
22 | 20 |
rm -f ./bin/boot.rom |
23 | 21 |
|
24 | 22 |
echo "Building.." |
... | ... |
@@ -29,12 +27,10 @@ then |
29 | 27 |
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxnasm.c -o bin/uxnasm |
30 | 28 |
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c -L/usr/local/lib $(sdl2-config --cflags --libs) -o bin/uxnemu |
31 | 29 |
cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/uxn.c src/uxncli.c -o bin/uxncli |
32 |
- cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined src/chr2img.c -o bin/chr2img |
|
33 | 30 |
else |
34 | 31 |
cc src/uxnasm.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxnasm |
35 | 32 |
cc src/uxn-fast.c src/uxncli.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxncli |
36 | 33 |
cc src/uxn-fast.c src/devices/ppu.c src/devices/apu.c src/devices/mpu.c src/uxnemu.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib $(sdl2-config --cflags --libs) -o bin/uxnemu |
37 |
- cc src/chr2img.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/chr2img |
|
38 | 34 |
fi |
39 | 35 |
|
40 | 36 |
echo "Installing.." |
... | ... |
@@ -43,7 +39,6 @@ then |
43 | 39 |
cp ./bin/uxnemu $HOME/bin |
44 | 40 |
cp ./bin/uxnasm $HOME/bin |
45 | 41 |
cp ./bin/uxncli $HOME/bin |
46 |
- cp ./bin/chr2img $HOME/bin |
|
47 | 42 |
echo "Installed in $HOME/bin" |
48 | 43 |
fi |
49 | 44 |
|
... | ... |
@@ -1,6 +1,6 @@ |
1 | 1 |
</$objtype/mkfile |
2 | 2 |
|
3 |
-TARG=bin/uxncli bin/uxnasm bin/uxnemu bin/chr2img |
|
3 |
+TARG=bin/uxncli bin/uxnasm bin/uxnemu |
|
4 | 4 |
USM=`{walk -f projects/ | grep '\.tal$' | grep -v blank.tal} |
5 | 5 |
ROM=${USM:%.tal=%.rom} |
6 | 6 |
CFLAGS=$CFLAGS -D__plan9__ -I/sys/include/npe -I/sys/include/npe/SDL2 |
... | ... |
@@ -38,10 +38,7 @@ bin/uxnasm: uxnasm.$O |
38 | 38 |
bin/uxnemu: uxnemu.$O apu.$O mpu.$O ppu.$O uxn.$O |
39 | 39 |
$LD $LDFLAGS -o $target $prereq |
40 | 40 |
|
41 |
-bin/chr2img: chr2img.$O |
|
42 |
- $LD $LDFLAGS -o $target $prereq |
|
43 |
- |
|
44 |
-(uxnasm|uxncli|uxnemu|uxn|chr2img)\.$O:R: src/\1.c |
|
41 |
+(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c |
|
45 | 42 |
$CC $CFLAGS -Isrc -o $target src/$stem1.c |
46 | 43 |
|
47 | 44 |
(apu|mpu|ppu)\.$O:R: src/devices/\1.c |
48 | 45 |
deleted file mode 100644 |
... | ... |
@@ -1,196 +0,0 @@ |
1 |
-#ifdef __plan9__ |
|
2 |
-#include <u.h> |
|
3 |
-#include <libc.h> |
|
4 |
-#include <draw.h> |
|
5 |
-#include <memdraw.h> |
|
6 |
-#else |
|
7 |
-#include <stdio.h> |
|
8 |
-#include <stdint.h> |
|
9 |
-#include <string.h> |
|
10 |
-#include <unistd.h> |
|
11 |
-#include <stdlib.h> |
|
12 |
-typedef uint8_t u8int; |
|
13 |
-typedef uint32_t u32int; |
|
14 |
-#define nil NULL |
|
15 |
-typedef struct { |
|
16 |
-} Memimage; |
|
17 |
-typedef struct { |
|
18 |
- u32int *base; |
|
19 |
- u8int *bdata; |
|
20 |
-} Memdata; |
|
21 |
-static char *argv0; |
|
22 |
-#define fprint(x, arg...) fprintf(stderr, arg) |
|
23 |
-#define exits(s) exit(s == NULL ? 0 : 1) |
|
24 |
-#define sysfatal(s) \ |
|
25 |
- do { \ |
|
26 |
- fprintf(stderr, "error\n"); \ |
|
27 |
- exit(1); \ |
|
28 |
- } while(0) |
|
29 |
-#define ARGBEGIN \ |
|
30 |
- for(((argv0 = *argv)), argv++, argc--; \ |
|
31 |
- argv[0] && argv[0][0] == '-' && argv[0][1]; \ |
|
32 |
- argc--, argv++) { \ |
|
33 |
- char *_args, _argc, *_argt; \ |
|
34 |
- _args = &argv[0][1]; \ |
|
35 |
- if(_args[0] == '-' && _args[1] == 0) { \ |
|
36 |
- argc--; \ |
|
37 |
- argv++; \ |
|
38 |
- break; \ |
|
39 |
- } \ |
|
40 |
- _argc = 0; \ |
|
41 |
- while(*_args && (_argc = *_args++)) \ |
|
42 |
- switch(_argc) |
|
43 |
-#define ARGEND \ |
|
44 |
- } \ |
|
45 |
- ; |
|
46 |
-#define EARGF(x) \ |
|
47 |
- (_argt = _args, _args = "", (*_argt ? _argt : argv[1] ? (argc--, *++argv) \ |
|
48 |
- : ((x), abort(), (char *)0))) |
|
49 |
-#endif |
|
50 |
- |
|
51 |
-static int hor = 44, ver = 26, bpp = 1; |
|
52 |
- |
|
53 |
-#define xy2n(x, y) ((y & 7) + (x / 8 + y / 8 * hor) * bpp * 8) |
|
54 |
- |
|
55 |
-static u8int * |
|
56 |
-readall(int f, int *isz) |
|
57 |
-{ |
|
58 |
- int bufsz, sz, n; |
|
59 |
- u8int *s; |
|
60 |
- |
|
61 |
- bufsz = 1023; |
|
62 |
- s = nil; |
|
63 |
- for(sz = 0;; sz += n) { |
|
64 |
- if(bufsz - sz < 1024) { |
|
65 |
- bufsz *= 2; |
|
66 |
- s = realloc(s, bufsz); |
|
67 |
- } |
|
68 |
- if((n = read(f, s + sz, bufsz - sz)) < 1) |
|
69 |
- break; |
|
70 |
- } |
|
71 |
- if(n < 0 || sz < 1) { |
|
72 |
- free(s); |
|
73 |
- return nil; |
|
74 |
- } |
|
75 |
- *isz = sz; |
|
76 |
- |
|
77 |
- return s; |
|
78 |
-} |
|
79 |
- |
|
80 |
-static int |
|
81 |
-getcoli(int x, int y, u8int *p) |
|
82 |
-{ |
|
83 |
- int ch1, ch2, r; |
|
84 |
- |
|
85 |
- r = xy2n(x, y); |
|
86 |
- ch1 = (p[r + 0] >> (7 - (x & 7))) & 1; |
|
87 |
- ch2 = bpp < 2 ? 0 : (p[r + 8] >> (7 - (x & 7))) & 1; |
|
88 |
- |
|
89 |
- return ch2 << 1 | ch1; |
|
90 |
-} |
|
91 |
- |
|
92 |
-static int |
|
93 |
-writebmp(int w, int h, u32int *p) |
|
94 |
-{ |
|
95 |
- /* clang-format off */ |
|
96 |
- int sz = 14 + 40 + 4*4 + 4*w*h; |
|
97 |
- u8int hd[14+40+4*4] = { |
|
98 |
- 'B', 'M', |
|
99 |
- sz, sz>>8, sz>>16, sz>>24, /* file size */ |
|
100 |
- 0, 0, |
|
101 |
- 0, 0, |
|
102 |
- 14+40+4*4, 0, 0, 0, /* pixel data offset */ |
|
103 |
- 40+4*4, 0, 0, 0, /* BITMAPINFOHEADER */ |
|
104 |
- w, w>>8, 0, 0, /* width */ |
|
105 |
- h, h>>8, 0, 0, /* height */ |
|
106 |
- 1, 0, /* color planes */ |
|
107 |
- 32, 0, /* bpp = rgba */ |
|
108 |
- 3, 0, 0, 0, /* no compression */ |
|
109 |
- 0, 0, 0, 0, /* dummy raw size */ |
|
110 |
- 0, 0, 0, 0, /* dummy hor ppm */ |
|
111 |
- 0, 0, 0, 0, /* dummy ver ppm */ |
|
112 |
- 0, 0, 0, 0, /* dummy num of colors */ |
|
113 |
- 0, 0, 0, 0, /* dummy important colors */ |
|
114 |
- 0, 0, 0, 0xff, /* R mask */ |
|
115 |
- 0, 0, 0xff, 0, /* G mask */ |
|
116 |
- 0, 0xff, 0, 0, /* B mask */ |
|
117 |
- 0xff, 0, 0, 0, /* A mask */ |
|
118 |
- }; |
|
119 |
- /* clang-format on */ |
|
120 |
- |
|
121 |
- write(1, hd, sizeof(hd)); |
|
122 |
- while(h-- >= 0) |
|
123 |
- write(1, p + w * h, 4 * w); |
|
124 |
- |
|
125 |
- return 0; |
|
126 |
-} |
|
127 |
- |
|
128 |
-static void |
|
129 |
-usage(void) |
|
130 |
-{ |
|
131 |
- fprint(2, "usage: %s [-1] [-2] [-w WIDTH]\n", argv0); |
|
132 |
- exits("usage"); |
|
133 |
-} |
|
134 |
- |
|
135 |
-int |
|
136 |
-main(int argc, char **argv) |
|
137 |
-{ |
|
138 |
- int sz, esz, h, w, x, y; |
|
139 |
- Memimage *m; |
|
140 |
- Memdata d; |
|
141 |
- u8int *p; |
|
142 |
- u32int col[2][4] = { |
|
143 |
- {0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff}, |
|
144 |
- {0xffffff00, 0xffffffff, 0x72dec2ff, 0x666666ff}, |
|
145 |
- }; |
|
146 |
- |
|
147 |
- ARGBEGIN |
|
148 |
- { |
|
149 |
- case '1': |
|
150 |
- bpp = 1; |
|
151 |
- break; |
|
152 |
- case '2': |
|
153 |
- bpp = 2; |
|
154 |
- break; |
|
155 |
- case 'w': |
|
156 |
- hor = atoi(EARGF(usage())); |
|
157 |
- break; |
|
158 |
- default: |
|
159 |
- usage(); |
|
160 |
- } |
|
161 |
- ARGEND |
|
162 |
- |
|
163 |
- if((p = readall(0, &sz)) == nil) |
|
164 |
- sysfatal("%r"); |
|
165 |
- |
|
166 |
- ver = sz / (bpp * 8) / hor; |
|
167 |
- esz = (hor * ver * (bpp * 8)); |
|
168 |
- w = hor * 8; |
|
169 |
- h = ver * 8; |
|
170 |
- if(sz != esz) |
|
171 |
- fprint(2, "warning: size differs (%d vs %d), dimensions must be wrong\n", sz, esz); |
|
172 |
- |
|
173 |
- memset(&d, 0, sizeof(d)); |
|
174 |
- if((d.base = malloc(4 * w * h)) == nil) |
|
175 |
- sysfatal("memory"); |
|
176 |
- d.bdata = (u8int *)d.base; |
|
177 |
- |
|
178 |
- for(y = 0; y < h; y++) { |
|
179 |
- for(x = 0; x < w; x++) |
|
180 |
- d.base[y * w + x] = col[bpp - 1][getcoli(x, y, p)]; |
|
181 |
- } |
|
182 |
- |
|
183 |
-#ifdef __plan9__ |
|
184 |
- memimageinit(); |
|
185 |
- if((m = allocmemimaged(Rect(0, 0, w, h), RGBA32, &d)) == nil) |
|
186 |
- sysfatal("%r"); |
|
187 |
- if(writememimage(1, m) != 0) |
|
188 |
- sysfatal("%r"); |
|
189 |
-#else |
|
190 |
- (void)m; |
|
191 |
- writebmp(w, h, d.base); |
|
192 |
-#endif |
|
193 |
- |
|
194 |
- exits(nil); |
|
195 |
- return 0; |
|
196 |
-} |