Advertisement
Guest User

Untitled

a guest
Feb 13th, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "ti83plus.inc"
  2. .org $9D93
  3. .db t2ByteTok,tAsmCmp
  4.     ld (8000h),sp ; This stores the stack pointer to spsave... for later dark ritual.
  5.     bcall(_RclAns)
  6.     dec a
  7.     ret nz ;quit if answer is non-list
  8.     ex de,hl
  9.     ld b,(hl)
  10.     inc hl
  11.     cp (hl)
  12.     ret nz
  13.     inc hl ; grabbed list size in b
  14.     ld a,b ;our list needs to be either 4 or 6 elements
  15.     cp 4
  16.     jr z,Pass
  17.     cp 6
  18.     ret nz
  19. Pass:  
  20.     ld ix,cX ;apparently I do need ix here because my HL DE BCs are used a lot
  21. loopbtimes:
  22.     push bc
  23.     rst 20h ;rMov9ToOP1
  24.     push hl
  25.     bcall(_ConvOP1)
  26.     pop hl
  27.     ld (ix),a
  28.     inc ix
  29.     pop bc
  30.     djnz loopbtimes
  31.     ;bcall(_ClrLCDFull)
  32.     call Resetrect
  33.     ld hl,StringData
  34.     rst 20h
  35.     rst 10h ;rFindSym
  36.     ret c ;quit if string is not found
  37.     ex de,hl
  38.     ld c,(hl) ;grab string size
  39.     inc hl
  40.     ld b,(hl)
  41.     inc hl
  42. loop:
  43.     ld a,(hl)   ;Need to check if it is a two-byte token, later
  44.     push af   ;Save A for later
  45.     push hl
  46.     push bc
  47.     bcall(_Get_Tok_Strng)
  48.     ld hl,op3-1    ;point to the byte *before* the output characters.
  49.     push hl
  50.     inc hl
  51.     ld a,(hl)
  52.     cp 1bh ;check if string is Exponent E. E = original 8 delay
  53.     pop hl
  54.     jr nz,notDelay1 ;skip if not
  55.     ld a,8
  56.     ld (Delay),a
  57.     pop bc
  58.     pop hl
  59.     pop af
  60.     jr +_
  61. NotDelay1:
  62.     push hl
  63.     inc hl
  64.     ld a,(hl)
  65.     cp 11h ;check if string is  -1. -1 = 16 Delay
  66.     pop hl
  67.     jr nz,notDelay2 ;skip if not
  68.     ld a,16
  69.     ld (Delay),a
  70.     pop bc
  71.     pop hl
  72.     pop af
  73.     jr +_
  74. NotDelay2:
  75.     push hl
  76.     inc hl
  77.     ld a,(hl)
  78.     cp 12h ;check if string is ^2. ^2 = slowest 32
  79.     pop hl
  80.     jr nz,notDelay3 ;skip if not
  81.     ld a,32
  82.     ld (Delay),a
  83.     pop bc
  84.     pop hl
  85.     pop af
  86.     jr +_
  87. NotDelay3:
  88.     push hl
  89.     inc hl
  90.     ld a,(hl)
  91.     cp 14h ;check if string is degree sign. deg = newline
  92.     pop hl
  93.     jr nz,notdegree ;skip if not degree sign
  94.     call Resetcur
  95.     pop bc
  96.     pop hl
  97.     pop af
  98.     jr +_
  99. notdegree:
  100.     push hl
  101.     inc hl
  102.     ld a,(hl)
  103.     cp 15h ;check if string is radian sign. rad = resetrect
  104.     pop hl
  105.     jr nz,tokenloop ;skip if not radian sign
  106.     call NextPageKey
  107.     call Resetrect
  108.     pop bc
  109.     pop hl
  110.     pop af
  111.     jr +_
  112. tokenloop:
  113.     push hl     ;save HL
  114.     push bc    ;and BC
  115.     call CheckXPos
  116.     pop bc
  117.     pop hl
  118.     inc hl   ;Need to increment first to get to the character since we started one byte behind
  119.     ld a,(hl)
  120.     bcall(_VPutMap)
  121.     push bc
  122.     ei
  123.     ld a,(Delay)
  124.     ld b,a
  125.     ld a,(843Fh)
  126.     ld c,a
  127.     ld a,(SkipKey)
  128.     cp c
  129.     jr nz,PauseTime
  130.     srl b
  131. PauseTime:
  132.     call Waith
  133.     djnz PauseTime
  134.     pop bc
  135.     dec c
  136.     jr nz,tokenloop
  137.     pop bc
  138.     pop hl
  139.     pop af
  140.     bcall(_IsA2ByteTok) ;Check if it was a 2 byte token
  141.     jr nz,+_
  142.     inc hl  ;increment hl for next calc since token was 2 bytes
  143.     dec bc  ;decrement bc since token was 2 bytes
  144. _:
  145.     cpi
  146.     jp pe,loop  ; pe is used to test if BC reached 0.
  147.     call NextPageKey
  148.     ret
  149. Waith:
  150.     ei
  151.     halt
  152.     bit onInterrupt,(iy+onFlags)
  153.     ret z
  154. HardExit:
  155.     ld sp,(8000h)
  156.     ret
  157. NextPageKey:
  158.     ld a,(NPKey)
  159.     ld c,a
  160. Sub1:
  161.     call Waith
  162.     ld a,(843Fh)
  163.     cp c
  164.     jr nz,Sub1
  165.     ret
  166. CheckXPos:
  167.     ld (hl),1 ; Put size byte. This string should always be 1 byte long.
  168.     bcall(_SStringLength) ;This destroys all but HL
  169.     ld a,(penCol)
  170.     add a,b ; Grab the future penCol position
  171.     ld b,a
  172.     dec b
  173.     dec b
  174.     ld a,(mX)
  175.     cp b
  176.     ret nc
  177. Resetcur:
  178.     ld a,(cX)
  179.     inc a ;if pencol > mX, change the cursor position
  180.     inc a ;to next line before writing
  181.     ld (penCol),a
  182.     ld a,(penRow)
  183.     add a,6
  184.     ld (penRow),a
  185.     ld b,a ;check the YPos
  186.     ld a,(mY)
  187.     sub 6
  188.     cp b ; test if penRow > mY
  189.     ret nc ; skip if penRow <= mY
  190.     call NextPageKey
  191.     call Resetrect
  192.     ret
  193. Resetrect:
  194.     push hl;Long push list yeah but I'll remove some
  195.     push de;when I see that I don't need to save them
  196.     push bc;later on when I code more
  197.     push af;
  198.     ld a,(cX)
  199.     ld l,a ;start setting rect boundary
  200.     ld a,(cY)
  201.     ld h,a
  202.     ld a,(cX)
  203.     inc a
  204.     inc a
  205.     ld (penCol),a ;set cursor column
  206.     dec a
  207.     dec a
  208.     ld d,a
  209.     ld a,(width)
  210.     ld b,a
  211.     ld a,d
  212.     add a,b
  213.     dec a
  214.     ld e,a
  215.     dec a
  216.     dec a
  217.     ld (mX),a ;set max c-length for x
  218.     ld a,(cY)
  219.     inc a
  220.     ld (penRow),a ;set cursor row
  221.     dec a
  222.     ld d,a
  223.     ld a,(height)
  224.     ld b,a
  225.     ld a,d
  226.     add a,b
  227.     dec a
  228.     ld d,a
  229.     dec a
  230.     dec a
  231.     ld (mY),a ;set max c-length for y
  232.     bcall(_DrawRectBorderClear) ; y u destroi all me registers
  233.     pop af
  234.     pop bc
  235.     pop de
  236.     pop hl
  237.     ret
  238. StringData:
  239.     .db StrngObj,tVarStrng,tStr1,0
  240. cX:
  241.     .db 0
  242. cY:
  243.     .db 0
  244. width:
  245.     .db 0
  246. height:
  247.     .db 0
  248. NPKey:
  249.     .db 36h
  250. SkipKey:
  251.     .db 30h
  252. mX:
  253.     .db 0
  254. mY:
  255.     .db 0
  256. Delay:
  257.     .db 8
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement