Jo Engine  2020.06.22
Jo Sega Saturn Engine
vdp2_malloc.h
Go to the documentation of this file.
1 /*
2 ** Jo Sega Saturn Engine
3 ** Copyright (c) 2012-2020, Johannes Fetz (johannesfetz@gmail.com)
4 ** All rights reserved.
5 **
6 ** Redistribution and use in source and binary forms, with or without
7 ** modification, are permitted provided that the following conditions are met:
8 ** * Redistributions of source code must retain the above copyright
9 ** notice, this list of conditions and the following disclaimer.
10 ** * Redistributions in binary form must reproduce the above copyright
11 ** notice, this list of conditions and the following disclaimer in the
12 ** documentation and/or other materials provided with the distribution.
13 ** * Neither the name of the Johannes Fetz nor the
14 ** names of its contributors may be used to endorse or promote products
15 ** derived from this software without specific prior written permission.
16 **
17 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ** ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 ** WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 ** DISCLAIMED. IN NO EVENT SHALL Johannes Fetz BE LIABLE FOR ANY
21 ** DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 ** (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 ** LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ** ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 ** SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
35 #ifndef __JO_VDP2_MALLOC_H__
36 # define __JO_VDP2_MALLOC_H__
37 
38 /*
39 ** MACROS
40 */
41 # define JO_VDP2_KTABLE_SIZE (0x1FE00)
42 # define JO_VDP2_ROTATION_TABLE_SIZE (0x00080)
43 # define JO_VDP2_MAP_SIZE (8192)
44 # define JO_VDP2_CELL_TO_MAP_OFFSET(CELL_PTR) JO_DIV_BY_32(JO_MOD_POW2((int)CELL_PTR, JO_VDP2_BANK_SIZE))
45 
46 typedef enum
47 {
76 
82 void *jo_vdp2_malloc(const jo_vdp2_ram_usage usage, const unsigned int n);
83 
89 {
90  return (jo_vdp2_malloc(usage, ~0));
91 }
92 
96 void jo_vdp2_free(const void * const p);
97 
98 #endif /* !__JO_VDP2_MALLOC_H__ */
99 
100 /*
101 ** END OF FILE
102 */
JO_VDP2_RAM_LINE_SCROLL
@ JO_VDP2_RAM_LINE_SCROLL
Line Scroll table (for slLineScrollTable0 and slLineScrollTable1)
Definition: vdp2_malloc.h:69
JO_VDP2_RAM_CELL_NBG2
@ JO_VDP2_RAM_CELL_NBG2
Definition: vdp2_malloc.h:63
JO_VDP2_RAM_COLOR
@ JO_VDP2_RAM_COLOR
Color RAM for Palette, etc.
Definition: vdp2_malloc.h:74
JO_VDP2_RAM_CELL_RBG0
@ JO_VDP2_RAM_CELL_RBG0
Definition: vdp2_malloc.h:65
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: conf.h:154
jo_vdp2_malloc_autosize
static __jo_force_inline void * jo_vdp2_malloc_autosize(const jo_vdp2_ram_usage usage)
Dynamic VDP2 memory allocator for known size usage (JO_VDP2_RAM_RTABLE, JO_VDP2_RAM_KTABLE,...
Definition: vdp2_malloc.h:88
JO_VDP2_RAM_MAP_NBG1
@ JO_VDP2_RAM_MAP_NBG1
Definition: vdp2_malloc.h:52
jo_vdp2_malloc
void * jo_vdp2_malloc(const jo_vdp2_ram_usage usage, const unsigned int n)
Dynamic VDP2 memory allocator.
JO_VDP2_RAM_BACK_COLOR
@ JO_VDP2_RAM_BACK_COLOR
Back color (for slBack1ColSet)
Definition: vdp2_malloc.h:67
JO_VDP2_RAM_BITMAP_NBG1
@ JO_VDP2_RAM_BITMAP_NBG1
Definition: vdp2_malloc.h:72
JO_VDP2_RAM_CELL_NBG0
@ JO_VDP2_RAM_CELL_NBG0
CELL (for slPageRbg0, slPageNbg1, etc)
Definition: vdp2_malloc.h:61
JO_VDP2_RAM_CELL_NBG3
@ JO_VDP2_RAM_CELL_NBG3
Definition: vdp2_malloc.h:64
JO_VDP2_RAM_BITMAP_NBG0
@ JO_VDP2_RAM_BITMAP_NBG0
CELL (for slBitMapNbg0, slBitMapNbg1, etc)
Definition: vdp2_malloc.h:71
JO_VDP2_RAM_MAP_NBG2
@ JO_VDP2_RAM_MAP_NBG2
Definition: vdp2_malloc.h:53
JO_VDP2_RAM_USER
@ JO_VDP2_RAM_USER
For user.
Definition: vdp2_malloc.h:49
jo_vdp2_free
void jo_vdp2_free(const void *const p)
function frees VDP2 memory space pointed to by p
JO_VDP2_RAM_KTABLE
@ JO_VDP2_RAM_KTABLE
KTABLE (for slMakeKtable)
Definition: vdp2_malloc.h:57
JO_VDP2_RAM_MAP_NBG3
@ JO_VDP2_RAM_MAP_NBG3
Definition: vdp2_malloc.h:54
jo_vdp2_ram_usage
jo_vdp2_ram_usage
Definition: vdp2_malloc.h:47
JO_VDP2_RAM_CELL_NBG1
@ JO_VDP2_RAM_CELL_NBG1
Definition: vdp2_malloc.h:62
JO_VDP2_RAM_MAP_RBG0
@ JO_VDP2_RAM_MAP_RBG0
Definition: vdp2_malloc.h:55
JO_VDP2_RAM_MAP_NBG0
@ JO_VDP2_RAM_MAP_NBG0
MAP (for sl1MapRA, slMapNbg1, etc)
Definition: vdp2_malloc.h:51
JO_VDP2_RAM_RTABLE
@ JO_VDP2_RAM_RTABLE
Rotation table (for slRparaInitSet)
Definition: vdp2_malloc.h:59