diff --git a/Dockerfile b/Dockerfile index 7dbdd897..ce89d63e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,12 +3,12 @@ FROM wombatant/devenv:latest ENV DEVKITPRO /opt/devkitPro ENV DEVKITARM ${DEVKITPRO}/devkitARM -RUN dnf install -y qt5-devel +RUN dnf install -y qt5-devel llvm libasan ############################################################################### # Install Ox -RUN git clone -b release-0.1 https://github.com/wombatant/ox.git /usr/local/src/ox && \ +RUN git clone -b e976fd3fe62c98be29c4389ba6700a4a1fb8e0ae https://github.com/wombatant/ox.git /usr/local/src/ox && \ cd /usr/local/src/ox && \ # setup build dirs mkdir -p \ diff --git a/Makefile b/Makefile index aaaacbb4..37bf3edf 100644 --- a/Makefile +++ b/Makefile @@ -10,6 +10,9 @@ endif make: ${ENV_RUN} make -j -C build HOST_ENV=${HOST_ENV} +build_rom: + ${ENV_RUN} make -j -C build HOST_ENV=${HOST_ENV} + ${ENV_RUN} ./build_rom.sh preinstall: ${ENV_RUN} make -j -C build ARGS="preinstall" HOST_ENV=${HOST_ENV} install: @@ -31,12 +34,13 @@ gdb: make devenv-build: docker build --no-cache . -t ${DEVENV_IMAGE} devenv: - docker run -d -v $(shell pwd):/usr/src/project \ + docker run -d \ -e LOCAL_USER_ID=$(shell id -u ${USER}) \ -e DISPLAY=$(DISPLAY) \ -e QT_AUTO_SCREEN_SCALE_FACTOR=1 \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -v /run/dbus/:/run/dbus/ \ + -v $(shell pwd):/usr/src/project \ -v /dev/shm:/dev/shm \ --restart=always \ --name ${DEVENV} \ diff --git a/build_rom.sh b/build_rom.sh index cf25db89..b6e1671d 100755 --- a/build_rom.sh +++ b/build_rom.sh @@ -2,9 +2,11 @@ set -e -padbin 32 build/gba-release/src/player/nostalgia.bin +${DEVKITARM}/bin/padbin 32 build/gba-release/src/player/nostalgia.bin echo NOSTALGIA_MEDIA_HEADER_________ > media_header.txt + oxfs format 32 1m nostalgia_media.oxfs ./build/current/src/tools/nost-pack -fs nostalgia_media.oxfs -img charset.png -inode 1 -tiles 40 -c + cat build/gba-release/src/player/nostalgia.bin media_header.txt nostalgia_media.oxfs > nostalgia.gba -gbafix nostalgia.gba +${DEVKITARM}/bin/gbafix nostalgia.gba diff --git a/src/core/gba/gba.hpp b/src/core/gba/gba.hpp index 4e3fdd04..4c5d0e80 100644 --- a/src/core/gba/gba.hpp +++ b/src/core/gba/gba.hpp @@ -13,15 +13,15 @@ namespace nostalgia { namespace core { -typedef struct { uint32_t data[8]; } Tile, Tile4; +typedef struct { uint32_t data[8]; } __attribute__((aligned(4))) Tile, Tile4; // d-tile: double-sized tile (8bpp) -typedef struct { uint32_t data[16]; } Tile8; +typedef struct { uint32_t data[16]; } __attribute__((aligned(4))) Tile8; // tile block: 32x16 tiles, 16x16 d-tiles typedef uint16_t Pallete[256]; typedef Tile CharBlock[512]; typedef Tile8 CharBlock8[256]; -struct GbaImageData { +struct __attribute__((packed)) GbaImageData { Pallete pal; uint16_t tileCount; uint8_t bpp; diff --git a/src/core/gba/gfx.cpp b/src/core/gba/gfx.cpp index 21c4754c..342ee0d1 100644 --- a/src/core/gba/gfx.cpp +++ b/src/core/gba/gfx.cpp @@ -133,7 +133,7 @@ void initConsole() { REG_BG0CNT |= (1 << 7); // set to use 8 bits per pixel if (fs) { FileStore32::FsSize_t readSize = 0; - fs->read(1, 516, 64 * 38, &TILE8_ADDR[0][1], nullptr); + fs->read(2, __builtin_offsetof(GbaImageData, tiles), 64 * 38, &TILE8_ADDR[0][1], nullptr); fs->read(1, 0, 512, &MEM_PALLETE_BG[0], &readSize); } } diff --git a/src/core/gba/media.cpp b/src/core/gba/media.cpp index cd5af72f..35695551 100644 --- a/src/core/gba/media.cpp +++ b/src/core/gba/media.cpp @@ -22,7 +22,7 @@ uint8_t *findMedia() { const static auto headerP1Len = 15; const static auto headerP2Len = 16; const static auto headerLen = headerP1Len + headerP2Len + 1; - + for (auto current = &MEM_ROM; current < ((uint8_t*) 0x0a000000); current += headerLen) { if (ox_memcmp(current, headerP1, headerP1Len) == 0 && ox_memcmp(current + headerP1Len, headerP2, headerP2Len) == 0) { diff --git a/src/tools/pack.cpp b/src/tools/pack.cpp index 0f64bddb..60d09e46 100644 --- a/src/tools/pack.cpp +++ b/src/tools/pack.cpp @@ -73,8 +73,9 @@ int run(ClArgs args) { } QMap colors; - const auto imgDataBuffSize = sizeof(Pallete) + argTiles * 64; + const auto imgDataBuffSize = sizeof(GbaImageData) + 1 + argTiles * 64; uint8_t imgDataBuff[imgDataBuffSize]; + memset(&imgDataBuff, 0, imgDataBuffSize); GbaImageData *id = (GbaImageData*) imgDataBuff; id->bpp = 8; id->tileCount = argTiles; @@ -90,7 +91,7 @@ int run(ClArgs args) { colors[c] = colorId; colorId++; } - ((uint8_t*) &id->tiles)[destI] = colors[c]; + id->tiles[destI] = colors[c]; } } }