Skip to content

Commit

Permalink
Working zcc build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pickle committed Oct 13, 2023
1 parent c28433a commit bd6dbbb
Show file tree
Hide file tree
Showing 19 changed files with 940 additions and 76 deletions.
32 changes: 0 additions & 32 deletions build.sh

This file was deleted.

28 changes: 17 additions & 11 deletions build_app.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
# rm $OUT_NAME.bin
16 changes: 6 additions & 10 deletions build_prog.sh
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions build_prog_zcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# sh build_prog.sh examples/zcc_helloworld hllo
sh build_app.sh examples/zcc_helloworld tix
1 change: 1 addition & 0 deletions examples/zcc_helloworld/.buildid
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0x82e3
59 changes: 59 additions & 0 deletions examples/zcc_helloworld/main.c
Original file line number Diff line number Diff line change
@@ -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



}
Binary file added examples/zcc_helloworld/tix.8xk
Binary file not shown.
Binary file added examples/zcc_helloworld/tix.bin
Binary file not shown.
31 changes: 8 additions & 23 deletions hello.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
#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 ad
#pragma string name tes
#define bcall(__LABEL__) rst 40 \ defw __LABEL__

// A bit of trash data so the program runs correctly
Expand All @@ -16,31 +8,26 @@ void _(){
defm "0000000000"
#endasm
}
#endif





void main()
{

#ifdef SDCC
__asm
#else

#asm
#endif
rst 40

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
Expand All @@ -49,11 +36,9 @@ void main()

bcall(0x4972 ) ; _getkey

#ifdef SDCC
__endasm;
#else

#endasm
#endif




Expand Down
Loading

0 comments on commit bd6dbbb

Please sign in to comment.