Details | Last modification | View Log
Rev | Author | Line No. | Line |
---|---|---|---|
1637 | galstaff | 1 | DEVICE ZXSPECTRUM128 |
2 | include "../_sdk/sys_h.asm" |
||
3 | include "playerdefs.asm" |
||
4 | |||
5 | org PLAYERSTART |
||
6 | |||
7 | begin PLAYERHEADER |
||
8 | |||
9 | isfilesupported |
||
10 | ;cde = file extension |
||
11 | mdrsupported=$+1 |
||
12 | ld a,'m' |
||
13 | cp c |
||
14 | ret nz |
||
15 | ld hl,'dr' |
||
16 | sub hl,de |
||
17 | ret |
||
18 | |||
19 | playerinit |
||
20 | ;hl = shared pages |
||
21 | ;a = player page |
||
22 | call ismoonsoundpresent |
||
23 | ret z |
||
24 | ld (mdrsupported),a ;writes 255 disabling the extension |
||
25 | ret |
||
26 | |||
27 | playerdeinit |
||
28 | ret |
||
29 | |||
30 | musicload |
||
31 | ;de = input file name |
||
32 | call openstream_file |
||
33 | or a |
||
34 | ret nz |
||
35 | |||
36 | ld hl,datapages |
||
37 | ld bc,0x8000 |
||
38 | loadloop |
||
39 | push bc |
||
40 | push hl |
||
41 | OS_NEWPAGE |
||
42 | pop hl |
||
43 | pop bc |
||
44 | ld (hl),e |
||
45 | |||
46 | ld a,c |
||
47 | inc c |
||
48 | call change_page3 |
||
49 | |||
50 | push bc |
||
51 | push hl |
||
52 | ld de,0x8000 |
||
53 | ld hl,0x4000 |
||
54 | call readstream_file |
||
55 | bit 6,h |
||
56 | pop hl |
||
57 | pop bc |
||
58 | jr z,exitloadloop |
||
59 | |||
60 | inc hl |
||
61 | djnz loadloop |
||
62 | |||
63 | exitloadloop |
||
64 | ld a,c |
||
65 | ld (datapagecount),a |
||
66 | |||
67 | call closestream_file |
||
68 | |||
69 | call moon_load_pcm |
||
70 | call moon_init_all |
||
71 | call resetloopflag |
||
72 | |||
73 | xor a |
||
74 | ld (loopcount),a |
||
75 | |||
76 | ld de,0x022f |
||
77 | call moon_fm1_out |
||
78 | |||
79 | ld de,0x0421 |
||
80 | call moon_fm1_out |
||
81 | |||
82 | xor a |
||
83 | ret |
||
84 | |||
85 | musicunload |
||
86 | call moon_seq_all_keyoff |
||
87 | |||
88 | ld hl,datapages |
||
89 | datapagecount=$+1 |
||
90 | ld b,0 |
||
91 | pagefreeloop |
||
92 | push bc |
||
93 | push hl |
||
94 | ld e,(hl) |
||
95 | OS_DELPAGE |
||
96 | pop hl |
||
97 | pop bc |
||
98 | inc hl |
||
99 | djnz pagefreeloop |
||
100 | ret |
||
101 | |||
102 | musicplay |
||
103 | ;out: zf=0 if still playing, zf=1 otherwise |
||
104 | in a,(MOON_STAT) |
||
105 | rla |
||
106 | jr nc,musicplay |
||
107 | |||
108 | ld de,0x0481 |
||
109 | call moon_fm1_out |
||
110 | |||
111 | call moon_proc_tracks |
||
112 | call checkifallchannelslooped |
||
113 | ret nz |
||
114 | |||
115 | call resetloopflag |
||
116 | |||
117 | ld hl,loopcount |
||
118 | inc (hl) |
||
119 | ld a,(hl) |
||
120 | cp 2 ;repeat twice |
||
121 | ret |
||
122 | |||
123 | change_page3 |
||
124 | push bc |
||
125 | add a,datapages%256 |
||
126 | ld c,a |
||
127 | adc a,datapages/256 |
||
128 | sub c |
||
129 | ld b,a |
||
130 | ld a,(bc) |
||
131 | SETPG8000 |
||
132 | pop bc |
||
133 | ret |
||
134 | |||
135 | resetloopflag |
||
136 | ld hl,seq_work+IDX_NOT_LOOPED |
||
137 | ld de,SEQ_WORKSIZE |
||
138 | ld b,USE_CH |
||
139 | ld a,255 |
||
140 | resetloopflagloop |
||
141 | ld (hl),a |
||
142 | add hl,de |
||
143 | djnz resetloopflagloop |
||
144 | ret |
||
145 | |||
146 | checkifallchannelslooped |
||
147 | ; zf=1 if all channels looped at least once, zf=0 otherwise |
||
148 | xor a |
||
149 | call change_page3_bank |
||
150 | ld hl,seq_work+IDX_NOT_LOOPED |
||
151 | ld de,SEQ_WORKSIZE |
||
152 | ld a,(S_DEVICE_FLAGS) |
||
153 | or a |
||
154 | jr z,checkopl4 |
||
155 | rrca |
||
156 | jr nc,checkopl3 |
||
157 | checkopl4 |
||
158 | ld c,a |
||
159 | ld b,$18 ;24 channels OPL4 |
||
160 | call checkchannels |
||
161 | ret nz |
||
162 | ld a,c |
||
163 | checkopl3 |
||
164 | or a |
||
165 | ret z |
||
166 | ld b,$12 ;18 channels OPL3 |
||
167 | checkchannels |
||
168 | ld a,(hl) |
||
169 | or a |
||
170 | ret nz |
||
171 | add hl,de |
||
172 | djnz checkchannels |
||
173 | ret |
||
174 | |||
175 | include "../_sdk/file.asm" |
||
176 | include "moonsound.asm" |
||
177 | include "moondriver/moon_driver.asm" |
||
178 | |||
179 | end |
||
180 | |||
181 | datapages |
||
182 | ds 128 ;there are max. 256 banks 8192 bytes each, so we can use up to 128 16k-pages |
||
183 | loopcount |
||
184 | ds 1 |
||
185 | |||
186 | savebin "mdr.bin",begin,end-begin |