CP/M User
Veteran Member
I ported this nice little BASIC game (nothing special) to TP3 a year or two ago, unfortunately I was persistant in using readkey which works great on an IBM, cause the function I'm using is calling BIOS function 16! :-o
So now I'm having trouble finding an TP3 solution to this cause my code which the offending code looks like this:
My readkey function looks like this:
I guess the trouble is I've been trying to use a machine equivalent (being a CPC), though it doesn't quite work the same as an IBM Interrupt 16 - even though it states it checks if a key has been pressed without waiting, I've good back to basics in writing a program which returns the keypress values - which maybe part of the problem. I guess with my code simply checks for a keypress it goes into checking which key has been pressed, the readkey function simply returns a value which I've feed into the Case statement. In the past things I've translated things like 'mychar:=readkey;' into 'read(kbd,mychar);' no probs, though throwing a readkey on it's own isn't usually done in TP3, and was just wondering if anyone here has made a generic TP3 readkey function without the machine BIOS Interrupts used in my readkey example above??
So now I'm having trouble finding an TP3 solution to this cause my code which the offending code looks like this:
Code:
if keypressed then
case readkey of
#120, #88 : checkvalue(myvalue,ghostvalue);
#109, #77 : begin
myvalue:=myvalue+1;
if myvalue=10 then myvalue:=0;
end;
end;
My readkey function looks like this:
Code:
CONST PendingKey : BYTE = 0;
TYPE Registers = Record
CASE Integer of
1 : (AX,BX,CX,DX,BP,SI,DI,DS,ES,Flags : Integer);
2 : (AL,AH,BL,BH,CL,CH,DL,DH : Byte);
END;
FUNCTION ReadKey : char;
VAR regs : registers;
BEGIN
If Pendingkey<>0 then BEGIN
Readkey:=chr(Pendingkey);
Pendingkey:=0;
END;
ELSE BEGIN
regs.ah:=0;
intr($16,regs);
if regs.AL=0 then Pendingkey:=Regs.AH;
Readkey:=CHR(regs.AL);
end;
end;
I guess the trouble is I've been trying to use a machine equivalent (being a CPC), though it doesn't quite work the same as an IBM Interrupt 16 - even though it states it checks if a key has been pressed without waiting, I've good back to basics in writing a program which returns the keypress values - which maybe part of the problem. I guess with my code simply checks for a keypress it goes into checking which key has been pressed, the readkey function simply returns a value which I've feed into the Case statement. In the past things I've translated things like 'mychar:=readkey;' into 'read(kbd,mychar);' no probs, though throwing a readkey on it's own isn't usually done in TP3, and was just wondering if anyone here has made a generic TP3 readkey function without the machine BIOS Interrupts used in my readkey example above??