Please answer quickly :)

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.
Ozzy_98Asked:
Who is Participating?
 
columbo666Connect With a Mentor Commented:
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
 
Ozzy_98Author Commented:
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
 
Ozzy_98Author Commented:
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
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.

 
Ozzy_98Author Commented:
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
 
columbo666Commented:
perhaps you must change the "words" to "longints", else you're getting an overflow (perhaps)...

greetings, columbo666
0
 
columbo666Commented:
are you scottish (so MANY points)... *grin*
0
 
HypoCommented:
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
 
Ozzy_98Author Commented:
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
 
Ozzy_98Author Commented:
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
 
columbo666Commented:
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
 
Ozzy_98Author Commented:
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
All Courses

From novice to tech pro — start learning today.