comparison Plugins/Input/adplug/core/psi.cpp @ 428:15ca2ea93a30 trunk

[svn] Sync with upstream CVS. This implements RIX playback.
author chainsaw
date Sat, 14 Jan 2006 07:27:13 -0800
parents 8df427a314a8
children f12d7e208b43
comparison
equal deleted inserted replaced
427:f61e69a1a376 428:15ca2ea93a30
67 { 67 {
68 opl_write(0x01, 0x20); 68 opl_write(0x01, 0x20);
69 opl_write(0x08, 0x00); 69 opl_write(0x08, 0x00);
70 opl_write(0xBD, 0x00); 70 opl_write(0xBD, 0x00);
71 71
72 // get header
73 header.instr_ptr = (tune[1] << 8) + tune[0];
74 header.seq_ptr = (tune[3] << 8) + tune[2];
75
72 // define instruments 76 // define instruments
73 psi.instr_table = (unsigned short *)&tune[((psi_header *)&tune[0])->instr_ptr]; 77 psi.instr_table = &tune[header.instr_ptr];
74 78
75 for(int i=0; i<8; i++) 79 for(int i=0; i<8; i++)
76 { 80 {
77 for(int j=0; j<11; j++) 81 for(int j=0; j<11; j++) {
78 opl_write(psi_adlib_registers[i*11 + j],tune[psi.instr_table[i] + j]); 82 unsigned short inspos = (psi.instr_table[i * 2 + 1] << 8) + psi.instr_table[i * 2];
83
84 opl_write(psi_adlib_registers[i*11 + j],tune[inspos + j]);
85 }
79 86
80 opl_write(0xA0+i, 0x00); 87 opl_write(0xA0+i, 0x00);
81 opl_write(0xB0+i, 0x00); 88 opl_write(0xB0+i, 0x00);
82 89
83 psi.note_delay[i] = 1; 90 psi.note_delay[i] = 1;
84 psi.note_curdelay[i] = 1; 91 psi.note_curdelay[i] = 1;
85 psi.looping[i] = 0; 92 psi.looping[i] = 0;
86 } 93 }
87 94
88 // calculate sequence pointer 95 // calculate sequence pointer
89 psi.seq_table = (unsigned short *)&tune[((psi_header *)&tune[0])->seq_ptr]; 96 psi.seq_table = &tune[header.seq_ptr];
90 } 97 }
91 98
92 void CxadpsiPlayer::xadplayer_update() 99 void CxadpsiPlayer::xadplayer_update()
93 { 100 {
94 unsigned short ptr; 101 unsigned short ptr;
95 102
96 for(int i=0; i<8; i++) 103 for(int i=0; i<8; i++)
97 { 104 {
98 ptr = psi.seq_table[i<<1]; 105 ptr = (psi.seq_table[(i<<1) * 2 + 1] << 8) + psi.seq_table[(i<<1) * 2];
99 106
100 psi.note_curdelay[i]--; 107 psi.note_curdelay[i]--;
101 108
102 if (!psi.note_curdelay[i]) 109 if (!psi.note_curdelay[i])
103 { 110 {
110 #endif 117 #endif
111 118
112 // end of sequence ? 119 // end of sequence ?
113 if (!event) 120 if (!event)
114 { 121 {
115 ptr = psi.seq_table[(i<<1) + 1]; 122 ptr = (psi.seq_table[(i<<1) * 2 + 3] << 8) + psi.seq_table[(i<<1) * 2 + 2];
116 123
117 event = tune[ptr++]; 124 event = tune[ptr++];
118 #ifdef DEBUG 125 #ifdef DEBUG
119 AdPlug_LogWrite(" channel %02X, event %02X:\n",i+1,event); 126 AdPlug_LogWrite(" channel %02X, event %02X:\n",i+1,event);
120 #endif 127 #endif
146 153
147 opl_write(0xA0+i, note & 0xFF); 154 opl_write(0xA0+i, note & 0xFF);
148 opl_write(0xB0+i, (note >> 8) + ((event >> 2) & 0xFC)); 155 opl_write(0xB0+i, (note >> 8) + ((event >> 2) & 0xFC));
149 156
150 // save position 157 // save position
151 psi.seq_table[i<<1] = ptr; 158 psi.seq_table[(i<<1) * 2] = ptr & 0xff;
159 psi.seq_table[(i<<1) * 2 + 1] = ptr >> 8;
152 } 160 }
153 } 161 }
154 } 162 }
155 163
156 float CxadpsiPlayer::xadplayer_getrefresh() 164 float CxadpsiPlayer::xadplayer_getrefresh()