Commit 473e9b1

Nick committed on
Instrument behavior now follows ProTracker
commit 473e9b1717df09760e48b66a7a4e0da531174fa7 parent 3e53acc
2 changed files +59−27
Modifiedconstants.inc +2−1
@@ -73,4 +73,5 @@ G#8 EQU 68
73 A8 EQU 69 73 A8 EQU 69
74 A#8 EQU 70 74 A#8 EQU 70
75 B8 EQU 71 75 B8 EQU 71
76 LAST_NOTE EQU 72 76 LAST_NOTE EQU 72
77 __ EQU 90 ; the default "no note" value
Modifieddriver.z80 +57−26
@@ -135,8 +135,8 @@ ENDM
135 135
136 SECTION "Song Data", ROM0 136 SECTION "Song Data", ROM0
137 ;; order_cnt is the number of orders times 2 137 ;; order_cnt is the number of orders times 2
138 order_cnt: db 4 138 order_cnt: db 2
139 order1: dw unreal, tfau_bass, empty 139 order1: dw testpatt2, tfau_bass, empty
140 order2: dw empty, empty, empty 140 order2: dw empty, empty, empty
141 order3: dw empty, empty, empty 141 order3: dw empty, empty, empty
142 order4: dw empty, empty, empty 142 order4: dw empty, empty, empty
@@ -155,6 +155,29 @@ empty:
155 rept 64 155 rept 64
156 dn 90, 0, 0 156 dn 90, 0, 0
157 endr 157 endr
158 testpatt:
159 rept 16
160 dn C4, 1, $000
161 dn __, 0, $000
162 dn __, 0, $000
163 dn __, 0, $000
164 dn __, 0, $000
165 dn __, 0, $000
166 dn __, 0, $000
167 dn __, 0, $000
168 endr
169 testpatt2:
170 dn C4, 1, $000
171 rept 16
172 dn D4, 0, $000
173 dn __, 0, $000
174 dn __, 0, $000
175 dn __, 0, $000
176 dn __, 0, $000
177 dn __, 0, $000
178 dn __, 0, $000
179 dn __, 0, $000
180 endr
158 drums: 181 drums:
159 rept 16 182 rept 16
160 dn C4, 2, 0 183 dn C4, 2, 0
@@ -255,7 +278,7 @@ square_instrument:
255 .sweep: db ; unused for channel 2 278 .sweep: db ; unused for channel 2
256 .length_and_duty: db %10000001 279 .length_and_duty: db %10000001
257 .envelope: db %11110000 280 .envelope: db %11110000
258 .highmask: db %11000000 281 .highmask: db %10000000
259 282
260 ;; Format for channel 3: 283 ;; Format for channel 3:
261 284
@@ -573,7 +596,6 @@ _update_channel4:
573 596
574 _playnote1: 597 _playnote1:
575 ;; Call with: 598 ;; Call with:
576 ;; Location of highmask on the stack
577 599
578 ;; Play a note on channel 1 (square wave) 600 ;; Play a note on channel 1 (square wave)
579 ld a, [temp_note_value+1] 601 ld a, [temp_note_value+1]
@@ -583,14 +605,9 @@ _playnote1:
583 ld a, [temp_note_value] 605 ld a, [temp_note_value]
584 ld [channel_period1+1], a 606 ld [channel_period1+1], a
585 607
586 ;; IN PROGRESS:
587
588 ;; Trying to figure out how the highmask and len works, and debugging
589 ;; it with this.
590
591 ;; Get the highmask and apply it. 608 ;; Get the highmask and apply it.
592 ; ld hl, highmask1 609 ld hl, highmask1
593 or %11000000; [hl] 610 or [hl]
594 ld [rAUD1HIGH], a 611 ld [rAUD1HIGH], a
595 612
596 ret 613 ret
@@ -604,7 +621,9 @@ _playnote2:
604 ld a, [temp_note_value] 621 ld a, [temp_note_value]
605 ld [channel_period2+1], a 622 ld [channel_period2+1], a
606 623
607 or %10000000 624 ;; Get the highmask and apply it.
625 ld hl, highmask2
626 or [hl]
608 ld [rAUD2HIGH], a 627 ld [rAUD2HIGH], a
609 628
610 ret 629 ret
@@ -618,7 +637,9 @@ _playnote3:
618 ld a, [temp_note_value] 637 ld a, [temp_note_value]
619 ld [channel_period3+1], a 638 ld [channel_period3+1], a
620 639
621 or %10000000 640 ;; Get the highmask and apply it.
641 ld hl, highmask3
642 or [hl]
622 ld [rAUD3HIGH], a 643 ld [rAUD3HIGH], a
623 644
624 ret 645 ret
@@ -641,7 +662,9 @@ _playnote4:
641 or b 662 or b
642 ld [rAUD4POLY], a 663 ld [rAUD4POLY], a
643 664
644 ld a, %10000000 665 ;; Get the highmask and apply it.
666 ld hl, highmask4
667 or [hl]
645 ld [rAUD4GO], a 668 ld [rAUD4GO], a
646 669
647 ret 670 ret
@@ -1301,6 +1324,10 @@ _dosound:
1301 jr nc, .do_setvol1 1324 jr nc, .do_setvol1
1302 1325
1303 call _setup_instrument_pointer 1326 call _setup_instrument_pointer
1327 ld a, [highmask1]
1328 res 7, a ; Turn off the "initial" flag
1329 jr z, .write_mask1
1330
1304 ld a, [de] 1331 ld a, [de]
1305 inc de 1332 inc de
1306 ld [rAUD1SWEEP], a 1333 ld [rAUD1SWEEP], a
@@ -1312,9 +1339,7 @@ _dosound:
1312 inc de 1339 inc de
1313 ld a, [de] 1340 ld a, [de]
1314 1341
1315 jr nz, .use_instr_mask1 ; if there's a real instrument, use its highmask 1342 .write_mask1:
1316 ld a, 0 ; if not, then use zero.
1317 .use_instr_mask1:
1318 ld [highmask1], a 1343 ld [highmask1], a
1319 1344
1320 .do_setvol1: 1345 .do_setvol1:
@@ -1340,6 +1365,10 @@ _dosound:
1340 jr nc, .do_setvol2 1365 jr nc, .do_setvol2
1341 1366
1342 call _setup_instrument_pointer 1367 call _setup_instrument_pointer
1368 ld a, [highmask2]
1369 res 7, a ; Turn off the "initial" flag
1370 jr z, .write_mask2
1371
1343 inc de 1372 inc de
1344 ld a, [de] 1373 ld a, [de]
1345 inc de 1374 inc de
@@ -1349,9 +1378,7 @@ _dosound:
1349 inc de 1378 inc de
1350 ld a, [de] 1379 ld a, [de]
1351 1380
1352 jr nz, .use_instr_mask2 ; if there's a real instrument, use its highmask 1381 .write_mask2:
1353 ld a, 0 ; if not, then use zero.
1354 .use_instr_mask2:
1355 ld [highmask2], a 1382 ld [highmask2], a
1356 1383
1357 .do_setvol2: 1384 .do_setvol2:
@@ -1378,6 +1405,10 @@ _dosound:
1378 jr nc, .do_setvol3 1405 jr nc, .do_setvol3
1379 1406
1380 call _setup_instrument_pointer 1407 call _setup_instrument_pointer
1408 ld a, [highmask3]
1409 res 7, a ; Turn off the "initial" flag
1410 jr z, .write_mask3
1411
1381 ld a, [de] 1412 ld a, [de]
1382 inc de 1413 inc de
1383 ld [rAUD3LEN], a 1414 ld [rAUD3LEN], a
@@ -1391,9 +1422,7 @@ _dosound:
1391 inc de 1422 inc de
1392 ld a, [de] 1423 ld a, [de]
1393 1424
1394 jr nz, .use_instr_mask3 ; if there's a real instrument, use its highmask 1425 .write_mask3:
1395 ld a, 0 ; if not, then use zero.
1396 .use_instr_mask3:
1397 ld [highmask3], a 1426 ld [highmask3], a
1398 1427
1399 .do_setvol3: 1428 .do_setvol3:
@@ -1421,6 +1450,10 @@ _dosound:
1421 jr nc, .do_setvol4 1450 jr nc, .do_setvol4
1422 1451
1423 call _setup_instrument_pointer 1452 call _setup_instrument_pointer
1453 ld a, [highmask4]
1454 res 7, a ; Turn off the "initial" flag
1455 jr z, .write_mask4
1456
1424 ld a, [de] 1457 ld a, [de]
1425 inc de 1458 inc de
1426 ld [rAUD4LEN], a 1459 ld [rAUD4LEN], a
@@ -1432,9 +1465,7 @@ _dosound:
1432 inc de 1465 inc de
1433 ld a, [de] 1466 ld a, [de]
1434 1467
1435 jr nz, .use_instr_mask4 ; if there's a real instrument, use its highmask 1468 .write_mask4:
1436 ld a, 0 ; if not, then use zero.
1437 .use_instr_mask4:
1438 ld [highmask4], a 1469 ld [highmask4], a
1439 1470
1440 .do_setvol4: 1471 .do_setvol4: