: 2>rect ( x y -- x:re x:im y:re y:im ) >r >rect r> >rect ;
: complex= ( x y -- ? ) 2>rect 2= ;
+
: complex+ ( x y -- x+y ) 2>rect swapd + >r + r> rect> ;
: complex- ( x y -- x-y ) 2>rect swapd - >r - r> rect> ;
: complex*re ( x y -- zx:re * y:re x:im * r:im )
FIELD: uchar type ! SDL_KEYDOWN or SDL_KEYUP
FIELD: uchar which ! The keyboard device index
FIELD: uchar state ! SDL_PRESSED or SDL_RELEASED
+ ! YUCK!
+ FIELD: uchar pad
+ FIELD: uchar pad
+ FIELD: uchar pad
! Later: inline structs
FIELD: uchar scancode
FIELD: int sym
BEGIN-STRUCT: button-event
FIELD: uchar type ! SDL_MOUSEBUTTONDOWN or SDL_MOUSEBUTTONUP
FIELD: uchar which ! The mouse device index
- FIELD: uchar button; ! The mouse button index
- FIELD: uchar state; ! SDL_PRESSED or SDL_RELEASED
+ FIELD: uchar button ! The mouse button index
+ FIELD: uchar state ! SDL_PRESSED or SDL_RELEASED
FIELD: ushort x
FIELD: ushort y ! The X/Y coordinates of the mouse at press time
END-STRUCT
USE: combinators
USE: lists
USE: logic
+USE: prettyprint
SYMBOL: surface
SYMBOL: width
] ifte SDL_Flip
] with-scope ;
-! : event-loop ( event -- )
-! dup SDL_WaitEvent 1 = [
-! dup event-type SDL_QUIT = [
-! drop
-! ] [
-! event-loop
-! ] ifte
-! ] [
-! drop
-! ] ifte ;
+: event-loop ( event -- )
+ dup SDL_WaitEvent 1 = [
+ dup event-type SDL_QUIT = [
+ drop
+ ] [
+ event-loop
+ ] ifte
+ ] [
+ drop
+ ] ifte ;
FIELD: uchar alpha
END-STRUCT
+BEGIN-STRUCT: rect
+ FIELD: short clip-x
+ FIELD: short clip-y
+ FIELD: ushort clip-w
+ FIELD: ushort clip-h
+END-STRUCT
+
BEGIN-STRUCT: surface
FIELD: uint flags
FIELD: format* format
FIELD: void* hwdata
FIELD: short clip-x
FIELD: short clip-y
- FIELD: short clip-w
- FIELD: short clip-h
+ FIELD: ushort clip-w
+ FIELD: ushort clip-h
FIELD: uint unused1
FIELD: uint locked
FIELD: int map
! SDL_SetGamma: float types
+: SDL_FillRect ( surface rect color -- n )
+ "int" "sdl" "SDL_FillRect"
+ [ "surface*" "rect*" "unint" ] alien-call ;
+
: SDL_LockSurface ( surface -- )
"int" "sdl" "SDL_LockSurface" [ "surface*" ] alien-call ;