Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2014-05

How To Rewrite/Replace Below MEM And MEMW

4 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

nitinjain

Hi,

Could any one help on replacing or rewriting below MEM and MEMW function for 32 bit OS.

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

PROCEDURE draw_window_outline(top_left_x,
top_left_y,
width,
height,
style,
fore,

                              back      : BYTE);
VAR
   x,y    : BYTE;
   offset : INTEGER;
BEGIN
     IF (style255) AND (width>2) AND (height>2) THEN
     BEGIN
          offset:=(top_left_x-1)*2
                 +(top_left_y-1)*160;
          MEM[$B800:offset]:=top_left_corner[style];
          MEM[$B800:offset+1]:=back*16+fore;
          FOR x:=1 TO (width-2) DO
          BEGIN
               MEM[$B800:offset+x*2]:=horizontal[style];
               MEM[$B800:offset+x*2+1]:=back*16+fore;
          END;
          MEM[$B800:offset+(width-1)*2]:=top_right_corner[style];
          MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
          FOR y:=1 TO (height-2) DO
          BEGIN
               MEM[$B800:offset+y*160]:=vertical[style];
               MEM[$B800:offset+y*160+1]:=back*16+fore;
               MEM[$B800:offset+(width-1)*2+y*160]:=vertical[style];
               MEM[$B800:offset+(width-1)*2+y*160+1]:=back*16+fore;
          END;
          offset:=(top_left_x-1)*2
                 +(top_left_y+height-2)*160;
          MEM[$B800:offset]:=bottom_left_corner[style];
          MEM[$B800:offset+1]:=back*16+fore;
          FOR x:=1 TO (width-2) DO
          BEGIN
               MEM[$B800:offset+x*2]:=horizontal[style];
               MEM[$B800:offset+x*2+1]:=back*16+fore;
          END;
          MEMW[$B800:offset+(width-1)*2]:=bottom_right_corner[style];
          MEM[$B800:offset+(width-1)*2+1]:=back*16+fore;
     END;
END;

----------------------------------------------------------- Regards,
Nitin

View this message in context: http://free-pascal-general.1045716.n5.nabble.com/How-To-Rewrite-Replace-Below-MEM-And-MEMW-tp5719283.html Sent from the Free Pascal - General mailing list .
Tomas Hajny
to nitinjain

On Tue, May 20, 2014 10:01, nitinjain wrote:

Hi Nitin,

Could any one help on replacing or rewriting below MEM and MEMW function for 32 bit OS.

.
.

MEM[$B800:offset]:=top_left_corner[style];

.
.

Have you already tried the recommendations discussed in a recent thread here (including my e-mail sent on the 12th of May)?

If yes, have you faced any issues which you need to resolve (which ones)?

If not, is there something unclear in the previous e-mails which prevents you from using those recommendations and which you would need to clarify first?

I'd be happy to help you, but I don't think that there's much on top of the rather straightforward translation of the Mem and MemW references to accesses of the VideoBuf pointer provided by unit Video which I already tried to describe. As you probably understand, the only difference between Mem and MemW in this context is the fact that in case of MemW you address the whole TVideoCell word element whereas in case of Mem you only change the upper or lower byte of that word. However, your code usually updates the two bytes one after the other anyway, so you can combine the two following Mem[] references to one assignment to VideoBuf^[]. If you need more, you'd need to be clearer in your needs.

Regards

Tomas

Tomas Hajny
to nitinjain
nitinjain wrote 5 lines
Thanks Tomas, Yes, I have allready followd the steps which you have given in last post (Video Unit), but it is throwing runtime error that is: *"Program Received Signal SIGSEGV Segmentation fault"*.

Have you managed to identify the exact code (line) giving the SIGESGV (e.g. in debugger or at least by compiling with -gl)? Can you post your (crashing) fully compilable source, so that others could check and test it?

Tomas