Jump to content
IGNORED

Converting from Sinclair BASIC


jonesypeter

Recommended Posts

I'm quite new to the TI, and just trying to convert some really simple Sinclair BASIC to get me used to TI BASIC.

 

This simple program moves a '+' character along the screen, and is the basis for quite a few BASIC magazine listings.

10 dim a$(32)
20 let a$(1)="+"
30 for a =32 to 1 step -1
40 print at 20,0;a$(A TO)+ a$(TO A-1)
50 NEXT A

For those not used to Sinclair BASIC A TO will display from position A in the string to the end, and To A-1 will display from the start to position A-1

 

The issue is that String functions in Sinclair BASIC go from start position to end position, and TI BASIC uses start position and number of characters. Having spent the afternoon trying, this is as far as I have got in extended BASIC. Any help, very much appreciated.

 

5 call clear
10 let a$="+                                       " (NOTE: 40 characters in total)
20 for a=40 to 1 step -1
30 let start$=SEG$(A$,a,40-a)
40 let end$=SEG$(A$,1,a-1)
50 display AT(0,0):start$;end$
60 next a

 

Edited by jonesypeter
Link to comment
Share on other sites

If I was going to move a + across the screen from left to right in TI BASIC on row 3, I would do it this way:

100 CALL CLEAR
110 R=3
120 FOR I=1 TO 32
130 CALL HCHAR(R,I,ASC(“+”))
140 CALL HCHAR(R,I,32)
150 NEXT I

In Extended BASIC, you could simplify it:

100 CALL CLEAR
110 FOR I=1 TO 28
120 DISPAY AT(3,I):”+”::DISPLAY AT(3,I):” “
130 NEXT I

One thing that isn’t obvious to a person new to the TI:  while the screen is 32 columns wide, PRINT and DISPLAY will only use the middle 28 columns, while CALL HCHAR can access all 32.  Column 1 for DISPLAY AT is the same as column 3 when used with CALL HCHAR.

  • Like 3
Link to comment
Share on other sites

6 minutes ago, Casey said:

If I was going to move a + across the screen from left to right in TI BASIC on row 3, I would do it this way:

In Extended BASIC, you could simplify it:

One thing that isn’t obvious to a person new to the TI:  while the screen is 32 columns wide, PRINT and DISPLAY will only use the middle 28 columns, while CALL HCHAR can access all 32.  Column 1 for DISPLAY AT is the same as column 3 when used with CALL HCHAR.

Thank you for pointing me in the right direction.  This works now.  Many Spectrum BASIC games use a string of User Defined Graphics to simulate movement. That information about the 28 columns when using Print is really useful.  The layout of the screen (in terms of 8x8 characters and one background and one foreground colour via BASIC is very similar to the Spectrum)

 

5 call clear
10 let a$="+                                       "  (total 28 characters)
20 for a=28 to 1 step -1
30 let start$=SEG$(A$,a,28-a)
40 let end$=SEG$(A$,1,a-1)
50 display AT(0,0):start$;end$
60 next a

 

 

Link to comment
Share on other sites

3 hours ago, jonesypeter said:

Thank you for pointing me in the right direction.  This works now.  Many Spectrum BASIC games use a string of User Defined Graphics to simulate movement. That information about the 28 columns when using Print is really useful.  The layout of the screen (in terms of 8x8 characters and one background and one foreground colour via BASIC is very similar to the Spectrum)

 


5 call clear
10 let a$="+                                       "  (total 28 characters)
20 for a=28 to 1 step -1
30 let start$=SEG$(A$,a,28-a)
40 let end$=SEG$(A$,1,a-1)
50 display AT(0,0):start$;end$
60 next a

 

 

I don't know if you have used sprites in the past. (requires Extended BASIC).

I came from using a ZX80 to a TI.  (Actually wrote a primitive shoot 'em up in BASIC.)

After learning about sprites, it was no contest. 

 

Try this if you are curious about sprites.

(Press any key at the end of the "DISPLAY AT" routine.)

 

100 CALL CLEAR
110 LET A$="+                          "
120 FOR A=28 TO 1 STEP -1
130 LET START$=SEG$(A$,A,28-A)
140 LET END$=SEG$(A$,1,A-1)
150 DISPLAY AT(0,0):START$;END$
160 NEXT A
170 CALL KEY(0,K,S):: IF S=0 THEN 170
180 CALL CLEAR
190 CALL SPRITE(#1,43,5,5,5)
200 FOR Q=1 TO 25
210 CALL LOCATE(#1,5,Q*10)
220 NEXT Q
230 FOR Q=25 TO 1 STEP -1
240 CALL LOCATE(#1,5,Q*10)
250 NEXT Q
260 GOTO 190

 

Fnct + "4"  to break the program.

 

 

  • Like 1
Link to comment
Share on other sites

Thank you @dgrissom

 

I will give that a go over the weekend.  Am I right in remembering the the graphics chip is like the one in the MSX and has the issue with knowing that a collision has taken place, but not with what?

 

I'm just starting to read this book from Compute:

 

https://archive.org/details/tibook_ti994a-sound-and-graphics

Edited by jonesypeter
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...