(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
05-20-24 01:09 AM
0 users currently in ROM Hacking.
Acmlm's Board - I3 Archive - ROM Hacking - Making Lightning flash in certain levels of Super Mario Bros. 3
  
User name:
Password:
Reply:
 
Options: - -
Quik-Attach:
Preview for more options

Max size 1.00 MB, types: png, gif, jpg, txt, zip, rar, tar, gz, 7z, ace, mp3, ogg, mid, ips, bz2, lzh, psd

UserPost
DahrkDaiz
Posts: 218/403
exactly, part of being a rom hcker is deciphering someone else's code, even if that someone else is the original programmer or another rom hacker
never-obsolete
Posts: 25/79
you shouldn't have to. if someone wants to copy/paste your code, they should at least have the understanding to figure out what it means.
DahrkDaiz
Posts: 216/403

$A100: AD 41 7B LDA $7B41 = #$0F
$A103: C9 0F CMP #$0F
$A105: F0 01 BEQ $A108
$A107: 60 RTS
$A108: AD C2 7D LDA $7DC2 = #$20
$A10B: F0 03 BEQ $A110
$A10D: 4C 1C A1 JMP $A11C
$A110: CE C1 7D DEC $7DC1 = #$00
$A113: F0 01 BEQ $A116
$A115: 60 RTS
$A116: A9 20 LDA #$20
$A118: 8D C2 7D STA $7DC2 = #$20
$A11B: 60 RTS
$A11C: 29 02 AND #$02
$A11E: D0 09 BNE $A129
$A120: AD EC 7D LDA $7DEC = #$0F
$A123: 8D CF 07 STA $07CF = #$0F
$A126: 4C 2E A1 JMP $A12E
$A129: A9 30 LDA #$30
$A12B: 8D CF 07 STA $07CF = #$0F
$A12E: CE C2 7D DEC $7DC2 = #$20
$A131: D0 5A BNE $A18D
$A133: A9 01 LDA #$01
$A135: 8D C6 7F STA $7FC6 = #$00
$A138: 8D C7 7F STA $7FC7 = #$00
$A13B: 8D C8 7F STA $7FC8 = #$00
$A13E: A5 FC LDA $FC = #$EF
$A140: 8D BF 05 STA $05BF = #$E4
$A143: 8D C0 05 STA $05C0 = #$E3
$A146: 8D C1 05 STA $05C1 = #$E4
$A149: A9 00 LDA #$00
$A14B: 8D D5 7F STA $7FD5 = #$01
$A14E: A9 00 LDA #$00
$A150: 8D D6 7F STA $7FD6 = #$01
$A153: 8D D7 7F STA $7FD7 = #$01
$A156: A5 90 LDA $90 = #$CA
$A158: 69 80 ADC #$80
$A15A: EA NOP
$A15B: EA NOP
$A15C: 8D C9 05 STA $05C9 = #$1B
$A15F: A5 90 LDA $90 = #$CA
$A161: 8D CA 05 STA $05CA = #$9A
$A164: A5 90 LDA $90 = #$CA
$A166: 65 6D ADC $6D = #$BD
$A168: EA NOP
$A169: EA NOP
$A16A: 8D CB 05 STA $05CB = #$43
$A16D: A9 00 LDA #$00
$A16F: 8D DD 05 STA $05DD = #$00
$A172: 8D DE 05 STA $05DE = #$00
$A175: 8D DF 05 STA $05DF = #$00
$A178: A9 01 LDA #$01
$A17A: 8D D3 05 STA $05D3 = #$6F
$A17D: 8D D4 05 STA $05D4 = #$6F
$A180: 8D D5 05 STA $05D5 = #$6F
$A183: A9 4E LDA #$4E
$A185: 8D 1D 07 STA $071D = #$4E
$A188: A9 80 LDA #$80
$A18A: 8D C1 7D STA $7DC1 = #$00
$A18D: 60 RTS


There's my routine... I don't feel like going through and commenting the code : \
never-obsolete
Posts: 22/79
it cant just be in any place with $FF's, it has to be in the currently loaded bank at the time you want to use the code. the nes can only address up to 32kb of prg at any given time. to get around this mappers switch in what prg-banks are loaded into that 32kb space. it does you no good to paste the routine in, if its not loaded when you call it.

your best bet is to find out which bank is hardwired into prg-rom at all times, and find somewhere to paste it there so its loaded at all times. you may or may not be able to do that though.
Giga_Bowser_009
Posts: 19/57
Aha! So if I paste JaSp's code somewhere in the prg-bank where there is a bunch of FF's and it will work? I'm going to try that.
never-obsolete
Posts: 21/79
if you are pasting someones routine into your hack, you have to make sure it is in the prg-bank that will be loaded when the routine is called or else its gonna jump to that address, but the code there will not be what u want and some unforseen things will happen. remember not all the prg/chr is "visible" to nes, only whatever the mmc3 has swapped in is.
Giga_Bowser_009
Posts: 18/57
Exactly. And I still haven't got it to work. Are there other custom ASM routines for the Lightning effects? Because I still don't have it in the levels I wanted yet. DahrkDaiz, what did you do to make the thunder flashes in certain levels of your hack? It might give me a clue on what to do.
richyawyingtmv
Posts: 147/294
Originally posted by Remoga Sanctum
So, I may be a noob but will this still work with SMW hacks?


Incase you hadn't realised, this is for Super Mario Bros 3. Therefore, the answer is no.
Deleted User
Posts: 30/-7750
So, I may be a noob but will this still work with SMW hacks?
never-obsolete
Posts: 19/79
agreed
DahrkDaiz
Posts: 209/403
yes but disabling NMI in SMB3 is rather dangerous since there are SO many writes to the PPU during Vblank (updating the status bar, updating the palette, drawing new tiles when scrolling) a simple check for the right bank by testing a byte suffices though
HyperHacker
Posts: 2008/5072
Can you not just disable the interrupt?
never-obsolete
Posts: 18/79
yes ive already taken the NMI into account because ive had similar promblems with different mappers. i had a the nmi check for what the "original" banks should be and switch them, and then just before the rti, switch back.
DahrkDaiz
Posts: 207/403
Originally posted by never-obsolete
well after looking at the mmc3 specs, i believe it is able to support adding more prg and chr banks. if i calculated correctly smb3 only uses half of its potential in both catagories. bank switching would allow more room to toy with and its not that difficult to do.


Just know I've already expected SMB3 to double it's size and bank swapping is not as easy as you think only because if you start adding enough code, then SMB3 will have executed SO much code that there's a small potential for Vblank to occur mid-bank swap, which basically means your game crashes at random moments (anyone who's beta tested Mario Adventure 2 can attest to this) so you have to figure a way to get around this (I did a small byte check in the PRG bank I was wanting to switch to, if that byte did not match what it should be, attempt to bank swap again.)
JaSp
Posts: 48/89
$7DB2 is originally part of player2 offsets, it's increased here so that with another custom routine placed somewhere else, when it's equal to 01 it plays the sound; I couldn't write directly to the original sound offsets in that part of the ROM because they were zeroed and thus the sound wouldn't play.
$E2C0 is a subroutine called somewhere in the ROM, that's where I placed my custom JSR $BF10, so I re-placed a JSR $E2C0 at the end of my routine, but it isn't related to my routine.
You're right with the sprites. Actually, the colors are defined by the offset $7DB5 : according to its value, a different table of colors is loaded for the flashing routine (the table is custom, it wasn't originally in the game).
never-obsolete
Posts: 17/79
where you reference the sound register (which is what im guessing it is):

    inc $7DB2


