Solved

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

Posted on 1998-06-08
7
178 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
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.

 

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

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

With the rising number of cyber attacks in recent years, keeping your personal data safe has become more important than ever. The tips outlined in this article will help you keep your identitfy safe.
A look at what happened in the Verizon cloud breach.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

623 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