Author Topic: Horror Pointer  (Read 6142 times)

0 Members and 2 Guests are viewing this topic.

JRS

  • Guest
Re: Horror Pointer
« Reply #15 on: February 27, 2013, 12:32:27 PM »
Peter,

Remind me to invite you to our next camping trip. You sound like just the right person to tell scary stories by campfire.  :D

John

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #16 on: February 28, 2013, 06:29:34 AM »
Hi Peter,

Quite a lot of C stuff is available: (without needing semicolons of course :) )
Perhaps this is the stuff you don't want..

== != >> << ++ --

Code: C
  1. int f cdecl (int a)
  2. {
  3.   a=2
  4.   switch a
  5.   {
  6.     case 1 : print "A" : break
  7.     case 2 : print "B" : break
  8.     case 3 : print "C" : break
  9.   }
  10. }
  11.  
  12. f(2)
  13.  

Charles


JRS

  • Guest
Re: Horror Pointer
« Reply #17 on: February 28, 2013, 09:18:21 AM »
Reminds me of my event loop for IUP and weeding out mouse movement events I didn't request callbacks for and return a NULL handles. Before SB even sees an event I filter these out in the extension module DLL.


Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #18 on: February 28, 2013, 11:01:52 AM »
Hi Peter,

something like this:

Code: OxygenBasic
  1. Sub DoEvents
  2.     pushad
  3.     lea   eax,Event
  4.     call  SDL_PollEvent eax
  5.     movzx edx,Event.type
  6.     cmp   edx,SDL_xQUIT    
  7.     jz    n1
  8.     cmp   edx,SDL_KEYDOWN
  9.     jz    n1
  10.     popad
  11.     ret    
  12. .n1 mov   run,0
  13.     call  SDL_Quit
  14.     popad
  15. End Sub
  16.  
  17. '===>
  18.  
  19. while (run)
  20.   DoEvents
  21.   SDL_Delay (10)
  22. wend
  23.  
  24. sys run=1
  25.  
  26. Sub DoEvents()
  27.   SDL_PollEvent @Event 'assume no prototype for this call
  28.  select Event.type
  29.   case SDL_xQUIT   : 'fall thru
  30.  case SDL_KEYDOWN : 'fall thru
  31.  case else        : exit sub
  32.   end select
  33.   run=0
  34.   SDL_Quit
  35. end sub
  36.  
  37. while (run)
  38.   DoEvents
  39.   SDL_Delay (10)
  40. wend
  41.  
  42.  

Charles
« Last Edit: February 28, 2013, 11:07:56 AM by Charles Pegge »

JRS

  • Guest
Re: Horror Pointer
« Reply #19 on: February 28, 2013, 01:29:55 PM »
Quote
But if this constructs doesn't go with OxygenBasic, then I will quit.
I have no interesting to go with dirty tricks.

Peter,

OxygenBasic is in it's alpha development stage. That means your use and feedback help shape O2's future. If it gets too hot in the kitchen then maybe your not cut out to be a cook and better off sitting out front waiting to be served. I think you're a bright and interesting person from my dealings with you here and other forums. It's okay to disagree, just don't be disagreeable.

John

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #20 on: February 28, 2013, 02:27:13 PM »

I have not encountered enumerations placed inside typedefs before. This is arcane but I will see what can be done.

Good reason for using case blocks: they are significantly faster and smaller than conditional statements.

John, I now have ScriptBasic chatting with the SAPI voice. Nice big hurdle to jump over :)

Aurel

  • Guest
Re: Horror Pointer
« Reply #21 on: February 28, 2013, 02:33:12 PM »
Quote
If OxygenBasic cannot handle this structures then is purposeless to work with my project.
Hmmm ...interesting standpoint,there is no ideal lang but hey programming in oxygen for me is somehow
cool....

JRS

  • Guest
