Advertiser Content

Development The Ruins of Alph Puzzles

Started by Diegoisawesome October 16th, 2010 1:53 PM
  • 21850 views
  • 53 replies

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Summary:
Well, it's been done. Three years after making this thread, many advancements in the Ruins of Alph have been accomplished; shiny quagsire obtained the original source code from Mastermind_X and put it up on GitHub, mwksoul took that code and made it almost work in Emerald, and finally, I took that code and made it completely compatible with existing in-game systems, getting rid of any bugs and incompatibilities and adding in things like fading. More recently, shiny quagsire ported my code over to FireRed, allowing for much more hacks to use it than before.

Screenshot:


Source:
https://github.com/shinyquagsire23/M_X-RuinsofAlph
Released under GPLv3, anyone is free to take this code and use it in their own hack as-is, or modify it and release the source code as well. Any forks from the code are free to be discussed in this thread.

Q/A:
Q: What engines does this work in?
A: Emerald and FireRed only.

Q: Will you be porting this to [Ruby, Sapphire, LeafGreen]?
A: Sorry, but no. Feel free to port the code over if you want to, though! shiny quagsire made this process extremely simple!

Q: How do you put this into a hack?
A: Get devkitARM from http://sourceforge.net/projects/devkitpro/. Drop your ROM of choice in the project folder. Compile the source into your ROM with
make (ROM code) fname="(ROM name.gba)" offset=(free space offset)
without parentheses.
The ROM code is either bpre for FireRed or bpee for Emerald.
Once it's been injected into your hack, use a script such as this to start it:
#org @start
lockall
setvar 0x8004 0x0
fadescreen 0x1
callasm 0x(free space offset + 1)
waitstate
compare LASTRESULT 0x1
if 0x1 goto @success
releaseall
end
Setting var 0x8004 to 0, 1, 2, or 3 will choose which one of the four puzzles to load (Kabuto, Aerodactyl, Omanyte, and Ho-Oh respectively), and you can check to see whether or not the player successfully solved the puzzle with the contents of LASTRESULT.

Q: Who did what in this?
A: Mastermind_X made the original standalone ROM (of course), shiny quagsire obtained the source and uploaded it to GitHub, mwksoul did the initial hard work (cleaning up the original, making it not a standalone), while I made it fully compatible with Emerald's callback system, sprite loading system, etc. shiny quagsire then ported that code over to FireRed, making it fully compatible with that engine.

Credits: (if you want to use this, then make sure to credit all of us)
Mastermind_X: The original
shiny quagsire: The obtaining of the source, the port to FireRed
mwksoul: The initial port and cleanup
diegoisawesome: The compatibility and customization



ORIGINAL POST:
We all know the Ruins of Alph puzzle made by Mastermind_X, right?
http://sfc.pokefans.net/lesson.php?id=21
Well, it was made for Fire Red, and when I wanted it in my Emerald hack, I tried to port it over. I changed the LASTRESULT address and tried it in-game.

As you can see, the result was less than satisfactory, and although it did work, it did have some glitches. As you can see here, the strange coloration is one part, and the other part is that after exiting it, pressing start would give you a weirdly formatted start menu, at the botom of the screen. Exiting it and trying again would bring up the normal Start menu, except exiting this one would remove all of the tiles on the top layer of the map.

So my question is this: How can Mastermind_X's brilliant puzzle be taken over to Emerald?

Shiny Quagsire

I'm Still Alive, Elsewhere

Age 21
Male
Hoenn Safari Zone
Seen 1 Week Ago
Posted April 17th, 2017
700 posts
10.4 Years
Could you post a picture of the pallet before you touch it and after for us? I'm not sure if it's just not changing the pallet or what the deal is.

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Could you post a picture of the pallet before you touch it and after for us? I'm not sure if it's just not changing the pallet or what the deal is.
It's not just that, the start menu is glitched up afterwards too. I believe it's because the RAM areas it uses are used in Emerald already... and maybe some ASM incompatibilities too.

Darthatron

巨大なトロール。

Age 28
Male
Melbourne, Australia
Seen February 2nd, 2015
Posted October 28th, 2014
1,152 posts
13.8 Years
It's not just that, the start menu is glitched up afterwards too. I believe it's because the RAM areas it uses are used in Emerald already... and maybe some ASM incompatibilities too.
It would definitely be the RAM areas, but it wouldn't be ASM incompatibilities, because that makes no logical sense. :)
あなた は しきしゃ です
わたし は ばか です

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
It would definitely be the RAM areas, but it wouldn't be ASM incompatibilities, because that makes no logical sense. :)
Well, what I meant was that you might have had to branch to different ROM locations or push and pop some extra registers.

Shiny Quagsire

I'm Still Alive, Elsewhere