is that something in original code that needed to be added, or what purpose does it serve? and does the routine at $E2C0 have any effect on the flashing or is something else i shouldn't be concerned with?

and if the sprite = $AB, then its the color flash, if sprite = $47 its the white/grey flash?

in your hack im assuming you enabled sram.
JaSp
Posts: 47/89
Well, here is my routine with a few coments. It might not be the best anyway because I'm not that good at cleaning up code. If you have any questions, feel free to ask.

$BF10:AD 41 7B * LDA $7B41 = #$AB ; $7B41 is the address of the first sprite in a level
$BF13:C9 AB * CMP #$AB ; checks if it is the sprite $AB
$BF15:D0 15 * BNE $BF2C ; if not, goes to $BF2C
$BF17:A5 15 * LDA $15 = #$6D
$BF19:29 F3 * AND #$F3
$BF1B:D0 0B * BNE $BF28
$BF1D:A9 10 * LDA #$10
$BF1F:8D FB 7C * STA $7CFB = #$00 ; $7CFB is an offset activating an already-existing flashing bg routine in the game, the value stored at it determines how long it flashes
$BF22:EE B2 7D * INC $7DB2 = #$00 ; this was to activate the sound later in the code; I couldn't directly write to any of the $4FX sounds addresses because they were zeroed after this routine before being read to play the sounds, if I remember right
$BF25:8D B5 7D * STA $7DB5 = #$10 ; $7DB5 is a custom-offset I used (replaced from a player2 related offset) to have different sets of colors for the flashing generated by $7CFB. That way in my hack there is a multicolor bg flashing & a white-grey bg flashing
$BF28:20 C0 E2 * JSR $E2C0 ; the routine I replaced (that was at $E738), placed at the end of the new routine
$BF2B:60 * RTS
$BF2C:AD 41 7B * LDA $7B41 = #$AB
$BF2F:C9 47 * CMP #$47 ; checks if it is the sprite $47 (this one activates the grey/white flashing)
$BF31:D0 F5 * BNE $BF28
$BF33:A5 15 * LDA $15 = #$6D
$BF35:29 DE * AND #$DE
$BF37:D0 EF * BNE $BF28
$BF39:A9 10 * LDA #$10
$BF3B:4C B6 BF * JMP $BFB6
(...)
$BFB6:8D FB 7C * STA $7CFB = #$00
$BFB9:EE B2 7D * INC $7DB2 = #$00
$BFBC:A9 00 * LDA #$00
$BFBE:8D B5 7D * STA $7DB5 = #$10
$BFC1:4C 25 BF * JMP $BF25

Note that with this way, it will flash regularly; I didn't bother to try it checking with two different offsets to create a random factor.
never-obsolete
Posts: 16/79
well after looking at the mmc3 specs, i believe it is able to support adding more prg and chr banks. if i calculated correctly smb3 only uses half of its potential in both catagories. bank switching would allow more room to toy with and its not that difficult to do.
Giga_Bowser_009
Posts: 17/57
I have enough unused space around the 003000 offset. I see a bunch FFs there so yeah. I have enough.
never-obsolete
Posts: 15/79
ok i see and you place that nothing as the first sprite in the levels you want to use the thunder. then you check against it and branch from there if it is nothing else contiue as normal. fair enough.

do you plan to use the routine i posted, because that was slapped together fairly hastily? also how much space in unused rom do you have for adding the routine?
This is a long thread. Click here to view it.
Acmlm's Board - I3 Archive - ROM Hacking - Making Lightning flash in certain levels of Super Mario Bros. 3


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.003 seconds; used 373.78 kB (max 437.02 kB)