MacOSX pre-compiled package

master
bzt 2019-12-12 17:35:18 +01:00
parent 56cc20d465
commit f6195dbe6e
15 changed files with 152 additions and 138 deletions

View File

@ -23,20 +23,22 @@ The User Interface is translatable. Supported languages: English, Magyar, Españ
The other component is a Minetest mod, under the [mt-mod](https://gitlab.com/bztsrc/mtsedit/tree/master/mt-mod) directory. This
small Lua script runs inside the game, and can import your edited MTS files into the game's world. It can also save MTS files
and capable of generating the blocks.csv for you.
and it's capable of generating the blocks data required by the editor (if the provided definitons are not enough for you).
<img src="https://gitlab.com/bztsrc/mtsedit/raw/master/docs/mtseditmod.png">
Installation
------------
To install from source, read [compilation instructions](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/compile.md).
### Under Linux
1. download [mtsedit-x86_64-linux.tgz](https://gitlab.com/bztsrc/mtsedit/raw/master/mtsedit-x86_64-linux.tgz)
2. as root, extract it to "/" (if you don't trust it, check the tarball first): "sudo tar -C / -xzvf mtsedit-x86_64-linux.tgz"
3. I guess you know your distro enough to assign a program to an extension. There are many ways, but if your desktop environment
recognizes the MTSEdit application from the installed .desktop file, then file assosiation has already taken care for you.
4. if the MTSEdit application appears in the application menu, but .mts files are not recognized, then as root add the
4. if the MTSEdit application appears in the application menu, but .mts files are still not recognized, then as root add the
```
model/vnd.mts mts schematic
```
@ -46,67 +48,39 @@ line to "/etc/mime.types".
1. download [mtsedit-i686-win.zip](https://gitlab.com/bztsrc/mtsedit/raw/master/mtsedit-i686-win.zip)
2. unpack it into "C:\\Program Files (x86)"
3. open My Computer, from the "Tools" menu, select "Folder Options"
4. click on "File Types" tab
5. scroll down to "MTS" (if you can't find it, click on "New" button and add it)
6. click on "Change" button
7. click on "Browse..." button
8. choose "C:\\Program Files (x86)\\MTSEdit\\mtsedit.exe"
9. check "Always use the selected program to open this kind of file"
10. click on "Ok" button
3. copy "C:\\Program Files (x86)\\MTSEdit\\MTSEdit.lnk" to your desktop or into your menu directory (whereever you like)
4. open My Computer, then from the "Tools" menu, select "Folder Options"
5. click on "File Types" tab
6. scroll down to "MTS" (if you can't find it, click on "New" button and add it)
7. click on "Change" button
8. click on "Browse..." button
9. choose "C:\\Program Files (x86)\\MTSEdit\\mtsedit.exe"
10. check "Always use the selected program to open this kind of file"
11. click on "Ok" button
### Under MacOSX
1. download [mtsedit-intel-macosx.zip](https://gitlab.com/bztsrc/mtsedit/raw/master/mtsedit-intel-macosx.zip)
2. unpack it into "/Applications"
3. in the Finder, find an .mts file
4. pull down the "File" menu and select "Get info" or press <kbd>Command</kbd>+<kbd>I</kbd>
5. expand the "Open With" submenu
6. choose "MTSEdit.app"
7. click on "Change All..." button
1. download [SDL2-X.dmg](http://libsdl.org/download-2.0.php) under Runtime Binaries
2. open it with Finder, and drag'n'drop SDL2.framework to "/Library/Frameworks"
3. download [mtsedit-intel-macosx.zip](https://gitlab.com/bztsrc/mtsedit/raw/master/mtsedit-intel-macosx.zip)
4. unpack it into "/Applications"
5. in the Finder, find an .mts file
6. pull down the "File" menu and select "Get info" or press <kbd>Command</kbd>+<kbd>I</kbd>
7. expand the "Open With" submenu
8. choose "MTSEdit.app"
9. click on "Change All..." button
### Installing the Minetest mod (common to all OS)
To install the Minetest mod, you can run the following command using your Minetest mods directory as parameter, for example:
To install the Minetest mod, run the following command in a Terminal using your Minetest mods directory as parameter, for example:
```
./mtsedit -i ~/.minetest/mods
mtsedit -i ~/.minetest/mods
```
or
```
mtsedit.exe -i C:\\Program Files (x86)\Minetest\mods
mtsedit.exe -i "C:\\Program Files (x86)\Minetest\mods"
```
Compilation
-----------
This is very simple, as MTSEdit was written in ANSI C. The one and only dependency it has is the SDL2 library. Just issue `make`
in the "src" directory, and that will autodetect your operating system (Linux, BSD, MacOSX and Windows).
It also needs some [data files](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/blocks.md), which can be found
[here](https://gitlab.com/bztsrc/mtsedit/tree/master/data).
### Under Linux, BSD, MacOSX
You'll need the development version of SDL2, which can be installed by your distro's standard package management software
("apt-get install", "emerge", "pacman", "port", "homebrew" etc.). It is usually called "libsdl-dev" or similar.
1. in the src directory, run `make`
2. run `sudo make install` (this will copy mtsedit into /usr/bin, and the data/ directory into /usr/share/mtsedit)
### Under Windows
You'll need a couple of tools, here's a step-by-step how to:
1. install [MinGW](https://osdn.net/projects/mingw/releases), this will give you "gcc" and "make" under Windows
2. download [SDL2-devel-X-mingw.tar.gz](http://libsdl.org/download-2.0.php) under the section Development Libraries
3. extract SDL2 into a directory under MinGW's home directory
4. open src/Makefile in Notepad, and edit MINGWSDL to the path where you've extracted the tarball, add the last SDL2-X part too
5. copy $(MINGWSDL)/i686-w64-mingw32/bin/SDL2.dll into C:\\Windows
6. start MSYS (part of MinGW), go to the src directory, and run `make` (if it complains about "cc", then `CC=gcc make`)
7. create C:\\Program Files (x86)\\MTSEdit
8. copy mtsedit.exe there
9. copy the contents of data/ directory to C:\\Program Files (x86)\\MTSEdit\\data
Enjoy!
Known Bugs
@ -115,8 +89,7 @@ Known Bugs
Zooming can be slow, because it scales blocks in run-time. Using a cache would require double the memory footprint. I suggest
to edit on 100% zoom, as that's using a different, fast blitting function.
Rotations are not handled properly, and only used if there's a block image for that rotaion, and they are picked numerically,
not necessarily in rotation CW / CCW order (but you can set all rotations, and they will be saved correctly, it's just you might
have to click more to get the one you want).
Rotations are picked numerically, not necessarily in rotation CW / CCW order (but you can set all rotations, and they will be
saved correctly, it's just you might have to click more to get the one you want).
bzt

38
docs/compile.md Normal file
View File

@ -0,0 +1,38 @@
Minetest MTS Editor Compilation
===============================
This is very simple, as MTSEdit was written in ANSI C. The one and only dependency it has is the SDL2 library. Just issue `make`
in the "src" directory, and that will autodetect your operating system (Linux, BSD, MacOSX and Windows).
It also needs some [data files](https://gitlab.com/bztsrc/mtsedit/blob/master/docs/blocks.md), which can be found
[here](https://gitlab.com/bztsrc/mtsedit/tree/master/data).
### Under Linux, BSD and all other POSIX systems
You'll need the development version of SDL2, which can be installed by your distro's standard package management software
("apt-get install", "emerge", "pacman", "port", "homebrew" etc.). It is usually called "libsdl-dev" or similar.
1. in the mtsedit/src/ directory, run `make`
2. run `sudo make install` (this will copy mtsedit into /usr/bin, and the data/ directory into /usr/share/mtsedit)
### Under MacOSX
1. in a Terminal, run `xcode-select --install` and in the pop-up window click on "Install", this will give you "gcc" and "make" under MacOSX
2. download [SDL2-X.dmg](http://libsdl.org/download-2.0.php) under the section Development Libraries
3. open it with Finder, and drag'n'drop SDL2.framework to "/Library/Frameworks"
4. in the mtsedit/src/ directory, run `make`
5. run `make package`
6. extract ../mtsedit-intel-macosx.zip to "/Applications"
### Under Windows
1. install [MinGW](https://osdn.net/projects/mingw/releases), this will give you "gcc" and "make" under Windows
2. download [SDL2-devel-X-mingw.tar.gz](http://libsdl.org/download-2.0.php) under the section Development Libraries
3. extract SDL2 into a directory under MinGW's home directory
4. open mtsedit/src/Makefile in Notepad, and edit MINGWSDL to the path where you've extracted the tarball, add the last SDL2-X part too
5. copy $(MINGWSDL)/i686-w64-mingw32/bin/SDL2.dll into C:\\Windows
6. start MSYS (part of MinGW), go to the mtsedit/src/ directory, and run `make` (if it complains about "cc", then run `CC=gcc make`)
7. create "C:\\Program Files (x86)\\MTSEdit"
8. copy the newly compiled mtsedit.exe there
9. copy the mtsedit/data/ directory to "C:\\Program Files (x86)\\MTSEdit\\data"

BIN
etc/MTSEdit.lnk Normal file

Binary file not shown.

Binary file not shown.

BIN
mtsedit-intel-macosx.zip Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,35 +1,36 @@
# --- set these according to your configuration ---
LINUXSDL = /usr/include/SDL2
MINGWSDL = ../..
MACSDL = ~/Library/Frameworks/SDL.framework/Versions/A/Headers
MACSDL = ~/Library/Frameworks/SDL2.framework/Versions/A/Headers
# -------------------------------------------------
TARGET = mtsedit
SRCS = $(filter-out bin2h.c,$(wildcard *.c))
OBJS = $(SRCS:.c=.o)
CFLAGS = -Wall -Wextra -ansi -pedantic
# MacOSX
ifneq ("$(wildcard $(MACSDL)/SDL.h)","")
CFLAGS += -I/usr/include/SDL2 -I$(MACSDL)
LIBS = -framework SDL
CFLAGS = -I$(MACSDL)
FDIR=$(MACSDL:/Headers=)
FDIR=$(FDIR:/Versions/A=)
FDIR=$(FDIR:/SDL2.framework=)
LIBS = -F$(FDIR) -framework SDL2
PACKAGE = MacOSX
else
ifneq ("$(wildcard /Library/Frameworks/SDL*)","")
CFLAGS += -I/usr/include/SDL2 -I/Library/Frameworks/SDL*/Versions/A/Headers
LIBS = -framework SDL
CFLAGS = -I/Library/Frameworks/SDL2.framework/Headers -I/Library/Frameworks/SDL2.framework/Versions/A/Headers
LIBS = -F/Library/Frameworks -framework SDL2
PACKAGE = MacOSX
else
# Linux
ifneq ("$(wildcard $(LINUXSDL)/SDL.h)","")
CFLAGS += -I$(LINUXSDL)
CFLAGS = -I$(LINUXSDL)
LIBS = -lSDL2
PACKAGE = Linux
else
# Windows MinGW
ifneq ("$(wildcard $(MINGWSDL)/i686-w64-mingw32/include/SDL2/SDL.h)","")
CFLAGS += -I$(MINGWSDL)/i686-w64-mingw32/include/SDL2
CFLAGS = -I$(MINGWSDL)/i686-w64-mingw32/include/SDL2
LIBDIRS = -static-libgcc -L$(MINGWSDL)/i686-w64-mingw32/lib
LIBS = -lSDL2 -luser32
OBJS += resource.o
@ -40,6 +41,8 @@ endif
endif
endif
CFLAGS += -Wall -Wextra -ansi -pedantic -D_$(PACKAGE)_=1
all: configure data.h $(OBJS) $(TARGET)
configure:
@ -50,14 +53,6 @@ ifeq ("$(LIBS)","")
@false
endif
# MaxOSX developers are bunch of loosers, they have removed "ld -r -b binary"
# support without providing an alternative! Hahahahaha, such loosers!
#icons.o: icons.png
# @$(LD) -r -b binary -o icons.o icons.png
#
#font.o: font.psf.gz
# @$(LD) -r -b binary -o font.o font.psf.gz
data.h: bin2h.c icons.png font.psf.gz
@$(CC) bin2h.c -o bin2h
./bin2h icons.png font.psf.gz ../mt-mod/mtsedit >data.h
@ -92,6 +87,7 @@ else
ifeq ("$(PACKAGE)","Win")
@mkdir MTSEdit
@cp $(TARGET).exe MTSEdit/$(TARGET).exe
@cp ../etc/MTSEdit.lnk MTSEdit
@cp $(MINGWSDL)/i686-w64-mingw32/bin/SDL2.dll MTSEdit/SDL2.dll
@cp -r ../data MTSEdit/data
zip -r ../$(TARGET)-i686-win.zip MTSEdit

View File

@ -271,7 +271,7 @@ void blocks_parse()
if(!dx || !dz || (!memcmp(s, "Cobblestone", 11) && s[11] != '_' && s[11] != ' ')) {
detcube(32, 32, blocks[j].img);
dx = x1 - x0;
dz = y1 - y0;
dz = _y1 - _y0;
}
}
free(img);

View File

@ -309,12 +309,12 @@ void brush_redraw()
src.w = 4 * font->width + 4;
SDL_FillRect(screen, &src, theme[THEME_INPBG]);
sdlprint(src.x, dst.y, THEME_BG, !brushfld ? THEME_INPUT : THEME_FG, "\033");
strsep = 0;
strsepar = 0;
str[1] = 0x80 + (4*brush_type) + (2*brush_hollow);
str[3] = 0x81 + (4*brush_type) + (2*brush_hollow);
sdlprint(src.x + font->width + font->width/2 + 1, dst.y, !brushfld ? THEME_INPUT : THEME_FG, THEME_INPBG, str);
sdlprint(src.x + 4*font->width + 4, dst.y, THEME_BG, !brushfld ? THEME_INPUT : THEME_FG, "\032");
strsep = 1; dst.y += font->height + 2;
strsepar = 1; dst.y += font->height + 2;
if(brush_type) {
sdlprint(dst.x + 4, dst.y, THEME_FG, THEME_BG, lang[HOLLOW]);

View File

@ -106,9 +106,9 @@ void load_redraw()
loadmax = listdir(mtsfile, &loadfiles, 1);
for(i = loadscr; i < loadmax && (rect.y + (int)font->height) < j; i++, rect.y += font->height) {
if(loadfiles[i][0] == '/') {
strsep = 0;
strsepar = 0;
sdlprint(44, rect.y, loadfld == 1 && loadpos == i ? THEME_INPUT : THEME_INACT, THEME_INPBG, "\002\003");
strsep = 1;
strsepar = 1;
k = 1;
} else k = 0;
sdlprint(48 + 2*font->width, rect.y, loadfld == 1 && loadpos == i ? THEME_INPUT : THEME_INACT, THEME_INPBG,

View File

@ -165,9 +165,15 @@ int main(int argc, char** argv, char** envp)
/* get blocks data */
blocks_getdir(argv, envp);
#ifdef _MacOSX_
/* MacOSX does not allow specifying arguments when started from Launchpad,
* and it won't show the output in a terminal either. So fake home dir. */
if(argc < 2) { argc++; argv[1] = "~"; }
#endif
if(argc < 2) {
usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license\r\n\r\n"
"./mtsedit [-v] [-l lang] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]\r\n"
"./mtsedit [-h] [-v] [-l lang] [-d|-p|-P] [-m map] <.mts|.schematic> [out.mts]\r\n"
"./mtsedit -g <block.png>\r\n"
"./mtsedit -t <blockimgs.csv> [blockid]\r\n"
"./mtsedit -i [Minetest mods dir]\r\n"
@ -200,17 +206,17 @@ usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
if(i >= argc || !argv[i]) goto usage;
#ifndef __WIN32__
if(argv[i][0] == '~') {
strncpy(mtsfile, home, sizeof(mtsfile));
strncat(mtsfile, argv[i] + 1, sizeof(mtsfile));
strncpy(mtsfile, home, sizeof(mtsfile) - 1);
strncat(mtsfile, argv[i] + 1, sizeof(mtsfile) - 1);
} else
#endif
strncpy(mtsfile, argv[i], sizeof(mtsfile));
strncpy(mtsfile, argv[i], sizeof(mtsfile) - 1);
savelen = savepos = strlen(mtsfile);
tmpblk = (unsigned char*)malloc(32 * 32 * 4);
if(!tmpblk) error(lang[ERR_MEM]);
mts_x = mts_y = mts_z = 0;
if(i+1 <= argc && argv[i+1] && !opt) opt = 7;
if(i+1 < argc && argv[i+1] && !opt) opt = 7;
if(opt && (opt < 4 || opt == 7)) {
blocks_parse();
readschem();
@ -227,11 +233,11 @@ usage: printf("MineTest Schematics Editor by bzt Copyright (C) 2019 MIT license
if(argv[i+1]) {
#ifndef __WIN32__
if(argv[i+1][0] == '~') {
strncpy(mtsfile, home, sizeof(mtsfile));
strncat(mtsfile, argv[i+1] + 1, sizeof(mtsfile));
strncpy(mtsfile, home, sizeof(mtsfile) - 1);
strncat(mtsfile, argv[i+1] + 1, sizeof(mtsfile) - 1);
} else
#endif
strncpy(mtsfile, argv[i+1], sizeof(mtsfile));
strncpy(mtsfile, argv[i+1], sizeof(mtsfile) - 1);
ret = mts_save();
}
}

View File

@ -102,10 +102,11 @@ typedef struct {
unsigned char *tr;
} mtsblock_t;
extern int numpalettes, lenpalettes, palette[16], strmaxw, strsep, savelen, savepos, savepal, savemapgen, savebiome;
extern int numpalettes, lenpalettes, palette[16], strmaxw, strsepar, savelen, savepos, savepal, savemapgen, savebiome;
extern int numresults, *results;
extern int currlayer, gndlayer, mts_x, mts_y, mts_z, mix, miy, miz, max, may, maz, bound_valid, dx, dz, cx, cz, ox, oy, up, zoom;
extern int zx, zz, zs, shift, ctrl, activetool, activeblock, quitting, verbose, x0, x1, y0, y1, y3, brush_type, brush_hollow;
/* that stupid MacOSX math.h defines y0, y1 and it is INCLUDED even if you don't #include math.h and don't link with -lm... */
extern int zx, zz, zs, shift, ctrl, activetool, activeblock, quitting, verbose, x0, x1, _y0, _y1, y3, brush_type, brush_hollow;
extern char **palettes, layerprob[256];
extern int numblocks;
extern mtsblock_t *blocks;

View File

@ -71,7 +71,7 @@ int mts_getbounds(int sanitize, unsigned short *tr, unsigned short *tr2)
if(y > may) may = y;
if(z < miz) miz = z;
if(z > maz) maz = z;
if(sanitize && !(nodes[y][z][x].param1 && 0x7F)) nodes[y][z][x].param1 |= 127;
if(sanitize && !(nodes[y][z][x].param1 & 0x7F)) nodes[y][z][x].param1 |= 127;
} else
if(sanitize) nodes[y][z][x].param1 = 0;
}
@ -331,7 +331,7 @@ int mts_view(int type)
n = (max - mix) + (maz - miz) + 1;
w = n * dx + 16;
lh = n * dz + 32 - dz;
l = 32 - 2*(y0 + dz);
l = 32 - 2*(_y0 + dz);
h = lh + (may - miy) * l;
blk = SDL_CreateRGBSurfaceFrom(NULL, 32, 32, 32, 32*4, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);
preview = SDL_CreateRGBSurface(0, w, h, 32, 0xFF, 0xFF00, 0xFF0000, 0xFF000000);

View File

@ -33,7 +33,7 @@
uint32_t theme[] = { 0xFFF0F0F0, 0xFFF4F4F4, 0xFFBEBEBE, 0xFF808080, 0xFF5C5C5C, 0xFF4C4C4C, 0xFF454545, 0xFF383838, 0xFF303030,
0xFFC00000, 0xFF800000 };
int quitting = 0, activetool = -1, overtool = -1, activeblock = 0, overblock = -1, palette[16], strmaxw, strsep = 1;
int quitting = 0, activetool = -1, overtool = -1, activeblock = 0, overblock = -1, palette[16], strmaxw, strsepar = 1;
int shift = 0, ctrl = 0, help = 0, systemcursor = 0;
char *status = NULL;
unsigned char *tmpblk = NULL;
@ -108,7 +108,7 @@ void sdlprint(int x, int y, int fg, int bg, char *s)
glyph += bytesperline;
offs += screen->pitch;
}
x += font->width + strsep;
x += font->width + strsepar;
}
}
@ -131,7 +131,7 @@ void sdlhelp()
rect.x += 4; rect.y += 4; strmaxw = rect.x + rect.w - 8;
for(i = 0; i < (int)(sizeof(helpkeys)/sizeof(helpkeys[0])); i++) {
strsep = 0; sdlprint(rect.x, rect.y, THEME_BG, THEME_FG, helpkeys[i].key); strsep = 1;
strsepar = 0; sdlprint(rect.x, rect.y, THEME_BG, THEME_FG, helpkeys[i].key); strsepar = 1;
sdlprint(rect.x + 136, rect.y, THEME_FG, THEME_BG, lang[(int)helpkeys[i].text]);
rect.y += font->height + 4;
}
@ -231,9 +231,9 @@ void sdltoolbar()
}
dst.x += 2*font->width + 6;
if((nodes[currlayer][cz][cx].param1 & 0x80) && dst.x >= 0) {
strsep = 0;
strsepar = 0;
sdlprint(dst.x, screen->h - font->height, THEME_FG, THEME_BG, "\004\005");
strsep = 1;
strsepar = 1;
}
dst.x += 2*font->width + 4;
if(dst.x >= 0) {
@ -257,11 +257,11 @@ void sdltoolbar()
dst.x += 3 * (font->width+1);
if(dst.x >= 0) {
memcpy(str, "\xC2\x80\xC2\x80", 5);
strsep = 0;
strsepar = 0;
str[1] = 0x80 + (4*brush_type) + (2*brush_hollow);
str[3] = 0x81 + (4*brush_type) + (2*brush_hollow);
sdlprint(dst.x, screen->h - font->height, THEME_FG, THEME_BG, str);
strsep = 1;
strsepar = 1;
}
if(s)
sdlprint(42, screen->h - font->height, THEME_FG, THEME_BG, s);

View File

@ -35,7 +35,7 @@
#define TMPSIZE 80
/* cube coordinates */
int x0,x1,x2, y0,y1,y2,y3,y4;
int x0,x1,x2, _y0,_y1,y2,y3,y4;
int verbose = 0;
int fncmp(const void *a, const void *b) { return strcmp(*((const char**)a), *((const char**)b)); }
@ -272,17 +272,17 @@ void detcube(int w, int h, unsigned char *block)
for(d = block; d[3] < 128; d += 4);
x1 = ((int)(d - block) % (w * 4)) / 4;
y0 = (int)(d - block) / (w * 4);
_y0 = (int)(d - block) / (w * 4);
for(i = 0, d = block; i < w/2 && d[3] < 128; i++)
for(j = 0, d = block + i*4; j < h/2 && d[3] < 128; j++, d += w*4);
x0 = ((int)(d - block) % (w * 4)) / 4 - 1;
y1 = (int)(d - block) / (w * 4);
_y1 = (int)(d - block) / (w * 4);
x2 = x1 + (x1 - x0) + 1;
y2 = y1 + (y1 - y0);
y2 = _y1 + (_y1 - _y0);
for(; d[3] > 128; d += w*4);
d -= w*4;
y3 = (int)(d - block) / (w * 4);
y4 = y3 + (y1 - y0);
y4 = y3 + (_y1 - _y0);
}
/**
@ -394,9 +394,9 @@ int stairgen()
/* detect cube edges */
detcube(w, w, block);
#if DEBUG
*((uint32_t*)(slab + y0*w*4 + x1*4)) = 0xFF0000FF;
*((uint32_t*)(slab + y1*w*4 + x0*4)) = 0xFF0000FF;
*((uint32_t*)(slab + y1*w*4 + x2*4)) = 0xFF00FF00;
*((uint32_t*)(slab + _y0*w*4 + x1*4)) = 0xFF0000FF;
*((uint32_t*)(slab + _y1*w*4 + x0*4)) = 0xFF0000FF;
*((uint32_t*)(slab + _y1*w*4 + x2*4)) = 0xFF00FF00;
*((uint32_t*)(slab + y2*w*4 + x1*4)) = 0xFF00FF00;
*((uint32_t*)(slab + y3*w*4 + x0*4)) = 0xFF0000FF;
*((uint32_t*)(slab + y3*w*4 + x2*4)) = 0xFF00FF00;
@ -409,7 +409,7 @@ int stairgen()
if(!block) return 1;
memset(block + w * w * 4, 0, w * w * 4);
for(i = x0; i <= x2+1; i++) {
for(j = y0; j <= y4; j++)
for(j = _y0; j <= y4; j++)
*((uint32_t*)(block + (32+j)*w*4 + (x2 - i + x0 + (x0 & 1))*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
data = (unsigned char *)stbi_write_png_to_mem(block, w*4, w, 2*w, 4, &l);
@ -423,16 +423,16 @@ int stairgen()
/* slab */
memset(slab, 0, w * w * 4);
for(i = x0; i <= x1; i++) {
l = (y1 - y0) * (i - x0) / (x1 - x0);
for(j = y0; j < y1 + (y3 - y1)/2 + l; j++)
*((uint32_t*)(slab + (j+(y3 - y1)/2+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * (i - x0) / (x1 - x0);
for(j = _y0; j < _y1 + (y3 - _y1)/2 + l; j++)
*((uint32_t*)(slab + (j+(y3 - _y1)/2+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
for(j = y3 + l; j < w; j++)
*((uint32_t*)(slab + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x1+1; i <= x2; i++) {
l = (y1 - y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = y0; j < y2 + (y3 - y1)/2 + l; j++)
*((uint32_t*)(slab + (j+(y3 - y1)/2+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = _y0; j < y2 + (y3 - _y1)/2 + l; j++)
*((uint32_t*)(slab + (j+(y3 - _y1)/2+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
for(j = y4 + l; j < w; j++)
*((uint32_t*)(slab + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
@ -447,16 +447,16 @@ int stairgen()
/* double slab */
memset(stair, 0, w * w * 4);
for(i = x0; i <= x1; i++) {
l = (y1 - y0) * (i - x0) / (x1 - x0);
for(j = y0; j < y1 + (y3 - y1)*3/4 + l; j++)
*((uint32_t*)(stair + (j+(y3 - y1)/4+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * (i - x0) / (x1 - x0);
for(j = _y0; j < _y1 + (y3 - _y1)*3/4 + l; j++)
*((uint32_t*)(stair + (j+(y3 - _y1)/4+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
for(j = y3 + l; j < w; j++)
*((uint32_t*)(stair + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x1+1; i <= x2; i++) {
l = (y1 - y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = y0; j < y2 + (y3 - y1)*3/4 + l; j++)
*((uint32_t*)(stair + (j+(y3 - y1)/4+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = _y0; j < y2 + (y3 - _y1)*3/4 + l; j++)
*((uint32_t*)(stair + (j+(y3 - _y1)/4+1)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
for(j = y4 + l; j < w; j++)
*((uint32_t*)(stair + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
@ -478,58 +478,58 @@ int stairgen()
/* rotated stairs */
memcpy(stair, slab, w * w * 4);
for(i = x0 + (x1 - x0)/2; i <= x1 + (x2 - x1)/2; i++) {
l = (y1 - y0) * (i - x0) / (x1 - x0);
for(j = y0; j <= y0 + l; j++)
l = (_y1 - _y0) * (i - x0) / (x1 - x0);
for(j = _y0; j <= _y0 + l; j++)
*((uint32_t*)(stair + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i--; i <= x2; i++) {
for(j = y0; j <= y4; j++)
for(j = _y0; j <= y4; j++)
*((uint32_t*)(stair + j*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x0; i <= x1; i++) {
l = (y1 - y0) * (i - x0) / (x1 - x0);
for(j = y1 + l - 1; j <= y1 + (y3 - y1)/2 + l; j++)
*((uint32_t*)(stair + (j-(y1-y0)/2)*w*4 + (i + (x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * (i - x0) / (x1 - x0);
for(j = _y1 + l - 1; j <= _y1 + (y3 - _y1)/2 + l; j++)
*((uint32_t*)(stair + (j-(_y1-_y0)/2)*w*4 + (i + (x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
memcpy(stair + w*w*4, slab, w * w * 4);
for(i = x0 + (x1 - x0)/2; i <= x2; i++) {
l = (y1 - y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = y1 + l; j < y4; j++)
l = (_y1 - _y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = _y1 + l; j < y4; j++)
*((uint32_t*)(stair + (w+j)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x0; i <= x1; i++) {
l = (y1 - y0) * ((x1-i+1) - x1) / (x1 - x0);
for(j = y1 + l; j <= y2 + l; j++)
*((uint32_t*)(stair + (w+j+(y1-y0)/2)*w*4 + (i+(x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * ((x1-i+1) - x1) / (x1 - x0);
for(j = _y1 + l; j <= y2 + l; j++)
*((uint32_t*)(stair + (w+j+(_y1-_y0)/2)*w*4 + (i+(x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
memcpy(stair + 2*w*w*4, slab, w * w * 4);
for(i = x0; i <= x1 + (x2 - x1)/2; i++) {
l = (y1 - y0) * (i - x0) / (x1 - x0);
for(j = y0 + l; j < y4; j++)
l = (_y1 - _y0) * (i - x0) / (x1 - x0);
for(j = _y0 + l; j < y4; j++)
*((uint32_t*)(stair + (2*w+j)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x1; i <= x2; i++) {
l = (y1 - y0) * (i - x1) / (x1 - x0);
for(j = y0 + l; j <= y0 + l + 1; j++)
*((uint32_t*)(stair + (2*w+(j+(y1-y0)/2))*w*4 + (i - (x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * (i - x1) / (x1 - x0);
for(j = _y0 + l; j <= _y0 + l + 1; j++)
*((uint32_t*)(stair + (2*w+(j+(_y1-_y0)/2))*w*4 + (i - (x1 - x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
memcpy(stair + 3*w*w*4, slab, w * w * 4);
for(i = x0; i <= x0 + (x1 - x0)/2 +1; i++) {
for(j = y0; j <= y4; j++)
for(j = _y0; j <= y4; j++)
*((uint32_t*)(stair + (3*w+j)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(; i <= x2; i++) {
l = (y1 - y0) * (i - (x0 + (x1 - x0)/2)) / (x2 - x1);
for(j = y0; j <= y1 + (y2 - y1)/2 - l; j++)
l = (_y1 - _y0) * (i - (x0 + (x1 - x0)/2)) / (x2 - x1);
for(j = _y0; j <= _y1 + (y2 - _y1)/2 - l; j++)
*((uint32_t*)(stair + (3*w+j)*w*4 + i*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
for(i = x1+1; i <= x2; i++) {
l = (y1 - y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = y2 + l - 1; j <= y2 + (y3 - y1)/2 + l; j++)
*((uint32_t*)(stair + (3*w+(j-(y1-y0)/2))*w*4 + (i-(x1-x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
l = (_y1 - _y0) * ((x2-i+1) - x1) / (x2 - x1);
for(j = y2 + l - 1; j <= y2 + (y3 - _y1)/2 + l; j++)
*((uint32_t*)(stair + (3*w+(j-(_y1-_y0)/2))*w*4 + (i-(x1-x0)/2)*4)) = *((uint32_t*)(block + j*w*4 + i*4));
}
data = (unsigned char *)stbi_write_png_to_mem(stair, w*4, w, 4*w, 4, &l);
if(data) {