├── .gitignore ├── Makefile ├── README.md ├── docs └── working_with_tiny3D.txt ├── lib ├── Makefile ├── include │ ├── matrix.h │ └── tiny3d.h ├── readme.txt ├── shader │ ├── vshader_text_normal.rvp │ └── vshader_text_normal.vcg └── source │ ├── buffer.c │ ├── buffer.h │ ├── commands.c │ ├── commands.h │ ├── glue.c │ ├── list_code.h │ ├── matrix.c │ ├── mm.c │ ├── nv_shaders.h │ ├── old_nv40.h │ ├── realityVP.c │ ├── realityVP.h │ ├── rsxtiny.h │ ├── rsxutil.c │ ├── rsxutil.h │ ├── tiny3d.c │ ├── vshader_text_normal.vcg.S │ └── vshader_text_normal.vcg.h ├── libfont ├── Makefile ├── include │ └── libfont.h └── source │ └── libfont.c ├── samples ├── Makefile ├── fireworks3D │ ├── Makefile │ ├── about_this.txt │ └── source │ │ ├── font.c │ │ ├── font.h │ │ ├── main.c │ │ ├── sincos.c │ │ └── sincos.h ├── fonts │ ├── Makefile │ └── source │ │ ├── font.c │ │ ├── font.h │ │ ├── font_b.c │ │ ├── font_b.h │ │ ├── main.c │ │ └── msxfont.c ├── fonts_from_ttf │ ├── Makefile │ ├── README.txt │ ├── data │ │ ├── andika_ttf.bin │ │ └── dejavusans_ttf.bin │ ├── licenses │ │ ├── andika_OFL.txt │ │ ├── andika_README.txt │ │ ├── dejavu-AUTHORS │ │ ├── dejavu-LICENSE │ │ └── dejavu_README │ └── source │ │ └── main.c ├── ps3loadx │ ├── ICON0.PNG │ ├── Makefile │ ├── README.md │ ├── data │ │ └── psl1ght_jpg.bin │ ├── package.xml │ ├── payload │ │ └── RELOAD.SELF │ ├── ps3loadx.cfw_hermes_3.41.pkg │ ├── ps3loadx.pkg │ └── source │ │ ├── font.c │ │ ├── font.h │ │ ├── gfx.c │ │ ├── gfx.h │ │ ├── main.c │ │ ├── pad.c │ │ └── pad.h ├── resources │ ├── effect_mp3.bin │ ├── m2003_mp3.bin │ └── sound_ogg.bin ├── spheres3D │ ├── Makefile │ ├── data │ │ ├── texture1_png.bin │ │ └── texture2_png.bin │ └── source │ │ ├── font.c │ │ ├── main.c │ │ ├── utils.c │ │ └── utils.h ├── sprites2D │ ├── Makefile │ ├── data │ │ ├── ghost1_png.bin │ │ ├── ghost2_png.bin │ │ ├── ghost3_png.bin │ │ ├── ghost4_png.bin │ │ ├── ghost5_png.bin │ │ ├── ghost6_png.bin │ │ ├── ghost7_png.bin │ │ └── ghost8_png.bin │ └── source │ │ └── main.c ├── surfaces │ ├── Makefile │ └── source │ │ ├── main.c │ │ └── msxfont.c ├── tiny3d_lists │ ├── Makefile │ └── source │ │ ├── main.c │ │ ├── utils.c │ │ └── utils.h ├── userviewport │ ├── Makefile │ └── source │ │ ├── main.c │ │ ├── msxfont.c │ │ ├── pad.c │ │ └── pad.h └── yuv │ ├── Makefile │ ├── data │ └── picture_png.bin │ └── source │ ├── main.c │ └── msxfont.c └── tools ├── toolshaderf ├── Makefile ├── crc.l ├── crc.y ├── license.txt ├── nv40_shader.h └── samples │ ├── cg │ ├── build.bat │ ├── yuv.cg │ ├── yuv8.cg │ ├── yuv_color.cg │ └── yuv_color8.cg │ ├── color.fp │ ├── compile.bat │ ├── texture.fp │ ├── texture2.fp │ ├── texture2_alt.fp │ ├── texture2_alt2.fp │ ├── texture_color.fp │ ├── texture_color2.fp │ ├── texture_color2_alt.fp │ ├── texture_color2_alt2.fp │ ├── yuv.fp │ ├── yuv8.fp │ ├── yuv_color.fp │ └── yuv_color8.fp └── vpcomp ├── Makefile ├── Makefile_orig ├── NOTES.txt ├── README.txt ├── main.cpp ├── microcode.cpp ├── microcode.h ├── nv40_vertprog.h ├── nvfx_shader.h ├── parameters.cpp ├── parameters.h ├── vpasm.cpp └── vpasm.h /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.a 3 | *~ 4 | lib/build 5 | 6 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: all pkg clean 3 | 4 | all: 5 | 6 | @$(MAKE) install -C lib --no-print-directory 7 | @$(MAKE) install -C libfont --no-print-directory 8 | @$(MAKE) -C samples --no-print-directory 9 | 10 | pkg: 11 | @$(MAKE) install -C lib --no-print-directory 12 | @$(MAKE) install -C libfont --no-print-directory 13 | @$(MAKE) pkg -C samples --no-print-directory 14 | 15 | clean: 16 | @$(MAKE) clean -C lib --no-print-directory 17 | @$(MAKE) clean -C libfont --no-print-directory 18 | @$(MAKE) clean -C samples --no-print-directory 19 | 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Tiny3D 2.0 + libfont 2 | ========== 3 | 4 | Tiny3D is one library to work with 2D/3D graphics. 5 | 6 | NOTE: this repository is updated to the last PSL1GHT libraries and tools 7 | 8 | It uses PSL1GHT and install the libraries in $PORTLIBS/lib, C Header files 9 | in $PORTLIBS/include. it will also install nv40v1.h that comes from PSL1GHT V1 10 | 11 | see the 'docs' folder to know more (i need to update the info to the 2.0 version) 12 | 13 | Credits 14 | ------- 15 | 16 | Hermes - Author 17 | ElSemi - Vertex Program Compiler and other useful sample code 18 | HACKERCHANNEL - PSL1GHT 19 | Oopo - ps3libraries 20 | xerpi - porting the lib to v2 21 | deroad/Wargio - check code 22 | Bucanero, CrystalCT, Miigotu, Shagkur, Wargio and Zeldin to update Tiny3D for GCC 7.2.0 23 | 24 | License 25 | ------- 26 | 27 | It use the same PSL1GHT license (it have one? XD) 28 | 29 | Some samples can use LPGL, GPL, OFL or maybe others licenses depending of the libraries 30 | or datas used. 31 | 32 | Environment 33 | ----------- 34 | 35 | libtiny3d.a -> the library 36 | 37 | tiny3d.h -> 2D/3D functions 38 | 39 | matrix.h -> Math support for matrix 40 | 41 | -------------------------------------- 42 | 43 | libfont.a -> library to work with fixed fonts (now allow capture from True Type Fonts) 44 | libfont.h 45 | 46 | 47 | Building 48 | -------- 49 | In order to build tiny3d you need to have PSL1GHT installed - https://github.com/ps3dev/PSL1GHT 50 | You need the environment variable $PSL1GHT defined 51 | 52 | For the samples to build you need to have ps3soundlib installed - https://github.com/wargio/ps3soundlib 53 | 54 | cd tiny3D 55 | make 56 | 57 | It makes and install libs and samples. 58 | 59 | Remember you can descend later to the samples folder to compile ONLY the samples: 60 | 61 | cd samples 62 | make 63 | make pkg 64 | 65 | Current Status 66 | -------------- 67 | 68 | Support lights (4 positional specular / diffuse lights + ambient) and materials. 69 | 70 | Support double textures and dedicated surface rendering (You can render in the scene in one texture). 71 | 72 | Support for YUV surfaces using two methods. (See 'docs' and yuv sample) 73 | 74 | Support for list of objects (See 'docs' and tiny3d_list sample) 75 | 76 | It uses a configurable vertex shader and 'n' pixel shaders to work 77 | 78 | Added libfont.a with support for fonts based in bitmaps arrays of characters 79 | 80 | It works with this samples: spheres3D, sprites2D, surfaces, fonts, fonts_from_ttf 81 | ps3loadx, yuv, tiny3d_lists 82 | 83 | spheres3D uses the advanced features of Tiny3D 2.0 84 | 85 | -------------------------------------------------------------------------------- /docs/working_with_tiny3D.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/docs/working_with_tiny3D.txt -------------------------------------------------------------------------------- /lib/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | 7 | ifeq ($(strip $(PSL1GHT)),) 8 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 9 | endif 10 | 11 | include $(PSL1GHT)/ppu_rules 12 | 13 | #--------------------------------------------------------------------------------- 14 | ifeq ($(strip $(PLATFORM)),) 15 | #--------------------------------------------------------------------------------- 16 | export BASEDIR := $(CURDIR) 17 | export DEPS := $(BASEDIR)/deps 18 | export LIBS := $(BASEDIR)/lib 19 | 20 | #--------------------------------------------------------------------------------- 21 | else 22 | #--------------------------------------------------------------------------------- 23 | 24 | export LIBDIR := $(LIBS)/$(PLATFORM) 25 | export DEPSDIR := $(DEPS)/$(PLATFORM) 26 | 27 | #--------------------------------------------------------------------------------- 28 | endif 29 | #--------------------------------------------------------------------------------- 30 | 31 | TARGET := libtiny3d 32 | BUILD := build 33 | SOURCE := source 34 | INCLUDE := include 35 | DATA := data 36 | LIBS := 37 | 38 | MACHDEP := -DBIGENDIAN 39 | CFLAGS += -O2 -Wall -mcpu=cell -fgnu89-inline $(MACHDEP) -fno-strict-aliasing $(INCLUDES) 40 | LD := ppu-ld 41 | 42 | ifneq ($(BUILD),$(notdir $(CURDIR))) 43 | 44 | export OUTPUT := $(CURDIR)/$(TARGET) 45 | export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ 46 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 47 | export BUILDDIR := $(CURDIR)/$(BUILD) 48 | export DEPSDIR := $(BUILDDIR) 49 | 50 | CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) 51 | CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) 52 | SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) 53 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 54 | VCGFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vcg))) 55 | VSAFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vsa))) 56 | 57 | 58 | export OFILES := $(CFILES:.c=.o) \ 59 | $(CXXFILES:.cpp=.o) \ 60 | $(SFILES:.S=.o) \ 61 | $(BINFILES:.bin=.bin.o) \ 62 | $(VCGFILES:.vcg=.vcg.o) \ 63 | $(VSAFILES:.vsa=.vsa.o) 64 | 65 | export BINFILES := $(BINFILES:.bin=.bin.h) 66 | export VCGFILES := $(VCGFILES:.vcg=.vcg.h) 67 | export VSAFILES := $(VSAFILES:.vsa=.vsa.h) 68 | 69 | export INCLUDES = $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ 70 | -I$(CURDIR)/$(BUILD) -I$(PSL1GHT)/ppu/include 71 | 72 | .PHONY: $(BUILD) install clean shader 73 | 74 | $(BUILD): 75 | @[ -d $@ ] || mkdir -p $@ 76 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 77 | 78 | shader: 79 | @echo "[CGCOMP] $(notdir $<)" 80 | @$(CGCOMP) shader/vshader_text_normal.vcg shader/vshader_text_normal.rvp 81 | @$(RAW2H) shader/vshader_text_normal.rvp source/vshader_text_normal.vcg.h source/vshader_text_normal.vcg.S vshader_text_normal_bin 82 | 83 | install: $(BUILD) 84 | @echo Copying... 85 | @cp include/*.h $(PORTLIBS)/include 86 | @cp *.a $(PORTLIBS)/lib 87 | @echo Done! 88 | 89 | clean: 90 | @echo Clean... 91 | @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).fake.self $(OUTPUT).a 92 | 93 | else 94 | 95 | DEPENDS := $(OFILES:.o=.d) 96 | 97 | $(OUTPUT).a: $(OFILES) 98 | $(OFILES): $(BINFILES) $(VCGFILES) $(VSAFILES) 99 | 100 | -include $(DEPENDS) 101 | 102 | endif 103 | -------------------------------------------------------------------------------- /lib/include/matrix.h: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D (c) 2010 Hermes 3 | This work is based in ElSemi, Phire, AerialX and may be, others PSL1GHT contributors 4 | 5 | */ 6 | 7 | #ifndef MATRIX_H 8 | #define MATRIX_H 9 | 10 | #ifdef __cplusplus 11 | extern "C" { 12 | #endif 13 | 14 | typedef struct { 15 | 16 | float data[4][4]; 17 | 18 | } MATRIX; 19 | 20 | typedef struct { 21 | 22 | float x, y, z; 23 | 24 | } VECTOR; 25 | 26 | MATRIX MakeLookAtMatrix(VECTOR eye, VECTOR center, VECTOR up); 27 | 28 | MATRIX MatrixProjPerspective(float fov, float aspect, float near, float far); 29 | 30 | VECTOR MatrixVectorMultiply(MATRIX mat, VECTOR vec); 31 | 32 | VECTOR MatrixVectorMultiply3x3(MATRIX mat, VECTOR vec); 33 | 34 | MATRIX MatrixMultiply(MATRIX old_matrix, MATRIX new_matrix); 35 | 36 | MATRIX MatrixIdentity(void); 37 | 38 | MATRIX MatrixTranslation(float x, float y, float z); 39 | 40 | MATRIX MatrixTranspose(MATRIX src); 41 | 42 | MATRIX MatrixScale(float x, float y, float z); 43 | 44 | MATRIX MatrixRotationX(float angle); 45 | 46 | MATRIX MatrixRotationY(float angle); 47 | 48 | MATRIX MatrixRotationZ(float angle); 49 | 50 | MATRIX MatrixRotationAxis(float angle, VECTOR v); 51 | 52 | /* vectors */ 53 | 54 | VECTOR VectorToUnit(VECTOR v); 55 | 56 | VECTOR VectorNormalPlane(VECTOR v1, VECTOR v2, VECTOR v3); 57 | 58 | #ifdef __cplusplus 59 | } 60 | #endif 61 | 62 | #endif -------------------------------------------------------------------------------- /lib/readme.txt: -------------------------------------------------------------------------------- 1 | vertex shader is precompiled. If you want modify and compile it uses: 2 | 3 | make shader 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /lib/shader/vshader_text_normal.rvp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/lib/shader/vshader_text_normal.rvp -------------------------------------------------------------------------------- /lib/shader/vshader_text_normal.vcg: -------------------------------------------------------------------------------- 1 | 2 | struct InputVertex 3 | { 4 | float4 vertex : POSITION; 5 | float3 normal : NORMAL; 6 | float4 color : COLOR; 7 | float2 texcoord : TEXCOORD0; 8 | float2 texcoord2 : TEXCOORD1; 9 | }; 10 | 11 | struct OutputVertex 12 | { 13 | float4 vertex : POSITION; 14 | float4 color : COLOR; 15 | float2 texcoord : TEXCOORD0; 16 | float2 texcoord2 : TEXCOORD1; 17 | }; 18 | 19 | uniform float4x4 ProjMatrix; 20 | uniform float4x4 WorldMatrix; 21 | 22 | // lights 23 | uniform float3 CameraPosition; 24 | uniform float4 lightAmbient; 25 | uniform float4x4 lightColor; 26 | uniform float4x4 lightPosition; 27 | 28 | // materials 29 | uniform float4 Memissive; 30 | uniform float4 Mambient; 31 | uniform float4 Mdiffuse; 32 | uniform float4 Mspecular; 33 | 34 | /* 35 | lightAmbient.xyz -> ambient light multiplier 36 | lightAmbient.w -> 0.0 = disable lights/material, other = enable lights/material 37 | 38 | lightPosition[n].xyz -> light position 39 | lightPosition[n].w -> 0.0 = Disable, 0.5 = Diffuse, 1.0 = Specular 40 | 41 | Mambient.xyz -> Material ambient color 42 | Mambient.w -> Output alpha 43 | 44 | Mspecular.xyz -> MaterialSpecular 45 | Mspecular.w -> shininess (with 0.0 disables specular) 46 | 47 | Mdiffuse.xyz -> MaterialDiffuse 48 | Mdiffuse.w -> with 0.0 disables diffuse 49 | */ 50 | 51 | OutputVertex main(InputVertex inputvertex) 52 | { 53 | OutputVertex outputvertex; 54 | 55 | float4 v; 56 | int n; 57 | 58 | v = mul(inputvertex.vertex, WorldMatrix); 59 | outputvertex.vertex = mul(v,ProjMatrix); 60 | outputvertex.vertex.z *= outputvertex.vertex.w; 61 | 62 | if(lightAmbient.w != 0.0) { 63 | 64 | float3 N = float3(mul( inputvertex.normal.xyz, (float3x3) WorldMatrix)); 65 | 66 | float3 color = min(Memissive.xyz + (Mambient.xyz * lightAmbient.xyz), 1.0f); 67 | 68 | float3 V = normalize(CameraPosition-v.xyz); 69 | 70 | for(n=0;n<4;n++) { 71 | 72 | if(lightPosition[n].w == 0.0) continue; 73 | 74 | float3 L = normalize(lightPosition[n].xyz - v.xyz); 75 | float diffuseLight = 1.0f; 76 | 77 | // Difusse 78 | if(Mdiffuse.w != 0.0f) { 79 | 80 | diffuseLight = max(dot(N, L), 0); 81 | color = min(color + Mdiffuse.xyz * lightColor[n].xyz * diffuseLight, 1.0f); 82 | 83 | } 84 | 85 | // Specular 86 | if(Mspecular.w != 0.0f && lightPosition[n].w == 1.0f && diffuseLight > 0) { 87 | 88 | float3 H = normalize(L + V); 89 | float specularLight = pow(max(dot(N, H), 0), Mspecular.w); 90 | color = min(color + Mspecular.xyz * lightColor[n].xyz * specularLight, 1.0f); 91 | } 92 | } 93 | 94 | outputvertex.color.xyz = color; 95 | outputvertex.color.w = Mambient.w; 96 | } 97 | else 98 | outputvertex.color = inputvertex.color; 99 | 100 | outputvertex.texcoord = inputvertex.texcoord; 101 | outputvertex.texcoord2 = inputvertex.texcoord2; 102 | 103 | return outputvertex; 104 | 105 | } 106 | -------------------------------------------------------------------------------- /lib/source/buffer.c: -------------------------------------------------------------------------------- 1 | #include "buffer.h" 2 | 3 | // Thanks to shagkur for working out how to get gcc to compile this callback 4 | // I highly recomend you don't try and "improve" this unless you are a gcc ninja. 5 | s32 __attribute__((noinline)) tiny_rsxContextCallback(tiny_gcmContextData *context,u32 count) 6 | { 7 | register s32 result asm("3"); 8 | asm volatile ( 9 | "stdu 1,-128(1)\n" // Make space on stack for clobbered registers 10 | "mr 31,2\n" // Save rtoc 11 | "lwz 0,0(%0)\n" // load callback funcion pointer 12 | "lwz 2,4(%0)\n" // load callback's rtoc 13 | "mtctr 0\n" 14 | "bctrl\n" // Branch to callback function 15 | "mr 2,31\n" // restore rtoc 16 | "addi 1,1,128\n" // restore stack pointer 17 | : : "b"(context->callback) 18 | #if __GNUC__ >= 7 //GCC now diagnoses inline assembly that clobbers register r2. This has always been invalid code, and is no longer quietly tolerated. 19 | : "r31", "r0", "lr" 20 | #else 21 | : "r31", "r0", "r1", "r2", "lr" 22 | #endif 23 | ); 24 | return result; 25 | } 26 | 27 | void commandBufferPut(tiny_gcmContextData* context, uint32_t value) { 28 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 29 | *buffer++ = value; 30 | context->current = (uint32_t)(uint64_t) buffer; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /lib/source/buffer.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rsxtiny.h" 4 | 5 | #ifdef __cplusplus 6 | extern "C" { 7 | #endif 8 | 9 | #ifndef assert 10 | #define assert(x) if(!(x)) return 11 | #endif 12 | 13 | 14 | #define INTERNAL_COMMAND_LENGTH(context, len) \ 15 | if(context->current + len*4 > context->end) {\ 16 | if(tinycallback_flag==1) tiny3d_alarm(1); \ 17 | if(tinycallback_flag==2) tiny3d_alarm(2); \ 18 | if(tiny_rsxContextCallback(context, len) != 0) {\ 19 | tinyerror_incallback = 1; tiny3d_alarm(0);return; \ 20 | }\ 21 | } 22 | 23 | typedef union { 24 | float f; 25 | uint32_t u; 26 | } rsxtiny_ieee32; 27 | 28 | // Internal function that you shouldn't use unless you are directly manulipting the buffer. 29 | s32 __attribute__((noinline)) tiny_rsxContextCallback(tiny_gcmContextData *context,u32 count); 30 | void commandBufferPut(tiny_gcmContextData *context, uint32_t value); 31 | 32 | // Inline macros for writing command packets to the rsx buffer. 33 | void inline extern internal_commandBufferPutCmd1(tiny_gcmContextData* context, uint32_t command, uint32_t v1) { 34 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 35 | *buffer++ = command | 1 << 18; 36 | *buffer++ = v1; 37 | context->current = (uint32_t)(uint64_t) buffer; 38 | } 39 | 40 | void inline extern internal_commandBufferPutCmd2(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2) { 41 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 42 | *buffer++ = command | 2 << 18; 43 | *buffer++ = v1; 44 | *buffer++ = v2; 45 | context->current = (uint32_t)(uint64_t) buffer; 46 | } 47 | 48 | void inline extern internal_commandBufferPutCmd3(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3) { 49 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 50 | *buffer++ = command | 3 << 18; 51 | *buffer++ = v1; 52 | *buffer++ = v2; 53 | *buffer++ = v3; 54 | context->current = (uint32_t)(uint64_t) buffer; 55 | } 56 | 57 | void inline extern internal_commandBufferPutCmd4(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4) { 58 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 59 | *buffer++ = command | 4 << 18; 60 | *buffer++ = v1; 61 | *buffer++ = v2; 62 | *buffer++ = v3; 63 | *buffer++ = v4; 64 | context->current = (uint32_t)(uint64_t) buffer; 65 | } 66 | 67 | void inline extern internal_commandBufferPutCmd5(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4, uint32_t v5) { 68 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 69 | *buffer++ = command | 5 << 18; 70 | *buffer++ = v1; 71 | *buffer++ = v2; 72 | *buffer++ = v3; 73 | *buffer++ = v4; 74 | *buffer++ = v5; 75 | context->current = (uint32_t)(uint64_t) buffer; 76 | } 77 | 78 | void inline extern internal_commandBufferPutCmd6(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4, uint32_t v5, uint32_t v6) { 79 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 80 | *buffer++ = command | 6 << 18; 81 | *buffer++ = v1; 82 | *buffer++ = v2; 83 | *buffer++ = v3; 84 | *buffer++ = v4; 85 | *buffer++ = v5; 86 | *buffer++ = v6; 87 | context->current = (uint32_t)(uint64_t) buffer; 88 | } 89 | 90 | void inline extern internal_commandBufferPutCmd7(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4, uint32_t v5, uint32_t v6, uint32_t v7) { 91 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 92 | *buffer++ = command | 7 << 18; 93 | *buffer++ = v1; 94 | *buffer++ = v2; 95 | *buffer++ = v3; 96 | *buffer++ = v4; 97 | *buffer++ = v5; 98 | *buffer++ = v6; 99 | *buffer++ = v7; 100 | context->current = (uint32_t)(uint64_t) buffer; 101 | } 102 | 103 | void inline extern internal_commandBufferPutCmd8(tiny_gcmContextData* context, uint32_t command, uint32_t v1, uint32_t v2, uint32_t v3, uint32_t v4, uint32_t v5, uint32_t v6, uint32_t v7, uint32_t v8) { 104 | uint32_t* buffer = (uint32_t *)(uint64_t) context->current; 105 | *buffer++ = command | 8 << 18; 106 | *buffer++ = v1; 107 | *buffer++ = v2; 108 | *buffer++ = v3; 109 | *buffer++ = v4; 110 | *buffer++ = v5; 111 | *buffer++ = v6; 112 | *buffer++ = v7; 113 | *buffer++ = v8; 114 | context->current = (uint32_t)(uint64_t) buffer; 115 | } 116 | 117 | #ifdef __cplusplus 118 | } 119 | #endif 120 | -------------------------------------------------------------------------------- /lib/source/glue.c: -------------------------------------------------------------------------------- 1 | #include "rsxtiny.h" 2 | 3 | void rsxtiny_FlushBuffer(tiny_gcmContextData *context) { 4 | u32 offset = 0; 5 | gcmControlRegister volatile *control = gcmGetControlRegister(context); 6 | __asm __volatile__("sync"); // Sync, to make sure the command was written; 7 | gcmAddressToOffset((void *) (u64) context->current, &offset); 8 | control->put = offset; 9 | } 10 | 11 | 12 | /* Maps the memory at ioAddress into the RSX's memory space so the userspace thread 13 | * and the RSX can comunicate. 14 | * This shared memory must be 1mb aligned, and at least 1mb long. 15 | * Also Initilizes a RSX command buffer of cmdSize inside the shared memory. 16 | * 17 | * Returns a context structure. 18 | */ 19 | tiny_gcmContextData *rsxtiny_Init(const u32 cmdSize, const u32 ioSize, const void* ioAddress) { 20 | #ifdef OLD_TINY3D 21 | u32 contextPointer; 22 | s32 ret = gcmInitBody(&contextPointer, cmdSize, ioSize, ioAddress); 23 | if (ret == 0) { 24 | // Double cast fixes warning about diffrent pointer sizes. 25 | tiny_gcmContextData *context = (tiny_gcmContextData *) (u64) contextPointer; 26 | return context; 27 | } 28 | #else 29 | gcmContextData * contextPointer; 30 | s32 ret = gcmInitBody(&contextPointer, cmdSize, ioSize, ioAddress); 31 | if (ret == 0) { 32 | // Double cast fixes warning about diffrent pointer sizes. 33 | tiny_gcmContextData *context = (void *) contextPointer; 34 | return context; 35 | } 36 | #endif 37 | return NULL; 38 | } 39 | 40 | int rsxtiny_AddressToOffset(void* ptr, u32 *offset) { 41 | #ifdef OLD_TINY3D 42 | // Double cast for warnings. 43 | return gcmAddressToOffset((u32) (u64) ptr, offset); 44 | #else 45 | return gcmAddressToOffset(ptr, offset); 46 | #endif 47 | } 48 | -------------------------------------------------------------------------------- /lib/source/mm.c: -------------------------------------------------------------------------------- 1 | #include "rsxtiny.h" 2 | 3 | static s8 initialized = 0; 4 | gcmConfiguration config; 5 | void *heap_pointer; 6 | 7 | 8 | // Really dumb allocater, It will do until we start dealing with textures and vertex buffers. 9 | void *rsxtiny_MemAlign(s32 alignment, s32 size) { 10 | if (!initialized || alignment==-1 ) { 11 | gcmGetConfiguration(&config); 12 | initialized = 1; 13 | #ifdef OLD_TINY3D 14 | heap_pointer = (void *)(u64)config.localAddress; 15 | #else 16 | heap_pointer = (void *) config.localAddress; 17 | #endif 18 | 19 | if(alignment==-1) return NULL; 20 | } 21 | void *pointer = heap_pointer; 22 | pointer = (void *)((((u64) pointer) + (alignment-1)) & (-alignment)); // Align 23 | #ifdef OLD_TINY3D 24 | if ((u64) pointer + size > config.localAddress + config.localSize) // Out of memory? 25 | return NULL; 26 | #else 27 | if ((u64) pointer + size > ((u64)(void *) config.localAddress) + config.localSize) // Out of memory? 28 | return NULL; 29 | #endif 30 | heap_pointer = (void *)((u64) pointer + size); 31 | return pointer; 32 | } 33 | 34 | void *rsxtiny_Mem(s32 size) { 35 | return rsxtiny_MemAlign(64, size); 36 | } 37 | 38 | 39 | -------------------------------------------------------------------------------- /lib/source/nv_shaders.h: -------------------------------------------------------------------------------- 1 | #ifndef __NV_SHADERS_H__ 2 | #define __NV_SHADERS_H__ 3 | 4 | //#include 5 | typedef struct { 6 | uint32_t offset; 7 | uint32_t size; 8 | uint32_t num_regs; 9 | uint32_t data[]; 10 | } realityFragmentProgram_internal; 11 | 12 | 13 | /******************************************************************************* 14 | * NV30/NV40/G70 fragment shaders 15 | */ 16 | 17 | // color0 only 18 | 19 | static realityFragmentProgram_internal nv30_fp_color = { 20 | .num_regs = 2, 21 | .size = (1*4), 22 | .data = { 23 | // MOV o[COLH], f[COL0]; 24 | 0x1003e81, 0x1c9dc801, 0x0, 0x0 25 | } 26 | }; 27 | 28 | // texture0 only 29 | 30 | static realityFragmentProgram_internal nv30_fp_texture = { 31 | .num_regs = 2, 32 | .size = (1*4), 33 | .data = { 34 | //TEXX o[COLH], f[TEX0], TEX0, 2D; 35 | 0x17809e81, 0x1c9dc801, 0x0, 0x0 36 | } 37 | }; 38 | 39 | // color0 and texture0 40 | 41 | static realityFragmentProgram_internal nv30_fp_texture_color = { 42 | .num_regs = 2, 43 | .size = (2*4), 44 | .data = { 45 | // TEXX R0, f[TEX0], TEX0, 2D; 46 | 0x17809e00, 0x1c9dc801, 0x0, 0x0, 47 | // MULX o[COLH], R0, f[COL0]; 48 | 0x2803e81, 0x1c9dc800, 0x1c801, 0x0 49 | } 50 | }; 51 | 52 | // texture0 + texture1 53 | static realityFragmentProgram_internal nv30_fp_texture2 = { 54 | .num_regs = 3, 55 | .size = (3*4), 56 | .data = { 57 | // TEX R0, f[TEX0], TEX0, 2D; 58 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 59 | // TEX R1, f[TEX1], TEX1, 2D; 60 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 61 | // MULX o[COLH], R0, R1; 62 | 0x2801e81, 0x1c9dc800, 0x1c804, 0x0 63 | } 64 | }; 65 | 66 | // texture0 + texture1 alternative 67 | static realityFragmentProgram_internal nv30_fp_texture2_alt = { 68 | .num_regs = 3, 69 | .size = (6*4), 70 | .data = { 71 | // TEX R0, f[TEX0], TEX0, 2D; 72 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 73 | // TEX R1, f[TEX1], TEX1, 2D; 74 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 75 | // ADDR R1.xyz, R1, -R0; 76 | 0x3000e02, 0x1c9dc804, 0x1c800, 0x0, 77 | // MADR o[COLH].xyz, R1, {0.5}.x, R0; 78 | 0x4000e80, 0x1c9dc804, 0x6, 0x1c800, 79 | // {0.5 , 0.0, 0.0, 0.0} 80 | 0x3f000000, 0x0, 0x0, 0x0, 81 | // MULX o[COLH].w, R0.w, R1.w; 82 | 0x2801081, 0x1c9dfe00, 0x1fe04, 0x0 83 | } 84 | }; 85 | 86 | // texture0 + texture1 alternative2 87 | static realityFragmentProgram_internal nv30_fp_texture2_alt2 = { 88 | .num_regs = 3, 89 | .size = (5*4), 90 | .data = { 91 | // TEX R0, f[TEX0], TEX0, 2D; 92 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 93 | // TEX R1, f[TEX1], TEX1, 2D; 94 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 95 | // ADDR R1, R1, -R0; 96 | 0x3001e02, 0x1c9dc804, 0x1c800, 0x0, 97 | // MADR o[COLH], R1, {0.5}.x, R0; 98 | 0x4001e81, 0x1c9dc804, 0x6, 0x1c800, 99 | // {0.5 , 0.0, 0.0, 0.0} 100 | 0x3f000000, 0x0, 0x0, 0x0, 101 | } 102 | }; 103 | 104 | // color0 + texture0 + texture1 105 | static realityFragmentProgram_internal nv30_fp_texture_color2 = { 106 | .num_regs = 3, 107 | .size = (4*4), 108 | .data = { 109 | // TEX R0, f[TEX0], TEX0, 2D; 110 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 111 | // TEX R1, f[TEX1], TEX1, 2D; 112 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 113 | // MUL R0, R0, R1; 114 | 0x2001e00, 0x1c9dc800, 0x1c804, 0x0, 115 | // MULX o[COLH], R0, f[COL0]; 116 | 0x2803e81, 0x1c9dc800, 0x1c801, 0x0 117 | } 118 | }; 119 | 120 | // color0 + texture0 + texture1 alternative 121 | static realityFragmentProgram_internal nv30_fp_texture_color2_alt = { 122 | .num_regs = 3, 123 | .size = (7*4), 124 | .data = { 125 | // TEX R0, f[TEX0], TEX0, 2D; 126 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 127 | // TEX R1, f[TEX1], TEX1, 2D; 128 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 129 | // ADDR R1.xyz, R1, -R0; 130 | 0x3000e02, 0x1c9dc804, 0x1c800, 0x0, 131 | // MADR R0.xyz, R1, {0.5}.x, R0; 132 | 0x4000e00, 0x1c9dc804, 0x6, 0x1c800, 133 | // {0.5 , 0.0, 0.0, 0.0} 134 | 0x3f000000, 0x0, 0x0, 0x0, 135 | // MUL R0.w, R0.w, R1.w; 136 | 0x2001000, 0x1c9dfe00, 0x1fe04, 0x0, 137 | // MULX o[COLH], R0, f[COL0]; 138 | 0x2803e81, 0x1c9dc800, 0x1c801, 0x0 139 | } 140 | }; 141 | 142 | // color0 + texture0 + texture1 alternative2 143 | static realityFragmentProgram_internal nv30_fp_texture_color2_alt2 = { 144 | .num_regs = 3, 145 | .size = (6*4), 146 | .data = { 147 | // TEX R0, f[TEX0], TEX0, 2D; 148 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 149 | // TEX R1, f[TEX1], TEX1, 2D; 150 | 0x1702be02, 0x1c9dc805, 0x0, 0x0, 151 | // ADDR R1, R1, -R0; 152 | 0x3001e02, 0x1c9dc804, 0x1c800, 0x0, 153 | // MADR R0, R1, {0.5}.x, R0; 154 | 0x4001e00, 0x1c9dc804, 0x6, 0x1c800, 155 | // {0.5 , 0.0, 0.0, 0.0} 156 | 0x3f000000, 0x0, 0x0, 0x0, 157 | // MULX o[COLH], R0, f[COL0]; 158 | 0x2803e81, 0x1c9dc800, 0x1c801, 0x0 159 | } 160 | }; 161 | 162 | 163 | static realityFragmentProgram_internal nv30_fp_yuv = { 164 | .num_regs = 4, 165 | .size = (17*4), 166 | .data = { 167 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 168 | 0x3000200, 0x1c9dc800, 0x1c802, 0x0, 169 | 0xbd800000, 0x0, 0x0, 0x0, 170 | 0x3000602, 0x1c9dcc00, 0x2, 0x0, 171 | 0xbf000000, 0x0, 0x0, 0x0, 172 | 0x2000200, 0x1c9dc800, 0x1c802, 0x0, 173 | 0x3f94fdf4, 0x0, 0x0, 0x0, 174 | 0x4000400, 0x1c9c0004, 0x6, 0x0, 175 | 0x3f5020c5, 0x0, 0x0, 0x0, 176 | 0x84000804, 0x1c9caa04, 0x6, 0x0, 177 | 0x400126e9, 0x0, 0x0, 0x0, 178 | 0x84000404, 0x1c9dc804, 0x6, 0x1c800, 179 | 0x3ec83127, 0x0, 0x0, 0x0, 180 | 0x84000204, 0x1c9dc804, 0x1c806, 0x1c800, 181 | 0x3fcc49ba, 0x0, 0x0, 0x0, 182 | 0x1800e80, 0x1c9dc808, 0x0, 0x0, 183 | 0x1801081, 0x1c9dc800, 0x0, 0x0 184 | } 185 | }; 186 | 187 | static realityFragmentProgram_internal nv30_fp_yuv8 = { 188 | .num_regs = 4, 189 | .size = (23*4), 190 | .data = { 191 | 0x17029e02, 0x1c9dc801, 0x0, 0x0, 192 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 193 | 0x3000402, 0x1c9c0000, 0x2, 0x0, 194 | 0xbd800000, 0x0, 0x0, 0x0, 195 | 0x17049e00, 0x1c9dc801, 0x0, 0x0, 196 | 0x2000400, 0x1c9dc804, 0x6, 0x0, 197 | 0x3f94fdf4, 0x0, 0x0, 0x0, 198 | 0x3000200, 0x1c9dc800, 0x1c802, 0x0, 199 | 0xbf000000, 0x0, 0x0, 0x0, 200 | 0x3000202, 0x1c9dc804, 0x1c806, 0x0, 201 | 0xbf000000, 0x0, 0x0, 0x0, 202 | 0x4000800, 0x1c9c0000, 0x2, 0xaa00, 203 | 0x3f5020c5, 0x0, 0x0, 0x0, 204 | 0x84000804, 0x1c9c0004, 0x6, 0xaa00, 205 | 0x400126e9, 0x0, 0x0, 0x0, 206 | 0x84000404, 0x1c9c0004, 0x6, 0x15400, 207 | 0x3ec83127, 0x0, 0x0, 0x0, 208 | 0x84000204, 0x1c9dc800, 0x1c802, 0xaa00, 209 | 0x3fcc49ba, 0x0, 0x0, 0x0, 210 | 0x1800e80, 0x1c9dc808, 0x0, 0x0, 211 | 0x1801080, 0x1c9dc800, 0x0, 0x0, 212 | 0x1801081, 0x1c9c0002, 0x0, 0x0, 213 | 0x3f800000, 0x0, 0x0, 0x0 214 | } 215 | }; 216 | 217 | static realityFragmentProgram_internal nv30_fp_yuv_color = { 218 | .num_regs = 3, 219 | .size = (18*4), 220 | .data = { 221 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 222 | 0x3000200, 0x1c9dc800, 0x1c802, 0x0, 223 | 0xbd800000, 0x0, 0x0, 0x0, 224 | 0x2000202, 0x1c9dc800, 0x1c802, 0x0, 225 | 0x3f94fdf4, 0x0, 0x0, 0x0, 226 | 0x3000600, 0x1c9dcc00, 0x2, 0x0, 227 | 0xbf000000, 0x0, 0x0, 0x0, 228 | 0x4000402, 0x1c9c0000, 0x2, 0x4, 229 | 0x3f5020c5, 0x0, 0x0, 0x0, 230 | 0x84000800, 0x1c9caa00, 0x2, 0x4, 231 | 0x400126e9, 0x0, 0x0, 0x0, 232 | 0x84000200, 0x1c9dc800, 0x1c802, 0x1c804, 233 | 0x3fcc49ba, 0x0, 0x0, 0x0, 234 | 0x84000400, 0x1c9dc800, 0x2, 0x1c804, 235 | 0x3ec83127, 0x0, 0x0, 0x0, 236 | 0x3002e02, 0x1c9dc805, 0x1c800, 0x0, 237 | 0x84002e80, 0x1c9dfe01, 0x1c804, 0x1c800, 238 | 0x1801081, 0x1c9dc800, 0x0, 0x0 239 | } 240 | }; 241 | 242 | static realityFragmentProgram_internal nv30_fp_yuv_color8 = { 243 | .num_regs = 3, 244 | .size = (23*4), 245 | .data = { 246 | 0x17049e02, 0x1c9dc801, 0x0, 0x0, 247 | 0x17009e00, 0x1c9dc801, 0x0, 0x0, 248 | 0x3000402, 0x1c9c0000, 0x2, 0x0, 249 | 0xbd800000, 0x0, 0x0, 0x0, 250 | 0x17029e00, 0x1c9dc801, 0x0, 0x0, 251 | 0x2000400, 0x1c9dc804, 0x6, 0x0, 252 | 0x3f94fdf4, 0x0, 0x0, 0x0, 253 | 0x3000202, 0x1c9dc804, 0x1c806, 0x0, 254 | 0xbf000000, 0x0, 0x0, 0x0, 255 | 0x3001000, 0x1c9c0000, 0x2, 0x0, 256 | 0xbf000000, 0x0, 0x0, 0x0, 257 | 0x4000402, 0x1c9c0004, 0x6, 0x1c800, 258 | 0x3f5020c5, 0x0, 0x0, 0x0, 259 | 0x84000200, 0x1c9dc804, 0x1c806, 0xaa00, 260 | 0x3fcc49ba, 0x0, 0x0, 0x0, 261 | 0x84000800, 0x1c9dfe00, 0x2, 0xaa00, 262 | 0x400126e9, 0x0, 0x0, 0x0, 263 | 0x84000400, 0x1c9dfe00, 0x2, 0x1c804, 264 | 0x3ec83127, 0x0, 0x0, 0x0, 265 | 0x3002e02, 0x1c9dc805, 0x1c800, 0x0, 266 | 0x84002e80, 0x1c9dfe01, 0x1c804, 0x1c800, 267 | 0x1801081, 0x1c9c0002, 0x0, 0x0, 268 | 0x3f800000, 0x0, 0x0, 0x0 269 | } 270 | }; 271 | 272 | #endif 273 | -------------------------------------------------------------------------------- /lib/source/realityVP.c: -------------------------------------------------------------------------------- 1 | #include "realityVP.h" 2 | #include "string.h" 3 | 4 | void *rsxtiny_VertexProgramGetUCode(rsxtiny_VertexProgram *vertexprogram) 5 | { 6 | unsigned char *ptr=(unsigned char *)vertexprogram; 7 | 8 | return (void*)(ptr+vertexprogram->UCodeOffset); 9 | } 10 | 11 | unsigned int rsxtiny_VertexProgramGetInputMask(rsxtiny_VertexProgram *vertexprogram) 12 | { 13 | return vertexprogram->InputMask; 14 | } 15 | 16 | unsigned int rsxtiny_VertexProgramGetOutputMask(rsxtiny_VertexProgram *vertexprogram) 17 | { 18 | return vertexprogram->OutputMask; 19 | } 20 | 21 | rsxtiny_VertexProgramAttribute *rsxtiny_VertexProgramGetAttributes(rsxtiny_VertexProgram *vertexprogram) 22 | { 23 | return (rsxtiny_VertexProgramAttribute*) (((unsigned char*)vertexprogram)+vertexprogram->AttributesOffset); 24 | } 25 | 26 | int rsxtiny_VertexProgramGetInputAttribute(rsxtiny_VertexProgram *vertexprogram,const char *name) 27 | { 28 | int i; 29 | rsxtiny_VertexProgramAttribute *attributes = rsxtiny_VertexProgramGetAttributes(vertexprogram); 30 | for(i=0;iNumAttributes;++i) 31 | { 32 | char *namePtr; 33 | if(attributes[i].NameOffset==0) 34 | continue; 35 | namePtr=((char*)vertexprogram)+attributes[i].NameOffset; 36 | if(strcasecmp(name,namePtr)==0) 37 | return attributes[i].Index; 38 | } 39 | 40 | return -1; 41 | } 42 | 43 | rsxtiny_VertexProgramConstant *rsxtiny_VertexProgramGetConstants(rsxtiny_VertexProgram *vertexprogram) 44 | { 45 | return (rsxtiny_VertexProgramConstant*) (((unsigned char*)vertexprogram)+vertexprogram->ConstantsOffset); 46 | } 47 | 48 | int rsxtiny_VertexProgramGetConstant(rsxtiny_VertexProgram *vertexprogram,const char *name) 49 | { 50 | int i; 51 | rsxtiny_VertexProgramConstant *constants = rsxtiny_VertexProgramGetConstants(vertexprogram); 52 | for(i=0;iNumConstants;++i) 53 | { 54 | char *namePtr; 55 | if(constants[i].NameOffset==0) 56 | continue; 57 | namePtr=((char*)vertexprogram)+constants[i].NameOffset; 58 | if(strcasecmp(name,namePtr)==0) 59 | return constants[i].Index; 60 | } 61 | 62 | return -1; 63 | } -------------------------------------------------------------------------------- /lib/source/realityVP.h: -------------------------------------------------------------------------------- 1 | #ifndef REALITYVP_H 2 | #define REALITYVP_H 3 | 4 | 5 | // libreality vertex program 6 | 7 | 8 | //Param types 9 | #define PARAM_FLOAT 0 10 | #define PARAM_FLOAT2 1 11 | #define PARAM_FLOAT3 2 12 | #define PARAM_FLOAT4 3 13 | 14 | 15 | #define PARAM_FLOAT4x4 4 16 | 17 | #pragma pack(push,1) 18 | //#pragma pack(1) 19 | typedef struct _VPAttribute 20 | { 21 | unsigned int NameOffset; 22 | unsigned int Index; 23 | } rsxtiny_VertexProgramAttribute; 24 | 25 | union _VPFloatUInt 26 | { 27 | unsigned int u; 28 | float f; 29 | }; 30 | 31 | typedef struct _VPConstant 32 | { 33 | unsigned int NameOffset; 34 | unsigned int Index; 35 | unsigned char Type; 36 | unsigned char Internal; //Is an internal constant? (unnamed but needs to be set) 37 | union _VPFloatUInt Values[4]; 38 | } rsxtiny_VertexProgramConstant; 39 | 40 | typedef struct _rsxtiny_VertexProgram 41 | { 42 | unsigned short Magic; //Magic text 'VP' 43 | unsigned short NumInsts; //Number of vertex program instructions 44 | unsigned int UCodeOffset; //Microcode offset (16 bytes per instruction) 45 | unsigned short NumConstants; //Number of named constants (parameters) 46 | unsigned short NumAttributes; //Number of named attributes (inputs) 47 | unsigned int ConstantsOffset; 48 | unsigned int AttributesOffset; 49 | unsigned int InputMask; //Used input attributes 50 | unsigned int OutputMask; //Used output registers 51 | 52 | //data (constants, attributes, ucode) 53 | } rsxtiny_VertexProgram; 54 | 55 | #pragma pack(pop) 56 | 57 | 58 | 59 | 60 | void *rsxtiny_VertexProgramGetUCode(rsxtiny_VertexProgram *vertexprogram); 61 | 62 | unsigned int rsxtiny_VertexProgramGetInputMask(rsxtiny_VertexProgram *vertexprogram); 63 | 64 | unsigned int rsxtiny_VertexProgramGetOutputMask(rsxtiny_VertexProgram *vertexprogram); 65 | 66 | rsxtiny_VertexProgramAttribute *rsxtiny_VertexProgramGetAttributes(rsxtiny_VertexProgram *vertexprogram); 67 | 68 | int rsxtiny_VertexProgramGetInputAttribute(rsxtiny_VertexProgram *vertexprogram,const char *name); 69 | 70 | rsxtiny_VertexProgramConstant *rsxtiny_VertexProgramGetConstants(rsxtiny_VertexProgram *vertexprogram); 71 | 72 | int rsxtiny_VertexProgramGetConstant(rsxtiny_VertexProgram *vertexprogram,const char *name); 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /lib/source/rsxtiny.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #ifdef OLD_TINY3D 4 | #include 5 | #include "rsx/gcm.h" 6 | #else 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | 13 | typedef struct{ 14 | u32 begin; 15 | u32 end; 16 | u32 current; 17 | u32 callback; 18 | } tiny_gcmContextData; 19 | 20 | extern int tinyerror_incallback; 21 | extern int tinycallback_flag; 22 | 23 | void tiny3d_alarm(int leds); 24 | 25 | /* rsxtiny_FlushBuffer: 26 | * Flushes the RSX Command buffer. 27 | */ 28 | void rsxtiny_FlushBuffer(tiny_gcmContextData *context); 29 | 30 | /* rsxtiny_Init: 31 | * Maps the memory at ioAddress into the RSX's memory space so the userspace thread 32 | * and the RSX can comunicate. 33 | * This shared memory must be 1mb aligned, and at least 1mb long. 34 | * Also Initilizes a RSX command buffer of cmdSize inside the shared memory. 35 | * 36 | * Returns a context structure that controls the current status of thecommand buffer. 37 | */ 38 | tiny_gcmContextData *rsxtiny_Init(const u32 cmdSize, const u32 ioSize, const void* ioAddress); 39 | 40 | s32 rsxtiny_AddressToOffset(void *ptr, u32 *offset); 41 | 42 | // RSX memory allocators 43 | void *rsxtiny_MemAlign(s32 alignment, s32 size); 44 | void *rsxtiny_Mem(s32 size); 45 | 46 | -------------------------------------------------------------------------------- /lib/source/rsxutil.c: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "commands.h" 8 | 9 | #include "rsxutil.h" 10 | 11 | 12 | tiny_gcmContextData *context; // Context to keep track of the RSX buffer. 13 | 14 | #ifdef OLD_TINY3D 15 | VideoResolution Video_Resolution; // Screen Resolution 16 | #else 17 | videoResolution Video_Resolution; // Screen Resolution 18 | #endif 19 | 20 | 21 | u32 *Video_buffer[2]; // The buffer we will be drawing into 22 | static u32 offset[2]; // The offset of the buffers in RSX memory 23 | 24 | static u32 *depth_buffer; // Depth buffer. 25 | static u32 depth_offset; 26 | 27 | int Video_pitch; 28 | static int depth_pitch; 29 | static u32 zformat; 30 | 31 | u8 Video_aspect; 32 | 33 | void *tiny_host_addr = NULL; 34 | extern int Video_currentBuffer; 35 | 36 | 37 | // Initilize and rsx 38 | void init_screen(int command_buffer, int z_method) { 39 | // Allocate a 1Mb buffer, alligned to a 1Mb boundary to be our shared IO memory with the RSX. 40 | 41 | if(!tiny_host_addr) { 42 | tiny_host_addr = memalign(1024*1024, command_buffer); 43 | // Initilise Reality, which sets up the command buffer and shared IO memory 44 | context = rsxtiny_Init(0x10000, command_buffer, tiny_host_addr); 45 | } 46 | 47 | 48 | 49 | if(z_method) zformat = REALITY_TARGET_FORMAT_ZETA_Z24S8; else zformat = REALITY_TARGET_FORMAT_ZETA_Z16; 50 | 51 | #ifdef OLD_TINY3D 52 | VideoState state; 53 | #else 54 | videoState state; 55 | #endif 56 | 57 | 58 | videoGetState(0, 0, &state); // Get the state of the display 59 | 60 | // Get the current resolution 61 | videoGetResolution(state.displayMode.resolution, &Video_Resolution); 62 | 63 | rsxtiny_MakeCmdSpace(context, 0x4000); 64 | 65 | Video_pitch = 4 * ((Video_Resolution.width + 15)/16) * 16; // each pixel is 4 bytes 66 | 67 | if(!z_method) 68 | // 16 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 69 | depth_pitch = 2 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+31)/32)*32) : 1920); 70 | else 71 | // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 72 | depth_pitch = 4 * ((Video_Resolution.width > 1920) ? (((Video_Resolution.width+15)/16)*16) : 1920); 73 | 74 | // Configure the buffer format to xRGB 75 | #ifdef OLD_TINY3D 76 | VideoConfiguration vconfig; 77 | memset(&vconfig, 0, sizeof(VideoConfiguration)); 78 | #else 79 | videoConfiguration vconfig; 80 | memset(&vconfig, 0, sizeof(videoConfiguration)); 81 | #endif 82 | 83 | vconfig.resolution = state.displayMode.resolution; 84 | vconfig.format = VIDEO_BUFFER_FORMAT_XRGB; 85 | vconfig.pitch = Video_pitch; 86 | 87 | Video_aspect=vconfig.aspect=state.displayMode.aspect; 88 | 89 | videoConfigure(0, &vconfig, NULL, 0); 90 | 91 | videoGetState(0, 0, &state); 92 | 93 | // trick to reinit the memory 94 | rsxtiny_MemAlign(-1, 0); 95 | 96 | s32 buffer_size = Video_pitch * Video_Resolution.height; 97 | s32 depth_buffer_size; 98 | 99 | if(!z_method) 100 | // 16 bit float. Note it uses 1088 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 101 | depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+31)/32)*32) : 1088); 102 | else { 103 | // 32 bit float. Note it uses 1920 as minimun because i thinking to use buffer Z with setupRenderTarget2() with one surface > screen 104 | depth_buffer_size = depth_pitch * ((Video_Resolution.height > 1088) ? (((Video_Resolution.height+15)/16)*16) : 1088); 105 | } 106 | gcmSetFlipMode(GCM_FLIP_VSYNC); // Wait for VSYNC to flip 107 | 108 | // Allocate two buffers for the RSX to draw to the screen (double buffering) 109 | Video_buffer[0] = rsxtiny_MemAlign(64, buffer_size); 110 | Video_buffer[1] = rsxtiny_MemAlign(64, buffer_size); 111 | 112 | depth_buffer = rsxtiny_MemAlign(64, depth_buffer_size); 113 | 114 | rsxtiny_AddressToOffset(Video_buffer[0], &offset[0]); 115 | rsxtiny_AddressToOffset(Video_buffer[1], &offset[1]); 116 | 117 | // Setup the display buffers 118 | gcmSetDisplayBuffer(0, offset[0], Video_pitch, Video_Resolution.width, Video_Resolution.height); 119 | gcmSetDisplayBuffer(1, offset[1], Video_pitch, Video_Resolution.width, Video_Resolution.height); 120 | 121 | rsxtiny_AddressToOffset(depth_buffer, &depth_offset); 122 | 123 | gcmResetFlipStatus(); 124 | flip(Video_currentBuffer ^ 1); 125 | 126 | } 127 | 128 | void waitFlip() { // Block the PPU thread untill the previous flip operation has finished. 129 | int n = 10000; 130 | while(n>0){ 131 | volatile int ret= gcmGetFlipStatus(); 132 | 133 | if(ret==0) break; 134 | if(ret<0) {tiny3d_alarm(4);return;} 135 | usleep(200); 136 | n--; 137 | } 138 | gcmResetFlipStatus(); 139 | 140 | if(n<=0) {tiny3d_alarm(5);return;} // fatal error 141 | } 142 | 143 | void flip(s32 buffer) { 144 | gcmSetFlip((gcmContextData *) context, buffer); 145 | rsxtiny_FlushBuffer(context); 146 | gcmSetWaitFlip((gcmContextData *) context); // Prevent the RSX from continuing until the flip has finished. 147 | } 148 | 149 | void setupRenderTarget(u32 currentBuffer) { 150 | // Set the color0 target to point at the offset of our current surface 151 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR0, REALITY_RSX_MEMORY, 152 | offset[currentBuffer], Video_pitch); 153 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR1, REALITY_RSX_MEMORY, 154 | 0, 64); 155 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR2, REALITY_RSX_MEMORY, 156 | 0, 64); 157 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR3, REALITY_RSX_MEMORY, 158 | 0, 64); 159 | 160 | // Setup depth buffer 161 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_ZETA, REALITY_RSX_MEMORY, 162 | depth_offset, depth_pitch); 163 | 164 | // Choose color0 as the render target and tell the rsx about the surface format. 165 | rsxtiny_SelectRenderTarget(context, REALITY_TARGET_0, 166 | REALITY_TARGET_FORMAT_COLOR_A8R8G8B8 | 167 | zformat | 168 | REALITY_TARGET_FORMAT_TYPE_LINEAR, 169 | Video_Resolution.width, Video_Resolution.height, 0, 0); 170 | } 171 | 172 | void setupRenderTarget2(u32 rsx_offset, u32 pitch, u32 width, u32 height, u32 format) { 173 | // Set the color0 target to point at the offset of our current surface 174 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR1, REALITY_RSX_MEMORY, 175 | rsx_offset, pitch); 176 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR0, REALITY_RSX_MEMORY, 177 | 0, 64); 178 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR2, REALITY_RSX_MEMORY, 179 | 0, 64); 180 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_COLOR3, REALITY_RSX_MEMORY, 181 | 0, 64); 182 | 183 | // Setup depth buffer 184 | rsxtiny_SetRenderSurface(context, REALITY_SURFACE_ZETA, REALITY_RSX_MEMORY, 185 | depth_offset, depth_pitch); 186 | 187 | // Choose color0 as the render target and tell the rsx about the surface format. 188 | rsxtiny_SelectRenderTarget(context, REALITY_TARGET_1, 189 | ((format) ? REALITY_TARGET_FORMAT_COLOR_A8R8G8B8 : REALITY_TARGET_FORMAT_COLOR_X1R5G5B5) | 190 | zformat | 191 | REALITY_TARGET_FORMAT_TYPE_LINEAR, 192 | width, height, 0, 0); 193 | } -------------------------------------------------------------------------------- /lib/source/rsxutil.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "rsxtiny.h" 4 | 5 | //extern u32 *buffer[2]; 6 | extern tiny_gcmContextData *context; 7 | 8 | #ifdef OLD_TINY3D 9 | extern VideoResolution Video_Resolution; 10 | #else 11 | extern videoResolution Video_Resolution; 12 | #endif 13 | 14 | // Initilize the screen and rsx 15 | void init_screen(int command_buffer, int z_method); 16 | 17 | // Block the PPU thread untill the previous flip operation has finished. 18 | void waitFlip(); 19 | 20 | void flip(s32 buffer); 21 | 22 | // Needs to be called each frame to map the buffers and setup render target 23 | void setupRenderTarget(u32 currentBuffer); 24 | 25 | // to render in one surface 26 | void setupRenderTarget2(u32 rsx_offset, u32 pitch, u32 width, u32 height, u32 format); 27 | -------------------------------------------------------------------------------- /lib/source/vshader_text_normal.vcg.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | extern const uint8_t vshader_text_normal_bin[0x00000e00]; 6 | -------------------------------------------------------------------------------- /libfont/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | 7 | ifeq ($(strip $(PSL1GHT)),) 8 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 9 | endif 10 | 11 | include $(PSL1GHT)/ppu_rules 12 | 13 | #--------------------------------------------------------------------------------- 14 | ifeq ($(strip $(PLATFORM)),) 15 | #--------------------------------------------------------------------------------- 16 | export BASEDIR := $(CURDIR) 17 | export DEPS := $(BASEDIR)/deps 18 | export LIBS := $(BASEDIR)/lib 19 | 20 | #--------------------------------------------------------------------------------- 21 | else 22 | #--------------------------------------------------------------------------------- 23 | 24 | export LIBDIR := $(LIBS)/$(PLATFORM) 25 | export DEPSDIR := $(DEPS)/$(PLATFORM) 26 | 27 | #--------------------------------------------------------------------------------- 28 | endif 29 | #--------------------------------------------------------------------------------- 30 | 31 | TARGET := libfont3d 32 | BUILD := build 33 | SOURCE := source 34 | INCLUDE := include 35 | DATA := data 36 | LIBS := 37 | 38 | MACHDEP := -DBIGENDIAN 39 | CFLAGS += -O2 -Wall -mcpu=cell $(MACHDEP) -fno-strict-aliasing $(INCLUDES) 40 | LD := ppu-ld 41 | 42 | ifneq ($(BUILD),$(notdir $(CURDIR))) 43 | 44 | export OUTPUT := $(CURDIR)/$(TARGET) 45 | export VPATH := $(foreach dir,$(SOURCE),$(CURDIR)/$(dir)) \ 46 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) 47 | export BUILDDIR := $(CURDIR)/$(BUILD) 48 | export DEPSDIR := $(BUILDDIR) 49 | 50 | CFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.c))) 51 | CXXFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.cpp))) 52 | SFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.S))) 53 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 54 | VCGFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vcg))) 55 | VSAFILES := $(foreach dir,$(SOURCE),$(notdir $(wildcard $(dir)/*.vsa))) 56 | 57 | 58 | export OFILES := $(CFILES:.c=.o) \ 59 | $(CXXFILES:.cpp=.o) \ 60 | $(SFILES:.S=.o) \ 61 | $(BINFILES:.bin=.bin.o) \ 62 | $(VCGFILES:.vcg=.vcg.o) \ 63 | $(VSAFILES:.vsa=.vsa.o) 64 | 65 | export BINFILES := $(BINFILES:.bin=.bin.h) 66 | export VCGFILES := $(VCGFILES:.vcg=.vcg.h) 67 | export VSAFILES := $(VSAFILES:.vsa=.vsa.h) 68 | 69 | export INCLUDES = $(foreach dir,$(INCLUDE),-I$(CURDIR)/$(dir)) \ 70 | -I$(CURDIR)/$(BUILD) -I$(PSL1GHT)/ppu/include -I$(PORTLIBS)/include 71 | 72 | .PHONY: $(BUILD) install clean shader 73 | 74 | $(BUILD): 75 | @[ -d $@ ] || mkdir -p $@ 76 | @make --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 77 | 78 | shader: 79 | @echo "[VPCOMP] $(notdir $<)" 80 | @$(VPCOMP) shader/vshader_text_normal.vcg shader/vshader_text_normal.rvp 81 | @$(RAW2H) shader/vshader_text_normal.rvp source/vshader_text_normal.vcg.h source/vshader_text_normal.vcg.S vshader_text_normal_bin 82 | 83 | install: $(BUILD) 84 | @echo Copying... 85 | @cp include/*.h $(PORTLIBS)/include 86 | @cp *.a $(PORTLIBS)/lib 87 | @echo Done! 88 | 89 | clean: 90 | @echo Clean... 91 | @rm -rf $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).a 92 | 93 | else 94 | 95 | DEPENDS := $(OFILES:.o=.d) 96 | 97 | $(OUTPUT).a: $(OFILES) 98 | $(OFILES): $(BINFILES) $(VCGFILES) $(VSAFILES) 99 | 100 | -include $(DEPENDS) 101 | 102 | endif 103 | -------------------------------------------------------------------------------- /libfont/include/libfont.h: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D - font library / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #ifndef LIBFONT_H 7 | #define LIBFONT_H 8 | 9 | #include 10 | 11 | #ifdef __cplusplus 12 | extern "C" { 13 | #endif 14 | 15 | /* NOTE: LIBFONT is thinkin to work with Tiny3D 2D mode: you need to call tiny3d_Project2D() before to work with draw functions */ 16 | 17 | // initialize all datas. After you call it you don't have any font to use 18 | 19 | void ResetFont(); 20 | 21 | // used as byte_order in AddFontFromBitmapArray() 22 | 23 | #define BIT0_FIRST_PIXEL 0 24 | #define BIT7_FIRST_PIXEL 1 25 | 26 | /* add one font from one bitmap array. You can define the font range with first_char and last_char (in my sample i use two fonts that starts 27 | at chr 32 and finish iat chr 255 and other font starts at 0 and finish at 254. fonts can have one depth of 1, 2, 4, 8 bits (used as pixel intensity) 28 | to create smooth fonts and you can select the byte order (some fonts can use bit 7 as first pixel or bit 0) . 29 | 30 | w and h must be 8, 16, 32, ..... 31 | 32 | It receive one RSX texture pointer and return the texture pointer increased and aligned to 16 bytes think to use this pointer to build the next 33 | RSX texture. 34 | */ 35 | 36 | u8 * AddFontFromBitmapArray(u8 *font, u8 *texture, u8 first_char, u8 last_char, int w, int h, int bits_per_pixel, int byte_order); 37 | 38 | /* 39 | add one bitmap font creating it from True Type Fonts. You can define the font range with first_char and last_char in the range 0 to 255 40 | w and h must be 8, 16, 32, ..... 41 | 42 | The callback is used to create the font externally (it don't need to use freetype library directly) 43 | 44 | It receive one RSX texture pointer and return the texture pointer increased and aligned to 16 bytes think to use this pointer to build the next 45 | RSX texture. 46 | */ 47 | 48 | u8 * AddFontFromTTF(u8 *texture, u8 first_char, u8 last_char, int w, int h, 49 | void (* ttf_callback) (u8 chr, u8 * bitmap, short *w, short *h, short *y_correction)); 50 | 51 | /* 52 | 53 | SetFontTextureMethod: enables/disables multitexture merge with font color. 54 | 55 | It needs an external texture loaded in unit 1 (tiny3d_SetTextureWrap(1, ...)) and tiny3d_SelMultiTexturesMethod() enabled 56 | 57 | */ 58 | 59 | #define FONT_SINGLE_TEXTURE 0 // default method 60 | #define FONT_DOUBLE_TEXTURE 1 // enable and maps external second texture char by char 61 | #define FONT_DOUBLE_TEXTURE2 2 // enable and maps external second texture using the screen coordinates rectangle 62 | #define FONT_DOUBLE_TEXTUREMOD 3 // enable and maps external second texture using the module of coordinates rectangle (fixed with SetDoubleTextureModule()) 63 | 64 | void SetFontTextureMethod(int method); 65 | 66 | // used with FONT_DOUBLE_TEXTUREMOD for double texture method: second texture coordinates is calculated using (virtual_screen % mod)/mod relation 67 | 68 | void SetDoubleTextureModule(int module_x, int module_y); 69 | 70 | /* function to select the current font to use (the first is 0. if you select an undefined font, it uses font 0) */ 71 | 72 | void SetCurrentFont(int nfont); 73 | 74 | // font are resizable: the minimun is 8 x 8 but you can use as you want. Remember the font quality depends of the original size 75 | 76 | void SetFontSize(int sx, int sy); 77 | 78 | // select the color and the background color for the font. if you use 0 for bkcolor background is not drawing 79 | 80 | void SetFontColor(u32 color, u32 bkcolor); 81 | 82 | // enable/disable the autocenter feature. don't use '\n' or unsupported characters here 83 | 84 | void SetFontAutoCenter(int on_off); 85 | 86 | // compatibility with old name 87 | #define SetFontAutocenter SetFontAutoCenter 88 | 89 | // enable the auto new line if width is different to 0. When one word exceed the width specified, it skip to the next line 90 | 91 | void SetFontAutoNewLine(int width); 92 | 93 | // Z used to draw the font. Usually is 0.0f 94 | 95 | void SetFontZ(float z); 96 | 97 | // last X used 98 | 99 | float GetFontX(); 100 | 101 | // last Y used 102 | 103 | float GetFontY(); 104 | 105 | // change the screen width/height limits (usually 848 x 512.0. It is used only for center function and one of multitexture modes) 106 | 107 | void SetFontScreenLimits(float width, float height); 108 | 109 | // function to draw one character 110 | 111 | void DrawChar(float x, float y, float z, u8 chr); 112 | 113 | // function to draw one string. It return X incremented 114 | 115 | float DrawString(float x, float y, char *str); 116 | 117 | // function to draw with fomat string similar to printf. It return X incremented 118 | 119 | float DrawFormatString(float x, float y, char *format, ...); 120 | 121 | #ifdef __cplusplus 122 | } 123 | #endif 124 | 125 | #endif -------------------------------------------------------------------------------- /samples/Makefile: -------------------------------------------------------------------------------- 1 | 2 | .PHONY: all pkg clean 3 | 4 | FTINCLUDE := $(PS3DEV)/portlibs/ppu/include/freetype2/freetype/freetype.h 5 | ZIPINCLUDE := $(PS3DEV)/portlibs/ppu/include/zip.h 6 | 7 | all: 8 | $(MAKE) -C fireworks3D 9 | $(MAKE) -C spheres3D 10 | $(MAKE) -C sprites2D 11 | $(MAKE) -C fonts 12 | $(MAKE) -C surfaces 13 | @if test -e $(FTINCLUDE); then $(MAKE) -C fonts_from_ttf; fi 14 | # @if test -e $(ZIPINCLUDE); then $(MAKE) -C ps3loadx; fi 15 | $(MAKE) -C yuv 16 | $(MAKE) -C tiny3d_lists 17 | $(MAKE) -C userviewport 18 | pkg: 19 | $(MAKE) pkg -C fireworks3D 20 | $(MAKE) pkg -C spheres3D 21 | $(MAKE) pkg -C sprites2D 22 | $(MAKE) pkg -C fonts 23 | $(MAKE) pkg -C surfaces 24 | @if test -e $(FTINCLUDE); then $(MAKE) pkg -C fonts_from_ttf; fi 25 | # @if test -e $(ZIPINCLUDE); then $(MAKE) pkg -C ps3loadx; fi 26 | $(MAKE) pkg -C yuv 27 | $(MAKE) pkg -C tiny3d_lists 28 | $(MAKE) pkg -C userviewport 29 | 30 | clean: 31 | $(MAKE) clean -C fireworks3D 32 | $(MAKE) clean -C spheres3D 33 | $(MAKE) clean -C sprites2D 34 | $(MAKE) clean -C fonts 35 | $(MAKE) clean -C surfaces 36 | @if test -e $(FTINCLUDE); then $(MAKE) clean -C fonts_from_ttf; fi 37 | # @if test -e $(ZIPINCLUDE); then $(MAKE) clean -C ps3loadx; fi 38 | $(MAKE) clean -C yuv 39 | $(MAKE) clean -C tiny3d_lists 40 | $(MAKE) clean -C userviewport 41 | 42 | 43 | -------------------------------------------------------------------------------- /samples/fireworks3D/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Sample1 - SOUNDLIB 14 | APPID := SNDS00001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data source/../../resources 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lsysmodule \ 40 | -laudioplayer -lmpg123 -logg -lspu_sound -laudio -lm -lspu_soundmodule 41 | 42 | 43 | #--------------------------------------------------------------------------------- 44 | # options for code generation 45 | #--------------------------------------------------------------------------------- 46 | 47 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 48 | CXXFLAGS = $(CFLAGS) 49 | 50 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 51 | 52 | 53 | #--------------------------------------------------------------------------------- 54 | # list of directories containing libraries, this must be the top level containing 55 | # include and lib 56 | #--------------------------------------------------------------------------------- 57 | LIBDIRS := 58 | 59 | #--------------------------------------------------------------------------------- 60 | # no real need to edit anything past this point unless you need to add additional 61 | # rules for different file extensions 62 | #--------------------------------------------------------------------------------- 63 | ifneq ($(BUILD),$(notdir $(CURDIR))) 64 | #--------------------------------------------------------------------------------- 65 | 66 | export OUTPUT := $(CURDIR)/$(TARGET) 67 | 68 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 70 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 71 | 72 | export DEPSDIR := $(CURDIR)/$(BUILD) 73 | 74 | export BUILDDIR := $(CURDIR)/$(BUILD) 75 | 76 | #--------------------------------------------------------------------------------- 77 | # automatically build a list of object files for our project 78 | #--------------------------------------------------------------------------------- 79 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 80 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 81 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 82 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 83 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 84 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 85 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 86 | 87 | VPOFILES := $(VCGFILES:.vcg=.vpo) 88 | FPOFILES := $(FCGFILES:.fcg=.fpo) 89 | 90 | #--------------------------------------------------------------------------------- 91 | # use CXX for linking C++ projects, CC for standard C 92 | #--------------------------------------------------------------------------------- 93 | ifeq ($(strip $(CPPFILES)),) 94 | export LD := $(CC) 95 | else 96 | export LD := $(CXX) 97 | endif 98 | 99 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 100 | $(addsuffix .o,$(VPOFILES)) \ 101 | $(addsuffix .o,$(FPOFILES)) \ 102 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 103 | $(sFILES:.s=.o) $(SFILES:.S=.o) 104 | 105 | #--------------------------------------------------------------------------------- 106 | # build a list of include paths 107 | #--------------------------------------------------------------------------------- 108 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 109 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 110 | $(LIBPSL1GHT_INC) -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include \ 111 | -I$(PORTLIBS)/modules -I$(PORTLIBS)/modules/include 112 | 113 | #--------------------------------------------------------------------------------- 114 | # build a list of library paths 115 | #--------------------------------------------------------------------------------- 116 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 117 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib -L$(PORTLIBS)/modules/lib 118 | 119 | export OUTPUT := $(CURDIR)/$(TARGET) 120 | .PHONY: $(BUILD) clean 121 | 122 | 123 | #--------------------------------------------------------------------------------- 124 | $(BUILD): 125 | @[ -d $@ ] || mkdir -p $@ 126 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 127 | 128 | #--------------------------------------------------------------------------------- 129 | clean: 130 | @echo clean ... 131 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).self $(OUTPUT).fake.self EBOOT.BIN 132 | 133 | #--------------------------------------------------------------------------------- 134 | run: 135 | ps3load $(OUTPUT).self 136 | 137 | #--------------------------------------------------------------------------------- 138 | pkg: $(BUILD) $(OUTPUT).pkg 139 | 140 | #--------------------------------------------------------------------------------- 141 | 142 | npdrm: $(BUILD) 143 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 144 | 145 | #--------------------------------------------------------------------------------- 146 | 147 | else 148 | 149 | DEPENDS := $(OFILES:.o=.d) 150 | 151 | #--------------------------------------------------------------------------------- 152 | # main targets 153 | #--------------------------------------------------------------------------------- 154 | $(OUTPUT).self: $(OUTPUT).elf 155 | $(OUTPUT).elf: $(OFILES) 156 | 157 | #--------------------------------------------------------------------------------- 158 | # This rule links in binary data with the .bin extension 159 | #--------------------------------------------------------------------------------- 160 | %.bin.o : %.bin 161 | #--------------------------------------------------------------------------------- 162 | @echo $(notdir $<) 163 | @$(bin2o) 164 | 165 | #--------------------------------------------------------------------------------- 166 | %.vpo.o : %.vpo 167 | #--------------------------------------------------------------------------------- 168 | @echo $(notdir $<) 169 | @$(bin2o) 170 | 171 | #--------------------------------------------------------------------------------- 172 | %.fpo.o : %.fpo 173 | #--------------------------------------------------------------------------------- 174 | @echo $(notdir $<) 175 | @$(bin2o) 176 | 177 | -include $(DEPENDS) 178 | 179 | #--------------------------------------------------------------------------------- 180 | endif 181 | #--------------------------------------------------------------------------------- 182 | -------------------------------------------------------------------------------- /samples/fireworks3D/about_this.txt: -------------------------------------------------------------------------------- 1 | 'fireworks3D' is a sound sample playing MP3 or OGG in the background and playing 8 voices from fireworks explosion. 2 | 3 | It also can play OGG/MP3 from one pendrive if you copy the OGG/MP3 files in the audio folder (it is played from /dev_usb/audio) 4 | 5 | NOTE: It uses Tiny3D to draw in the screen 6 | 7 | Controls: 8 | 9 | - Press CROSS to exit (this function is delayed some second from the sample starts) 10 | 11 | - Press CIRCLE to play one voice effect as you want 12 | 13 | - Press TRIANGLE to play one OGG/MP3 from /dev_usb/audio. If it fails, it play the internal MP3 14 | 15 | - Press SQUARE to pause the fireworks voices (OGG/MP3 is played with half volume and the rest of voices are mixed with it) 16 | 17 | - Press PS to exit. 18 | 19 | 'fireworks3D' decode ogg and mp3 from memory to memory to play audio effects. Voice 0 is used by audio player. Voices 8 to F is used by explosions. 20 | Voice 5 is used when you press CIRCLE. 21 | 22 | The voice map is displayed in the screen and OGG/MP3 time too (and filename w hen you play from USB) 23 | 24 | - Hermes - -------------------------------------------------------------------------------- /samples/fireworks3D/source/font.h: -------------------------------------------------------------------------------- 1 | #define size_font 28672 2 | 3 | extern unsigned char font[28672]; 4 | -------------------------------------------------------------------------------- /samples/fireworks3D/source/main.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/fireworks3D/source/main.c -------------------------------------------------------------------------------- /samples/fireworks3D/source/sincos.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/fireworks3D/source/sincos.c -------------------------------------------------------------------------------- /samples/fireworks3D/source/sincos.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/fireworks3D/source/sincos.h -------------------------------------------------------------------------------- /samples/fonts/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Fonts - Tiny3D 14 | APPID := FONTS0001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/fonts/source/font.h: -------------------------------------------------------------------------------- 1 | #define size_font 28672 2 | 3 | extern unsigned char font[28672]; 4 | -------------------------------------------------------------------------------- /samples/fonts/source/font_b.h: -------------------------------------------------------------------------------- 1 | #define size_font_b 28672 2 | 3 | extern unsigned char font_b[28672]; 4 | -------------------------------------------------------------------------------- /samples/fonts/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D sample / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | // font 0: 224 chr from 32 to 255, 16 x 32 pix 2 bit depth 19 | #include "font.h" 20 | 21 | // font 1: 224 chr from 32 to 255, 16 x 32 pix 2 bit depth 22 | #include "font_b.h" 23 | 24 | // font 2: 255 chr from 0 to 254, 8 x 8 pix 1 bit depth 25 | extern unsigned char msx[]; 26 | 27 | 28 | // draw one background color in virtual 2D coordinates 29 | 30 | void DrawBackground2D(u32 rgba) 31 | { 32 | tiny3d_SetPolygon(TINY3D_QUADS); 33 | 34 | tiny3d_VertexPos(0 , 0 , 65535); 35 | tiny3d_VertexColor(rgba); 36 | 37 | tiny3d_VertexPos(847, 0 , 65535); 38 | 39 | tiny3d_VertexPos(847, 511, 65535); 40 | 41 | tiny3d_VertexPos(0 , 511, 65535); 42 | tiny3d_End(); 43 | } 44 | 45 | void drawScene() 46 | { 47 | float x, y; 48 | tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) 49 | DrawBackground2D(0x0040ffff) ; // light blue 50 | 51 | SetFontSize(12, 24); 52 | 53 | x= 0.0; y = 0.0; 54 | 55 | SetCurrentFont(1); 56 | SetFontColor(0xffffffff, 0x0); 57 | x = DrawString(x,y, "Hello World!. My nick is "); 58 | SetFontColor(0x00ff00ff, 0x0); 59 | SetCurrentFont(0); 60 | x = DrawString(x,y, "Hermes "); 61 | SetCurrentFont(1); 62 | SetFontColor(0xffffffff, 0x0); 63 | x = DrawString(x,y, "and this is one sample working with\nfonts."); 64 | 65 | SetCurrentFont(2); 66 | 67 | x= 0; y += 64; 68 | SetCurrentFont(1); 69 | DrawString(x, y, "I am using 3 fonts:"); 70 | 71 | SetCurrentFont(0); 72 | y += 64; 73 | SetFontColor(0xffffffff, 0x00a000ff); 74 | DrawString(x, y, "Font 0 is one array of 224 chars 16 x 32 pix and 2 bit depth"); 75 | 76 | SetCurrentFont(1); 77 | y += 64; 78 | SetFontColor(0xffffffff, 0xa00000ff); 79 | DrawString(x, y, "Font 1 is one array of 224 chars 16 x 32 pix and 2 bit depth"); 80 | 81 | SetCurrentFont(2); 82 | y += 64; 83 | SetFontColor(0x000000ff, 0xffff00ff); 84 | DrawString(x, y, "Font 2 is one array of 255 chars 8 x 8 pix and 1 bit depth"); 85 | 86 | y += 64; 87 | SetCurrentFont(1); 88 | SetFontSize(32, 64); 89 | SetFontColor(0xffffffff, 0x000000ff); 90 | SetFontAutoCenter(1); 91 | DrawString(0, y, "You can resize letters"); 92 | SetFontAutoCenter(0); 93 | 94 | SetFontSize(12, 24); 95 | SetFontColor(0xffffffff, 0x00000000); 96 | y += 72; 97 | DrawString(0, y, "change the color, background color and center the text\nwith SetFontAutoCenter()"); 98 | y += 72; 99 | 100 | SetFontColor(0x00ff00ff, 0x00000000); 101 | DrawFormatString(0, y, "Here %s font 0 uses %i bytes as texture", "using DrawFormatString()", 224*(16*2/8)*32); 102 | 103 | } 104 | 105 | 106 | void LoadTexture() 107 | { 108 | 109 | u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) 110 | 111 | u32 * texture_pointer; // use to asign texture space without changes texture_mem 112 | 113 | if(!texture_mem) return; // fail! 114 | 115 | texture_pointer = texture_mem; 116 | 117 | ResetFont(); 118 | texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); 119 | texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font_b, (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); 120 | texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx , (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); 121 | 122 | // here you can add more textures using 'texture_pointer'. It is returned aligned to 16 bytes 123 | } 124 | 125 | 126 | 127 | s32 main(s32 argc, const char* argv[]) 128 | { 129 | padInfo padinfo; 130 | padData paddata; 131 | int i; 132 | 133 | tiny3d_Init(1024*1024); 134 | 135 | ioPadInit(7); 136 | 137 | // Load texture 138 | 139 | LoadTexture(); 140 | 141 | 142 | // Ok, everything is setup. Now for the main loop. 143 | while(1) { 144 | 145 | /* DRAWING STARTS HERE */ 146 | 147 | // clear the screen, buffer Z and initializes environment to 2D 148 | 149 | tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); 150 | 151 | // Enable alpha Test 152 | tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); 153 | 154 | // Enable alpha blending. 155 | tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 156 | TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO, 157 | TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); 158 | 159 | 160 | // Check the pads. 161 | ioPadGetInfo(&padinfo); 162 | 163 | for(i = 0; i < MAX_PADS; i++){ 164 | 165 | if(padinfo.status[i]){ 166 | ioPadGetData(i, &paddata); 167 | 168 | if(paddata.BTN_CROSS){ 169 | return 0; 170 | } 171 | } 172 | 173 | } 174 | 175 | drawScene(); // Draw 176 | 177 | /* DRAWING FINISH HERE */ 178 | 179 | tiny3d_Flip(); 180 | 181 | } 182 | 183 | return 0; 184 | } 185 | 186 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Fonts TTF - Tiny3D 14 | APPID := FONTSTTF1 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -lfreetype -lpng -ltiny3d -lrsx -lz -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include -I$(PORTLIBS)/include/freetype2 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/README.txt: -------------------------------------------------------------------------------- 1 | NOTE: fonts_from_ttf requires Oopo ps3libraries libz and freetype. You can download 2 | 3 | from here: http://mods.elotrolado.net/~hermes/ps3/ps3dev/ppu_oopo-ps3libraries.rar 4 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/data/andika_ttf.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/fonts_from_ttf/data/andika_ttf.bin -------------------------------------------------------------------------------- /samples/fonts_from_ttf/data/dejavusans_ttf.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/fonts_from_ttf/data/dejavusans_ttf.bin -------------------------------------------------------------------------------- /samples/fonts_from_ttf/licenses/andika_OFL.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2008, SIL International (http://scripts.sil.org), 2 | with Reserved Font Names 'Andika' and 'SIL'. 3 | 4 | This Font Software is licensed under the SIL Open Font License, Version 1.1. 5 | This license is copied below, and is also available with a FAQ at: 6 | http://scripts.sil.org/OFL 7 | 8 | 9 | ----------------------------------------------------------- 10 | SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 11 | ----------------------------------------------------------- 12 | 13 | PREAMBLE 14 | The goals of the Open Font License (OFL) are to stimulate worldwide 15 | development of collaborative font projects, to support the font creation 16 | efforts of academic and linguistic communities, and to provide a free and 17 | open framework in which fonts may be shared and improved in partnership 18 | with others. 19 | 20 | The OFL allows the licensed fonts to be used, studied, modified and 21 | redistributed freely as long as they are not sold by themselves. The 22 | fonts, including any derivative works, can be bundled, embedded, 23 | redistributed and/or sold with any software provided that any reserved 24 | names are not used by derivative works. The fonts and derivatives, 25 | however, cannot be released under any other type of license. The 26 | requirement for fonts to remain under this license does not apply 27 | to any document created using the fonts or their derivatives. 28 | 29 | DEFINITIONS 30 | "Font Software" refers to the set of files released by the Copyright 31 | Holder(s) under this license and clearly marked as such. This may 32 | include source files, build scripts and documentation. 33 | 34 | "Reserved Font Name" refers to any names specified as such after the 35 | copyright statement(s). 36 | 37 | "Original Version" refers to the collection of Font Software components as 38 | distributed by the Copyright Holder(s). 39 | 40 | "Modified Version" refers to any derivative made by adding to, deleting, 41 | or substituting -- in part or in whole -- any of the components of the 42 | Original Version, by changing formats or by porting the Font Software to a 43 | new environment. 44 | 45 | "Author" refers to any designer, engineer, programmer, technical 46 | writer or other person who contributed to the Font Software. 47 | 48 | PERMISSION & CONDITIONS 49 | Permission is hereby granted, free of charge, to any person obtaining 50 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 51 | redistribute, and sell modified and unmodified copies of the Font 52 | Software, subject to the following conditions: 53 | 54 | 1) Neither the Font Software nor any of its individual components, 55 | in Original or Modified Versions, may be sold by itself. 56 | 57 | 2) Original or Modified Versions of the Font Software may be bundled, 58 | redistributed and/or sold with any software, provided that each copy 59 | contains the above copyright notice and this license. These can be 60 | included either as stand-alone text files, human-readable headers or 61 | in the appropriate machine-readable metadata fields within text or 62 | binary files as long as those fields can be easily viewed by the user. 63 | 64 | 3) No Modified Version of the Font Software may use the Reserved Font 65 | Name(s) unless explicit written permission is granted by the corresponding 66 | Copyright Holder. This restriction only applies to the primary font name as 67 | presented to the users. 68 | 69 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 70 | Software shall not be used to promote, endorse or advertise any 71 | Modified Version, except to acknowledge the contribution(s) of the 72 | Copyright Holder(s) and the Author(s) or with their explicit written 73 | permission. 74 | 75 | 5) The Font Software, modified or unmodified, in part or in whole, 76 | must be distributed entirely under this license, and must not be 77 | distributed under any other license. The requirement for fonts to 78 | remain under this license does not apply to any document created 79 | using the Font Software. 80 | 81 | TERMINATION 82 | This license becomes null and void if any of the above conditions are 83 | not met. 84 | 85 | DISCLAIMER 86 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 87 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 88 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 89 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 90 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 91 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 92 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 93 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 94 | OTHER DEALINGS IN THE FONT SOFTWARE. 95 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/licenses/andika_README.txt: -------------------------------------------------------------------------------- 1 | README - Andika Basic Regular Release 1.0 2 May 2008 2 | =========================================================== 3 | 4 | Thank you for your interest in Andika ("Write!" in Swahili), a Unicode-compliant sans serif font designed by SIL International primarily for literacy use. 5 | 6 | See FONTLOG.txt for detailed information on the rationale for Andika, as well as a complete list of supported characters. 7 | 8 | See AndikaBasicR-FAQ-KI.txt for frequently-asked questions and known issues. 9 | 10 | See OFL.txt for the complete text of the SIL Open Font License. See OFL-FAQ.txt for frequently-asked questions about the SIL Open Font License. 11 | 12 | There is one TrueType (.ttf) font file included: 13 | AndBasR.ttf 14 | 15 | 16 | INSTALLATION 17 | ============= 18 | In Windows XP: 19 | -->Right click on Start icon in Taskbar, choose Explore, navigate to downloaded font file (AndBasR.ttf; wherever you unzipped it to). On Folders side of window, go to Local Disk (C:)/Windows/, and drag font files into Fonts folder. 20 | 21 | 22 | CONTACT 23 | ======== 24 | For more information please visit the Andika page on SIL International's Computers and Writing Systems website at http://scripts.sil.org/Andika. Or send an e-mail to . -------------------------------------------------------------------------------- /samples/fonts_from_ttf/licenses/dejavu-AUTHORS: -------------------------------------------------------------------------------- 1 | abysta at yandex.ru 2 | Adrian Schroeter 3 | Andrey Valentinovich Panov 4 | Ben Laenen 5 | Besarion Gugushvili 6 | Bhikkhu Pesala 7 | Clayborne Arevalo 8 | Dafydd Harries 9 | Danilo Segan 10 | Davide Viti 11 | David Jez 12 | David Lawrence Ramsey 13 | Denis Jacquerye 14 | Dwayne Bailey 15 | Eugeniy Meshcheryakov 16 | Gee Fung Sit 17 | Heikki Lindroos 18 | James Cloos 19 | James Crippen 20 | John Karp 21 | Keenan Pepper 22 | Lars Naesbye Christensen 23 | Mashrab Kuvatov 24 | Max Berger 25 | Mederic Boquien 26 | Michael Everson 27 | MihailJP 28 | Misu Moldovan 29 | Nguyen Thai Ngoc Duy 30 | Nicolas Mailhot 31 | Ognyan Kulev 32 | Ondrej Koala Vacha 33 | Peter Cernak 34 | Remy Oudompheng 35 | Roozbeh Pournader 36 | Sahak Petrosyan 37 | Sander Vesik 38 | Stepan Roh 39 | Stephen Hartke 40 | Steve Tinney 41 | Tavmjong Bah 42 | Thomas Henlich 43 | Tim May 44 | Valentin Stoykov 45 | Vasek Stodulka 46 | Wesley Transue 47 | 48 | $Id: AUTHORS 2404 2010-07-30 17:13:05Z noct_dreamer $ 49 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/licenses/dejavu-LICENSE: -------------------------------------------------------------------------------- 1 | Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. 2 | Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) 3 | 4 | Bitstream Vera Fonts Copyright 5 | ------------------------------ 6 | 7 | Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is 8 | a trademark of Bitstream, Inc. 9 | 10 | Permission is hereby granted, free of charge, to any person obtaining a copy 11 | of the fonts accompanying this license ("Fonts") and associated 12 | documentation files (the "Font Software"), to reproduce and distribute the 13 | Font Software, including without limitation the rights to use, copy, merge, 14 | publish, distribute, and/or sell copies of the Font Software, and to permit 15 | persons to whom the Font Software is furnished to do so, subject to the 16 | following conditions: 17 | 18 | The above copyright and trademark notices and this permission notice shall 19 | be included in all copies of one or more of the Font Software typefaces. 20 | 21 | The Font Software may be modified, altered, or added to, and in particular 22 | the designs of glyphs or characters in the Fonts may be modified and 23 | additional glyphs or characters may be added to the Fonts, only if the fonts 24 | are renamed to names not containing either the words "Bitstream" or the word 25 | "Vera". 26 | 27 | This License becomes null and void to the extent applicable to Fonts or Font 28 | Software that has been modified and is distributed under the "Bitstream 29 | Vera" names. 30 | 31 | The Font Software may be sold as part of a larger software package but no 32 | copy of one or more of the Font Software typefaces may be sold by itself. 33 | 34 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 35 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, 36 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, 37 | TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME 38 | FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING 39 | ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, 40 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF 41 | THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE 42 | FONT SOFTWARE. 43 | 44 | Except as contained in this notice, the names of Gnome, the Gnome 45 | Foundation, and Bitstream Inc., shall not be used in advertising or 46 | otherwise to promote the sale, use or other dealings in this Font Software 47 | without prior written authorization from the Gnome Foundation or Bitstream 48 | Inc., respectively. For further information, contact: fonts at gnome dot 49 | org. 50 | 51 | Arev Fonts Copyright 52 | ------------------------------ 53 | 54 | Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. 55 | 56 | Permission is hereby granted, free of charge, to any person obtaining 57 | a copy of the fonts accompanying this license ("Fonts") and 58 | associated documentation files (the "Font Software"), to reproduce 59 | and distribute the modifications to the Bitstream Vera Font Software, 60 | including without limitation the rights to use, copy, merge, publish, 61 | distribute, and/or sell copies of the Font Software, and to permit 62 | persons to whom the Font Software is furnished to do so, subject to 63 | the following conditions: 64 | 65 | The above copyright and trademark notices and this permission notice 66 | shall be included in all copies of one or more of the Font Software 67 | typefaces. 68 | 69 | The Font Software may be modified, altered, or added to, and in 70 | particular the designs of glyphs or characters in the Fonts may be 71 | modified and additional glyphs or characters may be added to the 72 | Fonts, only if the fonts are renamed to names not containing either 73 | the words "Tavmjong Bah" or the word "Arev". 74 | 75 | This License becomes null and void to the extent applicable to Fonts 76 | or Font Software that has been modified and is distributed under the 77 | "Tavmjong Bah Arev" names. 78 | 79 | The Font Software may be sold as part of a larger software package but 80 | no copy of one or more of the Font Software typefaces may be sold by 81 | itself. 82 | 83 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 84 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 85 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 86 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL 87 | TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 88 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 89 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 90 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 91 | OTHER DEALINGS IN THE FONT SOFTWARE. 92 | 93 | Except as contained in this notice, the name of Tavmjong Bah shall not 94 | be used in advertising or otherwise to promote the sale, use or other 95 | dealings in this Font Software without prior written authorization 96 | from Tavmjong Bah. For further information, contact: tavmjong @ free 97 | . fr. 98 | 99 | $Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $ 100 | -------------------------------------------------------------------------------- /samples/fonts_from_ttf/licenses/dejavu_README: -------------------------------------------------------------------------------- 1 | DejaVu fonts 2.32 (c)2004-2010 DejaVu fonts team 2 | ------------------------------------------------ 3 | 4 | The DejaVu fonts are a font family based on the Bitstream Vera Fonts 5 | (http://gnome.org/fonts/). Its purpose is to provide a wider range of 6 | characters (see status.txt for more information) while maintaining the 7 | original look and feel. 8 | 9 | DejaVu fonts are based on Bitstream Vera fonts version 1.10. 10 | 11 | Available fonts (Sans = sans serif, Mono = monospaced): 12 | 13 | DejaVu Sans Mono 14 | DejaVu Sans Mono Bold 15 | DejaVu Sans Mono Bold Oblique 16 | DejaVu Sans Mono Oblique 17 | DejaVu Sans 18 | DejaVu Sans Bold 19 | DejaVu Sans Bold Oblique 20 | DejaVu Sans Oblique 21 | DejaVu Sans ExtraLight (experimental) 22 | DejaVu Serif 23 | DejaVu Serif Bold 24 | DejaVu Serif Bold Italic (experimental) 25 | DejaVu Serif Italic (experimental) 26 | DejaVu Sans Condensed (experimental) 27 | DejaVu Sans Condensed Bold (experimental) 28 | DejaVu Sans Condensed Bold Oblique (experimental) 29 | DejaVu Sans Condensed Oblique (experimental) 30 | DejaVu Serif Condensed (experimental) 31 | DejaVu Serif Condensed Bold (experimental) 32 | DejaVu Serif Condensed Bold Italic (experimental) 33 | DejaVu Serif Condensed Italic (experimental) 34 | 35 | All fonts are also available as derivative called DejaVu LGC with support 36 | only for Latin, Greek and Cyrillic scripts. 37 | 38 | For license information see LICENSE. What's new is described in NEWS. Known 39 | bugs are in BUGS. All authors are mentioned in AUTHORS. 40 | 41 | Fonts are published in source form as SFD files (Spline Font Database from 42 | FontForge - http://fontforge.sf.net/) and in compiled form as TTF files 43 | (TrueType fonts). 44 | 45 | For more information go to http://dejavu.sourceforge.net/. 46 | 47 | Characters from Arev fonts, Copyright (c) 2006 by Tavmjong Bah: 48 | --------------------------- 49 | U+01BA, U+01BF, U+01F7, U+021C-U+021D, U+0220, U+0222-U+0223, 50 | U+02B9, U+02BA, U+02BD, U+02C2-U+02C5, U+02d4-U+02D5, 51 | U+02D7, U+02EC-U+02EE, U+0346-U+034E, U+0360, U+0362, 52 | U+03E2-03EF, U+0460-0463, U+0466-U+0486, U+0488-U+0489, U+04A8-U+04A9, 53 | U+0500-U+050F, U+2055-205E, U+20B0, U+20B2-U+20B3, U+2102, U+210D, U+210F, 54 | U+2111, U+2113, U+2115, U+2118-U+211A, U+211C-U+211D, U+2124, U+2135, 55 | U+213C-U+2140, U+2295-U+2298, U+2308-U+230B, U+26A2-U+26B1, U+2701-U+2704, 56 | U+2706-U+2709, U+270C-U+274B, U+2758-U+275A, U+2761-U+2775, U+2780-U+2794, 57 | U+2798-U+27AF, U+27B1-U+27BE, U+FB05-U+FB06 58 | 59 | $Id: README 2423 2010-08-22 15:48:31Z moyogo $ 60 | -------------------------------------------------------------------------------- /samples/ps3loadx/ICON0.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/ps3loadx/ICON0.PNG -------------------------------------------------------------------------------- /samples/ps3loadx/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := PS3loadX 14 | APPID := PSL145310 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | SFOXML := package.xml 17 | ICON0 := ICON0.PNG 18 | 19 | include $(PSL1GHT)/ppu_rules 20 | 21 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 22 | SCETOOL_FLAGS += 23 | 24 | #--------------------------------------------------------------------------------- 25 | # TARGET is the name of the output 26 | # BUILD is the directory where object files & intermediate files will be placed 27 | # SOURCES is a list of directories containing source code 28 | # INCLUDES is a list of directories containing extra header files 29 | #--------------------------------------------------------------------------------- 30 | TARGET := $(notdir $(CURDIR)) 31 | BUILD := build 32 | SOURCES := source 33 | DATA := data 34 | SHADERS := shaders 35 | INCLUDES := include 36 | 37 | 38 | #--------------------------------------------------------------------------------- 39 | # any extra libraries we wish to link with the project 40 | #--------------------------------------------------------------------------------- 41 | LIBS := -lzip -lz -lfont3d -ltiny3d -lgcm_sys -lsysutil -lio -lm -lpngdec -ljpgdec -lnet -lsysmodule 42 | 43 | 44 | #--------------------------------------------------------------------------------- 45 | # options for code generation 46 | #--------------------------------------------------------------------------------- 47 | 48 | CFLAGS = -O2 -Wall -mcpu=cell -std=gnu99 $(MACHDEP) $(INCLUDE) 49 | CXXFLAGS = $(CFLAGS) 50 | 51 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 52 | 53 | 54 | #--------------------------------------------------------------------------------- 55 | # list of directories containing libraries, this must be the top level containing 56 | # include and lib 57 | #--------------------------------------------------------------------------------- 58 | LIBDIRS := 59 | 60 | #--------------------------------------------------------------------------------- 61 | # no real need to edit anything past this point unless you need to add additional 62 | # rules for different file extensions 63 | #--------------------------------------------------------------------------------- 64 | ifneq ($(BUILD),$(notdir $(CURDIR))) 65 | #--------------------------------------------------------------------------------- 66 | 67 | export OUTPUT := $(CURDIR)/$(TARGET) 68 | 69 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 70 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 71 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 72 | 73 | export DEPSDIR := $(CURDIR)/$(BUILD) 74 | 75 | export BUILDDIR := $(CURDIR)/$(BUILD) 76 | 77 | #--------------------------------------------------------------------------------- 78 | # automatically build a list of object files for our project 79 | #--------------------------------------------------------------------------------- 80 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 81 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 82 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 83 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 84 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 85 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 86 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 87 | 88 | VPOFILES := $(VCGFILES:.vcg=.vpo) 89 | FPOFILES := $(FCGFILES:.fcg=.fpo) 90 | 91 | #--------------------------------------------------------------------------------- 92 | # use CXX for linking C++ projects, CC for standard C 93 | #--------------------------------------------------------------------------------- 94 | ifeq ($(strip $(CPPFILES)),) 95 | export LD := $(CC) 96 | else 97 | export LD := $(CXX) 98 | endif 99 | 100 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 101 | $(addsuffix .o,$(VPOFILES)) \ 102 | $(addsuffix .o,$(FPOFILES)) \ 103 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 104 | $(sFILES:.s=.o) $(SFILES:.S=.o) 105 | 106 | #--------------------------------------------------------------------------------- 107 | # build a list of include paths 108 | #--------------------------------------------------------------------------------- 109 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 110 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 111 | $(LIBPSL1GHT_INC) \ 112 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 113 | 114 | #--------------------------------------------------------------------------------- 115 | # build a list of library paths 116 | #--------------------------------------------------------------------------------- 117 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 118 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 119 | 120 | export OUTPUT := $(CURDIR)/$(TARGET) 121 | .PHONY: $(BUILD) clean 122 | 123 | 124 | #--------------------------------------------------------------------------------- 125 | $(BUILD): 126 | @[ -d $@ ] || mkdir -p $@ 127 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 128 | 129 | #--------------------------------------------------------------------------------- 130 | clean: 131 | @echo clean ... 132 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 133 | 134 | #--------------------------------------------------------------------------------- 135 | run: 136 | ps3load $(OUTPUT).self 137 | 138 | #--------------------------------------------------------------------------------- 139 | pkg: $(BUILD) $(OUTPUT).pkg 140 | 141 | #--------------------------------------------------------------------------------- 142 | 143 | npdrm: $(BUILD) 144 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 145 | 146 | #--------------------------------------------------------------------------------- 147 | 148 | else 149 | 150 | DEPENDS := $(OFILES:.o=.d) 151 | 152 | #--------------------------------------------------------------------------------- 153 | # main targets 154 | #--------------------------------------------------------------------------------- 155 | $(OUTPUT).self: $(OUTPUT).elf 156 | $(OUTPUT).elf: $(OFILES) 157 | 158 | #--------------------------------------------------------------------------------- 159 | # This rule links in binary data with the .bin extension 160 | #--------------------------------------------------------------------------------- 161 | %.bin.o : %.bin 162 | #--------------------------------------------------------------------------------- 163 | @echo $(notdir $<) 164 | @$(bin2o) 165 | 166 | #--------------------------------------------------------------------------------- 167 | %.vpo.o : %.vpo 168 | #--------------------------------------------------------------------------------- 169 | @echo $(notdir $<) 170 | @$(bin2o) 171 | 172 | #--------------------------------------------------------------------------------- 173 | %.fpo.o : %.fpo 174 | #--------------------------------------------------------------------------------- 175 | @echo $(notdir $<) 176 | @$(bin2o) 177 | 178 | -include $(DEPENDS) 179 | 180 | #--------------------------------------------------------------------------------- 181 | endif 182 | #--------------------------------------------------------------------------------- 183 | -------------------------------------------------------------------------------- /samples/ps3loadx/README.md: -------------------------------------------------------------------------------- 1 | # PS3loadX 2 | 3 | PS3loadX is my personal evolution of PSL1GHT PS3load sample, using now the Tiny3D library. I hope this version helps to you to work easily ;) 4 | 5 | ## Features 6 | - You can load SELF files using the net. 7 | - You can load applications from USB/ HDD devices 8 | - You can install applications to the USB or HDD devices from one .zip file 9 | - You can copy applications from USB devices to HDD 10 | - Also you can delete installed applications. 11 | 12 | NOTE: 13 | ----- 14 | 15 | You can include this lines in your app to return to the PS3LoadX application 16 | ```c 17 | #include 18 | ..... 19 | sysProcessExitSpawn2("/dev_hdd0/game/PSL145310/RELOAD.SELF", NULL, NULL, NULL, 0, 1001, SYS_PROCESS_SPAWN_STACK_SIZE_1M); 20 | ``` 21 | 22 | ZIP Format 23 | ---------- 24 | 25 | ``` 26 | app_folder 27 | | 28 | |---- EBOOT.BIN 29 | | 30 | |---- ICON0.PNG 31 | | 32 | |---- title.txt 33 | ``` 34 | 35 | `app_folder`: folder to install the app 36 | - in USB devices `/dev_usb000/homebrew/app_folder` 37 | - from HDD: `/dev_hdd0/game/PSL145310/homebrew/app_folder` 38 | 39 | `EBOOT.BIN`: SELF file 40 | 41 | `ICON0.PNG`: optional app. image 42 | 43 | `title.txt`: it countain one text line with the name app name. It it don't exist PS3LoadX uses `app_folder` as title. i.e: "My application - test 1" 44 | 45 | Sending SELF files from the net 46 | ------------------------------- 47 | 48 | You need send it from the PC using psloadx.exe (see PSL1GHT tools) 49 | 50 | For example from one .bat file under windows: 51 | ``` 52 | set PS3LOAD = tcp:192.168.2.12 // -> PS3 IP 53 | 54 | ps3load.exe *.self 55 | 56 | pause 57 | ``` 58 | 59 | Installing ZIP files 60 | -------------------- 61 | 62 | HDD0 is selected by default. To change to USB you need plug one device. 63 | 64 | When you send a ZIP file the app ask to you if you want really install it or not in the current device. 65 | 66 | Select one Application 67 | ---------------------- 68 | 69 | Use LEFT/RIGHT in digital pad 70 | 71 | Copying files from USB 72 | ---------------------- 73 | 74 | Press CIRCLE and select 'Yes' using digital pad 75 | 76 | Deleting Applications 77 | --------------------- 78 | 79 | Press SQUARE and select 'Yes' using digital pad 80 | 81 | Launch Applications 82 | ------------------- 83 | 84 | Press CROSS and select 'Yes' using digital pad 85 | 86 | Exiting from PS3LoadX 87 | --------------------- 88 | 89 | Press TRIANGLE to exit. 90 | 91 | Also you can force exit pressing 'PS' (if the network crashes use it) 92 | -------------------------------------------------------------------------------- /samples/ps3loadx/data/psl1ght_jpg.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/ps3loadx/data/psl1ght_jpg.bin -------------------------------------------------------------------------------- /samples/ps3loadx/package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 01.02 5 | 6 | 7 | 0 8 | 9 | 10 | 1 11 | 12 | 13 | CB 14 | 15 | 16 | This application was created with the official non-official SDK called PSL1GHT, for more information visit http://www.psl1ght.com/ . This is in no way associated with Sony Computer Entertainment Inc., please do not contact them for help, they will not be able to provide it. 17 | 18 | 19 | 0 20 | 21 | 22 | 01.8000 23 | 24 | 25 | 63 26 | 27 | 28 | 279 29 | 30 | 31 | PS3LoadX 32 | 33 | 34 | PSL145310 35 | 36 | 37 | 01.02 38 | 39 | 40 | -------------------------------------------------------------------------------- /samples/ps3loadx/payload/RELOAD.SELF: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/ps3loadx/payload/RELOAD.SELF -------------------------------------------------------------------------------- /samples/ps3loadx/ps3loadx.cfw_hermes_3.41.pkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/ps3loadx/ps3loadx.cfw_hermes_3.41.pkg -------------------------------------------------------------------------------- /samples/ps3loadx/ps3loadx.pkg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/ps3loadx/ps3loadx.pkg -------------------------------------------------------------------------------- /samples/ps3loadx/source/font.h: -------------------------------------------------------------------------------- 1 | #define size_font 28672 2 | 3 | extern unsigned char font[28672]; 4 | -------------------------------------------------------------------------------- /samples/ps3loadx/source/gfx.c: -------------------------------------------------------------------------------- 1 | #include "gfx.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | jpgData jpg1; 9 | u32 jpg1_offset; 10 | 11 | u32 * texture_pointer; // use to asign texture space without changes texture_mem 12 | u32 * texture_pointer2; // use to asign texture for PNG 13 | 14 | pngData Png_datas[5]; 15 | u32 Png_offset[5]; 16 | 17 | void LoadTexture() 18 | { 19 | 20 | u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) 21 | 22 | 23 | if(!texture_mem) return; // fail! 24 | 25 | texture_pointer = texture_mem; 26 | 27 | ResetFont(); 28 | texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) font , (u8 *) texture_pointer, 32, 255, 16, 32, 2, BIT0_FIRST_PIXEL); 29 | 30 | // here you can add more textures using 'texture_pointer'. It is returned aligned to 16 bytes 31 | 32 | jpgLoadFromBuffer(psl1ght_jpg_bin, psl1ght_jpg_bin_size, &jpg1); 33 | 34 | jpg1_offset = 0; 35 | 36 | if(jpg1.bmp_out) { 37 | 38 | memcpy(texture_pointer, jpg1.bmp_out, jpg1.pitch * jpg1.height); 39 | 40 | free(jpg1.bmp_out); 41 | 42 | jpg1.bmp_out= texture_pointer; 43 | 44 | texture_pointer += (jpg1.pitch/4 * jpg1.height + 3) & ~3; // aligned to 16 bytes (it is u32) and update the pointer 45 | 46 | jpg1_offset = tiny3d_TextureOffset(jpg1.bmp_out); // get the offset (RSX use offset instead address) 47 | } 48 | } 49 | 50 | int LoadTexturePNG(char * filename, int index) 51 | { 52 | 53 | texture_pointer2 = texture_pointer + index * 1024 * 1024; // 4 MB reserved for PNG index 54 | 55 | // here you can add more textures using 'texture_pointer'. It is returned aligned to 16 bytes 56 | 57 | pngLoadFromFile(filename, &Png_datas[index]); 58 | 59 | Png_offset[index] = 0; 60 | 61 | if(Png_datas[index].bmp_out) { 62 | 63 | memcpy(texture_pointer2, Png_datas[index].bmp_out, Png_datas[index].pitch * Png_datas[index].height); 64 | 65 | free(Png_datas[index].bmp_out); 66 | 67 | Png_datas[index].bmp_out= texture_pointer2; 68 | 69 | Png_offset[index] = tiny3d_TextureOffset(Png_datas[index].bmp_out); // get the offset (RSX use offset instead address) 70 | 71 | return 0; 72 | } 73 | 74 | return -1; 75 | } 76 | 77 | void DrawBox(float x, float y, float z, float w, float h, u32 rgba) 78 | { 79 | tiny3d_SetPolygon(TINY3D_QUADS); 80 | 81 | tiny3d_VertexPos(x , y , z); 82 | tiny3d_VertexColor(rgba); 83 | 84 | tiny3d_VertexPos(x + w, y , z); 85 | 86 | tiny3d_VertexPos(x + w, y + h, z); 87 | 88 | tiny3d_VertexPos(x , y + h, z); 89 | 90 | tiny3d_End(); 91 | } 92 | 93 | void DrawTextBox(float x, float y, float z, float w, float h, u32 rgba) 94 | { 95 | tiny3d_SetPolygon(TINY3D_QUADS); 96 | 97 | 98 | tiny3d_VertexPos(x , y , z); 99 | tiny3d_VertexColor(rgba); 100 | tiny3d_VertexTexture(0.0f , 0.0f); 101 | 102 | tiny3d_VertexPos(x + w, y , z); 103 | tiny3d_VertexTexture(0.99f, 0.0f); 104 | 105 | tiny3d_VertexPos(x + w, y + h, z); 106 | tiny3d_VertexTexture(0.99f, 0.99f); 107 | 108 | tiny3d_VertexPos(x , y + h, z); 109 | tiny3d_VertexTexture(0.0f , 0.99f); 110 | 111 | tiny3d_End(); 112 | } 113 | 114 | struct { 115 | float x, y, dx, dy, r, rs; 116 | 117 | } m_twat[32]; 118 | 119 | void init_twat() 120 | { 121 | int i; 122 | 123 | for(i = 0; i < 32; i++) { 124 | m_twat[i].x = (rand() % 640) + 104; 125 | m_twat[i].y = (rand() % 300) + 106; 126 | 127 | m_twat[i].dx = ((float) ((int) (rand() & 7) - 3)) / 12.0f; 128 | m_twat[i].dy = ((float) ((int) (rand() & 7) - 3)) / 12.0f; 129 | m_twat[i].r = 0; 130 | m_twat[i].rs = ((float) ((int) (rand() & 7) - 3)) / 80.0f; 131 | } 132 | } 133 | 134 | void update_twat() 135 | { 136 | int i; 137 | 138 | for(i = 0; i < 32; i++) { 139 | 140 | if((rand() & 0x1ff) == 5) { 141 | m_twat[i].dx = ((float) ((int) (rand() & 7) - 3)) / 12.0f; 142 | m_twat[i].dy = ((float) ((int) (rand() & 7) - 3)) / 12.0f; 143 | m_twat[i].rs = ((float) ((int) (rand() & 7) - 3)) / 80.0f; 144 | 145 | } 146 | 147 | if(m_twat[i].dx == 0.0f && m_twat[i].dy == 0.0f) {m_twat[i].dy = 0.25f; m_twat[i].dx = (rand() & 1) ? 0.25f : -0.25f;} 148 | if(m_twat[i].rs == 0.0f) m_twat[i].rs = (rand() & 1) ? .001f : -0.001f; 149 | 150 | m_twat[i].x += m_twat[i].dx; 151 | m_twat[i].y += m_twat[i].dy; 152 | m_twat[i].r += m_twat[i].rs; 153 | 154 | if(i & 1) { 155 | if(m_twat[i].x < 0) { 156 | if(m_twat[i].dx < 0) m_twat[i].dx = -m_twat[i].dx; 157 | } 158 | 159 | if(m_twat[i].y < 0) { 160 | if(m_twat[i].dy < 0) m_twat[i].dy = -m_twat[i].dy; 161 | } 162 | 163 | if(m_twat[i].x >= 600) { 164 | if(m_twat[i].dx > 0) m_twat[i].dx = -m_twat[i].dx; 165 | } 166 | 167 | if(m_twat[i].y >= 480) { 168 | if(m_twat[i].dy > 0) m_twat[i].dy = -m_twat[i].dy; 169 | } 170 | } else { 171 | if(m_twat[i].x < 248) { 172 | if(m_twat[i].dx < 0) m_twat[i].dx = -m_twat[i].dx; 173 | } 174 | 175 | if(m_twat[i].y < 32) { 176 | if(m_twat[i].dy < 0) m_twat[i].dy = -m_twat[i].dy; 177 | } 178 | 179 | if(m_twat[i].x >= 848) { 180 | if(m_twat[i].dx > 0) m_twat[i].dx = -m_twat[i].dx; 181 | } 182 | 183 | if(m_twat[i].y >= 512) { 184 | if(m_twat[i].dy > 0) m_twat[i].dy = -m_twat[i].dy; 185 | } 186 | 187 | } 188 | 189 | draw_twat(m_twat[i].x, m_twat[i].y, m_twat[i].r); 190 | } 191 | 192 | } 193 | 194 | void draw_twat(float x, float y, float angle) 195 | { 196 | int n; 197 | 198 | float ang, angs = 6.2831853071796 / 8, angs2 = 6.2831853071796 / 32; 199 | 200 | MATRIX matrix; 201 | 202 | // rotate and translate the sprite 203 | matrix = MatrixRotationZ(angle); 204 | matrix = MatrixMultiply(matrix, MatrixTranslation(x , y , 65535.0f)); 205 | 206 | // fix ModelView Matrix 207 | tiny3d_SetMatrixModelView(&matrix); 208 | 209 | tiny3d_SetPolygon(TINY3D_TRIANGLES); 210 | 211 | ang = 0.0f; 212 | 213 | for(n = 0; n <8; n++) { 214 | 215 | tiny3d_VertexPos(4.0f *sinf(ang), 4.0f *cosf(ang), 0); 216 | tiny3d_VertexColor(0xffffff30); 217 | tiny3d_VertexPos(7.0f *sinf(ang+angs/2), 7.0f *cosf(ang+angs/2), 0); 218 | tiny3d_VertexColor(0xff00ff40); 219 | tiny3d_VertexPos(4.0f *sinf(ang+angs), 4.0f *cosf(ang+angs), 0); 220 | tiny3d_VertexColor(0xffffff30); 221 | 222 | ang += angs; 223 | } 224 | 225 | tiny3d_End(); 226 | 227 | tiny3d_SetPolygon(TINY3D_POLYGON); 228 | 229 | ang = 0.0f; 230 | 231 | for(n = 0; n <32; n++) { 232 | tiny3d_VertexPos(3.0f * sinf(ang), 3.0f * cosf(ang), 0); 233 | if(n & 1) tiny3d_VertexColor(0x80ffff40); else tiny3d_VertexColor(0xffffff40); 234 | ang += angs2; 235 | } 236 | 237 | tiny3d_End(); 238 | 239 | tiny3d_SetMatrixModelView(NULL); // set matrix identity 240 | 241 | } 242 | 243 | -------------------------------------------------------------------------------- /samples/ps3loadx/source/gfx.h: -------------------------------------------------------------------------------- 1 | #ifndef GFX_H 2 | #define GFX_H 3 | 4 | #include 5 | #include 6 | 7 | // font 0: 224 chr from 32 to 255, 16 x 32 pix 2 bit depth 8 | #include "font.h" 9 | 10 | 11 | #include 12 | #include 13 | #include "psl1ght_jpg_bin.h" // jpg in memory 14 | 15 | extern jpgData jpg1; 16 | extern u32 jpg1_offset; 17 | 18 | extern u32 * texture_pointer; // use to asign texture space without changes texture_mem 19 | extern u32 * texture_pointer2; // use to asign texture for PNG 20 | 21 | extern pngData Png_datas[5]; 22 | extern u32 Png_offset[5]; 23 | 24 | 25 | void LoadTexture(); 26 | int LoadTexturePNG(char * filename, int index); 27 | 28 | void DrawBox(float x, float y, float z, float w, float h, u32 rgba); 29 | void DrawTextBox(float x, float y, float z, float w, float h, u32 rgba); 30 | 31 | void init_twat(); 32 | void update_twat(); 33 | void draw_twat(float x, float y, float angle); 34 | 35 | 36 | #endif -------------------------------------------------------------------------------- /samples/ps3loadx/source/pad.c: -------------------------------------------------------------------------------- 1 | #include "pad.h" 2 | #include 3 | 4 | unsigned temp_pad = 0, new_pad = 0, old_pad = 0; 5 | 6 | padInfo padinfo; 7 | padData paddata; 8 | int pad_alive=0; 9 | 10 | 11 | int rumble1_on = 0; 12 | int rumble2_on = 0; 13 | int last_rumble = 0; 14 | 15 | 16 | unsigned ps3pad_read() 17 | { 18 | int n; 19 | 20 | padActParam actparam; 21 | 22 | unsigned butt = 0; 23 | 24 | pad_alive = 0; 25 | 26 | sysUtilCheckCallback(); 27 | 28 | ioPadGetInfo(&padinfo); 29 | 30 | for(n = 0; n < MAX_PADS; n++) { 31 | 32 | if(padinfo.status[n]) { 33 | 34 | ioPadGetData(n, &paddata); 35 | pad_alive = 1; 36 | butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff); 37 | break; 38 | 39 | } 40 | } 41 | 42 | 43 | if(!pad_alive) butt = 0; 44 | else { 45 | actparam.small_motor = 0; 46 | actparam.large_motor = 0; 47 | 48 | if(rumble1_on) { 49 | 50 | actparam.large_motor = 255; 51 | 52 | rumble1_on++; 53 | 54 | if(rumble1_on > 15) rumble1_on = 0; 55 | 56 | } 57 | 58 | if(rumble2_on) { 59 | 60 | actparam.small_motor = 1; 61 | 62 | rumble2_on++; 63 | 64 | if(rumble2_on > 10) rumble2_on = 0; 65 | } 66 | 67 | last_rumble = n; 68 | 69 | ioPadSetActDirect(n, &actparam); 70 | } 71 | 72 | temp_pad = butt; 73 | 74 | new_pad = temp_pad & (~old_pad); old_pad = temp_pad; 75 | 76 | 77 | return butt; 78 | } -------------------------------------------------------------------------------- /samples/ps3loadx/source/pad.h: -------------------------------------------------------------------------------- 1 | #ifndef PAD_H 2 | #define PAD_H 3 | 4 | #include 5 | 6 | #define BUTTON_LEFT 32768 7 | #define BUTTON_DOWN 16384 8 | #define BUTTON_RIGHT 8192 9 | #define BUTTON_UP 4096 10 | #define BUTTON_START 2048 11 | #define BUTTON_R3 1024 12 | #define BUTTON_L3 512 13 | #define BUTTON_SELECT 256 14 | 15 | #define BUTTON_SQUARE 128 16 | #define BUTTON_CROSS 64 17 | #define BUTTON_CIRCLE 32 18 | #define BUTTON_TRIANGLE 16 19 | #define BUTTON_R1 8 20 | #define BUTTON_L1 4 21 | #define BUTTON_R2 2 22 | #define BUTTON_L2 1 23 | 24 | extern padInfo padinfo; 25 | extern padData paddata; 26 | 27 | extern unsigned new_pad; // new pad buttons pressed (only can see one time, when it change from 0 to 1) 28 | extern unsigned old_pad; // old pad buttons pressed (only can change when you release the button) 29 | 30 | extern int pad_alive; // if 1 paddata is valid 31 | 32 | extern int rumble1_on; // used for rumble 33 | extern int rumble2_on; 34 | 35 | unsigned ps3pad_read(); // read the first conected pad 36 | 37 | #endif -------------------------------------------------------------------------------- /samples/resources/effect_mp3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/resources/effect_mp3.bin -------------------------------------------------------------------------------- /samples/resources/m2003_mp3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/resources/m2003_mp3.bin -------------------------------------------------------------------------------- /samples/resources/sound_ogg.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/resources/sound_ogg.bin -------------------------------------------------------------------------------- /samples/spheres3D/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Spheres 3D - Tiny3D 14 | APPID := SPHERES01 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lpngdec -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/spheres3D/data/texture1_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/spheres3D/data/texture1_png.bin -------------------------------------------------------------------------------- /samples/spheres3D/data/texture2_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/spheres3D/data/texture2_png.bin -------------------------------------------------------------------------------- /samples/spheres3D/source/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D sample / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #ifndef UTILS_H 7 | #define UTILS_H 8 | 9 | #include 10 | 11 | extern u32 font_offset; 12 | extern u32 font_w; 13 | extern u32 font_h; 14 | extern u32 font_s; 15 | 16 | void CreateSphere(float rx, float ry, int sx, int sy, float r, float g, float b, float a); 17 | 18 | void CreateSphereNormal(float rx, float ry, int sx, int sy); 19 | 20 | void CreateSphereNormalTextured(float rx, float ry, int sx, int sy); 21 | 22 | void CreateSphereNormalTextured2(float rx, float ry, int sx, int sy); 23 | 24 | void CreateSphereLine(float rx, float ry, int sx, int sy); 25 | 26 | void DrawCorners2d(float x, float y, float z, u32 rgba); 27 | 28 | void PrintChar(float x, float y, float z, u8 ch, u32 color); 29 | 30 | void PrintStr(float x, float y, float z, char *ch, u32 color); 31 | 32 | 33 | #endif 34 | 35 | -------------------------------------------------------------------------------- /samples/sprites2D/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Sprites 2D - Tiny3D 14 | APPID := SPRITES01 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lpngdec -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost1_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost1_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost2_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost2_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost3_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost3_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost4_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost4_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost5_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost5_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost6_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost6_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost7_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost7_png.bin -------------------------------------------------------------------------------- /samples/sprites2D/data/ghost8_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/sprites2D/data/ghost8_png.bin -------------------------------------------------------------------------------- /samples/surfaces/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Surfaces - Tiny3D 14 | APPID := SURFACES1 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/tiny3d_lists/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := Tiny3d_list - Tiny3D 14 | APPID := TINYLIST1 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/tiny3d_lists/source/utils.c: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D sample / (c) 2011 Hermes 3 | 4 | */ 5 | 6 | #include "utils.h" 7 | 8 | #include 9 | #include 10 | 11 | #define S_PI 3.14159265f 12 | #define D_PI 6.28318531f 13 | 14 | #define FLOAT(x) ((float) (x)) 15 | 16 | #define NORMALIZE(X,Y,Z) \ 17 | l=sqrtf(X*X + Y*Y + Z*Z); \ 18 | \ 19 | if(l == 0.0f) l = 1.0f; \ 20 | \ 21 | nx= X / l; ny= Y / l; nz = Z / l; 22 | 23 | 24 | void CreateSphereNormal(float rx, float ry, int sx, int sy/*, int textured*/) 25 | { 26 | int n, m, k; 27 | float x, y, z; 28 | float x2, y2, z2; 29 | 30 | VECTOR n1, n2; 31 | 32 | for(n = 0; n < sy; n++) { 33 | 34 | tiny3d_SetPolygon(TINY3D_QUAD_STRIP); 35 | 36 | for(k = 0;k <= sx; k++) { 37 | 38 | m = k % sx; 39 | 40 | x = x2 = rx * cosf(D_PI * FLOAT(m) / FLOAT(sx)); 41 | z= z2 = rx * sinf(D_PI * FLOAT(m) / FLOAT(sx)); 42 | 43 | x *= sinf(S_PI * FLOAT(n) / FLOAT(sy)); 44 | z *= sinf(S_PI * FLOAT(n) / FLOAT(sy)); 45 | x2 *= sinf(S_PI * FLOAT(n + 1) / FLOAT(sy)); 46 | z2 *= sinf(S_PI * FLOAT(n + 1) / FLOAT(sy)); 47 | 48 | y = ry * cosf(S_PI * FLOAT(n) / FLOAT(sy)); 49 | y2 = ry * cosf(S_PI * FLOAT(n + 1) / FLOAT(sy)); 50 | 51 | n1.x = x; 52 | n1.y = y; 53 | n1.z = z; 54 | 55 | n2.x = x2; 56 | n2.y = y2; 57 | n2.z = z2; 58 | 59 | n1 = VectorToUnit(n1); 60 | n2 = VectorToUnit(n2); 61 | //NORMALIZE(x, y, z); 62 | 63 | tiny3d_VertexPos(x, y, z); 64 | //f(textured) tiny3d_VertexTexture((float) k / sx, (float) (n) / sy); 65 | tiny3d_NormalVector(n1); 66 | 67 | //NORMALIZE(x2, y2, z2); 68 | 69 | tiny3d_VertexPos(x2, y2, z2); 70 | //if(textured) tiny3d_VertexTexture((float) k / sx, (float) (n+1) / sy); 71 | tiny3d_NormalVector(n2); 72 | 73 | } 74 | 75 | tiny3d_End(); 76 | 77 | } 78 | } 79 | 80 | void CreateCilinderNormal(float rx, float ry, int sx, int sy) 81 | { 82 | int n, m, k; 83 | float x, y, z; 84 | float x2, y2, z2; 85 | 86 | float nx, ny, nz, l; 87 | 88 | 89 | 90 | y = ry; 91 | y2 = -ry; 92 | 93 | 94 | tiny3d_SetPolygon(TINY3D_TRIANGLE_FAN); 95 | tiny3d_VertexPos(0.0f, y, 0.0f); 96 | tiny3d_Normal(0, 1, 0); 97 | 98 | for(k = 0;k <= sx; k++) { 99 | 100 | n = k % sx; 101 | 102 | 103 | x = rx * cosf(D_PI * FLOAT(n) / FLOAT(sx)); 104 | z = rx * sinf(D_PI * FLOAT(n) / FLOAT(sx)); 105 | 106 | tiny3d_VertexPos(x, y, z); 107 | 108 | } 109 | 110 | tiny3d_End(); 111 | 112 | for(n = 0; n < sy; n++) { 113 | 114 | tiny3d_SetPolygon(TINY3D_QUAD_STRIP); 115 | 116 | for(k = 0;k <= sx; k++) { 117 | 118 | m = k % sx; 119 | 120 | x = x2 = rx * cosf(D_PI * FLOAT(m) / FLOAT(sx)); 121 | z= z2 = rx * sinf(D_PI * FLOAT(m) / FLOAT(sx)); 122 | 123 | y = ry - 2.0f * ry * ( FLOAT(n) / FLOAT(sy)); 124 | y2 = ry - 2.0f * ry * ( FLOAT(n + 1) / FLOAT(sy)); 125 | 126 | NORMALIZE(x, y, z); 127 | 128 | tiny3d_VertexPos(x, y, z); 129 | tiny3d_Normal(nx, ny, nz); 130 | 131 | NORMALIZE(x2, y2, z2); 132 | 133 | tiny3d_VertexPos(x2, y2, z2); 134 | tiny3d_Normal(nx, ny, nz); 135 | 136 | } 137 | 138 | tiny3d_End(); 139 | 140 | } 141 | 142 | tiny3d_SetPolygon(TINY3D_TRIANGLE_FAN); 143 | tiny3d_VertexPos(0.0f, y2, 0.0f); 144 | tiny3d_Normal(0, -1, 0); 145 | 146 | for(k = 0;k <= sx; k++) { 147 | 148 | n = k % sx; 149 | 150 | 151 | x = rx * cosf(D_PI * FLOAT(n) / FLOAT(sx)); 152 | z = rx * sinf(D_PI * FLOAT(n) / FLOAT(sx)); 153 | 154 | tiny3d_VertexPos(x, y2, z); 155 | 156 | } 157 | 158 | tiny3d_End(); 159 | } 160 | 161 | 162 | 163 | void DrawCorners2d(float x, float y, float z, u32 rgba) 164 | { 165 | tiny3d_SetPolygon(TINY3D_QUADS); 166 | tiny3d_VertexPos(x, y, z); 167 | tiny3d_VertexColor(rgba); 168 | tiny3d_VertexPos(x+32.0, y, z); 169 | tiny3d_VertexPos(x+32.0, y+32.0, z); 170 | tiny3d_VertexPos(x, y+32.0, z); 171 | tiny3d_End(); 172 | } 173 | 174 | 175 | -------------------------------------------------------------------------------- /samples/tiny3d_lists/source/utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D sample / (c) 2011 Hermes 3 | 4 | */ 5 | 6 | #ifndef UTILS_H 7 | #define UTILS_H 8 | 9 | #include 10 | 11 | 12 | void CreateSphereNormal(float rx, float ry, int sx, int sy); 13 | 14 | void CreateCilinderNormal(float rx, float ry, int sx, int sy); 15 | 16 | void DrawCorners2d(float x, float y, float z, u32 rgba); 17 | 18 | 19 | #endif 20 | 21 | -------------------------------------------------------------------------------- /samples/userviewport/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := User Viewport - Tiny3D 14 | APPID := USERVIEW1 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/userviewport/source/main.c: -------------------------------------------------------------------------------- 1 | /* 2 | TINY3D sample / (c) 2010 Hermes 3 | 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | #include "pad.h" 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | // font 2: 255 chr from 0 to 254, 8 x 8 pix 1 bit depth 21 | extern unsigned char msx[]; 22 | 23 | // draw one background color in virtual 2D coordinates 24 | 25 | void DrawBackground2D(u32 rgba) 26 | { 27 | 28 | tiny3d_SetPolygon(TINY3D_QUADS); 29 | 30 | tiny3d_VertexPos(0 , 0 , 65535); 31 | tiny3d_VertexColor(rgba); 32 | 33 | tiny3d_VertexPos(847, 0 , 65535); 34 | 35 | tiny3d_VertexPos(847, 511, 65535); 36 | 37 | tiny3d_VertexPos(0 , 511, 65535); 38 | tiny3d_End(); 39 | 40 | tiny3d_SetPolygon(TINY3D_LINE_LOOP); 41 | 42 | tiny3d_VertexPos(0 , 0 , 65535); 43 | tiny3d_VertexColor(0xffffffff); 44 | 45 | tiny3d_VertexPos(847, 0 , 65535); 46 | 47 | tiny3d_VertexPos(847, 511, 65535); 48 | 49 | tiny3d_VertexPos(0 , 511, 65535); 50 | tiny3d_End(); 51 | } 52 | 53 | 54 | /* 55 | void DrawBackground3D(u32 rgba) 56 | { 57 | tiny3d_SetPolygon(TINY3D_LINE_LOOP); 58 | 59 | tiny3d_VertexPos(-960 , -540 , 0); 60 | tiny3d_VertexColor(rgba); 61 | 62 | tiny3d_VertexPos(960, -540 , 0); 63 | 64 | tiny3d_VertexPos(960, 540, 0); 65 | 66 | tiny3d_VertexPos(-960 , 540, 0); 67 | tiny3d_End(); 68 | } 69 | 70 | */ 71 | int videoscale_x = 0; 72 | int videoscale_y = -120; 73 | 74 | void drawScene() 75 | { 76 | 77 | /* 78 | tiny3d_Project3D(); 79 | tiny3d_SetProjectionMatrix(NULL); 80 | 81 | DrawBackground3D(0xffff00ff) ; // yellow 82 | */ 83 | 84 | tiny3d_Project2D(); // change to 2D context (remember you it works with 848 x 512 as virtual coordinates) 85 | 86 | // fix Perspective Projection Matrix 87 | 88 | DrawBackground2D(0x0040ffff) ; // light blue 89 | 90 | 91 | SetFontSize(16, 24); 92 | SetFontColor(0xffffffff, 0x0); 93 | 94 | SetFontAutoCenter(1); 95 | DrawString(0, (512 - 24)/2 - 64, "Use LEFT/RIGHT/UP/DOWN to adjust the screen"); 96 | 97 | DrawFormatString(0, (512 - 24)/2, "Video Scale X: %i Y: %i", videoscale_x, videoscale_y); 98 | 99 | DrawString(0, (512 - 24)/2 + 64, "Press 'X' to exit"); 100 | SetFontAutoCenter(0); 101 | 102 | 103 | } 104 | 105 | 106 | void LoadTexture() 107 | { 108 | 109 | u32 * texture_mem = tiny3d_AllocTexture(64*1024*1024); // alloc 64MB of space for textures (this pointer can be global) 110 | 111 | u32 * texture_pointer; // use to asign texture space without changes texture_mem 112 | 113 | if(!texture_mem) return; // fail! 114 | 115 | ResetFont(); 116 | 117 | texture_pointer = texture_mem; 118 | 119 | texture_pointer = (u32 *) AddFontFromBitmapArray((u8 *) msx , (u8 *) texture_pointer, 0, 254, 8, 8, 1, BIT7_FIRST_PIXEL); 120 | 121 | } 122 | 123 | 124 | void exiting() 125 | { 126 | 127 | 128 | 129 | } 130 | 131 | s32 main(s32 argc, const char* argv[]) 132 | { 133 | 134 | tiny3d_Init(1024*1024); 135 | 136 | ioPadInit(7); 137 | 138 | atexit(exiting); // Tiny3D register the event 3 and do exit() call when you exit to the menu 139 | 140 | // Load texture 141 | 142 | LoadTexture(); 143 | 144 | 145 | // Ok, everything is setup. Now for the main loop. 146 | while(1) { 147 | 148 | static long frame_count = 0; 149 | 150 | 151 | /* DRAWING STARTS HERE */ 152 | 153 | // clear the screen, buffer Z and initializes environment to 2D 154 | 155 | double sx = (double) Video_Resolution.width; 156 | double sy = (double) Video_Resolution.height; 157 | double px = (double) (1000 + videoscale_x)/1000.0; 158 | double py = (double) (1000 + videoscale_y)/1000.0; 159 | 160 | tiny3d_UserViewport(1, 161 | (float) ((sx - sx * px) / 2.0), // 2D position 162 | (float) ((sy - sy * py) / 2.0), 163 | (float) ((sx * px) / 848.0), // 2D scale 164 | (float) ((sy * py) / 512.0), 165 | (((float) Video_Resolution.width) / 1920.0f) * (float) (1000 + videoscale_x)/1000.0f, // 3D scale 166 | (((float) Video_Resolution.height) / 1080.0f) * (float) (1000 + videoscale_y)/1000.0f); 167 | 168 | tiny3d_Clear(0xff000000, TINY3D_CLEAR_ALL); 169 | 170 | // Enable alpha Test 171 | tiny3d_AlphaTest(1, 0x10, TINY3D_ALPHA_FUNC_GEQUAL); 172 | 173 | // Enable alpha blending. 174 | tiny3d_BlendFunc(1, TINY3D_BLEND_FUNC_SRC_RGB_SRC_ALPHA | TINY3D_BLEND_FUNC_SRC_ALPHA_SRC_ALPHA, 175 | TINY3D_BLEND_FUNC_DST_RGB_ONE_MINUS_SRC_ALPHA | TINY3D_BLEND_FUNC_DST_ALPHA_ZERO, 176 | TINY3D_BLEND_RGB_FUNC_ADD | TINY3D_BLEND_ALPHA_FUNC_ADD); 177 | 178 | ps3pad_read(); 179 | 180 | if(!(frame_count & 3)) { 181 | if(old_pad & BUTTON_UP) {if(videoscale_y > -179) videoscale_y--;} 182 | if(old_pad & BUTTON_DOWN) {if(videoscale_y < 10) videoscale_y++;} 183 | if(old_pad & BUTTON_LEFT) {if(videoscale_x > -199) videoscale_x--;} 184 | if(old_pad & BUTTON_RIGHT) {if(videoscale_x < 10) videoscale_x++;} 185 | } 186 | 187 | 188 | if(new_pad & BUTTON_CROSS) break; 189 | 190 | drawScene(); // Draw 191 | 192 | /* DRAWING FINISH HERE */ 193 | 194 | tiny3d_Flip(); 195 | 196 | frame_count++; 197 | 198 | } 199 | 200 | return 0; 201 | } 202 | 203 | -------------------------------------------------------------------------------- /samples/userviewport/source/pad.c: -------------------------------------------------------------------------------- 1 | #include "pad.h" 2 | #include 3 | 4 | unsigned temp_pad = 0, new_pad = 0, old_pad = 0; 5 | 6 | padInfo padinfo; 7 | padData paddata; 8 | int pad_alive=0; 9 | 10 | 11 | int rumble1_on = 0; 12 | int rumble2_on = 0; 13 | int last_rumble = 0; 14 | 15 | 16 | unsigned ps3pad_read() 17 | { 18 | int n; 19 | 20 | padActParam actparam; 21 | 22 | unsigned butt = 0; 23 | 24 | pad_alive = 0; 25 | 26 | sysUtilCheckCallback(); 27 | 28 | ioPadGetInfo(&padinfo); 29 | 30 | for(n = 0; n < MAX_PADS; n++) { 31 | 32 | if(padinfo.status[n]) { 33 | 34 | ioPadGetData(n, &paddata); 35 | pad_alive = 1; 36 | butt = (paddata.button[2] << 8) | (paddata.button[3] & 0xff); 37 | break; 38 | 39 | } 40 | } 41 | 42 | 43 | if(!pad_alive) butt = 0; 44 | else { 45 | actparam.small_motor = 0; 46 | actparam.large_motor = 0; 47 | 48 | if(rumble1_on) { 49 | 50 | actparam.large_motor = 255; 51 | 52 | rumble1_on++; 53 | 54 | if(rumble1_on > 15) rumble1_on = 0; 55 | 56 | } 57 | 58 | if(rumble2_on) { 59 | 60 | actparam.small_motor = 1; 61 | 62 | rumble2_on++; 63 | 64 | if(rumble2_on > 10) rumble2_on = 0; 65 | } 66 | 67 | last_rumble = n; 68 | 69 | ioPadSetActDirect(n, &actparam); 70 | } 71 | 72 | temp_pad = butt; 73 | 74 | new_pad = temp_pad & (~old_pad); old_pad = temp_pad; 75 | 76 | 77 | return butt; 78 | } -------------------------------------------------------------------------------- /samples/userviewport/source/pad.h: -------------------------------------------------------------------------------- 1 | #ifndef PAD_H 2 | #define PAD_H 3 | 4 | #include 5 | 6 | #define BUTTON_LEFT 32768 7 | #define BUTTON_DOWN 16384 8 | #define BUTTON_RIGHT 8192 9 | #define BUTTON_UP 4096 10 | #define BUTTON_START 2048 11 | #define BUTTON_R3 1024 12 | #define BUTTON_L3 512 13 | #define BUTTON_SELECT 256 14 | 15 | #define BUTTON_SQUARE 128 16 | #define BUTTON_CROSS 64 17 | #define BUTTON_CIRCLE 32 18 | #define BUTTON_TRIANGLE 16 19 | #define BUTTON_R1 8 20 | #define BUTTON_L1 4 21 | #define BUTTON_R2 2 22 | #define BUTTON_L2 1 23 | 24 | extern padInfo padinfo; 25 | extern padData paddata; 26 | 27 | extern unsigned new_pad; // new pad buttons pressed (only can see one time, when it change from 0 to 1) 28 | extern unsigned old_pad; // old pad buttons pressed (only can change when you release the button) 29 | 30 | extern int pad_alive; // if 1 paddata is valid 31 | 32 | extern int rumble1_on; // used for rumble 33 | extern int rumble2_on; 34 | 35 | unsigned ps3pad_read(); // read the first conected pad 36 | 37 | #endif -------------------------------------------------------------------------------- /samples/yuv/Makefile: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------- 2 | # Clear the implicit built in rules 3 | #--------------------------------------------------------------------------------- 4 | .SUFFIXES: 5 | #--------------------------------------------------------------------------------- 6 | ifeq ($(strip $(PSL1GHT)),) 7 | $(error "Please set PSL1GHT in your environment. export PSL1GHT=") 8 | endif 9 | 10 | #--------------------------------------------------------------------------------- 11 | # TITLE, APPID, CONTENTID, ICON0 SFOXML before ppu_rules. 12 | #--------------------------------------------------------------------------------- 13 | TITLE := YUV - Tiny3D 14 | APPID := YUV000001 15 | CONTENTID := UP0001-$(APPID)_00-0000000000000000 16 | 17 | include $(PSL1GHT)/ppu_rules 18 | 19 | # aditional scetool flags (--self-ctrl-flags, --self-cap-flags...) 20 | SCETOOL_FLAGS += 21 | 22 | #--------------------------------------------------------------------------------- 23 | # TARGET is the name of the output 24 | # BUILD is the directory where object files & intermediate files will be placed 25 | # SOURCES is a list of directories containing source code 26 | # INCLUDES is a list of directories containing extra header files 27 | #--------------------------------------------------------------------------------- 28 | TARGET := $(notdir $(CURDIR)) 29 | BUILD := build 30 | SOURCES := source 31 | DATA := data 32 | SHADERS := shaders 33 | INCLUDES := include build 34 | 35 | 36 | #--------------------------------------------------------------------------------- 37 | # any extra libraries we wish to link with the project 38 | #--------------------------------------------------------------------------------- 39 | LIBS := -lfont3d -ltiny3d -lrsx -lsimdmath -lgcm_sys -lio -lsysutil -lrt -llv2 -lpngdec -lsysmodule -lm 40 | 41 | 42 | #--------------------------------------------------------------------------------- 43 | # options for code generation 44 | #--------------------------------------------------------------------------------- 45 | 46 | CFLAGS = -O2 -Wall -mcpu=cell $(MACHDEP) $(INCLUDE) 47 | CXXFLAGS = $(CFLAGS) 48 | 49 | LDFLAGS = $(MACHDEP) -Wl,-Map,$(notdir $@).map 50 | 51 | 52 | #--------------------------------------------------------------------------------- 53 | # list of directories containing libraries, this must be the top level containing 54 | # include and lib 55 | #--------------------------------------------------------------------------------- 56 | LIBDIRS := 57 | 58 | #--------------------------------------------------------------------------------- 59 | # no real need to edit anything past this point unless you need to add additional 60 | # rules for different file extensions 61 | #--------------------------------------------------------------------------------- 62 | ifneq ($(BUILD),$(notdir $(CURDIR))) 63 | #--------------------------------------------------------------------------------- 64 | 65 | export OUTPUT := $(CURDIR)/$(TARGET) 66 | 67 | export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ 68 | $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \ 69 | $(foreach dir,$(SHADERS),$(CURDIR)/$(dir)) 70 | 71 | export DEPSDIR := $(CURDIR)/$(BUILD) 72 | 73 | export BUILDDIR := $(CURDIR)/$(BUILD) 74 | 75 | #--------------------------------------------------------------------------------- 76 | # automatically build a list of object files for our project 77 | #--------------------------------------------------------------------------------- 78 | CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) 79 | CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) 80 | sFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s))) 81 | SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.S))) 82 | BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.bin))) 83 | VCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.vcg))) 84 | FCGFILES := $(foreach dir,$(SHADERS),$(notdir $(wildcard $(dir)/*.fcg))) 85 | 86 | VPOFILES := $(VCGFILES:.vcg=.vpo) 87 | FPOFILES := $(FCGFILES:.fcg=.fpo) 88 | 89 | #--------------------------------------------------------------------------------- 90 | # use CXX for linking C++ projects, CC for standard C 91 | #--------------------------------------------------------------------------------- 92 | ifeq ($(strip $(CPPFILES)),) 93 | export LD := $(CC) 94 | else 95 | export LD := $(CXX) 96 | endif 97 | 98 | export OFILES := $(addsuffix .o,$(BINFILES)) \ 99 | $(addsuffix .o,$(VPOFILES)) \ 100 | $(addsuffix .o,$(FPOFILES)) \ 101 | $(CPPFILES:.cpp=.o) $(CFILES:.c=.o) \ 102 | $(sFILES:.s=.o) $(SFILES:.S=.o) 103 | 104 | #--------------------------------------------------------------------------------- 105 | # build a list of include paths 106 | #--------------------------------------------------------------------------------- 107 | export INCLUDE := $(foreach dir,$(INCLUDES), -I$(CURDIR)/$(dir)) \ 108 | $(foreach dir,$(LIBDIRS),-I$(dir)/include) \ 109 | $(LIBPSL1GHT_INC) \ 110 | -I$(CURDIR)/$(BUILD) -I$(PORTLIBS)/include 111 | 112 | #--------------------------------------------------------------------------------- 113 | # build a list of library paths 114 | #--------------------------------------------------------------------------------- 115 | export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) \ 116 | $(LIBPSL1GHT_LIB) -L$(PORTLIBS)/lib 117 | 118 | export OUTPUT := $(CURDIR)/$(TARGET) 119 | .PHONY: $(BUILD) clean 120 | 121 | 122 | #--------------------------------------------------------------------------------- 123 | $(BUILD): 124 | @[ -d $@ ] || mkdir -p $@ 125 | @$(MAKE) --no-print-directory -C $(BUILD) -f $(CURDIR)/Makefile 126 | 127 | #--------------------------------------------------------------------------------- 128 | clean: 129 | @echo clean ... 130 | @rm -fr $(BUILD) $(OUTPUT).elf $(OUTPUT).fake.self $(OUTPUT).self EBOOT.BIN 131 | 132 | #--------------------------------------------------------------------------------- 133 | run: 134 | ps3load $(OUTPUT).self 135 | 136 | #--------------------------------------------------------------------------------- 137 | pkg: $(BUILD) $(OUTPUT).pkg 138 | 139 | #--------------------------------------------------------------------------------- 140 | 141 | npdrm: $(BUILD) 142 | @$(SELF_NPDRM) $(SCETOOL_FLAGS) --np-content-id=$(CONTENTID) --encrypt $(BUILDDIR)/$(basename $(notdir $(OUTPUT))).elf $(BUILDDIR)/../EBOOT.BIN 143 | 144 | #--------------------------------------------------------------------------------- 145 | 146 | else 147 | 148 | DEPENDS := $(OFILES:.o=.d) 149 | 150 | #--------------------------------------------------------------------------------- 151 | # main targets 152 | #--------------------------------------------------------------------------------- 153 | $(OUTPUT).self: $(OUTPUT).elf 154 | $(OUTPUT).elf: $(OFILES) 155 | 156 | #--------------------------------------------------------------------------------- 157 | # This rule links in binary data with the .bin extension 158 | #--------------------------------------------------------------------------------- 159 | %.bin.o : %.bin 160 | #--------------------------------------------------------------------------------- 161 | @echo $(notdir $<) 162 | @$(bin2o) 163 | 164 | #--------------------------------------------------------------------------------- 165 | %.vpo.o : %.vpo 166 | #--------------------------------------------------------------------------------- 167 | @echo $(notdir $<) 168 | @$(bin2o) 169 | 170 | #--------------------------------------------------------------------------------- 171 | %.fpo.o : %.fpo 172 | #--------------------------------------------------------------------------------- 173 | @echo $(notdir $<) 174 | @$(bin2o) 175 | 176 | -include $(DEPENDS) 177 | 178 | #--------------------------------------------------------------------------------- 179 | endif 180 | #--------------------------------------------------------------------------------- 181 | -------------------------------------------------------------------------------- /samples/yuv/data/picture_png.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wargio/tiny3D/9b02ae6e9f21ff15185f8a3846bdca5304d7e0ae/samples/yuv/data/picture_png.bin -------------------------------------------------------------------------------- /tools/toolshaderf/Makefile: -------------------------------------------------------------------------------- 1 | TARGET=fp.exe 2 | all: crc.l crc.y 3 | yacc -d crc.y 4 | flex crc.l 5 | gcc lex.yy.c y.tab.c -o $(TARGET) 6 | -------------------------------------------------------------------------------- /tools/toolshaderf/crc.l: -------------------------------------------------------------------------------- 1 | %{ 2 | #include 3 | #include "y.tab.h" 4 | 5 | //MARK ARL MOV LIT COM RCP RSQ EXP LOG MUL ADD DP3 DP4 DST MIN MAX SLT SGE MAD DOT X Y Z W OPOS WGHT NRML COL0 COL1 FOGC TEX0 TEX1 TEX2 TEX3 TEX4 TEX5 TEX6 TEX7 ADDREG R HPOS BFC0 BFC1 FOGC PSIZ 6 | 7 | 8 | extern float f[256]; 9 | 10 | 11 | void lex( const char *s ) 12 | { 13 | 14 | int v_ptr = 0; 15 | f[0] = 0.0f; 16 | f[1] = 0.0f; 17 | f[2] = 0.0f; 18 | f[3] = 0.0f; 19 | 20 | 21 | while( 1 ) 22 | { 23 | char v = *s; 24 | if( v == 0 || v == '}' || v_ptr == 4 ) 25 | { 26 | break; 27 | } 28 | if( v == '{' || v == ' ' || v == ',' || v == '\t' ) 29 | { 30 | ++s; 31 | } 32 | else 33 | { 34 | int symbols = 0; 35 | sscanf( s, "%f%n", &f[v_ptr], &symbols ); 36 | if( symbols == 0 ) 37 | { 38 | break; 39 | } 40 | v_ptr++; 41 | if( v_ptr == 4 ) 42 | { 43 | break; 44 | } 45 | s += symbols; 46 | } 47 | } 48 | 49 | }; 50 | 51 | 52 | %} 53 | 54 | _0 _1 _2 _3 _4 _5 _6 _7 _8 _9 _1D _2D _3D DOT CONST WHITE WORD DEC SAT CUBE RECT COLR COLH DEPR WPOS COL0 COL1 FOGC F R H X Y Z W GE GT LE LT NE TR FL DDX DDY FLR FRC LIT MOV PK2H PK2US PK4B PK4UB BEG END COS EXP LG2 RCP RSQ SIN UP2H UP2US UP4B UP4UB POW ADD DP3 DP4 DST MAX MIN MUL RFL SEQ SFL SGE SGT SLE SLT SNE STR SUB MAD LRP X2D KIL TEX TXP TXD 55 | 56 | %% 57 | 58 | DECLARE return DEC; 59 | 60 | F return F; 61 | R return R; 62 | H return H; 63 | X return X; 64 | Y return Y; 65 | Z return Z; 66 | W return W; 67 | C return C; 68 | 69 | 70 | r return R; 71 | h return H; 72 | x return X; 73 | y return Y; 74 | z return Z; 75 | w return W; 76 | c return C; 77 | 78 | 79 | WPOS return WPOS; 80 | COL0 return COL0; 81 | COL1 return COL1; 82 | FOGC return FOGC; 83 | 84 | 85 | 1D return _1D; 86 | 2D return _2D; 87 | 3D return _3D; 88 | CUBE return CUBE; 89 | RECT return RECT; 90 | 91 | 92 | 0 return _0; 93 | 1 return _1; 94 | 2 return _2; 95 | 3 return _3; 96 | 4 return _4; 97 | 5 return _5; 98 | 6 return _6; 99 | 7 return _7; 100 | 8 return _8; 101 | 9 return _9; 102 | 103 | 104 | "!!FP1.0" return BEG; 105 | 106 | "END" return END; 107 | ";" return ';'; 108 | "," return ','; 109 | [.] return DOT; 110 | "o" return 'o'; 111 | "f" return 'f'; 112 | "v" return 'v'; 113 | "[" return '['; 114 | "]" return ']'; 115 | 116 | "(" return '('; 117 | ")" return ')'; 118 | 119 | "|" return '|'; 120 | "=" return '='; 121 | 122 | 123 | "_SAT" return SAT; 124 | 125 | 126 | "DDX" return DDX; 127 | "DDY" return DDY; 128 | "FLR" return FLR; 129 | "FRC" return FRC; 130 | "LIT" return LIT; 131 | "MOV" return MOV; 132 | "PK2H" return PK2H; 133 | "PK2US" return PK2US; 134 | "PK4B" return PK4B; 135 | "PK4UB" return PK4UB; 136 | 137 | "COS" return COS; 138 | "EXP" return EXP; 139 | "LG2" return LG2; 140 | "RCP" return RCP; 141 | "RSQ" return RSQ; 142 | "SIN" return SIN; 143 | "UP2H" return UP2H; 144 | "UP2US" return UP2US; 145 | "UP4B" return UP4B; 146 | "UP4UB" return UP4UB; 147 | 148 | "POW" return POW; 149 | 150 | "ADD" return ADD; 151 | "DP3" return DP3; 152 | "DP4" return DP4; 153 | "DST" return DST; 154 | "MAX" return MAX; 155 | "MIN" return MIN; 156 | "MUL" return MUL; 157 | "RFL" return RFL; 158 | "SEQ" return SEQ; 159 | "SFL" return SFL; 160 | "SGE" return SGE; 161 | "SGT" return SGT; 162 | "SLE" return SLE; 163 | "SLT" return SLT; 164 | "SNE" return SNE; 165 | "STR" return STR; 166 | "SUB" return SUB; 167 | 168 | "MAD" return MAD; 169 | "LRP" return LRP; 170 | "X2D" return X2D; 171 | 172 | "KIL" return KIL; 173 | TEX return TEX; 174 | "TXP" return TXP; 175 | "TXD" return TXD; 176 | 177 | "GE" return GE; 178 | "GT" return GT; 179 | "LE" return LE; 180 | "LT" return LT; 181 | "NE" return NE; 182 | "TR" return TR; 183 | "FL" return FL; 184 | "EQ" return EQ; 185 | 186 | 187 | 188 | "COLR" return COLR; 189 | "COLH" return COLH; 190 | "DEPR" return DEPR; 191 | 192 | 193 | \n ; 194 | [ \t]+ return WHITE; 195 | 196 | 197 | [_][a-zA-Z][a-zA-Z0-9]* return WORD; 198 | 199 | [{][ \t.,\-\+0-9]*[}] printf( "const %s \n", yytext ); lex( yytext ); return CONST; 200 | 201 | %% 202 | -------------------------------------------------------------------------------- /tools/toolshaderf/license.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | The MIT License 4 | 5 | Copyright (c) <2007> 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/cg/build.bat: -------------------------------------------------------------------------------- 1 | cgc -profile fp30 -o yuv.fsa yuv.cg 2 | cgc -profile fp30 -o yuv8.fsa yuv8.cg 3 | cgc -profile fp30 -o yuv_color.fsa yuv_color.cg 4 | cgc -profile fp30 -o yuv_color8.fsa yuv_color8.cg 5 | pause -------------------------------------------------------------------------------- /tools/toolshaderf/samples/cg/yuv.cg: -------------------------------------------------------------------------------- 1 | 2 | struct Output { 3 | fixed4 color : COLOR; 4 | }; 5 | 6 | Output main(float2 texCoord : TEXCOORD0, uniform sampler2D decal) 7 | { 8 | Output OUT; 9 | float4 yuv; 10 | fixed4 rgba; 11 | 12 | yuv = tex2D(decal, texCoord); 13 | 14 | yuv.x = 1.164 * (yuv.x - 0.0625); // y 15 | yuv.y -= 0.5; // u 16 | yuv.z -= 0.5; // v 17 | 18 | rgba.x = saturate(yuv.x + 1.596 * yuv.z); 19 | rgba.y = saturate(yuv.x - 0.813 * yuv.z - 0.391 * yuv.y); 20 | rgba.z = saturate(yuv.x + 2.018 * yuv.y); 21 | 22 | rgba.w = yuv.w; 23 | 24 | OUT.color = rgba; 25 | return OUT; 26 | } -------------------------------------------------------------------------------- /tools/toolshaderf/samples/cg/yuv8.cg: -------------------------------------------------------------------------------- 1 | 2 | struct Output { 3 | fixed4 color : COLOR; 4 | }; 5 | 6 | Output main(float2 texCoord : TEXCOORD0, uniform sampler2D decal, uniform sampler2D decal2, uniform sampler2D decal3) 7 | { 8 | Output OUT; 9 | float4 yuv; 10 | float4 rgba; 11 | 12 | yuv.x = tex2D(decal, texCoord).x; 13 | yuv.y = tex2D(decal2, texCoord).x; 14 | yuv.z = tex2D(decal3, texCoord).x; 15 | 16 | yuv.x = 1.164 * (yuv.x - 0.0625); // y 17 | yuv.y -= 0.5; // u 18 | yuv.z -= 0.5; // v 19 | yuv.w = 1.0f; 20 | 21 | rgba.x = saturate(yuv.x + 1.596 * yuv.z); 22 | rgba.y = saturate(yuv.x - 0.813 * yuv.z - 0.391 * yuv.y); 23 | rgba.z = saturate(yuv.x + 2.018 * yuv.y); 24 | 25 | rgba.w = yuv.w; 26 | 27 | OUT.color = rgba; 28 | return OUT; 29 | } -------------------------------------------------------------------------------- /tools/toolshaderf/samples/cg/yuv_color.cg: -------------------------------------------------------------------------------- 1 | 2 | struct Output { 3 | fixed4 color : COLOR; 4 | }; 5 | 6 | Output main(float4 incolor : COLOR, float2 texCoord : TEXCOORD0, uniform sampler2D decal) 7 | { 8 | Output OUT; 9 | float4 yuv; 10 | float4 rgba; 11 | 12 | yuv = tex2D(decal, texCoord); 13 | 14 | yuv.x = 1.164 * (yuv.x - 0.0625); // y 15 | yuv.y -= 0.5; // u 16 | yuv.z -= 0.5; // v 17 | 18 | rgba.x = saturate(yuv.x + 1.596 * yuv.z); 19 | rgba.y = saturate(yuv.x - 0.813 * yuv.z - 0.391 * yuv.y); 20 | rgba.z = saturate(yuv.x + 2.018 * yuv.y); 21 | 22 | rgba.w = yuv.w; 23 | 24 | rgba.xyz = saturate(lerp(rgba.xyz, incolor.xyz, incolor.a)); 25 | 26 | OUT.color = (fixed4) rgba; 27 | return OUT; 28 | } -------------------------------------------------------------------------------- /tools/toolshaderf/samples/cg/yuv_color8.cg: -------------------------------------------------------------------------------- 1 | 2 | struct Output { 3 | fixed4 color : COLOR; 4 | }; 5 | 6 | Output main(float4 incolor : COLOR, float2 texCoord : TEXCOORD0, uniform sampler2D decal, uniform sampler2D decal2, uniform sampler2D decal3) 7 | { 8 | Output OUT; 9 | float4 yuv; 10 | float4 rgba; 11 | 12 | yuv.x = tex2D(decal, texCoord).x; 13 | yuv.y = tex2D(decal2, texCoord).x; 14 | yuv.z = tex2D(decal3, texCoord).x; 15 | 16 | yuv.x = 1.164 * (yuv.x - 0.0625); // y 17 | yuv.y -= 0.5; // u 18 | yuv.z -= 0.5; // v 19 | yuv.w = 1.0f; 20 | 21 | rgba.x = saturate(yuv.x + 1.596 * yuv.z); 22 | rgba.y = saturate(yuv.x - 0.813 * yuv.z - 0.391 * yuv.y); 23 | rgba.z = saturate(yuv.x + 2.018 * yuv.y); 24 | 25 | rgba.w = yuv.w; 26 | 27 | rgba.xyz = saturate(lerp(rgba.xyz, incolor.xyz, incolor.a)); 28 | 29 | OUT.color = (fixed4) rgba; 30 | return OUT; 31 | } -------------------------------------------------------------------------------- /tools/toolshaderf/samples/color.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | MOV o[COLH], f[COL0]; 3 | END 4 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/compile.bat: -------------------------------------------------------------------------------- 1 | fp color.fp color 2 | fp texture.fp texture 3 | fp texture_color.fp texture_color 4 | fp texture2.fp texture2 5 | fp texture2_alt.fp texture2_alt 6 | fp texture2_alt2.fp texture2_alt2 7 | fp texture_color2.fp texture_color2 8 | fp texture_color2_alt.fp texture_color2_alt 9 | fp texture_color2_alt2.fp texture_color2_alt2 10 | fp yuv.fp yuv 11 | fp yuv8.fp yuv8 12 | fp yuv_color.fp yuv_color 13 | fp yuv_color8.fp yuv_color8 14 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEXX o[COLH], f[TEX0], TEX0, 2D; 3 | END 4 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture2.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | MULX o[COLH], R0, R1; 5 | END 6 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture2_alt.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | ADDR R1.xyz, R1, -R0; 5 | MADR o[COLH].xyz, R1, {0.5}.x, R0; 6 | MULX o[COLH].w, R0.w, R1.w; 7 | END 8 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture2_alt2.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | ADDR R1, R1, -R0; 5 | MADR o[COLH], R1, {0.5}.x, R0; 6 | END 7 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture_color.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEXX R0, f[TEX0], TEX0, 2D; 3 | MULX o[COLH], R0, f[COL0]; 4 | END 5 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture_color2.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | MUL R0, R0, R1; 5 | MULX o[COLH], R0, f[COL0]; 6 | END 7 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture_color2_alt.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | ADDR R1.xyz, R1, -R0; 5 | MADR R0.xyz, R1, {0.5}.x, R0;, 6 | MUL R0.w, R0.w, R1.w; 7 | MULX o[COLH], R0, f[COL0]; 8 | END 9 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/texture_color2_alt2.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | TEX R1, f[TEX1], TEX1, 2D; 4 | ADDR R1, R1, -R0; 5 | MADR R0, R1, {0.5}.x, R0; 6 | MULX o[COLH], R0, f[COL0]; 7 | END 8 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/yuv.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | ADDR R0.x, R0, {-0.0625}; 4 | ADDR R1.xy, R0.zyzw, {-0.5}.x; 5 | MULR R0.x, R0, {1.164}; 6 | MADR R0.y, -R1.x, {0.81300002}.x, R0.x; 7 | MADR_SAT R2.z, R1.y, {2.0179999}.x, R0.x; 8 | MADR_SAT R2.y, -R1, {0.391}.x, R0; 9 | MADR_SAT R2.x, R1, {1.596}, R0; 10 | MOVX o[COLH].xyz, R2; 11 | MOVX o[COLH].w, R0; 12 | END 13 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/yuv8.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R1, f[TEX0], TEX1, 2D; 3 | TEX R0, f[TEX0], TEX0, 2D; 4 | ADDR R1.y, R0.x, {-0.0625}.x; 5 | TEX R0, f[TEX0], TEX2, 2D; 6 | MULR R0.y, R1, {1.164}.x; 7 | ADDR R0.x, R0, {-0.5}; 8 | ADDR R1.x, R1, {-0.5}; 9 | MADR R0.z, -R0.x, {0.81300002}.x, R0.y; 10 | MADR_SAT R2.z, R1.x, {2.0179999}.x, R0.y; 11 | MADR_SAT R2.y, -R1.x, {0.391}.x, R0.z; 12 | MADR_SAT R2.x, R0, {1.596}, R0.y; 13 | MOVX o[COLH].xyz, R2; 14 | MOVX o[COLH].w, R0; 15 | MOVX o[COLH].w, {1}.x; 16 | END 17 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/yuv_color.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R0, f[TEX0], TEX0, 2D; 3 | ADDR R0.x, R0, {-0.0625}; 4 | MULR R1.x, R0, {1.164}; 5 | ADDR R0.xy, R0.zyzw, {-0.5}.x; 6 | MADR R1.y, -R0.x, {0.81300002}.x, R1.x; 7 | MADR_SAT R0.z, R0.y, {2.0179999}.x, R1.x; 8 | MADR_SAT R0.x, R0, {1.596}, R1; 9 | MADR_SAT R0.y, -R0, {0.391}.x, R1; 10 | ADDR R1.xyz, f[COL0], -R0; 11 | MADR_SAT o[COLH].xyz, f[COL0].w, R1, R0; 12 | MOVX o[COLH].w, R0; 13 | END 14 | -------------------------------------------------------------------------------- /tools/toolshaderf/samples/yuv_color8.fp: -------------------------------------------------------------------------------- 1 | !!FP1.0 2 | TEX R1, f[TEX0], TEX2, 2D; 3 | TEX R0, f[TEX0], TEX0, 2D; 4 | ADDR R1.y, R0.x, {-0.0625}.x; 5 | TEX R0, f[TEX0], TEX1, 2D; 6 | MULR R0.y, R1, {1.164}.x; 7 | ADDR R1.x, R1, {-0.5}; 8 | ADDR R0.w, R0.x, {-0.5}.x; 9 | MADR R1.y, -R1.x, {0.81300002}.x, R0; 10 | MADR_SAT R0.x, R1, {1.596}, R0.y; 11 | MADR_SAT R0.z, R0.w, {2.0179999}.x, R0.y; 12 | MADR_SAT R0.y, -R0.w, {0.391}.x, R1; 13 | ADDR R1.xyz, f[COL0], -R0; 14 | MADR_SAT o[COLH].xyz, f[COL0].w, R1, R0; 15 | MOVX o[COLH].w, {1}.x; 16 | END 17 | -------------------------------------------------------------------------------- /tools/vpcomp/Makefile: -------------------------------------------------------------------------------- 1 | NVIDIA= /cygdrive/c/Cg 2 | 3 | CFLAGS += -Wall -Os -g -pipe -I../../include/rsx -I$(NVIDIA)/include 4 | LDFLAGS += -lstdc++ 5 | 6 | UNAME := $(shell uname -s) 7 | 8 | ifeq ($(UNAME),Darwin) 9 | LDFLAGS += /Library/Frameworks/Cg.framework/Cg 10 | endif 11 | 12 | ifeq ($(UNAME),Linux) 13 | LDFLAGS += -lCg -lpthread 14 | endif 15 | LDFLAGS += $(NVIDIA)/lib/cg.lib -lpthread 16 | 17 | CC = $(PREFIX)gcc 18 | STRIP = $(PREFIX)strip 19 | 20 | BIN = vpcomp$(BIN_EXT) 21 | 22 | OBJS = main.o microcode.o parameters.o vpasm.o 23 | 24 | all: $(BIN) 25 | 26 | clean: 27 | @rm -f *.o core core.* $(BIN) 28 | 29 | strip: all 30 | $(STRIP) $(BIN) 31 | 32 | install: strip 33 | install -m 755 $(BIN) $(DEVKITPPC)/bin 34 | 35 | $(BIN): $(OBJS) 36 | $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ 37 | 38 | %.o: %.c 39 | $(CC) $(CFLAGS) -c $< -o $@ 40 | 41 | %.o: %.cpp 42 | $(CC) $(CFLAGS) -c $< -o $@ 43 | 44 | 45 | osx: 46 | $(MAKE) clean 47 | PREFIX=/opt/toolchains/powerpc-apple-darwin8-10.2/bin/ppc-apple-darwin8- CFLAGS=-fabi-version=1 $(MAKE) strip 48 | cp $(BIN) $(BIN)_ppc 49 | $(MAKE) clean 50 | PREFIX=/opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9- $(MAKE) strip 51 | cp $(BIN) $(BIN)_intel 52 | $(MAKE) clean 53 | /opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9-lipo -create $(BIN)_ppc $(BIN)_intel -output $(BIN) 54 | rm $(BIN)_ppc $(BIN)_intel 55 | -------------------------------------------------------------------------------- /tools/vpcomp/Makefile_orig: -------------------------------------------------------------------------------- 1 | CFLAGS += -Wall -Os -g -pipe -I../../include/rsx 2 | LDFLAGS += -lstdc++ 3 | 4 | UNAME := $(shell uname -s) 5 | 6 | ifeq ($(UNAME),Darwin) 7 | LDFLAGS += /Library/Frameworks/Cg.framework/Cg 8 | endif 9 | 10 | ifeq ($(UNAME),Linux) 11 | LDFLAGS += -lCg -lpthread 12 | endif 13 | 14 | CC = $(PREFIX)gcc 15 | STRIP = $(PREFIX)strip 16 | 17 | BIN = vpcomp$(BIN_EXT) 18 | 19 | OBJS = main.o microcode.o parameters.o vpasm.o 20 | 21 | all: $(BIN) 22 | 23 | clean: 24 | @rm -f *.o core core.* $(BIN) 25 | 26 | strip: all 27 | $(STRIP) $(BIN) 28 | 29 | install: strip 30 | install -m 755 $(BIN) $(DEVKITPPC)/bin 31 | 32 | $(BIN): $(OBJS) 33 | $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ 34 | 35 | %.o: %.c 36 | $(CC) $(CFLAGS) -c $< -o $@ 37 | 38 | %.o: %.cpp 39 | $(CC) $(CFLAGS) -c $< -o $@ 40 | 41 | 42 | osx: 43 | $(MAKE) clean 44 | PREFIX=/opt/toolchains/powerpc-apple-darwin8-10.2/bin/ppc-apple-darwin8- CFLAGS=-fabi-version=1 $(MAKE) strip 45 | cp $(BIN) $(BIN)_ppc 46 | $(MAKE) clean 47 | PREFIX=/opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9- $(MAKE) strip 48 | cp $(BIN) $(BIN)_intel 49 | $(MAKE) clean 50 | /opt/toolchains/i686-apple-darwin9-10.4/bin/i686-apple-darwin9-lipo -create $(BIN)_ppc $(BIN)_intel -output $(BIN) 51 | rm $(BIN)_ppc $(BIN)_intel 52 | -------------------------------------------------------------------------------- /tools/vpcomp/NOTES.txt: -------------------------------------------------------------------------------- 1 | This is the modified version of PSL1GHT vpcomp tool from ElSemi. 2 | 3 | This version works with VP30 instead VP40 (to use it with 'pow' function used in Tiny3D vertex shader) 4 | 5 | Also it can works with ASM files becuase i have modified some fread() functions to work properly 6 | -------------------------------------------------------------------------------- /tools/vpcomp/README.txt: -------------------------------------------------------------------------------- 1 | Vertex program compiler for libreality 2 | 3 | Preliminary version. It should compile most simple programs. 4 | Based on the information from Nouveau open source NVidia driver 5 | http://nouveau.freedesktop.org/wiki/ 6 | 7 | Supported: 8 | All scalar and vector opcodes 9 | Branches 10 | Calls (untested) 11 | Parameter passing in constants 12 | 13 | Unsupported: 14 | Texture lookup 15 | Address register access (ARL,ARR) 16 | Indirect constant register access 17 | Program relocation (jump & constants relocations) 18 | 19 | The assembler parser is quite simplistic, so it might fail to properly compiled 20 | some valid assembler files. 21 | 22 | It requires NVidia CG.dll in the same directory (or in path) in order to 23 | compile .cg programs into .rvp (reality vertex program) files. 24 | (Download NVidia CG toolkit from their webpage to get the .dll) 25 | 26 | Only the windows version of the toolkit is currently supported. 27 | -------------------------------------------------------------------------------- /tools/vpcomp/microcode.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "stdlib.h" 3 | 4 | typedef signed char int8_t; 5 | typedef unsigned char uint8_t; 6 | typedef unsigned int uint32_t; 7 | typedef unsigned char boolean; 8 | 9 | #define INLINE 10 | 11 | #include "nv40_vertprog.h" 12 | #include "vpasm.h" 13 | #include "microcode.h" 14 | 15 | unsigned int build_src(unsigned char src,_Reg *reg,unsigned int words[4],unsigned int *attribs) 16 | { 17 | unsigned int val=0; 18 | switch(reg->type) 19 | { 20 | case NVFXSR_IMM: 21 | val|=NV40_VP_SRC_REG_TYPE_INPUT<index<<8; 23 | return val; 24 | break; 25 | case NVFXSR_TEMP: 26 | val|=NV40_VP_SRC_REG_TYPE_TEMP<index<index<index; 33 | break; 34 | case NVFXSR_CONST: 35 | val|=NV40_VP_SRC_REG_TYPE_CONST<index<neg) 44 | val|=NV40_VP_SRC_NEGATE; 45 | if(reg->abs) 46 | { 47 | switch(src) 48 | { 49 | case 0: words[0]|=NV40_VP_INST_SRC0_ABS; break; 50 | case 1: words[0]|=NV40_VP_INST_SRC1_ABS; break; 51 | case 2: words[0]|=NV40_VP_INST_SRC2_ABS; break; 52 | } 53 | } 54 | val|=reg->swizzle[0]<swizzle[1]<swizzle[2]<swizzle[3]<unit==NVFX_VP_INST_SLOT_SCA) 80 | { 81 | if(inst->op==NVFX_VP_INST_SCA_OP_BRA || inst->op==NVFX_VP_INST_SCA_OP_CAL || inst->op==NVFX_VP_INST_SCA_OP_RET) 82 | { 83 | words[1]|=inst->op<dstMask<op<dstMask<op<dstMask<updateCC) 105 | words[0]|=NV40_VP_INST_COND_UPDATE_ENABLE; 106 | 107 | if(inst->testCC) 108 | words[0]|=NV40_VP_INST_COND_TEST_ENABLE; 109 | words[0]|=inst->condition<condSwizzle[0]<condSwizzle[1]<condSwizzle[2]<condSwizzle[3]<saturate) 116 | words[0]|=NV40_VP_INST_SATURATE; 117 | 118 | switch(inst->dstType) 119 | { 120 | case NVFXSR_NONE: 121 | words[3]|=NV40_VP_INST_DEST_MASK; 122 | if(inst->unit==NVFX_VP_INST_SLOT_SCA) 123 | words[3]|=NV40_VP_INST_SCA_DEST_TEMP_MASK; 124 | else 125 | words[0]|=NV40_VP_INST_VEC_DEST_TEMP_MASK; 126 | break; 127 | case NVFXSR_TEMP: 128 | words[3]|=NV40_VP_INST_DEST_MASK; 129 | if(inst->unit==NVFX_VP_INST_SLOT_SCA) 130 | words[3]|=inst->dstIndex<dstIndex<dstIndex<unit==NVFX_VP_INST_SLOT_SCA) 137 | { 138 | words[3]|=NV40_VP_INST_SCA_RESULT; 139 | words[3]|=NV40_VP_INST_SCA_DEST_TEMP_MASK; 140 | } 141 | else 142 | { 143 | words[0]|=NV40_VP_INST_VEC_RESULT; 144 | words[0]|=NV40_VP_INST_VEC_DEST_TEMP_MASK; 145 | } 146 | if(inst->dstIndex<7) 147 | UsedOutputs|=1<dstIndex; 148 | else 149 | UsedOutputs|=1<<(inst->dstIndex+7); 150 | break; 151 | } 152 | 153 | tmp=build_src(0,inst->src+0,words,&UsedAttribs); 154 | words[1]|=((tmp&NV40_VP_SRC0_HIGH_MASK)>>NV40_VP_SRC0_HIGH_SHIFT)<src+1,words,&UsedAttribs); 158 | words[2]|=tmp<src+2,words,&UsedAttribs); 161 | words[2]|=((tmp&NV40_VP_SRC2_HIGH_MASK)>>NV40_VP_SRC2_HIGH_SHIFT)<unit!=NVFX_VP_INST_SLOT_SCA) //?? it's reversed 165 | words[3]|=NV40_VP_INST_SCA_RESULT; //?? 166 | 167 | if(i==nInsts-1) 168 | words[3]|=1; //END 169 | 170 | 171 | } 172 | printf("%d instructions\n",nInsts); 173 | printf("Attribute mask %x\n",UsedAttribs); 174 | printf("Output mask %x\n",UsedOutputs); 175 | 176 | microcode.ucode=ucode; 177 | microcode.InputMask=UsedAttribs; 178 | microcode.OutputMask=UsedOutputs; 179 | 180 | return µcode; 181 | } 182 | -------------------------------------------------------------------------------- /tools/vpcomp/microcode.h: -------------------------------------------------------------------------------- 1 | #ifndef UCODE_H 2 | #define UCODE_H 3 | 4 | 5 | #include "vpasm.h" 6 | 7 | struct _Microcode 8 | { 9 | unsigned int *ucode; 10 | unsigned int InputMask; 11 | unsigned int OutputMask; 12 | }; 13 | 14 | _Microcode *GenerateMicrocode(_Instruction *instructions,int nInst); 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /tools/vpcomp/parameters.cpp: -------------------------------------------------------------------------------- 1 | #include "stdio.h" 2 | #include "string.h" 3 | #include "stdlib.h" 4 | 5 | #include "parameters.h" 6 | 7 | #include "string" 8 | #include "sstream" 9 | 10 | 11 | struct _ParamType 12 | { 13 | const char *Name; 14 | unsigned char Type; 15 | } ParamTypes[]= 16 | { 17 | {"float",PARAM_FLOAT}, 18 | {"float2",PARAM_FLOAT2}, 19 | {"float3",PARAM_FLOAT3}, 20 | {"float4",PARAM_FLOAT4}, 21 | {"float4x4",PARAM_FLOAT4x4}, 22 | }; 23 | 24 | const unsigned char nParamTypes = sizeof(ParamTypes)/sizeof(_ParamType); 25 | 26 | 27 | static int nLine; 28 | static void fatal(const char *error, char *param) 29 | { 30 | printf("Line %d: %s %s\n",nLine,error, param); 31 | exit(-1); 32 | } 33 | 34 | unsigned char GetParamType(char *str) 35 | { 36 | for(int i=0;i ScanParameters(char *input) 131 | { 132 | std::stringstream file(input); 133 | list<_Parameter> parameters; 134 | 135 | nLine=0; 136 | 137 | while(!file.eof()) 138 | { 139 | char line[256]; 140 | 141 | file.getline(line,255); 142 | 143 | ++nLine; 144 | //remove \n & \r 145 | char *newline = strchr(line,'\n'); 146 | if(newline) 147 | *newline=0; 148 | newline = strchr(line,'\n'); 149 | if(newline) 150 | *newline=0; 151 | 152 | if(line[0]==0) 153 | continue; 154 | //is it a comment 155 | if(line[0]=='#') 156 | { 157 | if(strncasecmp(line+1,"var",3)==0) 158 | { 159 | _Parameter p; 160 | char *token = strtok(line+5," :"); 161 | p.Type=GetParamType(token); 162 | p.IsInternal=0; 163 | p.IsConstant=0; 164 | p.Name = strtok(NULL," :"); 165 | p.Values[0]=0.0f; 166 | p.Values[1]=0.0f; 167 | p.Values[2]=0.0f; 168 | p.Values[3]=0.0f; 169 | token = strtok(NULL,":"); 170 | if(isempty(token)) 171 | { 172 | p.IsConstant=1; 173 | token=strtok(NULL," :"); 174 | if(token[0]=='c') 175 | { 176 | p.Index = atoi(token+2); 177 | } 178 | else 179 | { 180 | fatal("unknown constant register",token); 181 | } 182 | } 183 | else if(strstr(token,"$vin")) //Scan input semantic 184 | { 185 | token=strtok(NULL," :"); 186 | if(strncasecmp(token,"ATTR",4)==0) //Numbered 187 | p.Index = atoi(token+4); 188 | else 189 | p.Index=ConvertInputReg(token); 190 | } 191 | else if(strstr(token,"$vout")) //scan output semantic 192 | { 193 | //we don't need the output attributes 194 | //token=strtok(NULL," :"); 195 | //p.Index=ConvertOutputReg(token); 196 | continue; 197 | } 198 | else if(isempty(token)) 199 | { 200 | continue; 201 | } 202 | else 203 | { 204 | fatal("Unknown semantic",token); 205 | } 206 | 207 | 208 | parameters.push_back(p); 209 | } 210 | else if(strncasecmp(line+1,"const",5)==0) 211 | { 212 | _Parameter p; 213 | p.IsInternal=1; 214 | p.IsConstant=1; 215 | p.Type=PARAM_FLOAT4; 216 | 217 | char *token = strtok(line+7," "); 218 | 219 | if(token[0]=='c') 220 | { 221 | p.Index = atoi(token+2); 222 | for(int i=0;i<4;++i) 223 | { 224 | token=strtok(NULL," ="); 225 | if(token) 226 | p.Values[i]=(float)atof(token); 227 | else 228 | p.Values[i]=0; 229 | } 230 | } 231 | else 232 | { 233 | fatal("unknown constant register",token); 234 | } 235 | 236 | 237 | parameters.push_back(p); 238 | } 239 | else if(strncasecmp(line+1,"default",7)==0) 240 | { 241 | char *token = strtok(line+9," "); 242 | char found=0; 243 | 244 | for(list<_Parameter>::iterator p = parameters.begin();p!=parameters.end();++p) 245 | { 246 | if(p->Name==token && p->IsConstant) 247 | { 248 | for(int i=0;i<4;++i) 249 | { 250 | token=strtok(NULL," ="); 251 | if(token) 252 | p->Values[i]=(float)atof(token); 253 | else 254 | p->Values[i]=0; 255 | } 256 | found=1; 257 | break; 258 | } 259 | } 260 | if(!found) 261 | { 262 | fatal("unknown constant register",token); 263 | } 264 | } 265 | } 266 | } 267 | 268 | return parameters; 269 | } 270 | -------------------------------------------------------------------------------- /tools/vpcomp/parameters.h: -------------------------------------------------------------------------------- 1 | #ifndef PARAMS_H 2 | #define PARAMS_H 3 | 4 | #include "list" 5 | #include "string" 6 | using namespace std; 7 | 8 | extern "C" 9 | { 10 | #include "realityVP.h" 11 | } 12 | 13 | struct _Parameter 14 | { 15 | string Name; 16 | unsigned char IsConstant; 17 | unsigned char IsInternal; 18 | unsigned char Type; 19 | unsigned int Index; 20 | float Values[4]; 21 | unsigned int User; 22 | }; 23 | 24 | 25 | list<_Parameter> ScanParameters(char *filename); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /tools/vpcomp/vpasm.h: -------------------------------------------------------------------------------- 1 | #ifndef VPASM_H 2 | #define VPASM_H 3 | 4 | struct _Reg 5 | { 6 | unsigned char type; 7 | unsigned short index; 8 | unsigned char swizzle[4]; 9 | unsigned char neg; 10 | unsigned char abs; 11 | }; 12 | 13 | struct _Instruction 14 | { 15 | unsigned char op; 16 | unsigned char unit; 17 | 18 | unsigned char saturate; 19 | unsigned char updateCC; 20 | unsigned char testCC; 21 | unsigned char condSwizzle[4]; 22 | unsigned char condition; 23 | 24 | unsigned char dstType; 25 | unsigned char dstIndex; 26 | unsigned int dstMask; 27 | 28 | _Reg src[3]; 29 | }; 30 | 31 | _Instruction *ParseAsm(char *file,int *nInsts); 32 | 33 | #endif 34 | --------------------------------------------------------------------------------