mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-17 20:10:23 +03:00
SDL/WASM Port
This commit is contained in:
committed by
iProgramInCpp
parent
0b16b2843a
commit
0fbe90752d
@@ -33,6 +33,8 @@
|
||||
|
||||
int g_TimeSecondsOnInit = 0;
|
||||
|
||||
#ifndef USE_SDL
|
||||
|
||||
DIR* opendir(const char* name)
|
||||
{
|
||||
size_t len = strlen(name);
|
||||
@@ -97,6 +99,13 @@ void closedir(DIR* dir)
|
||||
free(dir);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
|
||||
#endif
|
||||
|
||||
bool createFolderIfNotExists(const char* pDir)
|
||||
{
|
||||
if (!XPL_ACCESS(pDir, 0))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -21,6 +21,6 @@ public:
|
||||
void fillGradient(int left, int top, int right, int bottom, int colorUp, int colorDown);
|
||||
|
||||
public:
|
||||
float field_4;
|
||||
float field_4 = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -30,7 +30,7 @@ void Screen::init(Minecraft* pMinecraft, int a3, int a4)
|
||||
|
||||
void Screen::init()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Screen::buttonClicked(Button* pButton)
|
||||
@@ -65,7 +65,7 @@ bool Screen::isInGameScreen()
|
||||
|
||||
void Screen::keyPressed(int key)
|
||||
{
|
||||
if (key == '\x1B')//escape
|
||||
if (key == AKEYCODE_MENU)//escape
|
||||
{
|
||||
m_pMinecraft->setScreen(nullptr);
|
||||
}
|
||||
|
||||
@@ -128,6 +128,11 @@ void TextInputBox::keyPressed(Minecraft* minecraft, int key)
|
||||
case AKEYCODE_ARROW_RIGHT:
|
||||
chr = '\003';
|
||||
break;
|
||||
#ifdef USE_SDL
|
||||
case AKEYCODE_DEL:
|
||||
chr = '\b';
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -93,7 +93,7 @@ void StartMenuScreen::init()
|
||||
m_buyButton.m_yPos = yPos;
|
||||
|
||||
m_startButton.m_xPos = (m_width - m_startButton.m_width) / 2;
|
||||
|
||||
|
||||
int x1 = m_width - m_joinButton.m_width;
|
||||
|
||||
m_joinButton.m_xPos = x1 / 2;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "Controller.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
bool Controller::isTouchedValues[2];
|
||||
float Controller::stickValuesX[2];
|
||||
float Controller::stickValuesY[2];
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "ControllerTurnInput.hpp"
|
||||
#include "Controller.hpp"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
ITurnInput::Delta ControllerTurnInput::getTurnDelta()
|
||||
{
|
||||
bool isTouched = Controller::isTouched(m_stickNo);
|
||||
|
||||
@@ -1,19 +1,28 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
|
||||
#include "Keyboard.hpp"
|
||||
|
||||
#include "GameMods.hpp"
|
||||
|
||||
std::vector<Keyboard::Input> Keyboard::_inputs;
|
||||
int Keyboard::_index = -1;
|
||||
int Keyboard::_states[256];
|
||||
int Keyboard::_states[KEYBOARD_STATES_SIZE];
|
||||
|
||||
void Keyboard::feed(int down, int key)
|
||||
{
|
||||
#ifndef ORIGINAL_CODE
|
||||
// Prevent Crashes
|
||||
if (key >= KEYBOARD_STATES_SIZE || key < 0) {
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
Input i;
|
||||
i.field_0 = down;
|
||||
i.field_4 = uint8_t(key);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -9,6 +9,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
|
||||
#define KEYBOARD_STATES_SIZE 256
|
||||
|
||||
class Keyboard
|
||||
{
|
||||
@@ -21,7 +24,7 @@ public:
|
||||
};
|
||||
|
||||
static std::vector<Input> _inputs;
|
||||
static int _states[256];
|
||||
static int _states[KEYBOARD_STATES_SIZE];
|
||||
static int _index;
|
||||
|
||||
// likely inlined
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -328,7 +328,7 @@ void GameRenderer::setupFog(int i)
|
||||
float GameRenderer::getFov(float f)
|
||||
{
|
||||
Mob* pMob = m_pMinecraft->m_pMobPersp;
|
||||
|
||||
|
||||
float x1 = 70.0f;
|
||||
|
||||
if (pMob->isUnderLiquid(Material::water))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -459,14 +459,14 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
|
||||
|
||||
if (!a)
|
||||
field_54 = field_58 = field_5C = field_60 = field_64 = 0;
|
||||
|
||||
|
||||
float mobX1 = pMob->m_pos.x;
|
||||
float mobX2 = pMob->field_98.x + (pMob->m_pos.x - pMob->field_98.x) * b;
|
||||
float mobY1 = pMob->m_pos.y;
|
||||
float mobY2 = pMob->field_98.y + (pMob->m_pos.y - pMob->field_98.y) * b;
|
||||
float mobZ1 = pMob->m_pos.z;
|
||||
float mobZ2 = pMob->field_98.z + (pMob->m_pos.z - pMob->field_98.z) * b;
|
||||
|
||||
|
||||
float dX = pMob->m_pos.x - field_4, dY = pMob->m_pos.y - field_8, dZ = pMob->m_pos.z - field_C;
|
||||
|
||||
if (dX * dX + dY * dY + dZ * dZ > 16.0f)
|
||||
@@ -567,7 +567,8 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
|
||||
|
||||
y3++;
|
||||
y2++;
|
||||
pChunk->field_4E++;
|
||||
//pChunk->field_4E++;
|
||||
pChunk->field_4E = true;
|
||||
if (y3 == x3)
|
||||
goto label_37;
|
||||
}
|
||||
@@ -576,7 +577,7 @@ void LevelRenderer::render(Mob* pMob, int a, float b)
|
||||
label_26:
|
||||
y3++;
|
||||
y2++;
|
||||
|
||||
|
||||
if (y3 == x3)
|
||||
goto label_37;
|
||||
|
||||
@@ -663,7 +664,7 @@ void LevelRenderer::tick()
|
||||
void LevelRenderer::updateDirtyChunks(Mob* pMob, bool b)
|
||||
{
|
||||
// @TODO This updates 16 chunks per frame. Not good.
|
||||
|
||||
|
||||
int updated = 0;
|
||||
for (int i = 0; i < 16 && i < int(field_88.size()); i++)
|
||||
{
|
||||
@@ -1021,7 +1022,7 @@ void LevelRenderer::takePicture(TripodCamera* pCamera, Entity* pOwner)
|
||||
#ifdef ENH_CAMERA_NO_PARTICLES
|
||||
g_bDisableParticles = false;
|
||||
#endif
|
||||
|
||||
|
||||
t_keepPic = -1;
|
||||
|
||||
static char str[256];
|
||||
@@ -1100,7 +1101,7 @@ void LevelRenderer::renderSky(float f)
|
||||
{
|
||||
if (m_pMinecraft->m_pLevel->m_pDimension->field_C)
|
||||
return;
|
||||
|
||||
|
||||
glDisable(GL_TEXTURE_2D);
|
||||
|
||||
Vec3 skyColor = m_pLevel->getSkyColor(m_pMinecraft->m_pMobPersp, f);
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "RenderList.hpp"
|
||||
#include "Tesselator.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
constexpr int C_MAX_RENDERS = 3072;
|
||||
|
||||
RenderList::RenderList()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -9,6 +9,8 @@
|
||||
#include "compat/GL.hpp"
|
||||
#include "Tesselator.hpp"
|
||||
|
||||
#include <cstddef>
|
||||
|
||||
int dword_2514A4 = 0;
|
||||
|
||||
Tesselator Tesselator::instance;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/********************************************************************
|
||||
Minecraft: Pocket Edition - Decompilation Project
|
||||
Copyright (C) 2023 iProgramInCpp
|
||||
|
||||
|
||||
The following code is licensed under the BSD 1 clause license.
|
||||
SPDX-License-Identifier: BSD-1-Clause
|
||||
********************************************************************/
|
||||
@@ -69,7 +69,7 @@ int Textures::assignTexture(const std::string& name, Texture& texture)
|
||||
if (texture.field_C)
|
||||
internalFormat = GL_RGBA;
|
||||
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, texture.m_pixels);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, texture.m_width, texture.m_height, 0, internalFormat, GL_UNSIGNED_BYTE, texture.m_pixels);
|
||||
|
||||
m_textures[name] = textureID;
|
||||
|
||||
|
||||
@@ -63,8 +63,13 @@ void SoundEngine::play(const std::string& name)
|
||||
|
||||
SoundDesc sd;
|
||||
|
||||
if (m_repository.get(name, sd))
|
||||
if (m_repository.get(name, sd)) {
|
||||
#ifdef USE_SDL
|
||||
m_soundSystem.play(sd, 0, 0, 0, 1, 1, true);
|
||||
#else
|
||||
m_soundSystem.playAt(sd, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void SoundEngine::play(const std::string& name, float a, float b, float c, float d, float e)
|
||||
@@ -74,6 +79,11 @@ void SoundEngine::play(const std::string& name, float a, float b, float c, float
|
||||
|
||||
SoundDesc sd;
|
||||
|
||||
if (m_repository.get(name, sd))
|
||||
if (m_repository.get(name, sd)) {
|
||||
#ifdef USE_SDL
|
||||
m_soundSystem.play(sd, a, b, c, d, e, false);
|
||||
#else
|
||||
m_soundSystem.playAt(sd, a, b, c, d, e);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user