[Reverse-engineering] [th04/th05] EMS: Cache area layout

Part of P0168, funded by Blue Bolt and rosenrose.
This commit is contained in:
nmlgc 2021-11-12 18:52:24 +01:00
parent 9c99bc0eb1
commit ccca7bf6ee
6 changed files with 73 additions and 5 deletions

View File

@ -1 +0,0 @@
extern seg_t Ems; /* ZUN symbol [MAGNet2010] */

55
th04/main/ems.hpp Normal file
View File

@ -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<dots8_t[]> 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<uint32_t>(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] */
/// --------------

View File

@ -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] */

View File

@ -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,

View File

@ -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

View File

@ -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] */