Oxygen Basic

Programming => Problems & Solutions => Topic started by: Peter on January 23, 2016, 11:53:59 AM

Title: Sint64
Post by: Peter on January 23, 2016, 11:53:59 AM
Hi Charles,

I use for a  Sint64 type a QUAD type,  is this alright?
Title: Re: Sint64
Post by: Charles Pegge on January 24, 2016, 01:26:14 PM
Hi Peter,

Sure. (the o2 quad type is a 64bit signed integer)
Title: Re: Sint64
Post by: Peter on January 24, 2016, 02:12:29 PM
Thanks Charles,

I'm writing just a SDL2 library for OxygenBasic.
But I can the sdl_header not directly use, especially the keys definition from sdl.h.
Therefore I do everything by hand.

At the moment, I have trouble with SDL_Rect, somehow it does not work.  ???
I can not imagine that this definition is wrong:

typedef struct SDL_Rect
{
Uint16 x
Uint16 y
Uint16 w
Uint16 h
} SDL_Rect
Title: Re: Sint64
Post by: jack on January 24, 2016, 06:52:50 PM
Peter, a C int is likely to be 32-bit and you are using 16-bit integers.
Title: Re: Sint64
Post by: Peter on January 24, 2016, 11:41:56 PM
Hi Jack,

 :)

typedef struct SDL_Rect
{
  int x, y
  int w, h
} SDL_Rect

But still no success.
Title: Re: Sint64
Post by: jack on January 25, 2016, 07:58:52 AM
sorry Peter, I am out of ideas
if Mike Lobanovsky shows up he may be able to help you.
Title: Re: Sint64
Post by: Aurel on January 25, 2016, 09:12:18 AM


hi Peter look into link:

https://wiki.libsdl.org/SDL_Rect

so if i understand this thing this must be type not typedef

something like we use in windows
TYPE Rect .rc
Title: Re: Sint64
Post by: Peter on January 25, 2016, 09:26:00 AM
Quote
sorry Peter, I am out of ideas

no, I need no help, I only was saying that I have trouble  with SDL_Rect.
nonetheless,  thanks for your help.

that poblem is somewhere else and I will find it.
Title: Re: Sint64
Post by: Peter on January 25, 2016, 09:38:34 AM
Quote
so if i understand this thing this must be type not typedef

something like we use in windows
TYPE Rect .rc

Aurel you need  a warm oven to warm up your brain cells.   ;D
Title: Re: Sint64
Post by: Charles Pegge on January 25, 2016, 09:53:32 AM

Hi Peter,

We don't have a core definition for uint16, but you can use word to define it before the C SDL headers

typedef word uint16
Title: Re: Sint64
Post by: Peter on January 25, 2016, 10:22:39 AM
Thanks Charles,

I already did it.
Code: [Select]
TypeDef byte  uint8
TypeDef word  uint16
TypeDef dword uint32
TypeDef short Sint16
TypeDef int   Sint32
TypeDef quad  Sint64
[/code]
Title: Re: Sint64
Post by: JRS on January 25, 2016, 10:35:52 AM
Quote from: Peter
Aurel you need  a warm oven to warm up your brain cells.

Good point Peter. I didn't consider the weather being a factor.  ;D

Title: Re: Sint64
Post by: Aurel on January 25, 2016, 02:41:25 PM
FYB
SDL sucks anyway  :P
or better to say ..one reason more to not visit this forum...bye
Title: Re: Sint64
Post by: JRS on January 25, 2016, 03:50:39 PM
FYB
SDL sucks anyway  :P
or better to say ..one reason more to not visit this forum...bye

I would wish you well but I would be lying. Sorry life didn't work out for you.
Title: Re: Sint64
Post by: Charles Pegge on January 27, 2016, 06:39:15 AM
Hi Peter,

I looked at the definition in SDL_stdinc.h

Code: [Select]
typedef int16_t Sint16;
/**
 * \brief An unsigned 16-bit integer type.
 */
typedef uint16_t Uint16;
/**

so the solution might be to define before the SDL headers:

typedef word uint16_t
typedef short int16_t

Title: Re: Sint64
Post by: Peter on January 27, 2016, 08:47:15 AM
Hi Charles,

the type-definition what I have is okay!

another thing here is an error  message in this typedef  struct.

 
Code: [Select]
typededef struct SDL_Surface
{
  Uint32 flags               
  SDL_PixelFormat *format   
  int w, h                   
  int pitch                 
  void *pixels             
  void *userdata           
  int locked                 
  void *lock_data           
  SDL_Rect clip_rect         
  struct SDL_BlitMap *map  '< here
  int refcount               
} SDL_Surface
I  got a solution, but whether this is a proper solution I have to test out.

.
Title: Re: Sint64
Post by: Charles Pegge on January 28, 2016, 02:19:45 AM

The problem is that SDL_BlitMap is an undefined private structure.

The solution is to define it before including the SDL headers

typedef struct SDL_BlitMap {}

or hack:

typedef sys SDL_BlitMap  

Title: Re: Sint64
Post by: Peter on January 28, 2016, 07:48:13 AM
Thanks Charles,

that was my solution!

Code: [Select]
typedef struct SDL_BlitMap SDL_BlitMap
Title: Re: Sint64
Post by: Peter on January 28, 2016, 02:12:59 PM
Hi Charles,

solved!
Sdl2 works now
Title: Re: Sint64
Post by: Charles Pegge on January 30, 2016, 02:24:55 AM
Very good!

I will need to adjust o2 struct semantics in a future release, to comply with C.