mirror of
https://github.com/nunuhara/xsystem4.git
synced 2026-09-22 23:18:01 +03:00
== Handles As a general pattern, these libraries have an interface based on integer handles allocated by Open() and released by Close(); in the AliceSoft's implementation, handles are pointers to internal objects. Note that: * 0 is used to represent an invalid handle, and * Small numbers cannot be handles. For example, Mamanyonyo has code that treats an integer as a CG number if it is less than 10000, and as a surface handle otherwise. In this patch, handles are generated using id_pool.h functions. In order to achieve the above, the interface is extended so that the minimum ID value can be specified (the `base` parameter of id_pool_init()). == Graphics System Surface objects (implemented in vmSurface.[ch]) plays a central role in Mamanyonyo's graphics system, and the sprite system (vmSprite.c) is implemented on top of it. vmSprite.c uses scene.h functions. == vmChrLoader and vmMapLoader Since Mamanyonyo's character data format is the same as Widenyo's, the ChrLoader code has been refactored and used from vmChrLoader.c. On the other hand, MapLoader and vmMapLoader do not share code because the map file format is different from Widenyo.
40 lines
1.4 KiB
C
40 lines
1.4 KiB
C
/* Copyright (C) 2019 Nunuhara Cabbage <nunuhara@haniwa.technology>
|
|
*
|
|
* 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 2 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://gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef SYSTEM4_ID_POOL_H
|
|
#define SYSTEM4_ID_POOL_H
|
|
|
|
// A reasonable base value for pointer-based handles.
|
|
#define ID_POOL_HANDLE_BASE 0x100000
|
|
|
|
struct id_pool {
|
|
void **slots;
|
|
int nr_slots;
|
|
int base;
|
|
};
|
|
|
|
void id_pool_init(struct id_pool *pool, int base);
|
|
void id_pool_delete(struct id_pool *pool);
|
|
void *id_pool_release(struct id_pool *pool, int id);
|
|
int id_pool_count(struct id_pool *pool);
|
|
int id_pool_get_unused(struct id_pool *pool);
|
|
int id_pool_get_first(struct id_pool *pool);
|
|
int id_pool_get_next(struct id_pool *pool, int id);
|
|
void *id_pool_get(struct id_pool *pool, int id);
|
|
void *id_pool_set(struct id_pool *pool, int id, void *data);
|
|
|
|
#endif /* SYSTEM4_ID_POOL_H */
|