(shouting)

Treasure Chest and stuff

Anthrax 2 Multiply Themodynamics
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

Using a bunch of Exgfx slots is perfectly fine. It's only around 80 levels and we have Exgfx slots 300-FFF.
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

Chdata: what does 'dynamic spriting' mean? Like copying tiles from different resources into particular GFX slots that are in RAM? Cause that was what I was sort of like what I was thinking of. I still need to work that out, though. Like using the first chest GFX slot to upload the treasure into it once the chest is opened (that way the cookie coin is also still free to use).

Limepie: As interesting as it sounds, I'd prefer to wait with using that option. My reason is not for aesthetics (as in code/memory efficiency), but suppose we want to change one tile in the common header (for whatever reason) then we'd have to edit them all. If we're going with such an option, I'd rather have it certain that it is otherwise final. If I can make the above method to work then only a minimum amount of ExGFX files are needed and those will be independent to changes in the common tiles.

BTW. Has anyone tried to play with the patch a bit? I couldn't find any bugs in the chest I made so far, but peer reviewing can be helpful in locating issues or making improvements.

BTW2. Aww.. my poor thread lost it's sticky status. Ah well, there are more important issues at the moment now. ^_~"
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

<_< >_> Boy, it is sure quiet here all of a sudden.

Anyhow, I've been investigating how to show the graphics tile over the Layer 3 message and found several things. Writing the 16x16 sprite tile to the screen using the OAM isn't much effort, in fact I got that part of the code running already.

The trickier part is to have the windowed HDMA box + Layer 3 text above all regular sprite / bg layers, but still show the treasure ontop of that again. The easiest way would be by removing sprites from the HDMA window masking, but then any sprite on-screen will appear over the box... The easiest way I found to get around this is by using two HDMA channels to generate left & right halves of the message box, so an empty segment can be left open in the center. That spot is then filled up with the treasure sprite (with max priority), hence completing the entire box without graphical glitches.

As for the GFX files I think I'll be going with Limepie's suggestion to use separate GFX00 for every chest, as making the tile dynamic requires overwriting VRAM during normal operation. The main problem is that VRAM can only be accessed in the VBlank period. E.g. in the NMI, unless we only support ZSNES. That dodge emu doesn't care about any rules. The dynamic spriting patch doesn't help here as it isn't generic enough, or would impose other restrictions on the level designers which I think would be a bad idea. And I fear writing a custom JSL subroutine for the NMI might break something else, so it doesn't seem too viable at the time being.
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

I really have no problem with going back and making a new exgfx file for each level so you really don't need to worry about that.
User avatar
yoshicookiezeus
Help! pawprint
Posts: 148
Joined: 15 years ago
Pronouns: he/him/his
Location: Sweden

Re: Treasure Chest and stuff

Post by yoshicookiezeus »

The main problem with that would probably be ROM space. One ExGFX file takes up 4 kB, and with one for each of the 95 levels that makes for a grand total of 380 kB, or almost a tenth of the possible available space we have. A better idea would probably be to have the sprite tile use the second page and read the tile number from some freeRAM address set through levelASM; I imagine that a lot of people are already using ExGFX for either SP3 or SP4, which would reduce the number of extra ExGFX files quite a bit.

Or perhaps someone could take a look at dsx.asm and try modifying it to allow uploads to one of the unused tiles in SP1?
User avatar
Tails_155
May be dead.
Posts: 23
Joined: 14 years ago
First name: Kit/Tails
Pronouns: he/him/his
Location: The Moon or Something.

Re: Treasure Chest and stuff

Post by Tails_155 »

HEY GUYS! HOW ABOUT THIS? Can you use ASM to check a position in a graphics file? Because You could save at LEAST 4 to a single ExGFX (for GFX0 replacements) by storing one in each of the HEY THERE EVERYONE segments since they're not going to be used in a level...Then if the X is able to hold graphics (the top left 4 tiles) that's 5, dividing by... 5...

