1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// SHOW_SOUNDS.CPP
//
// Show Sounds Display.
//=====================================================================================//
#include "vxconsole.h"
#define ID_SHOWSOUNDS_LISTVIEW 100
// column id
#define ID_SS_NAME 0
#define ID_SS_PREFIX 1
#define ID_SS_FORMAT 2
#define ID_SS_RATE 3
#define ID_SS_BITS 4
#define ID_SS_CHANNELS 5
#define ID_SS_SIZE 6
#define ID_SS_STREAMED 7
#define ID_SS_LOOPED 8
#define ID_SS_LENGTH 9
typedef struct
{
int listIndex;
char *pName;
char *pPrefix;
char *pFormat;
int rate;
char rateBuff[16];
int bits;
char bitsBuff[16];
int channels;
char channelsBuff[16];
int numSamples;
int dataSize;
char dataSizeBuff[16];
int streamed;
char streamedBuff[16];
int looped;
char loopedBuff[16];
float length;
char lengthBuff[16];
} sound_t;
typedef struct
{ const CHAR* name;
int width;
int subItemIndex;
CHAR nameBuff[32];
} label_t;
HWND g_showSounds_hWnd;
HWND g_showSounds_hWndListView;
RECT g_showSounds_windowRect;
int g_showSounds_sortColumn;
int g_showSounds_sortDescending;
sound_t *g_showSounds_pSounds;
int g_showSounds_numSounds;
int g_showSounds_currentFrame;
label_t g_showSounds_Labels[] =
{
{"Name", 300, ID_SS_NAME},
{"Prefix", 80, ID_SS_PREFIX},
{"Format", 80, ID_SS_FORMAT},
{"Rate", 80, ID_SS_RATE},
{"Bits", 80, ID_SS_BITS},
{"Channels", 80, ID_SS_CHANNELS},
{"Size", 80, ID_SS_SIZE},
{"Streamed", 80, ID_SS_STREAMED},
{"Looped", 80, ID_SS_LOOPED},
{"Length", 80, ID_SS_LENGTH},
};
//-----------------------------------------------------------------------------
// ShowSounds_SaveConfig
//
//-----------------------------------------------------------------------------
void ShowSounds_SaveConfig()
{
char buff[256];
Sys_SetRegistryInteger( "showSoundsSortColumn", g_showSounds_sortColumn );
Sys_SetRegistryInteger( "showSoundsSortDescending", g_showSounds_sortDescending );
WINDOWPLACEMENT wp;
memset( &wp, 0, sizeof( wp ) );
wp.length = sizeof( WINDOWPLACEMENT );
GetWindowPlacement( g_showSounds_hWnd, &wp );
g_showSounds_windowRect = wp.rcNormalPosition;
sprintf( buff, "%d %d %d %d", g_showSounds_windowRect.left, g_showSounds_windowRect.top, g_showSounds_windowRect.right, g_showSounds_windowRect.bottom );
Sys_SetRegistryString( "showSoundsWindowRect", buff );
}
//-----------------------------------------------------------------------------
// ShowSounds_LoadConfig
//
//-----------------------------------------------------------------------------
void ShowSounds_LoadConfig()
{
int numArgs;
char buff[256];
Sys_GetRegistryInteger( "showSoundsSortColumn", ID_SS_NAME, g_showSounds_sortColumn );
Sys_GetRegistryInteger( "showSoundsSortDescending", false, g_showSounds_sortDescending );
Sys_GetRegistryString( "showSoundsWindowRect", buff, "", sizeof( buff ) );
numArgs = sscanf( buff, "%d %d %d %d", &g_showSounds_windowRect.left, &g_showSounds_windowRect.top, &g_showSounds_windowRect.right, &g_showSounds_windowRect.bottom );
if ( numArgs != 4 || g_showSounds_windowRect.left < 0 || g_showSounds_windowRect.top < 0 || g_showSounds_windowRect.right < 0 || g_showSounds_windowRect.bottom < 0 )
memset( &g_showSounds_windowRect, 0, sizeof( g_showSounds_windowRect ) );
}
//-----------------------------------------------------------------------------
// ShowSounds_Clear
//
//-----------------------------------------------------------------------------
void ShowSounds_Clear()
{
// delete all the list view entries
if ( g_showSounds_hWnd )
ListView_DeleteAllItems( g_showSounds_hWndListView );
if ( !g_showSounds_pSounds )
return;
for ( int i=0; i<g_showSounds_numSounds; i++ )
{
free( g_showSounds_pSounds[i].pName );
free( g_showSounds_pSounds[i].pPrefix );
free( g_showSounds_pSounds[i].pFormat );
}
g_showSounds_pSounds = NULL;
g_showSounds_numSounds = 0;
}
//-----------------------------------------------------------------------------
// ShowSounds_Export
//
//-----------------------------------------------------------------------------
void ShowSounds_Export()
{
}
//-----------------------------------------------------------------------------
// ShowSounds_Summary
//
//-----------------------------------------------------------------------------
void ShowSounds_Summary()
{
char buff[1024];
// tally the totals
int totalStreamed = 0;
int totalStatic = 0;
for ( int i=0; i<g_showSounds_numSounds; i++ )
{
if ( g_showSounds_pSounds[i].streamed )
{
totalStreamed += g_showSounds_pSounds[i].dataSize;
}
else
{
totalStatic += g_showSounds_pSounds[i].dataSize;
}
}
sprintf(
buff,
"Entries:\t\t\t%d\n"
"Static Memory:\t\t%.2f MB\n"
"Streamed Memory:\t\t%.2f MB\n",
g_showSounds_numSounds,
( float )totalStatic/( 1024.0F*1024.0F ),
( float )totalStreamed/( 1024.0F*1024.0F ) );
MessageBox( g_showSounds_hWnd, buff, "Sound Summary", MB_OK|MB_APPLMODAL );
}
//-----------------------------------------------------------------------------
// ShowSounds_Play
//
//-----------------------------------------------------------------------------
void ShowSounds_Play()
{
char command[256];
sound_t* pSound;
int selection;
LVITEM lvitem;
if ( !g_connectedToApp )
return;
selection = ListView_GetSelectionMark( g_showSounds_hWndListView );
if ( selection == -1 )
return;
memset( &lvitem, 0, sizeof( lvitem ) );
lvitem.mask = LVIF_PARAM;
lvitem.iItem = selection;
ListView_GetItem( g_showSounds_hWndListView, &lvitem );
pSound = ( sound_t* )lvitem.lParam;
sprintf( command, "play %s%s", pSound->pPrefix, pSound->pName );
// send the command to application
ProcessCommand( command );
}
//-----------------------------------------------------------------------------
// ShowSounds_CompareFunc
//
//-----------------------------------------------------------------------------
int CALLBACK ShowSounds_CompareFunc( LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort )
{
sound_t* pSoundA = ( sound_t* )lParam1;
sound_t* pSoundB = ( sound_t* )lParam2;
int sort = 0;
switch ( g_showSounds_sortColumn )
{
case ID_SS_NAME:
sort = stricmp( pSoundA->pName, pSoundB->pName );
break;
case ID_SS_PREFIX:
sort = stricmp( pSoundA->pPrefix, pSoundB->pPrefix );
break;
case ID_SS_FORMAT:
sort = stricmp( pSoundA->pFormat, pSoundB->pFormat );
break;
case ID_SS_RATE:
sort = pSoundA->rate - pSoundB->rate;
break;
case ID_SS_BITS:
sort = pSoundA->bits - pSoundB->bits;
break;
case ID_SS_CHANNELS:
sort = stricmp( pSoundA->channelsBuff, pSoundB->channelsBuff );
break;
case ID_SS_SIZE:
sort = pSoundA->dataSize - pSoundB->dataSize;
break;
case ID_SS_STREAMED:
sort = stricmp( pSoundA->streamedBuff, pSoundB->streamedBuff );
break;
case ID_SS_LOOPED:
sort = stricmp( pSoundA->loopedBuff, pSoundB->loopedBuff );
break;
case ID_SS_LENGTH:
if ( pSoundA->length < pSoundB->length )
sort = -1;
else if ( pSoundA->length == pSoundB->length )
sort = 0;
else
sort = 1;
break;
}
// flip the sort order
if ( g_showSounds_sortDescending )
sort *= -1;
return ( sort );
}
//-----------------------------------------------------------------------------
// ShowSounds_SortItems
//
//-----------------------------------------------------------------------------
void ShowSounds_SortItems()
{
LVITEM lvitem;
sound_t *pSound;
int i;
if ( !g_showSounds_hWnd )
{
// only sort if window is visible
return;
}
ListView_SortItems( g_showSounds_hWndListView, ShowSounds_CompareFunc, 0 );
memset( &lvitem, 0, sizeof( lvitem ) );
lvitem.mask = LVIF_PARAM;
// get each item and reset its list index
int itemCount = ListView_GetItemCount( g_showSounds_hWndListView );
for ( i=0; i<itemCount; i++ )
{
lvitem.iItem = i;
ListView_GetItem( g_showSounds_hWndListView, &lvitem );
pSound = ( sound_t* )lvitem.lParam;
pSound->listIndex = i;
}
// update list view columns with sort key
for ( i=0; i<sizeof( g_showSounds_Labels )/sizeof( g_showSounds_Labels[0] ); i++ )
{
char symbol;
LVCOLUMN lvc;
if ( i == g_showSounds_sortColumn )
symbol = g_showSounds_sortDescending ? '<' : '>';
else
symbol = ' ';
sprintf( g_showSounds_Labels[i].nameBuff, "%s %c", g_showSounds_Labels[i].name, symbol );
memset( &lvc, 0, sizeof( lvc ) );
lvc.mask = LVCF_TEXT;
lvc.pszText = ( LPSTR )g_showSounds_Labels[i].nameBuff;
ListView_SetColumn( g_showSounds_hWndListView, i, &lvc );
}
}
//-----------------------------------------------------------------------------
// ShowSounds_AddViewItem
//
//-----------------------------------------------------------------------------
void ShowSounds_AddViewItem( sound_t* pSound )
{
LVITEM lvi;
if ( !g_showSounds_hWnd )
{
// only valid if log window is visible
return;
}
// update the text callback buffers
if ( pSound->rate >= 0 )
sprintf( pSound->rateBuff, "%5.2f KHz", ( float )pSound->rate/1000.0f );
else
strcpy( pSound->rateBuff, "???" );
if ( pSound->bits >= 0 )
sprintf( pSound->bitsBuff, "%d", pSound->bits );
else
strcpy( pSound->bitsBuff, "???" );
if ( pSound->channels >= 1 )
strcpy( pSound->channelsBuff, pSound->channels == 2 ? "Stereo" : "Mono" );
else
strcpy( pSound->channelsBuff, "???" );
if ( pSound->dataSize >= 0 )
sprintf( pSound->dataSizeBuff, "%d", pSound->dataSize );
else
strcpy( pSound->dataSizeBuff, "???" );
if ( pSound->streamed >= 0 )
strcpy( pSound->streamedBuff, pSound->streamed ? "Stream" : "Static" );
else
strcpy( pSound->streamedBuff, "???" );
if ( pSound->looped >= 0 )
strcpy( pSound->loopedBuff, pSound->looped ? "Looped" : "One-Shot" );
else
strcpy( pSound->loopedBuff, "???" );
sprintf( pSound->lengthBuff, "%2.2d:%2.2d:%3.3d", ( int )pSound->length/60, ( int )pSound->length%60, ( int )( 1000*( pSound->length-( int )pSound->length ) )%1000 );
int itemCount = ListView_GetItemCount( g_showSounds_hWndListView );
// setup and insert at end of list
memset( &lvi, 0, sizeof( lvi ) );
lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE;
lvi.iItem = itemCount;
lvi.iSubItem = 0;
lvi.state = 0;
lvi.stateMask = 0;
lvi.pszText = LPSTR_TEXTCALLBACK;
lvi.lParam = ( LPARAM )pSound;
// insert and set the real index
pSound->listIndex = ListView_InsertItem( g_showSounds_hWndListView, &lvi );
}
//-----------------------------------------------------------------------------
// ShowSounds_Refresh
//
//-----------------------------------------------------------------------------
void ShowSounds_Refresh()
{
char command[256];
strcpy( command, "vx_soundlist" );
// send the command to application which replies with list data
if ( g_connectedToApp )
ProcessCommand( command );
}
//-----------------------------------------------------------------------------
// ShowSounds_SizeWindow
//
//-----------------------------------------------------------------------------
void ShowSounds_SizeWindow( HWND hwnd, int cx, int cy )
{
if ( cx==0 || cy==0 )
{
RECT rcClient;
GetClientRect( hwnd, &rcClient );
cx = rcClient.right;
cy = rcClient.bottom;
}
// position the ListView
SetWindowPos( g_showSounds_hWndListView, NULL, 0, 0, cx, cy, SWP_NOZORDER );
}
//-----------------------------------------------------------------------------
// ShowSounds_WndProc
//
//-----------------------------------------------------------------------------
LRESULT CALLBACK ShowSounds_WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
WORD wID = LOWORD( wParam );
sound_t* pSound;
switch ( message )
{
case WM_CREATE:
return 0L;
case WM_DESTROY:
ShowSounds_SaveConfig();
g_showSounds_hWnd = NULL;
return 0L;
case WM_INITMENU:
return 0L;
case WM_SIZE:
ShowSounds_SizeWindow( hwnd, LOWORD( lParam ), HIWORD( lParam ) );
return 0L;
case WM_NOTIFY:
switch ( ( ( LPNMHDR )lParam )->code )
{
case LVN_COLUMNCLICK:
NMLISTVIEW* pnmlv;
pnmlv = ( NMLISTVIEW* )lParam;
if ( g_showSounds_sortColumn == pnmlv->iSubItem )
{
// user has clicked on same column - flip the sort
g_showSounds_sortDescending ^= 1;
}
else
{
// sort by new column
g_showSounds_sortColumn = pnmlv->iSubItem;
}
ShowSounds_SortItems();
return 0L;
case LVN_GETDISPINFO:
NMLVDISPINFO* plvdi;
plvdi = ( NMLVDISPINFO* )lParam;
pSound = ( sound_t* )plvdi->item.lParam;
switch ( plvdi->item.iSubItem )
{
case ID_SS_NAME:
plvdi->item.pszText = pSound->pName;
return 0L;
case ID_SS_PREFIX:
plvdi->item.pszText = pSound->pPrefix;
return 0L;
case ID_SS_FORMAT:
plvdi->item.pszText = pSound->pFormat;
return 0L;
case ID_SS_RATE:
plvdi->item.pszText = pSound->rateBuff;
return 0L;
case ID_SS_BITS:
plvdi->item.pszText = pSound->bitsBuff;
return 0L;
case ID_SS_CHANNELS:
plvdi->item.pszText = pSound->channelsBuff;
return 0L;
case ID_SS_SIZE:
plvdi->item.pszText = pSound->dataSizeBuff;
return 0L;
case ID_SS_STREAMED:
plvdi->item.pszText = pSound->streamedBuff;
return 0L;
case ID_SS_LOOPED:
plvdi->item.pszText = pSound->loopedBuff;
return 0L;
case ID_SS_LENGTH:
plvdi->item.pszText = pSound->lengthBuff;
return 0L;
default:
break;
}
break;
}
break;
case WM_COMMAND:
switch ( wID )
{
case IDM_OPTIONS_SUMMARY:
ShowSounds_Summary();
return 0L;
case IDM_OPTIONS_REFRESH:
ShowSounds_Refresh();
return 0L;
case IDM_OPTIONS_EXPORT:
ShowSounds_Export();
return 0L;
case IDM_OPTIONS_PLAYSOUND:
ShowSounds_Play();
return 0L;
}
break;
}
return ( DefWindowProc( hwnd, message, wParam, lParam ) );
}
//-----------------------------------------------------------------------------
// ShowSounds_Init
//
//-----------------------------------------------------------------------------
bool ShowSounds_Init()
{
// set up our window class
WNDCLASS wndclass;
memset( &wndclass, 0, sizeof( wndclass ) );
wndclass.style = 0;
wndclass.lpfnWndProc = ShowSounds_WndProc;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = g_hInstance;
wndclass.hIcon = g_hIcons[ICON_APPLICATION];
wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
wndclass.hbrBackground = g_hBackgroundBrush;
wndclass.lpszMenuName = MAKEINTRESOURCE( MENU_SHOWSOUNDS );
wndclass.lpszClassName = "SHOWSOUNDSCLASS";
if ( !RegisterClass( &wndclass ) )
return false;
ShowSounds_LoadConfig();
return true;
}
//-----------------------------------------------------------------------------
// ShowSounds_Open
//
//-----------------------------------------------------------------------------
void ShowSounds_Open()
{
RECT clientRect;
HWND hWnd;
int i;
if ( g_showSounds_hWnd )
{
// only one instance
if ( IsIconic( g_showSounds_hWnd ) )
ShowWindow( g_showSounds_hWnd, SW_RESTORE );
SetForegroundWindow( g_showSounds_hWnd );
return;
}
hWnd = CreateWindowEx(
WS_EX_CLIENTEDGE,
"SHOWSOUNDSCLASS",
"Sounds",
WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_SIZEBOX|WS_MINIMIZEBOX|WS_MAXIMIZEBOX,
0,
0,
700,
400,
g_hDlgMain,
NULL,
g_hInstance,
NULL );
g_showSounds_hWnd = hWnd;
GetClientRect( g_showSounds_hWnd, &clientRect );
hWnd = CreateWindow(
WC_LISTVIEW,
"",
WS_VISIBLE|WS_CHILD|LVS_REPORT|LVS_SHOWSELALWAYS|LVS_SINGLESEL,
0,
0,
clientRect.right-clientRect.left,
clientRect.bottom-clientRect.top,
g_showSounds_hWnd,
( HMENU )ID_SHOWSOUNDS_LISTVIEW,
g_hInstance,
NULL );
g_showSounds_hWndListView = hWnd;
// init list view columns
for ( i=0; i<sizeof( g_showSounds_Labels )/sizeof( g_showSounds_Labels[0] ); i++ )
{
LVCOLUMN lvc;
memset( &lvc, 0, sizeof( lvc ) );
lvc.mask = LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
lvc.iSubItem = 0;
lvc.cx = g_showSounds_Labels[i].width;
lvc.fmt = LVCFMT_LEFT;
lvc.pszText = ( LPSTR )g_showSounds_Labels[i].name;
ListView_InsertColumn( g_showSounds_hWndListView, i, &lvc );
}
ListView_SetBkColor( g_showSounds_hWndListView, g_backgroundColor );
ListView_SetTextBkColor( g_showSounds_hWndListView, g_backgroundColor );
DWORD style = LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES|LVS_EX_HEADERDRAGDROP;
ListView_SetExtendedListViewStyleEx( g_showSounds_hWndListView, style, style );
// populate list view
for ( i=0; i<g_showSounds_numSounds; i++ )
ShowSounds_AddViewItem( &g_showSounds_pSounds[i] );
ShowSounds_SortItems();
if ( g_showSounds_windowRect.right && g_showSounds_windowRect.bottom )
MoveWindow( g_showSounds_hWnd, g_showSounds_windowRect.left, g_showSounds_windowRect.top, g_showSounds_windowRect.right-g_showSounds_windowRect.left, g_showSounds_windowRect.bottom-g_showSounds_windowRect.top, FALSE );
ShowWindow( g_showSounds_hWnd, SHOW_OPENWINDOW );
// get data from application
ShowSounds_Refresh();
}
//-----------------------------------------------------------------------------
// rc_SoundList
//
// Sent from application with sound list
//-----------------------------------------------------------------------------
int rc_SoundList( char* commandPtr )
{
char* cmdToken;
int numSounds;
int soundList;
int retAddr;
int retVal;
int errCode = -1;
xrSound_t* pLocalList;
int prefixLen;
char *pStr;
// remove old entries
ShowSounds_Clear();
// get number of sounds
cmdToken = GetToken( &commandPtr );
if ( !cmdToken[0] )
goto cleanUp;
sscanf( cmdToken, "%x", &numSounds );
// get sound list
cmdToken = GetToken( &commandPtr );
if ( !cmdToken[0] )
goto cleanUp;
sscanf( cmdToken, "%x", &soundList );
// get retAddr
cmdToken = GetToken( &commandPtr );
if ( !cmdToken[0] )
goto cleanUp;
sscanf( cmdToken, "%x", &retAddr );
pLocalList = new xrSound_t[numSounds];
memset( pLocalList, 0, numSounds*sizeof( xrSound_t ) );
g_showSounds_numSounds = numSounds;
g_showSounds_pSounds = new sound_t[numSounds];
memset( g_showSounds_pSounds, 0, numSounds*sizeof( sound_t ) );
// get the caller's command list
DmGetMemory( ( void* )soundList, numSounds*sizeof( xrSound_t ), pLocalList, NULL );
// build out the resident list
for ( int i=0; i<numSounds; i++ )
{
// swap the structure
pLocalList[i].rate = BigDWord( pLocalList[i].rate );
pLocalList[i].bits = BigDWord( pLocalList[i].bits );
pLocalList[i].channels = BigDWord( pLocalList[i].channels );
pLocalList[i].looped = BigDWord( pLocalList[i].looped );
pLocalList[i].dataSize = BigDWord( pLocalList[i].dataSize );
pLocalList[i].numSamples = BigDWord( pLocalList[i].numSamples );
pLocalList[i].streamed = BigDWord( pLocalList[i].streamed );
// strip the prefix
pStr = pLocalList[i].nameString;
while ( *pStr )
{
if ( __iscsym( *pStr ) )
{
// first non-preifx character
break;
}
pStr++;
}
g_showSounds_pSounds[i].pName = strdup( pStr );
char prefixString[256];
prefixLen = pStr - pLocalList[i].nameString;
memcpy( prefixString, pLocalList[i].nameString, prefixLen );
prefixString[prefixLen] = '\0';
g_showSounds_pSounds[i].pPrefix = strdup( prefixString );
// get the format name
g_showSounds_pSounds[i].pFormat = strdup( pLocalList[i].formatString );
g_showSounds_pSounds[i].rate = pLocalList[i].rate;
g_showSounds_pSounds[i].bits = pLocalList[i].bits;
g_showSounds_pSounds[i].channels = pLocalList[i].channels;
g_showSounds_pSounds[i].dataSize = pLocalList[i].dataSize;
g_showSounds_pSounds[i].numSamples = pLocalList[i].numSamples;
g_showSounds_pSounds[i].streamed = pLocalList[i].streamed;
g_showSounds_pSounds[i].looped = pLocalList[i].looped;
// determine duration
// must use sample count due to compression
if ( g_showSounds_pSounds[i].rate > 0 )
g_showSounds_pSounds[i].length = ( float )g_showSounds_pSounds[i].numSamples/( float )g_showSounds_pSounds[i].rate;
else
g_showSounds_pSounds[i].length = 0;
// add to list view
ShowSounds_AddViewItem( &g_showSounds_pSounds[i] );
}
// return the result
retVal = numSounds;
int xboxRetVal = BigDWord( retVal );
DmSetMemory( ( void* )retAddr, sizeof( int ), &xboxRetVal, NULL );
DebugCommand( "0x%8.8x = SoundList( 0x%8.8x, 0x%8.8x )\n", retVal, numSounds, soundList );
delete [] pLocalList;
// update
ShowSounds_SortItems();
// success
errCode = 0;
cleanUp:
return ( errCode );
}
|