(Link to AcmlmWiki) Offline: thank ||bass
Register | Login
Views: 13,040,846
Main | Memberlist | Active users | Calendar | Chat | Online users
Ranks | FAQ | ACS | Stats | Color Chart | Search | Photo album
06-26-24 08:48 PM
0 users currently in Programming.
Acmlm's Board - I3 Archive - Programming - [VB-DX7] Fighting game paletteswaps New poll | |
Add to favorites | Next newer thread | Next older thread
User Post
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6337 days
Last view: 6337 days
Posted on 05-13-06 12:53 PM Link | Quote
I have here in one hand, a fighting game that uses XML to describe it's characters. This includes any alternate colors a fighter can have if needed.

In the other, I have the DirectDrawPalette object which does not work. Calling FighterDDS.GetPalette fails horribly. The one time it did work, it contained only black.

I've just now tried to recolor the characters by locking their surface and get/compare/set pixels. This is not only very slow on sprite sheets that are in excess of 800x1600 pixels, but it also does not work.

Any suggestions?
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6617 days
Last view: 6617 days
Posted on 05-13-06 01:46 PM Link | Quote
Just to cover the obvious, GetPalette/SetPalette will only work on Palettized surfaces of course (8 or less bpp). If you have RGB surfaces they will of course fail when you try to assign a palette.

I see no reason why setting individual pixels would not work as long as the surface is locked. Perhaps when you compare you're comparing colors of another format? If you have a 16-bit surface or something, comparing them to a 24 or 32-bit RGB value of course won't work unless you do color conversions. (Though really, I don't see why you'd need color comparisons for a palette change anyway -- just plug in a new palette and replace the old one. Well that's what I'd do anyway)


But regardless. The first thing you should always do in a situation like this is check error returns. GetPalette() and SetPalette() will both return an error code if they fail. Check that error code to figure out what the problem is.
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6337 days
Last view: 6337 days
Posted on 05-14-06 06:56 AM Link | Quote
Just to cover the obvious, GetPalette/SetPalette will only work on Palettized surfaces of course (8 or less bpp).
All my images are palettized to save space.

Dim mypal As DirectDrawPalette
Dim palents(16) As PALETTEENTRY
Set mypal = HealthBars.dds.GetPalette
mypal.GetEntries 0, 16, palents


The GetPalette call raises DDERR_GENERIC, an "undefined error condition". I can't figure out shit from that.

Naturally, the GetEntries call fails because mypal is nothing.
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6617 days
Last view: 6617 days
Posted on 05-14-06 01:15 PM Link | Quote
Well for starters it looks like you're calling it wrong.

Only error codes are returned... anything else you want "filled" by the function must have a pointer passed to it. Er wait... VB... I mean "passed by reference". Your finished product will probably look something like this:




Dim mypal As DirectDrawPalette
Dim errorcode As HResult

errorcode = HealthBars.dds.GetPalette mypal




'errorcode' catches the returned error value. 'mypal' is passed by reference to be filled with the Palette information -- much like what you do with 'palents' in your GetEntries call below it.


I'm suprised that even compiled. How would it compile the function call without having all the required arguments? Gah VB drives me nuts. Most languages would give you a nice error saying "hey you're not giving this function enough arguments" instead of allowing you to compile just fine and then have you chase down the problem yourself. I guess VB tries to make things so easy it actually makes them harder.

</obigatory VB bash>


(edited by Disch on 05-14-06 12:17 PM)
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6338 days
Last view: 6338 days
Posted on 05-14-06 06:52 PM Link | Quote
VB always warned me if I didn't supply enough arguments.
Guy Perfect









Since: 11-18-05

Last post: 6340 days
Last view: 6338 days
Posted on 05-14-06 08:58 PM Link | Quote
Disch, do some research before posting next time. mypal isn't being assigned with a function call. Using the Set statement, an object reference is applied to a class variable.

