Author Topic: Quick Routine  (Read 4623 times)

0 Members and 1 Guest are viewing this topic.

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Quick Routine
« 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:

Code: [Select]
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

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Quick Routine
« Reply #1 on: October 01, 2011, 02:50:48 pm »
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.

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Quick Routine
« Reply #2 on: October 01, 2011, 03:00:03 pm »
For getting the text, here's an awesome routine I made.

Code: [Select]

;#####################################
;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.)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Quick Routine
« Reply #3 on: October 01, 2011, 03:17:01 pm »
For getting the text, here's an awesome routine I made.

Code: [Select]

;#####################################
;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?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Quick Routine
« Reply #4 on: October 01, 2011, 04:35:45 pm »
Oh, sorry, I mis-typed there.

Quote
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)
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112

Offline ACagliano

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 919
  • Rating: +32/-2
    • View Profile
    • ClrHome Productions
Re: Quick Routine
« Reply #5 on: October 03, 2011, 10:38:18 am »
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?

Offline thepenguin77

  • z80 Assembly Master
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1594
  • Rating: +823/-5
  • The game in my avatar is bit.ly/p0zPWu
    • View Profile
Re: Quick Routine
« Reply #6 on: October 04, 2011, 03:25:04 pm »
Rather than give you some long and complicated response, here is the code for numbers only:

Code: [Select]
;#####################################
;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.
zStart v1.3.013 9-20-2013 
All of my utilities
TI-Connect Help
You can build a statue out of either 1'x1' blocks or 12'x12' blocks. The 1'x1' blocks will take a lot longer, but the final product is worth it.
       -Runer112