GRFCodec feature discussion thread

Discussions about the technical aspects of graphics development, including NewGRF tools and utilities.

Moderator: Graphics Moderators

Locked
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

GRFCodec feature discussion thread

Post by DaleStan »

I've decided I need my own thread for this, so here it is.

It turns out that I failed to check some of my code in grfcodec and nforenum, resulting in subtly broken NFO file reading, so here's 0.9.10, to fix that.

PNG support is stalled, due to me spending too much time attempting to write Patch code, but rest assured that it is still on the TODO.

NOTE: GRFCodec is now being maintained by members of the OpenTTD project. A thread discussing the latest preview release (as of August 2010) can be found here.
Last edited by DaleStan on 10 Jan 2007 18:44, edited 2 times in total.
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
Patchman
Tycoon
Tycoon
Posts: 7576
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

It's up on the patch site too now.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

I've implemented a new option that tells grfcodec to crop extraneous transparent blue out of real sprites. I think this works, but I'd to have some other people to test it too.

To enable, add -c to the command-line when encoding.

There are also several other changes since 0.9.10; see the the changelog for more details.
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: 5948
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> I've implemented a new option that tells grfcodec to crop extraneous transparent blue out of real sprites.

Does that mean it fits offsets depending on the cropped area(s)?

regards
Michael
Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Yes. It adjusts the offsets as necessary when it crops from the top or left sides. Obviously (I hope), it does not adjust the offsets when cropping from the bottom or right sides.
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: 5948
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> Yes. It adjusts the offsets as necessary [...]

Very nice. I´ve thrown down ttdpbase.grf for it (which is a good candidate, *lots* of unnecessary blue, <arrgh>, (my own sets don´t have that)) and it reduced it from 310KB to 289KB. 8)

Re-calculated offsets *seem* to be OK, but I´ve to test them more in-game (tram sprites). Do you like to check that file too?

regards
Michael
Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Actually, no. Bad candidate. I tried that some time ago, and cropping the foundation sprites messed up the landscape drawing something awful.
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
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Lakie caught me in an off-by-one error that was causing crashes, so here's a new version with that fixed.
Attachments
grfcodec-i386.tar.gz
(51.66 KiB) Downloaded 519 times
grfcodec-win32.zip
(79.51 KiB) Downloaded 730 times
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
User avatar
eis_os
TTDPatch Developer
TTDPatch Developer
Posts: 3603
Joined: 07 Mar 2003 13:10
Location: Germany
Contact:

Post by eis_os »

Will it crop as well fully blue sprites?

At least erails should have two fully blue helper sprites, so actually the ttdpatch base graphic will work, but the sorting may change when you crop certain helper sprites... (In the way how certain things get overdrawn, when in time...)

So I am not sure if it's a really good idea for all grfs without testing all current grfs and see what happens spritesorting wise...
TTDPatch dev in retirement ... Search a grf, try Grf Crawler 0.9 - now with even faster details view and new features...
Image
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

eis_os wrote:Will it crop as well fully blue sprites?
At least erails should have two fully blue helper sprites, [...]
Yes, indeed. NewStations also uses 2 full blue helper sprites (for icon display). (Although there´s no need to "crop" its sprites.)
So I am not sure if it's a really good idea for all grfs without testing all current grfs and see what happens spritesorting wise...
Anyway. At least for the "official" ttdpbase.grf we should do some cropping of its sprites because the usage of "blue" is somewhat excessive with that file[*]. I always wanted to do that. 8)

[ttdpatch.grf]
DaleStan wrote:I tried that some time ago, and cropping the foundation sprites messed up the landscape drawing something awful.
Possibly because of cropping such "all blue" helper sprites? (There´s one full blue sprite to be seen at the lower left corner in the screenshot). Other than that, it must be a bug. Don´t you think? I´ll do some testing today evening.

regards
Michael
Attachments
Clipboard01.png
Clipboard01.png (3.92 KiB) Viewed 19071 times
Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

eis_os wrote:Will it crop as well fully blue sprites?
It crops fully blue sprites from the right and bottom -- xrel and yrel are left unchanged.

If that is a problem, fixing should be pretty easy.
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: 5948
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> It crops fully blue sprites from the right and bottom [...]

