Solved

Please answer quickly :)

Posted on 2000-05-01
11
235 Views
Last Modified: 2010-04-16
When I'm drawing in 640X400, or 1280X1024, or what ever, I can't draw onto the bottom parts of the screen.  I have the unit from TDS, but I can't use it on my compler, since 5.5 dosn't use the asm command.
I have a nice BMP reading program, and can't use it since it's all bunched up on the top of the screen!!!!
I'm trying to write directly to the screen using mem, but it still wraps around.  I'm, sending the data to $a000, if that helps.  
Sorry about the low points, but I'm starting to hurt here, and since I just got my first computer, I know I'll be asking a lot of questions real soon.
0
Comment
Question by:Ozzy_98
[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
  • 6
  • 4
11 Comments
 

Author Comment

by:Ozzy_98
ID: 2768064
Damn this is hard.
ax = $4f05
bx = 0
dx = the bank you want to use
call intr ($10,regester)

Is this right?
You mean I need to switch like this four times to show the whole thing? All these interupts will kill the speed!
So, when I get so far down the screen, I switch banks?  A demo-code will help here.  Try not to use the asm code, since I have that from TDS.
0
 

Author Comment

by:Ozzy_98
ID: 2768095
And every 65536 pixels, you add one to the bank number.  I get it now.  So, insted of giving me an answer, can anyone give me some pointers?  I'll give my points to the best one.
Like, how to use mode 111h, which is 16-bit color, right?
0
 

Author Comment

by:Ozzy_98
ID: 2768116
Ok, no one tell me to use a lookup table, I'm doing that now.  But any help on speeding this up will help. Thanks for any help, I'll try not to ask any more questions I can figure out myself.
0
Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

 
LVL 1

Accepted Solution

by:
columbo666 earned 15 total points
ID: 2768306
ok. you got 32 values for red, 64 values for green and 32 values for blue.

and thats the order :

¦ RRRRR GGG ¦ GGG BBBBB ¦



so you write now :

memw[$a000:(640*y+x) shl 1]:=...

memw : because there are 2 bytes for each pixel
$a000 : is the segment of the video-page
640*y : because the screen ist 640px width
+x : for the x-pos of the pixel
shl 1 : because there are 2 bytes for each pixel


.... shl 1]:=
round(r/255*31) shl 11+
round(g/255*63) shl 5+
roung(b/255*31);

that would be ok, but we can speed it up :

memw[$a000:(640*y+x) shl 1]:=
((r shr 3) shl 11)+
((g shr 2) shl 5)+
(b shr 3);

anyway this is slow as a slug. lets speed it up again :

memw[$a000:(y shl 8)+(y shl 10)+(x shl 1)]:=
((r shr 3) shl 11)+
((g shr 2) shl 5)+
(b shr 3);


(y*128)+(y*512)+x is much faster than (y*640)+x.

now you could replace also the ...shr 3) shl 11) with some binary and's, but it gets actually slower.

----------------------------------

so finally the code for putting a pixel is :


var oldpage:byte;
procedure setpix(x,y:longint;r,g,b:byte)
var addr:longint;page,ofs:word;
begin
   addr:=(y shl 8)+(y shl 10)+(x shl 1);
   page:=addr shr 16;
   ofs:=addr and 65536;
   if page<>oldpage then begin
      oldpage:=page;
      setpage(page); {this is your problem}
   end;
   memw[$a000:ofs]:=
      ((r shr 3) shl 11)+
      ((g shr 2) shl 5)+
      (b shr 3);
   {the pixel should be set}
end;

ok ?
0
 
LVL 1

Expert Comment

by:columbo666
ID: 2768311
perhaps you must change the "words" to "longints", else you're getting an overflow (perhaps)...

greetings, columbo666
0
 
LVL 1

Expert Comment

by:columbo666
ID: 2768315
are you scottish (so MANY points)... *grin*
0
 
LVL 12

Expert Comment

by:Hypo
ID: 2769809
Hey, I have written a graphic unit that works with the VESA modes... I think it's pretty easy to use, and it works for both 256color and Hicolor modes.

Give me your email if you want it.

*It comes along with complete source and a demo* ;)
0
 

Author Comment

by:Ozzy_98
ID: 2770052
memw ? I didn't know anything about a command called memw.  Only one I know is mem, and I can't find memw in the help file.  Any help there would be great.  Nothing worse then discovering you don't know a simple command.

As for the line :
(y*128)+(y*512)+x is much faster than (y*640)+x
 that part I knew from Denthor of Asphyxia (got to love his trainers), but the rest, that realy helps to clear things up.  I figured how to switch pages, but that stuff helped clear things up.

To Hypo: Thanks for the help on these questions.  You (and anyone else) can e-mail your unit (or any good demos/source) at:
Ozzy_98@msn.com
If you keep helping me out like this, I'll have to ask a question just so I can give you some points. :)


0
 

Author Comment

by:Ozzy_98
ID: 2770125
Hey! I need to use shl 7 and 9, not 8 and 10. (that would be 256 *1024, right? I might just be figuring your code differntly then you ment.)
0
 
LVL 1

Expert Comment

by:columbo666
ID: 2770371
hmm... i thougt, you would be in 16bit color mode. then every pixel takes 2 bytes ->
you can use (640*y+x)*2 OR (1280*y+x+x). do you know what i mean ?

i just "included" the "shl 1" into the other "shl"'s. clear ?

to memw[... :
memw writes 2 bytes to the ram. you could use 2 x mem[..., but memw[ ist much faster than mem[.

if you use mem[ you have to split the word in 2 bytes. the easiest way is the following (not sooo fast) :

------------------------------------

procedure storew(seg,ofs,b:word);
begin
  mem[seg:ofs]:=lo(b);
  mem[seg:ofs+1]:=hi(b);
end;

--------------------------------------

to use this procedure, you have to change all

memw[$a000:x*y]:=r shl 5 (for example)

to

storew($a000,x*y,r shl 5);

clear ?
0
 

Author Comment

by:Ozzy_98
ID: 2771423
Yep, Thanx.  640*480*256 is too much work for me right now, so 16-bit will kill me.  I'd just never find the time to get anything done.  I'm sticking to mode 13h for my games, since it's easer to make my sprites.  I'm just using hi-res now for title screens and such, and becouse I'm curious about it.

And just so you know, my knowlage of Pascal is 'spotty', and I might not know some things common to others.  I'm just learning chain-4, and I've known about mode-x and 13h for little over one month. Hell, I've only had an IBM computer since the begining of march.  I took pascal in school (5 years ago), and used it very little since then, just a little here and there on other people's computers.  Before this computer, the only computer I ever owned was a Commandore 64, just slightly diffrent then an IBM. :)
I didn't even go to college even though I had a fair-sized scollership, but stayed on the family farm here in Ohio.  I've just now gotten around to working on computers again.  (And no one try to tell me to leave farming becouse programing is where the money is.  I'm in farming only for the money, which for us at least, is pretty good. :)
0

Featured Post

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.

Question has a verified solution.

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

Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
Let's take a look back at the commercialization of the internet to understand why keeping it open and neutral is in our best interest as a society.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

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