[Decompilation] [th01] MDRV2: Move all data to C land

Part of P0213, funded by Ember2528 and GhostRiderCog.
This commit is contained in:
nmlgc 2022-08-10 17:04:08 +02:00
parent 04f5c27d13
commit a3bc614e68
5 changed files with 15 additions and 18 deletions

View File

@ -15,6 +15,8 @@ extern "C" {
#include "th01/snd/mdrv2.h"
}
#define MDRV2_MAGIC "Mdrv2System"
typedef enum {
MDRV2_MPLAY = 0x00,
MDRV2_MFADE_OUT_BLOCK = 0x01,
@ -29,29 +31,32 @@ typedef enum {
static const uint8_t MDRV2 = 0xF2;
inline int16_t mdrv2_segment(void) {
// 0000:((0xF2 * 4) + 2)
return peek(0, ((MDRV2 * sizeof(void far *)) + sizeof(void near *)));
}
inline uint16_t mdrv2_call(mdrv2_func_t func) {
_AH = func;
geninterrupt(MDRV2);
return _AX;
}
extern char mdrv2_have_board;
struct hack { char x[12]; }; // XXX
extern const struct hack mdrv2_magic;
static int8_t mdrv2_have_board = false; // ACTUAL TYPE: bool
static int8_t mdrv2_unused = 0; // ZUN bloat
bool16 mdrv2_resident(void)
{
char s1[sizeof(mdrv2_magic)];
const struct hack s2 = mdrv2_magic;
char far *magicp = (char far *)(
((long)peek(0, MDRV2 * 4 + 2) << 16) + 0x102
char s1[sizeof(MDRV2_MAGIC)];
const char MAGIC[] = "Mdrv2System";
char far *magicp = reinterpret_cast<char far *>(
(static_cast<uint32_t>(mdrv2_segment()) << 16) + 0x102
);
int i;
for(i = 0; i < sizeof(s1); i++) {
for(int i = 0; i < sizeof(s1); i++) {
s1[i] = magicp[i];
}
if(strcmp(s1, s2.x) != 0) {
if(strcmp(s1, MAGIC) != 0) {
return false;
}
return true;

View File

@ -1,5 +0,0 @@
public _mdrv2_have_board
_mdrv2_have_board db 0
db 0
public _mdrv2_magic
_mdrv2_magic db 'Mdrv2System',0

View File

@ -16,6 +16,5 @@ include th01/hardware/palette[data].asm
include th01/hardware/graph_r[data].asm
include th01/hardware/respal[data].asm
include th01/formats/grp_ptn[data].asm
include th01/snd/mdrv2[data].asm
end

View File

@ -1612,7 +1612,6 @@ include libs/master.lib/clip[data].asm
include libs/master.lib/rand[data].asm
public _res_id
_res_id db 'ReiidenConfig',0
include th01/snd/mdrv2[data].asm
.data?
public _rand

View File

@ -3343,7 +3343,6 @@ include th01/sprites/ileave_m.asp
db 0
db 0FFh
include th01/sprites/laser_s.asp
include th01/snd/mdrv2[data].asm
extern _arc_key:byte
extern _card_flip_cycle:byte