Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build for PS2 #5238

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft

Build for PS2 #5238

wants to merge 6 commits into from

Conversation

AJenbo
Copy link
Member

@AJenbo AJenbo commented Aug 13, 2022

docker run -it -w /project -v $(pwd):/project ps2dev/ps2dev sh

apk add git make cmake gmp mpc1 mpfr

git config --global --add safe.directory /project

cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=/usr/local/ps2dev/ps2sdk/ps2dev.cmake

cmake --build build -j $(nproc)

if you need to build the SDK (don't forget to clone and build ps2_drivers) you will also need this:

apk add musl-dev gcc bash

image

todo

Side note

Initially we tried using SDL1.2, but the version provided by ps2sdk is 1.2.8 and we expect 1.2.10. There is also an issue with there port not correctly implementing Uint64. Solving that wasn't to big of an issue, but the game gets stuck during SDL_JoystickInit, so instead we for now have opted for SDL2 which went much smoother.

@AJenbo AJenbo force-pushed the ps2 branch 4 times, most recently from 8981e82 to dfb7f2a Compare August 13, 2022 17:36
@AJenbo AJenbo force-pushed the ps2 branch 6 times, most recently from 74521db to 2ee918d Compare August 15, 2022 06:08
@glebm
Copy link
Collaborator

glebm commented Nov 5, 2022

The CLX stuff is done and PS2 SDK recently received lots of updates, might be a good time to give this another go!

set(BUILD_ASSETS_MPQ OFF)
set(UNPACKED_MPQS ON)

https://github.com/diasurgical/devilutionx-mpq-tools

@AJenbo
Copy link
Member Author

AJenbo commented Jan 17, 2023

Slight update, the latest build chain fixes the ReadOnlyTest issue as well as remove the need for building the drivers.
Currently the game is crashing for me when loading town.

@AJenbo
Copy link
Member Author

AJenbo commented Jan 17, 2023

Everything appears to be working now with streaming audio (currently requires individual files and not using an MPQ)... but the PS2 only allows 16 files to be open at the same time meaning that we can't open all the needed audio files for streaming. So that's something we might have to look in to a solution for.

@glebm
Copy link
Collaborator

glebm commented Jan 18, 2023

It should now allow up to 128 open files ps2dev/ps2sdk#396

CMake/platforms/ps2.cmake Outdated Show resolved Hide resolved
CMake/platforms/ps2.cmake Outdated Show resolved Hide resolved
@AJenbo AJenbo force-pushed the ps2 branch 2 times, most recently from a488eeb to a25fcda Compare January 21, 2023 15:10
@AJenbo AJenbo force-pushed the ps2 branch 2 times, most recently from 190499a to 3b2bc7a Compare February 4, 2023 06:49
@AJenbo AJenbo force-pushed the ps2 branch 3 times, most recently from 8aeb2ce to dd281a7 Compare February 11, 2023 22:16
Comment on lines +9 to 10
#ifndef PS2
#ifndef NOSOUND
Copy link
Collaborator

@glebm glebm Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider doing this instead throughout:

#if !defined(NOSOUND) && !defined(PS2)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the svid portion is still just a the stage where i stubbed everything out to avoid linking with audiolib. I still have to find the best way to bring video sound back up.

Comment on lines +243 to +250
AssetHandle handle = OpenAsset(file_path_.c_str(), size);
if (handle.ok()) {
size -= 16;
uint32_t buffer[3];
if (handle.read(buffer, sizeof(buffer))) {
pitch = buffer[2];
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a bit surprising to have GetLength() open a file.
This should probably be done when the SoundSample is constructed.

Comment on lines +147 to +148
audsrv_adpcm_t *sampleId_ = nullptr;
std::unique_ptr<audsrv_adpcm_t> stream_;
Copy link
Collaborator

@glebm glebm Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a bool owned_; instead. Or simply std::shared_ptr

Comment on lines +364 to +368
#ifndef PS2
texture = SDLWrap::CreateTexture(renderer, SDL_PIXELFORMAT_RGB888, SDL_TEXTUREACCESS_STREAMING, gnScreenWidth, gnScreenHeight);
#else
texture = SDLWrap::CreateTexture(renderer, SDL_PIXELFORMAT_ABGR1555, SDL_TEXTUREACCESS_STREAMING, gnScreenWidth, gnScreenHeight);
#endif
Copy link
Collaborator

@glebm glebm Feb 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider doing it more generally by adding a CMake define for DEVILUTIONX_DISPLAY_TEXTURE_FORMAT (can then be used in storm_svid.cpp as well)

This give us 2MB of dedicated audio memory and support for compressed
audio at runtime which is a huge boost to the already limited system
memory
glebm added a commit to glebm/devilutionX that referenced this pull request Feb 19, 2023
List taken from the PS2 PR
(diasurgical#5238)
glebm added a commit to glebm/devilutionX that referenced this pull request Sep 2, 2023
List taken from the PS2 PR
(diasurgical#5238)

Regexp used for removal:

```
PS_(WARR|ROGUE|MAGE|MONK)(14B|14C|16B|16C|17|18|19|20|21|22|23|25|26|28|30|31|32|33|36|37|38|39|40|41|42|44|45|47|48|57|64|65|66|67|72|73|74|75|76|77|78|97|98)\b
```
glebm added a commit to glebm/devilutionX that referenced this pull request Sep 2, 2023
List taken from the PS2 PR
(diasurgical#5238)

Regexp used for removal:

```
PS_(WARR|ROGUE|MAGE|MONK)(14B|14C|16B|16C|17|18|19|20|21|22|23|25|26|28|30|31|32|33|36|37|38|39|40|41|42|44|45|47|48|57|64|65|66|67|72|73|74|75|76|77|78|97|98)\b
```
glebm added a commit to glebm/devilutionX that referenced this pull request Sep 2, 2023
List taken from the PS2 PR
(diasurgical#5238)

Regexp used for removal:

```
PS_(WARR|ROGUE|MAGE|MONK)(14B|14C|16B|16C|17|18|19|20|21|22|23|25|26|28|30|31|32|33|36|37|38|39|40|41|42|44|45|47|48|57|64|65|66|67|72|73|74|75|76|77|78|97|98)\b
```
/*PS_WARR16B*/ { sfx_STREAM, "sfx\\warrior\\wario16b.wav", nullptr },
/*PS_WARR16C*/ { sfx_STREAM, "sfx\\warrior\\wario16c.wav", nullptr },
/*PS_WARR17*/ { sfx_STREAM, "sfx\\warrior\\warior17.wav", nullptr },
/*PS_WARR18*/ { sfx_STREAM, "sfx\\warrior\\warior18.wav", nullptr },
Copy link
Collaborator

@glebm glebm Sep 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct.
This file is "Not a chance" and it is actually used (HeroSpeech::NotAChance)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants