Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "ti83plus.inc"
- #include "grammer.inc"
- #include "grammer2.5.inc"
- .db "Gram"
- .dw 0
- .dw 1
- .dw func0
- .org 0
- func0:
- .db "TBOX",$10
- .dw func0_end-func0_start
- func0_start:
- ld (8000h),sp ; This stores the stack pointer to spsave... for later dark ritual.
- ld ix,cX
- call ParseFullArg
- ld (ix),c
- inc ix
- ld b,3
- Grabdata:
- push bc
- call ParseNextFullArg
- ld (ix),c
- inc ix
- pop bc
- djnz Grabdata
- call ParseNextFullArg ; grab teh string
- push bc ; save teh string pointer
- cp 2Bh ; moar argument?
- jr nz,no_more_args
- call ParseNextFullArg
- cp 2Bh ; Make sure this list have 7 arguments. 6 is a bad number.
- jr nz,+_
- pop bc
- ret
- _:
- ld (ix),c
- inc ix
- call ParseNextFullArg
- ld (ix),c
- no_more_args:
- pop bc ; retrieve teh string pointer
- ld h,b
- ld l,c
- push hl
- call GetGrammerStr
- pop hl ; hl is now string, bc is now size o the string
- call saveSScreen+Resetrect-func0_start
- loop:
- ld a,(hl) ;Need to check if it is a two-byte token, later
- push af ;Save A for later
- push hl
- push bc
- bcall(_Get_Tok_Strng)
- ld hl,op3-1 ;point to the byte *before* the output characters.
- push hl
- inc hl
- ld a,(hl)
- cp 1bh ;check if string is Exponent E. E = original 8 delay
- pop hl
- jr nz,notDelay1 ;skip if not
- ld a,8
- ld (Delay),a
- pop bc
- pop hl
- pop af
- jr +_
- NotDelay1:
- push hl
- inc hl
- ld a,(hl)
- cp 11h ;check if string is -1. -1 = 16 Delay
- pop hl
- jr nz,notDelay2 ;skip if not
- ld a,16
- ld (Delay),a
- pop bc
- pop hl
- pop af
- jr +_
- NotDelay2:
- push hl
- inc hl
- ld a,(hl)
- cp 12h ;check if string is ^2. ^2 = slowest 32
- pop hl
- jr nz,notDelay3 ;skip if not
- ld a,32
- ld (Delay),a
- pop bc
- pop hl
- pop af
- jr +_
- NotDelay3:
- push hl
- inc hl
- ld a,(hl)
- cp 14h ;check if string is degree sign. deg = newline
- pop hl
- jr nz,notdegree ;skip if not degree sign
- call saveSScreen+Resetcur-func0_start
- pop bc
- pop hl
- pop af
- jr +_
- notdegree:
- push hl
- inc hl
- ld a,(hl)
- cp 15h ;check if string is radian sign. rad = resetrect
- pop hl
- jr nz,tokenloop ;skip if not radian sign
- call saveSScreen+NextPageKey-func0_start
- call saveSScreen+Resetrect-func0_start
- pop bc
- pop hl
- pop af
- jr +_
- tokenloop:
- push hl ;save HL
- push bc ;and BC
- call saveSScreen+CheckXPos-func0_start
- pop bc
- pop hl
- inc hl ;Need to increment first to get to the character since we started one byte behind
- ld a,(hl)
- bcall(_VPutMap)
- push bc
- ei
- ld a,(Delay)
- ld b,a
- ld a,(843Fh)
- ld c,a
- ld a,(SkipKey)
- cp c
- jr nz,PauseTime
- srl b
- PauseTime:
- call saveSScreen+Waith-func0_start
- djnz PauseTime
- pop bc
- dec c
- jr nz,tokenloop
- pop bc
- pop hl
- pop af
- bcall(_IsA2ByteTok) ;Check if it was a 2 byte token
- jr nz,+_
- inc hl ;increment hl for next calc since token was 2 bytes
- dec bc ;decrement bc since token was 2 bytes
- _:
- cpi
- jp pe,loop ; pe is used to test if BC reached 0.
- call saveSScreen+NextPageKey-func0_start
- ret
- Waith:
- ei
- halt
- bit onInterrupt,(iy+onFlags)
- ret z
- HardExit:
- ld sp,(8000h)
- ret
- NextPageKey:
- ld a,(NPKey)
- ld c,a
- Sub1:
- call saveSScreen+Waith-func0_start
- ld a,(843Fh)
- cp c
- jr nz,Sub1
- ret
- CheckXPos:
- ld (hl),1 ; Put size byte. This string should always be 1 byte long.
- bcall(_SStringLength) ;This destroys all but HL
- ld a,(penCol)
- add a,b ; Grab the future penCol position
- ld b,a
- dec b
- dec b
- ld a,(mX)
- cp b
- ret nc
- Resetcur:
- ld a,(cX)
- inc a ;if pencol > mX, change the cursor position
- inc a ;to next line before writing
- ld (penCol),a
- ld a,(penRow)
- add a,6
- ld (penRow),a
- ld b,a ;check the YPos
- ld a,(mY)
- sub 6
- cp b ; test if penRow > mY
- ret nc ; skip if penRow <= mY
- call saveSScreen+NextPageKey-func0_start
- call saveSScreen+Resetrect-func0_start
- ret
- Resetrect:
- push hl;Long push list yeah but I'll remove some
- push de;when I see that I don't need to save them
- push bc;later on when I code more
- push af;
- ld a,(cX)
- ld l,a ;start setting rect boundary
- ld a,(cY)
- ld h,a
- ld a,(cX)
- inc a
- inc a
- ld (penCol),a ;set cursor column
- dec a
- dec a
- ld d,a
- ld a,(width)
- ld b,a
- ld a,d
- add a,b
- dec a
- ld e,a
- dec a
- dec a
- ld (mX),a ;set max c-length for x
- ld a,(cY)
- inc a
- ld (penRow),a ;set cursor row
- dec a
- ld d,a
- ld a,(height)
- ld b,a
- ld a,d
- add a,b
- dec a
- ld d,a
- dec a
- dec a
- ld (mY),a ;set max c-length for y
- bcall(_DrawRectBorderClear) ; y u destroi all me registers
- pop af
- pop bc
- pop de
- pop hl
- ret
- GetGrammerStr:
- ld bc,0
- _:
- inc hl
- inc bc
- ld a,(hl)
- cp 4 \ ret z
- cp 3Fh \ ret z
- cp 2Ah \ jr nz,-_
- inc hl
- ret
- cX:
- .db 0
- cY:
- .db 0
- width:
- .db 0
- height:
- .db 0
- NPKey:
- .db 36h
- SkipKey:
- .db 30h
- mX:
- .db 0
- mY:
- .db 0
- Delay:
- .db 8
- func0_end:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement