Browse Source

Update for current version of ALlegro and add more tests.

Beoran 6 years ago
parent
commit
6f2da58f6a
11 changed files with 1514 additions and 1343 deletions
  1. 2 3
      README.md
  2. 50 42
      al/aid.go
  3. 245 242
      al/al.go
  4. 217 223
      al/al_test.go
  5. 315 326
      al/audio.go
  6. 60 79
      al/bitmap.go
  7. 1 10
      al/callbacks.c
  8. 151 145
      al/display.go
  9. 146 106
      al/font.go
  10. 236 77
      al/mouse.go
  11. 91 90
      al/native_dialog.go

+ 2 - 3
README.md

@@ -1,7 +1,7 @@
 algo
 ====
 
-Go language binding to Allegro 5.1.5 (under construction).
+Go language binding to Allegro 5.2.x (under construction).
 
 It presents a more Go-like interface with OOP on most resources after they are created or 
 loaded. 
@@ -11,5 +11,4 @@ on them, or with a finalizer set that calls Destroy automatically. It shoul be s
 Destroy multiple times, and finalizers are not 100% reliable, so it is recommended to call
 the Destoy() method manually on any resource that isn't needed anymore.
 
-
-
+This wrapper is licensed for free use under the MIT license. 

+ 50 - 42
al/aid.go

@@ -2,6 +2,7 @@ package al
 
 /*
 #include <stdlib.h>
+#include <stdint.h>
 */
 import "C"
 import "unsafe"
