Calculator Community > ASM

Working on Textbox program for asm [Complete]

<< < (3/3)

Yeong:
This little project is nearing the end, and currently it is fully functional as intended, except for the failsafe part.
The "force exit after pressing [ON]" part doesn't work that well.
(It's the label "NextPageKey" that handles it, along with "HardExit" right after.)

What am I doing wrong here?

EDIT: It apparently wasn't wrong, but it was sometimes missing the input.
It is fixed now.


--- Code: ---#include "ti83plus.inc"
.org $9D93
.db t2ByteTok,tAsmCmp
ld (8000h),sp ; This stores the stack pointer to spsave... for later dark ritual.
bcall(_RclAns)
dec a
ret nz ;quit if answer is non-list
ex de,hl
ld b,(hl)
inc hl
cp (hl)
ret nz
inc hl ; grabbed list size in b
ld a,b ;our list needs to be either 4 or 6 elements
cp 4
jr z,Pass
cp 6
ret nz
Pass:
ld ix,cX ;apparently I do need ix here because my HL DE BCs are used a lot
loopbtimes:
push bc
rst 20h ;rMov9ToOP1
push hl
bcall(_ConvOP1)
pop hl
ld (ix),a
inc ix
pop bc
djnz loopbtimes
;bcall(_ClrLCDFull)
call Resetrect
ld hl,StringData
rst 20h
rst 10h ;rFindSym
ret c ;quit if string is not found
ex de,hl
ld c,(hl) ;grab string size
inc hl
ld b,(hl)
inc hl
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 Resetcur
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 NextPageKey
call Resetrect
pop bc
pop hl
pop af
jr +_
tokenloop:
push hl     ;save HL
push bc    ;and BC
call CheckXPos
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 Waith
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 NextPageKey
ret
Waith:
ei
halt
bit onInterrupt,(iy+onFlags)
ret z
HardExit:
ld sp,(8000h)
ret
NextPageKey:
ld a,(NPKey)
ld c,a
Sub1:
call Waith
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 NextPageKey
call Resetrect
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
StringData:
.db StrngObj,tVarStrng,tStr1,0
cX:
.db 0
cY:
.db 0
width:
.db 0
height:
.db 0
mX:
.db 0
mY:
.db 0
NPKey:
.db 36h
SkipKey:
.db 30h
Delay:
.db 8

--- End code ---

Yeong:
Finally, it is finished!

Navigation

[0] Message Index

[*] Previous page

Go to full version