Prefix the JNI types from SquirrelJME with sjme_ so that they can easily be mixed...
[SquirrelJME.git] / nanocoat / include / sjme / modelessStars.h
blob6d0207833c5d31965a49564e390a109320416fdc
1 /* -*- Mode: C; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
3 // SquirrelJME
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the Mozilla Public License Version 2.0.
7 // See license.mkd for licensing and copyright information.
8 // -------------------------------------------------------------------------*/
10 /**
11 * Modeless Star Screen.
13 * @since 2023/11/28
16 #ifndef SQUIRRELJME_MODELESSSTARS_H
17 #define SQUIRRELJME_MODELESSSTARS_H
19 #include "sjme/nvm.h"
21 /* Anti-C++. */
22 #ifdef __cplusplus
23 #ifndef SJME_CXX_IS_EXTERNED
24 #define SJME_CXX_IS_EXTERNED
25 #define SJME_CXX_SQUIRRELJME_MODELESSSTARS_H
26 extern "C" {
27 #endif /* #ifdef SJME_CXX_IS_EXTERNED */
28 #endif /* #ifdef __cplusplus */
30 /*--------------------------------------------------------------------------*/
32 /** Modeless color info. */
33 typedef struct sjme_modelessStarColor
35 /** XRGB. */
36 sjme_jint xrgb[4];
37 } sjme_modelessStarColor;
39 /**
40 * Keeps track of modeless stars.
42 * @since 2023/11/22
44 typedef struct sjme_modelessStar
46 /** Is this star shining? */
47 sjme_jboolean shining;
49 /** The X coordinate. */
50 sjme_jint x;
52 /** The Y coordinate. */
53 sjme_jint y;
55 /** The speed of the star. */
56 sjme_jint speed;
57 } sjme_modelessStar;
59 /** Color shift. */
60 #define SJME_MODELESS_STAR_COLOR_SHIFT 16
62 /** Number of modeless stars. */
63 #define SJME_MODELESS_STAR_COUNT 128
65 /** Modeless color options. */
66 typedef enum sjme_modelessStarColorId
68 /** Starting color. */
69 SJME_MODELESS_STAR_COLOR_ID_START,
71 /** Ending color. */
72 SJME_MODELESS_STAR_COLOR_ID_END,
74 /** Current color at. */
75 SJME_MODELESS_STAR_COLOR_ID_AT,
77 /** The slice addition. */
78 SJME_MODELESS_STAR_COLOR_ID_SLICE,
80 /** The number of color IDs. */
81 SJME_NUM_MODELESS_STAR_COLOR_IDS
82 } sjme_modelessStarColorId;
84 /**
85 * Contains the state of modeless stars.
87 * @since 2023/11/28
89 typedef struct sjme_modelessStarState
91 /** The modeless stars. */
92 sjme_modelessStar modelessStars[SJME_MODELESS_STAR_COUNT];
94 /** Is star creation locked? */
95 sjme_jint lockStarCreation;
97 /** The last @c lockStarCreation value. */
98 sjme_jint lockStarCreationLast;
100 /** First go latched? */
101 sjme_jboolean latchedFirstGo;
102 } sjme_modelessStarState;
105 * Draws modeless stars into the buffer.
107 * @param state The modeless star state.
108 * @param buf The buffer to draw into.
109 * @param width The width of the buffer.
110 * @param height The height of the buffer.
111 * @param pitch The pitch of the buffer.
112 * @param tick The current tick.
113 * @return Returns @c SJME_JNI_FALSE if there are issues with inputs.
114 * @since 2023/11/22
116 sjme_jboolean sjme_modelessStars(
117 sjme_attrInOutNotNull sjme_modelessStarState* state,
118 sjme_attrInNotNull uint32_t* buf,
119 sjme_attrInPositiveNonZero sjme_jint width,
120 sjme_attrInPositiveNonZero sjme_jint height,
121 sjme_attrInPositiveNonZero sjme_jint pitch,
122 sjme_attrInValue sjme_jint tick);
124 /*--------------------------------------------------------------------------*/
126 /* Anti-C++. */
127 #ifdef __cplusplus
128 #ifdef SJME_CXX_SQUIRRELJME_MODELESSSTARS_H
130 #undef SJME_CXX_SQUIRRELJME_MODELESSSTARS_H
131 #undef SJME_CXX_IS_EXTERNED
132 #endif /* #ifdef SJME_CXX_SQUIRRELJME_MODELESSSTARS_H */
133 #endif /* #ifdef __cplusplus */
135 #endif /* SQUIRRELJME_MODELESSSTARS_H */