Solved

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

Posted on 1998-06-08
7
171 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

 

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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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

When the s#!t hits the fan, you don’t have time to look up who’s on call, draft emails, call collaborators, or send text messages. An instant chat window is definitely the way to go, especially one like HipChat. HipChat is a true business app. An…
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

752 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