Color mapping problems

Discuss, get help with, or post new graphics for TTDPatch and OpenTTD, using the NewGRF system, here. Graphics for plain TTD also acceptable here.

Moderator: Graphics Moderators

Post Reply
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Color mapping problems

Post by Uwe »

Hi,

for the GermanRV project (see sig) I'm currently implementing lots of special stuff which relies on appropriate usage of recolor tables. For example, vehicles will provide "real" liveries which are achieved by recoloring a basic wrong-colored sprite using recolor tables. Now the code for that works fine in TTDPatch, but not in OTTD, all I get to see is the sprite as it is drawn in the underlying graphics file, without any recoloring applied.

The code for it looks like this:

Code: Select all

10 * 5	 0D 01 00 00 00				// set var 01 = var 00
11 * 9	 0D 00 00 00 FE FF 08 00 01		// reserve 256 tables
12 * 5	 0D 01 02 00 01				// set var 01 = var 00 - var 01
13 * 44	 06 01 82 03 01 82 06 01 		// add var 01 to the base of each table
14 * 44	 0A 0E 80 00 00 80 80 00 		// define 2*128 new sprites
...
here come the recolor tables, real sprites and other stuff
...
// check refit cycle to determine usage of 2CC sprites or false color sprites
 1887 * 14	 02 01 02 81 F2 00 FF 01 //
 	 03 00 00 00 	// 2CC case, goto 03 00 (points to 2CC sprites)
 	 04 00		// else goto 04 00 (points to false color sprites)

// CB 2D chain, select color table (Berlin)
 1889 * 17	 02 01 20 85
        7F 00 20 FF FF 00
        1A 00 00 00		// use recolor table 0
     00 00 80			

// CB 2D chain, select color table (Bochum)
 1890 * 17	 02 01 21 85 // colour mapping select
        7F 00 20 FF FF 00
        1A 00 01 00		// use recolor table 1
     00 00 80			

// CB 2D, select color mapping
 1891 * 18	 02 01 12 81 F2 00 FF 02 // check var F2 (refit cycle)
     20 00 01 01	// goto 20 (Berlin)
     21 00 02 02	// goto 21 (Bochum)
     02 00    		// else fail (no recoloring shall be applied to 2CC sprites)

// standard chain, check CBs
 1894 * 30	 02 01 01 81 0C 00 FF 05
     01 80 11 11	// CB 11, make vehicle shorter by one 1/8th
     10 00 16 16	// CB 16, articulation
     11 00 19 19	// CB 19, cargo subtype display
     12 00 2D 2D	// CB 2D, select color mapping
     13 00 33 33	// CB 33, sound effects
     02 00		// goto 02

// action 03
 1896 * 10	 03 01 01 46 01
 	 FF 00 00 	// buy menu, goto 00 00
 	 01 00		// default,  goto 01 00

... here come action 0, enabling all used CBs
Somebody with helpful advice? A test file can be provided if necessary.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Color mapping problems

Post by DaleStan »

Code: Select all

10 * 5	 0D 01 00 00 00				// set var 01 = var 00
11 * 9	 0D 00 00 00 FE FF 08 00 01		// reserve 256 tables
12 * 5	 0D 01 02 00 01				// set var 01 = var 00 - var 01

...

// check refit cycle to determine usage of 2CC sprites or false color sprites
 1889 * 17	 02 01 20 85
        7F 00 20 FF FF \2+
        1A 00 00 00		// use recolor table 0
     00 00 80			

 1890 * 17	 02 01 21 85 // colour mapping select
        7F 00 20 FF FF \2+
        1A 00 01 00		// use recolor table 1
     00 00 80
What happens to those var2s the second time the file is activated? Param 0 is now (usually, at least) 0, which is not what you need to be adding to get to recolor tables 0 and 1.

Also, from your comments, I assume you have 256 total recolor tables -- 128 for Windows and 128 for DOS. If this is the case, as a style/sanity issue, only reserve 128 sprites, and replace them twice, with two action As. Once for DOS and again for Windows. Whichever one comes second should be skipped for the other palette is in use. Otherwise, each CB 2D call needs to check both the refit cycle and the DOS/Win state.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Re: Color mapping problems

Post by Uwe »

I'm afraid I can't completely follow you here. Are you hinting at the information given in the wiki on Action 06, pointing out the fact to skip the whole GRM stuff during the test stage? If that's the case, then yes, that is indeed missing from the file. It is also missing from the example given in the wiki on the very same page... How would I be able to check if this missing test could lead to problems? I just tried repeated activation and deactivation ingame, and it always worked in TTDPatch, I couldn't produce any corrupt sprites. OTTD wasn't impressed at all, always ignoring the recoloring. To me it seems that OTTD just completely ignores callback 2D.

DOS/Windows is no concern here, I am in fact using all 256 recolor tables for Windows only.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Color mapping problems

Post by DaleStan »

Oh. Nevermind. I assumed your code was the way I'd do it the first time through; I thought sprite 12 was " 12 * 5 0D 00 02 00 01 // set var 00 = var 00 - var 01"

