Jump to content
IGNORED

Inty Basic Question


Recommended Posts

Hello,

i have a newbie question.  I'm toying with Inty Basic.  is there a way to split a BASIC line in multiple lines?

 

For instance , i would like to write something like :

if #backtab(#pos_joueur) = ECHELLE1 
or #backtab(#pos_joueur) = ECHELLE2 
or #backtab(#pos_joueur) = ECHELLE3 
or #backtab(#pos_joueur) = ECHELLE4 
or #backtab(#pos_joueur) = ECHELLE5 
or #backtab(#pos_joueur) = ECHELLE6 then

....

end if

 

instead of 

 

if #backtab(#pos_joueur) = ECHELLE1 or #backtab(#pos_joueur) = ECHELLE2 or #backtab(#pos_joueur) = ECHELLE3 or #backtab(#pos_joueur) = ECHELLE4 or #backtab(#pos_joueur) = ECHELLE5 or #backtab(#pos_joueur) = ECHELLE6 then
...

end if

 

I have tested to put all "new line" character i knew from other BASIC (like  & ,  _  , / )   it seems IntyBASIC does not support them.

 

thanks for your help.

  • Like 1
Link to comment
Share on other sites

You can use the inverted slash character at the end of the line.

 

Like this:

 

if #backtab(#pos_joueur) = ECHELLE1 \
or #backtab(#pos_joueur) = ECHELLE2 \
or #backtab(#pos_joueur) = ECHELLE3 \
or #backtab(#pos_joueur) = ECHELLE4 \
or #backtab(#pos_joueur) = ECHELLE5 \
or #backtab(#pos_joueur) = ECHELLE6 then

....

end if

 

BTW, it is more efficient to use the idiom (a=1)+(b=2)+(c=3) as the OR operation isn't implemented into Intellivision processor and uses several instructions to be processed.

 

Edited by nanochess
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

You might also want to load #backtab(#pos_joueur) into a temporary variable, as it appears IntyBASIC (at least v1.4.1) doesn't re-use the value it loaded.

 

#tmp = #backtab(#pos_joueur)
IF (#tmp = ECHELLE1) \
+  (#tmp = ECHELLE2) \
+  (#tmp = ECHELLE3) \
+  (#tmp = ECHELLE4) \
+  (#tmp = ECHELLE5) \
+  (#tmp = ECHELLE6) THEN

 ' ... stuff ...

END IF

 

Assuming ECHELLE1 through ECHELLE6 are constants, there may be even better ways to write this depending on what the values are.

 

I did try writing up a generic "FIND" assembly helper.  Counting the cycles, it's about the same as using a temp variable in the worst case (value not found), and shows bigger wins when the value is found in the list:

 

' Call this as USR Find(VARPTR table(0), length, value)
' Returns 1 through N if found, or 0 if not.
ASM FIND: PROC
ASM       MOVR R0, R4
ASM @@1:  CMP@ R4, R2
ASM       BEQ  @@2
ASM       DECR R1
ASM       BNEQ @@1
ASM       MOVR R0, R4
ASM @@2:  SUBR R0, R4
ASM       MOVR R4, R0
ASM       JR   R5
ASM       ENDP

' Usage example:

IF USR Find(VARPTR items(0), 6, #backtab(#pos_joueur)) > 0 THEN
  ' ... stuff ...
END IF

' Elsewhere, outside a Procedure:
items: DATA ECHELLE1, ECHELLE2, ECHELLE3
       DATA ECHELLE4, ECHELLE5, ECHELLE6

 

With that kind of helper, you could also start to use ON Find(...) GOTO or ON Find(...) GOSUB to do even fancier things.

  • Like 4
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...