Compare commits
22 Commits
Author | SHA1 | Date | |
---|---|---|---|
586edb90c1 | |||
7f81b0aa62 | |||
70b9486ece | |||
d6d52c740c | |||
90461ce1e9 | |||
86523bcbc6 | |||
895d89c585 | |||
2b0c7a9028 | |||
33172c7fe2 | |||
d9007bfc26 | |||
d87d99e63b | |||
c5c8e90417 | |||
c083d1de85 | |||
d850180727 | |||
56a9fa382f | |||
758cb5bcec | |||
c0b40e4747 | |||
411f47831f | |||
9ae3857fad | |||
4bc75f43a5 | |||
d578148edf | |||
04a3bbbece |
44
.github/workflows/linux-build.yml
vendored
Normal file
44
.github/workflows/linux-build.yml
vendored
Normal file
@ -0,0 +1,44 @@
|
||||
name: Linux build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Install mipsel toolchain
|
||||
run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install gcc-mipsel-linux-gnu g++-mipsel-linux-gnu binutils-mipsel-linux-gnu p7zip cmake build-essential libtinyxml2-6 libtinyxml2-dev
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Clone mkpsxiso
|
||||
uses: GuillaumeFalourd/clone-github-repo-action@v1
|
||||
with:
|
||||
owner: 'Lameguy64'
|
||||
repository: 'mkpsxiso'
|
||||
- name: Build mkpsxiso
|
||||
run: |
|
||||
sudo chown -R runner:docker ${{github.workspace}}/mkpsxiso/
|
||||
mkdir ${{github.workspace}}/mkpsxiso/build
|
||||
cmake -DCMAKE_BUILD_TYPE=Release -S ${{github.workspace}}/mkpsxiso/ -B ${{github.workspace}}/mkpsxiso/build
|
||||
cmake --build ${{github.workspace}}/mkpsxiso/build
|
||||
echo "${{github.workspace}}/mkpsxiso/build" >> $GITHUB_PATH
|
||||
- name: Get converted libs
|
||||
run: |
|
||||
wget http://psx.arthus.net/sdk/Psy-Q/psyq-4.7-converted-full.7z
|
||||
7z x psyq-4.7-converted-full.7z -o./psyq
|
||||
- name: Make all
|
||||
run: make all
|
||||
- name: Upload bin/cue
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: 3dcam-latest
|
||||
path: |
|
||||
${{github.workspace}}/3dcam.bin
|
||||
${{github.workspace}}/3dcam.cue
|
30
.github/workflows/windows-build.yml
vendored
Normal file
30
.github/workflows/windows-build.yml
vendored
Normal file
@ -0,0 +1,30 @@
|
||||
name: Windows build
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: windows-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Fetch submodules
|
||||
run: git submodule update --init --recursive
|
||||
- name: Set script
|
||||
run: |
|
||||
C:\msys64\usr\bin\wget.exe http://static.grumpycoder.net/pixel/mips/g++-mipsel-none-elf-11.2.0.zip
|
||||
C:\msys64\usr\bin\wget.exe http://lameguy64.github.io/mkpsxiso/mkpsxiso-1.20.zip
|
||||
C:\msys64\usr\bin\wget.exe http://psx.arthus.net/sdk/Psy-Q/psyq-4.7-converted-full.7z
|
||||
echo "Extracting to $GITHUB_WORKSPACE/mipsel..."
|
||||
7z.exe x g++-mipsel-none-elf-11.2.0.zip -o"$GITHUB_WORKSPACE/mipsel"
|
||||
echo "Extracting to $GITHUB_WORKSPACE/mkpsxiso..."
|
||||
7z.exe x mkpsxiso-1.20.zip -o"$GITHUB_WORKSPACE/mkpsxiso"
|
||||
echo "Extracting to $GITHUB_WORKSPACE/psyq..."
|
||||
7z.exe x psyq-4.7-converted-full.7z -o"D:/a/3dcam-headers/3dcam-headers/psyq"
|
||||
echo "$GITHUB_WORKSPACE/mipsel/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
echo "$GITHUB_WORKSPACE/mkpsxiso" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
|
||||
|
||||
- name: Make all
|
||||
run: make all
|
16
Makefile
16
Makefile
@ -1,6 +1,15 @@
|
||||
TARGET = main
|
||||
TYPE = ps-exe
|
||||
TARGET = 3dcam
|
||||
|
||||
.PHONY: all cleansub
|
||||
|
||||
all:
|
||||
mkpsxiso -y ./config/3dcam.xml
|
||||
|
||||
cleansub:
|
||||
$(MAKE) clean
|
||||
rm -f $(TARGET).cue $(TARGET).bin
|
||||
rm -f *.mcd *.frag *.lua *.vert
|
||||
|
||||
SRCS = src/main.c \
|
||||
src/pad.c \
|
||||
src/math.c \
|
||||
@ -21,6 +30,9 @@ TIM/bg_camPath_002.tim \
|
||||
TIM/bg_camPath_003.tim \
|
||||
TIM/bg_camPath_004.tim \
|
||||
TIM/bg_camPath_005.tim \
|
||||
TIM/ground.tim \
|
||||
TIM/trees.tim \
|
||||
TIM/woods.tim \
|
||||
VAG/hello.vag \
|
||||
VAG/poly.vag \
|
||||
VAG/0_come.vag \
|
||||
|
@ -26,6 +26,7 @@ Real-time 3D / 8bpp background / 4bpp background
|
||||
* Up to 3 light sources
|
||||
* Use pre-rendered backgrounds (8bpp and 4bpp)
|
||||
* Basic collisions
|
||||
* Sound effects (VAG/XA)
|
||||
|
||||
### Demo Controls
|
||||
|
||||
@ -39,11 +40,10 @@ Real-time 3D / 8bpp background / 4bpp background
|
||||
## Planned
|
||||
|
||||
* Fix and improve all the things !
|
||||
* Wall collisions
|
||||
|
||||
# Compiling
|
||||
|
||||
You need to install [mkpsxiso](https://github.com/Lameguy64/mkpsxiso) and the [Nugget+PsyQ SDK](https://github.com/ABelliqueux/nolibgs_hello_worlds/tree/newtree#installation) before
|
||||
You need to install [mkpsxiso](https://github.com/Lameguy64/mkpsxiso) and the [Nugget+PsyQ SDK](https://github.com/ABelliqueux/nolibgs_hello_worlds#installation) before
|
||||
you can build the engine. Put `mkpsxiso` and `pcsx-redux` in your $PATH and you should be good to go.
|
||||
|
||||
1. Clone this repo in your nugget+PsyQ folder as a new project :
|
||||
|
BIN
TIM/ground.tim
Normal file
BIN
TIM/ground.tim
Normal file
Binary file not shown.
BIN
TIM/trees.tim
Normal file
BIN
TIM/trees.tim
Normal file
Binary file not shown.
BIN
TIM/woods.tim
Normal file
BIN
TIM/woods.tim
Normal file
Binary file not shown.
8
XA/inter_0.txt
Normal file
8
XA/inter_0.txt
Normal file
@ -0,0 +1,8 @@
|
||||
1 xa XA/3_hehe.xa 0 0
|
||||
1 xa XA/3_hehe.xa 0 1
|
||||
1 xa XA/1_cuek.xa 0 2
|
||||
1 xa XA/1_cuek.xa 0 3
|
||||
1 xa XA/1_cuek.xa 0 4
|
||||
1 xa XA/3_hehe.xa 0 5
|
||||
1 null
|
||||
1 null
|
BIN
XA/inter_0.xa
Normal file
BIN
XA/inter_0.xa
Normal file
Binary file not shown.
15
common.mk
15
common.mk
@ -4,6 +4,9 @@ TYPE = ps-exe
|
||||
THISDIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
|
||||
|
||||
SRCS += $(THISDIR)thirdparty/nugget/common/crt0/crt0.s
|
||||
SRCS += $(THISDIR)thirdparty/nugget/common/syscalls/printf.s
|
||||
|
||||
CPPFLAGS += -I$(THISDIR)include
|
||||
|
||||
CPPFLAGS += -I$(THISDIR)thirdparty/nugget/psyq/include -I$(THISDIR)psyq-4_7-converted/include -I$(THISDIR)psyq-4.7-converted-full/include -I$(THISDIR)psyq/include -I$(THISDIR)../psyq/include
|
||||
LDFLAGS += -L$(THISDIR)thirdparty/nugget/psyq/lib -L$(THISDIR)psyq-4_7-converted/lib -L$(THISDIR)psyq-4.7-converted-full/lib -L$(THISDIR)psyq/lib -L$(THISDIR)../psyq/lib
|
||||
@ -37,10 +40,18 @@ LDFLAGS += -Wl,--end-group
|
||||
|
||||
include $(THISDIR)thirdparty/nugget/common.mk
|
||||
|
||||
define OBJCOPYME
|
||||
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips $< $@
|
||||
endef
|
||||
|
||||
# convert TIM file to bin
|
||||
%.o: %.tim
|
||||
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips $< $@
|
||||
$(call OBJCOPYME)
|
||||
|
||||
# convert VAG files to bin
|
||||
%.o: %.vag
|
||||
$(PREFIX)-objcopy -I binary --set-section-alignment .data=4 --rename-section .data=.rodata,alloc,load,readonly,data,contents -O $(FORMAT) -B mips $< $@
|
||||
$(call OBJCOPYME)
|
||||
|
||||
# convert HIT to bin
|
||||
%.o: %.HIT
|
||||
$(call OBJCOPYME)
|
@ -13,10 +13,11 @@
|
||||
<!--<license file="LICENSEE.DAT"/>-->
|
||||
<directory_tree>
|
||||
<file name="system.cnf" type="data" source="config/3dcam.cnf"/>
|
||||
<file name="SCES_313.37" type="data" source="main.ps-exe"/>
|
||||
<file name="SCES_313.37" type="data" source="3dcam.ps-exe"/>
|
||||
<file name="LEVEL0.bin" type="data" source="Overlay.lvl0" />
|
||||
<file name="LEVEL1.bin" type="data" source="Overlay.lvl1" />
|
||||
<file name="INTER8.XA" type="xa" source="xa/inter8.xa"/>
|
||||
<file name="INTER8.XA" type="xa" source="XA/inter8.xa"/>
|
||||
<file name="INTER_0.XA" type="xa" source="XA/inter_0.xa"/>
|
||||
|
||||
<dummy sectors="1024"/>
|
||||
</directory_tree>
|
||||
|
168
custom_types.h
168
custom_types.h
@ -1,168 +0,0 @@
|
||||
#pragma once
|
||||
#include <sys/types.h>
|
||||
#include <libgte.h>
|
||||
#include <libgpu.h>
|
||||
|
||||
struct BODY;
|
||||
struct VANIM;
|
||||
struct PRIM;
|
||||
struct MESH;
|
||||
struct CAMPOS;
|
||||
struct CAMPATH;
|
||||
struct CAMANGLE;
|
||||
struct SIBLINGS;
|
||||
struct CHILDREN;
|
||||
struct NODE;
|
||||
struct LEVEL;
|
||||
struct VAGsound;
|
||||
struct VAGbank;
|
||||
struct XAbank;
|
||||
struct XAsound;
|
||||
|
||||
typedef struct BODY {
|
||||
VECTOR gForce;
|
||||
VECTOR position;
|
||||
SVECTOR velocity;
|
||||
int mass;
|
||||
int invMass;
|
||||
VECTOR min;
|
||||
VECTOR max;
|
||||
int restitution;
|
||||
} BODY;
|
||||
|
||||
typedef struct VANIM {
|
||||
int nframes; // number of frames e.g 20
|
||||
int nvert; // number of vertices e.g 21
|
||||
int cursor; // anim cursor
|
||||
int lerpCursor; // anim cursor
|
||||
int dir; // playback direction (1 or -1)
|
||||
int interpolate; // use lerp to interpolate keyframes
|
||||
SVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
|
||||
} VANIM;
|
||||
|
||||
typedef struct PRIM {
|
||||
VECTOR order;
|
||||
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
||||
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
||||
} PRIM;
|
||||
|
||||
typedef struct MESH {
|
||||
int totalVerts;
|
||||
TMESH * tmesh;
|
||||
PRIM * index;
|
||||
TIM_IMAGE * tim;
|
||||
unsigned long * tim_data;
|
||||
MATRIX mat;
|
||||
VECTOR pos;
|
||||
SVECTOR rot;
|
||||
short isProp;
|
||||
short isRigidBody;
|
||||
short isStaticBody;
|
||||
short isRound;
|
||||
short isPrism;
|
||||
short isAnim;
|
||||
short isActor;
|
||||
short isLevel;
|
||||
short isWall;
|
||||
short isBG;
|
||||
short isSprite;
|
||||
long p;
|
||||
long OTz;
|
||||
BODY * body;
|
||||
VANIM * anim;
|
||||
struct NODE * node;
|
||||
VECTOR pos2D;
|
||||
} MESH;
|
||||
|
||||
typedef struct QUAD {
|
||||
VECTOR v0, v1;
|
||||
VECTOR v2, v3;
|
||||
} QUAD;
|
||||
|
||||
typedef struct CAMPOS {
|
||||
SVECTOR pos;
|
||||
SVECTOR rot;
|
||||
} CAMPOS;
|
||||
|
||||
|
||||
// Blender cam ~= PSX cam with these settings :
|
||||
// NTSC - 320x240, PAL 320x256, pixel ratio 1:1,
|
||||
// cam focal length : perspective 90° ( 16 mm ))
|
||||
// With a FOV of 1/2, camera focal length is ~= 16 mm / 90°
|
||||
// Lower values mean wider angle
|
||||
|
||||
typedef struct CAMANGLE {
|
||||
CAMPOS * campos;
|
||||
TIM_IMAGE * BGtim;
|
||||
unsigned long * tim_data;
|
||||
QUAD bw, fw;
|
||||
int index;
|
||||
MESH * objects[];
|
||||
} CAMANGLE;
|
||||
|
||||
typedef struct CAMPATH {
|
||||
short len, cursor, pos;
|
||||
VECTOR points[];
|
||||
} CAMPATH;
|
||||
|
||||
typedef struct SIBLINGS {
|
||||
int index;
|
||||
struct NODE * list[];
|
||||
} SIBLINGS ;
|
||||
|
||||
typedef struct CHILDREN {
|
||||
int index;
|
||||
MESH * list[];
|
||||
} CHILDREN ;
|
||||
|
||||
typedef struct NODE {
|
||||
MESH * plane;
|
||||
SIBLINGS * siblings;
|
||||
CHILDREN * objects;
|
||||
CHILDREN * rigidbodies;
|
||||
} NODE;
|
||||
|
||||
typedef struct VAGsound {
|
||||
u_char * VAGfile; // Pointer to VAG data address
|
||||
u_long spu_channel; // SPU voice to playback to
|
||||
u_long spu_address; // SPU address for memory freeing spu mem
|
||||
} VAGsound;
|
||||
|
||||
typedef struct VAGbank {
|
||||
u_int index;
|
||||
VAGsound samples[];
|
||||
} VAGbank;
|
||||
|
||||
// XA
|
||||
typedef struct XAsound {
|
||||
u_int id;
|
||||
u_int size;
|
||||
u_char file, channel;
|
||||
u_int start, end;
|
||||
int cursor;
|
||||
} XAsound;
|
||||
|
||||
typedef struct XAbank {
|
||||
char name[16];
|
||||
u_int index;
|
||||
int offset;
|
||||
XAsound samples[];
|
||||
} XAbank;
|
||||
|
||||
typedef struct LEVEL {
|
||||
CVECTOR * BGc;
|
||||
VECTOR * BKc;
|
||||
MATRIX * cmat;
|
||||
MATRIX * lgtmat;
|
||||
MESH ** meshes;
|
||||
int * meshes_length;
|
||||
MESH * actorPtr;
|
||||
MESH * levelPtr;
|
||||
MESH * propPtr;
|
||||
CAMANGLE * camPtr;
|
||||
CAMPATH * camPath;
|
||||
CAMANGLE ** camAngles;
|
||||
NODE * curNode;
|
||||
VAGbank * VAG;
|
||||
XAbank * XA;
|
||||
} LEVEL;
|
210
include/custom_types.h
Normal file
210
include/custom_types.h
Normal file
@ -0,0 +1,210 @@
|
||||
#pragma once
|
||||
#include <sys/types.h>
|
||||
#include <libgte.h>
|
||||
#include <stdint.h>
|
||||
#include <libgpu.h>
|
||||
|
||||
struct BODY;
|
||||
struct BVECTOR;
|
||||
struct VANIM;
|
||||
struct MESH_ANIMS_TRACKS;
|
||||
struct PRIM;
|
||||
struct MESH;
|
||||
struct CAMPOS;
|
||||
struct CAMPATH;
|
||||
struct CAMANGLE;
|
||||
struct SIBLINGS;
|
||||
struct CHILDREN;
|
||||
struct NODE;
|
||||
struct QUAD;
|
||||
struct LEVEL;
|
||||
struct VAGsound;
|
||||
struct VAGbank;
|
||||
struct XAsound;
|
||||
struct XAbank;
|
||||
struct XAfiles;
|
||||
struct SOUND_OBJECT;
|
||||
struct LEVEL_SOUNDS;
|
||||
|
||||
typedef struct BODY {
|
||||
VECTOR gForce;
|
||||
VECTOR position;
|
||||
SVECTOR velocity;
|
||||
int mass;
|
||||
int invMass;
|
||||
VECTOR min;
|
||||
VECTOR max;
|
||||
int restitution;
|
||||
SVECTOR normal;
|
||||
} BODY;
|
||||
|
||||
typedef struct BVECTOR {
|
||||
int8_t vx, vy;
|
||||
int8_t vz;
|
||||
// int8_t factor; // could be useful for anims where delta is > 256
|
||||
} BVECTOR;
|
||||
|
||||
typedef struct VANIM {
|
||||
int nframes; // number of frames e.g 20
|
||||
int nvert; // number of vertices e.g 21
|
||||
int cursor; // anim cursor : -1 == not playing, n>=0 == current frame number
|
||||
int lerpCursor; // anim cursor
|
||||
int loop; // loop anim : -1 == infinite, n>0 == play n times
|
||||
int dir; // playback direction (1 or -1)
|
||||
int pingpong; // ping pong animation (A>B>A)
|
||||
int interpolate; // use lerp to interpolate keyframes
|
||||
BVECTOR data[]; // vertex pos as SVECTORs e.g 20 * 21 SVECTORS
|
||||
} VANIM;
|
||||
|
||||
typedef struct MESH_ANIMS_TRACKS {
|
||||
u_short index;
|
||||
VANIM * strips[];
|
||||
} MESH_ANIMS_TRACKS;
|
||||
|
||||
typedef struct PRIM {
|
||||
VECTOR order;
|
||||
int code; // Same as POL3/POL4 codes : Code (F3 = 1, FT3 = 2, G3 = 3,
|
||||
// GT3 = 4) Code (F4 = 5, FT4 = 6, G4 = 7, GT4 = 8)
|
||||
} PRIM;
|
||||
|
||||
typedef struct MESH {
|
||||
int totalVerts;
|
||||
TMESH * tmesh;
|
||||
PRIM * index;
|
||||
TIM_IMAGE * tim;
|
||||
unsigned long * tim_data;
|
||||
MATRIX mat;
|
||||
VECTOR pos;
|
||||
SVECTOR rot;
|
||||
short isProp;
|
||||
short isRigidBody;
|
||||
short isStaticBody;
|
||||
short isRound;
|
||||
short isPrism;
|
||||
short isAnim;
|
||||
short isActor;
|
||||
short isLevel;
|
||||
short isWall;
|
||||
short isBG;
|
||||
short isSprite;
|
||||
long p;
|
||||
long OTz;
|
||||
BODY * body;
|
||||
MESH_ANIMS_TRACKS * anim_tracks;
|
||||
VANIM * currentAnim;
|
||||
struct NODE * node;
|
||||
VECTOR pos2D;
|
||||
} MESH;
|
||||
|
||||
typedef struct QUAD {
|
||||
VECTOR v0, v1;
|
||||
VECTOR v2, v3;
|
||||
} QUAD;
|
||||
|
||||
typedef struct CAMPOS {
|
||||
SVECTOR pos;
|
||||
SVECTOR rot;
|
||||
} CAMPOS;
|
||||
|
||||
|
||||
// Blender cam ~= PSX cam with these settings :
|
||||
// NTSC - 320x240, PAL 320x256, pixel ratio 1:1,
|
||||
// cam focal length : perspective 90° ( 16 mm ))
|
||||
// With a FOV of 1/2, camera focal length is ~= 16 mm / 90°
|
||||
// Lower values mean wider angle
|
||||
|
||||
typedef struct CAMANGLE {
|
||||
CAMPOS * campos;
|
||||
TIM_IMAGE * BGtim;
|
||||
unsigned long * tim_data;
|
||||
QUAD bw, fw;
|
||||
int index;
|
||||
MESH * objects[];
|
||||
} CAMANGLE;
|
||||
|
||||
typedef struct CAMPATH {
|
||||
short len, cursor, pos;
|
||||
VECTOR points[];
|
||||
} CAMPATH;
|
||||
|
||||
typedef struct SIBLINGS {
|
||||
int index;
|
||||
struct NODE * list[];
|
||||
} SIBLINGS ;
|
||||
|
||||
typedef struct CHILDREN {
|
||||
int index;
|
||||
MESH * list[];
|
||||
} CHILDREN ;
|
||||
|
||||
typedef struct NODE {
|
||||
MESH * plane;
|
||||
SIBLINGS * siblings;
|
||||
CHILDREN * objects;
|
||||
CHILDREN * rigidbodies;
|
||||
} NODE;
|
||||
|
||||
//VAG
|
||||
typedef struct VAGsound {
|
||||
u_char * VAGfile; // Pointer to VAG data address
|
||||
u_long spu_channel; // SPU voice to playback to
|
||||
u_long spu_address; // SPU address for memory freeing spu mem
|
||||
} VAGsound;
|
||||
|
||||
typedef struct VAGbank {
|
||||
u_int index;
|
||||
VAGsound samples[];
|
||||
} VAGbank;
|
||||
|
||||
// XA
|
||||
typedef struct XAsound {
|
||||
u_int id;
|
||||
u_int size;
|
||||
u_char file, channel;
|
||||
u_int start, end;
|
||||
int cursor;
|
||||
} XAsound;
|
||||
|
||||
typedef struct XAbank {
|
||||
char name[16];
|
||||
u_int index;
|
||||
int offset;
|
||||
XAsound samples[];
|
||||
} XAbank;
|
||||
|
||||
typedef struct XAfiles {
|
||||
u_int index;
|
||||
XAbank * banks[];
|
||||
} XAfiles;
|
||||
|
||||
typedef struct SOUND_OBJECT {
|
||||
VECTOR location;
|
||||
int volumeL, volumeR, volume_min, volume_max;
|
||||
VAGsound * VAGsample;
|
||||
XAsound * XAsample;
|
||||
MESH * parent;
|
||||
} SOUND_OBJECT;
|
||||
|
||||
typedef struct LEVEL_SOUNDS {
|
||||
int index;
|
||||
SOUND_OBJECT * sounds[];
|
||||
} LEVEL_SOUNDS;
|
||||
|
||||
typedef struct LEVEL {
|
||||
CVECTOR * BGc;
|
||||
VECTOR * BKc;
|
||||
MATRIX * cmat;
|
||||
MATRIX * lgtmat;
|
||||
MESH ** meshes;
|
||||
int * meshes_length;
|
||||
MESH * actorPtr;
|
||||
MESH * levelPtr;
|
||||
MESH * propPtr;
|
||||
CAMANGLE * camPtr;
|
||||
CAMPATH * camPath;
|
||||
CAMANGLE ** camAngles;
|
||||
NODE * curNode;
|
||||
LEVEL_SOUNDS * levelSounds;
|
||||
VAGbank * VAG;
|
||||
XAfiles * XA;
|
||||
} LEVEL;
|
@ -10,7 +10,19 @@
|
||||
#define CLEAR_COLOR_G 0
|
||||
#define CLEAR_COLOR_B 0
|
||||
|
||||
#define CAM_DIST_TO_ACT 200
|
||||
#define CAM_DIST_TO_GND 100
|
||||
|
||||
// Sound
|
||||
// Sound engine
|
||||
#define SND_DIST_MIN 200
|
||||
#define SND_DIST_MAX 800
|
||||
#define SND_ATTENUATION 6144
|
||||
#define SND_MAX_VOL 16383
|
||||
#define SND_RANGE (SND_DIST_MAX - SND_DIST_MIN)
|
||||
#define SND_NMALIZED (SND_RANGE * SND_ATTENUATION / SND_MAX_VOL)
|
||||
#define SND_DZ 32
|
||||
// SPU channels
|
||||
#define SPU_00CH (0x1L<< 0)
|
||||
#define SPU_01CH (0x1L<< 1)
|
||||
#define SPU_02CH (0x1L<< 2)
|
||||
@ -19,7 +31,23 @@
|
||||
#define SPU_05CH (0x1L<< 5)
|
||||
#define SPU_06CH (0x1L<< 6)
|
||||
#define SPU_07CH (0x1L<< 7)
|
||||
#define SPU_08CH (0x1L<< 8)
|
||||
#define SPU_09CH (0x1L<< 9)
|
||||
#define SPU_10CH (0x1L<<10)
|
||||
#define SPU_11CH (0x1L<<11)
|
||||
#define SPU_12CH (0x1L<<12)
|
||||
#define SPU_13CH (0x1L<<13)
|
||||
#define SPU_14CH (0x1L<<14)
|
||||
#define SPU_15CH (0x1L<<15)
|
||||
#define SPU_16CH (0x1L<<16)
|
||||
#define SPU_17CH (0x1L<<17)
|
||||
#define SPU_18CH (0x1L<<18)
|
||||
#define SPU_19CH (0x1L<<19)
|
||||
|
||||
#define SPU_20CH (0x1L<<20)
|
||||
#define SPU_21CH (0x1L<<21)
|
||||
#define SPU_22CH (0x1L<<22)
|
||||
#define SPU_23CH (0x1L<<23)
|
||||
// CDDA / XA volume
|
||||
#define XA_CHANNELS 8
|
||||
#define MVOL_L 0x3fff
|
||||
@ -33,9 +61,9 @@
|
||||
#define FNT_VRAM_X 960
|
||||
#define FNT_VRAM_Y 256
|
||||
#define FNT_SCR_X 16
|
||||
#define FNT_SCR_Y 168
|
||||
#define FNT_SCR_Y 150
|
||||
#define FNT_SCR_W 240
|
||||
#define FNT_SCR_H 48
|
||||
#define FNT_SCR_H 88
|
||||
#define FNT_SCR_BG 0
|
||||
#define FNT_SCR_MAX_CHAR 512
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
#include "../include/camera.h"
|
||||
#include "../include/physics.h"
|
||||
#include "../include/defines.h"
|
||||
#include <camera.h>
|
||||
#include <physics.h>
|
||||
#include <defines.h>
|
||||
|
||||
// Drawing
|
||||
void updateLight(void);
|
||||
@ -10,18 +10,22 @@ void enlightMesh(LEVEL * curLvl, MESH * actorPtr, SVECTOR * lgtang);
|
||||
void drawPoly(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw);
|
||||
// Tri drawing
|
||||
long drawTri(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw, int t, int i);
|
||||
void set3VertexPos(MESH * mesh, long t, int atime);
|
||||
void set3VertexLerPos(MESH * mesh, long t);
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, char * db, int i, int t);
|
||||
void set3Tex(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, long t, int i);
|
||||
long interpolateTri(POLY_GT3 * poly, MESH * mesh, long t);
|
||||
void interpolateTri(POLY_GT3 * poly, MESH * mesh, long t);
|
||||
//Quad drawing
|
||||
long drawQuad(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * ot, char * db, DRAWENV * draw, int t, int i);
|
||||
void set4VertexPos(MESH * mesh, long t, int atime);
|
||||
void set4VertexLerPos(MESH * mesh, long t);
|
||||
void set4Prism(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, char * db, int i, int t);
|
||||
void set4Tex(POLY_GT4 * poly4, MESH * mesh, DRAWENV * draw, long t, int i);
|
||||
int set4Subdiv(MESH * mesh, POLY_GT4 * poly4, u_long * ot, long t, int i, char ** nextpri);
|
||||
long interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t);
|
||||
void interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t);
|
||||
//2D drawing
|
||||
void drawBG(CAMANGLE * camPtr, char ** nextpri, u_long * otdisc, char * db);
|
||||
// Rendering
|
||||
void renderScene(LEVEL * curLvl, CAMERA * camera, int * camMode, char ** nextpri, u_long * ot, u_long * otdisc, char * db, DRAWENV * draw, short curCamAngle, int atime);
|
||||
// Animation
|
||||
void playAnim(MESH * mesh, VANIM * anim, int loop);
|
||||
|
@ -15,10 +15,11 @@
|
||||
#define max(a,b) \
|
||||
(a)-(b)>0?(a):(b)
|
||||
// add 2 vector and store in a third vector
|
||||
#define addVector2(v0, v1, v2) \
|
||||
(v2)->vx = (v0)->vx + (v1)->vx, \
|
||||
(v2)->vy = (v0)->vy + (v1)->vy, \
|
||||
(v2)->vz = (v0)->vz + (v1)->vz \
|
||||
#define addVector2(v0, v1, v2) \
|
||||
(v2)->vx = (v0)->vx + (v1)->vx, \
|
||||
(v2)->vy = (v0)->vy + (v1)->vy, \
|
||||
(v2)->vz = (v0)->vz + (v1)->vz, \
|
||||
(v2)->pad = (v0)->pad + (v1)->pad \
|
||||
|
||||
// substract vector
|
||||
#define subVector(v0, v1) \
|
||||
|
@ -3,10 +3,9 @@
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <libgte.h>
|
||||
#include "../include/macros.h"
|
||||
|
||||
#include <macros.h>
|
||||
// Precalculated arctan values
|
||||
#include "../src/atan.c"
|
||||
#include <atan.h>
|
||||
|
||||
// fixed point math
|
||||
int32_t dMul(int32_t a, int32_t b);
|
||||
@ -33,3 +32,5 @@ long long easeIn(long long i);
|
||||
int easeOut(int i);
|
||||
//~ int easeInOut(int i, int div);
|
||||
VECTOR getVectorTo(VECTOR actor, VECTOR target);
|
||||
|
||||
int32_t round( int32_t n);
|
||||
|
@ -3,18 +3,21 @@
|
||||
#include <libgte.h>
|
||||
#include <libetc.h>
|
||||
#include <libgpu.h>
|
||||
#include "../include/defines.h"
|
||||
#include "../include/math.h"
|
||||
#include "../include/macros.h"
|
||||
#include "../custom_types.h"
|
||||
#include <defines.h>
|
||||
#include <math.h>
|
||||
#include <macros.h>
|
||||
#include <custom_types.h>
|
||||
#include "../thirdparty/nugget/common/syscalls/syscalls.h"
|
||||
#define printf ramsyscall_printf
|
||||
|
||||
short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh );
|
||||
short checkLineS( VECTOR * pointA, VECTOR * pointB, MESH * mesh );
|
||||
VECTOR getIntCollision(BODY one, BODY two);
|
||||
VECTOR getExtCollision(BODY one, BODY two);
|
||||
void checkBodyCol(BODY * one, BODY * two);
|
||||
VECTOR checkBodyCol(BODY * one, BODY * two);
|
||||
void applyAngMom(LEVEL curLvl );
|
||||
void ResolveCollision( BODY * one, BODY * two );
|
||||
VECTOR angularMom(BODY body);
|
||||
void applyAcceleration(BODY * actor, int dt);
|
||||
u_int jump(BODY * actor, int dt);
|
||||
void respawnMesh(LEVEL * level, MESH * mesh, VECTOR * rot, VECTOR * pos, NODE * node);
|
||||
|
@ -10,8 +10,11 @@
|
||||
#include <string.h>
|
||||
#include <inline_n.h>
|
||||
#include <gtemac.h>
|
||||
#include "../include/defines.h"
|
||||
#include "../custom_types.h"
|
||||
#include <defines.h>
|
||||
#include <stdint.h>
|
||||
#include <custom_types.h>
|
||||
#include "../thirdparty/nugget/common/syscalls/syscalls.h"
|
||||
#define printf ramsyscall_printf
|
||||
|
||||
// PSX setup
|
||||
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng);
|
||||
|
@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "../include/psx.h"
|
||||
#include "../include/macros.h"
|
||||
#include <psx.h>
|
||||
#include <camera.h>
|
||||
#include <math.h>
|
||||
#include <macros.h>
|
||||
// XA
|
||||
// Sector offset for XA data 4: simple speed, 8: double speed
|
||||
#define XA_CHANNELS 8
|
||||
@ -8,20 +10,8 @@
|
||||
#define XA_RATE 380
|
||||
// Number of XA samples ( != # of XA files )
|
||||
#define XA_TRACKS 2
|
||||
// VAG
|
||||
// Number of VAG files to load
|
||||
#define VAG_NBR 8
|
||||
#define MALLOC_MAX VAG_NBR // Max number of time we can call SpuMalloc
|
||||
// Custom struct to handle VAG files
|
||||
//~ typedef struct VAGsound {
|
||||
//~ u_char * VAGfile; // Pointer to VAG data address
|
||||
//~ u_long spu_channel; // SPU voice to playback to
|
||||
//~ u_long spu_address; // SPU address for memory freeing spu mem
|
||||
//~ } VAGsound;
|
||||
//~ typedef struct VAGbank {
|
||||
//~ u_int index;
|
||||
//~ VAGsound samples[];
|
||||
//~ } VAGbank;
|
||||
// SPU
|
||||
#define MALLOC_MAX 48 // Max number of time we can call SpuMalloc
|
||||
// VAG header struct (see fileformat47.pdf, p.209)
|
||||
typedef struct VAGhdr { // All the values in this header must be big endian
|
||||
char id[4]; // VAGp 4 bytes -> 1 char * 4
|
||||
@ -33,29 +23,18 @@ typedef struct VAGhdr { // All the values in this header must be
|
||||
char name[16]; // 16 bytes -> 1 char * 16
|
||||
// Waveform data after that
|
||||
} VAGhdr;
|
||||
//~ // XA
|
||||
//~ typedef struct XAsound {
|
||||
//~ u_int id;
|
||||
//~ u_int size;
|
||||
//~ u_char file, channel;
|
||||
//~ u_int start, end;
|
||||
//~ int cursor;
|
||||
//~ } XAsound;
|
||||
|
||||
//~ typedef struct XAbank {
|
||||
//~ char * name;
|
||||
//~ u_int index;
|
||||
//~ int offset;
|
||||
//~ XAsound samples[];
|
||||
//~ } XAbank;
|
||||
|
||||
// VAG playback
|
||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec);
|
||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax);
|
||||
u_long sendVAGtoSPU(unsigned int VAG_data_size, u_char *VAG_data);
|
||||
void setVoiceAttr(SpuVoiceAttr * voiceAttributes, u_int pitch, long channel, u_long soundAddr );
|
||||
u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound);
|
||||
void setVAGvolume(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volumeL,int volumeR);
|
||||
void setLvlVAG(LEVEL * level, SpuCommonAttr * spuSettings, SpuVoiceAttr * voiceAttributes, char spu_malloc_rec[]);
|
||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volumeL, int volumeR );
|
||||
void setSFXdist(LEVEL * level, CAMERA * camera, int camMode);
|
||||
// XA playback
|
||||
void XAsetup(void);
|
||||
void getXAoffset(LEVEL * level);
|
||||
void setXAsample(XAsound * sound, CdlFILTER * filter);
|
||||
void setLvlXA(LEVEL * level, int sample);
|
||||
void XAplayback(LEVEL * level, int sample, long dt);
|
||||
|
@ -2,7 +2,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <libgte.h>
|
||||
#include <libgpu.h>
|
||||
#include "../include/defines.h"
|
||||
#include <defines.h>
|
||||
|
||||
int cliptest3(short * v1);
|
||||
void worldToScreen( VECTOR * worldPos, VECTOR * screenPos );
|
||||
|
17
include/stdint.h
Normal file
17
include/stdint.h
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* STDINT based on ansi c for PSYQ
|
||||
*
|
||||
* John Convertino
|
||||
* https://github.com/electrobs/PSYQ_Examples/blob/master/PSYQ_MODS/STDINT.h
|
||||
*/
|
||||
#ifndef STDINT_H
|
||||
#define STDINT_H
|
||||
typedef char int8_t;
|
||||
typedef short int16_t;
|
||||
typedef int int32_t;
|
||||
typedef long long int64_t;
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#endif
|
@ -1,2 +1,2 @@
|
||||
#!/bin/bash
|
||||
make && ~/bin/mkpsxiso -y config/3dcam.xml && pcsx-redux -run -iso 3dcam.cue
|
||||
make && ~/bin/mkpsxiso -y config/3dcam.xml && prime-run pcsx-redux -run -iso 3dcam.cue
|
||||
|
6099
levels/level0.c
6099
levels/level0.c
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,16 @@
|
||||
#pragma once
|
||||
#include "../custom_types.h"
|
||||
#include "../include/defines.h"
|
||||
#include <custom_types.h>
|
||||
#include <defines.h>
|
||||
|
||||
extern LEVEL level0;
|
||||
extern CVECTOR level0_BGc;
|
||||
extern VECTOR level0_BKc;
|
||||
extern MESH_ANIMS_TRACKS level0_modelCube_001_anims;
|
||||
extern VANIM level0_modelCube_001_anim_KeyAction_003;
|
||||
extern VANIM level0_modelCube_001_anim_KeyAction_001;
|
||||
extern VANIM level0_modelCube_001_anim_KeyAction_002;
|
||||
extern VANIM level0_modelCube_001_anim_KeyAction;
|
||||
extern VANIM level0_modelCube_001_anim_KeyAction_004;
|
||||
extern CAMPOS level0_camPos_Camera;
|
||||
extern CAMPATH level0_camPath;
|
||||
extern MATRIX level0_lgtmat;
|
||||
@ -16,14 +22,58 @@ extern PRIM level0_modelCube_index[];
|
||||
extern BODY level0_modelCube_body;
|
||||
extern TMESH level0_modelCube;
|
||||
extern MESH level0_meshCube;
|
||||
extern SVECTOR modelPlane_mesh[];
|
||||
extern SVECTOR level0_modelPlane_normal[];
|
||||
extern CVECTOR level0_modelPlane_color[];
|
||||
extern PRIM level0_modelPlane_index[];
|
||||
extern BODY level0_modelPlane_body;
|
||||
extern TMESH level0_modelPlane;
|
||||
extern MESH level0_meshPlane;
|
||||
extern MESH * level0_meshes[2];
|
||||
extern SVECTOR modelCube_001_mesh[];
|
||||
extern SVECTOR level0_modelCube_001_normal[];
|
||||
extern CVECTOR level0_modelCube_001_color[];
|
||||
extern PRIM level0_modelCube_001_index[];
|
||||
extern BODY level0_modelCube_001_body;
|
||||
extern TMESH level0_modelCube_001;
|
||||
extern MESH level0_meshCube_001;
|
||||
extern SVECTOR modelPlane_000_mesh[];
|
||||
extern SVECTOR level0_modelPlane_000_normal[];
|
||||
extern SVECTOR level0_modelPlane_000_uv[];
|
||||
extern CVECTOR level0_modelPlane_000_color[];
|
||||
extern PRIM level0_modelPlane_000_index[];
|
||||
extern BODY level0_modelPlane_000_body;
|
||||
extern TMESH level0_modelPlane_000;
|
||||
extern unsigned long _binary_TIM_woods_tim_start[];
|
||||
extern unsigned long _binary_TIM_woods_tim_end[];
|
||||
extern unsigned long _binary_TIM_woods_tim_length;
|
||||
extern TIM_IMAGE level0_tim_woods;
|
||||
extern MESH level0_meshPlane_000;
|
||||
extern SVECTOR modelPlane_001_mesh[];
|
||||
extern SVECTOR level0_modelPlane_001_normal[];
|
||||
extern SVECTOR level0_modelPlane_001_uv[];
|
||||
extern CVECTOR level0_modelPlane_001_color[];
|
||||
extern PRIM level0_modelPlane_001_index[];
|
||||
extern BODY level0_modelPlane_001_body;
|
||||
extern TMESH level0_modelPlane_001;
|
||||
extern MESH level0_meshPlane_001;
|
||||
extern SVECTOR modelPlane_002_mesh[];
|
||||
extern SVECTOR level0_modelPlane_002_normal[];
|
||||
extern SVECTOR level0_modelPlane_002_uv[];
|
||||
extern CVECTOR level0_modelPlane_002_color[];
|
||||
extern PRIM level0_modelPlane_002_index[];
|
||||
extern BODY level0_modelPlane_002_body;
|
||||
extern TMESH level0_modelPlane_002;
|
||||
extern MESH level0_meshPlane_002;
|
||||
extern SVECTOR modelPlane_005_mesh[];
|
||||
extern SVECTOR level0_modelPlane_005_normal[];
|
||||
extern SVECTOR level0_modelPlane_005_uv[];
|
||||
extern CVECTOR level0_modelPlane_005_color[];
|
||||
extern PRIM level0_modelPlane_005_index[];
|
||||
extern BODY level0_modelPlane_005_body;
|
||||
extern TMESH level0_modelPlane_005;
|
||||
extern MESH level0_meshPlane_005;
|
||||
extern SVECTOR modelPlane_006_mesh[];
|
||||
extern SVECTOR level0_modelPlane_006_normal[];
|
||||
extern SVECTOR level0_modelPlane_006_uv[];
|
||||
extern CVECTOR level0_modelPlane_006_color[];
|
||||
extern PRIM level0_modelPlane_006_index[];
|
||||
extern BODY level0_modelPlane_006_body;
|
||||
extern TMESH level0_modelPlane_006;
|
||||
extern MESH level0_meshPlane_006;
|
||||
extern MESH * level0_meshes[7];
|
||||
extern int level0_meshes_length;
|
||||
extern CAMANGLE level0_camAngle_Camera;
|
||||
extern CAMANGLE * level0_camAngles[0];
|
||||
@ -36,6 +86,18 @@ extern MESH * level0_levelPtr;
|
||||
extern MESH * level0_propPtr;
|
||||
extern CAMANGLE * level0_camPtr;
|
||||
extern NODE * level0_curNode;
|
||||
extern VAGbank level0_VAGBank;
|
||||
extern XAbank level0_XABank_0;
|
||||
extern XAfiles level0_XAFiles;
|
||||
extern SOUND_OBJECT level0_Speaker;
|
||||
extern SOUND_OBJECT level0_Speaker_001;
|
||||
extern SOUND_OBJECT level0_Speaker_003;
|
||||
extern SOUND_OBJECT level0_Speaker_004;
|
||||
extern SOUND_OBJECT level0_Speaker_005;
|
||||
extern SOUND_OBJECT level0_Speaker_006;
|
||||
extern SOUND_OBJECT level0_Speaker_007;
|
||||
extern SOUND_OBJECT level0_Speaker_008;
|
||||
extern SOUND_OBJECT level0_Speaker_009;
|
||||
extern SOUND_OBJECT level0_Speaker_010;
|
||||
extern LEVEL_SOUNDS level0_sounds;
|
||||
extern NODE level0_nodePlane;
|
||||
extern VAGbank VAGBank0;
|
||||
extern XAbank XABank0;
|
||||
|
22503
levels/level1.c
22503
levels/level1.c
File diff suppressed because it is too large
Load Diff
@ -1,10 +1,14 @@
|
||||
#pragma once
|
||||
#include "../custom_types.h"
|
||||
#include "../include/defines.h"
|
||||
#include <custom_types.h>
|
||||
#include <defines.h>
|
||||
|
||||
extern LEVEL level1;
|
||||
extern CVECTOR level1_BGc;
|
||||
extern VECTOR level1_BKc;
|
||||
extern MESH_ANIMS_TRACKS level1_modelCube_anims;
|
||||
extern VANIM level1_modelCube_anim_Cube;
|
||||
extern MESH_ANIMS_TRACKS level1_modelCylindre_anims;
|
||||
extern VANIM level1_modelCylindre_anim_Cylindre;
|
||||
extern CAMPOS level1_camPos_camPath;
|
||||
extern CAMPOS level1_camPos_camPath_001;
|
||||
extern CAMPOS level1_camPos_camPath_002;
|
||||
@ -31,7 +35,6 @@ extern SVECTOR level1_modelCylindre_normal[];
|
||||
extern SVECTOR level1_modelCylindre_uv[];
|
||||
extern CVECTOR level1_modelCylindre_color[];
|
||||
extern PRIM level1_modelCylindre_index[];
|
||||
extern VANIM level1_modelCylindre_anim;
|
||||
extern BODY level1_modelCylindre_body;
|
||||
extern TMESH level1_modelCylindre;
|
||||
extern unsigned long _binary_TIM_home_tim_start[];
|
||||
@ -151,6 +154,14 @@ extern MESH * level1_meshes[15];
|
||||
extern int level1_meshes_length;
|
||||
extern CAMANGLE level1_camAngle_camPath_001;
|
||||
extern CAMANGLE * level1_camAngles[0];
|
||||
extern SIBLINGS level1_nodegnd_siblings;
|
||||
extern CHILDREN level1_nodegnd_objects;
|
||||
extern CHILDREN level1_nodegnd_rigidbodies;
|
||||
extern NODE level1_nodegnd;
|
||||
extern SIBLINGS level1_nodegnd_002_siblings;
|
||||
extern CHILDREN level1_nodegnd_002_objects;
|
||||
extern CHILDREN level1_nodegnd_002_rigidbodies;
|
||||
extern NODE level1_nodegnd_002;
|
||||
extern SIBLINGS level1_nodegnd_001_siblings;
|
||||
extern CHILDREN level1_nodegnd_001_objects;
|
||||
extern CHILDREN level1_nodegnd_001_rigidbodies;
|
||||
@ -159,22 +170,12 @@ extern SIBLINGS level1_nodegnd_003_siblings;
|
||||
extern CHILDREN level1_nodegnd_003_objects;
|
||||
extern CHILDREN level1_nodegnd_003_rigidbodies;
|
||||
extern NODE level1_nodegnd_003;
|
||||
extern SIBLINGS level1_nodegnd_002_siblings;
|
||||
extern CHILDREN level1_nodegnd_002_objects;
|
||||
extern CHILDREN level1_nodegnd_002_rigidbodies;
|
||||
extern NODE level1_nodegnd_002;
|
||||
extern SIBLINGS level1_nodegnd_siblings;
|
||||
extern CHILDREN level1_nodegnd_objects;
|
||||
extern CHILDREN level1_nodegnd_rigidbodies;
|
||||
extern NODE level1_nodegnd;
|
||||
extern MESH * level1_actorPtr;
|
||||
extern MESH * level1_levelPtr;
|
||||
extern MESH * level1_propPtr;
|
||||
extern CAMANGLE * level1_camPtr;
|
||||
extern NODE * level1_curNode;
|
||||
extern NODE level1_nodegnd;
|
||||
extern NODE level1_nodegnd_002;
|
||||
extern NODE level1_nodegnd_001;
|
||||
extern NODE level1_nodegnd_003;
|
||||
extern NODE level1_nodegnd_002;
|
||||
extern NODE level1_nodegnd;
|
||||
extern VAGbank VAGBank1;
|
||||
extern XAbank XABank1;
|
||||
|
14
overlay.ld
14
overlay.ld
@ -14,20 +14,20 @@ SECTIONS {
|
||||
KEEP(levels/level0.o(.text.startup._GLOBAL__*))
|
||||
KEEP(levels/level0.o(.text.*))
|
||||
KEEP(levels/level0.o(.rodata*))
|
||||
KEEP(levels/level0.o(.sdata*))
|
||||
KEEP(levels/level0.o(.sdata*))
|
||||
KEEP(levels/level0.o(.data*))
|
||||
KEEP(levels/level0.o(.sbss*))
|
||||
KEEP(levels/level0.o(.sbss*))
|
||||
KEEP(levels/level0.o(.bss*))
|
||||
KEEP(levels/level0.o(.ctors))
|
||||
|
||||
/*KEEP(TIM/bg_camPath_*.o(.text))
|
||||
/*KEEP(TIM/bg_camPath_*.o(.text))
|
||||
__lvl0_ctor = .;
|
||||
KEEP(TIM/bg_camPath_*.o(.text.startup._GLOBAL__*))
|
||||
KEEP(TIM/bg_camPath_*.o(.text.*))
|
||||
KEEP(TIM/bg_camPath_*.o(.rodata*))
|
||||
KEEP(TIM/bg_camPath_*.o(.sdata*))
|
||||
KEEP(TIM/bg_camPath_*.o(.sdata*))
|
||||
KEEP(TIM/bg_camPath_*.o(.data*))
|
||||
KEEP(TIM/bg_camPath_*.o(.sbss*))
|
||||
KEEP(TIM/bg_camPath_*.o(.sbss*))
|
||||
KEEP(TIM/bg_camPath_*.o(.bss*))
|
||||
KEEP(TIM/bg_camPath_*.o(.ctors))
|
||||
*/
|
||||
@ -42,9 +42,9 @@ SECTIONS {
|
||||
KEEP(levels/level1.o(.text.startup._GLOBAL__*))
|
||||
KEEP(levels/level1.o(.text.*))
|
||||
KEEP(levels/level1.o(.rodata*))
|
||||
KEEP(levels/level1.o(.sdata*))
|
||||
KEEP(levels/level1.o(.sdata*))
|
||||
KEEP(levels/level1.o(.data*))
|
||||
KEEP(levels/level1.o(.sbss*))
|
||||
KEEP(levels/level1.o(.sbss*))
|
||||
KEEP(levels/level1.o(.bss*))
|
||||
KEEP(levels/level1.o(.ctors))
|
||||
|
||||
|
@ -1,31 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Path to nops executable
|
||||
NOPS="nops"
|
||||
|
||||
if [ $# -eq 0 ]
|
||||
then
|
||||
echo "PSX Overlay Upload helper script
|
||||
|
||||
Upload a binary and the corresponding executable to a real PSX memory, via unirom + serial cable.
|
||||
|
||||
This script is dependant on NOTpsxserial being available on your system : https://github.com/JonathanDotCel/NOTPSXSerial
|
||||
Edit the $NOPS value to reflect the executable path on your system, e.g :
|
||||
\$NOPS = '/blah/nops'
|
||||
Usage : ./ovly_upload_helper.sh bin_filename psx_exe_name com_port
|
||||
|
||||
- bin_filename , eg : Overlay.lvl0
|
||||
- psx_exe_name, e.g : main.ps-exe
|
||||
- com_port, e.g : /dev/ttyUSB0, COM1
|
||||
"
|
||||
else
|
||||
# Find map file corresponding to ps-exe
|
||||
MAP_FILE="`echo $2 | awk -F. '{print $1}'`.map"
|
||||
# Find loading address
|
||||
LOAD_ADDR="0x`cat $MAP_FILE | grep load_all_overlays_here | awk '{print $1}' | cut -c 11-`"
|
||||
|
||||
$NOPS /debug $3
|
||||
$NOPS /fast /bin $LOAD_ADDR $1 $3
|
||||
$NOPS /fast /exe $2 $3
|
||||
$NOPS /slow $3
|
||||
fi
|
18
src/camera.c
18
src/camera.c
@ -1,8 +1,8 @@
|
||||
#include "../include/psx.h"
|
||||
#include "../include/camera.h"
|
||||
#include "../include/math.h"
|
||||
#include "../include/physics.h"
|
||||
#include "../include/space.h"
|
||||
#include <psx.h>
|
||||
#include <camera.h>
|
||||
#include <math.h>
|
||||
#include <physics.h>
|
||||
#include <space.h>
|
||||
|
||||
void getCameraXZ(int * x, int * z, int actorX, int actorZ, int angle, int distance) {
|
||||
// Using Nic's Costable : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102
|
||||
@ -44,7 +44,7 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
||||
switch (camMode){
|
||||
// Camera follows actor
|
||||
case 0 :
|
||||
dist = 200;
|
||||
dist = CAM_DIST_TO_ACT;
|
||||
setVector(dc_camPos, -(camera->x/ONE), -(camera->y/ONE), -(camera->z/ONE));
|
||||
angle->vy = -(curLvl->actorPtr->rot.vy / 2) + angleCam->vy;
|
||||
// Camera horizontal and vertical position
|
||||
@ -55,9 +55,9 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
||||
// Camera rotates continuously around actor
|
||||
case 1 :
|
||||
// Set distance between cam and actor
|
||||
dist = 150;
|
||||
dist = CAM_DIST_TO_ACT;
|
||||
// Set camera position
|
||||
setVector(dc_camPos, -(camera->x/ONE), 100, -(camera->z/ONE));
|
||||
setVector(dc_camPos, -(camera->x/ONE), CAM_DIST_TO_GND, -(camera->z/ONE));
|
||||
// Find new camera position
|
||||
getCameraXZ(&camera->x, &camera->z, curLvl->actorPtr->pos.vx, curLvl->actorPtr->pos.vz, angle->vy, dist);
|
||||
// Set rotation amount
|
||||
@ -105,7 +105,7 @@ void setCameraMode(LEVEL * curLvl, CAMERA * camera, VECTOR * posToActor, VECTOR
|
||||
// Using precalc sqrt
|
||||
dist = psqrt( (posToActor->vx * posToActor->vx ) + (posToActor->vz * posToActor->vz) );
|
||||
// Set camera position
|
||||
setVector(dc_camPos, 190, 100, 180);
|
||||
setVector(dc_camPos, 190, CAM_DIST_TO_GND, 180);
|
||||
break;
|
||||
// Flyby mode with LERP from camStart to camEnd
|
||||
case 4 :
|
||||
|
327
src/graphics.c
327
src/graphics.c
@ -1,7 +1,7 @@
|
||||
#include "../include/psx.h"
|
||||
#include "../include/graphics.h"
|
||||
#include "../include/math.h"
|
||||
#include "../include/CPUMAC.H"
|
||||
#include <psx.h>
|
||||
#include <graphics.h>
|
||||
#include <math.h>
|
||||
#include <CPUMAC.H>
|
||||
|
||||
void updateLight(void){
|
||||
RotMatrix_gte(dc_lgtangp, dc_lgtmatp);
|
||||
@ -51,107 +51,140 @@ void set3VertexLerPos(MESH * mesh, long t){
|
||||
// TODO : Pre-calculate lerp positions at runtime (for i in nframes, do calc)
|
||||
// Fixed point math precision
|
||||
short precision = 12;
|
||||
// Vertex 1
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vx].vx << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vx].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vx].vz << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vx].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vx].vy << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vx].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
// Vertex 2
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vz].vx << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vz].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vz].vz << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vz].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vz].vy << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vz].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
// Vertex 3
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vy].vx << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vy].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vy].vz << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vy].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = lerpD( mesh->anim->data[mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[t].order.vy].vy << precision , mesh->anim->data[(mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[t].order.vy].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->anim->cursor += 24 * mesh->anim->dir;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ // Vertex 2
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ // Vertex 3
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = round(lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vx].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vx].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
// Vertex 2
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vz].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vz].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
// Vertex 3
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vx << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vx << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vz << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vz << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = (lerpD( mesh->currentAnim->data[mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[t].order.vy].vy << precision , mesh->currentAnim->data[(mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[t].order.vy].vy << precision, mesh->currentAnim->cursor << precision)) >> precision;
|
||||
|
||||
mesh->currentAnim->cursor += 24 * mesh->currentAnim->dir;
|
||||
};
|
||||
void set3VertexPos(MESH * mesh, long t, int atime){
|
||||
// Set vertices according to anim
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vz;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vz;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vz;
|
||||
|
||||
}
|
||||
void set4VertexLerPos(MESH * mesh, long t){
|
||||
// Find and set 4 interpolated vertex value
|
||||
short precision = 12;
|
||||
// Vertex 1
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vx ].vx << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vx ].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vx ].vz << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vx ].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vx ].vy << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vx ].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
short precision = 12;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vx << precision ,
|
||||
mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vx << precision,
|
||||
mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vz << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vz << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vy << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vx ].vy << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
// Vertex 2
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vz ].vx << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vz ].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vz ].vz << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vz ].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vz ].vy << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vz ].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vx << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vx << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vz << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vz << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vy << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vz ].vy << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
// Vertex 3
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vy ].vx << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vy ].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vy ].vz << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vy ].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.vy ].vy << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.vy ].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vx << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vx << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vz << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vz << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vy << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.vy ].vy << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
// Vertex 4
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vx = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.pad ].vx << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.pad ].vx << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vz = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.pad ].vz << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.pad ].vz << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vy = lerpD( mesh->anim->data[ mesh->anim->lerpCursor * mesh->anim->nvert + mesh->index[ t ].order.pad ].vy << precision , mesh->anim->data[ (mesh->anim->lerpCursor + 1) * mesh->anim->nvert + mesh->index[ t ].order.pad ].vy << precision, mesh->anim->cursor << precision) >> precision;
|
||||
mesh->anim->cursor += 2 * mesh->anim->dir;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vx = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vx << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vx << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vz = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vz << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vz << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vy = lerpD( mesh->currentAnim->data[ mesh->currentAnim->lerpCursor * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vy << precision , mesh->currentAnim->data[ (mesh->currentAnim->lerpCursor + 1) * mesh->currentAnim->nvert + mesh->index[ t ].order.pad ].vy << precision, mesh->currentAnim->cursor << precision) >> precision;
|
||||
|
||||
mesh->currentAnim->cursor += 24 * mesh->currentAnim->dir;
|
||||
}
|
||||
long interpolateTri(POLY_GT3 * poly, MESH * mesh, long t){
|
||||
void set4VertexPos(MESH * mesh, long t, int atime){
|
||||
// Set vertices according to anim
|
||||
// TODO : fix using delta animation
|
||||
//~ SVECTOR x, y, z, pad;
|
||||
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vx ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ], &x );
|
||||
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vz ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ], &z );
|
||||
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.vy ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ], &y );
|
||||
//~ addVector2(&mesh->tmesh->v[ mesh->index[ t ].order.pad ], &mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ], &pad );
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vx ] = x;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vz ] = z;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.vy ] = y;
|
||||
//~ mesh->tmesh->v[ mesh->index[ t ].order.pad ] = pad;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vx ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vx ].vz;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vz ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vz ].vz;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.vy ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.vy ].vz;
|
||||
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vx = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vx;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vy = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vy;
|
||||
mesh->tmesh->v[ mesh->index[ t ].order.pad ].vz = mesh->currentAnim->data[ atime % mesh->currentAnim->nframes * mesh->currentAnim->nvert + mesh->index[t].order.pad ].vz;
|
||||
}
|
||||
void interpolateTri(POLY_GT3 * poly, MESH * mesh, long t){
|
||||
long Flag, nclip = 0;
|
||||
// Ping pong
|
||||
//~ //if (mesh->anim->cursor > 4096 || mesh->anim->cursor < 0){
|
||||
//~ // mesh->anim->dir *= -1;
|
||||
//~ //}
|
||||
// Find next keyframe
|
||||
if (mesh->anim->cursor > (1 << 12)) {
|
||||
if (mesh->currentAnim->cursor > (1 << 12)) {
|
||||
// There are still keyframes to interpolate between
|
||||
if ( mesh->anim->lerpCursor < mesh->anim->nframes - 1 ) {
|
||||
mesh->anim->lerpCursor ++;
|
||||
mesh->anim->cursor = 0;
|
||||
if ( mesh->currentAnim->lerpCursor < mesh->currentAnim->nframes - 1 ) {
|
||||
mesh->currentAnim->lerpCursor ++;
|
||||
mesh->currentAnim->cursor = 0;
|
||||
}
|
||||
// We've reached last frame, go back to first frame
|
||||
if ( mesh->anim->lerpCursor == mesh->anim->nframes - 1 ) {
|
||||
mesh->anim->lerpCursor = 0;
|
||||
mesh->anim->cursor = 0;
|
||||
if ( mesh->currentAnim->lerpCursor == mesh->currentAnim->nframes - 1 ) {
|
||||
mesh->currentAnim->lerpCursor = 0;
|
||||
mesh->currentAnim->cursor = 0;
|
||||
}
|
||||
}
|
||||
// Find and set interpolated vertex value
|
||||
set3VertexLerPos(mesh, t);
|
||||
// Coord transformation from world space to screen space
|
||||
gte_RotAverageNclip3(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
( long* ) &poly->x0, ( long* ) &poly->x1, ( long* ) &poly->x2,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
return nclip;
|
||||
};
|
||||
long interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t){
|
||||
void interpolateQuad(POLY_GT4 * poly4, MESH * mesh, long t){
|
||||
long Flag, nclip = 0;
|
||||
// ping pong
|
||||
//~ if (mesh->anim->cursor > 4096 || mesh->anim->cursor < 0){
|
||||
//~ mesh->anim->dir *= -1;
|
||||
//~ }
|
||||
short precision = 12;
|
||||
if ( mesh->anim->cursor > 1<<precision ) {
|
||||
if ( mesh->anim->lerpCursor < mesh->anim->nframes - 1 ) {
|
||||
mesh->anim->lerpCursor ++;
|
||||
mesh->anim->cursor = 0;
|
||||
//~ if ( mesh->anim->cursor > 1<<precision ) {
|
||||
if ( mesh->currentAnim->cursor > (1 << 12) ) {
|
||||
if ( mesh->currentAnim->lerpCursor < mesh->currentAnim->nframes - 1 ) {
|
||||
mesh->currentAnim->lerpCursor ++;
|
||||
mesh->currentAnim->cursor = 0;
|
||||
}
|
||||
if ( mesh->anim->lerpCursor == mesh->anim->nframes - 1 ) {
|
||||
mesh->anim->lerpCursor = 0;
|
||||
mesh->anim->cursor = 0;
|
||||
if ( mesh->currentAnim->lerpCursor == mesh->currentAnim->nframes - 1 ) {
|
||||
mesh->currentAnim->lerpCursor = 0;
|
||||
mesh->currentAnim->cursor = 0;
|
||||
}
|
||||
}
|
||||
// Find and set interpolated vertex value
|
||||
set4VertexLerPos(mesh, t);
|
||||
// Coord transformations
|
||||
gte_RotAverageNclip4(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.pad ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
( long* )&poly4->x0, ( long* )&poly4->x1, ( long* )&poly4->x2, ( long* )&poly4->x3,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
return nclip;
|
||||
};
|
||||
void set3Prism(POLY_GT3 * poly, MESH * mesh, DRAWENV * draw, char * db, int i, int t){
|
||||
// Transparency effect :
|
||||
@ -346,48 +379,40 @@ long drawQuad(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * o
|
||||
poly4 = (POLY_GT4 *)*nextpri;
|
||||
|
||||
// Vertex Anim
|
||||
if (mesh->isAnim){
|
||||
if (mesh->isAnim && mesh->currentAnim){
|
||||
// with interpolation
|
||||
if ( mesh->anim->interpolate ){
|
||||
if ( mesh->currentAnim->interpolate ){
|
||||
//~ nclip = interpolateQuad(poly4, mesh, t);
|
||||
interpolateQuad(poly4, mesh, t);
|
||||
} else {
|
||||
// TODO : write playAnim()
|
||||
// No interpolation, use all vertices coordinates in anim data
|
||||
gte_RotAverageNclip4(
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.pad ],
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vz ],
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vx ],
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vy ],
|
||||
( long* )&poly4->x0, ( long* )&poly4->x1, ( long* )&poly4->x2, ( long* )&poly4->x3,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
set4VertexPos(mesh, t, atime);
|
||||
}
|
||||
} else {
|
||||
// Mesh is sprite
|
||||
if (mesh->isSprite){
|
||||
// Find inverse rotation matrix so that sprite always faces camera
|
||||
MATRIX rot, invRot;
|
||||
gte_ReadRotMatrix(&rot);
|
||||
TransposeMatrix(&rot, &invRot);
|
||||
//~ SetMulRotMatrix(&invRot);
|
||||
gte_MulMatrix0(&rot, &invRot, &invRot);
|
||||
gte_SetRotMatrix(&invRot);
|
||||
}
|
||||
// Use regular vertex coords
|
||||
gte_RotAverageNclip4(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.pad ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
(long*)&poly4->x0, (long*)&poly4->x1, (long*)&poly4->x2, (long*)&poly4->x3,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
}
|
||||
// Mesh is sprite
|
||||
if (mesh->isSprite){
|
||||
// Find inverse rotation matrix so that sprite always faces camera
|
||||
MATRIX rot, invRot;
|
||||
gte_ReadRotMatrix(&rot);
|
||||
TransposeMatrix(&rot, &invRot);
|
||||
//~ SetMulRotMatrix(&invRot);
|
||||
gte_MulMatrix0(&rot, &invRot, &invRot);
|
||||
gte_SetRotMatrix(&invRot);
|
||||
}
|
||||
// Apply rtp
|
||||
gte_RotAverageNclip4(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.pad ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
(long*)&poly4->x0, (long*)&poly4->x1, (long*)&poly4->x2, (long*)&poly4->x3,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
|
||||
if (nclip > 0 && mesh->OTz > 0 && (mesh->p < 4096)) {
|
||||
SetPolyGT4(poly4);
|
||||
if (mesh->tim){
|
||||
@ -410,7 +435,7 @@ long drawQuad(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * o
|
||||
set4Tex(poly4, mesh, draw, t, i);
|
||||
}
|
||||
if ( (mesh->OTz > 0) /*&& (*mesh->OTz < OTLEN)*/ && (mesh->p < 4096) ) {
|
||||
AddPrim( &ot[ mesh->OTz-3 ], poly4 );
|
||||
AddPrim( &ot[ mesh->OTz-5 ], poly4 );
|
||||
}
|
||||
*nextpri += sizeof( POLY_GT4 );
|
||||
}
|
||||
@ -429,48 +454,38 @@ long drawTri(MESH * mesh, int atime, int * camMode, char ** nextpri, u_long * ot
|
||||
if ( !( mesh->isBG ) || *camMode != 2) {
|
||||
poly = (POLY_GT3 *)*nextpri;
|
||||
// If Vertex Anim flag is set, use it
|
||||
if (mesh->isAnim){
|
||||
if (mesh->isAnim && mesh->currentAnim){
|
||||
// If interpolation flag is set, use it
|
||||
if(mesh->anim->interpolate){
|
||||
nclip = interpolateTri(poly, mesh, t);
|
||||
if(mesh->currentAnim->interpolate){
|
||||
interpolateTri(poly, mesh, t);
|
||||
} else {
|
||||
// No interpolation
|
||||
// Use the pre-calculated vertices coordinates from the animation data
|
||||
gte_RotAverageNclip3(
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vx ],
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vz ],
|
||||
&mesh->anim->data[ atime % mesh->anim->nframes * mesh->anim->nvert + mesh->index[t].order.vy ],
|
||||
( long* ) &poly->x0, ( long* ) &poly->x1, ( long* ) &poly->x2,
|
||||
// Use the pre-calculated vertices coordinates from the animation data
|
||||
set3VertexPos(mesh, t, atime);
|
||||
}
|
||||
}
|
||||
// No animation
|
||||
if (mesh->isSprite){
|
||||
// Find inverse rotation matrix so that sprite always faces camera
|
||||
//~ MATRIX rot, invRot;
|
||||
// Use scratchpad dc_wrkmatp and dc_retmatp
|
||||
gte_ReadRotMatrix(dc_wrkmatp);
|
||||
TransposeMatrix(dc_wrkmatp, dc_retmatp);
|
||||
//~ SetMulRotMatrix(&invRot);
|
||||
gte_MulMatrix0(dc_wrkmatp, dc_retmatp, dc_retmatp);
|
||||
gte_SetRotMatrix(dc_retmatp);
|
||||
}
|
||||
// Use model's regular vertex coordinates
|
||||
gte_RotAverageNclip3(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
( long * ) &poly->x0, ( long * ) &poly->x1, ( long * ) &poly->x2,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
}
|
||||
} else {
|
||||
// No animation
|
||||
if (mesh->isSprite){
|
||||
// Find inverse rotation matrix so that sprite always faces camera
|
||||
//~ MATRIX rot, invRot;
|
||||
// Use scratchpad dc_wrkmatp and dc_retmatp
|
||||
gte_ReadRotMatrix(dc_wrkmatp);
|
||||
TransposeMatrix(dc_wrkmatp, dc_retmatp);
|
||||
//~ SetMulRotMatrix(&invRot);
|
||||
gte_MulMatrix0(dc_wrkmatp, dc_retmatp, dc_retmatp);
|
||||
gte_SetRotMatrix(dc_retmatp);
|
||||
}
|
||||
// Use model's regular vertex coordinates
|
||||
gte_RotAverageNclip3(
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vx ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vz ],
|
||||
&mesh->tmesh->v[ mesh->index[t].order.vy ],
|
||||
( long * ) &poly->x0, ( long * ) &poly->x1, ( long * ) &poly->x2,
|
||||
&mesh->p,
|
||||
&mesh->OTz,
|
||||
&Flag,
|
||||
&nclip
|
||||
);
|
||||
}
|
||||
// Do not draw invisible meshes
|
||||
if ( nclip > 0 && mesh->OTz > 0 && (mesh->p < 4096) ) {
|
||||
SetPolyGT3( poly );
|
||||
@ -599,3 +614,27 @@ void renderScene(LEVEL * curLvl, CAMERA * camera, int * camMode, char ** nextpri
|
||||
}
|
||||
updateLight();
|
||||
};
|
||||
|
||||
void playAnim(MESH * mesh, VANIM * anim, int loop){
|
||||
if (mesh->isAnim){
|
||||
// Set looping (-1 : infinite, n > 0 : loop n times )
|
||||
if (mesh->currentAnim->loop == 0){
|
||||
mesh->currentAnim->loop = loop;
|
||||
}
|
||||
// If anim not is not playing yet
|
||||
if (mesh->currentAnim->cursor == -1){
|
||||
// if cursor is -1, set to 0, start playback
|
||||
mesh->currentAnim->cursor = 0;
|
||||
} else {
|
||||
|
||||
}
|
||||
// Anim is already playing
|
||||
} else if (mesh->currentAnim == anim){
|
||||
// If we're not in an infinite loop (-1)
|
||||
if (mesh->currentAnim->loop > 0){
|
||||
// Add loop iterations ?
|
||||
mesh->currentAnim->loop = loop;
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
206
src/main.c
206
src/main.c
@ -16,15 +16,16 @@
|
||||
* eye */
|
||||
// Blender debug mode
|
||||
// bpy. app. debug = True
|
||||
#include "../include/psx.h"
|
||||
#include "../include/pad.h"
|
||||
#include "../include/math.h"
|
||||
#include "../include/camera.h"
|
||||
#include "../include/physics.h"
|
||||
#include "../include/graphics.h"
|
||||
#include "../include/space.h"
|
||||
#include "../include/sound.h"
|
||||
|
||||
#include <psx.h>
|
||||
#include <pad.h>
|
||||
#include <math.h>
|
||||
#include <camera.h>
|
||||
#include <physics.h>
|
||||
#include <graphics.h>
|
||||
#include <space.h>
|
||||
#include <sound.h>
|
||||
//~ #include "../thirdparty/nugget/common/syscalls/syscalls.h"
|
||||
//~ #define printf ramsyscall_printf
|
||||
#define USECD
|
||||
|
||||
// START OVERLAY
|
||||
@ -37,7 +38,7 @@ u_long overlaySize = 0;
|
||||
#include "../levels/level1.h"
|
||||
|
||||
// Levels
|
||||
u_char level = 1;
|
||||
u_char level = 0;
|
||||
u_short levelWas = 0;
|
||||
u_short levelHasChanged = 0;
|
||||
// Overlay
|
||||
@ -79,9 +80,9 @@ int dist = 150;
|
||||
int lerping = 0;
|
||||
short curCamAngle = 0;
|
||||
// Actor's forward vector (used for dualshock)
|
||||
VECTOR fVecActor = {0,0,0,0};
|
||||
VECTOR fVecActor;
|
||||
u_long triCount = 0;
|
||||
LEVEL curLvl = {0};
|
||||
LEVEL curLvl;
|
||||
LEVEL * loadLvl;
|
||||
// Actor start position
|
||||
VECTOR actorStartPos = {0};
|
||||
@ -95,7 +96,6 @@ NODE * propStartNode;
|
||||
void callback();
|
||||
// variable FPS
|
||||
long oldTime = 0;
|
||||
long XATime = 0;
|
||||
long dt = 0;
|
||||
// Physics/collisions
|
||||
short physics = 1;
|
||||
@ -113,10 +113,6 @@ char spu_malloc_rec[SPU_MALLOC_RECSIZ * (2 + MALLOC_MAX + 1)];
|
||||
// SPU settings
|
||||
SpuCommonAttr spuSettings; // structure for changing common voice attributes
|
||||
SpuVoiceAttr voiceAttributes ; // structure for changing individual voice attributes
|
||||
// CD filter
|
||||
CdlFILTER filter;
|
||||
// File position in m/s/f
|
||||
CdlLOC loc;
|
||||
// Keep track of XA Sample currently playing
|
||||
int sample = -1;
|
||||
|
||||
@ -134,7 +130,7 @@ int main() {
|
||||
} else if ( level == 1) {
|
||||
overlayFile = "\\level1.bin;1";
|
||||
overlaySize = __lvl1_end;
|
||||
loadLvl = &level1;
|
||||
//~ loadLvl = &level1;
|
||||
}
|
||||
// Load overlay from cd
|
||||
#ifdef USECD
|
||||
@ -147,15 +143,8 @@ int main() {
|
||||
if ( level == 0 ) {
|
||||
LvlPtrSet( &curLvl, &level0);
|
||||
} else if ( level == 1) {
|
||||
LvlPtrSet( &curLvl, &level1);
|
||||
//~ LvlPtrSet( &curLvl, &level1);
|
||||
}
|
||||
#ifdef USECD
|
||||
getXAoffset(&curLvl);
|
||||
//~ // Load XA file
|
||||
//~ CdSearchFile(&XAPos, curLvl.XA->name);
|
||||
//~ // Set cd head to start of file
|
||||
//~ curLvl.XA->offset = CdPosToInt(&XAPos.pos);
|
||||
#endif
|
||||
levelWas = level;
|
||||
// Copy light matrices / vector to scratchpad
|
||||
setDCLightEnv(curLvl.cmat, curLvl.lgtmat, &lgtang);
|
||||
@ -199,46 +188,20 @@ int main() {
|
||||
// Time counter
|
||||
oldTime = GetRCnt(RCntCNT1);
|
||||
// Sound
|
||||
SpuInit();
|
||||
// Init sound settings
|
||||
initSnd(&spuSettings, spu_malloc_rec);
|
||||
//~ spuCDsetup(&spuSettings);
|
||||
XAsetup();
|
||||
for (u_short vag = 0; vag < VAG_NBR; vag++ ){
|
||||
//~ VAGBank.samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &VAGBank.samples[vag]);
|
||||
curLvl.VAG->samples[vag].spu_address = setSPUtransfer(&voiceAttributes, &curLvl.VAG->samples[vag]);
|
||||
}
|
||||
SpuInit();
|
||||
// Load level's VAGs to SPU
|
||||
setLvlVAG(&curLvl, &spuSettings, &voiceAttributes, spu_malloc_rec);
|
||||
// Set XA sample
|
||||
sample = 0;
|
||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
||||
setLvlXA(&curLvl, sample);
|
||||
// Main loop
|
||||
//~ while ( VSync(VSYNC) ) {
|
||||
while ( 1 ) {
|
||||
printf("Let's go!");
|
||||
dt = GetRCnt(RCntCNT1) - oldTime;
|
||||
oldTime = GetRCnt(RCntCNT1);
|
||||
// XA playback
|
||||
// if sample is set
|
||||
if (sample != -1 ){
|
||||
// Begin XA file playback...
|
||||
// if sample's cursor is 0
|
||||
if (curLvl.XA->samples[sample].cursor == 0){
|
||||
// Convert sector number to CD position in min/second/frame and set CdlLOC accordingly.
|
||||
CdIntToPos(curLvl.XA->samples[sample].start + curLvl.XA->offset , &loc);
|
||||
// Send CDROM read command
|
||||
CdControlF(CdlReadS, (u_char *)&loc);
|
||||
XATime = VSync(-1);
|
||||
// Set playing flag
|
||||
}
|
||||
// if sample's cursor is close to sample's end position, stop playback
|
||||
//~ if ((curLvl.XA->samples[sample].cursor += XA_CDSPEED) >= curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start ){
|
||||
//~ if ((curLvl.XA->samples[sample].cursor += (XA_CDSPEED*4096)/((400/(dt+1)+1)) ) >= (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)*4096 ){
|
||||
// XA playback has fixed rate
|
||||
if ((curLvl.XA->samples[sample].cursor += XA_CDSPEED / ((XA_RATE/(dt+1)+1)) ) >= (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start) * ONE ){
|
||||
//~ CdControlF(CdlStop,0);
|
||||
curLvl.XA->samples[sample].cursor = -1;
|
||||
//~ sample = !sample;
|
||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
||||
}
|
||||
}
|
||||
// XA playback (keep track of playback and loop XA)
|
||||
XAplayback(&curLvl, sample, dt);
|
||||
// Check if level has changed
|
||||
// TODO : Proper level system / loader
|
||||
if ( levelWas != level ){
|
||||
@ -253,7 +216,7 @@ int main() {
|
||||
case 1:
|
||||
overlayFile = "\\level1.bin;1";
|
||||
overlaySize = __lvl1_end;
|
||||
loadLvl = &level1;
|
||||
//~ loadLvl = &level1;
|
||||
// Copy light matrices / vector to scratchpad
|
||||
|
||||
break;
|
||||
@ -277,37 +240,29 @@ int main() {
|
||||
// Set level lighting
|
||||
setLightEnv(draw, curLvl.BGc, curLvl.BKc);
|
||||
levelWas = level;
|
||||
// Change XA track
|
||||
XAsetup();
|
||||
sample = !sample;
|
||||
curLvl.XA->samples[sample].cursor = -1;
|
||||
setXAsample(&curLvl.XA->samples[sample], &filter);
|
||||
CdIntToPos( curLvl.XA->samples[sample].start + curLvl.XA->offset , &loc);
|
||||
// Send CDROM read command
|
||||
CdControlF(CdlReadS, (u_char *)&loc);
|
||||
// Load level's VAGs to SPU
|
||||
setLvlVAG(&curLvl, &spuSettings, &voiceAttributes, spu_malloc_rec);
|
||||
// Set
|
||||
setLvlXA(&curLvl, sample);
|
||||
}
|
||||
//~ FntPrint("Ovl:%s\nLvl : %x\nLvl: %d %d \n%x", overlayFile, &level, level, levelWas, loadLvl);
|
||||
// atime is used for animations timing
|
||||
timediv = 1;
|
||||
timediv = 2;
|
||||
// If timediv is > 1, animation time will be slower
|
||||
if (time % timediv == 0){
|
||||
if (time++ % timediv == 0){
|
||||
atime ++;
|
||||
}
|
||||
// TODO : put in a function
|
||||
// Reset player/prop pos
|
||||
if(curLvl.actorPtr->pos.vy >= 200){
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[6]);
|
||||
copyVector(&curLvl.actorPtr->body->position, &actorStartPos );
|
||||
copyVector(&curLvl.actorPtr->rot, &actorStartRot );
|
||||
curLvl.curNode = actorStartNode;
|
||||
curLvl.levelPtr = curLvl.curNode->plane;
|
||||
if(curLvl.actorPtr->pos.vy >= curLvl.levelPtr->body->max.vy + 200){
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[6]->VAGsample, curLvl.levelSounds->sounds[6]->volumeL, curLvl.levelSounds->sounds[6]->volumeR);
|
||||
respawnMesh(&curLvl, curLvl.actorPtr, &actorStartRot, &actorStartPos, actorStartNode );
|
||||
}
|
||||
if(curLvl.propPtr->pos.vy >= 200){
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[3]);
|
||||
copyVector(&curLvl.propPtr->body->position, &propStartPos );
|
||||
copyVector(&curLvl.propPtr->rot, &propStartRot );
|
||||
curLvl.propPtr->node = propStartNode;
|
||||
if(curLvl.propPtr->pos.vy >= curLvl.levelPtr->body->max.vy + 200){
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[3]->VAGsample, curLvl.levelSounds->sounds[3]->volumeL, curLvl.levelSounds->sounds[3]->volumeR);
|
||||
respawnMesh(&curLvl, curLvl.propPtr, &propStartRot, &propStartPos, propStartNode );
|
||||
}
|
||||
// Spatialize Sound
|
||||
setSFXdist(&curLvl, &camera, camMode);
|
||||
// Spatial partitioning
|
||||
if (curLvl.curNode){
|
||||
for ( int msh = 0; msh < curLvl.curNode->siblings->index; msh ++ ) {
|
||||
@ -355,26 +310,37 @@ int main() {
|
||||
// Get col between actor and level
|
||||
if ( curLvl.meshes[k]->isActor ){
|
||||
// Check col
|
||||
checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body );
|
||||
VECTOR colLvl = checkBodyCol( curLvl.meshes[k]->body , curLvl.levelPtr->body );
|
||||
FntPrint("ColLvl: %d %d %d\n", colLvl.vz, colLvl.vx, colLvl.vy);
|
||||
// Get col between actor and current node's walls
|
||||
// Loop on current node's objects
|
||||
for (short obj=0; obj < curLvl.curNode->objects->index; obj++){
|
||||
VECTOR col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body );
|
||||
// If isWall, check collision
|
||||
if ( curLvl.curNode->objects->list[obj]->isWall ){
|
||||
if( getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vz &&
|
||||
getExtCollision( *curLvl.meshes[k]->body, *curLvl.curNode->objects->list[obj]->body ).vx) {
|
||||
curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
|
||||
curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
|
||||
//~ if ( curLvl.curNode->objects->list[obj]->isWall){
|
||||
//~ if( col.vz && col.vx) {
|
||||
//~ curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
|
||||
//~ curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
|
||||
//~ }
|
||||
//~ }
|
||||
if ( curLvl.curNode->objects->list[obj]->isStaticBody ){
|
||||
FntPrint("Col : %d %d %d\n", col.vz, col.vx, col.vy);
|
||||
if( col.vz && col.vx && col.vy ) {
|
||||
if (!colLvl.vy) {
|
||||
curLvl.meshes[k]->body->position.vz = curLvl.meshes[k]->body->position.vz - curLvl.meshes[k]->body->velocity.vz ;
|
||||
curLvl.meshes[k]->body->position.vx = curLvl.meshes[k]->body->position.vx - curLvl.meshes[k]->body->velocity.vx ;
|
||||
}
|
||||
curLvl.meshes[k]->body->position.vy = curLvl.meshes[k]->body->position.vy - curLvl.meshes[k]->body->velocity.vy ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Only evaluate collision if actor is on same plane as prop
|
||||
if ( curLvl.curNode == curLvl.propPtr->node ){
|
||||
// Get col between actor and props
|
||||
col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.propPtr->body );
|
||||
if (col.vx && col.vz && canMove == 1 ) {
|
||||
VECTOR col = getExtCollision( *curLvl.meshes[k]->body, *curLvl.propPtr->body );
|
||||
if (col.vx && col.vz && col.vy && canMove == 1 ) {
|
||||
setVector( &curLvl.propPtr->body->velocity,
|
||||
curLvl.meshes[k]->body->velocity.vx,
|
||||
0,
|
||||
@ -406,7 +372,7 @@ int main() {
|
||||
// Angle between camera and actor
|
||||
applyVector( dc_actorRot,
|
||||
(patan(dist, posToActor.vy) >> 4 ) - 256,
|
||||
(patan(-posToActor.vx, -posToActor.vz) / 16) - 3076,
|
||||
(patan(-posToActor.vx, -posToActor.vz) / 16) + 1024,
|
||||
0,
|
||||
=
|
||||
);
|
||||
@ -421,7 +387,8 @@ int main() {
|
||||
curLvl.actorPtr->pos.vy,
|
||||
curLvl.actorPtr->pos.vz - (ncos(curLvl.actorPtr->rot.vy/2))
|
||||
);
|
||||
|
||||
curLvl.levelPtr->body->normal = curLvl.levelPtr->tmesh->n[0];
|
||||
|
||||
// Add secondary OT to main OT
|
||||
AddPrims(otdisc[db], ot[db] + OTLEN - 1, ot[db]);
|
||||
|
||||
@ -430,7 +397,14 @@ int main() {
|
||||
//~ FntPrint("Dt : %d %d %d\n", 400/(dt+1), (XA_CDSPEED)/((400/(dt+1))+1), (curLvl.XA->samples[sample].end - curLvl.XA->samples[sample].start)<<12);
|
||||
//~ FntPrint("XA : %d\n", (XA_CDSPEED)/((400/(dt+1))+1) );
|
||||
//~ FntPrint("XA : %d\n", curLvl.XA->samples[sample].cursor );
|
||||
FntPrint("CamAngle : %d\n", curCamAngle);
|
||||
FntPrint("CamAngle : %d\n", curCamAngle );
|
||||
FntPrint("fVector : %d %d %d\n", fVecActor.vx, fVecActor.vy, fVecActor.vz );
|
||||
//~ FntPrint("XA: %x\n", curLvl.XA);
|
||||
//~ FntPrint("Ofst: %d\n", curLvl.XA->banks[0]->offset);
|
||||
//~ FntPrint("Vol: %d %d\n", curLvl.levelSounds->sounds[0]->volumeL, curLvl.levelSounds->sounds[0]->volumeR );
|
||||
FntPrint("Curanim : %x\n", curLvl.meshes[1]->currentAnim);
|
||||
FntPrint("Gforce: %d", curLvl.actorPtr->body->gForce.vy);
|
||||
//~ FntPrint("Anims : %x %x", curLvl.meshes[1]->anim_tracks->strips[3], curLvl.meshes[1]->anim_tracks->strips[4]);
|
||||
FntFlush(-1);
|
||||
display( &disp[db], &draw[db], otdisc[db], primbuff[db], &nextpri, &db);
|
||||
|
||||
@ -508,7 +482,7 @@ void callback() {
|
||||
} else {
|
||||
curLvl.actorPtr->isPrism = 1;
|
||||
}
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[0]);
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[0]->VAGsample, curLvl.levelSounds->sounds[0]->volumeL, curLvl.levelSounds->sounds[0]->volumeR );
|
||||
//~ timer = 10;
|
||||
lastPad = PAD;
|
||||
}
|
||||
@ -516,7 +490,17 @@ void callback() {
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PAD & Square && !( lastPad & Square ) ){
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[7]);
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[7]->VAGsample, curLvl.levelSounds->sounds[7]->volumeL, curLvl.levelSounds->sounds[7]->volumeR);
|
||||
if ( curLvl.meshes[1]->currentAnim == 0 ||
|
||||
curLvl.meshes[1]->currentAnim == curLvl.meshes[1]->anim_tracks->strips[0]
|
||||
){
|
||||
if (curLvl.meshes[1]->anim_tracks->index > 1) {
|
||||
curLvl.meshes[1]->currentAnim = curLvl.meshes[1]->anim_tracks->strips[4];
|
||||
}
|
||||
} else {
|
||||
//~ curLvl.meshes[1]->anim_tracks->strips[0]->interpolate = 1;
|
||||
curLvl.meshes[1]->currentAnim = curLvl.meshes[1]->anim_tracks->strips[0];
|
||||
}
|
||||
//~ sample = 0;
|
||||
//~ setXAsample(&XABank.samples[sample], &filter);
|
||||
lastPad = PAD;
|
||||
@ -525,36 +509,32 @@ void callback() {
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PAD & Cross && !(lastPad & Cross) ){
|
||||
if (curLvl.actorPtr->body->gForce.vy == 0 && (curLvl.actorPtr->body->position.vy - curLvl.actorPtr->body->min.vy) == curLvl.levelPtr->body->min.vy ){
|
||||
//~ if (curLvl.actorPtr->body->gForce.vy == 0 && (curLvl.actorPtr->body->position.vy - curLvl.actorPtr->body->min.vy) == curLvl.levelPtr->body->min.vy ){
|
||||
if (curLvl.actorPtr->body->gForce.vy == 0){
|
||||
// Use delta to find jump force
|
||||
//~ curLvl.actorPtr->body->gForce.vy = - ((200/((ONE/(dt<1?1:dt))<1?1:(ONE/(dt<1?1:dt))))*14);
|
||||
curLvl.actorPtr->body->gForce.vy = -200;
|
||||
curLvl.actorPtr->body->gForce.vy = -300;
|
||||
}
|
||||
timer = 10;
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[4]);
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[4]->VAGsample, curLvl.levelSounds->sounds[4]->volumeL, curLvl.levelSounds->sounds[4]->volumeR );
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !(PAD & Cross) && lastPad & Cross ) {
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PAD & Circle && !(PAD & lastPad) ){
|
||||
playSFX(&voiceAttributes, &curLvl.VAG->samples[5]);
|
||||
playSFX(&voiceAttributes, curLvl.levelSounds->sounds[5]->VAGsample, curLvl.levelSounds->sounds[5]->volumeL, curLvl.levelSounds->sounds[5]->volumeR );
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !(PAD & Circle) && lastPad & Circle ) {
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( PAD & PadLeft && !(lastPad & PadLeft) ) {
|
||||
if (curLvl.actorPtr->anim->interpolate){
|
||||
curLvl.actorPtr->anim->interpolate = 0;
|
||||
} else {
|
||||
curLvl.actorPtr->anim->interpolate = 1;
|
||||
}
|
||||
lastPad = PAD;
|
||||
}
|
||||
if ( !(PAD & PadLeft) && lastPad & PadLeft ) {
|
||||
lastPad = PAD;
|
||||
}
|
||||
//~ if ( PAD & PadLeft && !(lastPad & PadLeft) ) {
|
||||
|
||||
//~ lastPad = PAD;
|
||||
//~ }
|
||||
//~ if ( !(PAD & PadLeft) && lastPad & PadLeft ) {
|
||||
//~ lastPad = PAD;
|
||||
//~ }
|
||||
if (theControllers[0].type == 0x73){
|
||||
// Analog stick L up
|
||||
if ( theControllers[0].analog3 >= 0 && theControllers[0].analog3 < (128 - DS_DZ/2)) {
|
||||
|
55
src/math.c
55
src/math.c
@ -1,4 +1,4 @@
|
||||
#include "../include/math.h"
|
||||
#include <math.h>
|
||||
|
||||
// Stolen from grumpycoder
|
||||
// this is from here : https://github.com/grumpycoders/Balau/blob/master/tests/test-Handles.cc#L20-L102
|
||||
@ -13,9 +13,11 @@ void generateTable(void){
|
||||
m_cosTable[0] = 16777216; // 2^24 * cos(0 * 2pi / 2048) => 2^24 * 1 = 2^24 : here, 2^24 defines the precision we want after the decimal point
|
||||
static const long long C = 16777137; // 2^24 * cos(1 * 2pi / 2048) = C = f(1);
|
||||
m_cosTable[1] = C;
|
||||
for (int i = 2; i < 512; i++){
|
||||
for (int i = 2; i < 511; i++){
|
||||
m_cosTable[i] = ((C * m_cosTable[i - 1]) >> 23) - m_cosTable[i - 2];
|
||||
m_cosTable[511] = 0;
|
||||
}
|
||||
for (int i = 0; i < 512; i++){
|
||||
m_cosTable[i] >>= 12;
|
||||
}
|
||||
};
|
||||
int ncos(unsigned int t) {
|
||||
@ -30,7 +32,7 @@ int ncos(unsigned int t) {
|
||||
} else {
|
||||
r = m_cosTable[DC_2PI - 1 - t];
|
||||
};
|
||||
return r >> 12;
|
||||
return r;
|
||||
};
|
||||
// sin(x) = cos(x - pi / 2)
|
||||
int nsin(unsigned int t) {
|
||||
@ -106,7 +108,8 @@ int32_t lerpS(int32_t start, int32_t dest, unsigned pos) {
|
||||
// precision = 2^24 - 2^x
|
||||
// << x : 0 < pos < precision
|
||||
// https://discord.com/channels/642647820683444236/646765703143227394/811318550978494505
|
||||
// my angles are between 0 and 2048 (full circle), so 2^11 for the range of angles; with numbers on a 8.24 representation, a 1.0 angle (or 2pi) means it's 2^24, so to "convert" my angles from 8.24 to my internal discrete cos, I only have to shift by 13
|
||||
// my angles are between 0 and 2048 (full circle), so 2^11 for the range of angles; with numbers on a 8.24 representation,
|
||||
// a 1.0 angle (or 2pi) means it's 2^24, so to "convert" my angles from 8.24 to my internal discrete cos, I only have to shift by 13
|
||||
int32_t lerpD(int32_t start, int32_t dest, int32_t pos) {
|
||||
return dMul(start, 16777216 - pos) + dMul(dest, pos);
|
||||
};
|
||||
@ -144,3 +147,45 @@ VECTOR getVectorTo( VECTOR actor, VECTOR target ) {
|
||||
VectorNormal(&direction, &Ndirection);
|
||||
return Ndirection ;
|
||||
};
|
||||
|
||||
// 20.12 fixed point to 20.12 fixed point rounding
|
||||
int32_t round(int32_t n) {
|
||||
return (n + 2048) & 0xfffff000;
|
||||
};
|
||||
|
||||
// 20.12 fixed point to int, rounding first
|
||||
static inline int32_t toint(int32_t n) {
|
||||
return (n + 2048) >> 12;
|
||||
};
|
||||
//~ int32_t round( int32_t n){
|
||||
//~ // GRS - Action
|
||||
//~ // 0xx - round down = do nothing (x means any bit value, 0 or 1)
|
||||
//~ // 100 - this is a tie: round up if the mantissa's bit just before G is 1, else round down=do nothing
|
||||
//~ // 101 - round up
|
||||
//~ // 110 - round up
|
||||
//~ // 111 - round up
|
||||
//~ // source : https://stackoverflow.com/a/8984135
|
||||
//~ // e.g : n == 106 150 == 0000 0000 0000 0001 1001 1110 1010 0110
|
||||
//~ // Get GRS bits
|
||||
//~ // 0xe00 == 0000 1110 0000 0000
|
||||
//~ int8_t grs = ( n & 0xe00) >> 8 ; // 1110 0000 0000 >> 8
|
||||
//~ // GRS == 111(0)
|
||||
//~ // Get G value - 0x8 == 1000
|
||||
//~ if (grs & 0x8){
|
||||
//~ // GRS = 1xx
|
||||
//~ if ( // Get R value - 0x4 == 0100
|
||||
//~ // GRS == 11x ; round up
|
||||
//~ grs & 0x4 ||
|
||||
//~ // Get S value - 0x2 == 0010
|
||||
//~ // GRS == 101 ; round up
|
||||
//~ ( !(grs & 0x4) && grs & 0x2)
|
||||
//~ ) {
|
||||
//~ n += 0x800;
|
||||
//~ } else if ( !(n & 0x1000) ) {
|
||||
//~ // Get mantissa lsb - 0x1000 == 0001 0000 0000
|
||||
//~ // GRS == 100 ; tie, round up if mantissa lsb is 1
|
||||
//~ n += 0x800;
|
||||
//~ }
|
||||
//~ }
|
||||
//~ return n;
|
||||
//~ };
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../include/pad.h"
|
||||
#include <pad.h>
|
||||
|
||||
void get_digital_direction( Controller_Data *c, int buttondata ) // get analog stick values
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../include/pcdrv.h"
|
||||
#include <pcdrv.h>
|
||||
|
||||
int waitForSIODone( int * flag ){
|
||||
// This should wait for a signal from the SIO to tell when it's done
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../include/physics.h"
|
||||
#include <physics.h>
|
||||
|
||||
short checkLineW( VECTOR * pointA, VECTOR * pointB, MESH * mesh ) {
|
||||
long val1 = ( ( mesh->body->position.vx + mesh->body->min.vx ) - pointA->vx ) * ( pointB->vy - pointA->vy ) - ( ( mesh->body->position.vz + mesh->body->min.vy ) - pointA->vy ) * ( pointB->vx - pointA->vx ) ;
|
||||
@ -87,7 +87,7 @@ VECTOR getIntCollision(BODY one, BODY two){
|
||||
d2.vy = (two.position.vy + two.max.vy) - (one.position.vy + one.min.vy);
|
||||
d2.vz = (two.position.vz + two.max.vz) - (one.position.vz - one.max.vz);
|
||||
col.vx = !(d1.vx > 0 && d2.vx > 0);
|
||||
col.vy = d1.vy > 0 && d2.vy > 0;
|
||||
col.vy = !(d1.vy > 0 && d2.vy > 0);
|
||||
col.vz = !(d1.vz > 0 && d2.vz > 0);
|
||||
return col;
|
||||
};
|
||||
@ -104,20 +104,39 @@ VECTOR getExtCollision(BODY one, BODY two){
|
||||
col.vz = d1.vz > 0 && d2.vz > 0;
|
||||
return col;
|
||||
};
|
||||
void checkBodyCol(BODY * one, BODY * two){
|
||||
VECTOR colInt, colExt;
|
||||
VECTOR checkBodyCol(BODY * one, BODY * two){
|
||||
VECTOR colInt;
|
||||
colInt = getIntCollision( *one , *two );
|
||||
//~ colExt = getExtCollision( *one , *two );
|
||||
// If collisiton on Y axis,
|
||||
if ( colInt.vy ) {
|
||||
if ( !(colInt.vy) ) {
|
||||
// and above plane
|
||||
if ( !colInt.vx && !colInt.vz ) {
|
||||
// collide
|
||||
one->position.vy = two->max.vy - one->max.vy ;
|
||||
short slopeX = two->normal.vx > 0 ? 1 : -1;
|
||||
//~ short slopeZ = two->normal.vz > 0 ? 1 : -1;
|
||||
long o = two->max.vy - two->min.vy ;
|
||||
long a = two->max.vx - two->min.vx;
|
||||
long aa = (two->position.vx + two->min.vx) - (one->position.vx + one->min.vx) ;
|
||||
//~ long b = two->max.vz - two->min.vz;
|
||||
//~ long ab = (two->position.vz + two->min.vz) - (one->position.vz + one->min.vz) ;
|
||||
// Avoid div/0
|
||||
if (a){
|
||||
long y = (( (slopeX * o) * ONE) / a) * aa;
|
||||
// long y = (( (slopeZ * o) * ONE) / b) * ab;
|
||||
// FntPrint("sly: %d", y >> 12);
|
||||
if (y) {
|
||||
one->position.vy = (y >> 12) - ( slopeX < 0 ? 128 : 0 );
|
||||
// one->position.vy = (y >> 12) - ( slopeZ < 0 ? 64 : 0 ) ;
|
||||
} else {
|
||||
one->position.vy = two->max.vy - one->max.vy;
|
||||
}
|
||||
}
|
||||
one->velocity.vy = 0;
|
||||
two->velocity.vy = 0;
|
||||
//~ FntPrint("col: %d %d %d %d\nY: %d, Z: %d, X: %d\nSlope: %d", o, a, aa, ab, one->position.vy, one->position.vz, one->position.vx, slopeX);
|
||||
}
|
||||
}
|
||||
return colInt;
|
||||
};
|
||||
void applyAngMom(LEVEL curLvl ){
|
||||
if (curLvl.propPtr->isRound){
|
||||
@ -231,3 +250,14 @@ u_int jump(BODY * actor, int dt){
|
||||
);
|
||||
return vt;
|
||||
};
|
||||
void respawnMesh(LEVEL * level, MESH * mesh, VECTOR * rot, VECTOR * pos, NODE * node){
|
||||
// Actor
|
||||
if( mesh->isActor ){
|
||||
level->curNode = node;
|
||||
level->levelPtr = level->curNode->plane;
|
||||
} else {
|
||||
level->propPtr->node = node;
|
||||
}
|
||||
copyVector(&mesh->body->position, pos );
|
||||
copyVector(&mesh->rot, rot );
|
||||
};
|
||||
|
@ -1,5 +1,5 @@
|
||||
#include "../include/psx.h"
|
||||
#include "../include/sound.h"
|
||||
#include <psx.h>
|
||||
#include <sound.h>
|
||||
|
||||
|
||||
void setDCLightEnv(MATRIX * curLevelCMat, MATRIX * curLevelLgtMat, SVECTOR * curLevelLgtAng){
|
||||
@ -106,6 +106,7 @@ void LvlPtrSet(LEVEL * curLevel, LEVEL * level){
|
||||
curLevel->curNode = level->curNode; // Blank
|
||||
curLevel->VAG = level->VAG;
|
||||
curLevel->XA = level->XA;
|
||||
curLevel->levelSounds = level->levelSounds;
|
||||
|
||||
//~ curLevel->actorPtr->body = level->actorPtr->body;
|
||||
// Move these to drawPoly()
|
||||
|
140
src/sound.c
140
src/sound.c
@ -1,10 +1,9 @@
|
||||
#include "../include/sound.h"
|
||||
#include "../include/space.h"
|
||||
#include <sound.h>
|
||||
#include <space.h>
|
||||
|
||||
// VAG playback
|
||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec){
|
||||
|
||||
SpuInitMalloc(MALLOC_MAX, spu_malloc_rec); // Maximum number of blocks, mem. management table address.
|
||||
void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec, u_int mallocMax){
|
||||
SpuInitMalloc(mallocMax, spu_malloc_rec); // Maximum number of blocks, mem. management table address.
|
||||
spuSettings->mask = (SPU_COMMON_MVOLL | SPU_COMMON_MVOLR | SPU_COMMON_CDVOLL | SPU_COMMON_CDVOLR | SPU_COMMON_CDMIX ); // Mask which attributes to set
|
||||
spuSettings->mvol.left = MVOL_L; // Master volume left
|
||||
spuSettings->mvol.right = MVOL_R; // see libref47.pdf, p.1058
|
||||
@ -12,21 +11,21 @@ void initSnd(SpuCommonAttr * spuSettings, char * spu_malloc_rec){
|
||||
spuSettings->cd.volume.right = CDVOL_R;
|
||||
// Enable CD input ON
|
||||
spuSettings->cd.mix = SPU_ON;
|
||||
|
||||
// Apply settings
|
||||
SpuSetCommonAttr(spuSettings);
|
||||
// Set transfer mode
|
||||
SpuSetTransferMode(SPU_TRANSFER_BY_DMA);
|
||||
SpuSetIRQ(SPU_OFF);
|
||||
// Mute all voices
|
||||
SpuSetKey(SpuOff, SPU_ALLCH);
|
||||
}
|
||||
};
|
||||
u_long sendVAGtoSPU(unsigned int VAG_data_size, u_char *VAG_data){
|
||||
u_long transferred;
|
||||
SpuSetTransferMode(SpuTransByDMA); // DMA transfer; can do other processing during transfer
|
||||
transferred = SpuWrite (VAG_data + sizeof(VAGhdr), VAG_data_size); // transfer VAG_data_size bytes from VAG_data address to sound buffer
|
||||
SpuIsTransferCompleted (SPU_TRANSFER_WAIT); // Checks whether transfer is completed and waits for completion
|
||||
return transferred;
|
||||
}
|
||||
};
|
||||
void setVoiceAttr(SpuVoiceAttr * voiceAttributes, u_int pitch, long channel, u_long soundAddr ){
|
||||
voiceAttributes->mask= //~ Attributes (bit string, 1 bit per attribute)
|
||||
(
|
||||
@ -57,7 +56,7 @@ void setVoiceAttr(SpuVoiceAttr * voiceAttributes, u_int pitch, long channel, u_l
|
||||
voiceAttributes->sr = 0x0; //~ Sustain rate
|
||||
voiceAttributes->sl = 0xf; //~ Sustain level
|
||||
SpuSetVoiceAttr(voiceAttributes); // set attributes
|
||||
}
|
||||
};
|
||||
u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
||||
// Return spu_address
|
||||
u_long transferred, spu_address;
|
||||
@ -68,24 +67,68 @@ u_long setSPUtransfer(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
||||
SpuSetTransferStartAddr(spu_address); // Sets a starting address in the sound buffer
|
||||
transferred = sendVAGtoSPU(SWAP_ENDIAN32(VAGheader->dataSize), sound->VAGfile);
|
||||
setVoiceAttr(voiceAttributes, pitch, sound->spu_channel, spu_address);
|
||||
// Return 1 if ok, size transferred else.
|
||||
//~ if (transferred == SWAP_ENDIAN32(VAGheader->dataSize)){
|
||||
//~ return 1;
|
||||
//~ }
|
||||
//~ return transferred;
|
||||
return spu_address;
|
||||
}
|
||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound){
|
||||
// Set voice volume to max
|
||||
};
|
||||
void setVAGvolume(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volumeL,int volumeR ){
|
||||
voiceAttributes->mask= ( SPU_VOICE_VOLL | SPU_VOICE_VOLR );
|
||||
voiceAttributes->voice = sound->spu_channel;
|
||||
// Range 0 - 3fff
|
||||
voiceAttributes->volume.left = VOICEVOL_L;
|
||||
voiceAttributes->volume.right = VOICEVOL_R;
|
||||
SpuSetVoiceAttr(voiceAttributes);
|
||||
voiceAttributes->volume.left = volumeL;
|
||||
voiceAttributes->volume.right = volumeR;
|
||||
SpuSetVoiceAttr(voiceAttributes);
|
||||
};
|
||||
void setLvlVAG(LEVEL * level, SpuCommonAttr * spuSettings, SpuVoiceAttr * voiceAttributes, char spu_malloc_rec[]){
|
||||
if (level->VAG != 0){
|
||||
// Free SPU mem
|
||||
for (u_short vag = 0; vag < level->VAG->index; vag++ ){
|
||||
if(level->VAG->samples[vag].spu_address != 0){
|
||||
SpuFree(level->VAG->samples[vag].spu_address);
|
||||
}
|
||||
}
|
||||
// Init sound settings
|
||||
initSnd(spuSettings, spu_malloc_rec, level->VAG->index );
|
||||
for (u_short vag = 0; vag < level->VAG->index; vag++ ){
|
||||
level->VAG->samples[vag].spu_address = setSPUtransfer(voiceAttributes, &level->VAG->samples[vag]);
|
||||
}
|
||||
}
|
||||
};
|
||||
void playSFX(SpuVoiceAttr * voiceAttributes, VAGsound * sound, int volumeL, int volumeR ){
|
||||
// Set voice volume to sample volume
|
||||
setVAGvolume(voiceAttributes, sound, volumeL, volumeR);
|
||||
// Play voice
|
||||
SpuSetKey(SpuOn, sound->spu_channel);
|
||||
}
|
||||
};
|
||||
void setSFXdist(LEVEL * level, CAMERA * camera, int camMode ){
|
||||
VECTOR sndPos2D = {0};
|
||||
if (level->levelSounds != 0){
|
||||
for(int snd = 0; snd < level->levelSounds->index; snd++){
|
||||
u_int r;
|
||||
// If parent is actor,
|
||||
if (level->levelSounds->sounds[snd]->parent == level->actorPtr && camMode <= 1){
|
||||
r = CAM_DIST_TO_ACT;
|
||||
// update sound location if sound has a parent and it's not actor
|
||||
} else if ( level->levelSounds->sounds[snd]->parent != 0){
|
||||
VECTOR dist;
|
||||
copyVector(&level->levelSounds->sounds[snd]->location, &level->levelSounds->sounds[snd]->parent->pos);
|
||||
// Get distance between sound source and camera
|
||||
dist.vx = -camera->pos->vx - level->levelSounds->sounds[snd]->location.vx;
|
||||
dist.vz = -camera->pos->vz - level->levelSounds->sounds[snd]->location.vz;
|
||||
r = psqrt((dist.vx * dist.vx) + (dist.vz * dist.vz));
|
||||
// Get snd screen coordinates
|
||||
// Range -1024 0 == screen left, 0 +1024 == screen right
|
||||
worldToScreen(&level->levelSounds->sounds[snd]->location, &sndPos2D);
|
||||
}
|
||||
// Find volume base on dist
|
||||
u_int volumeBase = (level->levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED > SND_MAX_VOL ? SND_MAX_VOL :
|
||||
(level->levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED < 0 ? 0 :
|
||||
(level->levelSounds->sounds[snd]->volume_max/r) * SND_NMALIZED;
|
||||
// Avoid value of 0
|
||||
sndPos2D.vx = sndPos2D.vx == 0 || sndPos2D.vx == -0 ? 1 : sndPos2D.vx;
|
||||
level->levelSounds->sounds[snd]->volumeL = volumeBase / ( (sndPos2D.vx > SND_DZ ? ( sndPos2D.vx - SND_DZ >> 7) + 1 : 1) );
|
||||
level->levelSounds->sounds[snd]->volumeR = volumeBase / ( (sndPos2D.vx < -SND_DZ ? ( ( -sndPos2D.vx - SND_DZ ) >> 7) + 1 : 1) );
|
||||
}
|
||||
}
|
||||
};
|
||||
void XAsetup(void){
|
||||
u_char param[4];
|
||||
// ORing the parameters we need to set ; drive speed, ADPCM play, Subheader filter, sector size
|
||||
@ -97,13 +140,16 @@ void XAsetup(void){
|
||||
CdControlB(CdlSetmode, param, 0);
|
||||
// Pause at current pos
|
||||
CdControlF(CdlPause,0);
|
||||
}
|
||||
};
|
||||
void getXAoffset(LEVEL * level){
|
||||
// TODO : Only works for first XA file
|
||||
CdlFILE XAPos = {0};
|
||||
// Load XA file
|
||||
CdSearchFile(&XAPos, level->XA->name);
|
||||
//~ CdSearchFile(&XAPos, level->XA->name);
|
||||
CdSearchFile(&XAPos, level->XA->banks[0]->name);
|
||||
// Set cd head to start of file
|
||||
level->XA->offset = CdPosToInt(&XAPos.pos);
|
||||
//~ level->XA->offset = CdPosToInt(&XAPos.pos);
|
||||
level->XA->banks[0]->offset = CdPosToInt(&XAPos.pos);
|
||||
};
|
||||
void setXAsample(XAsound * sound, CdlFILTER * filter){
|
||||
filter->chan = sound->channel;
|
||||
@ -112,4 +158,48 @@ void setXAsample(XAsound * sound, CdlFILTER * filter){
|
||||
CdControlF(CdlSetfilter, (u_char *)filter);
|
||||
// Reset sample's cursor
|
||||
sound->cursor = 0;
|
||||
}
|
||||
};
|
||||
void setLvlXA(LEVEL * level, int sample){
|
||||
if(sample >= 0){
|
||||
// CD filter
|
||||
CdlFILTER filter;
|
||||
// File position in m/s/f
|
||||
CdlLOC loc;
|
||||
if (level->XA != 0){
|
||||
// Change XA track
|
||||
XAsetup();
|
||||
//~ sample = !sample;
|
||||
level->XA->banks[0]->samples[sample].cursor = -1;
|
||||
getXAoffset(level);
|
||||
setXAsample(&level->XA->banks[0]->samples[sample], &filter);
|
||||
CdIntToPos(level->XA->banks[0]->samples[sample].start + level->XA->banks[0]->offset , &loc);
|
||||
// Send CDROM read command
|
||||
CdControlF(CdlReadS, (u_char *)&loc);
|
||||
}
|
||||
}
|
||||
};
|
||||
void XAplayback(LEVEL * level, int sample, long dt){
|
||||
if (sample != -1 ){
|
||||
// CD filter
|
||||
CdlFILTER filter;
|
||||
// File position in m/s/f
|
||||
CdlLOC loc;
|
||||
// Begin XA file playback...
|
||||
// if sample's cursor is 0
|
||||
if (level->XA->banks[0]->samples[sample].cursor == 0){
|
||||
// Convert sector number to CD position in min/second/frame and set CdlLOC accordingly.
|
||||
CdIntToPos(level->XA->banks[0]->samples[sample].start + level->XA->banks[0]->offset , &loc);
|
||||
// Send CDROM read command
|
||||
CdControlF(CdlReadS, (u_char *)&loc);
|
||||
//~ *XATime = VSync(-1);
|
||||
// Set playing flag
|
||||
}
|
||||
// if sample's cursor is close to sample's end position, stop playback
|
||||
// XA playback has fixed rate
|
||||
if ((level->XA->banks[0]->samples[sample].cursor += XA_CDSPEED / ((XA_RATE/(dt+1)+1)) ) >= (level->XA->banks[0]->samples[sample].end - level->XA->banks[0]->samples[sample].start) * ONE ){
|
||||
//~ CdControlF(CdlStop,0);
|
||||
level->XA->banks[0]->samples[sample].cursor = -1;
|
||||
setXAsample(&level->XA->banks[0]->samples[sample], &filter);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include "../include/space.h"
|
||||
#include <space.h>
|
||||
|
||||
// From 'psyq/addons/graphics/ZIMEN/CLIP.C'
|
||||
void worldToScreen( VECTOR * worldPos, VECTOR * screenPos ) {
|
||||
@ -13,9 +13,9 @@ void worldToScreen( VECTOR * worldPos, VECTOR * screenPos ) {
|
||||
// Get world translation vectors from rot and add to screenPos vx, vy, vz
|
||||
applyVector(screenPos, curRot.t[0], curRot.t[1], curRot.t[2], +=);
|
||||
// Correct perspective
|
||||
screenPos -> vx = screenPos -> vx * distToScreen / ( screenPos -> vz + 1 ) ; // Add 1 to avoid division by 0
|
||||
screenPos -> vy = screenPos -> vy * distToScreen / ( screenPos -> vz + 1 ) ;
|
||||
screenPos -> vz = distToScreen ;
|
||||
//~ screenPos -> vx = screenPos -> vx * distToScreen / ( screenPos -> vz + 1 ) ; // Add 1 to avoid division by 0
|
||||
//~ screenPos -> vy = screenPos -> vy * distToScreen / ( screenPos -> vz + 1 ) ;
|
||||
//~ screenPos -> vz = distToScreen ;
|
||||
};
|
||||
void screenToWorld( VECTOR * screenPos, VECTOR * worldPos ) {
|
||||
int distToScreen; // corresponds to FOV
|
||||
|
2
thirdparty/nugget
vendored
2
thirdparty/nugget
vendored
@ -1 +1 @@
|
||||
Subproject commit 6483f1e13b5c89932500129548e8aa8f2a026f25
|
||||
Subproject commit a6e3be17bac082d789dfcc9e3b767128f560c28f
|
@ -1,8 +0,0 @@
|
||||
1 xa lobby.xa 1 0
|
||||
1 xa pixel.xa 1 1
|
||||
1 null
|
||||
1 null
|
||||
1 null
|
||||
1 null
|
||||
1 null
|
||||
1 null
|
BIN
xa/lobby.xa
BIN
xa/lobby.xa
Binary file not shown.
BIN
xa/pixel.xa
BIN
xa/pixel.xa
Binary file not shown.
Loading…
Reference in New Issue
Block a user