Post by firstname.lastname@example.org
Maybe something like this?
LDA $BE42 ; 0=immediate (prompt), >0=definite (BASIC program)
LDA $32 ; is immediate mode applesoft?
CMP #$DD ; look for "]" at current applesoft line pointer
BEQ $D995 ; jump to DATA to process rest of line
EXIT RTS ; we are in ML or definite mode
Noticing a serious lack of documentation regarding some of this stuff. Haven't seen either of these books below in PDF, which would have probably answered a lot of my questions.
Mastering ProDOS – April, 1986 by T. Rice (Author), K. Rice (Author)
Exploring Apple GS/OS and ProDOS 8 - Jan 1, 1989 by Gary B. Little
Gary Little's other book "Inside the IIe" was the only place I found those Applosoft pointers listed ($D995).
An FYI, the routine at $D995 is just named DATA and pertains to more than just the applesoft DATA command. It is used to find the end-of-line marker or the next statement marker in an applesoft program line. In doing so it can skip past REM's, find the closing quotation mark (I think) and even skip past DATA statements that are in the middle of your program when the program is executing.
I just want to say, "kudos" for doing your research. You did what most programmers have already done, which is search for your own answers instead of expecting an answer given to them, and it took a lot of reading.
I think most of my knowledge came from reading Nibble magazine where you can see the disassembled listings, more than it came from thick books of long-winded, redundant information. The best article for me was "Disassembly Lines" that showed the disassembly of Basic.system.
I don't think there are any books dedicated to Basic.system itself.
I will try to summarize what I have learned with what you are doing.
On to the main subject.
There are 4 ways in which you can initialize the 80-col card from.
1) from the prompt
2) from an applesoft program
3) from a binary program
4) from a system program
The first 3 require Basic.system to be in memory. The 4th doesn't and can be ignored.
The first 3 also have to deal with applesoft ROM linked through Basic.systems input/ouput vectors. Even though calls may not be made to applesoft, calls made to input/output devices and not telling Basic.system about them, can mess up Basic.system's vectors when exiting your program and, can leave Basic.system in a state no longer linked to applesoft. Applesoft ROM is where the prompt is being displayed and a running applesoft program passes code through Basic.system.
Commands to initialize input/output devices at the prompt are intercepted by Basic.system and its vectors are updated accordingly.
When running applesoft programs, Basic.system intercepts each character and looks for the CTRL-D character and when used with PR# and IN#, B.S. will update its I/O vectors.
Binary programs though are not expected to send a CTRL character to signal Basic.system to update its vectors and there are some special use cases with which to watch out for.
- binary programs can be either called from the prompt or an applesoft program
which can be in conflict if user would like to use the routine for both cases
- binary programs can make applesoft calls, some of which don't leave the
end-of-line set properly, and can cause an error on exit
- binary programs can initialize input/output devices and can leave
I find that the applesoft commands that don't exit with the end-of-line marker are the commands without expressions.
Hope this helps in your programming efforts.