Skip to content

Commit

Permalink
modder
Browse files Browse the repository at this point in the history
  • Loading branch information
rgnter committed Sep 16, 2021
1 parent fa77290 commit 41029bd
Show file tree
Hide file tree
Showing 42 changed files with 4,347 additions and 3,366 deletions.
11 changes: 0 additions & 11 deletions .gitignore

This file was deleted.

10 changes: 0 additions & 10 deletions CMakeLists.txt

This file was deleted.

28 changes: 0 additions & 28 deletions CMakeSettings.json

This file was deleted.

8 changes: 8 additions & 0 deletions alicia_modder/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CLion
.idea/
cmake-build-dbg/
cmake-build-release/
*.iml

# General
build/
66 changes: 66 additions & 0 deletions alicia_modder/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.19)
project(alicia_modder)

set(CMAKE_CXX_STANDARD 20)

list(APPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR})

if (NOT EXISTS "${CMAKE_BINARY_DIR}/cmake/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/develop/conan.cmake"
"${CMAKE_BINARY_DIR}/cmake/conan.cmake"
TLS_VERIFY ON)
endif ()

include(${CMAKE_BINARY_DIR}/cmake/conan.cmake)
conan_cmake_configure(REQUIRES spdlog/1.8.5 ctre/3.4.1 cxxopts/2.2.1 imgui/1.83 zlib/1.2.11
GENERATORS cmake_find_package)
conan_cmake_autodetect(settings)
conan_cmake_install(PATH_OR_REFERENCE .
BUILD missing
REMOTE conan-center
SETTINGS ${settings})

find_package(spdlog)
find_package(imgui)
find_package(ctre)
find_package(cxxopts)
find_package(ZLIB)
link_libraries(spdlog::spdlog ctre::ctre cxxopts::cxxopts imgui::imgui d3d9 ZLIB::ZLIB)

set(AM_VENDOR_SOURCES
vendor/imgui/imgui_impl_win32.h
vendor/imgui/imgui_impl_win32.cpp
vendor/imgui/imgui_impl_dx9.h
vendor/imgui/imgui_impl_dx9.cpp
)

set(AM_SOURCES
source/main/buffer/buffer.cpp
source/main/buffer/buffer.hpp
source/main/main.cpp

source/main/mod/alicia/game/alicia_modder.cpp
source/main/mod/alicia/game/alicia_modder.hpp

source/main/interface/interface.hpp
source/main/interface/interface.cpp

source/main/tools/dbg/debugger.hpp
source/main/tools/dbg/debugger.cpp

source/main/mod/alicia/launcher/launcher_modder.cpp
source/main/mod/alicia/launcher/launcher_modder.hpp

source/main/interface/views/data_view.cpp
source/main/interface/views/data_view.hpp

source/main/tools/assets/defs.hpp

source/main/tools/rw/defs.hpp source/main/tools/assets/assets.cpp source/main/tools/assets/assets.hpp source/main/helpers/filesystem.cpp source/main/helpers/filesystem.hpp source/main/mod/alicia/assets/assets_modder.cpp source/main/mod/alicia/assets/assets_modder.hpp)

include_directories(vendor/)
include_directories(source/)

add_executable(alicia_modder ${AM_VENDOR_SOURCES} ${AM_SOURCES})
121 changes: 121 additions & 0 deletions alicia_modder/source/main/buffer/buffer.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
//
// Created by maros on 31/05/2021.
//

#include "buffer.hpp"
#include "cstdio"
#include "string.h"

buffer::stack_buffer::stack_buffer(const void *dataPtr, size_t dataLen) :
m_buffer((uint8_t *) dataPtr), m_bufferLength(dataLen), m_bufferCursor(0) {
}




void buffer::stack_buffer::setCursor(size_t pos) {
this->m_bufferCursor = pos;
}

void buffer::stack_buffer::resetCursor() {
this->m_bufferCursor = 0;
}

size_t buffer::stack_buffer::getCursor() const {
return this->m_bufferCursor;
}

uint8_t *buffer::stack_buffer::dataPtr() const {
return this->m_buffer;
}

size_t buffer::stack_buffer::getLength() const {
return this->m_bufferLength;
}

size_t buffer::stack_buffer::getSize() const {
return this->m_bufferLength;
}

uint8_t buffer::stack_buffer::readUnsignedByte() {
if (m_bufferCursor > m_bufferLength)
return 0;
const auto result = m_buffer[m_bufferCursor++];
return result;
}

void buffer::stack_buffer::writeUnsignedByte(uint8_t byte) {
m_buffer[m_bufferCursor++] = byte;
}

uint8_t buffer::stack_buffer::peekUnsignedByte() const {
return m_buffer[m_bufferCursor];
}

int8_t buffer::stack_buffer::readByte() {
return (int8_t) readUnsignedByte();
}

void buffer::stack_buffer::writeByte(int8_t byte) {
writeUnsignedByte((uint8_t) byte);
}

int8_t buffer::stack_buffer::peekByte() const {
return (int8_t) peekUnsignedByte();
}



uint16_t buffer::stack_buffer::readUnsignedShort() {
return (uint16_t) (readUnsignedByte() + (readUnsignedByte() << 8));
}

void buffer::stack_buffer::writeUnsignedShort(uint16_t val) {
writeUnsignedByte(val & 0xFF);
writeUnsignedByte(val >> 8);
}

uint16_t buffer::stack_buffer::peekUnsignedShort() const {
return (uint16_t) (peekUnsignedByte() + (peekUnsignedByte() << 8));
}

int16_t buffer::stack_buffer::readShort() {
return (int16_t) readUnsignedShort();
}

void buffer::stack_buffer::writeShort(int16_t val) {
writeUnsignedShort((uint16_t) val);
}

int16_t buffer::stack_buffer::peekShort() const {
return (int16_t) peekUnsignedShort();
}


uint32_t buffer::stack_buffer::readUnsignedInteger() {
uint16_t least = readUnsignedShort();
uint32_t most = readUnsignedShort() << 16;
return (uint32_t) (least+most);
}

void buffer::stack_buffer::writeUnsignedInteger(uint32_t val) {
writeUnsignedShort(val & 0xFFFF);
writeUnsignedShort(val << 16);
}

uint32_t buffer::stack_buffer::peekUnsignedInteger() const {
return (uint32_t) (peekUnsignedShort() + (peekUnsignedShort() << 16));
}

int32_t buffer::stack_buffer::readInteger() {
return (int32_t) readUnsignedInteger();
}

void buffer::stack_buffer::writeInteger(int32_t val) {
writeUnsignedInteger((uint16_t) val);
}

int32_t buffer::stack_buffer::peekInteger() const {
return (int32_t) peekUnsignedInteger();
}

Loading

0 comments on commit 41029bd

Please sign in to comment.