From ccca7bf6ee9607bc31f2e1226399b578c6e2d571 Mon Sep 17 00:00:00 2001 From: nmlgc Date: Fri, 12 Nov 2021 18:52:24 +0100 Subject: [PATCH] [Reverse-engineering] [th04/th05] EMS: Cache area layout Part of P0168, funded by Blue Bolt and rosenrose. --- th04/main/ems.h | 1 - th04/main/ems.hpp | 55 +++++++++++++++++++++++++++++++++++++++ th04/mem.h | 2 -- th04/sprites/main_cdg.h | 15 +++++++++++ th04/sprites/main_cdg.inc | 3 +++ th05/mem.h | 2 -- 6 files changed, 73 insertions(+), 5 deletions(-) delete mode 100644 th04/main/ems.h create mode 100644 th04/main/ems.hpp diff --git a/th04/main/ems.h b/th04/main/ems.h deleted file mode 100644 index dc2a9c20..00000000 --- a/th04/main/ems.h +++ /dev/null @@ -1 +0,0 @@ -extern seg_t Ems; /* ZUN symbol [MAGNet2010] */ diff --git a/th04/main/ems.hpp b/th04/main/ems.hpp new file mode 100644 index 00000000..b315732e --- /dev/null +++ b/th04/main/ems.hpp @@ -0,0 +1,55 @@ +/// EMS cache area +/// -------------- +/// Stores situational .CDG images that can later be copied into conventional +/// memory as needed. +/// (Yes, this is not how you make optimal use of EMS memory.) + +#if (GAME == 5) + #define EMS_NAME "GENSOEMS" +#else + #define EMS_NAME "KAIKIEMS" +#endif + +// Layout +// ------ +// This is technically a structure of Planar elements with the +// given size. But since such a structure would exceed 64 KiB, we can't declare +// it as such for a 16-bit compiler. Using an enum won't work either, as Turbo +// C++ 4.0J silently degrades any signed 32-bit values to signed 16-bit ones +// at compile time. That only leaves constants, unfortunately. +// MODDERS: Just remove the needless assignments of hardcoded offset values, +// they only provide unnecessary (and unsafe) padding. Define them in terms of +// their predecessor instead. + +#define sizeof_planar_rect(w, h) \ + ((((w) / BYTE_DOTS) * h) * static_cast(PLANE_COUNT)) + +static const uint32_t EMS_EYECATCH_OFFSET = 0; +static const uint32_t EMS_EYECATCH_END = ( + EMS_EYECATCH_OFFSET + sizeof_planar_rect(EYECATCH_W, EYECATCH_H) +); +static const uint32_t EMS_PLAYCHAR_BOMB_BG_OFFSET = 34000; +static const uint32_t EMS_PLAYCHAR_BOMB_BG_END = (EMS_PLAYCHAR_BOMB_BG_OFFSET + + sizeof_planar_rect(BOMB_BG_W_MAX, BOMB_BG_H_MAX) +); +#if (GAME == 5) + static const uint32_t EMS_FACESET_PLAYCHAR_OFFSET = 100000; +#else + static const uint32_t EMS_FACESET_PLAYCHAR_OFFSET = 94000; +#endif +static const uint32_t EMS_FACESET_PLAYCHAR_END = (EMS_FACESET_PLAYCHAR_OFFSET + + (FACESET_PLAYCHAR_COUNT * sizeof_planar_rect(FACE_W, FACE_H)) +); +#if (GAME == 5) + static const uint32_t EMS_FACESET_BOSS_OFFSET = 200000; + static const uint32_t EMS_FACESET_BOSS_END = (EMS_FACESET_BOSS_OFFSET + + (FACESET_BOSS_COUNT * sizeof_planar_rect(FACE_W, FACE_H)) + ); + static const uint32_t EMSSIZE = 320000; /* ZUN symbol [MAGNet2010] */ +#else + static const uint32_t EMSSIZE = 180000; /* ZUN symbol [MAGNet2010] */ +#endif +// ------ + +extern seg_t Ems; /* ZUN symbol [MAGNet2010] */ +/// -------------- diff --git a/th04/mem.h b/th04/mem.h index 5f8c3db4..c4d49cf7 100644 --- a/th04/mem.h +++ b/th04/mem.h @@ -3,6 +3,4 @@ #define MEM_ASSIGN_PARAS_MAIN (320000 >> 4) #define MEM_ASSIGN_PARAS_MAINE (336000 >> 4) -#define EMSSIZE (180000) /* ZUN symbol [MAGNet2010] */ - #define DEMO_N 4000 /* ZUN symbol [MAGNet2010] */ diff --git a/th04/sprites/main_cdg.h b/th04/sprites/main_cdg.h index 9247ca47..69f7dd50 100644 --- a/th04/sprites/main_cdg.h +++ b/th04/sprites/main_cdg.h @@ -1,10 +1,25 @@ #define FACESET_PLAYCHAR_COUNT 6 #if (GAME == 5) #define FACESET_BOSS_COUNT 6 + + #define EYECATCH_W 288 + #define EYECATCH_H 130 + + #define BOMB_BG_W_MAX ((PLAYFIELD_W / 6) * 5) + #define BOMB_BG_H_MAX PLAYFIELD_H #else #define FACESET_BOSS_COUNT 4 + + #define EYECATCH_W 384 + #define EYECATCH_H 176 + + #define BOMB_BG_W_MAX PLAYFIELD_W + #define BOMB_BG_H_MAX (PLAYFIELD_H - 94) #endif +#define FACE_W 128 +#define FACE_H 128 + // CDG slots for TH04's and TH05's MAIN.EXE. typedef enum { CDG_BG_PLAYCHAR_BOMB = 0, diff --git a/th04/sprites/main_cdg.inc b/th04/sprites/main_cdg.inc index 2cdd9fe8..4642dfda 100644 --- a/th04/sprites/main_cdg.inc +++ b/th04/sprites/main_cdg.inc @@ -5,6 +5,9 @@ else FACESET_BOSS_COUNT = 4 endif +FACE_W = 128 +FACE_H = 128 + CDG_BG_PLAYCHAR_BOMB = 0 CDG_PER_STAGE = 1 CDG_FACESET_PLAYCHAR = 2 diff --git a/th05/mem.h b/th05/mem.h index b9059ef7..e8172c66 100644 --- a/th05/mem.h +++ b/th05/mem.h @@ -3,6 +3,4 @@ #define MEM_ASSIGN_PARAS_MAIN (291200 >> 4) #define MEM_ASSIGN_PARAS_MAINE (336000 >> 4) -#define EMSSIZE (320000) /* ZUN symbol [MAGNet2010] */ - #define DEMO_N 5000 /* ZUN symbol [MAGNet2010] */