Path: utzoo!mnetor!uunet!husc6!hao!ames!aurora!labrea!rocky!ali From: ali@rocky.STANFORD.EDU (Ali Ozer) Newsgroups: comp.sys.amiga Subject: OpenScreen() problem Message-ID: <883@rocky.STANFORD.EDU> Date: 22 Dec 87 06:58:37 GMT Distribution: na Organization: Stanford University Computer Science Department Lines: 49 [] A chip-memory hog program of mine was losing 256 bytes whenever it failed to open a hires, 4-bit plane, interlaced screen. I finally tracked the problem to the OpenScreen() calls in the following routine. Seems like when OpenScreen() fails in the following example, I lose 128 chip bytes. Because OpenScreen() is called twice, I end up losing 256. Any ideas on why? Is there a problem with OpenScreen(), or am I just being rather blind? (Note: Taking out the font assignment line doesn't help, and neither does running without morerows...) Ali Ozer, ali@rocky.stanford.edu ---------buggy code---------- struct TextAttr NormalFontDesc = {(STRPTR)"topaz.font", 8, 0, 0}; struct Screen *OpenPictureScreen (borderpen, detailpen, depth) int borderpen, detailpen, depth; { struct NewScreen ns; struct NewWindow nw; setmem (&ns, sizeof(ns), 0); setmem (&nw, sizeof(nw), 0); ns.DefaultTitle = (UBYTE *)PROGNAME; /* Some #define'ed string */ ns.Font = &NormalFontDesc; ns.Width = nw.Width = ((struct GfxBase *)GfxBase)->NormalDisplayColumns; ns.Height = nw.Height = ((struct GfxBase *)GfxBase)->NormalDisplayRows * 2; ns.DetailPen = nw.DetailPen = detailpen; ns.BlockPen = nw.BlockPen = borderpen; ns.Depth = depth; ns.Type = nw.Type = CUSTOMSCREEN; nw.Flags = SMART_REFRESH | BORDERLESS | BACKDROP | RMBTRAP | ACTIVATE; nw.IDCMPFlags = MOUSEBUTTONS | MOUSEMOVE | GADGETUP; ns.ViewModes = HIRES | LACE; if (nw.Screen = OpenScreen (&ns)) { if (OpenWindow (&nw)) return (nw.Screen); else CloseScreen (nw.Screen); } else { /* Try with a smaller screen and see if we can open that. */ ns.Width = nw.Width = 640; ns.Height = nw.Height = 400; if (nw.Screen = OpenScreen (&ns)) { if (OpenWindow (&nw)) return (nw.Screen); else CloseScreen (nw.Screen); } } return (NULL); }