An error has been found in the tutorials of Adding the Goggles Monitor to work with in LZ. I recently found this out by using the Full Tutorial given. The error occurs where the branch is inserted in the final steps. Link found here: Sonic 1: How to get the Goggles monitor to work Executing from SN68k v2.53 SN 68k version 2.53 F:\SONICRETRO.ORG\SONED2\S1\SONIC1.ASM(25439) : Error : Branch (136 bytes) is out of range Assembly completed. 1 error(s) from 47456 lines in 15.23 seconds Lightning's ROM Padder Reported Size: 0 Reported Checksum: 0 Size applied: 7F Checksum Applied: 0 Press any key to continue . . . This is an addition to where I added the code. I followed it exactly to the point where it told me to use Obj10A_GoMakeItem. Code Where Error occurrs: Obj2E_ChkS: cmpi.b #7,d0 ; does monitor contain 'S' -> bne.s Obj2E_ChkGoggles nop Obj2E_ChkGoggles: -> cmpi.b #8,d0 ; does monitor contain 'GoggleS' -> bne.s Obj2E_ChkEnd; if not, branch to Goggle code -> move.b #1,($FFFFFFFB).w ; move 1 to the goggle check Obj0A_ReduceAir: -> tst.b ($FFFFFFFB).w ; was a goggle monitor broken? ==> beq.s Obj0A_GoMakeItem ; if yes, branch subq.w #1,($FFFFFE14).w ; subtract 1 from air remaining bcc.w Obj0A_GoMakeItem ; if air is above 0, branch bsr.w ResumeMusic move.b #$81,($FFFFF7C8).w ; lock controls move.w #$B2,d0 jsr (PlaySound_Special).l ; play drowning sound move.b #$A,$34(a0) move.w #1,$36(a0) move.w #$78,$2C(a0) move.l a0,-(sp) lea ($FFFFD000).w,a0 bsr.w Sonic_ResetOnFloor move.b #$17,$1C(a0) ; use Sonic's drowning animation bset #1,$22(a0) bset #7,2(a0) move.w #0,$12(a0) move.w #0,$10(a0) move.w #0,$14(a0) move.b #1,($FFFFF744).w movea.l (sp)+,a0 rts Key -> Line inserted that works ==> Line inserted that gives source error If I comment the line that branches to GoMakeItem, then the compiler is okay, if I don't, then the compiler complains and exits on command. For this reason, I added "Pause" as a command to my cmd batch to see the error. Could you please help me to find the correct code as I want to insert a goggle monitor into LZ of Sonic 1. If the fault is on me, could you direct me to fixing the code myself. Thanks for the effort
This. Also, I'm gonna update that tutorial by removing those extensions. They are unnecessary (because the assembler can automatically add them) and only cause trouble.
That's fine, but inserting code can cause existing branches to get out of range. A page explaining how to fix some commonly occurring errors would be more generally useful. I added a section about branch out of range errors in one of my guides because there was no such resource.
Wrong, there are loads of guides telling how to fix the out of range error, including these two (both are very old, yes, but you get the point): - http://forums.sonicretro.org/index.php?showtopic=17016 - http://sonicresearch.org/forums/index.php?showtopic=857
Thanks, the code works now. I also noted that in the tutorial, after the code ($FFFFFFA0) is inserted, the tutorial tells you to paste the code ($FFFFFFFB), which is incorrect. The code ($FFFFFFFB) causes the monitor to activate debug mode for some odd reason. I had to recode the assembly in order to have the goggles to work. So now they do. Thanks again for the efforts to fix the code
I'm the kind of guy who tends to invent his own solution before looking for existing ones, so sorry that I overlooked that; I only knew there was no page dedicated to this on Sonic Retro's wiki. I think it would be more accessible if it was in a wiki article: instead of reading a topic that has the initial information (possibly edited, if the author bothered) in the first post and additions or corrections (or random chatter) in subsequent posts, you just read an article that integrates the correct information and leaves out information that was initially incorrect.
The Sonic 1 disassembly lets you use a jeq instruction (actually a macro), which is like beq except it's never out of range.
Now, THAT is very cool! Maybe have to add that in the Sonic 2 disassembly, if it is not there already.
Hey thanks, Hivebrain, I suppose this should go into the SCHG wiki of basic ASM hacking as well, this code can be useful for error-tracing and handling.