diff --git a/th01/mdrv2.c b/th01/mdrv2.c index 782cb0e4..4d8e91ad 100644 --- a/th01/mdrv2.c +++ b/th01/mdrv2.c @@ -28,6 +28,26 @@ typedef enum { } mdrv2_func_t; extern char mdrv2_have_board; +struct hack { char x[12]; }; // XXX +extern const struct hack mdrv2_magic; + +int far 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 + ); + int i; + + for(i = 0; i < sizeof(s1); i++) { + s1[i] = magicp[i]; + } + if(strcmp(s1, s2.x) != 0) { + return 0; + } + return 1; +} static void near pascal mdrv2_load(const char *fn, char func) { diff --git a/th01/mdrv2[data].asm b/th01/mdrv2[data].asm new file mode 100644 index 00000000..9b8d64b9 --- /dev/null +++ b/th01/mdrv2[data].asm @@ -0,0 +1,5 @@ +public _mdrv2_have_board +_mdrv2_have_board db 0 + db 0 +public _mdrv2_magic +_mdrv2_magic db 'Mdrv2System',0 diff --git a/th01_fuuin.asm b/th01_fuuin.asm index b9d98a0a..cc197342 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -316,7 +316,7 @@ _envp = dword ptr 0Ch push bp mov bp, sp - call sub_EF80 + call _mdrv2_resident or ax, ax jnz short loc_A105 pop bp @@ -9909,74 +9909,7 @@ fuuin_12_TEXT ends ; Segment type: Pure code fuuin_13_TEXT segment byte public 'CODE' use16 - assume cs:fuuin_13_TEXT - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_EF80 proc far - -s2 = byte ptr -1Ch -s1 = byte ptr -10h -var_4 = dword ptr -4 - - enter 1Ch, 0 - push si - lea ax, [bp+s2] - push ss - push ax - push ds - push offset aMdrv2system ; "Mdrv2System" - mov cx, 0Ch - call SCOPY@ - xor ax, ax - mov es, ax - movsx eax, word ptr es:[03CAh] - shl eax, 10h - add eax, 102h - shld edx, eax, 10h - mov word ptr [bp+var_4+2], dx - mov word ptr [bp+var_4], ax - xor si, si - jmp short loc_EFC6 -; --------------------------------------------------------------------------- - -loc_EFBA: - les bx, [bp+var_4] - assume es:nothing - add bx, si - mov al, es:[bx] - mov [bp+si+s1], al - inc si - -loc_EFC6: - cmp si, 0Ch - jl short loc_EFBA - push ss - lea ax, [bp+s2] - push ax ; s2 - push ss - lea ax, [bp+s1] - push ax ; s1 - call _strcmp - add sp, 8 - or ax, ax - jz short loc_EFE5 - xor ax, ax - jmp short loc_EFE8 -; --------------------------------------------------------------------------- - -loc_EFE5: - mov ax, 1 - -loc_EFE8: - pop si - leave - retf -sub_EF80 endp - + extern _mdrv2_resident:proc extern _mdrv2_bgm_load:proc extern _mdrv2_se_load:proc extern _mdrv2_bgm_play:proc @@ -10338,10 +10271,7 @@ word_134FA dw 1 db 0 word_13507 dw 64h byte_13509 db 0 -public _mdrv2_have_board -_mdrv2_have_board db 0 - db 0 -aMdrv2system db 'Mdrv2System',0 +include th01/mdrv2[data].asm include libs/master.lib/version[data].asm include libs/master.lib/grp[data].asm include libs/master.lib/pal[data].asm diff --git a/th01_op.asm b/th01_op.asm index 4924e16e..2aca05d6 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -7578,75 +7578,7 @@ op_10_TEXT ends ; Segment type: Pure code op_11_TEXT segment byte public 'CODE' use16 - assume cs:op_11_TEXT - ;org 5 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -_mdrv2_resident proc far - -s2 = byte ptr -1Ch -s1 = byte ptr -10h -var_4 = dword ptr -4 - - enter 1Ch, 0 - push si - lea ax, [bp+s2] - push ss - push ax - push ds - push offset aMdrv2system ; "Mdrv2System" - mov cx, 0Ch - call SCOPY@ - xor ax, ax - mov es, ax - movsx eax, word ptr es:[03CAh] - shl eax, 10h - add eax, 102h - shld edx, eax, 10h - mov word ptr [bp+var_4+2], dx - mov word ptr [bp+var_4], ax - xor si, si - jmp short loc_E42B -; --------------------------------------------------------------------------- - -loc_E41F: - les bx, [bp+var_4] - assume es:nothing - add bx, si - mov al, es:[bx] - mov [bp+si+s1], al - inc si - -loc_E42B: - cmp si, 0Ch - jl short loc_E41F - push ss - lea ax, [bp+s2] - push ax ; s2 - push ss - lea ax, [bp+s1] - push ax ; s1 - call _strcmp - add sp, 8 - or ax, ax - jz short loc_E44A - xor ax, ax - jmp short loc_E44D -; --------------------------------------------------------------------------- - -loc_E44A: - mov ax, 1 - -loc_E44D: - pop si - leave - retf -_mdrv2_resident endp - + extern _mdrv2_resident:proc extern _mdrv2_bgm_load:proc extern _mdrv2_bgm_play:proc extern _mdrv2_bgm_stop:proc @@ -7654,7 +7586,6 @@ _mdrv2_resident endp extern _mdrv2_check_board:proc op_11_TEXT ends -; --------------------------------------------------------------------------- ; =========================================================================== op_12_TEXT segment byte public 'CODE' use16 @@ -8025,10 +7956,7 @@ include libs/master.lib/clip[data].asm include libs/master.lib/rand[data].asm public _res_id _res_id db 'ReiidenConfig',0 -public _mdrv2_have_board -_mdrv2_have_board db 0 - db 0 -aMdrv2system db 'Mdrv2System',0 +include th01/mdrv2[data].asm .data? ; TODO: Missing clip[bss].asm (16 bytes) somewhere in there... diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 787db55e..bb6df6dc 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -4012,7 +4012,7 @@ _envp = dword ptr 0Ch mov [bp+var_2], 0 xor si, si mov [bp+var_4], 0 - call sub_12455 + call _mdrv2_resident or ax, ax jnz short loc_D54F jmp short loc_D579 @@ -12723,75 +12723,7 @@ main_15_TEXT ends ; Segment type: Pure code main_16_TEXT segment byte public 'CODE' use16 - assume cs:main_16_TEXT - ;org 5 - assume es:nothing, ss:nothing, ds:_DATA, fs:nothing, gs:nothing - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_12455 proc far - -_s2 = byte ptr -1Ch -s1 = byte ptr -10h -var_4 = dword ptr -4 - - enter 1Ch, 0 - push si - lea ax, [bp+_s2] - push ss - push ax - push ds - push offset aMdrv2system ; "Mdrv2System" - mov cx, 0Ch - call SCOPY@ - xor ax, ax - mov es, ax - movsx eax, word ptr es:[03CAh] - shl eax, 10h - add eax, 102h - shld edx, eax, 10h - mov word ptr [bp+var_4+2], dx - mov word ptr [bp+var_4], ax - xor si, si - jmp short loc_1249B -; --------------------------------------------------------------------------- - -loc_1248F: - les bx, [bp+var_4] - assume es:nothing - add bx, si - mov al, es:[bx] - mov [bp+si+s1], al - inc si - -loc_1249B: - cmp si, 0Ch - jl short loc_1248F - push ss - lea ax, [bp+_s2] - push ax ; s2 - push ss - lea ax, [bp+s1] - push ax ; s1 - call _strcmp - add sp, 8 - or ax, ax - jz short loc_124BA - xor ax, ax - jmp short loc_124BD -; --------------------------------------------------------------------------- - -loc_124BA: - mov ax, 1 - -loc_124BD: - pop si - leave - retf -sub_12455 endp - + extern _mdrv2_resident:proc extern _mdrv2_bgm_load:proc extern _mdrv2_se_load:proc extern _mdrv2_bgm_play:proc @@ -29839,10 +29771,7 @@ unk_355EC db 0 db 0FCh db 1 db 0FEh -public _mdrv2_have_board -_mdrv2_have_board db 0 - db 0 -aMdrv2system db 'Mdrv2System',0 +include th01/mdrv2[data].asm aVqvnvtvmvcb@vp db '‚q‚n‚t‚m‚c@‚P@‚b‚k‚d‚`‚q',0 aVbvpvovzvtvbvf db '‚b‚‚Ž‚‡‚’‚‚”‚•‚Œ‚‚”‚‰‚‚ŽII',0 aVrvevmvevgvfb@ db '‚r‚…‚Œ‚…‚ƒ‚”@‚Ž‚…‚˜‚”@‚q‚‚•‚Ž‚„',0