Points of Required Attention™
Please chime in on a proposed restructuring of the ROM hacking sections.
Views: 89,934,375
Main | FAQ | Uploader | IRC chat | Radio | Memberlist | Active users | Latest posts | Calendar | Stats | Online users | Search 10-09-24 02:52 PM
Guest: Register | Login

0 users currently in ROM Hacking | 1 guest | 1 bot

Main - ROM Hacking - nes programming? New thread | New reply


MartsINY
Posted on 09-07-14 05:01 AM Link | Quote | ID: 158162


Micro-Goomba
Level: 11

Posts: 8/17
EXP: 4927
Next: 1058

Since: 03-31-11

Last post: 2239 days
Last view: 2239 days
hi!

I have a simple question : I'm now analyzing the whole code of MM4, ans then I'd like to create a new rom from scratch, in which I could write my function in assembly (like with FCEUX). I wondered if such a program exists? and if so, I'd like to know if there is one which allows me to give name to function, so when I create the code, it would place my functions in banks I set previously, but to adress not predetermined, so I would be able to expand my code again if I need to...

thx!!

ShaneM
Posted on 09-07-14 05:32 AM (rev. 14 of 09-07-14 05:53 AM) Link | Quote | ID: 158163


Snifit
Compromised account.
Please contact an admin to restore access.
Level: 36

Posts: 119/285
EXP: 299958
Next: 8152

Since: 02-17-14

Last post: 3303 days
Last view: 2819 days
Posted by MartsINY
hi!

I have a simple question : I'm now analyzing the whole code of MM4, ans then I'd like to create a new rom from scratch, in which I could write my function in assembly (like with FCEUX). I wondered if such a program exists? and if so, I'd like to know if there is one which allows me to give name to function, so when I create the code, it would place my functions in banks I set previously, but to adress not predetermined, so I would be able to expand my code again if I need to...

thx!!


First off, if I understand you correctly, you're asking how does one make a homebrew? It's either that or you're asking how to 'hack' a ROM image. Well, no. There are no tools that do specifically that (unless you count a disassembler which spits out raw code/data which would need to be labeled). What you would do is start a .asm file from a disassembly of MM4 then add/take away what you want in it. Then you'd use an assembler, such as ASM6 by loopy to assemble the file/files. Whether you are merely wanting to edit binary or the whole ROM is up to you. What I'd do is use a make.bat to assemble with (I personally add @pause and @echo).

What you are looking for are called "labels". You can also accomplish your needs within a hex editor. I really feel you are asking how to hack rather than homebrew. What you'd do is a JMP (unconditional) or JSR or branch to the subroutine that you want to create. If you are using hex, make sure your absolute address reflects Program RAM and that the code is in the right bank within PRG (in case MM4 is not NROM, which I've never hacked MM games). Code looks something like this:


;;;SMB2J:

BuzzyBeetleMutate:
cmp #Goomba ;if below $37, check for goomba
bne StrID ;value ($3f or more always fails)
;;;;; ldy PrimaryHardMode ;check if primary hard mode flag is set
JSR newcode
beq StrID ;and if so, change goomba to buzzy beetle
lda #BuzzyBeetle
StrID: sta Enemy_ID,x ;store enemy object number into buffer
lda #$01
sta Enemy_Flag,x ;set flag for enemy in buffer
jsr InitEnemyObject
lda Enemy_Flag,x ;check to see if flag is set
bne Inc2B ;if not, leave, otherwise branch
rts

newcode: ;;;;somewhere where there's freespace
ldy gamesbeatencount ;the number times game is beaten value saved to SRAM
cpy #$08
bcc $03 ;if 0-7 we branch
ldy #$01 ;otherwise set bit
rts ;return
ldy $00 ;clear bit
rts ;return


^The above code changes Goombas into Buzzy Beetles after accumulating 8 stars on the title screen. It's code I added to my Mario hack.

Notice that I replaced my "ldy PrimaryHardMode" with "JSR newcode". (Assemblers don't read antyhing past a ";", which are considered comments.) Then I put my custom routine in. This is how it's done. Anywhere, period. Whether it is an .asm file or hex editor. (In a hex editor you use opcodes rather than mnemonics.) Make sure that you have room in the bank for your code as each PRG bank is $4000 bytes. Good luck.

EDIT: You cannot add more bytes in than what was taken out within a hex editor or an UNLABELED disassembly. My LDY was to check if a flag bit was set at RAM address 076A (PrimaryHardMode). It was an absolute address = 3 bytes. My JSR took three bytes. If you ever do something like use branching (conditional statements; 2 bytes) then you'd NOP the third byte, if there was one.

____________________
At the end, when the day is over, the only one left to face is yourself. Have you been true to yourself and made the most of your day?

MartsINY
Posted on 09-08-14 01:55 AM Link | Quote | ID: 158185


Micro-Goomba
Level: 11

Posts: 9/17
EXP: 4927
Next: 1058

Since: 03-31-11

Last post: 2239 days
Last view: 2239 days
a big thx!! it was I was meaning, I always coded with FCEUX... dawn if I knew about it before!!

thx again

Main - ROM Hacking - nes programming? New thread | New reply

Acmlmboard 2.1+4δ (2023-01-15)
© 2005-2023 Acmlm, blackhole89, Xkeeper et al.

Page rendered in 0.066 seconds. (343KB of memory used)
MySQL - queries: 47, rows: 70/70, time: 0.061 seconds.