array into XMS problem 
Author Message
 array into XMS problem

Hello. The following, is supposed to get data (a picture) from XMS memory
and put it into an array.  I have two solutions one of which works, but I
can't use the other solutoion which is the one I need.

solution 1:
   XMSToReal(baddr,0,virtual_screen^,64000);
   Move (virtual_Screen^,mem [VGA:(0)],64000);
----------
ok. Plain and simple.  This transfers "baddr" [which is a 64kb block (or
whatever it is called) in the XMS memory], to a virtual_screen [which is a
array of 64000 of byte].  It then transfers that virtual_screen to the
display.  This works but it doesn't do what I want it to.  I want it to only
get a certain area of the "baddr" screen and store it which I tried to do in
the second solution:

solution 2:
{get a car from the xms memory}
{x1,y1 and x2,y2 are the co-ordinants of a box.  (x1,y1) is the co-ordinant
 of the top left corner, and x2,y2 is the co-ordinant of te bottom-left
corner
          x1:=0;
          y1:=0;
          x2:=320;
          y2:=200;
          j:=100;
          for j:=j to 200 do
          begin
               XMSToReal(baddr,((320*j)+x1),virtual_screen^,(x2));
               Move (virtual_screen^,mem [VGA:(j*320)],x2);
          end;
-----
There it is.  Is supposed to move a 320 pixel line from "baddr" in the XMS
to virtual_screen^ and then write that line from the virtual_screen to the
display.  It sould do this 200 times (for 200 rows).  The reason I need to
use this solution instead of the first, is because I only need certain areas
of the screen to be displayed.

 The problem is that the second half of the screen (from row 102 and on), is
a copy of row 102.  I think it is a problem with the calculations but I
can't seem to figure it out.  Can someone please help.

Thank you!
Nektarios Ioannides (aka. Nick)



Wed, 18 Jun 1902 08:00:00 GMT  
 array into XMS problem

Quote:

> {x1,y1 and x2,y2 are the co-ordinants of a box.  (x1,y1) is the co-ordinant
>  of the top left corner, and x2,y2 is the co-ordinant of te bottom-left
> corner
>           x1:=0;
>           y1:=0;
>           x2:=320;
>           y2:=200;
>           j:=100;
>           for j:=j to 200 do

Did it ever occur to you that this is a *really* bad construction?

Quote:
>           begin
>                XMSToReal(baddr,((320*j)+x1),virtual_screen^,(x2));
>                Move (virtual_screen^,mem [VGA:(j*320)],x2);
>           end;
>  The problem is that the second half of the screen (from row 102 and on), is
> a copy of row 102.  I think it is a problem with the calculations but I
> can't seem to figure it out.  Can someone please help.

Try it with a better loop (for j := 100 to 200 will do for a start). I think
you'd also want to change x2 to (x2-x1) or (x2-x1+1) - as x1 is 0 here that
won't matter too much initially, so I'd suggest that your main problem is
probably the loop control.

--
______________________________________________________________________
     The Scarlet Manuka,      |        Nitpickers' Party motto:
  Pratchett Quoter At Large,  |  "He who guards his lips guards his
 First Prophet of Bonni, is:  |  soul, but he who speaks rashly will

______________________________|_______________________________________



Wed, 18 Jun 1902 08:00:00 GMT  
 array into XMS problem

Quote:

>solution 2:
>{get a car from the xms memory}
>{x1,y1 and x2,y2 are the co-ordinants of a box.  (x1,y1) is the co-ordinant
> of the top left corner, and x2,y2 is the co-ordinant of te bottom-left
>corner
>          x1:=0;
>          y1:=0;
>          x2:=320;
>          y2:=200;
>          j:=100;
>          for j:=j to 200 do
>          begin
>               XMSToReal(baddr,((320*j)+x1),virtual_screen^,(x2));
>               Move (virtual_screen^,mem [VGA:(j*320)],x2);
>          end;
>-----

My guess is that you have defined j as an integer. This causes the
multiplication to be signed. Instead define j as a word, similarly other
variables should also be words.

However, it should be better to move the data from XMS to base memory
with one XMSToReal and then move it in parts to the screen. You should
start by defining:

Type Tscreen=array[0..199,0..319] of byte;
     PScreen=^TScreen;

Var Screen:Tscreen Absolute $A000:0;
    Virtual_screen:Pscreen;

Then

XMSToReal(handle,0,VirtualScreen^,64000);
for i:=100 to 200 do...

Note that the first parameter is a handle, not an address. Also if you
really want to move the while second half, or any other number of full
rows, you do not need any loop.

Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 array into XMS problem
once again..... thanks!!!
....I should put you in my program's credits :)


Quote:


> >solution 2:
> >{get a car from the xms memory}
> >{x1,y1 and x2,y2 are the co-ordinants of a box.  (x1,y1) is the
co-ordinant
> > of the top left corner, and x2,y2 is the co-ordinant of te bottom-left
> >corner
> >          x1:=0;
> >          y1:=0;
> >          x2:=320;
> >          y2:=200;
> >          j:=100;
> >          for j:=j to 200 do
> >          begin
> >               XMSToReal(baddr,((320*j)+x1),virtual_screen^,(x2));
> >               Move (virtual_screen^,mem [VGA:(j*320)],x2);
> >          end;
> >-----

> My guess is that you have defined j as an integer. This causes the
> multiplication to be signed. Instead define j as a word, similarly other
> variables should also be words.

> However, it should be better to move the data from XMS to base memory
> with one XMSToReal and then move it in parts to the screen. You should
> start by defining:

> Type Tscreen=array[0..199,0..319] of byte;
>      PScreen=^TScreen;

> Var Screen:Tscreen Absolute $A000:0;
>     Virtual_screen:Pscreen;

> Then

> XMSToReal(handle,0,VirtualScreen^,64000);
> for i:=100 to 200 do...

> Note that the first parameter is a handle, not an address. Also if you
> really want to move the while second half, or any other number of full
> rows, you do not need any loop.

> Osmo



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. move array to XMS problem... @#$%@#$@@$!@#$!@

2. Big arrays in XMS?

3. TP7 XMS problems

4. XMS Problems

5. Please help with this problem!!ARRAY problem

6. problem passing array values.

7. Pascal Problem...Array[0] in String.

8. Problems passing a field array as argument to InsertRecord

9. Array Problem

10. Array problem

11. Array problems

12. Array Problem

 

 
Powered by phpBB® Forum Software