From 18058c14f1b26313f56f38d775928962a559b75a Mon Sep 17 00:00:00 2001 From: neauoire Date: Tue, 5 Apr 2022 19:13:14 -0700 Subject: [PATCH] Fixed issue with uxncli --- build.sh | 9 ++- etc/drifblim.rom | Bin 0 -> 1420 bytes etc/polycat.tal | 146 +++++++++++++++++++++++++++++++++++++++++++++++ src/uxn11.c | 2 +- src/uxncli.c | 52 ++++++----------- 5 files changed, 169 insertions(+), 40 deletions(-) create mode 100644 etc/drifblim.rom create mode 100644 etc/polycat.tal diff --git a/build.sh b/build.sh index 9879d3f..7585659 100755 --- a/build.sh +++ b/build.sh @@ -26,7 +26,10 @@ else gcc -std=c89 -D_POSIX_C_SOURCE=199309L -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/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli fi -echo "Done." +echo "Assembling polycat.." +bin/uxncli etc/drifblim.rom etc/polycat.tal && mv etc/polycat.rom bin/ -# echo "Running.." -bin/uxn11 ~/roms/left.rom README.md +echo "Running.." +bin/uxn11 bin/polycat.rom + +echo "Done." \ No newline at end of file diff --git a/etc/drifblim.rom b/etc/drifblim.rom new file mode 100644 index 0000000000000000000000000000000000000000..3b992bbceef225ac7b4e93b4b66a8ea68ce385db GIT binary patch literal 1420 zcmY*ZOKcle6n*0v4|d`irz9qBX^3Z>xGqY^Zk0Ap0-;VPB@RjK+D?j6kmAsMps$)J z1u00CdX`m{1&fgo6-X~#MO8&MAQrHQ#Fj-=g(?!8W`RVJz^q`wBHU*aQ5K&2d2jAL z_nbQx$_r>4V1ls>UVKSKqE*M8mM(M{brGyOg1zx7LejtH#1>efE|gJ61fq^70^d18 ziFPt<4G5;-;eb%ecr*ZpkckHuy70Tfk-n>;$H3{P*>6M4K;oW;R}8@}CXp}&%Zi}u z1UMAzA0xvWhE5wTxdhP##o$8U5c;A|2OVLw8k_y(S-p;JbIYWU1YL17uU{-}VUCcxKoO;_#3!5GAuIiB2$e zPz1S?Bq{JDD-<>;vsjB=X4xzY4oc05j6lkg3=w911%#r0gQMio+FXoiJv z&156@zcC&YLIe?vKtMBtU?$N?V7BSiI^p;5t-X8TQ&R=X%Hd_RiSm0LG+}Ga0^bI zh$9=P)uq3MA0*y3QzU4q!)9Z7&zwonQ1MP`NiFzfp<0-}R4SI-nbLHjRJmFz&X&u? z>e!W;>9H$sR>vo+;}cV*iA&QHm2!nbcdk;Mn{>%9PrCU^HSdlU+_7Tbbt^NYQ!|rp zVKzVQ7R&juV!3j;I$C~fWpSPH_djIUKU!r=wKcZ3xWsNOe$3Xqn=F6p*5b_tzIZ*s qZmV~D)K4y|pQqFZj=I&SZVjtn52@duQg?0j$7|}ryXrwwjs64dPs2$7 literal 0 HcmV?d00001 diff --git a/etc/polycat.tal b/etc/polycat.tal new file mode 100644 index 0000000..354ed12 --- /dev/null +++ b/etc/polycat.tal @@ -0,0 +1,146 @@ +( Polycat: + A cat with one eye, and the hind and tail of a lizard. + Original character by Rekka Bellum ) + +|00 @System &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 &debug $1 &halt $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixeld $1 &sprite $1 +|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &pad $3 &scrollx $2 &scrolly $2 + +|0000 + +@cat &x $2 &y $2 &timer $1 +@pointer &x $2 &y $2 + +|0100 ( -> ) + + ( theme ) + #0a3f .System/r DEO2 + #05df .System/g DEO2 + #0caf .System/b DEO2 + ( DOS resolution ) + #0140 .Screen/width DEO2 + #00c8 .Screen/height DEO2 + ( vectors ) + ;on-mouse .Mouse/vector DEO2 + ( find center ) + .Screen/width DEI2 #01 SFT2 .cat/x STZ2 + .Screen/height DEI2 #01 SFT2 .cat/y STZ2 + ( draw ground ) + #f6 .Screen/auto DEO + .cat/y LDZ2 #0018 ADD2 .Screen/y DEO2 + .cat/x LDZ2 #0010 SUB2 .Screen/x DEO2 + ;ground .Screen/addr DEO2 + #01 .Screen/sprite DEO + ( init ) + #ff ;draw-eye/last STA + #ff ;draw-tail/last STA + ( set screen mode auto-x ) + #05 .Screen/auto DEO + ,draw-polycat JSR + +BRK + +@draw-polycat ( -- ) + + ( ears ) + .cat/y LDZ2 .Screen/y DEO2 + .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2 + ;ears .Screen/addr DEO2 + #81 .Screen/sprite DEOk DEO + ( body ) + .cat/y LDZ2 #0010 ADD2 .Screen/y DEO2 + .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2 + ;body .Screen/addr DEO2 + #81 .Screen/sprite DEO + ( eye/tail ) + #00 ,draw-eye JSR + #00 ,draw-tail JSR + +JMP2r + +@on-mouse ( -> ) + + .Mouse/x DEI2 .cat/x LDZ2 GTH2 #50 SFT + .Mouse/y DEI2 .cat/y LDZ2 GTH2 #60 SFT + ADD ,draw-eye JSR + .cat/timer LDZ INC [ DUP ] .cat/timer STZ + #04 SFT ,draw-tail JSR + ,draw-cursor JSR + +BRK + +@draw-eye ( quad -- ) + + DUP ,&last LDR NEQ ,&changed JCN + POP JMP2r &changed + ( only redraw on change ) + DUP + #00 SWP ;eye ADD2 .Screen/addr DEO2 + .cat/y LDZ2 #0008 ADD2 .Screen/y DEO2 + .cat/x LDZ2 #0008 SUB2 .Screen/x DEO2 + #81 .Screen/sprite DEOk DEO + ,&last STR + +JMP2r + &last $1 + +@draw-tail ( frame -- ) + + STHk ,&last LDR NEQ ,&changed JCN + POPr JMP2r &changed + ( only redraw on change ) + STHr #00 OVR ;frames ADD2 LDA + #00 SWP #40 SFT2 ;body/tail ADD2 + .Screen/addr DEO2 + .cat/x LDZ2 .Screen/x DEO2 + .cat/y LDZ2 #0010 ADD2 .Screen/y DEO2 + #81 .Screen/sprite DEO + ,&last STR + +JMP2r + &last $1 + +@draw-cursor ( -- ) + + ( last cursor ) + ;cursor STH2k .Screen/addr DEO2 + .pointer/x LDZ2 .Screen/x DEO2 + .pointer/y LDZ2 .Screen/y DEO2 + #40 .Screen/sprite DEO + ( new cursor ) + STH2r .Screen/addr DEO2 + .Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 + .Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2 + #41 .Mouse/state DEI #00 NEQ ADD .Screen/sprite DEO + +JMP2r + +@cursor + 80c0 e0f0 f8e0 1000 +@frames + 00 01 02 03 02 01 00 00 + 00 00 00 00 00 00 00 00 +@ears + 081c 3e3e 7f7f ffff 081c 3e3e 7f7f fffc + 081c 3c3e 7e7e ffff 081c 3c3e 7e7e ff1f +@eye + ffff ffff ff7f 3f0f f7ef cfe7 f07c 3f0f + ffff ffff fffe fcf0 87c3 c183 071e fcf0 + ffff ffff ff7f 3f0f f0e1 c1e0 f07c 3f0f + ffff ffff fffe fcf0 f7fb f9f3 071e fcf0 + ffff ffff ff7f 3f0f f0e7 cfef f77c 3f0f + ffff ffff fffe fcf0 0783 c1c3 871e fcf0 + ffff ffff ff7f 3f0f f0e0 c1e1 f07c 3f0f + ffff ffff fffe fcf0 07f3 f9fb f71e fcf0 +@body + 0707 0707 0302 0200 0107 0707 0300 0000 + &tail + e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000 + e0f0 f0e0 e080 8000 c0f2 f9f9 fef8 b000 + e0f0 f0e0 e080 8000 c0f2 faf9 fef8 b000 + e0f0 f0e0 e080 8000 c0f1 faf9 fef8 b000 + 0707 0707 0f08 1000 0307 0707 0f00 0000 + e0e0 e0e0 e080 8000 f2f9 f9fe b884 8400 +@ground + bf00 5c02 0202 020c ef10 6f90 8080 8074 + ff00 fe01 0100 0116 fd00 3c40 4040 4028 diff --git a/src/uxn11.c b/src/uxn11.c index 9d7ba96..4123405 100644 --- a/src/uxn11.c +++ b/src/uxn11.c @@ -138,7 +138,7 @@ processEvent(Uxn *u) char buf[7]; XLookupString((XKeyPressedEvent *)&ev, buf, 7, &sym, 0); controller_down(u, &u->dev[0x80], get_button(sym)); - controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : buf[0]); + controller_key(u, &u->dev[0x80], sym < 0x80 ? sym : (Uint8)buf[0]); } break; case KeyRelease: { KeySym sym; diff --git a/src/uxncli.c b/src/uxncli.c index 07bc5a2..64af552 100644 --- a/src/uxncli.c +++ b/src/uxncli.c @@ -18,7 +18,7 @@ WITH REGARD TO THIS SOFTWARE. */ static int -error(char *msg, const char *err) +emu_error(char *msg, const char *err) { fprintf(stderr, "Error %s: %s\n", msg, err); return 0; @@ -44,7 +44,7 @@ console_deo(Uint8 *d, Uint8 port) } static Uint8 -uxn11_dei(struct Uxn *u, Uint8 addr) +emu_dei(struct Uxn *u, Uint8 addr) { Uint8 p = addr & 0x0f, d = addr & 0xf0; switch(d) { @@ -56,7 +56,7 @@ uxn11_dei(struct Uxn *u, Uint8 addr) } static void -uxn11_deo(Uxn *u, Uint8 addr, Uint8 v) +emu_deo(Uxn *u, Uint8 addr, Uint8 v) { Uint8 p = addr & 0x0f, d = addr & 0xf0; u->dev[addr] = v; @@ -68,51 +68,31 @@ uxn11_deo(Uxn *u, Uint8 addr, Uint8 v) } } -static void -run(Uxn *u) -{ - while(!u->dev[0x0f]) { - int c = fgetc(stdin); - if(c != EOF) - console_input(u, (Uint8)c); - } -} - -int -uxn_interrupt(void) -{ - return 1; -} - -static int -start(Uxn *u) -{ - if(!uxn_boot(u, (Uint8 *)calloc(0x10200, sizeof(Uint8)))) - return error("Boot", "Failed"); - u->dei = uxn11_dei; - u->deo = uxn11_deo; - return 1; -} - int main(int argc, char **argv) { Uxn u; int i; if(argc < 2) - return error("Usage", "uxncli game.rom args"); - if(!start(&u)) - return error("Start", "Failed"); + return emu_error("Usage", "uxncli game.rom args"); + if(!uxn_boot(&u, (Uint8 *)calloc(0x10300, sizeof(Uint8)))) + return emu_error("Boot", "Failed"); + u.dei = emu_dei; + u.deo = emu_deo; if(!load_rom(&u, argv[1])) - return error("Load", "Failed"); - fprintf(stderr, ">> Loaded %s\n", argv[1]); + return emu_error("Load", "Failed"); + fprintf(stderr, "Loaded %s\n", argv[1]); if(!uxn_eval(&u, PAGE_PROGRAM)) - return error("Init", "Failed"); + return emu_error("Init", "Failed"); for(i = 2; i < argc; i++) { char *p = argv[i]; while(*p) console_input(&u, *p++); console_input(&u, '\n'); } - run(&u); + while(!u.dev[0x0f]) { + int c = fgetc(stdin); + if(c != EOF) + console_input(&u, (Uint8)c); + } return 0; }