Say: level 1 tiles 300 301 310 311, Level 2 tiles 302 303 312 313, level 3 tiles 304 305 314 315, level 4 306 307 316 317, level 5 308 309 318 319... repeat with 6-10, etc.

then it's only 76 KB no?
I'm member number 499 (⬤)∀(⬤)
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

Well, ycz said that in-level the Nintendo Presents switches to tiles mario uses (or something like that) so we can't use it.
User avatar
Tails_155
May be dead.
Posts: 23
Joined: 14 years ago
First name: Kit/Tails
Pronouns: he/him/his
Location: The Moon or Something.

Re: Treasure Chest and stuff

Post by Tails_155 »

Oh, darn.
I'm member number 499 (⬤)∀(⬤)
User avatar
Isocitration
Posts: 33
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Isocitration »

I have an idea, and it would only require a few ExGFX pages plus a few minor additions to existing ones.

ExAnimation. Have a few pages filled with the treasure graphics, locate the correct page with the levels treasure on it, animate it over the sprite graphic, and that should solve the issue. Unless I'm mistaken somewhere of course.

And even if that level's Exanimation page is full already, I'd like to point out this:
SMWC Tip wrote:Tip: Keep in mind that the maximum size for an ExAnimation ExGFX file is 16 by 13 tiles, rather than 16 by 8 tiles like you would expect.
Source: http://www.smwcentral.net/faq/totd.txt

I've never actually seen this utilized anywhere before, but we should be able to use those extra tile rows to fit in a treasure if the rest of the page is full.

Keep in mind though that utilizing the extra space increases the ExGFX size to 8 Kb, and LM gives a warning upon inserting it.
raocow wrote:you are dommed iso.
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

That's a great idea. All the chest tiles could fit on one exgfx file. The only problem I can see with it is if a level utilizes every exanimation space but that could be easily solved by using an extra exgfx file with the tile already in its place instead of exanimated on.
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

yoshicookiezeus wrote:The main problem with that would probably be ROM space. One ExGFX file takes up 4 kB, and with one for each of the 95 levels that makes for a grand total of 380 kB, or almost a tenth of the possible available space we have.
I thought SMW compresses all gfx files when inserted in the ROM. Otherwise, having separate files isn't a good idea after all.
yoshicookiezeus wrote:A better idea would probably be to have the sprite tile use the second page and read the tile number from some freeRAM address set through levelASM; I imagine that a lot of people are already using ExGFX for either SP3 or SP4, which would reduce the number of extra ExGFX files quite a bit.

Or perhaps someone could take a look at dsx.asm and try modifying it to allow uploads to one of the unused tiles in SP1?
Actually, what I had in mind at first was the following:
-The treasure GFX are stored in one of the level's GFX files, BG/SP doesn't matter
-An absolute tile index pointer is stored in ROM (e.g. a direct VRAM address).
-When the chest is opened the first chest sprite (SP1=GFX00 at tile 0x20) is free as the closed chest tiles aren't used anymore as there's only 1 chest per level.
-The tile index pointer is used to copy the data from the arbitrary location to SP=1 tile 0x20 in VRAM. Both read/write VRAM must occur during VBlank period.

That would make showing the graphics via OAM is easy (fixed location) and gives maximum freedom to the designer to place the tile somewhere in one of the free spaces of any (Ex)GFX file that is used. If it's wasn't for VRAM restrictions this would work like a charm.
Isocitration/Limepie wrote:ExAnimation ideas
I'm not sure if ExAnimation will do the job as the treasure has to be shown using sprite tiles, using Layer1/2 will screw up the background afterwards. I'll try to look into that first. Reading the other posts leads me to the conclusion it would still be worth writing such code for the NMI, cause that's how dsx.asm also does it.
User avatar
Isocitration
Posts: 33
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Isocitration »

The sprite layer can be animated just as easily as layers 1 and 2 can, so unless it conflicts with layer 3 in some way, exanimation shouldn't be too problematic.
raocow wrote:you are dommed iso.
User avatar
yoshicookiezeus
Help! pawprint
Posts: 148
Joined: 15 years ago
Pronouns: he/him/his
Location: Sweden

