PS2SDK
PS2 Homebrew Libraries
Loading...
Searching...
No Matches
vm_init.c
1/*
2# _____ ___ ____ ___ ____
3# ____| | ____| | | |____|
4# | ___| |____ ___| ____| | \ PS2DEV Open Source Project.
5#-----------------------------------------------------------------------
6# Copyright ps2dev - http://www.ps2dev.org
7# Licenced under Academic Free License version 2.0
8# Review ps2sdk README & LICENSE files for further details.
9*/
10
11#include "libsnd2_internal.h"
12
13static libspu2_malloc_t _ss_spu_vm_rec[32];
14
15void _SsVmInit(int voice_count)
16{
17 u16 v8;
18 SpuVoiceAttr voice_attr;
19
20 _spu_setInTransfer(0);
21 _svm_damper = 0;
22 SpuInitMalloc(32, (char *)_ss_spu_vm_rec);
23 memset(&_svm_sreg_buf, 0, sizeof(_svm_sreg_buf));
24 memset(&_svm_sreg_buf2, 0, sizeof(_svm_sreg_buf2));
25 memset(&_svm_sreg_dirty, 0, sizeof(_svm_sreg_dirty));
26 _svm_vab_count = 0;
27 memset(&_svm_vab_used, 0, sizeof(_svm_vab_used));
28 if ( ((char)voice_count & 0xFFFFu) < 0x18 )
29 _SsVmMaxVoice = (char)voice_count;
30 else
31 _SsVmMaxVoice = 24;
32 voice_attr.mask =
33 SPU_VOICE_VOLL | SPU_VOICE_VOLR | SPU_VOICE_PITCH | SPU_VOICE_WDSA | SPU_VOICE_ADSR_ADSR1 | SPU_VOICE_ADSR_ADSR2;
34 voice_attr.pitch = 0x1000;
35 voice_attr.addr = 0x5000;
36 voice_attr.adsr1 = 0x80FF;
37 voice_attr.volume.left = 0;
38 voice_attr.volume.right = 0;
39 voice_attr.adsr2 = 0x4000;
40 for ( v8 = 0; v8 < _SsVmMaxVoice; v8 += 1 )
41 {
42 libsnd2_spu_voice_t *voice_struct;
43
44 voice_struct = &_svm_voice[v8];
45 voice_struct->m_unk02 = 24;
46 voice_struct->m_vag_idx = 255;
47 voice_struct->m_unk1d = 0;
48 voice_struct->m_pitch = 0;
49 voice_struct->m_key_stat = 0;
50 voice_struct->m_seq_sep_no = -1;
51 voice_struct->m_fake_program = 0;
52 voice_struct->m_prog = 0;
53 voice_struct->m_tone = 255;
54 voice_struct->m_voll1 = 0;
55 voice_struct->m_channel_idx = 0;
56 voice_struct->m_pan = 64;
57 voice_struct->m_voll2 = 0;
58 voice_struct->m_b_auto_vol = 0;
59 voice_struct->m_auto_vol_amount = 0;
60 voice_struct->m_auto_vol_dt1 = 0;
61 voice_struct->m_auto_vol_dt2 = 0;
62 voice_struct->m_b_auto_pan = 0;
63 voice_struct->m_auto_pan_amount = 0;
64 voice_struct->m_auto_pan_dt1 = 0;
65 voice_struct->m_auto_pan_dt2 = 0;
66 voice_struct->m_auto_pan_start = 0;
67 voice_struct->m_auto_vol_start = 0;
68 voice_attr.voice = 1 << v8;
69 SpuSetVoiceAttr(&voice_attr);
70 _svm_cur.m_voice_idx = v8;
71 _SsVmKeyOffNow();
72 }
73 _svm_rattr.mask = 0;
74 _svm_rattr.depth.left = 0x3FFF;
75 _svm_rattr.depth.right = 0x3FFF;
76 _svm_rattr.mode = 0;
77 _svm_okon1 = 0;
78 _svm_okon2 = 0;
79 _svm_okof1 = 0;
80 _svm_orev1 = 0;
81 _svm_orev2 = 0;
82 _svm_onos1 = 0;
83 _svm_onos2 = 0;
84 _svm_auto_kof_mode = 0;
85 _svm_stereo_mono = 0;
86 _svm_vab_not_send_size = 0;
87 kMaxPrograms = 128;
88 _SsVmFlush();
89}