From bd6dbbbec408dc007798ab81680bba8696cf0f9e Mon Sep 17 00:00:00 2001 From: pickle Date: Fri, 13 Oct 2023 13:25:55 -0400 Subject: [PATCH] Working zcc build scripts --- build.sh | 32 ---- build_app.sh | 28 +-- build_prog.sh | 16 +- build_prog_zcc.sh | 2 + examples/zcc_helloworld/.buildid | 1 + examples/zcc_helloworld/main.c | 59 +++++++ examples/zcc_helloworld/tix.8xk | Bin 0 -> 1697 bytes examples/zcc_helloworld/tix.bin | Bin 0 -> 563 bytes hello.c | 31 +--- other_files/ti83p_crt0.asm | 283 +++++++++++++++++++++++++++++++ other_files/ti83p_crt0_app.asm | 247 +++++++++++++++++++++++++++ other_files/ti83papp.asm | 281 ++++++++++++++++++++++++++++++ x/hello.8xp | Bin 0 -> 508 bytes x/hello.bin | Bin 0 -> 401 bytes x/v.8xp | Bin 470 -> 0 bytes x/v.bin | Bin 396 -> 0 bytes x/x.8xp | Bin 472 -> 0 bytes x/x.bin | Bin 396 -> 0 bytes z88dk.Dockerfile | 36 ++++ 19 files changed, 940 insertions(+), 76 deletions(-) delete mode 100644 build.sh create mode 100644 build_prog_zcc.sh create mode 100644 examples/zcc_helloworld/.buildid create mode 100644 examples/zcc_helloworld/main.c create mode 100644 examples/zcc_helloworld/tix.8xk create mode 100644 examples/zcc_helloworld/tix.bin create mode 100644 other_files/ti83p_crt0.asm create mode 100644 other_files/ti83p_crt0_app.asm create mode 100644 other_files/ti83papp.asm create mode 100644 x/hello.8xp create mode 100644 x/hello.bin delete mode 100644 x/v.8xp delete mode 100644 x/v.bin delete mode 100644 x/x.8xp delete mode 100644 x/x.bin create mode 100644 z88dk.Dockerfile diff --git a/build.sh b/build.sh deleted file mode 100644 index b3b5c00..0000000 --- a/build.sh +++ /dev/null @@ -1,32 +0,0 @@ -DIRECTORY=$(cd `dirname $0` && pwd) - - - -export MAINC="hello.c" -export OUT_NAME="helloworld" - - -# sdasz80 -p -g -o tios_crt0.rel $DIRECTORY/other_files/tios_crt0.s - - -# sdcc -DRAM_PROG --no-std-crt0 --code-loc 40347 --data-loc 0 --std-sdcc99 -mz80 --reserve-regs-iy -o $OUT_NAME.ihx tios_crt0.rel $MAINC - -# /opt/z88dk/lib/target/ti83p/classic/ti83p_crt0.asm -# docker run -v ${DIRECTORY}:/src/ z88dk/z88dk zcc +ti83p -subtype=asm -Cz--altfmt -lm -o x/hello.bin hello.c - -docker run -v ${DIRECTORY}:/src/ z88dk/z88dk zcc +ti83p -lm -o x/v.bin hello.c -create-app - -# sleep 1 - -cd x -cp v.bin x.bin -python $DIRECTORY/other_files/binpac8x.py x.bin -O ad -# docker run -v ${DIRECTORY}:/src/ z88dk/z88dk zcc +ti83p -crt0 other_files/tios_crt0.s -lm -o x/hello.bin hello.c -# zcc +ti83p -startup=10 -Cz--altfmt -lm -o x/adv_a -create-app hello.c - -# python $DIRECTORY/other_files/binpac8x.py $DIRECTORY/x/hello.bin -O wee - - -# docker run -v ${DIRECTORY}:/src/ z88dk/z88dk z88dk-dis x/hello.bin - -# +z80 -vn -mz80 --reserve-regs-iy --no-cleanup -o examples/helloworld examples/helloworld/main.c \ No newline at end of file diff --git a/build_app.sh b/build_app.sh index de9dab2..2df85f2 100644 --- a/build_app.sh +++ b/build_app.sh @@ -13,23 +13,29 @@ echo $BC export MAINC="main.c" export OUT_NAME=$2 -trunkName=$(printf '%-8s' "$(head -c 8 <<<$2)") # truncate name and pad with extra spaces to make sure it is 8 char long +trunkName=$(head -c 8 <<<$2) # truncate name to make sure it is no more than 8 char long -crt="$DIRECTORY/other_files/tios_crt0_app.s" # just got path to crt0 +# Compile with custom crt0 +docker run -v ${DIRECTORY}:/src/ z88dk/z88dk zcc +ti83p -subtype=asm -o $1/$OUT_NAME.bin $1/$MAINC -crt0 other_files/ti83p_crt0_app.asm -sed "s/qwertyui/$trunkName/" $crt > TEMP_crt0.s # fill in name in crt0 -sed "s/0x6969/$BC/" TEMP_crt0.s > TEMP_crt0.s.s +# Now we need to rebuild the .bin with our custom name -sdasz80 -p -g -o tios_crt0.rel TEMP_crt0.s.s -sdcc -DFLASH_APP --no-std-crt0 --code-loc 16429 --data-loc 0 --std-sdcc99 -mz80 --reserve-regs-iy -o $OUT_NAME.ihx tios_crt0.rel $MAINC +nameLn=${#trunkName} #length of trunkName +cat $OUT_NAME.bin | head -c 18 > x.bin # Write bytes before name in header +echo -n $trunkName >> x.bin # Write your name -objcopy -Iihex -Obinary $OUT_NAME.ihx $OUT_NAME.bin - - -rm $OUT_NAME.ihx $OUT_NAME.lk $OUT_NAME.lst $OUT_NAME.map $OUT_NAME.noi $OUT_NAME.rel $OUT_NAME.sym tios_crt0.rel TEMP_crt0.s TEMP_crt0.s.s +# Pad name (if needed) +while [ $nameLn -lt 8 ] +do + echo -n " " >> x.bin + ((nameLn++)) +done +# Write rest of app +cat $OUT_NAME.bin | tail -c+27 >> x.bin +mv x.bin $OUT_NAME.bin $DIRECTORY/other_files/rabbitsign -t 8xk -g -f $OUT_NAME.bin -rm $OUT_NAME.bin \ No newline at end of file +# rm $OUT_NAME.bin \ No newline at end of file diff --git a/build_prog.sh b/build_prog.sh index e371f73..d3b561f 100644 --- a/build_prog.sh +++ b/build_prog.sh @@ -1,19 +1,15 @@ DIRECTORY=$(cd `dirname $0` && pwd) -cd x -export MAINC="../hello.c" -export OUT_NAME="testtex" +export MAINC="main.c" +export OUT_NAME=$2 -sdasz80 -p -g -o tios_crt0.rel $DIRECTORY/other_files/tios_crt0.s +docker run -v ${DIRECTORY}:/src/ z88dk/z88dk zcc +ti83p -subtype=asm -o $1/$OUT_NAME.bin $1/$MAINC +cat <( echo -ne "\xbb\x6d" ) $1/$OUT_NAME.bin > $1/$OUT_NAME.bin2 -sdcc -DSDCC --no-std-crt0 --code-loc 40347 --data-loc 0 --std-sdcc99 -mz80 --reserve-regs-iy -o $OUT_NAME.ihx tios_crt0.rel $MAINC +cd $1 +python $DIRECTORY/other_files/binpac8x.py $OUT_NAME.bin2 -O $OUT_NAME -objcopy -Iihex -Obinary $OUT_NAME.ihx $OUT_NAME.bin -python $DIRECTORY/other_files/binpac8x.py $OUT_NAME.bin -O $OUT_NAME - -rm $OUT_NAME.bin $OUT_NAME.ihx $OUT_NAME.lk $OUT_NAME.lst $OUT_NAME.map $OUT_NAME.noi $OUT_NAME.rel $OUT_NAME.sym tios_crt0.rel -# rm $OUT_NAME.asm diff --git a/build_prog_zcc.sh b/build_prog_zcc.sh new file mode 100644 index 0000000..9612a50 --- /dev/null +++ b/build_prog_zcc.sh @@ -0,0 +1,2 @@ +# sh build_prog.sh examples/zcc_helloworld hllo +sh build_app.sh examples/zcc_helloworld tix \ No newline at end of file diff --git a/examples/zcc_helloworld/.buildid b/examples/zcc_helloworld/.buildid new file mode 100644 index 0000000..d0dc1e1 --- /dev/null +++ b/examples/zcc_helloworld/.buildid @@ -0,0 +1 @@ +0x82e3 diff --git a/examples/zcc_helloworld/main.c b/examples/zcc_helloworld/main.c new file mode 100644 index 0000000..d9275d6 --- /dev/null +++ b/examples/zcc_helloworld/main.c @@ -0,0 +1,59 @@ +#ifdef SDCC +#define bcall(__LABEL__) rst 40 \ + .dw __LABEL__ +// A bit of trash data so the program runs correctly +void _(){__asm ret + .ascii "0000000000" __endasm;} + +#else +#pragma string name teext +#define bcall(__LABEL__) rst 40 \ defw __LABEL__ + +// A bit of trash data so the program runs correctly +void _(){ + #asm + ret + defm "0000000000" + #endasm +} +#endif + + + + +void main() +{ + + #ifdef SDCC + __asm + #else + #asm + #endif + bcall(0x4540 ) ; _ClrLCDFull + + xor a, a + ld (0x86D7), a + ld (0x86D8), a + + #ifdef SDCC + ld a, #'!' + #else + ld a, '!' + #endif + + push ix + bcall(0x455E) ; _VPutMap + pop ix + + + bcall(0x4972 ) ; _getkey + + #ifdef SDCC + __endasm; + #else + #endasm + #endif + + + +} \ No newline at end of file diff --git a/examples/zcc_helloworld/tix.8xk b/examples/zcc_helloworld/tix.8xk new file mode 100644 index 0000000000000000000000000000000000000000..b1cc1c9e7aa40cbd70c3e0812529de6b87fe6ec2 GIT binary patch literal 1697 zcmbtU&B`S;5dCH&A_#&nFrce%Rewn;vr8%|5ZsL~;aV3yf{*P<-@YG;gN#fyr2AIV zr>o96bzfh9`6+*XeSP=t-Jjom|Ne)sfB*H5_a|OH9l!nf>HN#f$FE*qK9JCfYt8uf zn-4;EWt=DFUiJkOX&70NUT=4eea`J1Z6RDIN>_AJU4qU6r6Tm{tXmFjq zXDxk3ZCSkZpk9M=8Yz;UR7GL~Y|{;PY7^QjktVC@G-+XjniQLTj}|%ykh8Yt+Q!~I zmYG=8>64Xn&S*DS1z1;~8QeKEcG%jb6{q%S{p$a}7ttFGZP7+W*$ph^$kd)amW1)i zE17`3z^M|eRb-JbHCIgPv+DNw#@V>QtbueQuC4Y{maf+Jnt-3+51Ay^>*S=7D!zQM zD`nB)t31`jC&@?5mQYD{!A?munhSN3cj5D5%-pM!Ckjs`UvK%jbJZsp)S%753*{%+ zjGlZB2ea>rhIXuy#!v9mBJ6^|*;R0tCidX$N*hJrJr(`a!bxG(4mRM!6qQL8ngg8x zdG;X{6ZqkdU1ha#gB_oN9%bgq1OxQk5->}NK2kV_;q3~Ym}440xCDkAVFEH~rMpc& zK4TSL&`B#7;Z4scgJ}drnnXXB(!VeClyO^wkI!KKax_}aD^|z40S_5=mTd)3yc5&_ z5H>+G+S|@e=m5i4_p`F&GxC6k0<|4tvSU6la29S@ryE4sG{iySrUd~0+lgVb-LuKZ zXMPSfaS$JGufstH4m&UnC4K?+I(I&PefkM0^%mgrnI+mFGmyR$9N~Tn{@l=ggB_oJ zY0P|p9cO%T^t&?oA7~<&)4DLS#?X6v(K2D3biXS*KFc9()Ivoj_kf~fv^`37gNMfO zN>XOqtQ`qpaVz1w$SCP^EYe#5{K-NbZN>W5$=t`%h1p&*WoryLi)t-lwV75SAdz6) W{}Iwr8Kw&6L1mv6mu5G=ocR|>$XXcy literal 0 HcmV?d00001 diff --git a/examples/zcc_helloworld/tix.bin b/examples/zcc_helloworld/tix.bin new file mode 100644 index 0000000000000000000000000000000000000000..bbd0e09ebc6234f07cabef3cc94a4eb90f69b381 GIT binary patch literal 563 zcmZqRX8?i*Ax4%4MaBk0#s-g)%nAh%XlP_?n82*Y$-^5&{{QdgXOvb%-lcTevABPnC^ z#`kGyLp{hQbnv$Lr-S0J|CT?`>NvhFHgHnpVR(AB%<2$(Nt)8ZHYc8c(xR@K@Gm zbKntV{CinIQjm*5QdwEJ?y{h?z_-eOItouuu2($e$e6((c-j%@79%4k#WRj(!iv`% z%|sO+fCz`lN_tKwPo6Y@gOl$aT-O_2Z!@~lW~X@f>H9d>yAR(Nd7e~cVz8|H$D<&` z#&PuQF~@@fKkXQdd|HgWTTcGt(qQ?=s~`v#u<~yC$F8Ah1Csb^<v%*e~IiIL6Gg#ijSF>YYoo%^|CT?`+RS@f>@Z)EhvDhjws{ZVhW$Ow zxy`Qotve$FV|r$Igl+lT4e9x2hn3APDVxn*Z`9i*Ver+ex9fDhg3{BgNB=(ktN5W) z5y<~{ljHyA&m1>F?0tV99=!PQA53=F?dzWi+0a9Kdn zc$%Gpzp^%)1CJo%-^&7$f?N!e%F4oZmj$H-zE%FyQFwZCz2dETj2R4qx90(!VdOMl z@y8%}(*|)Aw<%cOSkl@;s@? z#9&$Xk4Hg>jpOLqYx52Y{Ip{*@@X;hZaMjnOM~SfuYw?0z{i`8 z17mt-c!X{F+YRaYW`~u{?kStiU2oLeC1LQ@s<-QOy@Jxyt4IGn{j2z)QxVAjca!7) z=g%BBLF|2hA0E8;@Z;~3A31Iwlz8?w?rhLJkh-^Fh71h9Prh8QxOX0727}9jy5CjWYdAIyy*HE+pNqn{P eY5B*mzz-Hv-~eg^EBW}I#r5QSJ=c>A^a20?Ig20w literal 0 HcmV?d00001 diff --git a/x/v.8xp b/x/v.8xp deleted file mode 100644 index 09c90def204ad006f520ba97ac11837208a19eb0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 470 zcmdPW3h}fscGHsLVu-S^aPd~qRY=OrGb&3gQYbUjGcsVn2IewyGxRaCML^~H7<(8` z8ZalOFuW}mnWy;czva)flJnjc%gtBhVR(8rW!}TLVSi6^ZnNut>(0o)n4TFPVO#!o zLwdg1VP&%$%4T!d8})Wc7<{$r?K)krp!D?W(Z5gsDt_ox1oHpgoX6e?roSM1HfL&~zh(`HH*dnF%W% znP(=dcn(B3OjeSafAZu>12{PO{=I|idZX)YMmO5*6z@KLALn}a;rk-blZs3XmUaJl z6ol9~j-K5z@1Vd>I|d`479;PLlmEChSpM-U2!aKyyj%XUYbe@)B)(etwEW{&;0KE- aZ~(P|m3(~9;(GGEp6f|$AxRT4-fjSyJ(L9i diff --git a/x/v.bin b/x/v.bin deleted file mode 100644 index a91ce7a99cc9c34f79f0a23d5a6161e7e64a149a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 396 zcmX?Uz?_)E@U~cFp5m|nmOsx*&U;%dH(!y5;py3wc@N)){XNaO&93{cJ0k;QdS-Zp zZTZ^`>G@`dmCbG_o6TKs)Y~Ot@YSlf>vX+>($lL)|33Yz_@Pq~$p3efjjp#D-DtB@y!-Thoa^0(?~6Q7Dl#!x z*8SsA5MtvvdUngag91P87>s;cjJ#V;{^QbM`Nyju2o|vNZu!Tqp=bk=_-f_T@{eDE ZA1tQ80n`Ro^6@>3>&f?et|uAj1ps|li248k diff --git a/x/x.8xp b/x/x.8xp deleted file mode 100644 index 4b6c4a3285aa44f79abe38cd4b7de37bf45b7282..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 472 zcmdPW3h}fscGHsLV(?8&NmVG%EXhy^@pR75D=sN2O)kkVQY%PI&Q48HNUBtD%FGK$ zOtz?)&&bQr$H?aB!T<$*j6IAe4VV*C7~U3(%v1dJ-}2{K$$4*!<>o8$Fg!h*GVkHr zu)n7{x7l^Sb!TK?OwSCDuq}VPAwA#hu(H_=WwW{Kje5Hz48B_RcAc(QP%rg^JJO?5iCM(IzKY8+`0UVrs|K7oMz0vhHqZ@5@ zig%yBk8{2I@O_czNkt|G%esF&3PNlgN6&7VcTnJ`9fOfii;;KB$$wlLEdO{F1i=DU u-Yx&wH56??5?`%+TK@4X@Pow^IDp!~NbOQkN(Vfr$ diff --git a/x/x.bin b/x/x.bin deleted file mode 100644 index a91ce7a99cc9c34f79f0a23d5a6161e7e64a149a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 396 zcmX?Uz?_)E@U~cFp5m|nmOsx*&U;%dH(!y5;py3wc@N)){XNaO&93{cJ0k;QdS-Zp zZTZ^`>G@`dmCbG_o6TKs)Y~Ot@YSlf>vX+>($lL)|33Yz_@Pq~$p3efjjp#D-DtB@y!-Thoa^0(?~6Q7Dl#!x z*8SsA5MtvvdUngag91P87>s;cjJ#V;{^QbM`Nyju2o|vNZu!Tqp=bk=_-f_T@{eDE ZA1tQ80n`Ro^6@>3>&f?et|uAj1ps|li248k diff --git a/z88dk.Dockerfile b/z88dk.Dockerfile new file mode 100644 index 0000000..4595c4b --- /dev/null +++ b/z88dk.Dockerfile @@ -0,0 +1,36 @@ +# To create the image: +# $ docker build -t z88dk -f z88dk.Dockerfile . +# To run the container: +# $ docker run -v ${PWD}:/src/ -it z88dk + +FROM alpine:latest + +LABEL Version="0.8" \ + Date="2018-Apr-10" \ + Docker_Version="18.03.0-ce-mac60 (23751)" \ + Maintainer="Garrafon Software (@garrafonsoft)" \ + Description="A basic Docker container to compile and use z88dk from GIT" + +ENV Z88DK_PATH="/opt/z88dk" + +RUN apk add --no-cache build-base libxml2 m4 curl \ + && apk add --no-cache -t .build_deps bison flex libxml2-dev git subversion boost-dev texinfo \ + perl-template-toolkit perl-app-cpanminus \ + && git clone --depth 1 --recursive https://github.com/HeronErin/z88dk.git ${Z88DK_PATH} + +RUN cpanm -l $HOME/perl5 --no-wget local::lib Template::Plugin::YAML + +# Add, edit or uncomment the following lines to customize the z88dk compilation +# COPY clib_const.m4 ${Z88DK_PATH}/libsrc/_DEVELOPMENT/target/ +# COPY config_sp1.m4 ${Z88DK_PATH}/libsrc/_DEVELOPMENT/target/zx/config/ + +RUN cd ${Z88DK_PATH} \ + && eval "$(perl -I$HOME/perl5/lib/perl5 -Mlocal::lib)" \ + && chmod 777 build.sh \ + && BUILD_SDCC=1 BUILD_SDCC_HTTP=1 ./build.sh \ + && apk del .build_deps + +ENV PATH="${Z88DK_PATH}/bin:${PATH}" \ + ZCCCFG="${Z88DK_PATH}/lib/config/" + +WORKDIR /src/