while looking into the thread viewtopic.php?p=41302#p41302 I was wondering how the initial start part works.
After some hours of puzzling I can see now some basic code within certain sysvars.
Some other sysvars get automatically set by the load procedure and a few are finally set by a machine code program.
This MC program is located as fractions in the sysvars as well and will partially overwrite the Basic line which started it.
abstracting from the actual locations and unconditional jumps the program logic could be described as:
Code: Select all
9793 GOTO USR 16393
basic: ld h,dfile_h ; highbyte of dfile
ld l,dfile_l
oldpcc: ld (D_FILE),hl ; self overwriting
strlen: ld h,vars_h
t_addr: ld c,h ; $4C follows $3B which is the code for RUN
inc c ; $0C40 it's address, just ignore
seed: ld l,vars_l
frames: ld (hl),$E9 ; frames will decrease the provided opcode
; this will load 'jp(hl)' into vars
coords: jp gamecode
But considering: Line number 9793 is already the 'ld h,dfile_h'.
The Basic line calls a machine code starting with it's own line number!
And Boy, I can hardly believe the code at 't_addr' and 'frames' which the debugger showed me.
In the comments is the explanation I came up with.
Please let me know if you have different ideas or if I may have missed something.