@@ -12,39 +13,39 @@ import "fmt"
 
 // Calls C malloc
 func malloc(size int) unsafe.Pointer {
-	return (unsafe.Pointer(C.calloc(C.size_t(size), C.size_t(1))))
+    return (unsafe.Pointer(C.calloc(C.size_t(size), C.size_t(1))))
 }
 
 // Calls C free
 func free(ptr unsafe.Pointer) {
-	C.free(ptr)
+    C.free(ptr)
 }
 
 // Allocates a string with the given byte length
 // don't forget a call to defer cstrFree() ! 
 func cstrNew(size int) *C.char {
-	return (*C.char)(malloc(size))
+    return (*C.char)(malloc((size)))
 }
 
 // free is a method on C char * strings to method to free the associated memory 
 func cstrFree(self *C.char) {
-	free(unsafe.Pointer(self))
+    free(unsafe.Pointer(self))
 }
 
 // Coverts a string to a C string. This allocates memory, 
 // so don't forget to add a "defer cstrFree(cstr)"
 func cstr(self string) *C.char {
-	return C.CString(self)
+    return C.CString(self)
 }
 
 // Shorthand for C.GoString. Yes, it's just laziness. :)
 func gostr(cstr *C.char) string {
-	return C.GoString(cstr)
+    return C.GoString(cstr)
 }
 
 // Converts an int pointer to a C.int pointer.
 func cintptr(ptr *int) *C.int {
-	return (*C.int)(unsafe.Pointer(ptr))
+    return (*C.int)(unsafe.Pointer(ptr))
 }
 
 /*
@@ -56,23 +57,23 @@ func cbyteptr(ptr * uint8)  (*C.Uint8)  {
 
 // Converts ints to bools.
 func i2b(res int) bool {
-	if res != 0 {
-		return true
-	}
-	return false
+    if res != 0 {
+        return true
+    }
+    return false
 }
 
 // Converts bools to ints.
 func b2i(res bool) int {
-	if res {
-		return 1
-	}
-	return 0
+    if res {
+        return 1
+    }
+    return 0
 }
 
 // Interface for destructable objects
 type Destroyer interface {
-	Destroy()
+    Destroy()
 }
 
 // Sets up a automatic finalizer for destructable objects
@@ -80,31 +81,38 @@ type Destroyer interface {
 // when the garbage collecter cleans up self.
 // self may also be nil in which case the destructor is NOT set up
 func SelfDestruct(self Destroyer) {
-	if self == nil {
-		return
-	}
-	clean := func(me Destroyer) {
-		fmt.Printf("Finalizing %#v.\n", me)
-		me.Destroy()
-	}
-	runtime.SetFinalizer(self, clean)
+    if self == nil {
+        return
+    }
+    clean := func(me Destroyer) {
+        fmt.Printf("Finalizing %#v.\n", me)
+        me.Destroy()
+    }
+    runtime.SetFinalizer(self, clean)
 }
 
 // this is too for laziness, but it's quite handy
 func cf(f float32) C.float {
-	return C.float(f)
+    return C.float(f)
 }
 
 // this is too for laziness, but it's quite handy
 func ci(f int) C.int {
-	return C.int(f)
+    return C.int(f)
 }
 
 // this is too for laziness, but it's quite handy
 func cd(f float64) C.double {
-	return C.double(f)
+    return C.double(f)
 }
 
+
+// this is too for laziness, but it's quite handy
+func cui16(f int) C.uint16_t {
+    return C.uint16_t(f)
+}
+
+
 /* This is the usual boilerplate for wrapping C types through a handle
 
 type XXX struct {
@@ -113,37 +121,37 @@ type XXX struct {
 
 // Converts a zzz to it's underlying C pointer
 func (self * XXX) toC() *C.YYY {
-	return (*C.YYY)(self.handle)
+    return (*C.YYY)(self.handle)
 }
 
 // Destroys the zzz.
 func (self *XXX) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_zzz(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_zzz(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C zzz into a go zzz
 func wrapXXXRaw(data *C.YYY) *XXX {
-	if data == nil {
-		return nil
-	}
-	return &XXX{data}
+    if data == nil {
+        return nil
+    }
+    return &XXX{data}
 }
 
 // Sets up a finalizer for this XXX that calls Destroy()
 func (self *XXX) SetDestroyFinalizer() *XXX {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *XXX) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *XXX) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C zzz into a go zzz and sets up a finalizer that calls Destroy()
 func wrapXXX(data *C.YYY) *XXX {
-	self := wrapXXXRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapXXXRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 

+ 245 - 242
al/al.go

@@ -18,142 +18,145 @@ const PI = 3.14159265358979323846
 
 // Allegro library ID calculation.
 func AL_ID(a, b, c, d int) int {
-	return (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
+    return (((a) << 24) | ((b) << 16) | ((c) << 8) | (d))
 }
 
-const VERSION = 5
-const SUB_VERSION = 1
-const WIP_VERSION = 5
-const RELEASE_NUMBER = 1
-const VERSION_STR = "5.0.7"
-const DATE_STR = "2012"
-const DATE = 20120624 /* yyyymmdd */
-const VERSION_INT = ((VERSION << 24) | (SUB_VERSION << 16) |
-	(WIP_VERSION << 8) | RELEASE_NUMBER)
+
+const (
+    VERSION         =  C.ALLEGRO_VERSION
+    SUB_VERSION     =  C.ALLEGRO_SUB_VERSION
+    WIP_VERSION     =  C.ALLEGRO_WIP_VERSION
+    UNSTABLE_BIT    =  0
+    RELEASE_NUMBER  =  C.ALLEGRO_RELEASE_NUMBER
+    VERSION_STR     =  C.ALLEGRO_VERSION_STR
+    DATE_STR        =  C.ALLEGRO_DATE_STR
+    VERSION_INT     =  ((VERSION << 24) | (SUB_VERSION << 16) |
+                        (WIP_VERSION << 8) | RELEASE_NUMBER | UNSTABLE_BIT)
+)
 
 // Converts bool to Allegro's C.bool
 func b2cb(res bool) C.bool {
-	if res {
-		return C.bool(true)
-	}
-	return C.bool(false)
+    if res {
+        return C.bool(true)
+    }
+    return C.bool(false)
 }
 
 // Memory allocation, use this in stead of malloc for allegro stuff
 func alMalloc(size uint) unsafe.Pointer {
-	return C.al_malloc_with_context(C.size_t(size), 0, nil, nil)
+    return C.al_malloc_with_context(C.size_t(size), 0, nil, nil)
 }
 
 // Memory allocation, use this in stead of calloc for allegro stuff
 func alCalloc(size, n uint) unsafe.Pointer {
-	return C.al_calloc_with_context(C.size_t(size), C.size_t(n), 0, nil, nil)
+    return C.al_calloc_with_context(C.size_t(size), C.size_t(n), 0, nil, nil)
 }
 
 // Free memory, use this in stead of free for allegro stuff
 func alFree(ptr unsafe.Pointer) {
-	C.al_free_with_context(ptr, 0, nil, nil)
+    C.al_free_with_context(ptr, 0, nil, nil)
 }
 
 // Converts C.bool to Allegro's C.bool
 func cb2b(res C.bool) bool {
-	if res {
-		return true
-	}
-	return false
+    if res {
+        return true
+    }
+    return false
 }
 
 // Checks if the basic Allegro system is installed or not.
 func IsSystemInstalled() bool {
-	return bool(C.al_is_system_installed())
+    return bool(C.al_is_system_installed())
 }
 
 // Gets the raw version of Allegro linked to as an integer.
 func GetAllegroVersion() uint32 {
-	return uint32(C.al_get_allegro_version())
+    return uint32(C.al_get_allegro_version())
 }
 
 // Initializes the Allegro system.
 func Initialize() bool {
-	return bool(C.al_install_system(VERSION_INT, nil))
-	//	return bool(C.algo_initialize())
+    return bool(C.al_install_system(VERSION_INT, nil))
+    //  return bool(C.algo_initialize())
 }
 
 // Cleans up the Allegro system. Needed after calling Initialize.
 func Cleanup() {
-	C.al_uninstall_system()
+    C.al_uninstall_system()
 }
 
 // Installs the Allegro system. 
 func InstallSystem() bool {
-	return bool(C.al_install_system(VERSION_INT, nil))
+    return bool(C.al_install_system(VERSION_INT, nil))
 }
 
 // Uninstalls the Allegro system. Must be called after using InstallSystem.
 func UninstallSystem() {
-	C.al_uninstall_system()
+    C.al_uninstall_system()
 }
 
 // allegro5/path.h
 
 // Wrapper for an Allegro path.
 type Path struct {
-	handle *C.ALLEGRO_PATH
+    handle *C.ALLEGRO_PATH
 }
 
 // Wraps an Allegro path into the go struct above, but does not set a finalizer
 func wrapPathRaw(handle *C.ALLEGRO_PATH) *Path {
-	if handle == nil {
-		return nil
-	}
-	return &Path{handle}
+    if handle == nil {
+        return nil
+    }
+    return &Path{handle}
 }
 
 // Wraps an Allegro path into the go struct above, and sets the finalizer
 // to be the struct's Destroy method
 func wrapPath(handle *C.ALLEGRO_PATH) *Path {
-	result := wrapPathRaw(handle)
-	if result != nil {
-		runtime.SetFinalizer(result, func(me *Path) { me.Destroy() })
-	}
-	return result
+    result := wrapPathRaw(handle)
+    if result != nil {
+        runtime.SetFinalizer(result, func(me *Path) { me.Destroy() })
+    }
+    return result
 }
 
 // Creates an Allegro path.
 func CreatePath(str string) *Path {
-	cstr := cstr(str)
-	defer cstrFree(cstr)
-	return wrapPath(C.al_create_path(cstr))
+    cstr := cstr(str)
+    defer cstrFree(cstr)
+    return wrapPath(C.al_create_path(cstr))
 }
 
 // Creates an allegro path for a directory.
 func CreatePathForDirectory(str string) *Path {
-	cstr := cstr(str)
-	defer cstrFree(cstr)
-	return wrapPath(C.al_create_path_for_directory(cstr))
+    cstr := cstr(str)
+    defer cstrFree(cstr)
+    return wrapPath(C.al_create_path_for_directory(cstr))
 }
 
 // Clones an allegro path.
 func (self *Path) ClonePath() *Path {
-	return wrapPath(C.al_clone_path(self.handle))
+    return wrapPath(C.al_clone_path(self.handle))
 }
 
 // Destroys an Allegro path. It may not be used after this.
 // Destroy may be called many times.
 func (self *Path) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_path(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_path(self.handle)
+    }
+    self.handle = nil
 }
 
 // Gets amount of components of the path name
 func (self *Path) GetPathNumComponents() int {
-	return int(C.al_get_path_num_components(self.handle))
+    return int(C.al_get_path_num_components(self.handle))
 }
 
 // converst the allegro path to a string 
 func (self *Path) String() string {
-	return gostr(C.al_path_cstr(self.handle, C.char(NATIVE_PATH_SEP)))
+    return gostr(C.al_path_cstr(self.handle, C.char(NATIVE_PATH_SEP)))
 }
 
 /*
@@ -193,49 +196,49 @@ AL_FUNC(bool, al_make_path_canonical, (ALLEGRO_PATH *path));
 // AL_FUNC(CONFIG *, al_get_system_config, (void));
 
 const (
-	RESOURCES_PATH = iota
-	TEMP_PATH
-	USER_DATA_PATH
-	USER_HOME_PATH
-	USER_SETTINGS_PATH
-	USER_DOCUMENTS_PATH
-	EXENAME_PATH
-	LAST_PATH
+    RESOURCES_PATH          = C.ALLEGRO_RESOURCES_PATH
+    TEMP_PATH               = C.ALLEGRO_TEMP_PATH
+    USER_DATA_PATH          = C.ALLEGRO_USER_DATA_PATH
+    USER_HOME_PATH          = C.ALLEGRO_USER_HOME_PATH
+    USER_SETTINGS_PATH      = C.ALLEGRO_USER_SETTINGS_PATH
+    USER_DOCUMENTS_PATH     = C.ALLEGRO_USER_DOCUMENTS_PATH
+    EXENAME_PATH            = C.ALLEGRO_EXENAME_PATH
+    LAST_PATH               = C.ALLEGRO_LAST_PATH
 )
 
 // Gets a standard path location.
 func GetStandardPath(id int) *Path {
-	return wrapPath(C.al_get_standard_path(C.int(id)))
+    return wrapPath(C.al_get_standard_path(C.int(id)))
 }
 
 // Sets the name of the executable.
 func SetExeName(name string) {
-	C.al_set_exe_name(cstr(name))
+    C.al_set_exe_name(cstr(name))
 }
 
 // Sets the name of the organisation.
 func SetOrgName(name string) {
-	C.al_set_org_name(cstr(name))
+    C.al_set_org_name(cstr(name))
 }
 
 // Sets the name of the app.
 func SetAppName(name string) {
-	C.al_set_app_name(cstr(name))
+    C.al_set_app_name(cstr(name))
 }
 
 // Gets the name of the organisation
 func GetOrgName() string {
-	return gostr(C.al_get_org_name())
+    return gostr(C.al_get_org_name())
 }
 
 // Sets the name of the app
 func GetAppName() string {
-	return gostr(C.al_get_app_name())
+    return gostr(C.al_get_app_name())
 }
 
 // Inibits the screensaver, or not debending on inhibit.
 func InhibitScreensaver(inhibit bool) bool {
-	return bool(C.al_inhibit_screensaver(C.bool(inhibit)))
+    return bool(C.al_inhibit_screensaver(C.bool(inhibit)))
 }
 
 /// XXX How to wrap this and is it needed????
@@ -245,70 +248,70 @@ func InhibitScreensaver(inhibit bool) bool {
 not needed in Go, so I will just wrap the basic conversion functions. */
 
 type USTR struct {
-	handle *C.ALLEGRO_USTR
+    handle *C.ALLEGRO_USTR
 }
 
 // Frees an Allegro unicode string.
 func (self *USTR) Free() {
-	if self.handle != nil {
-		C.al_ustr_free(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_ustr_free(self.handle)
+    }
+    self.handle = nil
 }
 
 // Just for consistency and to allow SelfDestruuct to work 
 func (self *USTR) Destroy() {
-	self.Free()
+    self.Free()
 }
 
 // Converts an Allegro Unicode string to a Go string 
 func (self *USTR) String() string {
-	if self.handle == nil {
-		return "<destroyed>"
-	}
-	return C.GoStringN(C.al_cstr(self.handle), C.int(C.al_ustr_size(self.handle)))
+    if self.handle == nil {
+        return "<destroyed>"
+    }
+    return C.GoStringN(C.al_cstr(self.handle), C.int(C.al_ustr_size(self.handle)))
 }
 
 // Wraps an Allegro USTR into the go struct above, but does not set a finalizer
 func wrapUSTRRaw(handle *C.ALLEGRO_USTR) *USTR {
-	if handle == nil {
-		return nil
-	}
-	return &USTR{handle}
+    if handle == nil {
+        return nil
+    }
+    return &USTR{handle}
 }
 
 // Wraps an Allegro path into the go struct above, and sets the finalizer to 
 // be the Destroy method of that struct.
 func wrapUSTR(handle *C.ALLEGRO_USTR) *USTR {
-	result := wrapUSTRRaw(handle)
-	if result != nil {
-		runtime.SetFinalizer(result, func(me *USTR) { me.Destroy() })
-	}
-	return result
+    result := wrapUSTRRaw(handle)
+    if result != nil {
+        runtime.SetFinalizer(result, func(me *USTR) { me.Destroy() })
+    }
+    return result
 }
 
 // Converts a go string to an Allegro Unicode string
 func USTRV(str string) *USTR {
-	cstr := cstr(str)
-	defer cstrFree(cstr)
-	return wrapUSTR(C.al_ustr_new(cstr))
+    cstr := cstr(str)
+    defer cstrFree(cstr)
+    return wrapUSTR(C.al_ustr_new(cstr))
 }
 
 // Converts a go string to an Allegro Unicode string
 func USTRP(str *string) *USTR {
-	return USTRV(*str)
+    return USTRV(*str)
 }
 
 // Allegro's timer functions 
 
 // Gets the time the app is running in seconds 
 func GetTime() float64 {
-	return float64(C.al_get_time())
+    return float64(C.al_get_time())
 }
 
 // Sleeps the given amount of seconds
 func Rest(seconds float64) {
-	C.al_rest(C.double(seconds))
+    C.al_rest(C.double(seconds))
 }
 
 // Event Type, not to avoid complications.
@@ -316,44 +319,44 @@ func Rest(seconds float64) {
 
 // Event Type constants
 const (
-	EVENT_JOYSTICK_AXIS          = C.ALLEGRO_EVENT_JOYSTICK_AXIS
-	EVENT_JOYSTICK_BUTTON_DOWN   = C.ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
-	EVENT_JOYSTICK_BUTTON_UP     = C.ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
-	EVENT_JOYSTICK_CONFIGURATION = C.ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
-
-	EVENT_KEY_DOWN = C.ALLEGRO_EVENT_KEY_DOWN
-	EVENT_KEY_CHAR = C.ALLEGRO_EVENT_KEY_CHAR
-	EVENT_KEY_UP   = C.ALLEGRO_EVENT_KEY_UP
-
-	EVENT_MOUSE_AXES          = C.ALLEGRO_EVENT_MOUSE_AXES
-	EVENT_MOUSE_BUTTON_DOWN   = C.ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
-	EVENT_MOUSE_BUTTON_UP     = C.ALLEGRO_EVENT_MOUSE_BUTTON_UP
-	EVENT_MOUSE_ENTER_DISPLAY = C.ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY
-	EVENT_MOUSE_LEAVE_DISPLAY = C.ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY
-	EVENT_MOUSE_WARPED        = C.ALLEGRO_EVENT_MOUSE_WARPED
-
-	EVENT_TIMER = C.ALLEGRO_EVENT_TIMER
-
-	EVENT_DISPLAY_EXPOSE      = C.ALLEGRO_EVENT_DISPLAY_EXPOSE
-	EVENT_DISPLAY_RESIZE      = C.ALLEGRO_EVENT_DISPLAY_RESIZE
-	EVENT_DISPLAY_CLOSE       = C.ALLEGRO_EVENT_DISPLAY_CLOSE
-	EVENT_DISPLAY_LOST        = C.ALLEGRO_EVENT_DISPLAY_LOST
-	EVENT_DISPLAY_FOUND       = C.ALLEGRO_EVENT_DISPLAY_FOUND
-	EVENT_DISPLAY_SWITCH_IN   = C.ALLEGRO_EVENT_DISPLAY_SWITCH_IN
-	EVENT_DISPLAY_SWITCH_OUT  = C.ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
-	EVENT_DISPLAY_ORIENTATION = C.ALLEGRO_EVENT_DISPLAY_ORIENTATION
+    EVENT_JOYSTICK_AXIS          = C.ALLEGRO_EVENT_JOYSTICK_AXIS
+    EVENT_JOYSTICK_BUTTON_DOWN   = C.ALLEGRO_EVENT_JOYSTICK_BUTTON_DOWN
+    EVENT_JOYSTICK_BUTTON_UP     = C.ALLEGRO_EVENT_JOYSTICK_BUTTON_UP
+    EVENT_JOYSTICK_CONFIGURATION = C.ALLEGRO_EVENT_JOYSTICK_CONFIGURATION
+
+    EVENT_KEY_DOWN = C.ALLEGRO_EVENT_KEY_DOWN
+    EVENT_KEY_CHAR = C.ALLEGRO_EVENT_KEY_CHAR
+    EVENT_KEY_UP   = C.ALLEGRO_EVENT_KEY_UP
+
+    EVENT_MOUSE_AXES          = C.ALLEGRO_EVENT_MOUSE_AXES
+    EVENT_MOUSE_BUTTON_DOWN   = C.ALLEGRO_EVENT_MOUSE_BUTTON_DOWN
+    EVENT_MOUSE_BUTTON_UP     = C.ALLEGRO_EVENT_MOUSE_BUTTON_UP
+    EVENT_MOUSE_ENTER_DISPLAY = C.ALLEGRO_EVENT_MOUSE_ENTER_DISPLAY
+    EVENT_MOUSE_LEAVE_DISPLAY = C.ALLEGRO_EVENT_MOUSE_LEAVE_DISPLAY
+    EVENT_MOUSE_WARPED        = C.ALLEGRO_EVENT_MOUSE_WARPED
+
+    EVENT_TIMER = C.ALLEGRO_EVENT_TIMER
+
+    EVENT_DISPLAY_EXPOSE      = C.ALLEGRO_EVENT_DISPLAY_EXPOSE
+    EVENT_DISPLAY_RESIZE      = C.ALLEGRO_EVENT_DISPLAY_RESIZE
+    EVENT_DISPLAY_CLOSE       = C.ALLEGRO_EVENT_DISPLAY_CLOSE
+    EVENT_DISPLAY_LOST        = C.ALLEGRO_EVENT_DISPLAY_LOST
+    EVENT_DISPLAY_FOUND       = C.ALLEGRO_EVENT_DISPLAY_FOUND
+    EVENT_DISPLAY_SWITCH_IN   = C.ALLEGRO_EVENT_DISPLAY_SWITCH_IN
+    EVENT_DISPLAY_SWITCH_OUT  = C.ALLEGRO_EVENT_DISPLAY_SWITCH_OUT
+    EVENT_DISPLAY_ORIENTATION = C.ALLEGRO_EVENT_DISPLAY_ORIENTATION
 )
 
 func EVENT_TYPE_IS_USER(t int) bool {
-	return ((t) >= 512)
+    return ((t) >= 512)
 }
 
 func GET_EVENT_TYPE(a, b, c, d int) int {
-	return AL_ID(a, b, c, d)
+    return AL_ID(a, b, c, d)
 }
 
 func getAnyEvenTimestamp(any *C.ALLEGRO_ANY_EVENT) float64 {
-	return float64(any.timestamp)
+    return float64(any.timestamp)
 }
 
 // Event sources that emit events.
@@ -361,12 +364,12 @@ type EventSource C.ALLEGRO_EVENT_SOURCE
 
 // Wraps an event source pointer but sets no finalizer (not needed anyway) 
 func wrapEventSourceRaw(ptr *C.ALLEGRO_EVENT_SOURCE) *EventSource {
-	return (*EventSource)(ptr)
+    return (*EventSource)(ptr)
 }
 
 // Converts wrapper Event source pointer to C Allegro event pointer
 func (self *EventSource) toC() *C.ALLEGRO_EVENT_SOURCE {
-	return (*C.ALLEGRO_EVENT_SOURCE)(self)
+    return (*C.ALLEGRO_EVENT_SOURCE)(self)
 }
 
 // Events that the event system emits.
@@ -374,152 +377,152 @@ type Event C.ALLEGRO_EVENT
 
 // Converts wrapper Event pointer to C Allegro event pointer
 func (self *Event) toC() *C.ALLEGRO_EVENT {
-	return (*C.ALLEGRO_EVENT)(self)
+    return (*C.ALLEGRO_EVENT)(self)
 }
 
 // Returns an unsafe pointer to the event 
 func (self *Event) toPointer() unsafe.Pointer {
-	return unsafe.Pointer(self.toC())
+    return unsafe.Pointer(self.toC())
 }
 
 // Converts wrapper Event pointer to C Allegro any event
 func (self *Event) ANY_EVENT() *C.ALLEGRO_ANY_EVENT {
-	return (*C.ALLEGRO_ANY_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_ANY_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro display event
 func (self *Event) DISPLAY_EVENT() *C.ALLEGRO_DISPLAY_EVENT {
-	return (*C.ALLEGRO_DISPLAY_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_DISPLAY_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro joystick event
 func (self *Event) JOYSTICK_EVENT() *C.ALLEGRO_JOYSTICK_EVENT {
-	return (*C.ALLEGRO_JOYSTICK_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_JOYSTICK_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro event
 func (self *Event) KEYBOARD_EVENT() *C.ALLEGRO_KEYBOARD_EVENT {
-	return (*C.ALLEGRO_KEYBOARD_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_KEYBOARD_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro touch event
 func (self *Event) TOUCH_EVENT() *C.ALLEGRO_TOUCH_EVENT {
-	return (*C.ALLEGRO_TOUCH_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_TOUCH_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro mouse event
 func (self *Event) MOUSE_EVENT() *C.ALLEGRO_MOUSE_EVENT {
-	return (*C.ALLEGRO_MOUSE_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_MOUSE_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro timer event
 func (self *Event) TIMER_EVENT() *C.ALLEGRO_TIMER_EVENT {
-	return (*C.ALLEGRO_TIMER_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_TIMER_EVENT)(self.toPointer())
 }
 
 // Converts wrapper Event pointer to C Allegro event
 func (self *Event) USER_EVENT() *C.ALLEGRO_USER_EVENT {
-	return (*C.ALLEGRO_USER_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_USER_EVENT)(self.toPointer())
 }
 
 // Returns the type of the event.
 func (self *Event) Type() int {
-	return int(self.ANY_EVENT()._type)
+    return int(self.ANY_EVENT()._type)
 }
 
 // Returns the timestamp of the event.
 func (self *Event) Timestamp() float64 {
-	return float64(self.ANY_EVENT().timestamp)
+    return float64(self.ANY_EVENT().timestamp)
 }
 
 // Returns the event source of the event
 func (self *Event) EventSource() *EventSource {
-	return (*EventSource)(self.ANY_EVENT().source)
+    return (*EventSource)(self.ANY_EVENT().source)
 }
 
 // Returns true if this is a dispay event, false if not.
 func (self *Event) IsDisplay() bool {
-	t := self.Type()
-	return (t >= EVENT_DISPLAY_EXPOSE) && (t <= EVENT_DISPLAY_ORIENTATION)
+    t := self.Type()
+    return (t >= EVENT_DISPLAY_EXPOSE) && (t <= EVENT_DISPLAY_ORIENTATION)
 }
 
 // Returns true if this is a mouse event, false if not.
 func (self *Event) IsMouse() bool {
-	t := self.Type()
-	return (t >= EVENT_MOUSE_AXES) && (t <= EVENT_MOUSE_WARPED)
+    t := self.Type()
+    return (t >= EVENT_MOUSE_AXES) && (t <= EVENT_MOUSE_WARPED)
 }
 
 // Returns true if this is a Joystick event, false if not.
 func (self *Event) IsJoystick() bool {
-	t := self.Type()
-	return (t >= EVENT_JOYSTICK_AXIS) && (t <= EVENT_JOYSTICK_CONFIGURATION)
+    t := self.Type()
+    return (t >= EVENT_JOYSTICK_AXIS) && (t <= EVENT_JOYSTICK_CONFIGURATION)
 }
 
 // Returns true if this is a keyboard event, false if not.
 func (self *Event) IsKeyboard() bool {
-	t := self.Type()
-	return (t >= EVENT_KEY_DOWN) && (t <= EVENT_KEY_UP)
+    t := self.Type()
+    return (t >= EVENT_KEY_DOWN) && (t <= EVENT_KEY_UP)
 }
 
 // Returns true if this is a timer event, false if not.
 func (self *Event) IsTimer() bool {
-	t := self.Type()
-	return (t == EVENT_TIMER)
+    t := self.Type()
+    return (t == EVENT_TIMER)
 }
 
 // Returns true if this is a user event, false if not.
 func (self *Event) IsUser() bool {
-	t := self.Type()
-	return EVENT_TYPE_IS_USER(t)
+    t := self.Type()
+    return EVENT_TYPE_IS_USER(t)
 }
 
 // Returns the event's source pointer
 func (self *Event) EVENT_SOURCE() *C.ALLEGRO_EVENT_SOURCE {
-	return self.ANY_EVENT().source
+    return self.ANY_EVENT().source
 }
 
 // Returns an unsafe pointer to the event's source pointer
 func (self *Event) EVENT_SOURCE_PTR() unsafe.Pointer {
-	return unsafe.Pointer(self.ANY_EVENT())
+    return unsafe.Pointer(self.ANY_EVENT())
 }
 
 // Returns the display that has emitted the event. Will return nil if 
 // this is not a display event.
 func (self *Event) DisplayDisplay() *Display {
-	if !(self.IsDisplay()) {
-		return nil
-	}
-	return wrapDisplayRaw((*C.ALLEGRO_DISPLAY)(self.EVENT_SOURCE_PTR()))
+    if !(self.IsDisplay()) {
+        return nil
+    }
+    return wrapDisplayRaw((*C.ALLEGRO_DISPLAY)(self.EVENT_SOURCE_PTR()))
 }
 
 // Returns the X position of the display event. Will return garbage 
 // if this is not a display event.
 func (self *Event) DisplayX() int {
-	return int((self.DISPLAY_EVENT()).x)
+    return int((self.DISPLAY_EVENT()).x)
 }
 
 // Returns the Y position of the display event. Will return garbage 
 // if this is not a display event.
 func (self *Event) DisplayY() int {
-	return int(self.DISPLAY_EVENT().y)
+    return int(self.DISPLAY_EVENT().y)
 }
 
 // Returns the width of the display event. Will return garbage 
 // if this is not a display event.
 func (self *Event) DisplayWidth() int {
-	return int(self.DISPLAY_EVENT().width)
+    return int(self.DISPLAY_EVENT().width)
 }
 
 // Returns the height of the display event. Will return garbage 
 // if this is not a display event.
 func (self *Event) DisplayHeight() int {
-	return int(self.DISPLAY_EVENT().height)
+    return int(self.DISPLAY_EVENT().height)
 }
 
 // Returns the orientation of the display event. Will return garbage 
 // if this is not a display event.
 func (self *Event) DisplayOrientation() int {
-	return int(self.DISPLAY_EVENT().orientation)
+    return int(self.DISPLAY_EVENT().orientation)
 }
 
 // XXX: maybe also wrap the source in a Joystick type? 
@@ -527,25 +530,25 @@ func (self *Event) DisplayOrientation() int {
 // Returns the stick number of the joystick event. Will return garbage 
 // if this is not a joystick event.
 func (self *Event) JoystickStick() int {
-	return int(self.JOYSTICK_EVENT().stick)
+    return int(self.JOYSTICK_EVENT().stick)
 }
 
 // Returns the axis number of the joystick event. Will return garbage 
 // if this is not a joystick event.
 func (self *Event) JoystickAxis() int {
-	return int(self.JOYSTICK_EVENT().axis)
+    return int(self.JOYSTICK_EVENT().axis)
 }
 
 // Returns the button number of the joystick event. Will return garbage 
 // if this is not a joystick event.
 func (self *Event) JoystickButton() int {
-	return int(self.JOYSTICK_EVENT().button)
+    return int(self.JOYSTICK_EVENT().button)
 }
 
 // Returns the position of the joystick event. Will return garbage 
 // if this is not a joystick event.
 func (self *Event) JoystickPos() float32 {
-	return float32(self.JOYSTICK_EVENT().pos)
+    return float32(self.JOYSTICK_EVENT().pos)
 }
 
 /// XXX also wrap Keyboard event source?
@@ -553,207 +556,207 @@ func (self *Event) JoystickPos() float32 {
 // Returns the display that has emitted the keyboard event. Will return nil if 
 // this is not a keyboard event.
 func (self *Event) KeyboardDisplay() *Display {
-	if !(self.IsKeyboard()) {
-		return nil
-	}
-	return wrapDisplayRaw(self.KEYBOARD_EVENT().display)
+    if !(self.IsKeyboard()) {
+        return nil
+    }
+    return wrapDisplayRaw(self.KEYBOARD_EVENT().display)
 }
 
 // Returns the keycode of the keyboard event. Returns garbage 
 // if this is not a keyboard event.
 func (self *Event) KeyboardKeycode() int {
-	return int(self.KEYBOARD_EVENT().keycode)
+    return int(self.KEYBOARD_EVENT().keycode)
 }
 
 // Returns the unichar of the keyboard event. Returns garbage 
 // if this is not a keyboard event.
 func (self *Event) KeyboardUnichar() rune {
-	return rune(self.KEYBOARD_EVENT().unichar)
+    return rune(self.KEYBOARD_EVENT().unichar)
 }
 
 // Returns the modifiers of the keyboard event. Returns garbage 
 // if this is not a keyboard event.
 func (self *Event) KeyboardModifiers() int {
-	return int(self.KEYBOARD_EVENT().modifiers)
+    return int(self.KEYBOARD_EVENT().modifiers)
 }
 
 // Returns is the keyboard event was autorepeated or not. Returns garbage 
 // if this is not a keyboard event.
 func (self *Event) KeyboardRepeat() bool {
-	return bool(self.KEYBOARD_EVENT().repeat)
+    return bool(self.KEYBOARD_EVENT().repeat)
 }
 
 // Returns the x postion of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseX() int {
-	return int(self.MOUSE_EVENT().x)
+    return int(self.MOUSE_EVENT().x)
 }
 
 // Returns the y postion of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseY() int {
-	return int(self.MOUSE_EVENT().y)
+    return int(self.MOUSE_EVENT().y)
 }
 
 // Returns the z postion of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseZ() int {
-	return int(self.MOUSE_EVENT().z)
+    return int(self.MOUSE_EVENT().z)
 }
 
 // Returns the w postion of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseW() int {
-	return int(self.MOUSE_EVENT().w)
+    return int(self.MOUSE_EVENT().w)
 }
 
 // Returns the dx of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseDX() int {
-	return int(self.MOUSE_EVENT().dx)
+    return int(self.MOUSE_EVENT().dx)
 }
 
 // Returns the dy of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseDY() int {
-	return int(self.MOUSE_EVENT().dy)
+    return int(self.MOUSE_EVENT().dy)
 }
 
 // Returns the dz of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseDZ() int {
-	return int(self.MOUSE_EVENT().dz)
+    return int(self.MOUSE_EVENT().dz)
 }
 
 // Returns the dw of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseDW() int {
-	return int(self.MOUSE_EVENT().dw)
+    return int(self.MOUSE_EVENT().dw)
 }
 
 // Returns the button of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MouseButton() int {
-	return int(self.MOUSE_EVENT().button)
+    return int(self.MOUSE_EVENT().button)
 }
 
 // Returns the pressure of the mouse event. Returns garbage 
 // if this is not a mouse event.
 func (self *Event) MousePressure() float32 {
-	return float32(self.MOUSE_EVENT().pressure)
+    return float32(self.MOUSE_EVENT().pressure)
 }
 
 // Returns the display that has emitted the mouse event. Will return nil if 
 // this is not a mouse event.
 func (self *Event) MouseDisplay() *Display {
-	if !(self.IsMouse()) {
-		return nil
-	}
-	return wrapDisplayRaw(self.MOUSE_EVENT().display)
+    if !(self.IsMouse()) {
+        return nil
+    }
+    return wrapDisplayRaw(self.MOUSE_EVENT().display)
 }
 
 // Returns the error of the timer event. Returns garbage 
 // if this is not a timer event.
 func (self *Event) TimerError() float64 {
-	return float64(self.TIMER_EVENT().error)
+    return float64(self.TIMER_EVENT().error)
 }
 
 // Returns the ticks of the timer event. Returns garbage 
 // if this is not a timer event.
 func (self *Event) TimerCount() int64 {
-	return int64(self.TIMER_EVENT().count)
+    return int64(self.TIMER_EVENT().count)
 }
 
 // Wrapping of user event seems not really meaningful in Go so leave that out.
 
 // Event queues.
 type EventQueue struct {
-	handle *C.ALLEGRO_EVENT_QUEUE
+    handle *C.ALLEGRO_EVENT_QUEUE
 }
 
 // Destroys the event queue.
 func (self *EventQueue) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_event_queue(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_event_queue(self.handle)
+    }
+    self.handle = nil
 }
 
 // Wraps an event queue, but does not set a finalizer.
 func wrapEventQueueRaw(handle *C.ALLEGRO_EVENT_QUEUE) *EventQueue {
-	if handle == nil {
-		return nil
-	}
-	return &EventQueue{handle}
+    if handle == nil {
+        return nil
+    }
+    return &EventQueue{handle}
 }
 
 // Wraps an event queue and sets a finalizer that calls Destroy
 func wrapEventQueue(handle *C.ALLEGRO_EVENT_QUEUE) *EventQueue {
-	result := wrapEventQueueRaw(handle)
-	if result != nil {
-		runtime.SetFinalizer(result, func(me *EventQueue) { me.Destroy() })
-	}
-	return result
+    result := wrapEventQueueRaw(handle)
+    if result != nil {
+        runtime.SetFinalizer(result, func(me *EventQueue) { me.Destroy() })
+    }
+    return result
 }
 
 // Create an event queue.
 func CreateEventQueue() *EventQueue {
-	return wrapEventQueue(C.al_create_event_queue())
+    return wrapEventQueue(C.al_create_event_queue())
 }
 
 // Register an event source with self. 
 func (self *EventQueue) RegisterEventSource(src *EventSource) {
-	C.al_register_event_source(self.handle, src.toC())
+    C.al_register_event_source(self.handle, src.toC())
 }
 
 // Unregister an event source with self. 
 func (self *EventQueue) UnregisterEventSource(src *EventSource) {
-	C.al_unregister_event_source(self.handle, src.toC())
+    C.al_unregister_event_source(self.handle, src.toC())
 }
 
 // Returns true if the event queue self is empty, false if not.
 func (self *EventQueue) IsEmpty() bool {
-	return bool(C.al_is_event_queue_empty(self.handle))
+    return bool(C.al_is_event_queue_empty(self.handle))
 }
 
 // Returns the next event from the event queue as well as a bool
 // to signify if an event was fetched sucessfully or not.
 func (self *EventQueue) GetNextEvent() (event *Event, ok bool) {
-	event = &Event{}
-	ok = bool(C.al_get_next_event(self.handle, event.toC()))
-	return event, ok
+    event = &Event{}
+    ok = bool(C.al_get_next_event(self.handle, event.toC()))
+    return event, ok
 }
 
 // Peeks at the next event in the event queue and returns it as well as a bool
 // to signify if an event was fetched sucessfully or not.
 func (self *EventQueue) PeekNextEvent() (event *Event, ok bool) {
-	event = &Event{}
-	ok = bool(C.al_peek_next_event(self.handle, event.toC()))
-	return event, ok
+    event = &Event{}
+    ok = bool(C.al_peek_next_event(self.handle, event.toC()))
+    return event, ok
 }
 
 // Drops the next event from the event queue
 func (self *EventQueue) DropNextEvent() bool {
-	return bool(C.al_drop_next_event(self.handle))
+    return bool(C.al_drop_next_event(self.handle))
 }
 
 // Flushes the event queue
 func (self *EventQueue) Flush() {
-	C.al_flush_event_queue(self.handle)
+    C.al_flush_event_queue(self.handle)
 }
 
 // Waits for the next event from the event queue 
 func (self *EventQueue) WaitForEvent() (event *Event) {
-	event = &Event{}
-	C.al_wait_for_event(self.handle, event.toC())
-	return event
+    event = &Event{}
+    C.al_wait_for_event(self.handle, event.toC())
+    return event
 }
 
 // Waits for secs seconds the next event from the event queue 
 func (self *EventQueue) WaitForEventTimed(secs float32) (event *Event, ok bool) {
-	event = &Event{}
-	ok = bool(C.al_wait_for_event_timed(self.handle, event.toC(), C.float(secs)))
-	return event, ok
+    event = &Event{}
+    ok = bool(C.al_wait_for_event_timed(self.handle, event.toC(), C.float(secs)))
+    return event, ok
 }
 
 /*
@@ -766,83 +769,83 @@ AL_FUNC(bool, al_wait_for_event_until, (ALLEGRO_EVENT_QUEUE *queue,
 
 // Precise (?) Timer 
 type Timer struct {
-	handle *C.ALLEGRO_TIMER
+    handle *C.ALLEGRO_TIMER
 }
 
 // Destroys the timer queue.
 func (self *Timer) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_timer(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_timer(self.handle)
+    }
+    self.handle = nil
 }
 
 // Wraps a timer, but does not set a finalizer.
 func wrapTimerRaw(handle *C.ALLEGRO_TIMER) *Timer {
-	if handle == nil {
-		return nil
-	}
-	return &Timer{handle}
+    if handle == nil {
+        return nil
+    }
+    return &Timer{handle}
 }
 
 // Wraps an event queue and sets a finalizer that calls Destroy
 func wrapTimer(handle *C.ALLEGRO_TIMER) *Timer {
-	result := wrapTimerRaw(handle)
-	if result != nil {
-		runtime.SetFinalizer(result, func(me *Timer) { me.Destroy() })
-	}
-	return result
+    result := wrapTimerRaw(handle)
+    if result != nil {
+        runtime.SetFinalizer(result, func(me *Timer) { me.Destroy() })
+    }
+    return result
 }
 
 // Creates a timer with the given tick speed.
 func CreateTimer(speed_secs float64) *Timer {
-	return wrapTimer(C.al_create_timer(C.double(speed_secs)))
+    return wrapTimer(C.al_create_timer(C.double(speed_secs)))
 }
 
 // Starts the timer.
 func (self *Timer) Start() {
-	C.al_start_timer(self.handle)
+    C.al_start_timer(self.handle)
 }
 
 // Stops the timer.
 func (self *Timer) Stop() {
-	C.al_stop_timer(self.handle)
+    C.al_stop_timer(self.handle)
 }
 
 // Returns true if the timer was started, false if not 
 func (self *Timer) IsStarted() bool {
-	return bool(C.al_get_timer_started(self.handle))
+    return bool(C.al_get_timer_started(self.handle))
 }
 
 // Sets the speed of the timer.
 func (self *Timer) SetSpeed(speed_secs float64) {
-	C.al_set_timer_speed(self.handle, C.double(speed_secs))
+    C.al_set_timer_speed(self.handle, C.double(speed_secs))
 }
 
 // Gets the speed of the timer.
 func (self *Timer) GetSpeed() float64 {
-	return float64(C.al_get_timer_speed(self.handle))
+    return float64(C.al_get_timer_speed(self.handle))
 }
 
 // Gets the count (in ticks) of the timer
 func (self *Timer) GetCount() int {
-	return int(C.al_get_timer_count(self.handle))
+    return int(C.al_get_timer_count(self.handle))
 }
 
 // Sets the count (in ticks) of the timer
 func (self *Timer) SetCount(count int) {
-	C.al_set_timer_count(self.handle, C.int64_t(count))
+    C.al_set_timer_count(self.handle, C.int64_t(count))
 }
 
 // Adds to the count (in ticks) of the timer
 func (self *Timer) AddCount(count int) {
-	C.al_add_timer_count(self.handle, C.int64_t(count))
+    C.al_add_timer_count(self.handle, C.int64_t(count))
 }
 
 // Gets the event source of this timer that can be registered 
 // on an event queue with RegisterEventSource.
 func (self *Timer) GetEventSource() *EventSource {
-	return (*EventSource)(C.al_get_timer_event_source(self.handle))
+    return (*EventSource)(C.al_get_timer_event_source(self.handle))
 }
 
 // Do nothing function for benchmarking only

+ 217 - 223
al/al_test.go

@@ -5,7 +5,7 @@ import "runtime"
 import "flag"
 
 // some parameters
-const expected_version = 83952897
+const expected_version = 84017665 // 83952897
 const SCREEN_W = 640
 const SCREEN_H = 480
 const TEST_FULLSCREEN = true
@@ -13,11 +13,11 @@ const TEST_FULLSCREEN = true
 var fullscreen = flag.Bool("fullscreen", false, "Run fullscreen or not")
 
 func TestGetAllegroVersion(t *testing.T) {
-	version := GetAllegroVersion()
-	if version != expected_version {
-		t.Errorf("unexpected version of Allegro: %d in stead of %d!",
-			version, expected_version)
-	}
+    version := GetAllegroVersion()
+    if version != expected_version {
+        t.Errorf("unexpected version of Allegro: %d in stead of %d!",
+            version, expected_version)
+    }
 }
 
 const CALLBACK_RESULT = 77
@@ -28,269 +28,263 @@ const BMP_H = 23
 
 // Test system installation and deinstallation
 func TestSystemInstall(t *testing.T) {
-	if IsSystemInstalled() {
-		t.Errorf("System should not be installed before install\n")
-		return
-	}
-	if !InstallSystem() {
-		t.Errorf("System should be installed now\n")
-		return
-	}
-	if !IsSystemInstalled() {
-		t.Errorf("System should be installed after install\n")
-		return
-	}
-	UninstallSystem()
-	if IsSystemInstalled() {
-		t.Errorf("System should not be installed after uninstall\n")
-		return
-	}
+    if IsSystemInstalled() {
+        t.Errorf("System should not be installed before install\n")
+        return
+    }
+    if !InstallSystem() {
+        t.Errorf("System should be installed now\n")
+        return
+    }
+    if !IsSystemInstalled() {
+        t.Errorf("System should be installed after install\n")
+        return
+    }
+    UninstallSystem()
+    if IsSystemInstalled() {
+        t.Errorf("System should not be installed after uninstall\n")
+        return
+    }
 }
 
 // Test USTR
 func TestUSTR(t *testing.T) {
-	s1 := "Hello no unicode!"
-	s2 := "Hello µ unicode!"
-	u1 := USTRV(s1)
-	u2 := USTRV(s2)
-	r1 := u1.String()
-	r2 := u2.String()
-	if s1 != r1 {
-		t.Errorf("USTR roundtrip failed: %s->%s", s1, r1)
-	}
-	if s2 != r2 {
-		t.Errorf("USTR roundtrip failed: %s->%s", s2, r2)
-	}
-	u1.Free()
-	u1.Free()
-	u1.Free()
-	if u1.String() != "<destroyed>" {
-		t.Error("USTR.String() should return <destroyed> after Free()")
-	}
+    s1 := "Hello no unicode!"
+    s2 := "Hello µ unicode!"
+    u1 := USTRV(s1)
+    u2 := USTRV(s2)
+    r1 := u1.String()
+    r2 := u2.String()
+    if s1 != r1 {
+        t.Errorf("USTR roundtrip failed: %s->%s", s1, r1)
+    }
+    if s2 != r2 {
+        t.Errorf("USTR roundtrip failed: %s->%s", s2, r2)
+    }
+    u1.Free()
+    u1.Free()
+    u1.Free()
+    if u1.String() != "<destroyed>" {
+        t.Error("USTR.String() should return <destroyed> after Free()")
+    }
 
 }
 
 // Test timer functions 
 func TestGetTimeRest(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	rest := 0.123
-	t1 := GetTime()
-	Rest(rest)
-	t2 := GetTime()
-	del := t2 - t1 - rest
-	if (del > 0.001) || (del < -0.001) {
-		t.Errorf("Rest/GetTime for %f not precise %f %f %f", rest, t1, t2, del)
-	}
+    InstallSystem()
+    defer UninstallSystem()
+    rest := 0.123
+    t1 := GetTime()
+    Rest(rest)
+    t2 := GetTime()
+    del := t2 - t1 - rest
+    if (del > 0.001) || (del < -0.001) {
+        t.Errorf("Rest/GetTime for %f not precise %f %f %f", rest, t1, t2, del)
+    }
 }
 
 // Test path functions
-func TestPath(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	path := GetStandardPath(TEMP_PATH)
-	str := path.String()
-	tmp := "/tmp/"
-	// special case for windows...
-	if runtime.GOOS == "windows" {
-		tmp = `C:\TMP\`
-	}
-	if str != tmp {
-		t.Errorf("GetStandardPath(TEMP_PATH) is not %s but %s", tmp, str)
-	}
+func TestPath(t *testing.T) {    
+    InstallSystem()
+    defer UninstallSystem()    
+    path := GetStandardPath(TEMP_PATH)
+    str := path.String()
+    tmp := "/tmp/"
+    // special case for windows...
+    if runtime.GOOS == "windows" {
+        tmp = `C:\TMP\`
+    }
+    if str != tmp {
+        t.Errorf("GetStandardPath(TEMP_PATH) is not %s but %s", tmp, str)
+    }
 }
 
 // Test display info 
 func TestGetInfo(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	nv := NumVideoAdapters()
-	if nv < 1 {
-		t.Error("No video adapters found!")
-	}
-	for index := 0; index < nv; index++ {
-		info := GetMonitorInfo(index)
-		if info == nil {
-			t.Errorf("Video adapter %d not found!", index)
-			continue
-		}
-		t.Logf("MonitorInfo for %d: %d %d %d %d\n", index,
-			info.X1(), info.Y1(), info.X2(), info.Y2())
-	}
+    InstallSystem()
+    defer UninstallSystem()
+    nv := NumVideoAdapters()
+    if nv < 1 {
+        t.Error("No video adapters found!")
+    }
+    for index := 0; index < nv; index++ {
+        info := GetMonitorInfo(index)
+        if info == nil {
+            t.Errorf("Video adapter %d not found!", index)
+            continue
+        }
+        t.Logf("MonitorInfo for %d: %d %d %d %d\n", index,
+            info.X1(), info.Y1(), info.X2(), info.Y2())
+    }
 }
 
 // Test screen saver inhibition.
 func TestInhibitScreensaver(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	ok := InhibitScreensaver(true)
-	if !ok {
-		t.Errorf("InhibitScreensaver failed: %v", ok)
-	}
+    InstallSystem()
+    defer UninstallSystem()
+    ok := InhibitScreensaver(true)
+    if !ok {
+        t.Errorf("InhibitScreensaver failed: %v", ok)
+    }
 }
 
 // Test joystick functions, works better with a joystick plugged in ;)
 func TestJoystick(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	InstallJoystick()
-	defer UninstallJoystick()
-	num := GetNumJoysticks()
-	t.Logf("Found %d joysticks\n", num)
-	for index := 0; index < num; index++ {
-		js := GetJoystick(index)
-		jsname := js.GetName()
-		sticks := js.GetNumSticks()
-		buttons := js.GetNumButtons()
-		t.Logf("Joystick %s (nr %d) has %d sticks and %d buttons:\n",
-			jsname, index, sticks, buttons)
-		for sdex := 0; sdex < sticks; sdex++ {
-			axes := js.GetNumAxes(sdex)
-			sname := js.GetStickName(sdex)
-			sfname := js.GetStickFlagsName(sdex)
-			t.Logf("Stick %s (nr %d, %s) has %d axes: ", sname, sdex, sfname, axes)
-			for adex := 0; adex < axes; adex++ {
-				aname := js.GetAxisName(sdex, adex)
-				t.Logf("%s (nr %d) ", aname, adex)
-			}
-		}
-		t.Logf("\nButtons :")
-		for bdex := 0; bdex < buttons; bdex++ {
-			bname := js.GetButtonName(bdex)
-			t.Logf("%s (nr %d) ", bname, bdex)
-		}
-		t.Logf("\n")
-	}
+    InstallSystem()
+    defer UninstallSystem()
+    InstallJoystick()
+    defer UninstallJoystick()
+    num := GetNumJoysticks()
+    t.Logf("Found %d joysticks\n", num)
+    for index := 0; index < num; index++ {
+        js := GetJoystick(index)
+        jsname := js.GetName()
+        sticks := js.GetNumSticks()
+        buttons := js.GetNumButtons()
+        t.Logf("Joystick %s (nr %d) has %d sticks and %d buttons:\n",
+            jsname, index, sticks, buttons)
+        for sdex := 0; sdex < sticks; sdex++ {
+            axes := js.GetNumAxes(sdex)
+            sname := js.GetStickName(sdex)
+            sfname := js.GetStickFlagsName(sdex)
+            t.Logf("Stick %s (nr %d, %s) has %d axes: ", sname, sdex, sfname, axes)
+            for adex := 0; adex < axes; adex++ {
+                aname := js.GetAxisName(sdex, adex)
+                t.Logf("%s (nr %d) ", aname, adex)
+            }
+        }
+        t.Logf("\nButtons :")
+        for bdex := 0; bdex < buttons; bdex++ {
+            bname := js.GetButtonName(bdex)
+            t.Logf("%s (nr %d) ", bname, bdex)
+        }
+        t.Logf("\n")
+    }
 }
 
 // Makesa display for testing, using the test's setting above 
 func makeDisplay() *Display {
-	flags := 0
-	// Use full screen mode if needed.
-	if *fullscreen {
-		flags = FULLSCREEN // | GENERATE_EXPOSE_EVENTS
-	} else {
-		SetNewDisplayFlags(flags)
-	}
-	// Create a window to display things on: 640x480 pixels.
-	display := CreateDisplay(SCREEN_W, SCREEN_H)
-	display.Resize(SCREEN_W, SCREEN_H)
-	if !(*fullscreen) {
-		display.SetTitle("Algo test window")
-	}
-	return display
+    flags := 0
+    // Use full screen mode if needed.
+    if *fullscreen {
+        flags = FULLSCREEN // | GENERATE_EXPOSE_EVENTS
+    } else {
+        SetNewDisplayFlags(flags)
+    }
+    // Create a window to display things on: 640x480 pixels.
+    display := CreateDisplay(SCREEN_W, SCREEN_H)
+    display.Resize(SCREEN_W, SCREEN_H)
+    if !(*fullscreen) {
+        display.SetTitle("Algo test window")
+    }
+    return display
 }
 
 // Test basic display functions 
 func TestBasicDisplay(t *testing.T) {
-	InstallSystem()
-	defer UninstallSystem()
-	display := makeDisplay()
-	if display == nil {
-		t.Error("Error creating display.")
-	}
-	HoldBitmapDrawing(true)
-	if !IsBitmapDrawingHeld() {
-		t.Error("Bitmap drawing hold failed")
-	}
-	HoldBitmapDrawing(false)
-	if IsBitmapDrawingHeld() {
-		t.Error("Bitmap drawing hold release failed")
-	}
+    InstallSystem()
+    defer UninstallSystem()
+    display := makeDisplay()
+    if display == nil {
+        t.Error("Error creating display.")
+    }
+    HoldBitmapDrawing(true)
+    if !IsBitmapDrawingHeld() {
+        t.Error("Bitmap drawing hold failed")
+    }
+    HoldBitmapDrawing(false)
+    if IsBitmapDrawingHeld() {
+        t.Error("Bitmap drawing hold release failed")
+    }
 
-	/*
-	   if ! {
-	     t.Error("Resize of display failed.")
-	   }
-	*/
-	blue := CreateColor(0.0, 0.0, 1.0, 1.0)
-	yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
-	ClearToColor(blue)
-	DrawPixel(20.0, 10.0, yellow)
-	FlipDisplay()
-	Rest(1.0)
-	display.SetWindowPosition(50, 100)
-	ClearToColor(yellow)
-	DrawPixel(20.0, 10.0, blue)
-	FlipDisplay()
-	display.Destroy()
-	Rest(1.0)
+    /*
+       if ! {
+         t.Error("Resize of display failed.")
+       }
+    */
+    blue := CreateColor(0.0, 0.0, 1.0, 1.0)
+    yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
+    ClearToColor(blue)
+    DrawPixel(20.0, 10.0, yellow)
+    FlipDisplay()
+    Rest(1.0)
+    display.SetWindowPosition(50, 100)
+    ClearToColor(yellow)
+    DrawPixel(20.0, 10.0, blue)
+    FlipDisplay()
+    display.Destroy()
+    Rest(1.0)
 }
 
-func TestCreateCustomBitmap(t *testing.T) {
-	// system must be installled and display opened to test CreateCustomBitmap
-	InstallSystem()
-	defer UninstallSystem()
-	display := makeDisplay()
-	if display == nil {
-		t.Error("Error creating display.")
-	}
-	defer display.Destroy()
+// Test some font functions 
+func TestFonts(t *testing.T) {
+    InstallSystem()
+    defer UninstallSystem()
+    InitFontAddon()
+    defer ShutdownFontAddon()
+    
+    display := makeDisplay()
+    if display == nil {
+        t.Error("Error creating display.")
+    }
+  
+    
+    font := CreateBuiltinFont()
+    if font == nil {
+        t.Error("Cannot create built in font.")
+    }
+    ranges , count := font.Ranges()
+    t.Logf("Built in font has ranges: %v, %d\n", ranges, count);
+    blue := CreateColor(0.0, 0.0, 1.0, 1.0)
+    yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
+    ClearToColor(blue)
+    font.DrawMultilineTextf(yellow, 20, 30, 100, 10, 0, "This is a rather long text that should flow over multiple lines, it also has placeholders like this one: %d, and this should all work fine.", 7)
+    FlipDisplay()
+    Rest(1.0)
+    font.Destroy()
+    display.Destroy()
+}
 
-	upval := "OK!"
-	called := false
-	MyCallback := func(bmp *Bitmap, data interface{}) bool {
-		t.Logf("Callback called! %s\n", upval)
-		called = true
-		if bmp.Height() != BMP_H {
-			t.Errorf("Height not correct: %d in stead of %d!\n", bmp.Height(), BMP_H)
-		}
-		return false
-	}
-	bmp := CreateCustomBitmap(BMP_W, BMP_H, MyCallback, nil)
-	if bmp == nil {
-		t.Errorf("Callback result should not be nil!")
-	}
-	if bmp.Height() != BMP_H {
-		t.Errorf("Height not correct: %d in stead of %d!\n", bmp.Height(), BMP_H)
-	}
-	if bmp.Width() != BMP_W {
-		t.Errorf("Height not correct: %d in stead of %d!\n", bmp.Height(), BMP_W)
-	}
 
-	if !called {
-		t.Errorf("Failed to call callback!\n")
-	}
-}
 
 // Benchmark basic display function ClearToColor
 func BenchmarkClearToColor(b *testing.B) {
-	b.StopTimer()
-	InstallSystem()
-	defer UninstallSystem()
-	display := makeDisplay()
-	blue := CreateColor(0.0, 0.0, 1.0, 1.0)
-	if display == nil {
-		b.Fatal("Error creating display. Cannot benchmark it.")
-	}
-	b.StartTimer()
-	for i := 0; i < b.N; i++ {
-		ClearToColor(blue)
-	}
-	// FlipDisplay()
-	display.Destroy()
+    b.StopTimer()
+    InstallSystem()
+    defer UninstallSystem()
+    display := makeDisplay()
+    blue := CreateColor(0.0, 0.0, 1.0, 1.0)
+    if display == nil {
+        b.Fatal("Error creating display. Cannot benchmark it.")
+    }
+    b.StartTimer()
+    for i := 0; i < b.N; i++ {
+        ClearToColor(blue)
+    }
+    // FlipDisplay()
+    display.Destroy()
 }
 
 // Benchmark basic display function FlipDisplay
 func BenchmarkFlipDisplay(b *testing.B) {
-	b.StopTimer()
-	InstallSystem()
-	defer UninstallSystem()
-	display := makeDisplay()
-	if display == nil {
-		b.Fatal("Error creating display. Cannot benchmark it.")
-	}
-	b.StartTimer()
-	for i := 0; i < b.N; i++ {
-		FlipDisplay()
-	}
-	display.Destroy()
+    b.StopTimer()
+    InstallSystem()
+    defer UninstallSystem()
+    display := makeDisplay()
+    if display == nil {
+        b.Fatal("Error creating display. Cannot benchmark it.")
+    }
+    b.StartTimer()
+    for i := 0; i < b.N; i++ {
+        FlipDisplay()
+    }
+    display.Destroy()
 }
 
 // Benchmarking of C call overhead
-// Benchmark basic display function FlipDisplay
 func BenchmarkDoNothing(b *testing.B) {
-	for i := 0; i < b.N; i++ {
-		DoNothing()
-	}
+    for i := 0; i < b.N; i++ {
+        DoNothing()
+    }
 }

+ 315 - 326
al/audio.go

@@ -3,7 +3,7 @@ package al
 
 /*
 #cgo pkg-config: allegro_audio-5
-#cgo CFLAGS: -I/usr/local/include
+#cgo CFLAGS: -I/usr/local/include -DALLEGRO_UNSTABLE
 #cgo linux LDFLAGS: -lc_nonshared
 #include <stdlib.h>
 #include <allegro5/allegro.h>
@@ -17,14 +17,14 @@ import "unsafe"
 // User event type emitted when a stream fragment is ready to be
 // refilled with more audio data.
 const (
-	EVENT_AUDIO_STREAM_FRAGMENT   = C.ALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT
-	EVENT_AUDIO_STREAM_FINISHED   = C.ALLEGRO_EVENT_AUDIO_STREAM_FINISHED
-	EVENT_AUDIO_RECORDER_FRAGMENT = C.ALLEGRO_EVENT_AUDIO_RECORDER_FRAGMENT
+    EVENT_AUDIO_STREAM_FRAGMENT   = C.ALLEGRO_EVENT_AUDIO_STREAM_FRAGMENT
+    EVENT_AUDIO_STREAM_FINISHED   = C.ALLEGRO_EVENT_AUDIO_STREAM_FINISHED
+    EVENT_AUDIO_RECORDER_FRAGMENT = C.ALLEGRO_EVENT_AUDIO_RECORDER_FRAGMENT
 )
 
 // Converts wrapper Event pointer to C Allegro audio recorder event
 func (self *Event) AUDIO_RECORDER_EVENT() *C.ALLEGRO_AUDIO_RECORDER_EVENT {
-	return (*C.ALLEGRO_AUDIO_RECORDER_EVENT)(self.toPointer())
+    return (*C.ALLEGRO_AUDIO_RECORDER_EVENT)(self.toPointer())
 }
 
 type AudioRecorderEvent C.ALLEGRO_AUDIO_RECORDER_EVENT
@@ -33,18 +33,18 @@ type AudioDepth int
 
 // Converts an AudioDepth to an ALLEGRO_AUDIO_DEPTH
 func (self AudioDepth) toC() C.ALLEGRO_AUDIO_DEPTH {
-	return C.ALLEGRO_AUDIO_DEPTH(self)
+    return C.ALLEGRO_AUDIO_DEPTH(self)
 }
 
 const (
-	AUDIO_DEPTH_INT8     AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT8
-	AUDIO_DEPTH_INT16    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT16
-	AUDIO_DEPTH_INT24    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT24
-	AUDIO_DEPTH_UINT8    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT8
-	AUDIO_DEPTH_UINT16   AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT16
-	AUDIO_DEPTH_UINT24   AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT24
-	AUDIO_DEPTH_FLOAT32  AudioDepth = C.ALLEGRO_AUDIO_DEPTH_FLOAT32
-	AUDIO_DEPTH_UNSIGNED AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UNSIGNED
+    AUDIO_DEPTH_INT8     AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT8
+    AUDIO_DEPTH_INT16    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT16
+    AUDIO_DEPTH_INT24    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_INT24
+    AUDIO_DEPTH_UINT8    AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT8
+    AUDIO_DEPTH_UINT16   AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT16
+    AUDIO_DEPTH_UINT24   AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UINT24
+    AUDIO_DEPTH_FLOAT32  AudioDepth = C.ALLEGRO_AUDIO_DEPTH_FLOAT32
+    AUDIO_DEPTH_UNSIGNED AudioDepth = C.ALLEGRO_AUDIO_DEPTH_UNSIGNED
 )
 
 /*
@@ -59,536 +59,530 @@ type ChannelConf int
 
 // Converts a ChannelConf to a C.ALLEGRO_CHANNEL_CONF
 func (self ChannelConf) toC() C.ALLEGRO_CHANNEL_CONF {
-	return (C.ALLEGRO_CHANNEL_CONF)(self)
+    return (C.ALLEGRO_CHANNEL_CONF)(self)
 }
 
 const (
-	CHANNEL_CONF_1   ChannelConf = C.ALLEGRO_CHANNEL_CONF_1
-	CHANNEL_CONF_2   ChannelConf = C.ALLEGRO_CHANNEL_CONF_2
-	CHANNEL_CONF_3   ChannelConf = C.ALLEGRO_CHANNEL_CONF_3
-	CHANNEL_CONF_4   ChannelConf = C.ALLEGRO_CHANNEL_CONF_4
-	CHANNEL_CONF_5_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_5_1
-	CHANNEL_CONF_6_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_6_1
-	CHANNEL_CONF_7_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_7_1
-	MAX_CHANNELS     ChannelConf = C.ALLEGRO_MAX_CHANNELS
+    CHANNEL_CONF_1   ChannelConf = C.ALLEGRO_CHANNEL_CONF_1
+    CHANNEL_CONF_2   ChannelConf = C.ALLEGRO_CHANNEL_CONF_2
+    CHANNEL_CONF_3   ChannelConf = C.ALLEGRO_CHANNEL_CONF_3
+    CHANNEL_CONF_4   ChannelConf = C.ALLEGRO_CHANNEL_CONF_4
+    CHANNEL_CONF_5_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_5_1
+    CHANNEL_CONF_6_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_6_1
+    CHANNEL_CONF_7_1 ChannelConf = C.ALLEGRO_CHANNEL_CONF_7_1
+    MAX_CHANNELS     ChannelConf = C.ALLEGRO_MAX_CHANNELS
 )
 
 type PlayMode int
 
 // Converts a PlayMode to a C.ALLEGRO_PLAYMODE
 func (self PlayMode) toC() C.ALLEGRO_PLAYMODE {
-	return (C.ALLEGRO_PLAYMODE)(self)
+    return (C.ALLEGRO_PLAYMODE)(self)
 }
 
 const (
-	PLAYMODE_ONCE  PlayMode = C.ALLEGRO_PLAYMODE_ONCE
-	PLAYMODE_LOOP  PlayMode = C.ALLEGRO_PLAYMODE_LOOP
-	PLAYMODE_BIDIR PlayMode = C.ALLEGRO_PLAYMODE_BIDIR
+    PLAYMODE_ONCE  PlayMode = C.ALLEGRO_PLAYMODE_ONCE
+    PLAYMODE_LOOP  PlayMode = C.ALLEGRO_PLAYMODE_LOOP
+    PLAYMODE_BIDIR PlayMode = C.ALLEGRO_PLAYMODE_BIDIR
 )
 
 type MixerQuality int
 
 // Converts a MixerQuaklity to a C.ALLEGRO_MIXER_QUALITY
 func (self MixerQuality) toC() C.ALLEGRO_MIXER_QUALITY {
-	return (C.ALLEGRO_MIXER_QUALITY)(self)
+    return (C.ALLEGRO_MIXER_QUALITY)(self)
 }
 
 const (
-	MIXER_QUALITY_POINT  MixerQuality = C.ALLEGRO_MIXER_QUALITY_POINT
-	MIXER_QUALITY_LINEAR MixerQuality = C.ALLEGRO_MIXER_QUALITY_LINEAR
-	MIXER_QUALITY_CUBIC  MixerQuality = C.ALLEGRO_MIXER_QUALITY_CUBIC
+    MIXER_QUALITY_POINT  MixerQuality = C.ALLEGRO_MIXER_QUALITY_POINT
+    MIXER_QUALITY_LINEAR MixerQuality = C.ALLEGRO_MIXER_QUALITY_LINEAR
+    MIXER_QUALITY_CUBIC  MixerQuality = C.ALLEGRO_MIXER_QUALITY_CUBIC
 )
 
 const AUDIO_PAN_NONE = -1000.0
 
 type AudioEventType int
 
-const (
-	ALLEGRO_EVENT_AUDIO_ROUTE_CHANGE = C.ALLEGRO_EVENT_AUDIO_ROUTE_CHANGE
-	EVENT_AUDIO_INTERRUPTION         = C.ALLEGRO_EVENT_AUDIO_INTERRUPTION
-	EVENT_AUDIO_END_INTERRUPTION     = C.ALLEGRO_EVENT_AUDIO_END_INTERRUPTION
-)
-
 type Sample struct {
-	handle *C.ALLEGRO_SAMPLE
+    handle *C.ALLEGRO_SAMPLE
 }
 
 type SampleId C.ALLEGRO_SAMPLE_ID
 
 func (self *SampleId) toC() *C.ALLEGRO_SAMPLE_ID {
-	return (*C.ALLEGRO_SAMPLE_ID)(self)
+    return (*C.ALLEGRO_SAMPLE_ID)(self)
 }
 
 type SampleInstance struct {
-	handle *C.ALLEGRO_SAMPLE_INSTANCE
+    handle *C.ALLEGRO_SAMPLE_INSTANCE
 }
 
 type AudioStream struct {
-	handle *C.ALLEGRO_AUDIO_STREAM
+    handle *C.ALLEGRO_AUDIO_STREAM
 }
 
 type Mixer struct {
-	handle *C.ALLEGRO_MIXER
+    handle *C.ALLEGRO_MIXER
 }
 
 type Voice struct {
-	handle *C.ALLEGRO_VOICE
+    handle *C.ALLEGRO_VOICE
 }
 
 type AudioRecorder struct {
-	handle *C.ALLEGRO_AUDIO_RECORDER
+    handle *C.ALLEGRO_AUDIO_RECORDER
 }
 
 func (self *Sample) toC() *C.ALLEGRO_SAMPLE {
-	return (*C.ALLEGRO_SAMPLE)(self.handle)
+    return (*C.ALLEGRO_SAMPLE)(self.handle)
 }
 
 // Destroys the sample.
 func (self *Sample) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_sample(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_sample(self.toC())
+    }
+    self.handle = nil
 }
 
 // Sets up a finalizer for this Sample that calls Destroy() and return self
 func (self *Sample) SetDestroyFinalizer() *Sample {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
+    }
+    return self
 }
 
 func wrapSampleRaw(sample *C.ALLEGRO_SAMPLE) *Sample {
-	if sample == nil {
-		return nil
-	}
-	return &Sample{sample}
+    if sample == nil {
+        return nil
+    }
+    return &Sample{sample}
 }
 
 func wrapSample(sample *C.ALLEGRO_SAMPLE) *Sample {
-	self := wrapSampleRaw(sample)
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
-	}
-	return self
+    self := wrapSampleRaw(sample)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Sample) { me.Destroy() })
+    }
+    return self
 }
 
 func createSample(data []byte, samples uint, freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_SAMPLE {
-	// don't let allegro free the data, it's owned by Go.
-	// XXX: copy data here in stead of using the go data???
-	return C.al_create_sample(unsafe.Pointer(&data[0]), C.uint(samples),
-		C.uint(freq), depth.toC(), chan_conf.toC(), b2cb(false))
+    // don't let allegro free the data, it's owned by Go.
+    // XXX: copy data here in stead of using the go data???
+    return C.al_create_sample(unsafe.Pointer(&data[0]), C.uint(samples),
+        C.uint(freq), depth.toC(), chan_conf.toC(), b2cb(false))
 }
 
 // Creates a Sample with a Destroy finalizer set. BEWARE! data must be big enough fort he params
 // or this will crash spectacularly. Also, make sure that data doesn't get collected by the GC, or 
 // trouble will arise. 
 func CreateSample(data []byte, samples uint, freq uint, depth AudioDepth, chan_conf ChannelConf) *Sample {
-	return wrapSample(createSample(data, samples, freq, depth, chan_conf))
+    return wrapSample(createSample(data, samples, freq, depth, chan_conf))
 }
 
 // Returns the frequency of the sample
 func (self *Sample) Frequency() uint {
-	return uint(C.al_get_sample_frequency(self.handle))
+    return uint(C.al_get_sample_frequency(self.handle))
 }
 
 // Returns the length of the sample
 func (self *Sample) Length() uint {
-	return uint(C.al_get_sample_length(self.handle))
+    return uint(C.al_get_sample_length(self.handle))
 }
 
 // Returns the depth of the sample 
 func (self *Sample) Depth() uint {
-	return uint(C.al_get_sample_depth(self.handle))
+    return uint(C.al_get_sample_depth(self.handle))
 }
 
 // returns the amount of channels the sample has
 func (self *Sample) Channels() uint {
-	return uint(C.al_get_sample_channels(self.handle))
+    return uint(C.al_get_sample_channels(self.handle))
 }
 
 // Returns the raw data pointer of the sample data. 
 func (self *Sample) DataRaw() unsafe.Pointer {
-	return (C.al_get_sample_data(self.handle))
+    return (C.al_get_sample_data(self.handle))
 }
 
 // Returns the frequency of the sample instance
 func (self *SampleInstance) Frequency() uint {
-	return uint(C.al_get_sample_instance_frequency(self.handle))
+    return uint(C.al_get_sample_instance_frequency(self.handle))
 }
 
 // Returns the length of the sample instance
 func (self *SampleInstance) Length() uint {
-	return uint(C.al_get_sample_instance_length(self.handle))
+    return uint(C.al_get_sample_instance_length(self.handle))
 }
 
 // Returns the position of the sample instance
 func (self *SampleInstance) Position() uint {
-	return uint(C.al_get_sample_instance_position(self.handle))
+    return uint(C.al_get_sample_instance_position(self.handle))
 }
 
 // Returns the of the sample instance
 func (self *SampleInstance) Speed() float32 {
-	return float32(C.al_get_sample_instance_speed(self.handle))
+    return float32(C.al_get_sample_instance_speed(self.handle))
 }
 
 // Returns the of the sample instance
 func (self *SampleInstance) Gain() float32 {
-	return float32(C.al_get_sample_instance_gain(self.handle))
+    return float32(C.al_get_sample_instance_gain(self.handle))
 }
 
 // Returns the of the sample instance
 func (self *SampleInstance) Pan() float32 {
-	return float32(C.al_get_sample_instance_pan(self.handle))
+    return float32(C.al_get_sample_instance_pan(self.handle))
 }
 
 // Returns the of the sample instance
 func (self *SampleInstance) Time() float32 {
-	return float32(C.al_get_sample_instance_time(self.handle))
+    return float32(C.al_get_sample_instance_time(self.handle))
 }
 
 // Returns the depth of the sample instance
 func (self *SampleInstance) Depth() AudioDepth {
-	return AudioDepth(C.al_get_sample_instance_depth(self.handle))
+    return AudioDepth(C.al_get_sample_instance_depth(self.handle))
 }
 
 // Returns the channel configuration of the sample instance
 func (self *SampleInstance) Channels() ChannelConf {
-	return ChannelConf(C.al_get_sample_instance_channels(self.handle))
+    return ChannelConf(C.al_get_sample_instance_channels(self.handle))
 }
 
 // Returns the play mode of the sample instance
 func (self *SampleInstance) Playmode() PlayMode {
-	return PlayMode(C.al_get_sample_instance_playmode(self.handle))
+    return PlayMode(C.al_get_sample_instance_playmode(self.handle))
 }
 
 // Returns wheter or not the sample instance is playing
 func (self *SampleInstance) Playing() bool {
-	return cb2b(C.al_get_sample_instance_playing(self.handle))
+    return cb2b(C.al_get_sample_instance_playing(self.handle))
 }
 
 // Returns wheter or not the sample instance is attached
 func (self *SampleInstance) Attached() bool {
-	return cb2b(C.al_get_sample_instance_attached(self.handle))
+    return cb2b(C.al_get_sample_instance_attached(self.handle))
 }
 
 // Sets the position of the sample instance.
 func (self *SampleInstance) SetPosition(val uint) bool {
-	return cb2b(C.al_set_sample_instance_position(self.handle, C.uint(val)))
+    return cb2b(C.al_set_sample_instance_position(self.handle, C.uint(val)))
 }
 
 // Sets the length of the sample instance.
 func (self *SampleInstance) SetLength(val uint) bool {
-	return cb2b(C.al_set_sample_instance_length(self.handle, C.uint(val)))
+    return cb2b(C.al_set_sample_instance_length(self.handle, C.uint(val)))
 }
 
 // Sets the speed of the sample instance.
 func (self *SampleInstance) SetSpeed(val float32) bool {
-	return cb2b(C.al_set_sample_instance_speed(self.handle, C.float(val)))
+    return cb2b(C.al_set_sample_instance_speed(self.handle, C.float(val)))
 }
 
 // Sets the gain of the sample instance.
 func (self *SampleInstance) SetGain(val float32) bool {
-	return cb2b(C.al_set_sample_instance_gain(self.handle, C.float(val)))
+    return cb2b(C.al_set_sample_instance_gain(self.handle, C.float(val)))
 }
 
 // Sets the pan of the sample instance.
 func (self *SampleInstance) SetPan(val float32) bool {
-	return cb2b(C.al_set_sample_instance_pan(self.handle, C.float(val)))
+    return cb2b(C.al_set_sample_instance_pan(self.handle, C.float(val)))
 }
 
 // Sets the play mode of the sample instance.
 func (self *SampleInstance) SetPlaymode(val PlayMode) bool {
-	return cb2b(C.al_set_sample_instance_playmode(self.handle, val.toC()))
+    return cb2b(C.al_set_sample_instance_playmode(self.handle, val.toC()))
 }
 
 // Sets the play status of the sample instance.
 func (self *SampleInstance) SetPlaying(val bool) bool {
-	return cb2b(C.al_set_sample_instance_playing(self.handle, b2cb(val)))
+    return cb2b(C.al_set_sample_instance_playing(self.handle, b2cb(val)))
 }
 
 // Detaches the sample instance from it's player
 func (self *SampleInstance) Detach() bool {
-	return cb2b(C.al_detach_sample_instance(self.handle))
+    return cb2b(C.al_detach_sample_instance(self.handle))
 }
 
 // Sets the sample data to use for the sample instance
 func (self *SampleInstance) SetSample(val *Sample) bool {
-	return cb2b(C.al_set_sample(self.handle, val.handle))
+    return cb2b(C.al_set_sample(self.handle, val.handle))
 }
 
 // Gets the RAW sample data that was linked to the sample instance
 func (self *SampleInstance) SampleRaw() *Sample {
-	return wrapSampleRaw(C.al_get_sample(self.handle))
+    return wrapSampleRaw(C.al_get_sample(self.handle))
 }
 
 // Plays the sample instance 
 func (self *SampleInstance) Play() bool {
-	return cb2b(C.al_play_sample_instance(self.handle))
+    return cb2b(C.al_play_sample_instance(self.handle))
 }
 
 // Stops the sample instannce playback
 func (self *SampleInstance) Stop() bool {
-	return cb2b(C.al_stop_sample_instance(self.handle))
+    return cb2b(C.al_stop_sample_instance(self.handle))
 }
 
 func (self *AudioStream) toC() *C.ALLEGRO_AUDIO_STREAM {
-	return (*C.ALLEGRO_AUDIO_STREAM)(self.handle)
+    return (*C.ALLEGRO_AUDIO_STREAM)(self.handle)
 }
 
 // Destroys the audio stream.
 func (self *AudioStream) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_audio_stream(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_audio_stream(self.toC())
+    }
+    self.handle = nil
 }
 
 // Sets up a finalizer for this AudioStream that calls Destroy() and return self
 func (self *AudioStream) SetDestroyFinalizer() *AudioStream {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *AudioStream) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *AudioStream) { me.Destroy() })
+    }
+    return self
 }
 
 func wrapAudioStreamRaw(data *C.ALLEGRO_AUDIO_STREAM) *AudioStream {
-	if data == nil {
-		return nil
-	}
-	return &AudioStream{data}
+    if data == nil {
+        return nil
+    }
+    return &AudioStream{data}
 }
 
 func wrapAudioStream(data *C.ALLEGRO_AUDIO_STREAM) *AudioStream {
-	self := wrapAudioStreamRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapAudioStreamRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 // Creates an audio stream, with finalizer installed.
 func CreateAudioStream(bufc, samples, freq uint, depth AudioDepth, chan_conf ChannelConf) *AudioStream {
-	return wrapAudioStream(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
-		C.uint(freq), depth.toC(), chan_conf.toC()))
+    return wrapAudioStream(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
+        C.uint(freq), depth.toC(), chan_conf.toC()))
 }
 
 // Creates an audio stream, with NO finalizer installed.
 func CreateAudioStreamRaw(bufc, samples, freq uint, depth AudioDepth, chan_conf ChannelConf) *AudioStream {
-	return wrapAudioStreamRaw(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
-		C.uint(freq), depth.toC(), chan_conf.toC()))
+    return wrapAudioStreamRaw(C.al_create_audio_stream(C.size_t(bufc), C.uint(samples),
+        C.uint(freq), depth.toC(), chan_conf.toC()))
 }
 
 // Drains all data from an audio stream
 func (self *AudioStream) Drain() {
-	C.al_drain_audio_stream(self.handle)
+    C.al_drain_audio_stream(self.handle)
 }
 
 // Returns the frequency of the audio stream
 func (self *AudioStream) Frequency() uint {
-	return uint(C.al_get_audio_stream_frequency(self.handle))
+    return uint(C.al_get_audio_stream_frequency(self.handle))
 }
 
 // Returns the length of the audio stream
 func (self *AudioStream) Length() uint {
-	return uint(C.al_get_audio_stream_length(self.handle))
+    return uint(C.al_get_audio_stream_length(self.handle))
 }
 
 // Returns the speed of the audio stream
 func (self *AudioStream) Speed() float32 {
-	return float32(C.al_get_audio_stream_speed(self.handle))
+    return float32(C.al_get_audio_stream_speed(self.handle))
 }
 
 // Returns the amount of fragments of the audio stream
 func (self *AudioStream) Fragments() float32 {
-	return float32(C.al_get_audio_stream_fragments(self.handle))
+    return float32(C.al_get_audio_stream_fragments(self.handle))
 }
 
 // Returns the amount of available fragments of the audio stream
 func (self *AudioStream) AvailableFragments() float32 {
-	return float32(C.al_get_available_audio_stream_fragments(self.handle))
+    return float32(C.al_get_available_audio_stream_fragments(self.handle))
 }
 
 // Returns the gain of the audio stream
 func (self *AudioStream) Gain() float32 {
-	return float32(C.al_get_audio_stream_gain(self.handle))
+    return float32(C.al_get_audio_stream_gain(self.handle))
 }
 
 // Returns the pan of the audio stream
 func (self *AudioStream) Pan() float32 {
-	return float32(C.al_get_audio_stream_pan(self.handle))
+    return float32(C.al_get_audio_stream_pan(self.handle))
 }
 
 // Returns the depth of the audio stream
 func (self *AudioStream) Depth() AudioDepth {
-	return AudioDepth(C.al_get_audio_stream_depth(self.handle))
+    return AudioDepth(C.al_get_audio_stream_depth(self.handle))
 }
 
 // Returns the channel configuration of the audio stream
 func (self *AudioStream) Channels() ChannelConf {
-	return ChannelConf(C.al_get_audio_stream_channels(self.handle))
+    return ChannelConf(C.al_get_audio_stream_channels(self.handle))
 }
 
 // Returns the play mode of the audio stream
 func (self *AudioStream) Playmode() PlayMode {
-	return PlayMode(C.al_get_audio_stream_playmode(self.handle))
+    return PlayMode(C.al_get_audio_stream_playmode(self.handle))
 }
 
 // Returns wheter or not the audio stream is playing
 func (self *AudioStream) Playing() bool {
-	return cb2b(C.al_get_audio_stream_playing(self.handle))
+    return cb2b(C.al_get_audio_stream_playing(self.handle))
 }
 
 // Returns wheter or not the audio stream is attached
 func (self *AudioStream) Attached() bool {
-	return cb2b(C.al_get_audio_stream_attached(self.handle))
+    return cb2b(C.al_get_audio_stream_attached(self.handle))
 }
 
 // Returns an unsafe pointer to the audio stream's fragment
 func (self *AudioStream) Fragment() unsafe.Pointer {
-	return C.al_get_audio_stream_fragment(self.handle)
+    return C.al_get_audio_stream_fragment(self.handle)
 }
 
 // Sets the speed of the audio stream.
 func (self *AudioStream) SetSpeed(val float32) bool {
-	return cb2b(C.al_set_audio_stream_speed(self.handle, C.float(val)))
+    return cb2b(C.al_set_audio_stream_speed(self.handle, C.float(val)))
 }
 
 // Sets the gain of the audio stream.
 func (self *AudioStream) SetGain(val float32) bool {
-	return cb2b(C.al_set_audio_stream_gain(self.handle, C.float(val)))
+    return cb2b(C.al_set_audio_stream_gain(self.handle, C.float(val)))
 }
 
 // Sets the pan of the audio stream.
 func (self *AudioStream) SetPan(val float32) bool {
-	return cb2b(C.al_set_audio_stream_pan(self.handle, C.float(val)))
+    return cb2b(C.al_set_audio_stream_pan(self.handle, C.float(val)))
 }
 
 // Sets the play mode of the audio stream.
 func (self *AudioStream) SetPlaymode(val PlayMode) bool {
-	return cb2b(C.al_set_audio_stream_playmode(self.handle, val.toC()))
+    return cb2b(C.al_set_audio_stream_playmode(self.handle, val.toC()))
 }
 
 // Sets the play status of the audio stream.
 func (self *AudioStream) SetPlaying(val bool) bool {
-	return cb2b(C.al_set_audio_stream_playing(self.handle, b2cb(val)))
+    return cb2b(C.al_set_audio_stream_playing(self.handle, b2cb(val)))
 }
 
 // Detaches the audio stream from it's player
 func (self *AudioStream) Detach() bool {
-	return cb2b(C.al_detach_sample_instance(self.handle))
+    return cb2b(C.al_detach_audio_stream(self.handle))
 }
 
 // Sets an unsafe pointer as the the audio stream's fragment
 func (self *AudioStream) SetFragment(ptr unsafe.Pointer) bool {
-	return cb2b(C.al_set_audio_stream_fragment(self.handle, ptr))
+    return cb2b(C.al_set_audio_stream_fragment(self.handle, ptr))
 }
 
 // Rewinds the audio stream
 func (self *AudioStream) Rewind() bool {
-	return cb2b(C.al_rewind_audio_stream(self.handle))
+    return cb2b(C.al_rewind_audio_stream(self.handle))
 }
 
 // Seeks to a position in the audio stream, expressed in seconds.
 func (self *AudioStream) SeekSeconds(secs float64) bool {
-	return cb2b(C.al_seek_audio_stream_secs(self.handle, C.double(secs)))
+    return cb2b(C.al_seek_audio_stream_secs(self.handle, C.double(secs)))
 }
 
 // Gets the position in the audio stream, expressed in seconds.
 func (self *AudioStream) PositionSeconds() (secs float64) {
-	return float64(C.al_get_audio_stream_position_secs(self.handle))
+    return float64(C.al_get_audio_stream_position_secs(self.handle))
 }
 
 // Gets the length of the audio stream, expressed in seconds.
 func (self *AudioStream) LengthSeconds() (secs float64) {
-	return float64(C.al_get_audio_stream_length_secs(self.handle))
+    return float64(C.al_get_audio_stream_length_secs(self.handle))
 }
 
 // Sets up a loop in the audio stream, expressed in seconds.
 func (self *AudioStream) LoopSeconds(start, end float64) bool {
-	return cb2b(C.al_set_audio_stream_loop_secs(self.handle, C.double(start), C.double(end)))
+    return cb2b(C.al_set_audio_stream_loop_secs(self.handle, C.double(start), C.double(end)))
 }
 
 // Returns the event source to use to listen to events on the audio stream.
 func (self *AudioStream) Eventsource() *EventSource {
-	return wrapEventSourceRaw(C.al_get_audio_stream_event_source(self.handle))
+    return wrapEventSourceRaw(C.al_get_audio_stream_event_source(self.handle))
 }
 
 // Converts a mixer to it's underlying C pointer
 func (self *Mixer) toC() *C.ALLEGRO_MIXER {
-	return (*C.ALLEGRO_MIXER)(self.handle)
+    return (*C.ALLEGRO_MIXER)(self.handle)
 }
 
 // Destroys the mixer.
 func (self *Mixer) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_mixer(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_mixer(self.toC())
+    }
+    self.handle = nil
 }
 
 // Sets up a finalizer for this Mixer that calls Destroy() and return self
 func (self *Mixer) SetDestroyFinalizer() *Mixer {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Mixer) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Mixer) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C mixer into a go mixer
 func wrapMixerRaw(data *C.ALLEGRO_MIXER) *Mixer {
-	if data == nil {
-		return nil
-	}
-	return &Mixer{data}
+    if data == nil {
+        return nil
+    }
+    return &Mixer{data}
 }
 
 // Wraps a C mixer into a go mixer and sets up a finalizer that calls Destroy()
 func wrapMixer(data *C.ALLEGRO_MIXER) *Mixer {
-	self := wrapMixerRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapMixerRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 func createMixer(freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_MIXER {
-	return C.al_create_mixer(C.uint(freq), depth.toC(), chan_conf.toC())
+    return C.al_create_mixer(C.uint(freq), depth.toC(), chan_conf.toC())
 }
 
 // Creates a new mixer with no finaliser attached to it.
 func CreateMixerRaw(freq uint, depth AudioDepth, chan_conf ChannelConf) *Mixer {
-	return wrapMixerRaw(createMixer(freq, depth, chan_conf))
+    return wrapMixerRaw(createMixer(freq, depth, chan_conf))
 }
 
 // Creates a new mixer with a finaliser that will call Destroy attached to it.
 func CreateMixer(freq uint, depth AudioDepth, chan_conf ChannelConf) *Mixer {
-	return wrapMixer(createMixer(freq, depth, chan_conf))
+    return wrapMixer(createMixer(freq, depth, chan_conf))
 }
 
 // Attaches a sample instance to the given mixer. 
 func (mixer *Mixer) AttachSampleInstance(stream *SampleInstance) bool {
-	return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
 }
 
 // Attaches the sample instance to the given mixer. 
 func (stream *SampleInstance) Attach(mixer *Mixer) bool {
-	return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_sample_instance_to_mixer(stream.handle, mixer.handle))
 }
 
 // Attaches an audio stream  to the given mixer. 
 func (mixer *Mixer) AttachAudioStream(stream *AudioStream) bool {
-	return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
 }
 
 // Attaches the audio stream to the given mixer. 
 func (stream *AudioStream) Attach(mixer *Mixer) bool {
-	return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_audio_stream_to_mixer(stream.handle, mixer.handle))
 }
 
 // Attaches a mixer to the given mixer. 
 func (mixer *Mixer) AttachMixer(stream *Mixer) bool {
-	return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
 }
 
 // Attaches the given mixer to the latter mixer. 
 func (stream *Mixer) Attach(mixer *Mixer) bool {
-	return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
+    return cb2b(C.al_attach_mixer_to_mixer(stream.handle, mixer.handle))
 }
 
 /*
@@ -601,520 +595,515 @@ ALLEGRO_KCM_AUDIO_FUNC(bool, al_set_mixer_postprocess_callback, (
 
 // Returns the frequency of the mixer
 func (self *Mixer) Frequency() uint {
-	return uint(C.al_get_mixer_frequency(self.handle))
+    return uint(C.al_get_mixer_frequency(self.handle))
 }
 
 // Returns the gain of the mixer
 func (self *Mixer) Gain() float32 {
-	return float32(C.al_get_mixer_gain(self.handle))
+    return float32(C.al_get_mixer_gain(self.handle))
 }
 
 // Returns the depth of the mixer
 func (self *Mixer) Depth() AudioDepth {
-	return AudioDepth(C.al_get_mixer_depth(self.handle))
+    return AudioDepth(C.al_get_mixer_depth(self.handle))
 }
 
 // Returns the channel configuration of the mixer
 func (self *Mixer) Channels() ChannelConf {
-	return ChannelConf(C.al_get_mixer_channels(self.handle))
+    return ChannelConf(C.al_get_mixer_channels(self.handle))
 }
 
 // Returns the quality of the mixer
 func (self *Mixer) Quality() MixerQuality {
-	return MixerQuality(C.al_get_mixer_quality(self.handle))
+    return MixerQuality(C.al_get_mixer_quality(self.handle))
 }
 
 // Returns wheter or not the mixer is playing
 func (self *Mixer) Playing() bool {
-	return cb2b(C.al_get_mixer_playing(self.handle))
+    return cb2b(C.al_get_mixer_playing(self.handle))
 }
 
 // Returns wheter or not the mixer is attached
 func (self *Mixer) Attached() bool {
-	return cb2b(C.al_get_mixer_attached(self.handle))
+    return cb2b(C.al_get_mixer_attached(self.handle))
 }
 
 // Sets the frequency of the mixer.
 func (self *Mixer) SetFrequency(val uint) bool {
-	return cb2b(C.al_set_mixer_frequency(self.handle, C.uint(val)))
+    return cb2b(C.al_set_mixer_frequency(self.handle, C.uint(val)))
 }
 
 // Sets the quality of the mixer.
 func (self *Mixer) SetQuality(val MixerQuality) bool {
-	return cb2b(C.al_set_mixer_quality(self.handle, val.toC()))
+    return cb2b(C.al_set_mixer_quality(self.handle, val.toC()))
 }
 
 // Sets the gain of the mixer.
 func (self *Mixer) SetGain(val float32) bool {
-	return cb2b(C.al_set_mixer_gain(self.handle, C.float(val)))
+    return cb2b(C.al_set_mixer_gain(self.handle, C.float(val)))
 }
 
 // Sets the play status of the mixer.
 func (self *Mixer) SetPlaying(val bool) bool {
-	return cb2b(C.al_set_mixer_playing(self.handle, b2cb(val)))
+    return cb2b(C.al_set_mixer_playing(self.handle, b2cb(val)))
 }
 
 // Detaches the mixer from it's player
 func (self *Mixer) Detach() bool {
-	return cb2b(C.al_detach_mixer(self.handle))
+    return cb2b(C.al_detach_mixer(self.handle))
 }
 
 // Converts a voice to it's underlying C pointer
 func (self *Voice) toC() *C.ALLEGRO_VOICE {
-	return (*C.ALLEGRO_VOICE)(self.handle)
+    return (*C.ALLEGRO_VOICE)(self.handle)
 }
 
 // Destroys the voice.
 func (self *Voice) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_voice(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_voice(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C voice into a go mixer
 func wrapVoiceRaw(data *C.ALLEGRO_VOICE) *Voice {
-	if data == nil {
-		return nil
-	}
-	return &Voice{data}
+    if data == nil {
+        return nil
+    }
+    return &Voice{data}
 }
 
 // Sets up a finalizer for this Voice Wraps a C voice that calls Destroy()
 func (self *Voice) SetDestroyFinalizer() *Voice {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Voice) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Voice) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C voice into a go mixer and sets up a finalizer that calls Destroy()
 func wrapVoice(data *C.ALLEGRO_VOICE) *Voice {
-	self := wrapVoiceRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapVoiceRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 // creates a C voice 
 func createVoice(freq uint, depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_VOICE {
-	return C.al_create_voice(C.uint(freq), depth.toC(), chan_conf.toC())
+    return C.al_create_voice(C.uint(freq), depth.toC(), chan_conf.toC())
 }
 
 // Creates a voice
 func CreateVoiceRaw(freq uint, depth AudioDepth, chan_conf ChannelConf) *Voice {
-	return wrapVoiceRaw(createVoice(freq, depth, chan_conf))
+    return wrapVoiceRaw(createVoice(freq, depth, chan_conf))
 }
 
 // Creates a voice and setsup a finalizer on it that calls Destroy
 func CreateVoice(freq uint, depth AudioDepth, chan_conf ChannelConf) *Voice {
-	return wrapVoice(createVoice(freq, depth, chan_conf))
+    return wrapVoice(createVoice(freq, depth, chan_conf))
 }
 
 // Attaches a sample instance to the given voice. 
 func (voice *Voice) AttachSampleInstance(stream *SampleInstance) bool {
-	return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
+    return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
 }
 
 // Attaches the sample instance to the given voice. 
 func (stream *SampleInstance) AttachToVoice(voice *Voice) bool {
-	return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
+    return cb2b(C.al_attach_sample_instance_to_voice(stream.handle, voice.handle))
 }
 
 // Attaches an audio stream  to the given voice. 
 func (voice *Voice) AttachAudioStream(stream *AudioStream) bool {
-	return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
+    return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
 }
 
 // Attaches the audio stream to the given voice. 
 func (stream *AudioStream) AttachToVoice(voice *Voice) bool {
-	return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
+    return cb2b(C.al_attach_audio_stream_to_voice(stream.handle, voice.handle))
 }
 
 // Attaches the given mixer to the voice.
 func (mixer *Mixer) AttachToVoice(voice *Voice) bool {
-	return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
+    return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
 }
 
 // Attaches the given voice to the mixer.
 func (voice *Voice) AttachMixer(mixer *Mixer) bool {
-	return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
+    return cb2b(C.al_attach_mixer_to_voice(mixer.handle, voice.handle))
 }
 
 // Detaches the voice.
 func (voice *Voice) Detach() {
-	C.al_detach_voice(voice.handle)
+    C.al_detach_voice(voice.handle)
 }
 
 // Returns the frequency of the voice
 func (self *Voice) Frequency() uint {
-	return uint(C.al_get_voice_frequency(self.handle))
+    return uint(C.al_get_voice_frequency(self.handle))
 }
 
 // Returns the position of the voice
 func (self *Voice) Position() uint {
-	return uint(C.al_get_voice_position(self.handle))
+    return uint(C.al_get_voice_position(self.handle))
 }
 
 // Returns the depth of the voice
 func (self *Voice) Depth() AudioDepth {
-	return AudioDepth(C.al_get_voice_depth(self.handle))
+    return AudioDepth(C.al_get_voice_depth(self.handle))
 }
 
 // Returns the channel configuration of the voice
 func (self *Voice) Channels() ChannelConf {
-	return ChannelConf(C.al_get_voice_channels(self.handle))
+    return ChannelConf(C.al_get_voice_channels(self.handle))
 }
 
 // Returns wheter or not the voice is playing
 func (self *Voice) Playing() bool {
-	return cb2b(C.al_get_voice_playing(self.handle))
+    return cb2b(C.al_get_voice_playing(self.handle))
 }
 
 // Sets the position of the voice.
 func (self *Voice) SetPosition(val uint) bool {
-	return cb2b(C.al_set_voice_position(self.handle, C.uint(val)))
+    return cb2b(C.al_set_voice_position(self.handle, C.uint(val)))
 }
 
 // Sets the play status of the voice.
 func (self *Voice) SetPlaying(val bool) bool {
-	return cb2b(C.al_set_voice_playing(self.handle, b2cb(val)))
+    return cb2b(C.al_set_voice_playing(self.handle, b2cb(val)))
 }
 
 // Installs the audio extension
 func InstallAudio() bool {
-	return cb2b(C.al_install_audio())
+    return cb2b(C.al_install_audio())
 }
 
 // Uninstalls the audio extension
 func UninstallAudio() {
-	C.al_uninstall_audio()
+    C.al_uninstall_audio()
 }
 
 // Returns true if the audio extension is installed 
 func IsAudioInstalled() bool {
-	return cb2b(C.al_is_audio_installed())
+    return cb2b(C.al_is_audio_installed())
 }
 
 // Returns the version of the audio extension
 func AudioVersion() uint32 {
-	return uint32(C.al_get_allegro_audio_version())
+    return uint32(C.al_get_allegro_audio_version())
 }
 
 // Gets the amount of available channels in a channel configguration
 func (self ChannelConf) ChannelCount() uint {
-	return uint(C.al_get_channel_count(self.toC()))
+    return uint(C.al_get_channel_count(self.toC()))
 }
 
 // Gets the size of (foe calculating the size of allocating a sample)
 func (self AudioDepth) Size() uint {
-	return uint(C.al_get_audio_depth_size(self.toC()))
+    return uint(C.al_get_audio_depth_size(self.toC()))
 }
 
 // Reserves the given amount of samples and attaches them to the default mixer
 func ReserveSamples(samples int) bool {
-	return cb2b(C.al_reserve_samples(C.int(samples)))
+    return cb2b(C.al_reserve_samples(C.int(samples)))
 }
 
 var defaultMixer *Mixer = nil
 
 // Returns a pointer to the default mixer. Has no dispose finaliser set. 
 func DefaultMixer() *Mixer {
-	return wrapMixerRaw(C.al_get_default_mixer())
+    return wrapMixerRaw(C.al_get_default_mixer())
 }
 
 // Sets the mixer as the default mixer. 
 func (mixer *Mixer) SetDefault() {
-	// this is purely to prevent the GC from collecting this mixer.
-	defaultMixer = mixer
-	C.al_set_default_mixer(mixer.handle)
+    // this is purely to prevent the GC from collecting this mixer.
+    defaultMixer = mixer
+    C.al_set_default_mixer(mixer.handle)
 }
 
 // Restores the default mixer
 func RestoreDefaultMixer() {
-	// GC reclaim is OK now.
-	defaultMixer = nil
-	C.al_restore_default_mixer()
+    // GC reclaim is OK now.
+    defaultMixer = nil
+    C.al_restore_default_mixer()
 }
 
 // Plays a sample on the default mixer if enough samples have been reserved.
 // id returns a sample if that can be used to track the sample.
 func (self *Sample) Play(gain, pan, speed float32, loop PlayMode) (ok bool, id SampleId) {
-	ok = cb2b(C.al_play_sample(self.handle, C.float(gain), C.float(pan), C.float(speed), loop.toC(), (&id).toC()))
-	return ok, id
+    ok = cb2b(C.al_play_sample(self.handle, C.float(gain), C.float(pan), C.float(speed), loop.toC(), (&id).toC()))
+    return ok, id
 }
 
 // Stops playing a sample that was started with sample.Play()  
 func (self *SampleId) Stop() {
-	C.al_stop_sample(self.toC())
+    C.al_stop_sample(self.toC())
 }
 
 // Stops playing all samples on the default mixer
 func StopSamples() {
-	C.al_stop_samples()
+    C.al_stop_samples()
 }
 
 /*
 Todo: 
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_sample_loader, (const char *ext,
-	ALLEGRO_SAMPLE *(*loader)(const char *filename)));
+    ALLEGRO_SAMPLE *(*loader)(const char *filename)));
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_sample_saver, (const char *ext,
-	bool (*saver)(const char *filename, ALLEGRO_SAMPLE *spl)));
+    bool (*saver)(const char *filename, ALLEGRO_SAMPLE *spl)));
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_audio_stream_loader, (const char *ext,
-	ALLEGRO_AUDIO_STREAM *(*stream_loader)(const char *filename,
-	    size_t buffer_count, unsigned int samples)));
+    ALLEGRO_AUDIO_STREAM *(*stream_loader)(const char *filename,
+        size_t buffer_count, unsigned int samples)));
 
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_sample_loader_f, (const char *ext,
-	ALLEGRO_SAMPLE *(*loader)(ALLEGRO_FILE *fp)));
+    ALLEGRO_SAMPLE *(*loader)(ALLEGRO_FILE *fp)));
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_sample_saver_f, (const char *ext,
-	bool (*saver)(ALLEGRO_FILE *fp, ALLEGRO_SAMPLE *spl)));
+    bool (*saver)(ALLEGRO_FILE *fp, ALLEGRO_SAMPLE *spl)));
 ALLEGRO_KCM_AUDIO_FUNC(bool, al_register_audio_stream_loader_f, (const char *ext,
-	ALLEGRO_AUDIO_STREAM *(*stream_loader)(ALLEGRO_FILE *fp,
-	    size_t buffer_count, unsigned int samples)));
+    ALLEGRO_AUDIO_STREAM *(*stream_loader)(ALLEGRO_FILE *fp,
+        size_t buffer_count, unsigned int samples)));
 */
 
 // Loads a C sample from a filename
 func loadSample(filename string) *C.ALLEGRO_SAMPLE {
-	cstr := cstr(filename)
-	defer cstrFree(cstr)
-	return C.al_load_sample(cstr)
+    cstr := cstr(filename)
+    defer cstrFree(cstr)
+    return C.al_load_sample(cstr)
 }
 
 // Loads a sample from a filename and sets up no finalizer 
 func LoadSampleRaw(filename string) *Sample {
-	return wrapSampleRaw(loadSample(filename))
+    return wrapSampleRaw(loadSample(filename))
 }
 
 // Loads a sample from a filename and sets up a finalizer 
 func LoadSample(filename string) *Sample {
-	return LoadSampleRaw(filename).SetDestroyFinalizer()
+    return LoadSampleRaw(filename).SetDestroyFinalizer()
 }
 
 // Saves a sample to a given filename
 func (self *Sample) Save(filename string) bool {
-	cstr := cstr(filename)
-	defer cstrFree(cstr)
-	return cb2b(C.al_save_sample(cstr, self.handle))
+    cstr := cstr(filename)
+    defer cstrFree(cstr)
+    return cb2b(C.al_save_sample(cstr, self.handle))
 }
 
 // Loads a C audio stream sample from a filename
 func loadAudioStream(filename string, buffer_count, samples uint) *C.ALLEGRO_AUDIO_STREAM {
-	cstr := cstr(filename)
-	defer cstrFree(cstr)
-	return C.al_load_audio_stream(cstr, C.size_t(buffer_count), C.uint(samples))
+    cstr := cstr(filename)
+    defer cstrFree(cstr)
+    return C.al_load_audio_stream(cstr, C.size_t(buffer_count), C.uint(samples))
 }
 
 // Loads a sample from a filename and sets up no finalizer 
 func LoadAudioStreamRaw(filename string, buffer_count, samples uint) *AudioStream {
-	return wrapAudioStreamRaw(loadAudioStream(filename, buffer_count, samples))
+    return wrapAudioStreamRaw(loadAudioStream(filename, buffer_count, samples))
 }
 
 // Loads a sample from a filename and sets up a finalizer 
 func LoadAudioStream(filename string, buffer_count, samples uint) *AudioStream {
-	return LoadAudioStreamRaw(filename, buffer_count, samples).SetDestroyFinalizer()
+    return LoadAudioStreamRaw(filename, buffer_count, samples).SetDestroyFinalizer()
 }
 
 // Allegro's own file for cross platform and physfs reasons.
 type File struct {
-	handle *C.ALLEGRO_FILE
+    handle *C.ALLEGRO_FILE
 }
 
 // Closes the Allegro file
 func (self *File) Close() {
-	if self.handle != nil {
-		C.al_fclose(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_fclose(self.handle)
+    }
+    self.handle = nil
 }
 
 // Wraps an ALLEGRO_FILE into a File
 func wrapFileRaw(file *C.ALLEGRO_FILE) *File {
-	if file == nil {
-		return nil
-	}
-	return &File{file}
+    if file == nil {
+        return nil
+    }
+    return &File{file}
 }
 
 // Opens an Allegro File
 func openFile(filename, mode string) *C.ALLEGRO_FILE {
-	cfilename := cstr(filename)
-	defer cstrFree(cfilename)
-	cmode := cstr(mode)
-	defer cstrFree(cmode)
-	return C.al_fopen(cfilename, cmode)
+    cfilename := cstr(filename)
+    defer cstrFree(cfilename)
+    cmode := cstr(mode)
+    defer cstrFree(cmode)
+    return C.al_fopen(cfilename, cmode)
 }
 
 // Sets up a finalizer for this File that calls Close()
 func (self *File) SetCloseFinalizer() *File {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *File) { me.Close() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *File) { me.Close() })
+    }
+    return self
 }
 
 // Wraps a file and sets up a finalizer that calls Destroy()
 func wrapFile(data *C.ALLEGRO_FILE) *File {
-	self := wrapFileRaw(data)
-	return self.SetCloseFinalizer()
+    self := wrapFileRaw(data)
+    return self.SetCloseFinalizer()
 }
 
 // Opens a file with no finalizer set
 func OpenFileRaw(filename, mode string) *File {
-	self := openFile(filename, mode)
-	return wrapFileRaw(self)
+    self := openFile(filename, mode)
+    return wrapFileRaw(self)
 }
 
 // Opens a file with a Close finalizer set
 func OpenFile(filename, mode string) *File {
-	self := OpenFileRaw(filename, mode)
-	return self.SetCloseFinalizer()
+    self := OpenFileRaw(filename, mode)
+    return self.SetCloseFinalizer()
 }
 
 // Loads a Sample from a File. Filetype is a file extension that identifies the file type 
 // like (.wav, .ogg, etc))
 func (self *File) loadSample(filetype string) *C.ALLEGRO_SAMPLE {
-	cfiletype := cstr(filetype)
-	defer cstrFree(cfiletype)
-	return C.al_load_sample_f(self.handle, cfiletype)
+    cfiletype := cstr(filetype)
+    defer cstrFree(cfiletype)
+    return C.al_load_sample_f(self.handle, cfiletype)
 }
 
 // Saves a Sample to a File. Filetype is a file extension that identifies the file type 
 func (self *File) SaveSample(filetype string, sample *Sample) bool {
-	cfiletype := cstr(filetype)
-	defer cstrFree(cfiletype)
-	return cb2b(C.al_save_sample_f(self.handle, cfiletype, sample.handle))
+    cfiletype := cstr(filetype)
+    defer cstrFree(cfiletype)
+    return cb2b(C.al_save_sample_f(self.handle, cfiletype, sample.handle))
 }
 
 // Loads an ALLEGRO_AUDIO_STREAM from a file. Filetype is a file extension
 // that identifies the file type (.ogg, etc)
 func (self *File) loadAudioStream(filetype string, buffer_count,
-	samples uint) *C.ALLEGRO_AUDIO_STREAM {
-	cfiletype := cstr(filetype)
-	defer cstrFree(cfiletype)
-	return C.al_load_audio_stream_f(self.handle, cfiletype,
-		C.size_t(buffer_count), C.uint(samples))
+    samples uint) *C.ALLEGRO_AUDIO_STREAM {
+    cfiletype := cstr(filetype)
+    defer cstrFree(cfiletype)
+    return C.al_load_audio_stream_f(self.handle, cfiletype,
+        C.size_t(buffer_count), C.uint(samples))
 }
 
 // Loads a Sample from a File. Filetype is a file extension that identifies the file type 
 // like (.wav, .ogg, etc))
 func (self *File) LoadSampleRaw(filetype string) *Sample {
-	return wrapSampleRaw(loadSample(filetype))
+    return wrapSampleRaw(loadSample(filetype))
 }
 
 // Loads a Sample from a File. Filetype is a file extension that identifies the file type 
 // like (.wav, .ogg, etc)). Sets up a finalizer. 
 func (self *File) LoadSample(filetype string) *Sample {
-	return LoadSampleRaw(filetype).SetDestroyFinalizer()
+    return LoadSampleRaw(filetype).SetDestroyFinalizer()
 }
 
 // Loads an AudioStream from a file. Filetype is a file extension
 // that identifies the file type (.ogg, etc)
 func (self *File) LoadAudioStreamRaw(filetype string, buffer_count,
-	samples uint) *AudioStream {
-	return wrapAudioStreamRaw(loadAudioStream(filetype, buffer_count, samples))
+    samples uint) *AudioStream {
+    return wrapAudioStreamRaw(loadAudioStream(filetype, buffer_count, samples))
 }
 
 // Loads an AudioStream from a file. Filetype is a file extension
 // that identifies the file type (.ogg, etc). Sets up a finalizer.
 func (self *File) LoadAudioStream(filetype string, buffer_count,
-	samples uint) *AudioStream {
-	return LoadAudioStreamRaw(filetype, buffer_count, samples).SetDestroyFinalizer()
-}
-
-// Returns the event source of the audio subsystem 
-func AudioEventSource() *EventSource {
-	return wrapEventSourceRaw(C.al_get_audio_event_source())
+    samples uint) *AudioStream {
+    return LoadAudioStreamRaw(filetype, buffer_count, samples).SetDestroyFinalizer()
 }
 
 // Converts a recorder to it's underlying C pointer
 func (self *AudioRecorder) toC() *C.ALLEGRO_AUDIO_RECORDER {
-	return (*C.ALLEGRO_AUDIO_RECORDER)(self.handle)
+    return (*C.ALLEGRO_AUDIO_RECORDER)(self.handle)
 }
 
 // Destroys the recorder.
 func (self *AudioRecorder) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_audio_recorder(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_audio_recorder(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C recorder into a go mixer
 func wrapAudioRecorderRaw(data *C.ALLEGRO_AUDIO_RECORDER) *AudioRecorder {
-	if data == nil {
-		return nil
-	}
-	return &AudioRecorder{data}
+    if data == nil {
+        return nil
+    }
+    return &AudioRecorder{data}
 }
 
 // Sets up a finalizer for this AudioRecorder Wraps a C recorder that calls Destroy()
 func (self *AudioRecorder) SetDestroyFinalizer() *AudioRecorder {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *AudioRecorder) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *AudioRecorder) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C recorder into a go recorder and sets up a finalizer that calls Destroy()
 func wrapAudioRecorder(data *C.ALLEGRO_AUDIO_RECORDER) *AudioRecorder {
-	self := wrapAudioRecorderRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapAudioRecorderRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 // Creates a C recorder 
 func createAudioRecorder(fragment_count, samples, freq uint,
-	depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_AUDIO_RECORDER {
-	return C.al_create_audio_recorder(C.size_t(fragment_count), C.uint(samples),
-		C.uint(freq), depth.toC(), chan_conf.toC())
+    depth AudioDepth, chan_conf ChannelConf) *C.ALLEGRO_AUDIO_RECORDER {
+    return C.al_create_audio_recorder(C.size_t(fragment_count), C.uint(samples),
+        C.uint(freq), depth.toC(), chan_conf.toC())
 }
 
 // Creates an Audio Recorder and sets no finalizer
 func CreateAudioRecorderRaw(fragment_count, samples, freq uint,
-	depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
-	return wrapAudioRecorderRaw(createAudioRecorder(fragment_count, samples, freq, depth, chan_conf))
+    depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
+    return wrapAudioRecorderRaw(createAudioRecorder(fragment_count, samples, freq, depth, chan_conf))
 }
 
 // Creates an Audio Recorder and sets a finalizer
 func CreateAudioRecorder(fragment_count, samples, freq uint,
-	depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
-	return CreateAudioRecorderRaw(fragment_count, samples,
-		freq, depth, chan_conf).SetDestroyFinalizer()
+    depth AudioDepth, chan_conf ChannelConf) *AudioRecorder {
+    return CreateAudioRecorderRaw(fragment_count, samples,
+        freq, depth, chan_conf).SetDestroyFinalizer()
 }
 
 // Starts recording on the audio recorder.
 func (self *AudioRecorder) Start() bool {
-	return cb2b(C.al_start_audio_recorder(self.handle))
+    return cb2b(C.al_start_audio_recorder(self.handle))
 }
 
 // Stops recording on the audio recorder.
 func (self *AudioRecorder) Stop() {
-	C.al_stop_audio_recorder(self.handle)
+    C.al_stop_audio_recorder(self.handle)
 }
 
 // Gets the audio recorder's event source
 func (self *AudioRecorder) EventSource() *EventSource {
-	return wrapEventSourceRaw(C.al_get_audio_recorder_event_source(self.handle))
+    return wrapEventSourceRaw(C.al_get_audio_recorder_event_source(self.handle))
 }
 
 // Converts to AudioRecorderEvent
 func wrapAudioRecorderEvent(event *C.ALLEGRO_AUDIO_RECORDER_EVENT) *AudioRecorderEvent {
-	return (*AudioRecorderEvent)(event)
+    return (*AudioRecorderEvent)(event)
 }
 
 // Converts an event into an allegro recorder event 
 func (self *Event) AudioRecorderEvent() *AudioRecorderEvent {
-	return wrapAudioRecorderEvent(C.al_get_audio_recorder_event(self.toC()))
+    return wrapAudioRecorderEvent(C.al_get_audio_recorder_event(self.toC()))
 }
 
 // Gets an unsafe pointer to the recorder event's buffer 
 func (self *AudioRecorderEvent) BufferPointer() unsafe.Pointer {
-	return self.buffer
+    return self.buffer
 }
 
 // Gets the amount of samples for this recorder event
 func (self *AudioRecorderEvent) Samples() uint {
-	return uint(self.samples)
+    return uint(self.samples)
 }
 
 // Gets the recorder's buffer copied into a byte slice
 func (self *AudioRecorderEvent) Buffer() []byte {
-	return C.GoBytes(self.buffer, C.int(self.samples))
+    return C.GoBytes(self.buffer, C.int(self.samples))
 }

+ 60 - 79
al/bitmap.go

@@ -11,214 +11,195 @@ import "C"
 
 import "runtime"
 
-import "unsafe"
-
 // Type that wraps a Bitmap
 type Bitmap struct {
-	handle *C.ALLEGRO_BITMAP
+    handle *C.ALLEGRO_BITMAP
+}
+
+// returns low level handle for the bitmap
+func (bmp *Bitmap) toC() * C.ALLEGRO_BITMAP {
+    return bmp.handle
 }
 
+
 // Destroys a bitmap. Use this only when really needed!
 func (self *Bitmap) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_bitmap(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_bitmap(self.handle)
+    }
+    self.handle = nil
 }
 
 // Wraps a C Allegro bitmap in a Bitmap. Sets no finalizer.
 func wrapBitmapRaw(handle *C.ALLEGRO_BITMAP) *Bitmap {
-	if handle == nil {
-		return nil
-	}
-	return &Bitmap{handle}
+    if handle == nil {
+        return nil
+    }
+    return &Bitmap{handle}
 }
 
 // Wraps a C Allegro Bitmap in a Bitmap. Sets a finalizer that calls Destroy.
 func wrapBitmap(handle *C.ALLEGRO_BITMAP) *Bitmap {
-	self := wrapBitmapRaw(handle)
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Bitmap) { me.Destroy() })
-	}
-	return self
+    self := wrapBitmapRaw(handle)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Bitmap) { me.Destroy() })
+    }
+    return self
 }
 
 const (
-	MEMORY_BITMAP       = C.ALLEGRO_MEMORY_BITMAP
-	FORCE_LOCKING       = C.ALLEGRO_FORCE_LOCKING
-	NO_PRESERVE_TEXTURE = C.ALLEGRO_NO_PRESERVE_TEXTURE
-	MIN_LINEAR          = C.ALLEGRO_MIN_LINEAR
-	MAG_LINEAR          = C.ALLEGRO_MAG_LINEAR
-	MIPMAP              = C.ALLEGRO_MIPMAP
-	VIDEO_BITMAP        = C.ALLEGRO_VIDEO_BITMAP
-	CONVERT_BITMAP      = C.ALLEGRO_CONVERT_BITMAP
+    MEMORY_BITMAP       = C.ALLEGRO_MEMORY_BITMAP
+    FORCE_LOCKING       = C.ALLEGRO_FORCE_LOCKING
+    NO_PRESERVE_TEXTURE = C.ALLEGRO_NO_PRESERVE_TEXTURE
+    MIN_LINEAR          = C.ALLEGRO_MIN_LINEAR
+    MAG_LINEAR          = C.ALLEGRO_MAG_LINEAR
+    MIPMAP              = C.ALLEGRO_MIPMAP
+    VIDEO_BITMAP        = C.ALLEGRO_VIDEO_BITMAP
+    CONVERT_BITMAP      = C.ALLEGRO_CONVERT_BITMAP
 )
 
 // Sets the format for new bitmaps that are created using CreateBitmap
 func SetNewBitmapFormat(format int) {
-	C.al_set_new_bitmap_format(C.int(format))
+    C.al_set_new_bitmap_format(C.int(format))
 }
 
 // Sets the flags for new bitmaps that are created using CreateBitmap
 func SetNewBitmapFlags(flags int) {
-	C.al_set_new_bitmap_flags(C.int(flags))
+    C.al_set_new_bitmap_flags(C.int(flags))
 }
 
 // Adds a flags to the flags that will be used for new bitmaps that are created 
 // using CreateBitmap
 func AddNewBitmapFlag(flags int) {
-	C.al_add_new_bitmap_flag(C.int(flags))
+    C.al_add_new_bitmap_flag(C.int(flags))
 }
 
 // Gets the format for new bitmaps that are created using CreateBitmap
 func NewBitmapFormat(format int) int {
-	return int(C.al_get_new_bitmap_format())
+    return int(C.al_get_new_bitmap_format())
 }
 
 // Gets the flags for new bitmaps that are created using CreateBitmap
 func NewBitmapFlags(flags int) int {
-	return int(C.al_get_new_bitmap_flags())
+    return int(C.al_get_new_bitmap_flags())
 }
 
 // Gets the width of the bitmap.
 func (self *Bitmap) Width() int {
-	return int(C.al_get_bitmap_width(self.handle))
+    return int(C.al_get_bitmap_width(self.handle))
 }
 
 // Gets the height of the bitmap.
 func (self *Bitmap) Height() int {
-	return int(C.al_get_bitmap_height(self.handle))
+    return int(C.al_get_bitmap_height(self.handle))
 }
 
 // Gets the format of the bitmap.
 func (self *Bitmap) Format() int {
-	return int(C.al_get_bitmap_format(self.handle))
+    return int(C.al_get_bitmap_format(self.handle))
 }
 
 // Gets the flags of the bitmap.
 func (self *Bitmap) Flags() int {
-	return int(C.al_get_bitmap_flags(self.handle))
+    return int(C.al_get_bitmap_flags(self.handle))
 }
 
 // Creates a new RAW bitmap. It will not be automatically destroyed!
 func CreateBitmapRaw(w, h int) *Bitmap {
-	return wrapBitmapRaw(C.al_create_bitmap(C.int(w), C.int(h)))
+    return wrapBitmapRaw(C.al_create_bitmap(C.int(w), C.int(h)))
 }
 
 // Creates a new bitmap. It has a finalizer in place that will let it be automatically 
 // destroyed.
 func CreateBitmap(w, h int) *Bitmap {
-	return wrapBitmap(C.al_create_bitmap(C.int(w), C.int(h)))
+    return wrapBitmap(C.al_create_bitmap(C.int(w), C.int(h)))
 }
 
 // Puts a pixel to the currently active bitmap
 func PutPixel(x, y int, color Color) {
-	C.al_put_pixel(C.int(x), C.int(y), color.toC())
+    C.al_put_pixel(C.int(x), C.int(y), color.toC())
 }
 
 // Blends a pixel to the currently active bitmap
 func PutBlendedPixel(x, y int, color Color) {
-	C.al_put_blended_pixel(C.int(x), C.int(y), color.toC())
+    C.al_put_blended_pixel(C.int(x), C.int(y), color.toC())
 }
 
 // Gets a pixel from the bitmap
 func (self *Bitmap) GetPixel(x, y int) (color Color) {
-	return wrapColor(C.al_get_pixel(self.handle, C.int(x), C.int(y)))
+    return wrapColor(C.al_get_pixel(self.handle, C.int(x), C.int(y)))
 }
 
 // Converts pixels of the mask color to transparent pixels (with an alpha channel) 
 // for the given bitmap. Useful for, say "magic pink" backgrounds.
 func (self *Bitmap) ConvertMaskToAlpha(mask_color Color) {
-	C.al_convert_mask_to_alpha(self.handle, mask_color.toC())
+    C.al_convert_mask_to_alpha(self.handle, mask_color.toC())
 }
 
 // Sets the clipping rectangle for the currently active bitmap. Anything drawn outside
 // this rectangle will be cut off or "clipped".
 func SetClippingRectangle(x, y, w, h int) {
-	C.al_set_clipping_rectangle(C.int(x), C.int(y), C.int(w), C.int(h))
+    C.al_set_clipping_rectangle(C.int(x), C.int(y), C.int(w), C.int(h))
 }
 
 // Resets the clipping rectangle for the currently active bitmap to the full size. 
 func ResetClippingRectangle() {
-	C.al_reset_clipping_rectangle()
+    C.al_reset_clipping_rectangle()
 }
 
 // Gets the clipping rectangle for the currently active bitmap. 
 func ClippingRectangle() (x, y, w, h int) {
-	var cx, cy, cw, ch C.int
-	C.al_get_clipping_rectangle(&cx, &cy, &cw, &ch)
-	return int(cx), int(cy), int(cw), int(ch)
+    var cx, cy, cw, ch C.int
+    C.al_get_clipping_rectangle(&cx, &cy, &cw, &ch)
+    return int(cx), int(cy), int(cw), int(ch)
 }
 
 // Creates a RAW sub bitmap of the given bitmap that must be manually destoyed with 
 // Destroy() 
 func (self *Bitmap) CreateSubBitmapRaw(x, y, w, h int) *Bitmap {
-	return wrapBitmapRaw(C.al_create_sub_bitmap(self.handle,
-		C.int(x), C.int(y), C.int(w), C.int(h)))
+    return wrapBitmapRaw(C.al_create_sub_bitmap(self.handle,
+        C.int(x), C.int(y), C.int(w), C.int(h)))
 }
 
 // Creates a sub bitmap of the given bitmap that will automatically be destoyed
 // through a finalizer. However, you must ensure that this destroy happens before the 
 // parent bitmap is disposed of. You may need to call Destroy manyally anyway. 
 func (self *Bitmap) CreateSubBitmap(x, y, w, h int) *Bitmap {
-	return wrapBitmap(C.al_create_sub_bitmap(self.handle,
-		C.int(x), C.int(y), C.int(w), C.int(h)))
+    return wrapBitmap(C.al_create_sub_bitmap(self.handle,
+        C.int(x), C.int(y), C.int(w), C.int(h)))
 }
 
 // Returns whether or not the bitmap is a sub bitmap 
 func (self *Bitmap) IsSubBitmap() bool {
-	return cb2b(C.al_is_sub_bitmap(self.handle))
+    return cb2b(C.al_is_sub_bitmap(self.handle))
 }
 
 // Returns the parent bitmap of this sub bitmap, or nil if there is no parent. 
 // This is a raw bitmap that has no finaliser set on it since likely 
 /// this function will only be used for inspection.
 func (self *Bitmap) Parent() *Bitmap {
-	return wrapBitmapRaw(C.al_get_parent_bitmap(self.handle))
+    return wrapBitmapRaw(C.al_get_parent_bitmap(self.handle))
 }
 
 // Returns a raw clone of the bitmap, that will not be automatically 
 // destroyed.
 func (self *Bitmap) CloneRaw() *Bitmap {
-	return wrapBitmapRaw(C.al_clone_bitmap(self.handle))
+    return wrapBitmapRaw(C.al_clone_bitmap(self.handle))
 }
 
 // Returns a clone of the bitmap, that will automatically be
 // destroyed.
 func (self *Bitmap) Clone() *Bitmap {
-	return wrapBitmap(C.al_clone_bitmap(self.handle))
+    return wrapBitmap(C.al_clone_bitmap(self.handle))
 }
 
 // Converts the bitmap to the current screen format, to ensure the blitting goes fast
 func (self *Bitmap) Convert() {
-	C.al_convert_bitmap(self.handle)
+    C.al_convert_bitmap(self.handle)
 }
 
