Page 1 of 1

Basic function

Posted: Wed Mar 25, 2009 8:52 pm
by Funct
hello,

I am a little new :D . I would ask you, if you are using the BASIC of the Atmos, which commands you are missing and would like to have.

bye.

Edited by Dbug: If you have some needs in your BASIC programs, he can help you with some 6502 assembly routines to spice up your programs. Just indicate what you would like to have, and he will help if he can.

Posted: Wed Mar 25, 2009 11:03 pm
by Dbug
Welcome to you, and thanks for the offering.

There are few people here on the forum who are programming in BASIC, so they may be interested by some stuff, perhaps some fast character redefinition using interrupts, or some scrolling.

People, answer him !

RECALL A$,FILENAME$

Posted: Tue May 12, 2009 4:26 pm
by Brana
Well, I know that the following example is impossible on Atmos BASIC:

10 DIM A$
20 INPUT "Enter desired filename", FN$
30 STORE A$, FN$

Instead, the user (myself) :) have to do it as follows:

10 DIM A$
20 rem
30 STORE A$,"FILENAME.TAP"

This also implies for RECALL (RECALL A$,"FILENAME.TAP")

Or, to put it in short:
The user must define the filename to STORE to / RECALL from
within the BASIC program (it cannot be defined while the program is already running!) This have something to do with some kind of bug in Oric BASIC rom/routine.

I wonder could it be "fixed"?

Brana

Edit:

Posted: Tue May 12, 2009 4:35 pm
by Brana
EDIT/in addition:

On the date of: Thu Dec 20, 2007

DBUG answered: (quote)

For the filename problem, you can do the STORE instruction yourself by POKing/DOKing the right parameters in page 2, and calling the right ROM instructions with CALL.

(EndQuote)

... hehe, but I (still) do not know how! :(

Brana

Posted: Fri May 22, 2009 10:11 am
by Funct
hello,

if I understood it, an 'input' is impossible ?

Cordialy

Posted: Fri May 22, 2009 12:02 pm
by Dbug
No, I think the problem is that the second parameter of the instruction STORE has to be a literal string. It cannot be a string variable, for some strange reason.

Re

Posted: Mon May 25, 2009 4:19 pm
by Brana
In addition to Mr. Dbug

If I use INPUT (string variable) then the file will save thousand errors! (file will become corrupted!) but, of course, it works fine if i use "literal string".

I can send you a small TAP (BASIC) demo file for this "bug" that I have made, if would like?

Posted: Mon Jun 01, 2009 2:57 pm
by carlsson
Does Oric Basic allow a line like this:

30 STORE A$,"FILENAME.TAP"::::::::

Note all the trailing colons. If that works, you might traverse the FN$ string as follows:

FOR I=1 TO LEN(FN$):POKE address+I,ASC(MID$(FN$,I,1)):NEXT

where address happens to be the location of the literal string FILENAME.TAP.

Possibly you need to extend the FOR statement to add an ending " and new colons to fill up to maximum file name length.

It might be a bit cumbersome, but while waiting for alternative ROM routines it could work, and also be an interesting example of self modifyfing Basic programs. :-D

Posted: Mon Jun 01, 2009 3:04 pm
by Dbug
That's EVIL !

I love it ! :twisted:

Posted: Mon Jun 01, 2009 3:46 pm
by Chema
What!? Obfuscated BASIC in Oric :twisted:

I also LOVE it! You have opened a door to darkness, you know...

Re:

Posted: Mon Jun 01, 2009 4:45 pm
by Brana
have You tested it?

I think it will not work as I think that - if the BASIC program is changed, then instantly after that change - all string variables will be "reset" to "zero"

However, I will test it as soon as I get home tonight :)

Posted: Mon Jun 01, 2009 4:58 pm
by Dbug
If you use POKE to modify the BASIC program, the interpreter will not realize that, should work really. The hard part is just to figure out which bytes to patch, so I guess you need a function that can identify a particular line number and then poke from there.

Posted: Tue Jun 02, 2009 10:11 am
by carlsson
Possibly you can add a REM statement using custom labels. A chunk of absolutely untested code which likely is full of bugs:

50 INPUT"LABEL",LB$
60 INPUT"FILENAME",FN$
70 GOSUB 200
80 END

100 REM STOREA$
101 STORE A$,"FILENAME.TAP"::::::::
102 RETURN

110 REM STOREX
111 STORE X,"XFILE.TAP":::::::::::
112 RETURN

200 REM SOB = START OF BASIC
201 REM EOB = END OF BASIC
203 REM LB$ = LABEL NAME
204 REM FN$ = FILE NAME
205 J=1
206 FOR I=SOB TO EOB
207 J=J+1
208 IF PEEK(I)<>ASC(MID$(LB$,J,1)) THEN J=1
209 IF J<LEN(LB$)+1 THEN NEXT I
210 REM "I" SHOULD POINT TO "STORE"
211 REM MOVE "I" FORWARD TO GET TO
212 REM THE FILE NAME STRING
211 I=I+7:REM WILD GUESS !!!
212 FOR J=1 TO LEN(FN$)
213 POKE I+J,ASC(MID$(FN$,J,1))
214 NEXT J
215 REM PAD LINE UP TO THE MAX
216 REM LENGTH OF A FILENAME
215 I=I+J:POKE I,CHR$(34):I=I+1
215 FOR J=I TO 16:REM WILD GUESS !!
216 POKE I+J,ASC(":"):NEXT J
217 RETURN

A lot of this could of course be done in machine code, but then again perhaps a patch to the STORE command would be a better way to go than all this possibly self modifying code.

Please note that I'm not familiar with Oric Basic so I don't know all its traits and features, e.g. if you have a WHILE/WEND statement, ELSE and so on.

Posted: Tue Jun 02, 2009 6:20 pm
by Dbug
carlsson wrote:Please note that I'm not familiar with Oric Basic so I don't know all its traits and features, e.g. if you have a WHILE/WEND statement, ELSE and so on.
Well, we have REPEAT/UNTIL, and ELSE as well.