浏览代码

* libogc improved by adding some helper functions
* fixed examples and makefiles

git-svn-id: trunk@17082 -

Legolas 14 年之前
父节点
当前提交
41b69d793c
共有 35 个文件被更改,包括 681 次插入276 次删除
  1. 1 1
      packages/libogcfpc/Makefile.fpc
  2. 47 47
      packages/libogcfpc/examples/devices/Makefile
  3. 1 1
      packages/libogcfpc/examples/devices/Makefile.fpc
  4. 1 1
      packages/libogcfpc/examples/devices/usbgecko/Makefile.fpc
  5. 1 1
      packages/libogcfpc/examples/devices/usbgecko/gdbstub/Makefile
  6. 1 1
      packages/libogcfpc/examples/devices/usbgecko/gdbstub/Makefile.fpc
  7. 17 16
      packages/libogcfpc/examples/graphics/gx/gxSprites/Makefile
  8. 19 18
      packages/libogcfpc/examples/graphics/gx/gxSprites/Makefile.fpc
  9. 1 1
      packages/libogcfpc/examples/graphics/gx/gxSprites/gxsprites.pp
  10. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson1/lesson1.pp
  11. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson2/lesson2.pp
  12. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson3/lesson3.pp
  13. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson4/lesson4.pp
  14. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson5/lesson5.pp
  15. 17 16
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/Makefile
  16. 18 17
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/Makefile.fpc
  17. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/lesson6.pp
  18. 17 16
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/Makefile
  19. 18 17
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/Makefile.fpc
  20. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/lesson7.pp
  21. 17 16
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/Makefile
  22. 18 17
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/Makefile.fpc
  23. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/lesson8.pp
  24. 19 18
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/Makefile
  25. 20 19
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/Makefile.fpc
  26. 1 1
      packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/lesson9.pp
  27. 1 1
      packages/libogcfpc/examples/graphics/gx/triangle/triangle.pp
  28. 1 1
      packages/libogcfpc/fpmake.pp
  29. 17 17
      packages/libogcfpc/src/gccore.inc
  30. 77 8
      packages/libogcfpc/src/ogc/lwp_heap.inc
  31. 97 2
      packages/libogcfpc/src/ogc/lwp_mutex.inc
  32. 49 0
      packages/libogcfpc/src/ogc/lwp_priority.inc
  33. 95 2
      packages/libogcfpc/src/ogc/lwp_threads.inc
  34. 83 0
      packages/libogcfpc/src/ogc/lwp_watchdog.inc
  35. 19 13
      packages/libogcfpc/src/ogc/machine/processor.inc

+ 1 - 1
packages/libogcfpc/Makefile.fpc

@@ -27,7 +27,7 @@ cpu=powerpc
 target=wii
 target=wii
 fpcdir=../..
 fpcdir=../..
 
 
-[require]
+[require] 
 nortl=y
 nortl=y
 
 
 [shared]
 [shared]

+ 47 - 47
packages/libogcfpc/examples/devices/Makefile

@@ -265,7 +265,7 @@ UNITSDIR:=$(wildcard $(FPCDIR)/units/$(OS_TARGET))
 endif
 endif
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 PACKAGESDIR:=$(wildcard $(FPCDIR) $(FPCDIR)/packages $(FPCDIR)/packages/base $(FPCDIR)/packages/extra)
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
-override TARGET_DIRS+=network usbgecko usbkeyboard
+override TARGET_DIRS+=network usbkeyboard usbgecko
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifdef REQUIRE_UNITSDIR
 ifdef REQUIRE_UNITSDIR
@@ -1417,8 +1417,8 @@ fpc_makefile_dirs: fpc_makefile_sub1 fpc_makefile_sub2
 fpc_makefiles: fpc_makefile fpc_makefile_dirs
 fpc_makefiles: fpc_makefile fpc_makefile_dirs
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 TARGET_DIRS_NETWORK=1
 TARGET_DIRS_NETWORK=1
-TARGET_DIRS_USBGECKO=1
 TARGET_DIRS_USBKEYBOARD=1
 TARGET_DIRS_USBKEYBOARD=1
+TARGET_DIRS_USBGECKO=1
 endif
 endif
 ifdef TARGET_DIRS_NETWORK
 ifdef TARGET_DIRS_NETWORK
 network_all:
 network_all:
@@ -1465,51 +1465,6 @@ network:
 	$(MAKE) -C network all
 	$(MAKE) -C network all
 .PHONY: network_all network_debug network_smart network_release network_units network_examples network_shared network_install network_sourceinstall network_exampleinstall network_distinstall network_zipinstall network_zipsourceinstall network_zipexampleinstall network_zipdistinstall network_clean network_distclean network_cleanall network_info network_makefiles network
 .PHONY: network_all network_debug network_smart network_release network_units network_examples network_shared network_install network_sourceinstall network_exampleinstall network_distinstall network_zipinstall network_zipsourceinstall network_zipexampleinstall network_zipdistinstall network_clean network_distclean network_cleanall network_info network_makefiles network
 endif
 endif
-ifdef TARGET_DIRS_USBGECKO
-usbgecko_all:
-	$(MAKE) -C usbgecko all
-usbgecko_debug:
-	$(MAKE) -C usbgecko debug
-usbgecko_smart:
-	$(MAKE) -C usbgecko smart
-usbgecko_release:
-	$(MAKE) -C usbgecko release
-usbgecko_units:
-	$(MAKE) -C usbgecko units
-usbgecko_examples:
-	$(MAKE) -C usbgecko examples
-usbgecko_shared:
-	$(MAKE) -C usbgecko shared
-usbgecko_install:
-	$(MAKE) -C usbgecko install
-usbgecko_sourceinstall:
-	$(MAKE) -C usbgecko sourceinstall
-usbgecko_exampleinstall:
-	$(MAKE) -C usbgecko exampleinstall
-usbgecko_distinstall:
-	$(MAKE) -C usbgecko distinstall
-usbgecko_zipinstall:
-	$(MAKE) -C usbgecko zipinstall
-usbgecko_zipsourceinstall:
-	$(MAKE) -C usbgecko zipsourceinstall
-usbgecko_zipexampleinstall:
-	$(MAKE) -C usbgecko zipexampleinstall
-usbgecko_zipdistinstall:
-	$(MAKE) -C usbgecko zipdistinstall
-usbgecko_clean:
-	$(MAKE) -C usbgecko clean
-usbgecko_distclean:
-	$(MAKE) -C usbgecko distclean
-usbgecko_cleanall:
-	$(MAKE) -C usbgecko cleanall
-usbgecko_info:
-	$(MAKE) -C usbgecko info
-usbgecko_makefiles:
-	$(MAKE) -C usbgecko makefiles
-usbgecko:
-	$(MAKE) -C usbgecko all
-.PHONY: usbgecko_all usbgecko_debug usbgecko_smart usbgecko_release usbgecko_units usbgecko_examples usbgecko_shared usbgecko_install usbgecko_sourceinstall usbgecko_exampleinstall usbgecko_distinstall usbgecko_zipinstall usbgecko_zipsourceinstall usbgecko_zipexampleinstall usbgecko_zipdistinstall usbgecko_clean usbgecko_distclean usbgecko_cleanall usbgecko_info usbgecko_makefiles usbgecko
-endif
 ifdef TARGET_DIRS_USBKEYBOARD
 ifdef TARGET_DIRS_USBKEYBOARD
 usbkeyboard_all:
 usbkeyboard_all:
 	$(MAKE) -C usbkeyboard all
 	$(MAKE) -C usbkeyboard all
