mirror of
https://github.com/dschmenk/PLASMA.git
synced 2024-09-29 16:55:22 +00:00
Add echo on/off to conio for Apple 3
This commit is contained in:
parent
d2566c89c0
commit
b56b57fa4d
@ -1,10 +1,13 @@
|
|||||||
import conio
|
import conio
|
||||||
const NORMAL = $FF
|
const NORMAL = $FF
|
||||||
const INVERSE = $3F
|
const INVERSE = $3F
|
||||||
const FLASH = $7F
|
const FLASH = $7F
|
||||||
|
const ECHO_ON = $80
|
||||||
|
const ECHO_OFF = $00
|
||||||
struc t_conio
|
struc t_conio
|
||||||
word keypressed
|
word keypressed
|
||||||
word getkey
|
word getkey
|
||||||
|
word echo
|
||||||
word home
|
word home
|
||||||
word gotoxy
|
word gotoxy
|
||||||
word viewport
|
word viewport
|
||||||
|
@ -38,6 +38,7 @@ const ENV_REG = $FFDF
|
|||||||
struc t_conio
|
struc t_conio
|
||||||
word keypressed
|
word keypressed
|
||||||
word getkey
|
word getkey
|
||||||
|
word echo
|
||||||
word home
|
word home
|
||||||
word gotoxy
|
word gotoxy
|
||||||
word viewport
|
word viewport
|
||||||
@ -52,7 +53,7 @@ end
|
|||||||
//
|
//
|
||||||
// Predefined functions.
|
// Predefined functions.
|
||||||
//
|
//
|
||||||
predef a2keypressed,a2home,a2gotoxy(x,y),a2viewport(left, top, width, height),a2texttype(type)
|
predef a2keypressed,a2home,a12echo(state),a2gotoxy(x,y),a2viewport(left, top, width, height),a2texttype(type)
|
||||||
predef a2textmode(cols),a2grmode(mix),a2grcolor(color),a2grplot(x,y),a2tone(duration, delay),a2rnd
|
predef a2textmode(cols),a2grmode(mix),a2grcolor(color),a2grplot(x,y),a2tone(duration, delay),a2rnd
|
||||||
//
|
//
|
||||||
// Exported function table.
|
// Exported function table.
|
||||||
@ -63,6 +64,7 @@ word conio[]
|
|||||||
//
|
//
|
||||||
word = @a2keypressed
|
word = @a2keypressed
|
||||||
word = @getc
|
word = @getc
|
||||||
|
word = @a12echo
|
||||||
word = @a2home
|
word = @a2home
|
||||||
word = @a2gotoxy
|
word = @a2gotoxy
|
||||||
word = @a2viewport
|
word = @a2viewport
|
||||||
@ -167,6 +169,9 @@ end
|
|||||||
def a1keypressed
|
def a1keypressed
|
||||||
return ^$D011 >= 128
|
return ^$D011 >= 128
|
||||||
end
|
end
|
||||||
|
def a12echo(state)
|
||||||
|
return 0
|
||||||
|
end
|
||||||
def a1home
|
def a1home
|
||||||
byte l
|
byte l
|
||||||
for l = 0 to 23
|
for l = 0 to 23
|
||||||
@ -292,6 +297,9 @@ def a3keypressed
|
|||||||
dev_status(cmdsys.devcons, 5, @count)
|
dev_status(cmdsys.devcons, 5, @count)
|
||||||
return count
|
return count
|
||||||
end
|
end
|
||||||
|
def a3echo(state)
|
||||||
|
return dev_control(cmdsys.devcons, 11, @state)
|
||||||
|
end
|
||||||
def a3home
|
def a3home
|
||||||
//curshpos = 0
|
//curshpos = 0
|
||||||
//cursvpos = 0
|
//cursvpos = 0
|
||||||
@ -386,6 +394,7 @@ when MACHID & MACHID_MODEL
|
|||||||
is MACHID_III
|
is MACHID_III
|
||||||
conio:keypressed = @a3keypressed
|
conio:keypressed = @a3keypressed
|
||||||
conio:getkey = @a13getkey
|
conio:getkey = @a13getkey
|
||||||
|
conio:echo = @a3echo
|
||||||
conio:home = @a3home
|
conio:home = @a3home
|
||||||
conio:gotoxy = @a3gotoxy
|
conio:gotoxy = @a3gotoxy
|
||||||
conio:viewport = @a3viewport
|
conio:viewport = @a3viewport
|
||||||
|
@ -135,6 +135,7 @@ end
|
|||||||
export def fight(player, enemy)
|
export def fight(player, enemy)
|
||||||
word p_atck, e_atck
|
word p_atck, e_atck
|
||||||
|
|
||||||
|
conio:echo(ECHO_ON)
|
||||||
repeat
|
repeat
|
||||||
conio:home()
|
conio:home()
|
||||||
conio:gotoxy(0, 0)
|
conio:gotoxy(0, 0)
|
||||||
@ -159,6 +160,7 @@ export def fight(player, enemy)
|
|||||||
next
|
next
|
||||||
conio:gotoxy(12, 8); puts("F)ight or R)un?")
|
conio:gotoxy(12, 8); puts("F)ight or R)un?")
|
||||||
if toupper(conio:getkey()) == 'R'
|
if toupper(conio:getkey()) == 'R'
|
||||||
|
conio:echo(ECHO_OFF)
|
||||||
return 1
|
return 1
|
||||||
else
|
else
|
||||||
//
|
//
|
||||||
@ -204,6 +206,7 @@ export def fight(player, enemy)
|
|||||||
fin
|
fin
|
||||||
fin
|
fin
|
||||||
until player->health == 0 or enemy->life == 0
|
until player->health == 0 or enemy->life == 0
|
||||||
|
conio:echo(ECHO_OFF)
|
||||||
return 0
|
return 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -625,6 +625,7 @@ if ^instr > 15
|
|||||||
^instr = 15
|
^instr = 15
|
||||||
fin
|
fin
|
||||||
memcpy(@player.name, instr, ^instr + 1)
|
memcpy(@player.name, instr, ^instr + 1)
|
||||||
|
conio:echo(ECHO_OFF)
|
||||||
while loadmap(level)
|
while loadmap(level)
|
||||||
puts(@prepstr)
|
puts(@prepstr)
|
||||||
free_entities = heapmark()
|
free_entities = heapmark()
|
||||||
@ -650,6 +651,7 @@ while loadmap(level)
|
|||||||
break
|
break
|
||||||
fin
|
fin
|
||||||
loop
|
loop
|
||||||
|
conio:echo(ECHO_ON)
|
||||||
if player.health > 0
|
if player.health > 0
|
||||||
puts(@youmadeitstr)
|
puts(@youmadeitstr)
|
||||||
puti(player.gold)
|
puti(player.gold)
|
||||||
|
@ -12,14 +12,14 @@ const ZEROSTR = $3001
|
|||||||
// Keypad structure
|
// Keypad structure
|
||||||
//
|
//
|
||||||
struc t_keypad
|
struc t_keypad
|
||||||
byte keychar
|
byte keychar
|
||||||
byte xpos
|
byte xpos
|
||||||
byte ypos
|
byte ypos
|
||||||
byte keystr[8]
|
byte keystr[8]
|
||||||
end
|
end
|
||||||
struc t_keyinput
|
struc t_keyinput
|
||||||
byte keyinfo[t_keypad]
|
byte keyinfo[t_keypad]
|
||||||
word phandler
|
word phandler
|
||||||
end
|
end
|
||||||
predef delKey(pkey)#0, cmdKey(pkey)#0, dropKey(pkey)#0, clearKey(pkey)#0
|
predef delKey(pkey)#0, cmdKey(pkey)#0, dropKey(pkey)#0, clearKey(pkey)#0
|
||||||
predef digitKey(pkey)#0, pointKey(pkey)#0, opKey(pkey)#0
|
predef digitKey(pkey)#0, pointKey(pkey)#0, opKey(pkey)#0
|
||||||
@ -46,401 +46,403 @@ byte memory[10*t_fpureg]
|
|||||||
// Key values
|
// Key values
|
||||||
//
|
//
|
||||||
byte[t_keypad] keypad = $08, 0, 0, ""
|
byte[t_keypad] keypad = $08, 0, 0, ""
|
||||||
word = @delKey
|
word = @delKey
|
||||||
byte[t_keypad] = $1B, 0, 0, ""
|
byte[t_keypad] = $1B, 0, 0, ""
|
||||||
word = @cmdKey
|
word = @cmdKey
|
||||||
byte[t_keypad] = '=', 0, 0, ""
|
byte[t_keypad] = '=', 0, 0, ""
|
||||||
word = @copyKey
|
word = @copyKey
|
||||||
byte[t_keypad] = 'Z', 0, 0, ""
|
byte[t_keypad] = 'Z', 0, 0, ""
|
||||||
word = @clearKey
|
word = @clearKey
|
||||||
byte[t_keypad] = '7', 3, 10, "[7]"
|
byte[t_keypad] = '7', 3, 10, "[7]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '8', 7, 10, "[8]"
|
byte[t_keypad] = '8', 7, 10, "[8]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '9', 11, 10, "[9]"
|
byte[t_keypad] = '9', 11, 10, "[9]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '/', 15, 10, "[/]"
|
byte[t_keypad] = '/', 15, 10, "[/]"
|
||||||
word = @opKey
|
word = @opKey
|
||||||
byte[t_keypad] = '4', 3, 12, "[4]"
|
byte[t_keypad] = '4', 3, 12, "[4]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '5', 7, 12, "[5]"
|
byte[t_keypad] = '5', 7, 12, "[5]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '6', 11, 12, "[6]"
|
byte[t_keypad] = '6', 11, 12, "[6]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '*', 15, 12, "[*]"
|
byte[t_keypad] = '*', 15, 12, "[*]"
|
||||||
word = @opKey
|
word = @opKey
|
||||||
byte[t_keypad] = '1', 3, 14, "[1]"
|
byte[t_keypad] = '1', 3, 14, "[1]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '2', 7, 14, "[2]"
|
byte[t_keypad] = '2', 7, 14, "[2]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '3', 11, 14, "[3]"
|
byte[t_keypad] = '3', 11, 14, "[3]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '-', 15, 14, "[-]"
|
byte[t_keypad] = '-', 15, 14, "[-]"
|
||||||
word = @opKey
|
word = @opKey
|
||||||
byte[t_keypad] = '0', 3, 16, "[0]"
|
byte[t_keypad] = '0', 3, 16, "[0]"
|
||||||
word = @digitKey
|
word = @digitKey
|
||||||
byte[t_keypad] = '.', 7, 16, "[.]"
|
byte[t_keypad] = '.', 7, 16, "[.]"
|
||||||
word = @pointKey
|
word = @pointKey
|
||||||
byte[t_keypad] = 'X', 11, 16, "[X]"
|
byte[t_keypad] = 'X', 11, 16, "[X]"
|
||||||
word = @dropKey
|
word = @dropKey
|
||||||
byte[t_keypad] = '+', 15, 16, "[+]"
|
byte[t_keypad] = '+', 15, 16, "[+]"
|
||||||
word = @opKey
|
word = @opKey
|
||||||
byte[t_keypad] = $0D, 3, 18, "[ENTER]"
|
byte[t_keypad] = $0D, 3, 18, "[ENTER]"
|
||||||
word = @enterKey
|
word = @enterKey
|
||||||
byte[t_keypad] = '<', 11, 18, "[<]"
|
byte[t_keypad] = '<', 11, 18, "[<]"
|
||||||
word = @memKey
|
word = @memKey
|
||||||
byte[t_keypad] = '>', 15, 18, "[>]"
|
byte[t_keypad] = '>', 15, 18, "[>]"
|
||||||
word = @memKey
|
word = @memKey
|
||||||
byte[t_keypad] = 'R', 3, 20, "[SQ(R)]"
|
byte[t_keypad] = 'R', 3, 20, "[SQ(R)]"
|
||||||
word = @opKey
|
word = @opKey
|
||||||
byte[t_keypad] = 'H', 11, 20, "[C(H)S]"
|
byte[t_keypad] = 'H', 11, 20, "[C(H)S]"
|
||||||
word = @chsKey
|
word = @chsKey
|
||||||
byte[t_keypad] = 'C', 22, 14, "[(C)OS]"
|
byte[t_keypad] = 'C', 22, 14, "[(C)OS]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'S', 22, 16, "[(S)IN]"
|
byte[t_keypad] = 'S', 22, 16, "[(S)IN]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'T', 22, 18, "[(T)AN]"
|
byte[t_keypad] = 'T', 22, 18, "[(T)AN]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'A', 22, 20, "[(A)TN]"
|
byte[t_keypad] = 'A', 22, 20, "[(A)TN]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = '^', 30, 14, "[X(^)Y]"
|
byte[t_keypad] = '^', 30, 14, "[X(^)Y]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'L', 30, 16, "[(L)G2]"
|
byte[t_keypad] = 'L', 30, 16, "[(L)G2]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'E', 30, 18, "[(E)^X]"
|
byte[t_keypad] = 'E', 30, 18, "[(E)^X]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte[t_keypad] = 'N', 30, 20, "[L(N)X]"
|
byte[t_keypad] = 'N', 30, 20, "[L(N)X]"
|
||||||
word = @elemsKey
|
word = @elemsKey
|
||||||
byte = 0
|
byte = 0
|
||||||
//
|
//
|
||||||
// Utility routines
|
// Utility routines
|
||||||
//
|
//
|
||||||
def repc(rep, c)#0
|
def repc(rep, c)#0
|
||||||
while rep > 0
|
while rep > 0
|
||||||
putc(c)
|
putc(c)
|
||||||
rep--
|
rep--
|
||||||
loop
|
loop
|
||||||
end
|
end
|
||||||
def rect(x, y, width, height, frame, title)#0
|
def rect(x, y, width, height, frame, title)#0
|
||||||
byte i
|
byte i
|
||||||
|
|
||||||
conio:gotoxy(x + 1, y)
|
conio:gotoxy(x + 1, y)
|
||||||
repc(width - 2, frame ?? '#' :: '-')
|
repc(width - 2, frame ?? '#' :: '-')
|
||||||
conio:gotoxy(x + 1, y + height - 1)
|
conio:gotoxy(x + 1, y + height - 1)
|
||||||
repc(width - 2, frame ?? '#' :: '-')
|
repc(width - 2, frame ?? '#' :: '-')
|
||||||
for i = 1 to height - 1
|
for i = 1 to height - 1
|
||||||
conio:gotoxy(x, y + i)
|
conio:gotoxy(x, y + i)
|
||||||
putc(frame ?? '#' :: '!')
|
putc(frame ?? '#' :: '!')
|
||||||
conio:gotoxy(x + width - 1, y + i)
|
conio:gotoxy(x + width - 1, y + i)
|
||||||
putc(frame ?? '#' :: '!')
|
putc(frame ?? '#' :: '!')
|
||||||
next
|
next
|
||||||
conio:gotoxy(x, y)
|
conio:gotoxy(x, y)
|
||||||
putc(frame ?? '/' :: '+')
|
putc(frame ?? '/' :: '+')
|
||||||
conio:gotoxy(x + width - 1, y)
|
conio:gotoxy(x + width - 1, y)
|
||||||
putc(frame ?? '\\' :: '+')
|
putc(frame ?? '\\' :: '+')
|
||||||
conio:gotoxy(x, y + height - 1)
|
conio:gotoxy(x, y + height - 1)
|
||||||
putc(frame ?? '\\' :: '+')
|
putc(frame ?? '\\' :: '+')
|
||||||
conio:gotoxy(x + width - 1, y + height - 1)
|
conio:gotoxy(x + width - 1, y + height - 1)
|
||||||
putc(frame ?? '/' :: '+')
|
putc(frame ?? '/' :: '+')
|
||||||
if title
|
if title
|
||||||
conio:gotoxy(x + (width - ^title) / 2, y)
|
conio:gotoxy(x + (width - ^title) / 2, y)
|
||||||
puts(title)
|
puts(title)
|
||||||
fin
|
fin
|
||||||
end
|
end
|
||||||
def showStack#0
|
def showStack#0
|
||||||
byte s
|
byte s
|
||||||
byte strFP[displayWidth+1]
|
byte strFP[displayWidth+1]
|
||||||
|
|
||||||
for s = 0 to 3
|
for s = 0 to 3
|
||||||
fpu:storStr(@strFP, displayInt, displayFix, FPSTR_FIXED, s)
|
fpu:storStr(@strFP, displayInt, displayFix, FPSTR_FIXED, s)
|
||||||
conio:gotoxy(4, 5 - s)
|
conio:gotoxy(4, 5 - s)
|
||||||
repc(displayWidth - strFP - 1, ' ')
|
repc(displayWidth - strFP - 1, ' ')
|
||||||
puts(@strFP)
|
puts(@strFP)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
def showMem#0
|
def showMem#0
|
||||||
byte m
|
byte m
|
||||||
byte strFP[displayWidth+1]
|
byte strFP[displayWidth+1]
|
||||||
|
|
||||||
for m = 0 to 9
|
for m = 0 to 9
|
||||||
ext2str(@memory[m*t_fpureg], @strFP, displayInt, displayFix, FPSTR_FIXED)
|
ext2str(@memory[m*t_fpureg], @strFP, displayInt, displayFix, FPSTR_FIXED)
|
||||||
conio:gotoxy(23, 2 + m)
|
conio:gotoxy(23, 2 + m)
|
||||||
repc(displayWidth - strFP - 1, ' ')
|
repc(displayWidth - strFP - 1, ' ')
|
||||||
puts(@strFP)
|
puts(@strFP)
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
def showInput#0
|
def showInput#0
|
||||||
conio:gotoxy(2,7)
|
conio:gotoxy(2,7)
|
||||||
repc(17 - inputStr, ' ')
|
repc(17 - inputStr, ' ')
|
||||||
puts(@inputStr)
|
puts(@inputStr)
|
||||||
end
|
end
|
||||||
def showStatus(pstr)#0
|
def showStatus(pstr)#0
|
||||||
conio:gotoxy(0,23)
|
conio:gotoxy(0,23)
|
||||||
puts(pstr)
|
puts(pstr)
|
||||||
end
|
end
|
||||||
def clearStatus#0
|
def clearStatus#0
|
||||||
conio:gotoxy(0,23)
|
conio:gotoxy(0,23)
|
||||||
repc(39, ' ')
|
repc(39, ' ')
|
||||||
end
|
end
|
||||||
def initInput#0
|
def initInput#0
|
||||||
inputStr = 0
|
inputStr = 0
|
||||||
end
|
end
|
||||||
def updateInput#0
|
def updateInput#0
|
||||||
//
|
//
|
||||||
// Lift stack if something input
|
// Lift stack if something input
|
||||||
//
|
//
|
||||||
if inputStr
|
if inputStr
|
||||||
fpu:pushStr(@inputStr)
|
fpu:pushStr(@inputStr)
|
||||||
fin
|
fin
|
||||||
initInput
|
initInput
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def initDisplay#0
|
def initDisplay#0
|
||||||
byte i
|
byte i
|
||||||
word pkeys
|
word pkeys
|
||||||
|
|
||||||
conio:home()
|
conio:home()
|
||||||
rect(0, 0, 40, 23, 1, "<RPN Calculator>")
|
rect(0, 0, 40, 23, 1, "<RPN Calculator>")
|
||||||
rect(1, 1, 19, 6, 0, ":Stack:")
|
rect(1, 1, 19, 6, 0, ":Stack:")
|
||||||
rect(1, 6, 19, 3, 0, 0)
|
rect(1, 6, 19, 3, 0, 0)
|
||||||
conio:gotoxy(2, 2); puts("T:")
|
conio:gotoxy(2, 2); puts("T:")
|
||||||
conio:gotoxy(2, 3); puts("Z:")
|
conio:gotoxy(2, 3); puts("Z:")
|
||||||
conio:gotoxy(2, 4); puts("Y:")
|
conio:gotoxy(2, 4); puts("Y:")
|
||||||
conio:gotoxy(2, 5); puts("X:")
|
conio:gotoxy(2, 5); puts("X:")
|
||||||
rect(20, 1, 19, 12, 0, ":Memory:")
|
rect(20, 1, 19, 12, 0, ":Memory:")
|
||||||
for i = 0 to 9
|
for i = 0 to 9
|
||||||
conio:gotoxy(21, 2 + i); puti(i); putc(':')
|
conio:gotoxy(21, 2 + i); puti(i); putc(':')
|
||||||
next
|
next
|
||||||
pkeys = @keypad
|
pkeys = @keypad
|
||||||
while ^pkeys
|
while ^pkeys
|
||||||
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
||||||
puts(pkeys + keystr)
|
puts(pkeys + keystr)
|
||||||
pkeys = pkeys + t_keyinput
|
pkeys = pkeys + t_keyinput
|
||||||
loop
|
loop
|
||||||
end
|
end
|
||||||
def initState#0
|
def initState#0
|
||||||
byte m
|
byte m
|
||||||
|
|
||||||
//
|
//
|
||||||
// Init FPU
|
// Init FPU
|
||||||
//
|
//
|
||||||
fpu:reset()
|
fpu:reset()
|
||||||
//
|
//
|
||||||
// Fill memory
|
// Fill memory
|
||||||
//
|
//
|
||||||
for m = 2 to 9
|
for m = 2 to 9
|
||||||
fpu:storExt(@memory[m*t_fpureg], X_REG)
|
fpu:storExt(@memory[m*t_fpureg], X_REG)
|
||||||
next
|
next
|
||||||
//
|
//
|
||||||
// Put some useful constants in there
|
// Put some useful constants in there
|
||||||
//
|
//
|
||||||
fpu:constPi()
|
fpu:constPi()
|
||||||
fpu:pullExt(@memory[0*t_fpureg])
|
fpu:pullExt(@memory[0*t_fpureg])
|
||||||
fpu:constE()
|
fpu:constE()
|
||||||
fpu:pullExt(@memory[1*t_fpureg])
|
fpu:pullExt(@memory[1*t_fpureg])
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Keypress input handlers
|
// Keypress input handlers
|
||||||
//
|
//
|
||||||
def delKey(pkey)#0
|
def delKey(pkey)#0
|
||||||
if inputStr
|
if inputStr
|
||||||
inputStr--
|
inputStr--
|
||||||
fin
|
fin
|
||||||
if inputStr:0 == 1 | ('-' << 8) //inputStr == 1 and inputStr.1 == '-'
|
if inputStr:0 == 1 | ('-' << 8) //inputStr == 1 and inputStr.1 == '-'
|
||||||
inputStr--
|
inputStr--
|
||||||
fin
|
fin
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def dropKey(pkey)#0
|
def dropKey(pkey)#0
|
||||||
fpu:pullStr(@inputStr, displayInt, displayFix, FPSTR_STRIP|FPSTR_FLOAT)
|
fpu:pullStr(@inputStr, displayInt, displayFix, FPSTR_STRIP|FPSTR_FLOAT)
|
||||||
if inputStr.1 == ' '
|
if inputStr.1 == ' '
|
||||||
inputStr--
|
inputStr--
|
||||||
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
||||||
fin
|
fin
|
||||||
showInput
|
showInput
|
||||||
showStack
|
showStack
|
||||||
end
|
end
|
||||||
def copyKey(pkey)#0
|
def copyKey(pkey)#0
|
||||||
fpu:storStr(@inputStr, displayInt, displayFix, FPSTR_STRIP|FPSTR_FLOAT, X_REG)
|
fpu:storStr(@inputStr, displayInt, displayFix, FPSTR_STRIP|FPSTR_FLOAT, X_REG)
|
||||||
if inputStr.1 == ' '
|
if inputStr.1 == ' '
|
||||||
inputStr--
|
inputStr--
|
||||||
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
||||||
fin
|
fin
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def clearKey(pkey)#0
|
def clearKey(pkey)#0
|
||||||
initInput
|
initInput
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def digitKey(pkey)#0
|
def digitKey(pkey)#0
|
||||||
if inputStr < inputLen
|
if inputStr < inputLen
|
||||||
if inputStr:0 <> ZEROSTR
|
if inputStr:0 <> ZEROSTR
|
||||||
inputStr++
|
inputStr++
|
||||||
fin
|
|
||||||
inputStr[inputStr] = ^pkey
|
|
||||||
showInput
|
|
||||||
fin
|
fin
|
||||||
|
inputStr[inputStr] = ^pkey
|
||||||
|
showInput
|
||||||
|
fin
|
||||||
end
|
end
|
||||||
def pointKey(pkey)#0
|
def pointKey(pkey)#0
|
||||||
byte c
|
byte c
|
||||||
|
|
||||||
if !inputStr
|
if !inputStr
|
||||||
//
|
//
|
||||||
// Start off with '0' if blank input
|
// Start off with '0' if blank input
|
||||||
//
|
//
|
||||||
inputStr:0 = ZEROSTR
|
inputStr:0 = ZEROSTR
|
||||||
else
|
else
|
||||||
//
|
//
|
||||||
// Check for existing decimal point
|
// Check for existing decimal point
|
||||||
//
|
//
|
||||||
for c = 1 to inputStr
|
for c = 1 to inputStr
|
||||||
if inputStr[c] == '.'
|
if inputStr[c] == '.'
|
||||||
return
|
return
|
||||||
fin
|
fin
|
||||||
next
|
next
|
||||||
fin
|
fin
|
||||||
inputStr++
|
inputStr++
|
||||||
inputStr[inputStr] = '.'
|
inputStr[inputStr] = '.'
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def chsKey(pkey)#0
|
def chsKey(pkey)#0
|
||||||
if inputStr
|
if inputStr
|
||||||
if inputStr.1 <> '-'
|
if inputStr.1 <> '-'
|
||||||
memcpy(@inputStr.2, @inputStr.1, inputStr)
|
memcpy(@inputStr.2, @inputStr.1, inputStr)
|
||||||
inputStr++
|
inputStr++
|
||||||
inputStr.1 = '-'
|
inputStr.1 = '-'
|
||||||
else
|
else
|
||||||
inputStr--
|
inputStr--
|
||||||
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
memcpy(@inputStr.1, @inputStr.2, inputStr)
|
||||||
fin
|
|
||||||
showInput
|
|
||||||
fin
|
fin
|
||||||
|
showInput
|
||||||
|
fin
|
||||||
end
|
end
|
||||||
def enterKey(pkey)#0
|
def enterKey(pkey)#0
|
||||||
fpu:pushStr(@inputStr)
|
fpu:pushStr(@inputStr)
|
||||||
showStack
|
showStack
|
||||||
initInput
|
initInput
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
def opKey(pkey)#0
|
def opKey(pkey)#0
|
||||||
updateInput
|
updateInput
|
||||||
when ^pkey
|
when ^pkey
|
||||||
is '+'
|
is '+'
|
||||||
fpu:addXY()
|
fpu:addXY()
|
||||||
break
|
break
|
||||||
is '-'
|
is '-'
|
||||||
fpu:subXY()
|
fpu:subXY()
|
||||||
break
|
break
|
||||||
is '*'
|
is '*'
|
||||||
fpu:mulXY()
|
fpu:mulXY()
|
||||||
break
|
break
|
||||||
is '/'
|
is '/'
|
||||||
fpu:divXY()
|
fpu:divXY()
|
||||||
break
|
break
|
||||||
is 'R'
|
is 'R'
|
||||||
fpu:sqrtX()
|
fpu:sqrtX()
|
||||||
break
|
break
|
||||||
wend
|
wend
|
||||||
showStack
|
showStack
|
||||||
end
|
end
|
||||||
def memKey(pkey)#0
|
def memKey(pkey)#0
|
||||||
word r
|
word r
|
||||||
|
|
||||||
showStatus("Press 0-9 for memory register:")
|
showStatus("Press 0-9 for memory register:")
|
||||||
r = getc - '0'
|
r = getc - '0'
|
||||||
clearStatus
|
clearStatus
|
||||||
if r >= 0 and r <= 9
|
if r >= 0 and r <= 9
|
||||||
if ^pkey == '<'
|
if ^pkey == '<'
|
||||||
fpu:pushExt(@memory[r*t_fpureg])
|
fpu:pushExt(@memory[r*t_fpureg])
|
||||||
showStack
|
showStack
|
||||||
else
|
else
|
||||||
fpu:storExt(@memory[r*t_fpureg], X_REG)
|
fpu:storExt(@memory[r*t_fpureg], X_REG)
|
||||||
showMem
|
showMem
|
||||||
fin
|
|
||||||
fin
|
fin
|
||||||
|
fin
|
||||||
end
|
end
|
||||||
def elemsKey(pkey)#0
|
def elemsKey(pkey)#0
|
||||||
updateInput
|
updateInput
|
||||||
when ^pkey
|
when ^pkey
|
||||||
is 'C'
|
is 'C'
|
||||||
fpu:cosX()
|
fpu:cosX()
|
||||||
break
|
break
|
||||||
is 'S'
|
is 'S'
|
||||||
fpu:sinX()
|
fpu:sinX()
|
||||||
break
|
break
|
||||||
is 'T'
|
is 'T'
|
||||||
fpu:tanX()
|
fpu:tanX()
|
||||||
break
|
break
|
||||||
is 'A'
|
is 'A'
|
||||||
fpu:atanX()
|
fpu:atanX()
|
||||||
break
|
break
|
||||||
is '^'
|
is '^'
|
||||||
fpu:powXY()
|
fpu:powXY()
|
||||||
break
|
break
|
||||||
is 'L'
|
is 'L'
|
||||||
fpu:log2X()
|
fpu:log2X()
|
||||||
break
|
break
|
||||||
is 'E'
|
is 'E'
|
||||||
fpu:powEX()
|
fpu:powEX()
|
||||||
break
|
break
|
||||||
is 'N'
|
is 'N'
|
||||||
fpu:lnX()
|
fpu:lnX()
|
||||||
break
|
break
|
||||||
wend
|
wend
|
||||||
showStack
|
showStack
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Command line handler
|
// Command line handler
|
||||||
//
|
//
|
||||||
def cmdKey(pkey)#0
|
def cmdKey(pkey)#0
|
||||||
// word cmdLine
|
// word cmdLine
|
||||||
|
|
||||||
// showStatus("Command")
|
// showStatus("Command")
|
||||||
// cmdLine = gets(':'|$80)
|
// cmdLine = gets(':'|$80)
|
||||||
word d
|
word d
|
||||||
|
|
||||||
showStatus("Press 1-9 for fix point digits(Q=Quit):")
|
showStatus("Press 1-9 for fix point digits(Q=Quit):")
|
||||||
d = toupper(getc) - '0'
|
d = toupper(getc) - '0'
|
||||||
if d >= 1 and d <= 9
|
if d >= 1 and d <= 9
|
||||||
displayFix = d
|
displayFix = d
|
||||||
displayInt = displayWidth - displayFix - 1
|
displayInt = displayWidth - displayFix - 1
|
||||||
elsif d == 'Q' - '0'
|
elsif d == 'Q' - '0'
|
||||||
quit = TRUE
|
quit = TRUE
|
||||||
fin
|
fin
|
||||||
clearStatus
|
clearStatus
|
||||||
//
|
//
|
||||||
// Do something
|
// Do something
|
||||||
//
|
//
|
||||||
initDisplay
|
initDisplay
|
||||||
showStack
|
showStack
|
||||||
showMem
|
showMem
|
||||||
showInput
|
showInput
|
||||||
end
|
end
|
||||||
//
|
//
|
||||||
// Keypress handler
|
// Keypress handler
|
||||||
//
|
//
|
||||||
def inputKey#0
|
def inputKey#0
|
||||||
byte inkey
|
byte inkey
|
||||||
word pkeys
|
word pkeys
|
||||||
|
|
||||||
while not quit
|
conio:echo(ECHO_OFF)
|
||||||
pkeys = @keypad
|
while not quit
|
||||||
conio:gotoxy(18, 7)
|
pkeys = @keypad
|
||||||
inkey = toupper(getc)
|
conio:gotoxy(18, 7)
|
||||||
while ^pkeys
|
inkey = toupper(getc)
|
||||||
if inkey == ^pkeys
|
while ^pkeys
|
||||||
conio:texttype(INVERSE)
|
if inkey == ^pkeys
|
||||||
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
conio:texttype(INVERSE)
|
||||||
puts(pkeys + keystr)
|
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
||||||
conio:texttype(NORMAL)
|
puts(pkeys + keystr)
|
||||||
pkeys=>phandler(pkeys)#0
|
conio:texttype(NORMAL)
|
||||||
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
pkeys=>phandler(pkeys)#0
|
||||||
puts(pkeys + keystr)
|
conio:gotoxy(pkeys->xpos, pkeys->ypos)
|
||||||
break
|
puts(pkeys + keystr)
|
||||||
fin
|
break
|
||||||
pkeys = pkeys + t_keyinput
|
fin
|
||||||
loop
|
pkeys = pkeys + t_keyinput
|
||||||
loop
|
loop
|
||||||
|
loop
|
||||||
|
conio:echo(ECHO_ON)
|
||||||
end
|
end
|
||||||
initDisplay
|
initDisplay
|
||||||
initState
|
initState
|
||||||
|
Loading…
Reference in New Issue
Block a user