Commodore 128 Alive!

Commodore 128 => 128 programmers => Topic started by: MIRKOSOFT on November 11, 2009, 12:43 PM

Title: Extending of BASIC
Post by: MIRKOSOFT on November 11, 2009, 12:43 PM
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
Title: Re: Extending of BASIC
Post by: Hydrophilic on November 11, 2009, 03:09 PM
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.
Title: Re: Extending of BASIC
Post by: BigDumbDinosaur on November 11, 2009, 03:15 PM
Good answer, Hydrophilic!
Title: Re: Extending of BASIC
Post by: MIRKOSOFT on November 11, 2009, 03:22 PM
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
Title: Re: Extending of BASIC
Post by: Hydrophilic on November 11, 2009, 03:49 PM
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.
Title: Re: Extending of BASIC
Post by: MIRKOSOFT on November 11, 2009, 03:56 PM
Hi!

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

Also thanks.

Miro
EhPortal 1.34 © 2025, WebDev