Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 1998-06-08
7
Medium Priority
?
193 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 300 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Microsoft's Excel has many features that most people will never need nor take advantage of.  Conditional formatting is one feature that you may find a necessity once you start using it.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

963 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