Extending of BASIC

Started by MIRKOSOFT, November 11, 2009, 12:43 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

MIRKOSOFT

Hi!

I want to extend BASIC 7.0 to my own command. It's not st. hard, if I will using prefix, e.g. @.
So, my command will be @DOS.

But I don't want to have any prefix - so I want to have command DOS.

Longer time ago I programmed extension of BASIC 7.0 and all commands began with @ prefix.
So, here's the Q:

When I scan all my possible commands and found not any, how to jump to detect standard BASIC 7.0 commands?

Thank you all.

Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

The direct answer to your question is probably JMP ($0304).  That goes into the CRUNCH routine to turn text into tokens.

If you are using the formal method of adding commands (not using special characters like @), then it sounds like you are doing this backwards.  Commodore created vectors to add your own keywords.  So BASIC will search all standard keywords and if it doesn't find a match, it will jump to your routine so you can check for your custom keywords.

In this case, you change vector at $030C to point to your code that checks for your custom keyword(s) and returns a token if found or returns with Carry flag set if not found.  Using this method, you also need to change vector at $030E to list your custom token as plain text.  And you also need to change $0310 to execute your new keyword, if it is a statement, and/or change $0312 if your new keyword is a function.

This formal method is a bit more complex.  The book Mapping the Commodore 128 has a decent description of this and includes an example program.
I'm kupo for kupo nuts!

BigDumbDinosaur

x86?  We ain't got no x86.  We don't need no stinking x86!

MIRKOSOFT

Hi!

Thanks for explain.

I tried to read letters with CHRGET ($0380), but this increases read out characters...

So, how to reset read out letters if after 3 letters is no match found?

Thanks.

Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk

Hydrophilic

CHRGET is very slow.  Don't use it.  Instead use the pointer at $3D like this:


LDY #0
STY $FF01 ;BANK0
test:
LDA ($3D),Y
CMP string,Y
BNE wrong
INY
CPY #len
BCC test
TYA
CLC
ADC $3D
STA $3D
BCC found
INC $3E
found:
;whatever you need to do here
STY $FF03 ;BANK 14
;jmp to BASIC, probably JMP ($0302)
wrong:
STY $FF03 ;BANK 14
JMP ($0304)


Your code must be visible in BANK 14; in RAM Bank 0 below $4000.
I'm kupo for kupo nuts!

MIRKOSOFT

Hi!

Thanks, but I solved it - reset of counter at $3D...

Also thanks.

Miro
MIRKOSOFT of megabytes

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

http://www.mirkosoft.sk