Advertisement
Guest User

Untitled

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