Jo Engine 2026.11.1
Jo Sega Saturn Engine
Loading...
Searching...
No Matches
vdp2_malloc.h
Go to the documentation of this file.
1/*
2** Jo Sega Saturn Engine
3** Copyright (c) 2012-2026, 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*/
34
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
78
84void *jo_vdp2_malloc(const jo_vdp2_ram_usage usage, const unsigned int n);
85
91{
92 return (jo_vdp2_malloc(usage, ~0));
93}
94
99bool __jo_vdp2_a0_start_is_free(const unsigned int n);
100
104void jo_vdp2_free(const void * const p);
105
106#endif /* !__JO_VDP2_MALLOC_H__ */
107
108/*
109** END OF FILE
110*/
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition types.h:39
void * jo_vdp2_malloc(const jo_vdp2_ram_usage usage, const unsigned int n)
Dynamic VDP2 memory allocator.
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:90
bool __jo_vdp2_a0_start_is_free(const unsigned int n)
Whether jo_vdp2_malloc() would return the start of the bank A0 for n bytes (bitmap,...
jo_vdp2_ram_usage
Definition vdp2_malloc.h:47
@ JO_VDP2_RAM_MAP_NBG1
Definition vdp2_malloc.h:52
@ JO_VDP2_RAM_BITMAP_NBG0
CELL (NBG0 and NBG1 bitmaps).
Definition vdp2_malloc.h:71
@ JO_VDP2_RAM_CELL_RBG0
Definition vdp2_malloc.h:65
@ JO_VDP2_RAM_MAP_NBG2
Definition vdp2_malloc.h:53
@ JO_VDP2_RAM_MAP_NBG3
Definition vdp2_malloc.h:54
@ JO_VDP2_RAM_USER
For user.
Definition vdp2_malloc.h:49
@ JO_VDP2_RAM_KTABLE
KTABLE (rotation coefficient table).
Definition vdp2_malloc.h:57
@ JO_VDP2_RAM_BITMAP_NBG1
Definition vdp2_malloc.h:72
@ JO_VDP2_RAM_RTABLE
Rotation table (rotation parameters).
Definition vdp2_malloc.h:59
@ JO_VDP2_RAM_MAP_RBG0
Definition vdp2_malloc.h:55
@ JO_VDP2_RAM_COLOR
Color RAM for Palette, etc.
Definition vdp2_malloc.h:74
@ JO_VDP2_RAM_CELL_NBG0
CELL (rotation and normal scroll screen cells).
Definition vdp2_malloc.h:61
@ JO_VDP2_RAM_BACK_COLOR
Back color (back screen color).
Definition vdp2_malloc.h:67
@ JO_VDP2_RAM_MAP_NBG0
MAP (rotation and normal scroll screen maps).
Definition vdp2_malloc.h:51
@ JO_VDP2_RAM_CELL_NBG3
Definition vdp2_malloc.h:64
@ JO_VDP2_RAM_CELL_NBG1
Definition vdp2_malloc.h:62
@ JO_VDP2_LINE_COLOR_TABLE
Line color table (line color screen).
Definition vdp2_malloc.h:76
@ JO_VDP2_RAM_CELL_NBG2
Definition vdp2_malloc.h:63
@ JO_VDP2_RAM_LINE_SCROLL
Line Scroll table (NBG0 and NBG1 line scroll).
Definition vdp2_malloc.h:69
void jo_vdp2_free(const void *const p)
function frees VDP2 memory space pointed to by p