How to execute long BASIC command from ML code?

Started by MIRKOSOFT, August 31, 2010, 08:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!


I have problem with executing BASIC command from ML code.


As everybody know keyboard-buffer is only 10 bytes long, so, it can't to be fit into this buffer.


I tried routine $4f93 (tokenize) with RETURN char (#13), but works not and escapes from my code and ends all.


Command is too long, look at attachment, can anybody help me how to execute it and going back continue in my code?


Many thanks for every help.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

Pinacolada

You don't need to stuff the entire keyboard buffer with the text of that BASIC command line. Just clear the screen, cursor down 3 lines, display the text, home the cursor, put a carriage return in the buffer, and END the program (how you do that from ML I don't know). Many disk menu systems use this technique on the C64.
C128 Programmer's Reference Guide FAIL:

1. Press 40/80 key DOWN.
2. Turn computer OFF, then ON.
3. Remove cartridge if present.

MIRKOSOFT

Thank you!


But this technique from BASIC I know, other it is it seems in ML code.


Miro
MIRKOSOFT of megabytes

Commodore 64 was great, Commodore 128 is bigger, better, faster and more!!!

http://www.mirkosoft.sk

wte

If you want to go back to your ML programm, then you have to add as SYS call!

Hydrophilic

#4
Quote from: wte on September 05, 2010, 06:25 AM
If you want to go back to your ML programm, then you have to add as SYS call!
You can also change vector IMAIN ($0302) so instead of returning to immediate mode ROM, you can go to your own code.  If you do this, remember memory will be configured for BANK 14, so target must be below $4000 in Bank 0.  Also you should save the stack pointer before executing the BASIC line because if an error occurs, the ROM will reset the stack before the JMP (IMAIN).

Quote from: MIRKOSOFT on September 02, 2010, 12:57 PM
But this technique from BASIC I know, other it is it seems in ML code.
One way to run BASIC line of code is store text in Bank 0 below $4000, terminated with null.  Load X and Y with low byte and high byte of string address - 1.  Then call EXECUTE_A_LINE from BASIC jump table $AFA5.  For example,

;this must be below $4000 in Bank 0 RAM
;untokenized BASIC text at $200~2xx
LDY #1
LDX #255
STA $FF03 ;set Bank 14
JMP $AFA5

Be sure you copy the text to a buffer, like $200~$2A0 because BASIC will re-write the text with tokens.

EditI've attached a sample program that demonstrates both methods.  Start it from the monitor with G 1300 or from BASIC with BANK0:SYS4864.  It copies string 'PRINT"{CLR}' into input buffer $200, then it changes IMAIN vector for after BASIC finishes.  Next it does the JMP to Execute_a_line.  The BASIC example line clears the screen, then control returns to ML at $1328 and does an infinite loop of flashing the VIC border.  Really a long-winded method of clearing the screen!:)
I'm kupo for kupo nuts!