@@ -1555,6 +1510,51 @@ usbkeyboard:
 	$(MAKE) -C usbkeyboard all
 	$(MAKE) -C usbkeyboard all
 .PHONY: usbkeyboard_all usbkeyboard_debug usbkeyboard_smart usbkeyboard_release usbkeyboard_units usbkeyboard_examples usbkeyboard_shared usbkeyboard_install usbkeyboard_sourceinstall usbkeyboard_exampleinstall usbkeyboard_distinstall usbkeyboard_zipinstall usbkeyboard_zipsourceinstall usbkeyboard_zipexampleinstall usbkeyboard_zipdistinstall usbkeyboard_clean usbkeyboard_distclean usbkeyboard_cleanall usbkeyboard_info usbkeyboard_makefiles usbkeyboard
 .PHONY: usbkeyboard_all usbkeyboard_debug usbkeyboard_smart usbkeyboard_release usbkeyboard_units usbkeyboard_examples usbkeyboard_shared usbkeyboard_install usbkeyboard_sourceinstall usbkeyboard_exampleinstall usbkeyboard_distinstall usbkeyboard_zipinstall usbkeyboard_zipsourceinstall usbkeyboard_zipexampleinstall usbkeyboard_zipdistinstall usbkeyboard_clean usbkeyboard_distclean usbkeyboard_cleanall usbkeyboard_info usbkeyboard_makefiles usbkeyboard
 endif
 endif
+ifdef TARGET_DIRS_USBGECKO
+usbgecko_all:
+	$(MAKE) -C usbgecko all
+usbgecko_debug:
+	$(MAKE) -C usbgecko debug
+usbgecko_smart:
+	$(MAKE) -C usbgecko smart
+usbgecko_release:
+	$(MAKE) -C usbgecko release
+usbgecko_units:
+	$(MAKE) -C usbgecko units
+usbgecko_examples:
+	$(MAKE) -C usbgecko examples
+usbgecko_shared:
+	$(MAKE) -C usbgecko shared
+usbgecko_install:
+	$(MAKE) -C usbgecko install
+usbgecko_sourceinstall:
+	$(MAKE) -C usbgecko sourceinstall
+usbgecko_exampleinstall:
+	$(MAKE) -C usbgecko exampleinstall
+usbgecko_distinstall:
+	$(MAKE) -C usbgecko distinstall
+usbgecko_zipinstall:
+	$(MAKE) -C usbgecko zipinstall
+usbgecko_zipsourceinstall:
+	$(MAKE) -C usbgecko zipsourceinstall
+usbgecko_zipexampleinstall:
+	$(MAKE) -C usbgecko zipexampleinstall
+usbgecko_zipdistinstall:
+	$(MAKE) -C usbgecko zipdistinstall
+usbgecko_clean:
+	$(MAKE) -C usbgecko clean
+usbgecko_distclean:
+	$(MAKE) -C usbgecko distclean
+usbgecko_cleanall:
+	$(MAKE) -C usbgecko cleanall
+usbgecko_info:
+	$(MAKE) -C usbgecko info
+usbgecko_makefiles:
+	$(MAKE) -C usbgecko makefiles
+usbgecko:
+	$(MAKE) -C usbgecko all
+.PHONY: usbgecko_all usbgecko_debug usbgecko_smart usbgecko_release usbgecko_units usbgecko_examples usbgecko_shared usbgecko_install usbgecko_sourceinstall usbgecko_exampleinstall usbgecko_distinstall usbgecko_zipinstall usbgecko_zipsourceinstall usbgecko_zipexampleinstall usbgecko_zipdistinstall usbgecko_clean usbgecko_distclean usbgecko_cleanall usbgecko_info usbgecko_makefiles usbgecko
+endif
 all: $(addsuffix _all,$(TARGET_DIRS))
 all: $(addsuffix _all,$(TARGET_DIRS))
 debug: $(addsuffix _debug,$(TARGET_DIRS))
 debug: $(addsuffix _debug,$(TARGET_DIRS))
 smart: $(addsuffix _smart,$(TARGET_DIRS))
 smart: $(addsuffix _smart,$(TARGET_DIRS))

+ 1 - 1
packages/libogcfpc/examples/devices/Makefile.fpc

@@ -3,7 +3,7 @@
 #
 #
 
 
 [target]
 [target]
-dirs=network usbkeyboard #usbgecko 
+dirs=network usbkeyboard usbgecko 
 
 
 [require]
 [require]
 packages=libogcfpc
 packages=libogcfpc

+ 1 - 1
packages/libogcfpc/examples/devices/usbgecko/Makefile.fpc

@@ -3,7 +3,7 @@
 #
 #
 
 
 [target]
 [target]
-dirs=#gdbstub
+dirs=gdbstub
 
 
 [require]
 [require]
 packages=libogcfpc
 packages=libogcfpc

+ 1 - 1
packages/libogcfpc/examples/devices/usbgecko/gdbstub/Makefile

