In the NOREM section I add the line length (BC) to the Pointer (HL) I then check to see if the Pointer is equal to or passes the D_FILE address with SBC HL,DE but It is incorrect since it only looks at the first line in the program. What is the best way to check to see if HL is equal to or greater than the D_FILE address?READPRG:
LD HL, STARTPROG
INC HL // Bypass line number
LD A,(HL) // Get length of line
LD B, A
DEC BC // Adjust for HL to read first token
CP $EA // check for REM
LD DE,(rems) // Increment number of rems found
ADC HL,BC // Point to next line
LD BC,(rems) // Return with number of rems
For a given BASIC line number this subroutine will return the starting address of the actual line or the starting address of the following line if it does not exist (C reset).
09D8 LINE-ADDR PUSH HL
09DE NEXT-TEST POP BC
Yes, this ROM sub-routine seem working in a pure ASM program, but it erase some Basic variables and the Basic monitor seem to hang if you try to back to the Basic program…Using the ROMs find line address routine at 09D8 LINE-ADDR
Not cool !
My idea is to use REM lines for DATA. Each REM will have RTTTL data for use with the ZX-GAME in it. From that I will build a look up table with each entry containing 10 bytes for name, length of RTTTL and Start address of RTTTL. I will then use the LUT to construct a menu that you can select a song from to play.