Age 21
Male
Hoenn Safari Zone
Seen 1 Week Ago
Posted April 17th, 2017
700 posts
10.4 Years
I found your little problem with the palette. In Fire Red, the palette is copied via DMA to 0x05000000, which means that manually writing to that location will have it automagically rewritten over by the DMA (I personally discovered this with some of my own ASM). However, there is a palette buffer (two actually, one is for fading) in the Pokemon Games where the DMA copies from. In Fire Red, this buffer is at 0x020371f8. However, in Emerald, it's 0x02037B14. so a simple pointer search should fix that. M_X may or may not have used this buffer, so if searching the FR pointer comes up with nothing, find the main palette memory (0x05000000) and the obj pallet memory, which is 0x200 more than the background palette and replace those accordingly (adding 0x200 to the offset for the OBJ palette)

As for the menu, it may have something to do with how he preserves the palettes and tiles. What he does is he copies a big portion (or all) of the OBJ memory and the tile memory, and stores them using these #defines in his main.h file:
#define lzData2         ((u16*)0x203C000)
#define lzData          ((u16*)0x203D000)
#define save1           ((u16*)0x203E000)
#define save2           ((u16*)0x203F000)
So perhaps repoint those RAM locations to fix the menu.

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
I found your little problem with the palette. In Fire Red, the palette is copied via DMA to 0x05000000, which means that manually writing to that location will have it automagically rewritten over by the DMA (I personally discovered this with some of my own ASM). However, there is a palette buffer (two actually, one is for fading) in the Pokemon Games where the DMA copies from. In Fire Red, this buffer is at 0x020371f8. However, in Emerald, it's 0x02037B14. so a simple pointer search should fix that. M_X may or may not have used this buffer, so if searching the FR pointer comes up with nothing, find the main palette memory (0x05000000) and the obj pallet memory, which is 0x200 more than the background palette and replace those accordingly (adding 0x200 to the offset for the OBJ palette)

As for the menu, it may have something to do with how he preserves the palettes and tiles. What he does is he copies a big portion (or all) of the OBJ memory and the tile memory, and stores them using these #defines in his main.h file:
#define lzData2         ((u16*)0x203C000)
#define lzData          ((u16*)0x203D000)
#define save1           ((u16*)0x203E000)
#define save2           ((u16*)0x203F000)
So perhaps repoint those RAM locations to fix the menu.
Well, to start with, this isn't the only problem. Being designed for a standalone ROM, it doesn't fade in and out nor play a jingle. Besides this, the routine needs to be rewritten to use the in-game methods of storing data, such as the LZ data and palette data. Basically, the source is amazing to finally have so these issues can be fixed.
Male
Seen June 26th, 2019
Posted January 2nd, 2017
83 posts
10.2 Years
I had this problem too, together with some other problems, the thing is that Mastermind_X used the direct palette RAM at 0x05000000, but as you know maybe Pokémon backstores the Palettes in the WRAM. The data is copied in the DMA3 line and you want to turn that off. I can only give you the adresses for the german ROMs and what you want to change, it might be similar to the english ones:

Firered(BPRD):

Disable: 0x02037AC0 = 0x80
Able: 0x02037AC0 = 0x40

Emerald(BPED):

Disable: 0x02037FDC = 0x80
Able: 0x02037FDC = 0x40

The Firered ones were researched by driver and published in his research note files.

You want to find the offset in the routine and change it.
As I tried that I had some problems with the OAM stuff. The sprites were all bugged and I wasnt able to end the code correctly, I think some layers and also the OAM was bugged, I wasn't able to solve that though.
Hope I could help and maybe I also find an answer to my problems^^

~SBird

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Well, it's been done. Three years after making this thread, many advancements in the Ruins of Alph have been accomplished; shiny quagsire obtained the original source code from Mastermind_X and put it up on GitHub, mwksoul took that code and made it almost work in Emerald, and finally, I took that code and made it completely compatible with existing in-game systems, getting rid of any bugs and incompatibilities and adding in things like fading.

Everything you need to know is in the first post, so check it out!

Shiny Quagsire

I'm Still Alive, Elsewhere

Age 21
Male
Hoenn Safari Zone
Seen 1 Week Ago
Posted April 17th, 2017
700 posts
10.4 Years
Just wanted to mention it but I got it working on Fire Red:


It was remarkably simple to get the base code down. All it took was a few bytes from the beginning of each Emerald function to find the equivalent in Fire Red. After that it was just tweaking and asking diegoisawesome what the heck that line of code over there does (he was a big help with the port). But as of now the status of Fire Red is fully ported. I also right aligned the text to fit more with the Fire Red style.

EDIT:
Just to expand on the possibilities of the source code, I made up this graphical hack to demonstrate:


And in terms of editing that's actually pretty weak. With this code you can do pretty much anything. Add more puzzles, change the gameplay to add rotation, make it one of those weird sliding puzzles where there's only one space open, the list goes on and on.

If anyone wants the skinned version of this though, you can grab it on the grayruins branch on the main GitHub page in the main post. If you modify the graphics, make sure to reexport them with winGRIT and rename them appropriately inside the img_bins folder or the changes won't show up. Also, a few notes on that:
  • Export the background at 4bpp with lz77 compression for the graphics and the map with lz77 compression as well. Also make sure that you export the palette
  • Exporting palettes on the tiles is not required, but exporting the palette on the pointer is. If you edit the palette in one, mirror the edits in all the others.
  • The pointer and the tiles share the same palette. This can be changed by editing the code but we opted to change as few palettes as possible.

