base:using_a_running_vice_session_for_development
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
base:using_a_running_vice_session_for_development [2016-06-28 19:17] – compyx | base:using_a_running_vice_session_for_development [2016-06-30 14:44] – compyx | ||
---|---|---|---|
Line 139: | Line 139: | ||
</ | </ | ||
- | Again, this becomes tedious, having to type this again and again, so we update our Makefile: | + | Again, this becomes tedious, having to type this again and again, so we update our Makefile |
<code make> | <code make> | ||
+ | ASM=64tass | ||
+ | |||
+ | |||
+ | # Default make target: just assemble the program: | ||
+ | all: demo.prg | ||
+ | |||
+ | |||
# Assemble program | # Assemble program | ||
demo.prg: demo.s | demo.prg: demo.s | ||
- | $(X64) -a -C -o demo.prg demo.s | + | $(ASM) -a -C -o demo.prg demo.s |
+ | |||
+ | # Inject program into VICE session and run it | ||
run: demo.prg | run: demo.prg | ||
# we need to wait one second for the reset to finish, so we use -q 1 | # we need to wait one second for the reset to finish, so we use -q 1 | ||
Line 153: | Line 162: | ||
echo 'g 080d' | netcat localhost 6510 | echo 'g 080d' | netcat localhost 6510 | ||
</ | </ | ||
+ | |||
+ | The `-q 1` argument to netcat is required to allow the reset to properly finish. netcat does not wait for VICE to complete its task, it immediately exits on EOF, so we use `-q 1` to tell netcat to wait one second after EOF. You could also use `sleep 1` after issuing 'reset 0', it has the same effect (adjust to sleep 3 when using a non-patched KERNAL). | ||
+ | |||
+ | Since the ' | ||
+ | |||
+ | |||
+ | === Loading labels into VICE === | ||
+ | |||
+ | The same goes for loading labels into VICE: since we use a running instance, when we do ' | ||
+ | <code bash> | ||
+ | echo ' | ||
+ | echo ' | ||
+ | </ | ||
+ | Again giving VICE time to process the ' | ||
+ | |||
+ | So, lets update our Makefile once again (full Makefile now): | ||
+ | <code make> | ||
+ | # x64 binary | ||
+ | X64=/ | ||
+ | # Assembler | ||
+ | ASM=64tass | ||
+ | |||
+ | # Original KERNAL | ||
+ | KERNAL=/ | ||
+ | # Patched KERNAL | ||
+ | KERNAL_PATCHED=kernal-quick-memtest | ||
+ | |||
+ | |||
+ | # Generate patched KERNAL for faster reset (skip BASIC memtest) | ||
+ | $(KERNAL_PATCHED): | ||
+ | cp $(KERNAL) $(KERNAL_PATCHED) | ||
+ | echo "1d69: 9f" | xxd -r - $(KERNAL_PATCHED) | ||
+ | all: demo.prg | ||
+ | |||
+ | |||
+ | # Assemble program and output VICE labels file | ||
+ | demo.prg: demo.s | ||
+ | $(ASM) -a -C -o demo.prg demo.s --vice-labels -l labels.txt | ||
+ | |||
+ | |||
+ | # Inject program into VICE session and run it | ||
+ | run: demo.prg | ||
+ | # we need to wait one second for the reset to finish, so we use -q 1 | ||
+ | echo 'reset 0' | netcat -q 1 localhost 6510 | ||
+ | # clear and (re)load labels | ||
+ | echo ' | ||
+ | echo ' | ||
+ | # load demo.prg from the virtual FS, our host OS | ||
+ | echo 'l " | ||
+ | # this assumes demo.prg starts at $080d | ||
+ | echo 'g 080d' | netcat localhost 6510 | ||
+ | |||
+ | |||
+ | # Start VICE session with remote monitor and patched KERNAL in the background | ||
+ | # redirecting VICE's output to a black hole | ||
+ | session: $(KERNAL_PATCHED) | ||
+ | $(X64) -remotemonitor -kernal $(KERNAL_PATCHED) \ | ||
+ | > /dev/null 2>&1 & | ||
+ | |||
+ | # Clean up | ||
+ | .PHONY: clean | ||
+ | clean: | ||
+ | rm -f demo.prg | ||
+ | rm -f $(KERNAL_PATCHED) | ||
+ | </ | ||
+ | |||
+ | There you have it, running and debugging code with a live VICE session, avoiding a lot of start up time. Unfortunately, | ||
+ | |||
+ | |||
+ | == Proper BASIC initialization == | ||
+ | |||
+ | Since we bypass the C64's OS (the BASIC interpreter), | ||
+ | |||
+ | So we need a way to do a proper ' | ||
+ | |||
+ | Let's assume our demo.s looks like this: | ||
+ | <code 64tass> | ||
+ | * = $0801 | ||
+ | | ||
+ | ; BASIC section: this becomes "2016 sys2061" | ||
+ | .word (+), 2016 | ||
+ | .null $9e, ^start | ||
+ | + .word 0 | ||
+ | |||
+ | start ; this is $080d | ||
+ | lda #0 | ||
+ | sta $d020 | ||
+ | sta $d021 | ||
+ | rts | ||
+ | </ | ||
+ | |||
+ | When we run this using the Makefile shown, the border and background turn black, but we get a blinking cursor. So we need to somehow force BASIC to properly run this SYS line. This can be done with a little tweaking: | ||
+ | (Thanks to Groepaz for coming up with the suggestion of simply putting ' | ||
+ | |||
+ | First we load the binary into VICE, then we set the end-of-basic pointer to $080d, fill the keyboard buffer with " | ||
+ | <code bash> | ||
+ | # reset, and wait, otherwise the BASIC start-of-basic pointer gets overwritten to $0000 while loading | ||
+ | echo 'reset 0' | netcat -q 1 localhost 6510 | ||
+ | # load binary | ||
+ | echo 'l " | ||
+ | # put ' | ||
+ | echo 'f 0277 027a 52 55 4e 0d' | netcat localhost 6510 | ||
+ | # set keyboard buffer size to $04 -> strlen(" | ||
+ | echo 'f 00c6 00c6 04' | netcat localhost 6510 | ||
+ | </ | ||
+ | |||
+ | Putting this in our Makefile, we end up with this: | ||
+ | <code make> | ||
+ | # x64 binary | ||
+ | X64 = / | ||
+ | # Assembler | ||
+ | ASM=64tass | ||
+ | |||
+ | # Original KERNAL | ||
+ | KERNAL=/ | ||
+ | # Patched KERNAL | ||
+ | KERNAL_PATCHED=kernal-quick-memtest | ||
+ | |||
+ | |||
+ | # Generate patched KERNAL for faster reset (skip BASIC memtest) | ||
+ | $(KERNAL_PATCHED): | ||
+ | cp $(KERNAL) $(KERNAL_PATCHED) | ||
+ | echo "1d69: 9f" | xxd -r - $(KERNAL_PATCHED) | ||
+ | all: demo.prg | ||
+ | |||
+ | |||
+ | # Assemble program and output VICE labels file | ||
+ | demo.prg: demo.s | ||
+ | $(ASM) -a -C -o demo.prg demo.s --vice-labels -l labels.txt | ||
+ | |||
+ | |||
+ | # Inject program into VICE session and run it | ||
+ | run: demo.prg | ||
+ | # we need to wait one second for the reset to finish, so we use -q 1 | ||
+ | echo 'reset 0' | netcat -q 1 localhost 6510 | ||
+ | # clear and (re)load labels | ||
+ | echo ' | ||
+ | echo ' | ||
+ | # load demo.prg from the virtual FS, our host OS | ||
+ | echo 'l " | ||
+ | # put ' | ||
+ | echo 'f 0277 027a 52 55 4e 0d' | netcat localhost 6510 | ||
+ | # set keyboard buffer size to $04 -> strlen(" | ||
+ | echo 'f 00c6 00c6 04' | netcat localhost 6510 | ||
+ | |||
+ | |||
+ | # Start VICE session with remote monitor and patched KERNAL in the background | ||
+ | # redirecting VICE's output to a black hole | ||
+ | session: $(KERNAL_PATCHED) | ||
+ | $(X64) -remotemonitor -kernal $(KERNAL_PATCHED) \ | ||
+ | > /dev/null 2>&1 & | ||
+ | |||
+ | # Clean up | ||
+ | .PHONY: clean | ||
+ | clean: | ||
+ | rm -f demo.prg | ||
+ | rm -f $(KERNAL_PATCHED) | ||
+ | </ | ||
+ | |||
+ | |||
+ | More later.. | ||
+ | |||
+ | TODO: | ||
+ | * attaching disk images | ||
+ | * debugging via telnet | ||
+ | * writing a proper Makefile (perhaps putting all those echo's into a file, updating it with sed) | ||
+ | * VIM integration | ||
+ |
base/using_a_running_vice_session_for_development.txt · Last modified: 2016-07-01 13:35 by compyx