@@ -283,7 +283,7 @@ override CLEAN_FILES+=*.elf *.o *.s *.h *.bin *.map $(BUILD)/* $(INC)/*
 endif
 endif
 override INSTALL_FPCPACKAGE=y
 override INSTALL_FPCPACKAGE=y
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
-override COMPILER_OPTIONS+=-g -Xm
+override COMPILER_OPTIONS+=-g -Xm  -k--gc-sections
 endif
 endif
 ifdef REQUIRE_UNITSDIR
 ifdef REQUIRE_UNITSDIR
 override UNITSDIR+=$(REQUIRE_UNITSDIR)
 override UNITSDIR+=$(REQUIRE_UNITSDIR)

+ 1 - 1
packages/libogcfpc/examples/devices/usbgecko/gdbstub/Makefile.fpc

@@ -20,7 +20,7 @@ target=wii
 fpcdir=../../../../../..
 fpcdir=../../../../../..
 
 
 [compiler]
 [compiler]
-options=-g -Xm  
+options=-g -Xm  -k--gc-sections
 
 
 [clean]
 [clean]
 files=*.elf *.o *.s *.h *.bin *.map \
 files=*.elf *.o *.s *.h *.bin *.map \

+ 17 - 16
packages/libogcfpc/examples/graphics/gx/gxSprites/Makefile

@@ -270,8 +270,8 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 override TARGET_PROGRAMS+=gxsprites
 override TARGET_PROGRAMS+=gxsprites
 endif
 endif
@@ -1643,10 +1643,12 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 dir_delete:
 dir_delete:
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
+	@$(DELTREE) $(CURDIR)/$(DATA) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 dir_make:
 dir_make:
 ifneq ($(BUILD), $(CURDIR))
 ifneq ($(BUILD), $(CURDIR))
@@ -1658,17 +1660,16 @@ endif
 ifneq ($(DATA), $(CURDIR))
 ifneq ($(DATA), $(CURDIR))
 	@$(MKDIR) $(DATA)
 	@$(MKDIR) $(DATA)
 endif
 endif
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
 	@echo 'Creating tpl file...'
 	@echo 'Creating tpl file...'
-	$(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
-$(BIN_FILES): $(wildcard %.*)
-	@echo 'Converting $(@) file to asm...'
-	@$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-	@echo 'Creating $(@).inc include file...'
-	@echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo 'Assembling $(@).s file...'
+	$(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+	@echo $(DATA)/$(TPL_FILES)
+	@$(bin2o)  	
+define bin2o
+	@$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-	@echo 'Done!'
+	@echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 19 - 18
packages/libogcfpc/examples/graphics/gx/gxSprites/Makefile.fpc

@@ -3,7 +3,7 @@
 #
 #
 
 
 [target]
 [target]
-loaders= 
+loaders=       
 programs=gxsprites
 programs=gxsprites
 
 
 [require]
 [require]
@@ -33,19 +33,21 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 
 
 #
 #
 # Delete temp directories
 # Delete temp directories
 #
 #
 dir_delete:
 dir_delete:
         @$(DELTREE) $(CURDIR)/$(BUILD) 
         @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(DATA) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         
         
 #
 #
@@ -65,22 +67,21 @@ endif
 #
 #
 # Textures processing rule
 # Textures processing rule
 #
 #
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
         @echo 'Creating tpl file...'
         @echo 'Creating tpl file...'
-        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
+        $(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+        @echo $(DATA)/$(TPL_FILES)
+        @$(bin2o)  	
+
 
 
-	
 #
 #
 # Binary files processing rule
 # Binary files processing rule
 # 
 # 
-$(BIN_FILES): $(wildcard %.*)
-        @echo 'Converting $(@) file to asm...'
-        @$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-        @echo 'Creating $(@).inc include file...'
-        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo 'Assembling $(@).s file...'
+define bin2o
+        @$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-        @echo 'Done!'
+        @echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/gxSprites/gxsprites.pp

@@ -5,7 +5,7 @@ program gxsprites;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
 
 
 {$include inc/textures.tpl.inc}
 {$include inc/textures.tpl.inc}
 {$link build/textures.tpl.o}
 {$link build/textures.tpl.o}

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson1/lesson1.pp

@@ -4,7 +4,7 @@ program lesson1;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
  
  
 const
 const
   DEFAULT_FIFO_SIZE = (256*1024);
   DEFAULT_FIFO_SIZE = (256*1024);

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson2/lesson2.pp

@@ -4,7 +4,7 @@ program lesson2;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
  
  
 const
 const
   DEFAULT_FIFO_SIZE = (256*1024);
   DEFAULT_FIFO_SIZE = (256*1024);

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson3/lesson3.pp

@@ -4,7 +4,7 @@ program lesson3;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
  
  
 const
 const
   DEFAULT_FIFO_SIZE = (256*1024);
   DEFAULT_FIFO_SIZE = (256*1024);

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson4/lesson4.pp

@@ -5,7 +5,7 @@ program lesson4;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
  
  
 const
 const
   DEFAULT_FIFO_SIZE = (256 * 1024);
   DEFAULT_FIFO_SIZE = (256 * 1024);

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson5/lesson5.pp

@@ -5,7 +5,7 @@ program lesson5;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
  
  
 const
 const
   DEFAULT_FIFO_SIZE = (256 * 1024);
   DEFAULT_FIFO_SIZE = (256 * 1024);

+ 17 - 16
packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/Makefile

@@ -270,8 +270,8 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 override TARGET_PROGRAMS+=lesson6
 override TARGET_PROGRAMS+=lesson6
 endif
 endif
@@ -1643,10 +1643,12 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 dir_delete:
 dir_delete:
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
+	@$(DELTREE) $(CURDIR)/$(DATA) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 dir_make:
 dir_make:
 ifneq ($(BUILD), $(CURDIR))
 ifneq ($(BUILD), $(CURDIR))
@@ -1658,17 +1660,16 @@ endif
 ifneq ($(DATA), $(CURDIR))
 ifneq ($(DATA), $(CURDIR))
 	@$(MKDIR) $(DATA)
 	@$(MKDIR) $(DATA)
 endif
 endif
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
 	@echo 'Creating tpl file...'
 	@echo 'Creating tpl file...'
-	$(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
-$(BIN_FILES): $(wildcard %.*)
-	@echo 'Converting $(@) file to asm...'
-	@$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-	@echo 'Creating $(@).inc include file...'
-	@echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo 'Assembling $(@).s file...'
+	$(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+	@echo $(DATA)/$(TPL_FILES)
+	@$(bin2o)  	
+define bin2o
+	@$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-	@echo 'Done!'
+	@echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 18 - 17
packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/Makefile.fpc

@@ -33,19 +33,21 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 
 
 #
 #
 # Delete temp directories
 # Delete temp directories
 #
 #
 dir_delete:
 dir_delete:
         @$(DELTREE) $(CURDIR)/$(BUILD) 
         @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(DATA) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         
         
 #
 #
@@ -65,22 +67,21 @@ endif
 #
 #
 # Textures processing rule
 # Textures processing rule
 #
 #
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
         @echo 'Creating tpl file...'
         @echo 'Creating tpl file...'
-        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
+        $(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+        @echo $(DATA)/$(TPL_FILES)
+        @$(bin2o)  	
+
 
 
-	
 #
 #
 # Binary files processing rule
 # Binary files processing rule
 # 
 # 
-$(BIN_FILES): $(wildcard %.*)
-        @echo 'Converting $(@) file to asm...'
-        @$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-        @echo 'Creating $(@).inc include file...'
-        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo 'Assembling $(@).s file...'
+define bin2o
+        @$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-        @echo 'Done!'
+        @echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson6/lesson6.pp

@@ -5,7 +5,7 @@ program lesson6;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
 
 
 {$include inc/NeHe.tpl.inc}
 {$include inc/NeHe.tpl.inc}
 {$link build/NeHe.tpl.o}
 {$link build/NeHe.tpl.o}

+ 17 - 16
packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/Makefile

@@ -270,8 +270,8 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 override TARGET_PROGRAMS+=lesson7
 override TARGET_PROGRAMS+=lesson7
 endif
 endif
@@ -1643,10 +1643,12 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 dir_delete:
 dir_delete:
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
+	@$(DELTREE) $(CURDIR)/$(DATA) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 dir_make:
 dir_make:
 ifneq ($(BUILD), $(CURDIR))
 ifneq ($(BUILD), $(CURDIR))
@@ -1658,17 +1660,16 @@ endif
 ifneq ($(DATA), $(CURDIR))
 ifneq ($(DATA), $(CURDIR))
 	@$(MKDIR) $(DATA)
 	@$(MKDIR) $(DATA)
 endif
 endif
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
 	@echo 'Creating tpl file...'
 	@echo 'Creating tpl file...'
-	$(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
-$(BIN_FILES): $(wildcard %.*)
-	@echo 'Converting $(@) file to asm...'
-	@$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-	@echo 'Creating $(@).inc include file...'
-	@echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo 'Assembling $(@).s file...'
+	$(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+	@echo $(DATA)/$(TPL_FILES)
+	@$(bin2o)  	
+define bin2o
+	@$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-	@echo 'Done!'
+	@echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 18 - 17
packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/Makefile.fpc

@@ -33,19 +33,21 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 
 
 #
 #
 # Delete temp directories
 # Delete temp directories
 #
 #
 dir_delete:
 dir_delete:
         @$(DELTREE) $(CURDIR)/$(BUILD) 
         @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(DATA) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         
         
 #
 #
@@ -65,22 +67,21 @@ endif
 #
 #
 # Textures processing rule
 # Textures processing rule
 #
 #
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
         @echo 'Creating tpl file...'
         @echo 'Creating tpl file...'
-        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
+        $(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+        @echo $(DATA)/$(TPL_FILES)
+        @$(bin2o)  	
+
 
 
-	
 #
 #
 # Binary files processing rule
 # Binary files processing rule
 # 
 # 
-$(BIN_FILES): $(wildcard %.*)
-        @echo 'Converting $(@) file to asm...'
-        @$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-        @echo 'Creating $(@).inc include file...'
-        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo 'Assembling $(@).s file...'
+define bin2o
+        @$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-        @echo 'Done!'
+        @echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson7/lesson7.pp

@@ -5,7 +5,7 @@ program lesson7;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
 
 
 {$include inc/crate.tpl.inc}
 {$include inc/crate.tpl.inc}
 {$link build/crate.tpl.o}
 {$link build/crate.tpl.o}

+ 17 - 16
packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/Makefile

@@ -270,8 +270,8 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 override TARGET_PROGRAMS+=lesson8
 override TARGET_PROGRAMS+=lesson8
 endif
 endif
@@ -1643,10 +1643,12 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 dir_delete:
 dir_delete:
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
+	@$(DELTREE) $(CURDIR)/$(DATA) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 dir_make:
 dir_make:
 ifneq ($(BUILD), $(CURDIR))
 ifneq ($(BUILD), $(CURDIR))
@@ -1658,17 +1660,16 @@ endif
 ifneq ($(DATA), $(CURDIR))
 ifneq ($(DATA), $(CURDIR))
 	@$(MKDIR) $(DATA)
 	@$(MKDIR) $(DATA)
 endif
 endif
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
 	@echo 'Creating tpl file...'
 	@echo 'Creating tpl file...'
-	$(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
-$(BIN_FILES): $(wildcard %.*)
-	@echo 'Converting $(@) file to asm...'
-	@$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-	@echo 'Creating $(@).inc include file...'
-	@echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo 'Assembling $(@).s file...'
+	$(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+	@echo $(DATA)/$(TPL_FILES)
+	@$(bin2o)  	
+define bin2o
+	@$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
 	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-	@echo 'Done!'
+	@echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 18 - 17
packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/Makefile.fpc

@@ -33,19 +33,21 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 
 
 #
 #
 # Delete temp directories
 # Delete temp directories
 #
 #
 dir_delete:
 dir_delete:
         @$(DELTREE) $(CURDIR)/$(BUILD) 
         @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(DATA) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         
         
 #
 #
@@ -65,22 +67,21 @@ endif
 #
 #
 # Textures processing rule
 # Textures processing rule
 #
 #
-$(TPL_FILES): $(wildcard %.scf) 
+$(TPL_FILES):
         @echo 'Creating tpl file...'
         @echo 'Creating tpl file...'
-        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
+        $(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES)
+        @echo $(DATA)/$(TPL_FILES)
+        @$(bin2o)  	
+
 
 
-	
 #
 #
 # Binary files processing rule
 # Binary files processing rule
 # 
 # 
-$(BIN_FILES): $(wildcard %.*)
-        @echo 'Converting $(@) file to asm...'
-        @$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-        @echo 'Creating $(@).inc include file...'
-        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo 'Assembling $(@).s file...'
+define bin2o
+        @$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
         @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-        @echo 'Done!'
+        @echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc
+endef

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson8/lesson8.pp

@@ -5,7 +5,7 @@ program lesson8;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore, math;
+  cmem, ctypes, gctypes, gccore, math;
 
 
 {$include inc/glass.tpl.inc}
 {$include inc/glass.tpl.inc}
 {$link build/glass.tpl.o}
 {$link build/glass.tpl.o}

+ 19 - 18
packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/Makefile

@@ -270,8 +270,8 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 ifeq ($(FULL_TARGET),powerpc-wii)
 ifeq ($(FULL_TARGET),powerpc-wii)
 override TARGET_PROGRAMS+=lesson9
 override TARGET_PROGRAMS+=lesson9
 endif
 endif
@@ -1643,10 +1643,12 @@ ifneq ($(wildcard fpcmake.loc),)
 include fpcmake.loc
 include fpcmake.loc
 endif
 endif
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 dir_delete:
 dir_delete:
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
 	@$(DELTREE) $(CURDIR)/$(BUILD) 
+	@$(DELTREE) $(CURDIR)/$(DATA) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 	@$(DELTREE) $(CURDIR)/$(INC) 
 dir_make:
 dir_make:
 ifneq ($(BUILD), $(CURDIR))
 ifneq ($(BUILD), $(CURDIR))
@@ -1658,17 +1660,16 @@ endif
 ifneq ($(DATA), $(CURDIR))
 ifneq ($(DATA), $(CURDIR))
 	@$(MKDIR) $(DATA)
 	@$(MKDIR) $(DATA)
 endif
 endif
-$(TPL_FILES): $(wildcard %.scf) 
-	@echo 'Creating tpl file...'
-	$(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
-$(BIN_FILES): $(wildcard %.*)
-	@echo 'Converting $(@) file to asm...'
-	@$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-	@echo 'Creating $(@).inc include file...'
-	@echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-	@echo 'Assembling $(@).s file...'
-	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-	@echo 'Done!'
+$(TPL_FILES):
+	@echo 'Creating tpl file...' 
+	$(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES) 
+	@echo $(DATA)/$(TPL_FILES) 
+	@$(bin2o)   	
+define bin2o
+	@$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s 
+	@$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s       
+	@echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc   
+	@echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+endef

+ 20 - 19
packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/Makefile.fpc

@@ -33,19 +33,21 @@ BUILD = build
 INC = inc
 INC = inc
 DATA = data
 DATA = data
 TEXTURES = textures
 TEXTURES = textures
-TPL_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
-BIN_FILES = $(foreach dir,data,$(notdir $(wildcard $(dir)/*)))
+SCF_FILES = $(foreach dir,textures,$(notdir $(wildcard $(dir)/*.scf)))
+TPL_FILES = $(basename $(SCF_FILES)).tpl 
 
 
 [rules]
 [rules]
 .NOTPARALLEL:
 .NOTPARALLEL:
-clean: dir_delete fpc_clean fpc_cleanall
-all: dir_make $(TPL_FILES) $(BIN_FILES) fpc_all 
+.PHONY: clean all
+clean: dir_delete fpc_clean fpc_cleanall    
+all: dir_make $(TPL_FILES) fpc_all 
 
 
 #
 #
 # Delete temp directories
 # Delete temp directories
 #
 #
 dir_delete:
 dir_delete:
         @$(DELTREE) $(CURDIR)/$(BUILD) 
         @$(DELTREE) $(CURDIR)/$(BUILD) 
+        @$(DELTREE) $(CURDIR)/$(DATA) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         @$(DELTREE) $(CURDIR)/$(INC) 
         
         
 #
 #
@@ -65,22 +67,21 @@ endif
 #
 #
 # Textures processing rule
 # Textures processing rule
 #
 #
-$(TPL_FILES): $(wildcard %.scf) 
-        @echo 'Creating tpl file...'
-        $(GXTEXCONV) -s textures/$(@) -o $(DATA)/$(basename $(@)).tpl
+$(TPL_FILES):
+        @echo 'Creating tpl file...' 
+        $(GXTEXCONV) -s textures/$(SCF_FILES) -o $(DATA)/$(TPL_FILES) 
+        @echo $(DATA)/$(TPL_FILES) 
+        @$(bin2o)   	
+
 
 
-	
 #
 #
 # Binary files processing rule
 # Binary files processing rule
 # 
 # 
-$(BIN_FILES): $(wildcard %.*)
-        @echo 'Converting $(@) file to asm...'
-        @$(BIN2S) -a 32 data/$(@) > $(BUILD)/$(@).s
-        @echo 'Creating $(@).inc include file...'
-        @echo "var" > `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo "inc/"$(@F) | tr . .)`.inc
-        @echo 'Assembling $(@).s file...'
-        @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s
-        @echo 'Done!'
+define bin2o
+        @$(BIN2S) -a 32 $(DATA)/$(@) > $(BUILD)/$(@).s 
+        @$(AS) -o $(BUILD)/$(@).o $(BUILD)/$(@).s       
+        @echo "var" > `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end: array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`": array [0..0] of cuint8; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc   
+        @echo " " `(echo $(@F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size": cuint32; cvar; external;" >> `(echo $(INC)"/"$(@F) | tr . .)`.inc 
+endef

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/neheGX/lesson9/lesson9.pp

@@ -5,7 +5,7 @@ program lesson9;
 {$mode objfpc}
 {$mode objfpc}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
 
 
 {$include inc/startex.tpl.inc}
 {$include inc/startex.tpl.inc}
 {$link build/startex.tpl.o}
 {$link build/startex.tpl.o}

+ 1 - 1
packages/libogcfpc/examples/graphics/gx/triangle/triangle.pp

@@ -6,7 +6,7 @@ program triangle;
 {$inline on}
 {$inline on}
 
 
 uses
 uses
-  cmem, ctypes, gccore;
+  cmem, ctypes, gctypes, gccore;
 
 
 var
 var
   framebuffer: pcuint32;
   framebuffer: pcuint32;

+ 1 - 1
packages/libogcfpc/fpmake.pp

@@ -18,7 +18,7 @@ begin
 {$endif ALLPACKAGES}
 {$endif ALLPACKAGES}
     P.Version:='2.5.1';
     P.Version:='2.5.1';
     P.SourcePath.Add('src');
     P.SourcePath.Add('src');
-//    P.Dependencies.Add('x11');
+    P.Dependencies.Add('mad');
 
 
     // not linux compilable, skip
     // not linux compilable, skip
 
 

+ 17 - 17
packages/libogcfpc/src/gccore.inc

@@ -25,23 +25,23 @@
 {$include ogc/gx_struct.inc}
 {$include ogc/gx_struct.inc}
 
 
 {$include ogc/lwp.inc}
 {$include ogc/lwp.inc}
-{ $include ogc/lwp_config.inc}
-{ $include ogc/lwp_heap.inc}
-
-{ $include ogc/lwp_tqdata.inc}
-{ $include ogc/lwp_objmgr.inc}
-{ $include ogc/lwp_priority.inc}
-{ $include ogc/lwp_watchdog.inc}
-{ $include ogc/lwp_threads.inc}
-
-
-{ $include ogc/lwp_messages.inc}
-{ $include ogc/lwp_mutex.inc}
-{ $include ogc/lwp_sema.inc}
-{ $include ogc/lwp_stack.inc}
-{ $include ogc/lwp_states.inc}
-{ $include ogc/lwp_threadq.inc}
-{ $include ogc/lwp_wkspace.inc}
+ {$include ogc/lwp_config.inc}
+ {$include ogc/lwp_heap.inc}
+
+ {$include ogc/lwp_tqdata.inc}
+ {$include ogc/lwp_objmgr.inc}
+ {$include ogc/lwp_priority.inc}
+ {$include ogc/lwp_watchdog.inc}
+ {$include ogc/lwp_threads.inc}  // tradurre lwp_threads.inl
+
+
+ {$include ogc/lwp_messages.inc}
+ {$include ogc/lwp_mutex.inc}
+ {$include ogc/lwp_sema.inc}
+ {$include ogc/lwp_stack.inc}
+ {$include ogc/lwp_states.inc}
+ {$include ogc/lwp_threadq.inc}
+ {$include ogc/lwp_wkspace.inc}
 
 
 
 
 {$include ogc/gu.inc}
 {$include ogc/gu.inc}

+ 77 - 8
packages/libogcfpc/src/ogc/lwp_heap.inc

@@ -44,16 +44,10 @@ type
   pheap_cntrl = ^heap_cntrl;
   pheap_cntrl = ^heap_cntrl;
 
 
 
 
-function __lwp_heap_init(theheap: Pheap_cntrl; start_addr: pointer;
-  size, pg_size: cuint32): cuint32; cdecl; external;
-
+function __lwp_heap_init(theheap: Pheap_cntrl; start_addr: pointer; size, pg_size: cuint32): cuint32; cdecl; external;
 function __lwp_heap_allocate(theheap: Pheap_cntrl; size: cuint32): pointer; cdecl; external;
 function __lwp_heap_allocate(theheap: Pheap_cntrl; size: cuint32): pointer; cdecl; external;
-
 function __lwp_heap_free(theheap: Pheap_cntrl; ptr: pointer): cbool; cdecl; external;
 function __lwp_heap_free(theheap: Pheap_cntrl; ptr: pointer): cbool; cdecl; external;
-
-function __lwp_heap_getinfo(theheap: Pheap_cntrl; theinfo: Pheap_iblock)
-  : cuint32; cdecl; external;
-
+function __lwp_heap_getinfo(theheap: Pheap_cntrl; theinfo: Pheap_iblock): cuint32; cdecl; external;
 
 
 //{$ifdef LIBOGC_INTERNAL}
 //{$ifdef LIBOGC_INTERNAL}
 //{$include libogc/lwp_heap.inl}
 //{$include libogc/lwp_heap.inl}
@@ -61,3 +55,78 @@ function __lwp_heap_getinfo(theheap: Pheap_cntrl; theinfo: Pheap_iblock)
 {$ENDIF}
 {$ENDIF}
 
 
 
 
+{$IFDEF OGC_IMPLEMENTATION}
+function __lwp_heap_head(theheap: pheap_cntrl): pheap_block;
+begin
+	result := theheap^.start;
+end;
+
+function __lwp_heap_tail(heap: pheap_cntrl): pheap_block;
+begin
+	result := heap^.final;
+end;
+
+function __lwp_heap_prevblock(block: pheap_block): pheap_block;
+begin
+	result := pheap_block (pcchar(block)^ - (block^.back_flag and not HEAP_BLOCK_USED));
+end;
+
+function __lwp_heap_nextblock(block: pheap_block): pheap_block;
+begin
+	result :=  pheap_block(pcchar(block)^ + (block^.front_flag and not HEAP_BLOCK_USED));
+end;
+
+function __lwp_heap_blockat(block: pheap_block; offset: cuint32): pheap_block;
+begin
+	result :=  pheap_block(pcchar(block) + offset);
+end;
+
+function __lwp_heap_usrblockat(ptr: pointer): pheap_block;
+var
+  offset: cuint32;
+begin
+	offset := (pcuint32(ptr)^ - 1);
+	result :=  __lwp_heap_blockat(ptr, -offset + (-HEAP_BLOCK_USED_OVERHEAD));
+end;
+
+function __lwp_heap_prev_blockfree(block: pheap_block): boolean;
+begin
+	result :=  (block^.back_flag and HEAP_BLOCK_USED) = 0;
+end;
+
+function __lwp_heap_blockfree(block: pheap_block): boolean;
+begin
+	result :=  (block^.front_flag and HEAP_BLOCK_USED) = 0;
+end;
+
+function __lwp_heap_blockused(block: pheap_block): boolean;
+begin
+	result :=  (block^.front_flag and HEAP_BLOCK_USED) <> 0;
+end;
+
+function __lwp_heap_blocksize(block: pheap_block): cuint32;
+begin
+	result :=  (block^.front_flag and not HEAP_BLOCK_USED);
+end;
+
+function __lwp_heap_startuser(block: pheap_block): pointer;
+begin
+	result := pointer(block^.next);
+end;
+
+function __lwp_heap_blockin(heap: pheap_cntrl; block: pheap_block): boolean;
+begin
+	result := ((cuint32(block) >= cuint32(heap^.start)) and (cuint32(block) <= cuint32(heap^.final)));
+end;
+
+function __lwp_heap_pgsize_valid(pgsize: cuint32): boolean;
+begin
+	result := (pgsize <> 0) and ((pgsize mod PPC_ALIGNMENT) = 0);
+end;
+
+function __lwp_heap_buildflag(size, flag: cuint32): cuint32;
+begin
+	result := (size or flag);
+end;
+{$ENDIF}
+

+ 97 - 2
packages/libogcfpc/src/ogc/lwp_mutex.inc

@@ -49,8 +49,7 @@ procedure __lwp_mutex_seize_irq_blocking(mutex: Plwp_mutex; timeout: cuint64); c
 
 
 procedure __lwp_mutex_flush(mutex: Plwp_mutex; status: cuint32); cdecl; external;
 procedure __lwp_mutex_flush(mutex: Plwp_mutex; status: cuint32); cdecl; external;
 
 
-
-function __lwp_mutex_seize_irq_trylock(mutex: plwp_mutex; isr_level: pcuint32): cuint32; cdecl; external;
+function __lwp_mutex_seize_irq_trylock(mutex: plwp_mutex; isr_level: pcuint32): cuint32; inline;
 
 
 procedure __lwp_mutex_seize(_mutex_t: plwp_mutex; _id: cuint32; _wait: cuint8; _timeout, _level: cuint32); inline;
 procedure __lwp_mutex_seize(_mutex_t: plwp_mutex; _id: cuint32; _wait: cuint8; _timeout, _level: cuint32); inline;
 
 
@@ -58,6 +57,32 @@ procedure __lwp_mutex_seize(_mutex_t: plwp_mutex; _id: cuint32; _wait: cuint8; _
 
 
 
 
 {$IFDEF OGC_IMPLEMENTATION}
 {$IFDEF OGC_IMPLEMENTATION}
+
+function __lwp_mutex_locked(mutex: plwp_mutex): boolean;
+begin
+	result := (mutex^.lock = LWP_MUTEX_LOCKED);
+end;
+
+function __lwp_mutex_isinheritprio(attrs: plwp_mutex_attr): boolean;
+begin
+	result := (attrs^.mode = LWP_MUTEX_INHERITPRIO);
+end;
+
+function __lwp_mutex_isprioceiling(attrs: plwp_mutex_attr): boolean;
+begin
+	result := (attrs^.mode = LWP_MUTEX_PRIORITYCEIL);
+end;
+
+function __lwp_mutex_ispriority(attrs: plwp_mutex_attr): boolean;
+begin
+	result := (attrs^.mode = LWP_MUTEX_PRIORITY);
+end;
+
+function __lwp_mutex_isfifo(attrs: plwp_mutex_attr): boolean;
+begin
+	result := (attrs^.mode = LWP_MUTEX_FIFO);
+end;
+
 procedure __lwp_mutex_seize(_mutex_t: plwp_mutex; _id: cuint32; _wait: cuint8; _timeout, _level: cuint32); inline;
 procedure __lwp_mutex_seize(_mutex_t: plwp_mutex; _id: cuint32; _wait: cuint8; _timeout, _level: cuint32); inline;
 begin
 begin
   repeat
   repeat
@@ -79,6 +104,76 @@ begin
 		end;
 		end;
 	until false;
 	until false;
 end;
 end;
+
+function __lwp_mutex_seize_irq_trylock(mutex: plwp_mutex; isr_level: pcuint32): cuint32; inline;
+var
+	exec: plwp_cntrl;
+	level: cuint32;
+	prioceiling, priocurr: cuint32;
+begin
+	level := isr_level^;
+	exec := _thr_executing;
+	exec^.wait.ret_code := LWP_MUTEX_SUCCESSFUL;
+	if not __lwp_mutex_locked(mutex) then 
+	begin
+		mutex^.lock := LWP_MUTEX_LOCKED;
+		mutex^.holder := exec;
+		mutex^.nest_cnt := 1;
+		if __lwp_mutex_isinheritprio(@(mutex^.atrrs)) or __lwp_mutex_isprioceiling(@(mutex^.atrrs)) then
+			inc(exec^.res_cnt);
+		if not __lwp_mutex_isprioceiling(@(mutex^.atrrs)) then
+		begin
+			_CPU_ISR_Restore(level);
+			result := 0;
+		end;
+		begin
+			prioceiling := mutex^.atrrs.prioceil;
+			priocurr := exec^.cur_prio;
+			if (priocurr = prioceiling) then
+			begin
+				_CPU_ISR_Restore(level);
+				result := 0;
+			end;
+			if (priocurr > prioceiling) then
+			begin
+				__lwp_thread_dispatchdisable();
+				_CPU_ISR_Restore(level);
+				__lwp_thread_changepriority(mutex^.holder, mutex^.atrrs.prioceil, 0);
+				__lwp_thread_dispatchenable();
+				result := 0;
+			end;
+			exec^.wait.ret_code := LWP_MUTEX_CEILINGVIOL;
+			mutex^.nest_cnt := 0;
+			dec(exec^.res_cnt);
+			_CPU_ISR_Restore(level);
+			result := 0;
+		end;
+		result := 0;
+	end;
+
+	if (__lwp_thread_isexec(mutex^.holder)) <> 0 then
+	begin
+		case mutex^.atrrs.nest_behavior of
+			LWP_MUTEX_NEST_ACQUIRE:
+			begin
+				inc(mutex^.nest_cnt);
+				_CPU_ISR_Restore(level);
+				result := 0;
+			end;
+			LWP_MUTEX_NEST_ERROR:
+			begin
+				exec^.wait.ret_code := LWP_MUTEX_NEST_NOTALLOWED;
+				_CPU_ISR_Restore(level);
+				result := 0;
+			end;
+			LWP_MUTEX_NEST_BLOCK:
+			begin
+			end;
+		end;
+	end;
+	result := 1;
+end;
+
 //{$ifdef LIBOGC_INTERNAL}
 //{$ifdef LIBOGC_INTERNAL}
 //{$include libogc/lwp_mutex.inl}
 //{$include libogc/lwp_mutex.inl}
 //{$endif}
 //{$endif}

+ 49 - 0
packages/libogcfpc/src/ogc/lwp_priority.inc

@@ -29,3 +29,52 @@ procedure __lwp_priority_init; cdecl; external;
 //{$endif}
 //{$endif}
 {$ENDIF}
 {$ENDIF}
 
 
+
+{$IFDEF OGC_IMPLEMENTATION}
+procedure __lwp_priomap_init(theprio: pprio_cntrl; prio: cuint32);
+var
+	major,minor,mask: cuint32;
+begin
+	major := prio div 16;
+	minor := prio mod 16;
+
+	theprio^.minor := @(_prio_bitmap[major]);
+
+	mask := $80000000 shr major;
+	theprio^.ready_major := mask;
+	theprio^.block_major := not mask;
+
+	mask := $80000000 shr minor;
+	theprio^.ready_minor := mask;
+	theprio^.block_minor := not mask;
+//#ifdef _LWPPRIO_DEBUG
+//	printf("__lwp_priomap_init(%p,%d,%p,%d,%d,%d,%d)\n",theprio,prio,theprio->minor,theprio->ready_major,theprio->ready_minor,theprio->block_major,theprio->block_minor);
+//#endif
+end;
+
+procedure __lwp_priomap_addto(theprio: pprio_cntrl);
+begin
+	theprio^.minor^ := theprio^.minor^ or theprio^.ready_minor;
+	_prio_major_bitmap := _prio_major_bitmap or theprio^.ready_major;
+end;
+
+procedure __lwp_priomap_removefrom(theprio: pprio_cntrl);
+begin
+	theprio^.minor^ := theprio^.minor^ and theprio^.block_minor;
+	if theprio^.minor^ = 0 then
+		_prio_major_bitmap := _prio_major_bitmap and theprio^.block_major;
+end;
+
+function __lwp_priomap_highest(): cuint32;
+var
+	major, minor: cuint32;
+begin
+  major := cntlzw(_prio_major_bitmap);
+	minor := cntlzw(_prio_bitmap[major]);
+//#ifdef _LWPPRIO_DEBUG
+//	printf("__lwp_priomap_highest(%d)\n",((major<<4)+minor));
+//#endif
+	result := ((major shl 4) + minor);
+end;
+{$ENDIF}
+

+ 95 - 2
packages/libogcfpc/src/ogc/lwp_threads.inc

@@ -133,9 +133,102 @@ procedure __lwp_thread_dispatchdisable(); inline;
 {$ENDIF}
 {$ENDIF}
 
 
 {$IFDEF OGC_IMPLEMENTATION}
 {$IFDEF OGC_IMPLEMENTATION}
-procedure __lwp_thread_dispatchdisable(); inline;
+function __lwp_thread_isexec(thethread: plwp_cntrl): cuint32;
+begin
+	result := 0;
+  if (thethread = _thr_executing) then result := 1;
+end;
+
+function __lwp_thread_isheir(thethread: plwp_cntrl): cuint32;
+begin
+	result := 0;
+  if (thethread = _thr_heir) then result := 1;
+end;
+
+procedure __lwp_thread_calcheir();
+begin
+	_thr_heir := plwp_cntrl(_lwp_thr_ready[__lwp_priomap_highest()].first);
+//#ifdef _LWPTHREADS_DEBUG
+//	printf("__lwp_thread_calcheir(%p)\n",_thr_heir);
+//#endif
+end;
+
+function __lwp_thread_isallocatedfp(thethread: plwp_cntrl): cuint32;
+begin
+	result := 0;
+  if (thethread = _thr_allocated_fp) then result := 1;
+end;
+
+procedure __lwp_thread_deallocatefp();
+begin
+	_thr_allocated_fp := nil;
+end;
+
+procedure __lwp_thread_dispatchinitialize();
+begin
+	_thread_dispatch_disable_level := 1;
+end;
+
+procedure __lwp_thread_dispatchenable();
+begin
+  dec(_thread_dispatch_disable_level);
+	if (_thread_dispatch_disable_level = 0) then
+		__thread_dispatch();
+end;
+
+procedure __lwp_thread_dispatchdisable();
+begin
+	inc(_thread_dispatch_disable_level);
+end;
+
+procedure __lwp_thread_dispatchunnest();
 begin
 begin
-  inc(_thread_dispatch_disable_level);
+	dec(_thread_dispatch_disable_level);
 end;
 end;
+
+procedure __lwp_thread_unblock(thethread: plwp_cntrl);
+begin
+	__lwp_thread_clearstate(thethread, LWP_STATES_BLOCKED);
+end;
+
+function __lwp_thread_getlibcreent(): pointer;
+begin
+	result := __lwp_thr_libc_reent;
+end;
+
+procedure __lwp_thread_setlibcreent(libc_reent: pointer);
+begin
+	__lwp_thr_libc_reent := libc_reent;
+end;
+
+function __lwp_thread_isswitchwant(): cbool;
+begin
+	result := cbool(_context_switch_want);
+end;
+
+function __lwp_thread_isdispatchenabled(): cbool;
+begin
+	result := (_thread_dispatch_disable_level = 0);
+end;
+
+procedure __lwp_thread_inittimeslice();
+begin
+	__lwp_wd_initialize(@_lwp_wd_timeslice, @__lwp_thread_tickle_timeslice, LWP_TIMESLICE_TIMER_ID, nil);
+end;
+
+procedure __lwp_thread_starttimeslice();
+begin
+	__lwp_wd_insert_ticks(@_lwp_wd_timeslice, millisecs_to_ticks(1));
+end;
+
+procedure __lwp_thread_stoptimeslice();
+begin
+	__lwp_wd_remove_ticks(@_lwp_wd_timeslice);
+end;
+
+//procedure __lwp_thread_dispatchdisable(); inline;
+//begin
+//  inc(_thread_dispatch_disable_level);
+//end;
 {$ENDIF}
 {$ENDIF}
 
 

+ 83 - 0
packages/libogcfpc/src/ogc/lwp_watchdog.inc

@@ -173,4 +173,87 @@ begin
     result := -x;
     result := -x;
 end;
 end;
 
 
+
+procedure __lwp_wd_initialize(wd: pwd_cntrl; routine: wd_service_routine; id: cuint32; usr_data: pointer);
+begin
+	wd^.state := LWP_WD_INACTIVE;
+	wd^.id := id;
+	wd^.routine := routine;
+	wd^.usr_data := usr_data;
+end;
+
+function __lwp_wd_first(queue: plwp_queue): pwd_cntrl;
+begin
+	result := pwd_cntrl(@(queue^.first));
+end;
+
+function __lwp_wd_last(queue: plwp_queue): pwd_cntrl;
+begin
+	result := pwd_cntrl(@(queue^.last));
+end;
+
+function __lwp_wd_next(wd: pwd_cntrl): pwd_cntrl;
+begin
+	result := pwd_cntrl(@(wd^.node.next));
+end;
+
+function __lwp_wd_prev(wd: pwd_cntrl): pwd_cntrl;
+begin
+	result := pwd_cntrl(@(wd^.node.prev));
+end;
+
+procedure __lwp_wd_activate(wd: pwd_cntrl);
+begin
+	wd^.state := LWP_WD_ACTIVE;
+end;
+
+procedure __lwp_wd_deactivate(wd: pwd_cntrl);
+begin
+	wd^.state := LWP_WD_REMOVE;
+end;
+
+function __lwp_wd_isactive(wd: pwd_cntrl): cuint32;
+begin
+	result := 0;
+  if (wd^.state = LWP_WD_ACTIVE) then result := 1;
+end;
+
+function __lwp_wd_calc_ticks(const time: ptimespec): cuint64;
+var
+	ticks: cuint64;
+begin
+	ticks := secs_to_ticks(time^.tv_sec);
+	ticks := ticks + nanosecs_to_ticks(time^.tv_nsec);
+	result := ticks;
+end;
+
+procedure __lwp_wd_tickle_ticks();
+begin
+	__lwp_wd_tickle(@_wd_ticks_queue);
+end;
+
+procedure __lwp_wd_insert_ticks(wd: pwd_cntrl; interval: cint64);
+begin
+	wd^.start := gettime();
+	wd^.fire := (wd^.start + LWP_WD_ABS(interval));
+	__lwp_wd_insert(@_wd_ticks_queue, wd);
+end;
+
+procedure __lwp_wd_adjust_ticks(dir: cuint32; interval: cint64);
+begin
+	__lwp_wd_adjust(@_wd_ticks_queue,dir,interval);
+end;
+
+procedure __lwp_wd_remove_ticks(wd: pwd_cntrl);
+begin
+	__lwp_wd_remove(@_wd_ticks_queue,wd);
+end;
+
+procedure __lwp_wd_reset(wd: pwd_cntrl);
+begin
+	__lwp_wd_remove(@_wd_ticks_queue,wd);
+	__lwp_wd_insert(@_wd_ticks_queue,wd);
+end;
+
+
 {$ENDIF}
 {$ENDIF}

+ 19 - 13
packages/libogcfpc/src/ogc/machine/processor.inc

@@ -11,13 +11,13 @@ procedure ppchalt(); inline;
 //procedure mfpvr(); inline;
 //procedure mfpvr(); inline;
 function mfpvr(): cint32; inline;
 function mfpvr(): cint32; inline;
 
 
-procedure mfdcr(_rn: cuint); inline;
+function mfdcr(_rn: cuint): cuint32; inline;
 procedure mtdcr(rn, val: cuint); inline;
 procedure mtdcr(rn, val: cuint); inline;
-procedure mfmsr(); inline;
+function mfmsr(): cuint32; inline;
 procedure mtmsr(val: cuint); inline;
 procedure mtmsr(val: cuint); inline;
-procedure mfdec(); inline;
+function mfdec(): cuint32; inline;
 procedure mtdec(_val: cuint); inline;
 procedure mtdec(_val: cuint); inline;
-procedure mfspr(_rn: cuint); inline;
+function mfspr(_rn: cuint): cuint32; inline;
 procedure mtspr(_rn, _val: cuint); inline;
 procedure mtspr(_rn, _val: cuint); inline;
 
 
 {$define mfwpar()	:= mfspr(WPAR)}
 {$define mfwpar()	:= mfspr(WPAR)}
@@ -46,12 +46,12 @@ procedure mtspr(_rn, _val: cuint); inline;
 {$define mfhid4() := mfspr(HID4)}
 {$define mfhid4() := mfspr(HID4)}
 {$define mthid4(_val) := mtspr(HID4,_val)}
 {$define mthid4(_val) := mtspr(HID4,_val)}
 
 
-procedure __lhbrx(base, index: cuint32); inline;
+function __lhbrx(base, index: cuint32): cuint16; inline;
 //procedure __lwbrx(base,index: cuint32); inline;
 //procedure __lwbrx(base,index: cuint32); inline;
 function __lwbrx(base,index: cuint32): cuint32; inline;
 function __lwbrx(base,index: cuint32): cuint32; inline;
 procedure __sthbrx(base,index,value: cuint32); inline;
 procedure __sthbrx(base,index,value: cuint32); inline;
 procedure __stwbrx(base,index,value: cuint32); inline;
 procedure __stwbrx(base,index,value: cuint32); inline;
-procedure cntlzw(_val: cuint32); inline;
+function cntlzw(_val: cuint32): cuint32; inline;
 procedure _CPU_MSR_GET( _msr_value: cuint32 ); inline;
 procedure _CPU_MSR_GET( _msr_value: cuint32 ); inline;
 procedure _CPU_MSR_SET( _msr_value: cuint32 ); inline;
 procedure _CPU_MSR_SET( _msr_value: cuint32 ); inline;
 procedure _CPU_ISR_Enable(); inline;
 procedure _CPU_ISR_Enable(); inline;
@@ -118,13 +118,14 @@ begin
   result := _rval;
   result := _rval;
 end;
 end;
 
 
-procedure mfdcr(_rn: cuint); inline;
+function mfdcr(_rn: cuint): cuint32; inline;
 var
 var
   _rval: cuint32;
   _rval: cuint32;
 begin
 begin
   asm
   asm
   //    mfdcr r3,_rn  // unrecognized opcode?
   //    mfdcr r3,_rn  // unrecognized opcode?
   end;
   end;
+  result := _rval;
 end;
 end;
 
 
 procedure mtdcr(rn, val: cuint); inline;
 procedure mtdcr(rn, val: cuint); inline;
@@ -134,13 +135,14 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure mfmsr(); inline;
+function mfmsr(): cuint32; inline;
 var
 var
   _rval: cuint32;
   _rval: cuint32;
 begin
 begin
   asm
   asm
     mfmsr r3
     mfmsr r3
   end;
   end;
+  result := _rval;
 end;
 end;
 
 
 procedure mtmsr(val: cuint); inline;
 procedure mtmsr(val: cuint); inline;
@@ -150,7 +152,7 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure mfdec(); inline;
+function mfdec(): cuint32; inline;
 var
 var
   _rval: cuint32;
   _rval: cuint32;
 begin
 begin
@@ -158,6 +160,7 @@ begin
 //    mfdec r3    // unrecognized opcode?
 //    mfdec r3    // unrecognized opcode?
     mfspr r3,22    // unrecognized opcode?
     mfspr r3,22    // unrecognized opcode?
   end;
   end;
+  result := _rval;
 end;
 end;
 
 
 procedure mtdec(_val: cuint); inline;
 procedure mtdec(_val: cuint); inline;
@@ -168,13 +171,14 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure mfspr(_rn: cuint); inline;
+function mfspr(_rn: cuint): cuint32; inline;
 var
 var
   _rval: cuint32 = 0;
   _rval: cuint32 = 0;
 begin
 begin
 	asm
 	asm
     mfspr r3,r4
     mfspr r3,r4
   end;
   end;
+  result := _rval;
 end;
 end;
 
 
 procedure mtspr(_rn, _val: cuint); inline;
 procedure mtspr(_rn, _val: cuint); inline;
@@ -184,13 +188,14 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure __lhbrx(base, index: cuint32); inline;
+function __lhbrx(base, index: cuint32): cuint16; inline;
 var
 var
   res: cuint16;
   res: cuint16;
 begin
 begin
 	asm
 	asm
     lhbrx	r3,r4,r5
     lhbrx	r3,r4,r5
   end;
   end;
+  result := res;
 end;
 end;
 
 
 //procedure __lwbrx(base,index: cuint32); inline;
 //procedure __lwbrx(base,index: cuint32); inline;
@@ -218,13 +223,14 @@ begin
   end;
   end;
 end;
 end;
 
 
-procedure cntlzw(_val: cuint32); inline;
+function cntlzw(_val: cuint32): cuint32; inline;
 var
 var
   _rval: cuint32;
   _rval: cuint32;
 begin
 begin
   asm
   asm
     cntlzw r3, r4
     cntlzw r3, r4
   end;
   end;
+  result := _rval;
 end;
 end;
 
 
 procedure _CPU_MSR_GET( _msr_value: cuint32 ); inline;
 procedure _CPU_MSR_GET( _msr_value: cuint32 ); inline;
@@ -327,7 +333,7 @@ var
   tmp: cuint16;
   tmp: cuint16;
 begin
 begin
 	tmp := val;
 	tmp := val;
-  __lhbrx(tmp,0); //??
+  result := __lhbrx(tmp,0); //??
 end;
 end;
 
 
 function bswap32(val: cuint32): cuint32; inline;
 function bswap32(val: cuint32): cuint32; inline;