Register | Login
Views: 19364387
Main | Memberlist | Active users | ACS | Commons | Calendar | Online users
Ranks | FAQ | Color Chart | Photo album | IRC Chat
11-02-05 12:59 PM
1 user currently in Rom Hacking: hukka | 2 guests
Acmlm's Board - I2 Archive - Rom Hacking - Editing code after tracing it
  
User name:
Password:
Reply:
 

UserPost
d4s
Posts: 246/325
Originally posted by Ringodoggie
I mean how do I change an address that is DMA'd to?


a dma transfer is initiated by writing to register $420B.
the individual bits correspond to the dma channels(0-7), eg writing $01 to
$420b will start a dma transfer on channel 0, $06 will start transfers on channels 1 and 2, you get the idea.
each dma channel is configured by writing to registers $43x0-$43x7 (x is the channel number).

the relevant registers for changing the dma transfer source are
$43x2-$43x4 (source adress+bank).

example:
if theres a dma transfer on channel 2 and you want to change the source adress to
$c6:0388 you'd have to write $0388 to register $4322 and $c6 to register $4324.
keep in mind that hdma and dma share the same channels when adding/changing dma transfer channels.

you can only dma from the a-bus to the b-bus (thats the ppu registers) or vice versa, but not from a to a or from b to b, mind you.
that means you can dma from rom to vram, but not from rom to wram, for example.
register $43x1 determines the b-bus target adress.
when writing to vram, it is used in conjunction with register $2116, wich contains the vram target adress.
keep in mind that vram adresses are always divided by 2 because theyre 16bit aligned.


heres how a typical dma transfer looks like:

;**********************************
;in: x,16bit: pointernumber of tilemap
;**********************************
CGIntroDMATileMapToVramBG2:

sep #$20
lda #(:BG2TileMap1+$c0) ;get source bank of tilemaps
sta.w $4304 ;Store the bank of the source data
rep #$30 ;accu/index 16bit
txa ;get number of tilemap
asl ;multiply by 4(each table-entry has 2 bytes adress, 2 bytes length)
asl ;
tax
lda.w Bg2TileMapPTable,x ;get source offset of tilemap
sta.w $4302
ldx.w #$0800
stx.w $2116 ;vram adress $0000
lda.w #$1000
sta.w $4305 ;Store the size of the data block
sep #$20
lda #$80
sta $2115 ;set VRAM transfer mode to word-access, increment by 1
lda #$01 ;Set the DMA mode (word, normal increment)
sta $4300
lda #$18 ;Set the destination register (VRAM gate)
sta $4301
lda #$01 ;Initiate the DMA transfer
sta $420B
rts
BGNG
Posts: 120/276
You might be able to find some useful info by looking up some technical documentation on the subject. Not exactly "change the programming"-esque, but it may provide some useful insight.
beneficii
Posts: 241/567
Probably because I don't trust those programs to write the code into, say, SMB3 the right way, so I simply do it myself.

Now, if I was writing a ROM from scratch, then I would definitely use an assembler.

Originally posted by d4s
Originally posted by beneficii
In FCEUXD, when I trace it, I look through the code I know I'll be editing and plan for what I'll be doing. I then open up Notepad to type my new ASM. Then I open up the ROM in a hex editor and write in the opcodes myself.


manually compiling code is a big time waster and doesnt give you any advantages at all.
ive done it myself, but only for processors that dont have a compiler available (super fx) and only for very, very small amounts of code, like 3 to 4 opcodes.
besides, its nearly impossible to write proper structured and dynamic code that way. why not use wla dx or any other readily-available compiler instead?

Originally posted by Ringodoggie

What about DMA code?


i assume you want to either detect dma transfers or you want to learn how to do them the right way.
try to be more specific with your questions.


Ringodoggie
Posts: 226/281
I mean how do I change an address that is DMA'd to?
d4s
Posts: 245/325
Originally posted by beneficii
In FCEUXD, when I trace it, I look through the code I know I'll be editing and plan for what I'll be doing. I then open up Notepad to type my new ASM. Then I open up the ROM in a hex editor and write in the opcodes myself.


manually compiling code is a big time waster and doesnt give you any advantages at all.
ive done it myself, but only for processors that dont have a compiler available (super fx) and only for very, very small amounts of code, like 3 to 4 opcodes.
besides, its nearly impossible to write proper structured and dynamic code that way. why not use wla dx or any other readily-available compiler instead?

Originally posted by Ringodoggie

What about DMA code?


i assume you want to either detect dma transfers or you want to learn how to do them the right way.
try to be more specific with your questions.

beneficii
Posts: 240/567
Originally posted by Ringodoggie
What about DMA code?


Do you mean sprite-loading code? Remember, I only really know the NES, not the SNES. I was just dropping off advice I thought was general ASM hacking.
Ringodoggie
Posts: 224/281
What about DMA code?
beneficii
Posts: 239/567
In FCEUXD, when I trace it, I look through the code I know I'll be editing and plan for what I'll be doing. I then open up Notepad to type my new ASM. Then I open up the ROM in a hex editor and write in the opcodes myself.
Ringodoggie
Posts: 222/281
In SNES9x Debug, how do I edit code that I trace? Do I disassemble the ROM first?
Acmlm's Board - I2 Archive - Rom Hacking - Editing code after tracing it


ABII


AcmlmBoard vl.ol (11-01-05)
© 2000-2005 Acmlm, Emuz, et al



Page rendered in 0.003 seconds.