-// Converts all known unconverted bitmaps to the current screen format, 
+// Converts all known unconverted memory bitmaps to the current screen format, 
 // to ensure the blitting goes fast. 
-func ConvertBitmaps() {
-	C.al_convert_bitmaps()
-}
-
-/*
-void qsort(void *base, size_t nmemb, size_t size,
-                  int (*compar)(const void *, const void *));
-*/
-
-// Creates a custom bitmap by calling the C wrapper 
-func createCustomBitmap(w int, h int, upload CreateCustomBitmapCallback, data interface{}) *C.ALLEGRO_BITMAP {
-	context := unsafe.Pointer(&createCustomBitmapContext{upload, data})
-	var res *C.ALLEGRO_BITMAP = nil
-	res = C.go_create_custom_bitmap(C.int(w), C.int(h), context)
-	return res
-}
-
-// Creates a custom bitmap, raw, with no automatic Destroy set
-func CreateCustomBitmap(w int, h int, upload CreateCustomBitmapCallback, data interface{}) *Bitmap {
-	return wrapBitmap(createCustomBitmap(w, h, upload, data))
-}
-
-// Creates a custom bitmap, raw, with no automatic Destroy set
-func CreateCustomBitmapRaw(w int, h int, upload CreateCustomBitmapCallback, data interface{}) *Bitmap {
-	return wrapBitmapRaw(createCustomBitmap(w, h, upload, data))
+func ConvertMemoryBitmaps() {
+    C.al_convert_memory_bitmaps()
 }

+ 1 - 10
al/callbacks.c

@@ -5,19 +5,10 @@
 #include "callbacks.h"
 #include "_cgo_export.h"
 
-typedef bool (*al_create_custom_bitmap_upload)(ALLEGRO_BITMAP *bitmap, void *data);
-
-/* Wrapper for al_create_custom_bitmap. */
-ALLEGRO_BITMAP * go_create_custom_bitmap(int w, int h, void * context) {	
-    return al_create_custom_bitmap(w, h, 
-        (al_create_custom_bitmap_upload) go_create_custom_bitmap_callback, context);
-}
-
-
 /* This wraps the C api function that takes a callback, to take go_take_callback_callback
  as the callback */
 int go_take_callback(void * context) {
-	return take_callback((function_pointer)go_take_callback_callback, context);
+    return take_callback((function_pointer)go_take_callback_callback, context);
 }
 
  

+ 151 - 145
al/display.go

@@ -15,101 +15,107 @@ import "runtime"
 
 // Possible bit combinations for the flags parameter of CreateDisplay.
 const (
-	WINDOWED                  = C.ALLEGRO_WINDOWED
-	FULLSCREEN                = C.ALLEGRO_FULLSCREEN
-	OPENGL                    = C.ALLEGRO_OPENGL
-	DIRECT3D_INTERNAL         = C.ALLEGRO_DIRECT3D_INTERNAL
-	RESIZABLE                 = C.ALLEGRO_RESIZABLE
-	FRAMELESS                 = C.ALLEGRO_FRAMELESS
-	NOFRAME                   = C.ALLEGRO_NOFRAME
-	GENERATE_EXPOSE_EVENTS    = C.ALLEGRO_GENERATE_EXPOSE_EVENTS
-	OPENGL_3_0                = C.ALLEGRO_OPENGL_3_0
-	OPENGL_FORWARD_COMPATIBLE = C.ALLEGRO_OPENGL_FORWARD_COMPATIBLE
-	FULLSCREEN_WINDOW         = C.ALLEGRO_FULLSCREEN_WINDOW
-	MINIMIZED                 = C.ALLEGRO_MINIMIZED
+    WINDOWED                  = C.ALLEGRO_WINDOWED
+    FULLSCREEN                = C.ALLEGRO_FULLSCREEN
+    OPENGL                    = C.ALLEGRO_OPENGL
+    DIRECT3D_INTERNAL         = C.ALLEGRO_DIRECT3D_INTERNAL
+    RESIZABLE                 = C.ALLEGRO_RESIZABLE
+    FRAMELESS                 = C.ALLEGRO_FRAMELESS
+    NOFRAME                   = C.ALLEGRO_NOFRAME
+    GENERATE_EXPOSE_EVENTS    = C.ALLEGRO_GENERATE_EXPOSE_EVENTS
+    OPENGL_3_0                = C.ALLEGRO_OPENGL_3_0
+    OPENGL_FORWARD_COMPATIBLE = C.ALLEGRO_OPENGL_FORWARD_COMPATIBLE
+    FULLSCREEN_WINDOW         = C.ALLEGRO_FULLSCREEN_WINDOW
+    MINIMIZED                 = C.ALLEGRO_MINIMIZED
 )
 
 /* Possible parameters for SetDisplayOption. */
 const (
-	RED_SIZE               = C.ALLEGRO_RED_SIZE
-	GREEN_SIZE             = C.ALLEGRO_GREEN_SIZE
-	BLUE_SIZE              = C.ALLEGRO_BLUE_SIZE
-	ALPHA_SIZE             = C.ALLEGRO_ALPHA_SIZE
-	RED_SHIFT              = C.ALLEGRO_RED_SHIFT
-	GREEN_SHIFT            = C.ALLEGRO_GREEN_SHIFT
-	BLUE_SHIFT             = C.ALLEGRO_BLUE_SHIFT
-	ALPHA_SHIFT            = C.ALLEGRO_ALPHA_SHIFT
-	ACC_RED_SIZE           = C.ALLEGRO_ACC_RED_SIZE
-	ACC_GREEN_SIZE         = C.ALLEGRO_ACC_GREEN_SIZE
-	ACC_BLUE_SIZE          = C.ALLEGRO_ACC_BLUE_SIZE
-	ACC_ALPHA_SIZE         = C.ALLEGRO_ACC_ALPHA_SIZE
-	STEREO                 = C.ALLEGRO_STEREO
-	AUX_BUFFERS            = C.ALLEGRO_AUX_BUFFERS
-	COLOR_SIZE             = C.ALLEGRO_COLOR_SIZE
-	DEPTH_SIZE             = C.ALLEGRO_DEPTH_SIZE
-	STENCIL_SIZE           = C.ALLEGRO_STENCIL_SIZE
-	SAMPLE_BUFFERS         = C.ALLEGRO_SAMPLE_BUFFERS
-	SAMPLES                = C.ALLEGRO_SAMPLES
-	RENDER_METHOD          = C.ALLEGRO_RENDER_METHOD
-	FLOAT_COLOR            = C.ALLEGRO_FLOAT_COLOR
-	FLOAT_DEPTH            = C.ALLEGRO_FLOAT_DEPTH
-	SINGLE_BUFFER          = C.ALLEGRO_SINGLE_BUFFER
-	SWAP_METHOD            = C.ALLEGRO_SWAP_METHOD
-	COMPATIBLE_DISPLAY     = C.ALLEGRO_COMPATIBLE_DISPLAY
-	UPDATE_DISPLAY_REGION  = C.ALLEGRO_UPDATE_DISPLAY_REGION
-	VSYNC                  = C.ALLEGRO_VSYNC
-	MAX_BITMAP_SIZE        = C.ALLEGRO_MAX_BITMAP_SIZE
-	SUPPORT_NPOT_BITMAP    = C.ALLEGRO_SUPPORT_NPOT_BITMAP
-	CAN_DRAW_INTO_BITMAP   = C.ALLEGRO_CAN_DRAW_INTO_BITMAP
-	SUPPORT_SEPARATE_ALPHA = C.ALLEGRO_SUPPORT_SEPARATE_ALPHA
-	DISPLAY_OPTIONS_COUNT  = C.ALLEGRO_DISPLAY_OPTIONS_COUNT
+    RED_SIZE               = C.ALLEGRO_RED_SIZE
+    GREEN_SIZE             = C.ALLEGRO_GREEN_SIZE
+    BLUE_SIZE              = C.ALLEGRO_BLUE_SIZE
+    ALPHA_SIZE             = C.ALLEGRO_ALPHA_SIZE
+    RED_SHIFT              = C.ALLEGRO_RED_SHIFT
+    GREEN_SHIFT            = C.ALLEGRO_GREEN_SHIFT
+    BLUE_SHIFT             = C.ALLEGRO_BLUE_SHIFT
+    ALPHA_SHIFT            = C.ALLEGRO_ALPHA_SHIFT
+    ACC_RED_SIZE           = C.ALLEGRO_ACC_RED_SIZE
+    ACC_GREEN_SIZE         = C.ALLEGRO_ACC_GREEN_SIZE
+    ACC_BLUE_SIZE          = C.ALLEGRO_ACC_BLUE_SIZE
+    ACC_ALPHA_SIZE         = C.ALLEGRO_ACC_ALPHA_SIZE
+    STEREO                 = C.ALLEGRO_STEREO
+    AUX_BUFFERS            = C.ALLEGRO_AUX_BUFFERS
+    COLOR_SIZE             = C.ALLEGRO_COLOR_SIZE
+    DEPTH_SIZE             = C.ALLEGRO_DEPTH_SIZE
+    STENCIL_SIZE           = C.ALLEGRO_STENCIL_SIZE
+    SAMPLE_BUFFERS         = C.ALLEGRO_SAMPLE_BUFFERS
+    SAMPLES                = C.ALLEGRO_SAMPLES
+    RENDER_METHOD          = C.ALLEGRO_RENDER_METHOD
+    FLOAT_COLOR            = C.ALLEGRO_FLOAT_COLOR
+    FLOAT_DEPTH            = C.ALLEGRO_FLOAT_DEPTH
+    SINGLE_BUFFER          = C.ALLEGRO_SINGLE_BUFFER
+    SWAP_METHOD            = C.ALLEGRO_SWAP_METHOD
+    COMPATIBLE_DISPLAY     = C.ALLEGRO_COMPATIBLE_DISPLAY
+    UPDATE_DISPLAY_REGION  = C.ALLEGRO_UPDATE_DISPLAY_REGION
+    VSYNC                  = C.ALLEGRO_VSYNC
+    MAX_BITMAP_SIZE        = C.ALLEGRO_MAX_BITMAP_SIZE
+    SUPPORT_NPOT_BITMAP    = C.ALLEGRO_SUPPORT_NPOT_BITMAP
+    CAN_DRAW_INTO_BITMAP   = C.ALLEGRO_CAN_DRAW_INTO_BITMAP
+    SUPPORT_SEPARATE_ALPHA = C.ALLEGRO_SUPPORT_SEPARATE_ALPHA
+    DISPLAY_OPTIONS_COUNT  = C.ALLEGRO_DISPLAY_OPTIONS_COUNT
 )
 
 // Constants that determine if a setting is required or not.
 const (
-	DONTCARE = C.ALLEGRO_DONTCARE
-	REQUIRE  = C.ALLEGRO_REQUIRE
-	SUGGEST  = C.ALLEGRO_SUGGEST
+    DONTCARE = C.ALLEGRO_DONTCARE
+    REQUIRE  = C.ALLEGRO_REQUIRE
+    SUGGEST  = C.ALLEGRO_SUGGEST
 )
 
 // Display orientations
 const (
-	DISPLAY_ORIENTATION_0_DEGREES   = C.ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES
-	DISPLAY_ORIENTATION_90_DEGREES  = C.ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES
-	DISPLAY_ORIENTATION_180_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES
-	DISPLAY_ORIENTATION_270_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES
-	DISPLAY_ORIENTATION_FACE_UP     = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_UP
-	DISPLAY_ORIENTATION_FACE_DOWN   = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN
+    DISPLAY_ORIENTATION_0_DEGREES   = C.ALLEGRO_DISPLAY_ORIENTATION_0_DEGREES
+    DISPLAY_ORIENTATION_90_DEGREES  = C.ALLEGRO_DISPLAY_ORIENTATION_90_DEGREES
+    DISPLAY_ORIENTATION_180_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_180_DEGREES
+    DISPLAY_ORIENTATION_270_DEGREES = C.ALLEGRO_DISPLAY_ORIENTATION_270_DEGREES
+    DISPLAY_ORIENTATION_FACE_UP     = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_UP
+    DISPLAY_ORIENTATION_FACE_DOWN   = C.ALLEGRO_DISPLAY_ORIENTATION_FACE_DOWN
 )
 
 // Type that wraps a Display (a main window)
 type Display struct {
-	handle *C.ALLEGRO_DISPLAY
+    handle *C.ALLEGRO_DISPLAY
 }
 
+// Converts display to C display 
+func (disp *Display) toC() *C.ALLEGRO_DISPLAY {
+    return disp.handle 
+}
+
+
 // Destroys a display. Use this only when really needed!
 func (self *Display) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_display(self.handle)
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_display(self.handle)
+    }
+    self.handle = nil
 }
 
 // Wraps a C Allegro display in a Display. Sets no finalizer.
 func wrapDisplayRaw(handle *C.ALLEGRO_DISPLAY) *Display {
-	if handle == nil {
-		return nil
-	}
-	return &Display{handle}
+    if handle == nil {
+        return nil
+    }
+    return &Display{handle}
 }
 
 // Wraps a C Allegro display in a Display. Sets a finalizer that calls Destroy
 func wrapDisplay(handle *C.ALLEGRO_DISPLAY) *Display {
-	self := wrapDisplayRaw(handle)
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Display) { me.Destroy() })
-	}
-	return self
+    self := wrapDisplayRaw(handle)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Display) { me.Destroy() })
+    }
+    return self
 }
 
 // Display mode info.
