Got build working on newer OSX, included missing ADFs

This commit is contained in:
alpine9000 2019-06-11 13:58:03 +10:00
parent abe4b9e850
commit ffc5f1f93d
40 changed files with 4937 additions and 341 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -140,4 +140,4 @@ blitObject64:
move.w #(BLIT_BOB_HEIGHT64*SCREEN_BIT_DEPTH)<<6|(BLIT_BOB_WIDTH64_WORDS),BLTSIZE(a6) ;rectangle size, starts blit
movem.l (sp)+,d0-a6
rts

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -16,11 +16,10 @@ out/copper-new.s: $(GIF_FILE) out/copper_fun_generate convert.sh
./convert.sh > out/copper-new.s
out/copper_fun_generate: copper_fun_generate.c Makefile
gcc $(HOST_CFLAGS) `GraphicsMagick-config --cppflags` copper_fun_generate.c -o out/copper_fun_generate $(LIBS)
gcc -Wno-ignored-attributes $(HOST_CFLAGS) `GraphicsMagick-config --cppflags` copper_fun_generate.c -o out/copper_fun_generate $(LIBS)
video: GIF_FILE:=assets/video.gif
video: all
vgo: RUN_SCRIPT:=$(A600_RUN_SCRIPT)
vgo: video go

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -11,10 +11,10 @@ typedef struct {
unsigned short lo;
unsigned short pad2;
unsigned short hi;
} copper_layout_t
} copper_layout_t;
void
void
PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned short interlace, unsigned short numBitplanes, unsigned short screenWidthBytes)
{
char i;
@ -29,5 +29,5 @@ PokeBitplanePointers(unsigned short* copper, unsigned char* bitplanes, unsigned
ptr->hi = extract.words.hi;
bitplanes += screenWidthBytes;
ptr++;
}
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,8 @@ SUBDIRS=tools/makeadf \
tools/croppa\
tools/external/shrinkler\
tools/external/doynamite68k\
tools/mapgen\
tools/fade\
000.trackdisk\
001.simple_image\
002.sprite_display\
@ -25,14 +27,14 @@ SUBDIRS=tools/makeadf \
018.vert_scroll\
019.hori_scroll\
020.shrinkler\
021.calling_c\
022.photons_bootloader\
023.slideshow\
024.simple_text\
025.scroll_text\
026.tile_hscroll\
027.parallax\
028.bs
#028.bs
#021.calling_c\
.PHONY: subdirs $(SUBDIRS)

View File

@ -1,6 +1,6 @@
HOST_WARNINGS=-pedantic-errors -Wfatal-errors -Wall -Werror -Wextra -Wno-unused-parameter -Wshadow
HOST_CFLAGS=$(HOST_WARNINGS)
SDK_INCLUDE=-I/usr/local/amiga/vgcc/ndk/include/
MAKEADFDIR=../tools/makeadf/
MAKEADF=$(MAKEADFDIR)/out/makeadf
IMAGECONDIR=../tools/imagecon
@ -16,7 +16,7 @@ A600_RUN_SCRIPT=~/Google\ Drive/Amiga/amiga600.sh
A1200T_RUN_SCRIPT=~/Google\ Drive/Amiga/amiga1200t.sh
#VASM_ARGS=-phxass -Fhunk -quiet -spaces
VASM_ARGS=-Fhunk -quiet -esc
VASM_ARGS=-Fhunk -quiet -esc
ifndef FLOPPY
FLOPPY=bin/$(EXAMPLE_NAME).adf
@ -110,18 +110,18 @@ out/bootblock.bin: out/bootblock.o
vlink -brawbin1 $< -o $@
out/bootblock.o: $(BOOTBLOCK_ASM) $(PROGRAM_BIN)
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_BOOTBLOCK_ARGS) -DUSERSTACK_ADDRESS="\$$$(USERSTACK_ADDRESS)" -DBASE_ADDRESS="\$$$(BASE_ADDRESS)" $< -o $@ -I/usr/local/amiga/os-include
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_BOOTBLOCK_ARGS) -DUSERSTACK_ADDRESS="\$$$(USERSTACK_ADDRESS)" -DBASE_ADDRESS="\$$$(BASE_ADDRESS)" $< -o $@ $(SDK_INCLUDE) -I../include
out/main.o: $(MODULE) $(EXTRA)
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ -I/usr/local/amiga/os-include
@vasmm68k_mot -depend=make $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ -I/usr/local/amiga/os-include > $*.d
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ $(SDK_INCLUDE)
@vasmm68k_mot -depend=make $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ $(SDK_INCLUDE) > $*.d
out/%.o: %.s
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ -I/usr/local/amiga/os-include
@vasmm68k_mot -depend=make $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ -I/usr/local/amiga/os-include > out/$*.d
vasmm68k_mot $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ $(SDK_INCLUDE)
@vasmm68k_mot -depend=make $(VASM_ARGS) $(VASM_EXTRA_ARGS) $< -o $@ $(SDK_INCLUDE) > out/$*.d
out/%.o: %.c
vc -O3 -c $< -o $@
m68k-amigaosvasm-gcc -O3 -c $< -o $@
-@vc -O3 -S $< -o out/$*.s > /dev/null 2> /dev/null
-@vc -O0 -S $< -o out/$*-noopt.s > /dev/null 2> /dev/null
@ -142,4 +142,4 @@ out/shrunk.bin: $(SHRINKLER_EXE) out/main.bin
clean:
rm -rf out bin *~
-include $(ALL_DEPENDS)
-include $(ALL_DEPENDS)