Set mypal = HealthBars.dds.GetPalette is not a function call; it is assignnig the object reference of mypal to the same object as HealthBars.dds.GetPalette.

I think the problem here is that HealthBars.dds.GetPalette does not appear to be an object, but a method. I know Microsoft did a slop-tastic job making VB type libraries for DirectX and OpenGL, so the development environment probably isn't able to discern that at compile time.

What I recommend, Kyoufu Kawa, is that you make sure you are using GetPalette correctly. Like Disch said, you probably pass mypal as an argument to the GetPalette function call.



EDIT:
I don't have experience with DirectX (I use OpenGL), but I thought of a possibility. Does GetPalette create a class object and return it in the C++ headers? If it does, then the type library is a COM hack and shouldn't technically work with Visual Basic. While your syntax would be correct under those circumstances, you may have to find a workaround.


(edited by BGNG on 05-14-06 08:02 PM)
Disch

Red Cheep-cheep


 





Since: 12-10-05

Last post: 6617 days
Last view: 6617 days
Posted on 05-14-06 10:33 PM Link | Quote
EDIT - Bah fine.

So it turns out I'm the douchebag this time. Sorry everyone. It must be my time of the month.


(edited by Disch on 05-14-06 09:42 PM)
(edited by Disch on 05-14-06 09:49 PM)
(edited by Disch on 05-15-06 01:33 PM)
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6337 days
Last view: 6337 days
Posted on 05-15-06 01:10 PM Link | Quote
Originally posted by MSDN Library, GetPalette Call

Remarks
The object returned by a successful function call must be assigned to a DirectDrawPalette object variable. For example:
Dim DDPalette as DirectDrawPalette
Set DDPalette = object.GetPalette()

Sheesh... I've been calling it right all along! Now to read the rest of the thread.

Edit: No, wait... I didn't... I'm gonna try adding (), call ya back tomorrow.


(edited by Kyoufu Kawa on 05-15-06 12:13 PM)
HyperHacker

Star Mario
Finally being paid to code in VB! If only I still enjoyed that. <_<
Wii #7182 6487 4198 1828


 





Since: 11-18-05
From: Canada, w00t!
My computer's specs, if anyone gives a damn.
STOP TRUNCATING THIS >8^(

Last post: 6338 days
Last view: 6338 days
Posted on 05-15-06 07:15 PM Link | Quote
Also try Set DDPalette = Call object.GetPalette. A wild guess but I think that's what Call does.


(edited by HyperMackerel on 05-15-06 06:15 PM)
Kyoufu Kawa
Intends to keep Rom Hacking in one piece until the end








Since: 11-18-05
From: Catgirl Central Station

Last post: 6337 days
Last view: 6337 days
Posted on 05-16-06 01:57 PM Link | Quote
Umm no. As far as I can remember, Call has been historically meant to call Functions like Subs, as a way not to need return variables. Nowadays, I suspect it's something to do with asynch calling, but don't quote me on that.

I also forgot to try. Was busy coding on an emulated Mac.

UPDATE
Set MyPal = MySurface.GetPalette() - MSDN example syntax, RTE
Set MyPal = MySurface.GetPalette - What I had before, RTE
Set MyPal = Call MySurface.GetPalette() - HyperCracker's suggestion, won't accept "Call".

Then I went to poop for a while, and got an idea. So now I'm making temp copies of the BMP files and replacing the first 32 palette entries with those referred to. This means I can put all the wanted palette swaps in the BMP file itself. 32 colors a swap gives me at least four to choose from, which is plenty, and still have room for props' colors.


(edited by Kyoufu Kawa on 05-17-06 12:22 PM)
Add to favorites | Next newer thread | Next older thread
Acmlm's Board - I3 Archive - Programming - [VB-DX7] Fighting game paletteswaps |


ABII

Acmlmboard 1.92.999, 9/17/2006
©2000-2006 Acmlm, Emuz, Blades, Xkeeper

Page rendered in 0.042 seconds; used 401.20 kB (max 495.42 kB)