Skip to content

Commit 5a971af

Browse files
committed
zztexview is now open source
1 parent 1e7f8f4 commit 5a971af

20 files changed

+16836
-0
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
end_of_line = lf
5+
insert_final_newline = true
6+
7+
# Matches multiple files with brace expansion notation
8+
[*.{c,h,ch}]
9+
charset = utf-8
10+
indent_style = tab
11+
indent_size = 3
12+
trim_trailing_whitespace = false
13+
14+
[*.md]
15+
trim_trailing_whitespace = false
16+

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
bin/
2+
*.o

README.md

Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
# zztexview
2+
3+
`zztexview` is a program for viewing, converting, and locating texture data in Nintendo 64 rom images and files dumped from them. Much inspiration was taken from [Texture64](https://github.com/queueRAM/Texture64).
4+
5+
![preview.png](preview.png)
6+
7+
## Features
8+
- Texture search locates pixel data matching a user-provided PNG file (even color-indexed formats are supported)
9+
- Export/import feature makes it easy to update existing textures
10+
- Create new texture banks from one or more PNGs, including the ability to share palettes
11+
- External palettes
12+
- Palette editing
13+
- Entirely self-contained with no external dependencies like the .NET Framework or Mono
14+
- Windows XP
15+
16+
## Supported Image Formats
17+
- rgba8888 (32 bit)
18+
- rgba5551 (16 bit)
19+
- intensity-alpha (16 bit)
20+
- intensity-alpha (8 bit)
21+
- intensity-alpha (4 bit)
22+
- intensity (8 bit)
23+
- intensity (4 bit)
24+
- color-indexed (8 bit)
25+
- color-indexed (4 bit)
26+
27+
## Quick Tips
28+
- First, click the `Open` button, or drag-and-drop a binary file onto the `left pane`.
29+
- Left-click any preview to bring up the `Import/Export PNG` dialog.
30+
- Right-click-drag in any preview window to scroll quickly.
31+
- Using the mouse wheel inside a preview window nudges it along one pixel at a time: perfect for making fine adjustments.
32+
- In a value box, you can right-click-drag up/down to rapidly change it, or use the mouse wheel for smaller increments.
33+
- Scroll the mouse wheel on any drop-down menu to quickly navigate through its items without having to click.
34+
35+
## Revision History
36+
* v1.0.2
37+
* Better `edge` results with `i` (intensity) formats
38+
* In exported images, alpha channel is user's selected 'blending' mode
39+
* `zztexview` is now open source
40+
* v1.0.1
41+
* Bug fix: could not edit value/text boxes after clicking drop-downs
42+
* Bug fix: "Scale" drop-down text now wraps properly when scrolling on it
43+
* Bug report credits: [AriaHiro64](https://github.com/AriaHiro64), [Zeldaboy14](https://github.com/Zeldaboy14)
44+
* v1.0.0
45+
* Initial release
46+
47+
## Manual
48+
```
49+
SYNOPSIS
50+
51+
zztexview is a program for viewing, converting, and locating
52+
texture data in Nintendo 64 rom images and files dumped from them.
53+
Much inspiration was taken from Texture64.
54+
55+
56+
LOADING FILES
57+
58+
To open a file for exploring, either click the 'Open' button
59+
or the left sidebar, or try dropping a file onto one of them.
60+
61+
62+
NAVIGATION
63+
64+
While you can edit the value boxes manually by clicking them, you
65+
will find the easiest way to navigate is by doing a right-click-drag
66+
inside any preview window. You do this by placing your cursor inside
67+
a preview, pressing and holding the right mouse button, then moving
68+
the cursor up or down. You can also do this inside a value box to
69+
quickly adjust its value up or down, or even navigate this manual.
70+
71+
Scrolling with the mouse wheel can also be used to adjust value
72+
box values, or quickly change a drop-down menu's selection without
73+
having to click it. Mouse wheel scrolling inside a preview area will
74+
nudge you forward or back a single pixel at a time.
75+
76+
77+
HOW CODECS WORK
78+
79+
Each codec describes a valid format/bit combination. For example,
80+
ci8 refers to a texture of the format ci (color indexed), where each
81+
pixel is eight (8) bits. Higher bit values provide more detail, but
82+
cost more space. A brief description of each format follows.
83+
84+
rgba contains a separate color/alpha value for every pixel
85+
86+
ci a series of index values, which are used to look up
87+
what color each pixel should be according to a palette
88+
(the palette offset is independent from the texture
89+
offset; multiple textures can use the same palette)
90+
91+
ia packed value list describing intensity (grayscale)
92+
and alpha (opacity) for every pixel
93+
94+
i every pixel contains a single value that is shared
95+
by all color channels: RGBA (whiter = more opaque)
96+
97+
98+
CI PALETTE
99+
100+
The 'CI Palette' pane contains a palette data preview. You can
101+
adjust the number of colors within it for safer editing, if you
102+
happen to know how many colors the one you're editing contains.
103+
All the same navigation rules described above apply here.
104+
105+
If for some reason you must load a palette from a separate file,
106+
you can do so by clicking or dropping a file onto the 'Load External
107+
Palette' button.
108+
109+
Otherwise, it will source palette data from whatever file is
110+
already loaded, since storing textures and palettes in the same
111+
file is a common practice.
112+
113+
'Palette Override' and what role palettes play when importing
114+
textures are both explained in the next section.
115+
116+
117+
CHANGING TEXTURES & PALETTES
118+
119+
You can click any preview (palette or texture) to open the image
120+
action dialog. Click 'Export PNG' inside this dialog and follow the
121+
prompt. Edit this file in your external editor of choice.
122+
123+
To import the modified PNG, click the same preview as before, and
124+
select 'Import PNG'. You will be asked to select the PNG you wish to
125+
import. Note that if you are importing over a CI format texture, the
126+
colors will be matched to the palette shown in the 'CI Palette' pane
127+
as closely as possible. If you want a new palette to be generated
128+
instead, enable the 'Palette Override' option before conversion. Be
129+
mindful that the old palette will be overwritten if you do this,
130+
which will break all other textures that use it if it is shared.
131+
132+
If you are making major changes to a CI texture (aka, using a new
133+
palette), it is recommended that you modify the palette before you
134+
import the new texture. Also be aware that a palette can be shared
135+
by multiple textures, so be prepared to import updated versions of
136+
all textures that rely on any palette you update.
137+
138+
As a final note, any texture imported this way will use the
139+
'AlphaColor' generation settings that have been selected within the
140+
'Texture Convert' pane, described below.
141+
142+
143+
TEXTURE CONVERT
144+
145+
First and foremost: the 'Texture Convert' pane is not for
146+
importing textures and palettes into the currently opened file.
147+
It is for creating a brand new file containing only textures. If
148+
changing textures in an existing file is what you're looking for,
149+
read the section above this one. That said, only a small niche has
150+
use for either of these features.
151+
152+
This pane allows you to convert one or more PNGs to a valid
153+
codec. Simply click or drop PNGs onto the 'New File from PNGs'
154+
button. You can hold the 'Ctrl' key on your keyboard when clicking
155+
files to select multiple. If everything goes well, you should get a
156+
preview of the results, and be able to copy notes to your clipboard
157+
if you wish. To actually save the generated file somewhere, click
158+
the 'Save As' button in the upper corner of the window.
159+
160+
When multiple PNGs are specified and the codec is a CI format,
161+
they are all optimized to use a shared palette, instead of one
162+
palette being derived for each.
163+
164+
AlphaColor
165+
166+
Older converters have a track record of mishandling textures
167+
containing transparency, such that you will notice white or black
168+
outlines along the edges of your textures in-game. This is because
169+
they are setting the colors of invisible pixels to white or black.
170+
The 'AlphaColor' menu offers algorithms that are meant to address
171+
this problem. Each is briefly described below:
172+
173+
edge derives alpha colors by expanding visible edge colors
174+
175+
average the alpha color used across the texture
176+
is the average of all its visible colors
177+
178+
white every invisible pixel's color is set to white
179+
180+
black every invisible pixel's color is set to black
181+
182+
image use invisible pixel colors that are stored in the PNG
183+
* NOTE: if the number of unique invisible colors exeeds
184+
the value of AlphaColorMax, it falls back to
185+
the 'edge' algorithm
186+
187+
AlphaColorMax
188+
189+
This is the maximum number of unique alpha colors to allow
190+
in the generated palette (applies to CI formats only).
191+
192+
193+
TEXTURE SEARCH
194+
195+
Use the 'Texture Search' pane to search the loaded file for any
196+
texture data that matches the PNG you provide. This is useful for
197+
locating rom offsets of textures dumped by video plugins.
198+
199+
If an external palette has been loaded loaded, that will be
200+
searched for palette data instead of the primary file.
201+
202+
When matches are found, they are displayed immediately. Use the
203+
'Results' drop-down to browse the results. A result containing 'P'
204+
(for example, 'ci8-P') indicates a partial match. Partial matches
205+
happen only for CI formats, and occur when matching CI data was
206+
located, but no palette could be found. You can copy the results
207+
to your clipboard by clicking the 'Results -> Clipboard' button.
208+
209+
Two additional codecs are introduced here:
210+
211+
auto search only for codecs that are most likely to match
212+
the provided PNG (this has proved to be extremely
213+
accurate throughout my rigorous testing)
214+
215+
all search every codec (this is slower and only recommended
216+
for textures that 'auto' fails to find matches for)
217+
218+
* The other codecs in this drop-down force it to search for the
219+
one codec you specify. This is most useful if you already
220+
know the codec of the texture you're trying to find.
221+
222+
Mode
223+
224+
1st match searches only up until it finds a match, then stops
225+
226+
find all this is slower, but if you want to locate multiple
227+
occurrences of the same texture, use this
228+
229+
230+
FAQ
231+
232+
Q: What is this blend feature?
233+
A: It allows you to see the colors of invisible pixels. The blending
234+
mode you have selected also controls how a texture appears when
235+
exported to PNG.
236+
237+
Q: What is the EOF toggle in the corner for?
238+
A: Files are padded at the end, which can sometimes be misleading.
239+
For this reason, I found it helpful to offer the option of
240+
customizing what value is used for padding the loaded file.
241+
242+
243+
<z64.me>
244+
```
245+

common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
echo "-DNDEBUG -Wall -Wno-unused-function -Wno-deprecated-declarations -flto -lm -Os -s -flto -Iwowlib -DWOW_OVERLOAD_FILE src/*.c -Isrc "

preview.png

158 KB
Loading

release-linux.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
mkdir -p bin/release
2+
3+
gcc -o bin/release/zztexview-linux `./common.sh` `wowlib/deps/wow_gui_x11.sh`
4+

release-win32.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
mkdir -p bin/release
2+
mkdir -p bin/o/win32
3+
4+
PATH=$PATH:~/c/mxe/usr/bin
5+
6+
# icon
7+
i686-w64-mingw32.static-windres src/icon.rc -o bin/o/win32/icon.o
8+
9+
i686-w64-mingw32.static-gcc -o bin/release/zztexview-win32.exe `./common.sh` \
10+
-municode \
11+
`wowlib/deps/wow_gui_win32.sh` \
12+
bin/o/win32/icon.o
13+

src/common.h

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* common.h <z64.me>
3+
*
4+
* things shared between GUI and eventual CLI version
5+
*
6+
*/
7+
8+
#ifndef TEXVIEW_COMMON_H_INCLUDED
9+
10+
#define TEXVIEW_COMMON_H_INCLUDED
11+
12+
#define PROGNAME "zztexview"
13+
#define PROGVER "v1.0.2"
14+
#define PROGATTRIB "<z64.me>"
15+
#define PROG_NAME_VER_ATTRIB PROGNAME" "PROGVER" "PROGATTRIB
16+
17+
#include "stb_image.h"
18+
#include "stb_image_write.h"
19+
20+
/* line ending used for log file generation */
21+
#ifdef _WIN32
22+
# define ENDLINE "\r\n"
23+
#else
24+
# define ENDLINE "\n"
25+
#endif
26+
27+
#endif
28+

0 commit comments

Comments
 (0)