Solved

Find out if coordinate has a text character there>>100 points

Posted on 1998-06-08
7
166 Views
Last Modified: 2010-04-16
I'm having some trouble with a small program i'm writing for fun.  You see, i have this little ascii character that moves around.  What i would like is that i can load a text file, which is displayed onscreen, and if a text character is there, it acts as a wall.  Basically i need some sort of boolean thing that just tells me if a character is writtne there.  THANKS
0
Comment
Question by:hansell
7 Comments
 
LVL 2

Accepted Solution

by:
kellyjj earned 100 total points
ID: 1217098
YOu can do it like this

if mem[b800:0000]='C' then dothis;

the offset inside the mem[] is the memory location for video.  You can read it just like that. However, and I don't remember off the top of my head which is,  even addresses are for attributes, odd for the char. (Could be the other way).
0
 
LVL 1

Expert Comment

by:shivers
ID: 1217099
he's right about the B800 address, but to access it use this formula:

offset := ((y * 80) + x) * 2

where x and y are the coordinates on the screen (zero based - ie 0-79, 0-24 not 1-80,1-25).  The reason for the *2 is that there is one byte for the attribute of the character (ie colour, flashing, etc) and the other is the ASCII code.

I can't quite remember which way round the bytes are though - if that doesnt work just add 1 to the offset.

then use this:

ch := mem[B800:offset];

or to make it faster, embed the equation in the mem[] call.

This is the best way to do this - can be up to 100 times faster than going through the BIOS - let alone a Pascal call.
0
 

Author Comment

by:hansell
ID: 1217100
Thanks for your help, I'll try to work with that...

But if you have any small snippets of code where this is done, that would be much appreciated, considering I don't quite understand all of what you have explained  ):


0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Comment

by:hansell
ID: 1217101
Well, i think i'm doing everything as I was told...but I get an 'unknown identifyer' for 'b800' and i'm not sure what to make it? Here is my snippet of code I was using...

program chartest;

uses crt;

var
offset:integer; {I assume offset would be an integer}

begin
gotoxy(1,1);
writeln('c');
offset:=((1*80)+1)*2; {the "1"'s are the coordinates}

if mem[b800:offset] then  {the b800 is an "unknown identifyer"}
begin
writeln('A character is there!');
end;
end.

NOTE:  I just want the simplest way of doing this, no speed efficiency is required.
0
 

Author Comment

by:hansell
ID: 1217102
Wait!!  I think i know SOMETHING i did wrong...i need to use $b800, so that's one thing solved...but i have another problem then..look at the comments...

Part of above code:
-----------------------------------------------------------------
     if mem[b800:offset] then {I get boolean expression expected?}
     begin
     writeln('A character is there!');
     end;
     end.
-----------------------------------------------------------------

HELP ME PLEASE!!!!!!  I'M DROWNING

0
 

Expert Comment

by:Mukke
ID: 1217103
You need to tell the program what it is looking for:
you either of these as I don't recall of what type mem is.
In the first I use typecasting (turning a variable into another, char)

if char(mem[b800:offset]) = " " then ......
if mem[b800:offset] = " " then ......
if mem[b800:offset] = 32 then ......

I think 1 and 3 results in the same, however I'm not sure.

Mukke

0
 

Expert Comment

by:Mukke
ID: 1217104
Sorry..... the above will trigger if there is NOT a character there. Simply add a NOT after IF or change = to <>

Mukke
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
If your vDisk VHD file gets deleted from the image store accidentally or on purpose, you won't be able to remove the vDisk from the PVS console. There is a known workaround that is solid.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now