Posted on 04-11-15, 02:57 pm in Export a SPA to a BMP (rev. 7 by  MeroMero on 04-13-15, 04:30 pm)
Death by cuteness

Karma: 6564
Posts: 273/598
Since: 05-01-13
All you need to know about SPA files:
http://florian.nouwt.com/wiki/index.php/SPA_%28File_Format%29

DISCLAIMER: The information in this present post before the edit is now obsolete, but will only be struck out and put into a spoiler instead of being deleted so that you know what part of this message  skawo originally responded to.
I also invite anyone to know something about SPA to post it there.
Thank you.
 MeroMero



To know what bitmap format a TPS uses, you have to look at nybble 0 (the rightmost nybble) from byte 4 on the TPS header.
Here are the different values (modulo 8 ?):
0: nothing ?
1: 8bpp (1 color per byte / 1 byte per color)1
2: 2bpp (4 colors per byte)2
3: 4bpp (2 colors per byte)3
4: ?
5: ?
6: 8bpp (1 color per byte / 1 byte per color)4
7: 16bpp (2 bytes per color)5, 6

You can also force the first color to be transparent by setting byte 5 at 1.

Notes:
1 P=32, C=1, B=1
2 C=4, B=1
3 C=2, B=1
4 P=8, C=1, B=1
5 C=1, B=2
6 Each word refers directly to the color rather than pointing to a 65536 colors-palette, essentially making said palette useless.


Opacity formula for cases 1 and 6 is:
O=math.floor(V/P) mod (256/P)
Where:
_V is the pixel's value (from 0 to 255);
_P is the number of colors allowed per palette before it loops again;
_O=0 is the highest transparency;
_O=(256/P)-1 is the highest opacity.

Bitmap size is determined by the following formula:
S=T×C/B
Where:
_T is the Texture Data Length;
_C/B is the number of colors per number of bytes.

Result S is always a number in the form of 2n:
_if n mod 2 is equal to 0, then the exported bitmap will be a square with a side's length equal to the square root of S;
_if n mod 2 is equal to 1, then the exported bitmap will be a rectangle with a width equal to the square root of S/2 and a height equal to twice the width.


At the time of writing, since there is no TPS to BMP converter, you'll have to do all those operations manually if you want to modify a texture inside a APS.


Don't hesitate to point out any mistake or misconception.
If you have any question or anything to add, feel free to do so.
This explanation is not complete, as such information in the post might be updated in the future.
Posted on 04-11-15, 09:15 pm in Export a SPA to a BMP
Death by cuteness

Karma: 6564
Posts: 274/598
Since: 05-01-13
Mutual compatibility with NSMBeditor ?
That was my (retrospectively shitty) idea.

Even without thinking about the png format, I just realized that actually the TPS texture uses the exact same pixel-positioning than a 8bpp bitmap, the only difference being the transparency that is.

But yeah pretty sure everyone worth their salt already knew it, but I didn't… Fuck me, I guess…

That's what happens when I get too excited, I am TOO focused and then become oblivious to even time-saving details…
Posted on 04-15-15, 07:57 pm in prototype Fairy-type in Black 2 White 2 (rev. 1 by  MeroMero on 04-15-15, 10:22 pm)
Death by cuteness

Karma: 6564
Posts: 281/598
Since: 05-01-13
Rather than C/P my own tutorial again, I'm going to link to this page instead:
http://projectpokemon.org/forums/showthread.php?45888


EDIT: Sorry about the previous video, it didn't held my quality standard, yet uploaded it anyways.
This one is much better and doesn't chop half the frames (most notably Extrasensory's animation).
/EDIT

Fairy-type in action, nothing too fancy:
Posted on 04-16-15, 10:15 pm in Export a SPA to a BMP
Death by cuteness

Karma: 6564
Posts: 282/598
Since: 05-01-13
I know this is somewhat what is already told in the SPA documentation, but I decided to do a breakthrough of how the data was read.
This is my attempt for a simpler-to-understand mechanics of the Particle data.



Particle length:
Generic data + Flag data

Generic data is always 96 bytes long.

Flag data is determined by the first 4 bytes (or 32 bits) of the Generic data.
The aforementionned bytes are in little-endian: GH IJ KL MN.
Reverse them: MN KL IJ GH.
Then convert the string from hexadecimal to binary.

MN KL IJ GH(16)

M3M2M1M0N3N2N1N0 K3K2K1K0L3L2L1L0 I3I2I1I0J3J2J1J0 G3G2G1G0H3H2H1H0(2)

Bit 0 (H0) is the rightmost bit, while bit 31 (M3) is the leftmost bit.


