|15th February 2014, 07:03 PM||#1|
Join Date: Feb 2014
Showing Mugshots via ASM
Showing Mugshots via ASM
Yo, PHO! I would like to present you a little ASM hack of mine:
Showing 1 or 2 mugshots and hiding them after.
The mugshots are stored in the OAM so its possible to display mugshots + textbox! Let's get started!
You need 3 things:
And then, ofc, you need to insert an image and it's palette.
Okay.. I think in this forum everyone knows how to do that, so
I will just skip that one and go on to the next part: The table!
My ASM code uses a table and vars for dynamic displaying of sprites.
Go to a free location somewhere at your ROM and start building the table.
[IMAGE_PNTR][PALETTE_PNTR][PAL#][00 00 00]
Well, I think image_pntr and palette_pntr are clear, but what is pal#?
OAM has access to 16 OBJ palettes, which can be found
from 0x5000200 - 0x5000400 in the Palette-RAM. If you, for example,
set 00-byte as pal#, the image-pal will be at 0x5000200 and so on..
Each entry is 0xC bytes long, directly after that you can set another entry.
Enough from that one.
Lets take a look at the code.
You need to change 2 things in general.
.equ TABLE, 0x08[TABLE]
Replace [TABLE] with the offset you have just written the entries to.
Near the end of the code there is some strange data.
[OFFSET_OF_CODE] needs to be replaced with the offset, where you
are going to insert this ASM code!
If you have done that, save the Loading.asm and close it.
Extract the thumb.zip to your desktop and put the loading.asm and removing.asm in this folder. DRAG AND DROP the loading.asm into thumb.bat and do the same with removing.asm.
You should get 2 files.. removing.bin and loading.bin
Open both of them in a hex-editor, as well as your ROM.
Go to the offset, which you have replaced [OFFSET_OF_CODE] with.
Now swap over to the loading.asm and do CTRL+A to copy all bytes.
At your ROM, mark now 0x11C bytes and make CTRL+V to insert
the bytes of loading.bin there.
Swap to removing.bin, copy all bytes and at your ROM, mark 0x40 bytes.
(I recommend you to insert the removing.bin right after loading.bin)
Then again, make CTRL+V to insert the bytes of removing.bin.
Write down the offsets you have written loading.bin and removing.bin to and add +1 to them, as they are THUMB codes.
Prepare a script:
We need to use 3 variables.
@/* VAR 0x4500 = SPRITE NUMBER IN TABLE */@ @/* VAR 0x4501 = LEFT OR RIGHT SIDE? */@ @/* VAR 0x4502 = SPRITE SLOT IN SCRIPT */@
In var 0x4500, you need to define the index of the picture you
want to display.
If you want to display the mugshot at the left side of the textbox,
set var 0x4501 to 0. Otherwise, set it to 0x1 for the right side.
At var 0x4502 you need to write 0x0 if you display the first sprite.
If you call the ASM the 2nd time (to display another mugshot) set this var to 0x1.
#dynamic 0x750000 #org @testscript setvar 0x4500 0x0 'first sprite setvar 0x4501 0x0 'left setvar 0x4502 0x0 'this sprite is the 1st one callasm 0x(offset_of_your_loading.bin) +1 setvar 0x4500 0x1 'second sprite setvar 0x4501 0x1 'right setvar 0x4502 0x1 'this sprite is the 2nd one callasm 0x(offset_of_your_loading.bin) +1 msgbox @text 0x6 callasm 0x(offset_of_your_removing.bin) +1 end #org @text = TEST.
At that moment, I decided to limit the displayable mugshots to 2.
I dont think you need more, and it would cause bugs if you would
spam a 100%-dynamic code.
Ok, let's test the code out:
(again, this forum wont let me post links ~.~)
Thanks for reading my tutorial and have fun!
Don't forget to give credits if you use it.
|asm, mugshots, showing, [Ongoing]|