Romhacking.net

Romhacking => Personal Projects => Topic started by: MojoDodo on December 30, 2021, 06:22:55 am

Title: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on December 30, 2021, 06:22:55 am
WIP - Patch to add color and level select to Alleyway.

I wanted to do my first patch colorizing something easy.
I figured Alleyway would be a good target. It all fits into 32k rom, and there was plenty of empty space available to play in.

I've learned a lot, getting to grips with asm, .sym files, bgb, beaten dying moon, yy-chr and many others.
 
the rom has been changed to work with GBC only, because I was sloppy with changes at the start of the project.


I haven't had a chance to test this on a real gbc yet, so if someone wants to take a look and let me know any issues etc, that would be great.

I've got a few more items on my todo list, but I figured it is a good time to get some feedback.

Here is a 6 day link to the .ips file
https://filebin.net/qkoo689udva7yz1s (https://filebin.net/qkoo689udva7yz1s)
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: kkzero on December 30, 2021, 01:23:03 pm
Hi, I gave this hack a run on my Everdrive. It works just as fine on hardware as it does on emulator, no real concerns there.

Other things to note:

This is looking to be a pretty good colorization though! I feel it could easily replace the original.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on December 30, 2021, 04:30:33 pm
Thanks, all good points!
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: Ok Impala! on December 31, 2021, 12:04:55 am
Just tested it. This looks mighty impressive!

As for improvement points:
- The green is indeed a bit too saturated. The border now blends into the core color.
- The purple background didn't seem to fit well with the other colors. I don't know exactly what it is, but it feels a bit "off".

But overall it looks really good. So keep at it!  :)

I'd like to get in contact with you both about Color hacking of B/W GB games. I'm currently working on a hack for Final Fantasy Adventure, a game that would enormously improve with colors added. I'll send you a PM about this.  :)

Title: Re: Alleyway DX - GBC version of Alleyway
Post by: Titney on January 02, 2022, 05:09:34 am
Tried it on a real, unmodified GBC and I love it! The colors really pop.

Contrary to the previous two comments the green does not look too saturated to me (maybe a bit too light rather) but the lack of a clear, darker outline on the green and purple bricks does make them a bit low contrast and hard to see against the background.

Two unfiltered daylight photos to show what I mean:
https://i.imgur.com/ghYKUtK.png
https://i.imgur.com/90gFpE9.png

That is a minor quibble though, and already this hack is good enough that I'd rather play this over the original. Thanks and keep up the good work!
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: ProstatePunch on January 03, 2022, 11:37:31 am
Yay! Love more color hacks for the GB.

Do you plan on posting this to the main site?
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 03, 2022, 05:10:01 pm
Yay! Love more color hacks for the GB.

Do you plan on posting this to the main site?

Once I get it finished.

I'm adding a high contrast palette switch, and fixing up the visual glitches at the moment.

Thinking about adding some custom block coloring on the regular levels, etc etc.

Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 15, 2022, 12:05:18 am
Ok, I think I'm done with this hack.

link to 6 day copy of ips for anyone who can't wait until it gets added to the main list of romhacks
https://filebin.net/fnqp7sj78ncboy83

This hack includes:
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: lilpuddy31 on January 15, 2022, 03:01:07 am
Hey Mojo, I just tried the patch you just posted, using the MGBA core in RetroArch, the game locks up at the GBC bios screen
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 15, 2022, 03:03:30 pm
Thank you for reporting this.

The .ips I posted had crc errors in the rom header. Those are fixed in the submitted patch, but even then, the game is running but looks messed up in MGBA.

Looks like I'm not quite done!



Hey Mojo, I just tried the patch you just posted, using the MGBA core in RetroArch, the game locks up at the GBC bios screen
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: Satoshi_Matrix on January 18, 2022, 03:04:14 am
PLease post some screenshots. I'd love to see what this looks like. I actually played a lot of Alleyway when I was a kid.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: j0nas on January 18, 2022, 04:33:22 am
Great job, very well done!  :)

Thanks for including the .SYM file, this is very interesting to see.

Is there any chance you release the full source code? That would be very much appreciated.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: ProstatePunch on January 18, 2022, 01:19:39 pm
PLease post some screenshots. I'd love to see what this looks like. I actually played a lot of Alleyway when I was a kid.