Re: Horror Pointer
« Reply #22 on: February 28, 2013, 02:36:05 PM »
Quote
John, I now have ScriptBasic chatting with the SAPI voice. Nice big hurdle to jump over.

Now that is something to talk about!  :o

BTW: Can you put a date next to the work in progress download link on the site? I would be happy to setup a mailing list for announcements for those of us developing / contributing as you go.


Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #23 on: March 01, 2013, 01:51:53 AM »
Hi Peter

in sdl.inc:
Code: OxygenBasic
  1. packed
  2. typedef struct SDL_keysym{
  3.   byte scancode
  4.   long sym
  5.   long mod
  6.   short unicode
  7. } SDL_keysym
  8.  
  9. typedef struct SDL_KeyboardEvent{
  10.   Uint8 type
  11.   Uint8 which
  12.   Uint8 state
  13.   SDL_keysym keysym
  14. } SDL_KeyboardEvent
  15.  

View Keyboard events in detail:

Code: OxygenBasic
  1. extern cdecl lib "sdl.dll"
  2.   include "sdl.inc"
  3. end extern
  4. SDL_Init SDL_INIT_EVERYTHING
  5.  
  6. 'SDL_SURFACE *image
  7. SDL_SURFACE *screen
  8.  
  9.  
  10. 'sys hfile 'rwops pointer treated as a handle
  11.  
  12. @screen=SDL_SetVideoMode 320,240,32,SDL_DOUBLEBUF | SDL_SWSURFACE  
  13. 'hfile=SDL_RWFromFile "bmp\alienmoon.bmp","rb"
  14. '@Image=SDL_LoadBMP_RW hfile,1
  15. 'SDL_UpperBlit @image, 0, @screen, 0
  16. 'SDL_Flip @screen
  17.  
  18. '#recordof SDL_KeyboardEvent
  19.  
  20. SDL_Event   Event
  21.  
  22. SDL_EnableUNICODE 1
  23.  
  24. cr=chr(13,10)
  25. tab=chr(9)
  26. do
  27.   if SDL_PollEvent(@Event)
  28.     'print event.type
  29.    select event.type
  30.     case SDL_xQUIT           : exit do
  31.     case SDL_KEYDOWN         :
  32.       print "Keyboard Event Data:" cr cr+
  33.       "type    " tab hex(event.key.type)            cr+
  34.       "which   " tab hex(event.key.which)           cr+
  35.       "state   " tab hex(event.key.state)           cr+
  36.       "scancode" tab hex(event.key.keysym.scancode) cr+
  37.       "sym     " tab hex(event.key.keysym.sym)      cr+
  38.       "mod     " tab hex(event.key.keysym.mod)      cr+
  39.       "unicode " tab hex(event.key.keysym.unicode)  cr+
  40.       ""
  41.       if event.key.keysym.sym=27 then exit do
  42.     case SDL_KEYUP           :
  43.     case SDL_MOUSEMOTION     :
  44.     case SDL_MOUSEBUTTONDOWN : 'exit do
  45.    case SDL_MOUSEBUTTONUP   :
  46.     end select
  47.   end if
  48.   Sdl_Delay(10)
  49. end do
  50.  
  51. 'SDL_FreeSurface @image
  52. SDL_FreeSurface @screen
  53. SDL_Quit
  54.  

Charles

JRS

  • Guest
Re: Horror Pointer
« Reply #24 on: March 01, 2013, 12:05:13 PM »
Peter,

FYI - You are violating the GNU license by wrapping the SDL library as a closed source project. Please make your source available!

John

Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #25 on: March 01, 2013, 12:19:54 PM »
Yes, source code much preferred.

I am in deep code trance to resolve some subtle typedef alignment issues.


Charles Pegge

  • Guest
Re: Horror Pointer
« Reply #26 on: March 02, 2013, 09:21:47 AM »
Voila!

The enumeration types will no longer disrupt type definitions, and the byte alignments are a bit smarter, so no need for 'packed' directives.

X