synth.s 20.5 KB
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 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958
#include "defines.h"
.arm
.align
.text
.global keyCheckSynth
.global displayData
notePlay:
push {r0-r12,lr}
ldr r0,[r6,r4] @@ set key used flag
cmp r0,#1
beq notePlayExit
mov r0,#1
str r0,[r6,r4]
ldr r7,=soundRegUsage @@ holds info about what sound registers are used
ldrh r0,[r7]
eors r0, r0, #1
strh r0,[r7]
ldrh r5, [r5, r4] @ Load Note
ldreq r1,=REG_SOUND1CNT_H
ldrne r1,=REG_SOUND2CNT_L
ldr r2,=notesettings
ldrh r3,[r2]
strh r3,[r1]
ldreq r1,=REG_SOUND1CNT_X
ldrne r1,=REG_SOUND2CNT_H
ldrh r3, [r2,#2] @ get note settings
mov r0, r5
orr r0, r3, r5
ldrh r3,[r2,#4]
cmp r3,#0
orrne r0,r0,#0b100000000000000
str r0,[r1]
notePlayExit:
pop {r0-r12,lr}
bx lr
keyClear:
push {r0-r12,lr}
mov r0,#0
str r0,[r6,r4]
pop {r0-r12,lr}
bx lr
@@@@@@@@
@
@ r4=offset for keystates and notes
@
@@@@@@@@
keyCheckSynth: @ Load keycheck routine and also call respective handlers
push {r0-r12,lr} @ Save link reg
ldr r0, =KEYINPUT
ldr r1, [r0]
ldr r6,=keystates
bl getScale
@@@ setup
ands r0,r1,#0b100
beq settingChange
@@@ Play Notes
mov r4, #0 @ keystates offset for key
ands r0, r1, #0b1000000000 @ AND key L
blne keyClear
bleq notePlay
mov r4, #4 @ keystates offset for key
ands r0, r1, #0b100000 @ AND key left
blne keyClear
bleq notePlay
mov r4, #8 @ keystates offset for key
ands r0, r1, #0b10000000 @ AND key down
blne keyClear
bleq notePlay
mov r4, #12 @ keystates offset for key
ands r0, r1, #0b10000 @ AND key right
blne keyClear
bleq notePlay
mov r4, #16 @ keystates offset for key
ands r0, r1, #0b1000000 @ AND key up
blne keyClear
bleq notePlay
mov r4, #20 @ keystates offset for key
ands r0, r1, #0b10 @ AND key B
blne keyClear
bleq notePlay
mov r4, #24 @ keystates offset for key
ands r0, r1, #0b1 @ AND key A
blne keyClear
bleq notePlay
mov r4, #28 @ keystates offset for key
ands r0, r1, #0b100000000 @ AND key R
blne keyClear
bleq notePlay
pop {r0-r12,lr} @ Recover link reg
bx lr
@@ While Select is held settings can be changed
settingChange:
ldr r0,=0b1100000100
ands r0,r1,r0 @ L+R+Select = Setup Menu
swieq 0x00000
mov r4, #36
ands r0, r1, #0b1000 @ A = toggle Major/Minor
blne keyClear
bleq toggleMajMin
mov r4, #16
ands r0, r1, #0b1000000 @ AND key up
blne keyClear
bleq octaveUp
mov r4, #8
ands r0, r1, #0b10000000 @ AND key down
blne keyClear
bleq octaveDown
mov r4, #12
ands r0, r1, #0b10000 @ AND key right
blne keyClear
bleq musicalkeyUp
mov r4, #4
ands r0, r1, #0b100000 @ AND key left
blne keyClear
bleq musicalkeyDown
pop {r0-r12,lr} @ Recover link reg
bx lr
toggleMajMin: @ toggle major minor flag
push {r0-r12,lr}
ldr r0,[r6,r4] @ Checks if held
cmp r0,#1
bxeq lr
mov r0,#1
str r0,[r6,r4]
ldr r0,=key
ldr r1,[r0,#4]
cmp r1,#0
moveq r1,#1
movne r1,#0
str r1,[r0,#4]
pop {r0-r12,lr}
getScale:
push {r0-r4,r6-r12,lr}
ldr r0,=key @ load address of key variable
ldr r0,[r0,#4] @ load maj/min flag
cmp r0,#0 @ 0 = major
beq getMajScale @ branch to getMajScale if ==
bne getMinScale @ branch to getMinSvale otherwise
getMajScale:
ldr r0, =key
ldr r1, [r0]
cmp r1, #0 @ if r1 = 0 get Cmaj
bleq getCmaj
cmp r1, #1 @ if r1 = 1 get Gmaj
bleq getGmaj
cmp r1, #2 @ Dmaj
bleq getDmaj
cmp r1, #3 @ Amaj
bleq getAmaj
cmp r1, #4 @ Emaj
bleq getEmaj
cmp r1, #5 @ Bmaj
bleq getBmaj
cmp r1, #6 @ F#maj
bleq getFsharpmaj
cmp r1, #7 @ C#maj
bleq getCsharpmaj
cmp r1, #8 @ Fmaj
bleq getFmaj
cmp r1, #9 @ Bflatmaj
bleq getBflatmaj
cmp r1, #10 @ Eflatmaj
bleq getEflatmaj
cmp r1, #11 @ Aflatmaj
bleq getAflatmaj
cmp r1, #12 @ Dflatmaj
bleq getDflatmaj
cmp r1, #13 @ Gflatmaj
bleq getGflatmaj
cmp r1, #14 @ Cflatmaj
bleq getCflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getMinScale:
ldr r0, =key
ldr r1, [r0]
cmp r1, #0 @ if r1 = 0 get Amin
bleq getAmin
cmp r1, #1 @ if r1 = 1 get Emin
bleq getEmin
cmp r1, #2 @ Bmin
bleq getBmin
cmp r1, #3 @ F#min
bleq getFsharpmin
cmp r1, #4 @ C#min
bleq getCsharpmin
cmp r1, #5 @ G#min
bleq getGsharpmin
cmp r1, #6 @ D#min
bleq getDsharpmin
cmp r1, #7 @ A#min
bleq getAsharpmin
cmp r1, #8 @ Dmin
bleq getDmin
cmp r1, #9 @ Gmin
bleq getGmin
cmp r1, #10 @ Cmin
bleq getCmin
cmp r1, #11 @ Fmin
bleq getFmin
cmp r1, #12 @ Bbmin
bleq getBflatmin
cmp r1, #13 @ Eflatmin
bleq getEflatmin
cmp r1, #14 @ Abmin
bleq getAflatmin
pop {r0-r4,r6-r12,lr}
bx lr
@@ Major Scale Loads
getCmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Cmaj
cmp r1, #3
ldreq r5, =notesOct3_Cmaj
cmp r1, #4
ldreq r5, =notesOct4_Cmaj
cmp r1, #5
ldreq r5, =notesOct5_Cmaj
cmp r1, #6
ldreq r5, =notesOct6_Cmaj
pop {r0-r4,r6-r12,lr}
bx lr
getGmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Gmaj
cmp r1, #3
ldreq r5, =notesOct3_Gmaj
cmp r1, #4
ldreq r5, =notesOct4_Gmaj
cmp r1, #5
ldreq r5, =notesOct5_Gmaj
cmp r1, #6
ldreq r5, =notesOct6_Gmaj
pop {r0-r4,r6-r12,lr}
bx lr
getDmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Dmaj
cmp r1, #3
ldreq r5, =notesOct3_Dmaj
cmp r1, #4
ldreq r5, =notesOct4_Dmaj
cmp r1, #5
ldreq r5, =notesOct5_Dmaj
cmp r1, #6
ldreq r5, =notesOct6_Dmaj
pop {r0-r4,r6-r12,lr}
bx lr
getAmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Amaj
cmp r1, #3
ldreq r5, =notesOct3_Amaj
cmp r1, #4
ldreq r5, =notesOct4_Amaj
cmp r1, #5
ldreq r5, =notesOct5_Amaj
cmp r1, #6
ldreq r5, =notesOct6_Amaj
pop {r0-r4,r6-r12,lr}
bx lr
getEmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Emaj
cmp r1, #3
ldreq r5, =notesOct3_Emaj
cmp r1, #4
ldreq r5, =notesOct4_Emaj
cmp r1, #5
ldreq r5, =notesOct5_Emaj
cmp r1, #6
ldreq r5, =notesOct6_Emaj
pop {r0-r4,r6-r12,lr}
bx lr
getBmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Bmaj
cmp r1, #3
ldreq r5, =notesOct3_Bmaj
cmp r1, #4
ldreq r5, =notesOct4_Bmaj
cmp r1, #5
ldreq r5, =notesOct5_Bmaj
cmp r1, #6
ldreq r5, =notesOct6_Bmaj
pop {r0-r4,r6-r12,lr}
bx lr
getFsharpmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Fsharpmaj
cmp r1, #3
ldreq r5, =notesOct3_Fsharpmaj
cmp r1, #4
ldreq r5, =notesOct4_Fsharpmaj
cmp r1, #5
ldreq r5, =notesOct5_Fsharpmaj
cmp r1, #6
ldreq r5, =notesOct6_Fsharpmaj
pop {r0-r4,r6-r12,lr}
bx lr
getCsharpmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Csharpmaj
cmp r1, #3
ldreq r5, =notesOct3_Csharpmaj
cmp r1, #4
ldreq r5, =notesOct4_Csharpmaj
cmp r1, #5
ldreq r5, =notesOct5_Csharpmaj
cmp r1, #6
ldreq r5, =notesOct6_Csharpmaj
pop {r0-r4,r6-r12,lr}
bx lr
getFmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Fmaj
cmp r1, #3
ldreq r5, =notesOct3_Fmaj
cmp r1, #4
ldreq r5, =notesOct4_Fmaj
cmp r1, #5
ldreq r5, =notesOct5_Fmaj
cmp r1, #6
ldreq r5, =notesOct6_Fmaj
pop {r0-r4,r6-r12,lr}
bx lr
getBflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Bflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Bflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Bflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Bflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Bflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getEflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Eflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Eflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Eflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Eflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Eflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getAflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Aflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Aflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Aflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Aflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Aflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getDflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Dflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Dflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Dflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Dflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Dflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getGflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Gflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Gflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Gflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Gflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Gflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
getCflatmaj:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Cflatmaj
cmp r1, #3
ldreq r5, =notesOct3_Cflatmaj
cmp r1, #4
ldreq r5, =notesOct4_Cflatmaj
cmp r1, #5
ldreq r5, =notesOct5_Cflatmaj
cmp r1, #6
ldreq r5, =notesOct6_Cflatmaj
pop {r0-r4,r6-r12,lr}
bx lr
@@ Minor Scale Loads
getAmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Amin
cmp r1, #3
ldreq r5, =notesOct3_Amin
cmp r1, #4
ldreq r5, =notesOct4_Amin
cmp r1, #5
ldreq r5, =notesOct5_Amin
cmp r1, #6
ldreq r5, =notesOct6_Amin
pop {r0-r4,r6-r12,lr}
bx lr
getEmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Emin
cmp r1, #3
ldreq r5, =notesOct3_Emin
cmp r1, #4
ldreq r5, =notesOct4_Emin
cmp r1, #5
ldreq r5, =notesOct5_Emin
cmp r1, #6
ldreq r5, =notesOct6_Emin
pop {r0-r4,r6-r12,lr}
bx lr
getBmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Bmin
cmp r1, #3
ldreq r5, =notesOct3_Bmin
cmp r1, #4
ldreq r5, =notesOct4_Bmin
cmp r1, #5
ldreq r5, =notesOct5_Bmin
cmp r1, #6
ldreq r5, =notesOct6_Bmin
pop {r0-r4,r6-r12,lr}
bx lr
getFsharpmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Fsharpmin
cmp r1, #3
ldreq r5, =notesOct3_Fsharpmin
cmp r1, #4
ldreq r5, =notesOct4_Fsharpmin
cmp r1, #5
ldreq r5, =notesOct5_Fsharpmin
cmp r1, #6
ldreq r5, =notesOct6_Fsharpmin
pop {r0-r4,r6-r12,lr}
bx lr
getCsharpmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Csharpmin
cmp r1, #3
ldreq r5, =notesOct3_Csharpmin
cmp r1, #4
ldreq r5, =notesOct4_Csharpmin
cmp r1, #5
ldreq r5, =notesOct5_Csharpmin
cmp r1, #6
ldreq r5, =notesOct6_Csharpmin
pop {r0-r4,r6-r12,lr}
bx lr
getGsharpmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Gsharpmin
cmp r1, #3
ldreq r5, =notesOct3_Gsharpmin
cmp r1, #4
ldreq r5, =notesOct4_Gsharpmin
cmp r1, #5
ldreq r5, =notesOct5_Gsharpmin
cmp r1, #6
ldreq r5, =notesOct6_Gsharpmin
pop {r0-r4,r6-r12,lr}
bx lr
getDsharpmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Dsharpmin
cmp r1, #3
ldreq r5, =notesOct3_Dsharpmin
cmp r1, #4
ldreq r5, =notesOct4_Dsharpmin
cmp r1, #5
ldreq r5, =notesOct5_Dsharpmin
cmp r1, #6
ldreq r5, =notesOct6_Dsharpmin
pop {r0-r4,r6-r12,lr}
bx lr
getAsharpmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Asharpmin
cmp r1, #3
ldreq r5, =notesOct3_Asharpmin
cmp r1, #4
ldreq r5, =notesOct4_Asharpmin
cmp r1, #5
ldreq r5, =notesOct5_Asharpmin
cmp r1, #6
ldreq r5, =notesOct6_Asharpmin
pop {r0-r4,r6-r12,lr}
bx lr
getDmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Dmin
cmp r1, #3
ldreq r5, =notesOct3_Dmin
cmp r1, #4
ldreq r5, =notesOct4_Dmin
cmp r1, #5
ldreq r5, =notesOct5_Dmin
cmp r1, #6
ldreq r5, =notesOct6_Dmin
pop {r0-r4,r6-r12,lr}
bx lr
getGmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Gmin
cmp r1, #3
ldreq r5, =notesOct3_Gmin
cmp r1, #4
ldreq r5, =notesOct4_Gmin
cmp r1, #5
ldreq r5, =notesOct5_Gmin
cmp r1, #6
ldreq r5, =notesOct6_Gmin
pop {r0-r4,r6-r12,lr}
bx lr
getCmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Cmin
cmp r1, #3
ldreq r5, =notesOct3_Cmin
cmp r1, #4
ldreq r5, =notesOct4_Cmin
cmp r1, #5
ldreq r5, =notesOct5_Cmin
cmp r1, #6
ldreq r5, =notesOct6_Cmin
pop {r0-r4,r6-r12,lr}
bx lr
getFmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Fmin
cmp r1, #3
ldreq r5, =notesOct3_Fmin
cmp r1, #4
ldreq r5, =notesOct4_Fmin
cmp r1, #5
ldreq r5, =notesOct5_Fmin
cmp r1, #6
ldreq r5, =notesOct6_Fmin
pop {r0-r4,r6-r12,lr}
bx lr
getBflatmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Bflatmin
cmp r1, #3
ldreq r5, =notesOct3_Bflatmin
cmp r1, #4
ldreq r5, =notesOct4_Bflatmin
cmp r1, #5
ldreq r5, =notesOct5_Bflatmin
cmp r1, #6
ldreq r5, =notesOct6_Bflatmin
pop {r0-r4,r6-r12,lr}
bx lr
getEflatmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Eflatmin
cmp r1, #3
ldreq r5, =notesOct3_Eflatmin
cmp r1, #4
ldreq r5, =notesOct4_Eflatmin
cmp r1, #5
ldreq r5, =notesOct5_Eflatmin
cmp r1, #6
ldreq r5, =notesOct6_Eflatmin
pop {r0-r4,r6-r12,lr}
bx lr
getAflatmin:
push {r0-r4,r6-r12,lr}
ldr r0, =octave
ldr r1, [r0]
cmp r1, #2
ldreq r5, =notesOct2_Aflatmin
cmp r1, #3
ldreq r5, =notesOct3_Aflatmin
cmp r1, #4
ldreq r5, =notesOct4_Aflatmin
cmp r1, #5
ldreq r5, =notesOct5_Aflatmin
cmp r1, #6
ldreq r5, =notesOct6_Aflatmin
pop {r0-r4,r6-r12,lr}
bx lr
octaveUp:
push {r0-r12,lr}
ldr r0,[r6,r4] @ Checks if held
cmp r0,#1
bxeq lr
mov r0,#1
str r0,[r6,r4]
ldr r0, =octave
ldr r1, [r0]
cmp r1, #6 @ if it's already at the highest...
moveq r1, #3 @ go to lowest
addne r1, r1, #1
str r1,[r0]
mov r9,r1
bl saveSettings @ save to sram
pop {r0-r12,lr}
bx lr
octaveDown:
push {r0-r12,lr}
ldr r0,[r6,r4] @ Checks if held
cmp r0,#1
bxeq lr
mov r0,#1
str r0,[r6,r4]
ldr r0, =octave
ldr r1, [r0]
cmp r1, #3 @ if it's already at the lowest...
moveq r1, #6 @ go to highest
subne r1, r1, #1
str r1,[r0]
mov r9,r1
bl saveSettings @ save to sram
pop {r0-r12,lr}
bx lr
musicalkeyUp:
push {r0-r12,lr}
ldr r0,[r6,r4] @ Checks if held.
cmp r0,#1
bxeq lr
mov r0,#1
str r0,[r6,r4]
ldr r0, =key
ldr r1, [r0]
cmp r1, #14 @ if it's already at the highest...
moveq r1, #0 @ go to lowest
addne r1, r1, #1
str r1,[r0]
mov r9,r1
bl saveSettings @save to sram
pop {r0-r12,lr}
bx lr
musicalkeyDown:
push {r0-r12,lr}
ldr r0,[r6,r4] @ Checks if held.
cmp r0,#1
bxeq lr
mov r0,#1
str r0,[r6,r4]
ldr r0, =key
ldr r1, [r0]
cmp r1, #0 @ if it's already at the lowest...
moveq r1, #14 @ go to highest
subne r1, r1, #1
str r1,[r0]
mov r9,r1
bl saveSettings @save to sram
pop {r0-r12,lr}
bx lr
displayData: @ edit synthText to show Key and Oct
push {r0-r12,lr}
ldr r0,=key @ get address of key
ldr r0,[r0,#4] @ load maj/min flag
cmp r0,#0 @ is it major?
bleq displayKeyMaj @if it is show the key's base note
cmp r0,#1
bleq displayKeyMin @ else show the minor version
ldr r4,=synthText
add r6,r6,#1 @ inc location
ldr r0,=octave @ get address of octave
ldrh r0,[r0] @ load octave's content
add r0,r0,#48 @ add 0's tile number
strb r0,[r4,r6] @ store it
@@ if key is major display maj
ldr r0,=key
ldr r0,[r0,#4]
cmp r0,#0
blne displayMin @ display minor
bleq displayMaj @ display major
pop {r0-r12,lr}
bx lr
displayMaj: @ display "maj" r4 must be address of synthText r6 must be current map index
push {r0-r5,r7-r12,lr}
add r6,r6,#1 @ load location to place tile
ldrh r0,=109 @ load index for 'm'
strb r0,[r4,r6] @ change tile map
add r6,r6,#1
ldrh r0,=97 @ load index for 'a'
strb r0,[r4,r6] @ change tile map
add r6,r6,#1
ldrh r0,=106 @ load index for 'j'
strb r0,[r4,r6] @ change tile map
pop {r0-r5,r7-r12,lr}
bx lr
displayMin: @ same as displayMaj but for minor scales
push {r0-r5,r7-r12,lr}
add r6,r6,#1 @ load location to place tile
ldrh r0,=109 @ load index for 'm'
strb r0,[r4,r6] @ change tile map
add r6,r6,#1 @ inc location
ldrh r0,=105 @ load index for 'i'
strb r0,[r4,r6] @ change tile map
add r6,r6,#1 @ inc location
ldrh r0,=110 @ load index for 'n'
strb r0,[r4,r6] @ change tile map
pop {r0-r5,r7-r12,lr}
bx lr
displayKeyMaj:
push {r0-r5,r7-r12,lr}
ldr r4,=synthText
ldr r0,=key
ldr r0,[r0]
cmp r0,#0
ldreqh r0,=67 @ C
@@ Sharp Key Sigs Major @@
cmp r0,#1
ldreqh r0,=71 @ G
cmp r0,#2
ldreqh r0,=68 @ Dmaj
cmp r0,#3
ldreqh r0,=65 @ Amaj
cmp r0,#4
ldreqh r0,=69 @ Emaj
cmp r0,#5
ldreqh r0,=66 @ Bmaj
cmp r0,#6
ldreqh r0,=70 @ F#maj
moveq r3,#1 @ sharp flag
cmp r0,#7
ldreqh r0,=67 @ C#maj
moveq r3,#1 @ sharp flag
@@ Flat Key Sigs Major @@
cmp r0,#8
ldreqh r0,=70 @ Fmaj
cmp r0,#9
ldreqh r0,=66 @ Bbmaj
moveq r3,#2 @ flat flag
cmp r0,#10
ldreqh r0,=69 @ Ebmaj
moveq r3,#2 @ flat flag
cmp r0,#11
ldreqh r0,=65 @ Abmaj
moveq r3,#2 @ flat flag
cmp r0,#12
ldreqh r0,=68 @ Dbmaj
moveq r3,#2 @ flat flag
cmp r0,#13
ldreqh r0,=71 @ Gbmaj
moveq r3,#2 @ flat flag
cmp r0,#14
ldreqh r0,=67 @ Cbmaj
moveq r3,#2 @ flat flag
ldr r6,=608 @ Store the tile id
strb r0,[r4,r6]
add r6,r6,#1
ldrb r0,=32
strb r0,[r4,r6]
@@ Display # or b if sharp or flat
cmp r3,#1
ldreqb r0,=128 @@ sharp sign
streqb r0,[r4,r6]
cmp r3,#2
ldreqb r0,=129 @@ flat sign
streqb r0,[r4,r6]
pop {r0-r5,r7-r12,lr}
bx lr
displayKeyMin:
push {r0-r5,r7-r12,lr}
ldr r4,=synthText
ldr r0,=key
ldr r0,[r0]
cmp r0,#0
ldreqh r0,=65 @ A
@@ Sharp Key Sigs Major @@
cmp r0,#1
ldreqh r0,=69 @ E
cmp r0,#2
ldreqh r0,=66 @ B
cmp r0,#3
ldreqh r0,=70 @ F#
moveq r3,#1 @ sharp flag
cmp r0,#4
ldreqh r0,=67 @ C#
moveq r3,#1 @ sharp flag
cmp r0,#5
ldreqh r0,=71 @ G#
moveq r3,#1 @ sharp flag
cmp r0,#6
ldreqh r0,=68 @ D#
moveq r3,#1 @ sharp flag
cmp r0,#7
ldreqh r0,=65 @ A#
moveq r3,#1 @ sharp flag
@@ Flat Key Sigs Major @@
cmp r0,#8
ldreqh r0,=68 @ D
cmp r0,#9
ldreqh r0,=71 @ G
cmp r0,#10
ldreqh r0,=67 @ C
cmp r0,#11
ldreqh r0,=70 @ F
cmp r0,#12
ldreqh r0,=66 @ Bb
moveq r3,#2 @ flat flag
cmp r0,#13
ldreqh r0,=69 @ Eb
moveq r3,#2 @ flat flag
cmp r0,#14
ldreqh r0,=65 @ Ab
moveq r3,#2 @ flat flag
ldr r6,=608 @ Store the tile id
strb r0,[r4,r6]
add r6,r6,#1
ldrb r0,=32
strb r0,[r4,r6]
@@ Display # or b if sharp or flat
cmp r3,#1
ldreqb r0,=128 @@ sharp sign
streqb r0,[r4,r6]
cmp r3,#2
ldreqb r0,=129 @@ flat sign
streqb r0,[r4,r6]
pop {r0-r5,r7-r12,lr}
bx lr
@ vim: syntax=armasm