View File

@ -1,6 +1,7 @@
include exec/io.i
include lvo/exec_lib.i
include devices/trackdisk.i
;; include funcdef.i
;; include exec/io.i
;; include exec/exec_lib.i
;; include devices/trackdisk.i
bootblock:
dc.b "DOS",0
dc.l 0
@ -10,23 +11,23 @@ bootEntry:
;; a6 = Exec base
;; a1 = trackdisk.device I/O request pointer
lea BASE_ADDRESS,a5 ; main.s entry point
lea BASE_ADDRESS,a5 ; main.s entry point
;; move.l #$ff000,a7
;; Load the progam from the floppy using trackdisk.device
move.l #mainEnd-mainStart,IO_LENGTH(a1)
move.l a5,IO_DATA(a1)
move.l #mainStart-bootblock,IO_OFFSET(a1)
jsr _LVODoIO(a6)
move.l #mainEnd-mainStart,36(a1) ;IO_LENGTH(a1)
move.l a5,40(a1) ;IO_DATA(a1)
move.l #mainStart-bootblock,44(a1) ;IO_OFFSET(a1)
jsr -456(a6) ;DoIO
;; Turn off drive motor
move.l #0,IO_LENGTH(a1)
move.w #TD_MOTOR,IO_COMMAND(a1)
jsr _LVODoIO(a6)
move.l #0,36(a1) ;IO_LENGTH(a1)
move.w #9,28(a1) ;#TD_MOTOR,28(a1) ;IO_COMMAND(a1)
jsr -456(a6) ;DoIO
jmp (a5) ; -> main.s entry point
;; Pad the remainder of the bootblock
cnop 0,1024
@ -34,4 +35,4 @@ mainStart:
incbin "out/main.bin"
cnop 0,512
mainEnd:
end
end

View File

@ -1,6 +1,7 @@
include "funcdef.i"
include "../include/registers.i"
include "exec/io.i"
include "lvo/exec_lib.i"
include "exec/exec_lib.i"
include "devices/trackdisk.i"
@ -75,4 +76,4 @@ mainStart:
endif ; SHRINKLER==0
cnop 0,512
mainEnd:
end
end

View File

@ -1,5 +1,5 @@
WARN_ERROR=-Werror
HOST_WARNINGS=$(WARN_ERROR) -pedantic-errors -Wfatal-errors -Wall -Wextra -Wno-unused-parameter -Wshadow -limagequant
HOST_WARNINGS=$(WARN_ERROR) -pedantic-errors -Wfatal-errors -Wall -Wextra -Wno-unused-parameter -Wshadow -limagequant -Wno-unused-command-line-argument -Wno-ignored-attributes
HOST_CFLAGS=$(HOST_WARNINGS) -O3 $(EXTRA_CFLAGS)
$(PROGRAM): out bin $(OBJS)

View File

