From cd2f6fa30e8e2f82c50b95f6a8c858a18d14de01 Mon Sep 17 00:00:00 2001 From: Kamila Szewczyk Date: Sun, 8 Oct 2023 14:15:08 +0200 Subject: [PATCH] finish ctype/avtype --- Makefile | 20 +++-- lib83/avtype.h | 220 +++++++++++++++++++++++++++++++++++++++++++++++++ lib83/ctype.c | 61 +++++++------- lib83/ctype.h | 16 ++++ 4 files changed, 278 insertions(+), 39 deletions(-) diff --git a/Makefile b/Makefile index 6ecc126..bc72e1d 100644 --- a/Makefile +++ b/Makefile @@ -10,23 +10,29 @@ OBJS=_crt0.rel clrscr.rel putchar.rel puts.rel exit.rel gotoxy.rel __assert_fail all: main.8xk clean: - rm -f * main.ihx main.bin main.8xk + @rm -f obj/* main.ihx main.bin main.8xk try: main.8xk - tilem2 --rom=ti83pv116.bin + @tilem2 --rom=ti83pv116.bin %.rel: lib83/%.c - $(CC) $(CFLAGS) $< -o obj/$@ + @echo "(lib) CC $<" + @$(CC) $(CFLAGS) $< -o obj/$@ %.rel: %.c - $(CC) $(CFLAGS) $< -o obj/$@ + @echo "CC $<" + @$(CC) $(CFLAGS) $< -o obj/$@ main.ihx: $(OBJS) - cd obj && $(CC) -mz80 --no-std-crt0 --code-loc 0x4000 --code-size 0x4000 --xram-loc 0x9D95 --xram-size 0x6060 $^ -o ../$@ && cd .. + @echo "LD $@" + @cd obj && $(CC) -mz80 --no-std-crt0 --code-loc 0x4000 --code-size 0x4000 --xram-loc 0x9D95 --xram-size 0x6060 $^ -o ../$@ && cd .. main.bin: main.ihx - objcopy -Iihex -Obinary $< $@ + @echo "IHX->BIN $@" + @objcopy -Iihex -Obinary $< $@ + @echo `stat -c %s $@` bytes main.8xk: main.bin - rabbitsign -v -P -p -t 8xk -g $< + @echo "SIGN $@" + @rabbitsign -P -p -t 8xk -g $< diff --git a/lib83/avtype.h b/lib83/avtype.h index e69de29..b89723b 100644 --- a/lib83/avtype.h +++ b/lib83/avtype.h @@ -0,0 +1,220 @@ + +#ifndef _AVTYPE_H +#define _AVTYPE_H + +#define AV_BLOCK 0x00 +#define AV_ETA_L 0x01 +#define AV_VEC_U 0x02 +#define AV_VEC_V 0x03 +#define AV_VEC_W 0x04 +#define AV_RPOINT 0x05 +#define AV_BOLDUPARROW 0x06 +#define AV_BOLDDOWNARROW 0x07 +#define AV_INTEGRAL 0x08 +#define AV_CROSS 0x09 +#define AV_SMALLCIRC 0x0A +#define AV_SMALLPLUS 0x0B +#define AV_SMALLDOT 0x0C +#define AV_BOTTOM 0x0D +#define AV_SS3 0x0E +#define AV_BOLDF 0x0F + +#define AV_SQRT 0x10 +#define AV_RECIP 0x11 +#define AV_SS2 0x12 +#define AV_ANGL 0x13 +#define AV_DEGREE 0x14 +#define AV_RAD 0x15 +#define AV_SBOTTOM 0x16 +#define AV_LEQ 0x17 +#define AV_NEQ 0x18 +#define AV_GEQ 0x19 +#define AV_MACRON 0x1A +#define AV_EXP 0x1B +#define AV_RIGHTARROW 0x1C +#define AV_SUB10 0x1D +#define AV_UPARROW 0x1E +#define AV_DOWNARROW 0x1F + +#define AV_SP 0x20 +#define AV_BANG 0x21 +#define AV_DQUOTE 0x22 +#define AV_HASH 0x23 +#define AV_SS4 0x24 +#define AV_PERCENT 0x25 +#define AV_AMP 0x26 +#define AV_SQUOTE 0x27 +#define AV_LPAREN 0x28 +#define AV_RPAREN 0x29 +#define AV_TIMES 0x2A +#define AV_PLUS 0x2B +#define AV_COMMA 0x2C +#define AV_MINUS 0x2D +#define AV_PERIOD 0x2E +#define AV_SLASH 0x2F + +#define AV_0 0x30 +#define AV_1 0x31 +#define AV_2 0x32 +#define AV_3 0x33 +#define AV_4 0x34 +#define AV_5 0x35 +#define AV_6 0x36 +#define AV_7 0x37 +#define AV_8 0x38 +#define AV_9 0x39 +#define AV_COLON 0x3A +#define AV_SEMI 0x3B +#define AV_LT 0x3C +#define AV_EQ 0x3D +#define AV_GT 0x3E +#define AV_QUERY 0x3F + +#define AV_AT 0x40 +#define AV_A 0x41 +#define AV_B 0x42 +#define AV_C 0x43 +#define AV_D 0x44 +#define AV_E 0x45 +#define AV_F 0x46 +#define AV_G 0x47 +#define AV_H 0x48 +#define AV_I 0x49 +#define AV_J 0x4A +#define AV_K 0x4B +#define AV_L 0x4C +#define AV_M 0x4D +#define AV_N 0x4E +#define AV_O 0x4F + +#define AV_P 0x50 +#define AV_Q 0x51 +#define AV_R 0x52 +#define AV_S 0x53 +#define AV_T 0x54 +#define AV_U 0x55 +#define AV_V 0x56 +#define AV_W 0x57 +#define AV_X 0x58 +#define AV_Y 0x59 +#define AV_Z 0x5A +#define AV_THETA 0x5B +#define AV_BSLASH 0x5C +#define AV_RBRACK 0x5D +#define AV_CARET 0x5E +#define AV_USCORE 0x5F + +#define AV_GRAVE 0x60 +#define AV_a 0x61 +#define AV_b 0x62 +#define AV_c 0x63 +#define AV_d 0x64 +#define AV_e 0x65 +#define AV_f 0x66 +#define AV_g 0x67 +#define AV_h 0x68 +#define AV_i 0x69 +#define AV_j 0x6A +#define AV_k 0x6B +#define AV_l 0x6C +#define AV_m 0x6D +#define AV_n 0x6E +#define AV_o 0x6F + +#define AV_p 0x70 +#define AV_q 0x71 +#define AV_r 0x72 +#define AV_s 0x73 +#define AV_t 0x74 +#define AV_u 0x75 +#define AV_v 0x76 +#define AV_w 0x77 +#define AV_x 0x78 +#define AV_y 0x79 +#define AV_z 0x7A +#define AV_LBRACE 0x7B +#define AV_PIPE 0x7C +#define AV_RBRACE 0x7D +#define AV_TILDE 0x7E +#define AV_INVEQ 0x7F + +#define AV_L0 0x80 +#define AV_L1 0x81 +#define AV_L2 0x82 +#define AV_L3 0x83 +#define AV_L4 0x84 +#define AV_L5 0x85 +#define AV_L6 0x86 +#define AV_L7 0x87 +#define AV_L8 0x88 +#define AV_L9 0x89 + +// Random special letter stuff... TODO... + +#define AV_M45 0xB6 +#define AV_M270 0xB7 +#define AV_DIAERESIS 0xB8 +#define AV_RQMARK 0xB9 +#define AV_RBANG 0xBA +#define AV_ALPHA 0xBB +#define AV_BETA 0xBC +#define AV_GAMMA 0xBD +#define AV_UP_DELTA 0xBE +#define AV_DELTA 0xBF + +#define AV_EPSILON 0xC0 +#define AV_LBRACK 0xC1 +#define AV_LAMBDA 0xC2 +#define AV_MU 0xC3 +#define AV_PI 0xC4 +#define AV_RHO 0xC5 +#define AV_UP_SIGMA 0xC6 +#define AV_SIGMA 0xC7 +#define AV_TAU 0xC8 +#define AV_UP_PHI 0xC9 +#define AV_UP_OMEGA 0xCA +#define AV_X_OBAR 0xCB +#define AV_PHI 0xCC +#define AV_SSCROSS 0xCD +#define AV_DOTS 0xCE +#define AV_LPOINT 0xCF + +#define AV_SEMISLASH 0xD1 +#define AV_SMALLMINUS 0xD2 +#define AV_SQUARED 0xD3 +#define AV_SQDEG 0xD4 +#define AV_CUBED 0xD5 +#define AV_BOLD_COLON 0xD6 +#define AV_IMAG 0xD7 +#define AV_RHO_CAP 0xD8 +#define AV_CHI 0xD9 +#define AV_UP_F 0xDA +#define AV_EUL 0xDB +#define AV_SUBL 0xDC +#define AV_BOLD_N 0xDD +#define AV_DOUBLE_RPAR 0xDE +#define AV_SMALL_RIGHTARROW 0xDF + +#define AV_RECT 0xE0 +#define AV_INV_UPARROW 0xE1 +#define AV_INV_A 0xE2 +#define AV_INV_a 0xE3 +#define AV_UBAR 0xE4 +#define AV_UPARROW_UBAR 0xE5 +#define AV_A_UBAR 0xE6 +#define AV_a_UBAR 0xE7 +#define AV_CENTR_DIAG 0xE8 +#define AV_BOLD_CENTR_DIAG 0xE9 +#define AV_UTRI 0xEA +#define AV_LTRI 0xEB +#define AV_0_LTACK 0xEC +#define AV_SMALL0 0xED +#define AV_DIAGDOTS 0xEE +#define AV_BOLD_LONG_UPARROW 0xEF + +#define AV_BOLD_LONG_DOWNARROW 0xF0 +#define AV_DOTSBLOCK 0xF1 + + +#endif + diff --git a/lib83/ctype.c b/lib83/ctype.c index 905ba6e..db4fe4a 100644 --- a/lib83/ctype.c +++ b/lib83/ctype.c @@ -13,61 +13,58 @@ // TODO. static unsigned char tab[256] = { - GRAPH, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, GRAPH, GRAPH, GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL, + GRAPH, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, LOWER|SPECL|ALPHA, GRAPH, GRAPH, GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, ALPHA|UPPER|SPECL, GRAPH|SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, SPECL, GRAPH|SPECL, GRAPH|SPECL, SPACE, PUNCT|SPECL, PUNCT|SPECL, SPECL|GRAPH, SPECL, SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, SPECL|GRAPH, + DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, DIGIT, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, PUNCT|SPECL|GRAPH, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, - UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, UPPER|ALPHA, SPECL|GRAPH|ALPHA, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, PUNCT|SPECL|GRAPH, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, - LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, - NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE, NONE + LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, LOWER|ALPHA, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH, + DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, DIGIT|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, + ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, + ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, + ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, + ALPHA|LOWER, SPECL|GRAPH|PUNCT, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|LOWER, ALPHA|UPPER, ALPHA|SPECL, ALPHA|SPECL, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, SPECL|GRAPH|PUNCT, + GRAPH, GRAPH|SPECL, GRAPH|SPECL, DIGIT|LOWER|SPECL, SPECL|GRAPH, DIGIT|LOWER|SPECL, GRAPH|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER|SPECL, ALPHA|UPPER|SPECL, ALPHA|LOWER|SPECL, ALPHA|LOWER, ALPHA|UPPER|SPECL, GRAPH|SPECL, GRAPH|SPECL, + GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, GRAPH|SPECL, + GRAPH|SPECL, GRAPH|SPECL, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH, GRAPH }; -int isalnum(int c) { - return tab[c & 0xFF] & (ALPHA | DIGIT); +unsigned char isalnum(unsigned char c) { + return tab[c] & (ALPHA | DIGIT); } -int isalpha(int c) { - return tab[c & 0xFF] & ALPHA; +unsigned char isalpha(unsigned char c) { + return tab[c] & ALPHA; } -int islower(int c) { - return tab[c & 0xFF] & LOWER; +unsigned char islower(unsigned char c) { + return tab[c] & LOWER; } -int isupper(int c) { - return tab[c & 0xFF] & UPPER; +unsigned char isupper(unsigned char c) { + return tab[c] & UPPER; } -int isdigit(int c) { - return tab[c & 0xFF] & DIGIT; +unsigned char isdigit(unsigned char c) { + return tab[c] & DIGIT; } -int isspecl(int c) { - return tab[c & 0xFF] & SPECL; +unsigned char isspecl(unsigned char c) { + return tab[c] & SPECL; } -int isspace(int c) { - return tab[c & 0xFF] & SPACE; +unsigned char isspace(unsigned char c) { + return tab[c] & SPACE; } -int ispunct(int c) { - return tab[c & 0xFF] & PUNCT; +unsigned char ispunct(unsigned char c) { + return tab[c] & PUNCT; } -int isgraph(int c) { - return tab[c & 0xFF] & GRAPH; +unsigned char isgraph(unsigned char c) { + return tab[c] & GRAPH; } diff --git a/lib83/ctype.h b/lib83/ctype.h index e69de29..d9c3345 100644 --- a/lib83/ctype.h +++ b/lib83/ctype.h @@ -0,0 +1,16 @@ + +#ifndef _CTYPE_H +#define _CTYPE_H + +unsigned char isalnum(unsigned char c); +unsigned char isalpha(unsigned char c); +unsigned char islower(unsigned char c); +unsigned char isupper(unsigned char c); +unsigned char isdigit(unsigned char c); +unsigned char isspecl(unsigned char c); +unsigned char isspace(unsigned char c); +unsigned char ispunct(unsigned char c); +unsigned char isgraph(unsigned char c); + +#endif +