--- np2/win9x/x86/opngeng.x86 2003/10/27 15:06:31 1.5 +++ np2/win9x/x86/opngeng.x86 2011/02/02 13:50:29 1.7 @@ -1,4 +1,33 @@ +FMDIV_BITS equ 8 +FMDIV_ENT equ (1 << FMDIV_BITS) +FMVOL_SFTBIT equ 4 + +SIN_BITS equ 11 +EVC_BITS equ 10 +ENV_BITS equ 16 +KF_BITS equ 6 +FREQ_BITS equ 20 +ENVTBL_BIT equ 14 +SINTBL_BIT equ 14 + +TL_BITS equ (FREQ_BITS+2) +OPM_OUTSB equ (TL_BITS + 2 - 16) + +SIN_ENT equ (1 << SIN_BITS) +EVC_ENT equ (1 << EVC_BITS) + +EC_ATTACK equ 0 +EC_DECAY equ (EVC_ENT << ENV_BITS) +EC_OFF equ ((2 * EVC_ENT) << ENV_BITS) + +EM_ATTACK equ 4 +EM_DECAY1 equ 3 +EM_DECAY2 equ 2 +EM_RELEASE equ 1 +EM_OFF equ 0 + + struc slot_t .detune1 resd 1 ; 00 .totallevel resd 1 ; 04 @@ -21,11 +50,10 @@ .env_inc_decay1 resd 1 ; 3c .env_inc_decay2 resd 1 ; 40 .env_inc_rel resd 1 ; 44 -.size endstruc struc ch_t -.slot resb (slot_t.size * 4) +.slot resb (slot_t_size * 4) .algorithm resb 1 .feedback resb 1 .playing resb 1 @@ -43,7 +71,6 @@ .extop resb 1 .stereo resb 1 resb 1 -.size endstruc struc opngen_t @@ -66,36 +93,11 @@ .vr_en resd 1 .vr_l resd 1 .vr_r resd 1 - endstruc - -FMDIV_BITS equ 8 -FMDIV_ENT equ (1 << FMDIV_BITS) -FMVOL_SFTBIT equ 4 - -SIN_BITS equ 11 -EVC_BITS equ 10 -ENV_BITS equ 16 -KF_BITS equ 6 -FREQ_BITS equ 20 -ENVTBL_BIT equ 14 -SINTBL_BIT equ 14 - -TL_BITS equ (FREQ_BITS+2) -OPM_OUTSB equ (TL_BITS + 2 - 16) - -SIN_ENT equ (1 << SIN_BITS) -EVC_ENT equ (1 << EVC_BITS) - -EC_ATTACK equ 0 -EC_DECAY equ (EVC_ENT << ENV_BITS) -EC_OFF equ ((2 * EVC_ENT) << ENV_BITS) - -EM_ATTACK equ 4 -EM_DECAY1 equ 3 -EM_DECAY2 equ 2 -EM_RELEASE equ 1 -EM_OFF equ 0 +.sintable resd SIN_ENT +.envtable resd EVC_ENT +.envcurve resd (EVC_ENT*2 + 1) + endstruc section .text @@ -105,10 +107,11 @@ section .text extern _opncfg extern _sinshift - extern _sintable extern _envshift - extern _envtable - extern _env_curve + +ENVCURVE equ (_opncfg + opncfg_t.envcurve) +SINTABLE equ (_opncfg + opncfg_t.sintable) +ENVTABLE equ (_opncfg + opncfg_t.envtable) global @opngen_getpcm@12 @@ -119,9 +122,9 @@ section .text shr eax, (FREQ_BITS - SIN_BITS) and eax, (SIN_ENT - 1) mov cl, [_sinshift + eax] - mov eax, [_sintable + eax*4] + mov eax, [SINTABLE + eax*4] add cl, [_envshift + edx] - imul eax, [_envtable + edx*4] + imul eax, [ENVTABLE + edx*4] sar eax, cl %endmacro @@ -135,7 +138,7 @@ section .text %2: mov [edi + slot_t.env_cnt], eax shr eax, ENV_BITS mov edx, [edi + slot_t.totallevel] - sub edx, [_env_curve + eax*4] + sub edx, [ENVCURVE + eax*4] %endmacro %macro setenv 3 @@ -233,21 +236,21 @@ og_algchk: cmp byte [esi + ch_t.algori jmp short og_calcslot3 og_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 add [ebx], eax -og_calcslot3: add edi, byte slot_t.size ; slot3 calculate +og_calcslot3: add edi, byte slot_t_size ; slot3 calculate calcenv envcalc2, envret2 jl short og_calcslot2 mov eax, [_opngen + opngen_t.feedback2] op_out mov ebx, [esi + ch_t.connect2] add [ebx], eax -og_calcslot2: add edi, byte slot_t.size ; slot2 calculate +og_calcslot2: add edi, byte slot_t_size ; slot2 calculate calcenv envcalc3, envret3 jl short og_calcslot4 mov eax, [_opngen + opngen_t.feedback3] op_out mov ebx, [esi + ch_t.connect3] add [ebx], eax -og_calcslot4: add edi, byte slot_t.size ; slot4 calculate +og_calcslot4: add edi, byte slot_t_size ; slot4 calculate calcenv envcalc4, envret4 jl short og_calcsloted mov eax, [_opngen + opngen_t.feedback4] @@ -255,7 +258,7 @@ og_calcslot4: add edi, byte slot_t.size mov ebx, [esi + ch_t.connect4] add [ebx], eax og_calcsloted: inc dword [_opngen + opngen_t.playing] -og_calcch_nt: add esi, ch_t.size +og_calcch_nt: add esi, ch_t_size dec ch jne near og_calcch_lp mov eax, [_opngen + opngen_t.outdc] @@ -365,28 +368,28 @@ ogv_algchk: cmp byte [esi + ch_t.algor jmp short ogv_calcslot3 ogv_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 add [ebx], eax -ogv_calcslot3: add edi, byte slot_t.size ; slot3 calculate +ogv_calcslot3: add edi, byte slot_t_size ; slot3 calculate calcenv vrenvcalc2, vrenvret2 jl short ogv_calcslot2 mov eax, [_opngen + opngen_t.feedback2] op_out mov ebx, [esi + ch_t.connect2] add [ebx], eax -ogv_calcslot2: add edi, byte slot_t.size ; slot2 calculate +ogv_calcslot2: add edi, byte slot_t_size ; slot2 calculate calcenv vrenvcalc3, vrenvret3 jl short ogv_calcslot4 mov eax, [_opngen + opngen_t.feedback3] op_out mov ebx, [esi + ch_t.connect3] add [ebx], eax -ogv_calcslot4: add edi, byte slot_t.size ; slot4 calculate +ogv_calcslot4: add edi, byte slot_t_size ; slot4 calculate calcenv vrenvcalc4, vrenvret4 jl short ogv_calcsloted mov eax, [_opngen + opngen_t.feedback4] op_out mov ebx, [esi + ch_t.connect4] add [ebx], eax -ogv_calcsloted: add edi, byte (ch_t.size - (slot_t.size * 3)) +ogv_calcsloted: add edi, byte (ch_t_size - (slot_t_size * 3)) dec ch jne near ogv_calcch_lp mov eax, [_opngen + opngen_t.outdl] @@ -446,5 +449,3 @@ ogv_noupdate: ret 4 setenv vrenvcalc3, vrenvret3, 4 setenv vrenvcalc4, vrenvret4, 8 - ends -