Commit 33cd38f1 authored by ROOL's avatar ROOL :robot:
Browse files

Give workspace locations symbolic names

Detail:
  Describe the workspace locations relative to R12 and replace their uses
  at sites with LDR/STR and ADR.
  This fixes a significant bug where the SharedSound handle was being stored at
  a random offset depending on the contents of R8 rather than at offset 8
  within the workspace. Most likely a missing # in the original BASIC sources
  (so [R12,wksp_ss_handle] => [R12,R8]).
No related merge requests found
...@@ -47,6 +47,15 @@ XSharedSound_RemoveHandler * &6B441 ...@@ -47,6 +47,15 @@ XSharedSound_RemoveHandler * &6B441
SharedSound_InstallHandler * &4B440 SharedSound_InstallHandler * &4B440
XSharedSound_InstallHandler * &6B440 XSharedSound_InstallHandler * &6B440
^ 0, R12
wksp_size # 4
wksp_pw # 4
wksp_ss_handle # 4
wksp_buffer_ptr # 4
wksp_live_weights # 5*4
reverb_buffer # &8000
reverb_wkspace_size * :INDEX:@
;;---------------------------------------------------------------------------- ;;----------------------------------------------------------------------------
;; Module header ;; Module header
;;---------------------------------------------------------------------------- ;;----------------------------------------------------------------------------
...@@ -66,7 +75,7 @@ ReverbOff_Syntax ...@@ -66,7 +75,7 @@ ReverbOff_Syntax
DCD 0 ; SWI handler code offset DCD 0 ; SWI handler code offset
DCD 0 ; SWI decoding table offset DCD 0 ; SWI decoding table offset
DCD 0 ; SWI decoding code offset DCD 0 ; SWI decoding code offset
DCB " Expressive Software Projects, Nottingham. (17 Aug 1997)" DCB " Expressive Software Projects, Nottingham."
Mod_Title Mod_Title
DCB "SoundReverb", 0 DCB "SoundReverb", 0
ALIGN ALIGN
...@@ -76,22 +85,24 @@ Mod_HelpStr ...@@ -76,22 +85,24 @@ Mod_HelpStr
Mod_Init ROUT Mod_Init ROUT
Push "R0-R12,R14" Push "R0-R12,R14"
LDR R3,reverb_buffer_size LDR R3,=reverb_wkspace_size
MOV R0,#ModHandReason_Claim MOV R0,#ModHandReason_Claim
SWI XOS_Module SWI XOS_Module
STR R2,[R12,#0]
BVS %FT90 BVS %FT90
STR R2,[R12] ; The OS will free that on die
MOV R10,R12 MOV R10,R12
MOV R12,R2 MOV R12,R2
STR R3,[R12,#0] STR R3,wksp_size
STR R10,[R12,#4] STR R10,wksp_pw
MOV R0,#0 MOV R0,#0
STR R0,[R12,R8] STR R0,wksp_ss_handle
MOV R0,#5 MOV R0,#5
; Copy and relocate offsets to live set
ADR R1,reverb_weights ADR R1,reverb_weights
ADD R2,R12,#&10 ADR R2,wksp_live_weights
ADD R3,R12,#&24 ADR R3,reverb_buffer
LDMIA R1,{R4-R8} LDMIA R1,{R4-R8}
ADD R4,R4,R3 ADD R4,R4,R3
ADD R5,R5,R3 ADD R5,R5,R3
...@@ -99,9 +110,11 @@ Mod_Init ROUT ...@@ -99,9 +110,11 @@ Mod_Init ROUT
ADD R7,R7,R3 ADD R7,R7,R3
ADD R8,R8,R3 ADD R8,R8,R3
STMIA R2,{R4-R8} STMIA R2,{R4-R8}
ADD R1,R12,#&24 ADR R1,reverb_buffer
STR R1,[R12,#12] STR R1,wksp_buffer_ptr
MOV R2,#&8000
; Fill buffer with zero
MOV R2,#?reverb_buffer
MOV R3,#0 MOV R3,#0
MOV R4,#0 MOV R4,#0
MOV R5,#0 MOV R5,#0
...@@ -166,12 +179,12 @@ ReverbOff_Code ...@@ -166,12 +179,12 @@ ReverbOff_Code
install_ss_handler install_ss_handler
Push "R0-R12,R14" Push "R0-R12,R14"
ADR R0,reverb_proc ADR R0,reverb_proc
LDR R1,[R12,#4] LDR R1,wksp_pw
MOV R2,#1 MOV R2,#1
ADR R3,handler_name ADR R3,handler_name
MOV R4,#2 MOV R4,#2
SWI SharedSound_InstallHandler SWI SharedSound_InstallHandler
STR R0,[R12,R8] STRVC R0,wksp_ss_handle
Pull "R0-R12,PC" Pull "R0-R12,PC"
handler_name handler_name
DCB "Reverb processing", 0 DCB "Reverb processing", 0
...@@ -179,12 +192,12 @@ handler_name ...@@ -179,12 +192,12 @@ handler_name
remove_ss_handler ROUT remove_ss_handler ROUT
Push "R0-R12,R14" Push "R0-R12,R14"
LDR R0,[R12,R8] LDR R0,wksp_ss_handle
CMP R0,#0 CMP R0,#0
BEQ %FT90 BEQ %FT90
SWI SharedSound_RemoveHandler SWI SharedSound_RemoveHandler
MOV R0,#0 MOV R0,#0
STR R0,[R12,R8] STR R0,wksp_ss_handle
90 90
Pull "R0-R12,PC" Pull "R0-R12,PC"
...@@ -193,52 +206,53 @@ remove_ss_handler ROUT ...@@ -193,52 +206,53 @@ remove_ss_handler ROUT
;;---------------------------------------------------------------------------- ;;----------------------------------------------------------------------------
reverb_proc ROUT reverb_proc ROUT
Push "R0-R12,R14" Push "R0-R12,R14"
LDR R12,[R0,#0] LDR R12,[R0,#0] ; Recover workspace from private word
ADD R0,R12,#&24 ADR R0,reverb_buffer
ADD R0,R0,#&8000 ADD R0,R0,#?reverb_buffer
ADD R3,R12,#&0C ADR R3,wksp_buffer_ptr
ASSERT wksp_buffer_ptr + 4 = wksp_live_weights
LDMIA R3,{R3-R8} LDMIA R3,{R3-R8}
10 10
LDR R9,[R1,#0] LDR R9,[R1,#0]
STR R9,[R3],#4 STR R9,[R3],#4
CMP R3,R0 CMP R3,R0
ADDEQ R3,R12,#&24 ADREQ R3,reverb_buffer
MOV R10,R9,ASR #16 MOV R10,R9,ASR #16
MOV R9,R9,LSL #16 MOV R9,R9,LSL #16
MOV R9,R9,ASR #16 MOV R9,R9,ASR #16
LDR R11,[R4],#4 LDR R11,[R4],#4
CMP R4,R0 CMP R4,R0
ADDEQ R4,R12,#&24 ADREQ R4,reverb_buffer
ADD R10,R10,R11,ASR #21 ADD R10,R10,R11,ASR #21
MOV R11,R11,LSL #16 MOV R11,R11,LSL #16
ADD R9,R9,R11,ASR #21 ADD R9,R9,R11,ASR #21
LDR R11,[R5],#4 LDR R11,[R5],#4
CMP R5,R0 CMP R5,R0
ADDEQ R5,R12,#&24 ADREQ R5,reverb_buffer
ADD R10,R10,R11,ASR #21 ADD R10,R10,R11,ASR #21
MOV R11,R11,LSL #16 MOV R11,R11,LSL #16
ADD R9,R9,R11,ASR #21 ADD R9,R9,R11,ASR #21
LDR R11,[R6],#4 LDR R11,[R6],#4
CMP R6,R0 CMP R6,R0
ADDEQ R6,R12,#&24 ADREQ R6,reverb_buffer
ADD R10,R10,R11,ASR #20 ADD R10,R10,R11,ASR #20
MOV R11,R11,LSL #16 MOV R11,R11,LSL #16
ADD R9,R9,R11,ASR #20 ADD R9,R9,R11,ASR #20
LDR R11,[R7],#4 LDR R11,[R7],#4
CMP R7,R0 CMP R7,R0
ADDEQ R7,R12,#&24 ADREQ R7,reverb_buffer
ADD R10,R10,R11,ASR #19 ADD R10,R10,R11,ASR #19
MOV R11,R11,LSL #16 MOV R11,R11,LSL #16
ADD R9,R9,R11,ASR #19 ADD R9,R9,R11,ASR #19
LDR R11,[R8],#4 LDR R11,[R8],#4
CMP R8,R0 CMP R8,R0
ADDEQ R8,R12,#&24 ADREQ R8,reverb_buffer
ADD R10,R10,R11,ASR #20 ADD R10,R10,R11,ASR #20
MOV R11,R11,LSL #16 MOV R11,R11,LSL #16
ADD R9,R9,R11,ASR #20 ADD R9,R9,R11,ASR #20
...@@ -250,12 +264,11 @@ reverb_proc ROUT ...@@ -250,12 +264,11 @@ reverb_proc ROUT
CMP R1,R2 CMP R1,R2
BNE %BT10 BNE %BT10
ADD R11,R12,#&0C ADR R11,wksp_buffer_ptr
ASSERT wksp_buffer_ptr + 4 = wksp_live_weights
STMIA R11,{R3-R8} STMIA R11,{R3-R8}
Pull "R0-R12,PC" Pull "R0-R12,PC"
reverb_buffer_size
DCD &8000+&24
reverb_weights reverb_weights
DCD &600 DCD &600
DCD &1F00 DCD &1F00
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment