From 11bfceb3274b080394eb54adaa2b00479c24d9a1 Mon Sep 17 00:00:00 2001 From: Derek Stevens Date: Fri, 27 Aug 2021 22:34:12 -0600 Subject: [PATCH] add cursor, font drawing, custom font --- uxn-client/mkfont.sh | 15 ++++++++++ uxn-client/xrxs.tal | 68 ++++++++++++++++++++++++++++++++++++++++--- uxn-client/zz.chr | Bin 0 -> 768 bytes 3 files changed, 79 insertions(+), 4 deletions(-) create mode 100755 uxn-client/mkfont.sh create mode 100644 uxn-client/zz.chr diff --git a/uxn-client/mkfont.sh b/uxn-client/mkfont.sh new file mode 100755 index 0000000..374d87b --- /dev/null +++ b/uxn-client/mkfont.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +rm $2 + +offset=0; +keep=1; +while [ ${offset} -lt 1536 ]; do + if [ ${keep} -eq 1 ]; then + head -c $((offset + 8)) $1 | tail -c 8 >> $2 + keep=0 + else + keep=1 + fi + offset=$((offset + 8)) +done diff --git a/uxn-client/xrxs.tal b/uxn-client/xrxs.tal index 47a2d1f..8db5f7c 100644 --- a/uxn-client/xrxs.tal +++ b/uxn-client/xrxs.tal @@ -9,6 +9,11 @@ %MOD { DIVk MUL SUB } %MOD2 { DIV2k MUL2 SUB2 } +%2** { #10 SFT2 } %2// { #01 SFT2 } +%8** { #30 SFT2 } %8// { #03 SFT2 } +%TOS { #00 SWP } %TOB { SWP POP } + + %NEXT-TILE { DUP2 #0010 ADD2 } %RTN { JMP2r } @@ -62,6 +67,11 @@ #0200 .File/offset DEO2 ;xrxslogo .File/load DEO2 + ;fontsheet .File/name DEO2 + #0000 .File/offset DEO2 + #0300 .File/length DEO2 + ;font .File/load DEO2 + #00 .ticker STZ #00 .state STZ #20 .anim-speed STZ @@ -74,6 +84,7 @@ BRK @on-frame ( -> ) + .ticker LDZ #01 ADD DUP .anim-speed LDZ EQU ,&next-render JCN @@ -129,6 +140,11 @@ BRK ;draw-uxn-logo JSR2 ;draw-xrxs-logo-xr JSR2 ;draw-xrxs-logo-xs JSR2 + [ ;title-loadCart + CENTER-X OVR2 ;strlen JSR2 #20 SFT2 SUB2 + #0010 + #02 ] ;draw-string JSR2 + ;draw-pointer JSR2 POP BRK &state5 POP @@ -259,7 +275,7 @@ RTN #0008 ,&x STR2 &whileld - ,&y LDR2 CENTER-Y SUB2 #0010 DIV2 DUP2 ADD2 #0008 ADD2 ,&x STR2 + ,&y LDR2 CENTER-Y SUB2 #04 SFT2 DUP2 ADD2 #0008 ADD2 ,&x STR2 .Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endld JCN &dlscan #0040 ,&x LDR2 EQU2 ,&enddlscan JCN ,&x LDR2 .Screen/x DEO2 @@ -276,7 +292,7 @@ RTN #0008 ,&x STR2 &whilelu - CENTER-Y ,&y LDR2 SUB2 #0010 DIV2 DUP2 ADD2 #0008 ADD2 ,&x STR2 + CENTER-Y ,&y LDR2 SUB2 #04 SFT2 DUP2 ADD2 #0008 ADD2 ,&x STR2 CENTER-Y ,&y LDR2 LTH2 ,&endlu JCN &ulscan #0040 ,&x LDR2 EQU2 ,&endulscan JCN ,&x LDR2 .Screen/x DEO2 @@ -296,7 +312,7 @@ RTN &whilerd .Screen/width DEI2 #0040 SUB2 ,&x STR2 .Screen/height DEI2 #0028 SUB2 ,&y LDR2 LTH2 ,&endrd JCN - &drscan .Screen/width DEI2 #0008 SUB2 ,&y LDR2 CENTER-Y SUB2 #0010 DIV2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&enddrscan JCN + &drscan .Screen/width DEI2 #0008 SUB2 ,&y LDR2 CENTER-Y SUB2 #04 SFT2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&enddrscan JCN ,&x LDR2 .Screen/x DEO2 ,&y LDR2 .Screen/y DEO2 #03 .Screen/pixel DEO @@ -313,7 +329,7 @@ RTN &whileru .Screen/width DEI2 #0040 SUB2 ,&x STR2 CENTER-Y ,&y LDR2 LTH2 ,&endru JCN - &urscan .Screen/width DEI2 #0008 SUB2 CENTER-Y ,&y LDR2 SUB2 #0010 DIV2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&endurscan JCN + &urscan .Screen/width DEI2 #0008 SUB2 CENTER-Y ,&y LDR2 SUB2 #04 SFT2 DUP2 ADD2 SUB2 ,&x LDR2 EQU2 ,&endurscan JCN ,&x LDR2 .Screen/x DEO2 ,&y LDR2 .Screen/y DEO2 #03 .Screen/pixel DEO @@ -325,10 +341,54 @@ RTN &y $2 +@draw-pointer ( -> ) + + ;pointer_icn .Screen/addr DEO2 + + .Mouse/x DEI2 .Screen/x DEO2 + .Mouse/y DEI2 .Screen/y DEO2 + + #4a .Screen/sprite DEO + +RTN + +@draw-string ( addr x y color -- ) + + STH ( save color ) + .Screen/y DEO2 ( set y ) + .Screen/x DEO2 ( set x ) + + ( now the string address is at the top of the stack ) + &loop + LDAk DUP #00 NEQ #20 MUL SUB TOS 8** ;font ADD2 .Screen/addr DEO2 + STHkr .Screen/sprite DEO + .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2 + #0001 ADD2 + LDAk #00 NEQ ,&loop JCN + POP2 + POPr + +RTN + +@strlen ( addr -- len ) + + DUP2 + &loop + #0001 ADD2 LDAk ,&loop JCN + SWP2 SUB2 + +RTN + ( constants ) @spritesheet "xrxs.chr 00 +@fontsheet "zz.chr 00 +@cartlist "n/carts 00 +@title-loadCart "Select 20 "A 20 "Cartridge 00 ( sprites ) @blank $16 @uxnlogo $128 @xrxslogo $128 +@pointer_icn [ 80c0 e0f0 f8e0 1000 ] +@font $768 + diff --git a/uxn-client/zz.chr b/uxn-client/zz.chr new file mode 100644 index 0000000000000000000000000000000000000000..b3bc941ef70b6cc5706c4bc6bdd2c04c490d4cc8 GIT binary patch literal 768 zcmYk4FHgik5XC2CLspzvabiO*q~b&cqCu@#$cC(_s6bR85D4T61fpWY_dxPZ`MoWI zxofBIb^g4WuGyc(7`=J3<8dd>UuXViAwQ?%7R;&-Lp6)T{oVNnABG<2Jm$=XfQhPO z7>TnGS|Ck!@crR&N8p3mm7`uUOLbjqGMki-Pt~Q;M_8 z)G_z$;A8xENf2!U`DTy&u;9s5-YHo3uP-G-kF`~FZ|TJ1b6U(!ro3bK=)F%Kx1=eShLvKtDgXv;}btWqRVA>b>1B-15`+&(HT${smS^ BZRP*~ literal 0 HcmV?d00001