Release - Some XB Applications

47 replies to this topic

#26 sometimes99erOFFLINE

sometimes99er

River Patroller

• 4,191 posts
• Location:Denmark

Posted Thu Jun 12, 2014 2:30 AM

Now, as am1933 alludes to in another thread, it's too bad plotting such graphs is not possible in pure BASIC.

Guess "pure BASIC" includes XB. Here's a little quick and dirty. Coordinate system is (0,0)-(63,47) starting in the top left corner of the screen. I guess it generally breaks if you go outside the limits. Source below.

```100 !CALL CLEAR
110 CALL SETUP
120 !*** DRAW AN ELLIPSE
130 FOR I=0 TO 3.14*2 STEP .04::CALL PLOT(COS(I)*30+32,SIN(I)*22+24)::NEXT I
140 !*** DRAW A LINE
150 FOR I=0 TO 63::CALL PLOT(I,I/64*48 )::NEXT I
160 END

800 !*** CREATE PLOT PATTERN CHARACTERS ***
810 SUB SETUP
820 S\$="00F00FFF"::FOR X2=0 TO 3::FOR X1=0 TO 3
830 CALL CHAR(128+X1+X2*4,RPT\$(SEG\$(S\$,X1*2+1,2),4)&RPT\$(SEG\$(S\$,X2*2+1,2),4))
840 NEXT X1::NEXT X2::SUBEND

900 !*** PLOT ROUTINE ***
910 SUB PLOT(X,Y)::CALL GCHAR(INT(Y/2+1),INT(X/2+1),G)
920 IF G<128 OR G>143 THEN G=128
930 G=128+((G AND 15)OR(((INT(X) AND 1)+1)*((INT(Y) AND 1)*3+1)))
940 CALL HCHAR(INT(Y/2+1),INT(X/2+1),G)::SUBEND
```

#27 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Thu Jun 12, 2014 2:54 AM

Very very clever.  Well, you've given me food for thought .   I think I might try and do something like this for the 3d Kinematics program - although it will have to be 2d projections, of course .

#28 sometimes99erOFFLINE

sometimes99er

River Patroller

• 4,191 posts
• Location:Denmark

Posted Thu Jun 12, 2014 3:45 AM

Tursi did a TI Basic High Resolution plot routine - which of course IIRC runs dry on characters - eventually.

#29 senior_falconONLINE

senior_falcon

Stargunner

• 1,336 posts
• Location:Lansing, NY, USA

Posted Thu Jun 12, 2014 7:15 AM

Don't overlook The Missing Link.  It gives you full bit mapped graphics, never runs short of characters, and is compatible with "real iron" (except for CF7)

#30 VorticonOFFLINE

Vorticon

River Patroller

• 3,495 posts
• Location:Eagan, MN, USA

Posted Thu Jun 12, 2014 8:10 AM

I've had the Decimal to Hex converter for some years, what would be nice is an EA5 version of it so it could be included on a utility cartridge.

Gazoo

Here's a version for the CC40 / TI74 I wrote in 2004 as a utility to support my coding of SkyChart.

It does interchangeable conversions between bin, hex and 2's complement. It also does conversions between float and Radix 100 (the internal representation of float numbers on the TI).

SkyChart required a large amount of heavy duty floating point calculations, and this little utility allowed me to easily verify the calculation results during the debugging phase

#31 TursiOFFLINE

Tursi

• 5,426 posts
• HarmlessLion
• Location:BUR

Posted Thu Jun 12, 2014 10:02 AM

Tursi did a TI Basic High Resolution plot routine - which of course IIRC runs dry on characters - eventually.

I like your 64x48 plot, though, that works really well!

#32 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Thu Jun 12, 2014 11:42 AM

Thank you sometimes and senior_falcon for the pointers.

Edit:  I just ran that example of yours sometimes - quite a big difference, the performance on Classic99 versus the real iron (no less cool, however ).

Edited by RobertLM78, Thu Jun 12, 2014 12:46 PM.

#33 sometimes99erOFFLINE

sometimes99er

River Patroller

• 4,191 posts
• Location:Denmark

Posted Thu Jun 12, 2014 3:37 PM

Here's another Decimal to Hexadecimal Converter. Also including the binary equivalent.

```100 PRINT
110 INPUT "DEC VAL: ":D
120 CALL CONVERT((D),16,"HEX VAL: ")
130 CALL CONVERT((D),2,"BIN VAL: ")
140 GOTO 100
200 SUB CONVERT(D,B,T\$)
210 R\$=""
220 C=D-INT(D/B)*B
230 IF C<10 THEN R\$=CHR\$(C+48)&R\$ ELSE R\$=CHR\$(C+55)&R\$
240 D=INT(D/B)::IF D>0 THEN 220
250 PRINT T\$;R\$
260 SUBEND
```

