Article View: comp.os.os2.programmer
Article #2078Re: Accessing memory (Monitor)
From: Kenneth A. Kahn
Date: Thu, 15 Oct 1992 11:41
Date: Thu, 15 Oct 1992 11:41
53 lines
2553 bytes
2553 bytes
In <1992Oct15.033035.16753@dragon.acadiau.ca> James R. Skinner writes:
>
>I am trying to write a simple program to clear the monochrome monitor
>that I have attached to my system. I am using the GCC compiler and the
>following code:
>
>
>
>main(int argc, char *argv[], char *envp[])
>{
>
> for ( int *p=0x80000 ; *p <= (0x80000+4000) ; (*p++) = 0x2007 );
>
>}
>
>This code causes an access violation exception when executed.
>How can I correct this? How do I get access to this memory area?
>Any help will be appriciated.. Thanks.
First off, you are trying to access the 'physical' Display Buffer Address,
which you can't do under OS/2. In order for you to do this, you will have
to use the 'Logical Video Buffer' which is a virtual address to this memory.
To get a pointer to the LVB use the ViogetBuf API:
/***************************************************************************
* Structure defining the layout of the LVB Buffers. The Buffer consists *
* of Host_Rows*Host_Cols 2-Byte Cells. *
***************************************************************************/
typedef union {
struct {
BYTE Character; /* ASCII Character */
BYTE Color; /* Foreground/Background Color */
} Byte;
UINT Cell; /* Allows access to the 2-byte cell */
} LVB;
LVB *lvb_Ptr; /* Logical Video Buffer */
USHORT lvb_Size; /* Size of LVB in bytes */
VioGetBuf(&lvb_Ptr,&lvb_Size,0);
However, if all you want to do is clear the screen, all you have to do is
use the VioScrollUp API:
BYTE Cell[2];
USHORT CellCount = 2;
VioReadCellStr(Cell,&CellCount,1,1,0);
Cell[0] = 0x20;
VioScrollUp(0,0,-1,-1,-1,Cell,0);
the values -1 effectively clear the screen. The VioReadCellStr is so you
can maintain the current Bg/Fg color attributes.
Technical Details
Message-ID:
<19921015.045120.701@almaden.ibm.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!PKSMRVM.VNET.IBM.COMReferences:
<1992Oct15.033035.16753@dragon.acadiau.ca>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!PKSMRVM.VNET.IBM.COM From: KENKAHN@PKSMRVM.VNET.IBM.COM (Kenneth A. Kahn) Message-ID: <19921015.045120.701@almaden.ibm.com> Date: Thu, 15 Oct 92 07:41:54 EDT Newsgroups: comp.os.os2.programmer Subject: Re: Accessing memory (Monitor) Organization: Staff of IBM Fellow - IBM Personal/370 Disclaimer: This posting represents the poster's views, not those of IBM News-Software: UReply 3.0 X-X-From: KENKAHN@PKSMRVM.VNET.IBM.COM (Ken Kahn) References: <1992Oct15.033035.16753@dragon.acadiau.ca> Lines: 53