Flag data's length is:
J0×12 + J1×12 + J2×8 + J3×12 + L0×24* + N0×8 + N1×8 + N2×16 + N3×4 + M0×8 + M1×16
If a bit is activated, it is equal to 1, else it is equal to 0.


Offsets of Flag data:
_the offset of the first bit activated is always 0×60;
_the offset of the second bit activated is 0×60 + length of the first bit activated;
_the offset of the third bit activated is 0×60 + length of the first bit activated + length of the second bit activated;
_etc…
The bits are always activated in the order given by the formula.


For example if only J2, J3 and L0 are activated, the formula would be:
0×12 + 0×12 + 1×8 + 1×12 + 1×24 + 0×8 + 0×8 + 0×16 + 0×4 + 0×8 + 0×16
=> 8+12+24
=> 44
thus the Flag data would be 44 bytes long, which means:
_Particle data would be 140 bytes long;
_J2 offset would be 0×60;
_J3 offset would be 0×68;
_L0 offset would be 0×74;


Textures seems to be summoned by a given particle when J3 is activated, from there you can specify the textures who will be used, as well as how many (up to 8).


*Erratum: I had trouble at first because I was assigning a value of 20 for the length of L0, like specified in the documentation, but it simply didn't add up to the rest of the data.
This is where I realized that the data length for L0 really was 24, and then the data flowed like a charm.
Posted on 04-17-15, 05:28 pm in Export a SPA to a BMP (rev. 3 by  MeroMero on 04-18-15, 05:28 pm)
Death by cuteness

Karma: 6564
Posts: 286/598
Since: 05-01-13
Due to the peculiar nature of this texture, next step would be to look at the particle data to single out anything out of the ordinary.

I already separated the 34 particles to ease the task:
Posted on 04-20-15, 06:30 pm in Misc. patches thread (rev. 1 by  MeroMero on 04-20-15, 06:30 pm)
Death by cuteness

Karma: 6564
Posts: 293/598
Since: 05-01-13
Nope. Just tested and the game isn't smart enough to recognize that you touched the key (or the flagpole for that matter) while being Mega, since Mario automatically reverts back to Super.

What the game checks is Mario's current powerup on the map.
Forcing the powerup on 3 on the map does make the game consider the alternate route instead, but since you can't have Mega-Mario on the map outside of cheats, value 3 is essentially wasted.
Posted on 04-21-15, 06:19 pm in Non-glitchy fourth pipe
Death by cuteness

Karma: 6564
Posts: 295/598
Since: 05-01-13
He means the grey 2×2 tiles square that make the corner of some pipes, aka:
It is represented by those files in the polygon_unit folder:
I_do_kanagu_ld.nsbtx
I_do_kanagu_lu.nsbtx
I_do_kanagu_rd.nsbtx
I_do_kanagu_ru.nsbtx


In fact I did that in my hack, but on top of that I modified 8 other sub-files inside I_dokan.nsbtx:
do_kousa_t_ld
do_kousa_t_lu
do_kousa_t_rd
do_kousa_t_ru
do_kousa_y_ld
do_kousa_y_lu
do_kousa_y_rd
do_kousa_y_ru


Keep in mind that I sacrificed those two joint-pipes in the process:
Posted on 04-23-15, 07:30 pm in Music and area overflow
Death by cuteness

Karma: 6564
Posts: 303/598
Since: 05-01-13
I can explain both conundrums:

The Mushrooms music reloads for Level 2-6 Area 1 View 2 because Area 1 have 2 views with different themes.
Had the View 1 been assigned the Mushrooms music instead, this "glitch" wouldn't happen and the music would flow without interruption from the beginning to the end.

For the Level 2-Castle, this is caused by the ?-Switch music stopping abruptly, the game still has memory of the previous soundtrack hence why you can hear the Castle theme for a split second (not always though).
Posted on 04-24-15, 07:54 am in Dinosaurs
Death by cuteness

Karma: 6564
Posts: 304/598
Since: 05-01-13
Dinosaurs you say? Dragons you say? Then there's only one true answer!

Say hello to Varanus komodoensis, more formally known as… Komodo dragon!

"Its keen sense of smell, the strength of its legs, its strong hide, and those enormous claws, make it a formidable predator… reminiscent of the great dinosaurs!"
-From the nature series Built for the Kill (Episode - Island)

The beast in the flesh:
Posted on 04-24-15, 09:03 pm in index NSMBdex of useful things for hacking
Death by cuteness

Karma: 6564
Posts: 306/598
Since: 05-01-13
I don't think this qualify as a likely question though, there are only 2 reported cases as far as I'm aware, and both because of NSMB3.
It's more of an exception than the rule.

