-
Notifications
You must be signed in to change notification settings - Fork 1
/
API.TXT
698 lines (349 loc) · 15.6 KB
/
API.TXT
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
ÛÛ Û ÛÛÛÛÛ ÛÛÛ ÛÛ /---/ / /---/ \ /
ÛÛ Û ÛÛ ÛÛ Û Û /---/ / /---/ \-/
ÛÛ Û ßßßßÛ ÛÛ Û / /____ / / /
ßßßßßß ßßßßß ßß ß
Useless Module Player v1.1
Application Programming Interface
By FreddyV/Useless
This file contains a full description of the API for USS.ASM, USMPLAY.ASM,
File Loaders, TIMER.ASM, MEMORY.ASM HARDWARE.ASM and FILES.ASM
* WATCOM C/C++ users:
The interface file (usmplay.h) contains only the more important
functions. A list of the available functions is at the end of this file.
-------------------------------------------------------------------------------
File Loaders API (MODLOAD.ASM, XMLOAD.ASM...)
-------------------------------------------------------------------------------
There is only one function in each loader:
- xxx_Load
Description: Load a xxx file (xxx can be MOD, STM, S3M, XM ,IT or USM)
Input: ESI Offset to the file name string.
EAX Default panning setting. (20202020h for Mono)
EBX=LM_File Load module from a file.
EBX=LM_Memory Load module from memory.
Output: CF Clear -> USM Header pointer is in ESI
CF Set -> Error code in EAX
-------------------------------------------------------------------------------
Useless USM Play API (USMPLAY.ASM)
-------------------------------------------------------------------------------
Music synchro variables:
------------------------
- _SynchroCount DWORD
It's incremented each time a Wxx or a EFxx effect occur.
- _SynchroVal BYTE
_SynchroVal is set to the Wxx or EFx effect parameter.
- _MusicEnd BYTE
_MusicEnd is set to 1 when the music is finished.
Note: the music is looped.
- _Order WORD (0 to Orders in the music-1)
It contains the current position in the order table.
- _Pattern WORD (0 to Patterns in the music-1)
It contains the current pattern number.
- _Row WORD (1 to Rows in the current pattern)
It contains the current row number.
- _ChInstrument BYTE*MAX_PLCHANNELS
- _ChNote BYTE*MAX_PLCHANNELS
- _ChCommand BYTE*MAX_PLCHANNELS
Order change functions.
-----------------------
- USMP_PrevOrder
Description: Go to the previous music pattern.
Input: --
Output: --
Note:
* It can be removed if you set Use_USMP_PrevOrder to No in SETUP.INC
- USMP_NextOrder
Description: Go to the next music pattern.
Input: --
Output: --
Note:
* It can be removed if you set Use_USMP_NextOrder to No in SETUP.INC
- USMP_SetOrder
Description: Set the current order number.
Input: AX New Order number. (0 to Orders in music-1)
Output: --
Note:
* It can be removed if you set Use_USMP_SetOrder to No in SETUP.INC
- USMP_SetPosition
Description: Set the current order and row number.
Input: AX New Order number. (0 to Orders in music-1)
BX New row. (0 to Rows in the current pattern-1)
Output: --
Note:
* It can be removed if you set Use_USMP_SetOrder to No in SETUP.INC
Music Load/Free functions.
--------------------------
- USMP_LoadInternalModule
Description: Load an "internal" USM file.
Input: ESI Pointer to the USM file in memory.
Output: --
Note:
* The file can be included in the EXE or loaded dirrectly.
- USMP_FreeInternalModule
Description: Free an USM module loaded with LoadInternalModule.
Input: ESI Pointer to an USM Header.
Output: CF Clear -> Ok
CF Set -> Error code in EAX.
Note:
* It can be removed if you set UseFreeInternalModule to No in SETUP.INC
- USMP_FreeModule
Description: Free the USM module from memory.
Input: ESI Pointer to an USM Header.
Output: CF Clear -> Ok
CF Set -> Error code in EAX.
Note:
* You can't use this function after a call to LoadInternalModule.
* It can be removed if you set UseFreeModule to No in SETUP.INC
Music Start/Stop functions.
---------------------------
- USMP_StartPlay
Description: Start the music replay.
Input: ESI Pointer to an USM Header.
Output: CF Clear -> Ok
CF Set -> Error code in EAX.
- USMP_StopPlay
Description: Stop the music replay.
Input: --
Output: --
-------------------------------------------------------------------------------
Useless Sound System API (USS.ASM)
-------------------------------------------------------------------------------
USS.ASM does the complete samples and Instruments managing.
This API will change in a near future, I don't guarantee for this API
compatibility with the other player version.
I will add a complete API for playing sound effects (not before v1.05).
Sound system Setup/Initialisation.
----------------------------------
- USS_Setup
Description: Display the setup menu and let the user to choose the sound
output.
Input: --
Output: CF Clear -> Ok
CF Set -> The choosen device is incorrect or Escape key pressed.
Note:
* It can be removed if you set UseSetup to No in SETUP.INC
(Setup code is big and Setup function need memory function)
- USS_SetAmpli
Description: Define the amplification value for the mixed devices.
Input: EAX Amplification value (0-65535)
Output: --
- USS_AutoSetup
Description: It does an automatic sound device detection.
Input: --
Output: --
Note:
* The detected device is the best available device.
( GUS first, then SB16 ...)
* It can be removed if you set UseAutoSetup to No in SETUP.INC
- USS_Init
Description : Sound System initialisation.
Input: --
Output: --
Note: This function is called by USMP_StartPlay
- USS_SetActiveChannels
Description: Set the number of active sound system channels
Input: Number of channels to use.
Output: --
Sound Stop/Start functions.
---------------------------
- USS_StartOutput
Description: Start the Sound System sound output.
Input: ESI Pointer to the periodic function called by the sound driver.
Output: CF Clear -> Ok
CF Set -> Error code in EAX
Note:
* The periodic function can be called by the computer timer or a
sound card IRQ.
When the function is called, eax contains the number of periode
( one period is 1/1193180 second) elapsed since the previouscall.
* The number of active channels MUST be set before with the
USS_SetActiveChannels function.
- USS_StopOutput
Description: Stop the Sound System sound output.
Input: --
Output: CF Clear -> Ok
CF Set -> Error in EAX
- USS_UpdateOutput
- USS_UpdateInstr
Samples Load and Free functions.
--------------------------------
- USS_LoadSample
- USS_FreeSample
Global or channels sound functions.
-----------------------------------
- USS_GetGlobalVolume
- USS_SetGlobalVolume
- USS_GetChannelVolume
- USS_SetChannelVolume
- USS_StartInstrument
- USS_InitInstrEnv
- USS_SetEnvPos
- USS_GetSampleVolume
- USS_GetSamplePanning
- USS_SetSampleOffset
- USS_SetNote
- USS_GetPeriod
- USS_SetPeriod
- USS_GetNotePeriod
- USS_GetVolume
- USS_SetVolume
- USS_GetPanning
- USS_SetPanning
- USS_NoteCut
- USS_NoteFade
- USS_KeyOff
-------------------------------------------------------------------------------
Memory manager API (MEMORY.ASM)
-------------------------------------------------------------------------------
- _Maxavail
Description: Return the length of the biggest available memory block.
Input: --
Output: EAX Length of the biggest available memory block.
Note:
* This function is not available if you are using WATCOM C/C++
- _Malloc
Description: Allocate a memory block.
Input: EAX Amount of needed Memory.
Output: CF Clear -> Memory block @ in EAX
CF Set -> Error code in EAX
- _Calloc
Description: Allocate and clear a memory block.
Input: EAX Amount of needed Memory.
Output: CF Clear -> Memory block @ in EAX
CF Set -> Error code in EAX
- _Free Free a memory block.
Description: Free a memory block.
Input: EAX @ of the memory block to free.
Output: CF Clear -> Ok
CF Set -> Error code in EAX
-------------------------------------------------------------------------------
Timer manager API (TIMER.ASM)
-------------------------------------------------------------------------------
- Timer_Start
Description: Start a timer.
Input: EAX Timer Procedure Offset
EBX Timer Speed ( 1193180/EBX hz )
Output: CF clear -> Ok
CF set -> EAX=TE_NoFreeTimer (No more timer available)
Note:
* You can't start more than "max_timers" timers (defined in SETUP.INC)
- Timer_Stop
Description: Stop a timer.
Input: EAX Timer Proc to stop.
Output: CF clear -> Ok
CF set -> EAX=TE_NotFound (It's not a correct proc offset)
-------------------------------------------------------------------------------
'Hardware' functions API (HARDWARE.ASM)
-------------------------------------------------------------------------------
HARDWARE.ASM and HARDWARE.INC included all the IRQ/DMA functions.
They are also used to initialise the pointers to the more usefull
informations in memory. (PSP, Environment variables and 'Zero' Offset)
- Public variable:
ZeroOffset, PSPOffset and EnvOffset
Note:
* They are initialised by the 'HardwareInit' Function
- HardwareInit
Description: It does all the public variable initialisation and
the DMA buffer allocation.
Input: --
Output: --
Note:
* This MUST be the first funtion call if you use USMPLAY.
- GetEnvOffset
Description: Returns the Environement variable Offset
Input: EAX, Offset of the variable name
Output: EDI, Variable offset if CF cleared
Example:
BlasterEnv DB 7,'BLASTER' ; 7 is the environment var size.
mov eax,Offset BlasterEnv
call GetEnvOffset
jc Error
- DMA_Setup
Description: Program a channel on the 8237 DMA controler.
Input: AL Mode Register ( bits 0..1 ignored )
AH channel ( 0..7 )
EBX Physical Base Address ( 0..0ffffffh )
ECX Bytes to transfer ( 1..10000h )
Output: --
Note:
* This function was done by Adam Seychell (DOS32 coder)
- IRQ_Enable
Description: Enable an Hardware IRQ
Input: DL, IRQ Number
Output: --
- IRQ_Disable
Description: Disable an Hardware IRQ
Input: DL, IRQ Number
Output: --
Macros defined in HARDWARE.INC:
- SetInt Macro Inter,Select,Offs
Description: Set a new interrupt function
- GetInt Macro Inter,_Ptr
Description: Get an interrupt function pointer
- RestInt Macro Inter,_Ptr
Description: Restore an interrupt function
- SetIRQ Macro IRQ,Select,Offs
Description: Set a new interrupt function
- GetIRQ Macro IRQ,_Ptr
Description: Get an interrupt function pointer
- RestIRQ Macro IRQ,_Ptr
Description: Restore an interrupt function
-------------------------------------------------------------------------------
Available functions/variables for WATCOM C/C++ (in USMPLAY.H)
-------------------------------------------------------------------------------
Useless USM Play Functions/Variables (USMPLAY.ASM)
--------------------------------------------------
Synchro variables.
- unsigned int SynchroCount;
- unsigned char SynchroVal;
- unsigned char MusicEnd;
- unsigned short Order; (0 to Orders in the music-1)
- unsigned short Pattern; (0 to Patterns in the music-1)
- unsigned short Row; (1 to Rows in the current pattern)
- unsigned short ChInstrument[MAX_PLCHANNELS];
- unsigned short ChNote[MAX_PLCHANNELS];
- unsigned short ChCommand[MAX_PLCHANNELS];
Player functions.
- void USMP_LoadInternalModule(void *music);
- void USMP_FreeInternalModule(void *music);
- void USMP_FreeModule(void *music);
- void USMP_StartPlay(void *music);
- void USMP_StopPlay(void);
- void USMP_PrevOrder(void);
- void USMP_NextOrder(void);
- void USMP_SetOrder(unsigned int order);
- void USMP_SetPosition(unsigned int order, unsigned int row);
Useless Sound System functions (USS.ASM)
----------------------------------------
- void USS_Setup(void);
- void USS_AutoSetup(void);
- void USS_SetAmpli(int Ampli);
Some device information.
------------------------
- char *DEV_Name; Device Name
- unsigned short DEV_BasePort; Device Base Port
- unsigned char DEV_IRQ; Device Interrupt
- unsigned char DEV_DMA; Device DMA
Files loaders (STMLOAD.ASM, MODLOAD.ASM, XMLOAD.AXM ...)
--------------------------------------------------------
- void *MOD_Load(unsigned int loadmode, unsigned int panning, char *filename);
- void *STM_Load(unsigned int loadmode, unsigned int panning, char *filename);
- void *S3M_Load(unsigned int loadmode, unsigned int panning, char *filename);
- void *XM_Load(unsigned int loadmode, unsigned int panning, char *filename);
- void *IT_Load(unsigned int loadmode, unsigned int panning, char *filename);
- void *USM_Load(unsigned int loadmode, unsigned int panning, char *filename);
* loadmode can be LM_Memory or LM_File (Load from memory or load from a file)
Timer functions (TIMER.ASM)
---------------------------
- int Timer_Start(void *function,int speed);
- int Timer_Stop(void *function);
! When you use a timer in WATCOM C, remove the stack checking.
(Add the -s parametter in the compiler command line)
Error variable and function (ERROR.ASM)
---------------------------------------
- int Error_Number;
It contains the Error number. 0 for no error.
- void Display_Error(int Error_Number);
Call this to display the error name.
'Hardware' Init function (HARDWARE.ASM)
---------------------------------------
- void HardwareInit(unsigned long psp);