-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.h
134 lines (108 loc) · 3.39 KB
/
level.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
/*
* Dragon - Level data interfacing
* Copyright (C) 2016 Sandor Zsuga (Jubatian)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
** Interfaces static (non object) level data.
**
** Level layout:
**
** Innermost L0 blocks are 4 x 4 tiles. There are up to 256 blocks. This also
** defines the logic of the block.
**
** L0 blocks may be replaced by a replacement list in RAM, detailed later
** below.
**
** L1 blocks are 16 x 8 tiles large (horizontally wide). They contain 8 L0
** blocks, taking 8 bytes each.
**
** The map is built from L1 blocks, up to 64 on X, 128 on Y (so up to 256 L0
** blocks in either dimensions). It can use at most 256 L1 blocks (so the L0
** replacement map fits in its 2048 bit storage). On the X dimension the L1
** count must be even.
**
** The replacement map is a simple bitmap mapping all L0 blocks of the level,
** indicating whether the replacement L0 should be used.
**
** L1 layout (L0 blocks within):
**
** 0123
** 4567
**
** The replacement map doesn't follow the L1 layout (it addresses L0 blocks
** directly, high bits corresponding to blocks on the left).
*/
#ifndef LEVEL_H
#define LEVEL_H
#include "types.h"
#include "leveldef.h"
/*
** Clears replacements.
*/
void level_repclear(void);
/*
** Adds L0 block to replacements.
**
** Marks the given L0 block as replaced. Marks by x:y locations (low 2 bits
** unused as they index within the L0. If it is already marked, nothing
** happens.
*/
void level_repadd(uint16 x, uint16 y);
/*
** Removes L0 block from replacements.
**
** Removes replaced mark from an L0. If it isn't marked, nothing happens.
*/
void level_reprem(uint16 x, uint16 y);
/*
** Set map by its L1 index table and width.
**
** The L1 index table (map) is in ROM starting at arbitrary location. Only map
** width is used here to serve as pitch. Width and height is to be interpreted
** in L1 blocks (so 16 x 8 tile blocks).
**
** The replacement map is cleared upon calling this.
*/
void level_set(uint16 map, auint wdt, auint hgt);
/*
** Retrieve tile from map.
**
** Fetches the tile at a given tile location on the map, to be used for
** filling and scrolling the VRAM. Returns the tile's index.
**
** For assembly routine calls XH:XL is not clobbered.
*/
auint level_gettile(uint16 x, uint16 y);
/*
** Retrieve L0 from map.
**
** Fetches the L0 block at the given tile location on the map. The low 2 bits
** of the location are not used (they specify offset within the L0). When an
** out of map coordinate is passed, return is generated according to the
** related defines in leveldef.h.
**
** For assembly routine calls XH:XL is not clobbered.
*/
auint level_getl0(uint16 x, uint16 y);
/*
** Map width (in L1 blocks: 16 tiles wide). Read only!
*/
extern auint level_w;
/*
** Map height (in L1 blocks: 8 tiles tall). Read only!
*/
extern auint level_h;
#endif