Welcome, Guest. Please login or register.

Author Topic: openscreen problems!!!  (Read 5368 times)

Description:

0 Members and 1 Guest are viewing this topic.

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
openscreen problems!!!
« on: March 22, 2004, 08:06:10 PM »
Hello!

I´m trying to open up an ordinary screen. this example comes directly from the RKRM Libraries, page 44.

the problem is that this programs hang my computer. It opens up the screen, and the screen flashes when displaybeep is called and then it waites the 2 seconds, and then everything freezes. I can´t even move the mousepointer.

I have a voodoo card in my machine, and I´m running my ordinary workbench here. But should´nt I be able to open up a standard screen on the other output? Do you have any hint?

Here is the program:
==============================================================
#define INTUI_V36_NAMES_ONLY   /* We will use the newer Intuition names. */

#include     /* Amiga Datatypes */
#include  /* Lots of important intuition! */
#include  /* structures we will be using */

#include   /* Function prototypes */
#include
#include

struct Library *IntuitionBase;  /* Intuition library base */

int main(int argc, char **argv)
{
 UWORD pens[] = { 0 };    /* This is the minimal pen specification */
 struct Screen *my_screen;   /* Pointer to our new custom screen */
 struct ExtNewScreen myscreen_setup; /* Same as NewScreen with tags attached */
 struct TagItem myscreen_tags[2]; /* A small tag array */

 /* Open the library before calling any functions */
 IntuitionBase = OpenLibrary("intuition.library",0);
 if (NULL != IntuitionBase)
 {
  /* Fill in the tag list with the minimal pen specification */
  myscreen_tags[0].ti_Tag=SA_Pens;
  myscreen_tags[0].ti_Data=(ULONG) pens;
  myscreen_tags[1].ti_Tag=TAG_DONE;

  /* The screen is opened two bitplanes deep so that the
  ** new look will show-up better. */
  myscreen_setup.LeftEdge=0;
  myscreen_setup.TopEdge=0;
  myscreen_setup.Width=640;     /* Smaller values here reduce    */
  myscreen_setup.Height=STDSCREENHEIGHT; /* drawing area and save memory. */
  myscreen_setup.Depth=2;      /* Two planes means 4 colors.    */
  myscreen_setup.DetailPen=0;    /* Normal V34 pen colors   */
  myscreen_setup.BlockPen=1;
  myscreen_setup.ViewModes=HIRES;
  myscreen_setup.Type=CUSTOMSCREEN | NS_EXTENDED; /* Extended Newscreen flag */
  myscreen_setup.Font=NULL;
  myscreen_setup.DefaultTitle="My Screen";
  myscreen_setup.Gadgets=NULL;
  myscreen_setup.CustomBitMap=NULL;

  /* Attach the pen specification tags to the ExtNewScreen structure */
  myscreen_setup.Extension=myscreen_tags;

  if (NULL != (my_screen = OpenScreen((struct NewScreen *)&myscreen_setup)));
  {
   /* Screen successfully opened */

   DisplayBeep(NULL);

   Delay(200L); /* Normally the program would be here */

   CloseScreen((struct Screen *) my_screen);

  }
  CloseLibrary((struct Library *) IntuitionBase);
 }
 return 0;
}
==============================================================

thanks for all help that I can get!
/Jörgen
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: openscreen problems!!!
« Reply #1 on: March 22, 2004, 08:20:12 PM »
2 things I noticed:

1) you open Intuition.library by hand. Most compiler allready
provide a symbol IntuitionBase in the standard linklib.

So maybe you are closing the IBase, and than the link-lib-code
tries to do the same when the prog terminates.

Try to put some printf()s or similar in between Delay(),
CloseScreen(), CloseLibrary() and return to find out
where it actually hangs.

2) You use a ExtNewScreen-structure. Better only use tags.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: openscreen problems!!!
« Reply #2 on: March 22, 2004, 08:26:14 PM »
Hello Kronos, and thanks for your reply!

This is an example directly from the RKRM Libraries manual, and for now, I´m only trying to get things to work the old way, before I get to the new thins, like Tags and so on.

Ok, I will try to put in some printf statements, but I doubt, that the text will be visible on the screen. How do I put text on a screen? Is´nt there a function like, Text() or something?

/Jörgen
 

Offline Kronos

  • Resident blue troll
  • Hero Member
  • *****
  • Join Date: Feb 2002
  • Posts: 4017
    • Show only replies by Kronos
    • http://www.SteamDraw.de
Re: openscreen problems!!!
« Reply #3 on: March 22, 2004, 09:31:46 PM »
O.k. got me there ....

a) use a scanf, this will put the prog to an halt till
you hit return in the shell-window.

b) put a delay(200) between CloseScreen and CloseLibrary()
to see where the problem lies. Closing a screen may be
delayed to the next vertical blank, enough time for your
code to hit that suspicious CloseLibrary().

c) remove CloseLibrary, and if that helps also remove OpenLibrary
and put extern in front of the IntuitioBase-definition.


Bout text on Screens:

There is IntuiText() for that, but you shouldn't use that
directly on a screen, but open a window (backdrop-wins are
praticly invisible), and it would be off little use since
we want to know what happens when you close that screen.

It would also be nice if you could tell us what compiler you
use and with which options.
1. Make an announcment.
2. Wait a while.
3. Check if it can actually be done.
4. Wait for someone else to do it.
5. Start working on it while giving out hillarious progress-reports.
6. Deny that you have ever announced it
7. Blame someone else
 

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: openscreen problems!!!
« Reply #4 on: March 22, 2004, 09:48:18 PM »
I use the Storm C V4 compiler/editor. I´m using the default configuration. I´m compiling "debug version".

