home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.pascal
- Path: sparky!uunet!mcsun!sunic!kth.se!kjell
- From: kjell@elixir.e.kth.se (Kjell Rilbe)
- Subject: Re: have wherey - how to modify for wherex?
- Message-ID: <1992Aug17.152527.17246@kth.se>
- Sender: usenet@kth.se (Usenet)
- Nntp-Posting-Host: elixir.e.kth.se
- Organization: Dept. of EE, Royal Institute of Technology, Stockholm, Sweden
- References: <1992Aug17.135257.18261@javelin.sim.es.com>
- Date: Mon, 17 Aug 1992 15:25:27 GMT
- Lines: 59
-
- In article <1992Aug17.135257.18261@javelin.sim.es.com> tpehrson@javelin.sim.es.com writes:
- >here's my wherey function (to find the cursor row) - how do i modify it to
- >find the wherex (cursor column)?
- >
- >function wherey:byte;
- > var reg:registers
- > begin
- > fillchar(reg,sizeof(reg),0);
- > reg.ax:=$0300; {change this to what?}
- > intr($10,reg);
- > with reg do
- > wherey:=hi(Dx)+1;
- > end;
-
- I'm taking the liberty to "clean up" this procedure ;-)
-
- FUNCTION WhereY : Byte;
- VAR Reg : Registers;
- BEGIN
- WITH Reg DO BEGIN
- AH:=$03; { BIOS function to get cursor position. }
- BH:=$00; { Text page number, normally 0, but can be 0-7. }
- Intr($10,Reg);
- WhereY:=DH; { Same as Hi(DX), check Ctrl-F1 on Registers! }
- END;
- END;
-
- FUNCTION WhereX : Byte;
- VAR Reg : Registers;
- BEGIN
- WITH Reg DO BEGIN
- AH:=$03;
- BH:=$00;
- Intr($10,Reg);
- WhereX:=DL; { Same as Lo(DX). }
- END;
- END;
-
- Simple, right?
-
- But, why don't you use the WhereX and WhereY functions in the CRT unit?????
- They work just fine. The only difference is they give you coordinates
- X=1..80 and Y=1..25, instead of beginning with 0, but that's easy to fix:
-
- USES CRT;
-
- FUNCTION WhereX : Byte;
- BEGIN
- WhereX:=CRT.WhereX-1;
- END;
-
- ...
-
- Or, you can just check the BIOS data area. I don't remember the addresses
- right now, but that info can easily be found.
-
- /Kjell Rilbe
-
- P.S. I know, this did get a bit lenghty......
-