@@ -117,27 +123,27 @@ type DisplayMode C.ALLEGRO_DISPLAY_MODE
 
 // Converts display mode to C display mode 
 func (self *DisplayMode) toC() *C.ALLEGRO_DISPLAY_MODE {
-	return (*C.ALLEGRO_DISPLAY_MODE)(self)
+    return (*C.ALLEGRO_DISPLAY_MODE)(self)
 }
 
 // Returns the width of the display mode self.
 func (self *DisplayMode) Width() int {
-	return int(self.width)
+    return int(self.width)
 }
 
 // Returns the height of the display mode self.
 func (self *DisplayMode) Height() int {
-	return int(self.height)
+    return int(self.height)
 }
 
 // Returns the format of the display mode self.
 func (self *DisplayMode) Format() int {
-	return int(self.format)
+    return int(self.format)
 }
 
 // Returns the refresh rate of the display mode self.
 func (self *DisplayMode) RefreshRate() int {
-	return int(self.refresh_rate)
+    return int(self.refresh_rate)
 }
 
 // Monitor info
@@ -145,52 +151,52 @@ type MonitorInfo C.ALLEGRO_MONITOR_INFO
 
 // Returns the X1 of the monitor info self.
 func (self *MonitorInfo) X1() int {
-	return int(self.x1)
+    return int(self.x1)
 }
 
 // Returns the Y1 of the monitor info self.
 func (self *MonitorInfo) Y1() int {
-	return int(self.y1)
+    return int(self.y1)
 }
 
 // Returns the X2 of the monitor info self.
 func (self *MonitorInfo) X2() int {
-	return int(self.x2)
+    return int(self.x2)
 }
 
 // Returns the Y2 of the monitor info self.
 func (self *MonitorInfo) Y2() int {
-	return int(self.y2)
+    return int(self.y2)
 }
 
 const (
-	DEFAULT_DISPLAY_ADAPTER = C.ALLEGRO_DEFAULT_DISPLAY_ADAPTER
+    DEFAULT_DISPLAY_ADAPTER = C.ALLEGRO_DEFAULT_DISPLAY_ADAPTER
 )
 
 // Sets the flags that a display created by CreateDisplay will get after
 // this function was called.
 func SetNewDisplayFlags(flags int) {
-	C.al_set_new_display_flags(C.int(flags))
+    C.al_set_new_display_flags(C.int(flags))
 }
 
 // Creates a new dosplay with the given size. Influenced by SetNewDisplayFlags.
 func CreateDisplay(width, height int) *Display {
-	return wrapDisplay(C.al_create_display(C.int(width), C.int(height)))
+    return wrapDisplay(C.al_create_display(C.int(width), C.int(height)))
 }
 
 // Resizes the display.
 func (self *Display) Resize(width, height int) bool {
-	return bool(C.al_resize_display(self.handle, C.int(width), C.int(height)))
+    return bool(C.al_resize_display(self.handle, C.int(width), C.int(height)))
 }
 
 // Updates the display to the physical scree no any changes become visible
 func FlipDisplay() {
-	C.al_flip_display()
+    C.al_flip_display()
 }
 
 // Same as FlipDisplay, for mere consistency
 func (self *Display) Flip() {
-	C.al_flip_display()
+    C.al_flip_display()
 }
 
 // Color type
