Hello! Let me first introduce me
. I actually started programming many years ago with Turbo Pascal, I believe it was with the computer club at my high school, that would be 1994 or something. And right now I still have some little programs lying around that I wrote around the period of 1996 until 2000, most of them written in Turbo pascal, Borland pascal or delphi.
Right now i'm trying to compile a little game I made back in those days for a 386 or 486 machine in DOS. It uses 2 pascal libraries that I didn't make, namely load_gif.pas (to load a GIF) and games.pas (to get around the 'default' keyboard handler that pauses after your first keypress and doesn't allow multiple keys being pressed at once, which is essential for games). One of the differences between freepascal and turbo pascal is that inline statements work differently. The unit 'games.pas' uses some of it, which I think should be able to be converted to use just 'asm' statements. But since I don't know much about assembler I couldn't really properly get around it.
This is the section that I need to convert.
procedure sti;
inline($fb); { STI: set interrupt flag }
procedure cli;
inline($fa); { CLI: clear interrupt flag -- not used }
procedure calloldint(sub: pointer);
{ calls old interrupt routine so that your programs don't deprive the computer
of any vital functions -- kudos to Stephen O'Brien and "Turbo Pascal 6.0:
The Complete Reference" for including this inline code on page 407 }
begin
inline($9c/ { PUSHF }
$ff/$5e/$06) { CALL DWORD PTR [BP+6] }
end;
which gets used in a number of places.
procedure newkbdint; interrupt; { new keyboard handler }
begin
keydown[port[$60] mod 128] := (port[$60] < 128); { key is down if value of
60h is less than 128 --
record current status }
if port[$60] < 128 then wasdown[port[$60]] := true; { update WASDOWN if the
key is currently
depressed }
calloldint(oldkbdint); { call old interrupt }
mem[$0040:$001a] := mem[$0040:$001c]; { Clear keyboard buffer: the buffer
is a ring buffer, where the com-
puter keeps track of the location
of the next character in the buffer
end the final character in the
buffer. To clear the buffer, set
the two equal to each other. }
sti
end;
procedure initnewkeyint; { set new keyboard interrupt }
var keycnt: byte;
begin
for keycnt := 0 to 127 do begin { reset arrays to all "False" }
keydown[keycnt] := false;
wasdown[keycnt] := false
end;
getintvec($09, oldkbdint); { record location of old keyboard int }
setintvec($09, addr(newkbdint)); { this line installs the new interrupt }
sti
end;
procedure setoldkeyint; { reset old interrupt }
begin
setintvec($09, oldkbdint);
sti
end;
Could you please help me with these, and how to call them from these functions?
This is what I came up with myself, would that work?
procedure sti;
begin;
asm
sti
{ STI: set interrupt flag }
end;
end;
procedure cli;
begin;
asm
cli
end;
{ CLI: clear interrupt flag -- not used }
end;
procedure calloldint(sub: pointer);
{ calls old interrupt routine so that your programs don't deprive the computer
of any vital functions -- kudos to Stephen O'Brien and "Turbo Pascal 6.0:
The Complete Reference" for including this inline code on page 407 }
begin
asm
pushf
call dword ptr [ebp+6]
end;
{ PUSHF }
{ CALL DWORD PTR [BP+6] }
end;
I added the entire source base as attachments. Keep in mind that I think I made this in 1998 so the code is kinda archaic and lame
.