@ -1,7 +1,7 @@
/*
/*
*
* Originally from: https://rosettacode.org/wiki/Color_quantization/C
* License information http://www.gnu.org/licenses/fdl-1.2.html
* License information http://www.gnu.org/licenses/fdl-1.2.html
*
*/
@ -13,10 +13,10 @@
#include <string.h>
#include <stdint.h>
#include <math.h>
#include "quant.h"
#include "quant.h"
quant_image_t*
quant_image_t*
quant_newImage(int w, int h)
{
quant_image_t* im = malloc(sizeof(quant_image_t) + h * w * 3);
@ -24,9 +24,9 @@ quant_newImage(int w, int h)
im->pix = (unsigned char *)(im + 1);
return im;
}
#define ON_INHEAP 1
typedef struct oct_node_t oct_node_t, *oct_node;
struct oct_node_t{
int64_t r, g, b; /* sum of all child node colors */
@ -34,22 +34,22 @@ struct oct_node_t{
unsigned char n_kids, kid_idx, flags, depth;
oct_node kids[8], parent;
};
typedef struct {
int alloc, n;
oct_node* buf;
} node_heap;
inline int cmp_node(oct_node a, oct_node b)
{
if (a->n_kids < b->n_kids) return -1;
if (a->n_kids > b->n_kids) return 1;
int ac = a->count >> a->depth;
int bc = b->count >> b->depth;
return ac < bc ? -1 : ac > bc;
}
void down_heap(node_heap *h, oct_node p)
{
int n = p->heap_idx, m;
@ -57,9 +57,9 @@ void down_heap(node_heap *h, oct_node p)
m = n * 2;
if (m >= h->n) break;
if (m + 1 < h->n && cmp_node(h->buf[m], h->buf[m + 1]) > 0) m++;
if (cmp_node(p, h->buf[m]) <= 0) break;
h->buf[n] = h->buf[m];
h->buf[n]->heap_idx = n;
n = m;
@ -67,16 +67,16 @@ void down_heap(node_heap *h, oct_node p)
h->buf[n] = p;
p->heap_idx = n;
}
void up_heap(node_heap *h, oct_node p)
{
int n = p->heap_idx;
oct_node prev;
while (n > 1) {
prev = h->buf[n / 2];
if (cmp_node(p, prev) >= 0) break;
h->buf[n] = prev;
prev->heap_idx = n;
n /= 2;
@ -84,7 +84,7 @@ void up_heap(node_heap *h, oct_node p)
h->buf[n] = p;
p->heap_idx = n;
}
void heap_add(node_heap *h, oct_node p)
{
if ((p->flags & ON_INHEAP)) {
@ -92,34 +92,34 @@ void heap_add(node_heap *h, oct_node p)
up_heap(h, p);
return;
}
p->flags |= ON_INHEAP;
if (!h->n) h->n = 1;
if (h->n >= h->alloc) {
while (h->n >= h->alloc) h->alloc += 1024;
h->buf = realloc(h->buf, sizeof(oct_node) * h->alloc);
}
p->heap_idx = h->n;
h->buf[h->n++] = p;
up_heap(h, p);
}
oct_node pop_heap(node_heap *h)
{
if (h->n <= 1) return 0;
oct_node ret = h->buf[1];
h->buf[1] = h->buf[--h->n];
h->buf[h->n] = 0;
h->buf[1]->heap_idx = 1;
down_heap(h, h->buf[1]);
return ret;
}
static oct_node pool = 0;
oct_node node_new(unsigned char idx, unsigned char depth, oct_node p)
{
@ -130,7 +130,7 @@ oct_node node_new(unsigned char idx, unsigned char depth, oct_node p)
pool = p_;
len = 2047;
}
oct_node x = pool + len--;
x->kid_idx = idx;
x->depth = depth;
@ -138,7 +138,7 @@ oct_node node_new(unsigned char idx, unsigned char depth, oct_node p)
if (p) p->n_kids++;
return x;
}
void node_free()
{
oct_node p;
@ -148,32 +148,32 @@ void node_free()
pool = p;
}
}
oct_node node_insert(oct_node root, unsigned char *pix)
{
unsigned char i, bit, depth = 0;
for (bit = 1 << 7; ++depth < 8; bit >>= 1) {
i = !!(pix[1] & bit) * 4 + !!(pix[0] & bit) * 2 + !!(pix[2] & bit);
if (!root->kids[i])
root->kids[i] = node_new(i, depth, root);
root = root->kids[i];
}
root->r += pix[0];
root->g += pix[1];
root->b += pix[2];
root->count++;
return root;
}
oct_node node_fold(oct_node p)
{
if (p->n_kids) abort();
oct_node q = p->parent;
q->count += p->count;
q->r += p->r;
q->g += p->g;
q->b += p->b;
@ -181,31 +181,31 @@ oct_node node_fold(oct_node p)
q->kids[p->kid_idx] = 0;
return q;
}
void color_replace(oct_node root, unsigned char *pix)
{
unsigned char i, bit;
for (bit = 1 << 7; bit; bit >>= 1) {
i = !!(pix[1] & bit) * 4 + !!(pix[0] & bit) * 2 + !!(pix[2] & bit);
if (!root->kids[i]) break;
root = root->kids[i];
}
pix[0] = root->r;
pix[1] = root->g;
pix[2] = root->b;
}
static oct_node
static oct_node
nearest_color(int *v, node_heap *h) {
int i;
int diff, max = 100000000;
oct_node o = 0;
for (i = 1; i < h->n; i++) {
diff = 3 * abs(h->buf[i]->r - v[0])
+ 5 * abs(h->buf[i]->g - v[1])
+ 2 * abs(h->buf[i]->b - v[2]);
diff = 3 * abs((int)(h->buf[i]->r - v[0]))
+ 5 * abs((int)(h->buf[i]->g - v[1]))
+ 2 * abs((int)(h->buf[i]->b - v[2]));
if (diff < max) {
max = diff;
o = h->buf[i];
@ -213,23 +213,23 @@ nearest_color(int *v, node_heap *h) {
}
return o;
}
void error_diffuse(quant_image_t* im, node_heap *h)
{
#define POS(i, j) (3 * ((i) * im->w + (j)))
int i, j;
int *npx = calloc(sizeof(int), im->h * im->w * 3), *px;
int v[3];
unsigned char *pix = im->pix;
oct_node nd;
#define C10 7
#define C01 5
#define C11 2
#define C00 1
#define C00 1
#define CTOTAL (C00 + C11 + C10 + C01)
for (px = npx, i = 0; i < im->h; i++) {
for (j = 0; j < im->w; j++, pix += 3, px += 3) {
px[0] = (int)pix[0] * CTOTAL;
@ -245,13 +245,13 @@ void error_diffuse(quant_image_t* im, node_heap *h)
px[1] /= CTOTAL;
px[2] /= CTOTAL;
clamp(px, 0); clamp(px, 1); clamp(px, 2);
nd = nearest_color(px, h);
v[0] = px[0] - nd->r;
v[1] = px[1] - nd->g;
v[2] = px[2] - nd->b;
pix[0] = nd->r; pix[1] = nd->g; pix[2] = nd->b;
if (j < im->w - 1) {
npx[POS(i, j+1) + 0] += v[0] * C10;
@ -259,11 +259,11 @@ void error_diffuse(quant_image_t* im, node_heap *h)
npx[POS(i, j+1) + 2] += v[2] * C10;
}
if (i >= im->h - 1) continue;
npx[POS(i+1, j) + 0] += v[0] * C01;
npx[POS(i+1, j) + 1] += v[1] * C01;
npx[POS(i+1, j) + 2] += v[2] * C01;
if (j < im->w - 1) {
npx[POS(i+1, j+1) + 0] += v[0] * C11;
npx[POS(i+1, j+1) + 1] += v[1] * C11;
@ -278,8 +278,8 @@ void error_diffuse(quant_image_t* im, node_heap *h)
}
free(npx);
}
void
void
quant_quantize(quant_image_t* im, int n_colors, int dither)
{
int i;
@ -291,12 +291,12 @@ quant_quantize(quant_image_t* im, int n_colors, int dither)
for (i = 0; i < im->w * im->h; i++, pix += 3)
heap_add(&heap, node_insert(root, pix));
while (heap.n > n_colors + 1)
heap_add(&heap, node_fold(pop_heap(&heap)));
double c;
for (i = 1; i < heap.n; i++) {
got = heap.buf[i];
@ -305,12 +305,12 @@ quant_quantize(quant_image_t* im, int n_colors, int dither)
got->g = got->g / c + .5;
got->b = got->b / c + .5;
}
if (dither) error_diffuse(im, &heap);
else
for (i = 0, pix = im->pix; i < im->w * im->h; i++, pix += 3)
color_replace(root, pix);
node_free();
free(heap.buf);
}

View File

@ -20,10 +20,10 @@ get_tile_address(tmx_map *m, unsigned int gid)
}
int ts_count = 0;
tmx_tileset** ta;
tmx_tileset_list** ta;
{
tmx_tileset* t = m->ts_head;
tmx_tileset_list* t = m->ts_head;
while (t != 0) {
t = t->next;
ts_count++;
@ -41,18 +41,18 @@ get_tile_address(tmx_map *m, unsigned int gid)
unsigned baseAddress = 0;
for (int y = 0; y < ts_count; y++) {
tmx_tileset* ts = ta[y];
for (unsigned int i = 0; i < ts->tilecount; i++) {
tmx_tile* t = ts->tiles;
tmx_tileset_list* ts = ta[y];
for (unsigned int i = 0; i < ts->tileset->tilecount; i++) {
tmx_tile* t = ts->tileset->tiles;
if (t[i].id+ts->firstgid == gid) {
unsigned address = baseAddress + (t[i].ul_y * ((ts->image->width/8) * config.bitDepth)) + (t[i].ul_x/8);
unsigned address = baseAddress + (t[i].ul_y * ((ts->tileset->image->width/8) * config.bitDepth)) + (t[i].ul_x/8);
if (config.verbose) {
printf("%s - baseAddress = %d address = %d\n", ts->name, baseAddress, address);
printf("%s - baseAddress = %d address = %d\n", ts->tileset->name, baseAddress, address);
}
return address;
}
}
baseAddress += ((ts->image->width/8) * config.bitDepth * ts->image->height);
baseAddress += ((ts->tileset->image->width/8) * config.bitDepth * ts->tileset->image->height);
}
return 0;
@ -67,10 +67,10 @@ get_tile_index(tmx_map *m, unsigned int gid)
}
int ts_count = 0;
tmx_tileset** ta;
tmx_tileset_list** ta;
{
tmx_tileset* t = m->ts_head;
tmx_tileset_list* t = m->ts_head;
while (t != 0) {
t = t->next;
ts_count++;
@ -87,12 +87,12 @@ get_tile_index(tmx_map *m, unsigned int gid)
for (int y = 0; y < ts_count; y++) {
tmx_tileset* ts = ta[y];
for (unsigned int i = 0; i < ts->tilecount; i++) {
tmx_tile* t = ts->tiles;
tmx_tileset_list* ts = ta[y];
for (unsigned int i = 0; i < ts->tileset->tilecount; i++) {
tmx_tile* t = ts->tileset->tiles;
if (t[i].id+ts->firstgid == gid) {
if (config.verbose) {
printf("%s - index = %d\n", ts->name, t[i].id);
printf("%s - index = %d\n", ts->tileset->name, t[i].id);
}
return t[i].id;
}
@ -102,7 +102,7 @@ get_tile_index(tmx_map *m, unsigned int gid)
return 0;
}
static void
static void
output_map_asm(tmx_map *m, tmx_layer *l)
{
if (!l) {
@ -128,7 +128,7 @@ output_map_asm(tmx_map *m, tmx_layer *l)
}
static void
static void
output_map_indexes(tmx_map *m, tmx_layer *l)
{
if (!l) {
@ -154,8 +154,8 @@ output_map_indexes(tmx_map *m, tmx_layer *l)
}
static void
process_map(tmx_map *m)
static void
process_map(tmx_map *m)
{
output_map_asm(m, m->ly_head);
output_map_indexes(m, m->ly_head);
@ -165,7 +165,7 @@ process_map(tmx_map *m)
void
usage()
{
fprintf(stderr,
fprintf(stderr,
"%s: --input <input.tmx> --depth <num bitplanes>\n"\
"options:\n"\
" --help\n"\
@ -174,8 +174,8 @@ usage()
}
int
main(int argc, char *argv[])
int
main(int argc, char *argv[])
{
int c;
tmx_map *m;
@ -190,46 +190,46 @@ main(int argc, char *argv[])
{"depth", required_argument, 0, 'd'},
{0, 0, 0, 0}
};
int option_index = 0;
c = getopt_long (argc, argv, "i:?", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
break;
case 'i':
config.inputFile = optarg;
break;
break;
case 'd':
sscanf(optarg, "%d", &config.bitDepth);
break;
break;
case '?':
usage();
break;
break;
default:
usage();
break;
}
}
if (config.inputFile == 0 || config.bitDepth == 0) {
usage();
abort();
}
}
m = tmx_load(config.inputFile);
if (!m) {
tmx_perror("error");
}
process_map(m);
tmx_map_free(m);
return EXIT_SUCCESS;
}

View File

@ -26,8 +26,8 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
void
print_orient(enum tmx_map_orient orient)
void
print_orient(enum tmx_map_orient orient)
{
switch(orient) {
case O_NONE: printf("none"); break;
@ -39,8 +39,8 @@ print_orient(enum tmx_map_orient orient)
}
}
void
print_stagger_index(enum tmx_stagger_index index)
void
print_stagger_index(enum tmx_stagger_index index)
{
switch(index) {
case SI_NONE: printf("none"); break;
@ -50,8 +50,8 @@ print_stagger_index(enum tmx_stagger_index index)
}
}
void
print_stagger_axis(enum tmx_stagger_axis axis)
void
print_stagger_axis(enum tmx_stagger_axis axis)
{
switch(axis) {
case SA_NONE: printf("none"); break;
@ -61,8 +61,8 @@ print_stagger_axis(enum tmx_stagger_axis axis)
}
}
void
print_renderorder(enum tmx_map_renderorder ro)
void
print_renderorder(enum tmx_map_renderorder ro)
{
switch(ro) {
case R_NONE: printf("none"); break;
@ -74,8 +74,8 @@ print_renderorder(enum tmx_map_renderorder ro)
}
}
void
print_draworder(enum tmx_objgr_draworder dro)
void
print_draworder(enum tmx_objgr_draworder dro)
{
switch(dro) {
case G_NONE: printf("none"); break;
@ -85,216 +85,9 @@ print_draworder(enum tmx_objgr_draworder dro)
}
}
void
void
mk_padding(char pad[11], int depth) {
if (depth>10) depth=10;
if (depth>0) memset(pad, '\t', depth);
pad[depth] = '\0';
}
void
dump_prop(tmx_property *p, int depth)
{
char padding[11]; mk_padding(padding, depth);
printf("\n%s" "properties={", padding);
if (!p) {
printf(" (NULL) }");
} else {
while (p) {
printf("\n%s\t" "'%s'='%s'", padding, p->name, p->value);
p = p->next;
}
printf("\n" "%s}", padding);
}
}
void
print_shape(enum tmx_shape shape) {
switch(shape) {
case S_NONE: printf("none"); break;
case S_SQUARE: printf("square"); break;
case S_ELLIPSE: printf("ellipse"); break;
case S_POLYGON: printf("polygon"); break;
case S_POLYLINE: printf("polyline"); break;
default: printf("unknown");
}
}
void
dump_image(tmx_image *i, int depth)
{
char padding[11]; mk_padding(padding, depth);
printf("\n%s" "image={", padding);
if (i) {
printf("\n%s\t" "source='%s'", padding, i->source);
printf("\n%s\t" "height=%lu", padding, i->height);
printf("\n%s\t" "width=%lu", padding, i->width);
printf("\n%s\t" "uses_trans=%s", padding, str_bool(i->uses_trans));
printf("\n%s\t" "trans=#%.6X", padding, i->trans);
printf("\n%s}", padding);
} else {
printf(" (NULL) }");
}
}
void
dump_points(double **p, int pl) {
int i;
for (i=0; i<pl; i++) {
printf(" (%f, %f)", p[i][0], p[i][1]);
}
}
void
dump_objects(tmx_object *o, int depth) {
char padding[11]; mk_padding(padding, depth);
printf("\n%s" "object={", padding);
if (!o) {
printf(" (NULL) }");
} else {
printf("\n%s\t" "id=%u", padding, o->id);
printf("\n%s\t" "name='%s'", padding, o->name);
printf("\n%s\t" "type='%s'", padding, o->type);
printf("\n%s\t" "shape=", padding); print_shape(o->shape);
printf("\n%s\t" "x=%f", padding, o->x);
printf("\n%s\t" "y=%f", padding, o->y);
printf("\n%s\t" "number of points='%d'", padding, o->points_len);
printf("\n%s\t" "rotation=%f", padding, o->rotation);
printf("\n%s\t" "visible=%s", padding, str_bool(o->visible));
if (o->points_len) {
printf("\n%s\t" "points=", padding);
dump_points(o->points, o->points_len);
}
dump_prop(o->properties, depth+1);
printf("\n%s}", padding);
}
if (o && o->next) {
dump_objects(o->next, depth);
}
}
void
dump_tile(tmx_tile *t, unsigned int tilecount) {
unsigned int i, j;
for (i=0; i<tilecount; i++) {
printf("\n\t" "tile={");
printf("\n\t\t" "id=%u", t[i].id);
printf("\n\t\t" "upper-left=(%u,%u)", t[i].ul_x, t[i].ul_y);
dump_image(t[i].image, 2);
dump_prop(t[i].properties, 2);
dump_objects(t[i].collision, 2);
if (t[i].animation) {
printf("\n\t\t" "animation={");
for (j=0; j<t[i].animation_len; j++) {
printf("\n\t\t\t" "tile=%3u (%6ums)", t[i].animation[j].tile_id, t[i].animation[j].duration);
}
printf("\n\t\t}");
}
printf("\n\t}");
}
}
void
dump_tileset(tmx_tileset *t) {
printf("\ntileset={");
if (t) {
printf("\n\t" "name=%s", t->name);
printf("\n\t" "tilecount=%u", t->tilecount);
printf("\n\t" "firstgid=%u", t->firstgid);
printf("\n\t" "tile_height=%u", t->tile_height);
printf("\n\t" "tile_width=%u", t->tile_width);
printf("\n\t" "firstgid=%u", t->firstgid);
printf("\n\t" "margin=%u", t->margin);
printf("\n\t" "spacing=%u", t->spacing);
printf("\n\t" "x_offset=%d", t->x_offset);
printf("\n\t" "y_offset=%d", t->y_offset);
dump_image(t->image, 1);
dump_tile(t->tiles, t->tilecount);
dump_prop(t->properties, 1);
printf("\n}");
} else {
printf(" (NULL) }");
}
if (t && t->next) {
dump_tileset(t->next);
}
}
void
dump_layer(tmx_layer *l, unsigned int tc)
{
unsigned int i;
printf("\nlayer={");
if (!l) {
printf(" (NULL) }");
} else {
printf("\n\t" "name='%s'", l->name);
printf("\n\t" "visible=%s", str_bool(l->visible));
printf("\n\t" "opacity='%f'", l->opacity);
printf("\n\t" "offsetx=%d", l->offsetx);
printf("\n\t" "offsety=%d", l->offsety);
if (l->type == L_LAYER && l->content.gids) {
printf("\n\t" "type=Layer" "\n\t" "tiles=");
for (i=0; i<tc; i++) {
printf("%d,", l->content.gids[i] & TMX_FLIP_BITS_REMOVAL);
}
} else if (l->type == L_OBJGR) {
printf("\n\t" "color=#%.6X", l->content.objgr->color);
printf("\n\t" "draworder="); print_draworder(l->content.objgr->draworder);
printf("\n\t" "type=ObjectGroup");
dump_objects(l->content.objgr->head, 1);
} else if (l->type == L_IMAGE) {
printf("\n\t" "type=ImageLayer");
dump_image(l->content.image, 1);
}
dump_prop(l->properties, 1);
printf("\n}");
}
if (l) {
if (l->next) dump_layer(l->next, tc);
}
}
void dump_map(tmx_map *m) {
fputs("map={", stdout);
if (m) {
printf("\n\t" "orient="); print_orient(m->orient);
printf("\n\t" "renderorder=%d", m->renderorder);
printf("\n\t" "height=%u", m->height);
printf("\n\t" "width=%u", m->width);
printf("\n\t" "theight=%u", m->tile_height);
printf("\n\t" "twidth=%u", m->tile_width);
printf("\n\t" "bgcol=#%.6X", m->backgroundcolor);
printf("\n\t" "staggerindex="); print_stagger_index(m->stagger_index);
printf("\n\t" "staggeraxis="); print_stagger_axis(m->stagger_axis);
printf("\n\t" "hexsidelength=%d", m->hexsidelength);
} else {
fputs("\n(NULL)", stdout);
}
puts("\n}");
if (m) {
dump_tileset(m->ts_head);
dump_layer(m->ly_head, m->height * m->width);
dump_prop(m->properties, 0);
}
}