Jump to content
IGNORED

Release - Some XB Applications


RobertLM78

Recommended Posts

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.

 

plot.gif

 

 

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
  • Like 1
Link to comment
Share on other sites

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 :)

CONVERT.ZIP

Link to comment
Share on other sites

Thank you sometimes and senior_falcon for the pointers.

 

It's time to dig into The Missing Link, which I've had downloaded for a few months now. Should I start with the tutorial, or the manual first?

 

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 8)).

Edited by RobertLM78
Link to comment
Share on other sites

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: ")

dec2hex.gif

  • Like 1
Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

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

Link to comment
Share on other sites

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
Link to comment
Share on other sites

It's time to dig into The Missing Link, which I've had downloaded for a few months now. Should I start with the tutorial, or the manual first?

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.

  • Like 1
Link to comment
Share on other sites

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.

 

Hexadecimal to Decimal

Version 2.0
License: GPLv3
---------------------------------
Converts hex to decimal, from 0 to FFFF (0 to 65535). Also gives binary equivalent.
TIFILE:
https://dl.dropboxusercontent.com/u/95921622/HEXTODEC2
Text XB source file:
https://dl.dropboxusercontent.com/u/95921622/HEXTODEC-2.0-XBS

Decimal to Hexadecimal

Version 2.0
License: GPLv3
---------------------------------
Converts decimal to hex, from 0 to 65535 (0 to FFFF). Also gives binary equivalent.
TIFILE:
https://dl.dropboxusercontent.com/u/95921622/DECTOHEX2
Text XB source file:
https://dl.dropboxusercontent.com/u/95921622/DECTOHEX-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.

Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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
  • Like 1
Link to comment
Share on other sites

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! :D

 

Vector Math 1.0

License: GPLv3

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

https://dl.dropboxusercontent.com/u/95921622/VMATH

Text XB source file:

https://dl.dropboxusercontent.com/u/95921622/VMATH-1.0-XBS

Link to comment
Share on other sites

  • 2 weeks later...

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.dropboxusercontent.com/u/95921622/MINI-ED

Text XB source file:

https://dl.dropboxusercontent.com/u/95921622/MINI-ED-XBS

Link to comment
Share on other sites

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 :grin: 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.

Notepad80.zip

  • Like 1
Link to comment
Share on other sites

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!

 

LIN-REGRES.png

 

LINear-REGRESsion 1.0
License: GPLv3
---------------------------
TIFILE:
https://dl.dropboxusercontent.com/u/95921622/LIN-REGRES
Read Me:
https://dl.dropboxusercontent.com/u/95921622/LIN-REGRES-ReadMe
Text XB source file:
https://dl.dropboxusercontent.com/u/95921622/LINear-REGRESsion-XBS

 

Zip Attached

LIN-REGRESsion.zip

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