home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cis.ohio-state.edu!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!relay!relay2!afterlife!mssmith
- From: mssmith@afterlife.ncsc.mil (M. Scott Smith)
- Subject: Re: Direct screen writing; getting to (x,y)
- Message-ID: <1993Jan12.081850.12759@afterlife.ncsc.mil>
- Organization: The Great Beyond
- References: <1993Jan11.235448.22675@afterlife.ncsc.mil> <1993Jan12.021320.7406@nntp.hut.fi>
- Date: Tue, 12 Jan 1993 08:18:50 GMT
- Lines: 59
-
- Juri -- thanks for the information.
-
- > If SCR_X is indeed the width of the display, you will run into trouble
- > with most Macintosh video cards. If it's the same as row_bytes, then
- > things should be almost ok.
-
- I re-wrote the function I posted so that I don't think it uses SCR_X
- anymore. Well, here's the new one:
-
- I do the following when I init the program:
-
- for (y=0; y<=(*screen_len_y); y++)
- line[y] = ((*row_bytes) * y);
-
- And here's my PlotPoint function:
-
- void PlotPoint(long x, long y, long color)
- {
- *(char *)(base_addr + x + line[y]) = color;
- }
-
-
- That avoids the use of SCR_X (and also seems to be about 1.5 times quicker
- than my original version); does this avoid the problem you mentioned? I'd
- like this to be as compatible as possible with all video configurations,
- including bit depth. What would be the easiest way to handle different
- bit depths? My primary concern for now is 8-bit.
-
- > Of course, it doesn't really work. It only works on some hardware, but
- > it will cause big problems with a lot of machines.
-
- Is my new routine a bit more friendly, or does it still have a problem?
-
- > As I said earlier, the keys to compatibly do direct video writes are:
- >
- > SwapMMUMode
- > and ShieldCursor
-
- I haven't messed with ShieldCursor before, so I'll look into that. I
- assume I should be calling SwapMMUMode in my PlotPoint function, right
- before and after I do the plot. Does this eat up much processor time?
- It seems if I'm plotting hundreds of points, then making those hundreds of
- calls might have a performance penalty. But I don't know. (And I guess
- it's necessary in some cases anyway.)
-
- > This works as long as no one changes the screen resolution suddenly. It
- > usually doesn't happen, but I think it's possible under some circumstances.
-
- Someone would do that?? How rude. :) Would the best strategy be to
- periodically check the depth of the screen you're working with, like in the
- event loop, and then to do whatever's necessary if the bit depth suddenly
- changes? (Like maybe put up a dialog that say "hey, don't do that!", or
- re-compute everything.)
-
- Well, thanks for all of your information. It was very helpful.
-
- M. Scott Smith
- (mssmith@afterlife.ncsc.mil)
-
-