Jo Engine  2023.08.26
Jo Sega Saturn Engine
core.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_CORE_H__
36 # define __JO_CORE_H__
37 
38 #ifdef JO_DEBUG
39 
44 void __jo_core_error(char *message, const char *function);
45 # define jo_core_error(...) do {sprintf(__jo_last_error, __VA_ARGS__); __jo_core_error(__jo_last_error, __FUNCTION__);} while(0)
46 
47 #endif
48 
50 # define JO_ENGINE_VERSION (10.0)
51 
52 /*
53 ** TYPEDEFS
54 */
56 typedef void (*jo_event_callback)(void);
57 
58 #ifdef JO_COMPILE_WITH_DUAL_CPU_SUPPORT
59 
61 typedef void (*jo_slave_callback)(void);
62 
63 #endif
64 
69 void jo_core_init(const jo_color back_color);
70 
74 void jo_core_run(void);
75 
81 
85 void jo_core_remove_vblank_callback(const int vblank_event_id);
86 
93 
97 void jo_core_remove_callback(const int event_id);
98 
99 #ifdef JO_COMPILE_WITH_DUAL_CPU_SUPPORT
100 
107 
111 void jo_core_remove_slave_callback(const int event_id);
112 
113 #endif
114 
119 
122 void jo_goto_boot_menu(void);
123 
124 #ifdef JO_COMPILE_WITH_DUAL_CPU_SUPPORT
125 
130 
134 
135 #endif
136 
140 {
143 }
144 
148 {
151 }
152 
156 {
157  slTVOff();
158 }
159 
163 {
164  slTVOn();
165 }
166 
172 {
173 
174  (**(void(**)(void))0x600026C)();
175 }
176 
181 {
184 }
185 
191 #define jo_core_set_screens_order(screen1, args...) __jo_core_set_screens_order(screen1, ## args, ~0);
192 
193 #ifdef JO_DEBUG
194 
197 void jo_core_suspend(void);
198 
203 {
204  return (__jo_last_error);
205 }
206 
210 
214 
215 #endif
216 
221 
222 #endif /* !__JO_CORE_H__ */
223 
224 /*
225 ** END OF FILE
226 */
jo_core_add_vblank_callback
int jo_core_add_vblank_callback(const jo_event_callback callback)
Add a callback during VBLANK interruption.
jo_slave_callback
void(* jo_slave_callback)(void)
Function prototype for jo_core_exec_on_slave()
Definition: core.h:61
jo_core_add_slave_callback
int jo_core_add_slave_callback(const jo_event_callback callback)
Add a callback in the game loop on slave CPU.
jo_core_wait_for_slave
void jo_core_wait_for_slave(void)
Wait until slave callback is completed.
jo_core_add_callback
int jo_core_add_callback(const jo_event_callback callback)
Add a callback in the game loop on main CPU.
__jo_core_set_screens_order
void __jo_core_set_screens_order(jo_scroll_screen screen1,...)
Screen order (Internal usage)
jo_core_restart_saturn
static __jo_force_inline void jo_core_restart_saturn(void)
Restart the Saturn.
Definition: core.h:180
jo_get_last_error
static __jo_force_inline char * jo_get_last_error(void)
Get last error.
Definition: core.h:202
jo_core_exit_to_multiplayer
static __jo_force_inline void jo_core_exit_to_multiplayer(void)
Exit program and return to the Saturn multiplayer (CD player) screen.
Definition: core.h:171
jo_core_init
void jo_core_init(const jo_color back_color)
Init the engine.
jo_core_tv_off
static __jo_force_inline void jo_core_tv_off(void)
Turn OFF scroll drawing processing in the monitor.
Definition: core.h:155
jo_color
unsigned short jo_color
15 bits color type
Definition: types.h:42
jo_core_disable_reset
static __jo_force_inline void jo_core_disable_reset(void)
Disable reset button.
Definition: core.h:139
JO_PRINTF_BUF_SIZE
#define JO_PRINTF_BUF_SIZE
Max character in available in jo_printf()
Definition: conf.h:165
jo_core_remove_vblank_callback
void jo_core_remove_vblank_callback(const int vblank_event_id)
Remove a callback during VBLANK interruption.
__jo_force_inline
#define __jo_force_inline
force inline attribute (and prevent Doxygen prototype parsing bug)
Definition: types.h:39
jo_event_callback
void(* jo_event_callback)(void)
Function prototype for jo_core_add_callback()
Definition: core.h:56
jo_core_suspend
void jo_core_suspend(void)
Stop the execution until someone press Start.
jo_core_run
void jo_core_run(void)
Run the game.
jo_goto_boot_menu
void jo_goto_boot_menu(void)
Return to the boot menu.
jo_core_set_restart_game_callback
void jo_core_set_restart_game_callback(const jo_event_callback callback)
Add a callback when A+B+C+Start is pressed on the first control pad.
DisableReset
@ DisableReset
Disables NMI requests to be sent when the Reset button is pressed.
Definition: smpc.h:78
__jo_last_error
char __jo_last_error[JO_PRINTF_BUF_SIZE]
Error handling (Internal usage)
jo_core_exec_on_slave
void jo_core_exec_on_slave(jo_slave_callback callback)
Execute a callback on the slave CPU.
jo_core_enable_reset
static __jo_force_inline void jo_core_enable_reset(void)
Enable reset button.
Definition: core.h:147
jo_core_remove_slave_callback
void jo_core_remove_slave_callback(const int event_id)
Remove a callback in the game loop from on slave CPU.
jo_dump_vdp1_registers
void jo_dump_vdp1_registers(void)
Dump VDP1 registers.
EnableReset
@ EnableReset
Enables NMI requests to be sent when the Reset button is pressed.
Definition: smpc.h:76
jo_dump_vdp2_registers
void jo_dump_vdp2_registers(void)
Dump VDP2 registers.
jo_smpc_begin_command
static __jo_force_inline void jo_smpc_begin_command(void)
Definition: smpc.h:150
jo_core_tv_on
static __jo_force_inline void jo_core_tv_on(void)
Turn ON scroll drawing processing in the monitor.
Definition: core.h:162
jo_core_remove_callback
void jo_core_remove_callback(const int event_id)
Remove a callback in the game loop from on main CPU.
SystemReset
@ SystemReset
Resets the System.
Definition: smpc.h:62
jo_smpc_end_command
static __jo_force_inline void jo_smpc_end_command(jo_smpc_command command)
Definition: smpc.h:155
__jo_core_error
void __jo_core_error(char *message, const char *function)
jo_scroll_screen
jo_scroll_screen
Sega Saturn Scroll Screen Ids.
Definition: types.h:316