uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 38aa48b8bc4739cd900f4f63505191997bdb3ecd
parent 80c8e750762984f0996bad8aa594288c5a16b92b
Author: Sigrid Solveig Haflínudóttir <ftrvxmtrx@gmail.com>
Date:   Wed, 23 Jun 2021 17:45:13 +0000

remove chr2img (see https://git.sr.ht/~rabbits/chr-format instead)

Diffstat:
Mbuild.sh | 5-----
Mmkfile | 7++-----
Dsrc/chr2img.c | 196-------------------------------------------------------------------------------
3 files changed, 2 insertions(+), 206 deletions(-)

diff --git a/build.sh b/build.sh @@ -12,13 +12,11 @@ clang-format -i src/devices/mpu.c clang-format -i src/uxnasm.c clang-format -i src/uxnemu.c clang-format -i src/uxncli.c -clang-format -i src/chr2img.c echo "Cleaning.." rm -f ./bin/uxnasm rm -f ./bin/uxnemu rm -f ./bin/uxncli -rm -f ./bin/chr2img rm -f ./bin/boot.rom echo "Building.." @@ -29,12 +27,10 @@ then 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 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 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 - 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 else cc src/uxnasm.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxnasm cc src/uxn-fast.c src/uxncli.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/uxncli 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 - cc src/chr2img.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o bin/chr2img fi echo "Installing.." @@ -43,7 +39,6 @@ then cp ./bin/uxnemu $HOME/bin cp ./bin/uxnasm $HOME/bin cp ./bin/uxncli $HOME/bin - cp ./bin/chr2img $HOME/bin echo "Installed in $HOME/bin" fi diff --git a/mkfile b/mkfile @@ -1,6 +1,6 @@ </$objtype/mkfile -TARG=bin/uxncli bin/uxnasm bin/uxnemu bin/chr2img +TARG=bin/uxncli bin/uxnasm bin/uxnemu USM=`{walk -f projects/ | grep '\.tal$' | grep -v blank.tal} ROM=${USM:%.tal=%.rom} CFLAGS=$CFLAGS -D__plan9__ -I/sys/include/npe -I/sys/include/npe/SDL2 @@ -38,10 +38,7 @@ bin/uxnasm: uxnasm.$O bin/uxnemu: uxnemu.$O apu.$O mpu.$O ppu.$O uxn.$O $LD $LDFLAGS -o $target $prereq -bin/chr2img: chr2img.$O - $LD $LDFLAGS -o $target $prereq - -(uxnasm|uxncli|uxnemu|uxn|chr2img)\.$O:R: src/\1.c +(uxnasm|uxncli|uxnemu|uxn)\.$O:R: src/\1.c $CC $CFLAGS -Isrc -o $target src/$stem1.c (apu|mpu|ppu)\.$O:R: src/devices/\1.c diff --git a/src/chr2img.c b/src/chr2img.c @@ -1,196 +0,0 @@ -#ifdef __plan9__ -#include <u.h> -#include <libc.h> -#include <draw.h> -#include <memdraw.h> -#else -#include <stdio.h> -#include <stdint.h> -#include <string.h> -#include <unistd.h> -#include <stdlib.h> -typedef uint8_t u8int; -typedef uint32_t u32int; -#define nil NULL -typedef struct { -} Memimage; -typedef struct { - u32int *base; - u8int *bdata; -} Memdata; -static char *argv0; -#define fprint(x, arg...) fprintf(stderr, arg) -#define exits(s) exit(s == NULL ? 0 : 1) -#define sysfatal(s) \ - do { \ - fprintf(stderr, "error\n"); \ - exit(1); \ - } while(0) -#define ARGBEGIN \ - for(((argv0 = *argv)), argv++, argc--; \ - argv[0] && argv[0][0] == '-' && argv[0][1]; \ - argc--, argv++) { \ - char *_args, _argc, *_argt; \ - _args = &argv[0][1]; \ - if(_args[0] == '-' && _args[1] == 0) { \ - argc--; \ - argv++; \ - break; \ - } \ - _argc = 0; \ - while(*_args && (_argc = *_args++)) \ - switch(_argc) -#define ARGEND \ - } \ - ; -#define EARGF(x) \ - (_argt = _args, _args = "", (*_argt ? _argt : argv[1] ? (argc--, *++argv) \ - : ((x), abort(), (char *)0))) -#endif - -static int hor = 44, ver = 26, bpp = 1; - -#define xy2n(x, y) ((y & 7) + (x / 8 + y / 8 * hor) * bpp * 8) - -static u8int * -readall(int f, int *isz) -{ - int bufsz, sz, n; - u8int *s; - - bufsz = 1023; - s = nil; - for(sz = 0;; sz += n) { - if(bufsz - sz < 1024) { - bufsz *= 2; - s = realloc(s, bufsz); - } - if((n = read(f, s + sz, bufsz - sz)) < 1) - break; - } - if(n < 0 || sz < 1) { - free(s); - return nil; - } - *isz = sz; - - return s; -} - -static int -getcoli(int x, int y, u8int *p) -{ - int ch1, ch2, r; - - r = xy2n(x, y); - ch1 = (p[r + 0] >> (7 - (x & 7))) & 1; - ch2 = bpp < 2 ? 0 : (p[r + 8] >> (7 - (x & 7))) & 1; - - return ch2 << 1 | ch1; -} - -static int -writebmp(int w, int h, u32int *p) -{ - /* clang-format off */ - int sz = 14 + 40 + 4*4 + 4*w*h; - u8int hd[14+40+4*4] = { - 'B', 'M', - sz, sz>>8, sz>>16, sz>>24, /* file size */ - 0, 0, - 0, 0, - 14+40+4*4, 0, 0, 0, /* pixel data offset */ - 40+4*4, 0, 0, 0, /* BITMAPINFOHEADER */ - w, w>>8, 0, 0, /* width */ - h, h>>8, 0, 0, /* height */ - 1, 0, /* color planes */ - 32, 0, /* bpp = rgba */ - 3, 0, 0, 0, /* no compression */ - 0, 0, 0, 0, /* dummy raw size */ - 0, 0, 0, 0, /* dummy hor ppm */ - 0, 0, 0, 0, /* dummy ver ppm */ - 0, 0, 0, 0, /* dummy num of colors */ - 0, 0, 0, 0, /* dummy important colors */ - 0, 0, 0, 0xff, /* R mask */ - 0, 0, 0xff, 0, /* G mask */ - 0, 0xff, 0, 0, /* B mask */ - 0xff, 0, 0, 0, /* A mask */ - }; - /* clang-format on */ - - write(1, hd, sizeof(hd)); - while(h-- >= 0) - write(1, p + w * h, 4 * w); - - return 0; -} - -static void -usage(void) -{ - fprint(2, "usage: %s [-1] [-2] [-w WIDTH]\n", argv0); - exits("usage"); -} - -int -main(int argc, char **argv) -{ - int sz, esz, h, w, x, y; - Memimage *m; - Memdata d; - u8int *p; - u32int col[2][4] = { - {0xffffffff, 0x000000ff, 0x000000ff, 0x000000ff}, - {0xffffff00, 0xffffffff, 0x72dec2ff, 0x666666ff}, - }; - - ARGBEGIN - { - case '1': - bpp = 1; - break; - case '2': - bpp = 2; - break; - case 'w': - hor = atoi(EARGF(usage())); - break; - default: - usage(); - } - ARGEND - - if((p = readall(0, &sz)) == nil) - sysfatal("%r"); - - ver = sz / (bpp * 8) / hor; - esz = (hor * ver * (bpp * 8)); - w = hor * 8; - h = ver * 8; - if(sz != esz) - fprint(2, "warning: size differs (%d vs %d), dimensions must be wrong\n", sz, esz); - - memset(&d, 0, sizeof(d)); - if((d.base = malloc(4 * w * h)) == nil) - sysfatal("memory"); - d.bdata = (u8int *)d.base; - - for(y = 0; y < h; y++) { - for(x = 0; x < w; x++) - d.base[y * w + x] = col[bpp - 1][getcoli(x, y, p)]; - } - -#ifdef __plan9__ - memimageinit(); - if((m = allocmemimaged(Rect(0, 0, w, h), RGBA32, &d)) == nil) - sysfatal("%r"); - if(writememimage(1, m) != 0) - sysfatal("%r"); -#else - (void)m; - writebmp(w, h, d.base); -#endif - - exits(nil); - return 0; -}