Browse Source

slightly reduce code size

ipatix 7 years ago
parent
commit
795224bff1
1 changed files with 9 additions and 10 deletions
  1. 9
    10
      src/music/main_mixer.s

+ 9
- 10
src/music/main_mixer.s View File

@@ -512,7 +512,6 @@ C_mixing_setup:
512 512
         ADD     R10, R10, R0
513 513
         CMP     R10, SP
514 514
         ADD     R10, R3, R0
515
-        ADR     R9, stack_backup
516 515
         /*
517 516
          * R2 = remaining samples after processing
518 517
          * R10 = final sample position
@@ -520,8 +519,9 @@ C_mixing_setup:
520 519
          * These values will get reloaded after channel processing
521 520
          * due to the lack of registers.
522 521
          */
523
-        STMIA   R9, {R2, R10, SP}
522
+        STMFD   SP!, {R2, R10}
524 523
         CMPCC   R0, #0x400                      @ > 0x400 bytes --> read directly from ROM rather than buffered
524
+        MOV     R10, SP
525 525
         BCS     C_select_highspeed_codepath
526 526
         /*
527 527
          * The code below inits the DMA to read word aligned
@@ -547,6 +547,7 @@ C_mixing_setup:
547 547
     .endif
548 548
 
549 549
 C_select_highspeed_codepath:
550
+        STMFD   SP!, {R10}                      @ save original SP for VLA
550 551
         /*
551 552
          * This code decides which piece of code to load
552 553
          * depending on playback-rate / default-rate ratio.
@@ -587,7 +588,7 @@ C_skip_fast_mixing_creation:
587 588
         MOV     R2, #0xFF000000                 @ load the fine position overflow bitmask
588 589
 C_fast_mixing_loop:
589 590
         /* This is the actual processing and interpolation code loop; NOPs will be replaced by the code above */
590
-            LDMIA   R5, {R0, R1, R10, LR}         @ load 4 stereo samples to Registers
591
+            LDMIA   R5, {R0, R1, R10, LR}       @ load 4 stereo samples to Registers
591 592
             MUL     R9, R7, R12
592 593
 fast_mixing_instructions:
593 594
             NOP                                 @ Block #1
@@ -625,9 +626,9 @@ fast_mixing_instructions:
625 626
             NOP
626 627
             NOP
627 628
             BIC     R7, R7, R2, ASR#1
628
-            STMIA   R5!, {R0, R1, R10, LR}        @ write 4 stereo samples
629
+            STMIA   R5!, {R0, R1, R10, LR}      @ write 4 stereo samples
629 630
 
630
-            LDMIA   R5, {R0, R1, R10, LR}         @ load the next 4 stereo samples
631
+            LDMIA   R5, {R0, R1, R10, LR}       @ load the next 4 stereo samples
631 632
             MULNE   R9, R7, R12
632 633
             NOP                                 @ Block #1
633 634
             NOP
@@ -668,15 +669,13 @@ fast_mixing_instructions:
668 669
             SUBS    R8, R8, #8
669 670
             BGT     C_fast_mixing_loop
670 671
         /* restore previously saved values */
671
-        ADR     R12, stack_backup
672
-        LDMIA   R12, {R2, R3, SP}
672
+        LDMFD   SP, {SP}                        @ reload original stack pointer from VLA
673
+        LDMFD   SP!, {R2, R3}
673 674
         B       C_end_mixing
674 675
 
675 676
 /* Various variables for the cached mixer */
676 677
 
677 678
     .align    2
678
-stack_backup:
679
-    .word    0x0, 0x0, 0x0
680 679
 upper_stack_bounds:
681 680
     .word    0x03007910
682 681
 previous_fast_code:
@@ -795,7 +794,7 @@ C_fixed_mixing_length_check:
795 794
         MOVGT   LR, R8                          @ min(buffer_size, sample_countdown)
796 795
         SUB     LR, LR, #1
797 796
         MOVS    LR, LR, LSR#2
798
-        BEQ     C_fixed_mixing_process_rest  @ <= 3 samples to process
797
+        BEQ     C_fixed_mixing_process_rest     @ <= 3 samples to process
799 798
 
800 799
         SUB     R8, R8, LR, LSL#2               @ subtract the amount of samples we need to process from the buffer length
801 800
         SUB     R2, R2, LR, LSL#2               @ subtract the amount of samples we need to process from the remaining samples