News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Help Replacing Akumajou Densetsu Title Screen!  (Read 7267 times)

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Help Replacing Akumajou Densetsu Title Screen!
« on: April 21, 2015, 04:04:01 pm »
Yesterday I posted a mockup I had done of a translated Akumajou Densetsu title screen that was made to look aesthetically similar to the original Japanese logo for the game. I've since made the necessary modifications so that it conforms to the NES color restrictions, and I've begun importing it. All of the tiles necessary have been inserted into the ROM, so now all that must be done is rearranging/replacing tiles on the title screen. Here's what I'm stuck with:



I tried looking it up in a hex editor, but couldn't find it. Is it compressed? If so, could someone give me a hand?

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #1 on: April 21, 2015, 04:32:53 pm »
To clarify, you're hacking the J version?  Not the US version?

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #2 on: April 21, 2015, 04:52:31 pm »
Yep, it's the J version. I don't have the patience to change all the palettes back to the way they should be in the US ROM.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #3 on: April 21, 2015, 05:37:29 pm »
Okay I took a look.

Bad news:  Yes, the data is compressed.
Good news:  It's very simple RLE and the format is very straightforward.  It's very hackable.

Here's the skinny:


There's like a common "do a big thing of drawing" routine.  This routine seems to be called twice to draw the title screen.  I would assume the first time it is called to clear the screen, and then it's called again to draw the title on a clean slate.  But I did not verify this.


If you care, the routine itself starts at offset 0x3EB94  (CPU address $EB84).


There's a pointer table starting at 0x3EC07.  I don't know how many entries there are in this table, but my guess is that there is one per "thing" for it to draw.  I would guess that things like the game over screen and maybe even the opening story screen each have a page entered here, but I don't know.  Again that is all a guess.

What I know for sure is that:

- pointer table starts at 0x3EC07
- When title screen is drawn the routine is called using the first pointer (presumably to clear the screen)
- Then the the routine is called again using the second pointer (presumably to draw the title)