Except for SKJmin, no one would even think about modifying the game code, making the answer almost pointless.

Also, for a moral standpoint, wanting to change back the gamecode just so you can open the ROM in NSMBe can be viewed as cheating your way out.
Posted on 04-27-15, 01:47 pm in Misc. patches thread
Death by cuteness

Karma: 6564
Posts: 310/598
Since: 05-01-13
Well, it would be kind of awful programming if you couldn't beat Mega Goomba just because the player happens to be mini and you were forced to lose a life because of that hypothetical technicality

Annnnnd… I knew I was forgetting something yesterday, the Bosses' behavior against the Starman:

Bowser Jr.:

Phase through.



Bowser:

Retains collision against a sliding Blue Shell, phase through otherwise.
Fireballs phase through.




Mummi-Pokey:

Phase through.
Sandballs retain collision.




Cheep Skipper:

Retains collision from above while out of water.
Retains collision against a sliding Blue Shell.




Mega Goomba:

OHKO if hit on the lower body (no points awarded).
Retains normal behavior if hit on the head.




Petey Piranha:

OHKO if hit on the lower body (4000 points).
Retains normal behavior if hit on the head.




Monty Tank:

The tank in itself retains normal behavior.
Retains normal behavior, except that a Ground-Pound deals the same damage as a normal Stomp.




Lakithunder:

Phase through.
Spinies retain collision obviously.




Dry Bowser:

Retains collision against a sliding Blue Shell, phase through otherwise.
Fireballs phase through.
Thrown bones retain collision.




Giant Bowser:

Retains normal behavior.
Fireballs phase through.
Homing Fireballs phase through.
Posted on 04-29-15, 09:00 am in Edit the symbol of the Star Coins
Death by cuteness

Karma: 6564
Posts: 312/598
Since: 05-01-13
Oops… seems like I didn't take into account that the palette for the Star Coins was only for the bottom screen.

Here is the updated palette for the Star Coins when they are loaded on the top screen:
d_2d_UI_O_1P_game_in_o_ud_TEN_ncl.bin

Sorry for the inconvenience
Posted on 04-30-15, 12:02 pm in The single levels thread! (rev. 1 by  MeroMero on 04-30-15, 12:39 pm)
Death by cuteness

Karma: 6564
Posts: 315/598
Since: 05-01-13
Earthquake without the Thwomps:




And you can control the magnitude too:



This kind of earthquake will only work when the camera is at the very bottom, for that reason Vertical scrolling must be disabled to ensure that the camera is locked to the 192 bottommost pixels.
Posted on 05-03-15, 02:43 pm in Sprite database overhaul
Death by cuteness

Karma: 6564
Posts: 325/598
Since: 05-01-13
Something like this is OK:
"Value X CRASHES the game. DO NOT USE IT!".
Posted on 05-04-15, 06:30 pm in Sprite database overhaul
Death by cuteness

Karma: 6564
Posts: 331/598
Since: 05-01-13
NSMBe has no problem with multiple checkboxes.

But that change was made:
_to have as few duplicated parameters as possible (shift by 8 pixels right and shift by 8 pixels down can both be grouped into a unique parameter Shift position).
_I feel it's more intuitive that way;
_also because of the Amp who has the same parameters, but on one nybble only, so it allows the DB to keep parameters' consistency between the sprites.
Posted on 01-30-16, 09:38 pm in New Actor discoveries (and extra info on old ones) (rev. 2 by  MeroMero on 01-31-16, 02:32 pm)
Death by cuteness

Karma: 6564
Posts: 335/598
Since: 05-01-13
Bullet Bill
Actor 27
Sprite set: 5-1
Data:
-- -- H- -- -- WD

Nybble 4 - H -, if set, pins the Actor's horizontal position on the same layer than the camera.

Nybble 10 - W - only works if nybble 11 is set to 1, still needs testing.

Nybble 11 - D - is the direction, already documented.


Fireball
Actor 78
Sprite set: 16-2
Data:
-- -- T- -A AA AM

Nybble 4 - T -, if nybble 11 is set to 0, controls the intensity of the fireball.
0: Leaves several sparks behind.
1: Leaves a little trail behind.
2: Doesn't leave any trail.


Nybbles 7-10 - AAAA -, if nybble 11 is set to 3, control the firing angle according to the unit circle.
To get the value in radians, apply the formula AAAA×π/32768, considering the circle rotates counterclockwise and starts from the right.
To get the value in degrees, apply the formula [450-(AAAA×45/8192)] mod 360, considering the circle rotates clockwise and starts from the top.
Noticeable values:
0×0000: Right
0×2000: Up-Right
0×4000: Up
0×6000: Up-Left
0×8000: Left
0×A000: Down-Left
0×C000: Down
0×E000: Down-Right