Re: Treasure Chest and stuff

Post by yoshicookiezeus »

Diortem wrote:Actually, what I had in mind at first was the following:
-The treasure GFX are stored in one of the level's GFX files, BG/SP doesn't matter
-An absolute tile index pointer is stored in ROM (e.g. a direct VRAM address).
-When the chest is opened the first chest sprite (SP1=GFX00 at tile 0x20) is free as the closed chest tiles aren't used anymore as there's only 1 chest per level.
-The tile index pointer is used to copy the data from the arbitrary location to SP=1 tile 0x20 in VRAM. Both read/write VRAM must occur during VBlank period.
If you're going to write the tile directly to VRAM anyway, why not patch a graphics file containing all the various treasure graphics to the ROM and read the tile (determined by what level you're in) from there? That way, we won't need any extra ExGFX files at all.
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

YoshiCookieZeus: You have a point there, then one only needs to patch one or two GFX files into the ROM. Plus it would simplify the VRAM routine.

My reasoning for keeping them in the level's (Ex)GFX files is because of the palettes, which are from my point of view, beyond control. I.e. having a variable palette is possible, but I can only select 8-F, not the actual used colors cause then the screen could screw up. But since each treasure needs to be tested/inserted on a level basis that doesn't matter too much all the same.~

Isocitration: Sounds good as well. Layer 3 shouldn't be an issue as it is already restricted by the text message itself. I'll have tinker with it to understand what really does, and how it works.


I'll think this over for today. I need to make up my mind here on what works best / is least error prone.
User avatar
yoshicookiezeus
Help! pawprint
Posts: 148
Joined: 15 years ago
Pronouns: he/him/his
Location: Sweden

Re: Treasure Chest and stuff

Post by yoshicookiezeus »

Diortem wrote:My reasoning for keeping them in the level's (Ex)GFX files is because of the palettes, which are from my point of view, beyond control. I.e. having a variable palette is possible, but I can only select 8-F, not the actual used colors cause then the screen could screw up. But since each treasure needs to be tested/inserted on a level basis that doesn't matter too much all the same.~
That would be a problem no matter the method of uploading the graphics, would it not? Just have it use palette E or F; the second halves of those palettes are used by none of the default sprites and very few custom ones. Or if this still causes trouble, you could have a big table determining the palette used on a level-by-level basis.
User avatar
Tails_155
May be dead.
Posts: 23
Joined: 14 years ago
First name: Kit/Tails
Pronouns: he/him/his
Location: The Moon or Something.

Re: Treasure Chest and stuff

Post by Tails_155 »

I think YCZ said this in words over my head, but why not just do like with dynamic sprites and manually insert the graphics file somewhere and have the tiles searched for, that way there is no level-by-level ExGFX file, they're just pre-inserted.
I'm member number 499 (⬤)∀(⬤)
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

Then I think we all have roughly the same idea in our head, but wrote it down differently and more/less descriptive. I didn't mention this before, but I was going to have a separate table for the palette index which can be inserted along with the text messages in automated fashion using the tool I made.

As soon as I can decipher the NMI routine (using all.log for starters), adding a small routine to copy a few data bytes into fixed VRAM address on the specific conditions of the treasure box trigger should work. I'll add one or two binary GFX files along the asm patch so it can be inserted by running xkas.

- - - -

That leaves me with one question, and considering Limepie has made the base ROMs so far I'm addressing him here in particular. For insertion in the base rom would you rather like my tool generates an output ASM file with a database that can be patched on the ROM afterwards, or writes the data directly in the ROM. E.g. there are two possible flows:

xkas.exe + Chest_Patch.asm + Chest_Gfx.bin + A2MT_Rom.smc -> Chest_Rom.smc
Chest_Tool.exe + Chest_Data.txt + Chest_Rom.smc -> Final_Chest_Rom.smc

or

Chest_Tool.exe + Chest_Data.txt -> Chest_Data.asm (containing a database in text)
xkas.exe + Chest_Patch.asm + Chest_Data.asm + Chest_Gfx.bin + A2MT_Rom.smc -> Final_Chest_Rom.smc

