Language…
16 users online:  Ahrion, CroNo, Dennsen86, Golden Yoshi, Green Jerry, Hammerer,  Lazy, MellyMellouange, Metal-Yoshi94, mtheordinarygamer, Nayfal, Neuromancer, OrangeRock57, signature_steve, slopcore, Sweetdude - Guests: 350 - Bots: 367
Users: 64,795 (2,370 active)
Latest user: mathew

SMW enabling MSU-1 by Con

File Name: SMW enabling MSU-1
Submitted: 07/2/2015 21:02:42 by Con
Authors: Con
Tool: xkas
Requires Free Space: Yes
Bug Fix: No
Featured: No
Description: This patch enables CD-Quality audio streaming via MSU-1 - this patch works on bsnes, higan and sd2snes.



Example video:

https://www.youtube.com/watch?v=SZkbchA67Fc





04/04/15: New version: sd2snes bugfix


While the patch supposedly works in intended in-game, unfortunately I will have to remove this because this patch is pretty poorly coded and dangerous.

First of all, you hijacked and put all MSU-1 code exactly where SMW updates the I/O ports, which runs on NMI. While I can't blame you since Nintendo had the silly idea of putting on NMI, you should move the code to around main loop instead or when loading some songs you will see a huge black bar for a split second and you know why it appears: the NMI resumes in a middle of frame, forcing half of screen to be on f-blank. This problem can be seen in the video you linked on description.

Second, you placed all the custom code in a unused area of ROM instead of using freespace. While in-game it will change absolutely nothing, it is not recommended to write a huge amount of code on a empty area since soon or later Lunar Magic, the SMW editor or even something else, can have the idea of putting the code on same place you placed. So yeah, please place your code in a freespace area instead. Together with that, I suggest you converting your patch to Asar format, which you can only have to use "autoclean" on your JSL and freecode, which automatically protects and allocates your code into a freespace area.

"But what about the .ips support?" -> IPSes aren't recommended anyway for the reasons stated above so don't even make one anymore.

Third, the patch itself is pretty poorly written. You often used branches (BEQ, BNE, BRA, etc.) using direct values, which can make the code unaligned if someone decide it to edit for some reason. And it's much better to view and edit if you label them anyway. But the worse is on the following codes:

Code
org $04efc0   ; select if track is looped. All tracks which are sfx are not looped:
; http://www.smwcentral.net/?p=viewthread&t=6665


LDA $1DFB 
CMP #$08       ; check head bowser valley entrance theme
BNE proceed
LDA $D0 ; check overworld
Beq $03
LDA #$03              
RTS
LDA #$01; we are at overworld so don't loop              
RTS  

proceed:
CMP #$09               	;mario died
BNE proceed2    		
LDA $D0 ; check overworld
Beq $03
LDA #$01              
RTS
LDA $70
CMP #$7E
BNE secrets
LDA #$01    ; we are at credits              
RTS
secrets:
LDA #$03              
RTS           

proceed2:
CMP #$0A             	; game over
BNE $03   
LDA #$01        
RTS                 
CMP #$0B             	; passed boss
BNE $03   
LDA #$01         
RTS              
CMP #$0C  		; passed Level      
BNE $03    
LDA #$01       
RTS                
CMP #$0F   		; Into keyhole       
BNE $03    
LDA #$01       
RTS            
CMP #$10   		; into keyhole       
BNE $03    
LDA #$01          
RTS              
CMP #$11        	; Zoom in
BNE $03    
LDA #$01         
RTS              
CMP #$13           	; Welcome!
BNE $03    
LDA #$01         
RTS             
CMP #$14         	;Done bonus game
BNE $03   
LDA #$01         
RTS            
CMP #$15        	;rescue egg
BNE $03   
LDA #$01        
RTS             
CMP #$17           	;Bowser Zoom out
BNE $03    
LDA #$01        
RTS              
CMP #$18   		;bowser zoom in        
BNE $03   
LDA #$01         
RTS            
CMP #$1B  		;Bowser died      
BNE $03    
LDA #$01          
RTS              
CMP #$1C   		;Princess kiss     
BNE $03    
LDA #$01         
RTS             
CMP #$1D         	;Bowser Interlude
BNE $03    
LDA #$01 
RTS
LDA #$03         	;loop all other tracks
RTS


