Article View: comp.sys.atari.st
Article #33791Re: Questions about ST Video Ram
From: John Joubert
Date: Fri, 26 Aug 1988 02:51
Date: Fri, 26 Aug 1988 02:51
57 lines
3260 bytes
3260 bytes
In article <535@skywest.UUCP> brenes@skywest.UUCP (Erasmo Brenes) writes:
>... If the Shifter expects the video ram to start at 32K boundaries,
>then how do I get MWC, or any C program to allocate a 32Kb buffer starting in
>a 32Kb boundary in an efficient manner? An initial thought was to use Malloc()
>to allocate 64Kb and then only use the 32Kb which start in a 32Kb boundary,
>but this method is too wasteful. There's got to be a better way, isn't there?
--------------------------
Here is how I find a 256 byte boundary to put in a screen.
char *blk; /* Pointer to the start of */
/* malloc'ed block. */
char *work_scr; /* New screen desired. */
char *desktop_scr; /* Old screen pointer. */
desktop_scr = (char *)Physbase(); /* Save old screen pointer.*/
/* Find a screen pointer */
/* On a 256 byte boundary. */
work_scr=(char *)( (long)(blk=malloc(32768L)) & 0xffffff00 )+0x0100;
Setscreen(work_scr,work_scr,-1); /* Flip in work screen. */
The "blk" pointer will give you a pointer to the beginning of the actual
block of mem that was malloc'ed, use this at the end of the program to
"free" up the memory.
The "work_scr" gives you the pointer to the new screen that you want to fill
with data.
The "desktop_scr" gives you the pointer to your old desktop. If you want a
graceful exit back to the desktop at the end of your program, make sure
to make this the current screen with the Setscreen() command right before
you exit.
The next line of code is not mine, I got it here off the net a while
back. I don't know who wrote it in it's original state, but it works fine.
It will place your pointer on a 256 byte boundary in your malloc'ed block.
I have not really taken the time to see how exactly it works, I just know that
it does. I was going to write my own ... when the very same day I saw this
thing. I plugged it in and it worked! Not one to re-invent the wheel,
I hardly ever glanced at it again, all that I ever did to it was add in the
"blk=" assignment.
The last line of code of course, sets the screen to the new work area.
Hope this helps,
----------------------------------------------------------------------------
John Joubert | /\ | /\ | _
jpdres13@usl-pc.USL or ... | \|<>|>|> \|<>|>|><`|`|
ut-sally!usl!usl-pc!jpdres13 |-----/|-------/|----------------------
GEnie: J.JOUBERT | \/ \/
-----------------------------------------------------------------------------
Technical Details
Message-ID:
<12@usl-pc.usl.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!usl!usl-pc!jpdres13References:
<535@skywest.UUCP> <2884@bath63.ux63.bath.ac.uk>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!usl!usl-pc!jpdres13 From: jpdres13@usl-pc.usl.edu (John Joubert) Newsgroups: comp.sys.atari.st Subject: Re: Questions about ST Video Ram Message-ID: <12@usl-pc.usl.edu> Date: 26 Aug 88 02:51:50 GMT References: <535@skywest.UUCP> <2884@bath63.ux63.bath.ac.uk> Reply-To: jpdres13@usl-pc.UUCP (John Joubert) Organization: Univ. of Southwestern La., Lafayette Lines: 57