You can easily add any other base like octal.

```125 CALL CONVERT((D),8,"OCT VAL: ")
```

#34 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Thu Jun 12, 2014 3:55 PM

Very nice, and it does numbers greater than 6553510 which mine does not do (nevermind how much shorter it is  than mine ).

#35 RXBOFFLINE

RXB

River Patroller

• 3,460 posts
• Location:Vancouver, Washington, USA

Posted Thu Jun 12, 2014 5:32 PM

RXB

CALL HEX(number-variable,string-variable)

or

CALL HEX(string-variable,number-variable)

Differs as RXB needed conversion that always worked with CALL PEEK or CALL LOAD or CALL GPOKE or CALL GPEEK or CALL VPEEK or CALL VPOKE

So only accepts values from >0000 to >FFFF hex or -32768 to 32767 otherwise a XB program check would be needed in every program to make sure it did not crash the XB program.

Thus I built it into RXB. I think I copied a version into GPL that you posted.

#36 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Thu Jun 12, 2014 6:01 PM

RXB

CALL HEX(number-variable,string-variable)

or

CALL HEX(string-variable,number-variable)

Here's a quick and dirty conversion of my program for RXB (it lacks the binary conversion - but no biggie, that was always just a bonus):

```100 !********************
110 !***  DEC TO HEX  ***
120 !***   CONVERTER  ***
130 !**VERSION 1.0-RXB **
140 !***  BY R. LOCK  ***
150 !***  JUNE 2014   ***
160 !********************
170 ON WARNING NEXT
180 DIM T(16)
190 !*********************
200 !** BUILD 2^X ARRAY **
210 !*********************
220 CALL CLEAR
230 FOR E=0 TO 15
240 T(E)=2^E
250 NEXT E
260 CALL CHAR(128,"0000FFFF00000000")
270 !**********************
280 !*** COLORS/DISPLAY ***
290 !**********************
300 CALL SCREEN(5) :: CALL COLOR(0,5,1)
310 FOR CS=1 TO 12 :: CALL COLOR(CS,15,2) :: NEXT CS :: CALL COLOR(13,12,2)
320 DISPLAY AT(1,10):"DEC TO HEX" :: CALL HCHAR(2,12,128,10)
330 DISPLAY AT(5,1):"DEC VAL:"
340 DISPLAY AT(7,1):"HEX VAL:"
350 !DISPLAY AT(9,1):"BIN VAL:"
360 !**********************
370 !***  ACCEPT INPUT  ***
380 !**********************
390 ACCEPT AT(5,10) VALIDATE(NUMERIC) BEEP SIZE(6):DEC
400 IF LEN(STR\$(DEC))=0 THEN 390
410 IF DEC<-32768 OR DEC>32767 THEN 390
420 !*******************
430 !** CALCULATE HEX **
440 !*******************
450 CALL HEX(DEC,HX\$)
460 !*********************
470 !***  DISPLAY HEX  ***
480 !*********************
490 DISPLAY AT(7,10):HX\$
500 !DISPLAY AT(9,10):BT\$
510 DISPLAY AT(20,2):"PRESS ANY KEY TO CONTINUE"
520 CALL KEY(0,K,S) :: IF S=0 THEN 520
530 CALL HCHAR(7,11,32,12)
540 CALL HCHAR(9,11,32,18)
550 CALL HCHAR(20,1,32,32)
560 GOTO 390

```

#37 RXBOFFLINE

RXB

River Patroller

• 3,460 posts
• Location:Vancouver, Washington, USA

Posted Thu Jun 12, 2014 6:07 PM

Cool! Very cool, thanks.

Rich

#38 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Thu Jun 12, 2014 6:15 PM

Actually, there is code there that isn't even necessary any longer.  Try this on for size:

```100 !********************
110 !***  DEC TO HEX  ***
120 !***   CONVERTER  ***
130 !**VERSION 1.0-RXB **
140 !***  BY R. LOCK  ***
150 !***  JUNE 2014   ***
160 !********************
170 ON WARNING NEXT
190 CALL CLEAR
200 CALL CHAR(128,"0000FFFF00000000")
210 !**********************
220 !*** COLORS/DISPLAY ***
230 !**********************
240 CALL SCREEN(5) :: CALL COLOR(0,5,1)
250 FOR CS=1 TO 12 :: CALL COLOR(CS,15,2) :: NEXT CS :: CALL COLOR(13,12,2)
260 DISPLAY AT(1,10):"DEC TO HEX" :: CALL HCHAR(2,12,128,10)
270 DISPLAY AT(5,1):"DEC VAL:"
280 DISPLAY AT(7,1):"HEX VAL:"
290 !**********************
300 !***  ACCEPT INPUT  ***
310 !**********************
320 ACCEPT AT(5,10) VALIDATE(NUMERIC) BEEP SIZE(6):DEC
330 IF LEN(STR\$(DEC))=0 THEN 320
340 IF DEC<-32768 OR DEC>32767 THEN 320
350 !*******************
360 !** CALCULATE HEX **
370 !*******************
380 CALL HEX(DEC,HX\$)
390 !*********************
400 !***  DISPLAY HEX  ***
410 !*********************
420 DISPLAY AT(7,10):HX\$
430 DISPLAY AT(20,2):"PRESS ANY KEY TO CONTINUE"
440 CALL KEY(0,K,S) :: IF S=0 THEN 440
450 CALL HCHAR(7,11,32,12)
460 CALL HCHAR(9,11,32,18)
470 CALL HCHAR(20,1,32,32)
480 GOTO 320

```

I think that trims all the fat (other than the fancy display ).

Edited by RobertLM78, Thu Jun 12, 2014 6:15 PM.

#39 RXBOFFLINE

RXB

River Patroller

• 3,460 posts
• Location:Vancouver, Washington, USA

Posted Thu Jun 12, 2014 6:16 PM

Look good and compact. Thanks!

#40 senior_falconONLINE

senior_falcon

Stargunner

• 1,336 posts
• Location:Lansing, NY, USA

Posted Thu Jun 12, 2014 8:49 PM

Read the manual first, especially the first half or so.  Then try some stuff out, like drawing lines, plotting circles and points, putting text on the screen, etc.  With half a dozen lines you can reproduce the LINES program.  Once you feel comfortable with the basics, work your way through the tutorial.

#41 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Sat Jun 14, 2014 1:06 PM

Sometime's brilliant and highly clever use of a loop inspired me to to go back and see how I could be clean up some of my programs.  The result is two new versions of DECTOHEX and HEXTODEC, each half the previous size.  As there are many ways to skin a cat, particularly this cat, I decided to keep the mechanism of calculation I originally concocted.

Version 2.0
---------------------------------
Converts hex to decimal, from 0 to FFFF (0 to 65535). Also gives binary equivalent.
TIFILE:
https://dl.dropboxus...21622/HEXTODEC2
Text XB source file:
https://dl.dropboxus...EXTODEC-2.0-XBS

Version 2.0
---------------------------------
Converts decimal to hex, from 0 to 65535 (0 to FFFF). Also gives binary equivalent.
TIFILE:
https://dl.dropboxus...21622/DECTOHEX2
Text XB source file:
https://dl.dropboxus...ECTOHEX-2.0-XBS

Note that with a little arithmetic to the inputs/outputs, these can be used for two's complement (e.g. -3 => -3+65536=65533=FFFD16 ).

__________________________________________________________________________________________________________

@Senior_Falcon: A while back you had showed me a simple conversion program.  I was looking at it yesterday, and I couldn't get my head around part of it:

```10 INPUT DEC :: HEX\$="" :: BIN\$=""
20 IF DEC>0 AND DEC<32768 THEN 30 :: DEC=DEC-65536
30 TEMP=DEC*16 :: FOR I=1 TO 4 :: TEMP=INT(TEMP/16):: HEX\$=SEG\$("0123456789ABCDEF",1+(TEMP AND 15),1)&HEX\$ :: NEXT I
40 TEMP=DEC*2 :: FOR I=1 TO 16 :: TEMP=INT(TEMP/2):: BIN\$=SEG\$("01",1+(TEMP AND 1),1)&BIN\$ :: NEXT I
50 PRINT STR\$(DEC):HEX\$:BIN\$: : :
60 GOTO 10
```

This is generally pretty straightforward, with a couple exceptions.  how the heck are (TEMP AND 15) and (TEMP AND 1) evaluated?  I can't make sense of what it's testing, nor how it comes up with the numbers it comes up with.  Unfortunately documentation on 'AND' is pretty sparse - just a few pages in the XB manual, and those were used with 'IF' statements.

#42 Lee StewartONLINE

Lee Stewart

River Patroller

• 3,872 posts
• Location:Silver Run, Maryland

Posted Sat Jun 14, 2014 6:49 PM

This is generally pretty straightforward, with a couple exceptions.  how the heck are (TEMP AND 15) and (TEMP AND 1) evaluated?  I can't make sense of what it's testing, nor how it comes up with the numbers it comes up with.  Unfortunately documentation on 'AND' is pretty sparse - just a few pages in the XB manual, and those were used with 'IF' statements.

"AND" used in numerical expressions functions as a bitwise operator.  "INT(TEMP/16)" effectively shifts TEMP right 1 nybble (4bits), dropping the fraction.  "TEMP AND 15" picks off the rightmost nybble for further processing because 15d ≡ Fh ≡ 1111b.  This is stepping through the number by hexadecimal digits.  The same process is going on with the binary conversion, except that "INT(TEMP/2)" shifts the number right 1 bit (binary digit) at a time.  "TEMP AND 1" is picking off binary digits.

...lee

#43 senior_falconONLINE

senior_falcon

Stargunner

• 1,336 posts
• Location:Lansing, NY, USA

Posted Sat Jun 14, 2014 6:56 PM

What is used above is a logical AND.  To understand this you have to think in binary. For example, in converting decimal to binary, 7 AND 1 gives a value of 1.  7 is 0111 and 1 is 0001. The ones digit is the only digit that is 1 in both numbers, so the answer is 1.  8 AND 1 gives a value of 0.  8 is 1000 and 1 is 0001.  None of the digits is a 1 in both numbers, so the answer is 0.  The only possible values are 0 or 1 and after adding 1 the values can be 1 or 2.  The SEG\$ then concatenates a "0" or a "1" string with BIN\$ until all 16 bits have been evaluated.  In the hex conversion it is similar except that  4 nybbles are evaluated instead of 16 bits.

XB rounds the floating point number up or down when doing logical operations.  4.5 is evaluated as a 5, while 4.49 is evaluated as a 4. I used INT in the example above but it may not be necessary.

If you want to know if someone is a computer programmer, ask them how much 1 AND 3 is.  If they are a programmer they will say one.  If  not, they will say four.

Edited by senior_falcon, Sat Jun 14, 2014 6:58 PM.

#44 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Sat Jun 14, 2014 7:17 PM

<Click> Ah, I get it!  Thank you fellas .

#45 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Fri Jun 20, 2014 6:43 PM

Hello again 99ers!  Here is another program I just finished up (with a little help from ti99_forever and Willsy ).

This program combines the functions of DOTPROD and CRSPROD, in addition to performing vector sums, differences, and scalar multiples.  It can add/subtract/scalar-multiply as many as 3 vectors at once in up to 15 dimensions.

Enjoy!

Vector Math 1.0

--------------------
TIFILE:

https://dl.dropboxus.../95921622/VMATH

Text XB source file:

https://dl.dropboxus...2/VMATH-1.0-XBS

#46 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Fri Jul 4, 2014 1:48 AM

Here is a simple BASIC-based mini text editor for creating format- and CR-free, DIS/VAR 80 files.  The cool thing is it can be adopted for cassette (for those without disk systems), just by changing VARIABLE 80 to FIXED 80 and entering CS1 or CS1 for a filename.  (Of course, the DIS/FIX 80 format is useful, too ).

Mini-Editor 1.0

-------------------

TIFILE:

https://dl.dropboxus...5921622/MINI-ED

Text XB source file:

https://dl.dropboxus...622/MINI-ED-XBS

#47 VorticonOFFLINE

Vorticon

River Patroller

• 3,495 posts
• Location:Eagan, MN, USA

Posted Sun Jul 6, 2014 11:35 AM

Here is a simple BASIC-based mini text editor for creating format- and CR-free, DIS/VAR 80 files.  The cool thing is it can be adopted for cassette (for those without disk systems), just by changing VARIABLE 80 to FIXED 80 and entering CS1 or CS1 for a filename.  (Of course, the DIS/FIX 80 format is useful, too ).

This definitely comes in handy for some programming tasks

It reminded me of a very quirky text editor I wrote back in 1998 in XB, which used an 80 column text terminal attached to the TI's RS232 to allow 80 column full text editing. The main TI monitor would display settings and page info, while all the text processing was displayed on the serial terminal and you used the TI keyboard for text entry and commands. This was a time when corporations were moving away from text based software to GUI based ones, and they were dumping large quantities of text terminals into the wild at ridiculously low prices (I remember paying something like \$10 for a full featured Wang terminal), so I figured I'd make use of them. Besides, getting an 80-column TI system was nigh impossible or very expensive at that time, so it kind of made sense. Looking back, this was clunky at best, but it did look cool for a few minutes  I even got Charlie Good to review it in Micropendium!

I actually found the files in my archives, so I am attaching them as a curiosity, and if a brave soul decides to test it out, I forgot to mention in the docs that the terminal settings were 2400bps 8-N-1.

#48 RobertLM78 OFFLINE

RobertLM78

Stargunner

• Topic Starter
• 1,055 posts

Posted Sun Jul 6, 2014 2:20 PM

Hello again 99ers!  Here's a new program.  It will perform a simple linear regression from data you you either enter from the program, or load from a pre-existing DIS/VAR 80 file.  There were a couple hiccups and a few improvements later, but it works nicely.  Enjoy!

LINear-REGRESsion 1.0
---------------------------
TIFILE:
https://dl.dropboxus...1622/LIN-REGRES
Text XB source file:
https://dl.dropboxus...-REGRESsion-XBS

Zip Attached

0 user(s) are browsing this forum

0 members, 0 guests, 0 anonymous users