You can simply replace most of the CMP-BNE chain with a simple and fast table, also using a table you can even make the user able to make some songs don't loop!

Or just think logically and do a simple code like p4plus2 suggested:

Code
[00:06:30] <p4plus2> CMP #$0A
[00:06:30] <p4plus2> BCC skip
[00:06:30] <p4plus2> CMP #$1D
[00:06:30] <p4plus2> BCS skip
[00:06:30] <p4plus2> lda #$01
[00:06:30] <p4plus2> RTS
[00:06:30] <p4plus2> skip:
[00:06:30] <p4plus2> LDA #$03
[00:06:30] <p4plus2> RTS


------------------------

Code
org $04f060 ; check if music bank needs switched
LDA $D0 ; 
BEQ overworld
LDA $04a0
bne level
LDA $04a1
bne level

overworld:  
  
LDA $1dfb
CMP #$01   		;title screen     
BNE $05    
LDA #$1e         
jmp continue2 
CMP #$02   		;ow2     
BNE $05    
LDA #$1f         
jmp continue2
CMP #$03   		;ow3     
BNE $05    
LDA #$20         
jmp continue2
CMP #$04   		;ow4     
BNE $05    
LDA #$21         
jmp continue2
CMP #$05   		;ow5     
BNE $05    
LDA #$22         
jmp continue2 
CMP #$06   		;ow6     
BNE $05    
LDA #$23         
jmp continue2 
CMP #$07   		;ow7     
BNE $05    
LDA #$24         
jmp continue2 
CMP #$08   		;ow8     
BNE $05    
LDA #$25         
jmp continue2  
CMP #$09   		;ow9     
BNE level    
LDA $70
CMP #$7E
BNE ow
LDA #$27
jmp continue2
ow:
LDA #$26         
jmp continue2 


level:
LDA $1DFB

CMP #$0A
bne playend2
lda $70
cmp #$7e      ; are we at credits?
beq $03
jmp continue1
LDA #$28
jmp continue2

playend2:
CMP #$0B
BEQ $03
jmp continue1
lda $70
cmp #$7e           ; are we at credits?
beq $03
jmp continue1
LDA #$29
jmp continue2


Same for here. Either make it a table or:

Code
[00:09:50] <p4plus2> OW code:
[00:09:51] <p4plus2> LDA $1DFB
[00:09:51] <p4plus2> ;add the *exceptions* here, the rest follow this pattern
[00:09:51] <p4plus2> CLC
[00:09:51] <p4plus2> ADC #$1D


Last but not relevant, decide at once if you're gonna write the code into upper or lowercase. :P

Continuing...
------------------------------------------

Fourth, time for minor but still 10% removal worthy problems:

1. You recommended bsnes v070 to use MSU-1, but you didn't add any workaround for the lack of support of "audio is missing" flag only present on most recent versions of bsnes and sd2snes. I don't think it will be a good idea to add .pcm values of SMW songs if you simply can play using the SPC engine itself. I recommend making a table where you can force certain songs to use SMW engine instead of MSU-1.

2. You created an IPS patch that changes the volume if you're gonna play the game with bsnes (or if it's too loud). But why? All games have the same volume regardless of emulator, so you shouldn't make emulator specific changes. I recommend you sticking with a fixed volume, for both emulators and sd2snes. The average SMW volume anyway is around 50%, so stick with MSU-1 volume 0x80. It will also prevent from some SFX being quieter than the song itself.

3. Also talking about MSU-1 volume, don't make the tracks change too suddenly or there's a chance of you hearing a *click* sound, which may be annoying for some people. I recommend you implementing a fade-out system which reduces the MSU-1 volume smoothly (but quickly of course) to zero before changing any song. You don't need to do that of course, but that's just a suggestion.

4. Another thing is, it would be good if you made this patch compatible with AddmusicK. Be sure to check "asm/patch.asm" on AMK folder and edit it to add your MSU-1 implementation. It would be cool to the hack still have some custom music even if the user isn't playing on bsnes or sd2snes. Remember, people will be using this patch and lot of people, with different profiles, may play his/her hack with different emulators. Again, this is not needed, but it would be interesting for a future update.


That's all. Fix the major ones (First/second/third) and I may approve this patch.