Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: ACagliano on October 01, 2011, 02:47:58 pm
-
I need help. I am uncertain how to get input in z80. There's a program I'm looking to make, but can someone help me with this. I need to do this in assembly:
Disp "A:ROCKET MASS"
Prompt A
Disp "B:PREV RCKT VELOCITY"
Prompt B
Disp "PROPELLENT MASS"
Prompt C
Disp "D:PROPELLENT VELOCITY"
Prompt D
Disp "E:PLANET MASS"
Prompt E
Disp "F:END TIME"
Prompt F
Disp "G:INITIAL DISTANCE"
Prompt G
-
Sorry, I have never done anything like that, so I can't help off the top of my head :/ I know you can use the actual bcalls to those commands, I am just not sure of the syntax for things like prompt.
-
For getting the text, here's an awesome routine I made.
;#####################################
;The all inclusive typing routine
;input: c = length
; de = curRow
; hl = buffer location
;output:
; b = length
; de = byte after
; hl = beginning
; carry = quit
; zero terminated string
;destroys:
; af, bc
; 2 bytes after length of string
typing:
push hl
ld (hl), e
inc hl
ld (hl), d
inc hl
ld (curRow), de
push hl
push bc
bcall(_clrTxtShd)
pop bc
pop hl
ld b, 0
editEntry:
set shiftAlpha, (iy + shiftFlags)
res shiftLwrAlph, (iy + shiftFlags)
set curAble, (iy + curFlags)
typeLoop:
call cursorOn
typeLoop2:
halt
push hl
bcall(_getCSC)
pop hl
or a
jr z, typeLoop2
push af
call cursorOff
pop af
cp skEnter
jr nz, notEnter
res curAble, (iy + curFlags)
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
pop hl
push hl
ld de, 2
add hl, de
pop de
push de
push bc
ld c, b
ld b, 0
ldir
pop bc
pop hl
xor a
ld (de), a
ret
notEnter:
cp sk2nd
jr nz, not2ndz
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
jr typeLoop
not2ndz:
cp skAlpha
jr nz, notAlpha
set shiftAlpha, (iy + shiftFlags)
ld a, (iy + shiftFlags)
xor %00000001 << shiftLwrAlph
ld (iy + shiftFlags), a
jr typeLoop
notAlpha:
cp skLeft
jr nz, notLeft
doLeft:
ld a, b
or a
jp z, typeLoop
dec b
dec hl
ld (hl), 0
ld de, (curRow)
dec d
jp p, notOffEdge
ld d, 15
dec e
notOffEdge:
ld (curRow), de
ld a, ' '
bcall(_putMap)
jp typeLoop
notLeft:
cp skDel
jr z, doLeft
notDelete:
cp skMode
jr nz, notMode
res curAble, (iy + curFlags)
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
pop hl
scf
ret
notMode:
cp skClear
jr nz, notClear
ld a, b
or a
jp z, typeLoop
pop hl
push hl
ld e, (hl)
inc hl
ld d, (hl)
inc hl
push hl
push de
ld (curRow), de
push bc
ld c, b
ld b, 0
inc bc
bcall(_memClear)
pop bc
ld a, ' '
clearLoop:
bcall(_putC)
djnz clearLoop
pop de
ld (curRow), de
pop hl
jp typeLoop
notClear:
sub skAdd
jp c, typeLoop
cp skMath - skAdd + 1
jp nc, typeLoop
push hl
ld hl, numTable
bit shiftAlpha, (iy + shiftFlags)
jr z, setFound
ld hl, lowTable
bit shiftLwrAlph, (iy + shiftFlags)
jr nz, setFound
ld hl, charTable
setFound:
ld e, a
ld d, 0
add hl, de
ld a, b
cp c
jr z, noMore
ld a, (hl)
or a
noMore:
pop hl
jp z, typeLoop
inc b
ld (hl), a
inc hl
bcall(_putC)
jp typeLoop
cursorOn:
res curOn, (iy + curFlags)
jr readyk
cursorOff:
set curOn, (iy + curFlags)
readyk:
ld a, 1
ld (curTime), a
ei
halt
ret
CharTable:
.db $22, "WRMH", 00, 00
.db "?", $5B, "VQLG", 00, 00
.db ":ZUPKFC", 00
.db " YTOJEB", 00, 00
.db "XSNIDA"
NumTable:
.db "+-*/^", 00, 00
.db $1A, "369)", 00, 00, 00
.db ".258(", 00, 00, 00
.db "0147,", 00, 00, 00, 00
.db $1C, 00, 00, $12, $11, 00
lowTable:
.db $22, "wrmh", 00, 00
.db "?", $5B, "vqlg", 00, 00
.db ":zupkfc", 00
.db " ytojeb", 00, 00
.db "xsnida"
This routine allows you to type letters, but you can remove that ability.
Then, as far as making a number out of it. You could probably parse it yourself, and if you can't do that, you might be able to save it as a string and parse it into a TI float, though, I don't really know how to do that. (Probably undocumented.)
-
For getting the text, here's an awesome routine I made.
;#####################################
;The all inclusive typing routine
;input: c = length
; de = curRow
; hl = buffer location
;output:
; b = length
; de = byte after
; hl = beginning
; carry = quit
; zero terminated string
;destroys:
; af, bc
; 2 bytes after length of string
typing:
push hl
ld (hl), e
inc hl
ld (hl), d
inc hl
ld (curRow), de
push hl
push bc
bcall(_clrTxtShd)
pop bc
pop hl
ld b, 0
editEntry:
set shiftAlpha, (iy + shiftFlags)
res shiftLwrAlph, (iy + shiftFlags)
set curAble, (iy + curFlags)
typeLoop:
call cursorOn
typeLoop2:
halt
push hl
bcall(_getCSC)
pop hl
or a
jr z, typeLoop2
push af
call cursorOff
pop af
cp skEnter
jr nz, notEnter
res curAble, (iy + curFlags)
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
pop hl
push hl
ld de, 2
add hl, de
pop de
push de
push bc
ld c, b
ld b, 0
ldir
pop bc
pop hl
xor a
ld (de), a
ret
notEnter:
cp sk2nd
jr nz, not2ndz
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
jr typeLoop
not2ndz:
cp skAlpha
jr nz, notAlpha
set shiftAlpha, (iy + shiftFlags)
ld a, (iy + shiftFlags)
xor %00000001 << shiftLwrAlph
ld (iy + shiftFlags), a
jr typeLoop
notAlpha:
cp skLeft
jr nz, notLeft
doLeft:
ld a, b
or a
jp z, typeLoop
dec b
dec hl
ld (hl), 0
ld de, (curRow)
dec d
jp p, notOffEdge
ld d, 15
dec e
notOffEdge:
ld (curRow), de
ld a, ' '
bcall(_putMap)
jp typeLoop
notLeft:
cp skDel
jr z, doLeft
notDelete:
cp skMode
jr nz, notMode
res curAble, (iy + curFlags)
res shiftLwrAlph, (iy + shiftFlags)
res shiftAlpha, (iy + shiftFlags)
pop hl
scf
ret
notMode:
cp skClear
jr nz, notClear
ld a, b
or a
jp z, typeLoop
pop hl
push hl
ld e, (hl)
inc hl
ld d, (hl)
inc hl
push hl
push de
ld (curRow), de
push bc
ld c, b
ld b, 0
inc bc
bcall(_memClear)
pop bc
ld a, ' '
clearLoop:
bcall(_putC)
djnz clearLoop
pop de
ld (curRow), de
pop hl
jp typeLoop
notClear:
sub skAdd
jp c, typeLoop
cp skMath - skAdd + 1
jp nc, typeLoop
push hl
ld hl, numTable
bit shiftAlpha, (iy + shiftFlags)
jr z, setFound
ld hl, lowTable
bit shiftLwrAlph, (iy + shiftFlags)
jr nz, setFound
ld hl, charTable
setFound:
ld e, a
ld d, 0
add hl, de
ld a, b
cp c
jr z, noMore
ld a, (hl)
or a
noMore:
pop hl
jp z, typeLoop
inc b
ld (hl), a
inc hl
bcall(_putC)
jp typeLoop
cursorOn:
res curOn, (iy + curFlags)
jr readyk
cursorOff:
set curOn, (iy + curFlags)
readyk:
ld a, 1
ld (curTime), a
ei
halt
ret
CharTable:
.db $22, "WRMH", 00, 00
.db "?", $5B, "VQLG", 00, 00
.db ":ZUPKFC", 00
.db " YTOJEB", 00, 00
.db "XSNIDA"
NumTable:
.db "+-*/^", 00, 00
.db $1A, "369)", 00, 00, 00
.db ".258(", 00, 00, 00
.db "0147,", 00, 00, 00, 00
.db $1C, 00, 00, $12, $11, 00
lowTable:
.db $22, "wrmh", 00, 00
.db "?", $5B, "vqlg", 00, 00
.db ":zupkfc", 00
.db " ytojeb", 00, 00
.db "xsnida"
This routine allows you to type letters, but you can remove that ability.
Then, as far as making a number out of it. You could probably parse it yourself, and if you can't do that, you might be able to save it as a string and parse it into a TI float, though, I don't really know how to do that. (Probably undocumented.)
I would like to only be able to accept numbers as input.
I can handle the moving to Op.
Where does it save that to?
-
Oh, sorry, I mis-typed there.
This routine allows you to type letters, but you can remove that ability.
This routine will get the numbers for you. It also allows you to type letters, but you can remove that ability*
To get rid of letters, just take out the alpha and 2nd functionality and make sure it always chooses a letter from NumTable:.
It saves the text wherever you want it to, just pass it HL. (It destroys 2 extra bytes after the maximum length you specify for the string)
-
Ok, so let me just double check. To make it only accept numbers, remove the upper and lowercase data tables, and take out the 2nd and Alpha key checks?
-
Rather than give you some long and complicated response, here is the code for numbers only:
;#####################################
;The all inclusive typing routine
;input: c = length
; de = curRow
; hl = buffer location
;output:
; b = length
; de = byte after
; hl = beginning
; carry = quit
; zero terminated string
;destroys:
; af, bc
; 2 bytes after length of string
typing:
push hl
ld (hl), e
inc hl
ld (hl), d
inc hl
ld (curRow), de
push hl
push bc
bcall(_clrTxtShd)
pop bc
pop hl
ld b, 0
editEntry:
set curAble, (iy + curFlags)
typeLoop:
call cursorOn
typeLoop2:
halt
push hl
bcall(_getCSC)
pop hl
or a
jr z, typeLoop2
push af
call cursorOff
pop af
cp skEnter
jr nz, notEnter
res curAble, (iy + curFlags)
pop hl
push hl
ld de, 2
add hl, de
pop de
push de
push bc
ld c, b
ld b, 0
ldir
pop bc
pop hl
xor a
ld (de), a
ret
notEnter:
cp skLeft
jr nz, notLeft
doLeft:
ld a, b
or a
jp z, typeLoop
dec b
dec hl
ld (hl), 0
ld de, (curRow)
dec d
jp p, notOffEdge
ld d, 15
dec e
notOffEdge:
ld (curRow), de
ld a, ' '
bcall(_putMap)
jp typeLoop
notLeft:
cp skDel
jr z, doLeft
notDelete:
cp skMode
jr nz, notMode
res curAble, (iy + curFlags)
pop hl
scf
ret
notMode:
cp skClear
jr nz, notClear
ld a, b
or a
jp z, typeLoop
pop hl
push hl
ld e, (hl)
inc hl
ld d, (hl)
inc hl
push hl
push de
ld (curRow), de
push bc
ld c, b
ld b, 0
inc bc
bcall(_memClear)
pop bc
ld a, ' '
clearLoop:
bcall(_putC)
djnz clearLoop
pop de
ld (curRow), de
pop hl
jp typeLoop
notClear:
sub skChs
jp c, typeLoop
cp skComma - skChs + 1
jp nc, typeLoop
push hl
ld hl, numTable
setFound:
ld e, a
ld d, 0
add hl, de
ld a, b
cp c
jr z, noMore
ld a, (hl)
or a
noMore:
pop hl
jp z, typeLoop
inc b
ld (hl), a
inc hl
bcall(_putC)
jp typeLoop
cursorOn:
res curOn, (iy + curFlags)
jr readyk
cursorOff:
set curOn, (iy + curFlags)
readyk:
ld a, 1
ld (curTime), a
ei
halt
ret
NumTable:
.db $1A, "369", 00, 00, 00, 00
.db ".258", 00, 00, 00, 00
.db "0147", $1B
I didn't test it, so it might give you a assembler error somewhere. Also, I left in the little E and the negative sign in case you want to handle them. If you don't, you can just zero them out in the character list.