Jump to content

  • Log In with Google      Sign In   
  • Create Account


Virtual screen in 640x480 mode


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
13 replies to this topic

#1 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 August 1999 - 08:11 AM

I'm having problems setting up a virtual screen for 640x480 VESA mode in Borland C++ 5.0. When I allocate 327680 Kb (I use the large memory model) the memset function doesn't work right. And I can't send the screen (in blocks of 64K) to the videocard properly. Anyone has some good routines?

Sponsor:

#2 FlyFire   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 1999 - 10:50 PM

I didn't work with BC 5.0, but v3.1 can't compile in 32bit PM mode, so your restricted with 64K segments and can't just allocate 327680 bytes of memory with malloc. Are you sure you allocating memory right? Or you allocating many blocks by 64K?
And what you get when you trying to send your virtual screen to video memory?

FlyFire/CodeX
http://codexorg.webjump.com


#3 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 August 1999 - 11:01 PM

I've discovered that malloc doesn't work but _fmalloc does.
But still problems. When I try for example to access buffer[65537] then compiler sets a value at buffer[1] (!) while the explanation says that you CAN allocate blocks >64Kb.
When sending it to the screen it just send the first block 5 times in staid of buffer[0],buffer[65536] etc.

#4 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 22 August 1999 - 07:16 AM

This is how i might handle it...
This will not be the cleanest code then again it is just a example so bear with me..

#include

unsigned char *vid_mem = (unsigned char *)0xA0000;

void main() {

unsigned char *back_buffer = (unsigned char *)malloc(width * height * bitdepth);

set_video(whatever);
pixel_stuff_to_back_buffer(back_buffer);
Update_vidmem_from_back_buffer(back_buffer);

set_video(back to whatever);
free(back_buffer);
}

void Update_vidmem_from_back_buffer(char *buffer) {

setpage(0);
memcpy(vid_mem,(unsigned char *)buffer,65536);
setpage(1)
memcpy(vid_mem,(unsigned char *)buffer+65536,65536);
...
...
...
}

I would never work with vid_mem directly cause there is a chance that something could screw up.. as for your memset stuff, that would most likely be used to set a backgroud color.. and you buffer[65537] is that an array? i am a bit confused on what you were trying to do...

E-mail me if ya want specific stuff, and i can help ya out more...
dieraxx@stega.smoky.org


#5 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 07:33 AM

You can use buffers as an array in C++. For example if you put a value at buffer[1] then what you are really doing is:
Asm{
les di, buffer //getting the buffer-address
inc di, 1 //you know, from buffer[1]
mov al, value //the value to transfer
stosb //or mov [es:di], value
};

Since real dos depends a lot on 64Kb stuff you can't access buffer[65537]
(why can you allocate buffers >64Kb when it is almost impossible to access?!).

But on to the subject if you use
memcpy(screen,buffer+65536,65536)
it's just the same as:
memcpy(screen,buffer,65536)
Since the reason I wanted to learn C++ is because you can allocate blocks >64Kb I'm now going to learn DJGPP (it is just C++ with DPMI).
Anyone knows how to use asm in that compiler?
asm { code }; doesn't work (parse error)


#6 Syntax   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 08:15 AM

I have never had problems accessing large arrays or pointers...i also use Watcom C/C++
i dont know if that would really matter,

you said
"memcpy(screen,buffer+65536,65536)
it's just the same as:
memcpy(screen,buffer,65536)"

I dont understand how they are the same..

because you are setting pages in video_memory you obviously have to copy it in segments, maybe i am thinking it all wrong and missing what you are trying to say, please explain though..Talk to ya later


#7 FlyFire   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 09:27 AM

You both messed up a lot here.
bosjoh: in real mode or 16bit pm mode you are restricted with 64K limit. As you write in asm example, BC generates code that uses di register (or other index) to access data. And because di is 16bit register (max 65535 value), you can't access 65537 element of an array. Of caurce, you can write your own code to use edi as index instead of di.

Other way, as Syntax says, is to use
memcpy(vid_mem,buffer+65536,65536);
it's really not the same as
memcpy(vid_mem,buffer,65536)
because in first way you copy memory beginning from 65536 offset of your buffer, and in second, from beginning.

Also, if you will go into DJGPP (i recommend Watcom, really), you can use large arrays without restrictions, because you will run in 32bit flat model. But inline asm there is really beast, but powerful thing. You gotta read about it in online help.

Syntax: if you are using a great thing like Watcom C++, why you still using banks, when you can use LFB addressing? And i don't agree with your words that working directly with video mem is dangerous. I always do so.
Also, if you interested, i'm currently developing a lot of stuff for Watcom C++, which you can find on my homepage. There is also my new VFlat library, which will allow you to use LFB addressing wihtout VESA 2.0 standart.

That's it. If you have any more questions, ask me. Just i worked for all this stuff for a long time and know a lot.

FlyFire/CodeX
http://codexorg.webjump.com


#8 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 09:51 AM

Yep i know that what I said about memcpy wasn't really true but it sure acts the same.
Now I'm using DJGPP and the memory management works fine.
But about Watcom: is it free and if so, where can I download it then (I hope it isn't too big too download)?

I'm really interested in that LFB addressing you talked about. Maybe you can send me an URL or something like that with more info.


#9 Syntax   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 10:00 AM

Good Point FlyFire and I am using the Great Thing know only as Watcom C/C++ I will check out the site, sorry for buggin ya bosjoh i was just confused at what was going on..see ya around

#10 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 08:20 PM

Thanks a lot guys. I'm now searching for watcom and LFB (linear frame buffer).

#11 FlyFire   Members   -  Reputation: 122

Like
Likes
Like

Posted 22 August 1999 - 10:34 PM

bosjoh:
Watcom isn't free and it's very huge. I have full CD version of Watcom 11.0B, and it takes full 650MB. (but i also have ripped v10.0 which installation package takes approx 30-40 mb, don't remember).
You can read about it at www.sybase.com

FlyFire/CodeX
http://codexorg.webjump.com


#12 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 23 August 1999 - 01:54 AM

I guess I should buy Watcom then.
Maybe they're selling a cheaper copy at school (despite the fact that the other students are still working in text-mode, counting numbers or something like that. And no teacher has ever heard of the word assembler).

#13 Anonymous Poster_Anonymous Poster_*   Guests   -  Reputation:

Likes

Posted 27 August 1999 - 07:43 AM

http://www.geocities.com/SiliconValley/Vista/7696/vesasm.zip

#14 bosjoh   Members   -  Reputation: 122

Like
Likes
Like

Posted 27 August 1999 - 08:11 AM

I don't know what you're trying to tell but this page doesn't exist (...)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS