Permalink
Browse files

added example

  • Loading branch information...
1 parent 17e1750 commit 102d8540f4fd4a7e5a3bab483b9f7c40874e21f9 @wargio committed Jan 16, 2013
View
@@ -5,8 +5,8 @@
#---------------------------------------------------------------------------------
all:
@$(MAKE) -C libmove --no-print-directory
- @$(MAKE) -C sample/libmove-NoRSX-example pkg --no-print-directory
+ @$(MAKE) -C sample/libmove-NoRSX pkg --no-print-directory
clean:
@$(MAKE) -C libmove clean --no-print-directory
- @$(MAKE) -C sample/llibmove-NoRSX-example clean --no-print-directory
+ @$(MAKE) -C sample/libmove-NoRSX clean --no-print-directory
Submodule libmove-NoRSX-example deleted from e94829

Large diffs are not rendered by default.

Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,185 @@
+#---------------------------------------------------------------------------------
+# Clear the implicit built in rules
+#---------------------------------------------------------------------------------
+.SUFFIXES:
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(PSL1GHT)),)
+$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
+endif
+
+include $(PSL1GHT)/ppu_rules
+
+#---------------------------------------------------------------------------------
+# TARGET is the name of the output
+# BUILD is the directory where object files & intermediate files will be placed
+# SOURCES is a list of directories containing source code
+# INCLUDES is a list of directories containing extra header files
+#---------------------------------------------------------------------------------
+TARGET := $(notdir $(CURDIR))
+BUILD := build
+SOURCES := source
+DATA := data
+INCLUDES := include
+PKGFILES := $(CURDIR)/pkgfiles
+
+TITLE := NoRSX Example With Move Support
+APPID := NORSXMOVE
+CONTENTID := UP0001-$(APPID)_00-0000000000000000
+ICON0 := $(CURDIR)/ICON0.PNG
+
+#---------------------------------------------------------------------------------
+# options for code generation
+#---------------------------------------------------------------------------------
+
+CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE)
+CXXFLAGS = $(CFLAGS)
+
+LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map
+
+#---------------------------------------------------------------------------------
+# any extra libraries we wish to link with the project
+#---------------------------------------------------------------------------------
+LIBS := -lNoRSX -lmove -lgem -lcamera -lspurs -lgcm_sys -lrsx -lsysutil -lio -lm -lfreetype -lz -lpixman-1 -lrt -llv2 -lsysmodule -lpng -lpngdec -ljpgdec
+
+#---------------------------------------------------------------------------------
+# list of directories containing libraries, this must be the top level containing
+# include and lib
+#---------------------------------------------------------------------------------
+LIBDIRS := $(PORTLIBS)
+
+#---------------------------------------------------------------------------------
+# no real need to edit anything past this point unless you need to add additional
+# rules for different file extensions
+#---------------------------------------------------------------------------------
+ifneq ($(BUILD),$(notdir $(CURDIR)))
+#---------------------------------------------------------------------------------
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+
+export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
+ $(foreach dir,$(DATA),$(CURDIR)/$(dir))
+
+export DEPSDIR := $(CURDIR)/$(BUILD)
+
+export BUILDDIR := $(CURDIR)/$(BUILD)
+
+#---------------------------------------------------------------------------------
+# automatically build a list of object files for our project
+#---------------------------------------------------------------------------------
+CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
+CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
+sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
+SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S)))
+BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin)))
+PNGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.png)))
+JPGFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.jpg)))
+TTFFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.ttf)))
+VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg)))
+FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg)))
+
+#---------------------------------------------------------------------------------
+# use CXX for linking C++ projects, CC for standard C
+#---------------------------------------------------------------------------------
+ifeq ($(strip $(CPPFILES)),)
+ export LD := $(CC)
+else
+ export LD := $(CXX)
+endif
+
+export OFILES := $(addsuffix .o,$(BINFILES)) \
+ $(addsuffix .o,$(TTFFILES)) \
+ $(addsuffix .o,$(VPOFILES)) \
+ $(addsuffix .o,$(FPOFILES)) \
+ $(addsuffix .o,$(PNGFILES)) \
+ $(addsuffix .o,$(JPGFILES)) \
+ $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \
+ $(sFILES:.s=.o) $(SFILES:.S=.o)
+
+#---------------------------------------------------------------------------------
+# build a list of include paths
+#---------------------------------------------------------------------------------
+export INCLUDE := -I$(PORTLIBS)/include/freetype2 \
+ $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \
+ $(foreach dir,$(LIBDIRS),-I$(dir)/include) \
+ $(LIBPSL1GHT_INC) \
+ -I$(CURDIR)/$(BUILD)
+
+#---------------------------------------------------------------------------------
+# build a list of library paths
+#---------------------------------------------------------------------------------
+export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \
+ $(LIBPSL1GHT_LIB)
+
+export OUTPUT := $(CURDIR)/$(TARGET)
+.PHONY: $(BUILD) clean
+
+#---------------------------------------------------------------------------------
+$(BUILD):
+ @[ -d $@ ] || mkdir -p $@
+ @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile
+
+#---------------------------------------------------------------------------------
+clean:
+ @echo clean ...
+ @rm -fr $(BUILD) *.elf *.self *.pkg
+
+#---------------------------------------------------------------------------------
+run:
+ ps3load $(OUTPUT).self
+
+#---------------------------------------------------------------------------------
+pkg: $(BUILD) $(OUTPUT).pkg
+
+#---------------------------------------------------------------------------------
+else
+
+DEPENDS := $(OFILES:.o=.d)
+
+#---------------------------------------------------------------------------------
+# main targets
+#---------------------------------------------------------------------------------
+$(OUTPUT).self: $(OUTPUT).elf
+$(OUTPUT).elf: $(OFILES)
+
+#---------------------------------------------------------------------------------
+# This rule links in binary data with the .bin extension
+#---------------------------------------------------------------------------------
+%.bin.o : %.bin
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+#---------------------------------------------------------------------------------
+%.ttf.o : %.ttf
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+#---------------------------------------------------------------------------------
+%.vpo.o : %.vpo
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+#---------------------------------------------------------------------------------
+%.fpo.o : %.fpo
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+#---------------------------------------------------------------------------------
+%.jpg.o : %.jpg
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+#---------------------------------------------------------------------------------
+%.png.o : %.png
+#---------------------------------------------------------------------------------
+ @echo $(notdir $<)
+ @$(bin2o)
+
+-include $(DEPENDS)
+
+#---------------------------------------------------------------------------------
+endif
+#---------------------------------------------------------------------------------
@@ -0,0 +1,14 @@
+libmove Example made with NoRSX
+===============================
+
+THIS EXAMPLE USES NORSX AS GRAPHIC LIB.
+
+Authors
+-------
+ deroad
+
+Fonts
+-----
+
+All the fonts included with this lib aren't mine..
+
No changes.
@@ -0,0 +1,146 @@
+/*
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+ This program was created by Grazioli Giovanni Dante <wargio@libero.it>.
+*/
+
+#include <io/pad.h>
+
+#include <NoRSX.h> //This is the new HEADER!!! Now it's a real new lib!!
+
+#include <time.h>
+#include <libmove/libmove.h>
+
+
+msgType MSG_OK = (msgType)(MSG_DIALOG_NORMAL | MSG_DIALOG_BTN_TYPE_OK | MSG_DIALOG_DISABLE_CANCEL_ON);
+
+s32 main(s32 argc, const char* argv[])
+{
+ padInfo padinfo;
+ padData paddata;
+ ioPadInit(7);
+
+ init_move();
+
+ NoRSX *GFX = new NoRSX(RESOLUTION_1920x1080); //set defined screen resolution You can change it to:
+ //RESOLUTION_720x480 | RESOLUTION_720x576 | RESOLUTION_1280x720 | RESOLUTION_1920x1080
+ Image IMG(GFX);
+ Background BG(GFX);
+ Object OBJ(GFX);
+ Bitmap BMap(GFX);
+ MsgDialog Msg(GFX);
+
+ NoRSX_Bitmap Precalculated_Layer;
+
+ BMap.GenerateBitmap(&Precalculated_Layer); //Initialize the Bitmap
+
+ Font F1(LATIN2 ,GFX); //Loaded from Memory
+ BG.MonoBitmap(COLOR_BLACK,&Precalculated_Layer); //a green hex color (you can use hex colors insted of COLOR_XXXXXXX)
+
+ F1.PrintfToBitmap(150,500,&Precalculated_Layer,COLOR_RED,"Screen %d x %d",GFX->width,GFX->height);
+ F1.PrintfToBitmap(150,350,&Precalculated_Layer,COLOR_BLUE, 35,"Press X to exit! (joypad)");
+ F1.PrintfToBitmap(150,400,&Precalculated_Layer,COLOR_YELLOW, 35,"Press start to exit! (move)");
+
+ GFX->AppStart();
+ int frame=0;
+ float x=GFX->width*0.5,y=GFX->height*0.5,z=0;
+ float x1=0,y1=0,z1=0;
+ movePadData data;
+
+ get_gyro_position(PLAYSTATION_MOVE_PAD_0,&x1,&y1,&z1);
+ x=GFX->width*0.5-x1;
+ y=GFX->height*0.5-y1;
+ z=-z1;
+
+ while(GFX->GetAppStatus()){
+ static time_t starttime = 0;
+ double fps = 0;
+ if (starttime == 0) starttime = time (NULL);
+ else fps = frame / difftime (time (NULL), starttime);
+ BMap.DrawBitmap(&Precalculated_Layer);
+
+ getMovePadData(PLAYSTATION_MOVE_PAD_0, &data);
+
+ ioPadGetInfo(&padinfo);
+ if(padinfo.status[0]){
+ ioPadGetData(0, &paddata);
+ if(paddata.BTN_CROSS){
+ GFX->AppExit();
+ }
+ }
+
+ if(data.BTN_ACTION){
+ calibrate_move(PLAYSTATION_MOVE_PAD_0);
+ get_gyro_position(PLAYSTATION_MOVE_PAD_0, &x1, &y1, &z1);
+ x=GFX->width*0.5-x1;
+ y=GFX->height*0.5-y1;
+ z=-z1;
+ }
+ get_3d_position(PLAYSTATION_MOVE_PAD_0, &x1, &y1, &z1);
+ F1.Printf(150,200,COLOR_WHITE,30,"3D: x %.2f, y %.2f, z %.2f",x1,y1,z1);
+
+ get_gyro_position(PLAYSTATION_MOVE_PAD_0, &x1, &y1, &z1);
+ F1.Printf(150,300,COLOR_WHITE,30,"Gyro: x %.2f, y %.2f, z %.2f",x1,y1,z1);
+
+
+ if(abs(x1) > 2)
+ x += x1;
+ if(abs(y1) > 2)
+ y += y1;
+ if(abs(z1) > 2)
+ z += z1;
+
+ if(x>=GFX->width ) x = GFX->width ;
+ else if(x<0) x = 0;
+ if(y>=GFX->height) y = GFX->height;
+ else if(y<0) y = 0;
+
+
+ F1.Printf(150,100,COLOR_RED,60,"FPS %f", fps);
+ if(data.BTN_CROSS)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_CROSS");
+ if(data.BTN_CIRCLE)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_CIRCLE");
+ if(data.BTN_SQUARE)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_SQUARE");
+ if(data.BTN_TRIANGLE)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_TRIANGLE");
+ if(data.BTN_T)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_T");
+ if(data.BTN_ACTION)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_ACTION");
+ if(data.BTN_START){
+ F1.Printf(150,150,COLOR_RED,60,"BTN_START");
+ goto end;
+ }
+ if(data.BTN_SELECT)
+ F1.Printf(150,150,COLOR_RED,60,"BTN_SELECT");
+
+
+
+ F1.Printf(150,250,COLOR_WHITE,30,"Trigger T 0x%04x",data.ANA_T);
+ OBJ.Rectangle(x-5, y-5 , 10, 10, COLOR_WHITE);
+ GFX->Flip();
+ move_set_rumble(PLAYSTATION_MOVE_PAD_0, (u8)data.ANA_T);
+ frame ++;
+ }
+end:
+ //You need to clean the Bitmap before exit
+ BMap.ClearBitmap(&Precalculated_Layer);
+ end_move();
+ GFX->NoRSX_Exit();
+ ioPadEnd();
+ return 0;
+}
+

0 comments on commit 102d854

Please sign in to comment.