🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #8103

Help with Simple Screen Program

#8103
From: Shawn Switenky
Date: Tue, 29 Jan 1991 02:19
123 lines
4925 bytes
Hello All,
	I need help.  I'm learnig both C and Amiga specific programming at
the same time.  I've been trying to get the following program working.  All
it does is create a window on a custom screen, and ten wiat for you to click 
on the close button.  Simple, right?
	What it actally does is hang.  It give me a requester then says:
Software Failed
Error number #80000004
	It compiles and links without any errors or warnings.  When I run it,
it hangs.  I'm using SAS C 5.10a under Workbench 2.02 and using the 2.0
version of includes.
	When I run CodeProbe on it, it hangs after the line:
if (IntuitionBase == NULL) exit(1);
	and I have to reboot the machine.

	I believe I am not successful in opening up the intuition.library, and
it could be because of the version number.  I'm using old documentation ( V1.1
RKM's and Leemon's Inside Amiga Graphics ) and I beleve that the version
number parameter format has changed.  But I believe that a version number of
36 should work right?

	As you see, I am confused and frustrated.  Can anyone spot my problem?
Here is the code.

#include "exec/types.h"
#include "intuition/intuition.h"
#include "stdlib.h"

struct IntuitionBase *IntuitionBase;
struct GfxBase *GfxBase;

struct Screen *CustScr;
struct Window *Wdw;
struct ViewPort *WVP;

#define WHITE        0xFFF
#define RED          0xF00
#define GREEN        0x0f0
#define BLUE         0x00f
#define CYAN         0x0ff
#define PURPLE       0xf0f
#define YELLOW       0xff0
#define BLACK        0x000
#define BGRP   0
#define WHTP   1
#define BLUP   2
#define REDP   3
#define GRNP   4
#define YELP   5     
#define PURP   6     
#define CYNP   7

static USHORT colormap [8] ={BLACK,WHITE,BLUE,RED,GREEN,YELLOW,PURPLE,CYAN};

struct TextAttr StdFont =
{
   "topaz.font",
   TOPAZ_EIGHTY,
   FS_NORMAL,
   FPF_ROMFONT,
};

struct NewScreen NewCustScr =
{
   0,0,                 /* Left Edge, Top Edge                          */
   320,200,3,           /* Width, Depth, Height                         */
   PURP,YELP,           /* Detail Pen and Block Pen                     */
   SPRITES,             /* Special Display Modes                        */
   CUSTOMSCREEN,        /* Screen Type                                  */
   &StdFont,            /* Pointer to Custom Font                       */
   NULL,                /* Pointer to Title Text                        */
   NULL,                /* Pointer to Screen Gadgets                    */
   NULL,                /* Pointer to Custom BitMap                     */
};

struct NewWindow NewWdw =
{
   0,0,                 /* Left Edge, Top Edge                          */
   320,200,             /* Width, Height                                */
   BLUP,WHTP,           /* Block Pen, Detail Pen                        */
   CLOSEWINDOW,         /* IDCMP Flags                                  */
   SMART_REFRESH | ACTIVATE | BORDERLESS | WINDOWCLOSE,                 
                        /* FLAGS                                        */
   NULL,                /* Pointer to first gadget                      */
   NULL,                /* Pointer to Checkmark Image                   */
   NULL,                /* Title                                        */
   NULL,                /* Pointer to Screen structure, dummy           */
   NULL,                /* Pointer to Custom BitMap                     */
   0,0,                 /* Minimum Width, Minimum Height                */
   0,0,                 /* Maximum Width, Height                        */
   CUSTOMSCREEN,        /* Type of screen it resides on                 */
};

void main(void)
{
   /* Open the Intuition and Graphics Libraries,                        */
   /* Get pointers to the routines                                      */

   IntuitionBase = (struct IntuitionBase *)
         OpenLibrary("intuition.library",36);
   if ( IntuitionBase == NULL ) exit(1); 

   GfxBase = (struct GfxBase *)
         OpenLibrary("graphics.library",36);
   if ( GfxBase == NULL ) exit(1);   
 
   if ( (NewWdw.Screen=CustScr=(struct Screen *)OpenScreen(&NewCustScr) ) ==NULL) exit(1);
   
   if ( (Wdw = (struct Window *)OpenWindow(&NewWdw))==NULL) exit(1);
   
   WVP = (struct ViewPort *)ViewPortAddress(Wdw);
   LoadRGB4(WVP,&colormap,8);
   
   Wait(1<<Wdw->UserPort->mp_SigBit);
   
   CloseWindow(Wdw);
   CloseScreen(CustScr);
   CloseLibrary(GfxBase);
   CloseLibrary(IntuitionBase);
}

Shawn Switenky
874226@watt.usask.ca
Technical Details
Message-ID: <43028@nigel.ee.udel.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!caen!uflorida!gatech!udel!mmdf

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!samsung!caen!uflorida!gatech!udel!mmdf
From: 874226@watt.usask.ca (Shawn Switenky)
Newsgroups: comp.sys.amiga.tech
Subject: Help with Simple Screen Program
Message-ID: <43028@nigel.ee.udel.edu>
Date: 29 Jan 91 02:19:24 GMT
Sender: mmdf@ee.udel.edu
Lines: 123