1 | /* |
---|
2 | * Abuse - dark 2D side-scrolling platform game |
---|
3 | * Copyright (c) 1995 Crack dot Com |
---|
4 | * |
---|
5 | * This software was released into the Public Domain. As with most public |
---|
6 | * domain software, no warranty is made or implied by Crack dot Com or |
---|
7 | * Jonathan Clark. |
---|
8 | */ |
---|
9 | |
---|
10 | class tile |
---|
11 | { |
---|
12 | uchar *im_data; |
---|
13 | uchar *run_data; |
---|
14 | boundary *points; |
---|
15 | ushort next; |
---|
16 | public : |
---|
17 | tile(bFILE *fp, int type); |
---|
18 | } ; |
---|
19 | |
---|
20 | |
---|
21 | tile::tile(bFILE *fp, int type, int w, int h) |
---|
22 | { |
---|
23 | int cw=fp->read_short(),ch=fp->read_short(); |
---|
24 | if (cw!=w || ch!=h) |
---|
25 | { |
---|
26 | lbreak("load_tiles : expecting tile size to be %dx%d, got %dx%d\n",w,h,cw,ch); |
---|
27 | exit(0); |
---|
28 | } |
---|
29 | |
---|
30 | im_data=(uchar *)jmalloc(w*h,"tile image"); |
---|
31 | fp->read(im_data,w*h); |
---|
32 | |
---|
33 | if (type==SPEC_FORETILE) |
---|
34 | { |
---|
35 | next=fp->read_short(); // next |
---|
36 | fp->read_byte(); // skip damage, not implemented |
---|
37 | points=new boundary(fp,"tile boundary"); |
---|
38 | uchar *c=im_data; |
---|
39 | int need_runs=0; |
---|
40 | |
---|
41 | if (need_runs) |
---|
42 | run_data=make_runs(im_data,w,h); |
---|
43 | } else run_data=NULL; |
---|
44 | } else { points=NULL; run_data=NULL; } |
---|
45 | } |
---|
46 | |
---|
47 | class tile_set |
---|
48 | { |
---|
49 | public : |
---|
50 | int w,h,t; |
---|
51 | int *id; |
---|
52 | tile_set *next; |
---|
53 | tile_set(int width, int height); |
---|
54 | void add(int tile_id, int tile_number); |
---|
55 | } ; |
---|
56 | |
---|
57 | |
---|
58 | tile_set::tile_set(int width, int height, tile_set *Next) |
---|
59 | { |
---|
60 | w=width; |
---|
61 | h=height; |
---|
62 | t=0; |
---|
63 | next=Next; |
---|
64 | id=NULL; |
---|
65 | } |
---|
66 | |
---|
67 | |
---|
68 | void tile_set::add(int tile_id, int tile_number) |
---|
69 | { |
---|
70 | if (tile_number>=t) |
---|
71 | { |
---|
72 | id=(int *)jrealloc(id,sizeof(int)*tile_number,"tile set list"); |
---|
73 | t=tile_number; |
---|
74 | } |
---|
75 | id[tile_number]=tile_id; |
---|
76 | } |
---|
77 | |
---|
78 | |
---|
79 | |
---|