The first call uses pointer $EC1D, which pulls data from offset 0x3EC2D
The second call uses pointer $B540, which pulls data from 0x0B550  (presumably, the data you're interested in is at this address)



The data itself is in the following format:

Start with 2 bytes to specify the PPU address to draw to (low byte first).
After that is a control code:

values 00-7E are followed by a single byte, and will draw that byte N times (where N is the 00-7E value)
values 80-FE are followed by N bytes, which are written in sequence (where N is the 80-FE value minus 80)
value 7F is followed by a new 2-byte PPU address to draw to (again, low byte first)
value FF indicates end of data


Example:  At offset 0x0B550:

Code: [Select]
00 20 24 00 18 CE 07 00 81 CF 18 00 81 F8 ...

This would:

00 20 = start drawing at ppu address $2000 (beginning of first nametable)
24 00 = draw tile '00' $24 times
18 CE = draw tile 'CE' $18 times
07 00 = draw tile '00' $07 times
81 CF = draw 1 tile: 'CF'
18 00 = draw tile '00' $18 times
81 F8 = draw 1 tile: 'F8'

etc

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #4 on: April 21, 2015, 06:22:06 pm »
Absolutely phenomenal. Thank you so much, Disch, you're absolutely right! No idea how you managed to figure that out but with that information in mind this is far simpler to do than I thought it would be. Again, thanks! I'll post back here once I've finished inserting the new logo. That, or upon the off-chance that I run into another problem (knock on wood!)

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #5 on: April 21, 2015, 06:27:26 pm »
Quote
Thank you so much, Disch, you're absolutely right!

No probalo.  Fun little things like this are a nice distraction to do sometimes.

Quote
No idea how you managed to figure that out

Knowledge of 6502 assembly
+ Knowledge of NES architecture
+ A good debugger (FCEUX)
+ A disassembler

= Can solve any NES hacking problem with relative ease.

I honestly don't know how hackers can get around without assembly knowledge.  Assembly is my go-to solution for everything.

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #6 on: April 21, 2015, 07:31:16 pm »
Seems as if this is something that would require ASM to accomplish. The entire title screen isn't written in the format you discovered - only everything besides the Akumajou Densetsu logo itself is written that way. The logo is just written straight out, no formatting at all. I quickly realized this but didn't notice that it would become an issue until it was too late. My logo stretches downwards slightly farther than the Akumajou Densetsu logo, so, as it currently stands, it would be impossible to insert the logo through a hex editor. At least, that's how it seems.

Oh, and Disch, where did you learn NES assembly? I know it's 6502, but I can't find any good resources for learning it as well as how to apply it when ROM hacking.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #7 on: April 21, 2015, 07:51:50 pm »
Quote
The entire title screen isn't written in the format you discovered - only everything besides the Akumajou Densetsu logo itself is written that way. The logo is just written straight out, no formatting at all.

Hrmph... I find that a little difficult to swallow.  Why would the game have a duplicate drawing routine to draw something it's already drawing in another routine?  Not that I doubt you -- I mean I've seen crazier things in games -- I'm just a little perplexed.

Are you sure the logo isn't inside a 80-FE style block?  What offset did you find it at?

I'll take another look at this in a bit.

Quote
it would be impossible to insert the logo through a hex editor.

As long as your logo does not exceed the limits of the NES's capabilities, then it is possible.  We just haven't figured out how to do it yet.  ;P

Quote
Oh, and Disch, where did you learn NES assembly? I know it's 6502, but I can't find any good resources for learning it as well as how to apply it when ROM hacking.

A long long time ago, in a previous life, I read 6502.txt, nestech.txt, then wrote an emulator to exercise that info.

These days, 6502.txt is still pretty solid to learn the basics, as it does a great job of giving you a high-level, reasonably easy to understand overview.  Though for a quick reference of opcodes and stuff, Obelisk is better:

http://www.obelisk.demon.co.uk/6502/reference.html

( EDIT:  I just looked at 6502.txt again and it isn't as great as I remember.  Was I thinking of another doc?  Whatever, it was over a decade ago -- I can't remember  =x )

nestech.txt is extremely outdated these days, and I would not recommend it.  Probably the most complete source of info is the nesdev wiki, although I don't know how "beginner friendly" it is, as it seems to be oriented more towards emu developers than hackers -- but maybe that's just the parts of it that I go to.  There's also a "Programming Guide" page on it that illustrates things from a homebrewer standpoint -- though I don't know if that'd be any easier for a hacker:

http://wiki.nesdev.com/w/index.php/Nesdev_Wiki




As for "how to apply it to ROM hacking" -- my advice is don't worry about that, and focus on the knowledge itself.  Once you understand the big picture, how to apply it will be obvious/self-evident.


Alternatively, you could read some kind of "learn to hack NES assembly in 6 steps" guide that loosely shows how to apply the knowledge without really explaining the knowledge itself -- but I don't like to learn things that way.  I'm sure there are guides like this out there (maybe even on this site?) but I don't know of any and probably wouldn't recommend them anyway.



EDIT:

More than once I've considered making a "learn NES assembly for ROM hacking" guide.  Maybe one of these days I'll do that.




EDIT AGAIN:

I just double checked and it certainly does look like the Akumajou Densetsu logo is stored with the rest of the title screen data as I originally thought.

The entirety of the data for the title screen starts at offset 0x0B550 and continues until the termination 'FF' character at offset 0x0B6FB.
« Last Edit: April 21, 2015, 08:12:18 pm by Disch »

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #8 on: April 21, 2015, 08:07:44 pm »
The logo starts at the end of 0x0B5A0. From then on, it switches from formatted, to unformatted, and so on each row of the title screen until the logo is out of the way. The stuff in bold is the logo, which is unformatted:

Spoiler:
00 82 FD FE 10 00 81 F8 06 00 9A CF 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F A0 A1 A2 A3 BC BD BE BF F8 06 00 9A CF 00 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F B0 B1 B2 B3 B4 B5 B6 B7 F8 06 00 9A CF 00 21 22 23 24 25 26 27 28 29 2A 2B 2C 2D 2E 2F C0 C1 C2 C3 C4 C5 C6 00 F8 06 00 9A CF 00 31 32 33 34 35 36 37 38 39 3A 3B 3C 3D 3E 3F E7 D1 D2 D3 D4 D5 D6 00 F8 06 00 9A CF 80 81 82 83 84 85 86 87 88 89 8A 8B 8C 8D 8E 8F......

EDIT: Oh, and thanks for the info on 6502! I'm extremely interested in learning to program for the NES.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #9 on: April 21, 2015, 08:18:00 pm »
Nah see that's all part of the format.  Perhaps I wasn't clear on the 80-FE bytes:

N bytes follow a 80-FE byte -- not just 1 byte... but N bytes.  As in, a bunch of uncompressed bytes.  That is what you are seeing.

This string:
Code: [Select]
81 F8 06 00 9A CF 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F A0 A1 A2 A3 BC BD BE BF F8 06 00

Is these blocks:

Code: [Select]
81 F8 <- a single 'F8' tile  (81 - 80 = 1, so N=1)
06 00 <- 6 '00' tiles
9A ... <- 9A - 80 = 1A, so the next 1A bytes are written verbatim (that is, CF 00 01 .. up to F8)
06 00 <- 6 '00' tiles

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #10 on: April 21, 2015, 09:45:37 pm »
It seems my issue still stands, I finished writing out all of the rows of the title screen that my logo takes up, and I was greeted with this:



It's... It's beautiful.

I was able to easily try again because I made a copy of the ROM when I was nearing the bottom of the logo (which is when I first encountered problems, and assumed it was due to odd formatting as I explained earlier):



It seems as if whenever I venture past here, I end up with issues. On my second try, it was a bit less glitchy, but all palettes besides one black/red/green palette were completely disabled from use, so it looked like Dracula was hosting a Christmas party or something. You can actually see the same problem with the palettes in the first screenshot in this post.

I hate to trouble you, Disch. I know there was a fan localization of Akumajou Densetsu that managed to replace the title screen with their own, I'll try to get in contact with the one responsible for that.

Disch

  • Hero Member
  • *****
  • Posts: 2814
  • NES Junkie
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #11 on: April 21, 2015, 09:53:32 pm »
The palettes are part of the attribute table which comes at the end of the name table.

Are you trying to just overwrite the logo and nothing else?  Because that's probably your problem.  You should probably be redrawing the entire screen.  Inserting new data or removing existing data will require everything after it to be shifted over, which is tricky.

Quote
I hate to trouble you, Disch.

It's no trouble.  I enjoy this stuff.

Trust me, if it were trouble I wouldn't be bothering.  As soon as I don't feel like responding to these threads, I stop responding.  =P
So the fact that I'm still responding is a sign that I'm still interested & don't mind helping at all.



EDIT:

My advice for how to do this:

1)  Lay out the tiles you want to draw for the entire screen.  You should have $03C0 bytes of uncompressed tiles
2)  Compress them / convert them to this format
3)  Make sure the compressed data does not exceed the space available -- remember the original data ended at 0x0B6FB, so that means you have $01AC bytes available.  You have to have the entire title screen (including the 'FF' terminator) in that space.
4)  Copy compressed data into the ROM