@@ -198,263 +204,263 @@ type Color C.ALLEGRO_COLOR
 
 // Convert from
 func wrapColor(color C.ALLEGRO_COLOR) Color {
-	return Color(color)
+    return Color(color)
 }
 
 // Convert to C
 func (self Color) toC() C.ALLEGRO_COLOR {
-	return C.ALLEGRO_COLOR(self)
+    return C.ALLEGRO_COLOR(self)
 }
 
 // Creates a new color 
 func CreateColor(r, g, b, a float32) Color {
-	return Color{C.float(r), C.float(g), C.float(b), C.float(a)}
+    return Color{C.float(r), C.float(g), C.float(b), C.float(a)}
 }
 
 // Returns the R component of the color self.
 func (self Color) R() float32 {
-	return float32(self.r)
+    return float32(self.r)
 }
 
 // Returns the G component of the color self.
 func (self Color) G() float32 {
-	return float32(self.g)
+    return float32(self.g)
 }
 
 // Returns the B component of the color self.
 func (self Color) B() float32 {
-	return float32(self.b)
+    return float32(self.b)
 }
 
 // Returns the A component of the color self.
 func (self Color) A() float32 {
-	return float32(self.a)
+    return float32(self.a)
 }
 
 // Fills the current active display with a color
 func ClearToColor(color Color) {
-	C.al_clear_to_color(color.toC())
+    C.al_clear_to_color(color.toC())
 }
 
 // Draws a pixel on the active display at the given location 
 // with the given color
 func DrawPixel(x, y float32, color Color) {
-	C.al_draw_pixel(C.float(x), C.float(y), C.ALLEGRO_COLOR(color))
+    C.al_draw_pixel(C.float(x), C.float(y), C.ALLEGRO_COLOR(color))
 }
 
 // Sets the refresh rate that the display should have after CreateDisplay().
 func SetNewDisplayRefreshRate(refresh_rate int) {
-	C.al_set_new_display_refresh_rate(C.int(refresh_rate))
+    C.al_set_new_display_refresh_rate(C.int(refresh_rate))
 }
 
 // Gets the refresh rate that the display should have after CreateDisplay().
 func NewDisplayRefreshRate() int {
-	return int(C.al_get_new_display_refresh_rate())
+    return int(C.al_get_new_display_refresh_rate())
 }
 
 // Gets the display flags that the display should have after CreateDisplay().
 func NewDisplayFlags() int {
-	return int(C.al_get_new_display_flags())
+    return int(C.al_get_new_display_flags())
 }
 
 // Gets the width of the display  in pixels
 func (self *Display) Width() int {
-	return int(C.al_get_display_width(self.handle))
+    return int(C.al_get_display_width(self.handle))
 }
 
 // Gets the height of the display in pixels
 func (self *Display) Height() int {
-	return int(C.al_get_display_height(self.handle))
+    return int(C.al_get_display_height(self.handle))
 }
 
 // Gets the refresh rate of the display
 func (self *Display) RefreshRate() int {
-	return int(C.al_get_display_refresh_rate(self.handle))
+    return int(C.al_get_display_refresh_rate(self.handle))
 }
 
 // Gets the display flags of the display
 func (self *Display) DisplayFlags() int {
-	return int(C.al_get_display_flags(self.handle))
+    return int(C.al_get_display_flags(self.handle))
 }
 
 // Sets a dispay flag on the display
 func (self *Display) SetDisplayFlag(flag int, onoff bool) bool {
-	return cb2b(C.al_set_display_flag(self.handle, C.int(flag), b2cb(onoff)))
+    return cb2b(C.al_set_display_flag(self.handle, C.int(flag), b2cb(onoff)))
 }
 
 // Returns the current display 
 func CurrentDisplay() *Display {
-	return wrapDisplayRaw(C.al_get_current_display())
+    return wrapDisplayRaw(C.al_get_current_display())
 }
 
 // Sets the target C bitmap of allegro drawing 
 func setTargetCBitmap(bmp *C.ALLEGRO_BITMAP) {
-	C.al_set_target_bitmap(bmp)
+    C.al_set_target_bitmap(bmp)
 }
 
 // Sets the target bitmap of the allegro drawing
 func SetTargetBitmap(bmp Bitmap) {
-	setTargetCBitmap(bmp.handle)
+    setTargetCBitmap(bmp.handle)
 }
 
 // Sets the target C backbuffer of allegro drawing 
 func setTargetCBackbuffer(display *C.ALLEGRO_DISPLAY) {
-	C.al_set_target_backbuffer(display)
+    C.al_set_target_backbuffer(display)
 }
 
 // Sets the target backbuffer of allegro drawing 
 func SetTargetBackbuffer(display *Display) {
-	setTargetCBackbuffer(display.handle)
+    setTargetCBackbuffer(display.handle)
 }
 
 // Gets the backbuffer bitmap of the display 
 func (self *Display) Backbuffer() *Bitmap {
-	return wrapBitmapRaw(C.al_get_backbuffer(self.handle))
+    return wrapBitmapRaw(C.al_get_backbuffer(self.handle))
 }
 
 // Gets the target bitmap of allegro drawing
 func TargetBitmap() *Bitmap {
-	return wrapBitmapRaw(C.al_get_target_bitmap())
+    return wrapBitmapRaw(C.al_get_target_bitmap())
 }
 
 // Must be called to aknowledge a RESIZE event
 func (self *Display) AcknowledgeResize() bool {
-	return cb2b(C.al_acknowledge_resize(self.handle))
+    return cb2b(C.al_acknowledge_resize(self.handle))
 }
 
 // Updates a region of the display (not the whole display like flip does)
 func UpdateDisplayRegion(x, y, width, height int) {
-	C.al_update_display_region(C.int(x), C.int(y), C.int(width), C.int(height))
+    C.al_update_display_region(C.int(x), C.int(y), C.int(width), C.int(height))
 }
 
 // Returns true of the bitmap is compatible with the currebt display, false if not. 
 func (bitmap *Bitmap) IsCompatibleBitmap() bool {
-	return cb2b(C.al_is_compatible_bitmap(bitmap.handle))
+    return cb2b(C.al_is_compatible_bitmap(bitmap.handle))
 }
 
 // Returns the number of display modes available to Allegro
 func NumDisplayModes() int {
-	return int(C.al_get_num_display_modes())
+    return int(C.al_get_num_display_modes())
 }
 
 // Returns the index'th display mode. Pass in a DisplayMode struct to store the display
 // mode info in. 
 func (self *DisplayMode) Get(index int) *DisplayMode {
-	return (*DisplayMode)(C.al_get_display_mode(C.int(index), self.toC()))
+    return (*DisplayMode)(C.al_get_display_mode(C.int(index), self.toC()))
 }
 
 // Gets display mode info for the index'th display mode
 func GetDisplayMode(index int) *DisplayMode {
-	var mode DisplayMode
-	if (&mode).Get(index) != nil {
-		return &mode
-	}
-	return nil
+    var mode DisplayMode
+    if (&mode).Get(index) != nil {
+        return &mode
+    }
+    return nil
 }
 
 // Waits for the vertical retrace of the monitor to lessen tearing.
 func WaitForVsync() {
-	C.al_wait_for_vsync()
+    C.al_wait_for_vsync()
 }
 
 // Gets the event source of the display to registeron an event queue 
 // with RegisterEventSource.
 func (self *Display) GetEventSource() *EventSource {
-	return (*EventSource)(C.al_get_display_event_source(self.handle))
+    return (*EventSource)(C.al_get_display_event_source(self.handle))
 }
 
 // Sets the display icon the window manager should use for the display window
 func (self *Display) SetDisplayIcon(bitmap *Bitmap) {
-	C.al_set_display_icon(self.handle, bitmap.handle)
+    C.al_set_display_icon(self.handle, bitmap.handle)
 }
 
 // Gets the number of available video adapters (I.E. grapic cards)
 func NumVideoAdapters() int {
-	return int(C.al_get_num_video_adapters())
+    return int(C.al_get_num_video_adapters())
 }
 
 // Converts a monitor info pointer to a C  * ALLEGRO_MONITOR_INFO
 func (self *MonitorInfo) toC() *C.ALLEGRO_MONITOR_INFO {
-	return (*C.ALLEGRO_MONITOR_INFO)(self)
+    return (*C.ALLEGRO_MONITOR_INFO)(self)
 }
 
 // Gets the monitor info for the index'th video adapter
 func (self *MonitorInfo) Get(index int) bool {
-	return cb2b(C.al_get_monitor_info(C.int(index), self.toC()))
+    return cb2b(C.al_get_monitor_info(C.int(index), self.toC()))
 }
 
 // Gets the monitor info for the index'th video adapter
 func GetMonitorInfo(index int) *MonitorInfo {
-	var info MonitorInfo
-	if (&info).Get(index) {
-		return &info
-	}
-	return nil
+    var info MonitorInfo
+    if (&info).Get(index) {
+        return &info
+    }
+    return nil
 }
 
 // Returns the number of the display adapter where new dsplays will be created
 func NewDisplayAdapter() int {
-	return int(C.al_get_new_display_adapter())
+    return int(C.al_get_new_display_adapter())
 }
 
 // Sets the number of the display adapter where new dsplays will be created
 func SetNewDisplayAdapter(adapter int) {
-	C.al_set_new_display_adapter(C.int(adapter))
+    C.al_set_new_display_adapter(C.int(adapter))
 }
 
 // Returns the position where new windowed displays will be created
 func NewWindowPosition() (x, y int) {
-	var cx, cy C.int
-	C.al_get_new_window_position(&cx, &cy)
-	return int(cx), int(cy)
+    var cx, cy C.int
+    C.al_get_new_window_position(&cx, &cy)
+    return int(cx), int(cy)
 }
 
 // Sets the position where new windowed displays will be created
 func SetNewWindowPosition(x, y int) {
-	C.al_set_new_window_position(C.int(x), C.int(y))
+    C.al_set_new_window_position(C.int(x), C.int(y))
 }
 
 // Returns the current position of the windowed display
 func (self *Display) WindowPosition() (x, y int) {
-	var cx, cy C.int
-	C.al_get_window_position(self.handle, &cx, &cy)
-	return int(cx), int(cy)
+    var cx, cy C.int
+    C.al_get_window_position(self.handle, &cx, &cy)
+    return int(cx), int(cy)
 }
 
 // Sets the position where new windowed displays will be created
 func (self *Display) SetWindowPosition(x, y int) {
-	C.al_set_window_position(self.handle, C.int(x), C.int(y))
+    C.al_set_window_position(self.handle, C.int(x), C.int(y))
 }
 
 // Sets the title of the windowed display
 func (self *Display) SetTitle(str string) {
-	cstr := cstr(str)
-	defer cstrFree(cstr)
-	C.al_set_window_title(self.handle, cstr)
+    cstr := cstr(str)
+    defer cstrFree(cstr)
+    C.al_set_window_title(self.handle, cstr)
 }
 
 // Sets a display option to be used when a new display is created
 func SetNewDisplayOption(option, value, importance int) {
-	C.al_set_new_display_option(C.int(option), C.int(value), C.int(importance))
+    C.al_set_new_display_option(C.int(option), C.int(value), C.int(importance))
 }
 
 // Resets all display oprions for new displays to their default values.
 func ResetNewDisplayOptions() {
-	C.al_reset_new_display_options()
+    C.al_reset_new_display_options()
 }
 
 // Gets the display option of this display
 func (self *Display) DisplayOption(option int) int {
-	return int(C.al_get_display_option(self.handle, C.int(option)))
+    return int(C.al_get_display_option(self.handle, C.int(option)))
 }
 
 // Allows to speed up drawing by holding the display . Only bitmap functions and font 
 // drawing, as well as tranformations shouldbe done until the hold is released
 func HoldBitmapDrawing(hold bool) {
-	C.al_hold_bitmap_drawing(b2cb(hold))
+    C.al_hold_bitmap_drawing(b2cb(hold))
 }
 
 // Returns whether or not the bitmap drawing was held
 func IsBitmapDrawingHeld() bool {
-	return cb2b(C.al_is_bitmap_drawing_held())
+    return cb2b(C.al_is_bitmap_drawing_held())
 }

