Solved

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

Posted on 1998-06-08
7
170 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

No single Antivirus application (despite claims by manufacturers) will catch or protect you from all Virus / Malware or Spyware threats. That doesn't stop you from further protecting yourself however - and this article is to show you how.
Although a lot of people devote their energy toward marketing for specific industries, there are some basic principles that can be applied to any sector imaginable. We’ll look at four steps to take and examine how those steps were put into action fo…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

685 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