Hey Satoshi,

Mojo posted the v1 of this patch already, and there's 4 screenshots: https://www.romhacking.net/hacks/6510/ (https://www.romhacking.net/hacks/6510/)
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 19, 2022, 04:52:03 pm
jOnas - Here is a copy of my scratch.txt file, where I would sometimes write code and data before copying it into bgb. It is all just a bunch of random code or data, but later in the work I started to note down where in the rom I was putting the bits of data etc.

https://filebin.net/944p14o5b6padq9j

I'll also include it in the zip with the next bugfix patch when it is ready.


The map color data, as well as the title screen and win screen is in a format where you specify chucks of data.
each chunk has 2 bytes of address (where the data starts getting written), then 1 byte that has write type and number of bytes, and then the actual data.

For the type / number bytes if the x40 bit is set, then every byte is written the same. if the 0x40 bit isn't set, then you need to specify every byte.

ie, the // nice play below is starting at 9842, write 0xA bytes as 0x02. that will be used somewhere to set the color data for the nice play text on screen to palette 2, which is yellow/gold.

the green laurels line 9884 08 0303070707070303
means at 9884, write x08 bytes with 03 03 07 07 07 07 03 03 as the values.

Then the processing stops if the next byte after a chunk is a 00.

Last time I looked at the code that processes the chunks, it looks like there is also an option to write vertical lines of data on the map as well, but that isn't used as far as I could tell. I could have used it with the color data, so it is a pain I didn't see it before I did all the color maps.

If you have any other questions, feel free to ask.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: j0nas on January 20, 2022, 06:49:42 am
Thanks MojoDodo, this is very helpful!  :thumbsup:

So, if I understand your workflow correctly, you use BGB's debugger as your main tool and inject your code there. Is that right? I actually expected you would use RGBDS (or something similar) to assemble your code and then insert it into the original ROM with the linker. But maybe it's easier to do it your way.

Quote
If you have any other questions, feel free to ask.

Thanks! Maybe it sounds a bit naive (I have quite some Game Boy coding experience but never really changed an existing ROM). You mentioned:

Quote
It all fits into 32k rom, and there was plenty of empty space available to play in.

How do you locate the "empty" parts of the ROM? I found the execution profiler in BGB that might help to identify the parts of the ROM that contain code. But I didn't see a data logger that would allow to separate the data (like tiles, maps, music etc.) from the sections that are actually unused. How can you be sure that you don't touch anything important?
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 20, 2022, 04:28:13 pm
In terms of disassembling or just hacking in code on the fly, I'm pretty sure disassembling, spending time reverse engineering everything before starting to make changes is easier and better in the long run. I just wanted to hack away like a lazy guy though, I get enough proper programming in my day job.

To find unused space, I'd just look for areas that were all ff or zero in either the memory browser or in yy-char, and put code in them. I guess it might be possible for a rom to have some big area of blank space that was being used for something (maybe a pause in some uncompressed music), but I didn't seem to hit any.

Open up Alleyway & bubble ghost in yy-char, and you will see what I mean pretty quickly about alleyway having lots of space. In reality, since hw costs aren't an issue, you can just change to a bigger mbc and rom, but keeping to the 32k size of the original is a fun extra challenge.

Sometimes before starting to use some memory location in ram for a new variable, I would put a write breakpoint on it and play for a while to check if it was being used.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: j0nas on January 20, 2022, 08:17:16 pm
Quote from: MojoDodo
To find unused space, I'd just look for areas that were all ff or zero in either the memory browser or in yy-char, and put code in them. I guess it might be possible for a rom to have some big area of blank space that was being used for something (maybe a pause in some uncompressed music), but I didn't seem to hit any.

Open up Alleyway & bubble ghost in yy-char, and you will see what I mean pretty quickly about alleyway having lots of space.

Ok, thanks! :) Looking at Alleyway, I know exactly what you mean. Unfortunately, the ROM I had in mind for my own hack doesn't contain such spaces and you just don't know if you're looking at code, data or junk.

Quote from: MojoDodo
In reality, since hw costs aren't an issue, you can just change to a bigger mbc and rom, but keeping to the 32k size of the original is a fun extra challenge.

That's more difficult than it seems. Take a look at the Game Boy memory map:

(https://kemenaran.winosx.com/images/zelda-links-awakening-progress-report-2/game-boy-memory-map.png)

In a ROM that is larger than 32KB, only the code in ROM bank 0 (16KB located at $0150 to $3FFF) is always present. If you add an additional ROM bank, it must be switched in before you access it (in the 16KB area from $4000 to $7FFF). It will then replace whatever other ROM bank was switched in before. Consequently, you can only jump to the custom code if the calling routine is located in ROM bank 0. And the custom code running in the additional ROM bank won't have access anything located in the other ROM banks (except ROM bank 0).

The only idea that came to my mind would be:


But that seems like an insane workaround. There must be a better way...  :huh:

Quote from: MojoDodo
I get enough proper programming in my day job.

That comment made my day.  ;D
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: verme on January 21, 2022, 08:32:28 am
Hi everyone, first of all, I'm sorry if this isn't the right place to post this question.
From what I can tell, the process of coloring an original Gameboy game requires a lot of work. so I was wondering if it would be possible to just change the rom header to GBC, and set the background and sprites palettes. I've seen some pirated cartridges that do this, and there was also an old "bunge" flashcart where you could do this. the question is how?
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 21, 2022, 03:05:47 pm
J0nas - You want to use a trampoline function in bank 0.

For one of my homebrew games I used one that takes 2 parameters, the bank # and address of the fn you want to call. It:


I've also seen similar fns that take a position into a jump table. So you call the Bank9Trampoline with 12, and then it switches to bank 9, and looks in the jump table at the start of bank 9 for the address of fn 12 and calls that.

If you need to make some space, hopefully there are some graphics you can move from bank 0 to somewhere else, otherwise you are stuck moving code around 

verme - Check out gb colorizer https://www.romhacking.net/utilities/30/ (https://www.romhacking.net/utilities/30/). It changs the header and injects code to setup the palettes for the background and sprites. I don't think it works for every game, but maybe it will get you started.

January 21, 2022, 04:59:26 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Also check out Beaten Dying Moon https://mattcurrie.com/bdm-demo/ (https://mattcurrie.com/bdm-demo/)

It is an online gb emulator that you can play, and it will create sym file with areas of data and code that are touched during play.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: j0nas on January 21, 2022, 07:45:42 pm
Quote from: MojoDodo
For one of my homebrew games I used one that takes 2 parameters, the bank # and address of the fn you want to call. It:
    reads the current bank
    pushes that onto the stack
    changes to the requested bank
    calls the requested fn
    when it returns it pop the original bank and switches back to that, then returns

Neat trick! I didn't realize. That should only require a minimum amount of free space in bank 0. Where do you learn this kind of stuff?

The only downside would be that the routine in the added ROM bank doesn't have access to the data in the ROM bank that was originally switched in. But that's probably not much of an issue, as you could put a copy of that data in the added ROM bank.

Quote from: verme
so I was wondering if it would be possible to just change the rom header to GBC, and set the background and sprites palettes.

The problem with that approach is that you have to set up all the values in the startup routine and can't change them later on. You can do it that way, but it won't look good. If you want to colorize a game properly, you have to change values at runtime.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: marc_max on January 22, 2022, 03:53:45 am
J0nas - You want to use a trampoline function in bank 0.

For one of my homebrew games I used one that takes 2 parameters, the bank # and address of the fn you want to call. It:

  • reads the current bank
  • pushes that onto the stack
  • changes to the requested bank
  • calls the requested fn
  • when it returns it pop the original bank and switches back to that, then returns

I've also seen similar fns that take a position into a jump table. So you call the Bank9Trampoline with 12, and then it switches to bank 9, and looks in the jump table at the start of bank 9 for the address of fn 12 and calls that.

If you need to make some space, hopefully there are some graphics you can move from bank 0 to somewhere else, otherwise you are stuck moving code around
Yep. That's the cleanest way to do it without having to messing with code moving :-) That's exactly how I rewrote the entire Mega Man World 5 DX code, as I was running out of space.

It is really useful to have some free space in bank 0 though. Also, look for the game's original memory and video management subroutines as they are usually on bank 0 and you can reuse them.


Neat trick! I didn't realize. That should only require a minimum amount of free space in bank 0. Where do you learn this kind of stuff?

The only downside would be that the routine in the added ROM bank doesn't have access to the data in the ROM bank that was originally switched in. But that's probably not much of an issue, as you could put a copy of that data in the added ROM bank.

The problem with that approach is that you have to set up all the values in the startup routine and can't change them later on. You can do it that way, but it won't look good. If you want to colorize a game properly, you have to change values at runtime.
It really depends on the game. Simple games like Dr. Mario or Alleyway could work without changing palettes, but player will thank for palette changing between levels.
Then there is also de fade in/fade out issue, which could lead to momentary glitched screen if you do not implement it.

But it's not just about setting palettes, it also requires to edit the sprite OAM and the VRAM map tile attributes so you can set which OBJ or BG palettes the sprites and background tiles will use. And, unfortunately, there isn't an universal method, as every game was coded in a different way, so the process of intercepting and injecting code is totally different in every game.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: GB-CG on January 22, 2022, 11:05:07 am
Thanks for making this. Not sure what's up with your screenshots but on my GBA and GB Player running GB Interface with the 'Identity' color matrix setting, the background color is B3C8FB instead of EDF0F7.

Left (B3C8FB) is mine, right (EDF0F7) is the RHDN one.
(https://i.imgur.com/Og7esih.png) (https://www.romhacking.net/hacks/gameboy/images/titles/6510titlescreen.png)
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 22, 2022, 04:03:39 pm
The screenshots were taken with bgb emulator, and maybe had some GBC filter on it.

But I'll change the next version so the "full color" palette has a lighter blue background color

Thanks for making this. Not sure what's up with your screenshots but on my GBA and GB Player running GB Interface with the 'Identity' color matrix setting, the background color is B3C8FB instead of EDF0F7.

Left (B3C8FB) is mine, right (EDF0F7) is the RHDN one.
(https://i.imgur.com/Og7esih.png) (https://www.romhacking.net/hacks/gameboy/images/titles/6510titlescreen.png)
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: lilpuddy31 on January 22, 2022, 05:01:25 pm
Were you able to figure out the Mgba issue?
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: GB-CG on January 22, 2022, 05:56:33 pm
The screenshots were taken with bgb emulator, and maybe had some GBC filter on it.

But I'll change the next version so the "full color" palette has a lighter blue background color
OK. I meant to say that your screenshots looked quite desaturated compared to the actual gameplay, it's a lot more vibrant. Works perfectly on hardware too (so far).
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: MojoDodo on January 22, 2022, 06:42:24 pm
Were you able to figure out the Mgba issue?

Yes, it is a horizontal dma I am using to try to update the tiles. It will be fixed in the next version of the patch, but I'm not sure when that will be available.
here is a 7 day link to a quick and dirty ips for the original unmodified rom that removes the hdma. It is a WIP, so there might be some other issues.
https://filebin.net/zssk566ozsseuvoc (https://filebin.net/zssk566ozsseuvoc)

GB-CG : Good to hear you are happy with it. The vibrancy really depends on the screen and system you are playing on. The gbc original screen is very washed out compared to newer screens. I'm waiting on a flash cart so I can test on real hardware, and until it arrives, my palettes are just best guesses.
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: lilpuddy31 on January 22, 2022, 11:19:18 pm
Yes, it is a horizontal dma I am using to try to update the tiles. It will be fixed in the next version of the patch, but I'm not sure when that will be available.
here is a 7 day link to a quick and dirty ips for the original unmodified rom that removes the hdma. It is a WIP, so there might be some other issues.
https://filebin.net/zssk566ozsseuvoc (https://filebin.net/zssk566ozsseuvoc)

Played through for about a half hour using the Mgba core of RetroArch, haven't noticed any issues yet
Title: Re: Alleyway DX - GBC version of Alleyway
Post by: KingMike on January 23, 2022, 10:34:26 am
GB-CG : Good to hear you are happy with it. The vibrancy really depends on the screen and system you are playing on. The gbc original screen is very washed out compared to newer screens. I'm waiting on a flash cart so I can test on real hardware, and until it arrives, my palettes are just best guesses.
Indeed, that was the reason emulators should have two palette options. One for the actual colors games use, and another to simulate the GBC/GBA LCD.