/
Sonic 2 Clone Driver v2 - Functions.asm
98 lines (91 loc) · 2.85 KB
/
Sonic 2 Clone Driver v2 - Functions.asm
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
; ---------------------------------------------------------------------------
; Load DAC driver (Mega PCM)
; ---------------------------------------------------------------------------
; SoundDriverLoad: JmpTo_SoundDriverLoad
SMPS_LoadDACDriver:
SMPS_stopZ80
SMPS_resetZ80
; load Mega PCM (Kosinski-compressed)
lea (MegaPCM).l,a0 ; source
lea (SMPS_z80_ram).l,a1 ; destination
bsr.w KosDec
moveq #0,d1
move.w d1,(SMPS_z80_reset).l
nop
nop
nop
nop
SMPS_resetZ80
move.w d1,(SMPS_z80_bus_request).l ; start the Z80
rts
; End of function SMPS_LoadDACDriver
; ---------------------------------------------------------------------------
; Queue sound for play (queue 1)
; ---------------------------------------------------------------------------
; sub_135E: PlayMusic:
SMPS_QueueSound1:
tst.b (Clone_Driver_RAM+SMPS_RAM.variables.v_playsnd1).w
bne.s +
move.b d0,(Clone_Driver_RAM+SMPS_RAM.variables.v_playsnd1).w
rts
+
move.b d0,(Clone_Driver_RAM+SMPS_RAM.variables.v_playsnd4).w
rts
; End of function SMPS_QueueSound1
; ---------------------------------------------------------------------------
; Queue sound for play (queue 2)
; and optionally only do so if object is on-screen (Sonic engine feature)
; ---------------------------------------------------------------------------
; sub_137C: PlaySoundLocal:
if SMPS_EnablePlaySoundLocal
SMPS_QueueSound2Local:
tst.b render_flags(a0)
bpl.s + ; rts
endif
; sub_1370: PlaySound:
SMPS_QueueSound2:
move.b d0,(Clone_Driver_RAM+SMPS_RAM.variables.v_playsnd2).w
+ rts
; End of function SMPS_QueueSound2
; ---------------------------------------------------------------------------
; Queue sound for play (queue 3)
; ---------------------------------------------------------------------------
; sub_1376: PlaySoundStereo:
SMPS_QueueSound3:
move.b d0,(Clone_Driver_RAM+SMPS_RAM.variables.v_playsnd3).w
rts
; End of function SMPS_QueueSound3
; ---------------------------------------------------------------------------
; Play a DAC sample
;
; d0 = Sample ID
; ---------------------------------------------------------------------------
SMPS_PlayDACSample:
SMPS_stopZ80_safe
st.b (SMPS_z80_ram+MegaPCM_DAC_Type).l ; This is a DAC SFX; ignore music DAC volume
move.b d0,(SMPS_z80_ram+MegaPCM_DAC_Number).l
SMPS_startZ80_safe
rts
; End of function SMPS_PlayDACSample
; ---------------------------------------------------------------------------
; Play a PWM sample
;
; d0 = Sample ID
; d1 = Sample volume/panning
; d2 = PWM channel*2 (0 = channel 1, 2 = channel 2, etc.)
; ---------------------------------------------------------------------------
if SMPS_EnablePWM
SMPS_PlayPWMSample:
; Merge ID with volume/pan to get PWM command
lsl.w #8,d1
move.b d0,d1
; Save a0
move.l a0,d0
; Send PWM command
lea ($A15128).l,a0
move.w d1,(a0,d2.w)
; Restore a0
movea.l d0,a0
rts
; End of function SMPS_PlayPWMSample
endif