diff --git a/libs/master.lib/resdata.asm b/libs/master.lib/resdata.asm new file mode 100644 index 00000000..3cbe683e --- /dev/null +++ b/libs/master.lib/resdata.asm @@ -0,0 +1,178 @@ +; master library - MS-DOS +; +; Description: +; 常駐データの検索( resdata_exist ) +; 常駐データの作成( resdata_create ) +; +; Function/Procedures: +; unsigned resdata_exist( char * idstr, unsigned idlen, unsigned parasize) ; +; unsigned resdata_create( char * idstr, unsigned idlen, unsigned parasize) ; +; +; Parameters: +; char * idstr ; /* 識別データ */ +; unsigned idlen ; /* 識別データの長さ */ +; unsigned parasize ; /* データブロックのパラグラフサイズ */ +; +; Returns: +; (resdata_exist) 常駐データが見つかったら、0以外を返します。 +; (常駐データのセグメントアドレス) +; (resdata_create) 作成できない(メモリ不足)ならば 0 +; 作成したなら (常駐データのセグメントアドレス) +; +; Binding Target: +; Microsoft-C / Turbo-C / Turbo Pascal +; +; Running Target: +; MS-DOS +; +; Requiring Resources: +; CPU: 8086 +; +; Notes: +; 開放は、dos_freeでやってね +; +; Compiler/Assembler: +; TASM 3.0 +; OPTASM 1.6 +; +; Author: +; 恋塚昭彦 +; +; Revision History: +; 92/11/16 Initial +; 92/11/21 for Pascal +; 93/ 4/15 respal_createに戻り値をつけた +; 95/ 1/ 7 Initial: resdata.asm/master.lib 0.23 + +_mcb_flg equ 0 +_mcb_owner equ 1 +_mcb_size equ 3 + +func RESDATA_EXIST ; resdata_exist() { + push BP + mov BP,SP + push SI + push DI + _push DS + + ; 引き数 + @@id_str = (RETSIZE+3)*2 + @@id_len = (RETSIZE+2)*2 + @@parasize = (RETSIZE+1)*2 + + ; 常駐パレットの捜索 + mov AH, 52h + int 21h + CLD + mov BX, ES:[BX-2] +@@FIND: + mov ES,BX + inc BX + mov AX,ES:[_mcb_owner] + or AX,AX + je short @@SKIP + mov AX,ES:[_mcb_size] + cmp AX,[BP+@@parasize] + jne short @@SKIP + mov CX,[BP+@@id_len] + _lds SI,[BP+@@id_str] + mov DI,10h ; MCBの次 + rep cmpsb + je short @@FOUND + @@SKIP: + mov AX,ES:[_mcb_size] + add BX,AX + mov AL,ES:[_mcb_flg] + cmp AL,'M' + je short @@FIND +@@NOTFOUND: + mov BX,0 +@@FOUND: + mov AX,BX + + _pop DS + pop DI + pop SI + pop BP + ret (2+DATASIZE)*2 +endfunc ; } + + +func RESDATA_CREATE ; resdata_create() { + push BP + mov BP,SP + push SI + push DI + _push DS + + ; 引き数 + @@id_str = (RETSIZE+3)*2 + @@id_len = (RETSIZE+2)*2 + @@parasize = (RETSIZE+1)*2 + +if LDATA + push word ptr [BP+@@id_str+2] +endif + push word ptr [BP+@@id_str] + push word ptr [BP+@@id_len] + push word ptr [BP+@@parasize] + _call RESDATA_EXIST + or AX,AX + jnz short @@IGNORE +@@CREATE: + mov AX,5800h ; アロケーションストラテジを得る + int 21h + mov DX,AX ; 得たストラテジを保存する + + mov AX,5801h + mov BX,1 ; 必要最小のアロケーション + int 21h + mov AH,48h ; メモリ割り当て + mov BX,[BP+@@parasize] + int 21h + mov CX,0 + jc short @@DAME + mov BX,CS ; 自分より前ならOK + cmp BX,AX + jnb short @@ALLOC_OK + mov ES,AX ; 自分より後ろだったら + mov AH,49h ; 解放する。 + int 21h ; + + mov AX,5801h ; + mov BX,2 ; 最上位からのアロケーション + int 21h + + mov AH,48h ; メモリ割り当て + mov BX,[BP+@@parasize] + int 21h + @@ALLOC_OK: + mov CX,AX + push AX + + dec CX ; MCBのownerを書き換える + mov ES,CX ; + mov AX,-1 ; + mov ES:[_mcb_owner],AX ; + inc CX + mov ES,CX + xor DI,DI ; IDの書き込み + mov CX,[BP+@@id_len] + _lds SI,[BP+@@id_str] + rep movsb + + pop CX + +@@DAME: + mov AX,5801h ; アロケーションストラテジの復帰 + mov BX,DX ; + int 21h ; + mov AX,CX + +@@IGNORE: + _pop DS + pop DI + pop SI + pop BP + ret (2+DATASIZE)*2 +endfunc ; } diff --git a/libs/master.lib/resdata[data].asm b/libs/master.lib/resdata[data].asm new file mode 100644 index 00000000..1f960866 --- /dev/null +++ b/libs/master.lib/resdata[data].asm @@ -0,0 +1,3 @@ +public RESDATA_ResPalID +RESDATA_ResPalID db 'pal98 grb', 0 +RESDATA_IDLEN EQU 10 diff --git a/th01_fuuin.asm b/th01_fuuin.asm index 8bb673c7..679a10b1 100644 --- a/th01_fuuin.asm +++ b/th01_fuuin.asm @@ -1813,137 +1813,7 @@ include libs/master.lib/palette_show.asm include libs/master.lib/palette_init.asm include libs/master.lib/respal_exist.asm include libs/master.lib/respal_free.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F6A proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = dword ptr 0Ah - - push bp - mov bp, sp - push si - push di - push ds - mov ah, 52h - int 21h ; DOS - 2+ internal - GET LIST OF LISTS - ; Return: ES:BX -> DOS list of lists - cld - mov bx, es:[bx-2] - -loc_F79: - mov es, bx - inc bx - mov ax, es:1 - or ax, ax - jz short loc_F9A - mov ax, es:3 - cmp ax, [bp+arg_0] - jnz short loc_F9A - mov cx, [bp+arg_2] - lds si, [bp+arg_4] - mov di, 10h - repe cmpsb - jz short loc_FAB - -loc_F9A: - mov ax, es:3 - add bx, ax - mov al, es:0 - cmp al, 4Dh ; 'M' - jz short loc_F79 - mov bx, 0 - -loc_FAB: - mov ax, bx - pop ds - pop di - pop si - pop bp - retf 8 -sub_F6A endp - -; --------------------------------------------------------------------------- - push bp - mov bp, sp - push si - push di - push ds - push word ptr [bp+0Ch] - push word ptr [bp+0Ah] - push word ptr [bp+8] - push word ptr [bp+6] - push cs - call near ptr sub_F6A - or ax, ax - jnz short loc_1028 - mov ax, 5800h - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: get allocation strategy - mov dx, ax - mov ax, 5801h - mov bx, 1 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+6] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - mov cx, 0 - jb short loc_101F - mov bx, cs - cmp bx, ax - jnb short loc_1004 - mov es, ax - assume es:nothing - mov ah, 49h - int 21h ; DOS - 2+ - FREE MEMORY - ; ES = segment address of area to be freed - mov ax, 5801h - mov bx, 2 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+6] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - -loc_1004: - mov cx, ax - push ax - dec cx - mov es, cx - assume es:nothing - mov ax, 0FFFFh - mov es:1, ax - inc cx - mov es, cx - assume es:nothing - xor di, di - mov cx, [bp+8] - lds si, [bp+0Ah] - rep movsb - pop cx - -loc_101F: - mov ax, 5801h - mov bx, dx - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ax, cx - -loc_1028: - pop ds - pop di - pop si - pop bp - retf 8 -; --------------------------------------------------------------------------- - +include libs/master.lib/resdata.asm include libs/master.lib/file_read.asm include libs/master.lib/file_close.asm include libs/master.lib/file_ropen.asm @@ -7434,7 +7304,7 @@ var_4 = dword ptr -4 push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F6A + call resdata_exist mov di, ax or di, di jnz short loc_9F65 @@ -7571,7 +7441,7 @@ var_4 = dword ptr -4 push offset aReiidenconfi_0 ; "ReiidenConfig" push 0Dh push 5 - call sub_F6A + call resdata_exist mov di, ax or di, di jz short loc_A0EE @@ -26580,7 +26450,7 @@ include libs/master.lib/grp[data].asm db 0 include libs/master.lib/pal[data].asm include libs/master.lib/respal_exist[data].asm -aPal98Grb_1 db 'pal98 grb',0 +include libs/master.lib/resdata[data].asm include libs/master.lib/fil[data].asm include libs/master.lib/dos_ropen[data].asm include libs/master.lib/clip[data].asm diff --git a/th01_op.asm b/th01_op.asm index 2d9f238c..6c4d9888 100644 --- a/th01_op.asm +++ b/th01_op.asm @@ -1728,149 +1728,7 @@ include libs/master.lib/palette_show.asm include libs/master.lib/palette_init.asm include libs/master.lib/respal_exist.asm include libs/master.lib/respal_free.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F12 proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = dword ptr 0Ah - - push bp - mov bp, sp - push si - push di - push ds - mov ah, 52h - int 21h ; DOS - 2+ internal - GET LIST OF LISTS - ; Return: ES:BX -> DOS list of lists - cld - mov bx, es:[bx-2] - -loc_F21: - mov es, bx - inc bx - mov ax, es:1 - or ax, ax - jz short loc_F42 - mov ax, es:3 - cmp ax, [bp+arg_0] - jnz short loc_F42 - mov cx, [bp+arg_2] - lds si, [bp+arg_4] - mov di, 10h - repe cmpsb - jz short loc_F53 - -loc_F42: - mov ax, es:3 - add bx, ax - mov al, es:0 - cmp al, 4Dh ; 'M' - jz short loc_F21 - mov bx, 0 - -loc_F53: - mov ax, bx - pop ds - pop di - pop si - pop bp - retf 8 -sub_F12 endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F5C proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = dword ptr 0Ah - - push bp - mov bp, sp - push si - push di - push ds - push word ptr [bp+arg_4+2] - push word ptr [bp+arg_4] - push [bp+arg_2] - push [bp+arg_0] - push cs - call near ptr sub_F12 - or ax, ax - jnz short loc_FD0 - mov ax, 5800h - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: get allocation strategy - mov dx, ax - mov ax, 5801h - mov bx, 1 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+arg_0] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - mov cx, 0 - jb short loc_FC7 - mov bx, cs - cmp bx, ax - jnb short loc_FAC - mov es, ax - assume es:nothing - mov ah, 49h - int 21h ; DOS - 2+ - FREE MEMORY - ; ES = segment address of area to be freed - mov ax, 5801h - mov bx, 2 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+arg_0] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - -loc_FAC: - mov cx, ax - push ax - dec cx - mov es, cx - assume es:nothing - mov ax, 0FFFFh - mov es:1, ax - inc cx - mov es, cx - assume es:nothing - xor di, di - mov cx, [bp+arg_2] - lds si, [bp+arg_4] - rep movsb - pop cx - -loc_FC7: - mov ax, 5801h - mov bx, dx - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ax, cx - -loc_FD0: - pop ds - pop di - pop si - pop bp - retf 8 -sub_F5C endp - -; --------------------------------------------------------------------------- - +include libs/master.lib/resdata.asm include libs/master.lib/file_read.asm include libs/master.lib/file_close.asm include libs/master.lib/file_ropen.asm @@ -15843,7 +15701,7 @@ arg_A = word ptr 10h push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F12 + call resdata_exist mov si, ax or si, si jnz short loc_E2C6 @@ -15851,7 +15709,7 @@ arg_A = word ptr 10h push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F5C + call resdata_create mov si, ax mov word ptr dword_13EE6+2, si mov word ptr dword_13EE6, 0 @@ -15901,7 +15759,7 @@ sub_E27C endp push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F12 + call resdata_exist mov si, ax or si, si jnz short loc_E33F @@ -15967,7 +15825,7 @@ sub_E3C5 proc far push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F12 + call resdata_exist mov si, ax or si, si jz short loc_E3E2 @@ -24056,16 +23914,7 @@ include libs/master.lib/grp[data].asm db 0 include libs/master.lib/pal[data].asm include libs/master.lib/respal_exist[data].asm - db 70h ; p - db 61h ; a - db 6Ch ; l - db 39h ; 9 - db 38h ; 8 - db 20h - db 67h ; g - db 72h ; r - db 62h ; b - db 0 +include libs/master.lib/resdata[data].asm include libs/master.lib/fil[data].asm db 3 db 0 diff --git a/th01_reiiden.asm b/th01_reiiden.asm index 9bfa2271..b3508edf 100644 --- a/th01_reiiden.asm +++ b/th01_reiiden.asm @@ -1849,149 +1849,7 @@ include libs/master.lib/palette_show.asm include libs/master.lib/palette_init.asm include libs/master.lib/respal_exist.asm include libs/master.lib/respal_free.asm - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_F5C proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = dword ptr 0Ah - - push bp - mov bp, sp - push si - push di - push ds - mov ah, 52h - int 21h ; DOS - 2+ internal - GET LIST OF LISTS - ; Return: ES:BX -> DOS list of lists - cld - mov bx, es:[bx-2] - -loc_F6B: - mov es, bx - inc bx - mov ax, es:1 - or ax, ax - jz short loc_F8C - mov ax, es:3 - cmp ax, [bp+arg_0] - jnz short loc_F8C - mov cx, [bp+arg_2] - lds si, [bp+arg_4] - mov di, 10h - repe cmpsb - jz short loc_F9D - -loc_F8C: - mov ax, es:3 - add bx, ax - mov al, es:0 - cmp al, 4Dh ; 'M' - jz short loc_F6B - mov bx, 0 - -loc_F9D: - mov ax, bx - pop ds - pop di - pop si - pop bp - retf 8 -sub_F5C endp - - -; =============== S U B R O U T I N E ======================================= - -; Attributes: bp-based frame - -sub_FA6 proc far - -arg_0 = word ptr 6 -arg_2 = word ptr 8 -arg_4 = dword ptr 0Ah - - push bp - mov bp, sp - push si - push di - push ds - push word ptr [bp+arg_4+2] - push word ptr [bp+arg_4] - push [bp+arg_2] - push [bp+arg_0] - push cs - call near ptr sub_F5C - or ax, ax - jnz short loc_101A - mov ax, 5800h - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: get allocation strategy - mov dx, ax - mov ax, 5801h - mov bx, 1 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+arg_0] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - mov cx, 0 - jb short loc_1011 - mov bx, cs - cmp bx, ax - jnb short loc_FF6 - mov es, ax - assume es:nothing - mov ah, 49h - int 21h ; DOS - 2+ - FREE MEMORY - ; ES = segment address of area to be freed - mov ax, 5801h - mov bx, 2 - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ah, 48h ; 'H' - mov bx, [bp+arg_0] - int 21h ; DOS - 2+ - ALLOCATE MEMORY - ; BX = number of 16-byte paragraphs desired - -loc_FF6: - mov cx, ax - push ax - dec cx - mov es, cx - assume es:nothing - mov ax, 0FFFFh - mov es:1, ax - inc cx - mov es, cx - assume es:nothing - xor di, di - mov cx, [bp+arg_2] - lds si, [bp+arg_4] - rep movsb - pop cx - -loc_1011: - mov ax, 5801h - mov bx, dx - int 21h ; DOS - 3+ - GET/SET MEMORY ALLOCATION STRATEGY - ; AL = function code: set allocation strategy - mov ax, cx - -loc_101A: - pop ds - pop di - pop si - pop bp - retf 8 -sub_FA6 endp - -; --------------------------------------------------------------------------- - +include libs/master.lib/resdata.asm include libs/master.lib/file_read.asm include libs/master.lib/file_close.asm include libs/master.lib/file_exist.asm @@ -23421,7 +23279,7 @@ arg_A = word ptr 10h push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F5C + call resdata_exist mov si, ax or si, si jnz short loc_11619 @@ -23429,7 +23287,7 @@ arg_A = word ptr 10h push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_FA6 + call resdata_create mov si, ax mov word ptr dword_3919C+2, si mov word ptr dword_3919C, 0 @@ -23493,7 +23351,7 @@ arg_18 = dword ptr 1Eh push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F5C + call resdata_exist mov si, ax or si, si jnz short loc_11692 @@ -23561,7 +23419,7 @@ sub_11718 proc far push offset aReiidenconfig ; "ReiidenConfig" push 0Dh push 5 - call sub_F5C + call resdata_exist mov si, ax or si, si jz short loc_11735 @@ -43113,7 +42971,7 @@ include libs/master.lib/grp[data].asm db 0 include libs/master.lib/pal[data].asm include libs/master.lib/respal_exist[data].asm -aPal98Grb_1 db 'pal98 grb',0 +include libs/master.lib/resdata[data].asm include libs/master.lib/fil[data].asm db 3 db 0