Once the tiles are right, you can work on the palettes.  Attribute tables are a little tricky -- so let's cross that bridge later.
« Last Edit: April 21, 2015, 09:59:12 pm by Disch »

Proveaux

  • Full Member
  • ***
  • Posts: 117
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #12 on: April 21, 2015, 10:37:19 pm »
This may be of some help.

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #13 on: April 22, 2015, 12:28:04 pm »
Success! Sort of.



The placement of the logo during the title intro where lightning flashes in front of it is still off, though. Probably something else I'll have to retile. One of the lightning flashes, for example:


ShadowOne333

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #14 on: April 22, 2015, 12:32:03 pm »
Vanya,  Proveaux and me were actually working on that a year ago or so.
Take a look:
http://www.romhacking.net/hacks/1983/



From your last results, I can only see palette issues, although I might have overlooked something.
If you want, I could help you out with the palette of the Title Screen.
Just let me see your mockup screen and once you have the complete Title Screen settled as you want it, send me the IPS to work over that and change the palette to your liking.

Edit:
One thing I want to ask, are you working over our Title Screen + Translation hack?
Or is it something you are doing from scratch?
I ask because I would love to see this title screen implemented over our translation/title screen hack of Akumajou Densetsu (since the latest revisions fixed issues still carried over from the original translation) so that your title screen goes along with the translation for a full English language game.

