I have a hobby project requiring adding some code to Super Mario Bros NES file.
Specifically I want to display custom text (at least 22 letters and numbers, but more likely above 100 characters) after completing each level. From what I see this cannot be done by simple text replacement inside the file. So I figure I'll write separate routine in machine code to display the text (using tiles from CHR part of the ROM). Then I plan to put this routine somewhere...
My questions are:
Is there any simpler way to achieve this?
If not: where can I add my code? From my understanding of this code: https://gist.github.com/1wErt3r/4048722 the game, after initialization, enters infinite loop and the entire logic happen in interrupt handler. My idea was to change the interrupt vector NMI pointer from original 0x8082 to some other address containing my code, check if this is the start-level screen and the level number is greater that one, display my text and jump to original 0x8082 address...
- (a) Will this work?
- (b) Where can I put my code? I noticed in hex editor that from 0x56b0 - 0x56d0 there are FFs only, I'm going to check if this is simply free space left. If not I would have to add additional 16K bank of program space (change header byte from 02 to 03 in NES file to indicate this) but I suspect that requires more adjustment?
Please advise if this approach is feasible.
UPDATE
I reduced the scope of this "project" to simply show "victory screen" after completing the first level (1-1). I can replace the texts showed on victory screen easily. The problem is to find the branch instruction that enters the victory routine and to enter it after the first level (instead of 8-4). Adittionally, some memory bytes and registers have to be set to the values the routine expects, because just jumping there after incrementing level counter crashes the game...