Author Topic: TI-58C calculator  (Read 3736 times)

0 Members and 1 Guest are viewing this topic.

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
TI-58C calculator
« on: January 31, 2019, 11:43:26 pm »
Code: QB64: [Select]
  1. _TITLE "TI-58C by rfrost@mail.com"
  2.  
  3. DEFINT A-Z
  4. DECLARE SUB DrawCalc ()
  5. DECLARE SUB Init ()
  6. DECLARE SUB Keyboard ()
  7. DECLARE SUB Learn ()
  8. DECLARE SUB MemOps ()
  9. DECLARE SUB Mouse ()
  10. DECLARE SUB NoPend ()
  11. DECLARE SUB NumDisp ()
  12. DECLARE SUB PlotNum (Text$)
  13. DECLARE SUB ProcessEquals ()
  14. DECLARE SUB ProcessKey ()
  15. DECLARE SUB ProcessTrig ()
  16. DECLARE SUB ColorSet ()
  17. DECLARE SUB ShowText (x, y, Text$, kolor)
  18. DECLARE SUB WriteProg ()
  19.  
  20. COMMON SHARED true, false, ddp
  21. COMMON SHARED black, white, yellow, redi, redd
  22. COMMON SHARED i$, lft, rgt, mkey$
  23. COMMON SHARED Num#, expo, dp&
  24. COMMON SHARED OperationPending, op$, MemOp$, Running, Prog
  25. COMMON SHARED LearnFlag, ProgPos
  26. COMMON SHARED y#, treg#, ShiftFlag, InvFlag, AngMode$, IsError
  27. COMMON SHARED pi#, ator#
  28. COMMON SHARED GetNum, GetNum$
  29. COMMON SHARED psize, msize
  30. COMMON SHARED minx, miny, maxx, maxy
  31. COMMON SHARED up, down, left, right
  32.  
  33. psize = 99: msize = 99
  34. DIM SHARED MemReg#(msize), ProgStep(psize), pat(255, 13), garr(999)
  35. DIM SHARED k$(100), kn(100), bx1(50), by1(50), bx2(50), by2(50)
  36. Init
  37.     Mouse
  38.     Keyboard
  39.     ProcessKey
  40.     IF Running AND Prog = 5 THEN Num# = Num# + 1: NumDisp
  41.    
  42. card:
  43. DATA "DOW, DAYS BETWEEN DATES",ML-20
  44. DATA (MMDD.YYYY),"","","",""
  45. DATA DATE1,DATE2,#Days,D>DOW,""
  46.  
  47. '      key  key color keycode keycode
  48. Keys:
  49. DATA "A","A'",0,11,16
  50. DATA "B","B'",0,12,17
  51. DATA "C","C'",0,13,18
  52. DATA "D","D'",0,14,19
  53. DATA "E","E'",0,15,20
  54.  
  55. DATA "2nd","",6,0,0
  56. DATA "INV","",0,22,0
  57. DATA "lnx","log",0,23,28
  58. DATA "CE","CP",0,24,29
  59. DATA "CLR","",6,25,0
  60.  
  61. DATA "LRN","Pgm",0,31,36
  62. DATA "xt","PR",0,32,37
  63. DATA "xý","sin",0,33,38
  64. DATA "ûx","cos",0,34,39
  65. DATA "1/x","tan",0,35,30
  66.  
  67. DATA "SST","Ins",0,41,45
  68. DATA "STO","CMs",0,42,46
  69. DATA "RCL","Exc",0,43,47
  70. DATA "SUM","Prd",0,44,48
  71. DATA "yx","Ind",0,45,49
  72.  
  73. DATA "BST","Del",0,51,55
  74. DATA "EE","Eng",0,52,56
  75. DATA "(","Fix",0,52,57
  76. DATA ")","Int",0,53,58
  77. DATA "ö","³x³",6,54,59
  78.  
  79. DATA "GTO","Pause",0,61,66
  80. DATA "7","x=t",15,7,67
  81. DATA "8","Nop",15,8,68
  82. DATA "9","Op",15,9,69
  83. DATA "x","Deg",6,65,70
  84.  
  85. DATA "SBR","Lbl",0,71,76
  86. DATA "4","xòt",15,4,77
  87. DATA "5","ä+",15,5,78
  88. DATA "6","x",15,6,79
  89. DATA "-","Rad",6,75,80
  90.  
  91. DATA "RST","St flg",0,81,86
  92. DATA "1","If flg",15,1,87
  93. DATA "2","D.MS",15,2,88
  94. DATA "3","ã",15,3,89
  95. DATA "+","Grad",6,85,90
  96.  
  97. DATA "R/S","",0,91,0
  98. DATA "0","Dsz",15,0,96
  99. DATA ".","Adv",15,93,97
  100. DATA "+/-","Prt",15,94,98
  101. DATA "=","Lst",6,95,99
  102.  
  103. DATA "RTN","",0,92,0
  104.  
  105. Logo:
  106. DATA ...XXX...X......
  107. DATA ...XXXX.........
  108. DATA ...XXXX..X.XXXXX
  109. DATA ...XXXX..X.XXXXX
  110. DATA ...XX....X....XX
  111. DATA ...XX....X....XX
  112. DATA XXXXXXX..X..XXXX
  113. DATA XXXXXXX..X..XXXX
  114. DATA .XXXXXX..X..XXX.
  115. DATA ..XXXXX..X..X...
  116. DATA ....XXX..X..X...
  117. DATA ......X.....X...
  118. DATA .......XXXXX....
  119. DATA ........XXXX....
  120. DATA .........XX.....
  121. DATA "end"
  122.  
  123. Prog:
  124. DATA 76,Lbl
  125. DATA 15,E
  126. DATA 85,+
  127. DATA 1,1
  128. DATA 66,Pause
  129. DATA 81,RST
  130. DATA 0,"end"
  131.  
  132. SUB ColorSet
  133.     black = 0
  134.     redi = 1
  135.     redd = 2
  136.     yellow = 6
  137.     white = 10
  138.     FOR i = 1 TO 15
  139.         IF i = yellow THEN
  140.             PALETTE i, 65536 * 20 + 256 * 30 + 40 ' yellow
  141.         ELSEIF i = redi THEN
  142.             PALETTE i, 65536 * 15 + 256 * 15 + 63 ' red intense
  143.         ELSEIF i = redd THEN
  144.             PALETTE i, 65536 * 5 + 256 * 5 + 13 ' red dim
  145.         ELSEIF i = white THEN
  146.             PALETTE i, 65536 * 35 + 256 * 35 + 35 ' white
  147.         END IF
  148.     NEXT i
  149.  
  150. SUB DrawCalc
  151.     CLS
  152.     ColorSet
  153.     LINE (177, 4)-(461, 475), white, B ' full machine
  154.     LINE (183, 30)-(456, 88), white, B ' number window
  155.     LINE (183, 88)-(456, 136), white, B ' card window
  156.     LINE (183, 104)-(456, 104), yellow ' card window
  157.     LINE (183, 119)-(456, 119), yellow ' card window
  158.  
  159.     LINE (183, 136)-(456, 470), yellow, B ' button window
  160.     LINE (185, 138)-(454, 468), yellow, B ' button window
  161.     PAINT (184, 140), yellow, yellow
  162.  
  163.     RESTORE Logo
  164.     bx = 190: x = bx
  165.     by = 10: y = by
  166.     DO
  167.         READ pat$
  168.         IF pat$ = "end" THEN EXIT DO
  169.         FOR t = 1 TO LEN(pat$)
  170.             IF MID$(pat$, t, 1) = "X" THEN PSET (x, y), white
  171.             x = x + 1
  172.         NEXT t
  173.         x = bx: y = y + 1
  174.     LOOP
  175.  
  176.     ShowText 225, 32, "Texas Instruments", black
  177.  
  178.     IF LearnFlag THEN
  179.         mkey$ = "xxx"
  180.         Learn
  181.     ELSE
  182.         NumDisp
  183.     END IF
  184.  
  185.     RESTORE card
  186.     READ Card1$: ShowText 206, 110, Card1$, -1
  187.     READ Card2$: ShowText 426, 110, Card2$, -1
  188.     FOR row = 1 TO 2
  189.         FOR col = 1 TO 5
  190.             READ Text$
  191.             IF Text$ = "D>DOW" THEN MID$(Text$, 2, 1) = CHR$(26)
  192.             x = (col - 1) * 54 + 208
  193.             y = (row - 1) * 16 + 140
  194.             z = 31
  195.             IF (Card2$ = "ML-20") AND (col = 1) THEN
  196.                 LINE (x + z, 119)-(x + z, 136), yellow
  197.             ELSEIF col < 5 THEN
  198.                 LINE (x + z, 104)-(x + z, 136), yellow
  199.             END IF
  200.             ShowText x, y - 14, Text$, -1
  201.         NEXT col
  202.     NEXT row
  203.  
  204.     RESTORE Keys
  205.     kn = 0
  206.     FOR row = 1 TO 9
  207.         FOR col = 1 TO 5
  208.             kn = kn + 1
  209.             READ k$(kn), k$(kn + 50), kolor, kn(kn), kn(kn + 50)
  210.             IF kolor = 6 THEN kolor = yellow
  211.             IF kolor = 15 THEN kolor = white
  212.             IF k$(kn + 50) = "PR" THEN k$(kn + 50) = "P" + CHR$(26) + "R"
  213.             x = (col - 1) * 54 + 208
  214.             y = (row - 1) * 34 + 180
  215.             ShowText x, y - 15, k$(kn + 50), -1
  216.             IF kolor = 0 THEN
  217.                 LINE (x - 13, y - 21)-(x + 21, y - 7), white, B
  218.             ELSE
  219.                 LINE (x - 13, y - 21)-(x + 21, y - 7), kolor, BF
  220.             END IF
  221.             bx1(kn) = x - 13: bx2(kn) = x + 21
  222.             by1(kn) = y - 21: by2(kn) = y - 7
  223.             ShowText x, y, k$(kn), kolor
  224.         NEXT col
  225.     NEXT row
  226.     kn = kn + 1
  227.     READ k$(kn), k$(kn + 50), kolor, kn(kn), kn(kn + 50)
  228.     ShowText 311, 471, "TI Programmable 58C", -1
  229.  
  230. SUB Init
  231.     CLS
  232.     true = -1
  233.     false = 0
  234.  
  235.     noise = true
  236.     pi# = ATN(1) * 4
  237.     ator# = ATN(1) / 45
  238.     AngMode$ = "D"
  239.  
  240.     s& = VARSEG(pat(0, 0))
  241.     o& = VARPTR(pat(0, 0))
  242.     DEF SEG = s&
  243.     BLOAD "font.dat", o&
  244.  
  245.     SCREEN 12 ' 640*480*16
  246.     minx = 196: maxx = 444
  247.     miny = 161: maxy = 444
  248.     msx = 334: msy = 234
  249.     DrawCalc
  250.  
  251.     psize = 99
  252.     OPEN "prog.txt" FOR APPEND AS #1
  253.     CLOSE #1
  254.     GetProg:
  255.     OPEN "prog.txt" FOR INPUT AS #1
  256.     IF EOF(1) THEN
  257.         CLOSE #1
  258.         RESTORE Prog
  259.         DO
  260.             READ ProgStep, Prog$
  261.             IF Prog$ = "end" THEN EXIT DO
  262.             ProgStep(ProgPos) = ProgStep
  263.             ProgPos = ProgPos + 1
  264.         LOOP
  265.         WriteProg
  266.         GOTO GetProg
  267.     ELSE
  268.         ProgPos = 0
  269.         WHILE NOT (EOF(1))
  270.             INPUT #1, pstep$
  271.             IF LEFT$(pstep$, 1) = "M" THEN
  272.                 INPUT #1, MemReg$, memval$
  273.                 MemReg#(VAL(MemReg$)) = VAL(memval$)
  274.             ELSE
  275.                 INPUT #1, pcode$, palph$
  276.                 ProgStep(ProgPos) = VAL(pcode$)
  277.                 ProgPos = ProgPos + 1
  278.             END IF
  279.         WEND
  280.     END IF
  281.     CLOSE #1
  282.     ProgPos = 0
  283.     dp& = 1
  284.     up = 72: down = 80: left = 75: right = 77
  285.  
  286. SUB Keyboard
  287.     IF mkey$ > "" THEN
  288.         i$ = mkey$
  289.         IF i$ = "CLR" THEN i$ = "c"
  290.         mkey$ = ""
  291.         IF noise THEN SOUND 3000, 1
  292.     ELSE
  293.         i$ = INKEY$
  294.         IF i$ = "s" THEN noise = noise XOR 1
  295.         IF noise AND LEN(i$) THEN SOUND 3000, 1
  296.     END IF
  297.  
  298. SUB Learn
  299.     IF mkey$ = "Del" THEN
  300.         FOR t = ProgPos TO psize - 1
  301.             ProgStep(t) = ProgStep(t + 1)
  302.         NEXT t
  303.         ProgStep(psize) = 0
  304.         mkey$ = ""
  305.     END IF
  306.  
  307.     IF mkey$ = "Ins" THEN
  308.         FOR t = psize TO ProgPos + 1 STEP -1
  309.             ProgStep(t) = ProgStep(t - 1)
  310.         NEXT t
  311.         ProgStep(ProgPos) = 0
  312.         mkey$ = ""
  313.     END IF
  314.  
  315.     IF mkey$ > "" THEN
  316.         FOR t = 1 TO 100
  317.             IF mkey$ = k$(t) THEN
  318.                 ProgStep(ProgPos) = kn(t)
  319.                 ProgPos = ProgPos + 1
  320.                 IF ProgPos > psize THEN
  321.                     ProgPos = psize
  322.                     LearnFlag = false
  323.                 END IF
  324.                 EXIT FOR
  325.             END IF
  326.         NEXT t
  327.     END IF
  328.  
  329.     Text$ = SPACE$(7) + RIGHT$("00" + LTRIM$(STR$(ProgPos)), 3) + " "
  330.     Text$ = Text$ + RIGHT$("00" + LTRIM$(STR$(ProgStep(ProgPos))), 2)
  331.     IF mkey$ > "" THEN PlotNum Text$
  332.     mkey$ = ""
  333.  
  334. SUB MemOps
  335.     MemReg = VAL(GetNum$)
  336.     SELECT CASE MemOp$
  337.         CASE IS = "STO"
  338.             MemReg#(MemReg) = Num#
  339.         CASE IS = "RCL"
  340.             Num# = MemReg#(MemReg)
  341.         CASE IS = "SUM"
  342.             MemReg#(MemReg) = MemReg#(MemReg) + Num#
  343.         CASE IS = "Exc"
  344.             SWAP MemReg#(MemReg), Num#
  345.         CASE IS = "Prd"
  346.             MemReg#(MemReg) = MemReg#(MemReg) * Num#
  347.     END SELECT
  348.     MemOp$ = ""
  349.     NumDisp
  350.     OperationPending = true
  351.  
  352. SUB Mouse
  353.         mx = _MOUSEX
  354.         my = _MOUSEY
  355.         lft = _MOUSEBUTTON(1)
  356.         rgt = _MOUSEBUTTON(2)
  357.     LOOP
  358.     msx = mx: msy = my
  359.  
  360.     IF NOT (lft OR rgt) THEN EXIT SUB
  361.  
  362.     FOR t = 1 TO 50
  363.         hitx = (mx > bx1(t)) AND (mx < bx2(t))
  364.         hity = (my > by1(t)) AND (my < by2(t))
  365.         IF hitx AND hity THEN
  366.             GET (bx1(t), by1(t))-(bx2(t), by2(t)), garr()
  367.             LINE (bx1(t), by1(t))-(bx2(t), by2(t)), 15, B
  368.             IF lft OR rgt THEN mkey$ = k$(t - ShiftFlag * 50)
  369.             ShiftFlag = 0
  370.             _DELAY .2
  371.             PUT (bx1(t), by1(t)), garr(), PSET
  372.             EXIT FOR
  373.         END IF
  374.     NEXT t
  375.  
  376.     IF Running AND (mkey$ <> "R/S") THEN mkey$ = "": EXIT SUB
  377.     IF mkey$ = "BST" THEN ProgPos = ProgPos - 1 - (ProgPos = 0): mkey$ = "xxx"
  378.     IF mkey$ = "SST" THEN
  379.         ProgPos = ProgPos + 1
  380.         IF ProgPos > psize THEN
  381.             ProgPos = psize
  382.             mkey$ = "LRN"
  383.         ELSE
  384.             mkey$ = "xxx"
  385.         END IF
  386.     END IF
  387.     IF mkey$ = "LRN" THEN LearnFlag = NOT (LearnFlag): mkey$ = " "
  388.     IF LearnFlag THEN Learn: EXIT SUB
  389.     IF mkey$ = "RST" THEN ProgPos = 0: mkey$ = ""
  390.     IF mkey$ = "GTO" THEN GetNum = 3: mkey$ = ""
  391.     IF mkey$ = "R/S" THEN Running = NOT (Running): OperationPending = true
  392.     IF mkey$ = "E" THEN Prog = 5: Running = true
  393.     IF mkey$ = "2nd" THEN ShiftFlag = true
  394.     IF mkey$ = "INV" THEN InvFlag = true
  395.     IF mkey$ = "log" THEN
  396.         IF InvFlag THEN
  397.             IsError = true
  398.             InvFlag = false
  399.         ELSE
  400.             Num# = LOG(Num#) / LOG(10): NoPend
  401.         END IF
  402.     END IF
  403.     IF mkey$ = "lnx" THEN
  404.         IF InvFlag THEN
  405.             IsError = true
  406.             InvFlag = false
  407.         ELSE
  408.             Num# = LOG(Num#): NoPend
  409.         END IF
  410.     END IF
  411.     IF mkey$ = "CE" THEN Num# = 0: ShiftFlag = false: InvFlag = false
  412.     IF mkey$ = "xt" THEN SWAP treg#, Num#: NoPend
  413.     IF mkey$ = "xý" THEN Num# = Num# * Num#: NoPend
  414.     IF LEN(mkey$) = 3 THEN
  415.         IF INSTR("STO RCL SUM Exc Prd", mkey$) > 0 THEN MemOp$ = mkey$: GetNum = 2
  416.         IF INSTR("SIN COS TAN", UCASE$(mkey$)) > 0 THEN ProcessTrig
  417.     END IF
  418.     IF mkey$ = "ûx" THEN Num# = SQR(Num#): NoPend
  419.     IF mkey$ = "1/x" THEN Num# = 1 / Num#: NoPend
  420.     IF mkey$ = "Int" THEN Num# = FIX(Num#): NoPend
  421.     IF mkey$ = "CMs" THEN
  422.         FOR MemReg = 0 TO 99
  423.             MemReg#(MemReg) = 0
  424.         NEXT MemReg
  425.     END IF
  426.     IF mkey$ = "yx" THEN
  427.         IF y# = 0 THEN
  428.             y# = Num#
  429.             op$ = "^"
  430.             OperationPending = true
  431.         END IF
  432.     END IF
  433.     IF mkey$ = "³x³" THEN Num# = ABS(Num#): NoPend
  434.     IF mkey$ = "Deg" THEN AngMode$ = "D": NoPend
  435.     IF mkey$ = "Rad" THEN AngMode$ = "R": NoPend
  436.     IF mkey$ = "Grad" THEN AngMode$ = "Grad": NoPend
  437.     IF mkey$ = "ã" THEN Num# = pi#: NoPend
  438.     IF mkey$ = "+/-" THEN Num# = -(Num#): NoPend
  439.  
  440. SUB NoPend
  441.     mkey$ = "="
  442.     InvFlag = false
  443.     ShiftFlag = false
  444.  
  445. SUB NumDisp
  446.     expo = 0
  447.     exp$ = SPACE$(3)
  448.  
  449.     IF Num# = INT(Num#) THEN
  450.         Num$ = RIGHT$(SPACE$(10) + STR$(Num#), 10)
  451.         ddp = 0
  452.     ELSE
  453.         Num$ = LTRIM$(STR$(Num#))
  454.         IF LEFT$(Num$, 1) = "." THEN Num$ = "0" + Num$
  455.         IF LEN(Num$) > 11 THEN Num$ = LEFT$(Num$, 11)
  456.         WHILE LEN(Num$) < 11
  457.             Num$ = " " + Num$
  458.         WEND
  459.         ddp = INSTR(Num$, ".")
  460.         Num$ = LEFT$(Num$, ddp - 1) + RIGHT$(Num$, LEN(Num$) - ddp)
  461.     END IF
  462.     GOTO woof
  463.  
  464.     Num$ = LTRIM$(STR$(Num#))
  465.     IF (Num# > 0) AND (Num# < .000000001#) THEN
  466.         tnum# = Num#
  467.         WHILE tnum# < 1
  468.             tnum# = tnum# * 10
  469.             expo = expo + 1
  470.         WEND
  471.         Num$ = RIGHT$(SPACE$(10) + STR$(tnum#), 10)
  472.         IF expo > 0 THEN exp$ = "-" + RIGHT$("00" + LTRIM$(STR$(expo)), 2)
  473.     ELSEIF Num# > 9999999999# THEN
  474.         tnum# = Num#
  475.         WHILE tnum# > 10
  476.             tnum# = tnum# / 10
  477.             expo = expo + 1
  478.         WEND
  479.         Num$ = RIGHT$(SPACE$(10) + STR$(tnum#), 10)
  480.         IF expo > 0 THEN exp$ = " " + RIGHT$("00" + LTRIM$(STR$(expo)), 2)
  481.     ELSE
  482.         IF LEN(Num$) > 10 THEN
  483.             Num$ = LEFT$(Num$, 10)
  484.         ELSE
  485.             Num$ = RIGHT$(SPACE$(10) + STR$(Num#), 10)
  486.         END IF
  487.     END IF
  488.  
  489.     woof:
  490.     IF expo > 99 THEN IsError = true
  491.     Text$ = Num$ + exp$
  492.     Text$ = RIGHT$(SPACE$(13) + Text$, 13)
  493.     IF IsError THEN Text$ = "         E   "
  494.     PlotNum Text$
  495.  
  496. SUB PlotNum (Text$)
  497.     LINE (184, 31)-(455, 87), black, BF ' erase number window
  498.     LINE (183, 30)-(456, 88), white, B ' number window
  499.  
  500.     FOR i = 1 TO LEN(Text$)
  501.         a = ASC(MID$(Text$, i, 1))
  502.         dx = 196 + i * 18
  503.         dy = 48
  504.         FOR byte = 1 TO 10
  505.             LINE (dx, dy)-(dx + 7, dy), redi, , pat(a, byte) * 128
  506.             dy = dy + 2
  507.         NEXT byte
  508.     NEXT i
  509.  
  510.     IF NOT (LearnFlag) AND (ddp > 0) THEN
  511.         dx = 188 + ddp * 18
  512.         dy = 65
  513.         LINE (dx, dy)-(dx + 1, dy + 1), redi, BF
  514.     END IF
  515.  
  516. SUB ProcessEquals
  517.     SELECT CASE op$
  518.         CASE IS = "+"
  519.             Num# = y# + Num#
  520.         CASE IS = "-"
  521.             Num# = y# - Num#
  522.         CASE IS = "*"
  523.             Num# = y# * Num#
  524.         CASE IS = "x"
  525.             Num# = y# * Num#
  526.         CASE IS = "ö"
  527.             Num# = y# / Num#
  528.         CASE IS = "/"
  529.             Num# = y# / Num#
  530.         CASE IS = "^"
  531.             Num# = y# ^ Num#
  532.             y# = 0
  533.     END SELECT
  534.     op$ = ""
  535.  
  536. SUB ProcessKey
  537.     IF LEN(i$) = 0 THEN EXIT SUB
  538.     IF i$ = CHR$(27) THEN WriteProg: SYSTEM
  539.     IF LearnFlag THEN EXIT SUB
  540.     IF INSTR(".0123456789", i$) > 0 THEN
  541.         IF (GetNum > 0) AND (i$ <> ".") THEN
  542.             GetNum$ = GetNum$ + i$
  543.             IF LEN(GetNum$) = GetNum THEN
  544.                 GetNum = 0
  545.                 IF LEN(MemOp$) > 0 THEN
  546.                     MemOps
  547.                 ELSE
  548.                     NewPos = VAL(GetNum$)
  549.                     IF NewPos <= psize THEN ProgPos = NewPos
  550.                 END IF
  551.                 GetNum$ = ""
  552.             END IF
  553.             EXIT SUB
  554.         END IF
  555.         IF OperationPending THEN
  556.             Num# = 0
  557.             dp& = 1
  558.             OperationPending = false
  559.         END IF
  560.         IF i$ = "." THEN
  561.             IF dp& = 1 THEN dp& = 10
  562.         ELSE
  563.             IF dp& > 1 THEN
  564.                 log10 = LOG(dp&) / LOG(10)
  565.                 IF log10 < 9 THEN
  566.                     Num# = Num# + VAL(i$) / dp&
  567.                     dp& = dp& * 10
  568.                 END IF
  569.             ELSE
  570.                 IF Num# < 1000000000 THEN Num# = Num# * 10 + VAL(i$)
  571.             END IF
  572.         END IF
  573.     END IF
  574.  
  575.     IF i$ = CHR$(8) THEN ' backspace
  576.         IF dp& > 1 THEN
  577.             tdp& = dp& \ 10
  578.             tnum& = Num# * tdp&
  579.             Num# = tnum& / tdp&
  580.             dp& = dp& \ 10
  581.         ELSE
  582.             Num# = Num# \ 10
  583.         END IF
  584.     END IF
  585.  
  586.     IF i$ = "c" THEN ' clear
  587.         IsError = false
  588.         ShiftFlag = false
  589.         InvFlag = false
  590.         OperationPending = false
  591.         MemOp$ = ""
  592.         op$ = ""
  593.         y# = 0
  594.         Num# = 0
  595.         dp& = 1
  596.     END IF
  597.  
  598.     IF INSTR("öx+-/*", i$) > 0 THEN ' operation
  599.         IF op$ <> "" THEN ProcessEquals
  600.         op$ = i$
  601.         y# = Num#
  602.         OperationPending = true
  603.     END IF
  604.  
  605.     IF i$ = CHR$(13) THEN i$ = "="
  606.     IF i$ = "=" THEN
  607.         ProcessEquals
  608.         OperationPending = true
  609.         y# = 0
  610.     END IF
  611.  
  612.     NumDisp
  613.  
  614. SUB ProcessTrig
  615.     IF AngMode$ = "G" THEN IsError = true
  616.     IF InvFlag THEN
  617.         IF mkey$ = "sin" THEN IsError = true
  618.         IF mkey$ = "cos" THEN IsError = true
  619.         IF mkey$ = "tan" THEN Num# = ATN(Num#)
  620.         InvFlag = false
  621.     ELSE
  622.         IF AngMode$ = "D" THEN Num# = Num# * ator#
  623.         IF mkey$ = "sin" THEN Num# = SIN(Num#)
  624.         IF mkey$ = "cos" THEN Num# = COS(Num#)
  625.         IF mkey$ = "tan" THEN Num# = TAN(Num#)
  626.     END IF
  627.     mkey$ = "="
  628.  
  629. SUB ShowText (x, y, Text$, kolor)
  630.     Text$ = LTRIM$(RTRIM$(Text$))
  631.     lt = LEN(Text$)
  632.     xb = -16 - (lt = 1) * 16 - (lt = 2) * 12 - (lt = 3) * 7 - (lt = 4) * 4
  633.     IF RIGHT$(Text$, 1) = "'" THEN xb = xb + 4
  634.     yb = -8
  635.     IF Text$ = "yx" THEN yb = -10
  636.     IF Text$ = "." THEN yb = -12: xb = xb - 1
  637.     FOR byte = 0 TO 13
  638.         ty = yb + (y - 12) + byte + ((Text$ = "yx") AND (i = 2)) * 2
  639.         FOR i = 1 TO LEN(Text$)
  640.             tx = xb + x + (i - 1) * 8
  641.             a = ASC(MID$(Text$, i, 1))
  642.             IF kolor = -1 THEN
  643.                 co = yellow
  644.             ELSEIF kolor = black THEN
  645.                 co = white
  646.             ELSE
  647.                 co = black
  648.             END IF
  649.             LINE (tx, ty)-(tx + 7, ty), co, , pat(a, byte) * 128
  650.         NEXT i
  651.     NEXT byte
  652.  
  653.     IF (Text$ = "x") AND (kolor = -1) THEN ' x bar
  654.         LINE (x + xb, y - 20)-(x + xb + 8, y - 20), yellow
  655.     END IF
  656.     IF Text$ = "ûx" THEN ' square root
  657.         LINE (x + xb, y - 20)-(x + xb + 8, y - 20), black
  658.         LINE (x + xb + 5, y - 19)-(x + xb + 15, y - 19), white
  659.     END IF
  660.     IF Text$ = "³x³" THEN ' abs
  661.         LINE (x + xb, y - 20)-(x + xb + 25, y - 20), black
  662.         LINE (x + xb, y - 19)-(x + xb + 25, y - 19), black
  663.         LINE (x + xb, y - 7)-(x + xb + 25, y - 7), black
  664.     END IF
  665.  
  666. SUB WriteProg
  667.     OPEN "prog.txt" FOR OUTPUT AS #1
  668.     FOR t = 0 TO psize ' program
  669.         pstep$ = RIGHT$("000" + LTRIM$(STR$(t)), 3)
  670.         pcode$ = RIGHT$("00" + LTRIM$(STR$(ProgStep(t))), 2)
  671.         palph$ = "0"
  672.         FOR i = 0 TO 100
  673.             IF kn(i) = ProgStep(t) THEN
  674.                 palph$ = k$(i)
  675.                 EXIT FOR
  676.             END IF
  677.         NEXT i
  678.         IF LEN(palph$) = 0 THEN palph$ = "0"
  679.         PRINT #1, pstep$; ","; pcode$; ","; palph$
  680.     NEXT t
  681.     FOR t = 0 TO msize ' memory
  682.         pstep$ = "M"
  683.         pcode$ = RIGHT$("00" + LTRIM$(STR$(t)), 2)
  684.         palph$ = LTRIM$(STR$(MemReg#(t)))
  685.         PRINT #1, pstep$; ","; pcode$; ","; palph$
  686.     NEXT t
  687.     CLOSE #1
  688.  
  689.  
* FONT.DAT (Filesize: 7.01 KB, Downloads: 207)
« Last Edit: March 02, 2020, 12:21:07 am by Richard Frost »
It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: TI-58C calculator
« Reply #1 on: February 01, 2019, 12:13:12 am »
Looks nice!
TI-58C.PNG
* TI-58C.PNG (Filesize: 20.03 KB, Dimensions: 643x511, Views: 235)
« Last Edit: February 01, 2019, 02:45:31 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: TI-58C calculator
« Reply #2 on: February 01, 2019, 02:20:25 am »
Found the code tag thing by chance, then scrolled down and saw it pointed out for me.  Duh!

This code has undergone one update/replacement already - killed a font that was in DATA statements in favor of BLOADing it. 
I'd like to use _PRINTSTRING, but I have to expand the font in the vertical direction for the number display.

It works better if you plug it in.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: TI-58C calculator
« Reply #3 on: February 01, 2019, 09:44:17 am »
This might be good link to manual (not secure), unless Richard has better?
http://83.156.189.247/ti58c/download/doc/LRNen.pdf

Dang! can't save a program? Can you emulate a printout from calculator?

Following the first steps in programming manual above, looks like the keys aren't all working yet.

The program clear function doesn't seem to be, nor picking up 2nd and the PI in program. SST and BST look OK.

Nope, Lst not working either, eh?

This is cool and ambitious project of course it will take awhile to get right.
« Last Edit: February 01, 2019, 02:49:24 pm by bplus »

Offline Richard Frost

  • Seasoned Forum Regular
  • Posts: 316
  • Needle nardle noo. - Peter Sellers
    • View Profile
Re: TI-58C calculator
« Reply #4 on: February 01, 2019, 04:13:42 pm »
True, I didn't take the simulation all the way to the end.   The program that's in there, under label E, works.
The E for Error thing is wonky - getting some weird INF (infinity) display beyond 10^99 too.....
It works better if you plug it in.