Solved

Please answer quickly :)

Posted on 2000-05-01
11
201 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
  • 6
  • 4
11 Comments
 

Author Comment

by:Ozzy_98
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 1

Accepted Solution

by:
columbo666 earned 15 total points
Comment Utility
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
Comment Utility
perhaps you must change the "words" to "longints", else you're getting an overflow (perhaps)...

greetings, columbo666
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 1

Expert Comment

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

Expert Comment

by:Hypo
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
Marketing can be an uncomfortable undertaking, especially if your material is technology based. Luckily, we’ve compiled some simple and (relatively) painless tips to put an end to your trepidation and start your path to success.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now