dragonflysots 6 лет назад
Родитель
Сommit
c7f7967fbc
3 измененных файлов: 52 добавлений и 110 удалений
  1. 3
    5
      patches/music.asm
  2. 49
    81
      src/music/main_mixer.s
  3. 0
    24
      src/music/titlescreen.s

+ 3
- 5
patches/music.asm Просмотреть файл

@@ -20,11 +20,9 @@
20 20
 // titlescreen cry id fix
21 21
 
22 22
 .org 0x080791EE
23
-ldr r2, =titlescreen_cry_id_override+1
24
-bx  r2
25
-.pool
26
-
27
-
23
+    mov r0, #80
24
+    bl  (m4aSongNumStart-1) // -1 because armips apparently cannot deal with that +1 in the symbol
25
+    nop
28 26
 
29 27
 // titlescreen music length extension
30 28
 .org 0x08078C1C

+ 49
- 81
src/music/main_mixer.s Просмотреть файл

@@ -870,123 +870,86 @@ C_end_channel_state_loop:
870 870
         B       C_channel_state_loop
871 871
 
872 872
 C_main_mixer_return:
873
-        ADR     R0, C_downsampler
874
-        BX      R0
873
+    ADR     R5, V_noise_shape
874
+    LDRB    R4, [R5, #0]            @ left noise shape
875
+    LSL     R4, R4, #16
876
+    LDRB    R5, [R5, #1]            @ right noise shape
877
+    LSL     R5, R5, #16
878
+    ADR     R0, C_downsampler
879
+    BX      R0
880
+
881
+
882
+V_noise_shape:
883
+    .byte 0, 0
875 884
 
876 885
     .arm
877 886
     .align  2
878 887
 
879 888
 C_downsampler:
880
-    LDR     R4, =0xFFF80035
881
-    LDR     R5, =0x0034FFF8
882 889
     LDR     R8, [SP, #ARG_FRAME_LENGTH]
883 890
     LDR     R9, [SP, #ARG_BUFFER_POS]
884 891
     LDR     R10, hq_buffer
885 892
     MOV     R11, #0xFF000000
893
+    MOV     LR, #0xC0000000
886 894
 
887 895
 C_downsampler_loop:
888 896
         LDMIA   R10, {R0, R1, R2, R3}
889
-
890
-        MOV     R12, R0             @ left sample #1
891
-        CMP     R12, #0x40000000
892
-        MOVGE   R12, #0x3FC00000
893
-        CMP     R12, #-0x40000000
894
-        MOVLT   R12, #-0x40000000
897
+        ADD     R12, R4, R0         @ left sample #1
898
+        ADDS    R4, R12, R12
899
+        EORVS   R12, LR, R4, ASR#31
900
+        AND     R4, R12, #0x007F0000
895 901
         AND     R6, R11, R12, LSL#1
896 902
 
897
-        MOV     R0, R0, LSL#16      @ right
898
-        CMP     R0, #0x40000000
899
-        MOVGE   R0, #0x3FC00000
900
-        CMP     R0, #-0x40000000
901
-        MOVLT   R0, #-0x40000000
903
+        ADD     R0, R5, R0, LSL#16  @ right
904
+        ADDS    R5, R0, R0
905
+        EORVS   R0, LR, R5, ASR#31
906
+        AND     R5, R0, #0x007F0000
902 907
         AND     R7, R11, R0, LSL#1
903 908
 
904
-        MOV     R12, R1             @ left sample #2
905
-        CMP     R12, #0x40000000
906
-        MOVGE   R12, #0x3FC00000
907
-        CMP     R12, #-0x40000000
908
-        MOVLT   R12, #-0x40000000
909
+        ADD     R12, R4, R1         @ left sample #2
910
+        ADDS    R4, R12, R12
911
+        EORVS   R12, LR, R4, ASR#31
912
+        AND     R4, R12, #0x007F0000
909 913
         AND     R12, R11, R12, LSL#1
910 914
         ORR     R6, R12, R6, LSR#8
911 915
 
912
-        MOV     R1, R1, LSL#16      @ right
913
-        CMP     R1, #0x40000000
914
-        MOVGE   R1, #0x3FC00000
915
-        CMP     R1, #-0x40000000
916
-        MOVLT   R1, #-0x40000000
916
+        ADD     R1, R5, R1, LSL#16  @ right
917
+        ADDS    R5, R1, R1
918
+        EORVS   R1, LR, R5, ASR#31
919
+        AND     R5, R1, #0x007F0000
917 920
         AND     R1, R11, R1, LSL#1
918 921
         ORR     R7, R1, R7, LSR#8
919 922
 
920
-        MOV     R12, R2             @ left sample #3
921
-        CMP     R12, #0x40000000
922
-        MOVGE   R12, #0x3FC00000
923
-        CMP     R12, #-0x40000000
924
-        MOVLT   R12, #-0x40000000
923
+        ADD     R12, R4, R2         @ left sample #3
924
+        ADDS    R4, R12, R12
925
+        EORVS   R12, LR, R4, ASR#31
926
+        AND     R4, R12, #0x007F0000
925 927
         AND     R12, R11, R12, LSL#1
926 928
         ORR     R6, R12, R6, LSR#8
927 929
 
928
-        MOV     R2, R2, LSL#16      @ right
929
-        CMP     R2, #0x40000000
930
-        MOVGE   R2, #0x3FC00000
931
-        CMP     R2, #-0x40000000
932
-        MOVLT   R2, #-0x40000000
930
+        ADD     R2, R5, R2, LSL#16  @ right
931
+        ADDS    R5, R2, R2
932
+        EORVS   R2, LR, R5, ASR#31
933
+        AND     R5, R2, #0x007F0000
933 934
         AND     R2, R11, R2, LSL#1
934 935
         ORR     R7, R2, R7, LSR#8
935 936
 
936
-        MOV     R12, R3             @ left sample #4
937
-        CMP     R12, #0x40000000
938
-        MOVGE   R12, #0x3FC00000
939
-        CMP     R12, #-0x40000000
940
-        MOVLT   R12, #-0x40000000
937
+        ADD     R12, R4, R3         @ left sample #4
938
+        ADDS    R4, R12, R12
939
+        EORVS   R12, LR, R4, ASR#31
940
+        AND     R4, R12, #0x007F0000
941 941
         AND     R12, R11, R12, LSL#1
942 942
         ORR     R6, R12, R6, LSR#8
943 943
 
944
-        MOV     R3, R3, LSL#16      @ right
945
-        CMP     R3, #0x40000000
946
-        MOVGE   R3, #0x3FC00000
947
-        CMP     R3, #-0x40000000
948
-        MOVLT   R3, #-0x40000000
944
+        ADD     R3, R5, R3, LSL#16  @ right
945
+        ADDS    R5, R3, R3
946
+        EORVS   R3, LR, R5, ASR#31
947
+        AND     R5, R3, #0x007F0000
949 948
         AND     R3, R11, R3, LSL#1
950 949
         ORR     R7, R3, R7, LSR#8
951 950
 
952
-        @LDR     R12, [R9, #0x630]    @ left
953 951
         STR     R6, [R9, #0x630]
954
-        @LDR     R6, [R9]            @ right
955 952
         STR     R7, [R9], #4
956
-
957
-        @MOVS    R7, R12, ASR#24
958
-        @ADDMI   R7, R7, #1
959
-        @MUL     R3, R4, R7
960
-        @MOVS    R7, R6, ASR#24
961
-        @ADDMI   R7, R7, #1
962
-        @MLA     R3, R5, R7, R3
963
-        @MOV     R12, R12, LSL#8
964
-        @MOV     R6, R6, LSL#8
965
-
966
-        @MOVS    R7, R12, ASR#24
967
-        @ADDMI   R7, R7, #1
968
-        @MUL     R2, R4, R7
969
-        @MOVS    R7, R6, ASR#24
970
-        @ADDMI   R7, R7, #1
971
-        @MLA     R2, R5, R7, R2
972
-        @MOV     R12, R12, LSL#8
973
-        @MOV     R6, R6, LSL#8
974
-
975
-        @MOVS    R7, R12, ASR#24
976
-        @ADDMI   R7, R7, #1
977
-        @MUL     R1, R4, R7
978
-        @MOVS    R7, R6, ASR#24
979
-        @ADDMI   R7, R7, #1
980
-        @MLA     R1, R5, R7, R1
981
-        @MOV     R12, R12, LSL#8
982
-        @MOV     R6, R6, LSL#8
983
-
984
-        @MOVS    R7, R12, ASR#24
985
-        @ADDMI   R7, R7, #1
986
-        @MUL     R0, R4, R7
987
-        @MOVS    R7, R6, ASR#24
988
-        @ADDMI   R7, R7, #1
989
-        @MLA     R0, R5, R7, R0
990 953
         MOV     R0, #0
991 954
         MOV     R1, #0
992 955
         MOV     R2, #0
@@ -997,6 +960,7 @@ C_downsampler_loop:
997 960
         SUBS    R8, #4
998 961
         BGT     C_downsampler_loop
999 962
 
963
+    ADR     R1, V_noise_shape
1000 964
     ADR     R0, (C_downsampler_return+1)
1001 965
     BX      R0
1002 966
 
@@ -1006,6 +970,10 @@ C_downsampler_loop:
1006 970
     .thumb
1007 971
 
1008 972
 C_downsampler_return:
973
+    LSR     R4, #16
974
+    STRB    R4, [R1, #0]
975
+    LSR     R5, #16
976
+    STRB    R5, [R1, #1]
1009 977
     LDR     R0, [SP, #ARG_PCM_STRUCT]
1010 978
     LDR     R3, mixer_finished_status           @ this is used to indicate the interrupt handler the rendering was finished properly
1011 979
     STR     R3, [R0]

+ 0
- 24
src/music/titlescreen.s Просмотреть файл

@@ -1,24 +0,0 @@
1
-#include <constants/pkmns.h>
2
-
3
-.text
4
-.thumb
5
-
6
-.global titlescreen_cry_id_override
7
-
8
-.align 2
9
-
10
-titlescreen_cry_id_override:
11
-    //ldr     r0, =PKMN_DEOXYS
12
-    //mov     r1, #0
13
-    //ldr     r2, =0x08071DF0+1       // cry_related
14
-    //bl      _call_via_r2
15
-    mov     r0, #80
16
-    ldr     r1, =m4aSongNumStart
17
-    bl      _call_via_r1
18
-    ldrb    r0, [r4, #0xC]
19
-    ldr     r1, =0x080791F8+1       // hook return address
20
-    bx      r1
21
-
22
-.align 2
23
-_call_via_r1:
24
-    bx      r1