+ 146 - 106
al/font.go

@@ -13,52 +13,53 @@ package al
 import "C"
 import "runtime"
 import "unsafe"
+import "fmt"
 
 type Font struct {
-	handle *C.ALLEGRO_FONT
+    handle *C.ALLEGRO_FONT
 }
 
 const (
-	ALIGN_LEFT    = C.ALLEGRO_ALIGN_LEFT
-	ALIGN_CENTRE  = C.ALLEGRO_ALIGN_CENTRE
-	ALIGN_CENTER  = C.ALLEGRO_ALIGN_CENTER
-	ALIGN_RIGHT   = C.ALLEGRO_ALIGN_RIGHT
-	ALIGN_INTEGER = C.ALLEGRO_ALIGN_INTEGER
+    ALIGN_LEFT    = C.ALLEGRO_ALIGN_LEFT
+    ALIGN_CENTRE  = C.ALLEGRO_ALIGN_CENTRE
+    ALIGN_CENTER  = C.ALLEGRO_ALIGN_CENTER
+    ALIGN_RIGHT   = C.ALLEGRO_ALIGN_RIGHT
+    ALIGN_INTEGER = C.ALLEGRO_ALIGN_INTEGER
 )
 
 // Converts a font to it's underlying C pointer
 func (self *Font) toC() *C.ALLEGRO_FONT {
-	return (*C.ALLEGRO_FONT)(self.handle)
+    return (*C.ALLEGRO_FONT)(self.handle)
 }
 
 // Destroys the font.
 func (self *Font) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_font(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_font(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C font into a go font
 func wrapFontRaw(data *C.ALLEGRO_FONT) *Font {
-	if data == nil {
-		return nil
-	}
-	return &Font{data}
+    if data == nil {
+        return nil
+    }
+    return &Font{data}
 }
 
 // Sets up a finalizer for this Font that calls Destroy()
 func (self *Font) SetDestroyFinalizer() *Font {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Font) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Font) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C voice into a go mixer and sets up a finalizer that calls Destroy()
 func wrapFont(data *C.ALLEGRO_FONT) *Font {
-	self := wrapFontRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapFontRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 /* 
@@ -67,226 +68,265 @@ ALLEGRO_FONT_FUNC(bool, al_register_font_loader, (const char *ext, ALLEGRO_FONT
 */
 
 func loadBitmapFont(filename string) *C.ALLEGRO_FONT {
-	cfilename := cstr(filename)
-	defer cstrFree(cfilename)
-	return C.al_load_bitmap_font(cfilename)
+    cfilename := cstr(filename)
+    defer cstrFree(cfilename)
+    return C.al_load_bitmap_font(cfilename)
 }
 
 func loadBitmapFontFlags(filename string, flags int) *C.ALLEGRO_FONT {
-	cfilename := cstr(filename)
-	defer cstrFree(cfilename)
-	return C.al_load_bitmap_font_flags(cfilename, C.int(flags))
+    cfilename := cstr(filename)
+    defer cstrFree(cfilename)
+    return C.al_load_bitmap_font_flags(cfilename, C.int(flags))
 }
 
 func loadFont(filename string, size, flags int) *C.ALLEGRO_FONT {
-	cfilename := cstr(filename)
-	defer cstrFree(cfilename)
-	return C.al_load_font(cfilename, C.int(size), C.int(flags))
+    cfilename := cstr(filename)
+    defer cstrFree(cfilename)
+    return C.al_load_font(cfilename, C.int(size), C.int(flags))
 }
 
 func (self *Bitmap) grabFont(ranges []int) *C.ALLEGRO_FONT {
-	cn := C.int(len(ranges) / 2)
-	cranges := (*C.int)(unsafe.Pointer(&ranges[0]))
-	return C.al_grab_font_from_bitmap(self.handle, cn, cranges)
+    cn := C.int(len(ranges) / 2)
+    cranges := (*C.int)(unsafe.Pointer(&ranges[0]))
+    return C.al_grab_font_from_bitmap(self.handle, cn, cranges)
 }
 
 func createBuiltinFont() *C.ALLEGRO_FONT {
-	return C.al_create_builtin_font()
+    return C.al_create_builtin_font()
 }
 
 // Loads a font from the give bitmap filename
 func LoadBitmapFontRaw(filename string) *Font {
-	return wrapFontRaw(loadBitmapFont(filename))
+    return wrapFontRaw(loadBitmapFont(filename))
 }
 
 // Loads a font from the give bitmap filename
 func LoadBitmapFont(filename string) *Font {
-	return LoadBitmapFontRaw(filename).SetDestroyFinalizer()
+    return LoadBitmapFontRaw(filename).SetDestroyFinalizer()
 }
 
 // Loads a font from the give bitmap filename with the given flags
 func LoadBitmapFontFlagsRaw(filename string, flags int) *Font {
-	return wrapFontRaw(loadBitmapFontFlags(filename, flags))
+    return wrapFontRaw(loadBitmapFontFlags(filename, flags))
 }
 
 // Loads a font from the give bitmap filename with the given flags
 func LoadBitmapFontFlags(filename string, flags int) *Font {
-	return LoadBitmapFontFlagsRaw(filename, flags).SetDestroyFinalizer()
+    return LoadBitmapFontFlagsRaw(filename, flags).SetDestroyFinalizer()
 }
 
 // Loads a font from the give font filename with the given size and flags.
 func LoadFontRaw(filename string, size, flags int) *Font {
-	return wrapFontRaw(loadFont(filename, size, flags))
+    return wrapFontRaw(loadFont(filename, size, flags))
 }
 
 // Loads a font from the give font filename with the given size and flags.
 func LoadFont(filename string, size, flags int) *Font {
-	return LoadFontRaw(filename, size, flags).SetDestroyFinalizer()
+    return LoadFontRaw(filename, size, flags).SetDestroyFinalizer()
 }
 
 // Converts this bitmap into a font
 func (self *Bitmap) GrabFontRaw(ranges []int) *Font {
-	return wrapFontRaw(self.grabFont(ranges))
+    return wrapFontRaw(self.grabFont(ranges))
 }
 
 // Converts this bitmap into a font
 func (self *Bitmap) GrabFont(ranges []int) *Font {
-	return self.GrabFontRaw(ranges).SetDestroyFinalizer()
+    return self.GrabFontRaw(ranges).SetDestroyFinalizer()
 }
 
 // Creates a builtin font. It must be Destroy() when done using it just like any other font. 
 func CreateBuiltinFontRaw() *Font {
-	return wrapFontRaw(createBuiltinFont())
+    return wrapFontRaw(createBuiltinFont())
 }
 
 // Creates a builtin font. Has a finalizer set that will call Destroy().
 func CreateBuiltinFont() *Font {
-	return wrapFont(createBuiltinFont())
+    return wrapFont(createBuiltinFont())
 }
 
 // Ustr basics 
 type Ustr struct {
-	handle *C.ALLEGRO_USTR
+    handle *C.ALLEGRO_USTR
 }
 
 // Converts a USTR to it's underlying C pointer
 func (self *Ustr) toC() *C.ALLEGRO_USTR {
-	return (*C.ALLEGRO_USTR)(self.handle)
+    return (*C.ALLEGRO_USTR)(self.handle)
 }
 
 // Destroys the USTR.
 func (self *Ustr) Destroy() {
-	if self.handle != nil {
-		C.al_ustr_free(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_ustr_free(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C USTR into a go font
 func wrapUstrRaw(data *C.ALLEGRO_USTR) *Ustr {
-	if data == nil {
-		return nil
-	}
-	return &Ustr{data}
+    if data == nil {
+        return nil
+    }
+    return &Ustr{data}
 }
 
 // Sets up a finalizer for this Ustr that calls Destroy()
 func (self *Ustr) SetDestroyFinalizer() *Ustr {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Ustr) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Ustr) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C Ustr into go Ustr  and sets up a finalizer that calls Destroy()
 func wrapUstr(data *C.ALLEGRO_USTR) *Ustr {
-	self := wrapUstrRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapUstrRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 // Draws an allegro UTF8 string
 func (font *Font) DrawUstr(color Color, x, y float32, flags int, ustr *Ustr) {
-	C.al_draw_ustr(font.toC(), color.toC(), C.float(x), C.float(y), C.int(flags), ustr.toC())
+    C.al_draw_ustr(font.toC(), color.toC(), C.float(x), C.float(y), C.int(flags), ustr.toC())
 }
 
 // Draws a C string
 func (font *Font) DrawText(color Color, x, y float32, flags int, text string) {
-	ctext := cstr(text)
-	defer cstrFree(ctext)
-	C.al_draw_text(font.toC(), color.toC(), C.float(x), C.float(y), C.int(flags), ctext)
+    ctext := cstr(text)
+    defer cstrFree(ctext)
+    C.al_draw_text(font.toC(), color.toC(), C.float(x), C.float(y), C.int(flags), ctext)
 }
 
 // Draws an allegro UTF8 string, justified
 func (font *Font) DrawJustifiedUstr(color Color, x1, x2, y, diff float32, flags int, ustr *Ustr) {
-	C.al_draw_justified_ustr(font.toC(), color.toC(), cf(x1), cf(x2), cf(y), cf(diff), ci(flags), ustr.toC())
+    C.al_draw_justified_ustr(font.toC(), color.toC(), cf(x1), cf(x2), cf(y), cf(diff), ci(flags), ustr.toC())
 }
 
 // Draws a C string, justified
 func (font *Font) DrawJustifiedText(color Color, x1, x2, y, diff float32, flags int, text string) {
-	ctext := cstr(text)
-	defer cstrFree(ctext)
-	C.al_draw_justified_text(font.toC(), color.toC(), cf(x1), cf(x2), cf(y), cf(diff), ci(flags), ctext)
+    ctext := cstr(text)
+    defer cstrFree(ctext)
+    C.al_draw_justified_text(font.toC(), color.toC(), cf(x1), cf(x2), cf(y), cf(diff), ci(flags), ctext)
 }
 
-/*
-TODO (or even better, implement in Go)
-ALLEGRO_FONT_PRINTFUNC(void, al_draw_textf, (const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x, float y, int flags, char const *format, ...), 6, 7);
-ALLEGRO_FONT_PRINTFUNC(void, al_draw_justified_textf, (const ALLEGRO_FONT *font, ALLEGRO_COLOR color, float x1, float x2, float y, float diff, int flags, char const *format, ...), 8, 9);
-*/
+// Formats a single line of text
+func (font * Font) DrawTextf(color Color, x, y float32, flags int, 
+                             format string, args ...interface{}) {
+    text := fmt.Sprintf(format, args...)
+    font.DrawText(color, x, y, flags, text)
+}
+
+// Formats justified text.
+func (font * Font) DrawJustifiedTextf(color Color, x1, x2, y, diff float32, flags int, 
+                             format string, args ...interface{}) {
+    text := fmt.Sprintf(format, args...)
+    font.DrawJustifiedText(color, x1, x2, y, diff, flags, text)
+}
 
 // Gets the width of a UTF8 encoded string for this font.
 func (font *Font) UstrWidth(ustr *Ustr) int {
-	return int(C.al_get_ustr_width(font.toC(), ustr.toC()))
+    return int(C.al_get_ustr_width(font.toC(), ustr.toC()))
 }
 
 // Gets the width of a string for this font.
 func (font *Font) TextWidth(text string) int {
-	ctext := cstr(text)
-	defer cstrFree(ctext)
-	return int(C.al_get_text_width(font.toC(), ctext))
+    ctext := cstr(text)
+    defer cstrFree(ctext)
+    return int(C.al_get_text_width(font.toC(), ctext))
 }
 
 // Gets the line height of this font.
 func (font *Font) LineHeight() int {
-	return int(C.al_get_font_line_height(font.toC()))
+    return int(C.al_get_font_line_height(font.toC()))
 }
 
 // Gets the ascent of this font.
 func (font *Font) Ascent() int {
-	return int(C.al_get_font_ascent(font.toC()))
+    return int(C.al_get_font_ascent(font.toC()))
 }
 
 // Gets the descent of this font.
 func (font *Font) Descent() int {
-	return int(C.al_get_font_descent(font.toC()))
+    return int(C.al_get_font_descent(font.toC()))
 }
 
 // Gets the dimension of a UTF-8 text in this font. 
 func (font *Font) UstrDimension(ustr *Ustr) (bbx, bby, bbw, bbh int) {
-	var cbbx, cbby, cbbw, cbbh C.int
-	C.al_get_ustr_dimensions(font.toC(), ustr.toC(), &cbbx, &cbby, &cbbw, &cbbh)
-	return int(cbbx), int(cbby), int(cbbw), int(cbbh)
+    var cbbx, cbby, cbbw, cbbh C.int
+    C.al_get_ustr_dimensions(font.toC(), ustr.toC(), &cbbx, &cbby, &cbbw, &cbbh)
+    return int(cbbx), int(cbby), int(cbbw), int(cbbh)
 }
 
-// Gets the dimension of a textthis font.
+// Gets the dimension of a text in this font.
 func (font *Font) TextDimension(text string) (bbx, bby, bbw, bbh int) {
-	ctext := cstr(text)
-	defer cstrFree(ctext)
-	var cbbx, cbby, cbbw, cbbh C.int
-	C.al_get_text_dimensions(font.toC(), ctext, &cbbx, &cbby, &cbbw, &cbbh)
-	return int(cbbx), int(cbby), int(cbbw), int(cbbh)
+    ctext := cstr(text)
+    defer cstrFree(ctext)
+    var cbbx, cbby, cbbw, cbbh C.int
+    C.al_get_text_dimensions(font.toC(), ctext, &cbbx, &cbby, &cbbw, &cbbh)
+    return int(cbbx), int(cbby), int(cbbw), int(cbbh)
 }
 
 // Initializes the font addon 
 func InitFontAddon() {
-	C.al_init_font_addon()
+    C.al_init_font_addon()
 }
 
 // Close the font addon
 func ShutdownFontAddon() {
-	C.al_init_font_addon()
+    C.al_init_font_addon()
 }
 
 // Gets the allegro font addon version
 func GetAllegroFontVersion() uint32 {
-	return (uint32)(C.al_get_allegro_font_version())
+    return (uint32)(C.al_get_allegro_font_version())
 }
 
-// Gets the range of cvharacters supported bu the font
-// TODO: fix return value.
-/*
-func (font *Font) Ranges() (ranges []byte, count int) {
-	count = int(C.al_get_font_ranges(font.toC(), 0, nil))
-	size := count * 2 * C.sizeof(C.int)
-	arr := malloc(count * 2 * C.sizeof(C.int))
-	defer free(arr)
-	C.al_get_font_ranges(font.toC(), ci(count), arr)
-	ranges := C.GoBytes(arr, ci(size))
-	return ranges, count
+// Gets the range of characters supported by the font
+func (font *Font) Ranges() (ranges []int, count int) {
+    count = int(C.al_get_font_ranges(font.toC(), 0, nil))
+    ranges = make([]int, count * 2)
+    isize := C.sizeof_int
+    cranges := C.malloc(C.size_t(isize * count * 2))
+    defer C.free(cranges)
+    C.al_get_font_ranges(font.toC(), ci(count), (*C.int)(cranges))
+    for i := 0 ; i < count * 2; i++ {
+        ranges[i] = int(*(*C.int)(unsafe.Pointer(uintptr(cranges) + uintptr(i * isize))))
+    }
+    return ranges, count
+}
+
+
+// Draws a C string text over multiple lines
+func (font *Font) DrawMultilineText(color Color, x, y, max_width, line_height float32, 
+                                    flags int, text string) {
+    ctext := cstr(text)
+    defer cstrFree(ctext)
+    C.al_draw_multiline_text(font.toC(), color.toC(), C.float(x), C.float(y), 
+                             C.float(max_width), C.float(line_height), C.int(flags), ctext)
+}
+
+// Formats text over multiple lines
+func (font * Font) DrawMultilineTextf(color Color, x, y, max_width, line_height float32, flags int, 
+                             format string, args ...interface{}) {
+    text := fmt.Sprintf(format, args...)
+    font.DrawMultilineText(color, x, y, max_width, line_height, flags, text)
+}
+
+func (font * Font) SetFallbackFont(fallback * Font) {
+    C.al_set_fallback_font(font.toC(), fallback.toC())
+}
+
+func (font * Font) FallbackFont() (* Font) {
+    return wrapFontRaw(C.al_get_fallback_font(font.toC()))
 }
-*/
 
 /*
-ALLEGRO_FONT_FUNC(int, al_get_font_ranges, (ALLEGRO_FONT *font,
-   int ranges_count, int *ranges));
+The fallback is a hassle, might be better to do this in Go.
+ALLEGRO_FONT_FUNC(void, al_do_multiline_text, (const ALLEGRO_FONT *font,
+   float max_width, const char *text,
+   bool (*cb)(int line_num, const char *line, int size, void *extra),
+   void *extra));
+
 */
+
+

+ 236 - 77
al/mouse.go

@@ -8,82 +8,241 @@ package al
 import "C"
 
 // import "unsafe"
-// import "runtime"
+import "runtime"
+
+
+// Type that wraps a mouse 
+type Mouse struct {
+    handle *C.ALLEGRO_MOUSE
+}
+
+// Wraps a C Allegro mouse in a Mouse. Sets no finalizer.
+func wrapMouseRaw(handle *C.ALLEGRO_MOUSE) *Mouse {
+    if handle == nil {
+        return nil
+    }
+    return &Mouse{handle}
+}
+
+// Destroys a mouse. Use this only when really needed!
+func (self *Mouse) Destroy() {
+    if self.handle != nil {
+        // do nothing
+    }
+    self.handle = nil
+}
+
+
+// Wraps a C Allegro mouse cursor in a MouseCursor. Sets a finalizer that calls Destroy.
+func wrapMouse(handle *C.ALLEGRO_MOUSE) *MouseCursor {
+    self := wrapMouse(handle)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Mouse) { me.Destroy() })
+    }
+    return self
+}
+
+// Type that wraps a mouse cursor
+type MouseCursor struct {
+    handle *C.ALLEGRO_MOUSE_CURSOR
+}
+
+// Returns low level hande for cursor
+func (cursor *MouseCursor) toC() *C.ALLEGRO_MOUSE_CURSOR {
+    return cursor.handle
+}
+
+
+// Destroys a mouse cursor. Use this only when really needed!
+func (self *MouseCursor) Destroy() {
+    if self.handle != nil {
+        C.al_destroy_mouse_cursor(self.handle)
+    }
+    self.handle = nil
+}
+
+// Wraps a C Allegro mouse cursor in a MouseCursor. Sets no finalizer.
+func wrapMouseCursorRaw(handle *C.ALLEGRO_MOUSE_CURSOR) *MouseCursor {
+    if handle == nil {
+        return nil
+    }
+    return &MouseCursor{handle}
+}
+
+// Wraps a C Allegro mouse cursor in a MouseCursor. Sets a finalizer that calls Destroy.
+func wrapMouseCursor(handle *C.ALLEGRO_MOUSE_CURSOR) *MouseCursor {
+    self := wrapMouseCursor(handle)
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *MouseCursor) { me.Destroy() })
+    }
+    return self
+}
+
+// Mouse state type
+type MouseState C.ALLEGRO_MOUSE_STATE
+
+// Convert from C
+func wrapMouseState(state C.ALLEGRO_MOUSE_STATE) MouseState {
+    return MouseState(state)
+}
+
+// Convert to C
+func (state MouseState) toC() C.ALLEGRO_MOUSE_STATE {
+    return C.ALLEGRO_MOUSE_STATE(state)
+}
+
+// Convert to C
+func (state * MouseState) toCPointer() * C.ALLEGRO_MOUSE_STATE {
+    return (* C.ALLEGRO_MOUSE_STATE)(state)
+}
+
+func (state MouseState) X() int {
+    return int(state.x)
+}
+
+func (state MouseState) Y() int {
+    return int(state.y)
+}
+
+func (state MouseState) Z() int {
+    return int(state.z)
+}
+
+func (state MouseState) W() int {
+    return int(state.w)
+}
+
+func (state MouseState) Buttons() int {
+    return int(state.buttons)
+}
+
+
+func (state MouseState) Pressure() float32 {
+    return float32(state.pressure)
+}
+
+func (state MouseState) Display() * Display {
+    return wrapDisplayRaw(state.display)
+}
+
+type SystemMouseCursor int
+
+const (
+    SYSTEM_MOUSE_CURSOR_NONE       = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE)       
+    SYSTEM_MOUSE_CURSOR_DEFAULT    = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT)    
+    SYSTEM_MOUSE_CURSOR_ARROW      = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_ARROW)      
+    SYSTEM_MOUSE_CURSOR_BUSY       = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_BUSY)       
+    SYSTEM_MOUSE_CURSOR_QUESTION   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_QUESTION)   
+    SYSTEM_MOUSE_CURSOR_EDIT       = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT)       
+    SYSTEM_MOUSE_CURSOR_MOVE       = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE)       
+    SYSTEM_MOUSE_CURSOR_RESIZE_N   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N)   
+    SYSTEM_MOUSE_CURSOR_RESIZE_W   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_W)   
+    SYSTEM_MOUSE_CURSOR_RESIZE_S   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_S)   
+    SYSTEM_MOUSE_CURSOR_RESIZE_E   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E)   
+    SYSTEM_MOUSE_CURSOR_RESIZE_NW  = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW)  
+    SYSTEM_MOUSE_CURSOR_RESIZE_SW  = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SW)  
+    SYSTEM_MOUSE_CURSOR_RESIZE_SE  = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SE)  
+    SYSTEM_MOUSE_CURSOR_RESIZE_NE  = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE)  
+    SYSTEM_MOUSE_CURSOR_PROGRESS   = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_PROGRESS)  
+    SYSTEM_MOUSE_CURSOR_PRECISION  = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_PRECISION)  
+    SYSTEM_MOUSE_CURSOR_LINK       = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_LINK)       
+    SYSTEM_MOUSE_CURSOR_ALT_SELECT = SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_ALT_SELECT) 
+    SYSTEM_MOUSE_CURSOR_UNAVAILABLE= SystemMouseCursor(C.ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE)
+    NUM_SYSTEM_MOUSE_CURSORS       = SystemMouseCursor(C.ALLEGRO_NUM_SYSTEM_MOUSE_CURSORS)       
+)
+
+func IsMouseInstalled() bool {
+    return cb2b(C.al_is_mouse_installed())
+}
+
+func InstallMouse() bool {
+    return cb2b(C.al_install_mouse())
+}
+
+func UninstallMouse() {
+    C.al_uninstall_mouse()
+}
+
+func GetMouseNumButtons() uint {
+    return uint(C.al_get_mouse_num_buttons())
+}
+
+func GetMouseNumAxes() uint {
+    return uint(C.al_get_mouse_num_axes())
+}
+
+func (display * Display) SetMouseXY(x , y int) bool {
+    return cb2b(C.al_set_mouse_xy(display.toC(), ci(x) , ci(y)))
+}
+
+func SetMouseZ(z int) bool {
+    return cb2b(C.al_set_mouse_z(ci(z)))
+}
+
+func SetMouseW(w int) bool {
+    return cb2b(C.al_set_mouse_w(ci(w)))
+}
+
+func SetMouseAxis(axis, value int) bool {
+    return cb2b(C.al_set_mouse_axis(ci(axis), ci(value)))
+}
+
+func AlGetMouseState() MouseState {
+    var state C.ALLEGRO_MOUSE_STATE
+    C.al_get_mouse_state(&state)
+    return wrapMouseState(state)
+}
+
+func (state * MouseState) ButtonDown(button int) bool {
+    return cb2b(C.al_mouse_button_down(state.toCPointer(), ci(button)))
+}
+
+func (state * MouseState) Axis(axis int) int {
+    return int(C.al_get_mouse_state_axis(state.toCPointer(), ci(axis)))
+}
+
+func GetMouseEventSource() * EventSource {
+    return wrapEventSourceRaw(C.al_get_mouse_event_source())
+}
+
+func CreateMouseCursor(sprite * Bitmap, xfocus, yfocus int) * MouseCursor {
+    return wrapMouseCursor(C.al_create_mouse_cursor(sprite.toC(), ci(xfocus), ci(yfocus)))
+}
+
+func (display * Display) SetMouseCursor(cursor * MouseCursor) bool {
+    return cb2b(C.al_set_mouse_cursor(display.toC(), cursor.toC()))
+}
+
+func (cursor SystemMouseCursor) toC() C.ALLEGRO_SYSTEM_MOUSE_CURSOR {
+    return C.ALLEGRO_SYSTEM_MOUSE_CURSOR(cursor)
+}
+
+func (display * Display) SetSystemMouseCursor(cursor SystemMouseCursor) bool {
+    return cb2b(C.al_set_system_mouse_cursor(display.toC(), cursor.toC()))
+}
+
+func (display * Display) ShowMouseCursor() bool {
+    return cb2b(C.al_show_mouse_cursor(display.toC()))
+}
+
+func (display * Display) HideMouseCursor() bool {
+    return cb2b(C.al_hide_mouse_cursor(display.toC()))
+}
+
+func GetMouseCursorPosition() (ok bool, x, y int) {
+    var cx, cy C.int
+    ok = cb2b(C.al_get_mouse_cursor_position(&cx, &cy))
+    x = int(cx)
+    y = int(cy)
+    return ok, x, y
+}
+
+func (display * Display) GrabMouse() bool {
+    return cb2b(C.al_grab_mouse(display.toC()))
+}
+
+func UngrabMouse() bool {
+    return cb2b(C.al_ungrab_mouse())
+}
 
-/*
-typedef struct ALLEGRO_MOUSE ALLEGRO_MOUSE;
-
-typedef struct ALLEGRO_MOUSE_STATE ALLEGRO_MOUSE_STATE;
-
-struct ALLEGRO_MOUSE_STATE
-{
-   int x;
-   int y;
-   int z;
-   int w;
-   int more_axes[ALLEGRO_MOUSE_MAX_EXTRA_AXES];
-   int buttons;
-   float pressure;
-   struct ALLEGRO_DISPLAY *display;
-};
-
-
-typedef struct ALLEGRO_MOUSE_CURSOR ALLEGRO_MOUSE_CURSOR;
-
-typedef enum ALLEGRO_SYSTEM_MOUSE_CURSOR
-{
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_NONE        =  0,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_DEFAULT     =  1,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_ARROW       =  2,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_BUSY        =  3,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_QUESTION    =  4,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_EDIT        =  5,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_MOVE        =  6,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_N    =  7,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_W    =  8,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_S    =  9,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_E    = 10,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NW   = 11,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SW   = 12,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_SE   = 13,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_RESIZE_NE   = 14,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_PROGRESS    = 15,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_PRECISION   = 16,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_LINK        = 17,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_ALT_SELECT  = 18,
-   ALLEGRO_SYSTEM_MOUSE_CURSOR_UNAVAILABLE = 19,
-   ALLEGRO_NUM_SYSTEM_MOUSE_CURSORS
-} ALLEGRO_SYSTEM_MOUSE_CURSOR;
-
-
-AL_FUNC(bool,           al_is_mouse_installed,  (void));
-AL_FUNC(bool,           al_install_mouse,       (void));
-AL_FUNC(void,           al_uninstall_mouse,     (void));
-AL_FUNC(unsigned int,   al_get_mouse_num_buttons, (void));
-AL_FUNC(unsigned int,   al_get_mouse_num_axes,  (void));
-AL_FUNC(bool,           al_set_mouse_xy,        (struct ALLEGRO_DISPLAY *display, int x, int y));
-AL_FUNC(bool,           al_set_mouse_z,         (int z));
-AL_FUNC(bool,           al_set_mouse_w,         (int w));
-AL_FUNC(bool,           al_set_mouse_axis,      (int axis, int value));
-AL_FUNC(void,           al_get_mouse_state,     (ALLEGRO_MOUSE_STATE *ret_state));
-AL_FUNC(bool,           al_mouse_button_down,   (const ALLEGRO_MOUSE_STATE *state, int button));
-AL_FUNC(int,            al_get_mouse_state_axis, (const ALLEGRO_MOUSE_STATE *state, int axis));
-
-AL_FUNC(ALLEGRO_EVENT_SOURCE *, al_get_mouse_event_source, (void));
-
-struct ALLEGRO_BITMAP;
-
-AL_FUNC(ALLEGRO_MOUSE_CURSOR *, al_create_mouse_cursor, (
-        struct ALLEGRO_BITMAP *sprite, int xfocus, int yfocus));
-AL_FUNC(void, al_destroy_mouse_cursor, (ALLEGRO_MOUSE_CURSOR *));
-AL_FUNC(bool, al_set_mouse_cursor, (struct ALLEGRO_DISPLAY *display,
-                                    ALLEGRO_MOUSE_CURSOR *cursor));
-AL_FUNC(bool, al_set_system_mouse_cursor, (struct ALLEGRO_DISPLAY *display,
-                                           ALLEGRO_SYSTEM_MOUSE_CURSOR cursor_id));
-AL_FUNC(bool, al_show_mouse_cursor, (struct ALLEGRO_DISPLAY *display));
-AL_FUNC(bool, al_hide_mouse_cursor, (struct ALLEGRO_DISPLAY *display));
-AL_FUNC(bool, al_get_mouse_cursor_position, (int *ret_x, int *ret_y));
-AL_FUNC(bool, al_grab_mouse, (struct ALLEGRO_DISPLAY *display));
-AL_FUNC(bool, al_ungrab_mouse, (void));
 
-*/