Nybble 11 - M - allows you to choose between mode 0 and mode 3.

Each instance of Actor 78 loads one Fireball, thus multiple fireballs can be loaded at the same time.
Cannot be loaded more than once without changing View.


Thunder
Actor 97
No need for manual input.


Flame Chomp
Actor 108
No need for manual input.


Snowball
Actor 156
No need for manual input.


Defunct Actor 229 (Some sort of platform judging by the data? Maybe uses puyo_lift.nsbtx as a texture?)
Actor 229 - Sprite 125
Sprite set: 8-4
Data:
II JJ KL H- -- --
Alas it seems that this sprite is impossible to load, but that doesn't mean it is devoid of data.

Nybbles 2-3 - JJ - are probably the Trigger ID 1?
Data supports the presence of Triggers ID, so most likely.

Nybbles 0-1 - II - are probably the Trigger ID 2?
Data supports the presence of Triggers ID, so most likely.

Nybble 4 - K - is probably the Trigger ID Check?
AND R1, R1, #1
Nybble 4 is stored in R1.
Basically if R1 is even, then R1 AND 1 = 0, else if odd R1 AND 1 = 1.
Trigger ID Check's code is exactly this, it gives credence to Nybble 4 being indeed the Trigger ID Check.


Nybble 5 - L - is probably the length by the looks of it?
If lower than 1, make it 1.
If higher than 4, make it 4.


Nybble 6 - H - is probably the height by the looks of it?
If lower than 1, make it 1.
If higher than 3, make it 3.



Banzai Bill
Actor 238
Sprite set: 5-1
Data:
-- -- H- -- -- WD

Nybble 4 - H -, if set, pins the Actor's horizontal position on the same layer than the camera.

Nybble 10 - W - only works if nybble 11 is set to 1, still needs testing.

Nybble 11 - D - is the direction, already documented.


Bill Blaster
Actor 248 - Sprite 27
Sprite set: 5-1
Data:
-- -- -- -- WD HU

Nybble 8 - W - was used by Nintendo devs, somehow as a copy of Nybble 10, but is apparently never called at all, needs testing.

Nybble 11 - U - is stored by the game for ulterior use but seems to never be called, still needs testing.


Banzai Bill Cannon
Actor 249 - Sprite 255
Sprite set: 5-1
Data:
-- -- -- -- -D -U

Nybble 11 - U - is stored by the game for ulterior use but seems to never be called, still needs testing.



Note on nybbles 0 to 3:
Those 4 nybbles are stored separately from the rest of the data, as such I came to the conclusion that if any of those nybbles are used, they will ALWAYS be identified as one category of Trigger ID.
Posted on 01-31-16, 02:16 pm in New Actor discoveries (and extra info on old ones) (rev. 1 by  MeroMero on 01-31-16, 02:33 pm)
Death by cuteness

Karma: 6564
Posts: 339/598
Since: 05-01-13
Knock yourself out, I don't have much interest in the sprite database nowadays.
If the sprite database was changed to a class database, which by all rights should be the logical choice now, then maybe it will spark my interest again, maybe.

EDIT: Fireball Actor updated.
Posted on 01-31-16, 04:36 pm in The single levels thread!
Death by cuteness

Karma: 6564
Posts: 340/598
Since: 05-01-13
Here you go: (Retrieved from the description of the video)

Snow levels now have an appropriate end-of-level castle that matches the level's theme.
As such, a new folder has been created in the ROM, called ztoride, containing a duplicate of S_tikei_nohara.ncg but with the added snow, as well as a duplicate of the 21 textures used for the end-of-level castle (again with the added snow).

This ASM hack will read a value unique to each level (that can be changed) to see if the game should load the normal castle graphics (bit=0) or the snow castle graphics (bit=1).
Posted on 01-31-16, 04:45 pm in New Actor discoveries (and extra info on old ones)
Death by cuteness

Karma: 6564
Posts: 341/598
Since: 05-01-13
See  Hiccup, this is why you shouldn't be so hasty when C/Ping another post. :/

Posted by Sharks
Nybble 11 - D - is the direction, already documented.


This was to be used in conjunction with your data, but now that you've wiped it out…

Nothing a Google cache can't find thankfully.
Posted on 02-03-16, 07:35 pm in Misc. patches thread
Death by cuteness

Karma: 6564
Posts: 342/598
Since: 05-01-13
Sinking Snow Pile (Sprite 274) works when length is 0

Decompress overlay 116.
Go to offset 0×A63 (US) 0×9BF (EU).
Change 9A into DA.