neocore
neocore.c
Go to the documentation of this file.
1 /*
2  David Vandensteen
3  2018
4 */
5 
6 #include <DATlib.h>
7 #include <input.h>
8 #include <stdio.h>
9 #include <neocore.h>
10 #include <math.h>
11 
12  /*------------------*/
13  /* -static */
14 /*------------------*/
15 
16 static WORD sprite_index = 1;
17 static BYTE palette_index = 16;
18 
19 static BOOL palette_auto_index = true;
20 static BOOL sprite_auto_index = true;
21 
22 static BOOL collide_point(short x, short y, Vec2short vec[], BYTE vector_max);
23 static const WORD shrunk_table_prop[] = { 0x000 , 0x001 , 0x002 , 0x003 , 0x004 , 0x005 , 0x006 , 0x007 , 0x008 , 0x009 , 0x00a , 0x00b , 0x00c , 0x00d , 0x00e , 0x00f , 0x010 , 0x111 , 0x112 , 0x113 , 0x114 , 0x115 , 0x116 , 0x117 , 0x118 , 0x119 , 0x11a , 0x11b , 0x11c , 0x11d , 0x11e , 0x11f , 0x120 , 0x121 , 0x222 , 0x223 , 0x224 , 0x225 , 0x226 , 0x227 , 0x228 , 0x229 , 0x22a , 0x22b , 0x22c , 0x22d , 0x22e , 0x22f , 0x230 , 0x231 , 0x232 , 0x333 , 0x334 , 0x335 , 0x336 , 0x337 , 0x338 , 0x339 , 0x33a , 0x33b , 0x33c , 0x33d , 0x33e , 0x33f , 0x340 , 0x341 , 0x342 , 0x343 , 0x444 , 0x445 , 0x446 , 0x447 , 0x448 , 0x449 , 0x44a , 0x44b , 0x44c , 0x44d , 0x44e , 0x44f , 0x450 , 0x451 , 0x452 , 0x453 , 0x454 , 0x555 , 0x556 , 0x557 , 0x558 , 0x559 , 0x55a , 0x55b , 0x55c , 0x55d , 0x55e , 0x55f , 0x560 , 0x561 , 0x562 , 0x563 , 0x564 , 0x565 , 0x666 , 0x667 , 0x668 , 0x669 , 0x66a , 0x66b , 0x66c , 0x66d , 0x66e , 0x66f , 0x670 , 0x671 , 0x672 , 0x673 , 0x674 , 0x675 , 0x676 , 0x777 , 0x778 , 0x779 , 0x77a , 0x77b , 0x77c , 0x77d , 0x77e , 0x77f , 0x780 , 0x781 , 0x782 , 0x783 , 0x784 , 0x785 , 0x786 , 0x787 , 0x888 , 0x889 , 0x88a , 0x88b , 0x88c , 0x88d , 0x88e , 0x88f , 0x890 , 0x891 , 0x892 , 0x893 , 0x894 , 0x895 , 0x896 , 0x897 , 0x898 , 0x999 , 0x99a , 0x99b , 0x99c , 0x99d , 0x99e , 0x99f , 0x9a0 , 0x9a1 , 0x9a2 , 0x9a3 , 0x9a4 , 0x9a5 , 0x9a6 , 0x9a7 , 0x9a8 , 0x9a9 , 0xaaa , 0xaab , 0xaac , 0xaad , 0xaae , 0xaaf , 0xab0 , 0xab1 , 0xab2 , 0xab3 , 0xab4 , 0xab5 , 0xab6 , 0xab7 , 0xab8 , 0xab9 , 0xaba , 0xbbb , 0xbbc , 0xbbd , 0xbbe , 0xbbf , 0xbc0 , 0xbc1 , 0xbc2 , 0xbc3 , 0xbc4 , 0xbc5 , 0xbc6 , 0xbc7 , 0xbc8 , 0xbc9 , 0xbca , 0xbcb , 0xccc , 0xccd , 0xcce , 0xccf , 0xcd0 , 0xcd1 , 0xcd2 , 0xcd3 , 0xcd4 , 0xcd5 , 0xcd6 , 0xcd7 , 0xcd8 , 0xcd9 , 0xcda , 0xcdb , 0xcdc , 0xddd , 0xdde , 0xddf , 0xde0 , 0xde1 , 0xde2 , 0xde3 , 0xde4 , 0xde5 , 0xde6 , 0xde7 , 0xde8 , 0xde9 , 0xdea , 0xdeb , 0xdec , 0xded , 0xeee , 0xeef , 0xef0 , 0xef1 , 0xef2 , 0xef3 , 0xef4 , 0xef5 , 0xef6 , 0xef7 , 0xef8 , 0xef9 , 0xefa , 0xefb , 0xefc , 0xefd , 0xefe , 0xfff , 0xefe , 0xefd , 0xefc , 0xefb , 0xefa , 0xef9 , 0xef8 , 0xef7 , 0xef6 , 0xef5 , 0xef4 , 0xef3 , 0xef2 , 0xef1 , 0xef0 , 0xeef , 0xeee , 0xded , 0xdec , 0xdeb , 0xdea , 0xde9 , 0xde8 , 0xde7 , 0xde6 , 0xde5 , 0xde4 , 0xde3 , 0xde2 , 0xde1 , 0xde0 , 0xddf , 0xdde , 0xddd , 0xcdc , 0xcdb , 0xcda , 0xcd9 , 0xcd8 , 0xcd7 , 0xcd6 , 0xcd5 , 0xcd4 , 0xcd3 , 0xcd2 , 0xcd1 , 0xcd0 , 0xccf , 0xcce , 0xccd , 0xccc , 0xbcb , 0xbca , 0xbc9 , 0xbc8 , 0xbc7 , 0xbc6 , 0xbc5 , 0xbc4 , 0xbc3 , 0xbc2 , 0xbc1 , 0xbc0 , 0xbbf , 0xbbe , 0xbbd , 0xbbc , 0xbbb , 0xaba , 0xab9 , 0xab8 , 0xab7 , 0xab6 , 0xab5 , 0xab4 , 0xab3 , 0xab2 , 0xab1 , 0xab0 , 0xaaf , 0xaae , 0xaad , 0xaac , 0xaab , 0xaaa , 0x9a9 , 0x9a8 , 0x9a7 , 0x9a6 , 0x9a5 , 0x9a4 , 0x9a3 , 0x9a2 , 0x9a1 , 0x9a0 , 0x99f , 0x99e , 0x99d , 0x99c , 0x99b , 0x99a , 0x999 , 0x898 , 0x897 , 0x896 , 0x895 , 0x894 , 0x893 , 0x892 , 0x891 , 0x890 , 0x88f , 0x88e , 0x88d , 0x88c , 0x88b , 0x88a , 0x889 , 0x888 , 0x787 , 0x786 , 0x785 , 0x784 , 0x783 , 0x782 , 0x781 , 0x780 , 0x77f , 0x77e , 0x77d , 0x77c , 0x77b , 0x77a , 0x779 , 0x778 , 0x777 , 0x676 , 0x675 , 0x674 , 0x673 , 0x672 , 0x671 , 0x670 , 0x66f , 0x66e , 0x66d , 0x66c , 0x66b , 0x66a , 0x669 , 0x668 , 0x667 , 0x666 , 0x565 , 0x564 , 0x563 , 0x562 , 0x561 , 0x560 , 0x55f , 0x55e , 0x55d , 0x55c , 0x55b , 0x55a , 0x559 , 0x558 , 0x557 , 0x556 , 0x555 , 0x454 , 0x453 , 0x452 , 0x451 , 0x450 , 0x44f , 0x44e , 0x44d , 0x44c , 0x44b , 0x44a , 0x449 , 0x448 , 0x447 , 0x446 , 0x445 , 0x444 , 0x343 , 0x342 , 0x341 , 0x340 , 0x33f , 0x33e , 0x33d , 0x33c , 0x33b , 0x33a , 0x339 , 0x338 , 0x337 , 0x336 , 0x335 , 0x334 , 0x333 , 0x232 , 0x231 , 0x230 , 0x22f , 0x22e , 0x22d , 0x22c , 0x22b , 0x22a , 0x229 , 0x228 , 0x227 , 0x226 , 0x225 , 0x224 , 0x223 , 0x222 , 0x121 , 0x120 , 0x11f , 0x11e , 0x11d , 0x11c , 0x11b , 0x11a , 0x119 , 0x118 , 0x117 , 0x116 , 0x115 , 0x114 , 0x113 , 0x112 , 0x111 , 0x010 , 0x00f , 0x00e , 0x00d , 0x00c , 0x00b , 0x00a , 0x009 , 0x008 , 0x007 , 0x006 , 0x005 , 0x004 , 0x003 , 0x002 , 0x001 , 0x000 , 0x001 , 0x002 , 0x003 , 0x004 , 0x005 , 0x006 , 0x007 , 0x008 , 0x009 , 0x00a , 0x00b , 0x00c , 0x00d , 0x00e , 0x00f , 0x010 , 0x111 , 0x112 , 0x113 , 0x114 , 0x115 , 0x116 , 0x117 , 0x118 , 0x119 , 0x11a , 0x11b , 0x11c , 0x11d , 0x11e , 0x11f , 0x120 , 0x121 , 0x222 , 0x223 , 0x224 , 0x225 , 0x226 , 0x227 , 0x228 , 0x229 , 0x22a , 0x22b , 0x22c , 0x22d , 0x22e , 0x22f , 0x230 , 0x231 , 0x232 , 0x333 , 0x334 , 0x335 , 0x336 , 0x337 , 0x338 , 0x339 , 0x33a , 0x33b , 0x33c , 0x33d , 0x33e , 0x33f , 0x340 , 0x341 , 0x342 , 0x343 , 0x444 , 0x445 , 0x446 , 0x447 , 0x448 , 0x449 , 0x44a , 0x44b , 0x44c , 0x44d , 0x44e , 0x44f , 0x450 , 0x451 , 0x452 , 0x453 , 0x454 , 0x555 , 0x556 , 0x557 , 0x558 , 0x559 , 0x55a , 0x55b , 0x55c , 0x55d , 0x55e , 0x55f , 0x560 , 0x561 , 0x562 , 0x563 , 0x564 , 0x565 , 0x666 , 0x667 , 0x668 , 0x669 , 0x66a , 0x66b , 0x66c , 0x66d , 0x66e , 0x66f , 0x670 , 0x671 , 0x672 , 0x673 , 0x674 , 0x675 , 0x676 , 0x777 , 0x778 , 0x779 , 0x77a , 0x77b , 0x77c , 0x77d , 0x77e , 0x77f , 0x780 , 0x781 , 0x782 , 0x783 , 0x784 , 0x785 , 0x786 , 0x787 , 0x888 , 0x889 , 0x88a , 0x88b , 0x88c , 0x88d , 0x88e , 0x88f , 0x890 , 0x891 , 0x892 , 0x893 , 0x894 , 0x895 , 0x896 , 0x897 , 0x898 , 0x999 , 0x99a , 0x99b , 0x99c , 0x99d , 0x99e , 0x99f , 0x9a0 , 0x9a1 , 0x9a2 , 0x9a3 , 0x9a4 , 0x9a5 , 0x9a6 , 0x9a7 , 0x9a8 , 0x9a9 , 0xaaa , 0xaab , 0xaac , 0xaad , 0xaae , 0xaaf , 0xab0 , 0xab1 , 0xab2 , 0xab3 , 0xab4 , 0xab5 , 0xab6 , 0xab7 , 0xab8 , 0xab9 , 0xaba , 0xbbb , 0xbbc , 0xbbd , 0xbbe , 0xbbf , 0xbc0 , 0xbc1 , 0xbc2 , 0xbc3 , 0xbc4 , 0xbc5 , 0xbc6 , 0xbc7 , 0xbc8 , 0xbc9 , 0xbca , 0xbcb , 0xccc , 0xccd , 0xcce , 0xccf , 0xcd0 , 0xcd1 , 0xcd2 , 0xcd3 , 0xcd4 , 0xcd5 , 0xcd6 , 0xcd7 , 0xcd8 , 0xcd9 , 0xcda , 0xcdb , 0xcdc , 0xddd , 0xdde , 0xddf , 0xde0 , 0xde1 , 0xde2 , 0xde3 , 0xde4 , 0xde5 , 0xde6 , 0xde7 , 0xde8 , 0xde9 , 0xdea , 0xdeb , 0xdec , 0xded , 0xeee , 0xeef , 0xef0 , 0xef1 , 0xef2 , 0xef3 , 0xef4 , 0xef5 , 0xef6 , 0xef7 , 0xef8 , 0xef9 , 0xefa , 0xefb , 0xefc , 0xefd , 0xefe , 0xfff };
24 static const char sinTable[] = {
25  32,34,35,37,38,40,41,43,44,46,47,48,50,51,52,53,
26  55,56,57,58,59,59,60,61,62,62,63,63,63,64,64,64,
27  64,64,64,64,63,63,63,62,62,61,60,59,59,58,57,56,
28  55,53,52,51,50,48,47,46,44,43,41,40,38,37,35,34,
29  32,30,29,27,26,24,23,21,20,18,17,16,14,13,12,11,
30  9,8,7,6,5,5,4,3,2,2,1,1,1,0,0,0,
31  0,0,0,0,1,1,1,2,2,3,4,5,5,6,7,8,
32  9,11,12,13,14,16,17,18,20,21,23,24,26,27,29,30
33 };
34 
35 static BOOL collide_point(short x, short y, Vec2short vec[], BYTE vector_max) {
36  BYTE i = 0, j = 0;
37  for (i = 0; i < vector_max; i++) {
38  j = i + 1;
39  if (j == vector_max) { j = 0; }
40  if (vector_is_left( // foreach edge vector check if dot is left
41  x,
42  y,
43  vec[i].x, vec[i].y,
44  vec[j].x, vec[j].y
45  )
46  ) { return false; } // if dot is left of the current vector, we return now (collide is impossible)
47  }
48  return true;
49 }
50 
51 static int x = LOGGER_X_INIT;
52 static int y = LOGGER_Y_INIT;
53 
54 static int x_default = LOGGER_X_INIT;
55 static int y_default = LOGGER_Y_INIT;
56 
57 void inline static setX(WORD _x);
58 void inline static setY(WORD _y);
59 void inline static setPosDefault();
60 WORD inline static countChar(char *txt);
61 void inline static autoInc(); // todo (minor) - logger_auto ... ?
62 
63 void inline static setX(WORD _x){
64  x = _x;
65 }
66 
67 void inline static setY(WORD _y){
68  y = _y;
69 }
70 
71 void inline static setPosDefault(){
72  x = LOGGER_X_INIT;
73  y = LOGGER_Y_INIT;
74 }
75 
76 WORD inline static countChar(char *txt){
77  WORD i = 0;
78  while (txt[i] != '\0') {
79  i++;
80  }
81  return i;
82 }
83 
84 void inline static autoInc(){
85  y++;
86 }
87 
88 JOYPAD
89 
90 
91 
92  //--------------------------------------------------------------------------//
93  // -A //
94 //--------------------------------------------------------------------------//
95  /*------------------*/
96  /* -animated_sprite */
97 /*------------------*/
98 void animated_sprite_init(Animated_Sprite *animated_sprite ,spriteInfo *si, paletteInfo *pali) {
99  flash_init(&animated_sprite->flash, 0, 0);
100  animated_sprite->si = si;
101  animated_sprite->pali = pali;
102 };
103 
104 void animated_sprite_display(Animated_Sprite *animated_sprite, short x, short y, WORD anim) {
105  BOOL palette_auto_index_state = palette_auto_index;
107  aSpriteInit(
108  &animated_sprite->as,
109  animated_sprite->si,
110  get_sprite_index_from_sprite(animated_sprite->si),
111  get_palette_index(animated_sprite->pali),
112  x,
113  y,
114  anim,
115  FLIP_NONE
116  );
117  if (palette_auto_index_state) palette_enable_auto_index();
118  palJobPut(
119  get_palette_index(animated_sprite->pali),
120  animated_sprite->pali->palCount,
121  animated_sprite->pali->data
122  );
123  aSpriteSetAnim(&animated_sprite->as, anim);
124 }
125 
126 BOOL animated_sprite_flash(Animated_Sprite *animated_sprite) {
127  BOOL rt = true;
128  if (animated_sprite->flash.frequency != 0 && animated_sprite->flash.lengh != 0) {
129  if (DAT_frameCounter % animated_sprite->flash.frequency == 0) {
130  if (is_visible(&animated_sprite->flash)) {
131  animated_sprite_hide(animated_sprite);
132  rt = false;
133  } else {
134  animated_sprite_show(animated_sprite);
135  rt = true;
136  }
137  animated_sprite->flash.lengh--;
138  if (animated_sprite->flash.lengh == 0) animated_sprite_show(animated_sprite);
139  }
140  }
141  return rt;
142 }
143 
144 void animated_sprite_set_animation(Animated_Sprite *animated_sprite, WORD anim) {
145  aSpriteSetAnim(&animated_sprite->as, anim);
146 }
147 
148 void animated_sprite_hide(Animated_Sprite *animated_sprite) {
149  animated_sprite->flash.visible = false;
150  aSpriteHide(&animated_sprite->as);
151  clearSprites(animated_sprite->as.baseSprite, animated_sprite->as.tileWidth);
152 }
153 
154 void animated_sprite_show(Animated_Sprite *animated_sprite) {
155  animated_sprite->flash.visible = true;
156  aSpriteShow(&animated_sprite->as);
157 }
158 
159  /*--------------------------*/
160  /* -animated_sprite_physic */
161 /*--------------------------*/
163  Animated_Sprite_Physic *animated_sprite_physic,
164  spriteInfo *si,
165  paletteInfo *pali,
166  short box_witdh,
167  short box_height,
168  short box_width_offset,
169  short box_height_offset
170  ) {
171  box_init(
172  &animated_sprite_physic->box,
173  box_witdh,
174  box_height,
175  box_width_offset,
176  box_height_offset
177  );
178  animated_sprite_physic->physic_enabled = true;
180  &animated_sprite_physic->animated_sprite,
181  si,
182  pali
183  );
184 }
185 
186 void animated_sprite_physic_display(Animated_Sprite_Physic *animated_sprite_physic, short x, short y, WORD anim) {
188  &animated_sprite_physic->animated_sprite,
189  x,
190  y,
191  anim
192  );
193  box_update(&animated_sprite_physic->box, x, y);
194 }
195 
196 void animated_sprite_physic_set_position(Animated_Sprite_Physic *animated_sprite_physic, short x, short y) {
197  animated_sprite_set_position(&animated_sprite_physic->animated_sprite, x, y);
198  box_update(&animated_sprite_physic->box, x, y);
199 }
200 
201 void animated_sprite_physic_move(Animated_Sprite_Physic *animated_sprite_physic, short x_offset, short y_offset) {
202  animated_sprite_move(&animated_sprite_physic->animated_sprite, x_offset, y_offset);
203  box_update(&animated_sprite_physic->box, animated_sprite_physic->animated_sprite.as.posX, animated_sprite_physic->animated_sprite.as.posY);
204 }
205 
206 void animated_sprite_physic_shrunk(Animated_Sprite_Physic *animated_sprite_physic, WORD shrunk_value) {
207  shrunk(animated_sprite_physic->animated_sprite.as.baseSprite, animated_sprite_physic->animated_sprite.si->maxWidth, shrunk_value);
208  // todo (minor) - box resize
209 }
210 
212  animated_sprite_hide(&animated_sprite_physic->animated_sprite);
213  animated_sprite_physic->physic_enabled = false;
214 }
215 
217  animated_sprite_show(&animated_sprite_physic->animated_sprite);
218  animated_sprite_physic->physic_enabled = true;
219 }
220 
222  animated_sprite_physic->physic_enabled = animated_sprite_flash(&animated_sprite_physic->animated_sprite);
223 }
224 
225  //--------------------------------------------------------------------------//
226  // -B //
227 //--------------------------------------------------------------------------//
228 BYTE boxes_collide(Box *b, Box *boxes[], BYTE box_max) {
229  BYTE rt = false;
230  BYTE i = 0;
231  for (i = 0; i < box_max; i++) {
232  if(
233  b->p1.x >= boxes[i]->p0.x
234  &&
235  b->p0.x <= boxes[i]->p1.x
236  &&
237  b->p3.y >= boxes[i]->p0.y
238  &&
239  b->p0.y <= boxes[i]->p3.y
240  ) { rt = i + 1; }
241  }
242  return rt;
243 }
244 
245 BOOL box_collide(Box *b1, Box *b2) { // todo - return a frixion vector
246  if(
247  b1->p1.x >= b2->p0.x
248  &&
249  b1->p0.x <= b2->p1.x
250  &&
251  b1->p3.y >= b2->p0.y
252  &&
253  b1->p0.y <= b2->p3.y
254  ) {
255  return true;
256  } else { return false; }
257 }
258 
259 void box_init(Box *b, short width, short height, short widthOffset, short heightOffset) {
260  b->width = width;
261  b->height = height;
262  b->widthOffset = widthOffset;
263  b->heightOffset = heightOffset;
264 }
265 
266 void box_update(Box *b, short x, short y) {
267  b->p0.x = x + b->widthOffset;
268  b->p0.y = y + b->heightOffset;
269 
270  b->p1.x = b->p0.x + b->width;
271  b->p1.y = b->p0.y;
272 
273  b->p2.x = b->p1.x;
274  b->p2.y = b->p1.y + b->height;
275 
276  b->p3.x = b->p0.x;
277  b->p3.y = b->p2.y;
278 
279  b->p4.x = b->p0.x + ((b->p1.x - b->p0.x) DIV2);
280  b->p4.y = b->p0.y + ((b->p3.y - b->p0.y) DIV2);
281 }
282 
283 void box_shrunk(Box *b, Box *bOrigin, WORD shrunkValue) {
284  // todo (minor) - optim.
285  // if i can read the shrunk VRAM value, i can compute the origin box...
286  // todo (minor) - improve precision
287  // todo (minor) - consider box offsets
288  BYTE shrunk_x = SHRUNK_EXTRACT_X(shrunkValue);
289  BYTE pix_step_x = (bOrigin->width DIV16);
290  BYTE trim_x = (((15 - shrunk_x) * pix_step_x) DIV2);
291 
292  int trim_y;
293  FIXED shrunk_y = FIX(SHRUNK_EXTRACT_Y(shrunkValue));
294  FIXED pix_step_y = FIX((float)bOrigin->height / (float)256); // todo (minor) - hmmm !!! float
295  FIXED shrunk_y_multiplicator = fsub(FIX(255), shrunk_y);
296  shrunk_y_multiplicator = fmul(shrunk_y_multiplicator, pix_step_y);
297  trim_y = fixtoi(shrunk_y_multiplicator);
298  trim_y = (trim_y DIV2);
299  trim_y += 1;
300 
301  b->p0.x = bOrigin->p0.x + trim_x - (bOrigin->width DIV2);
302  b->p0.y = bOrigin->p0.y + trim_y - (bOrigin->height DIV2);
303 
304  b->p1.x = bOrigin->p1.x - trim_x - (bOrigin->width DIV2);
305  b->p1.y = bOrigin->p1.y + trim_y - (bOrigin->height DIV2);
306 
307  b->p2.x = bOrigin->p2.x - trim_x - (bOrigin->width DIV2);
308  b->p2.y = bOrigin->p2.y - trim_y - (bOrigin->height DIV2);
309 
310  b->p3.x = bOrigin->p3.x + trim_x - (bOrigin->width DIV2);
311  b->p3.y = bOrigin->p3.y - trim_y - (bOrigin->height DIV2);
312 
313  b->p4.x = b->p0.x + ((b->p1.x - b->p0.x) DIV2);
314  b->p4.y = b->p0.y + ((b->p3.y - b->p0.y) DIV2);
315 }
316 
317 // todo (minor) - deprecated ?
318 void box_resize(Box *box, short edge) {
319  box->p0.x -= edge;
320  box->p0.y -= edge;
321 
322  box->p1.x += edge;
323  box->p1.y -= edge;
324 
325  box->p2.x += edge;
326  box->p2.y += edge;
327 
328  box->p3.x -= edge;
329  box->p3.y += edge;
330 }
331 
332  //--------------------------------------------------------------------------//
333  // -C //
334 //--------------------------------------------------------------------------//
335 void inline clear_vram() { // todo (minor) - disable interrupt
336  WORD addr = 0x0000;
337  WORD addr_end = 0x8FFF;
338  for (addr = addr; addr <= addr_end; addr++) {
339  SC234Put(addr, 0);
340  }
341  SCClose();
342  wait_vbl_max(10);
343  SCClose();
344  wait_vbl_max(10);
345 }
346 
347  //--------------------------------------------------------------------------//
348  // -F //
349 //--------------------------------------------------------------------------//
350 void inline fix_print_neocore(int x, int y, char *label){
351  fixPrint(x, y, 0, 0, label);
352 }
353 
354 void flash_init(Flash *flash, short frequency, short lengh) {
355  flash->frequency = frequency;
356  flash->lengh = lengh;
357 }
358 
359  //--------------------------------------------------------------------------//
360  // -G //
361 //--------------------------------------------------------------------------//
362 void inline gpu_init() {
363  backgroundColor(0x7000); // todo (minor) - macro with some colors ...
364  clearFixLayer();
365  initGfx();
366  volMEMWORD(0x400002) = 0xffff; // debug text white
367  LSPCmode = 0x1c00; // autoanim speed
368  sprite_index = 1;
369  palette_index = 16;
370 }
371 
372 WORD get_sprite_index() { return sprite_index; }
373 
374 WORD get_sprite_index_from_picture(pictureInfo *pi) {
375  WORD rt = sprite_index;
376  if (sprite_auto_index) sprite_index += pi->tileWidth;
377  return rt;
378 }
379 
380 WORD get_sprite_index_from_sprite(spriteInfo *si) {
381  WORD rt = sprite_index;
382  if (sprite_auto_index) sprite_index += si->maxWidth;
383  return rt;
384 }
385 
386 BYTE get_palette_index(paletteInfo *pali) {
387  BYTE rt = palette_index;
388  if (palette_auto_index) palette_index += pali->palCount;
389  return rt;
390 }
391 
393  return shrunk_table_prop[index]; // todo (minor) - rename shrunk_proportional_table
394 }
395 
396 char get_sin(WORD index) {
397  return sinTable[index];
398 }
399 
400  //--------------------------------------------------------------------------//
401  // -I //
402 //--------------------------------------------------------------------------//
403 BOOL is_visible(Flash *flash) {
404  return flash->visible;
405 }
406 
407  /*------------------*/
408  /* -image */
409 /*------------------*/
410 void image_init(Image *image, pictureInfo *pi, paletteInfo *pali) {
411  flash_init(&image->flash, 0, 0);
412  image->pali = pali;
413  image->pi = pi;
414 }
415 
416 void image_display(Image *image, short x, short y) {
417  BOOL palette_auto_index_state = palette_auto_index;
419  pictureInit(
420  &image->pic,
421  image->pi,
423  get_palette_index(image->pali),
424  x,
425  y,
426  FLIP_NONE
427  );
428  if (palette_auto_index_state) palette_enable_auto_index();
429  palJobPut(
430  get_palette_index(image->pali),
431  image->pali->palCount,
432  image->pali->data
433  );
434 }
435 
436 void image_set_position(Image *image, short x, short y) {
437  pictureSetPos(&image->pic, x, y);
438 }
439 
440 
441 void image_hide(Image *image) {
442  pictureHide(&image->pic);
443  image->flash.visible = false;
444 }
445 
446 void image_show(Image *image) {
447  pictureShow(&image->pic);
448  image->flash.visible = true;
449 }
450 
451 BOOL image_flash(Image *image) {
452  BOOL rt = true;
453  if (image->flash.frequency != 0 && image->flash.lengh != 0) {
454  if (DAT_frameCounter % image->flash.frequency == 0) {
455  if (is_visible(&image->flash)) {
456  image_hide(image);
457  rt = false;
458  } else {
459  image_show(image);
460  rt = true;
461  }
462  image->flash.lengh--;
463  if (image->flash.lengh == 0) image_show(image);
464  }
465  }
466  return rt;
467 }
468 
469  /*------------------*/
470  /* -image_physic */
471 /*------------------*/
473  Image_Physic *image_physic,
474  pictureInfo *pi,
475  paletteInfo *pali,
476  short box_witdh,
477  short box_height,
478  short box_width_offset,
479  short box_height_offset
480 ) {
481  image_init(&image_physic->image, pi, pali);
482  box_init(&image_physic->box, box_witdh, box_height, box_width_offset, box_height_offset);
483 }
484 
485 void image_physic_display(Image_Physic *image_physic, short x, short y) {
486  image_display(&image_physic->image, x, y);
487  box_update(&image_physic->box, x, y);
488 }
489 
490 void image_physic_move(Image_Physic *image_physic, short x_offset, short y_offset) {
491  image_move(&image_physic->image, x_offset, y_offset);
492  box_update(&image_physic->box, image_physic->image.pic.posX, image_physic->image.pic.posY);
493 }
494 
495 void image_physic_set_position(Image_Physic *image_physic, short x, short y) {
496  image_set_position(&image_physic->image, x, y);
497  box_update(&image_physic->box, x, y);
498 }
499 
500 void image_physic_hide(Image_Physic *image_physic) {
501  image_hide(&image_physic->image);
502  image_physic->physic_enabled = false;
503 }
504 
505 void image_physic_show(Image_Physic *image_physic) {
506  image_show(&image_physic->image);
507  image_physic->physic_enabled = true;
508 }
509 
510 void image_physic_flash(Image_Physic *image_physic) {
511  image_physic->physic_enabled = image_flash(&image_physic->image);
512 }
513 
514 void image_physic_shrunk(Image_Physic *image_physic, WORD shrunk_value) {
515  shrunk(image_physic->image.pic.baseSprite, image_physic->image.pic.info->tileWidth, shrunk_value);
516  // todo (minor) - shrunk box
517 }
518 
519 void image_shrunk_centroid(Image *image, short center_x, short center_y, WORD shrunk_value) {
520  shrunk(image->pic.baseSprite, image->pic.info->tileWidth, shrunk_value);
522  image,
523  shrunk_centroid_get_translated_x(center_x, image->pi->tileWidth, SHRUNK_EXTRACT_X(shrunk_value)),
524  shrunk_centroid_get_translated_y(center_y, image->pi->tileHeight, SHRUNK_EXTRACT_Y(shrunk_value))
525  );
526 }
527 
528  //--------------------------------------------------------------------------//
529  // -J //
530 //--------------------------------------------------------------------------//
531  /*----------*/
532  /* -joypad */
533 /*----------*/
534 void inline joypad_debug() {
536  if (joypad_is_start()) { fix_print_neocore(10, 11, "JOYPAD START"); }
537  if (joypad_is_up()) { fix_print_neocore(10, 11, "JOYPAD UP "); }
538  if (joypad_is_down()) { fix_print_neocore(10, 11, "JOYPAD DOWN "); }
539  if (joypad_is_left()) { fix_print_neocore(10, 11, "JOYPAD LEFT "); }
540  if (joypad_is_right()) { fix_print_neocore(10, 11, "JOYPAD RIGHT"); }
541  if (joypad_is_a()) { fix_print_neocore(10, 11, "JOYPAD A "); }
542  if (joypad_is_b()) { fix_print_neocore(10, 11, "JOYPAD B "); }
543  if (joypad_is_c()) { fix_print_neocore(10, 11, "JOYPAD C "); }
544  if (joypad_is_d()) { fix_print_neocore(10, 11, "JOYPAD D "); }
545 }
546 
549 }
550 
553 }
554 
555 BOOL joypad_is_up() { return (JOYPAD_IS_UP) ? (true) : (false); }
556 BOOL joypad_is_down() { return (JOYPAD_IS_DOWN) ? (true) : (false); }
557 BOOL joypad_is_left() { return (JOYPAD_IS_LEFT) ? (true) : (false); }
558 BOOL joypad_is_right() { return (JOYPAD_IS_RIGHT) ? (true) : (false); }
559 BOOL joypad_is_start() { return (JOYPAD_IS_START) ? (true) : (false); }
560 BOOL joypad_is_a() { return (JOYPAD_IS_A) ? (true) : (false); }
561 BOOL joypad_is_b() { return (JOYPAD_IS_B) ? (true) : (false); }
562 BOOL joypad_is_c() { return (JOYPAD_IS_C) ? (true) : (false); }
563 BOOL joypad_is_d() { return (JOYPAD_IS_D) ? (true) : (false); }
564 
565  //--------------------------------------------------------------------------//
566  // -L //
567 //--------------------------------------------------------------------------//
568  /*----------*/
569  /* -logger */
570 /*----------*/
571 void logger_init() {
572  #ifdef LOGGER_ON
573  x = LOGGER_X_INIT;
574  y = LOGGER_Y_INIT;
575  x_default = LOGGER_X_INIT;
576  y_default = LOGGER_Y_INIT;
577  clearFixLayer();
578  #endif
579 }
580 
581 void logger_set_position(WORD _x, WORD _y){
582  x = _x;
583  y = _y;
584  x_default = x;
585  y_default = y;
586 }
587 
588 WORD inline logger_info(char *label){
589  #ifdef LOGGER_ON
590  fixPrintf(x, y , 0, 0 , label);
591  autoInc();
592  return countChar(label);
593  #endif
594 }
595 
596 void inline logger_word(char *label, WORD value){
597  #ifdef LOGGER_ON
598  WORD yc = y;
599  x = x_default + logger_info(label) + 2;
600  fixPrintf(x , yc, 0, 0, "%04d", value);
601  x = x_default;
602  #endif
603 }
604 
605 void inline logger_int(char *label, int value){
606  #ifdef LOGGER_ON
607  WORD yc = y;
608  x = x_default + logger_info(label) + 2;
609  fixPrintf(x , yc, 0, 0, "%08d", value);
610  x = x_default;
611  #endif
612 }
613 
614 void inline logger_dword(char *label, DWORD value){
615  #ifdef LOGGER_ON
616  WORD yc = y;
617  x = x_default + logger_info(label) + 2;
618  fixPrintf(x , yc, 0, 0, "%08d", value);
619  x = x_default;
620  #endif
621 }
622 
623 void inline logger_short(char *label, short value) {
624  #ifdef LOGGER_ON
625  WORD yc = y;
626  x = x_default + logger_info(label) + 2;
627  fixPrintf(x , yc, 0, 0, "%02d", value);
628  x = x_default;
629  #endif
630 }
631 
632 void inline logger_byte(char *label, BYTE value) {
633  #ifdef LOGGER_ON
634  WORD yc = y;
635  x = x_default + logger_info(label) + 2;
636  fixPrintf(x , yc, 0, 0, "%02d", value);
637  x = x_default;
638  #endif
639 }
640 
641 void inline logger_bool(char *label, BOOL value) {
642  #ifdef LOGGER_ON
643  WORD yc = y;
644  x = x_default + logger_info(label) + 2;
645  fixPrintf(x , yc, 0, 0, "%01d", value);
646  x = x_default;
647  #endif
648 }
649 
650 void inline logger_animated_sprite(char *label, Animated_Sprite *animated_sprite) {
651  #ifdef LOGGER_ON
652  logger_info(label);
653  logger_word("BASESPRITE : " , animated_sprite->as.baseSprite);
654  logger_word("BASEPALETTE : ", animated_sprite->as.basePalette);
655  logger_short("POSX : ", animated_sprite->as.posX);
656  logger_short("POSY : ", animated_sprite->as.posY);
657  logger_short("CURRENTSTEPNUM : ", animated_sprite->as.currentStepNum);
658  logger_short("MAXSTEP : ", animated_sprite->as.maxStep);
659  logger_dword("COUNTER : ", animated_sprite->as.counter);
660  logger_word("REPEATS : ", animated_sprite->as.repeats);
661  logger_word("CURRENTFLIP : ", animated_sprite->as.currentFlip);
662  logger_word("TILEWIDTH : ", animated_sprite->as.tileWidth);
663  logger_word("ANIMID : ", animated_sprite->as.animID);
664  logger_word("FLAGS", animated_sprite->as.flags);
665  #endif
666 }
667 
668 void inline logger_spriteInfo(char *label, spriteInfo *si) {
669  #ifdef LOGGER_ON
670  logger_info(label);
671  logger_word("PALCOUNT : ", si->palCount);
672  logger_word("FRAMECOUNT : ", si->frameCount);
673  logger_word("MAXWIDTH : ", si->maxWidth);
674  #endif
675 }
676 
677 void inline logger_box(char *label, Box *b) {
678  #ifdef LOGGER_ON
679  logger_info(label);
680  logger_short("P0X", (short)b->p0.x);
681  logger_short("P0Y", (short)b->p0.y);
682  logger_info("");
683  logger_short("P1X", (short)b->p1.x);
684  logger_short("P1Y", (short)b->p1.y);
685  logger_info("");
686  logger_short("P2X", (short)b->p2.x);
687  logger_short("P2Y", (short)b->p2.y);
688  logger_info("");
689  logger_short("P3X", (short)b->p3.x);
690  logger_short("P3Y", (short)b->p3.y);
691  logger_info("");
692  logger_short("P4X", (short)b->p4.x);
693  logger_short("P4Y", (short)b->p4.y);
694  logger_info("");
695  logger_short("WIDTH ", b->width);
696  logger_short("HEIGHT ", b->height);
697  logger_info("");
698  logger_short("WIDTH OFFSET ", b->widthOffset);
699  logger_short("HEIGHT OFFSET ", b->heightOffset);
700  #endif
701 }
702 
703 void inline logger_pictureInfo(char *label, pictureInfo *pi) {
704  #ifdef LOGGER_ON
705  logger_info(label);
706  logger_word("COLSIZE : ", (WORD)pi->colSize);
707  logger_word("UNUSED HEIGHT : ", (WORD)pi->unused__height);
708  logger_word("TILEWIDTH : ", (WORD)pi->tileWidth);
709  logger_word("TILEHEIGHT : ", (WORD)pi->tileHeight);
710  #endif
711 }
712 
713  //--------------------------------------------------------------------------//
714  // -P //
715 //--------------------------------------------------------------------------//
716  /*-----------*/
717  /* -palette */
718 /*-----------*/
719 
720 void palette_disable_auto_index() { palette_auto_index = false; }
721 void palette_enable_auto_index() { palette_auto_index = true; }
722 
723  //--------------------------------------------------------------------------//
724  // -V //
725 //--------------------------------------------------------------------------//
726 BOOL vector_is_left(short x, short y, short v1x, short v1y, short v2x, short v2y) {
727  BOOL rt = false;
728  short vectorD[2] = {v2x - v1x, v2y - v1y};
729  short vectorT[2] = {x - v1x, y -v1y};
730  short d = vectorD[X] * vectorT[Y] - vectorD[Y] * vectorT[X];
731  (d > 0) ? (rt = false) : (rt = true);
732  return rt;
733 }
734 
735 void vec2int_init(Vec2int *vec, int x, int y) { vec->x = x; vec->y = y; }
736 void vec2short_init(Vec2short *vec, short x, short y) { vec->x = x; vec->y = y; }
737 void vec2byte_init(Vec2byte *vec, BYTE x, BYTE y) { vec->x = x; vec->y = y; }
738 
739 BOOL vectors_collide(Box *box, Vec2short vec[], BYTE vector_max) {
740  BOOL p0 = false, p1 = false, p2 = false, p3 = false, p4 = false;
741  p0 = collide_point(box->p0.x, box->p0.y, vec, vector_max);
742  p1 = collide_point(box->p1.x, box->p1.y, vec, vector_max);
743  p2 = collide_point(box->p2.x, box->p2.y, vec, vector_max);
744  p3 = collide_point(box->p3.x, box->p3.y, vec, vector_max);
745  p4 = collide_point(box->p4.x, box->p4.y, vec, vector_max);
746  return (p0 || p1 || p2 || p3 || p4);
747 }
748 
749  //--------------------------------------------------------------------------//
750  // -S //
751 //--------------------------------------------------------------------------//
752 BYTE set_palette_index(BYTE index) {
753  palette_index = index;
754  return palette_index;
755 }
756 
757 void sprite_disable_autoinc() { sprite_auto_index = false; }
758 void sprite_enable_autoinc() { sprite_auto_index = true; }
759 
760 void sprite_set_index(WORD index) {
761  sprite_index = index;
762 }
763 
764  /*-----------*/
765  /* -scroller */
766 /*-----------*/
767 void scroller_set_position(Scroller *s, short x, short y) {
768  scrollerSetPos(&s->s, x, y);
769 }
770 
771 void scroller_display(Scroller *s, short x, short y) {
772  BOOL palette_auto_index_state = palette_auto_index;
774  scrollerInit(
775  &s->s,
776  s->si,
779  x,
780  y
781  );
782  sprite_index += 21;
783  if (palette_auto_index_state) palette_enable_auto_index();
784  palJobPut(
786  s->pali->palCount,
787  s->pali->data
788  );
789 }
790 
791 void scroller_move(Scroller *s, short x, short y) {
792  scrollerSetPos(&s->s, s->s.scrlPosX + x, s->s.scrlPosY + y);
793 }
794 
795 void scroller_init(Scroller *s, scrollerInfo *si, paletteInfo *pali) {
796  s->si = si;
797  s->pali = pali;
798 }
799 
800  /*-----------*/
801  /* -shrunk */
802 /*-----------*/
803 void inline shrunk_addr(WORD addr, WORD shrunk_value) {
804  SC234Put(addr, shrunk_value);
805 }
806 
807 WORD shrunk_forge(BYTE xc, BYTE yc) { // todo (minor) - xcF, ycFF
808  //F FF - x (hor) , y (vert)
809  // vertical shrinking 8 bit
810  // horizontal shrinking 4 bit
811  WORD value = 0;
812  value = xc << 8;
813  value += yc;
814  return value;
815 }
816 
817 WORD shrunk_range(WORD addr_start, WORD addr_end, WORD shrunk_value) {
818  WORD cur_addr = addr_start;
819  while (cur_addr < addr_end) {
820  SC234Put(cur_addr, shrunk_value);
821  cur_addr++;
822  }
823  return addr_end;
824 }
825 
826 void shrunk(WORD base_sprite, WORD max_width, WORD value) {
827  shrunk_range(0x8000 + base_sprite, 0x8000 + base_sprite + max_width, value);
828 }
829 
830 int shrunk_centroid_get_translated_x(short centerPosX, WORD tileWidth, BYTE shrunkX) {
831  FIXED newX = FIX(centerPosX);
832  newX -= (shrunkX + 1) * FIX((tileWidth MULT8) / 0x10);
833  return fixtoi(newX);
834 }
835 
836 int shrunk_centroid_get_translated_y(short centerPosY, WORD tileHeight, BYTE shrunkY) {
837  FIXED newY = FIX(centerPosY);
838  newY -= shrunkY * FIX((tileHeight MULT8) / 0xFF);
839  return fixtoi(newY);
840 }
841 
842  //--------------------------------------------------------------------------//
843  // -W //
844 //--------------------------------------------------------------------------//
845 DWORD inline wait_vbl_max(WORD nb) {
846  WORD i = 0;
847  for (i = 0; i <= nb; i++) waitVBlank();
848  return DAT_frameCounter;
849 }
850 
851 
853 
854 /* todo (minor)
855 void box_debug_update(picture5 *pics, Box *box) {
856  pictureSetPos(&pics->pic0, box->p0.x, box->p0.y);
857  pictureSetPos(&pics->pic1, box->p1.x, box->p1.y);
858  pictureSetPos(&pics->pic2, box->p2.x, box->p2.y);
859  pictureSetPos(&pics->pic3, box->p3.x, box->p3.y);
860  pictureSetPos(&pics->pic4, box->p4.x, box->p4.y);
861 }
862 */
863 
864 /*
865 void box_display(picture5 *pics, Box *box, pictureInfo *pi, paletteInfo *pali) {
866  palette_disable_autoinc();
867  image_display(&pics->pic0, pi, pali, box->p0.x, box->p0.y);
868  image_display(&pics->pic1, pi, pali, box->p1.x, box->p1.y);
869  image_display(&pics->pic2, pi, pali, box->p2.x, box->p2.y);
870  image_display(&pics->pic3, pi, pali, box->p3.x, box->p3.y);
871  palette_enable_autoinc();
872  image_display(&pics->pic4, pi, pali, box->p4.x, box->p4.y);
873 }
874 */
875 
876 /*
877 void image_physic_shrunk_centroid_update(picturePhysicShrunkCentroid *pps, WORD shrunk) {
878  image_shrunk_centroid(&pps->pp.p, pps->pi, pps->positionCenter.x, pps->positionCenter.y, shrunk);
879  box_shrunk(&pps->pp.box, &pps->boxOrigin, shrunk);
880 }
881 
882 void image_physic_shrunk_centroid_display(picturePhysicShrunkCentroid *pps, WORD shrunk) {
883  image_physic_display(&pps->pp, pps->pi, pps->pali, pps->positionCenter.x, pps->positionCenter.y);
884  image_shrunk_centroid(&pps->pp.p, pps->pi, pps->positionCenter.x, pps->positionCenter.y, shrunk);
885  BOXCOPY(&pps->pp.box, &pps->boxOrigin);
886 }
887 
888 void image_physic_shrunk_centroid_init(picturePhysicShrunkCentroid *pps, pictureInfo *pi, paletteInfo *pali, short xCenter, short yCenter) {
889  pps->pi = pi;
890  pps->pali = pali;
891  pps->positionCenter.x = xCenter;
892  pps->positionCenter.y = yCenter;
893 }
894 
895 void image_physic_shrunk_centroid_set_position(picturePhysicShrunkCentroid *pps, short x, short y) {
896  pps->positionCenter.x = x;
897  pps->positionCenter.y = y;
898  box_update(&pps->boxOrigin, x, y);
899 }
900 
901 void image_physic_shrunk_centroid_move(picturePhysicShrunkCentroid *pps, short xShift, short yShift) {
902  image_physic_shrunk_centroid_set_position(pps, pps->positionCenter.x + xShift, pps->positionCenter.y + yShift);
903 }
904 
905 void image_physic_display(picturePhysic *pp, pictureInfo *pi, paletteInfo *pali, short posX, short posY) {
906  image_display(&pp->p, pi, pali, posX, posY);
907  box_update(&pp->box, posX, posY);
908 }
909 
910 void image_physic_set_position(picturePhysic *pp, short x, short y) {
911  pictureSetPos(&pp->p, x, y);
912  box_update(&pp->box, x, y);
913 }
914 */
915 
916 /* todo (minor) - deprecated
917 WORD image_get_sprite_index_autoinc(pictureInfo *pi) {
918  WORD rt = sprite_index;
919  if (sprite_auto_index) sprite_index += pi->tileWidth;
920  return rt;
921 }
922 */
923 
924 /* todo (minor)
925 void image5_show(picture5 *pics, BOOL visible) {
926  if (visible) {
927  pictureShow(&pics->pic0);
928  pictureShow(&pics->pic1);
929  pictureShow(&pics->pic2);
930  pictureShow(&pics->pic3);
931  pictureShow(&pics->pic4);
932  } else {
933  pictureHide(&pics->pic0);
934  pictureHide(&pics->pic1);
935  pictureHide(&pics->pic2);
936  pictureHide(&pics->pic3);
937  pictureHide(&pics->pic4);
938  }
939 }
940 */
941 
942 /* todo (minor)
943 void maskDisplay(picture pic[], vec2short vec[], BYTE vector_max) {
944  BYTE i = 0;
945  for (i = 0; i < vector_max; i++) {
946  pic[i] = pictureDisplay(&dot_img, &dot_img_Palettes, vec[i].x, vec[i].y);
947  }
948 }
949 */
950 
951 void mask_update(short x, short y, Vec2short vec[], Vec2short offset[], BYTE vector_max) {
952  BYTE i = 0;
953  for (i = 0; i < vector_max; i++) {
954  vec[i].x = x + offset[i].x;
955  vec[i].y = y + offset[i].y;
956  }
957 }
WORD shrunk_range(WORD addr_start, WORD addr_end, WORD shrunk_value)
Definition: neocore.c:817
void vec2int_init(Vec2int *vec, int x, int y)
init a Vec2int structure
Definition: neocore.c:735
WORD get_shrunk_proportional_table(WORD index)
Definition: neocore.c:392
void animated_sprite_show(Animated_Sprite *animated_sprite)
Definition: neocore.c:154
void fix_print_neocore(int x, int y, char *label)
Definition: neocore.c:350
void logger_byte(char *label, BYTE value)
Definition: neocore.c:632
void logger_init()
Definition: neocore.c:571
BOOL joypad_is_b()
Definition: neocore.c:561
void animated_sprite_physic_set_position(Animated_Sprite_Physic *animated_sprite_physic, short x, short y)
Definition: neocore.c:196
#define JOYPAD_IS_UP
Definition: neocore.h:55
#define FIX(value)
Definition: neocore.h:71
BOOL vectors_collide(Box *box, Vec2short vec[], BYTE vector_max)
Definition: neocore.c:739
WORD frequency
Definition: neocore.h:151
#define SHRUNK_EXTRACT_X(value)
Definition: neocore.h:74
Image encapsulation with Box.
Definition: neocore.h:201
void mask_update(short x, short y, Vec2short vec[], Vec2short offset[], BYTE vector_max)
Definition: neocore.c:951
WORD lengh
Definition: neocore.h:152
#define X
Definition: neocore.h:47
collider definition
Definition: neocore.h:118
short width
Definition: neocore.h:124
void logger_spriteInfo(char *label, spriteInfo *si)
Definition: neocore.c:668
void animated_sprite_physic_display(Animated_Sprite_Physic *animated_sprite_physic, short x, short y, WORD anim)
Definition: neocore.c:186
int shrunk_centroid_get_translated_x(short centerPosX, WORD tileWidth, BYTE shrunkX)
Definition: neocore.c:830
void image_init(Image *image, pictureInfo *pi, paletteInfo *pali)
Definition: neocore.c:410
void image_physic_init(Image_Physic *image_physic, pictureInfo *pi, paletteInfo *pali, short box_witdh, short box_height, short box_width_offset, short box_height_offset)
Definition: neocore.c:472
int x
Definition: neocore.h:85
#define LOGGER_Y_INIT
Definition: neocore.h:67
BOOL animated_sprite_flash(Animated_Sprite *animated_sprite)
refresh flash
Definition: neocore.c:126
void logger_box(char *label, Box *b)
Definition: neocore.c:677
Vec2short p4
Definition: neocore.h:123
void animated_sprite_set_animation(Animated_Sprite *animated_sprite, WORD anim)
Definition: neocore.c:144
void sprite_set_index(WORD index)
Definition: neocore.c:760
BOOL joypad_is_right()
Definition: neocore.c:558
DATLib picture structure encapsulation.
Definition: neocore.h:174
content x & y short coordinate
Definition: neocore.h:94
void flash_init(Flash *flash, short frequency, short lengh)
Definition: neocore.c:354
void logger_dword(char *label, DWORD value)
Definition: neocore.c:614
void logger_set_position(WORD _x, WORD _y)
Definition: neocore.c:581
BOOL joypad_is_c()
Definition: neocore.c:562
pictureInfo * pi
Definition: neocore.h:176
void logger_bool(char *label, BOOL value)
Definition: neocore.c:641
void image_physic_flash(Image_Physic *image_physic)
Definition: neocore.c:510
#define animated_sprite_set_position(animated_sprite, x, y)
Definition: neocore.h:289
picture pic
Definition: neocore.h:175
BOOL joypad_is_left()
Definition: neocore.c:557
BOOL joypad_is_start()
Definition: neocore.c:559
content x & y byte coordinate
Definition: neocore.h:104
BOOL visible
Definition: neocore.h:153
void scroller_set_position(Scroller *s, short x, short y)
Definition: neocore.c:767
BYTE set_palette_index(BYTE index)
Definition: neocore.c:752
int y
Definition: neocore.h:86
BYTE y
Definition: neocore.h:106
#define JOYPAD_IS_D
Definition: neocore.h:63
void logger_int(char *label, int value)
Definition: neocore.c:605
void sprite_disable_autoinc()
Definition: neocore.c:757
Vec2short p1
Definition: neocore.h:120
#define LOGGER_X_INIT
Definition: neocore.h:66
#define JOYPAD_IS_DOWN
Definition: neocore.h:56
void logger_short(char *label, short value)
Definition: neocore.c:623
char get_sin(WORD index)
Definition: neocore.c:396
spriteInfo * si
Definition: neocore.h:164
#define JOYPAD_IS_START
Definition: neocore.h:59
Definition: neocore.h:150
#define JOYPAD_IS_LEFT
Definition: neocore.h:57
void animated_sprite_physic_init(Animated_Sprite_Physic *animated_sprite_physic, spriteInfo *si, paletteInfo *pali, short box_witdh, short box_height, short box_width_offset, short box_height_offset)
Definition: neocore.c:162
void image_physic_show(Image_Physic *image_physic)
Show Image_Physic & enable physic.
Definition: neocore.c:505
void scroller_init(Scroller *s, scrollerInfo *si, paletteInfo *pali)
Definition: neocore.c:795
Animated_Sprite animated_sprite
Definition: neocore.h:189
int shrunk_centroid_get_translated_y(short centerPosY, WORD tileHeight, BYTE shrunkY)
Definition: neocore.c:836
scroller s
Definition: neocore.h:213
void clear_vram()
Definition: neocore.c:335
#define DIV16
Definition: neocore.h:42
void box_update(Box *b, short x, short y)
refresh Box position
Definition: neocore.c:266
void sprite_enable_autoinc()
Definition: neocore.c:758
void animated_sprite_physic_flash(Animated_Sprite_Physic *animated_sprite_physic)
refresh a Animated_Sprite_Physic flash
Definition: neocore.c:221
void vec2byte_init(Vec2byte *vec, BYTE x, BYTE y)
init a Vec2byte structure
Definition: neocore.c:737
void vec2short_init(Vec2short *vec, short x, short y)
init a Vec2short structure
Definition: neocore.c:736
void scroller_display(Scroller *s, short x, short y)
Definition: neocore.c:771
void image_display(Image *image, short x, short y)
Definition: neocore.c:416
BOOL is_visible(Flash *flash)
Definition: neocore.c:403
void logger_pictureInfo(char *label, pictureInfo *pi)
Definition: neocore.c:703
void box_shrunk(Box *b, Box *bOrigin, WORD shrunkValue)
Definition: neocore.c:283
Image image
Definition: neocore.h:202
void image_physic_shrunk(Image_Physic *image_physic, WORD shrunk_value)
Definition: neocore.c:514
#define JOYPAD_READ_EDGE
Definition: neocore.h:54
short y
Definition: neocore.h:96
void palette_enable_auto_index()
Enable auto management of palette index.
Definition: neocore.c:721
short height
Definition: neocore.h:125
BOOL vector_is_left(short x, short y, short v1x, short v1y, short v2x, short v2y)
Definition: neocore.c:726
void joypad_update()
Definition: neocore.c:547
aSprite as
Definition: neocore.h:163
void animated_sprite_physic_shrunk(Animated_Sprite_Physic *animated_sprite_physic, WORD shrunk_value)
Definition: neocore.c:206
paletteInfo * pali
Definition: neocore.h:215
void image_hide(Image *image)
hide Image
Definition: neocore.c:441
#define JOYPAD
Definition: neocore.h:52
#define JOYPAD_IS_RIGHT
Definition: neocore.h:58
BOOL joypad_is_d()
Definition: neocore.c:563
content x & y int coordinate
Definition: neocore.h:84
void gpu_init()
Definition: neocore.c:362
void animated_sprite_hide(Animated_Sprite *animated_sprite)
Definition: neocore.c:148
BOOL joypad_is_up()
Definition: neocore.c:555
Flash flash
Definition: neocore.h:178
void box_init(Box *b, short width, short height, short widthOffset, short heightOffset)
Definition: neocore.c:259
void image_set_position(Image *image, short x, short y)
Definition: neocore.c:436
void scroller_move(Scroller *s, short x, short y)
Definition: neocore.c:791
void image_physic_hide(Image_Physic *image_physic)
Hide Image_Physic & disable physic.
Definition: neocore.c:500
short heightOffset
Definition: neocore.h:127
short x
Definition: neocore.h:95
BYTE get_palette_index(paletteInfo *pali)
Definition: neocore.c:386
#define JOYPAD_READ
Definition: neocore.h:53
void animated_sprite_physic_hide(Animated_Sprite_Physic *animated_sprite_physic)
hide a Animated_Sprite_Physic
Definition: neocore.c:211
WORD get_sprite_index()
Definition: neocore.c:372
Animated_Sprite encapsulation with Box.
Definition: neocore.h:188
Vec2short p2
Definition: neocore.h:121
void palette_disable_auto_index()
Disable auto management of palette index.
Definition: neocore.c:720
#define JOYPAD_IS_C
Definition: neocore.h:62
#define JOYPAD_IS_A
Definition: neocore.h:60
JOYPAD void animated_sprite_init(Animated_Sprite *animated_sprite, spriteInfo *si, paletteInfo *pali)
Definition: neocore.c:98
BOOL box_collide(Box *b1, Box *b2)
check if two box is colliding
Definition: neocore.c:245
Vec2short p0
Definition: neocore.h:119
WORD shrunk_forge(BYTE xc, BYTE yc)
Definition: neocore.c:807
BOOL image_flash(Image *image)
Definition: neocore.c:451
WORD get_sprite_index_from_picture(pictureInfo *pi)
Definition: neocore.c:374
void image_shrunk_centroid(Image *image, short center_x, short center_y, WORD shrunk_value)
Definition: neocore.c:519
BOOL joypad_is_a()
Definition: neocore.c:560
BYTE boxes_collide(Box *b, Box *boxes[], BYTE box_max)
check if a box is colliding with a box list
Definition: neocore.c:228
#define JOYPAD_IS_B
Definition: neocore.h:61
void image_physic_set_position(Image_Physic *image_physic, short x, short y)
Definition: neocore.c:495
void image_show(Image *image)
show Image
Definition: neocore.c:446
BYTE x
Definition: neocore.h:105
#define image_move(image, x_offset, y_offset)
Definition: neocore.h:509
void shrunk_addr(WORD addr, WORD shrunk_value)
Definition: neocore.c:803
void box_resize(Box *box, short edge)
Definition: neocore.c:318
void joypad_update_edge()
Definition: neocore.c:551
void animated_sprite_display(Animated_Sprite *animated_sprite, short x, short y, WORD anim)
Definition: neocore.c:104
#define SHRUNK_EXTRACT_Y(value)
Definition: neocore.h:75
void image_physic_move(Image_Physic *image_physic, short x_offset, short y_offset)
Definition: neocore.c:490
BOOL joypad_is_down()
Definition: neocore.c:556
paletteInfo * pali
Definition: neocore.h:165
scrollerInfo * si
Definition: neocore.h:214
WORD get_sprite_index_from_sprite(spriteInfo *si)
Definition: neocore.c:380
DWORD wait_vbl_max(WORD nb)
Definition: neocore.c:845
void logger_animated_sprite(char *label, Animated_Sprite *animated_sprite)
Definition: neocore.c:650
void logger_word(char *label, WORD value)
Definition: neocore.c:596
WORD logger_info(char *label)
Definition: neocore.c:588
DATLib scroller structure encapsulation.
Definition: neocore.h:212
#define MULT8
Definition: neocore.h:35
void animated_sprite_physic_move(Animated_Sprite_Physic *animated_sprite_physic, short x_offset, short y_offset)
Definition: neocore.c:201
void image_physic_display(Image_Physic *image_physic, short x, short y)
Definition: neocore.c:485
#define DIV2
Definition: neocore.h:39
paletteInfo * pali
Definition: neocore.h:177
#define animated_sprite_move(animated_sprite, x_offset, y_offset)
Definition: neocore.h:282
void animated_sprite_physic_show(Animated_Sprite_Physic *animated_sprite_physic)
show a Animated_Sprite_Physic
Definition: neocore.c:216
BOOL physic_enabled
Definition: neocore.h:204
DATLib aSprite structure encapsulation.
Definition: neocore.h:162
void joypad_debug()
Definition: neocore.c:534
void shrunk(WORD base_sprite, WORD max_width, WORD value)
Definition: neocore.c:826
#define Y
Definition: neocore.h:48
short widthOffset
Definition: neocore.h:126
Vec2short p3
Definition: neocore.h:122