Basic function

Everything related to BASIC version 1.x (Oric 1 and Atmos) or HYPERBASIC (Telestrat).
Don't hesitate to give your small program samples, technical insights, or questions...
Funct
Private
Posts: 2
Joined: Wed Mar 25, 2009 8:42 pm
Location: blue planet

Basic function

Post 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.
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post 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 !
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

RECALL A$,FILENAME$

Post 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
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

Edit:

Post 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
Funct
Private
Posts: 2
Joined: Wed Mar 25, 2009 8:42 pm
Location: blue planet

Post by Funct »

hello,

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

Cordialy
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post 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.
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

Re

Post 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?
User avatar
carlsson
Pilot Officer
Posts: 127
Joined: Thu Jan 12, 2006 11:26 pm
Location: Västerås, Sweden

Post 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
Anders Carlsson
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post by Dbug »

That's EVIL !

I love it ! :twisted:
User avatar
Chema
Game master
Posts: 3013
Joined: Tue Jan 17, 2006 10:55 am
Location: Gijón, SPAIN
Contact:

Post by Chema »

What!? Obfuscated BASIC in Oric :twisted:

I also LOVE it! You have opened a door to darkness, you know...
Brana
Flying Officer
Posts: 169
Joined: Fri Nov 30, 2007 8:30 pm
Contact:

Re:

Post 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 :)
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post 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.
User avatar
carlsson
Pilot Officer
Posts: 127
Joined: Thu Jan 12, 2006 11:26 pm
Location: Västerås, Sweden

Post 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.
Anders Carlsson
User avatar
Dbug
Site Admin
Posts: 4437
Joined: Fri Jan 06, 2006 10:00 pm
Location: Oslo, Norway
Contact:

Post 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.
Post Reply