basic: do registers-to-vars transfer after pgm hook call

This commit is contained in:
Virgil Dupras 2019-11-25 23:16:15 -05:00
parent 264e72e0fd
commit fc23a7c4a1
3 changed files with 18 additions and 4 deletions

View File

@ -238,3 +238,10 @@ contents. Any line not starting with a number is ignored (not an error).
is iterated to see if it finds a file with the same name. If it does, it loads is iterated to see if it finds a file with the same name. If it does, it loads
its contents at `USER_CODE` (from `user.h`) and calls that address, with HL its contents at `USER_CODE` (from `user.h`) and calls that address, with HL
pointing to the the remaining args in the command line. pointing to the the remaining args in the command line.
The user code called this way follows the *usr* convention for output, that is,
it converts all registers at the end of the call and stores them in appropriate
variables. If `A` is nonzero, an error is considered to have occurred.
It doesn't do var-to-register transfers on input, however. Only HL is passed
through (with the contents of the command line).

View File

@ -86,7 +86,6 @@ basFNEW:
call rdSep ; HL now points to filename call rdSep ; HL now points to filename
push ix \ pop de push ix \ pop de
ld a, e ld a, e
out (42), a
jp fsAlloc jp fsAlloc
; Deletes filename with specified name ; Deletes filename with specified name
@ -114,11 +113,18 @@ basPgmHook:
inc hl ; Z preserved in 16-bit inc hl ; Z preserved in 16-bit
inc de ; Z preserved in 16-bit inc de ; Z preserved in 16-bit
jr z, .loop jr z, .loop
; Ready to jump. Return USER_CODE in IX and basCallCmd will take care ; Ready to jump. Return .call in IX and basCallCmd will take care
; of setting (HL) to the arg string. ; of setting (HL) to the arg string. .call then takes care of wrapping
ld ix, USER_CODE ; the USER_CODE call.
ld ix, .call
cp a ; ensure Z cp a ; ensure Z
ret ret
.call:
ld iy, USER_CODE
call callIY
call basR2Var
or a ; Z set only if A is zero
ret
basFSCmds: basFSCmds:
.dw basFLS .dw basFLS

View File

@ -415,6 +415,7 @@ basUSR:
; and finally, A ; and finally, A
ld a, (VAR_TBL) ld a, (VAR_TBL)
call callIY call callIY
basR2Var: ; Just send reg to vars. Used in basPgmHook
; Same dance, opposite way ; Same dance, opposite way
ld (VAR_TBL), a ld (VAR_TBL), a
ld (VAR_TBL+46), ix ld (VAR_TBL+46), ix