Where:
Chest_Patch.asm - The overall custom routines
Chest_Gfx.bin - Treasure gfx data (uncompressed)
Chest_Data.txt - Variable input parameters per level (palette, name, value, message)
Chest_Tool.exe - tool for processing Chest_Data.txt, so no manual intervention is needed
A2MT_Rom.smc - an input rom

My guess would be the latter would be preferred, but I'm just making sure.
User avatar
keckcellent
Posts: 0
Joined: 14 years ago
Location: Catskills, NY

Re: Treasure Chest and stuff

Post by keckcellent »

All this ASM stuff is above my head and I have just a basic understanding of whats going on. But what I do understand does sound pretty good - dynamic sprites, palettes E&F, etc. I'm really just here to say that I think that the chest sprite is coming along quite nicely. I played around with it a little and didn't notice any bugs. My chest (in my level) was green but it worked. Keep up the good work.
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

I think I would prefer the second option so that it's inserted with a patch and not a tool.
User avatar
Chdata
Posts: 11
Joined: 14 years ago
Location: Computer Chair

Re: Treasure Chest and stuff

Post by Chdata »

Well my suggestion is still to make it like any other dynamic sprite with a single treasure.bin of all the treasure images and use the 3 16x16 spots reserved for the chest in gfx00.

As for making the treasure appear above the message and other sprites below it, yep, cutting a box is the only way to do it. That was an overly complicated thing to do though so I settled for allowing other sprites infront of it.
Image
Trouble with a capital COW.

<math>\tan{A}\sin{N}</math>
User avatar
Diortem
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Diortem »

It works! I got the dynamic VRAM routines in the NMI going. :D The treasure tiles are now completely independent from the rest of the graphic files, like most of you proposed. Combine that with dual windowed HDMA boxing, some windowing logic (register $212A) and you get a message box that will only show the treasure sprite over the text and nothing else.~ The sprite looks a bit far in the corner, but that's because the name can extend 2 more characters.
A2MT_Chest_w_Treasure.png
A2MT_Chest_w_Treasure.png (5.77 KiB) Viewed 8419 times
Keckcellent: Thanks for the input! I think there's something strange going on with the palettes indeed. If you look a the picture above the in-game chest and treasure sprite use exact same color indices and palettes, yet the one at the top is darker. In Lunar Magic they both look dark when editing, so it seems the palette of the sprite next to Demo is manipulated by something, just like yours is green most likely. The only thing I could think of is that 'color addition' is enabled (register $2130 or $44 using the in-game mirror). Hmm... does anyone have some ideas about this?

Limepie: Okay, I'll modify my tool to generate a separate output file instead of putting it into the ROM. I'll fix up all my stuff, test it on a clean rom and post a link here in the thread to the source files. It should be done in a few days.

Chdata: Indeed, that is what has become of it. ;) Although, I saved a tile cause the closed treasure chest tile can be overwritten once it is opened. So people can still put pink berries in their levels, as that third tile you used was used for the cookie cloud IIRC.
User avatar
raocow
the death of the incredible huge
Posts: 4078
Joined: 15 years ago
Location: maybe the Wizards are the most complex, and the sales guys are up their daily
https://raocow.talkhaus.com/

Re: Treasure Chest and stuff

Post by raocow »

oh my god oh my god oh my god
the chillaxest of dragonsImage
Image
Image
limepie20
Posts: 0
Joined: 14 years ago
Location: Doesn't Matter

Re: Treasure Chest and stuff

Post by limepie20 »

Alright, thanks Diortem. I'll try to get this in with the next baserom, too (the patches aren't completely functional yet).
User avatar
Money
Posts: 467
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by Money »

That chest sprite looks... weird. I think It may be the shading.
What palette does it use? I may be able to edit it to look a bit better.
kil3
Posts: 0
Joined: 13 years ago

Re: Treasure Chest and stuff

Post by kil3 »

I still like red chests with gold filigree. Brown ones just kinda look like a box.
Locked