Compare commits
93 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c7f210706d | |||
| 3a06ac548d | |||
| 8225abf328 | |||
| 2e23914c17 | |||
| e7c2f8a7c7 | |||
| 756fb216a4 | |||
| de4ce28839 | |||
| ed59d6b254 | |||
| 3fe9715958 | |||
| cba177f2db | |||
| 781c97eb73 | |||
| 5245ba3f55 | |||
| f0b5d25a27 | |||
| 5f22c02d2e | |||
| d63bd6cb0e | |||
| 921f34eb4c | |||
| 385e553e5a | |||
| e4230f1b62 | |||
| 94a353cdb8 | |||
| 8a162be036 | |||
| 1d273de455 | |||
| eecfc0b6c2 | |||
| 7ff8153086 | |||
| 9cb52ff620 | |||
| 3023bb7501 | |||
| 762e7eada2 | |||
| 70ea8e47ba | |||
| dd8499abad | |||
| 0816f522bb | |||
| fafc66d35c | |||
| d8458b98e0 | |||
| d0d7ed85e5 | |||
| a80f62e843 | |||
| 8b0233a45d | |||
| 10b275055c | |||
| 164d9f558c | |||
| 247e71a407 | |||
| ea49543542 | |||
| 20de0dc17d | |||
| 1090801f4e | |||
| 7b43c0c90f | |||
| b0ae873a88 | |||
| 7b3a28065b | |||
| 589b3b03a4 | |||
| 611d4f76be | |||
| bf0c65a14c | |||
| ab0c999117 | |||
| 28599512e4 | |||
| db6c84ba11 | |||
| b0c94a1602 | |||
| f34284591f | |||
| 7203f6f5c4 | |||
| 94f6e9fbf2 | |||
| 18ba08dc7a | |||
| 9dd69317e3 | |||
| 24509f7f20 | |||
| 9268628ccd | |||
| 4160bddc4b | |||
| e022fcdafe | |||
| 444990a262 | |||
| b749a80a25 | |||
| e43fae88e8 | |||
| 11717f42eb | |||
| 142bf60a6d | |||
| 9efd8ab3e1 | |||
| 7b2e411a13 | |||
| 8bd5476d61 | |||
| 4146df48a9 | |||
| 35fc8aea73 | |||
| c0bb78f1c9 | |||
| e5c2aa1548 | |||
| c72393b236 | |||
| a973c47321 | |||
| bc41afdf89 | |||
| 67bbe2e674 | |||
| 69b3621215 | |||
| b053504623 | |||
| ad43a4bfd3 | |||
| 1b6e1e94ee | |||
| 6e09741d19 | |||
| 152bc7d6cf | |||
| 25255c1c22 | |||
| fcf03b27fa | |||
| b8d31fc1cc | |||
| 249c2431a2 | |||
| 2d1d36ddcc | |||
| bd11955fd4 | |||
| 3c827a407b | |||
| 607c2abc0c | |||
| 49713dc145 | |||
| 18db9875ad | |||
| 37703e69d0 | |||
| 91e8f791b0 |
@@ -0,0 +1,60 @@
|
|||||||
|
# Based on https://github.com/ps2dev/gsKit/blob/master/.github/workflows/compilation.yml
|
||||||
|
# Thanks fjtrujy!
|
||||||
|
|
||||||
|
name: CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
pull_request:
|
||||||
|
repository_dispatch:
|
||||||
|
types: [run_build]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container: ps2dev/ps2sdk-ports:latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
apk add build-base git
|
||||||
|
|
||||||
|
- name: Compile engine
|
||||||
|
working-directory: ./src/engine
|
||||||
|
env:
|
||||||
|
ZLIB: ${PS2SDK}/ports
|
||||||
|
LIBTIFF: ${PS2SDK}/ports
|
||||||
|
LIBJPEG: ${PS2SDK}/ports
|
||||||
|
LIBPNG: ${PS2SDK}/ports
|
||||||
|
TYRA: ${GITHUB_WORKSPACE}
|
||||||
|
run: |
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Compile unit test project
|
||||||
|
working-directory: ./src/unit_tests/
|
||||||
|
env:
|
||||||
|
TYRA: ${GITHUB_WORKSPACE}
|
||||||
|
run: |
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Compile cube project
|
||||||
|
working-directory: ./src/samples/cube/
|
||||||
|
env:
|
||||||
|
TYRA: ${GITHUB_WORKSPACE}
|
||||||
|
run: |
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Compile floors project
|
||||||
|
working-directory: ./src/samples/floors/
|
||||||
|
env:
|
||||||
|
TYRA: ${GITHUB_WORKSPACE}
|
||||||
|
run: |
|
||||||
|
make
|
||||||
|
|
||||||
|
- name: Compile dolphin project
|
||||||
|
working-directory: ./src/samples/dolphin/
|
||||||
|
env:
|
||||||
|
TYRA: ${GITHUB_WORKSPACE}
|
||||||
|
run: |
|
||||||
|
make
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
|
||||||
# ---
|
# ---
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,37 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## [1.36.3] - 2021-05-28
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Unit test project
|
||||||
|
- Assert
|
||||||
|
- CI via Github workflows
|
||||||
|
- Install tutorial as separated .MD file
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Improved BMP loader.
|
||||||
|
- All PRINT_LOG and PRINT_ERR to consoleLog() and assertMsg()
|
||||||
|
- Refactored makefiles
|
||||||
|
- **CHANGED ENV VARIABLES!**
|
||||||
|
- Install tutorial
|
||||||
|
- Readme
|
||||||
|
|
||||||
|
## [1.31.2] - 2021-02-06
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Id to MeshFrame
|
||||||
|
- Non textured rendering (RGBA only)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Moved color from mesh to mesh material.
|
||||||
|
- OBJ Loader refactor
|
||||||
|
- Logic of loadFrom()
|
||||||
|
- Migrated to GCC9 (valid with latest PS2SDK)
|
||||||
|
|
||||||
|
### Removed
|
||||||
|
- Removed MeshId from TextureLink, TextureRepository
|
||||||
|
|
||||||
## [1.29.1] - 2020-12-27
|
## [1.29.1] - 2020-12-27
|
||||||
### Added
|
### Added
|
||||||
- Created libpacket2 in PS2SDK
|
- Created libpacket2 in PS2SDK
|
||||||
@@ -96,6 +127,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Makefile
|
- Makefile
|
||||||
- Primitive floors sample
|
- Primitive floors sample
|
||||||
|
|
||||||
|
[1.36.3]: https://github.com/h4570/tyra/compare/v1.31.2-alpha...v1.36.3-alpha
|
||||||
|
[1.31.2]: https://github.com/h4570/tyra/compare/v1.29.1-alpha...v1.31.2-alpha
|
||||||
[1.29.1]: https://github.com/h4570/tyra/compare/1.1.0...v1.29.1-alpha
|
[1.29.1]: https://github.com/h4570/tyra/compare/1.1.0...v1.29.1-alpha
|
||||||
[1.1.0]: https://github.com/h4570/tyra/compare/1.0.0...1.1.0
|
[1.1.0]: https://github.com/h4570/tyra/compare/1.0.0...1.1.0
|
||||||
[1.0.0]: https://github.com/h4570/tyra/compare/1.0.0
|
[1.0.0]: https://github.com/h4570/tyra/compare/1.0.0
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash.png" alt="Logo" width="100%" height="auto">
|
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash.png" alt="Logo" width="100%" height="auto">
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<h3 align="center">Tyra - alpha 1.29.1</h3>
|
<h3 align="center">Tyra - alpha 1.36.3</h3>
|
||||||
|
|
||||||
<p align="center">
|
<p align="center">
|
||||||
Open source game engine for PlayStation 2™
|
Open source game engine for PlayStation 2™
|
||||||
@@ -25,44 +25,63 @@
|
|||||||
</p>
|
</p>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
[](https://github.com/h4570/tyra/stargazers)
|
||||||
|
|
||||||
## Table of Contents
|
## Table of Contents
|
||||||
|
|
||||||
* [About the Project](#about-the-project)
|
* [About the Project](#about-the-project)
|
||||||
* [Samples](#samples)
|
* [Samples](#samples)
|
||||||
* [About project](#about-project)
|
* [Description](#description)
|
||||||
* [Tyra features](#tyra-features)
|
* [Features](#features)
|
||||||
* [Branches](#branches)
|
* [Branches](#branches)
|
||||||
* [Getting Started](#getting-started)
|
* [Getting Started](#getting-started)
|
||||||
* [Installation](#installation)
|
* [Installation](#installation)
|
||||||
* [Prerequisites](#prerequisites)
|
* [Prerequisites](#prerequisites)
|
||||||
* [Roadmap](#roadmap)
|
* [Roadmap](#roadmap)
|
||||||
* [Tyra team](#tyra-team)
|
|
||||||
* [Contributing](#contributing)
|
* [Contributing](#contributing)
|
||||||
* [License](#license)
|
* [License](#license)
|
||||||
* [Built With](#built-with)
|
* [Built With](#built-with)
|
||||||
* [Acronyms](#acronyms)
|
* [Acronyms](#acronyms)
|
||||||
* [Thanks](#thanks)
|
* [Thanks](#thanks)
|
||||||
|
|
||||||
## About The Project
|
<br />
|
||||||
|
|
||||||
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/tyra.gif" alt="sample" width="600" height="auto">
|
## About the Project
|
||||||
|
|
||||||
### Contributors wanted [](https://discord.gg/NhhTmg3Gm5)
|
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/tyra.gif" alt="Sample code" width="600" height="auto">
|
||||||
We will be grateful for any help. If you dont know PS2.. don't worry, we are open to explain how things work.
|
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/dolphin.gif " alt="Sample game" width="500" height="auto">
|
||||||
|
|
||||||
### Samples
|
### Samples
|
||||||
* [Dolphin](https://github.com/h4570/tyra/tree/master/src/samples/dolphin)
|
* [Dolphin](https://github.com/h4570/tyra/tree/master/src/samples/dolphin)
|
||||||
* [Floors](https://github.com/h4570/tyra/tree/master/src/samples/floors)
|
* [Floors](https://github.com/h4570/tyra/tree/master/src/samples/floors)
|
||||||
|
* [Cube](https://github.com/h4570/tyra/tree/master/src/samples/cube)
|
||||||
|
|
||||||
### About project
|
### Description
|
||||||
Goal of Tyra project is to provide simple API for PS2 game creation, so you can just run PS2 emulator, grab .obj file, and put it into live in a seconds. Project is on alpha stage, so keep in mind that there are many things to be done and to fix.
|
Tyra is a project that aims to facilitate the development of PlayStation 2 games. The goal is simple API which will allow you to develop some nice small homebrew games in a short period of time. Finally, (thanks to PS2DEV team) Tyra supports C++20, so we are free from the 2003's GCC which only supported C++98.
|
||||||
|
**Project is on alpha stage, so keep in mind that there are many things to be done and to fix.**
|
||||||
|
Unfortunately there are not many people, which want's to help with this project. **If you want to be a volunteer**, but don't have too much knowledge in this field, write to me on Discord, **I will be happy to help.**
|
||||||
|
|
||||||
YouTube tutorials soon!
|
When project will be on beta stage, we plan to create some YouTube tutorials :)
|
||||||
|
|
||||||
**Why Tyra is needed?** Raw PS2 development can be a big challenge. PS2 it's pretty low-level and there are a lot of stuff that you must do from scratch.
|
**Why was this project created?**
|
||||||
Tyra takes care for you, and rendering, coprocessors communication, synchronization and many more low-level stuff is already done.
|
PS2 development can be a big challenge.
|
||||||
|
PS2 it's pretty low-level and there are a lot of stuff that you must do from scratch.
|
||||||
|
For example, if you want to render something using only PS2DEV you must:
|
||||||
|
- Create VU1 micro-program
|
||||||
|
- Load micro-program and send it to VU1
|
||||||
|
- Create parser for your 3D file
|
||||||
|
- Create parser for texture file
|
||||||
|
- Calculate lights, shadows, MVP matrices (3D->2D)..
|
||||||
|
- Clip triangles ([sic!](https://github.com/h4570/tyra/issues/14))
|
||||||
|
- Prepare DMA packets for coprocessors communication
|
||||||
|
- Setup rasterizer (GS)
|
||||||
|
- Send texture to GS
|
||||||
|
- Send packets
|
||||||
|
- Synchronize all
|
||||||
|
|
||||||
### Tyra features
|
but with Tyra you can do it with methods like `loadObj()` and `draw()` 😁.
|
||||||
|
|
||||||
|
### Features
|
||||||
* 3D support - VU1 "Path 1 rendering"
|
* 3D support - VU1 "Path 1 rendering"
|
||||||
* 2D support - PNG & BMP
|
* 2D support - PNG & BMP
|
||||||
* Frustum culling, backface culling
|
* Frustum culling, backface culling
|
||||||
@@ -78,37 +97,38 @@ Tyra takes care for you, and rendering, coprocessors communication, synchronizat
|
|||||||
* Master - monthly releases - tested on PS2 & PCSX2.
|
* Master - monthly releases - tested on PS2 & PCSX2.
|
||||||
* Develop - daily builds - can be unstable.
|
* Develop - daily builds - can be unstable.
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
|
|
||||||
### Installation [](https://discord.gg/NhhTmg3Gm5)
|
### Installation
|
||||||
In our Discord channel, there is detailed tutorial which will help you with setting up the all environment - starting from installing dependencies and ending on emulator setup or intellisense.
|
Step by step [tutorial here](https://github.com/h4570/tyra/tree/develop/docs)
|
||||||
|
If you need any support, feel free to ask questions on discord:
|
||||||
|
[](https://discord.gg/NhhTmg3Gm5)
|
||||||
|
|
||||||
### Prerequisites
|
### Prerequisites
|
||||||
|
|
||||||
This is an example of how to list things you need to use the software.
|
|
||||||
* PS2 DEV environment - [PS2DEV](https://github.com/ps2dev/ps2dev)
|
* PS2 DEV environment - [PS2DEV](https://github.com/ps2dev/ps2dev)
|
||||||
* At least #674b6f4 PS2SDK (01.12.2020) - [PS2SDK](https://github.com/ps2dev/ps2sdk)
|
* At least #58ffb33 PS2SDK (28.05.2021) - [PS2SDK](https://github.com/ps2dev/ps2sdk)
|
||||||
* PS2 Emulator. For example [PCSX2](https://pcsx2.net/)
|
* PS2 Emulator. For example [PCSX2](https://pcsx2.net/)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Extra info
|
## Extra info
|
||||||
* BMP loader needs some polishing so be sure that you exporting BMP with 24bit: RGB888 and without information about colors.
|
* If you want to use your own .obj file, please check "triangulate faces" in blender.
|
||||||
* If you want to run .elf in PCSX2, be sure that you have version >=1.6 and **Host access** enabled in PCSX2 configuration file.
|
PS2 is supporting only triangle primitive type.
|
||||||
* If you want to use your own .obj file, please check "triangulate faces" in blender. PS2 is supporting only triangle primitive type.
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Roadmap
|
## Roadmap
|
||||||
|
|
||||||
### Roadmap for next master release:
|
### Roadmap for next master release:
|
||||||
[January 2021 Roadmap](https://github.com/h4570/tyra/projects/4)
|
[Next release roadmap](https://github.com/h4570/tyra/projects/4)
|
||||||
|
|
||||||
## Tyra team
|
|
||||||
|
|
||||||
Sandro Sobczyński - sandro.sobczynski@gmail.com
|
|
||||||
[![LinkedIn][linkedin-shield]](https://linkedin.com/in/sandro-sobczyński-28820b15a)
|
|
||||||
Michał Mostowik - mostek3pl@gmail.com
|
|
||||||
[![LinkedIn][linkedin-shield]](https://www.linkedin.com/in/notfoxar)
|
|
||||||
|
|
||||||
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
See the [open issues](https://github.com/h4570/tyra/issues) for a list of proposed features (and known issues).
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
|
||||||
@@ -119,27 +139,35 @@ Contributions are what make the open source community such an amazing place to b
|
|||||||
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
4. Push to the Branch (`git push origin feature/amazing-feature`)
|
||||||
5. Open a Pull Request
|
5. Open a Pull Request
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
Distributed under the Apache License 2.0 License. See `LICENSE` for more information.
|
Distributed under the Apache License 2.0 License. See `LICENSE` for more information.
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Built With
|
## Built With
|
||||||
|
|
||||||
* [PS2SDK](https://github.com/ps2dev/ps2sdk)
|
* [PS2DEV](https://github.com/ps2dev/ps2dev)
|
||||||
|
|
||||||
### Acronyms
|
<br />
|
||||||
|
|
||||||
|
## Acronyms
|
||||||
* EE (Emotion Engine) - whole set of processors and subsystems that make up the PlayStation 2
|
* EE (Emotion Engine) - whole set of processors and subsystems that make up the PlayStation 2
|
||||||
* GS (Graphic synthesizer) - configurable rasterizer and texture mapper. Has only 2MB~ memory for textures, but for the opposite have very high transfer rate, so you can switch textures in the blink
|
* GS (Graphic synthesizer) - configurable rasterizer and texture mapper. Has only 2MB~ memory for textures, but for the opposite have very high transfer rate, so you can switch textures in the blink
|
||||||
* VU0 - programmable (ASM) vector processor that is accessed by inline assembly code injected into C program.
|
* VU0 - programmable (ASM) vector processor that is accessed by inline assembly code injected into C program.
|
||||||
* VU1 - programmable (ASM) vector processor, which is similar to vertex shader. Accessed via DMA.
|
* VU1 - programmable (ASM) vector processor, which is similar to vertex shader. Accessed via DMA.
|
||||||
* IOP - I/O processor which enables access to peripheral devices, such the game controller
|
* IOP - I/O processor which enables access to peripheral devices, such the game controller
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Thanks
|
## Thanks
|
||||||
|
|
||||||
Without these guys, everything would be harder:
|
Without these guys, everything would be harder:
|
||||||
* Dr Henry Fortuna - for code sources
|
* Dr Henry Fortuna - for code sources
|
||||||
* Rick Gaiser - for help and new GCC!
|
* Rick Gaiser, fjtrujy - for help and new GCC!
|
||||||
* Lukasz D.K. - for huge archive of PS2 stuff-
|
* Lukasz D.K. - for huge archive of PS2 stuff
|
||||||
* Guilherme Lampert - for code sources
|
* Guilherme Lampert - for code sources
|
||||||
* Jesper Svennevid, Daniel Collin - for openvcl's code samples
|
* Jesper Svennevid, Daniel Collin - for openvcl's code samples
|
||||||
* Whole PS2DEV team
|
* Whole PS2DEV team
|
||||||
@@ -147,6 +175,8 @@ Without these guys, everything would be harder:
|
|||||||
* And so many other guys. Thanks!
|
* And so many other guys. Thanks!
|
||||||
|
|
||||||
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
Project Link: [https://github.com/h4570/tyra](https://github.com/h4570/tyra)
|
||||||
|
Sandro Sobczyński - sandro.sobczynski@gmail.com
|
||||||
|
[![LinkedIn][linkedin-shield]](https://linkedin.com/in/sandro-sobczyński-28820b15a)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
<a href="https://github.com/h4570/tyra">
|
<a href="https://github.com/h4570/tyra">
|
||||||
|
|||||||
+210
@@ -0,0 +1,210 @@
|
|||||||
|
# Installation tutorial
|
||||||
|
|
||||||
|
This tutorial will show you, how to:
|
||||||
|
- Setup your WSL machine for PS2DEV
|
||||||
|
- Install entire PS2DEV+Tyra environment
|
||||||
|
- Setup VSCode with Intelisense
|
||||||
|
- Setup PCSX2
|
||||||
|
|
||||||
|
So let's get started!
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## VSCode and WSL
|
||||||
|
- Install VSCode from
|
||||||
|
https://code.visualstudio.com/
|
||||||
|
- Install WSL
|
||||||
|
https://docs.microsoft.com/en-us/windows/wsl/install-win10
|
||||||
|
`Info: Please choose Ubuntu-20.04`
|
||||||
|
- Set root as default WSL user.
|
||||||
|
Open `cmd.exe` and type:
|
||||||
|
`ubuntu2004 config --default-user root`
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Ubuntu configuration and PS2DEV+Tyra
|
||||||
|
- Open WSL terminal (Windows search -> wsl)
|
||||||
|
`Info: Be sure that are you logged as a root!`
|
||||||
|
- Type these commands
|
||||||
|
```
|
||||||
|
apt-get update && apt-get upgrade -y
|
||||||
|
apt-get install -y build-essential make texinfo cmake bison flex gettext libgmp3-dev libmpfr-dev libmpc-dev libz-dev wget patch
|
||||||
|
```
|
||||||
|
- Configure git (replace your name and email)
|
||||||
|
```
|
||||||
|
git config --global user.email "your@email.com"
|
||||||
|
git config --global user.name "Your Name"
|
||||||
|
```
|
||||||
|
- Create directories
|
||||||
|
```
|
||||||
|
mkdir /ps2dev
|
||||||
|
mkdir /ps2dev/built
|
||||||
|
mkdir /ps2dev/source
|
||||||
|
mkdir /repos
|
||||||
|
mkdir /repos/tyra
|
||||||
|
```
|
||||||
|
- Clone repos
|
||||||
|
```
|
||||||
|
git clone https://github.com/ps2dev/ps2dev.git /ps2dev/source/
|
||||||
|
git clone https://github.com/h4570/tyra.git /repos/tyra/
|
||||||
|
```
|
||||||
|
- Open bashrc via `nano ~/.bashrc` and add these lines at the end of file. Be sure that they are 1:1, so don't add additional spaces!
|
||||||
|
```
|
||||||
|
export PS2DEV=/ps2dev/built
|
||||||
|
export PS2SDK=$PS2DEV/ps2sdk
|
||||||
|
export GSKIT=$PS2DEV/gsKit
|
||||||
|
export PATH=$PATH:$PS2DEV/bin:$PS2DEV/ee/bin:$PS2DEV/iop/bin:$PS2DEV/dvp/bin:$PS2SDK/bin
|
||||||
|
export PS2HOSTNAME=192.168.0.200
|
||||||
|
export TYRA=/repos/tyra
|
||||||
|
export WSL_MAKE_WINDOWS=\\\\\\\\wsl\$\$\\\\Ubuntu-20.04
|
||||||
|
export WSL_LINUX_PCSX2=/mnt/c/Program\\\ Files\\\ \\\(x86\\\)/PCSX2
|
||||||
|
```
|
||||||
|
- Refresh env variables via -> `. ~/.bashrc`
|
||||||
|
- Close wsl terminal
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Mapping WSL directories to your Windows machine
|
||||||
|
- Open cmd and type `wsl.exe --list`
|
||||||
|
`Info: Remember your distribution name from this list. My is "Ubuntu-20.04"`
|
||||||
|
- Click at the windows logo on your keyboard, type "This PC" and open
|
||||||
|
- At the upper menu click "Map disk drive"
|
||||||
|
`Info: Replace my name with your WSL name!`
|
||||||
|
- Folder: \\\\wsl$\\Ubuntu-20.04
|
||||||
|
- Click OK
|
||||||
|
|
||||||
|
`Info: You will have now new disk on your PC, this is the WSL filesystem.`
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Configuring VSCode
|
||||||
|
- Open VSCode
|
||||||
|
- Install extension "Remote - WSL"
|
||||||
|
- Install extension "C/C++"
|
||||||
|
- Restart VSCode if required
|
||||||
|
- VSCode: Click on "File" -> "Open folder in WSL"
|
||||||
|
- Open "repos/tyra"
|
||||||
|
- VSCode: Click on "Terminal" -> "New terminal"
|
||||||
|
|
||||||
|
`Info: New terminal should appear. This is the same WSL terminal :)`
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## PS2DEV installation
|
||||||
|
- In VSCode's WSL terminal type:
|
||||||
|
```
|
||||||
|
cd /ps2dev/source
|
||||||
|
./build-all.sh
|
||||||
|
```
|
||||||
|
`Info: This can take some time...`
|
||||||
|
- And open again .bashrc via `nano ~/.bashrc` and add these lines at the end of file.
|
||||||
|
```
|
||||||
|
export ZLIB=${PS2SDK}/ports
|
||||||
|
export LIBTIFF=${PS2SDK}/ports
|
||||||
|
export LIBJPEG=${PS2SDK}/ports
|
||||||
|
export LIBPNG=${PS2SDK}/ports
|
||||||
|
```
|
||||||
|
- Refresh env variables via `. ~/.bashrc`
|
||||||
|
|
||||||
|
### !!! Please don't forgot to remove/refresh these 4 exports when you will want to update PS2DEV (./build-all.sh), because there is circular dependency between these libs and gsKit which is included in PS2DEV !!!
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Build Tyra
|
||||||
|
- Go to one of the samples via `cd /repos/tyra/src/samples/floors`
|
||||||
|
- Build debug version: `make rebuild-dbg-engine`
|
||||||
|
`Info: If you want to build final version in future, type make rebuild-engine `
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Install & configure PCSX2
|
||||||
|
- Download & install PCSX2 from (1.6+ version)
|
||||||
|
https://pcsx2.net/
|
||||||
|
- Extract bios files from
|
||||||
|
https://romsmania.cc/bios/pcsx2-playstation-2-bios-3
|
||||||
|
to
|
||||||
|
`C:\Users%USERNAME%\Documents\PCSX2\bios`
|
||||||
|
- Close `PCSX2` if you have opened!
|
||||||
|
- Open `C:\Users\hasto\Documents\PCSX2\inis\PCSX2_vm.ini` in notepad
|
||||||
|
```
|
||||||
|
HostFs=enabled
|
||||||
|
```
|
||||||
|
- Open PCSX2 and map pad to your keyboard, for example:
|
||||||
|
```
|
||||||
|
WASD = Left joy
|
||||||
|
Arrows = Right joy
|
||||||
|
Space = X
|
||||||
|
Circle = C
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Run one of the samples
|
||||||
|
|
||||||
|
- Add assets for "floors" sample
|
||||||
|
- Download assets from
|
||||||
|
https://github.com/h4570/tyra/tree/master/src/samples/floors
|
||||||
|
- Windows: Open your WSL folder (This PC -> WSL folder)
|
||||||
|
- Extract assets to /repos/tyra/src/samples/floors/bin/ (create bin folder if not exists)
|
||||||
|
- Compile sample via `make`
|
||||||
|
`Info: Elf file should be produced in /bin`
|
||||||
|
- Run sample in PSX2 via `make run-pcsx2`
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## How to code?
|
||||||
|
Do some changes in your sample and just type `make clean all run-pcsx2` in your sample folder.
|
||||||
|
You can create your own sample, by just copying cube folder.
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Setup Intelisense
|
||||||
|
|
||||||
|
- Download
|
||||||
|
http://apgcglz.cluster028.hosting.ovh.net/tyra/intellisense.zip
|
||||||
|
- Unpack `.vscode` folder to WSL's `/repos/tyra/`
|
||||||
|
`Info: This configuration is set for cube sample, but you can change it in tasks.json file`
|
||||||
|
|
||||||
|
---
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
## Advanced: Compiling VU1 programs
|
||||||
|
`Info: Based on https://github.com/microsoft/wsl/issues/2468#issuecomment-374904520`
|
||||||
|
- Download VCL
|
||||||
|
http://lukasz.dk/files/vcl.1.4.beta7.x86.tgz
|
||||||
|
- Rename `vcl_14beta7_x86` binary to `vcl`
|
||||||
|
- Put `vcl` to WSL's `/usr/bin`
|
||||||
|
```
|
||||||
|
apt-get install qemu qemu-user-static binfmt-support
|
||||||
|
update-binfmts --install i386 /usr/bin/qemu-i386-static --magic '\x7fELF\x01\x01\x01\x03\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x03\x00\x01\x00\x00\x00' --mask '\xff\xff\xff\xff\xff\xff\xff\xfc\xff\xff\xff\xff\xff\xff\xff\xff\xf8\xff\xff\xff\xff\xff\xff\xff'
|
||||||
|
dpkg --add-architecture i386
|
||||||
|
apt-get update
|
||||||
|
apt-get install libstdc++5:i386
|
||||||
|
chmod 755 /usr/bin/vcl
|
||||||
|
```
|
||||||
|
`Info: In Ubuntu 18.04 I was obligated to install lib32ncurses5 also`
|
||||||
|
- Add this line to `~/.bashrc`
|
||||||
|
```
|
||||||
|
service binfmt-support start &>/dev/null
|
||||||
|
```
|
||||||
|
- Uncomment `.vsm`/`.vcl` recipe from Tyra's engine `Makefile`
|
||||||
|
- Download & install VCL preprocessor
|
||||||
|
```
|
||||||
|
mkdir temp && cd temp
|
||||||
|
git clone https://github.com/glampert/vclpp .
|
||||||
|
make
|
||||||
|
cp vclpp /usr/bin/
|
||||||
|
chmod 755 /usr/bin/vclpp
|
||||||
|
cd .. && rm -rf ./temp
|
||||||
|
```
|
||||||
|
- Uncomment `.vclpp`/`.vcl` recipe from Tyra's engine `Makefile`
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
EE_LIBS := $(EE_LIBS) -ldraw -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz
|
EE_LIBS := $(EE_LIBS) -ldraw -lcdvd -lgraph -lmath3d -lpacket -ldma -lpacket2 -lpad -laudsrv -lc -lstdc++ -lpng -lz
|
||||||
EE_INCS := -I$(TYRA_DIR)/include -I$(PS2SDK)/ports/include $(EE_INCS)
|
EE_INCS := -I$(TYRA)/src/engine/include -I$(PS2SDK)/ports/include $(EE_INCS)
|
||||||
EE_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(TYRA_DIR) $(EE_LDFLAGS)
|
EE_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(TYRA)/src/engine $(EE_LDFLAGS)
|
||||||
EE_CFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CFLAGS)
|
EE_CXXFLAGS := -DHAVE_LIBJPEG -DHAVE_LIBTIFF -DHAVE_LIBPNG -DHAVE_ZLIB -D_XCDVD $(EE_CXXFLAGS)
|
||||||
EE_CXXFLAGS := -DHAVE_LIBPNG -DHAVE_ZLIB $(EE_CXXFLAGS)
|
|
||||||
EE_DVP = dvp-as
|
EE_DVP = dvp-as
|
||||||
EE_VCL = vcl
|
EE_VCL = vcl
|
||||||
EE_VCLPP = vclpp
|
EE_VCLPP = vclpp
|
||||||
|
|||||||
@@ -52,17 +52,13 @@ void Engine::setDefaultScreen()
|
|||||||
|
|
||||||
void Engine::init(Game *t_game, u32 t_gifPacketSize)
|
void Engine::init(Game *t_game, u32 t_gifPacketSize)
|
||||||
{
|
{
|
||||||
if (isInitialized)
|
assertMsg(!isInitialized, "Engine was already initialized!");
|
||||||
PRINT_ERR("Already initialized!");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
game = t_game;
|
game = t_game;
|
||||||
renderer = new Renderer(t_gifPacketSize, &screen);
|
renderer = new Renderer(t_gifPacketSize, &screen);
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
game->onInit();
|
game->onInit();
|
||||||
gameLoop();
|
gameLoop();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** Do not call this method. This is used in gameLoop() to maintain multithreading */
|
/** Do not call this method. This is used in gameLoop() to maintain multithreading */
|
||||||
void Engine::wakeup(s32 t_alarmId, u16 t_time, void *t_common)
|
void Engine::wakeup(s32 t_alarmId, u16 t_time, void *t_common)
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
#include "./texture.hpp"
|
#include "./texture.hpp"
|
||||||
#include "./mesh_frame.hpp"
|
#include "./mesh_frame.hpp"
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <draw_types.h>
|
|
||||||
#include <draw_buffers.h>
|
#include <draw_buffers.h>
|
||||||
#include <draw_sampling.h>
|
#include <draw_sampling.h>
|
||||||
#include "./anim_state.hpp"
|
#include "./anim_state.hpp"
|
||||||
@@ -43,7 +42,6 @@ public:
|
|||||||
* When true, mesh materials are not drawn when they are outside of view frustum.
|
* When true, mesh materials are not drawn when they are outside of view frustum.
|
||||||
*/
|
*/
|
||||||
u8 shouldBeFrustumCulled;
|
u8 shouldBeFrustumCulled;
|
||||||
color_t color;
|
|
||||||
clutbuffer_t clut;
|
clutbuffer_t clut;
|
||||||
lod_t lod;
|
lod_t lod;
|
||||||
|
|
||||||
@@ -176,6 +174,8 @@ public:
|
|||||||
|
|
||||||
void setAnimSpeed(const float &t_value) { animState.speed = t_value; }
|
void setAnimSpeed(const float &t_value) { animState.speed = t_value; }
|
||||||
|
|
||||||
|
const u8 &areFramesAllocated() const { return _areFramesAllocated; };
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if this class loaded mesh data first.
|
* Check if this class loaded mesh data first.
|
||||||
* Meshes which use loadFrom() method have false there.
|
* Meshes which use loadFrom() method have false there.
|
||||||
@@ -207,9 +207,8 @@ private:
|
|||||||
AnimState animState;
|
AnimState animState;
|
||||||
MeshFrame *frames;
|
MeshFrame *frames;
|
||||||
u32 id, framesCount;
|
u32 id, framesCount;
|
||||||
u8 _isMother;
|
u8 _isMother, _areFramesAllocated;
|
||||||
Vector3 calc3Vectors[3];
|
Vector3 calc3Vectors[3];
|
||||||
void setDefaultColor();
|
|
||||||
void setDefaultLODAndClut();
|
void setDefaultLODAndClut();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,12 @@ public:
|
|||||||
// Getters
|
// Getters
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto generated unique Id.
|
||||||
|
* Core role of this variable is to select correct texture to draw
|
||||||
|
*/
|
||||||
|
const u32 &getId() const { return id; };
|
||||||
|
|
||||||
const u32 &getVertexCount() const { return vertexCount; };
|
const u32 &getVertexCount() const { return vertexCount; };
|
||||||
const u32 &getSTsCount() const { return stsCount; };
|
const u32 &getSTsCount() const { return stsCount; };
|
||||||
const u32 &getNormalsCount() const { return normalsCount; };
|
const u32 &getNormalsCount() const { return normalsCount; };
|
||||||
@@ -119,12 +125,27 @@ public:
|
|||||||
// Other
|
// Other
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this object is mother.
|
||||||
|
* Mother = object loaded with loadObj(), loadDff()..
|
||||||
|
* Have all mother data: vertex, st, etc..
|
||||||
|
* Non-mother = object loaded with loadFrom().
|
||||||
|
* Have reference copy to mother data: vertex, st, etc..
|
||||||
|
*
|
||||||
|
* When you will destruct mother object, all vertex, st data will be deleted.
|
||||||
|
* When you will destruct non-mother object, all vertex, st data will be NOT deleted.
|
||||||
|
*/
|
||||||
|
const u8 &isMother() const { return _isMother; };
|
||||||
|
|
||||||
const u8 &areSTsAllocated() const { return _areSTsAllocated; };
|
const u8 &areSTsAllocated() const { return _areSTsAllocated; };
|
||||||
const u8 &areVerticesAllocated() const { return _areVerticesAllocated; };
|
const u8 &areVerticesAllocated() const { return _areVerticesAllocated; };
|
||||||
const u8 &areNormalsAllocated() const { return _areNormalsAllocated; };
|
const u8 &areNormalsAllocated() const { return _areNormalsAllocated; };
|
||||||
const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; };
|
const u8 &areMaterialsAllocated() const { return _areMaterialsAllocated; };
|
||||||
const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; };
|
const u8 &isBoundingBoxCalculated() const { return _isBoundingBoxCalculated; };
|
||||||
|
|
||||||
|
/** Create reference copy (non-mother) */
|
||||||
|
void copyFrom(MeshFrame *t_refCopy);
|
||||||
|
|
||||||
/** Set STs count and allocate memory. */
|
/** Set STs count and allocate memory. */
|
||||||
void allocateSTs(const u32 &t_val);
|
void allocateSTs(const u32 &t_val);
|
||||||
|
|
||||||
@@ -146,12 +167,13 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
BoundingBox *boundingBoxObj;
|
BoundingBox *boundingBoxObj;
|
||||||
u8 _areSTsAllocated,
|
u8 _isMother,
|
||||||
|
_areSTsAllocated,
|
||||||
_areVerticesAllocated,
|
_areVerticesAllocated,
|
||||||
_areNormalsAllocated,
|
_areNormalsAllocated,
|
||||||
_areMaterialsAllocated,
|
_areMaterialsAllocated,
|
||||||
_isBoundingBoxCalculated;
|
_isBoundingBoxCalculated;
|
||||||
u32 vertexCount, stsCount, normalsCount, materialsCount;
|
u32 vertexCount, stsCount, normalsCount, materialsCount, id;
|
||||||
MeshMaterial *materials;
|
MeshMaterial *materials;
|
||||||
Point __attribute__((aligned(16))) * sts;
|
Point __attribute__((aligned(16))) * sts;
|
||||||
Vector3 __attribute__((aligned(16))) * vertices, *normals;
|
Vector3 __attribute__((aligned(16))) * vertices, *normals;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#define _TYRA_MESH_MATERIAL_
|
#define _TYRA_MESH_MATERIAL_
|
||||||
|
|
||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
|
#include <draw_types.h>
|
||||||
#include "bounding_box.hpp"
|
#include "bounding_box.hpp"
|
||||||
#include "./math/vector3.hpp"
|
#include "./math/vector3.hpp"
|
||||||
#include "./math/plane.hpp"
|
#include "./math/plane.hpp"
|
||||||
@@ -29,6 +30,8 @@ public:
|
|||||||
MeshMaterial();
|
MeshMaterial();
|
||||||
~MeshMaterial();
|
~MeshMaterial();
|
||||||
|
|
||||||
|
color_t color;
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Getters
|
// Getters
|
||||||
// ----
|
// ----
|
||||||
@@ -104,11 +107,43 @@ public:
|
|||||||
/** Set material name. */
|
/** Set material name. */
|
||||||
void setName(char *t_val);
|
void setName(char *t_val);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not call this method unless you know what you do.
|
||||||
|
* Should be called by data loader.
|
||||||
|
*/
|
||||||
|
void setSTsPresent(const u8 &b) { _areSTsPresent = b; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Do not call this method unless you know what you do.
|
||||||
|
* Should be called by data loader.
|
||||||
|
*/
|
||||||
|
void setNormalsPresent(const u8 &b) { _areNormalsPresent = b; };
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Other
|
// Other
|
||||||
// ----
|
// ----
|
||||||
|
|
||||||
|
const u8 &areSTsPresent() const { return _areSTsPresent; };
|
||||||
|
|
||||||
|
const u8 &areNormalsPresent() const { return _areNormalsPresent; };
|
||||||
|
|
||||||
|
/** Create reference copy (non-mother) */
|
||||||
|
void copyFrom(MeshMaterial *t_refCopy);
|
||||||
|
|
||||||
const u8 &isNameSet() const { return _isNameSet; };
|
const u8 &isNameSet() const { return _isNameSet; };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this object is mother.
|
||||||
|
* Mother = object loaded with loadObj(), loadDff()..
|
||||||
|
* Have all mother data: vertex faces, st faces, etc..
|
||||||
|
* Non-mother = object loaded with loadFrom().
|
||||||
|
* Have reference copy to mother data: vertex faces, st faces, etc..
|
||||||
|
*
|
||||||
|
* When you will destruct mother object, all faces data will be deleted.
|
||||||
|
* When you will destruct non-mother object, all faces data will be NOT deleted.
|
||||||
|
*/
|
||||||
|
const u8 &isMother() const { return _isMother; };
|
||||||
|
|
||||||
const u8 &areFacesAllocated() const { return _areFacesAllocated; };
|
const u8 &areFacesAllocated() const { return _areFacesAllocated; };
|
||||||
|
|
||||||
/** Set faces count and allocate memory. */
|
/** Set faces count and allocate memory. */
|
||||||
@@ -125,10 +160,16 @@ public:
|
|||||||
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
|
u8 isInFrustum(Plane *t_frustumPlanes, const Vector3 &position);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void setDefaultColor();
|
||||||
BoundingBox *boundingBoxObj;
|
BoundingBox *boundingBoxObj;
|
||||||
u32 facesCount, id;
|
u32 facesCount, id;
|
||||||
u32 *vertexFaces, *stFaces, *normalFaces;
|
u32 *vertexFaces, *stFaces, *normalFaces;
|
||||||
u8 _isNameSet, _areFacesAllocated, _isBoundingBoxCalculated;
|
u8 _isMother,
|
||||||
|
_isNameSet,
|
||||||
|
_areFacesAllocated,
|
||||||
|
_isBoundingBoxCalculated,
|
||||||
|
_areSTsPresent,
|
||||||
|
_areNormalsPresent;
|
||||||
char *name;
|
char *name;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -83,21 +83,18 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns index of link.
|
* Returns index of link.
|
||||||
* -1 if not found.
|
* -1 if not found.
|
||||||
|
* @param t_id
|
||||||
|
* For 3D: Mesh material id.
|
||||||
|
* For 2D: Sprite id.
|
||||||
*/
|
*/
|
||||||
const s32 getIndexOfLink(const u32 &t_meshId, const u32 &t_materialId) const
|
const s32 getIndexOfLink(const u32 &t_id) const
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < texLinks.size(); i++)
|
for (u32 i = 0; i < texLinks.size(); i++)
|
||||||
if (texLinks[i].materialId == t_materialId && texLinks[i].meshOrSpriteId == t_meshId)
|
if (texLinks[i].id == t_id)
|
||||||
return i;
|
return i;
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns index of link.
|
|
||||||
* -1 if not found.
|
|
||||||
*/
|
|
||||||
inline const s32 getIndexOfLink(const u32 &t_spriteId) const { return getIndexOfLink(t_spriteId, 0); };
|
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Setters
|
// Setters
|
||||||
// ----
|
// ----
|
||||||
@@ -144,18 +141,15 @@ public:
|
|||||||
|
|
||||||
const u8 &isSizeSet() const { return _isSizeSet; };
|
const u8 &isSizeSet() const { return _isSizeSet; };
|
||||||
|
|
||||||
const u8 isLinkedWith(const u32 &t_meshId, const u32 &t_materialId) const
|
/**
|
||||||
|
* Check if texture is linked with Mesh/Sprite.
|
||||||
|
* @param t_id
|
||||||
|
* For 3D: Mesh material id.
|
||||||
|
* For 2D: Sprite id.
|
||||||
|
*/
|
||||||
|
const u8 isLinkedWith(const u32 &t_id) const
|
||||||
{
|
{
|
||||||
s32 index = getIndexOfLink(t_meshId, t_materialId);
|
s32 index = getIndexOfLink(t_id);
|
||||||
if (index != -1)
|
|
||||||
return true;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
};
|
|
||||||
|
|
||||||
const u8 isLinkedWith(const u32 &t_spriteId) const
|
|
||||||
{
|
|
||||||
s32 index = getIndexOfLink(t_spriteId);
|
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
@@ -164,22 +158,17 @@ public:
|
|||||||
|
|
||||||
void removeLinkByIndex(const u32 &t_index) { texLinks.erase(texLinks.begin() + t_index); }
|
void removeLinkByIndex(const u32 &t_index) { texLinks.erase(texLinks.begin() + t_index); }
|
||||||
|
|
||||||
void removeLinkBySprite(const u32 &t_spriteId)
|
/**
|
||||||
|
* Remove texture link with given Mesh/Sprite.
|
||||||
|
* @param t_id
|
||||||
|
* For 3D: Mesh material id.
|
||||||
|
* For 2D: Sprite id.
|
||||||
|
*/
|
||||||
|
void removeLinkById(const u32 &t_id)
|
||||||
{
|
{
|
||||||
s32 index = getIndexOfLink(t_spriteId);
|
s32 index = getIndexOfLink(t_id);
|
||||||
if (index != -1)
|
assertMsg(index != -1, "Cant remove link, because it was not found!");
|
||||||
removeLinkByIndex(index);
|
removeLinkByIndex(index);
|
||||||
else
|
|
||||||
PRINT_ERR("Cant remove link, because it was not found!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void removeLinkByMesh(const u32 &t_meshId, const u32 &t_materialId)
|
|
||||||
{
|
|
||||||
s32 index = getIndexOfLink(t_meshId, t_materialId);
|
|
||||||
if (index != -1)
|
|
||||||
removeLinkByIndex(index);
|
|
||||||
else
|
|
||||||
PRINT_ERR("Cant remove link, because it was not found!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -15,10 +15,11 @@
|
|||||||
|
|
||||||
struct TextureLink
|
struct TextureLink
|
||||||
{
|
{
|
||||||
/** Mesh id or sprite id */
|
/**
|
||||||
u32 meshOrSpriteId;
|
* For 3D: Mesh material id.
|
||||||
/** Mesh material id or 0 if is sprite */
|
* For 2D: Sprite id.
|
||||||
u32 materialId;
|
*/
|
||||||
|
u32 id;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -126,6 +126,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
u8 songLoaded, volume, realVolume, songPlaying, songInLoop, songFinished;
|
u8 songLoaded, volume, realVolume, songPlaying, songInLoop, songFinished;
|
||||||
|
u8 hack; // TODO
|
||||||
std::vector<AudioListenerRef *> songListeners;
|
std::vector<AudioListenerRef *> songListeners;
|
||||||
FILE *wav;
|
FILE *wav;
|
||||||
audsrv_fmt_t format;
|
audsrv_fmt_t format;
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public:
|
|||||||
~GifSender();
|
~GifSender();
|
||||||
|
|
||||||
void initPacket(u8 context);
|
void initPacket(u8 context);
|
||||||
void addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
|
void addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer, color_t *t_color);
|
||||||
void addClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
|
void addClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
|
||||||
void sendPacket();
|
void sendPacket();
|
||||||
void sendClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
|
void sendClear(zbuffer_t *t_zBuffer, color_t *t_rgb);
|
||||||
@@ -54,7 +54,7 @@ private:
|
|||||||
float halfScreenW, halfScreenH;
|
float halfScreenW, halfScreenH;
|
||||||
MATRIX localWorld, localScreen, localLight;
|
MATRIX localWorld, localScreen, localLight;
|
||||||
|
|
||||||
void calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount);
|
void calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount, color_t *t_color);
|
||||||
void convertCalcs(u32 t_vertCount, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_sts, color_t &t_color);
|
void convertCalcs(u32 t_vertCount, VECTOR *t_vertices, VECTOR *t_colors, VECTOR *t_sts, color_t &t_color);
|
||||||
void addCurrentCalcs(u32 &t_vertexCount);
|
void addCurrentCalcs(u32 &t_vertexCount);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,39 +64,39 @@ public:
|
|||||||
/** 2D draw. */
|
/** 2D draw. */
|
||||||
void draw(Sprite &t_sprite);
|
void draw(Sprite &t_sprite);
|
||||||
|
|
||||||
/// --- Draw: PATH3
|
/// --- OBSOLETE
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
// * WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
||||||
* Draw many meshes with lighting information.
|
// * Draw many meshes with lighting information.
|
||||||
* Slowest way of rendering (PATH 3, using EE and GIF).
|
// * Slowest way of rendering (PATH 3, using EE and GIF).
|
||||||
* NOTICE: Animation supported, lighting supported
|
// * NOTICE: Animation supported, lighting supported
|
||||||
*/
|
// */
|
||||||
void drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
// void drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
// * WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
||||||
* Draw mesh with lighting information.
|
// * Draw mesh with lighting information.
|
||||||
* Slowest way of rendering (PATH 3, using EE and GIF).
|
// * Slowest way of rendering (PATH 3, using EE and GIF).
|
||||||
* NOTICE: Animation supported, lighting supported
|
// * NOTICE: Animation supported, lighting supported
|
||||||
*/
|
// */
|
||||||
void drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
// void drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
// * WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
||||||
* Draw many meshes without lighting information.
|
// * Draw many meshes without lighting information.
|
||||||
* Slowest way of rendering (PATH 3, using EE and GIF).
|
// * Slowest way of rendering (PATH 3, using EE and GIF).
|
||||||
* NOTICE: Animation supported, lighting supported
|
// * NOTICE: Animation supported, lighting supported
|
||||||
*/
|
// */
|
||||||
void drawByPath3(Mesh *t_meshes, u16 t_amount);
|
// void drawByPath3(Mesh *t_meshes, u16 t_amount);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
// * WARNING: THIS FUNC CAUSE VISUAL ARTIFACTS!
|
||||||
* Draw mesh without lighting information.
|
// * Draw mesh without lighting information.
|
||||||
* Slowest way of rendering (PATH 3, using EE and GIF).
|
// * Slowest way of rendering (PATH 3, using EE and GIF).
|
||||||
* NOTICE: Animation supported, lighting supported
|
// * NOTICE: Animation supported, lighting supported
|
||||||
*/
|
// */
|
||||||
void drawByPath3(Mesh &t_mesh);
|
// void drawByPath3(Mesh &t_mesh);
|
||||||
|
|
||||||
/// --- Draw: PATH1
|
/// --- Draw: PATH1
|
||||||
|
|
||||||
|
|||||||
@@ -45,23 +45,14 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Returns single texture.
|
* Returns single texture.
|
||||||
* NULL if not found.
|
* NULL if not found.
|
||||||
|
* @param t_id
|
||||||
|
* For 3D: Mesh material id.
|
||||||
|
* For 2D: Sprite id.
|
||||||
*/
|
*/
|
||||||
Texture *getBySprite(const u32 &t_spriteId)
|
Texture *getBySpriteOrMesh(const u32 &t_id)
|
||||||
{
|
{
|
||||||
for (u32 i = 0; i < textures.size(); i++)
|
for (u32 i = 0; i < textures.size(); i++)
|
||||||
if (textures[i]->isLinkedWith(t_spriteId))
|
if (textures[i]->isLinkedWith(t_id))
|
||||||
return textures[i];
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns single texture.
|
|
||||||
* NULL if not found.
|
|
||||||
*/
|
|
||||||
Texture *getByMesh(const u32 &t_meshId, const u32 &t_materialId)
|
|
||||||
{
|
|
||||||
for (u32 i = 0; i < textures.size(); i++)
|
|
||||||
if (textures[i]->isLinkedWith(t_meshId, t_materialId))
|
|
||||||
return textures[i];
|
return textures[i];
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -128,10 +119,8 @@ public:
|
|||||||
const void removeById(const u32 &t_texId)
|
const void removeById(const u32 &t_texId)
|
||||||
{
|
{
|
||||||
s32 index = getIndexOf(t_texId);
|
s32 index = getIndexOf(t_texId);
|
||||||
if (index != -1)
|
assertMsg(index != -1, "Cant remove texture, because it was not found!");
|
||||||
removeByIndex(index);
|
removeByIndex(index);
|
||||||
else
|
|
||||||
PRINT_ERR("Cant remove texture, because it was not found!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public:
|
|||||||
~VifSender();
|
~VifSender();
|
||||||
|
|
||||||
// TODO refactor
|
// TODO refactor
|
||||||
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer);
|
void drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer, color_t *t_color, u8 t_rgbaOnly);
|
||||||
void calcMatrix(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation);
|
void calcMatrix(const RenderData &t_renderData, const Vector3 &t_position, const Vector3 &t_rotation);
|
||||||
void drawTheSameWithOtherMatrices(const RenderData &t_renderData, Mesh **t_meshes, const u32 &t_skip, const u32 &t_count);
|
void drawTheSameWithOtherMatrices(const RenderData &t_renderData, Mesh **t_meshes, const u32 &t_skip, const u32 &t_count);
|
||||||
void enableWait() { isDrawWaitEnabled = true; }
|
void enableWait() { isDrawWaitEnabled = true; }
|
||||||
@@ -37,11 +37,12 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
u32 lastVertCount; // needed for drawTheSameWithOtherMatrices()
|
u32 lastVertCount; // needed for drawTheSameWithOtherMatrices()
|
||||||
|
u8 isLastRGBAOnly; // needed for drawTheSameWithOtherMatrices()
|
||||||
u8 isDrawWaitEnabled;
|
u8 isDrawWaitEnabled;
|
||||||
Light *light;
|
Light *light;
|
||||||
void uploadMicroProgram();
|
void uploadMicroProgram();
|
||||||
void setDoubleBufferAddStaticData();
|
void setDoubleBufferAddStaticData();
|
||||||
void drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *t_textureBuffer, u8 t_addDrawWait);
|
void drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *t_textureBuffer, u8 t_addDrawWait, color_t *t_color, u8 t_rgbaOnly);
|
||||||
packet2_t *packets[2] __attribute__((aligned(64)));
|
packet2_t *packets[2] __attribute__((aligned(64)));
|
||||||
packet2_t *currPacket;
|
packet2_t *currPacket;
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -11,14 +11,16 @@
|
|||||||
#ifndef _TYRA_DEBUG_
|
#ifndef _TYRA_DEBUG_
|
||||||
#define _TYRA_DEBUG_
|
#define _TYRA_DEBUG_
|
||||||
|
|
||||||
#include <tamtypes.h>
|
#ifdef NDEBUG
|
||||||
#include <math3d.h>
|
#define consoleLog(message) ((void)0)
|
||||||
#include <stdio.h>
|
#define assertMsg(condition, message) ((void)0)
|
||||||
|
|
||||||
|
#else // IF Debug
|
||||||
|
#include <stdio.h>
|
||||||
class Debug
|
class Debug
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void errTrap(char *t_text, char *t_file)
|
static void trap(const char *t_text, const char *t_file)
|
||||||
{
|
{
|
||||||
printf("\n");
|
printf("\n");
|
||||||
printf("====================================\n");
|
printf("====================================\n");
|
||||||
@@ -29,8 +31,10 @@ public:
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#define consoleLog(message) printf("LOG: " message " (" __FILE__ ")\n")
|
||||||
|
#define assertMsg(condition, message) \
|
||||||
|
if (!(condition)) \
|
||||||
|
Debug::trap(message, __FILE__)
|
||||||
|
#endif // NDEBUG
|
||||||
|
|
||||||
#define PRINT_LOG(TEXT) printf("LOG: " TEXT " (" __FILE__ ")\n")
|
#endif // _TYRA_DEBUG_
|
||||||
#define PRINT_ERR(TEXT) Debug::errTrap(TEXT, __FILE__)
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@
|
|||||||
#include <tamtypes.h>
|
#include <tamtypes.h>
|
||||||
#include <math3d.h>
|
#include <math3d.h>
|
||||||
#include "../models/math/vector3.hpp"
|
#include "../models/math/vector3.hpp"
|
||||||
|
#include <fastmath.h>
|
||||||
|
|
||||||
class Vector3; // Forward definition
|
class Vector3; // Forward definition
|
||||||
|
|
||||||
@@ -24,16 +25,15 @@ class Math
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
const static float HALF_ANG2RAD = 3.14159265358979323846F / 360.0F;
|
constexpr static float HALF_ANG2RAD = 3.14159265358979323846F / 360.0F;
|
||||||
const static float ANG2RAD = 3.14159265358979323846F / 180.0F;
|
constexpr static float ANG2RAD = 3.14159265358979323846F / 180.0F;
|
||||||
const static float PI = 3.1415926535897932384626433832795F;
|
constexpr static float PI = 3.1415926535897932384626433832795F;
|
||||||
const static float HALF_PI = 1.5707963267948966192313216916398F;
|
constexpr static float HALF_PI = 1.5707963267948966192313216916398F;
|
||||||
static float cos(float x);
|
static float cos(float x);
|
||||||
static float asin(float x);
|
static float asin(float x);
|
||||||
static float mod(float x, float y);
|
static float mod(float x, float y);
|
||||||
static inline float sin(float x) { return cos(x - HALF_PI); };
|
static inline float sin(float x) { return cos(x - HALF_PI); };
|
||||||
static inline float tan(float x) { return sin(x) / cos(x); }
|
static inline float tan(float x) { return sin(x) / cos(x); }
|
||||||
static float sqrt(float x);
|
|
||||||
static float invSqrt(float x);
|
static float invSqrt(float x);
|
||||||
static inline u32 max(u32 a, u32 b) { return (a > b) ? a : b; }
|
static inline u32 max(u32 a, u32 b) { return (a > b) ? a : b; }
|
||||||
static inline s32 max(s32 a, s32 b) { return (a > b) ? a : b; }
|
static inline s32 max(s32 a, s32 b) { return (a > b) ? a : b; }
|
||||||
|
|||||||
@@ -17,12 +17,12 @@ class String
|
|||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static char *createU32ToString(u32 a);
|
static char *createU32ToString(const u32 a);
|
||||||
static char *createWithLeadingZeros(char *a);
|
static char *createWithLeadingZeros(const char *a);
|
||||||
static char *createCopy(char *source);
|
static char *createCopy(const char *source);
|
||||||
static u32 getLength(char *a);
|
static u32 getLength(const char *a);
|
||||||
static char *createConcatenated(char *a, char *b);
|
static char *createConcatenated(const char *a, const char *b);
|
||||||
static char *createWithoutExtension(char *source);
|
static char *createWithoutExtension(const char *source);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,25 +38,28 @@ void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
|
|||||||
delete[] path_part1;
|
delete[] path_part1;
|
||||||
delete[] path_part2;
|
delete[] path_part2;
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
|
assertMsg(file != NULL, "Failed to load .bmp file!");
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
PRINT_ERR("Failed to load .bmp file!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char header[54];
|
unsigned char header[54];
|
||||||
fread(header, sizeof(unsigned char), 54, file);
|
fread(header, sizeof(unsigned char), 54, file);
|
||||||
|
|
||||||
u32 width = (u32)header[18];
|
u32 width = (u32)header[18];
|
||||||
u32 height = (u32)header[22];
|
u32 height = (u32)header[22];
|
||||||
|
u32 bits = (u32)header[28];
|
||||||
|
u32 dataOffset = (u32)header[10];
|
||||||
|
|
||||||
|
assertMsg(bits == 24, "Invalid bits per pixel in .bmp file - expected 24!");
|
||||||
|
|
||||||
o_texture.setSize(width, height, TEX_TYPE_RGB);
|
o_texture.setSize(width, height, TEX_TYPE_RGB);
|
||||||
printf("BMPLoader - width: %d | height: %d\n", width, height);
|
printf("BMPLoader - width: %d | height: %d | bits: %d\n", width, height, bits);
|
||||||
|
|
||||||
u64 rowPadded = (width * 3 + 3) & (~3);
|
u64 rowPadded = (width * 3 + 3) & (~3);
|
||||||
|
|
||||||
unsigned char row[rowPadded];
|
unsigned char row[rowPadded];
|
||||||
|
|
||||||
|
//Offset file stream to raster data
|
||||||
|
fseek(file, dataOffset, SEEK_SET);
|
||||||
|
|
||||||
u32 x = 0;
|
u32 x = 0;
|
||||||
for (u32 i = 0; i < height; i++)
|
for (u32 i = 0; i < height; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -36,11 +36,10 @@ DffLoader::~DffLoader() {}
|
|||||||
|
|
||||||
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Loading dff file");
|
consoleLog("Loading dff file");
|
||||||
char *path = String::createConcatenated("host:", t_filename);
|
char *path = String::createConcatenated("host:", t_filename);
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
if (file == NULL)
|
assertMsg(file != NULL, "Failed to load .dff file!");
|
||||||
PRINT_ERR("Failed to load .dff file!");
|
|
||||||
fseek(file, 0L, SEEK_END);
|
fseek(file, 0L, SEEK_END);
|
||||||
long fileSize = ftell(file);
|
long fileSize = ftell(file);
|
||||||
u8 data[fileSize];
|
u8 data[fileSize];
|
||||||
@@ -50,7 +49,7 @@ void DffLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
serialize(o_result, t_invertT, data, t_scale);
|
serialize(o_result, t_invertT, data, t_scale);
|
||||||
o_result->calculateBoundingBoxes();
|
o_result->calculateBoundingBoxes();
|
||||||
delete[] path;
|
delete[] path;
|
||||||
PRINT_LOG("Dff file loaded!");
|
consoleLog("Dff file loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// void DffLoader::im_not_used_anywhere(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
// void DffLoader::im_not_used_anywhere(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_invertT)
|
||||||
@@ -244,6 +243,8 @@ void DffLoader::readGeometryExtension(MeshFrame *o_frame, char **materialNames,
|
|||||||
{
|
{
|
||||||
u32 facesCount = readDwordFromArrayLE(t_buffer, t_ptrPos);
|
u32 facesCount = readDwordFromArrayLE(t_buffer, t_ptrPos);
|
||||||
u32 materialIndex = readDwordFromArrayLE(t_buffer, t_ptrPos);
|
u32 materialIndex = readDwordFromArrayLE(t_buffer, t_ptrPos);
|
||||||
|
o_frame->getMaterial(i).setSTsPresent(true);
|
||||||
|
o_frame->getMaterial(i).setNormalsPresent(true);
|
||||||
o_frame->getMaterial(i).allocateFaces(facesCount);
|
o_frame->getMaterial(i).allocateFaces(facesCount);
|
||||||
o_frame->getMaterial(i).setName(materialNames[materialIndex]);
|
o_frame->getMaterial(i).setName(materialNames[materialIndex]);
|
||||||
for (u32 j = 0; j < facesCount; j++)
|
for (u32 j = 0; j < facesCount; j++)
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ int MEM_fread(char *buf, size_t size, size_t n, const FILE *f)
|
|||||||
*/
|
*/
|
||||||
MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWithoutExtension, float t_scale, u8 t_invertT)
|
MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWithoutExtension, float t_scale, u8 t_invertT)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Loading new MD2 file");
|
consoleLog("Loading new MD2 file");
|
||||||
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
|
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
|
||||||
char *part2 = String::createConcatenated("host:", part1);
|
char *part2 = String::createConcatenated("host:", part1);
|
||||||
char *finalPath = String::createConcatenated(part2, ".md2"); // "folder/object.md2"
|
char *finalPath = String::createConcatenated(part2, ".md2"); // "folder/object.md2"
|
||||||
@@ -53,20 +53,11 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
|
|||||||
md2_t header;
|
md2_t header;
|
||||||
|
|
||||||
FILE *file = fopen(finalPath, "rb");
|
FILE *file = fopen(finalPath, "rb");
|
||||||
|
assertMsg(file != NULL, "Failed to load .md2 file!");
|
||||||
if (file == NULL)
|
|
||||||
{
|
|
||||||
PRINT_ERR("Failed to load .md2 file!");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
fread((char *)&header, sizeof(md2_t), 1, file);
|
fread((char *)&header, sizeof(md2_t), 1, file);
|
||||||
|
|
||||||
if ((header.ident != MD2_IDENT) && (header.version != MD2_VERSION))
|
assertMsg((header.ident == MD2_IDENT) && (header.version == MD2_VERSION), "This MD2 file was not in correct format!");
|
||||||
{
|
|
||||||
PRINT_ERR("This MD2 file was not in correct format!");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
u32 framesCount = header.num_frames;
|
u32 framesCount = header.num_frames;
|
||||||
u32 vertexCount = header.num_xyz;
|
u32 vertexCount = header.num_xyz;
|
||||||
@@ -138,6 +129,8 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
|
|||||||
{
|
{
|
||||||
for (u32 x = 0; x < framesCount; x++)
|
for (u32 x = 0; x < framesCount; x++)
|
||||||
{
|
{
|
||||||
|
resultFrames[x].getMaterial(0).setSTsPresent(true);
|
||||||
|
resultFrames[x].getMaterial(0).setNormalsPresent(true);
|
||||||
resultFrames[x].getMaterial(0).setVertexFace((i * 3) + j, triangle->index_xyz[j]);
|
resultFrames[x].getMaterial(0).setVertexFace((i * 3) + j, triangle->index_xyz[j]);
|
||||||
resultFrames[x].getMaterial(0).setSTFace((i * 3) + j, triangle->index_st[j]);
|
resultFrames[x].getMaterial(0).setSTFace((i * 3) + j, triangle->index_st[j]);
|
||||||
resultFrames[x].getMaterial(0).setNormalFace((i * 3) + j, triangle->index_xyz[j]);
|
resultFrames[x].getMaterial(0).setNormalFace((i * 3) + j, triangle->index_xyz[j]);
|
||||||
@@ -145,7 +138,7 @@ MeshFrame *MD2Loader::load(u32 &o_framesCount, char *t_subpath, char *t_nameWith
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINT_LOG("MD2 file loaded!");
|
consoleLog("MD2 file loaded!");
|
||||||
delete[] finalPath;
|
delete[] finalPath;
|
||||||
o_framesCount = framesCount;
|
o_framesCount = framesCount;
|
||||||
for (u32 i = 0; i < framesCount; i++)
|
for (u32 i = 0; i < framesCount; i++)
|
||||||
|
|||||||
@@ -30,12 +30,13 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
{
|
{
|
||||||
char *path = String::createConcatenated("host:", t_filename);
|
char *path = String::createConcatenated("host:", t_filename);
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
if (file == NULL)
|
assertMsg(file != NULL, "Failed to load .obj file!");
|
||||||
PRINT_ERR("Failed to load .obj file!");
|
|
||||||
allocateObjMemory(file, o_result);
|
allocateObjMemory(file, o_result);
|
||||||
fseek(file, 0, SEEK_SET);
|
fseek(file, 0, SEEK_SET);
|
||||||
u32 verticesI = 0, cordsI = 0, normalsI = 0, faceI = 0, vertexIndex[3], coordIndex[3], normalIndex[3];
|
u32 verticesI = 0, cordsI = 0, normalsI = 0, faceI = 0, vertexIndex[3], coordIndex[3], normalIndex[3];
|
||||||
s16 materialsI = -1;
|
s16 materialsI = -1;
|
||||||
|
Vector3 vector = Vector3();
|
||||||
|
Point point = Point();
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
char lineHeader[128]; // read the first word of the line
|
char lineHeader[128]; // read the first word of the line
|
||||||
@@ -44,13 +45,11 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
{
|
{
|
||||||
if (strcmp(lineHeader, "v") == 0)
|
if (strcmp(lineHeader, "v") == 0)
|
||||||
{
|
{
|
||||||
Vector3 vector = Vector3();
|
|
||||||
fscanf(file, "%f %f %f\n", &vector.x, &vector.y, &vector.z);
|
fscanf(file, "%f %f %f\n", &vector.x, &vector.y, &vector.z);
|
||||||
o_result->setVertex(verticesI++, vector * t_scale);
|
o_result->setVertex(verticesI++, vector * t_scale);
|
||||||
}
|
}
|
||||||
else if (strcmp(lineHeader, "vt") == 0)
|
else if (strcmp(lineHeader, "vt") == 0)
|
||||||
{
|
{
|
||||||
Point point = Point();
|
|
||||||
fscanf(file, "%f %f\n", &point.x, &point.y);
|
fscanf(file, "%f %f\n", &point.x, &point.y);
|
||||||
if (t_invertT)
|
if (t_invertT)
|
||||||
point.y = 1.0F - point.y;
|
point.y = 1.0F - point.y;
|
||||||
@@ -58,7 +57,6 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
}
|
}
|
||||||
else if (strcmp(lineHeader, "vn") == 0)
|
else if (strcmp(lineHeader, "vn") == 0)
|
||||||
{
|
{
|
||||||
Vector3 vector = Vector3();
|
|
||||||
fscanf(file, "%f %f %f\n", &vector.x, &vector.y, &vector.z);
|
fscanf(file, "%f %f %f\n", &vector.x, &vector.y, &vector.z);
|
||||||
o_result->setNormal(normalsI++, vector);
|
o_result->setNormal(normalsI++, vector);
|
||||||
}
|
}
|
||||||
@@ -71,32 +69,112 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
|
|||||||
}
|
}
|
||||||
else if (strcmp(lineHeader, "f") == 0)
|
else if (strcmp(lineHeader, "f") == 0)
|
||||||
{
|
{
|
||||||
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n",
|
int *x = &res; // random assignment, to disable compilation warning
|
||||||
|
fpos_t start;
|
||||||
|
fgetpos(file, &start);
|
||||||
|
int matches = fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n", x, x, x, x, x, x, x, x, x);
|
||||||
|
fsetpos(file, &start);
|
||||||
|
int newerMatches = 0;
|
||||||
|
switch (matches)
|
||||||
|
{
|
||||||
|
/** Vs, VTs and VNs all set */
|
||||||
|
case 9:
|
||||||
|
{
|
||||||
|
fscanf(file, "%d/%d/%d %d/%d/%d %d/%d/%d\n",
|
||||||
&vertexIndex[0], &coordIndex[0], &normalIndex[0],
|
&vertexIndex[0], &coordIndex[0], &normalIndex[0],
|
||||||
&vertexIndex[1], &coordIndex[1], &normalIndex[1],
|
&vertexIndex[1], &coordIndex[1], &normalIndex[1],
|
||||||
&vertexIndex[2], &coordIndex[2], &normalIndex[2]);
|
&vertexIndex[2], &coordIndex[2], &normalIndex[2]);
|
||||||
if (matches != 9)
|
}
|
||||||
PRINT_ERR(".obj can't be read by this simple parser. Try exporting with other options");
|
break;
|
||||||
|
/** Loaded only two digits (V, VT) succesfuly. Not setting VN. */
|
||||||
|
case 3:
|
||||||
|
{
|
||||||
|
fscanf(file, "%d/%d/ %d/%d/ %d/%d/\n",
|
||||||
|
&vertexIndex[0], &coordIndex[0],
|
||||||
|
&vertexIndex[1], &coordIndex[1],
|
||||||
|
&vertexIndex[2], &coordIndex[2]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
/** Only V set. Checking for existance of VT or VN. */
|
||||||
|
case 1:
|
||||||
|
{
|
||||||
|
/** Check for existance of V/// configuration.. */
|
||||||
|
newerMatches = fscanf(file, "%d// %d// %d//\n", x, x, x);
|
||||||
|
fsetpos(file, &start);
|
||||||
|
if (newerMatches == 3)
|
||||||
|
{
|
||||||
|
/** Configuration confirmed. */
|
||||||
|
fscanf(file, "%d// %d// %d//\n", &vertexIndex[0], &vertexIndex[1], &vertexIndex[2]);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
/** Failed, checking configuration V//VN */
|
||||||
|
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", x, x, x, x, x, x);
|
||||||
|
fsetpos(file, &start);
|
||||||
|
assertMsg(newerMatches == 6, "Unknown .obj face for .obj file!");
|
||||||
|
/** Configuration confirmed. */
|
||||||
|
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d",
|
||||||
|
&vertexIndex[0], &normalIndex[0],
|
||||||
|
&vertexIndex[1], &normalIndex[1],
|
||||||
|
&vertexIndex[2], &normalIndex[2]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
assertMsg(true == false, "Unknown faces format in .obj file!");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches == 9 || matches == 2 || matches == 1)
|
||||||
{
|
{
|
||||||
o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1);
|
o_result->getMaterial(materialsI).setVertexFace(faceI, vertexIndex[0] - 1);
|
||||||
o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1);
|
o_result->getMaterial(materialsI).setVertexFace(faceI + 1, vertexIndex[1] - 1);
|
||||||
o_result->getMaterial(materialsI).setVertexFace(faceI + 2, vertexIndex[2] - 1);
|
o_result->getMaterial(materialsI).setVertexFace(faceI + 2, vertexIndex[2] - 1);
|
||||||
|
}
|
||||||
|
if (matches == 9 || matches == 2)
|
||||||
|
{
|
||||||
o_result->getMaterial(materialsI).setSTFace(faceI, coordIndex[0] - 1);
|
o_result->getMaterial(materialsI).setSTFace(faceI, coordIndex[0] - 1);
|
||||||
o_result->getMaterial(materialsI).setSTFace(faceI + 1, coordIndex[1] - 1);
|
o_result->getMaterial(materialsI).setSTFace(faceI + 1, coordIndex[1] - 1);
|
||||||
o_result->getMaterial(materialsI).setSTFace(faceI + 2, coordIndex[2] - 1);
|
o_result->getMaterial(materialsI).setSTFace(faceI + 2, coordIndex[2] - 1);
|
||||||
|
o_result->getMaterial(materialsI).setSTsPresent(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (matches == 9)
|
||||||
|
{
|
||||||
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
|
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
|
||||||
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
|
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
|
||||||
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
|
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
|
||||||
|
o_result->getMaterial(materialsI).setNormalsPresent(true);
|
||||||
faceI += 3;
|
faceI += 3;
|
||||||
}
|
}
|
||||||
|
else if (matches == 2)
|
||||||
|
{
|
||||||
|
faceI += 2;
|
||||||
|
}
|
||||||
|
else if (matches == 1)
|
||||||
|
{
|
||||||
|
if (newerMatches == 3)
|
||||||
|
{
|
||||||
|
faceI += 1;
|
||||||
|
}
|
||||||
|
else if (newerMatches == 6)
|
||||||
|
{
|
||||||
|
o_result->getMaterial(materialsI).setNormalFace(faceI, normalIndex[0] - 1);
|
||||||
|
o_result->getMaterial(materialsI).setNormalFace(faceI + 1, normalIndex[1] - 1);
|
||||||
|
o_result->getMaterial(materialsI).setNormalFace(faceI + 2, normalIndex[2] - 1);
|
||||||
|
o_result->getMaterial(materialsI).setNormalsPresent(true);
|
||||||
|
faceI += 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
o_result->calculateBoundingBoxes();
|
o_result->calculateBoundingBoxes();
|
||||||
fclose(file);
|
fclose(file);
|
||||||
delete[] path;
|
delete[] path;
|
||||||
|
|||||||
@@ -40,9 +40,7 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
|
|||||||
delete[] path_part2;
|
delete[] path_part2;
|
||||||
|
|
||||||
FILE *file = fopen(path, "rb");
|
FILE *file = fopen(path, "rb");
|
||||||
|
assertMsg(file != NULL, "Failed to open .png file!");
|
||||||
if (file == NULL)
|
|
||||||
PRINT_ERR("Failed to open .png file!");
|
|
||||||
|
|
||||||
png_structp png_ptr;
|
png_structp png_ptr;
|
||||||
png_infop info_ptr;
|
png_infop info_ptr;
|
||||||
@@ -51,27 +49,16 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
|
|||||||
u32 sig_read = 0, row = 0, i = 0, j = 0;
|
u32 sig_read = 0, row = 0, i = 0, j = 0;
|
||||||
int bit_depth, color_type, interlace_type;
|
int bit_depth, color_type, interlace_type;
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||||
|
assertMsg(png_ptr, "PNG read struct init failed!");
|
||||||
if (!png_ptr)
|
|
||||||
PRINT_ERR("PNG struct info init failed(1)!");
|
|
||||||
|
|
||||||
info_ptr = png_create_info_struct(png_ptr);
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
assertMsg(info_ptr, "PNG info struct init failed!");
|
||||||
if (!info_ptr)
|
assertMsg(!setjmp(png_jmpbuf(png_ptr)), "PNG reader fatal error!");
|
||||||
PRINT_ERR("PNG struct info init failed(2)!");
|
|
||||||
|
|
||||||
if (setjmp(png_jmpbuf(png_ptr)))
|
|
||||||
PRINT_ERR("PNG reader fatal error!");
|
|
||||||
|
|
||||||
png_init_io(png_ptr, file);
|
png_init_io(png_ptr, file);
|
||||||
|
|
||||||
png_set_sig_bytes(png_ptr, sig_read);
|
png_set_sig_bytes(png_ptr, sig_read);
|
||||||
|
|
||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
|
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_type, NULL, NULL);
|
||||||
|
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
|
||||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
@@ -98,7 +85,7 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
|
|||||||
type = TEX_TYPE_RGB;
|
type = TEX_TYPE_RGB;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
PRINT_ERR("This png format is not supported! RGB/RGBA only.");
|
assertMsg(true == false, "This png format is not supported! RGB/RGBA only.");
|
||||||
}
|
}
|
||||||
|
|
||||||
o_texture.setSize(width, height, type);
|
o_texture.setSize(width, height, type);
|
||||||
|
|||||||
@@ -58,16 +58,16 @@ Vector3 Matrix::operator*(const Vector3 &v) const
|
|||||||
float a[4] = {v.x, v.y, v.z, 1.0F};
|
float a[4] = {v.x, v.y, v.z, 1.0F};
|
||||||
float res[4];
|
float res[4];
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x00(%1) \n\t"
|
"lqc2 $vf4, 0x00(%1) \n\t"
|
||||||
"lqc2 vf5, 0x10(%1) \n\t"
|
"lqc2 $vf5, 0x10(%1) \n\t"
|
||||||
"lqc2 vf6, 0x20(%1) \n\t"
|
"lqc2 $vf6, 0x20(%1) \n\t"
|
||||||
"lqc2 vf7, 0x30(%1) \n\t"
|
"lqc2 $vf7, 0x30(%1) \n\t"
|
||||||
"lqc2 vf8, 0x00(%2) \n\t"
|
"lqc2 $vf8, 0x00(%2) \n\t"
|
||||||
"vmulax.xyzw ACC, vf4, vf8 \n\t"
|
"vmulax.xyzw $ACC, $vf4, $vf8 \n\t"
|
||||||
"vmadday.xyzw ACC, vf5, vf8 \n\t"
|
"vmadday.xyzw $ACC, $vf5, $vf8 \n\t"
|
||||||
"vmaddaz.xyzw ACC, vf6, vf8 \n\t"
|
"vmaddaz.xyzw $ACC, $vf6, $vf8 \n\t"
|
||||||
"vmaddw.xyzw vf9, vf7, vf8 \n\t"
|
"vmaddw.xyzw $vf9, $vf7, $vf8 \n\t"
|
||||||
"sqc2 vf9, 0x00(%0) \n\t"
|
"sqc2 $vf9, 0x00(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(res), "r"(this->data), "r"(a));
|
: "r"(res), "r"(this->data), "r"(a));
|
||||||
return Vector3(res[0], res[1], res[2]);
|
return Vector3(res[0], res[1], res[2]);
|
||||||
@@ -80,15 +80,15 @@ Vector3 Matrix::operator*(const Vector3 &v) const
|
|||||||
void Matrix::identity()
|
void Matrix::identity()
|
||||||
{
|
{
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"vsub.xyzw vf4, vf0, vf0 \n\t"
|
"vsub.xyzw $vf4, $vf0, $vf0 \n\t"
|
||||||
"vadd.w vf4, vf4, vf0 \n\t"
|
"vadd.w $vf4, $vf4, $vf0 \n\t"
|
||||||
"vmr32.xyzw vf5, vf4 \n\t"
|
"vmr32.xyzw $vf5, $vf4 \n\t"
|
||||||
"vmr32.xyzw vf6, vf5 \n\t"
|
"vmr32.xyzw $vf6, $vf5 \n\t"
|
||||||
"vmr32.xyzw vf7, vf6 \n\t"
|
"vmr32.xyzw $vf7, $vf6 \n\t"
|
||||||
"sqc2 vf4, 0x30(%0) \n\t"
|
"sqc2 $vf4, 0x30(%0) \n\t"
|
||||||
"sqc2 vf5, 0x20(%0) \n\t"
|
"sqc2 $vf5, 0x20(%0) \n\t"
|
||||||
"sqc2 vf6, 0x10(%0) \n\t"
|
"sqc2 $vf6, 0x10(%0) \n\t"
|
||||||
"sqc2 vf7, 0x0(%0) \n\t"
|
"sqc2 $vf7, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(this->data));
|
: "r"(this->data));
|
||||||
}
|
}
|
||||||
@@ -131,17 +131,17 @@ void Matrix::lookAt(const Vector3 &t_position, const Vector3 &t_target)
|
|||||||
VECTOR eye = {t_position.x, t_position.y, t_position.z, 1.0F};
|
VECTOR eye = {t_position.x, t_position.y, t_position.z, 1.0F};
|
||||||
VECTOR obj = {t_target.x, t_target.y, t_target.z, 1.0F};
|
VECTOR obj = {t_target.x, t_target.y, t_target.z, 1.0F};
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x00(%2) # eye \n\t"
|
"lqc2 $vf4, 0x00(%2) # eye \n\t"
|
||||||
"lqc2 vf5, 0x00(%3) # obj \n\t"
|
"lqc2 $vf5, 0x00(%3) # obj \n\t"
|
||||||
"vsub.xyz vf7, vf4, vf5 # view_vec = vf7 \n\t"
|
"vsub.xyz $vf7, $vf4, $vf5 # view_vec = $vf7 \n\t"
|
||||||
"vmove.xyzw vf6, vf0 \n\t"
|
"vmove.xyzw $vf6, $vf0 \n\t"
|
||||||
"vaddw.y vf6, vf0, vf0 # vf6 = { 0.0f, 1.0f, 0.0f, 1.0f } \n\t"
|
"vaddw.y $vf6, $vf0, $vf0 # $vf6 = { 0.0f, 1.0f, 0.0f, 1.0f } \n\t"
|
||||||
"vopmula.xyz ACC, vf6, vf7 \n\t"
|
"vopmula.xyz $ACC, $vf6, $vf7 \n\t"
|
||||||
"vopmsub.xyz vf9, vf7, vf6 # vec = vf9 \n\t"
|
"vopmsub.xyz $vf9, $vf7, $vf6 # vec = $vf9 \n\t"
|
||||||
"vopmula.xyz ACC, vf7, vf9 \n\t"
|
"vopmula.xyz $ACC, $vf7, $vf9 \n\t"
|
||||||
"vopmsub.xyz vf8, vf9, vf7 # up_vec = vf8 \n\t"
|
"vopmsub.xyz $vf8, $vf9, $vf7 # up_vec = $vf8 \n\t"
|
||||||
"sqc2 vf7, 0x00(%0) # view_vec \n\t"
|
"sqc2 $vf7, 0x00(%0) # view_vec \n\t"
|
||||||
"sqc2 vf6, 0x00(%1) # up_vec \n\t"
|
"sqc2 $vf6, 0x00(%1) # up_vec \n\t"
|
||||||
:
|
:
|
||||||
: "r"(view_vec), "r"(up_vec), "r"(eye), "r"(obj));
|
: "r"(view_vec), "r"(up_vec), "r"(eye), "r"(obj));
|
||||||
Matrix temp;
|
Matrix temp;
|
||||||
@@ -270,45 +270,45 @@ void Matrix::setScale(const Vector3 &t_val)
|
|||||||
|
|
||||||
void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_vy[4])
|
void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_vy[4])
|
||||||
{
|
{
|
||||||
// Matrix vf4, vf5, vf6, vf7
|
// Matrix $vf4, $vf5, $vf6, $vf7
|
||||||
// t_pos vf8
|
// t_pos $vf8
|
||||||
// t_vz vf9
|
// t_vz $vf9
|
||||||
// t_vy vf10
|
// t_vy $vf10
|
||||||
// vtmp vf11
|
// vtmp $vf11
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf9, 0x00(%2) \n\t"
|
"lqc2 $vf9, 0x00(%2) \n\t"
|
||||||
"lqc2 vf10, 0x00(%3) \n\t"
|
"lqc2 $vf10, 0x00(%3) \n\t"
|
||||||
// mtmp.unit()
|
// mtmp.unit()
|
||||||
"vsub.w vf5, vf0, vf0 # mtmp[1][PW] = 0.0F \n\t"
|
"vsub.w $vf5, $vf0, $vf0 # mtmp[1][PW] = 0.0F \n\t"
|
||||||
// vtmp.outerProduct(vy, vz);
|
// vtmp.outerProduct(vy, vz);
|
||||||
"vopmula.xyz ACC, vf10, vf9 \n\t"
|
"vopmula.xyz $ACC, $vf10, $vf9 \n\t"
|
||||||
"vopmsub.xyz vf11, vf9, vf10 \n\t"
|
"vopmsub.xyz $vf11, $vf9, $vf10 \n\t"
|
||||||
// mtmp[0] = vtmp.normalize();
|
// mtmp[0] = vtmp.normalize();
|
||||||
"vmul.xyz vf12, vf11, vf11 \n\t"
|
"vmul.xyz $vf12, $vf11, $vf11 \n\t"
|
||||||
"vaddy.x vf12, vf12, vf12 \n\t"
|
"vaddy.x $vf12, $vf12, $vf12 \n\t"
|
||||||
"vaddz.x vf12, vf12, vf12 \n\t"
|
"vaddz.x $vf12, $vf12, $vf12 \n\t"
|
||||||
"vrsqrt Q, vf0w, vf12x \n\t"
|
"vrsqrt $Q, $vf0w, $vf12x \n\t"
|
||||||
"vsub.xyzw vf4, vf0, vf0 \n\t"
|
"vsub.xyzw $vf4, $vf0, $vf0 \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vmulq.xyz vf4, vf11, Q \n\t"
|
"vmulq.xyz $vf4, $vf11, $Q \n\t"
|
||||||
// mtmp[2] = vz.normalize();
|
// mtmp[2] = vz.normalize();
|
||||||
"vmul.xyz vf12, vf9, vf9 \n\t"
|
"vmul.xyz $vf12, $vf9, $vf9 \n\t"
|
||||||
"vaddy.x vf12, vf12, vf12 \n\t"
|
"vaddy.x $vf12, $vf12, $vf12 \n\t"
|
||||||
"vaddz.x vf12, vf12, vf12 \n\t"
|
"vaddz.x $vf12, $vf12, $vf12 \n\t"
|
||||||
"vrsqrt Q, vf0w, vf12x \n\t"
|
"vrsqrt $Q, $vf0w, $vf12x \n\t"
|
||||||
"vsub.xyzw vf6, vf0, vf0 \n\t"
|
"vsub.xyzw $vf6, $vf0, $vf0 \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vmulq.xyz vf6, vf9, Q \n\t"
|
"vmulq.xyz $vf6, $vf9, $Q \n\t"
|
||||||
// mtmp[1].outerProduct(mtmp[2], mtmp[0]);
|
// mtmp[1].outerProduct(mtmp[2], mtmp[0]);
|
||||||
"vopmula.xyz ACC, vf6, vf4 \n\t"
|
"vopmula.xyz $ACC, $vf6, $vf4 \n\t"
|
||||||
"vopmsub.xyz vf5, vf4, vf6 \n\t"
|
"vopmsub.xyz $vf5, $vf4, $vf6 \n\t"
|
||||||
// mtmp.transpose(pos);
|
// mtmp.transpose(pos);
|
||||||
"lqc2 vf7, 0x00(%1) \n\t"
|
"lqc2 $vf7, 0x00(%1) \n\t"
|
||||||
// m = mtmp.inverse();
|
// m = mtmp.inverse();
|
||||||
"qmfc2.ni $11, vf0 \n\t"
|
"qmfc2.ni $11, $vf0 \n\t"
|
||||||
"qmfc2.ni $8, vf4 \n\t"
|
"qmfc2.ni $8, $vf4 \n\t"
|
||||||
"qmfc2.ni $9, vf5 \n\t"
|
"qmfc2.ni $9, $vf5 \n\t"
|
||||||
"qmfc2.ni $10, vf6 \n\t"
|
"qmfc2.ni $10, $vf6 \n\t"
|
||||||
|
|
||||||
"pextlw $12, $9, $8 \n\t"
|
"pextlw $12, $9, $8 \n\t"
|
||||||
"pextuw $13, $9, $8 \n\t"
|
"pextuw $13, $9, $8 \n\t"
|
||||||
@@ -318,18 +318,18 @@ void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_
|
|||||||
"pcpyud $9, $12, $14 \n\t"
|
"pcpyud $9, $12, $14 \n\t"
|
||||||
"pcpyld $10, $15, $13 \n\t"
|
"pcpyld $10, $15, $13 \n\t"
|
||||||
|
|
||||||
"qmtc2.ni $8, vf16 \n\t"
|
"qmtc2.ni $8, $vf16 \n\t"
|
||||||
"qmtc2.ni $9, vf17 \n\t"
|
"qmtc2.ni $9, $vf17 \n\t"
|
||||||
"qmtc2.ni $10, vf18 \n\t"
|
"qmtc2.ni $10, $vf18 \n\t"
|
||||||
"vmulax.xyz ACC, vf16, vf7 \n\t"
|
"vmulax.xyz $ACC, $vf16, $vf7 \n\t"
|
||||||
"vmadday.xyz ACC, vf17, vf7 \n\t"
|
"vmadday.xyz $ACC, $vf17, $vf7 \n\t"
|
||||||
"vmaddz.xyz vf5, vf18, vf7 \n\t"
|
"vmaddz.xyz $vf5, $vf18, $vf7 \n\t"
|
||||||
"vsub.xyzw vf5, vf0, vf5 \n\t"
|
"vsub.xyzw $vf5, $vf0, $vf5 \n\t"
|
||||||
|
|
||||||
"sq $8, 0x00(%0) \n\t"
|
"sq $8, 0x00(%0) \n\t"
|
||||||
"sq $9, 0x10(%0) \n\t"
|
"sq $9, 0x10(%0) \n\t"
|
||||||
"sq $10, 0x20(%0) \n\t"
|
"sq $10, 0x20(%0) \n\t"
|
||||||
"sqc2 vf5, 0x30(%0) \n\t"
|
"sqc2 $vf5, 0x30(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(this->data), "r"(t_pos), "r"(t_vz), "r"(t_vy));
|
: "r"(this->data), "r"(t_pos), "r"(t_vz), "r"(t_vy));
|
||||||
}
|
}
|
||||||
@@ -337,34 +337,34 @@ void Matrix::setCamera(const float t_pos[4], const float t_vz[4], const float t_
|
|||||||
void Matrix::cross(float res[16], const float a[16], const float b[16]) const
|
void Matrix::cross(float res[16], const float a[16], const float b[16]) const
|
||||||
{
|
{
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf1, 0x00(%1) \n\t"
|
"lqc2 $vf1, 0x00(%1) \n\t"
|
||||||
"lqc2 vf2, 0x10(%1) \n\t"
|
"lqc2 $vf2, 0x10(%1) \n\t"
|
||||||
"lqc2 vf3, 0x20(%1) \n\t"
|
"lqc2 $vf3, 0x20(%1) \n\t"
|
||||||
"lqc2 vf4, 0x30(%1) \n\t"
|
"lqc2 $vf4, 0x30(%1) \n\t"
|
||||||
"lqc2 vf5, 0x00(%2) \n\t"
|
"lqc2 $vf5, 0x00(%2) \n\t"
|
||||||
"lqc2 vf6, 0x10(%2) \n\t"
|
"lqc2 $vf6, 0x10(%2) \n\t"
|
||||||
"lqc2 vf7, 0x20(%2) \n\t"
|
"lqc2 $vf7, 0x20(%2) \n\t"
|
||||||
"lqc2 vf8, 0x30(%2) \n\t"
|
"lqc2 $vf8, 0x30(%2) \n\t"
|
||||||
"vmulax.xyzw ACC, vf5, vf1 \n\t"
|
"vmulax.xyzw $ACC, $vf5, $vf1 \n\t"
|
||||||
"vmadday.xyzw ACC, vf6, vf1 \n\t"
|
"vmadday.xyzw $ACC, $vf6, $vf1 \n\t"
|
||||||
"vmaddaz.xyzw ACC, vf7, vf1 \n\t"
|
"vmaddaz.xyzw $ACC, $vf7, $vf1 \n\t"
|
||||||
"vmaddw.xyzw vf1, vf8, vf1 \n\t"
|
"vmaddw.xyzw $vf1, $vf8, $vf1 \n\t"
|
||||||
"vmulax.xyzw ACC, vf5, vf2 \n\t"
|
"vmulax.xyzw $ACC, $vf5, $vf2 \n\t"
|
||||||
"vmadday.xyzw ACC, vf6, vf2 \n\t"
|
"vmadday.xyzw $ACC, $vf6, $vf2 \n\t"
|
||||||
"vmaddaz.xyzw ACC, vf7, vf2 \n\t"
|
"vmaddaz.xyzw $ACC, $vf7, $vf2 \n\t"
|
||||||
"vmaddw.xyzw vf2, vf8, vf2 \n\t"
|
"vmaddw.xyzw $vf2, $vf8, $vf2 \n\t"
|
||||||
"vmulax.xyzw ACC, vf5, vf3 \n\t"
|
"vmulax.xyzw $ACC, $vf5, $vf3 \n\t"
|
||||||
"vmadday.xyzw ACC, vf6, vf3 \n\t"
|
"vmadday.xyzw $ACC, $vf6, $vf3 \n\t"
|
||||||
"vmaddaz.xyzw ACC, vf7, vf3 \n\t"
|
"vmaddaz.xyzw $ACC, $vf7, $vf3 \n\t"
|
||||||
"vmaddw.xyzw vf3, vf8, vf3 \n\t"
|
"vmaddw.xyzw $vf3, $vf8, $vf3 \n\t"
|
||||||
"vmulax.xyzw ACC, vf5, vf4 \n\t"
|
"vmulax.xyzw $ACC, $vf5, $vf4 \n\t"
|
||||||
"vmadday.xyzw ACC, vf6, vf4 \n\t"
|
"vmadday.xyzw $ACC, $vf6, $vf4 \n\t"
|
||||||
"vmaddaz.xyzw ACC, vf7, vf4 \n\t"
|
"vmaddaz.xyzw $ACC, $vf7, $vf4 \n\t"
|
||||||
"vmaddw.xyzw vf4, vf8, vf4 \n\t"
|
"vmaddw.xyzw $vf4, $vf8, $vf4 \n\t"
|
||||||
"sqc2 vf1, 0x00(%0) \n\t"
|
"sqc2 $vf1, 0x00(%0) \n\t"
|
||||||
"sqc2 vf2, 0x10(%0) \n\t"
|
"sqc2 $vf2, 0x10(%0) \n\t"
|
||||||
"sqc2 vf3, 0x20(%0) \n\t"
|
"sqc2 $vf3, 0x20(%0) \n\t"
|
||||||
"sqc2 vf4, 0x30(%0) \n\t"
|
"sqc2 $vf4, 0x30(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(res), "r"(b), "r"(a)
|
: "r"(res), "r"(b), "r"(a)
|
||||||
: "memory");
|
: "memory");
|
||||||
|
|||||||
@@ -30,10 +30,10 @@ Vector3 Vector3::operator+(const Vector3 &v) const
|
|||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"lqc2 vf5, 0x0(%2) \n\t"
|
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||||
"vadd.xyz vf6, vf4, vf5 \n\t"
|
"vadd.xyz $vf6, $vf4, $vf5 \n\t"
|
||||||
"sqc2 vf6, 0x0(%0) \n\t"
|
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||||
return result;
|
return result;
|
||||||
@@ -43,10 +43,10 @@ Vector3 Vector3::operator-(const Vector3 &v) const
|
|||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"lqc2 vf5, 0x0(%2) \n\t"
|
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||||
"vsub.xyz vf6, vf4, vf5 \n\t"
|
"vsub.xyz $vf6, $vf4, $vf5 \n\t"
|
||||||
"sqc2 vf6, 0x0(%0) \n\t"
|
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
: "r"(result.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||||
return result;
|
return result;
|
||||||
@@ -56,12 +56,12 @@ Vector3 Vector3::operator*(const Vector3 &v) const
|
|||||||
{
|
{
|
||||||
Vector3 res;
|
Vector3 res;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = this
|
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = this
|
||||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v
|
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v
|
||||||
"vopmula.xyz ACC, vf4, vf5 \n\t"
|
"vopmula.xyz $ACC, $vf4, $vf5 \n\t"
|
||||||
"vopmsub.xyz vf8, vf5, vf4 \n\t"
|
"vopmsub.xyz $vf8, $vf5, $vf4 \n\t"
|
||||||
"vsub.w vf8, vf00, vf00 \n\t"
|
"vsub.w $vf8, $vf0, $vf0 \n\t"
|
||||||
"sqc2 vf8, 0x0(%0) \n\t" // vf8 = res
|
"sqc2 $vf8, 0x0(%0) \n\t" // $vf8 = res
|
||||||
:
|
:
|
||||||
: "r"(res.xyz), "r"(this->xyz), "r"(v.xyz));
|
: "r"(res.xyz), "r"(this->xyz), "r"(v.xyz));
|
||||||
// result.x = y * v.z - z * v.y;
|
// result.x = y * v.z - z * v.y;
|
||||||
@@ -74,11 +74,11 @@ Vector3 Vector3::operator*(const float &t) const
|
|||||||
{
|
{
|
||||||
Vector3 result;
|
Vector3 result;
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"mfc1 $8, %2 \n\t"
|
"mfc1 $8, %2 \n\t"
|
||||||
"qmtc2 $8, vf5 \n\t"
|
"qmtc2 $8, $vf5 \n\t"
|
||||||
"vmulx.xyz vf6, vf4, vf5 \n\t"
|
"vmulx.xyz $vf6, $vf4, $vf5 \n\t"
|
||||||
"sqc2 vf6, 0x0(%0) \n\t"
|
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(result.xyz), "r"(this->xyz), "f"(t));
|
: "r"(result.xyz), "r"(this->xyz), "f"(t));
|
||||||
return result;
|
return result;
|
||||||
@@ -96,10 +96,10 @@ Vector3 Vector3::operator/(const float &t) const
|
|||||||
void Vector3::operator+=(const Vector3 &t)
|
void Vector3::operator+=(const Vector3 &t)
|
||||||
{
|
{
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%0) \n\t"
|
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||||
"lqc2 vf5, 0x0(%1) \n\t"
|
"lqc2 $vf5, 0x0(%1) \n\t"
|
||||||
"vadd.xyz vf4, vf4, vf5 \n\t"
|
"vadd.xyz $vf4, $vf4, $vf5 \n\t"
|
||||||
"sqc2 vf4, 0x0(%0) \n\t"
|
"sqc2 $vf4, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(this->xyz), "r"(t.xyz));
|
: "r"(this->xyz), "r"(t.xyz));
|
||||||
}
|
}
|
||||||
@@ -107,11 +107,11 @@ void Vector3::operator+=(const Vector3 &t)
|
|||||||
void Vector3::operator*=(const float &t)
|
void Vector3::operator*=(const float &t)
|
||||||
{
|
{
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x0(%0) \n\t"
|
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||||
"mfc1 $8, %1 \n\t"
|
"mfc1 $8, %1 \n\t"
|
||||||
"qmtc2 $8, vf5 \n\t"
|
"qmtc2 $8, $vf5 \n\t"
|
||||||
"vmulx.xyz vf4, vf4, vf5 \n\t"
|
"vmulx.xyz $vf4, $vf4, $vf5 \n\t"
|
||||||
"sqc2 vf4, 0x0(%0) \n\t"
|
"sqc2 $vf4, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(this->xyz), "f"(t));
|
: "r"(this->xyz), "f"(t));
|
||||||
}
|
}
|
||||||
@@ -140,12 +140,12 @@ float Vector3::innerProduct(const Vector3 &v) const
|
|||||||
{
|
{
|
||||||
float result;
|
float result;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"lqc2 vf5, 0x0(%2) \n\t"
|
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||||
"vmul.xyz vf6, vf4, vf5 \n\t"
|
"vmul.xyz $vf6, $vf4, $vf5 \n\t"
|
||||||
"vaddy.x vf6, vf6, vf6 \n\t"
|
"vaddy.x $vf6, $vf6, $vf6 \n\t"
|
||||||
"vaddz.x vf6, vf6, vf6 \n\t"
|
"vaddz.x $vf6, $vf6, $vf6 \n\t"
|
||||||
"qmfc2 $2, vf6 \n\t"
|
"qmfc2 $2, $vf6 \n\t"
|
||||||
"mtc1 $2, %0 \n\t"
|
"mtc1 $2, %0 \n\t"
|
||||||
: "=f"(result)
|
: "=f"(result)
|
||||||
: "r"(this->xyz), "r"(v.xyz));
|
: "r"(this->xyz), "r"(v.xyz));
|
||||||
@@ -157,14 +157,14 @@ float Vector3::length() const
|
|||||||
{
|
{
|
||||||
float result;
|
float result;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"vmul.xyz vf5, vf4, vf4 \n\t"
|
"vmul.xyz $vf5, $vf4, $vf4 \n\t"
|
||||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"vsqrt Q , vf5x \n\t"
|
"vsqrt $Q , $vf5x \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vaddq.x vf8, vf0, Q \n\t"
|
"vaddq.x $vf8, $vf0, $Q \n\t"
|
||||||
"qmfc2 $2, vf8 \n\t"
|
"qmfc2 $2, $vf8 \n\t"
|
||||||
"mtc1 $2, %0 \n\t"
|
"mtc1 $2, %0 \n\t"
|
||||||
: "=f"(result)
|
: "=f"(result)
|
||||||
: "r"(this->xyz));
|
: "r"(this->xyz));
|
||||||
@@ -175,17 +175,17 @@ float Vector3::length() const
|
|||||||
void Vector3::normalize()
|
void Vector3::normalize()
|
||||||
{
|
{
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%0) \n\t"
|
"lqc2 $vf4, 0x0(%0) \n\t"
|
||||||
"vmul.xyz vf5, vf4, vf4 \n\t"
|
"vmul.xyz $vf5, $vf4, $vf4 \n\t"
|
||||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"vrsqrt Q, vf0w, vf5x \n\t"
|
"vrsqrt $Q, $vf0w, $vf5x \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vsub.xyz vf6, vf0, vf0 \n\t"
|
"vsub.xyz $vf6, $vf0, $vf0 \n\t"
|
||||||
"vaddw.xyz vf6, vf6, vf4 \n\t"
|
"vaddw.xyz $vf6, $vf6, $vf4 \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vmulq.xyz vf6, vf4, Q \n\t"
|
"vmulq.xyz $vf6, $vf4, $Q \n\t"
|
||||||
"sqc2 vf6, 0x0(%0) \n\t"
|
"sqc2 $vf6, 0x0(%0) \n\t"
|
||||||
:
|
:
|
||||||
: "r"(this->xyz));
|
: "r"(this->xyz));
|
||||||
}
|
}
|
||||||
@@ -194,16 +194,16 @@ float Vector3::distanceTo(const Vector3 &v) const
|
|||||||
{
|
{
|
||||||
register float result;
|
register float result;
|
||||||
asm volatile( // VU0 Macro program
|
asm volatile( // VU0 Macro program
|
||||||
"lqc2 vf4, 0x0(%1) \n\t"
|
"lqc2 $vf4, 0x0(%1) \n\t"
|
||||||
"lqc2 vf5, 0x0(%2) \n\t"
|
"lqc2 $vf5, 0x0(%2) \n\t"
|
||||||
"vsub.xyz vf6, vf4, vf5 \n\t"
|
"vsub.xyz $vf6, $vf4, $vf5 \n\t"
|
||||||
"vmul.xyz vf7, vf6, vf6 \n\t"
|
"vmul.xyz $vf7, $vf6, $vf6 \n\t"
|
||||||
"vaddy.x vf7, vf7, vf7 \n\t"
|
"vaddy.x $vf7, $vf7, $vf7 \n\t"
|
||||||
"vaddz.x vf7, vf7, vf7 \n\t"
|
"vaddz.x $vf7, $vf7, $vf7 \n\t"
|
||||||
"vsqrt Q , vf7x \n\t"
|
"vsqrt $Q , $vf7x \n\t"
|
||||||
"vwaitq \n\t"
|
"vwaitq \n\t"
|
||||||
"vaddq.x vf8, vf0, Q \n\t"
|
"vaddq.x $vf8, $vf0, $Q \n\t"
|
||||||
"qmfc2 $2, vf8 \n\t"
|
"qmfc2 $2, $vf8 \n\t"
|
||||||
"mtc1 $2, %0 \n\t"
|
"mtc1 $2, %0 \n\t"
|
||||||
: "=f"(result)
|
: "=f"(result)
|
||||||
: "r"(this->xyz), "r"(v.xyz));
|
: "r"(this->xyz), "r"(v.xyz));
|
||||||
@@ -217,20 +217,20 @@ u8 Vector3::shouldBeBackfaceCulled(const Vector3 *t_cameraPos, const Vector3 *t_
|
|||||||
{
|
{
|
||||||
register float dot;
|
register float dot;
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = cameraPos
|
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = cameraPos
|
||||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v0
|
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v0
|
||||||
"lqc2 vf6, 0x0(%3) \n\t" // vf6 = v1
|
"lqc2 $vf6, 0x0(%3) \n\t" // $vf6 = v1
|
||||||
"lqc2 vf7, 0x0(%4) \n\t" // vf7 = v2
|
"lqc2 $vf7, 0x0(%4) \n\t" // $vf7 = v2
|
||||||
"vsub.xyz vf8, vf7, vf5 \n\t" // vf8 = vf7(v2) - vf5(v0)
|
"vsub.xyz $vf8, $vf7, $vf5 \n\t" // $vf8 = $vf7(v2) - $vf5(v0)
|
||||||
"vsub.xyz vf9, vf6, vf5 \n\t" // vf9 = vf6(v1) - vf5(v0)
|
"vsub.xyz $vf9, $vf6, $vf5 \n\t" // $vf9 = $vf6(v1) - $vf5(v0)
|
||||||
"vopmula.xyz ACC, vf8, vf9 \n\t" // vf6 = cross(vf8, vf9)
|
"vopmula.xyz $ACC, $vf8, $vf9 \n\t" // $vf6 = cross($vf8, $vf9)
|
||||||
"vopmsub.xyz vf6, vf9, vf8 \n\t"
|
"vopmsub.xyz $vf6, $vf9, $vf8 \n\t"
|
||||||
"vsub.w vf6, vf6, vf6 \n\t"
|
"vsub.w $vf6, $vf6, $vf6 \n\t"
|
||||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = vf5(v0) - vf4(cameraPos)
|
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = $vf5(v0) - $vf4(cameraPos)
|
||||||
"vmul.xyz vf5, vf7, vf6 \n\t" // vf5 = dot(vf7, vf6)
|
"vmul.xyz $vf5, $vf7, $vf6 \n\t" // $vf5 = dot($vf7, $vf6)
|
||||||
"vaddy.x vf5, vf5, vf5 \n\t"
|
"vaddy.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"vaddz.x vf5, vf5, vf5 \n\t"
|
"vaddz.x $vf5, $vf5, $vf5 \n\t"
|
||||||
"qmfc2 $2, vf5 \n\t" // store result on `dot` variable
|
"qmfc2 $2, $vf5 \n\t" // store result on `dot` variable
|
||||||
"mtc1 $2, %0 \n\t"
|
"mtc1 $2, %0 \n\t"
|
||||||
: "=f"(dot)
|
: "=f"(dot)
|
||||||
: "r"(t_cameraPos->xyz), "r"(t_v0->xyz), "r"(t_v1->xyz), "r"(t_v2->xyz));
|
: "r"(t_cameraPos->xyz), "r"(t_v0->xyz), "r"(t_v1->xyz), "r"(t_v2->xyz));
|
||||||
@@ -240,14 +240,14 @@ u8 Vector3::shouldBeBackfaceCulled(const Vector3 *t_cameraPos, const Vector3 *t_
|
|||||||
void Vector3::setByLerp(const Vector3 &t_v1, const Vector3 &t_v2, const float &t_interp, const float &t_scale)
|
void Vector3::setByLerp(const Vector3 &t_v1, const Vector3 &t_v2, const float &t_interp, const float &t_scale)
|
||||||
{
|
{
|
||||||
asm volatile(
|
asm volatile(
|
||||||
"lqc2 vf4, 0x0(%1) \n\t" // vf4 = v1
|
"lqc2 $vf4, 0x0(%1) \n\t" // $vf4 = v1
|
||||||
"lqc2 vf5, 0x0(%2) \n\t" // vf5 = v2
|
"lqc2 $vf5, 0x0(%2) \n\t" // $vf5 = v2
|
||||||
"mfc1 $8, %3 \n\t" // vf6 = t
|
"mfc1 $8, %3 \n\t" // $vf6 = t
|
||||||
"qmtc2 $8, vf6 \n\t" // lerp:
|
"qmtc2 $8, $vf6 \n\t" // lerp:
|
||||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||||
"sqc2 vf9, 0x0(%0) \n\t" // v0 = vf9
|
"sqc2 $vf9, 0x0(%0) \n\t" // v0 = $vf9
|
||||||
:
|
:
|
||||||
: "r"(&this->xyz), "r"(&t_v1.xyz), "r"(&t_v2.xyz), "f"(t_interp));
|
: "r"(&this->xyz), "r"(&t_v1.xyz), "r"(&t_v2.xyz), "f"(t_interp));
|
||||||
operator*=(t_scale);
|
operator*=(t_scale);
|
||||||
|
|||||||
+75
-92
@@ -28,6 +28,7 @@ Mesh::Mesh()
|
|||||||
shouldBeFrustumCulled = true;
|
shouldBeFrustumCulled = true;
|
||||||
shouldBeBackfaceCulled = false;
|
shouldBeBackfaceCulled = false;
|
||||||
shouldBeLighted = false;
|
shouldBeLighted = false;
|
||||||
|
_areFramesAllocated = false;
|
||||||
_isMother = false;
|
_isMother = false;
|
||||||
scale = 1.0F;
|
scale = 1.0F;
|
||||||
framesCount = 0;
|
framesCount = 0;
|
||||||
@@ -40,13 +41,12 @@ Mesh::Mesh()
|
|||||||
animState.isStayFrameSet = false;
|
animState.isStayFrameSet = false;
|
||||||
animState.nextFrame = 0;
|
animState.nextFrame = 0;
|
||||||
animState.speed = 0.1F;
|
animState.speed = 0.1F;
|
||||||
setDefaultColor();
|
|
||||||
setDefaultLODAndClut();
|
setDefaultLODAndClut();
|
||||||
}
|
}
|
||||||
|
|
||||||
Mesh::~Mesh()
|
Mesh::~Mesh()
|
||||||
{
|
{
|
||||||
if (_isMother)
|
if (_areFramesAllocated)
|
||||||
delete[] frames;
|
delete[] frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +59,7 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, con
|
|||||||
ObjLoader loader = ObjLoader();
|
ObjLoader loader = ObjLoader();
|
||||||
framesCount = 1;
|
framesCount = 1;
|
||||||
frames = new MeshFrame[framesCount];
|
frames = new MeshFrame[framesCount];
|
||||||
|
_areFramesAllocated = true;
|
||||||
char *part1 = String::createConcatenated(t_subfolder, t_objFile); // "folder/object"
|
char *part1 = String::createConcatenated(t_subfolder, t_objFile); // "folder/object"
|
||||||
char *finalPath = String::createConcatenated(part1, ".obj"); // "folder/object.obj"
|
char *finalPath = String::createConcatenated(part1, ".obj"); // "folder/object.obj"
|
||||||
loader.load(&frames[0], finalPath, t_scale, t_invertT);
|
loader.load(&frames[0], finalPath, t_scale, t_invertT);
|
||||||
@@ -69,15 +70,15 @@ void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, con
|
|||||||
|
|
||||||
void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, const u32 &t_framesCount, const u8 &t_invertT)
|
void Mesh::loadObj(char *t_subfolder, char *t_objFile, const float &t_scale, const u32 &t_framesCount, const u8 &t_invertT)
|
||||||
{
|
{
|
||||||
if (t_framesCount == 0)
|
assertMsg(t_framesCount != 0, "Frames count cannot be 0!");
|
||||||
PRINT_ERR("Frames count cannot be 0!");
|
if (t_framesCount == 1)
|
||||||
else if (t_framesCount == 1)
|
|
||||||
loadObj(t_subfolder, t_objFile, t_scale, t_invertT);
|
loadObj(t_subfolder, t_objFile, t_scale, t_invertT);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ObjLoader loader = ObjLoader();
|
ObjLoader loader = ObjLoader();
|
||||||
framesCount = t_framesCount;
|
framesCount = t_framesCount;
|
||||||
frames = new MeshFrame[framesCount];
|
frames = new MeshFrame[framesCount];
|
||||||
|
_areFramesAllocated = true;
|
||||||
char *part1 = String::createConcatenated(t_subfolder, t_objFile); // "folder/object"
|
char *part1 = String::createConcatenated(t_subfolder, t_objFile); // "folder/object"
|
||||||
char *part2 = String::createConcatenated(part1, "_"); // "folder/object_"
|
char *part2 = String::createConcatenated(part1, "_"); // "folder/object_"
|
||||||
for (u32 i = 0; i < framesCount; i++)
|
for (u32 i = 0; i < framesCount; i++)
|
||||||
@@ -105,6 +106,7 @@ void Mesh::loadDff(char *t_subfolder, char *t_dffFile, const float &t_scale, con
|
|||||||
char *dffPath = String::createConcatenated(part1, ".dff");
|
char *dffPath = String::createConcatenated(part1, ".dff");
|
||||||
framesCount = 1;
|
framesCount = 1;
|
||||||
frames = new MeshFrame[1];
|
frames = new MeshFrame[1];
|
||||||
|
_areFramesAllocated = true;
|
||||||
loader.load(frames, dffPath, t_scale, t_invertT);
|
loader.load(frames, dffPath, t_scale, t_invertT);
|
||||||
delete[] part1;
|
delete[] part1;
|
||||||
delete[] dffPath;
|
delete[] dffPath;
|
||||||
@@ -120,16 +122,18 @@ void Mesh::loadMD2(char *t_subfolder, char *t_md2File, const float &t_scale, con
|
|||||||
|
|
||||||
void Mesh::loadFrom(const Mesh &t_mesh)
|
void Mesh::loadFrom(const Mesh &t_mesh)
|
||||||
{
|
{
|
||||||
frames = t_mesh.frames;
|
|
||||||
framesCount = t_mesh.framesCount;
|
framesCount = t_mesh.framesCount;
|
||||||
|
frames = new MeshFrame[framesCount];
|
||||||
|
_areFramesAllocated = true;
|
||||||
|
for (u32 i = 0; i < framesCount; i++)
|
||||||
|
frames[i].copyFrom(&t_mesh.getFrame(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame)
|
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame)
|
||||||
{
|
{
|
||||||
if (framesCount > 1)
|
assertMsg(framesCount > 0, "Cant play animation, because no mesh data was loaded!");
|
||||||
{
|
assertMsg(framesCount != 1, "Cant play animation, because this mesh have only one frame.");
|
||||||
if (t_endFrame >= framesCount)
|
assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
|
||||||
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-1)");
|
|
||||||
animState.startFrame = t_startFrame;
|
animState.startFrame = t_startFrame;
|
||||||
animState.endFrame = t_endFrame;
|
animState.endFrame = t_endFrame;
|
||||||
if (animState.currentFrame == t_startFrame)
|
if (animState.currentFrame == t_startFrame)
|
||||||
@@ -137,29 +141,18 @@ void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame)
|
|||||||
else
|
else
|
||||||
animState.nextFrame = t_startFrame;
|
animState.nextFrame = t_startFrame;
|
||||||
}
|
}
|
||||||
else if (framesCount == 0)
|
|
||||||
PRINT_ERR("Cant play animation, because no mesh data was loaded!");
|
|
||||||
else if (framesCount == 1)
|
|
||||||
PRINT_ERR("Cant play animation, because this mesh have only one frame.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame, const u32 &t_stayFrame)
|
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame, const u32 &t_stayFrame)
|
||||||
{
|
{
|
||||||
if (framesCount > 1)
|
assertMsg(framesCount > 0, "Cant play animation, because no mesh data was loaded!");
|
||||||
{
|
assertMsg(framesCount != 1, "Cant play animation, because this mesh have only one frame.");
|
||||||
if (t_endFrame >= framesCount)
|
assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
|
||||||
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-1)");
|
|
||||||
animState.startFrame = t_startFrame;
|
animState.startFrame = t_startFrame;
|
||||||
animState.endFrame = t_endFrame;
|
animState.endFrame = t_endFrame;
|
||||||
animState.isStayFrameSet = true;
|
animState.isStayFrameSet = true;
|
||||||
animState.stayFrame = t_stayFrame;
|
animState.stayFrame = t_stayFrame;
|
||||||
animState.nextFrame = t_startFrame;
|
animState.nextFrame = t_startFrame;
|
||||||
}
|
}
|
||||||
else if (framesCount == 0)
|
|
||||||
PRINT_ERR("Cant play animation, because no mesh data was loaded!");
|
|
||||||
else if (framesCount == 1)
|
|
||||||
PRINT_ERR("Cant play animation, because this mesh have only one frame.");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Mesh::animate()
|
void Mesh::animate()
|
||||||
{
|
{
|
||||||
@@ -189,7 +182,7 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
|||||||
asm volatile(
|
asm volatile(
|
||||||
// VU0 macro program:
|
// VU0 macro program:
|
||||||
// Load vector with 1.0F values to VF21
|
// Load vector with 1.0F values to VF21
|
||||||
"lqc2 vf21, 0x0(%0) \n\t" // load "one vec"
|
"lqc2 $vf21, 0x0(%0) \n\t" // load "one vec"
|
||||||
:
|
:
|
||||||
: "r"(ONE_VEC));
|
: "r"(ONE_VEC));
|
||||||
|
|
||||||
@@ -215,34 +208,34 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
|||||||
// Calculate lerp() and store data into calc3Vectors
|
// Calculate lerp() and store data into calc3Vectors
|
||||||
|
|
||||||
// Vertex 0
|
// Vertex 0
|
||||||
"lqc2 vf4, 0x0(%3) \n\t" // vf4 = v1
|
"lqc2 $vf4, 0x0(%3) \n\t" // $vf4 = v1
|
||||||
"lqc2 vf5, 0x0(%6) \n\t" // vf5 = v2
|
"lqc2 $vf5, 0x0(%6) \n\t" // $vf5 = v2
|
||||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||||
"sqc2 vf9, 0x0(%0) \n\t" // v0 = vf9
|
"sqc2 $vf9, 0x0(%0) \n\t" // v0 = $vf9
|
||||||
|
|
||||||
// Vertex 1
|
// Vertex 1
|
||||||
"lqc2 vf4, 0x0(%4) \n\t" // vf4 = v1
|
"lqc2 $vf4, 0x0(%4) \n\t" // $vf4 = v1
|
||||||
"lqc2 vf5, 0x0(%7) \n\t" // vf5 = v2
|
"lqc2 $vf5, 0x0(%7) \n\t" // $vf5 = v2
|
||||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||||
"sqc2 vf9, 0x0(%1) \n\t" // v0 = vf9
|
"sqc2 $vf9, 0x0(%1) \n\t" // v0 = $vf9
|
||||||
|
|
||||||
// Vertex 2
|
// Vertex 2
|
||||||
"lqc2 vf4, 0x0(%5) \n\t" // vf4 = v1
|
"lqc2 $vf4, 0x0(%5) \n\t" // $vf4 = v1
|
||||||
"lqc2 vf5, 0x0(%8) \n\t" // vf5 = v2
|
"lqc2 $vf5, 0x0(%8) \n\t" // $vf5 = v2
|
||||||
"mfc1 $10, %9 \n\t" // vf6 = t
|
"mfc1 $10, %9 \n\t" // $vf6 = t
|
||||||
"qmtc2 $10, vf6 \n\t" // lerp:
|
"qmtc2 $10, $vf6 \n\t" // lerp:
|
||||||
"vsub.xyz vf7, vf5, vf4 \n\t" // vf7 = v2 - v1
|
"vsub.xyz $vf7, $vf5, $vf4 \n\t" // $vf7 = v2 - v1
|
||||||
"vmulx.xyz vf8, vf7, vf6 \n\t" // vf8 = vf7 * t
|
"vmulx.xyz $vf8, $vf7, $vf6 \n\t" // $vf8 = $vf7 * t
|
||||||
"vadd.xyz vf9, vf8, vf4 \n\t" // vf9 = vf8 + vf4
|
"vadd.xyz $vf9, $vf8, $vf4 \n\t" // $vf9 = $vf8 + $vf4
|
||||||
"sqc2 vf9, 0x0(%2) \n\t" // v0 = vf9
|
"sqc2 $vf9, 0x0(%2) \n\t" // v0 = $vf9
|
||||||
|
|
||||||
:
|
:
|
||||||
: "r"(calc3Vectors[0].xyz),
|
: "r"(calc3Vectors[0].xyz),
|
||||||
@@ -262,12 +255,12 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
|||||||
asm volatile(
|
asm volatile(
|
||||||
// VU0 macro program
|
// VU0 macro program
|
||||||
// Copy 0,1,2 vertices
|
// Copy 0,1,2 vertices
|
||||||
"lqc2 vf1, 0x0(%3) \n\t" // load vert
|
"lqc2 $vf1, 0x0(%3) \n\t" // load vert
|
||||||
"lqc2 vf2, 0x0(%4) \n\t" // load normal
|
"lqc2 $vf2, 0x0(%4) \n\t" // load normal
|
||||||
"lqc2 vf3, 0x0(%5) \n\t" // load st
|
"lqc2 $vf3, 0x0(%5) \n\t" // load st
|
||||||
"sqc2 vf1, 0x0(%0) \n\t" // store vert
|
"sqc2 $vf1, 0x0(%0) \n\t" // store vert
|
||||||
"sqc2 vf2, 0x0(%1) \n\t" // store normal
|
"sqc2 $vf2, 0x0(%1) \n\t" // store normal
|
||||||
"sqc2 vf3, 0x0(%2) \n\t" // store st
|
"sqc2 $vf3, 0x0(%2) \n\t" // store st
|
||||||
:
|
:
|
||||||
: "r"(calc3Vectors[0].xyz),
|
: "r"(calc3Vectors[0].xyz),
|
||||||
"r"(calc3Vectors[1].xyz),
|
"r"(calc3Vectors[1].xyz),
|
||||||
@@ -286,37 +279,37 @@ u32 Mesh::getDrawData(u32 t_materialIndex, VECTOR *o_vertices, VECTOR *o_normals
|
|||||||
// Copy data and set vert/normal "w" and st "z"+"w" to 1.0F
|
// Copy data and set vert/normal "w" and st "z"+"w" to 1.0F
|
||||||
|
|
||||||
// Vertex 0
|
// Vertex 0
|
||||||
"lqc2 vf1, 0x0(%3) \n\t" // load vert
|
"lqc2 $vf1, 0x0(%3) \n\t" // load vert
|
||||||
"lqc2 vf2, 0x0(%4) \n\t" // load normal
|
"lqc2 $vf2, 0x0(%4) \n\t" // load normal
|
||||||
"lqc2 vf3, 0x0(%5) \n\t" // load st
|
"lqc2 $vf3, 0x0(%5) \n\t" // load st
|
||||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||||
"sqc2 vf1, 0x0(%0) \n\t" // store vert
|
"sqc2 $vf1, 0x0(%0) \n\t" // store vert
|
||||||
"sqc2 vf2, 0x0(%1) \n\t" // store normal
|
"sqc2 $vf2, 0x0(%1) \n\t" // store normal
|
||||||
"sqc2 vf3, 0x0(%2) \n\t" // store st
|
"sqc2 $vf3, 0x0(%2) \n\t" // store st
|
||||||
|
|
||||||
// Vertex 1
|
// Vertex 1
|
||||||
"lqc2 vf1, 0x0(%9) \n\t" // load vert
|
"lqc2 $vf1, 0x0(%9) \n\t" // load vert
|
||||||
"lqc2 vf2, 0x0(%10) \n\t" // load normal
|
"lqc2 $vf2, 0x0(%10) \n\t" // load normal
|
||||||
"lqc2 vf3, 0x0(%11) \n\t" // load st
|
"lqc2 $vf3, 0x0(%11) \n\t" // load st
|
||||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||||
"sqc2 vf1, 0x0(%6) \n\t" // store vert
|
"sqc2 $vf1, 0x0(%6) \n\t" // store vert
|
||||||
"sqc2 vf2, 0x0(%7) \n\t" // store normal
|
"sqc2 $vf2, 0x0(%7) \n\t" // store normal
|
||||||
"sqc2 vf3, 0x0(%8) \n\t" // store st
|
"sqc2 $vf3, 0x0(%8) \n\t" // store st
|
||||||
|
|
||||||
// Vertex 2
|
// Vertex 2
|
||||||
"lqc2 vf1, 0x0(%15) \n\t" // load vert
|
"lqc2 $vf1, 0x0(%15) \n\t" // load vert
|
||||||
"lqc2 vf2, 0x0(%16) \n\t" // load normal
|
"lqc2 $vf2, 0x0(%16) \n\t" // load normal
|
||||||
"lqc2 vf3, 0x0(%17) \n\t" // load st
|
"lqc2 $vf3, 0x0(%17) \n\t" // load st
|
||||||
"vadd.w vf1, vf20, vf21 \n\t" // set vert.w to 1.0F
|
"vadd.w $vf1, $vf20, $vf21 \n\t" // set vert.w to 1.0F
|
||||||
"vadd.w vf2, vf20, vf21 \n\t" // set normal.W to 1.0F
|
"vadd.w $vf2, $vf20, $vf21 \n\t" // set normal.W to 1.0F
|
||||||
"vadd.zw vf3, vf20, vf21 \n\t" // set st.zw to 1.0F
|
"vadd.zw $vf3, $vf20, $vf21 \n\t" // set st.zw to 1.0F
|
||||||
"sqc2 vf1, 0x0(%12) \n\t" // store vert
|
"sqc2 $vf1, 0x0(%12) \n\t" // store vert
|
||||||
"sqc2 vf2, 0x0(%13) \n\t" // store normal
|
"sqc2 $vf2, 0x0(%13) \n\t" // store normal
|
||||||
"sqc2 vf3, 0x0(%14) \n\t" // store st
|
"sqc2 $vf3, 0x0(%14) \n\t" // store st
|
||||||
|
|
||||||
:
|
:
|
||||||
: "r"(o_vertices[addedFaces]),
|
: "r"(o_vertices[addedFaces]),
|
||||||
@@ -375,16 +368,6 @@ u8 Mesh::isInFrustum(Plane *t_frustumPlanes)
|
|||||||
return boxResult;
|
return boxResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Set's default object color + no transparency */
|
|
||||||
void Mesh::setDefaultColor()
|
|
||||||
{
|
|
||||||
color.r = 0x80;
|
|
||||||
color.g = 0x80;
|
|
||||||
color.b = 0x80;
|
|
||||||
color.a = 0x80;
|
|
||||||
color.q = 1.0F;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Sets texture level of details settings and CLUT settings */
|
/** Sets texture level of details settings and CLUT settings */
|
||||||
void Mesh::setDefaultLODAndClut()
|
void Mesh::setDefaultLODAndClut()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
#include "../include/models/mesh_frame.hpp"
|
#include "../include/models/mesh_frame.hpp"
|
||||||
#include "../include/utils/debug.hpp"
|
#include "../include/utils/debug.hpp"
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@
|
|||||||
|
|
||||||
MeshFrame::MeshFrame()
|
MeshFrame::MeshFrame()
|
||||||
{
|
{
|
||||||
|
id = rand() % 1000000;
|
||||||
vertexCount = 0;
|
vertexCount = 0;
|
||||||
stsCount = 0;
|
stsCount = 0;
|
||||||
normalsCount = 0;
|
normalsCount = 0;
|
||||||
@@ -25,9 +27,12 @@ MeshFrame::MeshFrame()
|
|||||||
_areVerticesAllocated = false;
|
_areVerticesAllocated = false;
|
||||||
_areNormalsAllocated = false;
|
_areNormalsAllocated = false;
|
||||||
_areMaterialsAllocated = false;
|
_areMaterialsAllocated = false;
|
||||||
|
_isMother = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshFrame::~MeshFrame()
|
MeshFrame::~MeshFrame()
|
||||||
|
{
|
||||||
|
if (_isMother)
|
||||||
{
|
{
|
||||||
if (_areSTsAllocated)
|
if (_areSTsAllocated)
|
||||||
delete[] sts;
|
delete[] sts;
|
||||||
@@ -35,9 +40,10 @@ MeshFrame::~MeshFrame()
|
|||||||
delete[] vertices;
|
delete[] vertices;
|
||||||
if (_areNormalsAllocated)
|
if (_areNormalsAllocated)
|
||||||
delete[] normals;
|
delete[] normals;
|
||||||
|
delete boundingBoxObj;
|
||||||
|
}
|
||||||
if (_areMaterialsAllocated)
|
if (_areMaterialsAllocated)
|
||||||
delete[] materials;
|
delete[] materials;
|
||||||
delete boundingBoxObj;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
@@ -46,11 +52,7 @@ MeshFrame::~MeshFrame()
|
|||||||
|
|
||||||
void MeshFrame::allocateSTs(const u32 &t_val)
|
void MeshFrame::allocateSTs(const u32 &t_val)
|
||||||
{
|
{
|
||||||
if (_areSTsAllocated)
|
assertMsg(!_areSTsAllocated, "Can't allocate STs, because were already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't allocate STs, because were already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
stsCount = t_val;
|
stsCount = t_val;
|
||||||
sts = new Point[t_val];
|
sts = new Point[t_val];
|
||||||
_areSTsAllocated = true;
|
_areSTsAllocated = true;
|
||||||
@@ -58,11 +60,7 @@ void MeshFrame::allocateSTs(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshFrame::allocateVertices(const u32 &t_val)
|
void MeshFrame::allocateVertices(const u32 &t_val)
|
||||||
{
|
{
|
||||||
if (_areVerticesAllocated)
|
assertMsg(!_areVerticesAllocated, "Can't allocate vertices, because were already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't allocate vertices, because were already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
vertexCount = t_val;
|
vertexCount = t_val;
|
||||||
vertices = new Vector3[t_val];
|
vertices = new Vector3[t_val];
|
||||||
_areVerticesAllocated = true;
|
_areVerticesAllocated = true;
|
||||||
@@ -70,11 +68,7 @@ void MeshFrame::allocateVertices(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshFrame::allocateNormals(const u32 &t_val)
|
void MeshFrame::allocateNormals(const u32 &t_val)
|
||||||
{
|
{
|
||||||
if (_areNormalsAllocated)
|
assertMsg(!_areNormalsAllocated, "Can't allocate normals, because were already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't allocate normals, because were already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
normalsCount = t_val;
|
normalsCount = t_val;
|
||||||
normals = new Vector3[t_val];
|
normals = new Vector3[t_val];
|
||||||
_areNormalsAllocated = true;
|
_areNormalsAllocated = true;
|
||||||
@@ -82,11 +76,7 @@ void MeshFrame::allocateNormals(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshFrame::allocateMaterials(const u32 &t_val)
|
void MeshFrame::allocateMaterials(const u32 &t_val)
|
||||||
{
|
{
|
||||||
if (_areMaterialsAllocated)
|
assertMsg(!_areMaterialsAllocated, "Can't allocate materials, because were already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't allocate materials, because were already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
materialsCount = t_val;
|
materialsCount = t_val;
|
||||||
materials = new MeshMaterial[t_val];
|
materials = new MeshMaterial[t_val];
|
||||||
_areMaterialsAllocated = true;
|
_areMaterialsAllocated = true;
|
||||||
@@ -94,14 +84,10 @@ void MeshFrame::allocateMaterials(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshFrame::calculateBoundingBoxes()
|
void MeshFrame::calculateBoundingBoxes()
|
||||||
{
|
{
|
||||||
Vector3 boundingBox[8];
|
assertMsg(_areVerticesAllocated, "Can't calculate bounding box, because vertices were not allocated!");
|
||||||
if (!_areVerticesAllocated)
|
|
||||||
{
|
|
||||||
PRINT_ERR("Can't calculate bounding box, because vertices were not allocated!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (u32 i = 0; i < materialsCount; i++)
|
for (u32 i = 0; i < materialsCount; i++)
|
||||||
materials->calculateBoundingBox(vertices, vertexCount);
|
materials->calculateBoundingBox(vertices, vertexCount);
|
||||||
|
|
||||||
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
||||||
lowX = hiX = vertices[0].x;
|
lowX = hiX = vertices[0].x;
|
||||||
lowY = hiY = vertices[0].y;
|
lowY = hiY = vertices[0].y;
|
||||||
@@ -124,6 +110,7 @@ void MeshFrame::calculateBoundingBoxes()
|
|||||||
hiZ = vertices[i].z;
|
hiZ = vertices[i].z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 boundingBox[8];
|
||||||
boundingBox[0].set(lowX, lowY, lowZ);
|
boundingBox[0].set(lowX, lowY, lowZ);
|
||||||
boundingBox[1].set(lowX, lowY, hiZ);
|
boundingBox[1].set(lowX, lowY, hiZ);
|
||||||
boundingBox[2].set(lowX, hiY, lowZ);
|
boundingBox[2].set(lowX, hiY, lowZ);
|
||||||
@@ -139,3 +126,26 @@ void MeshFrame::calculateBoundingBoxes()
|
|||||||
// constructor instantiated BoundingBox objects.
|
// constructor instantiated BoundingBox objects.
|
||||||
boundingBoxObj = new BoundingBox(boundingBox);
|
boundingBoxObj = new BoundingBox(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshFrame::copyFrom(MeshFrame *t_refCopy)
|
||||||
|
{
|
||||||
|
vertexCount = t_refCopy->vertexCount;
|
||||||
|
stsCount = t_refCopy->stsCount;
|
||||||
|
normalsCount = t_refCopy->normalsCount;
|
||||||
|
materialsCount = t_refCopy->materialsCount;
|
||||||
|
materials = new MeshMaterial[materialsCount];
|
||||||
|
for (u32 i = 0; i < materialsCount; i++)
|
||||||
|
materials[i].copyFrom(&t_refCopy->materials[i]);
|
||||||
|
_areSTsAllocated = true;
|
||||||
|
_areVerticesAllocated = true;
|
||||||
|
_areNormalsAllocated = true;
|
||||||
|
_areMaterialsAllocated = true;
|
||||||
|
vertices = t_refCopy->vertices;
|
||||||
|
sts = t_refCopy->sts;
|
||||||
|
normals = t_refCopy->normals;
|
||||||
|
|
||||||
|
boundingBoxObj = t_refCopy->boundingBoxObj;
|
||||||
|
_isBoundingBoxCalculated = true;
|
||||||
|
|
||||||
|
_isMother = false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -25,9 +25,15 @@ MeshMaterial::MeshMaterial()
|
|||||||
_isNameSet = false;
|
_isNameSet = false;
|
||||||
_areFacesAllocated = false;
|
_areFacesAllocated = false;
|
||||||
_isBoundingBoxCalculated = false;
|
_isBoundingBoxCalculated = false;
|
||||||
|
_areSTsPresent = false;
|
||||||
|
_areNormalsPresent = false;
|
||||||
|
_isMother = true;
|
||||||
|
setDefaultColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
MeshMaterial::~MeshMaterial()
|
MeshMaterial::~MeshMaterial()
|
||||||
|
{
|
||||||
|
if (_isMother)
|
||||||
{
|
{
|
||||||
if (_areFacesAllocated)
|
if (_areFacesAllocated)
|
||||||
{
|
{
|
||||||
@@ -38,6 +44,7 @@ MeshMaterial::~MeshMaterial()
|
|||||||
if (_isNameSet)
|
if (_isNameSet)
|
||||||
delete[] name;
|
delete[] name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Methods
|
// Methods
|
||||||
@@ -45,11 +52,7 @@ MeshMaterial::~MeshMaterial()
|
|||||||
|
|
||||||
void MeshMaterial::allocateFaces(const u32 &t_val)
|
void MeshMaterial::allocateFaces(const u32 &t_val)
|
||||||
{
|
{
|
||||||
if (_areFacesAllocated)
|
assertMsg(!_areFacesAllocated, "Can't allocate faces, because were already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't allocate faces, because were already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
facesCount = t_val;
|
facesCount = t_val;
|
||||||
stFaces = new u32[t_val];
|
stFaces = new u32[t_val];
|
||||||
normalFaces = new u32[t_val];
|
normalFaces = new u32[t_val];
|
||||||
@@ -59,11 +62,7 @@ void MeshMaterial::allocateFaces(const u32 &t_val)
|
|||||||
|
|
||||||
void MeshMaterial::setName(char *t_val)
|
void MeshMaterial::setName(char *t_val)
|
||||||
{
|
{
|
||||||
if (_isNameSet)
|
assertMsg(!_isNameSet, "Can't set name, because was already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't set name, because was already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
name = String::createCopy(t_val);
|
name = String::createCopy(t_val);
|
||||||
_isNameSet = true;
|
_isNameSet = true;
|
||||||
}
|
}
|
||||||
@@ -102,7 +101,6 @@ u8 MeshMaterial::isInFrustum(Plane *t_frustumPlanes, const Vector3 &position)
|
|||||||
|
|
||||||
void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
||||||
{
|
{
|
||||||
Vector3 boundingBox[8];
|
|
||||||
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
float lowX, lowY, lowZ, hiX, hiY, hiZ;
|
||||||
lowX = hiX = t_vertices[vertexFaces[0]].x;
|
lowX = hiX = t_vertices[vertexFaces[0]].x;
|
||||||
lowY = hiY = t_vertices[vertexFaces[0]].y;
|
lowY = hiY = t_vertices[vertexFaces[0]].y;
|
||||||
@@ -124,6 +122,8 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
|||||||
if (hiZ < t_vertices[vertexFaces[i]].z)
|
if (hiZ < t_vertices[vertexFaces[i]].z)
|
||||||
hiZ = t_vertices[vertexFaces[i]].z;
|
hiZ = t_vertices[vertexFaces[i]].z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 boundingBox[8];
|
||||||
boundingBox[0].set(lowX, lowY, lowZ);
|
boundingBox[0].set(lowX, lowY, lowZ);
|
||||||
boundingBox[1].set(lowX, lowY, hiZ);
|
boundingBox[1].set(lowX, lowY, hiZ);
|
||||||
boundingBox[2].set(lowX, hiY, lowZ);
|
boundingBox[2].set(lowX, hiY, lowZ);
|
||||||
@@ -139,3 +139,32 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
|
|||||||
// constructor instantiated BoundingBox objects.
|
// constructor instantiated BoundingBox objects.
|
||||||
boundingBoxObj = new BoundingBox(boundingBox);
|
boundingBoxObj = new BoundingBox(boundingBox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MeshMaterial::copyFrom(MeshMaterial *t_refCopy)
|
||||||
|
{
|
||||||
|
_isNameSet = true;
|
||||||
|
name = t_refCopy->name;
|
||||||
|
|
||||||
|
_isBoundingBoxCalculated = true;
|
||||||
|
boundingBoxObj = t_refCopy->boundingBoxObj;
|
||||||
|
|
||||||
|
vertexFaces = t_refCopy->vertexFaces;
|
||||||
|
stFaces = t_refCopy->stFaces;
|
||||||
|
normalFaces = t_refCopy->normalFaces;
|
||||||
|
facesCount = t_refCopy->facesCount;
|
||||||
|
_areSTsPresent = t_refCopy->_areSTsPresent;
|
||||||
|
_areNormalsPresent = t_refCopy->_areNormalsPresent;
|
||||||
|
_areFacesAllocated = true;
|
||||||
|
|
||||||
|
_isMother = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set's default object color + no transparency */
|
||||||
|
void MeshMaterial::setDefaultColor()
|
||||||
|
{
|
||||||
|
color.r = 0x80;
|
||||||
|
color.g = 0x80;
|
||||||
|
color.b = 0x80;
|
||||||
|
color.a = 0x80;
|
||||||
|
color.q = 1.0F;
|
||||||
|
}
|
||||||
|
|||||||
@@ -41,13 +41,8 @@ Texture::~Texture()
|
|||||||
|
|
||||||
void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
|
void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
|
||||||
{
|
{
|
||||||
if (_isSizeSet)
|
assertMsg(!_isSizeSet, "Can't set size, because was already set!");
|
||||||
{
|
assertMsg(t_width <= 256 && t_height <= 256, "Given texture can be too big for PS2. Please strict to 256x256 max. Prefer 128x128.");
|
||||||
PRINT_ERR("Can't set size, because was already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (t_width > 256 || t_height > 256)
|
|
||||||
PRINT_ERR("Given texture can be too big for PS2. Please strict to 256x256 max. Prefer 128x128.");
|
|
||||||
width = t_width;
|
width = t_width;
|
||||||
height = t_height;
|
height = t_height;
|
||||||
_type = t_type;
|
_type = t_type;
|
||||||
@@ -57,11 +52,7 @@ void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &
|
|||||||
|
|
||||||
void Texture::setName(char *t_val)
|
void Texture::setName(char *t_val)
|
||||||
{
|
{
|
||||||
if (_isNameSet)
|
assertMsg(!_isNameSet, "Can't set name, because was already set!");
|
||||||
{
|
|
||||||
PRINT_ERR("Can't set name, because was already set!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
name = String::createCopy(t_val);
|
name = String::createCopy(t_val);
|
||||||
_isNameSet = true;
|
_isNameSet = true;
|
||||||
}
|
}
|
||||||
@@ -82,18 +73,9 @@ void Texture::setWrapSettings(const WrapSettings t_horizontal, const WrapSetting
|
|||||||
wrapSettings.vertical = t_vertical;
|
wrapSettings.vertical = t_vertical;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Texture::addLink(const u32 &t_meshId, const u32 &t_materialId)
|
void Texture::addLink(const u32 &t_id)
|
||||||
{
|
{
|
||||||
TextureLink link;
|
TextureLink link;
|
||||||
link.materialId = t_materialId;
|
link.id = t_id;
|
||||||
link.meshOrSpriteId = t_meshId;
|
|
||||||
texLinks.push_back(link);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Texture::addLink(const u32 &t_spriteId)
|
|
||||||
{
|
|
||||||
TextureLink link;
|
|
||||||
link.materialId = 0;
|
|
||||||
link.meshOrSpriteId = t_spriteId;
|
|
||||||
texLinks.push_back(link);
|
texLinks.push_back(link);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,20 +52,15 @@ void Audio::loadSong(char *t_path)
|
|||||||
char *fullFilename = String::createConcatenated("host:", t_path);
|
char *fullFilename = String::createConcatenated("host:", t_path);
|
||||||
wav = fopen(fullFilename, "rb");
|
wav = fopen(fullFilename, "rb");
|
||||||
delete[] fullFilename;
|
delete[] fullFilename;
|
||||||
if (wav == NULL)
|
assertMsg(wav != NULL, "Failed to open wav file!");
|
||||||
PRINT_ERR("Failed to open wav file!");
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rewindSongToStart();
|
rewindSongToStart();
|
||||||
songLoaded = true;
|
songLoaded = true;
|
||||||
PRINT_LOG("Song loaded!");
|
consoleLog("Song loaded!");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Audio::playSong()
|
void Audio::playSong()
|
||||||
{
|
{
|
||||||
if (!songLoaded)
|
assertMsg(songLoaded, "Cant play song because was not loaded!");
|
||||||
PRINT_ERR("Cant play song because was not loaded!");
|
|
||||||
if (songFinished)
|
if (songFinished)
|
||||||
rewindSongToStart();
|
rewindSongToStart();
|
||||||
volume = realVolume;
|
volume = realVolume;
|
||||||
@@ -105,8 +100,7 @@ void Audio::removeSongListener(const u32 &t_id)
|
|||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (index == -1)
|
assertMsg(index != -1, "Cant remove listener because given id was not found!");
|
||||||
PRINT_ERR("Cant remove listener because given id was not found!");
|
|
||||||
delete songListeners[index];
|
delete songListeners[index];
|
||||||
songListeners.erase(songListeners.begin() + index);
|
songListeners.erase(songListeners.begin() + index);
|
||||||
}
|
}
|
||||||
@@ -132,7 +126,7 @@ audsrv_adpcm_t *Audio::loadADPCM(char *t_path)
|
|||||||
if (audsrv_load_adpcm(result, data, adpcmFileSize))
|
if (audsrv_load_adpcm(result, data, adpcmFileSize))
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("audsrv_load_adpcm() failed!");
|
assertMsg(true == false, "audsrv_load_adpcm() failed!");
|
||||||
}
|
}
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return result;
|
return result;
|
||||||
@@ -143,7 +137,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm)
|
|||||||
if (audsrv_play_adpcm(t_adpcm))
|
if (audsrv_play_adpcm(t_adpcm))
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("audsrv_play_adpcm() failed!");
|
assertMsg(true == false, "audsrv_play_adpcm() failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,7 +146,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm, const s8 &t_ch)
|
|||||||
if (audsrv_ch_play_adpcm(t_ch, t_adpcm))
|
if (audsrv_ch_play_adpcm(t_ch, t_adpcm))
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("audsrv_play_adpcm() failed!");
|
assertMsg(true == false, "audsrv_ch_play_adpcm() failed!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +154,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm, const s8 &t_ch)
|
|||||||
|
|
||||||
void Audio::startThread(FileService *t_fileService)
|
void Audio::startThread(FileService *t_fileService)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating audio thread");
|
consoleLog("Creating audio thread");
|
||||||
// fileService = t_fileService;
|
// fileService = t_fileService;
|
||||||
extern void *_gp;
|
extern void *_gp;
|
||||||
thread.func = (void *)Audio::mainThread;
|
thread.func = (void *)Audio::mainThread;
|
||||||
@@ -168,16 +162,30 @@ void Audio::startThread(FileService *t_fileService)
|
|||||||
thread.stack_size = getThreadStackSize();
|
thread.stack_size = getThreadStackSize();
|
||||||
thread.gp_reg = (void *)&_gp;
|
thread.gp_reg = (void *)&_gp;
|
||||||
thread.initial_priority = 0x17;
|
thread.initial_priority = 0x17;
|
||||||
if ((threadId = CreateThread(&thread)) < 0)
|
threadId = CreateThread(&thread);
|
||||||
PRINT_ERR("Create audio thread failed!");
|
assertMsg(threadId >= 0, "Create audio thread failed!");
|
||||||
PRINT_LOG("Audio thread created");
|
consoleLog("Audio thread created");
|
||||||
StartThread(threadId, NULL);
|
StartThread(threadId, NULL);
|
||||||
PRINT_LOG("Audio thread started");
|
consoleLog("Audio thread started");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main thread loop */
|
/** Main thread loop */
|
||||||
void Audio::threadLoop()
|
void Audio::threadLoop()
|
||||||
{
|
{
|
||||||
|
// ---
|
||||||
|
// TODO - bug here, GCC11 is doing some optimizations and this method probably think that
|
||||||
|
// "songPlaying" is false + on real PS2 I see that program tries to turn on this
|
||||||
|
// method as rarely as possible (slow, flickering sound). On GCC 3.2.3 this one was fine lol!.
|
||||||
|
if (songPlaying) // HACK1 - im not proud of that
|
||||||
|
songPlaying = 1;
|
||||||
|
if (songLoaded)
|
||||||
|
songLoaded = 1;
|
||||||
|
if (hack == 1) // HACK2 - lets give some work to gcc lol
|
||||||
|
hack = 2;
|
||||||
|
else
|
||||||
|
hack = 1;
|
||||||
|
// ---
|
||||||
|
|
||||||
if (!songPlaying || !songLoaded)
|
if (!songPlaying || !songLoaded)
|
||||||
return;
|
return;
|
||||||
if (songFinished)
|
if (songFinished)
|
||||||
@@ -242,25 +250,23 @@ void Audio::rewindSongToStart()
|
|||||||
/** Initialize semaphore which will wait until chunk of the song is not finished. */
|
/** Initialize semaphore which will wait until chunk of the song is not finished. */
|
||||||
void Audio::initSema()
|
void Audio::initSema()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating audio semaphore");
|
consoleLog("Creating audio semaphore");
|
||||||
sema.init_count = 0;
|
sema.init_count = 0;
|
||||||
sema.max_count = 1;
|
sema.max_count = 1;
|
||||||
sema.option = 0;
|
sema.option = 0;
|
||||||
fillbufferSema = CreateSema(&sema);
|
fillbufferSema = CreateSema(&sema);
|
||||||
PRINT_LOG("Audio semaphore created");
|
consoleLog("Audio semaphore created");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Load LIBSD and AUDSRV modules */
|
/** Load LIBSD and AUDSRV modules */
|
||||||
void Audio::loadModules()
|
void Audio::loadModules()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Modules loading started (LIBSD, AUDSRV)");
|
consoleLog("Modules loading started (LIBSD, AUDSRV)");
|
||||||
int ret = SifLoadModule("rom0:LIBSD", 0, NULL);
|
int ret = SifLoadModule("rom0:LIBSD", 0, NULL);
|
||||||
if (ret == -203)
|
assertMsg(ret != -203, "LIBSD loading failed!");
|
||||||
PRINT_ERR("LIBSD loading failed!");
|
|
||||||
ret = SifLoadModule("host:AUDSRV.IRX", 0, NULL);
|
ret = SifLoadModule("host:AUDSRV.IRX", 0, NULL);
|
||||||
if (ret == -203)
|
assertMsg(ret != -203, "AUDSRV.IRX loading failed!");
|
||||||
PRINT_ERR("AUDSRV.IRX loading failed!");
|
consoleLog("Audio modules loaded");
|
||||||
PRINT_LOG("Audio modules loaded");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -269,26 +275,26 @@ void Audio::loadModules()
|
|||||||
*/
|
*/
|
||||||
void Audio::initAUDSRV()
|
void Audio::initAUDSRV()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing AUDSRV");
|
consoleLog("Initializing AUDSRV");
|
||||||
int ret = audsrv_init();
|
int ret = audsrv_init();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("Failed to initialize AUDSRV!");
|
assertMsg(true == false, "Failed to initialize AUDSRV!");
|
||||||
}
|
}
|
||||||
ret = audsrv_adpcm_init();
|
ret = audsrv_adpcm_init();
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("Failed to initialize AUDSRV ADPCM!");
|
assertMsg(true == false, "Failed to initialize AUDSRV ADPCM!");
|
||||||
}
|
}
|
||||||
ret = audsrv_on_fillbuf(getSongBufferSize(), (audsrv_callback_t)iSignalSema, (void *)fillbufferSema);
|
ret = audsrv_on_fillbuf(getSongBufferSize(), (audsrv_callback_t)iSignalSema, (void *)fillbufferSema);
|
||||||
if (ret != 0)
|
if (ret != 0)
|
||||||
{
|
{
|
||||||
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
printf("AUDSRV returned error string: %s", audsrv_get_error_string());
|
||||||
PRINT_ERR("Failed to initialize AUDSRV fillbuffer!");
|
assertMsg(true == false, "Failed to initialize AUDSRV fillbuffer!");
|
||||||
}
|
}
|
||||||
PRINT_LOG("AUDSRV initialized!");
|
consoleLog("AUDSRV initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
|
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
|
||||||
: screen(t_screen)
|
: screen(t_screen)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing frustum");
|
consoleLog("Initializing frustum");
|
||||||
farPlaneDist = screen->farPlaneDist;
|
farPlaneDist = screen->farPlaneDist;
|
||||||
nearPlaneDist = screen->nearPlaneDist;
|
nearPlaneDist = screen->nearPlaneDist;
|
||||||
float tang = tanf(screen->fov * Math::HALF_ANG2RAD);
|
float tang = tanf(screen->fov * Math::HALF_ANG2RAD);
|
||||||
@@ -31,7 +31,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
|
|||||||
farWidth = farHeight * screen->aspectRatio;
|
farWidth = farHeight * screen->aspectRatio;
|
||||||
p_position = t_position;
|
p_position = t_position;
|
||||||
up.set(0.0F, 1.0F, 0.0F);
|
up.set(0.0F, 1.0F, 0.0F);
|
||||||
PRINT_LOG("CameraBase initialized!");
|
consoleLog("CameraBase initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ u32 FileService::addReadChunk(FILE *t_file, void *t_destination, const u32 &t_si
|
|||||||
s32 FileService::isTaskDone(const u32 &t_taskId)
|
s32 FileService::isTaskDone(const u32 &t_taskId)
|
||||||
{
|
{
|
||||||
s32 taskIndex = getIndexOf(t_taskId);
|
s32 taskIndex = getIndexOf(t_taskId);
|
||||||
if (taskIndex == -1)
|
assertMsg(taskIndex != -1, "Task was not found!");
|
||||||
PRINT_ERR("Task was not found!");
|
|
||||||
s32 result = tasks[taskIndex].readStatus;
|
s32 result = tasks[taskIndex].readStatus;
|
||||||
if (result != -2137)
|
if (result != -2137)
|
||||||
removeByIndex(taskIndex);
|
removeByIndex(taskIndex);
|
||||||
@@ -54,10 +53,8 @@ s32 FileService::isTaskDone(const u32 &t_taskId)
|
|||||||
const void FileService::removeById(const u32 &t_taskId)
|
const void FileService::removeById(const u32 &t_taskId)
|
||||||
{
|
{
|
||||||
s32 index = getIndexOf(t_taskId);
|
s32 index = getIndexOf(t_taskId);
|
||||||
if (index != -1)
|
assertMsg(index != -1, "Cant remove task, because it was not found!");
|
||||||
removeByIndex(index);
|
removeByIndex(index);
|
||||||
else
|
|
||||||
PRINT_ERR("Cant remove task, because it was not found!");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const s32 FileService::getIndexOf(const u32 &t_taskId)
|
const s32 FileService::getIndexOf(const u32 &t_taskId)
|
||||||
@@ -72,18 +69,18 @@ const s32 FileService::getIndexOf(const u32 &t_taskId)
|
|||||||
|
|
||||||
void FileService::startThread()
|
void FileService::startThread()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating file service thread");
|
consoleLog("Creating file service thread");
|
||||||
extern void *_gp;
|
extern void *_gp;
|
||||||
thread.func = (void *)FileService::mainThread;
|
thread.func = (void *)FileService::mainThread;
|
||||||
thread.stack = threadStack;
|
thread.stack = threadStack;
|
||||||
thread.stack_size = getThreadStackSize();
|
thread.stack_size = getThreadStackSize();
|
||||||
thread.gp_reg = (void *)&_gp;
|
thread.gp_reg = (void *)&_gp;
|
||||||
thread.initial_priority = 0x12;
|
thread.initial_priority = 0x12;
|
||||||
if ((threadId = CreateThread(&thread)) < 0)
|
threadId = CreateThread(&thread);
|
||||||
PRINT_ERR("Create audio thread failed!");
|
assertMsg(threadId >= 0, "Create audio thread failed!");
|
||||||
PRINT_LOG("File service created");
|
consoleLog("File service created");
|
||||||
StartThread(threadId, NULL);
|
StartThread(threadId, NULL);
|
||||||
PRINT_LOG("File service started");
|
consoleLog("File service started");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main thread loop */
|
/** Main thread loop */
|
||||||
|
|||||||
@@ -30,12 +30,12 @@
|
|||||||
*/
|
*/
|
||||||
GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen, Light *t_light) : screen(t_screen)
|
GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen, Light *t_light) : screen(t_screen)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing GifSender");
|
consoleLog("Initializing GifSender");
|
||||||
light = t_light;
|
light = t_light;
|
||||||
packetSize = t_packetSize;
|
packetSize = t_packetSize;
|
||||||
packets[0] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
packets[0] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
||||||
packets[1] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
packets[1] = packet2_create(t_packetSize, P2_TYPE_NORMAL, P2_MODE_CHAIN, false);
|
||||||
PRINT_LOG("GifSender initialized!");
|
consoleLog("GifSender initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Releases packets memory */
|
/** Releases packets memory */
|
||||||
@@ -131,16 +131,16 @@ void GifSender::addClear(zbuffer_t *t_zBuffer, color_t *t_rgb)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Adds meshes to current packet */
|
/** Adds meshes to current packet */
|
||||||
void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer, color_t *t_color)
|
||||||
{
|
{
|
||||||
packet2_chain_open_cnt(currentPacket, 0, 0, 0);
|
packet2_chain_open_cnt(currentPacket, 0, 0, 0);
|
||||||
packet2_update(currentPacket, draw_texture_sampling(currentPacket->next, 0, &t_mesh.lod));
|
packet2_update(currentPacket, draw_texture_sampling(currentPacket->next, 0, &t_mesh.lod));
|
||||||
packet2_update(currentPacket, draw_texturebuffer(currentPacket->next, 0, textureBuffer, &t_mesh.clut));
|
packet2_update(currentPacket, draw_texturebuffer(currentPacket->next, 0, textureBuffer, &t_mesh.clut));
|
||||||
packet2_update(currentPacket, draw_prim_start(currentPacket->next, 0, t_renderData->prim, &t_mesh.color));
|
packet2_update(currentPacket, draw_prim_start(currentPacket->next, 0, t_renderData->prim, t_color));
|
||||||
xyz = new xyz_t[vertexCount];
|
xyz = new xyz_t[vertexCount];
|
||||||
rgbaq = new color_t[vertexCount];
|
rgbaq = new color_t[vertexCount];
|
||||||
st = new texel_t[vertexCount];
|
st = new texel_t[vertexCount];
|
||||||
calc3DObject(*t_renderData->projection, t_mesh, vertexCount, vertices, normals, coordinates, t_renderData, t_bulbs, t_bulbsCount);
|
calc3DObject(*t_renderData->projection, t_mesh, vertexCount, vertices, normals, coordinates, t_renderData, t_bulbs, t_bulbsCount, t_color);
|
||||||
addCurrentCalcs(vertexCount);
|
addCurrentCalcs(vertexCount);
|
||||||
delete[] xyz;
|
delete[] xyz;
|
||||||
delete[] rgbaq;
|
delete[] rgbaq;
|
||||||
@@ -152,7 +152,7 @@ void GifSender::addObject(RenderData *t_renderData, Mesh &t_mesh, u32 vertexCoun
|
|||||||
/** Calculates 3D object data into xyz, rgbq, st
|
/** Calculates 3D object data into xyz, rgbq, st
|
||||||
* After it addCurrentCalcs() can be done
|
* After it addCurrentCalcs() can be done
|
||||||
*/
|
*/
|
||||||
void GifSender::calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount)
|
void GifSender::calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, RenderData *t_renderData, LightBulb *t_bulbs, u16 t_bulbsCount, color_t *t_color)
|
||||||
{
|
{
|
||||||
VECTOR *colors = new VECTOR[vertexCount];
|
VECTOR *colors = new VECTOR[vertexCount];
|
||||||
VECTOR position, rotation;
|
VECTOR position, rotation;
|
||||||
@@ -187,9 +187,9 @@ void GifSender::calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount
|
|||||||
for (u32 i = 0; i < vertexCount; i++)
|
for (u32 i = 0; i < vertexCount; i++)
|
||||||
{
|
{
|
||||||
// Apply the light value to the colour.
|
// Apply the light value to the colour.
|
||||||
colors[i][0] = (t_mesh.color.r * lights[i][0]);
|
colors[i][0] = (t_color->r * lights[i][0]);
|
||||||
colors[i][1] = (t_mesh.color.g * lights[i][1]);
|
colors[i][1] = (t_color->g * lights[i][1]);
|
||||||
colors[i][2] = (t_mesh.color.b * lights[i][2]);
|
colors[i][2] = (t_color->b * lights[i][2]);
|
||||||
vector_clamp(colors[i], colors[i], 0.00F, 1.99F);
|
vector_clamp(colors[i], colors[i], 0.00F, 1.99F);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -201,14 +201,14 @@ void GifSender::calc3DObject(Matrix t_perspective, Mesh &t_mesh, u32 vertexCount
|
|||||||
else
|
else
|
||||||
for (u32 i = 0; i < vertexCount; i++)
|
for (u32 i = 0; i < vertexCount; i++)
|
||||||
{
|
{
|
||||||
colors[i][0] = t_mesh.color.r / 128.0F;
|
colors[i][0] = t_color->r / 128.0F;
|
||||||
colors[i][1] = t_mesh.color.g / 128.0F;
|
colors[i][1] = t_color->g / 128.0F;
|
||||||
colors[i][2] = t_mesh.color.b / 128.0F;
|
colors[i][2] = t_color->b / 128.0F;
|
||||||
}
|
}
|
||||||
|
|
||||||
calculate_vertices(vertices, vertexCount, vertices, localScreen);
|
calculate_vertices(vertices, vertexCount, vertices, localScreen);
|
||||||
|
|
||||||
convertCalcs(vertexCount, vertices, colors, coordinates, t_mesh.color);
|
convertCalcs(vertexCount, vertices, colors, coordinates, *t_color);
|
||||||
|
|
||||||
delete[] colors;
|
delete[] colors;
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-33
@@ -30,15 +30,10 @@ Pad::Pad()
|
|||||||
this->slot = 0; // Always zero if not using multitap
|
this->slot = 0; // Always zero if not using multitap
|
||||||
if ((this->ret = padPortOpen(this->port, this->slot, padBuf)) == 0)
|
if ((this->ret = padPortOpen(this->port, this->slot, padBuf)) == 0)
|
||||||
{
|
{
|
||||||
PRINT_ERR("padPortOpen failed!");
|
|
||||||
printf("padPortOpen returned: %d\n", this->ret);
|
printf("padPortOpen returned: %d\n", this->ret);
|
||||||
SleepThread();
|
assertMsg(true == false, "padPortOpen failed!");
|
||||||
}
|
|
||||||
if (!this->initPad())
|
|
||||||
{
|
|
||||||
PRINT_ERR("initPad failed!");
|
|
||||||
SleepThread();
|
|
||||||
}
|
}
|
||||||
|
assertMsg(this->initPad(), "initPad failed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Pad::~Pad() {}
|
Pad::~Pad() {}
|
||||||
@@ -50,22 +45,20 @@ Pad::~Pad() {}
|
|||||||
/** Load SIO2MAN and PADMAN modules */
|
/** Load SIO2MAN and PADMAN modules */
|
||||||
void Pad::loadModules()
|
void Pad::loadModules()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Loading pad modules");
|
consoleLog("Loading pad modules");
|
||||||
this->ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
this->ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
|
||||||
if (this->ret < 0)
|
if (this->ret < 0)
|
||||||
{
|
{
|
||||||
PRINT_ERR("SifLoadModule (SIO2MAN) failed!");
|
|
||||||
printf("SifLoadModule returned: %d\n", this->ret);
|
printf("SifLoadModule returned: %d\n", this->ret);
|
||||||
SleepThread();
|
assertMsg(true == false, "SifLoadModule (SIO2MAN) failed!");
|
||||||
}
|
}
|
||||||
this->ret = SifLoadModule("rom0:PADMAN", 0, NULL);
|
this->ret = SifLoadModule("rom0:PADMAN", 0, NULL);
|
||||||
if (this->ret < 0)
|
if (this->ret < 0)
|
||||||
{
|
{
|
||||||
PRINT_ERR("SifLoadModule (PADMAN) failed!");
|
|
||||||
printf("SifLoadModule returned: %d\n", this->ret);
|
printf("SifLoadModule returned: %d\n", this->ret);
|
||||||
SleepThread();
|
assertMsg(true == false, "SifLoadModule (PADMAN) failed!");
|
||||||
}
|
}
|
||||||
PRINT_LOG("Pad modules loaded!");
|
consoleLog("Pad modules loaded!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Wait when pad will be ready (stable and ready) */
|
/** Wait when pad will be ready (stable and ready) */
|
||||||
@@ -81,7 +74,7 @@ int Pad::waitPadReady()
|
|||||||
if (state != lastState)
|
if (state != lastState)
|
||||||
{
|
{
|
||||||
padStateInt2String(state, stateString);
|
padStateInt2String(state, stateString);
|
||||||
PRINT_LOG("Pad state changed");
|
consoleLog("Pad state changed");
|
||||||
printf("Curent pad(%d,%d) status: %s\n", this->port, this->slot, stateString);
|
printf("Curent pad(%d,%d) status: %s\n", this->port, this->slot, stateString);
|
||||||
}
|
}
|
||||||
lastState = state;
|
lastState = state;
|
||||||
@@ -89,23 +82,20 @@ int Pad::waitPadReady()
|
|||||||
}
|
}
|
||||||
// Were the pad ever 'out of sync'?
|
// Were the pad ever 'out of sync'?
|
||||||
if (lastState != -1)
|
if (lastState != -1)
|
||||||
PRINT_LOG("Pad is ready!");
|
consoleLog("Pad is ready!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes and checks type of pad */
|
/** Initializes and checks type of pad */
|
||||||
int Pad::initPad()
|
int Pad::initPad()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing pad");
|
consoleLog("Initializing pad");
|
||||||
this->waitPadReady();
|
this->waitPadReady();
|
||||||
// How many different modes can this device operate in?
|
// How many different modes can this device operate in?
|
||||||
// i.e. get # entrys in the modetable
|
// i.e. get # entrys in the modetable
|
||||||
int modes = padInfoMode(this->port, this->slot, PAD_MODETABLE, -1);
|
int modes = padInfoMode(this->port, this->slot, PAD_MODETABLE, -1);
|
||||||
if (modes == 0)
|
assertMsg(modes, "Connected device is not a dual shock controller!"); // (it has no actuator engines)
|
||||||
{
|
|
||||||
PRINT_ERR("Connected device is not a dual shock controller!"); // (it has no actuator engines)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Verify that the controller has a DUAL SHOCK mode
|
// Verify that the controller has a DUAL SHOCK mode
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do
|
do
|
||||||
@@ -115,22 +105,14 @@ int Pad::initPad()
|
|||||||
i++;
|
i++;
|
||||||
} while (i < modes);
|
} while (i < modes);
|
||||||
|
|
||||||
if (i >= modes)
|
assertMsg(i < modes, "Connected device is not a dual shock controller!");
|
||||||
{
|
|
||||||
PRINT_ERR("Connected device is not a dual shock controller!");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If ExId != 0x0 => This controller has actuator engines
|
// If ExId != 0x0 => This controller has actuator engines
|
||||||
// This check should always pass if the Dual Shock test above passed
|
// This check should always pass if the Dual Shock test above passed
|
||||||
this->ret = padInfoMode(this->port, this->slot, PAD_MODECUREXID, 0);
|
this->ret = padInfoMode(this->port, this->slot, PAD_MODECUREXID, 0);
|
||||||
if (this->ret == 0)
|
assertMsg(this->ret, "Connected device is not a dual shock controller!");
|
||||||
{
|
|
||||||
PRINT_ERR("Connected device is not a dual shock controller!");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRINT_LOG("Enabling dual shock functions.");
|
consoleLog("Enabling dual shock functions.");
|
||||||
|
|
||||||
// When using MMODE_LOCK, user cant change mode with Select button
|
// When using MMODE_LOCK, user cant change mode with Select button
|
||||||
padSetMainMode(this->port, this->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);
|
padSetMainMode(this->port, this->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);
|
||||||
@@ -156,7 +138,7 @@ int Pad::initPad()
|
|||||||
else
|
else
|
||||||
printf("Did not find any actuators.\n");
|
printf("Did not find any actuators.\n");
|
||||||
this->waitPadReady();
|
this->waitPadReady();
|
||||||
PRINT_LOG("Pad initialized!");
|
consoleLog("Pad initialized!");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ static const float SCREEN_CENTER = GS_CENTER / 2.0F;
|
|||||||
*/
|
*/
|
||||||
Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
|
Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing renderer");
|
consoleLog("Initializing renderer");
|
||||||
dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0); // Initialize DMA to enable data transfer
|
dma_channel_initialize(DMA_CHANNEL_GIF, NULL, 0); // Initialize DMA to enable data transfer
|
||||||
dma_channel_fast_waits(DMA_CHANNEL_GIF);
|
dma_channel_fast_waits(DMA_CHANNEL_GIF);
|
||||||
screen = t_screen;
|
screen = t_screen;
|
||||||
@@ -53,7 +53,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
|
|||||||
vifSender = new VifSender(&light);
|
vifSender = new VifSender(&light);
|
||||||
perspective.setPerspective(*t_screen);
|
perspective.setPerspective(*t_screen);
|
||||||
renderData.projection = &perspective;
|
renderData.projection = &perspective;
|
||||||
PRINT_LOG("Renderer initialized!");
|
consoleLog("Renderer initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Renderer::~Renderer() {}
|
Renderer::~Renderer() {}
|
||||||
@@ -69,8 +69,7 @@ void Renderer::allocateTextureBuffer(Texture *t_texture)
|
|||||||
textureBuffer.psm = t_texture->getType();
|
textureBuffer.psm = t_texture->getType();
|
||||||
textureBuffer.info.components = textureBuffer.psm == TEX_TYPE_RGBA ? TEXTURE_COMPONENTS_RGBA : TEXTURE_COMPONENTS_RGB;
|
textureBuffer.info.components = textureBuffer.psm == TEX_TYPE_RGBA ? TEXTURE_COMPONENTS_RGBA : TEXTURE_COMPONENTS_RGB;
|
||||||
textureBuffer.address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), textureBuffer.psm, GRAPH_ALIGN_BLOCK);
|
textureBuffer.address = graph_vram_allocate(t_texture->getWidth(), t_texture->getHeight(), textureBuffer.psm, GRAPH_ALIGN_BLOCK);
|
||||||
if (textureBuffer.address <= 1)
|
assertMsg(textureBuffer.address > 1, "Texture buffer allocation error. No memory!");
|
||||||
PRINT_ERR("Texture buffer allocation error. No memory!");
|
|
||||||
textureBuffer.info.width = draw_log2(t_texture->getWidth());
|
textureBuffer.info.width = draw_log2(t_texture->getWidth());
|
||||||
textureBuffer.info.height = draw_log2(t_texture->getHeight());
|
textureBuffer.info.height = draw_log2(t_texture->getHeight());
|
||||||
textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE;
|
textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE;
|
||||||
@@ -89,8 +88,7 @@ void Renderer::deallocateTextureBuffer()
|
|||||||
|
|
||||||
void Renderer::changeTexture(Texture *t_tex)
|
void Renderer::changeTexture(Texture *t_tex)
|
||||||
{
|
{
|
||||||
if (t_tex != NULL)
|
assertMsg(t_tex != NULL, "Texture was not found in texture repository!");
|
||||||
{
|
|
||||||
if (t_tex->getId() != lastTextureId)
|
if (t_tex->getId() != lastTextureId)
|
||||||
{
|
{
|
||||||
lastTextureId = t_tex->getId();
|
lastTextureId = t_tex->getId();
|
||||||
@@ -99,13 +97,10 @@ void Renderer::changeTexture(Texture *t_tex)
|
|||||||
GifSender::sendTexture(*t_tex, &textureBuffer);
|
GifSender::sendTexture(*t_tex, &textureBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
PRINT_ERR("Texture was not found in texture repository!");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Renderer::draw(Sprite &t_sprite)
|
void Renderer::draw(Sprite &t_sprite)
|
||||||
{
|
{
|
||||||
Texture *texture = textureRepo.getBySprite(t_sprite.getId());
|
Texture *texture = textureRepo.getBySpriteOrMesh(t_sprite.getId());
|
||||||
texrect_t rect;
|
texrect_t rect;
|
||||||
float sizeX, sizeY;
|
float sizeX, sizeY;
|
||||||
if (t_sprite.getMode() == MODE_REPEAT)
|
if (t_sprite.getMode() == MODE_REPEAT)
|
||||||
@@ -164,7 +159,7 @@ void Renderer::draw(Sprite &t_sprite)
|
|||||||
/** Initializes drawing environment (1st app packet) */
|
/** Initializes drawing environment (1st app packet) */
|
||||||
void Renderer::initDrawingEnv()
|
void Renderer::initDrawingEnv()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing drawing environment");
|
consoleLog("Initializing drawing environment");
|
||||||
packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0);
|
packet2_t *packet2 = packet2_create(20, P2_TYPE_NORMAL, P2_MODE_NORMAL, 0);
|
||||||
packet2_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer)));
|
packet2_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer)));
|
||||||
packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0,
|
packet2_update(packet2, draw_primitive_xyoffset(packet2->next, 0,
|
||||||
@@ -174,7 +169,7 @@ void Renderer::initDrawingEnv()
|
|||||||
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
|
dma_channel_send_packet2(packet2, DMA_CHANNEL_GIF, true);
|
||||||
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
dma_channel_wait(DMA_CHANNEL_GIF, 0);
|
||||||
packet2_free(packet2);
|
packet2_free(packet2);
|
||||||
PRINT_LOG("Drawing environment initialized!");
|
consoleLog("Drawing environment initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Sets drawing prim for all 3D objects */
|
/** Sets drawing prim for all 3D objects */
|
||||||
@@ -189,7 +184,7 @@ void Renderer::setPrim()
|
|||||||
prim.mapping_type = PRIM_MAP_ST;
|
prim.mapping_type = PRIM_MAP_ST;
|
||||||
prim.colorfix = PRIM_UNFIXED;
|
prim.colorfix = PRIM_UNFIXED;
|
||||||
renderData.prim = &prim;
|
renderData.prim = &prim;
|
||||||
PRINT_LOG("Prim set!");
|
consoleLog("Prim set!");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Renderer::setWorldColor(const color_t &t_rgb)
|
void Renderer::setWorldColor(const color_t &t_rgb)
|
||||||
@@ -219,7 +214,7 @@ void Renderer::allocateBuffers(int t_screenW, int t_screenH)
|
|||||||
zBuffer.method = ZTEST_METHOD_GREATER_EQUAL;
|
zBuffer.method = ZTEST_METHOD_GREATER_EQUAL;
|
||||||
zBuffer.zsm = GS_ZBUF_24;
|
zBuffer.zsm = GS_ZBUF_24;
|
||||||
zBuffer.address = graph_vram_allocate(t_screenW, t_screenH, zBuffer.zsm, GRAPH_ALIGN_PAGE);
|
zBuffer.address = graph_vram_allocate(t_screenW, t_screenH, zBuffer.zsm, GRAPH_ALIGN_PAGE);
|
||||||
PRINT_LOG("Framebuffers, zBuffer set and allocated!");
|
consoleLog("Framebuffers, zBuffer set and allocated!");
|
||||||
|
|
||||||
// Initialize the screen and tie the first framebuffer to the read circuits.
|
// Initialize the screen and tie the first framebuffer to the read circuits.
|
||||||
graph_initialize(frameBuffers[0].address, frameBuffers[0].width, frameBuffers[0].height, frameBuffers[0].psm, 0, 0);
|
graph_initialize(frameBuffers[0].address, frameBuffers[0].width, frameBuffers[0].height, frameBuffers[0].psm, 0, 0);
|
||||||
@@ -227,51 +222,55 @@ void Renderer::allocateBuffers(int t_screenW, int t_screenH)
|
|||||||
|
|
||||||
/// --- Draw: PATH3
|
/// --- Draw: PATH3
|
||||||
|
|
||||||
void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
// Obsolete
|
||||||
{
|
// void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||||
for (u16 i = 0; i < t_amount; i++)
|
// {
|
||||||
drawByPath3(t_meshes[i], t_bulbs, t_bulbsCount);
|
// for (u16 i = 0; i < t_amount; i++)
|
||||||
}
|
// drawByPath3(t_meshes[i], t_bulbs, t_bulbsCount);
|
||||||
|
// }
|
||||||
|
|
||||||
void Renderer::drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
// Obsolete
|
||||||
{
|
// void Renderer::drawByPath3(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||||
beginFrameIfNeeded();
|
// {
|
||||||
if (!t_mesh.isDataLoaded())
|
// beginFrameIfNeeded();
|
||||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
// if (!t_mesh.isDataLoaded())
|
||||||
if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
|
// PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
||||||
t_mesh.animate();
|
// if (t_mesh.getCurrentAnimationFrame() != t_mesh.getNextAnimationFrame())
|
||||||
for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
// t_mesh.animate();
|
||||||
{
|
// for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
||||||
if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
// {
|
||||||
return;
|
// MeshMaterial *material = &t_mesh.getMaterial(i);
|
||||||
Texture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId());
|
// if (t_mesh.shouldBeFrustumCulled && !material->isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
||||||
changeTexture(tex);
|
// return;
|
||||||
gifSender->initPacket(context);
|
// Texture *tex = textureRepo.getBySpriteOrMesh(material->getId());
|
||||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
// changeTexture(tex);
|
||||||
VECTOR *vertices = new VECTOR[vertCount];
|
// gifSender->initPacket(context);
|
||||||
VECTOR *normals = new VECTOR[vertCount];
|
// u32 vertCount = material->getFacesCount();
|
||||||
VECTOR *coordinates = new VECTOR[vertCount];
|
// VECTOR *vertices = new VECTOR[vertCount];
|
||||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
// VECTOR *normals = new VECTOR[vertCount];
|
||||||
gifSender->addObject(&renderData, t_mesh, vertCount, vertices, normals, coordinates, t_bulbs, t_bulbsCount, &textureBuffer);
|
// VECTOR *coordinates = new VECTOR[vertCount];
|
||||||
gifSender->sendPacket();
|
// vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, *renderData.cameraPosition);
|
||||||
delete[] vertices;
|
// gifSender->addObject(&renderData, t_mesh, vertCount, vertices, normals, coordinates, t_bulbs, t_bulbsCount, &textureBuffer, &material->color);
|
||||||
delete[] normals;
|
// gifSender->sendPacket();
|
||||||
delete[] coordinates;
|
// delete[] vertices;
|
||||||
}
|
// delete[] normals;
|
||||||
}
|
// delete[] coordinates;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount) { drawByPath3(t_meshes, t_amount, NULL, 0); }
|
// Obsolete
|
||||||
|
// void Renderer::drawByPath3(Mesh *t_meshes, u16 t_amount) { drawByPath3(t_meshes, t_amount, NULL, 0); }
|
||||||
|
|
||||||
void Renderer::drawByPath3(Mesh &t_mesh) { drawByPath3(t_mesh, NULL, 0); }
|
// Obsolete
|
||||||
|
// void Renderer::drawByPath3(Mesh &t_mesh) { drawByPath3(t_mesh, NULL, 0); }
|
||||||
|
|
||||||
/// --- Draw: PATH1
|
/// --- Draw: PATH1
|
||||||
|
|
||||||
void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
|
||||||
{
|
{
|
||||||
beginFrameIfNeeded();
|
beginFrameIfNeeded();
|
||||||
if (!t_meshes[0]->isDataLoaded())
|
assertMsg(t_meshes[0]->isDataLoaded(), "Can't draw, because no mesh data was loaded!");
|
||||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
if (
|
||||||
else if (
|
|
||||||
t_amount >= 3 &&
|
t_amount >= 3 &&
|
||||||
!t_meshes[0]->shouldBeBackfaceCulled &&
|
!t_meshes[0]->shouldBeBackfaceCulled &&
|
||||||
t_meshes[0]->getFramesCount() == 1 &&
|
t_meshes[0]->getFramesCount() == 1 &&
|
||||||
@@ -304,9 +303,7 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
|||||||
{
|
{
|
||||||
beginFrameIfNeeded();
|
beginFrameIfNeeded();
|
||||||
vifSender->calcMatrix(renderData, t_mesh.position, t_mesh.rotation);
|
vifSender->calcMatrix(renderData, t_mesh.position, t_mesh.rotation);
|
||||||
if (!t_mesh.isDataLoaded())
|
assertMsg(t_mesh.isDataLoaded(), "Can't draw, because no mesh data was loaded!");
|
||||||
PRINT_ERR("Can't draw, because no mesh data was loaded!");
|
|
||||||
|
|
||||||
camRotation.identity();
|
camRotation.identity();
|
||||||
camRotation.rotate(-t_mesh.rotation);
|
camRotation.rotate(-t_mesh.rotation);
|
||||||
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
|
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
|
||||||
@@ -315,16 +312,17 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
|
|||||||
t_mesh.animate();
|
t_mesh.animate();
|
||||||
for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
for (u32 i = 0; i < t_mesh.getMaterialsCount(); i++)
|
||||||
{
|
{
|
||||||
if (t_mesh.shouldBeFrustumCulled && !t_mesh.getMaterial(i).isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
MeshMaterial *material = &t_mesh.getMaterial(i);
|
||||||
|
if (t_mesh.shouldBeFrustumCulled && !material->isInFrustum(renderData.frustumPlanes, t_mesh.position))
|
||||||
return;
|
return;
|
||||||
u32 vertCount = t_mesh.getMaterial(i).getFacesCount();
|
u32 vertCount = material->getFacesCount();
|
||||||
VECTOR vertices[vertCount] __attribute__((aligned(16)));
|
VECTOR vertices[vertCount] __attribute__((aligned(16)));
|
||||||
VECTOR normals[vertCount] __attribute__((aligned(16)));
|
VECTOR normals[vertCount] __attribute__((aligned(16)));
|
||||||
VECTOR coordinates[vertCount] __attribute__((aligned(16)));
|
VECTOR coordinates[vertCount] __attribute__((aligned(16)));
|
||||||
Texture *tex = textureRepo.getByMesh(t_mesh.getId(), t_mesh.getMaterial(i).getId());
|
Texture *tex = textureRepo.getBySpriteOrMesh(material->getId());
|
||||||
changeTexture(tex);
|
changeTexture(tex);
|
||||||
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera);
|
vertCount = t_mesh.getDrawData(i, vertices, normals, coordinates, rotatedCamera);
|
||||||
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer);
|
vifSender->drawMesh(&renderData, perspective, vertCount, vertices, normals, coordinates, t_mesh, t_bulbs, t_bulbsCount, &textureBuffer, &material->color, !material->areSTsPresent());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
|
|
||||||
TextureRepository::TextureRepository()
|
TextureRepository::TextureRepository()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing texture repository");
|
consoleLog("Initializing texture repository");
|
||||||
PRINT_LOG("Texture repository initialized!");
|
consoleLog("Texture repository initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
TextureRepository::~TextureRepository()
|
TextureRepository::~TextureRepository()
|
||||||
@@ -57,7 +57,7 @@ void TextureRepository::addByMesh(char *t_path, Mesh &mesh, TextureFormat t_form
|
|||||||
else
|
else
|
||||||
pngLoader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".png");
|
pngLoader.load(*texture, t_path, mesh.getMaterial(i).getName(), ".png");
|
||||||
texture->setName(mesh.getMaterial(i).getName());
|
texture->setName(mesh.getMaterial(i).getName());
|
||||||
texture->addLink(mesh.getId(), mesh.getMaterial(i).getId());
|
texture->addLink(mesh.getMaterial(i).getId());
|
||||||
textures.push_back(texture);
|
textures.push_back(texture);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ extern u32 VU1Draw3D_CodeEnd __attribute__((section(".vudata")));
|
|||||||
|
|
||||||
VifSender::VifSender(Light *t_light)
|
VifSender::VifSender(Light *t_light)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing VifSender");
|
consoleLog("Initializing VifSender");
|
||||||
light = t_light;
|
light = t_light;
|
||||||
lastVertCount = 0;
|
lastVertCount = 0;
|
||||||
isDrawWaitEnabled = true;
|
isDrawWaitEnabled = true;
|
||||||
@@ -44,7 +44,7 @@ VifSender::VifSender(Light *t_light)
|
|||||||
packets[1] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
packets[1] = packet2_create(VU1_PACKET_SIZE, P2_TYPE_NORMAL, P2_MODE_CHAIN, true);
|
||||||
context = 0;
|
context = 0;
|
||||||
setDoubleBufferAddStaticData();
|
setDoubleBufferAddStaticData();
|
||||||
PRINT_LOG("VifSender initialized!");
|
consoleLog("VifSender initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
VifSender::~VifSender()
|
VifSender::~VifSender()
|
||||||
@@ -83,7 +83,7 @@ void VifSender::calcMatrix(const RenderData &t_renderData, const Vector3 &t_posi
|
|||||||
modelViewProj = *t_renderData.projection * modelViewProj;
|
modelViewProj = *t_renderData.projection * modelViewProj;
|
||||||
}
|
}
|
||||||
|
|
||||||
void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer)
|
void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 vertCount2, VECTOR *vertices, VECTOR *normals, VECTOR *coordinates, Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount, texbuffer_t *textureBuffer, color_t *t_color, u8 t_rgbaOnly)
|
||||||
{
|
{
|
||||||
// we have to split 3D object into small parts, because of small memory of VU1
|
// we have to split 3D object into small parts, because of small memory of VU1
|
||||||
|
|
||||||
@@ -97,7 +97,7 @@ void VifSender::drawMesh(RenderData *t_renderData, Matrix t_perspective, u32 ver
|
|||||||
i -= 3;
|
i -= 3;
|
||||||
|
|
||||||
const u32 endI = i + (VU1_PACKAGE_VERTS_PER_BUFF - 1) > vertCount2 ? vertCount2 : i + (VU1_PACKAGE_VERTS_PER_BUFF - 1);
|
const u32 endI = i + (VU1_PACKAGE_VERTS_PER_BUFF - 1) > vertCount2 ? vertCount2 : i + (VU1_PACKAGE_VERTS_PER_BUFF - 1);
|
||||||
drawVertices(t_mesh, i, endI, vertices, coordinates, t_renderData->prim, textureBuffer, isDrawWaitEnabled ? endI == vertCount2 : false);
|
drawVertices(t_mesh, i, endI, vertices, coordinates, t_renderData->prim, textureBuffer, isDrawWaitEnabled ? endI == vertCount2 : false, t_color, t_rgbaOnly);
|
||||||
if (endI == vertCount2) // if there are no more vertices to draw, break
|
if (endI == vertCount2) // if there are no more vertices to draw, break
|
||||||
{
|
{
|
||||||
i = vertCount2;
|
i = vertCount2;
|
||||||
@@ -130,28 +130,34 @@ void VifSender::setDoubleBufferAddStaticData()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Draw using PATH1 */
|
/** Draw using PATH1 */
|
||||||
void VifSender::drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *t_texBuff, u8 t_addDrawWait)
|
void VifSender::drawVertices(Mesh &t_mesh, u32 t_start, u32 t_end, VECTOR *t_vertices, VECTOR *t_coordinates, prim_t *t_prim, texbuffer_t *t_texBuff, u8 t_addDrawWait, color_t *t_color, u8 t_rgbaOnly)
|
||||||
{
|
{
|
||||||
const u32 vertCount = t_end - t_start;
|
const u32 vertCount = t_end - t_start;
|
||||||
lastVertCount = vertCount;
|
lastVertCount = vertCount;
|
||||||
|
isLastRGBAOnly = t_rgbaOnly;
|
||||||
packet2_utils_vu_open_unpack(currPacket, 0, true);
|
packet2_utils_vu_open_unpack(currPacket, 0, true);
|
||||||
packet2_add_data(currPacket, modelViewProj.data, 4);
|
packet2_add_data(currPacket, modelViewProj.data, 4);
|
||||||
packet2_add_u32(currPacket, t_addDrawWait); // Draw finish?
|
packet2_add_u32(currPacket, t_addDrawWait); // Draw finish?
|
||||||
packet2_add_u32(currPacket, vertCount); // Vertex count
|
packet2_add_u32(currPacket, vertCount); // Vertex count
|
||||||
packet2_add_u32(currPacket, vertCount / 3); // Triangles count
|
packet2_add_u32(currPacket, vertCount / 3); // Triangles count
|
||||||
packet2_add_u32(currPacket, 0); // Free
|
packet2_add_u32(currPacket, t_rgbaOnly); // 0 = STQ+RGBA, 1 = RGBA
|
||||||
packet2_utils_gs_add_lod(currPacket, &t_mesh.lod);
|
packet2_utils_gs_add_lod(currPacket, &t_mesh.lod);
|
||||||
packet2_utils_gs_add_texbuff_clut(currPacket, t_texBuff, &t_mesh.clut);
|
packet2_utils_gs_add_texbuff_clut(currPacket, t_texBuff, &t_mesh.clut);
|
||||||
|
if (t_rgbaOnly)
|
||||||
|
packet2_utils_gs_add_prim_giftag(currPacket, t_prim, vertCount, DRAW_RGBAQ_REGLIST, 2, 0);
|
||||||
|
else
|
||||||
packet2_utils_gs_add_prim_giftag(currPacket, t_prim, vertCount, DRAW_STQ2_REGLIST, 3, 0);
|
packet2_utils_gs_add_prim_giftag(currPacket, t_prim, vertCount, DRAW_STQ2_REGLIST, 3, 0);
|
||||||
packet2_add_u32(currPacket, t_mesh.color.r);
|
packet2_add_u32(currPacket, t_color->r);
|
||||||
packet2_add_u32(currPacket, t_mesh.color.g);
|
packet2_add_u32(currPacket, t_color->g);
|
||||||
packet2_add_u32(currPacket, t_mesh.color.b);
|
packet2_add_u32(currPacket, t_color->b);
|
||||||
packet2_add_u32(currPacket, t_mesh.color.a);
|
packet2_add_u32(currPacket, t_color->a);
|
||||||
u32 vif_added_bytes = packet2_utils_vu_close_unpack(currPacket);
|
u32 vif_added_bytes = packet2_utils_vu_close_unpack(currPacket);
|
||||||
packet2_utils_vu_add_unpack_data(currPacket, vif_added_bytes, t_vertices + t_start, vertCount, true);
|
packet2_utils_vu_add_unpack_data(currPacket, vif_added_bytes, t_vertices + t_start, vertCount, true);
|
||||||
|
if (!t_rgbaOnly)
|
||||||
|
{
|
||||||
vif_added_bytes += vertCount;
|
vif_added_bytes += vertCount;
|
||||||
packet2_utils_vu_add_unpack_data(currPacket, vif_added_bytes, t_coordinates + t_start, vertCount, true);
|
packet2_utils_vu_add_unpack_data(currPacket, vif_added_bytes, t_coordinates + t_start, vertCount, true);
|
||||||
vif_added_bytes += vertCount;
|
}
|
||||||
packet2_utils_vu_add_start_program(currPacket, 0);
|
packet2_utils_vu_add_start_program(currPacket, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,10 +189,10 @@ void VifSender::drawTheSameWithOtherMatrices(const RenderData &t_renderData, Mes
|
|||||||
packet2_utils_vu_close_unpack(currMPacket);
|
packet2_utils_vu_close_unpack(currMPacket);
|
||||||
packet2_utils_vu_open_unpack(currMPacket, VU1_RGBA_ADDRESS, true);
|
packet2_utils_vu_open_unpack(currMPacket, VU1_RGBA_ADDRESS, true);
|
||||||
{
|
{
|
||||||
packet2_add_u32(currMPacket, t_meshes[i]->color.r);
|
packet2_add_u32(currMPacket, t_meshes[i]->getMaterial(0).color.r);
|
||||||
packet2_add_u32(currMPacket, t_meshes[i]->color.g);
|
packet2_add_u32(currMPacket, t_meshes[i]->getMaterial(0).color.g);
|
||||||
packet2_add_u32(currMPacket, t_meshes[i]->color.b);
|
packet2_add_u32(currMPacket, t_meshes[i]->getMaterial(0).color.b);
|
||||||
packet2_add_u32(currMPacket, t_meshes[i]->color.a);
|
packet2_add_u32(currMPacket, t_meshes[i]->getMaterial(0).color.a);
|
||||||
}
|
}
|
||||||
packet2_utils_vu_close_unpack(currMPacket);
|
packet2_utils_vu_close_unpack(currMPacket);
|
||||||
|
|
||||||
@@ -203,7 +209,7 @@ void VifSender::drawTheSameWithOtherMatrices(const RenderData &t_renderData, Mes
|
|||||||
packet2_add_u32(currMPacket, true); // Draw wait finish?
|
packet2_add_u32(currMPacket, true); // Draw wait finish?
|
||||||
packet2_add_u32(currMPacket, lastVertCount); // Vertex count
|
packet2_add_u32(currMPacket, lastVertCount); // Vertex count
|
||||||
packet2_add_u32(currMPacket, lastVertCount / 3); // Triangles count
|
packet2_add_u32(currMPacket, lastVertCount / 3); // Triangles count
|
||||||
packet2_add_u32(currMPacket, 0); // Free
|
packet2_add_u32(currMPacket, isLastRGBAOnly); // 0 = STQ+RGBA, 1 = RGBA
|
||||||
}
|
}
|
||||||
packet2_utils_vu_close_unpack(currMPacket);
|
packet2_utils_vu_close_unpack(currMPacket);
|
||||||
packet2_utils_vu_add_start_program(currMPacket, 0); // and start program
|
packet2_utils_vu_add_start_program(currMPacket, 0); // and start program
|
||||||
@@ -231,7 +237,7 @@ void VifSender::drawTheSameWithOtherMatrices(const RenderData &t_renderData, Mes
|
|||||||
packet2_add_u32(currMPacket, true); // Draw wait finish?
|
packet2_add_u32(currMPacket, true); // Draw wait finish?
|
||||||
packet2_add_u32(currMPacket, lastVertCount); // Vertex count
|
packet2_add_u32(currMPacket, lastVertCount); // Vertex count
|
||||||
packet2_add_u32(currMPacket, lastVertCount / 3); // Triangles count
|
packet2_add_u32(currMPacket, lastVertCount / 3); // Triangles count
|
||||||
packet2_add_u32(currMPacket, 0); // Free
|
packet2_add_u32(currMPacket, isLastRGBAOnly); // 0 = STQ+RGBA, 1 = RGBA
|
||||||
}
|
}
|
||||||
packet2_utils_vu_close_unpack(currMPacket);
|
packet2_utils_vu_close_unpack(currMPacket);
|
||||||
packet2_utils_vu_add_start_program(currMPacket, 0);
|
packet2_utils_vu_add_start_program(currMPacket, 0);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
#include "../include/utils/math.hpp"
|
#include "../include/utils/math.hpp"
|
||||||
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <fastmath.h>
|
|
||||||
|
|
||||||
float Math::cos(float x)
|
float Math::cos(float x)
|
||||||
{
|
{
|
||||||
@@ -72,16 +71,6 @@ float Math::cos(float x)
|
|||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
float Math::sqrt(float x)
|
|
||||||
{
|
|
||||||
float r;
|
|
||||||
__asm__ volatile(
|
|
||||||
"sqrt.s %0, %1 \n\t"
|
|
||||||
: "=&f"(r)
|
|
||||||
: "f"(x));
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
float Math::invSqrt(float x) { return 1.0F / sqrt(x); }
|
float Math::invSqrt(float x) { return 1.0F / sqrt(x); }
|
||||||
|
|
||||||
/** Converts Vector3 to PS2SDK's Vector4 */
|
/** Converts Vector3 to PS2SDK's Vector4 */
|
||||||
|
|||||||
@@ -11,8 +11,9 @@
|
|||||||
#include "../include/utils/string.hpp"
|
#include "../include/utils/string.hpp"
|
||||||
#include "../include/utils/debug.hpp"
|
#include "../include/utils/debug.hpp"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#define CHAR_BIT 8
|
||||||
|
|
||||||
char *String::createU32ToString(u32 a)
|
char *String::createU32ToString(const u32 a)
|
||||||
{
|
{
|
||||||
char *result = new char[(((sizeof a) * CHAR_BIT) + 2) / 3 + 2];
|
char *result = new char[(((sizeof a) * CHAR_BIT) + 2) / 3 + 2];
|
||||||
sprintf(result, "%d", a);
|
sprintf(result, "%d", a);
|
||||||
@@ -20,7 +21,7 @@ char *String::createU32ToString(u32 a)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Converts "123" to "000123". 6 digits length */
|
/** Converts "123" to "000123". 6 digits length */
|
||||||
char *String::createWithLeadingZeros(char *a)
|
char *String::createWithLeadingZeros(const char *a)
|
||||||
{
|
{
|
||||||
const u8 digitsAmount = 6;
|
const u8 digitsAmount = 6;
|
||||||
char *part = createConcatenated("00000000", a);
|
char *part = createConcatenated("00000000", a);
|
||||||
@@ -34,7 +35,7 @@ char *String::createWithLeadingZeros(char *a)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createWithoutExtension(char *source)
|
char *String::createWithoutExtension(const char *source)
|
||||||
{
|
{
|
||||||
u32 length = 0;
|
u32 length = 0;
|
||||||
for (;; length++)
|
for (;; length++)
|
||||||
@@ -47,7 +48,7 @@ char *String::createWithoutExtension(char *source)
|
|||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createCopy(char *source)
|
char *String::createCopy(const char *source)
|
||||||
{
|
{
|
||||||
u32 srcLength = getLength(source);
|
u32 srcLength = getLength(source);
|
||||||
char *res = new char[srcLength + 1];
|
char *res = new char[srcLength + 1];
|
||||||
@@ -58,7 +59,7 @@ char *String::createCopy(char *source)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For test\0 will return 4
|
// For test\0 will return 4
|
||||||
u32 String::getLength(char *a)
|
u32 String::getLength(const char *a)
|
||||||
{
|
{
|
||||||
if (a == NULL)
|
if (a == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
@@ -67,7 +68,7 @@ u32 String::getLength(char *a)
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *String::createConcatenated(char *a, char *b)
|
char *String::createConcatenated(const char *a, const char *b)
|
||||||
{
|
{
|
||||||
u32 aLength = getLength(a);
|
u32 aLength = getLength(a);
|
||||||
u32 bLength = getLength(b);
|
u32 bLength = getLength(b);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
; TODO
|
; TODO
|
||||||
; - Add dynamic lighting (feature)
|
; - Add dynamic lighting (feature)
|
||||||
; - Add --cont + MSCNT instead of alltime MSCAL
|
; - Add --cont + MSCNT instead of alltime MSCAL
|
||||||
|
; - Split this program into two (RBA/STQ), so we can get better performance
|
||||||
|
|
||||||
#include "/repos/tyra/src/engine/vu1_progs/geometry.inc"
|
#include "/repos/tyra/src/engine/vu1_progs/geometry.inc"
|
||||||
#include "/repos/tyra/src/engine/vu1_progs/matrix.inc"
|
#include "/repos/tyra/src/engine/vu1_progs/matrix.inc"
|
||||||
@@ -51,6 +52,7 @@ MatrixLoad{ matrix, 0, double_buffer }
|
|||||||
ilw.x do_draw_finish, 4(double_buffer) ; Add draw finish tag? (sync)
|
ilw.x do_draw_finish, 4(double_buffer) ; Add draw finish tag? (sync)
|
||||||
ilw.y vertex_count, 4(double_buffer) ; Vertex count
|
ilw.y vertex_count, 4(double_buffer) ; Vertex count
|
||||||
ilw.z triangles_count, 4(double_buffer) ; Triangles count
|
ilw.z triangles_count, 4(double_buffer) ; Triangles count
|
||||||
|
ilw.w rgba_only, 4(double_buffer) ; RGBA (1) or STQ+RGBA (0)
|
||||||
lq tex_gif_tag_1, 5(double_buffer) ; GIF tag - texture LOD
|
lq tex_gif_tag_1, 5(double_buffer) ; GIF tag - texture LOD
|
||||||
lq tex_gif_tag_2, 6(double_buffer) ; GIF tag - texture buffer & CLUT
|
lq tex_gif_tag_2, 6(double_buffer) ; GIF tag - texture buffer & CLUT
|
||||||
lq prim_tag, 7(double_buffer) ; GIF tag - tell GS how many data we will send
|
lq prim_tag, 7(double_buffer) ; GIF tag - tell GS how many data we will send
|
||||||
@@ -70,10 +72,10 @@ sqi gif_set_tag, (dest_address++) ;
|
|||||||
sqi tex_gif_tag_1, (dest_address++) ; texture LOD tag
|
sqi tex_gif_tag_1, (dest_address++) ; texture LOD tag
|
||||||
sqi gif_set_tag, (dest_address++) ;
|
sqi gif_set_tag, (dest_address++) ;
|
||||||
sqi tex_gif_tag_2, (dest_address++) ; texture buffer & CLUT tag
|
sqi tex_gif_tag_2, (dest_address++) ; texture buffer & CLUT tag
|
||||||
iblez do_draw_finish, kick
|
iblez do_draw_finish, prim_tag_l
|
||||||
sqi gif_set_tag, (dest_address++) ;
|
sqi gif_set_tag, (dest_address++) ;
|
||||||
sqi gif_draw_finish_tag, (dest_address++) ; do draw_finish is needed
|
sqi gif_draw_finish_tag, (dest_address++) ; do draw_finish is needed
|
||||||
kick:
|
prim_tag_l:
|
||||||
sqi prim_tag, (dest_address++) ; prim + tell gs how many data will be
|
sqi prim_tag, (dest_address++) ; prim + tell gs how many data will be
|
||||||
;////////////////////////////////////////////
|
;////////////////////////////////////////////
|
||||||
|
|
||||||
@@ -87,52 +89,87 @@ iaddiu triangle_counter, vi00, 0 ; Reset counter
|
|||||||
triangle_loop: --LoopCS 1,3
|
triangle_loop: --LoopCS 1,3
|
||||||
|
|
||||||
;//////////////// VERTEX 1 //////////////////
|
;//////////////// VERTEX 1 //////////////////
|
||||||
|
vec1:
|
||||||
VectorLoad{ vertex, vertex_data, 0 }
|
VectorLoad{ vertex, vertex_data, 0 }
|
||||||
VectorLoad{ stq1, stq_data, 0 }
|
|
||||||
MatrixXForm{ xformed_vertex, matrix, vertex }
|
MatrixXForm{ xformed_vertex, matrix, vertex }
|
||||||
VectorClip{ gs_vertex, xformed_vertex }
|
VectorClip{ gs_vertex, xformed_vertex }
|
||||||
VectorPerspectiveDivide{ xformed_vertex }
|
VectorPerspectiveDivide{ xformed_vertex }
|
||||||
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
||||||
|
|
||||||
|
ibgtz rgba_only, vec_1_rgba
|
||||||
|
|
||||||
|
vec_1_stq_rgba:
|
||||||
|
VectorLoad{ stq1, stq_data, 0 }
|
||||||
VectorTexturePerspectiveCorrection{ pers_stq, stq1 }
|
VectorTexturePerspectiveCorrection{ pers_stq, stq1 }
|
||||||
VectorStore{ pers_stq, dest_address, 0 }
|
VectorStore{ pers_stq, dest_address, 0 }
|
||||||
VectorStore{ rgba, dest_address, 1 }
|
VectorStore{ rgba, dest_address, 1 }
|
||||||
VectorStore{ gs_vertex, dest_address, 2 }
|
VectorStore{ gs_vertex, dest_address, 2 }
|
||||||
|
ibeq vi00, vi00, vec2
|
||||||
|
|
||||||
|
vec_1_rgba:
|
||||||
|
VectorStore{ rgba, dest_address, 0 }
|
||||||
|
VectorStore{ gs_vertex, dest_address, 1 }
|
||||||
|
|
||||||
;////////////////////////////////////////////
|
;////////////////////////////////////////////
|
||||||
|
|
||||||
;//////////////// VERTEX 2 //////////////////
|
;//////////////// VERTEX 2 //////////////////
|
||||||
|
vec2:
|
||||||
VectorLoad{ vertex, vertex_data, 1 }
|
VectorLoad{ vertex, vertex_data, 1 }
|
||||||
VectorLoad{ stq2, stq_data, 1 }
|
|
||||||
MatrixXForm{ xformed_vertex, matrix, vertex }
|
MatrixXForm{ xformed_vertex, matrix, vertex }
|
||||||
VectorClip{ gs_vertex, xformed_vertex }
|
VectorClip{ gs_vertex, xformed_vertex }
|
||||||
VectorPerspectiveDivide{ xformed_vertex }
|
VectorPerspectiveDivide{ xformed_vertex }
|
||||||
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
||||||
|
|
||||||
|
ibgtz rgba_only, vec_2_rgba
|
||||||
|
|
||||||
|
vec_2_stq_rgba:
|
||||||
|
VectorLoad{ stq2, stq_data, 1 }
|
||||||
VectorTexturePerspectiveCorrection{ pers_stq, stq2 }
|
VectorTexturePerspectiveCorrection{ pers_stq, stq2 }
|
||||||
VectorStore{ pers_stq, dest_address, 3 }
|
VectorStore{ pers_stq, dest_address, 3 }
|
||||||
VectorStore{ rgba, dest_address, 4 }
|
VectorStore{ rgba, dest_address, 4 }
|
||||||
VectorStore{ gs_vertex, dest_address, 5 }
|
VectorStore{ gs_vertex, dest_address, 5 }
|
||||||
|
ibeq vi00, vi00, vec3
|
||||||
|
|
||||||
|
vec_2_rgba:
|
||||||
|
VectorStore{ rgba, dest_address, 2 }
|
||||||
|
VectorStore{ gs_vertex, dest_address, 3 }
|
||||||
|
|
||||||
;////////////////////////////////////////////
|
;////////////////////////////////////////////
|
||||||
|
|
||||||
;//////////////// VERTEX 3 //////////////////
|
;//////////////// VERTEX 3 //////////////////
|
||||||
|
vec3:
|
||||||
VectorLoad{ vertex, vertex_data, 2 }
|
VectorLoad{ vertex, vertex_data, 2 }
|
||||||
VectorLoad{ stq3, stq_data, 2 }
|
|
||||||
MatrixXForm{ xformed_vertex, matrix, vertex }
|
MatrixXForm{ xformed_vertex, matrix, vertex }
|
||||||
VectorClip{ gs_vertex, xformed_vertex }
|
VectorClip{ gs_vertex, xformed_vertex }
|
||||||
VectorPerspectiveDivide{ xformed_vertex }
|
VectorPerspectiveDivide{ xformed_vertex }
|
||||||
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
VectorAddGSScales{ gs_vertex, xformed_vertex, gs_scale }
|
||||||
VectorTexturePerspectiveCorrection{ pers_stq, stq3 }
|
|
||||||
VectorStore{ pers_stq, dest_address, 6 }
|
|
||||||
VectorStore{ rgba, dest_address, 7 }
|
|
||||||
|
|
||||||
fcand vi01, 0x03FFFF
|
fcand vi01, 0x03FFFF
|
||||||
iaddiu new_adc_bit, vi01, 0x7FFF
|
iaddiu new_adc_bit, vi01, 0x7FFF
|
||||||
mfir.w gs_vertex, new_adc_bit
|
mfir.w gs_vertex, new_adc_bit
|
||||||
|
|
||||||
|
ibgtz rgba_only, vec_3_rgba
|
||||||
|
|
||||||
|
vec_3_stq_rgba:
|
||||||
|
VectorLoad{ stq3, stq_data, 2 }
|
||||||
|
VectorTexturePerspectiveCorrection{ pers_stq, stq3 }
|
||||||
|
VectorStore{ pers_stq, dest_address, 6 }
|
||||||
|
VectorStore{ rgba, dest_address, 7 }
|
||||||
VectorStore{ gs_vertex, dest_address, 8 }
|
VectorStore{ gs_vertex, dest_address, 8 }
|
||||||
|
iaddiu dest_address, dest_address, 9 // Loop control
|
||||||
|
ibeq vi00, vi00, loop_ctrl
|
||||||
|
|
||||||
|
vec_3_rgba:
|
||||||
|
VectorStore{ rgba, dest_address, 4 }
|
||||||
|
VectorStore{ gs_vertex, dest_address, 5 }
|
||||||
|
iaddiu dest_address, dest_address, 6 // Loop control
|
||||||
|
|
||||||
;////////////////////////////////////////////
|
;////////////////////////////////////////////
|
||||||
|
|
||||||
;////////////// LOOP CONTROL ////////////////
|
;////////////// LOOP CONTROL ////////////////
|
||||||
|
loop_ctrl:
|
||||||
iaddiu vertex_data, vertex_data, 3
|
iaddiu vertex_data, vertex_data, 3
|
||||||
iaddiu stq_data, stq_data, 3
|
iaddiu stq_data, stq_data, 3
|
||||||
iaddiu dest_address, dest_address, 9
|
|
||||||
|
|
||||||
iaddiu triangle_counter, triangle_counter, 1 // Incrementing this
|
iaddiu triangle_counter, triangle_counter, 1 // Incrementing this
|
||||||
// by other value than 1 is causing HUGE problems, but.. why?
|
// by other value than 1 is causing HUGE problems, but.. why?
|
||||||
|
|||||||
+116
-154
@@ -3,10 +3,6 @@
|
|||||||
;-----VCL CODE------------
|
;-----VCL CODE------------
|
||||||
;-------------------------
|
;-------------------------
|
||||||
;-------------------------
|
;-------------------------
|
||||||
; === __LP__ EXPL_draw3D_vcl_triangle_loop__MAIN_LOOP:
|
|
||||||
; === hDown : optimal=30 clid=0 mlid=2 size=(31)
|
|
||||||
; === dUp : optimal=30 clid=0 mlid=2 size=(31)
|
|
||||||
; === another : optimal=30 clid=0 mlid=2 size=(31)
|
|
||||||
; =================================================
|
; =================================================
|
||||||
; flowMon::Emit() vcl 1.4beta7 produced this code:
|
; flowMon::Emit() vcl 1.4beta7 produced this code:
|
||||||
.vu
|
.vu
|
||||||
@@ -15,171 +11,137 @@
|
|||||||
.global VU1Draw3D_CodeEnd
|
.global VU1Draw3D_CodeEnd
|
||||||
VU1Draw3D_CodeStart:
|
VU1Draw3D_CodeStart:
|
||||||
__v_draw3D_vcl_4:
|
__v_draw3D_vcl_4:
|
||||||
; _LNOPT_w=[ normal2 ] 26 [26 0] 26 [__v_draw3D_vcl_4]
|
; _LNOPT_w=[ normal2 ] 27 [27 0] 27 [__v_draw3D_vcl_4]
|
||||||
NOP xtop VI05
|
NOP xtop VI06
|
||||||
NOP lq VF02,1(VI00)
|
NOP lq VF02,1(VI00)
|
||||||
NOP lq VF01,0(VI00)
|
NOP lq VF01,0(VI00)
|
||||||
NOP ilw.x VI01,4(VI05)
|
NOP ilw.x VI01,4(VI06)
|
||||||
NOP ilw.y VI07,4(VI05)
|
NOP ilw.y VI08,4(VI06)
|
||||||
NOP lq VF03,0(VI05)
|
NOP lq VF03,0(VI06)
|
||||||
NOP lq VF08,5(VI05)
|
NOP lq VF04,1(VI06)
|
||||||
NOP lq VF10,6(VI05)
|
NOP lq VF08,5(VI06)
|
||||||
NOP lq VF04,1(VI05)
|
NOP lq VF10,6(VI06)
|
||||||
NOP lq VF05,2(VI05)
|
NOP lq VF05,2(VI06)
|
||||||
NOP iaddiu VI03,VI05,0x00000009
|
NOP lq VF06,3(VI06)
|
||||||
NOP iadd VI04,VI03,VI07
|
NOP iaddiu VI04,VI06,0x00000009
|
||||||
NOP lq VF06,3(VI05)
|
NOP iadd VI05,VI04,VI08
|
||||||
NOP iadd VI06,VI04,VI07
|
NOP ilw.z VI02,4(VI06)
|
||||||
|
NOP iadd VI07,VI05,VI08
|
||||||
NOP loi 0x44fff000
|
NOP loi 0x44fff000
|
||||||
NOP ilw.z VI02,4(VI05)
|
NOP ilw.w VI03,4(VI06)
|
||||||
NOP lq VF07,7(VI05)
|
NOP lq VF07,7(VI06)
|
||||||
NOP sqi VF02,(VI06++)
|
NOP sqi VF02,(VI07++)
|
||||||
NOP sqi VF08,(VI06++)
|
NOP sqi VF08,(VI07++)
|
||||||
NOP sqi VF02,(VI06++)
|
NOP sqi VF02,(VI07++)
|
||||||
NOP lq VF08,8(VI05)
|
NOP lq VF08,8(VI06)
|
||||||
NOP iadd VI05,VI04,VI07
|
NOP iadd VI06,VI05,VI08
|
||||||
addi.xy VF09,VF00,I loi 0x492aaaaa
|
addi.xy VF09,VF00,I loi 0x492aaaaa
|
||||||
NOP fcset 0
|
NOP fcset 0
|
||||||
NOP iblez VI01,kick
|
NOP iblez VI01,prim_tag_l
|
||||||
addi.z VF09,VF00,I sqi VF10,(VI06++)
|
addi.z VF09,VF00,I sqi VF10,(VI07++)
|
||||||
; _LNOPT_w=[ normal2 ] 2 [2 0] 2 [__v_draw3D_vcl_5]
|
; _LNOPT_w=[ normal2 ] 2 [2 0] 2 [__v_draw3D_vcl_5]
|
||||||
NOP sqi VF02,(VI06++)
|
NOP sqi VF02,(VI07++)
|
||||||
NOP sqi VF01,(VI06++)
|
NOP sqi VF01,(VI07++)
|
||||||
kick:
|
prim_tag_l:
|
||||||
; _LNOPT_w=[ normal2 ] 27 [27 0] 32 [kick]
|
; _LNOPT_w=[ normal2 ] 4 [4 0] 4 [prim_tag_l]
|
||||||
NOP sqi VF07,(VI06++)
|
NOP iaddiu VI08,VI00,0x00007fff
|
||||||
NOP lq VF07,0(VI03)
|
NOP sqi VF07,(VI07++)
|
||||||
mulax ACC,VF03,VF07x lq VF14,1(VI03) ; STALL_LATENCY ?3
|
NOP iaddiu VI08,VI08,0x00000001
|
||||||
madday ACC,VF04,VF07y sq VF08,1(VI06)
|
NOP iaddiu VI09,VI00,0
|
||||||
maddaz ACC,VF05,VF07z sq VF08,7(VI06)
|
triangle_loop:
|
||||||
maddw VF11,VF06,VF07w NOP
|
; _LNOPT_w=[ normal2 ] 11 [27 0] 27 [triangle_loop]
|
||||||
mulax ACC,VF03,VF14x lq VF07,2(VI03)
|
NOP lq VF02,0(VI04)
|
||||||
madday ACC,VF04,VF14y NOP
|
mulax ACC,VF03,VF02x mfir.w VF01,VI08 ; STALL_LATENCY ?3
|
||||||
maddaz ACC,VF05,VF14z NOP
|
madday ACC,VF04,VF02y NOP
|
||||||
maddw VF14,VF06,VF14w div Q,VF00w,VF11w
|
maddaz ACC,VF05,VF02z NOP
|
||||||
mulax ACC,VF03,VF07x NOP
|
maddw VF02,VF06,VF02w NOP
|
||||||
madday ACC,VF04,VF07y iaddiu VI07,VI00,0x00007fff
|
clipw.xyz VF02xyz,VF02w div Q,VF00w,VF02w ; STALL_LATENCY ?3
|
||||||
maddaz ACC,VF05,VF07z iaddiu VI07,VI07,0x00000001
|
mulq.xyz VF02,VF02,Q waitq ; STALL_LATENCY ?6
|
||||||
maddw VF07,VF06,VF07w iaddiu VI08,VI00,0
|
mulaw.xyz ACC,VF09,VF00w NOP
|
||||||
clipw.xyz VF11xyz,VF11w iaddiu VI04,VI04,0
|
madd.xyz VF02,VF02,VF09 NOP ; STALL_LATENCY ?2
|
||||||
clipw.xyz VF14xyz,VF14w div Q,VF00w,VF14w ; STALL_THRUPUT ?1
|
NOP ibgtz VI03,vec_1_rgba
|
||||||
clipw.xyz VF07xyz,VF07w lq VF15,0(VI04)
|
ftoi4.xyz VF01,VF02 NOP ; STALL_LATENCY ?2
|
||||||
mulq.xyz VF02,VF11,Q sq VF08,4(VI06)
|
; _LNOPT_w=[ normal2 ] 5 [9 0] 9 [vec_1_stq_rgba]
|
||||||
mulaw.xyz ACC,VF09,VF00w iaddiu VI03,VI03,0
|
NOP lq VF02,0(VI05)
|
||||||
mulq VF11,VF15,Q iaddiu VI06,VI06,0 ; STALL_LATENCY ?1
|
mulq VF01,VF02,Q sq VF01,2(VI07) ; STALL_LATENCY ?3
|
||||||
madd.xyz VF01,VF02,VF09 lq VF02,1(VI04)
|
NOP sq VF08,1(VI07)
|
||||||
NOP div Q,VF00w,VF07w
|
NOP b vec2
|
||||||
mulq.xyz VF15,VF14,Q iaddiu VI08,VI08,0x00000001
|
NOP sq VF01,0(VI07) ; STALL_LATENCY ?1
|
||||||
mulaw.xyz ACC,VF09,VF00w sq VF11,0(VI06)
|
vec_1_rgba:
|
||||||
mulq VF14,VF02,Q mfir.w VF11,VI07
|
; _LNOPT_w=[ normal2 ] 4 [2 0] 4 [vec_1_rgba]
|
||||||
ftoi4.xyz VF11,VF01 ibeq VI08,VI02,EXPL_draw3D_vcl_triangle_loop__EPI1
|
|
||||||
madd.xyz VF02,VF15,VF09 lq VF15,2(VI04)
|
|
||||||
; _LNOPT_w=[ ] 31 [29 0] 31 [EXPL_draw3D_vcl_triangle_loop__PRO1]
|
|
||||||
NOP lq VF12,3(VI03)
|
|
||||||
NOP NOP
|
NOP NOP
|
||||||
mulq.xyz VF01,VF07,Q NOP
|
|
||||||
mulq VF11,VF15,Q sq VF11,2(VI06)
|
|
||||||
mulax ACC,VF03,VF12x lq VF10,4(VI03)
|
|
||||||
madday ACC,VF04,VF12y NOP
|
|
||||||
maddaz ACC,VF05,VF12z NOP
|
|
||||||
maddw VF11,VF06,VF12w sq VF11,6(VI06)
|
|
||||||
mulax ACC,VF03,VF10x lq VF07,5(VI03)
|
|
||||||
madday ACC,VF04,VF10y sq VF14,3(VI06)
|
|
||||||
maddaz ACC,VF05,VF10z sq VF08,10(VI06)
|
|
||||||
maddw VF10,VF06,VF10w div Q,VF00w,VF11w
|
|
||||||
mulax ACC,VF03,VF07x sq VF08,13(VI06)
|
|
||||||
madday ACC,VF04,VF07y sq VF08,16(VI06)
|
|
||||||
maddaz ACC,VF05,VF07z iaddiu VI03,VI03,0x00000006
|
|
||||||
maddw VF07,VF06,VF07w iaddiu VI04,VI04,0x00000006
|
|
||||||
clipw.xyz VF11xyz,VF11w lq VF12,-3(VI04)
|
|
||||||
clipw.xyz VF10xyz,VF10w iaddiu VI06,VI06,0x00000012
|
|
||||||
mulq.xyz VF14,VF11,Q div Q,VF00w,VF10w
|
|
||||||
clipw.xyz VF07xyz,VF07w fcand VI01,262143
|
|
||||||
mulq VF12,VF12,Q iaddiu VI08,VI08,0x00000001
|
|
||||||
ftoi4.xyz VF11,VF02 iaddiu VI01,VI01,0x00007fff
|
|
||||||
mulaw.xyz ACC,VF09,VF00w mfir.w VF11,VI07
|
|
||||||
madd.xyz VF14,VF14,VF09 mfir.w VF10,VI01
|
|
||||||
mulaw.xyz ACC,VF09,VF00w lq VF02,-2(VI04)
|
|
||||||
madd.xyz VF01,VF01,VF09 div Q,VF00w,VF07w
|
|
||||||
mulq.xyz VF10,VF10,Q lq VF15,-1(VI04)
|
|
||||||
ftoi4.xyz VF11,VF14 sq VF11,-13(VI06)
|
|
||||||
mulq VF14,VF02,Q sq VF12,-9(VI06)
|
|
||||||
mulaw.xyz ACC,VF09,VF00w ibeq VI08,VI02,EXPL_draw3D_vcl_triangle_loop__EPI0
|
|
||||||
madd.xyz VF02,VF10,VF09 mfir.w VF11,VI07
|
|
||||||
EXPL_draw3D_vcl_triangle_loop__MAIN_LOOP:
|
|
||||||
; _LPOPT_w=[ hDown ] 31 [30 30] 31 [EXPL_draw3D_vcl_triangle_loop__MAIN_LOOP]
|
|
||||||
ftoi4.xyz VF10,VF01 lq VF13,0(VI03)
|
|
||||||
NOP lq VF12,1(VI03)
|
|
||||||
mulq.xyz VF01,VF07,Q sq VF14,-6(VI06)
|
|
||||||
mulq VF11,VF15,Q sq VF11,-7(VI06)
|
|
||||||
mulax ACC,VF03,VF13x sq VF10,-10(VI06)
|
|
||||||
madday ACC,VF04,VF13y sq VF08,1(VI06)
|
|
||||||
maddaz ACC,VF05,VF13z NOP
|
|
||||||
maddw VF11,VF06,VF13w sq VF11,-3(VI06)
|
|
||||||
mulax ACC,VF03,VF12x lq VF07,2(VI03)
|
|
||||||
madday ACC,VF04,VF12y sq VF08,4(VI06)
|
|
||||||
maddaz ACC,VF05,VF12z sq VF08,7(VI06)
|
|
||||||
maddw VF10,VF06,VF12w div Q,VF00w,VF11w
|
|
||||||
mulax ACC,VF03,VF07x NOP
|
|
||||||
madday ACC,VF04,VF07y iaddiu VI03,VI03,0x00000003
|
|
||||||
maddaz ACC,VF05,VF07z NOP
|
|
||||||
maddw VF07,VF06,VF07w iaddiu VI04,VI04,0x00000003
|
|
||||||
clipw.xyz VF11xyz,VF11w lq VF12,-3(VI04)
|
|
||||||
clipw.xyz VF10xyz,VF10w iaddiu VI06,VI06,0x00000009
|
|
||||||
mulq.xyz VF13,VF11,Q fcand VI01,262143
|
|
||||||
clipw.xyz VF07xyz,VF07w div Q,VF00w,VF10w
|
|
||||||
mulq VF12,VF12,Q iaddiu VI08,VI08,0x00000001
|
|
||||||
ftoi4.xyz VF11,VF02 iaddiu VI01,VI01,0x00007fff
|
|
||||||
mulaw.xyz ACC,VF09,VF00w mfir.w VF10,VI01
|
|
||||||
madd.xyz VF13,VF13,VF09 mfir.w VF11,VI07
|
|
||||||
mulaw.xyz ACC,VF09,VF00w lq VF02,-2(VI04)
|
|
||||||
madd.xyz VF01,VF01,VF09 sq VF12,-9(VI06)
|
|
||||||
mulq.xyz VF10,VF10,Q div Q,VF00w,VF07w
|
|
||||||
ftoi4.xyz VF11,VF13 sq VF11,-13(VI06)
|
|
||||||
mulq VF14,VF02,Q mfir.w VF11,VI07
|
|
||||||
mulaw.xyz ACC,VF09,VF00w ibne VI08,VI02,EXPL_draw3D_vcl_triangle_loop__MAIN_LOOP
|
|
||||||
madd.xyz VF02,VF10,VF09 lq VF15,-1(VI04)
|
|
||||||
EXPL_draw3D_vcl_triangle_loop__EPI0:
|
|
||||||
; _LNOPT_w=[ ] 13 [13 0] 15 [EXPL_draw3D_vcl_triangle_loop__EPI0]
|
|
||||||
NOP NOP
|
NOP NOP
|
||||||
ftoi4.xyz VF10,VF01 fcand VI01,262143
|
NOP sq VF08,0(VI07)
|
||||||
mulq.xyz VF01,VF07,Q sq VF14,-6(VI06)
|
NOP sq VF01,1(VI07)
|
||||||
mulq VF11,VF15,Q sq VF11,-7(VI06)
|
vec2:
|
||||||
mulaw.xyz ACC,VF09,VF00w iaddiu VI01,VI01,0x00007fff
|
; _LNOPT_w=[ normal2 ] 11 [27 0] 27 [vec2]
|
||||||
madd.xyz VF01,VF01,VF09 sq VF10,-10(VI06) ; STALL_LATENCY ?1
|
NOP lq VF02,1(VI04)
|
||||||
ftoi4.xyz VF11,VF02 sq VF11,-3(VI06)
|
mulax ACC,VF03,VF02x mfir.w VF01,VI08 ; STALL_LATENCY ?3
|
||||||
NOP mfir.w VF11,VI07
|
madday ACC,VF04,VF02y NOP
|
||||||
NOP mfir.w VF10,VI01
|
maddaz ACC,VF05,VF02z NOP
|
||||||
ftoi4.xyz VF10,VF01 NOP
|
maddw VF02,VF06,VF02w NOP
|
||||||
NOP sq VF11,-4(VI06) ; STALL_LATENCY ?1
|
clipw.xyz VF02xyz,VF02w div Q,VF00w,VF02w ; STALL_LATENCY ?3
|
||||||
NOP b EXPL_draw3D_vcl_triangle_loop__EXIT_POINT
|
mulq.xyz VF02,VF02,Q waitq ; STALL_LATENCY ?6
|
||||||
NOP sq VF10,-1(VI06)
|
mulaw.xyz ACC,VF09,VF00w NOP
|
||||||
EXPL_draw3D_vcl_triangle_loop__EPI1:
|
madd.xyz VF02,VF02,VF09 NOP ; STALL_LATENCY ?2
|
||||||
; _LNOPT_w=[ ] 12 [13 0] 14 [EXPL_draw3D_vcl_triangle_loop__EPI1]
|
NOP ibgtz VI03,vec_2_rgba
|
||||||
|
ftoi4.xyz VF01,VF02 NOP ; STALL_LATENCY ?2
|
||||||
|
; _LNOPT_w=[ normal2 ] 5 [9 0] 9 [vec_2_stq_rgba]
|
||||||
|
NOP lq VF02,1(VI05)
|
||||||
|
mulq VF01,VF02,Q sq VF01,5(VI07) ; STALL_LATENCY ?3
|
||||||
|
NOP sq VF08,4(VI07)
|
||||||
|
NOP b vec3
|
||||||
|
NOP sq VF01,3(VI07) ; STALL_LATENCY ?1
|
||||||
|
vec_2_rgba:
|
||||||
|
; _LNOPT_w=[ normal2 ] 4 [2 0] 4 [vec_2_rgba]
|
||||||
NOP NOP
|
NOP NOP
|
||||||
mulq.xyz VF14,VF07,Q sq VF14,3(VI06)
|
|
||||||
NOP NOP
|
NOP NOP
|
||||||
mulq VF11,VF15,Q sq VF11,2(VI06)
|
NOP sq VF08,2(VI07)
|
||||||
mulaw.xyz ACC,VF09,VF00w fcand VI01,262143
|
NOP sq VF01,3(VI07)
|
||||||
madd.xyz VF14,VF14,VF09 iaddiu VI01,VI01,0x00007fff
|
vec3:
|
||||||
NOP mfir.w VF14,VI01
|
; _LNOPT_w=[ normal2 ] 13 [27 0] 27 [vec3]
|
||||||
ftoi4.xyz VF11,VF02 sq VF11,6(VI06)
|
NOP lq VF01,2(VI04)
|
||||||
NOP mfir.w VF11,VI07
|
mulax ACC,VF03,VF01x NOP ; STALL_LATENCY ?3
|
||||||
ftoi4.xyz VF14,VF14 NOP
|
madday ACC,VF04,VF01y NOP
|
||||||
NOP sq VF11,5(VI06) ; STALL_LATENCY ?2
|
maddaz ACC,VF05,VF01z NOP
|
||||||
NOP sq VF14,8(VI06)
|
maddw VF01,VF06,VF01w NOP
|
||||||
EXPL_draw3D_vcl_triangle_loop__EXIT_POINT:
|
clipw.xyz VF01xyz,VF01w div Q,VF00w,VF01w ; STALL_LATENCY ?3
|
||||||
; _LNOPT_w=[ ] 0 [0 0] 0 [EXPL_draw3D_vcl_triangle_loop__EXIT_POINT]
|
mulq.xyz VF01,VF01,Q waitq ; STALL_LATENCY ?6
|
||||||
; _LNOPT_w=[ normal2 ] 3 [1 0] 3 [__v_draw3D_vcl_9]
|
mulaw.xyz ACC,VF09,VF00w NOP
|
||||||
NOP xgkick VI05
|
madd.xyz VF01,VF01,VF09 fcand VI01,262143 ; STALL_LATENCY ?2
|
||||||
|
NOP iaddiu VI01,VI01,0x00007fff
|
||||||
|
NOP mfir.w VF01,VI01
|
||||||
|
NOP ibgtz VI03,vec_3_rgba
|
||||||
|
ftoi4.xyz VF01,VF01 NOP
|
||||||
|
; _LNOPT_w=[ normal2 ] 6 [9 0] 9 [vec_3_stq_rgba]
|
||||||
|
NOP lq VF02,2(VI05)
|
||||||
|
mulq VF01,VF02,Q sq VF01,8(VI07) ; STALL_LATENCY ?3
|
||||||
|
NOP sq VF08,7(VI07)
|
||||||
|
NOP iaddiu VI07,VI07,0x00000009
|
||||||
|
NOP b loop_ctrl
|
||||||
|
NOP sq VF01,-3(VI07)
|
||||||
|
vec_3_rgba:
|
||||||
|
; _LNOPT_w=[ normal2 ] 4 [3 0] 4 [vec_3_rgba]
|
||||||
|
NOP NOP
|
||||||
|
NOP sq VF08,4(VI07)
|
||||||
|
NOP iaddiu VI07,VI07,0x00000006
|
||||||
|
NOP sq VF01,-1(VI07)
|
||||||
|
loop_ctrl:
|
||||||
|
; _LNOPT_w=[ normal2 ] 4 [4 0] 4 [loop_ctrl]
|
||||||
|
NOP iaddiu VI09,VI09,0x00000001
|
||||||
|
NOP iaddiu VI04,VI04,0x00000003
|
||||||
|
NOP ibne VI09,VI02,triangle_loop
|
||||||
|
NOP iaddiu VI05,VI05,0x00000003
|
||||||
|
; _LNOPT_w=[ normal2 ] 3 [1 0] 3 [__v_draw3D_vcl_21]
|
||||||
|
NOP xgkick VI06
|
||||||
NOP[E] NOP
|
NOP[E] NOP
|
||||||
NOP NOP
|
NOP NOP
|
||||||
.align 4
|
.align 4
|
||||||
VU1Draw3D_CodeEnd:
|
VU1Draw3D_CodeEnd:
|
||||||
; iCount=145
|
; iCount=103
|
||||||
; register stats:
|
; register stats:
|
||||||
; 9 VU User integer
|
; 10 VU User integer
|
||||||
; 16 VU User floating point
|
; 11 VU User floating point
|
||||||
;-------------------------
|
;-------------------------
|
||||||
;-------------------------
|
;-------------------------
|
||||||
;-------------------------
|
;-------------------------
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.vscode/
|
||||||
|
fonts/**
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
# Project settings
|
||||||
|
|
||||||
|
DIR_NAME = cube
|
||||||
|
EE_LIBS = -ltyra
|
||||||
|
EE_OBJS = \
|
||||||
|
objects/cube.o \
|
||||||
|
camera.o \
|
||||||
|
cubes.o \
|
||||||
|
main.o
|
||||||
|
|
||||||
|
# ----------------
|
||||||
|
# Other
|
||||||
|
|
||||||
|
EE_BIN = $(DIR_NAME).elf
|
||||||
|
|
||||||
|
all: $(EE_BIN)
|
||||||
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
|
|
||||||
|
rebuild-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make EE_CXXFLAGS="-DNDEBUG $(EE_CXXFLAGS)"
|
||||||
|
|
||||||
|
rebuild-dbg-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(EE_OBJS)
|
||||||
|
|
||||||
|
run:
|
||||||
|
killall -v ps2client || true
|
||||||
|
ps2client reset
|
||||||
|
ps2client reset
|
||||||
|
cd bin/ && ps2client execee host:$(EE_BIN)
|
||||||
|
|
||||||
|
run-pcsx2:
|
||||||
|
taskkill.exe /f /t /im pcsx2.exe || true
|
||||||
|
$(WSL_LINUX_PCSX2)/pcsx2.exe --elf=$(WSL_MAKE_WINDOWS)\\repos\\tyra\\src\\samples\\$(DIR_NAME)\\bin\\$(EE_BIN)
|
||||||
|
|
||||||
|
include $(TYRA)/src/engine/Makefile.pref
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
## Cube Sample
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
- Rotating Cube
|
||||||
|
|
||||||
|
### Assets
|
||||||
|
You can download assets from [latest release](https://github.com/h4570/tyra/releases/latest) (unpack to `/repos/tyra/src/samples/cube/bin`)
|
||||||
|
|
||||||
|
### Screenshot
|
||||||
|
|
||||||
|
[![Cube screenshot][Cube-screenshot]](#)
|
||||||
|
|
||||||
|
[Cube-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/cube.gif
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "camera.hpp"
|
||||||
|
|
||||||
|
#include <utils/debug.hpp>
|
||||||
|
#include <fastmath.h>
|
||||||
|
|
||||||
|
const float CAMERA_Y = 30.0F;
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// Constructors/Destructors
|
||||||
|
// ----
|
||||||
|
|
||||||
|
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||||
|
{
|
||||||
|
consoleLog("Initializing camera");
|
||||||
|
verticalLevel = 80.0F;
|
||||||
|
consoleLog("Camera initialized!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Camera::~Camera() {}
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// Methods
|
||||||
|
// ----
|
||||||
|
|
||||||
|
void Camera::update(Pad &t_pad, Mesh &t_mesh)
|
||||||
|
{
|
||||||
|
rotate(t_pad);
|
||||||
|
followBy(t_mesh);
|
||||||
|
lookAt(t_mesh.position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Set camera rotation by pad right joy and update unit circle
|
||||||
|
* https://en.wikipedia.org/wiki/Unit_circle
|
||||||
|
* https://www.desmos.com/calculator/3e7iypw4ow
|
||||||
|
*/
|
||||||
|
void Camera::rotate(Pad &t_pad)
|
||||||
|
{
|
||||||
|
if (t_pad.rJoyH <= 100)
|
||||||
|
horizontalLevel -= 0.08;
|
||||||
|
else if (t_pad.rJoyH >= 200)
|
||||||
|
horizontalLevel += 0.08;
|
||||||
|
if (t_pad.rJoyV <= 50 && verticalLevel > 25.0F)
|
||||||
|
verticalLevel -= 0.9F;
|
||||||
|
else if (t_pad.rJoyV >= 200 && verticalLevel < 80.0F)
|
||||||
|
verticalLevel += 0.9F;
|
||||||
|
unitCirclePosition.x = (sin(horizontalLevel) * verticalLevel);
|
||||||
|
unitCirclePosition.y = CAMERA_Y;
|
||||||
|
unitCirclePosition.z = (cos(horizontalLevel) * verticalLevel);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Rotate camera around 3D object */
|
||||||
|
void Camera::followBy(Mesh &t_mesh)
|
||||||
|
{
|
||||||
|
position.x = unitCirclePosition.x + t_mesh.position.x;
|
||||||
|
position.y = unitCirclePosition.y + t_mesh.position.y;
|
||||||
|
position.z = unitCirclePosition.z + t_mesh.position.z;
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CAMERA_
|
||||||
|
#define _CAMERA_
|
||||||
|
|
||||||
|
#include <modules/pad.hpp>
|
||||||
|
#include <models/mesh.hpp>
|
||||||
|
#include <models/math/vector3.hpp>
|
||||||
|
#include <models/screen_settings.hpp>
|
||||||
|
#include <modules/camera_base.hpp>
|
||||||
|
#include <tamtypes.h>
|
||||||
|
|
||||||
|
/** 3D camera which follow by 3D object. Can be rotated via pad */
|
||||||
|
class Camera : public CameraBase
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Vector3 up, position, unitCirclePosition;
|
||||||
|
float horizontalLevel, verticalLevel;
|
||||||
|
|
||||||
|
Camera(ScreenSettings *t_screen);
|
||||||
|
~Camera();
|
||||||
|
|
||||||
|
void update(Pad &t_pad, Mesh &t_mesh);
|
||||||
|
void rotate(Pad &t_pad);
|
||||||
|
void followBy(Mesh &t_mesh);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
Vector3 *getPosition() { return &position; };
|
||||||
|
ScreenSettings screen;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cubes.hpp"
|
||||||
|
|
||||||
|
Cubes::Cubes(Engine *t_engine)
|
||||||
|
: engine(t_engine), camera(&t_engine->screen)
|
||||||
|
{
|
||||||
|
consoleLog("Initing cubes sample");
|
||||||
|
}
|
||||||
|
|
||||||
|
Cubes::~Cubes()
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cubes::onInit()
|
||||||
|
{
|
||||||
|
texRepo = engine->renderer->getTextureRepository();
|
||||||
|
cube = new Cube(texRepo);
|
||||||
|
setBgColorAndAmbientColor();
|
||||||
|
engine->renderer->setCameraDefinitions(&camera.view, &camera.unitCirclePosition, camera.planes);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cubes::onUpdate()
|
||||||
|
{
|
||||||
|
camera.update(engine->pad, cube->mesh);
|
||||||
|
cube->update(engine->pad, camera);
|
||||||
|
engine->renderer->draw(cube->mesh);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cubes::setBgColorAndAmbientColor()
|
||||||
|
{
|
||||||
|
color_t bgColor;
|
||||||
|
bgColor.r = 0x20;
|
||||||
|
bgColor.g = 0x20;
|
||||||
|
bgColor.b = 0x20;
|
||||||
|
engine->renderer->setWorldColor(bgColor);
|
||||||
|
Vector3 ambient = Vector3(0.2F, 0.2F, 0.2F);
|
||||||
|
engine->renderer->setAmbientLight(ambient);
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CUBES_
|
||||||
|
#define _CUBES_
|
||||||
|
|
||||||
|
#include <tamtypes.h>
|
||||||
|
#include <game.hpp>
|
||||||
|
#include <engine.hpp>
|
||||||
|
#include "modules/texture_repository.hpp"
|
||||||
|
#include "camera.hpp"
|
||||||
|
#include "objects/cube.hpp"
|
||||||
|
|
||||||
|
class Cubes : public Game
|
||||||
|
{
|
||||||
|
|
||||||
|
public:
|
||||||
|
Cubes(Engine *t_engine);
|
||||||
|
~Cubes();
|
||||||
|
|
||||||
|
void onInit();
|
||||||
|
void onUpdate();
|
||||||
|
|
||||||
|
Engine *engine;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void setBgColorAndAmbientColor();
|
||||||
|
TextureRepository *texRepo;
|
||||||
|
Cube *cube;
|
||||||
|
Camera camera;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cubes.hpp"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
Engine engine = Engine();
|
||||||
|
Cubes game = Cubes(&engine);
|
||||||
|
game.engine->init(&game, 128);
|
||||||
|
SleepThread();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "cube.hpp"
|
||||||
|
#include <models/mesh.hpp>
|
||||||
|
#include <loaders/obj_loader.hpp>
|
||||||
|
#include <utils/debug.hpp>
|
||||||
|
|
||||||
|
// ----
|
||||||
|
// Constructors/Destructors
|
||||||
|
// ----
|
||||||
|
|
||||||
|
Cube::Cube(TextureRepository *t_texRepo)
|
||||||
|
{
|
||||||
|
consoleLog("Creating cube");
|
||||||
|
texRepo = t_texRepo;
|
||||||
|
speed = 1.2F;
|
||||||
|
|
||||||
|
mesh.loadObj("meshes/cube/", "cube", 10.0F, true);
|
||||||
|
mesh.position.set(20.00F, 40.00F, 10.00F);
|
||||||
|
mesh.rotation.x = -1.566F;
|
||||||
|
mesh.rotation.z = 1.566F;
|
||||||
|
|
||||||
|
texRepo->addByMesh("meshes/cube/", mesh, PNG);
|
||||||
|
|
||||||
|
consoleLog("Cube object created!");
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cube::update(const Pad &t_pad, const Camera &t_camera)
|
||||||
|
{
|
||||||
|
rotate(t_pad);
|
||||||
|
Vector3 *nextPos = getNextPosition(t_pad, t_camera);
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 *Cube::getNextPosition(const Pad &t_pad, const Camera &t_camera)
|
||||||
|
{
|
||||||
|
Vector3 *result = new Vector3(mesh.position);
|
||||||
|
Vector3 normalizedCamera = Vector3(t_camera.unitCirclePosition);
|
||||||
|
normalizedCamera.normalize();
|
||||||
|
normalizedCamera *= speed;
|
||||||
|
if (t_pad.lJoyV <= 100)
|
||||||
|
{
|
||||||
|
result->x += -normalizedCamera.x;
|
||||||
|
result->z += -normalizedCamera.z;
|
||||||
|
}
|
||||||
|
else if (t_pad.lJoyV >= 200)
|
||||||
|
{
|
||||||
|
result->x += normalizedCamera.x;
|
||||||
|
result->z += normalizedCamera.z;
|
||||||
|
}
|
||||||
|
if (t_pad.lJoyH <= 100)
|
||||||
|
{
|
||||||
|
result->x += -normalizedCamera.z;
|
||||||
|
result->z += normalizedCamera.x;
|
||||||
|
}
|
||||||
|
else if (t_pad.lJoyH >= 200)
|
||||||
|
{
|
||||||
|
result->x += normalizedCamera.z;
|
||||||
|
result->z += -normalizedCamera.x;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cube::rotate(const Pad &t_pad)
|
||||||
|
{
|
||||||
|
//if (t_pad.rJoyH >= 200)
|
||||||
|
//else if (t_pad.rJoyH <= 100)
|
||||||
|
mesh.rotation.x += (0.01 * speed);
|
||||||
|
mesh.rotation.y += (0.01 * speed);
|
||||||
|
mesh.rotation.z += (0.01 * speed);
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2020, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Wellington Carvalho <wellcoj@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _CUBE_
|
||||||
|
#define _CUBE_
|
||||||
|
|
||||||
|
#include "../camera.hpp"
|
||||||
|
#include <tamtypes.h>
|
||||||
|
#include <modules/pad.hpp>
|
||||||
|
#include <modules/timer.hpp>
|
||||||
|
#include "modules/texture_repository.hpp"
|
||||||
|
|
||||||
|
/** Cube 3D object class */
|
||||||
|
class Cube
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Mesh mesh;
|
||||||
|
Cube( TextureRepository *t_texRepo );
|
||||||
|
~Cube();
|
||||||
|
|
||||||
|
void update(const Pad &t_pad, const Camera &t_camera);
|
||||||
|
|
||||||
|
private:
|
||||||
|
TextureRepository *texRepo;
|
||||||
|
Vector3 *getNextPosition(const Pad &t_pad, const Camera &t_camera);
|
||||||
|
void rotate(const Pad &t_pad);
|
||||||
|
float speed;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
bin/**
|
|
||||||
fonts/**
|
fonts/**
|
||||||
|
|||||||
Executable → Regular
+17
-11
@@ -1,7 +1,7 @@
|
|||||||
EE_BIN = dolphin.elf
|
# Project settings
|
||||||
|
|
||||||
TYRA_DIR = ./../../engine
|
|
||||||
|
|
||||||
|
DIR_NAME = dolphin
|
||||||
|
EE_LIBS = -ltyra
|
||||||
EE_OBJS = \
|
EE_OBJS = \
|
||||||
camera.o \
|
camera.o \
|
||||||
objects/player.o \
|
objects/player.o \
|
||||||
@@ -10,26 +10,32 @@ EE_OBJS = \
|
|||||||
dolphin.o \
|
dolphin.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
EE_LIBS = -ltyra
|
# ----------------
|
||||||
|
# Other
|
||||||
|
|
||||||
|
EE_BIN = $(DIR_NAME).elf
|
||||||
|
|
||||||
all: $(EE_BIN)
|
all: $(EE_BIN)
|
||||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
mv $(EE_BIN) bin/$(EE_BIN)
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
rm $(EE_OBJS)
|
|
||||||
|
|
||||||
rebuild-engine:
|
rebuild-engine:
|
||||||
cd $(TYRA_DIR) && make clean && make
|
cd $(TYRA)/src/engine && make clean && make EE_CXXFLAGS="-DNDEBUG $(EE_CXXFLAGS)"
|
||||||
|
|
||||||
|
rebuild-dbg-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(EE_OBJS)
|
rm -f $(EE_OBJS)
|
||||||
|
|
||||||
run: $(EE_BIN)
|
run:
|
||||||
killall -v ps2client || true
|
killall -v ps2client || true
|
||||||
ps2client reset
|
ps2client reset
|
||||||
ps2client reset
|
ps2client reset
|
||||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
|
||||||
mv $(EE_BIN) bin/$(EE_BIN)
|
|
||||||
rm $(EE_OBJS)
|
|
||||||
cd bin/ && ps2client execee host:$(EE_BIN)
|
cd bin/ && ps2client execee host:$(EE_BIN)
|
||||||
|
|
||||||
include $(TYRA_DIR)/Makefile.pref
|
run-pcsx2:
|
||||||
|
taskkill.exe /f /t /im pcsx2.exe || true
|
||||||
|
$(WSL_LINUX_PCSX2)/pcsx2.exe --elf=$(WSL_MAKE_WINDOWS)\\repos\\tyra\\src\\samples\\$(DIR_NAME)\\bin\\$(EE_BIN)
|
||||||
|
|
||||||
|
include $(TYRA)/src/engine/Makefile.pref
|
||||||
|
|||||||
@@ -11,10 +11,10 @@
|
|||||||
- Usage of draw() in array mode (for water tiles, very fast)
|
- Usage of draw() in array mode (for water tiles, very fast)
|
||||||
|
|
||||||
### Assets
|
### Assets
|
||||||
[Download](http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/samples/dolphin/assets.zip)
|
You can download assets from [latest release](https://github.com/h4570/tyra/releases/latest) (unpack to `/repos/tyra/src/samples/dolphin/bin`)
|
||||||
|
|
||||||
### Screenshot
|
### Screenshot
|
||||||
|
|
||||||
[![Dolphin screenshot][dolphin-screenshot]](#)
|
[![Dolphin screenshot][dolphin-screenshot]](#)
|
||||||
|
|
||||||
[dolphin-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/samples/dolphin/dolphin.gif
|
[dolphin-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/dolphin.gif
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
@@ -73,7 +73,7 @@ void Dolphin::onInit()
|
|||||||
|
|
||||||
printf("Loading water...\n");
|
printf("Loading water...\n");
|
||||||
|
|
||||||
u32 spiralOffset = (u32)Math::sqrt(WATER_TILES_COUNT);
|
u32 spiralOffset = (u32)sqrt(WATER_TILES_COUNT);
|
||||||
waterDrawList = new Mesh *[WATER_TILES_COUNT];
|
waterDrawList = new Mesh *[WATER_TILES_COUNT];
|
||||||
calcSpiral(spiralOffset, spiralOffset);
|
calcSpiral(spiralOffset, spiralOffset);
|
||||||
water[0].loadObj("water/", "water", WATER_TILE_SCALE, false);
|
water[0].loadObj("water/", "water", WATER_TILE_SCALE, false);
|
||||||
@@ -88,8 +88,7 @@ void Dolphin::onInit()
|
|||||||
water[i].shouldBeFrustumCulled = true;
|
water[i].shouldBeFrustumCulled = true;
|
||||||
water[i].shouldBeBackfaceCulled = false;
|
water[i].shouldBeBackfaceCulled = false;
|
||||||
water[i].position.set(WATER_TILE_SCALE * 2.0F * spirals[i].x, WATER_LEVEL, WATER_TILE_SCALE * 2.0F * spirals[i].y);
|
water[i].position.set(WATER_TILE_SCALE * 2.0F * spirals[i].x, WATER_LEVEL, WATER_TILE_SCALE * 2.0F * spirals[i].y);
|
||||||
texRepo->getByMesh(water[0].getId(), water[0].getMaterial(0).getId())
|
texRepo->getBySpriteOrMesh(water[0].getMaterial(0).getId())->addLink(water[i].getMaterial(0).getId());
|
||||||
->addLink(water[i].getId(), water[i].getMaterial(0).getId());
|
|
||||||
waterDrawList[i] = &water[i];
|
waterDrawList[i] = &water[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,8 +122,7 @@ void Dolphin::onInit()
|
|||||||
oysters[i].mesh.loadFrom(oysters[0].mesh);
|
oysters[i].mesh.loadFrom(oysters[0].mesh);
|
||||||
oysters[i].mesh.shouldBeBackfaceCulled = false;
|
oysters[i].mesh.shouldBeBackfaceCulled = false;
|
||||||
oysters[i].mesh.shouldBeFrustumCulled = false;
|
oysters[i].mesh.shouldBeFrustumCulled = false;
|
||||||
texRepo->getByMesh(oysters[0].mesh.getId(), oysters[0].mesh.getMaterial(0).getId())
|
texRepo->getBySpriteOrMesh(oysters[0].mesh.getMaterial(0).getId())->addLink(oysters[i].mesh.getMaterial(0).getId());
|
||||||
->addLink(oysters[i].mesh.getId(), oysters[i].mesh.getMaterial(0).getId());
|
|
||||||
oysters[i].mesh.position.set(i * -100, 5.0F, i * -100);
|
oysters[i].mesh.position.set(i * -100, 5.0F, i * -100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -141,8 +139,7 @@ void Dolphin::onInit()
|
|||||||
mines[i].mesh.loadFrom(mines[0].mesh);
|
mines[i].mesh.loadFrom(mines[0].mesh);
|
||||||
mines[i].mesh.shouldBeBackfaceCulled = false;
|
mines[i].mesh.shouldBeBackfaceCulled = false;
|
||||||
mines[i].mesh.shouldBeFrustumCulled = false;
|
mines[i].mesh.shouldBeFrustumCulled = false;
|
||||||
texRepo->getByMesh(mines[0].mesh.getId(), mines[0].mesh.getMaterial(0).getId())
|
texRepo->getBySpriteOrMesh(mines[0].mesh.getMaterial(0).getId())->addLink(mines[i].mesh.getMaterial(0).getId());
|
||||||
->addLink(mines[i].mesh.getId(), mines[i].mesh.getMaterial(0).getId());
|
|
||||||
mines[i].mesh.position.set(i * -10, 0.0F, i * -68);
|
mines[i].mesh.position.set(i * -10, 0.0F, i * -68);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +239,11 @@ void Dolphin::onUpdate()
|
|||||||
waterbox.position.set(player.mesh.position.x, -260.0F, player.mesh.position.z);
|
waterbox.position.set(player.mesh.position.x, -260.0F, player.mesh.position.z);
|
||||||
|
|
||||||
engine->renderer->draw(island);
|
engine->renderer->draw(island);
|
||||||
engine->renderer->draw(waterDrawList, WATER_TILES_COUNT);
|
|
||||||
|
for (int i = 0; i < WATER_TILES_COUNT; i++)
|
||||||
|
{
|
||||||
|
engine->renderer->draw(*waterDrawList[i]);
|
||||||
|
}
|
||||||
engine->renderer->draw(skybox);
|
engine->renderer->draw(skybox);
|
||||||
engine->renderer->draw(waterbox);
|
engine->renderer->draw(waterbox);
|
||||||
engine->renderer->draw(seabed);
|
engine->renderer->draw(seabed);
|
||||||
|
|||||||
@@ -1,3 +1,2 @@
|
|||||||
.vscode/
|
.vscode/
|
||||||
bin/**
|
|
||||||
fonts/**
|
fonts/**
|
||||||
+17
-11
@@ -1,7 +1,7 @@
|
|||||||
EE_BIN = floors.elf
|
# Project settings
|
||||||
|
|
||||||
TYRA_DIR = ./../../engine
|
|
||||||
|
|
||||||
|
DIR_NAME = floors
|
||||||
|
EE_LIBS = -ltyra
|
||||||
EE_OBJS = \
|
EE_OBJS = \
|
||||||
managers/light_manager.o \
|
managers/light_manager.o \
|
||||||
managers/floor_manager.o \
|
managers/floor_manager.o \
|
||||||
@@ -14,26 +14,32 @@ EE_OBJS = \
|
|||||||
floors.o \
|
floors.o \
|
||||||
main.o
|
main.o
|
||||||
|
|
||||||
EE_LIBS = -ltyra
|
# ----------------
|
||||||
|
# Other
|
||||||
|
|
||||||
|
EE_BIN = $(DIR_NAME).elf
|
||||||
|
|
||||||
all: $(EE_BIN)
|
all: $(EE_BIN)
|
||||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
mv $(EE_BIN) bin/$(EE_BIN)
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
rm $(EE_OBJS)
|
|
||||||
|
|
||||||
rebuild-engine:
|
rebuild-engine:
|
||||||
cd $(TYRA_DIR) && make clean && make
|
cd $(TYRA)/src/engine && make clean && make EE_CXXFLAGS="-DNDEBUG $(EE_CXXFLAGS)"
|
||||||
|
|
||||||
|
rebuild-dbg-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f $(EE_OBJS)
|
rm -f $(EE_OBJS)
|
||||||
|
|
||||||
run: $(EE_BIN)
|
run:
|
||||||
killall -v ps2client || true
|
killall -v ps2client || true
|
||||||
ps2client reset
|
ps2client reset
|
||||||
ps2client reset
|
ps2client reset
|
||||||
$(EE_STRIP) --strip-all $(EE_BIN)
|
|
||||||
mv $(EE_BIN) bin/$(EE_BIN)
|
|
||||||
rm $(EE_OBJS)
|
|
||||||
cd bin/ && ps2client execee host:$(EE_BIN)
|
cd bin/ && ps2client execee host:$(EE_BIN)
|
||||||
|
|
||||||
include $(TYRA_DIR)/Makefile.pref
|
run-pcsx2:
|
||||||
|
taskkill.exe /f /t /im pcsx2.exe || true
|
||||||
|
$(WSL_LINUX_PCSX2)/pcsx2.exe --elf=$(WSL_MAKE_WINDOWS)\\repos\\tyra\\src\\samples\\$(DIR_NAME)\\bin\\$(EE_BIN)
|
||||||
|
|
||||||
|
include $(TYRA)/src/engine/Makefile.pref
|
||||||
|
|||||||
@@ -10,10 +10,10 @@
|
|||||||
- Usage of draw() in array mode (for floors, very fast)
|
- Usage of draw() in array mode (for floors, very fast)
|
||||||
|
|
||||||
### Assets
|
### Assets
|
||||||
[Download](http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/samples/floors/assets.zip)
|
You can download assets from [latest release](https://github.com/h4570/tyra/releases/latest) (unpack to `/repos/tyra/src/samples/dolphin/bin`)
|
||||||
|
|
||||||
### Screenshot
|
### Screenshot
|
||||||
|
|
||||||
[![Floors screenshot][floors-screenshot]](#)
|
[![Floors screenshot][floors-screenshot]](#)
|
||||||
|
|
||||||
[floors-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/1.29.1/samples/floors/floors.gif
|
[floors-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/floors.gif
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
@@ -21,9 +21,9 @@ const float CAMERA_Y = 30.0F;
|
|||||||
|
|
||||||
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing camera");
|
consoleLog("Initializing camera");
|
||||||
verticalLevel = 80.0F;
|
verticalLevel = 80.0F;
|
||||||
PRINT_LOG("Camera initialized!");
|
consoleLog("Camera initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera::~Camera() {}
|
Camera::~Camera() {}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include <utils/math.hpp>
|
#include <utils/math.hpp>
|
||||||
#include <utils/debug.hpp>
|
#include <utils/debug.hpp>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Constructors/Destructors
|
// Constructors/Destructors
|
||||||
@@ -26,7 +27,7 @@ FloorManager::FloorManager(int t_floorAmount, TextureRepository *t_texRepo)
|
|||||||
texRepo = t_texRepo;
|
texRepo = t_texRepo;
|
||||||
floorAmount = t_floorAmount;
|
floorAmount = t_floorAmount;
|
||||||
spirals = new Point[t_floorAmount];
|
spirals = new Point[t_floorAmount];
|
||||||
int floorSpiralMaxOffset = (int)Math::sqrt(t_floorAmount);
|
int floorSpiralMaxOffset = (int)sqrt(t_floorAmount);
|
||||||
calcSpiral(floorSpiralMaxOffset, floorSpiralMaxOffset);
|
calcSpiral(floorSpiralMaxOffset, floorSpiralMaxOffset);
|
||||||
initFloors();
|
initFloors();
|
||||||
trick = 0.0F;
|
trick = 0.0F;
|
||||||
@@ -50,7 +51,7 @@ FloorManager::~FloorManager()
|
|||||||
*/
|
*/
|
||||||
void FloorManager::calcSpiral(int X, int Y)
|
void FloorManager::calcSpiral(int X, int Y)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Calculating square spiral for floors");
|
consoleLog("Calculating square spiral for floors");
|
||||||
int x, y, dx;
|
int x, y, dx;
|
||||||
x = y = dx = 0;
|
x = y = dx = 0;
|
||||||
int dy = -1;
|
int dy = -1;
|
||||||
@@ -72,7 +73,7 @@ void FloorManager::calcSpiral(int X, int Y)
|
|||||||
x += dx;
|
x += dx;
|
||||||
y += dy;
|
y += dy;
|
||||||
}
|
}
|
||||||
PRINT_LOG("Square spiral calculated!");
|
consoleLog("Square spiral calculated!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialize all floors by:
|
/** Initialize all floors by:
|
||||||
@@ -81,7 +82,7 @@ void FloorManager::calcSpiral(int X, int Y)
|
|||||||
*/
|
*/
|
||||||
void FloorManager::initFloors()
|
void FloorManager::initFloors()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing floors");
|
consoleLog("Initializing floors");
|
||||||
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
|
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
|
||||||
floors[0].mesh.shouldBeFrustumCulled = true;
|
floors[0].mesh.shouldBeFrustumCulled = true;
|
||||||
floors[0].mesh.shouldBeLighted = true;
|
floors[0].mesh.shouldBeLighted = true;
|
||||||
@@ -91,11 +92,10 @@ void FloorManager::initFloors()
|
|||||||
{
|
{
|
||||||
floors[i].mesh.shouldBeFrustumCulled = true;
|
floors[i].mesh.shouldBeFrustumCulled = true;
|
||||||
floors[i].init(floors[0].mesh, spirals[i], i);
|
floors[i].init(floors[0].mesh, spirals[i], i);
|
||||||
texRepo->getByMesh(floors[0].mesh.getId(), floors[0].mesh.getMaterial(0).getId())
|
texRepo->getBySpriteOrMesh(floors[0].mesh.getMaterial(0).getId())->addLink(floors[i].mesh.getMaterial(0).getId());
|
||||||
->addLink(floors[i].mesh.getId(), floors[i].mesh.getMaterial(0).getId());
|
|
||||||
meshes[i] = &floors[i].mesh;
|
meshes[i] = &floors[i].mesh;
|
||||||
}
|
}
|
||||||
PRINT_LOG("Floors initialized!");
|
consoleLog("Floors initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Main floor loop.
|
/** Main floor loop.
|
||||||
@@ -123,18 +123,18 @@ void FloorManager::update(Player &t_player)
|
|||||||
for (u16 i = 0; i < floorAmount; i++)
|
for (u16 i = 0; i < floorAmount; i++)
|
||||||
{
|
{
|
||||||
floors[i].animate(t_player);
|
floors[i].animate(t_player);
|
||||||
|
MeshMaterial *material = &floors[i].mesh.getMaterial(0);
|
||||||
if (floors[i].isByAudioTriggered)
|
if (floors[i].isByAudioTriggered)
|
||||||
{
|
{
|
||||||
floors[i].mesh.color.r = trigColor.r;
|
material->color.r = trigColor.r;
|
||||||
floors[i].mesh.color.g = trigColor.g;
|
material->color.g = trigColor.g;
|
||||||
floors[i].mesh.color.b = trigColor.b;
|
material->color.b = trigColor.b;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
floors[i].mesh.color.r = defaultColor.r;
|
material->color.r = defaultColor.r;
|
||||||
floors[i].mesh.color.g = defaultColor.g;
|
material->color.g = defaultColor.g;
|
||||||
floors[i].mesh.color.b = defaultColor.b;
|
material->color.b = defaultColor.b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
LightManager::LightManager()
|
LightManager::LightManager()
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating light manager!");
|
consoleLog("Creating light manager!");
|
||||||
bulbsCount = 2;
|
bulbsCount = 2;
|
||||||
|
|
||||||
bulbs = new LightBulb[2];
|
bulbs = new LightBulb[2];
|
||||||
@@ -31,7 +31,7 @@ LightManager::LightManager()
|
|||||||
|
|
||||||
audioOffset = audioTick = 0;
|
audioOffset = audioTick = 0;
|
||||||
|
|
||||||
PRINT_LOG("Light manager created!");
|
consoleLog("Light manager created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
LightManager::~LightManager()
|
LightManager::~LightManager()
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include <modules/gif_sender.hpp>
|
#include <modules/gif_sender.hpp>
|
||||||
#include <utils/debug.hpp>
|
#include <utils/debug.hpp>
|
||||||
#include <utils/math.hpp>
|
#include <utils/math.hpp>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
// ----
|
// ----
|
||||||
// Constructors/Destructors
|
// Constructors/Destructors
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
|
|
||||||
Enemy::Enemy(TextureRepository *t_texRepo)
|
Enemy::Enemy(TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating enemy object");
|
consoleLog("Creating enemy object");
|
||||||
|
|
||||||
meshes = new Mesh[getMeshesCount()];
|
meshes = new Mesh[getMeshesCount()];
|
||||||
drawMeshes = new Mesh *[getMeshesCount()];
|
drawMeshes = new Mesh *[getMeshesCount()];
|
||||||
@@ -47,7 +48,7 @@ Enemy::Enemy(TextureRepository *t_texRepo)
|
|||||||
|
|
||||||
isKilled = true;
|
isKilled = true;
|
||||||
|
|
||||||
PRINT_LOG("Enemy object created!");
|
consoleLog("Enemy object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Enemy::~Enemy()
|
Enemy::~Enemy()
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Creating player object");
|
consoleLog("Creating player object");
|
||||||
texRepo = t_texRepo;
|
texRepo = t_texRepo;
|
||||||
audio = t_audio;
|
audio = t_audio;
|
||||||
gravity = 0.1F;
|
gravity = 0.1F;
|
||||||
@@ -53,7 +53,7 @@ Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
|
|||||||
boomAdpcm = audio->loadADPCM("sounds/boom.adpcm");
|
boomAdpcm = audio->loadADPCM("sounds/boom.adpcm");
|
||||||
audio->setADPCMVolume(70, 0);
|
audio->setADPCMVolume(70, 0);
|
||||||
|
|
||||||
PRINT_LOG("Player object created!");
|
consoleLog("Player object created!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Player::~Player()
|
Player::~Player()
|
||||||
|
|||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
Ui::Ui(TextureRepository *t_texRepo)
|
Ui::Ui(TextureRepository *t_texRepo)
|
||||||
{
|
{
|
||||||
PRINT_LOG("Initializing ui");
|
consoleLog("Initializing ui");
|
||||||
|
|
||||||
isTask1Done = false;
|
isTask1Done = false;
|
||||||
isTask2Done = false;
|
isTask2Done = false;
|
||||||
@@ -52,7 +52,7 @@ Ui::Ui(TextureRepository *t_texRepo)
|
|||||||
grayCheckboxTex->addLink(task1Checkbox.getId());
|
grayCheckboxTex->addLink(task1Checkbox.getId());
|
||||||
grayCheckboxTex->addLink(task2Checkbox.getId());
|
grayCheckboxTex->addLink(task2Checkbox.getId());
|
||||||
|
|
||||||
PRINT_LOG("Ui initialized!");
|
consoleLog("Ui initialized!");
|
||||||
}
|
}
|
||||||
|
|
||||||
Ui::~Ui() {}
|
Ui::~Ui() {}
|
||||||
@@ -66,13 +66,13 @@ void Ui::update(const Player &player)
|
|||||||
if (!isTask1Done && player.getJumpCount() >= 10)
|
if (!isTask1Done && player.getJumpCount() >= 10)
|
||||||
{
|
{
|
||||||
isTask1Done = true;
|
isTask1Done = true;
|
||||||
grayCheckboxTex->removeLinkBySprite(task1Checkbox.getId());
|
grayCheckboxTex->removeLinkById(task1Checkbox.getId());
|
||||||
blueCheckboxTex->addLink(task1Checkbox.getId());
|
blueCheckboxTex->addLink(task1Checkbox.getId());
|
||||||
}
|
}
|
||||||
if (!isTask2Done && player.getKilledEnemiesCount() >= 10)
|
if (!isTask2Done && player.getKilledEnemiesCount() >= 10)
|
||||||
{
|
{
|
||||||
isTask2Done = true;
|
isTask2Done = true;
|
||||||
grayCheckboxTex->removeLinkBySprite(task2Checkbox.getId());
|
grayCheckboxTex->removeLinkById(task2Checkbox.getId());
|
||||||
blueCheckboxTex->addLink(task2Checkbox.getId());
|
blueCheckboxTex->addLink(task2Checkbox.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
.vscode/
|
||||||
|
fonts/**
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
EE_BIN = unit_tests.elf
|
||||||
|
EE_LIBS = -ltyra
|
||||||
|
EE_OBJS = \
|
||||||
|
tests/utils/math.o \
|
||||||
|
main.o
|
||||||
|
|
||||||
|
all: $(EE_BIN)
|
||||||
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
|
rm $(EE_OBJS)
|
||||||
|
|
||||||
|
rebuild-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make EE_CXXFLAGS="-DNDEBUG $(EE_CXXFLAGS)"
|
||||||
|
|
||||||
|
rebuild-dbg-engine:
|
||||||
|
cd $(TYRA)/src/engine && make clean && make
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f $(EE_OBJS)
|
||||||
|
|
||||||
|
run: $(EE_BIN)
|
||||||
|
killall -v ps2client || true
|
||||||
|
ps2client reset
|
||||||
|
ps2client reset
|
||||||
|
$(EE_STRIP) --strip-all $(EE_BIN)
|
||||||
|
mv $(EE_BIN) bin/$(EE_BIN)
|
||||||
|
rm $(EE_OBJS)
|
||||||
|
cd bin/ && ps2client execee host:$(EE_BIN)
|
||||||
|
|
||||||
|
run-pcsx2:
|
||||||
|
taskkill.exe /f /t /im pcsx2.exe || true
|
||||||
|
$(WSL_LINUX_PCSX2)/pcsx2.exe --elf=$(WSL_MAKE_WINDOWS)\\repos\\tyra\\src\\unit_tests\\bin\\unit_tests.elf
|
||||||
|
|
||||||
|
show:
|
||||||
|
cat bin/test-result.txt
|
||||||
|
|
||||||
|
include $(TYRA)/src/engine/Makefile.pref
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
# Ignore everything in this directory
|
||||||
|
*
|
||||||
|
# Except this file
|
||||||
|
!.gitignore
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2021, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
// To run unit tests
|
||||||
|
// 1. Make sure that your $(PCSX2_PATH) and $(WSL_TYRA_PATH) Makefile variables are correct
|
||||||
|
// 2. make && make run-pcsx2 && make show
|
||||||
|
// 3. Click 'X' in PCSX2 when screen will be on memory card selection stage
|
||||||
|
// 4. Voila :)
|
||||||
|
|
||||||
|
const int CUSTOM_ARGC = 5;
|
||||||
|
char const *CUSTOM_ARGV[] = {
|
||||||
|
"",
|
||||||
|
"--reporter",
|
||||||
|
"console",
|
||||||
|
"--out",
|
||||||
|
"test-result.txt"};
|
||||||
|
|
||||||
|
#define CATCH_CONFIG_MAIN
|
||||||
|
#define CATCH_CONFIG_NO_POSIX_SIGNALS
|
||||||
|
|
||||||
|
#include "catch.hpp"
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
# ______ ____ ___
|
||||||
|
# | \/ ____| |___|
|
||||||
|
# | | | \ | |
|
||||||
|
#-----------------------------------------------------------------------
|
||||||
|
# Copyright 2021, tyra - https://github.com/h4570/tyra
|
||||||
|
# Licenced under Apache License 2.0
|
||||||
|
# Sandro Sobczyński <sandro.sobczynski@gmail.com>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <catch.hpp>
|
||||||
|
#include <utils/math.hpp>
|
||||||
|
|
||||||
|
SCENARIO("min(a,b) greater 'a' should return 'b'", "[math.cpp]")
|
||||||
|
{
|
||||||
|
REQUIRE(Math::min(10, 5) == 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
SCENARIO("min(a,b) greater 'b' should return 'a'", "[math.cpp]")
|
||||||
|
{
|
||||||
|
REQUIRE(Math::min(-5, 5) == -5);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user