From cae5f7c94daa4ca039391f07a799340f744ad73c Mon Sep 17 00:00:00 2001 From: Philip Zembrod Date: Sun, 31 Jul 2022 21:56:33 +0200 Subject: [PATCH] Get v4th-x16 to work with r41 of x16emu and x16 ROM. Main change is that c64key? and getkey are implemented through new Kernal API calls instead of direct reading the keyboard buffer. A separate intermediate test target for r41 is introduced. But also the main x16 target is switched to r41 now. Also, the KEEPEMU env var is introduced to run-in-x16emu.sh for debugging that has proved its usefulness in cc64 emulator scripts. --- 6502/C64/Makefile | 31 +++++++++++++++++++-------- 6502/C64/emulator/run-in-x16-41.sh | 9 ++++++++ 6502/C64/emulator/run-in-x16emu.sh | 18 ++++++++++++---- 6502/C64/src/vf-lbls-cbm.fth | 1 + 6502/C64/src/vf-sys-x16.fth | 34 ++++++------------------------ 5 files changed, 53 insertions(+), 40 deletions(-) create mode 100755 6502/C64/emulator/run-in-x16-41.sh diff --git a/6502/C64/Makefile b/6502/C64/Makefile index 3b76b96..c874703 100644 --- a/6502/C64/Makefile +++ b/6502/C64/Makefile @@ -34,7 +34,7 @@ clean: binaries: $(vf_binaries) -test: $(test_resuls) test-v4th-x16-39.result +test: $(test_resuls) test64: std64 blk64 @@ -93,8 +93,9 @@ cbmfiles/v4th-x16: $(test_logs): $(test_files_petscii) emulator/run-in-vice.sh -test-v4thblk-c64.log: emulator/v4thblk-c64.T64 disks/scratch.d64 - rm -f cbmfiles/test.log +test-v4thblk-c64.log: emulator/v4thblk-c64.T64 disks/empty.d64 + rm -f cbmfiles/test.log disks/scratch.d64 + cp disks/empty.d64 disks/scratch.d64 DISK9=scratch emulator/run-in-vice.sh v4thblk-c64 \ "include run-blk-tests.fth\n1234567890\n" petscii2ascii cbmfiles/test.log $@ @@ -105,9 +106,10 @@ test-v4th-c64.log: emulator/v4th-c64.T64 "include run-std-tests.fth\n1234567890\n" petscii2ascii cbmfiles/test.log $@ -test-v4thblk-c16+.log: emulator/v4thblk-c16+.T64 disks/scratch.d64 - rm -f cbmfiles/test.log - VICE=xplus4 emulator/run-in-vice.sh v4thblk-c16+ \ +test-v4thblk-c16+.log: emulator/v4thblk-c16+.T64 disks/empty.d64 + rm -f cbmfiles/test.log disks/scratch.d64 + cp disks/empty.d64 disks/scratch.d64 + VICE=xplus4 DISK9=scratch emulator/run-in-vice.sh v4thblk-c16+ \ "include run-blk-tests.fth\n1234567890\n" petscii2ascii cbmfiles/test.log $@ @@ -136,6 +138,8 @@ test-v4th-x16.log: cbmfiles/v4th-x16 emulator/sdcard.img mcopy -i emulator/sdcard.img ::TEST.LOG cbmfiles/test.log petscii2ascii cbmfiles/test.log $@ +test-v4th-x16-39.log: $(test_files_petscii) emulator/run-in-vice.sh + test-v4th-x16-39.log: cbmfiles/v4th-x16 emulator/sdcard.img rm -f cbmfiles/test.log emulator/run-in-x16-39.sh v4th-x16 \ @@ -146,13 +150,22 @@ test-v4th-x16-39.log: cbmfiles/v4th-x16 emulator/sdcard.img test-v4th-x16-39.golden: test-v4th-x16.golden cp $< $@ +test-v4th-x16-41.log: $(test_files_petscii) emulator/run-in-vice.sh + +test-v4th-x16-41.log: cbmfiles/v4th-x16 emulator/sdcard.img + rm -f cbmfiles/test.log + emulator/run-in-x16-41.sh v4th-x16 \ + "include run-std-tests.fth\n1234567890\n" + mcopy -i emulator/sdcard.img ::TEST.LOG cbmfiles/test.log + petscii2ascii cbmfiles/test.log $@ + +test-v4th-x16-41.golden: test-v4th-x16.golden + cp $< $@ + test-%.result: test-%.log test-%.golden tests/evaluate-test.sh rm -f $@ tests/evaluate-test.sh $(basename $@) -disks/scratch.d64: disks/empty.d64 - cp $< $@ - emulator/sdcard.img: emulator/sdcard.sfdisk rm -f $@ $@.tmp dd if=/dev/zero of=$@.tmp count=64 bs=1M diff --git a/6502/C64/emulator/run-in-x16-41.sh b/6502/C64/emulator/run-in-x16-41.sh new file mode 100755 index 0000000..89487d4 --- /dev/null +++ b/6502/C64/emulator/run-in-x16-41.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +emulatordir="$(realpath --relative-to="$PWD" "$(dirname "${BASH_SOURCE[0]}")")" + +export PATH="${HOME}/x16-r41:${PATH}" +echo "PATH = ${PATH}" +"${emulatordir}/run-in-x16emu.sh" "$@" diff --git a/6502/C64/emulator/run-in-x16emu.sh b/6502/C64/emulator/run-in-x16emu.sh index ab94f63..ea7f15d 100755 --- a/6502/C64/emulator/run-in-x16emu.sh +++ b/6502/C64/emulator/run-in-x16emu.sh @@ -1,6 +1,9 @@ #!/bin/bash set -e +executable="${1}" +keybuf="${2}" + emulatordir="$(realpath --relative-to="$PWD" "$(dirname "${BASH_SOURCE[0]}")")" basedir="$(realpath --relative-to="$PWD" "${emulatordir}/..")" cbmfilesdir="${basedir}/cbmfiles" @@ -16,20 +19,27 @@ do done autostart="" -if [ -n "$1" ] +if [ -n "${executable}" ] then - autostart="-prg ${cbmfilesdir}/${1} -run" + autostart="-prg ${cbmfilesdir}/${executable} -run" fi script="" warp="" scale="" debug="" -if [ -n "$2" ] +if [ -n "${keybuf}" ] then test -d tmp || mkdir tmp rm -f "${x16script}".* - echo "load\"${1}\"\nrun\n${2}" | sed 's/\\n/\n/g' > "${x16script}".ascii + # Magic env variable KEEPEMU: If set, remove the final CR. + if [ -n "${KEEPEMU}" ]; then + tr_remove='\n' + else + tr_remove='' + fi + echo "load\"${executable}\"\nrun\n${keybuf}" | tr -d "${tr_remove}" \ + | sed 's/\\n/\n/g' > "${x16script}".ascii ascii2petscii "${x16script}.ascii" "${x16script}.petscii" script="-bas ${x16script}.petscii" autostart="" diff --git a/6502/C64/src/vf-lbls-cbm.fth b/6502/C64/src/vf-lbls-cbm.fth index d1a5480..1a2b77d 100644 --- a/6502/C64/src/vf-lbls-cbm.fth +++ b/6502/C64/src/vf-lbls-cbm.fth @@ -18,6 +18,7 @@ $FF84 >label IOINIT $FFB1 >label LISTEN $FFC0 >label OPEN $FFF0 >label PLOT +$FFB7 >label READST $FF8A >label RESTOR $FF93 >label SECOND $FFE1 >label STOP diff --git a/6502/C64/src/vf-sys-x16.fth b/6502/C64/src/vf-sys-x16.fth index 084887c..18cbc7e 100644 --- a/6502/C64/src/vf-sys-x16.fth +++ b/6502/C64/src/vf-sys-x16.fth @@ -6,10 +6,11 @@ include vf-lbls-cbm.fth \ X16 labels 0ffd2 >label ConOut - 0286 >label IOStatus +0febd >label KbdbufPeek + 0289 >label IOStatus 028c >label MsgFlg - 028b >label OutDev - 028a >label InDev + 028e >label OutDev + 028d >label InDev 09f2c >label BrdCol 0266 >label BkgCol 0284 >label PenCol @@ -46,33 +47,12 @@ include vf-lbls-cbm.fth \ X16 c64key? getkey Code c64key? ( -- flag) - RamBank ldx -\ TODO(issues/33): Remove the lines accessing RamBank38. - RamBank38 ldy - 0 # lda RamBank sta - RamBank38 sta - Ndx lda - 0<> ?[ 0FF # lda ]? pha - RamBank stx - RamBank38 sty + KbdbufPeek jsr + txa pha Push jmp end-code Code getkey ( -- 8b) - RamBank lda N sta -\ TODO(issues/33): Remove the lines accessing RamBank38. - RamBank38 lda N 1+ sta - 0 # lda RamBank sta - RamBank38 sta - Ndx lda 0<> - ?[ sei KeyD ldy - [[ KeyD 1+ ,X lda KeyD ,X sta inx - Ndx cpx 0= ?] - Ndx dec - N lda RamBank sta - N 1+ lda RamBank38 sta - tya cli 0A0 # cmp - 0= ?[ bl # lda ]? - ]? + GETIN jsr Push0A jmp end-code