Let me know what do you think.
« Last Edit: April 22, 2015, 01:13:40 pm by ShadowOne333 »

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #15 on: April 22, 2015, 02:28:48 pm »
As long as you're willing to do the palette fixes for me, then of course I can send it your way. I do still have to fix the lightning flash effects, though, but after that I'll send you a PM with the necessary stuff. I wasn't using your title+translation at first, since I thought using the original J version wouldn't require fixing the palettes, but clearly I was wrong so I'll just quickly port everything over to the translated ROM and then get to fixing the lightning effect.

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #16 on: April 22, 2015, 02:35:34 pm »
As long as you're willing to do the palette fixes for me, then of course I can send it your way. I do still have to fix the lightning flash effects, though, but after that I'll send you a PM with the necessary stuff. I wasn't using your title+translation at first, since I thought using the original J version wouldn't require fixing the palettes, but clearly I was wrong so I'll just quickly port everything over to the translated ROM and then get to fixing the lightning effect.
Well, I suggested using the hack Vanya, Proveaux and me worked on so you can avoid doing the translation and all the fixes yet again from scratch.
Simply grab the IPS and put it over a clean ROM, then work over that one so that you can implement your changes.

Thing is that the palette used for the Title Screen is not the same as the one used during the lighting scene, same goes for the ending title screen palette.
Apparently the game uses different sets of palettes (three IIRC) for then the title screen tiles load up in these particular parts:
1) Main Title Screen (where you can choose OPENING or PASSWORD)
2) Lighting Title Screen
3) Ending Title Screen

For each one of those cases, the game uses different palettes.
I bumped into that issue when I was fixing the credits text.

Enough of that mumbo-jumbo though. :P
Once you are done with your changes, drop me a PM so I can start working on the palette.
Just remember to write up the details about the palette, it would be better if you send me a mockup of the colors you want it to have to grab those as a base for the palette.
« Last Edit: April 22, 2015, 02:41:14 pm by ShadowOne333 »

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #17 on: April 22, 2015, 03:25:34 pm »
I'm have shit loads of trouble fixing the logo as it appears during the lightning flashes, would it be at all possible for you to fix that as well? I can understand if you'd rather not, but I figured I'd ask since my brain is about to explode. If you give the word I'll send everything your way.

ShadowOne333

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #18 on: April 22, 2015, 03:28:32 pm »
I'm have shit loads of trouble fixing the logo as it appears during the lightning flashes, would it be at all possible for you to fix that as well? I can understand if you'd rather not, but I figured I'd ask since my brain is about to explode. If you give the word I'll send everything your way.

Before you send it to me, what exactly is it that is occurring with the flashing effect and the Title Screen?
Could you post images or a quick video about it?

FixtySour

  • Jr. Member
  • **
  • Posts: 18
    • View Profile
Re: Help Replacing Akumajou Densetsu Title Screen!
« Reply #19 on: April 22, 2015, 03:49:34 pm »
Not only is the logo not centered correctly, but half of it is lower than it should be:


Here it is all sewn together and imposed over the mockup so you can see how it's unaligned: