Remove Overlayhader and support loading overlays

This commit is contained in:
2023-04-10 17:01:28 +02:00
parent 7a373a38ff
commit 1a0d175779
8 changed files with 47 additions and 65 deletions

View File

@@ -7,13 +7,15 @@ namespace JabyEngine {
enum struct CDFileType : uint8_t {
SimpleTIM = 0,
CopyTo,
Overlay,
};
struct __no_align CDFile {
union __no_align Payload {
uint32_t empty;
uint32_t raw;
SimpleTIM simple_tim;
CopyTo copy_to;
Overlay overlay;
};
uint8_t rel_lba_idx;
@@ -31,6 +33,10 @@ namespace JabyEngine {
static constexpr CDFile copy_to(uint8_t rel_lba_idx, uint32_t* dst) {
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::CopyTo, .payload = {.copy_to = CopyTo{dst}}};
}
static constexpr CDFile overlay(uint8_t rel_lba_idx, uint32_t* overlay_dst) {
return CDFile{.rel_lba_idx = rel_lba_idx, .type = CDFileType::Overlay, .payload = {.overlay = Overlay{overlay_dst}}};
}
};
}
#endif //!__JABYENGINE_CD_FILE_TYPES_HPP__

View File

@@ -42,5 +42,7 @@ namespace JabyEngine {
struct __no_align CopyTo {
uint32_t* dst;
};
typedef CopyTo Overlay;
}
#endif // !__JABYENGINE_FILE_TYPES_HPP__

View File

@@ -3,11 +3,9 @@
#include "../AutoLBA/auto_lba.hpp"
namespace JabyEngine {
struct __attribute__((packed)) OverlayHeader {
void (*execute)();
uint16_t lba_size; //< The size of the OverlayLBA section
};
typedef AutoLBAEntry OverlayLBA;
// Can be used to create dummy values to trick LZ4 into compressing an uncompressed overlay
#define __create_dummy_fill(length) static const uint8_t __section(".keep.dummy") __used DummyFilling[length] = {0x0}
}
#endif //!__JABYENGINE_OVERLAY__HPP__

View File

@@ -4,10 +4,7 @@
// No include here because this header should be included in a namespace and we don't want multiple namespace definitions of OverlayHeader and OverlayLBA
#include "../AutoLBA/auto_lba_declaration.hpp"
extern const JabyEngine::OverlayHeader overlay_header;
#define __declare_overlay_header(function, enum_struct) \
__declare_lba_header(enum_struct); \
[[gnu::used]] \
const JabyEngine::OverlayHeader __section(".header") overlay_header = {.execute = &function, .lba_size = static_cast<uint16_t>(enum_struct::EndOfRequest)};
__declare_lba_header(enum_struct)
#endif //!__JABYENGINE_OVERLAY_DECLARATION__HPP__

View File

@@ -3,7 +3,7 @@
#include "jabyengine_config.hpp"
#include "../stddef.h"
#define __keep __attribute__((used))
#define __used __attribute__((used))
#define __no_align __attribute__((packed))
#define __no_inline __attribute__((noinline))
#define __always_inline __attribute__((always_inline))