Author Topic: Horror Pointer  (Read 6141 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
Horror Pointer
« on: February 26, 2013, 06:04:27 AM »
Deleted.
« Last Edit: May 05, 2015, 11:46:15 AM by Peter »

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #1 on: February 26, 2013, 09:21:11 AM »


Actually, it turned out to be a sensitivity to tabs in the #define macros. How devious is that!

Thanks Peter.

PS Oxygen updated later in this thread


« Last Edit: February 27, 2013, 02:19:43 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #2 on: February 26, 2013, 11:02:26 AM »
Yes let is useful, it automatically creates an appropriate variable type and assigns a value, including pointered types.

The bug was definitely a tab problem. My examples are now working. Is the new dll in the right place?
« Last Edit: February 26, 2013, 11:10:39 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #3 on: February 26, 2013, 12:13:45 PM »
Depending on how you have declared PollEvents:

extern DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event);

I could not find the defintion for SDL_Event, but I think the  parameter shout not have the addressof prefix '@'
« Last Edit: February 26, 2013, 03:49:12 PM by Charles Pegge »

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #4 on: February 26, 2013, 03:22:11 PM »
As I lay there half way between dreaming and waking, I thought " Hey! Peter is not using cdecl!"

Without cdecl, a loop will eventually drain your entire stack whenever you go into a loop.

Currently bind does not support cdecl. It just makes the call.

The alternative is to use standard declarations, with or without parameter specifiers (...).

extern cdecl lib "sdl.dll"
  ! SDL_AddTimer
  ! SDL_AllocRW
  ! SDL_AudioDriverName
  !SDL_AudioInit
  ! SDL_AudioQuit
...
end extern


If you define your functions this way,(unprototyped), then of course you need to use the @ operator for passing params byref.

Charles
 

JRS

  • Guest
Re: Horror Pointer
« Reply #5 on: February 26, 2013, 06:36:09 PM »
Peter,

Isn't there a C example for SDL that can give you some guidance with this? When things don't work for me, I try and find examples that are close enough that do work.

This is what separates the men from the boys. Don't give up, take a break and come back to it.

John

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #6 on: February 26, 2013, 11:59:55 PM »

Using proper C or Basic headers is one solution, but don't give up yet Peter, I haven't. There is something else I need to do to make cdecl work with unprototyped declarations.

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #7 on: February 27, 2013, 02:17:46 AM »
I have made a few corrections here and implemented cdecl support for both bind and unprototyped declarations - so you now have a choice, Peter. I used your sdl.inc here

I found Google was the best way to get information about SDL. The online documentation is very good.

Code: [Select]
extern cdecl lib "sdl.dll"
  include "sdl.inc"
end extern
SDL_Init SDL_INIT_EVERYTHING

SDL_SURFACE *image
SDL_SURFACE *screen

SDL_Event   Event

sys hfile 'rwops pointer treated as a handle

@screen=SDL_SetVideoMode 320,240,32,SDL_DOUBLEBUF | SDL_SWSURFACE  
hfile=SDL_RWFromFile "bmp\alienmoon.bmp","rb"
@Image=SDL_LoadBMP_RW hfile,1
SDL_UpperBlit @image, 0, @screen, 0
SDL_FreeSurface @image
SDL_Flip @screen
do
  e=SDL_PollEvent(@Event)
  if e
    'print event.type
    if Event.type=SDL_xQUIT
      SDL_Quit
    end if
  end if
  Sdl_Delay(10)
end do

Charles

Oxygen reposter later
« Last Edit: March 02, 2013, 09:24:07 AM by Charles Pegge »

Aurel

  • Guest
Re: Horror Pointer
« Reply #8 on: February 27, 2013, 04:32:21 AM »
I also want try this but i am not sure that i have right version of sdl.dll
so which version to use ?

Aurel

  • Guest
Re: Horror Pointer
« Reply #9 on: February 27, 2013, 04:43:11 AM »
Ok i download from SDL site,
It looks that Charles example work and load image on black background
but after closing app stuck in memory,look into Task manager.
So i think that SDL_Quit not work properly... :-\

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #10 on: February 27, 2013, 05:04:10 AM »
Yes I get the same problem, Aurel. Will investigate...
« Last Edit: February 27, 2013, 05:33:00 AM by Charles Pegge »

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #11 on: February 27, 2013, 05:31:22 AM »
This does a clean exit :)

Code: [Select]
extern cdecl lib "sdl.dll"
  include "sdl.inc"
end extern
SDL_Init SDL_INIT_EVERYTHING

SDL_SURFACE *image
SDL_SURFACE *screen

SDL_Event   Event

sys hfile 'rwops pointer treated as a handle

@screen=SDL_SetVideoMode 320,240,32,SDL_DOUBLEBUF | SDL_SWSURFACE 
hfile=SDL_RWFromFile "bmp\alienmoon.bmp","rb"
@Image=SDL_LoadBMP_RW hfile,1
SDL_UpperBlit @image, 0, @screen, 0
SDL_Flip @screen
do
  e=SDL_PollEvent(@Event)
  if e
    'print event.type
    if Event.type=SDL_xQUIT
      exit do
    end if
  end if
  Sdl_Delay(10)
end do

SDL_FreeSurface @image
SDL_FreeSurface @screen
SDL_Quit

JRS

  • Guest
Re: Horror Pointer
« Reply #12 on: February 27, 2013, 07:31:52 AM »
Peter,

I downloaded your attachments (.bmp / fonts) but there was no DLL or .inc file. Are we suppose to use the original for this example?

John

JRS

  • Guest
Re: Horror Pointer
« Reply #13 on: February 27, 2013, 09:14:37 AM »
Peter,

Code: [Select]
if Event.key.keysym.sym = SDLK_ESCAPE   '< key trouble    


/** Keyboard event structure */
typedef struct SDL_KeyboardEvent {
   Uint8 type;   /**< SDL_KEYDOWN or SDL_KEYUP */
   Uint8 which;   /**< The keyboard device index */
   Uint8 state;   /**< SDL_PRESSED or SDL_RELEASED */
   SDL_keysym keysym;
} SDL_KeyboardEvent;


I couldn't locate the SDL_keysym type structure in SDL_events.h.


John
« Last Edit: February 27, 2013, 09:31:31 AM by JRS »

JRS

  • Guest
Re: Horror Pointer
« Reply #14 on: February 27, 2013, 11:01:31 AM »
I hope Charles (O2) does a better job of finding structures in .h files then I.  >:(

The structure was 4 levels down into the INCLUDE stack so I don't feel so bad.

« Last Edit: February 27, 2013, 11:47:36 AM by JRS »