Which is, obviously, not the way to do it. Now that I've read the code correctly, I do not see a problem. You might get useful information with -d grf=9 or whatever it is that OpenTTD uses to generate gobs of GRF-related debugging output.
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Color mapping problems

Post by michael blunck »

Uwe wrote:[...] To me it seems that OTTD just completely ignores callback 2D.
No, it works alright in the DBXL 0.9 here.

regards
Michael
Image
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Re: Color mapping problems

Post by Uwe »

Ok, I started OTTD with debugging enabled just as DaleStan suggested. I could not see anything that would resemble an error message, but I have attached the logs as well as the grf file that I use for testing. Hopefully that helps tracking down the problem.
Attachments
recolornotworking.zip
(18.34 KiB) Downloaded 51 times
User avatar
planetmaker
OpenTTD Developer
OpenTTD Developer
Posts: 9432
Joined: 07 Nov 2007 22:44
Location: Sol d

Re: Color mapping problems

Post by planetmaker »

Uwe wrote:Ok, I started OTTD with debugging enabled just as DaleStan suggested. I could not see anything that would resemble an error message, but I have attached the logs as well as the grf file that I use for testing. Hopefully that helps tracking down the problem.
Excerpt from your log:

Code: Select all

dbg: [grf] [recolortest.grf:1] DecodeSpecialSprite: Handling action 0x08 in stag
e 0
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'trg1r.grf'
dbg: [grf] LoadNewGRFFile: Custom .grf has invalid format
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'trgcr.grf'
dbg: [grf] LoadNewGRFFile: Custom .grf has invalid format
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'trghr.grf'
dbg: [grf] LoadNewGRFFile: Custom .grf has invalid format
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'trgir.grf'
dbg: [grf] LoadNewGRFFile: Custom .grf has invalid format
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'trgtr.grf'
dbg: [grf] LoadNewGRFFile: Custom .grf has invalid format
dbg: [grf] LoadNewGRFFile: Reading NewGRF-file 'openttdd.grf'
dbg: [grf] [openttdd.grf:1] DecodeSpecialSprite: Skipping action 0x07 in stage 0
Assuming that your newgrf is the only one loaded, it fails with the action 0x08 in a few places. Though unlikely, alternatively you just might have faulty base graphics. With clean trunk I don't get such errors.
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Re: Color mapping problems

Post by Uwe »

Just rechecked that, even without any newgrfs loaded, it keeps telling me those messages about the base graphics. Quite weird, as these are straight from a clean TTDX CD archive I keep on my harddrive. Suggestions?
Apart from that, how could an action 08 possibly fail? And what would happen then? I'd assume the newgrf wouldn't be loaded at all, which isn't the case here. The newgrf runs just fine, only the part with the refitting doesn't work.
Rubidium
OpenTTD Developer
OpenTTD Developer
Posts: 3815
Joined: 09 Feb 2006 19:15

Re: Color mapping problems

Post by Rubidium »

It's just telling you that it found the TTD (not New)GRFs and that it determined that they are not a NewGRF. Absolutely nothing to worry about.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Re: Color mapping problems

Post by DaleStan »

Bother. That was not the debugging information I was hopping to see.

I was more interested in the type of data that would be found in grfdebug.log. Does anyone know how to get that sort of information from OpenTTD?
To get a good answer, ask a Smart Question. Similarly, if you want a bug fixed, write a Useful Bug Report. No TTDPatch crashlog? Then follow directions.
Projects: NFORenum (download) | PlaneSet (Website) | grfcodec (download) | grfdebug.log parser
Uwe
Transport Coordinator
Transport Coordinator
Posts: 359
Joined: 09 Jul 2004 14:05
Location: Germany

Re: Color mapping problems

Post by Uwe »

Ok, I think I found the problem. It seems CB 2D does indeed not work - for road vehicles. Since Michael Blunck declared the CB would work I changed the vehicle to appear as a train, and behold, recoloring worked like a charm without further fiddling. Should this then reported as bug, and if so, where?
Eddi
Tycoon
Tycoon
Posts: 8289
Joined: 17 Jan 2007 00:14

Re: Color mapping problems

Post by Eddi »

frosch
OpenTTD Developer
OpenTTD Developer
Posts: 991
Joined: 20 Dec 2006 13:31
Location: Aschaffenburg

Re: Color mapping problems

Post by frosch »

Fixed in r15286.
The colour map cache was not invalidated on refitting.
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
User avatar
Roest
Traffic Manager
Traffic Manager
Posts: 215
Joined: 03 Apr 2008 08:18

Re: Color mapping problems

Post by Roest »

michael blunck wrote: No, it works alright in the DBXL 0.9 here.
Is that one released already and i'm just too stupid to find it?
michael blunck
Tycoon
Tycoon
Posts: 5954
Joined: 27 Apr 2005 07:09
Contact:

Re: Color mapping problems

Post by michael blunck »

Roest wrote:
michael blunck wrote: [DBXL 0.9]
Is that one released already and i'm just too stupid to find it?
No, not yet. I was speaking about my own working copy which you won´t find elsewhere, regardless of being stupid or smart. 8)

regards
Michael
Image
Post Reply

Return to “Graphics Development”

Who is online

Users browsing this forum: No registered users and 8 guests