And finally, one last note on porting. Currently our system is designed to be easily portable between versions, meaning that if you edit the main code and test on Fire Red it should still be able to compile for Emerald without error. To port another game over, create a new useful-XXXX.h with your appropriate game code. So if I were to port this to Ruby, it would be useful-axve.h. Once you have that file set up you just need to find all the equivalent functions and pointers inside the file and then set up the makefile and main.c to recognize your game and useful-axve.h file. It's a long and trivial process, but once you have it done you are set to be able to compile code between all of the supported games.
Male
Seen June 26th, 2019
Posted January 2nd, 2017
83 posts
10.2 Years
I have a question concerning the "tutorial bar" thing, I have set up a version which is working with the german version of emerald(It was quite easy, thanks to the header file), now I wanted to translate the text into german as well, but as soon as I change something, everything seems to be messed up(Made a screenshot, to make you aware of what I mean):


As you can see it renders the things like twice, maybe someone has an idea of what's going on here :)

~SBird

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
I have a question concerning the "tutorial bar" thing, I have set up a version which is working with the german version of emerald(It was quite easy, thanks to the header file), now I wanted to translate the text into german as well, but as soon as I change something, everything seems to be messed up(Made a screenshot, to make you aware of what I mean):


As you can see it renders the things like twice, maybe someone has an idea of what's going on here :)

~SBird
If you modify the text, you'll also need to change the array length to be the length of your new text.
const u8 tutorialText[23]
That 23 will need to be changed to reflect your new text length.
Male
Seen June 26th, 2019
Posted January 2nd, 2017
83 posts
10.2 Years
If you modify the text, you'll also need to change the array length to be the length of your new text.
const u8 tutorialText[23]
That 23 will need to be changed to reflect your new text length.
Thank you very much for explaining such simple stuff to a C-Noob like me. :)
Everything works perfectly now!

~SBird

Le pug

Creator of Pokémon: Discovery / Fat Kid

Age 26
Male
Le bed
Seen August 17th, 2019
Posted June 6th, 2019
871 posts
6.2 Years
Do you think you could do a more in depth explanation on how to implement into the hack? I know it's probably super easy for you to do, but I have been stuck on inserting this for awhile. Downloaded....
"Drop your ROM of choice in the project folder"
er where is this project folder?
"Compile the source into your ROM with
Code:
make (ROM code) fname="(ROM name.gba)" offset=(free space offset)"
and how to do this?

thanks in advance and thanks for this resource
Retired. Thank you guys for a wonderful five years.
Male
Seen June 26th, 2019
Posted January 2nd, 2017
83 posts
10.2 Years
You want to have your romfile in the same directory as the ruins_of_alph project you downloaded(The folder in which the makefile is, that is)
Then you have to open your command terminal by eighter pressing Windows Key + R and typing "cmd", and then navigate to this particular folder(Command "cd" for change directory), or you may be able to open the command terminal at a specific place by shift right-clicking the folder and selecting "open command terminal here" or something like that. (I can't tell you exactly because my UI is in german)

After that you just type in the make command like provided above and the toolkit will automatically install it for you. Further it may be neccesary to download and install "DevkitPro" (Google it), and adding it to your environment variables/PATH. (I have this because of developement reasons, I don't know if it's required, if it does'nt work you might try to do that, you can find out how to edit your PATH variables via google)

~SBird

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Hi, I have a problem with this routine, When I try to continue the script after solve the puzzle, this don't work, I need change a value of var to activate a script when I completed this. How can I make it?
Post the script you're using to call it; I didn't get a good look at it over the IRC.
Male
Seen 3 Days Ago
Posted July 6th, 2019
208 posts
2.7 Years
Can anyone tell how to implement it?
When I type that code in cmd in root folder, shows error,
Here is what I did:
Copied my rom in root, then copied 3 files from bin folder of gnumake, then open cmd here, and typed the following:
make bpre fname="test" offset=800000
My rom name was test, obviously...

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Can anyone tell how to implement it?
When I type that code in cmd in root folder, shows error,
Here is what I did:
Copied my rom in root, then copied 3 files from bin folder of gnumake, then open cmd here, and typed the following:
make bpre fname="test" offset=800000
My rom name was test, obviously...
You're meant to use devkitPro and its toolkit in order to build this. Also, you need to also give the file extension in the fname parameter.

Diegoisawesome

Oh god the bees

Age 22
Male
Somewhere the rains of Africa can be blessed
Seen 8 Hours Ago
Posted August 25th, 2019
1,056 posts
11.8 Years
Can anyone provide me a bin file insead?
Problems compiling,
Offset > 0xAA0000
What issues are you having? It would be best to fix those problems instead of someone providing you a binary.
Male
Seen 3 Days Ago
Posted July 6th, 2019
208 posts
2.7 Years
What issues are you having? It would be best to fix those problems instead of someone providing you a binary.
That's true, Do i need any software for this?
I have make and devkitpro installed and added to patch variables...
Also have java runtime.
Plz guide me, thanks
Advertiser Content