65 Commits

Author SHA1 Message Date
h4570 c7f210706d Merge branch 'master' into develop 2021-05-28 22:00:42 +02:00
Sandro Sobczyński 3a06ac548d Update README.MD 2021-05-28 21:59:34 +02:00
Sandro Sobczyński 8225abf328 Update README.MD 2021-05-28 21:59:24 +02:00
Sandro Sobczyński 2e23914c17 Update README.MD 2021-05-28 21:58:40 +02:00
Sandro Sobczyński e7c2f8a7c7 Update README.MD 2021-05-28 21:58:19 +02:00
Sandro Sobczyński 756fb216a4 Update README.MD 2021-05-28 21:58:00 +02:00
Sandro Sobczyński de4ce28839 Update README.MD 2021-05-28 21:57:16 +02:00
Sandro Sobczyński ed59d6b254 Update README.MD 2021-05-28 21:56:55 +02:00
Sandro Sobczyński 3fe9715958 Update README.MD 2021-05-28 21:56:39 +02:00
Sandro Sobczyński cba177f2db Update README.MD 2021-05-28 21:55:23 +02:00
Sandro Sobczyński 781c97eb73 updated version 2021-05-28 21:40:47 +02:00
Sandro Sobczyński 5245ba3f55 updated version 2021-05-28 21:40:09 +02:00
Sandro Sobczyński f0b5d25a27 updated version 2021-05-28 21:35:56 +02:00
h4570 5f22c02d2e added bin folders
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:31:28 +02:00
h4570 d63bd6cb0e fixed typo
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:26:47 +02:00
h4570 921f34eb4c fixed typo
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:26:16 +02:00
Sandro Sobczyński 385e553e5a changed tyra env path 2021-05-28 21:24:47 +02:00
Sandro Sobczyński e4230f1b62 added tyra env path 2021-05-28 21:22:10 +02:00
Sandro Sobczyński 94a353cdb8 Update CHANGELOG.MD 2021-05-28 21:17:51 +02:00
Sandro Sobczyński 8a162be036 Create compilation.yml 2021-05-28 21:16:56 +02:00
Sandro Sobczyński 1d273de455 Update README.MD 2021-05-28 21:08:57 +02:00
h4570 eecfc0b6c2 updated changelog
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:08:11 +02:00
h4570 7ff8153086 modified makefiles
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:08:07 +02:00
h4570 9cb52ff620 added install tutorial
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:07:58 +02:00
h4570 3023bb7501 update
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 21:07:46 +02:00
h4570 762e7eada2 modified changelog
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 19:40:20 +02:00
h4570 70ea8e47ba modified makefiles
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 19:31:23 +02:00
h4570 dd8499abad fixed PRINT_LOG in samples
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-28 19:30:45 +02:00
Sandro Sobczyński 0816f522bb Merge pull request #95 from h4570/assert
Add assertions
2021-05-26 19:39:08 +02:00
h4570 fafc66d35c replaced PRINT_LOG and PRINT_ERR
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-26 19:36:59 +02:00
h4570 d8458b98e0 added assert
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-25 21:31:20 +02:00
h4570 d0d7ed85e5 added pcsx2 to makefile (by wsl)
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-25 21:27:56 +02:00
Sandro Sobczyński a80f62e843 Merge pull request #94 from h4570/unit-test-proj
Unit tests support
2021-05-25 19:19:45 +02:00
h4570 8b0233a45d added unit tests support
Signed-off-by: h4570 <sandro.sobczynski@gmail.com>
2021-05-25 19:18:21 +02:00
Sandro Sobczyński 10b275055c Merge pull request #93 from Foxar/feature/bmploader_colordataoffset
bmp_loader: Auto skipping of color table information.
2021-04-23 20:02:09 +02:00
Sandro Sobczyński 164d9f558c Merge pull request #92 from Foxar/feature/bmploader_bitchecking
Feature/bmploader bitchecking
2021-04-23 20:00:45 +02:00
Foxar 247e71a407 Oops, uncommented function that was commented by accident. 2021-04-23 15:44:54 +02:00
Foxar ea49543542 Added offset to pixel data reading in bmp_loader 2021-04-23 15:36:44 +02:00
Foxar 20de0dc17d Removed redundant print 2021-04-21 10:55:25 +02:00
Foxar 1090801f4e Added checking for 24bitmap in file. 2021-04-21 10:41:32 +02:00
Sandro Sobczyński 7b43c0c90f Merge pull request #91 from Foxar/develop
Fixed loading erros in .obj loader when loading models without UVMap or Normals.
2021-04-19 11:35:06 +02:00
Foxar b0ae873a88 Adjusted scanf results checking to correct value, fixing the loading of models without set normals. 2021-04-19 11:19:18 +02:00
Foxar 7b3a28065b Fixed loading errors when loading models without Normals or UVMaps, by modifying the fscanf format, and adding a missing break statement. 2021-04-19 10:07:38 +02:00
Sandro Sobczyński 589b3b03a4 Merge pull request #90 from Foxar/develop
Dolphin sample deep diving crashing fix.
2021-04-18 23:41:09 +02:00
Foxar 611d4f76be Replaced renderer::draw() call with array of meshes and size of array as argument with a loop iterating through water tile array, calling draw on the individual water tiles. 2021-04-18 23:02:21 +02:00
Michał Mostowik bf0c65a14c Merge pull request #6 from h4570/develop
Update develop to newest version
2021-04-18 22:18:13 +02:00
Michał Mostowik ab0c999117 Merge pull request #5 from h4570/develop
Updating develop with h4570/tyra develop
2021-04-18 14:32:42 +02:00
Sandro Sobczyński 28599512e4 Update README.MD 2021-04-13 20:26:58 +02:00
Sandro Sobczyński db6c84ba11 Merge pull request #89 from Wellinator/cube-sample
Create basic cube sample
2021-04-13 20:22:33 +02:00
Wellinator b0c94a1602 Merge branch 'cube-sample' of github.com:Wellinator/tyra into cube-sample 2021-04-13 13:48:39 -03:00
Wellinator f34284591f Add README.MD 2021-04-13 13:48:29 -03:00
Sandro Sobczyński 7203f6f5c4 Delete readme.txt 2021-04-13 17:13:58 +02:00
Wellinator 94f6e9fbf2 Add header in all files in cube sample 2021-04-13 08:23:46 -03:00
Wellinator 18ba08dc7a Remove light_manager 2021-04-09 13:36:40 -03:00
Wellinator 9dd69317e3 Add readme file 2021-04-09 13:30:41 -03:00
Wellinator 24509f7f20 remove bin dir 2021-04-09 13:26:06 -03:00
Wellinator 9268628ccd update .gitignore 2021-04-09 13:23:25 -03:00
Wellinator 4160bddc4b Update scale and speed rotation 2021-04-09 13:19:12 -03:00
Wellinator e022fcdafe Update cube mesh object 2021-04-09 13:18:34 -03:00
Wellinator 444990a262 Change background color 2021-04-09 13:16:50 -03:00
Wellinator b749a80a25 Add rotation function 2021-04-08 08:33:06 -03:00
Wellinator e43fae88e8 Setup initial cube sample 2021-04-07 08:17:10 -03:00
Wellinator 11717f42eb Initial setup for Cube sample 2021-04-02 09:01:14 -03:00
Sandro Sobczyński 142bf60a6d Update README.MD 2021-02-07 17:03:16 +01:00
Sandro Sobczyński 9efd8ab3e1 Update README.MD 2021-02-07 14:13:31 +01:00
62 changed files with 19016 additions and 368 deletions
+60
View File
@@ -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
View File
@@ -1,4 +1,5 @@
.vscode/
.idea/
# ---
+17
View File
@@ -4,6 +4,22 @@ 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/),
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
@@ -111,6 +127,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Makefile
- 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.1.0]: https://github.com/h4570/tyra/compare/1.0.0...1.1.0
+62 -29
View File
@@ -9,7 +9,7 @@
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/github-splash.png" alt="Logo" width="100%" height="auto">
</a>
<h3 align="center">Tyra - alpha 1.31.2</h3>
<h3 align="center">Tyra - alpha 1.36.3</h3>
<p align="center">
Open source game engine for PlayStation 2™
@@ -25,41 +25,63 @@
</p>
</p>
[![Stargazers repo roster for h4570/tyra](https://reporoster.com/stars/h4570/tyra)](https://github.com/h4570/tyra/stargazers)
## Table of Contents
* [About the Project](#about-the-project)
* [Samples](#samples)
* [About project](#about-project)
* [Tyra features](#tyra-features)
* [Description](#description)
* [Features](#features)
* [Branches](#branches)
* [Getting Started](#getting-started)
* [Installation](#installation)
* [Prerequisites](#prerequisites)
* [Roadmap](#roadmap)
* [Tyra team](#tyra-team)
* [Contributing](#contributing)
* [License](#license)
* [Built With](#built-with)
* [Acronyms](#acronyms)
* [Thanks](#thanks)
## About The Project
<br />
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/tyra.gif" alt="sample" width="600" height="auto">
## About the Project
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/tyra.gif" alt="Sample code" width="600" height="auto">
<img src="http://apgcglz.cluster028.hosting.ovh.net/tyra/dolphin.gif " alt="Sample game" width="500" height="auto">
### Samples
* [Dolphin](https://github.com/h4570/tyra/tree/master/src/samples/dolphin)
* [Floors](https://github.com/h4570/tyra/tree/master/src/samples/floors)
* [Cube](https://github.com/h4570/tyra/tree/master/src/samples/cube)
### About project
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.
### Description
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.
Tyra takes care for you, and rendering, coprocessors communication, synchronization and many more low-level stuff is already done.
**Why was this project created?**
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"
* 2D support - PNG & BMP
* Frustum culling, backface culling
@@ -75,37 +97,38 @@ Tyra takes care for you, and rendering, coprocessors communication, synchronizat
* Master - monthly releases - tested on PS2 & PCSX2.
* Develop - daily builds - can be unstable.
<br />
## Getting Started
### Installation [![Discord](https://img.shields.io/badge/discord-Tyra-brightgreen?logo=discord)](https://discord.gg/NhhTmg3Gm5)
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.
### Installation
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:
[![Discord](https://img.shields.io/badge/discord-Tyra-brightgreen?logo=discord)](https://discord.gg/NhhTmg3Gm5)
### 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)
* At least #e8e9edb PS2SDK (06.02.2021) - [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/)
<br />
## 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 run .elf in PCSX2, be sure that you have version >=1.6 and **Host access** enabled in PCSX2 configuration file.
* If you want to use your own .obj file, please check "triangulate faces" in blender. 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 for next master release:
[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).
<br />
## 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**.
@@ -116,26 +139,34 @@ 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`)
5. Open a Pull Request
<br />
## License
Distributed under the Apache License 2.0 License. See `LICENSE` for more information.
<br />
## 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
* 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.
* 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
<br />
## Thanks
Without these guys, everything would be harder:
* 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
* Guilherme Lampert - for code sources
* Jesper Svennevid, Daniel Collin - for openvcl's code samples
@@ -144,6 +175,8 @@ Without these guys, everything would be harder:
* And so many other guys. Thanks!
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 />
<a href="https://github.com/h4570/tyra">
+210
View File
@@ -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`
+2 -2
View File
@@ -35,10 +35,10 @@ all: $(EE_OBJS)
ar rcs $(LIB_NAME) $(EE_OBJS)
rm -f $(EE_OBJS)
#%.vcl: %.vclpp
# %.vcl: %.vclpp
# $(EE_VCLPP) $< $@
#%.vsm: %.vcl
# %.vsm: %.vcl
# $(EE_VCL) $< >> $@
%.o: %.vsm
+3 -4
View File
@@ -1,8 +1,7 @@
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_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(TYRA_DIR) $(EE_LDFLAGS)
EE_CFLAGS := -DHAVE_LIBPNG -D_XCDVD -DHAVE_ZLIB $(EE_CFLAGS)
EE_CXXFLAGS := -DHAVE_LIBPNG -D_XCDVD -DHAVE_ZLIB $(EE_CXXFLAGS)
EE_INCS := -I$(TYRA)/src/engine/include -I$(PS2SDK)/ports/include $(EE_INCS)
EE_LDFLAGS := -L$(PS2SDK)/ports/lib -L$(TYRA)/src/engine $(EE_LDFLAGS)
EE_CXXFLAGS := -DHAVE_LIBJPEG -DHAVE_LIBTIFF -DHAVE_LIBPNG -DHAVE_ZLIB -D_XCDVD $(EE_CXXFLAGS)
EE_DVP = dvp-as
EE_VCL = vcl
EE_VCLPP = vclpp
+1 -5
View File
@@ -52,16 +52,12 @@ void Engine::setDefaultScreen()
void Engine::init(Game *t_game, u32 t_gifPacketSize)
{
if (isInitialized)
PRINT_ERR("Already initialized!");
else
{
assertMsg(!isInitialized, "Engine was already initialized!");
game = t_game;
renderer = new Renderer(t_gifPacketSize, &screen);
isInitialized = true;
game->onInit();
gameLoop();
}
}
/** Do not call this method. This is used in gameLoop() to maintain multithreading */
+1 -3
View File
@@ -167,10 +167,8 @@ public:
void removeLinkById(const u32 &t_id)
{
s32 index = getIndexOfLink(t_id);
if (index != -1)
assertMsg(index != -1, "Cant remove link, because it was not found!");
removeLinkByIndex(index);
else
PRINT_ERR("Cant remove link, because it was not found!");
}
private:
@@ -119,10 +119,8 @@ public:
const void removeById(const u32 &t_texId)
{
s32 index = getIndexOf(t_texId);
if (index != -1)
assertMsg(index != -1, "Cant remove texture, because it was not found!");
removeByIndex(index);
else
PRINT_ERR("Cant remove texture, because it was not found!");
}
private:
+12 -8
View File
@@ -11,14 +11,16 @@
#ifndef _TYRA_DEBUG_
#define _TYRA_DEBUG_
#include <tamtypes.h>
#include <math3d.h>
#include <stdio.h>
#ifdef NDEBUG
#define consoleLog(message) ((void)0)
#define assertMsg(condition, message) ((void)0)
#else // IF Debug
#include <stdio.h>
class Debug
{
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");
@@ -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")
#define PRINT_ERR(TEXT) Debug::errTrap(TEXT, __FILE__)
#endif
#endif // _TYRA_DEBUG_
+6 -6
View File
@@ -17,12 +17,12 @@ class String
{
public:
static char *createU32ToString(u32 a);
static char *createWithLeadingZeros(char *a);
static char *createCopy(char *source);
static u32 getLength(char *a);
static char *createConcatenated(char *a, char *b);
static char *createWithoutExtension(char *source);
static char *createU32ToString(const u32 a);
static char *createWithLeadingZeros(const char *a);
static char *createCopy(const char *source);
static u32 getLength(const char *a);
static char *createConcatenated(const char *a, const char *b);
static char *createWithoutExtension(const char *source);
};
#endif
+10 -7
View File
@@ -38,25 +38,28 @@ void BmpLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
delete[] path_part1;
delete[] path_part2;
FILE *file = fopen(path, "rb");
if (file == NULL)
{
PRINT_ERR("Failed to load .bmp file!");
return;
}
assertMsg(file != NULL, "Failed to load .bmp file!");
unsigned char header[54];
fread(header, sizeof(unsigned char), 54, file);
u32 width = (u32)header[18];
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);
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);
unsigned char row[rowPadded];
//Offset file stream to raster data
fseek(file, dataOffset, SEEK_SET);
u32 x = 0;
for (u32 i = 0; i < height; i++)
{
+3 -4
View File
@@ -36,11 +36,10 @@ DffLoader::~DffLoader() {}
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);
FILE *file = fopen(path, "rb");
if (file == NULL)
PRINT_ERR("Failed to load .dff file!");
assertMsg(file != NULL, "Failed to load .dff file!");
fseek(file, 0L, SEEK_END);
long fileSize = ftell(file);
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);
o_result->calculateBoundingBoxes();
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)
+4 -13
View File
@@ -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)
{
PRINT_LOG("Loading new MD2 file");
consoleLog("Loading new MD2 file");
char *part1 = String::createConcatenated(t_subpath, t_nameWithoutExtension);
char *part2 = String::createConcatenated("host:", part1);
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;
FILE *file = fopen(finalPath, "rb");
if (file == NULL)
{
PRINT_ERR("Failed to load .md2 file!");
return NULL;
}
assertMsg(file != NULL, "Failed to load .md2 file!");
fread((char *)&header, sizeof(md2_t), 1, file);
if ((header.ident != MD2_IDENT) && (header.version != MD2_VERSION))
{
PRINT_ERR("This MD2 file was not in correct format!");
return NULL;
}
assertMsg((header.ident == MD2_IDENT) && (header.version == MD2_VERSION), "This MD2 file was not in correct format!");
u32 framesCount = header.num_frames;
u32 vertexCount = header.num_xyz;
@@ -147,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;
o_framesCount = framesCount;
for (u32 i = 0; i < framesCount; i++)
+9 -15
View File
@@ -30,8 +30,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
{
char *path = String::createConcatenated("host:", t_filename);
FILE *file = fopen(path, "rb");
if (file == NULL)
PRINT_ERR("Failed to load .obj file!");
assertMsg(file != NULL, "Failed to load .obj file!");
allocateObjMemory(file, o_result);
fseek(file, 0, SEEK_SET);
u32 verticesI = 0, cordsI = 0, normalsI = 0, faceI = 0, vertexIndex[3], coordIndex[3], normalIndex[3];
@@ -76,7 +75,6 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
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 */
@@ -89,7 +87,7 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
}
break;
/** Loaded only two digits (V, VT) succesfuly. Not setting VN. */
case 2:
case 3:
{
fscanf(file, "%d/%d/ %d/%d/ %d/%d/\n",
&vertexIndex[0], &coordIndex[0],
@@ -101,38 +99,34 @@ void ObjLoader::load(MeshFrame *o_result, char *t_filename, float t_scale, u8 t_
case 1:
{
/** Check for existance of V/// configuration.. */
newerMatches = fscanf(file, "%d/// %d/// %d///\n", x, x, x);
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]);
fscanf(file, "%d// %d// %d//\n", &vertexIndex[0], &vertexIndex[1], &vertexIndex[2]);
}
else
{
/** Failed, checking configuration V//VN */
newerMatches = fscanf(file, "%d//%d %d//%d %d//%d", x, x, x, x, x, x);
fsetpos(file, &start);
if (newerMatches == 6)
{
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]);
}
else
{
/**Unknown configuration.*/
PRINT_ERR("Unknown .obj face for .obj file!");
}
}
break;
}
break;
default:
PRINT_ERR("Unknown faces format in .obj file!");
{
assertMsg(true == false, "Unknown faces format in .obj file!");
break;
}
}
if (matches == 9 || matches == 2 || matches == 1)
{
+6 -19
View File
@@ -40,9 +40,7 @@ void PngLoader::load(Texture &o_texture, char *t_subfolder, char *t_name, char *
delete[] path_part2;
FILE *file = fopen(path, "rb");
if (file == NULL)
PRINT_ERR("Failed to open .png file!");
assertMsg(file != NULL, "Failed to open .png file!");
png_structp png_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;
int bit_depth, color_type, interlace_type;
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, (png_voidp)NULL, NULL, NULL);
if (!png_ptr)
PRINT_ERR("PNG struct info init failed(1)!");
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
assertMsg(png_ptr, "PNG read struct init failed!");
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
PRINT_ERR("PNG struct info init failed(2)!");
if (setjmp(png_jmpbuf(png_ptr)))
PRINT_ERR("PNG reader fatal error!");
assertMsg(info_ptr, "PNG info struct init failed!");
assertMsg(!setjmp(png_jmpbuf(png_ptr)), "PNG reader fatal error!");
png_init_io(png_ptr, file);
png_set_sig_bytes(png_ptr, sig_read);
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_set_strip_16(png_ptr);
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;
break;
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);
+8 -21
View File
@@ -70,9 +70,8 @@ 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)
{
if (t_framesCount == 0)
PRINT_ERR("Frames count cannot be 0!");
else if (t_framesCount == 1)
assertMsg(t_framesCount != 0, "Frames count cannot be 0!");
if (t_framesCount == 1)
loadObj(t_subfolder, t_objFile, t_scale, t_invertT);
else
{
@@ -132,39 +131,27 @@ void Mesh::loadFrom(const Mesh &t_mesh)
void Mesh::playAnimation(const u32 &t_startFrame, const u32 &t_endFrame)
{
if (framesCount > 1)
{
if (t_endFrame >= framesCount)
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-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.");
assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
animState.startFrame = t_startFrame;
animState.endFrame = t_endFrame;
if (animState.currentFrame == t_startFrame)
animState.nextFrame = t_endFrame;
else
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)
{
if (framesCount > 1)
{
if (t_endFrame >= framesCount)
PRINT_ERR("End frame value is too high. Valid range: (0, getFramesCount()-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.");
assertMsg(t_endFrame < framesCount, "End frame value is too high. Valid range: (0, getFramesCount()-1)");
animState.startFrame = t_startFrame;
animState.endFrame = t_endFrame;
animState.isStayFrameSet = true;
animState.stayFrame = t_stayFrame;
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()
+5 -23
View File
@@ -52,11 +52,7 @@ MeshFrame::~MeshFrame()
void MeshFrame::allocateSTs(const u32 &t_val)
{
if (_areSTsAllocated)
{
PRINT_ERR("Can't allocate STs, because were already set!");
return;
}
assertMsg(!_areSTsAllocated, "Can't allocate STs, because were already set!");
stsCount = t_val;
sts = new Point[t_val];
_areSTsAllocated = true;
@@ -64,11 +60,7 @@ void MeshFrame::allocateSTs(const u32 &t_val)
void MeshFrame::allocateVertices(const u32 &t_val)
{
if (_areVerticesAllocated)
{
PRINT_ERR("Can't allocate vertices, because were already set!");
return;
}
assertMsg(!_areVerticesAllocated, "Can't allocate vertices, because were already set!");
vertexCount = t_val;
vertices = new Vector3[t_val];
_areVerticesAllocated = true;
@@ -76,11 +68,7 @@ void MeshFrame::allocateVertices(const u32 &t_val)
void MeshFrame::allocateNormals(const u32 &t_val)
{
if (_areNormalsAllocated)
{
PRINT_ERR("Can't allocate normals, because were already set!");
return;
}
assertMsg(!_areNormalsAllocated, "Can't allocate normals, because were already set!");
normalsCount = t_val;
normals = new Vector3[t_val];
_areNormalsAllocated = true;
@@ -88,11 +76,7 @@ void MeshFrame::allocateNormals(const u32 &t_val)
void MeshFrame::allocateMaterials(const u32 &t_val)
{
if (_areMaterialsAllocated)
{
PRINT_ERR("Can't allocate materials, because were already set!");
return;
}
assertMsg(!_areMaterialsAllocated, "Can't allocate materials, because were already set!");
materialsCount = t_val;
materials = new MeshMaterial[t_val];
_areMaterialsAllocated = true;
@@ -100,9 +84,7 @@ void MeshFrame::allocateMaterials(const u32 &t_val)
void MeshFrame::calculateBoundingBoxes()
{
if (!_areVerticesAllocated)
PRINT_ERR("Can't calculate bounding box, because vertices were not allocated!");
assertMsg(_areVerticesAllocated, "Can't calculate bounding box, because vertices were not allocated!");
for (u32 i = 0; i < materialsCount; i++)
materials->calculateBoundingBox(vertices, vertexCount);
+4 -12
View File
@@ -52,11 +52,7 @@ MeshMaterial::~MeshMaterial()
void MeshMaterial::allocateFaces(const u32 &t_val)
{
if (_areFacesAllocated)
{
PRINT_ERR("Can't allocate faces, because were already set!");
return;
}
assertMsg(!_areFacesAllocated, "Can't allocate faces, because were already set!");
facesCount = t_val;
stFaces = new u32[t_val];
normalFaces = new u32[t_val];
@@ -66,11 +62,7 @@ void MeshMaterial::allocateFaces(const u32 &t_val)
void MeshMaterial::setName(char *t_val)
{
if (_isNameSet)
{
PRINT_ERR("Can't set name, because was already set!");
return;
}
assertMsg(!_isNameSet, "Can't set name, because was already set!");
name = String::createCopy(t_val);
_isNameSet = true;
}
@@ -143,8 +135,8 @@ void MeshMaterial::calculateBoundingBox(Vector3 *t_vertices, u32 t_vertCount)
boundingBox[7].set(hiX, hiY, hiZ);
_isBoundingBoxCalculated = true;
//BoundingBox is declared on the heap to prevent any ill-formed default
//constructor instantiated BoundingBox objects.
// BoundingBox is declared on the heap to prevent any ill-formed default
// constructor instantiated BoundingBox objects.
boundingBoxObj = new BoundingBox(boundingBox);
}
+3 -12
View File
@@ -41,13 +41,8 @@ Texture::~Texture()
void Texture::setSize(const u8 &t_width, const u8 &t_height, const TextureType &t_type)
{
if (_isSizeSet)
{
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.");
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.");
width = t_width;
height = t_height;
_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)
{
if (_isNameSet)
{
PRINT_ERR("Can't set name, because was already set!");
return;
}
assertMsg(!_isNameSet, "Can't set name, because was already set!");
name = String::createCopy(t_val);
_isNameSet = true;
}
+23 -31
View File
@@ -52,20 +52,15 @@ void Audio::loadSong(char *t_path)
char *fullFilename = String::createConcatenated("host:", t_path);
wav = fopen(fullFilename, "rb");
delete[] fullFilename;
if (wav == NULL)
PRINT_ERR("Failed to open wav file!");
else
{
assertMsg(wav != NULL, "Failed to open wav file!");
rewindSongToStart();
songLoaded = true;
PRINT_LOG("Song loaded!");
}
consoleLog("Song loaded!");
}
void Audio::playSong()
{
if (!songLoaded)
PRINT_ERR("Cant play song because was not loaded!");
assertMsg(songLoaded, "Cant play song because was not loaded!");
if (songFinished)
rewindSongToStart();
volume = realVolume;
@@ -105,8 +100,7 @@ void Audio::removeSongListener(const u32 &t_id)
index = i;
break;
}
if (index == -1)
PRINT_ERR("Cant remove listener because given id was not found!");
assertMsg(index != -1, "Cant remove listener because given id was not found!");
delete songListeners[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))
{
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);
return result;
@@ -143,7 +137,7 @@ void Audio::playADPCM(audsrv_adpcm_t *t_adpcm)
if (audsrv_play_adpcm(t_adpcm))
{
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))
{
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)
{
PRINT_LOG("Creating audio thread");
consoleLog("Creating audio thread");
// fileService = t_fileService;
extern void *_gp;
thread.func = (void *)Audio::mainThread;
@@ -168,11 +162,11 @@ void Audio::startThread(FileService *t_fileService)
thread.stack_size = getThreadStackSize();
thread.gp_reg = (void *)&_gp;
thread.initial_priority = 0x17;
if ((threadId = CreateThread(&thread)) < 0)
PRINT_ERR("Create audio thread failed!");
PRINT_LOG("Audio thread created");
threadId = CreateThread(&thread);
assertMsg(threadId >= 0, "Create audio thread failed!");
consoleLog("Audio thread created");
StartThread(threadId, NULL);
PRINT_LOG("Audio thread started");
consoleLog("Audio thread started");
}
/** Main thread loop */
@@ -256,25 +250,23 @@ void Audio::rewindSongToStart()
/** Initialize semaphore which will wait until chunk of the song is not finished. */
void Audio::initSema()
{
PRINT_LOG("Creating audio semaphore");
consoleLog("Creating audio semaphore");
sema.init_count = 0;
sema.max_count = 1;
sema.option = 0;
fillbufferSema = CreateSema(&sema);
PRINT_LOG("Audio semaphore created");
consoleLog("Audio semaphore created");
}
/** Load LIBSD and AUDSRV modules */
void Audio::loadModules()
{
PRINT_LOG("Modules loading started (LIBSD, AUDSRV)");
consoleLog("Modules loading started (LIBSD, AUDSRV)");
int ret = SifLoadModule("rom0:LIBSD", 0, NULL);
if (ret == -203)
PRINT_ERR("LIBSD loading failed!");
assertMsg(ret != -203, "LIBSD loading failed!");
ret = SifLoadModule("host:AUDSRV.IRX", 0, NULL);
if (ret == -203)
PRINT_ERR("AUDSRV.IRX loading failed!");
PRINT_LOG("Audio modules loaded");
assertMsg(ret != -203, "AUDSRV.IRX loading failed!");
consoleLog("Audio modules loaded");
}
/**
@@ -283,26 +275,26 @@ void Audio::loadModules()
*/
void Audio::initAUDSRV()
{
PRINT_LOG("Initializing AUDSRV");
consoleLog("Initializing AUDSRV");
int ret = audsrv_init();
if (ret != 0)
{
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();
if (ret != 0)
{
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);
if (ret != 0)
{
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!");
}
/**
+2 -2
View File
@@ -21,7 +21,7 @@
CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
: screen(t_screen)
{
PRINT_LOG("Initializing frustum");
consoleLog("Initializing frustum");
farPlaneDist = screen->farPlaneDist;
nearPlaneDist = screen->nearPlaneDist;
float tang = tanf(screen->fov * Math::HALF_ANG2RAD);
@@ -31,7 +31,7 @@ CameraBase::CameraBase(ScreenSettings *t_screen, Vector3 *t_position)
farWidth = farHeight * screen->aspectRatio;
p_position = t_position;
up.set(0.0F, 1.0F, 0.0F);
PRINT_LOG("CameraBase initialized!");
consoleLog("CameraBase initialized!");
}
// ----
+7 -10
View File
@@ -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 taskIndex = getIndexOf(t_taskId);
if (taskIndex == -1)
PRINT_ERR("Task was not found!");
assertMsg(taskIndex != -1, "Task was not found!");
s32 result = tasks[taskIndex].readStatus;
if (result != -2137)
removeByIndex(taskIndex);
@@ -54,10 +53,8 @@ s32 FileService::isTaskDone(const u32 &t_taskId)
const void FileService::removeById(const u32 &t_taskId)
{
s32 index = getIndexOf(t_taskId);
if (index != -1)
assertMsg(index != -1, "Cant remove task, because it was not found!");
removeByIndex(index);
else
PRINT_ERR("Cant remove task, because it was not found!");
}
const s32 FileService::getIndexOf(const u32 &t_taskId)
@@ -72,18 +69,18 @@ const s32 FileService::getIndexOf(const u32 &t_taskId)
void FileService::startThread()
{
PRINT_LOG("Creating file service thread");
consoleLog("Creating file service thread");
extern void *_gp;
thread.func = (void *)FileService::mainThread;
thread.stack = threadStack;
thread.stack_size = getThreadStackSize();
thread.gp_reg = (void *)&_gp;
thread.initial_priority = 0x12;
if ((threadId = CreateThread(&thread)) < 0)
PRINT_ERR("Create audio thread failed!");
PRINT_LOG("File service created");
threadId = CreateThread(&thread);
assertMsg(threadId >= 0, "Create audio thread failed!");
consoleLog("File service created");
StartThread(threadId, NULL);
PRINT_LOG("File service started");
consoleLog("File service started");
}
/** Main thread loop */
+2 -2
View File
@@ -30,12 +30,12 @@
*/
GifSender::GifSender(u32 t_packetSize, ScreenSettings *t_screen, Light *t_light) : screen(t_screen)
{
PRINT_LOG("Initializing GifSender");
consoleLog("Initializing GifSender");
light = t_light;
packetSize = t_packetSize;
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);
PRINT_LOG("GifSender initialized!");
consoleLog("GifSender initialized!");
}
/** Releases packets memory */
+15 -33
View File
@@ -30,15 +30,10 @@ Pad::Pad()
this->slot = 0; // Always zero if not using multitap
if ((this->ret = padPortOpen(this->port, this->slot, padBuf)) == 0)
{
PRINT_ERR("padPortOpen failed!");
printf("padPortOpen returned: %d\n", this->ret);
SleepThread();
}
if (!this->initPad())
{
PRINT_ERR("initPad failed!");
SleepThread();
assertMsg(true == false, "padPortOpen failed!");
}
assertMsg(this->initPad(), "initPad failed!");
}
Pad::~Pad() {}
@@ -50,22 +45,20 @@ Pad::~Pad() {}
/** Load SIO2MAN and PADMAN modules */
void Pad::loadModules()
{
PRINT_LOG("Loading pad modules");
consoleLog("Loading pad modules");
this->ret = SifLoadModule("rom0:SIO2MAN", 0, NULL);
if (this->ret < 0)
{
PRINT_ERR("SifLoadModule (SIO2MAN) failed!");
printf("SifLoadModule returned: %d\n", this->ret);
SleepThread();
assertMsg(true == false, "SifLoadModule (SIO2MAN) failed!");
}
this->ret = SifLoadModule("rom0:PADMAN", 0, NULL);
if (this->ret < 0)
{
PRINT_ERR("SifLoadModule (PADMAN) failed!");
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) */
@@ -81,7 +74,7 @@ int Pad::waitPadReady()
if (state != lastState)
{
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);
}
lastState = state;
@@ -89,23 +82,20 @@ int Pad::waitPadReady()
}
// Were the pad ever 'out of sync'?
if (lastState != -1)
PRINT_LOG("Pad is ready!");
consoleLog("Pad is ready!");
return 0;
}
/** Initializes and checks type of pad */
int Pad::initPad()
{
PRINT_LOG("Initializing pad");
consoleLog("Initializing pad");
this->waitPadReady();
// How many different modes can this device operate in?
// i.e. get # entrys in the modetable
int modes = padInfoMode(this->port, this->slot, PAD_MODETABLE, -1);
if (modes == 0)
{
PRINT_ERR("Connected device is not a dual shock controller!"); // (it has no actuator engines)
return 1;
}
assertMsg(modes, "Connected device is not a dual shock controller!"); // (it has no actuator engines)
// Verify that the controller has a DUAL SHOCK mode
int i = 0;
do
@@ -115,22 +105,14 @@ int Pad::initPad()
i++;
} while (i < modes);
if (i >= modes)
{
PRINT_ERR("Connected device is not a dual shock controller!");
return 1;
}
assertMsg(i < modes, "Connected device is not a dual shock controller!");
// If ExId != 0x0 => This controller has actuator engines
// This check should always pass if the Dual Shock test above passed
this->ret = padInfoMode(this->port, this->slot, PAD_MODECUREXID, 0);
if (this->ret == 0)
{
PRINT_ERR("Connected device is not a dual shock controller!");
return 1;
}
assertMsg(this->ret, "Connected device is not a dual shock controller!");
PRINT_LOG("Enabling dual shock functions.");
consoleLog("Enabling dual shock functions.");
// When using MMODE_LOCK, user cant change mode with Select button
padSetMainMode(this->port, this->slot, PAD_MMODE_DUALSHOCK, PAD_MMODE_LOCK);
@@ -156,7 +138,7 @@ int Pad::initPad()
else
printf("Did not find any actuators.\n");
this->waitPadReady();
PRINT_LOG("Pad initialized!");
consoleLog("Pad initialized!");
return 1;
}
+11 -19
View File
@@ -33,7 +33,7 @@ static const float SCREEN_CENTER = GS_CENTER / 2.0F;
*/
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_fast_waits(DMA_CHANNEL_GIF);
screen = t_screen;
@@ -53,7 +53,7 @@ Renderer::Renderer(u32 t_packetSize, ScreenSettings *t_screen)
vifSender = new VifSender(&light);
perspective.setPerspective(*t_screen);
renderData.projection = &perspective;
PRINT_LOG("Renderer initialized!");
consoleLog("Renderer initialized!");
}
Renderer::~Renderer() {}
@@ -69,8 +69,7 @@ void Renderer::allocateTextureBuffer(Texture *t_texture)
textureBuffer.psm = t_texture->getType();
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);
if (textureBuffer.address <= 1)
PRINT_ERR("Texture buffer allocation error. No memory!");
assertMsg(textureBuffer.address > 1, "Texture buffer allocation error. No memory!");
textureBuffer.info.width = draw_log2(t_texture->getWidth());
textureBuffer.info.height = draw_log2(t_texture->getHeight());
textureBuffer.info.function = TEXTURE_FUNCTION_MODULATE;
@@ -89,8 +88,7 @@ void Renderer::deallocateTextureBuffer()
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)
{
lastTextureId = t_tex->getId();
@@ -98,9 +96,6 @@ void Renderer::changeTexture(Texture *t_tex)
allocateTextureBuffer(t_tex);
GifSender::sendTexture(*t_tex, &textureBuffer);
}
}
else
PRINT_ERR("Texture was not found in texture repository!");
}
void Renderer::draw(Sprite &t_sprite)
@@ -164,7 +159,7 @@ void Renderer::draw(Sprite &t_sprite)
/** Initializes drawing environment (1st app packet) */
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_update(packet2, draw_setup_environment(packet2->base, 0, frameBuffers, &(zBuffer)));
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_wait(DMA_CHANNEL_GIF, 0);
packet2_free(packet2);
PRINT_LOG("Drawing environment initialized!");
consoleLog("Drawing environment initialized!");
}
/** Sets drawing prim for all 3D objects */
@@ -189,7 +184,7 @@ void Renderer::setPrim()
prim.mapping_type = PRIM_MAP_ST;
prim.colorfix = PRIM_UNFIXED;
renderData.prim = &prim;
PRINT_LOG("Prim set!");
consoleLog("Prim set!");
}
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.zsm = GS_ZBUF_24;
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.
graph_initialize(frameBuffers[0].address, frameBuffers[0].width, frameBuffers[0].height, frameBuffers[0].psm, 0, 0);
@@ -274,9 +269,8 @@ void Renderer::allocateBuffers(int t_screenW, int t_screenH)
void Renderer::draw(Mesh **t_meshes, u16 t_amount, LightBulb *t_bulbs, u16 t_bulbsCount)
{
beginFrameIfNeeded();
if (!t_meshes[0]->isDataLoaded())
PRINT_ERR("Can't draw, because no mesh data was loaded!");
else if (
assertMsg(t_meshes[0]->isDataLoaded(), "Can't draw, because no mesh data was loaded!");
if (
t_amount >= 3 &&
!t_meshes[0]->shouldBeBackfaceCulled &&
t_meshes[0]->getFramesCount() == 1 &&
@@ -309,9 +303,7 @@ void Renderer::draw(Mesh &t_mesh, LightBulb *t_bulbs, u16 t_bulbsCount)
{
beginFrameIfNeeded();
vifSender->calcMatrix(renderData, t_mesh.position, t_mesh.rotation);
if (!t_mesh.isDataLoaded())
PRINT_ERR("Can't draw, because no mesh data was loaded!");
assertMsg(t_mesh.isDataLoaded(), "Can't draw, because no mesh data was loaded!");
camRotation.identity();
camRotation.rotate(-t_mesh.rotation);
Vector3 rotatedCamera = Vector3(camRotation * *renderData.cameraPosition);
+2 -2
View File
@@ -17,8 +17,8 @@
TextureRepository::TextureRepository()
{
PRINT_LOG("Initializing texture repository");
PRINT_LOG("Texture repository initialized!");
consoleLog("Initializing texture repository");
consoleLog("Texture repository initialized!");
}
TextureRepository::~TextureRepository()
+2 -2
View File
@@ -33,7 +33,7 @@ extern u32 VU1Draw3D_CodeEnd __attribute__((section(".vudata")));
VifSender::VifSender(Light *t_light)
{
PRINT_LOG("Initializing VifSender");
consoleLog("Initializing VifSender");
light = t_light;
lastVertCount = 0;
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);
context = 0;
setDoubleBufferAddStaticData();
PRINT_LOG("VifSender initialized!");
consoleLog("VifSender initialized!");
}
VifSender::~VifSender()
+6 -6
View File
@@ -13,7 +13,7 @@
#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];
sprintf(result, "%d", a);
@@ -21,7 +21,7 @@ char *String::createU32ToString(u32 a)
}
/** Converts "123" to "000123". 6 digits length */
char *String::createWithLeadingZeros(char *a)
char *String::createWithLeadingZeros(const char *a)
{
const u8 digitsAmount = 6;
char *part = createConcatenated("00000000", a);
@@ -35,7 +35,7 @@ char *String::createWithLeadingZeros(char *a)
return result;
}
char *String::createWithoutExtension(char *source)
char *String::createWithoutExtension(const char *source)
{
u32 length = 0;
for (;; length++)
@@ -48,7 +48,7 @@ char *String::createWithoutExtension(char *source)
return res;
}
char *String::createCopy(char *source)
char *String::createCopy(const char *source)
{
u32 srcLength = getLength(source);
char *res = new char[srcLength + 1];
@@ -59,7 +59,7 @@ char *String::createCopy(char *source)
}
// For test\0 will return 4
u32 String::getLength(char *a)
u32 String::getLength(const char *a)
{
if (a == NULL)
return 0;
@@ -68,7 +68,7 @@ u32 String::getLength(char *a)
return i;
}
char *String::createConcatenated(char *a, char *b)
char *String::createConcatenated(const char *a, const char *b)
{
u32 aLength = getLength(a);
u32 bLength = getLength(b);
+2
View File
@@ -0,0 +1,2 @@
.vscode/
fonts/**
+39
View File
@@ -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
+15
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
+67
View File
@@ -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;
}
+41
View File
@@ -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
+48
View File
@@ -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);
}
+40
View File
@@ -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
+20
View File
@@ -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;
}
+78
View File
@@ -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);
}
+37
View File
@@ -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
View File
@@ -1,3 +1,2 @@
.vscode/
bin/**
fonts/**
Executable → Regular
+17 -11
View File
@@ -1,7 +1,7 @@
EE_BIN = dolphin.elf
TYRA_DIR = ./../../engine
# Project settings
DIR_NAME = dolphin
EE_LIBS = -ltyra
EE_OBJS = \
camera.o \
objects/player.o \
@@ -10,26 +10,32 @@ EE_OBJS = \
dolphin.o \
main.o
EE_LIBS = -ltyra
# ----------------
# Other
EE_BIN = $(DIR_NAME).elf
all: $(EE_BIN)
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
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:
rm -f $(EE_OBJS)
run: $(EE_BIN)
run:
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)
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
+2 -2
View File
@@ -11,10 +11,10 @@
- Usage of draw() in array mode (for water tiles, very fast)
### Assets
[Download](http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/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
[![Dolphin screenshot][dolphin-screenshot]](#)
[dolphin-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/samples/dolphin/dolphin.gif
[dolphin-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/dolphin.gif
+4
View File
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
+5 -1
View File
@@ -239,7 +239,11 @@ void Dolphin::onUpdate()
waterbox.position.set(player.mesh.position.x, -260.0F, player.mesh.position.z);
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(waterbox);
engine->renderer->draw(seabed);
-1
View File
@@ -1,3 +1,2 @@
.vscode/
bin/**
fonts/**
+17 -11
View File
@@ -1,7 +1,7 @@
EE_BIN = floors.elf
TYRA_DIR = ./../../engine
# Project settings
DIR_NAME = floors
EE_LIBS = -ltyra
EE_OBJS = \
managers/light_manager.o \
managers/floor_manager.o \
@@ -14,26 +14,32 @@ EE_OBJS = \
floors.o \
main.o
EE_LIBS = -ltyra
# ----------------
# Other
EE_BIN = $(DIR_NAME).elf
all: $(EE_BIN)
$(EE_STRIP) --strip-all $(EE_BIN)
mv $(EE_BIN) bin/$(EE_BIN)
rm $(EE_OBJS)
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:
rm -f $(EE_OBJS)
run: $(EE_BIN)
run:
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)
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
+2 -2
View File
@@ -10,10 +10,10 @@
- Usage of draw() in array mode (for floors, very fast)
### Assets
[Download](http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/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
[![Floors screenshot][floors-screenshot]](#)
[floors-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/1.31.2/samples/floors/floors.gif
[floors-screenshot]: http://apgcglz.cluster028.hosting.ovh.net/tyra/floors.gif
+4
View File
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
+2 -2
View File
@@ -21,9 +21,9 @@ const float CAMERA_Y = 30.0F;
Camera::Camera(ScreenSettings *t_screen) : CameraBase(t_screen, &position)
{
PRINT_LOG("Initializing camera");
consoleLog("Initializing camera");
verticalLevel = 80.0F;
PRINT_LOG("Camera initialized!");
consoleLog("Camera initialized!");
}
Camera::~Camera() {}
@@ -51,7 +51,7 @@ FloorManager::~FloorManager()
*/
void FloorManager::calcSpiral(int X, int Y)
{
PRINT_LOG("Calculating square spiral for floors");
consoleLog("Calculating square spiral for floors");
int x, y, dx;
x = y = dx = 0;
int dy = -1;
@@ -73,7 +73,7 @@ void FloorManager::calcSpiral(int X, int Y)
x += dx;
y += dy;
}
PRINT_LOG("Square spiral calculated!");
consoleLog("Square spiral calculated!");
}
/** Initialize all floors by:
@@ -82,7 +82,7 @@ void FloorManager::calcSpiral(int X, int Y)
*/
void FloorManager::initFloors()
{
PRINT_LOG("Initializing floors");
consoleLog("Initializing floors");
floors[0].mesh.loadObj("meshes/floor/", "floor", 3.0F, false);
floors[0].mesh.shouldBeFrustumCulled = true;
floors[0].mesh.shouldBeLighted = true;
@@ -95,7 +95,7 @@ void FloorManager::initFloors()
texRepo->getBySpriteOrMesh(floors[0].mesh.getMaterial(0).getId())->addLink(floors[i].mesh.getMaterial(0).getId());
meshes[i] = &floors[i].mesh;
}
PRINT_LOG("Floors initialized!");
consoleLog("Floors initialized!");
}
/** Main floor loop.
@@ -17,7 +17,7 @@
LightManager::LightManager()
{
PRINT_LOG("Creating light manager!");
consoleLog("Creating light manager!");
bulbsCount = 2;
bulbs = new LightBulb[2];
@@ -31,7 +31,7 @@ LightManager::LightManager()
audioOffset = audioTick = 0;
PRINT_LOG("Light manager created!");
consoleLog("Light manager created!");
}
LightManager::~LightManager()
+2 -2
View File
@@ -24,7 +24,7 @@
Enemy::Enemy(TextureRepository *t_texRepo)
{
PRINT_LOG("Creating enemy object");
consoleLog("Creating enemy object");
meshes = new Mesh[getMeshesCount()];
drawMeshes = new Mesh *[getMeshesCount()];
@@ -48,7 +48,7 @@ Enemy::Enemy(TextureRepository *t_texRepo)
isKilled = true;
PRINT_LOG("Enemy object created!");
consoleLog("Enemy object created!");
}
Enemy::~Enemy()
+2 -2
View File
@@ -23,7 +23,7 @@
Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
{
PRINT_LOG("Creating player object");
consoleLog("Creating player object");
texRepo = t_texRepo;
audio = t_audio;
gravity = 0.1F;
@@ -53,7 +53,7 @@ Player::Player(Audio *t_audio, TextureRepository *t_texRepo)
boomAdpcm = audio->loadADPCM("sounds/boom.adpcm");
audio->setADPCMVolume(70, 0);
PRINT_LOG("Player object created!");
consoleLog("Player object created!");
}
Player::~Player()
+2 -2
View File
@@ -18,7 +18,7 @@
Ui::Ui(TextureRepository *t_texRepo)
{
PRINT_LOG("Initializing ui");
consoleLog("Initializing ui");
isTask1Done = false;
isTask2Done = false;
@@ -52,7 +52,7 @@ Ui::Ui(TextureRepository *t_texRepo)
grayCheckboxTex->addLink(task1Checkbox.getId());
grayCheckboxTex->addLink(task2Checkbox.getId());
PRINT_LOG("Ui initialized!");
consoleLog("Ui initialized!");
}
Ui::~Ui() {}
+2
View File
@@ -0,0 +1,2 @@
.vscode/
fonts/**
+37
View File
@@ -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
+4
View File
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
File diff suppressed because it is too large Load Diff
+28
View File
@@ -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"
+22
View File
@@ -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);
}