| |||
Views: 88,434,013 |
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search | 04-19-24 02:30 AM |
|
Guest: Register | Login |
0 users currently in ROM Hacking | 3 guests | 2 bots |
Main - ROM Hacking - Need help with a practice hack - SMB Rain | New thread | New reply |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 35/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
I found a good SMB ROM, added 16K of CHR-ROM to it, and added Mapper 4 (MMC3). I changed the blank sky tile to this rain tile. Also, on the free CHR-ROM space I added, I copied that graphics bank and pasted it 3 more times, and changed the rain tile slightly in each one. Do you see where I'm going with this? I want to make 4-frame animation for the rain. I never did this before. I remember DahrkDaiz did this in a few of his hacks. I was wondering if I can get any advice or tips on how to finish this.
According to the mapper document, $8000 and $8001 are responsible for the bank switches and page numbers respectively. LDA #$02 ; Select 1K VROM page at PPU $1000 STA $8000 ; Store it LDA [Page Number Here] ; Select Page that will go into the 1K VROM page STA $8001 ; Store it I think what I'm stuck on, is where to put my code. I can write a loop that cycles through the pages, but there isn't a lot of free space as it is. But also, looking through SMB's code, I'm have a hard time just finding the code which stores the PPU $1000 VROM bank. Anyone have any suggestions on how I can make this work? This could be a fun learning experience, which is why I'm doing it. I'm going to keep working on this in the meantime. I got to keep trying to see if I can get it to work. ____________________ My YouTube Channel |
smkdan |
| ||
Ninji Level: 36 Posts: 94/238 EXP: 288477 Next: 19633 Since: 05-26-07 Last post: 4055 days Last view: 4004 days |
Why woud SMB1 store anything to 'the $1000 VROM bank'? It only has 8kb of CHR so it never needs to switch anything. The 8kb is always at $0000-$1FFF.
When I read the SMB disassembly, I didn't take notes on free space although you only need a few bytes to jump to a different bank. You could for example have a little chunk of code in free space and switch the bank which the new code is not located in. i.e. free space at $A000 and from there you can switch the bank at $8000-$9FFF, then jump to the appropriate address in your new PRG code. When you return from your new code you can restore the bank SMB1 expects to be there and it should behave fine. |
DahrkDaiz |
| ||
Nipper Plant Sandwich Artist Level: 46 Posts: 108/417 EXP: 674056 Next: 37718 Since: 02-22-07 Last post: 3479 days Last view: 3399 days |
My advice is to erase all the level and enemy data (or actually, relocate it to an expanded area in your rom) and use that space for needed bank swaps. Honestly, I would suggest using sprites instead of tile animated rain. Sprites move with the screen, you can have the rain change direction and it prevents the effect where the rain is miscolored on some tiles. |
Hamtaro126 |
| ||
Cheep-cheep Level: 33 Posts: 61/194 EXP: 212712 Next: 16467 Since: 05-02-07 From: Shelton, WA Last post: 2465 days Last view: 2308 days |
Posted by DahrkDaiz Level data to WRAM? Sounds like a good idea. But I should use MMC5 or something to use for levels. There are the limited number of sprites that are used ($0200-$02FF) and the NES allows only 8 sprites per scanline unless you use an emulator that disables the 8 sprite per scanline. ____________________ Mah boi, romhacking is what all true warriors strive for! I wonder what's for dinner? |
Ailure |
| ||
Hats Steam Board2 group Level: 121 Posts: 2277/3965 EXP: 19767527 Next: 289169 Since: 02-19-07 From: Sweden, Skåne Last post: 3294 days Last view: 2045 days |
Is it possible to give sprites a priotory? Then drops of water could be low-priotory.
Could always make sure to only have one raindrop per scanline, but make it's position randomized. That would look flickery, but might give impression of it being more rainy than it actually is. ____________________ AIM: gamefreak1337, MSN: Emil_sim@spray.se, XMPP: ailure@xmpp.kafuka.org
|
CKY-9K |
| ||
Pokey Level: 57 Posts: 322/693 EXP: 1429613 Next: 56315 Since: 06-27-07 From: cKy Last post: 203 days Last view: 111 days |
Think of the wind effect in SMB2j where there were leaves flying all over the place.
Also I hate Hamtaro. ____________________ |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 36/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
What I'm really stuck on right now, is the whole concept of bank switching. I'm just not getting it. I know how to do bank switching when I was programming my game from scratch, but I'm having a hard time when it comes to hacking. If anyone could provide some useful information on bank switching in ROM hacking, that would be awesome. ____________________ My YouTube Channel |
smkdan |
| ||
Ninji Level: 36 Posts: 97/238 EXP: 288477 Next: 19633 Since: 05-26-07 Last post: 4055 days Last view: 4004 days |
Is there a particular part that confuses you? You have to place some bankswitching code somewhere in the original code depending on when you want it to be run (you have to overwrite some original code that you need to include in your new code), and when you are done with your new code you need to restore the bank so that SMB can access data that was originally mapped there. |
never-obsolete |
| ||
Rat Level: 24 Posts: 14/96 EXP: 74452 Next: 3673 Since: 02-22-07 From: Phoenix, AZ Last post: 2589 days Last view: 2589 days |
this is the hook i used to add an in-game playbook editor to Tecmo Super Bowl (nes).
this first piece is where the game handles your menu choices, with my jump inserted ("jsr off_menu_p1"). there is also another similar code snippet that handles player 2.
now, depending on the calling player, code will jump to "off_menu_p1" or "off_menu_p2". $E1 and $E7 hold the index of the menu choice taken, for p1 and p2 respectively. "_off_menu_normal" is code that should be executed for original menu choices.
writing 7s to MMC3_CTRL and MMC3_DATA swap in the code banks needed by the playbook editor. the 7 and 15 swap back the bank that was there before. all code after the two PLA is for re-entry into the game's code. the most important thing is to return to the game's code with the NES in the same state it was before your code was executed. unless you know the game will swap in the proper banks (prg/chr) or will discard the register values. |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 37/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
I don't know. I'm not getting this because I'm probably retarded or something.
Alright, let me try to explain this, using a simpler game: SMB3. Last night, I got out a fresh SMB3 ROM. I added $8000 bytes of CHR-ROM at the end of the file. After that, I copied 8 1K CHR banks into that new free space. The 1K CHR bank I copied 8 times, is the one with the ? blocks and note blocks, coins, and munchers. So, I want to try to get 8-frame tile animation out of this. [][][][][][][][][][] = 1K VROM CHR Page PPU Viewer: [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] [][][][][][][][][][] So now that I got all of this out of the way, the next step is to add new code. Question 1: Where do I add the new code within $8000-$9FFF? Where exactly do I add it? I found some free space near the end of the bank (a bunch of FFs), but when I added code, it didn't do anything. I found a bunch of EAs (NOPs) in the middle of the bank, but when I paused the game, it locked it up. So, does it matter where you put the code within the bank? Question 2: If I put the swapping code too soon in the first bank, if I swap, and then swap back, how is it supposed to read the rest of the code without constantly swapping banks? Question 3: Is the code supposed to look something like this? (Using Mapper 4 - MMC3, SMB3 uses Mapper 4) LDA #$01 ; Second 2K VROM Page STA $8000 LDA [2K Graphics Page Here] STA $8001 This is the Second 2K VROM Page [][][][][][][][][][] [][][][][][][][][][] I'm typing from school right now, so if this is unclear, I will show pictures when I get home. But all of this is just practice. So I can have an understanding of how to do bank switching. I figure SMB3 is easier to work with for practicing, since it already has a mapper and a decent amount of free space, from the get go. Simpler Version: So, given the situation, the CHR-ROM is expanded, and 8 1K graphics pages are added to it, how do you go about swapping those in for 8 frame animation? Something else I forgot to ask. I want to try this with background tiles first, but if you use sprites, isn't there a limit to how many sprites you can have on the screen at one time? EDIT - I just thought of this. Could I just simply find the original code that is doing the bank switching for that second 2K VROM page, and just edit it to swap the new graphics pages in? ____________________ My YouTube Channel |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 38/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
Back to my SMB1 ROM, I copied all of the bytes from $9D70 to $AEDA to one of my free PRG banks. That is the enemy object data, and area object data. I'm putting code in place of that, but it is not working. I'm trying to swap in a different VROM page at PPU Address $1400. What could be the problem?
I'm using code like this: LDA #$03 STA $8000 LDA [VROM Page Here] STA $8001 I can't write a loop for the animation of tiles until I can get a page to show up. If I'm merely swapping CHR banks, this is all I need right? EDIT - I'm almost there! I know the code I am using is right now! See, instead of going with the rain, I decide to do 4-tile animation of ? block and coins, like in SMB3. I put my code at the beginning of $C000, and the game freezes, but I know that my code works! All I have to do is figure out the bank swapping, and I'm home free! ____________________ My YouTube Channel |
CKY-9K |
| ||
Pokey Level: 57 Posts: 333/693 EXP: 1429613 Next: 56315 Since: 06-27-07 From: cKy Last post: 203 days Last view: 111 days |
Good job!
Hope it works out for you. ____________________ |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 39/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
EDIT - I have the code for the 4-tile animation, and I figured out the bankswapping. Now all I have to do is put it all together. I'm having a hard time where to put my code and do the swapping, as working with level/enemy data isn't having any effect... ____________________ My YouTube Channel |
frantik |
| ||
Red Koopa Level: 28 Posts: 51/139 EXP: 127328 Next: 4010 Since: 10-09-07 Last post: 4482 days Last view: 4475 days |
If you're not planning on using the Castle looping effect in your hack, you can clear out quite a bit of space starting at $c06b ( 0x407b )
also the coin palette animation code is a good place to locate the tile animation code imo (it's around $89e1 ( 0x09f1 ) i'm not super familiair with MMC3 but it looks like at start up the only guarenteed bank which will be loaded is $A000 - $BFFF so perhaps the initialization code needs to go there? then once you set up the mapper you will know where the rest of the code can go |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 40/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
Based on everything else I have done, whatever code I use, I have to use it in the first bank, $8000-$9FFF. It won't work in other banks. Yeah frantik, I agree that a piece of already existing code will have to be overwritten to make this work. I also found flaws in my animation code when I was placing it in different areas of the ROM to test it. There's nothing really more stopping me, except the proper code for the tile animation.
This is my tile animation code for the ? Blocks btw, incase you're curious: LDA #$03 ; Selecting the VROM Page at PPU $1400 LDX #$05 ; VROM Page Number LDY #$04 ; How many times it goes through the loop, one for each frame. Loop: STA $8000 ; Store the VROM Page at PPU $1400 STX $8001 ; Store the VROM Page Number INX ; Increment X 4 Times, to get to the next VROM Page, the next frame. INX INX INX DEY ; Decrement the Loop by 1. BNE Loop ; If not zero, loop again, until all frames have been loaded. ____________________ My YouTube Channel |
frantik |
| ||
Red Koopa Level: 28 Posts: 52/139 EXP: 127328 Next: 4010 Since: 10-09-07 Last post: 4482 days Last view: 4475 days |
ok well if you need it to be in the first bank you will probably have enough room in the coin animation code to do whatever you like.
here's some code disch gave me for getting the right frame number.. you can use it with a little modification for a lot of mappers.. it's some very efficient code to get frame # for animation. not even sure if you can use it but if so cool lol.. i've used it for two diff mapper implementations LDA $09 ; load frame counter -- it's automatically incremented each frame by the engine LSR A LSR A LSR A ; right shift 3 times (divide by 8 ) -- makes it so a new page is selected every 8 frames AND #$03 ; mask out low 2 bits (produces 0,1,2,3,0,1,2,3,0,1,2,3,... repeating pattern) |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 41/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
Thanks for the code frantik. I have been experimenting with it. It definately does something. I am so close to what I want, but I'm not sure of the right code. I'm having a tough time with it. I can get 4-tile animation, but it is very flickery, because it is using pages I don't want it to use.
LDA #$03 STA $8000 LDA #$09 STA $8001 LDA $09 AND #$03 STA $8001 I have even used the LSRs, and all sorts of different remixes of the code you gave me, and nothing is getting me the results I want. PPU Viewer: [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] <----- PPU $1400 (LDA #$03 and STA $8000, We don't need to worry about this) [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] It is the LDA #$09 and STA $8001 that is the problem here. There are 4 pages that have to be animated. #$09 = First ? Block Frame #$0D = Second ? Block Frame #$11 = Third ? Block Frame #$15 = Fourth ? Block Frame #$09 needs to be incremented by 4 to do each frame, because.... Right Side Pattern Table: [][][][][][][][] #$08 [][][][][][][][] #$09 [][][][][][][][] #$0A [][][][][][][][] #$0B [][][][][][][][] #$0C [][][][][][][][] #$0D [][][][][][][][] #$0E [][][][][][][][] #$0F [][][][][][][][] #$10 [][][][][][][][] #$11 [][][][][][][][] #$12 [][][][][][][][] #$13 [][][][][][][][] #$14 [][][][][][][][] #$15 [][][][][][][][] #$16 [][][][][][][][] #$17 And that is because I am using Mapper 4 (MMC3), where the Right side pattern table is split into 4 VROM pages, as opposed to the Left side, which is split into 2 VROM pages, like so....... [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] [][][][][][][][] Now I could use a different mapper, but that is running away from the problem at hand. I need to be able to do this. The only thing I have to do is get proper code for my animation to work. Everything else is already taken care of. I guess what I'm asking is, how do I get the frame counter (Address $09), to select my 4 values, without selecting other pages that I don't want in there? I tried CMPs also... I'm going to keep playing around with it though, because I'm almost there. This is the last part. ____________________ My YouTube Channel |
never-obsolete |
| ||
Rat Level: 24 Posts: 15/96 EXP: 74452 Next: 3673 Since: 02-22-07 From: Phoenix, AZ Last post: 2589 days Last view: 2589 days |
keep an array of indexes to determine the page to swap in.
then put this in some free space
that way your counter only loops from 0 to 3 and no adding or shifting is needed. |
RetroRain |
| ||
Fuzz Ball Level: 66 Posts: 42/994 EXP: 2436708 Next: 25143 Since: 09-30-07 Last post: 1927 days Last view: 950 days |
I tried it, but it is not working. Here is the code I typed, shown from the debugger:
$89E1: A9 03 LDA #$03 $89E3: 8D 00 80 STA $8000 = #$78 $89E6: EE 0F 00 INC $000F = #$01 $89E9: AD 0F 00 LDA $000F = #$01 $89EC: 29 03 AND #$03 $89EE: 8D 0F 00 STA $000F = #$01 $89F1: AA TAX $89F2: BD F8 89 LDA $89F8,X @ $89F9 = #$09 $89F5: 8D 01 80 STA $8001 = #$D8 $89F8: 05 09 ORA $09 = #$1A $89FA: 0D 11 00 ORA $0011 = #$00 Since $0F isn't used, I decided to use that as my counter. Also, I confused the numbers before. It is #$05, #$09, #$0D, and #$11. It appears to stop loading at #$09. Is there any errors in this code? EDIT - It is actually only loading one tile, because the INC $000F comes before it is stored, so it is storing #$09, and then that's it. ____________________ My YouTube Channel |
frantik |
| ||
Red Koopa Level: 28 Posts: 53/139 EXP: 127328 Next: 4010 Since: 10-09-07 Last post: 4482 days Last view: 4475 days |
you can't put the data right after the code because the program will go on to interpret the data as opcodes
also $0f is definitely used by the program.. i suspect all zero page addresses are used. you can check dopplegangers SMB memory map for free space. $09 is an internal counter which is automatically incremented so there's need to create a second counter this should give you the numbers you want, though it's longer than never-obsoletes ; $00 - temp math var LDA $09 ; load frame counter -- it's automatically incremented each frame by the engine LSR A LSR A LSR A ; right shift 3 times (divide by 8 ) -- makes it so a new page is selected every 8 frame AND #$03 ; mask out low 2 bits (produces 0,1,2,3,0,1,2,3,0,1,2,3,... repeating pattern) STA $00 ; store A into $00 for use with INC INC $00 ; 0,1,2,3 = 1,2,3,4 ASL $00 ; = 2,4,6,8 ASL $00 ; = 4,8,C,10 INC $00 ; = 5,9,D,11 LDA $00; ==== edit: or even a hybrid of the two should work LDA $09 ; load frame counter -- it's automatically incremented each frame by the engine LSR A LSR A LSR A ; right shift 3 times (divide by 8 ) -- makes it so a new page is selected every 8 frame AND #$03 ; mask out low 2 bits (produces 0,1,2,3,0,1,2,3,0,1,2,3,... repeating pattern) TAX LDA chrpages, X STA $8001 RTS ; replace with a jump or whatever you like to make the program not execute the data below chrpages: .db $09, $0D, $11, $15 |
Main - ROM Hacking - Need help with a practice hack - SMB Rain | New thread | New reply |
© 2005-2023 Acmlm, blackhole89, Xkeeper et al. |
MySQL - queries: 127, rows: 167/167, time: 0.019 seconds. |