|
|
| version 1.2, 2003/10/18 09:02:38 | version 1.8, 2011/02/04 14:43:55 |
|---|---|
| Line 1 | Line 1 |
| 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 21 | |
| 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 | struc slot_t |
| .detune1 resd 1 ; 00 | .detune1 resd 1 ; 00 |
| .totallevel resd 1 ; 04 | .totallevel resd 1 ; 04 |
| Line 21 | Line 50 |
| .env_inc_decay1 resd 1 ; 3c | .env_inc_decay1 resd 1 ; 3c |
| .env_inc_decay2 resd 1 ; 40 | .env_inc_decay2 resd 1 ; 40 |
| .env_inc_rel resd 1 ; 44 | .env_inc_rel resd 1 ; 44 |
| .size | |
| endstruc | endstruc |
| struc ch_t | struc ch_t |
| .slot resb (slot_t.size * 4) | .slot resb (slot_t_size * 4) |
| .algorithm resb 1 | .algorithm resb 1 |
| .feedback resb 1 | .feedback resb 1 |
| resb 2 | .playing resb 1 |
| .outslot resb 1 | |
| .op1fb resd 1 | .op1fb resd 1 |
| .connect1 resd 1 | .connect1 resd 1 |
| .connect3 resd 1 | .connect3 resd 1 |
| Line 42 | Line 71 |
| .extop resb 1 | .extop resb 1 |
| .stereo resb 1 | .stereo resb 1 |
| resb 1 | resb 1 |
| .size | |
| endstruc | endstruc |
| struc opngen_t | struc opngen_t |
| .playchannels resd 1 | .playchannels resd 1 |
| .playing resd 1 | |
| .feedback2 resd 1 | .feedback2 resd 1 |
| .feedback3 resd 1 | .feedback3 resd 1 |
| .feedback4 resd 1 | .feedback4 resd 1 |
| Line 64 | Line 93 |
| .vr_en resd 1 | .vr_en resd 1 |
| .vr_l resd 1 | .vr_l resd 1 |
| .vr_r resd 1 | .vr_r resd 1 |
| endstruc | |
| FMDIV_BITS equ 8 | .sintable resd SIN_ENT |
| FMDIV_ENT equ (1 << FMDIV_BITS) | .envtable resd EVC_ENT |
| FMVOL_SFTBIT equ 4 | .envcurve resd (EVC_ENT*2 + 1) |
| endstruc | |
| 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 | |
| section .text | section .text |
| Line 103 section .text | Line 107 section .text |
| extern _opncfg | extern _opncfg |
| extern _sinshift | extern _sinshift |
| extern _sintable | |
| extern _envshift | 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 | global @opngen_getpcm@12 |
| Line 117 section .text | Line 122 section .text |
| shr eax, (FREQ_BITS - SIN_BITS) | shr eax, (FREQ_BITS - SIN_BITS) |
| and eax, (SIN_ENT - 1) | and eax, (SIN_ENT - 1) |
| mov cl, [_sinshift + eax] | mov cl, [_sinshift + eax] |
| mov eax, [_sintable + eax*4] | mov eax, [SINTABLE + eax*4] |
| add cl, [_envshift + edx] | add cl, [_envshift + edx] |
| imul eax, [_envtable + edx*4] | imul eax, [ENVTABLE + edx*4] |
| sar eax, cl | sar eax, cl |
| %endmacro | %endmacro |
| Line 133 section .text | Line 138 section .text |
| %2: mov [edi + slot_t.env_cnt], eax | %2: mov [edi + slot_t.env_cnt], eax |
| shr eax, ENV_BITS | shr eax, ENV_BITS |
| mov edx, [edi + slot_t.totallevel] | mov edx, [edi + slot_t.totallevel] |
| sub edx, [_env_curve + eax*4] | sub edx, [ENVCURVE + eax*4] |
| %endmacro | %endmacro |
| %macro setenv 2 | %macro setenv 3 |
| %1: mov dl, [edi + slot_t.env_mode] | %1: mov dl, [edi + slot_t.env_mode] |
| dec dl | dec dl |
| je short %%setrr | je short %%setrr |
| Line 162 section .text | Line 167 section .text |
| %%setrr: mov byte [edi + slot_t.env_mode], EM_OFF | %%setrr: mov byte [edi + slot_t.env_mode], EM_OFF |
| %%setd2: mov dword [edi + slot_t.env_end], EC_OFF + 1 | %%setd2: mov dword [edi + slot_t.env_end], EC_OFF + 1 |
| and dword [edi + slot_t.env_inc], byte 0 | and dword [edi + slot_t.env_inc], byte 0 |
| and byte [esi + ch_t.playing], ~(%3) | |
| mov eax, EC_OFF | mov eax, EC_OFF |
| jmp near %2 | jmp near %2 |
| %endmacro | %endmacro |
| Line 171 section .text | Line 177 section .text |
| @opngen_getpcm@12: | @opngen_getpcm@12: |
| cmp dword [esp+4], byte 0 | cmp dword [esp+4], byte 0 |
| je near og_noupdate | je near og_noupdate |
| cmp dword [_opngen + opngen_t.playing], byte 0 | |
| je near og_noupdate | |
| push ebx | push ebx |
| push esi | push esi |
| Line 191 og_fmout_st: mov eax, ebx | Line 199 og_fmout_st: mov eax, ebx |
| sub ebx, eax | sub ebx, eax |
| imul eax, [_opngen + opngen_t.outdr] | imul eax, [_opngen + opngen_t.outdr] |
| mov [esp + OPN_SAMPR], eax | mov [esp + OPN_SAMPR], eax |
| og_fmout_lp: xor eax, eax | og_fmout_lp: mov [_opngen + opngen_t.calcremain], ebx |
| mov [_opngen + opngen_t.calcremain], ebx | and dword [_opngen + opngen_t.playing], byte 0 |
| mov [_opngen + opngen_t.outdl], eax | and dword [_opngen + opngen_t.outdl], byte 0 |
| mov [_opngen + opngen_t.outdc], eax | and dword [_opngen + opngen_t.outdc], byte 0 |
| mov [_opngen + opngen_t.outdr], eax | and dword [_opngen + opngen_t.outdr], byte 0 |
| mov ch, [_opngen + opngen_t.playchannels] | mov ch, [_opngen + opngen_t.playchannels] |
| mov edi, _opnch | mov esi, _opnch |
| og_calcch_lp: xor eax, eax | og_calcch_lp: mov cl, [esi + ch_t.outslot] |
| mov [_opngen + opngen_t.feedback2], eax | test cl, [esi + ch_t.playing] |
| mov [_opngen + opngen_t.feedback3], eax | je near og_calcch_nt |
| mov [_opngen + opngen_t.feedback4], eax | and dword [_opngen + opngen_t.feedback2], byte 0 |
| mov esi, edi | and dword [_opngen + opngen_t.feedback3], byte 0 |
| and dword [_opngen + opngen_t.feedback4], byte 0 | |
| mov edi, esi | |
| calcenv envcalc1, envret1 ; slot1 calculate | calcenv envcalc1, envret1 ; slot1 calculate |
| jl near og_calcslot3 | jl near og_calcslot3 |
| mov cl, [esi + ch_t.feedback] | mov cl, [esi + ch_t.feedback] |
| Line 226 og_algchk: cmp byte [esi + ch_t.algori | Line 236 og_algchk: cmp byte [esi + ch_t.algori |
| jmp short og_calcslot3 | jmp short og_calcslot3 |
| og_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 | og_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 |
| add [ebx], eax | 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 | calcenv envcalc2, envret2 |
| jl short og_calcslot2 | jl short og_calcslot2 |
| mov eax, [_opngen + opngen_t.feedback2] | mov eax, [_opngen + opngen_t.feedback2] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect2] | mov ebx, [esi + ch_t.connect2] |
| add [ebx], eax | 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 | calcenv envcalc3, envret3 |
| jl short og_calcslot4 | jl short og_calcslot4 |
| mov eax, [_opngen + opngen_t.feedback3] | mov eax, [_opngen + opngen_t.feedback3] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect3] | mov ebx, [esi + ch_t.connect3] |
| add [ebx], eax | 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 | calcenv envcalc4, envret4 |
| jl short og_calcsloted | jl short og_calcsloted |
| mov eax, [_opngen + opngen_t.feedback4] | mov eax, [_opngen + opngen_t.feedback4] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect4] | mov ebx, [esi + ch_t.connect4] |
| add [ebx], eax | add [ebx], eax |
| og_calcsloted: add edi, byte (ch_t.size - (slot_t.size * 3)) | og_calcsloted: inc dword [_opngen + opngen_t.playing] |
| og_calcch_nt: add esi, ch_t_size | |
| dec ch | dec ch |
| jne near og_calcch_lp | jne near og_calcch_lp |
| mov eax, [_opngen + opngen_t.outdc] | mov eax, [_opngen + opngen_t.outdc] |
| Line 273 og_nextsamp: neg ebx | Line 284 og_nextsamp: neg ebx |
| imul eax, [_opngen + opngen_t.outdl] | imul eax, [_opngen + opngen_t.outdl] |
| add eax, [esp + OPN_SAMPL] | add eax, [esp + OPN_SAMPL] |
| imul dword [_opncfg + opncfg_t.fmvol] | imul dword [_opncfg + opncfg_t.fmvol] |
| mov [ebp], edx | add [ebp], edx |
| mov eax, [_opngen + opngen_t.outdr] | mov eax, [_opngen + opngen_t.outdr] |
| imul ecx | imul ecx |
| add eax, [esp + OPN_SAMPR] | add eax, [esp + OPN_SAMPR] |
| imul dword [_opncfg + opncfg_t.fmvol] | imul dword [_opncfg + opncfg_t.fmvol] |
| mov [ebp+4], edx | add [ebp+4], edx |
| add ebp, byte 8 | add ebp, byte 8 |
| dec dword [esp + OPN_LENG] | dec dword [esp + OPN_LENG] |
| jne near og_fmout_st | jne near og_fmout_st |
| Line 289 og_nextsamp: neg ebx | Line 300 og_nextsamp: neg ebx |
| pop ebx | pop ebx |
| og_noupdate: ret 4 | og_noupdate: ret 4 |
| setenv envcalc1, envret1 | setenv envcalc1, envret1, 1 |
| setenv envcalc2, envret2 | setenv envcalc2, envret2, 2 |
| setenv envcalc3, envret3 | setenv envcalc3, envret3, 4 |
| setenv envcalc4, envret4 | setenv envcalc4, envret4, 8 |
| align 16 | align 16 |
| Line 357 ogv_algchk: cmp byte [esi + ch_t.algor | Line 368 ogv_algchk: cmp byte [esi + ch_t.algor |
| jmp short ogv_calcslot3 | jmp short ogv_calcslot3 |
| ogv_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 | ogv_calcalg5: mov ebx, [esi + ch_t.connect1] ; case ALG != 5 |
| add [ebx], eax | 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 | calcenv vrenvcalc2, vrenvret2 |
| jl short ogv_calcslot2 | jl short ogv_calcslot2 |
| mov eax, [_opngen + opngen_t.feedback2] | mov eax, [_opngen + opngen_t.feedback2] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect2] | mov ebx, [esi + ch_t.connect2] |
| add [ebx], eax | 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 | calcenv vrenvcalc3, vrenvret3 |
| jl short ogv_calcslot4 | jl short ogv_calcslot4 |
| mov eax, [_opngen + opngen_t.feedback3] | mov eax, [_opngen + opngen_t.feedback3] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect3] | mov ebx, [esi + ch_t.connect3] |
| add [ebx], eax | 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 | calcenv vrenvcalc4, vrenvret4 |
| jl short ogv_calcsloted | jl short ogv_calcsloted |
| mov eax, [_opngen + opngen_t.feedback4] | mov eax, [_opngen + opngen_t.feedback4] |
| op_out | op_out |
| mov ebx, [esi + ch_t.connect4] | mov ebx, [esi + ch_t.connect4] |
| add [ebx], eax | 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 | dec ch |
| jne near ogv_calcch_lp | jne near ogv_calcch_lp |
| mov eax, [_opngen + opngen_t.outdl] | mov eax, [_opngen + opngen_t.outdl] |
| Line 433 ogv_nextsamp: neg ebx | Line 444 ogv_nextsamp: neg ebx |
| pop ebx | pop ebx |
| ogv_noupdate: ret 4 | ogv_noupdate: ret 4 |
| setenv vrenvcalc1, vrenvret1 | setenv vrenvcalc1, vrenvret1, 1 |
| setenv vrenvcalc2, vrenvret2 | setenv vrenvcalc2, vrenvret2, 2 |
| setenv vrenvcalc3, vrenvret3 | setenv vrenvcalc3, vrenvret3, 4 |
| setenv vrenvcalc4, vrenvret4 | setenv vrenvcalc4, vrenvret4, 8 |
| ends | |