/Jörgen
 

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: openscreen problems!!!
« Reply #5 on: March 22, 2004, 11:00:19 PM »
Ok, the error seems more complicated than I thought. When running my workbench in aga mode and runs the cpp program, The screen opens up, it flashes and then it seems to close and the system is still running. But I get this message from the Storm C V4 output window: "Screen 0x7877a948 not closed"

So I suspect that the screen does not close properly, and that´s probably the cause to my system freeze also. If the screen does´nt close, I don´t get my WB on the Voodoo card back.

So, why does the screen not close? any hints?

/Jörgen
 

Offline Thomas

Re: openscreen problems!!!
« Reply #6 on: March 23, 2004, 09:55:26 AM »

The program is correct as it is. It works well if compiled with Dice C. It must be the compiler's fault. Try to compile without debug.

The complaint of IntuitionBase closed twice is nonsense. The Amiga Library system maintains an open counter and each and every OpenLibrary must be complemented by a CloseLibrary. If the compiler lib opens the library, it is opened twice and so it must be closed twice either.

Also the complaint about closing IntuitionBase before the screen is closed is nonsense, too. When OpenScreen returns, the program does no longer have any responsibilities against it or against Intuition. Also IntuitionBase will never be flushed from memory because it is always in use by other programs and by the OS itself.

Bye,
Thomas

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: openscreen problems!!!
« Reply #7 on: March 23, 2004, 10:02:53 AM »
Hello Thomas!

Do you have a Voodoo card? It seems to work fine when I'm only using AGA, but not when I have the WB on the Voodoo.

I will try to compile the release version when I get home today.

Is there any else that have a Voodoo and are using Storm C V4, that can test the program?

/Jörgen
 

Offline Thomas

Re: openscreen problems!!!
« Reply #8 on: March 23, 2004, 03:40:14 PM »
Well, I tried it on WinUAE with Picasso96 running. Will try again tonight at home (A4000 + Voodoo).

Additinally I would do what Kronos suggested: drop the NewScreen structure completely and use the OpenScreenTags function.

Here is an example which should work:

Code: [Select]

#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/graphics_protos.h>

int main (void)

{
struct Screen *scr;
struct Window *win;
struct RastPort *rp;

if (scr = OpenScreenTags (NULL,SA_LikeWorkbench,TRUE,TAG_END))
{
Delay (50); /* one second */
if (win = OpenWindowTags (NULL,
WA_CustomScreen,scr,
WA_Left,100,WA_Top,100,
WA_Width,200,WA_Height,100,
TAG_END))
{
rp = win->RPort;
Move (rp,20,40);
Text (rp,&quot;Beep !&quot;,6); /* you won't see DisplayBeep on a Picasso screen */
Delay (50); /* one second */
CloseWindow (win);
}
Delay (100); /* two seconds */
CloseScreen (scr);
}

return (0);
}


Bye,
Thomas

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: openscreen problems!!!
« Reply #9 on: March 23, 2004, 03:51:27 PM »
Quick Q : Are you trying opening an RTG screen or a native one?
int p; // A
 

Offline Thomas

Re: openscreen problems!!!
« Reply #10 on: March 23, 2004, 04:02:45 PM »

Quick Answer: look at the code.

Long Answer: Jörgen opens a native screen (VidewModes = HIRES) and I open a RTG screen (SA_LikeWorkbench,TRUE).

Bye,
Thomas

Offline Thomas

Re: openscreen problems!!!
« Reply #11 on: March 23, 2004, 05:55:31 PM »

Well, I tried both programs on my Amiga with StormC4 and both work as they should.

I too get this strange message "screen 0x09ddcc10 not closed" although I can clearly watch the screen disappear. Must be a compiler error. If I run the program in a shell window with avail before and after it both avails show exactly the same numbers, so no memory is left unfreed.

However, my example with OpenScreenTags works without any messages.

Bye,
Thomas

Offline Karlos

  • Sockologist
  • Global Moderator
  • Hero Member
  • *****
  • Join Date: Nov 2002
  • Posts: 16879
  • Country: gb
  • Thanked: 5 times
    • Show only replies by Karlos
Re: openscreen problems!!!
« Reply #12 on: March 23, 2004, 06:31:30 PM »
Quote

Thomas wrote:

Quick Answer: look at the code.


Guess I deserved that. I was gonna paste the code I use to open RTG screens, but its buried in the private implementation of a class so probably isn't best viewed alone ;-)
int p; // A
 

Offline jonssonjTopic starter

  • Sr. Member
  • ****
  • Join Date: Oct 2003
  • Posts: 254
    • Show only replies by jonssonj
Re: openscreen problems!!!
« Reply #13 on: March 24, 2004, 11:45:04 AM »
Thanks to you all for your replies.

Ok, I will have to take a closer look tonight, when I get home from work. I really, really, really, really!!!!!!!! hope that I get my BPPC card today. I have now been waiting 13 business days if I count today also.

@Thomas
The problem remains though, with the program above. I can't run it, if my WB is on the Voodoo card. My Amiga will freeze totally on the native screen that I have on a second monitor. But if I change my WB screen to the aga mode and use the second monitor only, then it works as you describes above.

Well, I will try your example tonight.

/Jörgen
 

Offline Noster

  • Sr. Member
  • ****
  • Join Date: Jan 2004
  • Posts: 375
    • Show only replies by Noster
Re: openscreen problems!!!
« Reply #14 on: March 25, 2004, 08:51:38 AM »
Hi

@jonssonj

Do you use CyberGraphX ? Which version ?
The older versions (< V.4) are known that they have problems with CyberGraphX-screens and screens opened via the custom-chips at the same time, upgrade to CyberGraphX version 4, look for newer patches vor version 4 in the internet.

Noster
DON\\\'T PANIC
    Douglas Adams - Hitch Hiker\\\'s Guide to the Galaxis