3 ; Id Sound Manager assembly stuff
\r
14 EXTRN SDL_DigitizedDone:FAR
\r
17 ;============================================================================
\r
22 EXTRN ssSample:DWORD
\r
23 EXTRN ssLengthLeft:WORD
\r
24 EXTRN ssControl:WORD
\r
31 EXTRN pcLengthLeft:WORD
\r
32 EXTRN pcLastSample:BYTE
\r
33 EXTRN pcSoundLookup:WORD
\r
37 EXTRN alLengthLeft:WORD
\r
38 EXTRN alTimeCount:DWORD
\r
41 EXTRN sqHackPtr:DWORD
\r
42 EXTRN sqHackLen:WORD
\r
43 EXTRN sqHackSeqLen:WORD
\r
44 EXTRN sqHackTime:DWORD
\r
46 EXTRN HackCount:WORD
\r
47 EXTRN TimeCount:WORD
\r
48 EXTRN LocalTime:WORD
\r
50 EXTRN TimerCount:WORD
\r
51 EXTRN TimerDivisor:WORD
\r
52 EXTRN t0OldService:DWORD
\r
54 EXTRN SoundMode:WORD
\r
57 EXTRN SoundNumber:WORD
\r
58 EXTRN SoundPriority:WORD
\r
63 pcdtab db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
64 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
65 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
66 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
67 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
68 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
69 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
70 db 00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b,00b
\r
71 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
72 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
73 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
74 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
75 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
76 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
77 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
78 db 10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b,10b
\r
81 ;============================================================================
\r
101 ; Macro used for common prefix code
\r
107 mov dx,STATUS_REGISTER_1
\r
110 mov al,ATR_OVERSCAN
\r
125 ; Macro used to do the sound effects code
\r
128 les di,[pcSound] ; PC sound effects
\r
131 jz @@nopc ; nil pointer - no PC sound effect going
\r
133 mov bl,[es:di] ; Get the byte
\r
134 inc [WORD PTR pcSound] ; Increment pointer
\r
135 cmp [pcLastSample],bl ; Is this sample the same as last?
\r
136 jz @@pcsame ; Yep - don't do anything
\r
137 mov [pcLastSample],bl ; No, save it for next time
\r
140 jz @@pcoff ; If 0, turn sounds off
\r
143 mov bx,[pcSoundLookup+bx] ; Use byte as index into frequency table
\r
145 mov al,0b6h ; Write to channel 2 (speaker) timer
\r
148 out pcTimer,al ; Low byte
\r
150 out pcTimer,al ; High byte
\r
152 in al,pcSpeaker ; Turn the speaker & gate on
\r
159 in al,pcSpeaker ; Turn the speaker & gate off
\r
164 dec [pcLengthLeft] ; Decrement length
\r
165 jnz @@nopc ; If not 0, we're not done with the sound
\r
168 mov [WORD PTR pcSound],ax ; Zero the pointer
\r
169 mov [WORD PTR pcSound + 2],ax
\r
170 mov [SoundNumber],ax ; Indicate no sound
\r
171 mov [SoundPriority],ax ; with no priority
\r
173 in al,pcSpeaker ; Turn the speaker off
\r
178 les di,[alSound] ; AdLib sound effects
\r
181 jz @@noal ; nil pointer - no AdLib effect going
\r
188 CALL alOut C,alFreqL,ax
\r
192 CALL alOut C,alFreqH,ax
\r
193 inc [WORD PTR alSound]
\r
198 mov [WORD PTR alSound],ax ; Zero the pointer
\r
199 mov [WORD PTR alSound + 2],ax
\r
200 mov [SoundNumber],ax ; Indicate no sound
\r
201 mov [SoundPriority],ax ; with no priority
\r
202 CALL alOut C,alFreqH,ax ; Turn off the sound
\r
214 adc [LocalTime+2],0
\r
216 adc [TimeCount+2],0
\r
223 ; Macro used for common suffix code
\r
239 mov ax,[TimerDivisor]
\r
240 add [TimerCount],ax
\r
244 call [t0OldService]
\r
256 mov dx,STATUS_REGISTER_1
\r
259 mov al,ATR_OVERSCAN
\r
263 mov al,20h ; normal
\r
275 PROC SDL_IndicatePC on:WORD
\r
276 PUBLIC SDL_IndicatePC
\r
279 mov [cs:pcindicate],ax
\r
285 ; SDL_t0ExtremeAsmService
\r
286 ; Timer 0 ISR 7000Hz interrupts
\r
288 PROC SDL_t0ExtremeAsmService
\r
289 PUBLIC SDL_t0ExtremeAsmService
\r
292 mov al,[BYTE PTR cs:pcindicate]
\r
317 jz @@donereg ; nil pointer
\r
319 mov bl,[es:di] ; Get the byte
\r
320 inc [WORD PTR pcSound] ; Increment pointer
\r
322 and bl,11100000b ; Nuke some of the precision (DEBUG - do this in the table)
\r
325 mov ah,[pcdtab+bx] ; Translate the byte
\r
335 mov [WORD PTR pcSound],0 ; We're done with this sample
\r
336 mov [WORD PTR pcSound+2],0
\r
342 call SDL_DigitizedDone
\r
359 cmp [cs:extreme],10
\r
371 ; jmp SDL_t0FastAsmService ; Drops through to SDL_t0FastAsmService
\r
376 ; SDL_t0FastAsmService
\r
377 ; Timer 0 ISR for 700Hz interrupts
\r
379 PROC SDL_t0FastAsmService
\r
380 PUBLIC SDL_t0FastAsmService
\r
384 inc [count_fx] ; Time to do PC/AdLib effects & time?
\r
388 mov ax,[sqActive] ; Is the sequencer active?
\r
392 mov ax,[WORD PTR ssSample] ; Is there a sample for the Sound Src?
\r
393 or ax,[WORD PTR ssSample+2]
\r
428 mov ax,[WORD PTR sqHackTime+2]
\r
429 cmp ax,[WORD PTR alTimeCount+2]
\r
431 mov ax,[WORD PTR sqHackTime]
\r
432 cmp ax,[WORD PTR alTimeCount]
\r
435 mov ax,[es:di+2] ; Get time to next event
\r
436 add ax,[WORD PTR alTimeCount]
\r
437 mov [WORD PTR sqHackTime],ax
\r
438 mov ax,[WORD PTR alTimeCount+2]
\r
440 mov [WORD PTR sqHackTime+2],ax
\r
442 mov ax,[es:di] ; Get register/value pair
\r
449 mov [WORD PTR sqHackPtr],di
\r
455 add [WORD PTR alTimeCount],1
\r
456 adc [WORD PTR alTimeCount+2],0
\r
461 mov ax,[WORD PTR sqHack] ; Copy pointer
\r
462 mov [WORD PTR sqHackPtr],ax
\r
463 mov ax,[WORD PTR sqHack+2]
\r
464 mov [WORD PTR sqHackPtr+2],ax
\r
466 mov ax,[sqHackSeqLen] ; Copy length
\r
470 mov [WORD PTR alTimeCount],ax ; Reset time counts
\r
471 mov [WORD PTR alTimeCount+2],ax
\r
472 mov [WORD PTR sqHackTime],ax
\r
473 mov [WORD PTR sqHackTime+2],ax
\r
476 les di,[ssSample] ; Get pointer to Sound Source sample
\r
479 jz @@ssdone ; If nil, skip this
\r
482 mov dx,[ssStatus] ; Check to see if FIFO has any empty slots
\r
485 jnz @@ssdone ; Nope - don't push any more data out
\r
488 mov al,[es:di] ; al = *ssSample
\r
489 out dx,al ; Pump the value out
\r
491 mov dx,[ssControl] ; Pulse printer select
\r
499 push ax ; Delay a short while
\r
503 mov [WORD PTR ssSample],di ; ssSample++
\r
508 mov [WORD PTR ssSample],0 ; We're done with this sample
\r
509 mov [WORD PTR ssSample+2],0
\r
511 call SDL_DigitizedDone
\r
519 ; SDL_t0SlowAsmService
\r
520 ; Timer 0 ISR for 140Hz interrupts
\r
522 PROC SDL_t0SlowAsmService
\r
523 PUBLIC SDL_t0SlowAsmService
\r
528 mov dx,STATUS_REGISTER_1
\r
531 mov al,ATR_OVERSCAN
\r
545 mov ax,[WORD PTR pcSound] ; Is there a PC sound effect going?
\r
546 or ax,[WORD PTR pcSound+2]
\r
549 mov ax,[WORD PTR alSound] ; Is there an AdLib sound effect going?
\r
550 or ax,[WORD PTR alSound+2]
\r