Leaving one pixel of blue. So far so good.

Question remains, whether for sprite sorting reasons full blue sprites have to keep their dimensions unchanged? I don´t think so, but I could be wrong.

regards
Michael
Image
Patchman
Tycoon
Tycoon
Posts: 7576
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

The elrails block has two entirely blue sprites whose size must not be changed or the sprite sorter will have problems.

Maybe some way of marking sprites that should not be cropped would be nice? Somehow that would have to be stored in the .grf too or else decoding&re-encoding would break it again. Maybe bit 6 of the code?
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
User avatar
eis_os
TTDPatch Developer
TTDPatch Developer
Posts: 3603
Joined: 07 Mar 2003 13:10
Location: Germany
Contact:

Post by eis_os »

hmm, do we still have a bit free then? Maybe someday we want to allow spritestreams, or we create a fully new grf2 format for them, maybe after all better...
TTDPatch dev in retirement ... Search a grf, try Grf Crawler 0.9 - now with even faster details view and new features...
Image
Patchman
Tycoon
Tycoon
Posts: 7576
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

Maybe one just has to be careful when using the flag with the ttdpbase graphics, I don't think regular sets would have problems.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
michael blunck
Tycoon
Tycoon
Posts: 5948
Joined: 27 Apr 2005 07:09
Contact:

Post by michael blunck »

> Maybe some way of marking sprites that should not be cropped would be nice? [...] Maybe bit 6 of the code?

I don´t get what you mean with "code", but possibly you think of the sprite´s "compression byte"?

According to http://wiki.ttdpatch.net/tiki-index.php ... ompression it´s a byte but only bits 0, 1, and 3 are used ATM.

regards
Michael
Image
Patchman
Tycoon
Tycoon
Posts: 7576
Joined: 02 Oct 2002 18:57
Location: Ithaca, New York
Contact:

Post by Patchman »

michael blunck wrote:> Maybe some way of marking sprites that should not be cropped would be nice? [...] Maybe bit 6 of the code?

I don´t get what you mean with "code", but possibly you think of the sprite´s "compression byte"?
Yes, sorry, I called it "code" internally.
Josef Drexler

TTDPatch main | alpha/beta | nightly | manual | FAQ | tracker
No private messages please, you'll only get the answering machine there. Send email instead.
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

JGR just added two new operators to variational action 2, and I'm wondering what escape sequences to use for them.

Personally, I'm inclined to use '\2=' for operator 0E, and '\2,' for operator 0F, on the grounds that 0E, like '=', does assignment; and 0F, like ',', evaluates and discards its left-hand side, prior to returning its right-hand side.

Neither of these are perfect, though. The comma operator is rather obscure, and the store operation assigns left-value to right-location, not right-value to left-location. I also considered '\2->' for operator 0E, since the TI calculators' BASICs (well, at least the TI-83 and TI-92) use a right-arrow for an operation called "sto", which does take the value on the left and store it to the location on the right, but this suffers from the obscurity problem. It also looks a lot like the C's member-from-pointer operator, which is a completely unrelated operation.

Does anyone have any other suggestions?
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
User avatar
minime
Transport Coordinator
Transport Coordinator
Posts: 339
Joined: 18 Jan 2004 10:02
Skype: dan.masek
Location: Prague, Czech Republic
Contact:

Post by minime »

How about using letters, like something along the lines of \2s (as in store for 0E) and \2r (as in return for 0F)? I do realize it makes the codes language depended, but I think it's somewhat better than using an obscure operator (or one that usually functions differently).
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. --Albert Einstein
Image Image Image
DaleStan
TTDPatch Developer
TTDPatch Developer
Posts: 10285
Joined: 18 Feb 2004 03:06
Contact:

Post by DaleStan »

Somehow, \2s and \2r seem too short to me, but I can't really explain how they're worse than the \7g, \7G, \7gG, \7gg, \7GG, \7c, and \7C sequences. And I suppose it doesn't really matter what I think, what matters is what the people who will be using these think.

I can easily see allowing both those one-letter forms and the three-letter \2sto and \2ret forms.
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
Locked

Return to “NewGRF Technical Discussions”

Who is online

Users browsing this forum: No registered users and 1 guest