+ 91 - 90
al/native_dialog.go

@@ -7,6 +7,7 @@ package al
 #cgo CFLAGS: -I/usr/local/include
 #cgo linux LDFLAGS: -lc_nonshared
 #include <stdlib.h>
+#include <stdint.h>
 #include <allegro5/allegro.h>
 #include <allegro5/allegro_native_dialog.h>
 #include "helpers.h"
@@ -17,198 +18,198 @@ import "unsafe"
 import "runtime"
 
 const (
-	FILECHOOSER_FILE_MUST_EXIST = 1
-	FILECHOOSER_SAVE            = 2
-	FILECHOOSER_FOLDER          = 4
-	FILECHOOSER_PICTURES        = 8
-	FILECHOOSER_SHOW_HIDDEN     = 16
-	FILECHOOSER_MULTIPLE        = 32
-
-	MESSAGEBOX_WARN      = 1 << 0
-	MESSAGEBOX_ERROR     = 1 << 1
-	MESSAGEBOX_OK_CANCEL = 1 << 2
-	MESSAGEBOX_YES_NO    = 1 << 3
-	MESSAGEBOX_QUESTION  = 1 << 4
-
-	TEXTLOG_NO_CLOSE  = 1 << 0
-	TEXTLOG_MONOSPACE = 1 << 1
-
-	EVENT_NATIVE_DIALOG_CLOSE = 600
-	EVENT_MENU_CLICK          = 601
-
-	MENU_ITEM_ENABLED  = 0
-	MENU_ITEM_CHECKBOX = 1
-	MENU_ITEM_CHECKED  = 2
-	MENU_ITEM_DISABLED = 4
+    FILECHOOSER_FILE_MUST_EXIST = 1
+    FILECHOOSER_SAVE            = 2
+    FILECHOOSER_FOLDER          = 4
+    FILECHOOSER_PICTURES        = 8
+    FILECHOOSER_SHOW_HIDDEN     = 16
+    FILECHOOSER_MULTIPLE        = 32
+
+    MESSAGEBOX_WARN      = 1 << 0
+    MESSAGEBOX_ERROR     = 1 << 1
+    MESSAGEBOX_OK_CANCEL = 1 << 2
+    MESSAGEBOX_YES_NO    = 1 << 3
+    MESSAGEBOX_QUESTION  = 1 << 4
+
+    TEXTLOG_NO_CLOSE  = 1 << 0
+    TEXTLOG_MONOSPACE = 1 << 1
+
+    EVENT_NATIVE_DIALOG_CLOSE = 600
+    EVENT_MENU_CLICK          = 601
+
+    MENU_ITEM_ENABLED  = 0
+    MENU_ITEM_CHECKBOX = 1
+    MENU_ITEM_CHECKED  = 2
+    MENU_ITEM_DISABLED = 4
 )
 
 type FileChooser struct {
-	handle *C.ALLEGRO_FILECHOOSER
+    handle *C.ALLEGRO_FILECHOOSER
 }
 
 // Converts a file chooser to it's underlying C pointer
 func (self *FileChooser) toC() *C.ALLEGRO_FILECHOOSER {
-	return (*C.ALLEGRO_FILECHOOSER)(self.handle)
+    return (*C.ALLEGRO_FILECHOOSER)(self.handle)
 }
 
 // Destroys the file chooser.
 func (self *FileChooser) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_native_file_dialog(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_native_file_dialog(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C file chooser into a go file chooser
 func wrapFileChooserRaw(data *C.ALLEGRO_FILECHOOSER) *FileChooser {
-	if data == nil {
-		return nil
-	}
-	return &FileChooser{data}
+    if data == nil {
+        return nil
+    }
+    return &FileChooser{data}
 }
 
 // Sets up a finalizer for this FileChooser that calls Destroy()
 func (self *FileChooser) SetDestroyFinalizer() *FileChooser {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *FileChooser) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *FileChooser) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C voice into a go mixer and sets up a finalizer that calls Destroy()
 func wrapFileChooser(data *C.ALLEGRO_FILECHOOSER) *FileChooser {
-	self := wrapFileChooserRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapFileChooserRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 type TextLog struct {
-	handle *C.ALLEGRO_TEXTLOG
+    handle *C.ALLEGRO_TEXTLOG
 }
 
 // Converts a native_text_log to it's underlying C pointer
 func (self *TextLog) toC() *C.ALLEGRO_TEXTLOG {
-	return (*C.ALLEGRO_TEXTLOG)(self.handle)
+    return (*C.ALLEGRO_TEXTLOG)(self.handle)
 }
 
 // Closes the native_text_log.
 func (self *TextLog) Close() {
-	if self.handle != nil {
-		C.al_close_native_text_log(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_close_native_text_log(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C native_text_log into a go native_text_log
 func wrapTextLogRaw(data *C.ALLEGRO_TEXTLOG) *TextLog {
-	if data == nil {
-		return nil
-	}
-	return &TextLog{data}
+    if data == nil {
+        return nil
+    }
+    return &TextLog{data}
 }
 
 // Sets up a finalizer for this TextLog that calls Destroy()
 func (self *TextLog) SetDestroyFinalizer() *TextLog {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *TextLog) { me.Close() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *TextLog) { me.Close() })
+    }
+    return self
 }
 
 // Wraps a C native_text_log into a go native_text_log and sets up a finalizer that calls Destroy()
 func wrapTextLog(data *C.ALLEGRO_TEXTLOG) *TextLog {
-	self := wrapTextLogRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapTextLogRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 type Menu struct {
-	handle *C.ALLEGRO_MENU
+    handle *C.ALLEGRO_MENU
 }
 
 // Converts a menu to it's underlying C pointer
 func (self *Menu) toC() *C.ALLEGRO_MENU {
-	return (*C.ALLEGRO_MENU)(self.handle)
+    return (*C.ALLEGRO_MENU)(self.handle)
 }
 
 // Destroys the menu.
 func (self *Menu) Destroy() {
-	if self.handle != nil {
-		C.al_destroy_menu(self.toC())
-	}
-	self.handle = nil
+    if self.handle != nil {
+        C.al_destroy_menu(self.toC())
+    }
+    self.handle = nil
 }
 
 // Wraps a C menu into a go menu
 func wrapMenuRaw(data *C.ALLEGRO_MENU) *Menu {
-	if data == nil {
-		return nil
-	}
-	return &Menu{data}
+    if data == nil {
+        return nil
+    }
+    return &Menu{data}
 }
 
 // Sets up a finalizer for this Menu that calls Destroy()
 func (self *Menu) SetDestroyFinalizer() *Menu {
-	if self != nil {
-		runtime.SetFinalizer(self, func(me *Menu) { me.Destroy() })
-	}
-	return self
+    if self != nil {
+        runtime.SetFinalizer(self, func(me *Menu) { me.Destroy() })
+    }
+    return self
 }
 
 // Wraps a C menu into a go menu and sets up a finalizer that calls Destroy()
 func wrapMenu(data *C.ALLEGRO_MENU) *Menu {
-	self := wrapMenuRaw(data)
-	return self.SetDestroyFinalizer()
+    self := wrapMenuRaw(data)
+    return self.SetDestroyFinalizer()
 }
 
 type MenuInfo C.ALLEGRO_MENU_INFO
 
 func makeMenuInfo(text *string, id, flags int, icon *Bitmap) C.ALLEGRO_MENU_INFO {
-	res := C.ALLEGRO_MENU_INFO{}
-	if text == nil {
-		res.caption = nil
-	} else {
-		bytes := []byte(*text)
-		res.caption = (*C.char)(unsafe.Pointer(&bytes[0]))
-	}
-	res.id = ci(id)
-	res.flags = ci(flags)
-	res.icon = icon.handle
-	return res
+    res := C.ALLEGRO_MENU_INFO{}
+    if text == nil {
+        res.caption = nil
+    } else {
+        bytes := []byte(*text)
+        res.caption = (*C.char)(unsafe.Pointer(&bytes[0]))
+    }
+    res.id = cui16(id)
+    res.flags = ci(flags)
+    res.icon = icon.handle
+    return res
 }
 
 /// Formats a menuinfo element for an element of the menu.
 func MakeMenuInfo(text *string, id, flags int, icon *Bitmap) MenuInfo {
-	return (MenuInfo)(makeMenuInfo(text, id, flags, icon))
+    return (MenuInfo)(makeMenuInfo(text, id, flags, icon))
 }
 
 // Returns a menuinfo that is a separator
 func MenuSeparator() MenuInfo {
-	return MakeMenuInfo(nil, -1, 0, nil)
+    return MakeMenuInfo(nil, -1, 0, nil)
 }
 
 // Returns a menuinfo that is the start of the menu
 func StartOfMenu(caption string, id int) MenuInfo {
-	return MakeMenuInfo(&caption, id, 0, nil)
+    return MakeMenuInfo(&caption, id, 0, nil)
 }
 
 // Returns a menuinfo that is the end of the menu
 func EndOfMenu(caption string, id int) MenuInfo {
-	return MakeMenuInfo(nil, 0, 0, nil)
+    return MakeMenuInfo(nil, 0, 0, nil)
 }
 
 // Starts the native dialog addon
 func InitNativeDialogAddon() bool {
-	return cb2b(C.al_init_native_dialog_addon())
+    return cb2b(C.al_init_native_dialog_addon())
 }
 
 // Stops the native dialog addon
 func ShutdownNativeDialogAddon() {
-	C.al_shutdown_native_dialog_addon()
+    C.al_shutdown_native_dialog_addon()
 }
 
 // Creates a native file dialog.
 func CreateNativeFileDialogRaw(path, title, patterns string, mode int) *FileChooser {
-	return nil
-	//return wrapFileChooser()
+    return nil
+    //return wrapFileChooser()
 }
 
 /*