Digimon World 3 decomp
The European version, SLES_039.36
Loading...
Searching...
No Matches
screen.c
Go to the documentation of this file.
1/* CARDGAME's card screen (CARDGAME_createScreen): its task and the
2 functions the battle calls on it. */
3
5
6/* The card screen's task: makes its cursor and text windows, then each frame
7 updates its blinkers, windows, sprites, gauges, background and panels */
9 switch (screen->state) {
10 case 0:
11 default:
12 screen->nextState(screen);
13 items->cursor = createCursor(0x100, 0, 0, 0);
14 items->cursor->setVisible(items->cursor, 0);
15 items->texts[0] = createTextWindow(0x100, 1, 0, 0);
16 items->texts[1] = createTextWindow(0x100, 1, 0, 0);
17 items->texts[2] = createTextWindow(0x100, 1, 0, 0);
18 items->panelTexts[0] = createTextWindow(0x100, 1, 0, 0);
19 items->panelTexts[1] = createTextWindow(0x100, 1, 0, 0);
20 items->moreTexts[0] = createTextWindow(0x100, 1, 0, 0);
21 items->moreTexts[1] = createTextWindow(0x100, 1, 0, 0);
22 items->moreTexts[1]->setLines(items->moreTexts[1], 3);
23 items->moreTexts[2] = createTextWindow(0x100, 1, 0, 0);
24 items->moreTexts[3] = createTextWindow(0x100, 1, 0, 0);
25 items->moreTexts[4] = createTextWindow(0x100, 1, 0, 0);
26 items->moreTexts[5] = createTextWindow(0x100, 1, 0, 0);
27 items->moreTexts[5]->setLines(items->moreTexts[5], 3);
28 items->moreTexts[6] = createTextWindow(0x100, 1, 0, 0);
29 items->moreTexts[6]->setLines(items->moreTexts[6], 5);
30 items->moreTexts[7] = createTextWindow(0x100, 1, 0, 0);
31 items->moreTexts[7]->setLines(items->moreTexts[7], 2);
32 break;
33 case 1:
34 screen->time += GFX.funcs.getFrameTime();
35 screen->spriteFlags = 0;
36 CARDGAME_updateBlinkers(screen, items);
37 CARDGAME_updateMenuWindow(screen, items);
38 CARDGAME_updateMessageWindow(screen, items);
39 CARDGAME_updateWindows(screen, items);
40 CARDGAME_updateSprites(screen, items);
41 CARDGAME_updateGauges(screen, items);
43 CARDGAME_updatePanels(screen, items);
44 break;
45 case 3:
46 break;
47 }
48}
49
50/* Opens gauge index showing value, over 10 frames */
51void CARDGAME_openGauge(CardScreen *screen, s32 index, s16 value) {
52 screen->gauges[index].from = 0x1000;
53 screen->gauges[index].state = 1;
54 screen->gauges[index].to = 0;
55 screen->gauges[index].value = value;
56 screen->gauges[index].duration = 10;
57 screen->gauges[index].time = 10;
58}
59
60/* Closes gauge index, over 5 frames */
61void CARDGAME_closeGauge(CardScreen *screen, s32 index) {
62 screen->gauges[index].from = 0x1000;
63 screen->gauges[index].to = 0x1000;
64 screen->gauges[index].state = 3;
65 screen->gauges[index].duration = 5;
66 screen->gauges[index].time = 5;
67}
68
69/* Opens window index (CardScreen.windows) at x, y, with its layout and value */
70void CARDGAME_openWindow(CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y) {
72 screen->windows[index].x = x;
73 screen->windows[index].y = y;
74 screen->windows[index].from = 0;
75 screen->windows[index].to = 0x1000;
76 screen->windows[index].state = 1;
77 screen->windows[index].layout = layout;
78 screen->windows[index].value = value;
79 screen->windows[index].duration = 12;
80 screen->windows[index].time = 12;
81}
82
83/* Closes window index */
84void CARDGAME_closeWindow(CardScreen *screen, s32 index) {
86 screen->windows[index].from = 0x1000;
87 screen->windows[index].to = 0x1000;
88 screen->windows[index].state = 3;
89 screen->windows[index].duration = 6;
90 screen->windows[index].time = 6;
91}
92
93/* Shows blinker index, still, at x, y. Nothing calls this method or
94 CARDGAME_startBlinkerMove. */
96 screen->blinkers[index].state = 1;
97 screen->blinkers[index].x = x;
98 screen->blinkers[index].y = y;
99 screen->blinkers[index].targetY = 0;
100 screen->blinkers[index].targetX = 0;
101 screen->blinkers[index].startY = 0;
102 screen->blinkers[index].startX = 0;
103 screen->blinkers[index].duration = 0;
104 screen->blinkers[index].time = 0;
105 screen->blinkers[index].blinkTime = 0;
106 return 0;
107}
108
109/* Starts moving blinker index to x, y over duration frames */
110s32 CARDGAME_startBlinkerMove(CardScreen *screen, s32 index, u8 duration, s16 x, s32 y) {
111 screen->blinkers[index].state = 2;
112 screen->blinkers[index].targetX = x;
113 screen->blinkers[index].duration = duration;
114 screen->blinkers[index].time = duration;
115 screen->blinkers[index].targetY = y;
116 screen->blinkers[index].startX = screen->blinkers[index].x;
117 screen->blinkers[index].startY = screen->blinkers[index].y;
118 return 0;
119}
120
121/* Opens the message window at place with message, asking prompt with the
122 cursor on choice */
123void CARDGAME_openMessage(CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place) {
125 screen->message.duration = 12;
126 screen->message.time = 12;
127 screen->message.choice = choice;
128 screen->message.message = message;
129 screen->message.prompt = prompt;
130 screen->message.place = place;
131 screen->message.state = 1;
132}
133
134/* Closes the message window */
137 screen->message.duration = 6;
138 screen->message.time = 6;
139 screen->message.state = 5;
140}
141
142/* Confirms the message window's choice: the cursor nudges, then it closes */
145 screen->message.duration = 10;
146 screen->message.time = 10;
147 screen->message.state = 4;
148}
149
150/* Puts the message window's cursor on choice */
152 screen->message.choice = choice;
153}
154
155/* Opens the menu window with the cursor on row */
158 screen->menuDuration = 12;
159 screen->menuTime = 12;
160 screen->menuRow = row;
161 screen->menuState = 1;
162}
163
164/* Closes the menu window */
167 screen->menuDuration = 6;
168 screen->menuTime = 6;
169 screen->menuState = 5;
170}
171
172/* Confirms the menu window's row: the cursor nudges, then it closes */
175 screen->menuDuration = 10;
176 screen->menuTime = 10;
177 screen->menuState = 4;
178}
179
180/* Puts the menu window's cursor on row */
182 screen->menuRow = row;
183}
184
185/* Puts both panels away at once */
187 screen->panels[0].state = 0;
188 screen->panels[0].duration = 0;
189 screen->panels[0].time = 0;
190 screen->panels[0].x = 0;
191 screen->panels[0].y = 0xF1;
192 screen->panels[0].boxX = 0x147;
193 screen->panels[0].boxY = 0x8F;
194 screen->panels[0].winsX = 0x140;
195 screen->panels[0].winsY = 0xBD;
196 screen->panels[1].state = 0;
197 screen->panels[1].duration = 0;
198 screen->panels[1].time = 0;
199 screen->panels[1].x = 0;
200 screen->panels[1].y = -100;
201 screen->panels[1].boxX = 0x147;
202 screen->panels[1].boxY = 0x50;
203 screen->panels[1].winsX = 0x140;
204 screen->panels[1].winsY = 0x26;
205}
206
207/* Slides both panels in, over 20 frames */
209 screen->panels[0].state = 1;
210 screen->panels[0].event = 2;
211 screen->panels[0].duration = 20;
212 screen->panels[0].time = 20;
213 screen->panels[0].x = 0;
214 screen->panels[0].y = 0xF1;
215 screen->panels[0].boxX = 0x147;
216 screen->panels[0].boxY = 0x8F;
217 screen->panels[0].winsX = 0x140;
218 screen->panels[0].winsY = 0xBD;
219 screen->panels[1].state = 1;
220 screen->panels[1].duration = 20;
221 screen->panels[1].time = 20;
222 screen->panels[1].x = 0;
223 screen->panels[1].y = -100;
224 screen->panels[1].boxX = 0xF9;
225 screen->panels[1].boxY = 0x50;
226 screen->panels[1].winsX = 0x140;
227 screen->panels[1].winsY = 0x26;
228}
229
230/* Slides both panels out, over 10 frames */
232 screen->panels[0].state = 3;
233 screen->panels[0].duration = 10;
234 screen->panels[0].time = 10;
235 screen->panels[0].x = 0;
236 screen->panels[0].y = 0x8D;
237 screen->panels[0].boxX = 0x120;
238 screen->panels[0].boxY = 0x8F;
239 screen->panels[0].winsX = 0x113;
240 screen->panels[0].winsY = 0xBD;
241 screen->panels[1].state = 3;
242 screen->panels[1].duration = 10;
243 screen->panels[1].time = 10;
244 screen->panels[1].x = 0;
245 screen->panels[1].y = 0;
246 screen->panels[1].boxX = 0x120;
247 screen->panels[1].boxY = 0x50;
248 screen->panels[1].winsX = 0x113;
249 screen->panels[1].winsY = 0x26;
250}
251
252/* Slides side's panel in over 10 frames, stopping the other's */
253void CARDGAME_openPanel(CardScreen *screen, s32 side) {
254 screen->panels[side].state = 4;
255 screen->panels[side ^ 1].state = 0;
256 screen->panels[side].event = 2;
257 screen->panels[side].duration = 10;
258 screen->panels[side].time = 10;
259 if (side == 0) {
260 screen->panels[0].x = 0;
261 screen->panels[0].y = 0xF1;
262 } else {
263 screen->panels[side].x = 0;
264 screen->panels[side].y = -100;
265 }
266}
267
268/* Slides side's panel out over 5 frames, stopping the other's */
269void CARDGAME_closePanel(CardScreen *screen, s32 side) {
270 screen->panels[side].state = 5;
271 screen->panels[side ^ 1].state = 0;
272 screen->panels[side].duration = 5;
273 screen->panels[side].time = 5;
274 if (side == 0) {
275 screen->panels[0].x = 0;
276 screen->panels[0].y = 0x8D;
277 } else {
278 screen->panels[side].x = 0;
279 screen->panels[side].y = 0;
280 }
281}
282
283/* Grows side's panel icon over 12 frames */
285 screen->panels[side].scale.state = 1;
286 screen->panels[side].scale.duration = 12;
287 screen->panels[side].scale.time = 12;
288 screen->panels[side].scale.value = 0;
289}
290
291/* Shrinks side's panel icon over 6 frames */
293 screen->panels[side].scale.state = 3;
294 screen->panels[side].scale.duration = 6;
295 screen->panels[side].scale.time = 6;
296 screen->panels[side].scale.value = 0x1000;
297}
298
299/* CardScreen.addSprite: puts a card sprite, still and at full size, at x, y */
301 HEAP.zero(&screen->sprites[index], sizeof(CardSprite));
302 screen->sprites[index].visible = 1;
303 screen->sprites[index].state = 1;
304 screen->sprites[index].x = x;
305 screen->sprites[index].y = y;
306 screen->sprites[index].targetScaleX = 0x1000;
307 screen->sprites[index].scaleX = 0x1000;
308 screen->sprites[index].targetScaleY = 0x1000;
309 screen->sprites[index].scaleY = 0x1000;
310 screen->sprites[index].index = 0;
311 screen->sprites[index].color = 0;
312 screen->sprites[index].slot = index;
313 screen->sprites[index].ap = 0;
314 screen->sprites[index].hp = 0;
315 screen->sprites[index].effect = 0;
316 screen->sprites[index].dimmed = 0;
317 screen->sprites[index].moving = 0;
318 return 0;
319}
320
321/* Starts turning a sprite over (state 4, CARDGAME_flipSprite) */
323 SOUND.playSound(0x8004613E);
324 screen->sprites[index].state = 4;
325 screen->sprites[index].time = 0;
326 screen->sprites[index].duration = 0;
327 screen->sprites[index].scaleX = 0x1000;
328 screen->sprites[index].scaleY = 0x1000;
329 screen->sprites[index].moving = 0;
330 return 0;
331}
332
333/* Starts a sprite's jitter (state 6, CARDGAME_jitterSprite), with effect 1 */
335 SOUND.playSound(0x9C0003);
336 screen->sprites[index].state = 6;
337 screen->sprites[index].scaleX = 0x1000;
338 screen->sprites[index].scaleY = 0x1000;
339 screen->sprites[index].time = 0;
340 screen->sprites[index].duration = 0;
341 screen->sprites[index].effect = 1;
342 screen->sprites[index].moving = 0;
343 screen->sprites[index].startX = screen->sprites[index].x;
344 screen->sprites[index].startY = screen->sprites[index].y;
345 return 0;
346}
347
348/* Starts a sprite's shake (state 7, CARDGAME_shakeSprite), with effect 1 */
350 SOUND.playSound(0x9C0003);
351 screen->sprites[index].state = 7;
352 screen->sprites[index].time = 0;
353 screen->sprites[index].duration = 0;
354 screen->sprites[index].effect = 1;
355 screen->sprites[index].moving = 0;
356 screen->sprites[index].startX = screen->sprites[index].x;
357 screen->sprites[index].startY = screen->sprites[index].y;
358 return 0;
359}
360
361/* Starts a sprite's effect 2 with the recovery sound (state 8), and then its
362 blink */
365 screen->sprites[index].state = 8;
366 screen->sprites[index].time = 0;
367 screen->sprites[index].duration = 0;
368 screen->sprites[index].effect = 2;
369 screen->sprites[index].moving = 0;
370 screen->sprites[index].startX = screen->sprites[index].x;
371 screen->sprites[index].startY = screen->sprites[index].y;
372 return 0;
373}
374
375/* Starts a sprite's effect 3 (which 0) for 36 frames, or 4 for 28 */
377 switch (which) {
378 case 0:
379 default:
380 screen->sprites[index].state = 9;
381 screen->sprites[index].effect = 3;
382 break;
383 case 1:
384 screen->sprites[index].effect = 4;
385 screen->sprites[index].state = 10;
386 break;
387 }
388 screen->sprites[index].time = 0;
389 screen->sprites[index].duration = 0;
390 screen->sprites[index].moving = 0;
391 screen->sprites[index].startX = screen->sprites[index].x;
392 screen->sprites[index].startY = screen->sprites[index].y;
393 return 0;
394}
395
396/* Scales a sprite to scaleX, scaleY: at once when instant is 1, else over
397 duration (state 2) */
398s32 CARDGAME_setSpriteScaleTarget(CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY, s32 instant) {
399 screen->sprites[index].targetScaleX = scaleX;
400 screen->sprites[index].targetScaleY = scaleY;
401 screen->sprites[index].startScaleX = screen->sprites[index].scaleX;
402 screen->sprites[index].startScaleY = screen->sprites[index].scaleY;
403 if (instant != 1) {
404 screen->sprites[index].duration = duration;
405 screen->sprites[index].time = duration;
406 screen->sprites[index].state = 2;
407 screen->sprites[index].moving = 1;
408 screen->sprites[index].targetX = screen->sprites[index].x;
409 screen->sprites[index].targetY = screen->sprites[index].y;
410 }
411 return 0;
412}
413
414/* CardScreen.setSpriteScale: scales a sprite at once */
415void CARDGAME_setSpriteScale(CardScreen *screen, s32 index, s32 scaleX, s32 scaleY) {
416 CARDGAME_setSpriteScaleTarget(screen, index, 0, scaleX, scaleY, 1);
417}
418
419/* CardScreen.scaleSprite: scales a sprite over duration */
420void CARDGAME_scaleSprite(CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY) {
421 CARDGAME_setSpriteScaleTarget(screen, index, duration, scaleX, scaleY, 0);
422}
423
424/* Sets a sprite's move to x, y over duration, from where it is */
425void CARDGAME_setSpriteMove(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y) {
426 screen->sprites[index].targetX = x;
427 screen->sprites[index].duration = duration;
428 screen->sprites[index].time = duration;
429 screen->sprites[index].targetY = y;
430 screen->sprites[index].startX = screen->sprites[index].x;
431 screen->sprites[index].startY = screen->sprites[index].y;
432}
433
434/* Starts moving a sprite to x, y over duration (state 2), with a sound at
435 the start and the end */
436void CARDGAME_startSpriteMove(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y) {
437 SOUND.playSound(0x8004603C);
438 screen->sprites[index].state = 2;
439 CARDGAME_setSpriteMove(screen, index, duration, x, y);
440}
441
442/* Starts moving a sprite to x, y over duration without sounds (state 3) */
443void CARDGAME_startSpriteSlide(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y) {
444 screen->sprites[index].state = 3;
445 CARDGAME_setSpriteMove(screen, index, duration, x, y);
446}
447
448/* Starts a sprite's flight to x, y and back (state 5, CARDGAME_flySprite),
449 after it grows for 16 frames */
450s32 CARDGAME_startSpriteFly(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y) {
451 screen->sprites[index].state = 5;
452 screen->sprites[index].growTime = 16;
453 screen->sprites[index].scaleX = 0x1000;
454 screen->sprites[index].scaleY = 0x1000;
455 screen->sprites[index].targetX = x;
456 screen->sprites[index].duration = duration;
457 screen->sprites[index].time = duration;
458 screen->sprites[index].targetY = y;
459 screen->sprites[index].startX = screen->sprites[index].x;
460 screen->sprites[index].startY = screen->sprites[index].y;
461 return 0;
462}
463
464/* CardScreen.setPanelValue: sets one of side's panel values: its points (0
465 to 4), its deck, hand and discard counts, its AP or its HP (CARD_PANEL_*) */
466void CARDGAME_setPanelValue(CardScreen *screen, s32 side, u32 which, s32 value) {
467 switch (which) {
468 case 0:
469 screen->panels[side].points[0] = value;
470 break;
471 case 1:
472 screen->panels[side].points[1] = value;
473 break;
474 case 2:
475 screen->panels[side].points[2] = value;
476 break;
477 case 3:
478 screen->panels[side].points[3] = value;
479 break;
480 case 4:
481 screen->panels[side].points[4] = value;
482 break;
483 case CARD_PANEL_DECK:
484 screen->panels[side].deckCount = value;
485 break;
486 case CARD_PANEL_HAND:
487 screen->panels[side].handCount = value;
488 break;
490 screen->panels[side].discardCount = value;
491 break;
492 case CARD_PANEL_AP:
493 screen->panels[side].apTotal = value;
494 break;
495 case CARD_PANEL_HP:
496 screen->panels[side].hpTotal = value;
497 break;
498 }
499}
500
501/* CardScreen.setPanelFlags: sets the panels' blink flags from bits, two to a
502 flag: the even bits the player's, the odd ones the opponent's */
504 if (bits & 1) {
505 screen->panels[0].flags[0] = 1;
506 }
507 if (bits & 4) {
508 screen->panels[0].flags[1] = 1;
509 }
510 if (bits & 0x10) {
511 screen->panels[0].flags[2] = 1;
512 }
513 if (bits & 0x40) {
514 screen->panels[0].flags[3] = 1;
515 }
516 if (bits & 0x100) {
517 screen->panels[0].flags[4] = 1;
518 }
519 if (bits & 0x400) {
520 screen->panels[0].flags[5] = 1;
521 }
522 if (bits & 0x1000) {
523 screen->panels[0].flags[6] = 1;
524 }
525 if (bits & 0x4000) {
526 screen->panels[0].flags[7] = 1;
527 }
528 if (bits & 0x10000) {
529 screen->panels[0].flags[8] = 1;
530 }
531 if (bits & 0x40000) {
532 screen->panels[0].flags[9] = 1;
533 }
534 if (bits & 2) {
535 screen->panels[1].flags[0] = 1;
536 }
537 if (bits & 8) {
538 screen->panels[1].flags[1] = 1;
539 }
540 if (bits & 0x20) {
541 screen->panels[1].flags[2] = 1;
542 }
543 if (bits & 0x80) {
544 screen->panels[1].flags[3] = 1;
545 }
546 if (bits & 0x200) {
547 screen->panels[1].flags[4] = 1;
548 }
549 if (bits & 0x800) {
550 screen->panels[1].flags[5] = 1;
551 }
552 if (bits & 0x2000) {
553 screen->panels[1].flags[6] = 1;
554 }
555 if (bits & 0x8000) {
556 screen->panels[1].flags[7] = 1;
557 }
558 if (bits & 0x20000) {
559 screen->panels[1].flags[8] = 1;
560 }
561 if (bits & 0x80000) {
562 screen->panels[1].flags[9] = 1;
563 }
564}
565
566/* CardScreen.clearPanelFlags: clears both panels' blink flags */
568 HEAP.zero(screen->panels[0].flags, sizeof(screen->panels[0].flags));
569 HEAP.zero(screen->panels[1].flags, sizeof(screen->panels[1].flags));
570}
571
572/* CardScreen.removeSprite: hides a sprite */
574 screen->sprites[index].state = 0;
575 screen->sprites[index].visible = 0;
576 screen->sprites[index].index = 0;
577 return 0;
578}
579
580/* Starts a sprite's blink (state 11), with the confirm sound */
583 screen->sprites[index].state = 11;
584 screen->sprites[index].duration = 0;
585 screen->sprites[index].time = 0;
586 return 0;
587}
588
589/* CardScreen.dealSprites: lays out count sprites as a hand from x, y, at
590 once (duration 0) or moving there */
591void CARDGAME_dealSprites(CardScreen *screen, s16 duration, s16 count, s32 x, s32 y) {
592 s32 i;
593 s32 sx;
594
595 for (i = 0; i < count; i++) {
596 sx = x + CARDGAME_getHandOffset(count, i);
597 if (duration == 0) {
598 CARDGAME_addSprite(screen, i, sx, y);
599 } else {
600 CARDGAME_startSpriteMove(screen, i, duration, sx, y);
601 }
602 }
603}
604
605/* CardScreen.getCardColor: the colour of the screen's card index */
607 CardDrawer drawer;
608
609 initCardDrawer(&drawer);
610 drawer.setCard(screen->cards[index] + 1);
611 return drawer.card->color;
612}
613
614/* CardScreen.setSpriteCard: shows the screen's card index on sprite, with
615 its AP, HP, points and colour */
616void CARDGAME_setSpriteCard(CardScreen *screen, s32 sprite, s32 index) {
617 CardDrawer drawer;
618
619 initCardDrawer(&drawer);
620 drawer.setCard(screen->cards[index] + 1);
621 screen->sprites[sprite].index = index;
622 screen->sprites[sprite].ap = drawer.card->ap;
623 screen->sprites[sprite].hp = drawer.card->hp;
624 screen->sprites[sprite].points = drawer.card->points;
625 screen->sprites[sprite].color = drawer.card->color - 1;
626 if (drawer.card->kind == 0x10) {
627 screen->sprites[sprite].isKind16 = 1;
628 } else {
629 screen->sprites[sprite].isKind16 = 0;
630 }
631}
632
633/* Loads a card's image to VRAM slot slot, in columns of eight, with its CLUT */
634void CARDGAME_loadCardImage(TimLoader *loader, u8 *image, s32 slot) {
635 loader->setImagePos(0x140 + slot / 8 * 16, 0x100 + slot % 8 * 32);
636 loader->setClutPos(0x300, 0x100 + slot);
637 loader->load(image);
638}
639
640/* Card index of CARDGAME_otherCards */
642 return CARDGAME_otherCards[index];
643}
644
645/* CardScreen.loadCardImages: loads the images of the player's 40 cards, the
646 opponent's 40, the 9 common ones and the 100 others, and lists them in
647 dst; returns how many */
648s32 CARDGAME_loadCardImages(s16 *dst, s16 *player, s16 *opponent) {
649 TimLoader loader;
650 CardDrawer drawer;
651 s32 i;
652 s32 count = 0;
653
654 initCardDrawer(&drawer);
655 initTimLoader(&loader);
656 for (i = 0; i < 40; i++) {
657 count++;
658 drawer.setCard(player[i] + 1);
659 CARDGAME_loadCardImage(&loader, drawer.card->tim, i);
660 dst[i] = player[i];
661 }
662 for (i = 0; i < 40; i++) {
663 count++;
664 drawer.setCard(opponent[i] + 1);
665 CARDGAME_loadCardImage(&loader, drawer.card->tim, i + 40);
666 dst[i + 40] = opponent[i];
667 }
668 for (i = 0; i < 9; i++) {
669 count++;
670 drawer.setCard(CARDGAME_commonCards[i] + 1);
671 CARDGAME_loadCardImage(&loader, drawer.card->tim, i + 80);
672 dst[i + 80] = CARDGAME_commonCards[i];
673 }
674 for (i = 0; i < 100; i++) {
675 drawer.setCard(CARDGAME_getOtherCard(i) + 1);
676 count++;
677 CARDGAME_loadCardImage(&loader, drawer.card->tim, i + 89);
678 dst[i + 89] = CARDGAME_getOtherCard(i);
679 }
680 return count;
681}
682
683/* Creates the card screen over cards, with its functions */
685 CardScreen *screen = createTask(CARDGAME_updateScreen, sizeof(CardScreen), 14 * 4);
686
719 screen->cards = cards;
730 return screen;
731}
CARDGAME.PRO: the card battle (mode 0x700).
void initCardDrawer(CardDrawer *obj)
Clears a card drawer, gives it its methods and binds it.
void CARDGAME_updateScreen(CardScreen *screen, CardScreenItems *items)
The card screen's task: makes its cursor and text windows, then each frame updates its blinkers,...
Definition screen.c:8
void CARDGAME_setPanelFlags(CardScreen *screen, s32 bits)
CardScreen.setPanelFlags: sets the panels' blink flags from bits, two to a flag: the even bits the pl...
Definition screen.c:503
void CARDGAME_setPanelValue(CardScreen *screen, s32 side, u32 which, s32 value)
CardScreen.setPanelValue: sets one of side's panel values: its points (0 to 4), its deck,...
Definition screen.c:466
s32 CARDGAME_startSpriteRecovery(CardScreen *screen, s32 index)
Starts a sprite's effect 2 with the recovery sound (state 8), and then its blink.
Definition screen.c:363
void CARDGAME_confirmMessage(CardScreen *screen)
Confirms the message window's choice: the cursor nudges, then it closes.
Definition screen.c:143
s32 CARDGAME_startSpriteFlip(CardScreen *screen, s32 index)
Starts turning a sprite over (state 4, CARDGAME_flipSprite)
Definition screen.c:322
s32 CARDGAME_startBlinkerMove(CardScreen *screen, s32 index, u8 duration, s16 x, s32 y)
Starts moving blinker index to x, y over duration frames.
Definition screen.c:110
void CARDGAME_resetPanels(CardScreen *screen)
Puts both panels away at once.
Definition screen.c:186
void CARDGAME_openWindow(CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y)
Opens window index (CardScreen.windows) at x, y, with its layout and value.
Definition screen.c:70
void CARDGAME_openPanels(CardScreen *screen)
Slides both panels in, over 20 frames.
Definition screen.c:208
void CARDGAME_closeWindow(CardScreen *screen, s32 index)
Closes window index.
Definition screen.c:84
void CARDGAME_openPanelIcon(CardScreen *screen, s32 side)
Grows side's panel icon over 12 frames.
Definition screen.c:284
void CARDGAME_closeMessage(CardScreen *screen)
Closes the message window.
Definition screen.c:135
void CARDGAME_setMessageChoice(CardScreen *screen, s32 choice)
Puts the message window's cursor on choice.
Definition screen.c:151
s32 CARDGAME_getCardColor(CardScreen *screen, s32 index)
CardScreen.getCardColor: the colour of the screen's card index.
Definition screen.c:606
void CARDGAME_closePanelIcon(CardScreen *screen, s32 side)
Shrinks side's panel icon over 6 frames.
Definition screen.c:292
void CARDGAME_openMenuWindow(CardScreen *screen, s16 row)
Opens the menu window with the cursor on row.
Definition screen.c:156
void CARDGAME_closePanels(CardScreen *screen)
Slides both panels out, over 10 frames.
Definition screen.c:231
s32 CARDGAME_showBlinker(CardScreen *screen, s32 index, s16 x, s16 y)
Shows blinker index, still, at x, y.
Definition screen.c:95
void CARDGAME_startSpriteSlide(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Starts moving a sprite to x, y over duration without sounds (state 3)
Definition screen.c:443
s32 CARDGAME_setSpriteScaleTarget(CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY, s32 instant)
Scales a sprite to scaleX, scaleY: at once when instant is 1, else over duration (state 2)
Definition screen.c:398
void CARDGAME_confirmMenuWindow(CardScreen *screen)
Confirms the menu window's row: the cursor nudges, then it closes.
Definition screen.c:173
void CARDGAME_openGauge(CardScreen *screen, s32 index, s16 value)
Opens gauge index showing value, over 10 frames.
Definition screen.c:51
void CARDGAME_clearPanelFlags(CardScreen *screen)
CardScreen.clearPanelFlags: clears both panels' blink flags.
Definition screen.c:567
void CARDGAME_closeGauge(CardScreen *screen, s32 index)
Closes gauge index, over 5 frames.
Definition screen.c:61
void CARDGAME_closePanel(CardScreen *screen, s32 side)
Slides side's panel out over 5 frames, stopping the other's.
Definition screen.c:269
void CARDGAME_openPanel(CardScreen *screen, s32 side)
Slides side's panel in over 10 frames, stopping the other's.
Definition screen.c:253
void CARDGAME_closeMenuWindow(CardScreen *screen)
Closes the menu window.
Definition screen.c:165
CardScreen * CARDGAME_createScreen(s16 *cards)
Creates the card screen over cards, with its functions.
Definition screen.c:684
void CARDGAME_openMessage(CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place)
Opens the message window at place with message, asking prompt with the cursor on choice.
Definition screen.c:123
s32 CARDGAME_addSprite(CardScreen *screen, s32 index, s32 x, s32 y)
CardScreen.addSprite: puts a card sprite, still and at full size, at x, y.
Definition screen.c:300
void CARDGAME_setSpriteScale(CardScreen *screen, s32 index, s32 scaleX, s32 scaleY)
CardScreen.setSpriteScale: scales a sprite at once.
Definition screen.c:415
void CARDGAME_scaleSprite(CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
CardScreen.scaleSprite: scales a sprite over duration.
Definition screen.c:420
s32 CARDGAME_loadCardImages(s16 *dst, s16 *player, s16 *opponent)
CardScreen.loadCardImages: loads the images of the player's 40 cards, the opponent's 40,...
Definition screen.c:648
void CARDGAME_startSpriteMove(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Starts moving a sprite to x, y over duration (state 2), with a sound at the start and the end.
Definition screen.c:436
void CARDGAME_loadCardImage(TimLoader *loader, u8 *image, s32 slot)
Loads a card's image to VRAM slot slot, in columns of eight, with its CLUT.
Definition screen.c:634
void CARDGAME_setMenuWindowRow(CardScreen *screen, s16 row)
Puts the menu window's cursor on row.
Definition screen.c:181
void CARDGAME_dealSprites(CardScreen *screen, s16 duration, s16 count, s32 x, s32 y)
CardScreen.dealSprites: lays out count sprites as a hand from x, y, at once (duration 0) or moving th...
Definition screen.c:591
s32 CARDGAME_startSpriteBlink(CardScreen *screen, s32 index)
Starts a sprite's blink (state 11), with the confirm sound.
Definition screen.c:581
s32 CARDGAME_startSpriteJitter(CardScreen *screen, s32 index)
Starts a sprite's jitter (state 6, CARDGAME_jitterSprite), with effect 1.
Definition screen.c:334
s32 CARDGAME_startSpriteEffect(CardScreen *screen, s32 index, s32 which)
Starts a sprite's effect 3 (which 0) for 36 frames, or 4 for 28.
Definition screen.c:376
s32 CARDGAME_startSpriteFly(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Starts a sprite's flight to x, y and back (state 5, CARDGAME_flySprite), after it grows for 16 frames...
Definition screen.c:450
s32 CARDGAME_startSpriteShake(CardScreen *screen, s32 index)
Starts a sprite's shake (state 7, CARDGAME_shakeSprite), with effect 1.
Definition screen.c:349
s32 CARDGAME_getOtherCard(s32 index)
Card index of CARDGAME_otherCards.
Definition screen.c:641
void CARDGAME_setSpriteCard(CardScreen *screen, s32 sprite, s32 index)
CardScreen.setSpriteCard: shows the screen's card index on sprite, with its AP, HP,...
Definition screen.c:616
void CARDGAME_setSpriteMove(CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Sets a sprite's move to x, y over duration, from where it is.
Definition screen.c:425
s32 CARDGAME_removeSprite(CardScreen *screen, s32 index)
CardScreen.removeSprite: hides a sprite.
Definition screen.c:573
s16 CARDGAME_commonCards[]
the cards everyone has, after the two decks in the card list
Definition cardgame_3.c:101
s16 CARDGAME_otherCards[]
the 100 cards whose images CARDGAME_loadCardImages loads after the decks (CARDGAME_getOtherCard)
Definition cardgame_3.c:85
signed int s32
Definition common.h:11
unsigned int u32
Definition common.h:12
signed short s16
Definition common.h:9
unsigned char u8
Definition common.h:8
GfxState GFX
GFX: the graphics state and its methods.
Definition display.c:209
Cursor * createCursor(s16 layerId, s32 depth, s16 x, s16 y)
A menu cursor on a layer at (x, y)
Definition cursor.c:92
Heap HEAP
The functions that return what a call left in v0 (allocMemHigh, findTask) and the ones that take othe...
Definition heap.c:184
void CARDGAME_updateMenuWindow(CardScreen *screen, CardScreenItems *items)
A menu window (CardScreen.menuState): it opens, shows text file 0x10 with the cursor on menuRow,...
s32 CARDGAME_getHandOffset(s32 count, s32 index)
CardScreen.getHandOffset: how far the hand's card index is from its first: 0x2900 a card up to six ca...
void CARDGAME_updateMessageWindow(CardScreen *screen, CardScreenItems *items)
The message window: it opens at its place, shows its prompt (showMessagePrompt) and message (showMess...
void CARDGAME_updateBlinkers(CardScreen *screen, CardScreenItems *items)
Moves and draws the twelve blinkers.
Definition panels.c:456
void CARDGAME_updatePanels(CardScreen *screen, CardScreenItems *items)
Runs and draws both panels and their icons.
Definition panels.c:473
@ CARD_PANEL_HAND
Definition screen.h:200
@ CARD_PANEL_DISCARDS
Definition screen.h:201
@ CARD_PANEL_HP
Definition screen.h:203
@ CARD_PANEL_AP
Definition screen.h:202
@ CARD_PANEL_DECK
Definition screen.h:199
SoundState SOUND
rsin and rcos (libgte) read rsin_tbl[a - 0x800] and the like: their addresses before the table fall i...
Definition sound.c:180
#define SOUND_RECOVERY
RECOVERY.
Definition sound.h:46
#define SOUND_MENU_CLOSE
SYSTEM04.
Definition sound.h:42
#define SOUND_MENU_CONFIRM
SYSTEM07.
Definition sound.h:44
#define SOUND_SELECT
Sounds the overlays share, with SOUNDTST's names.
Definition sound.h:38
#define SOUND_MENU_OPEN
SYSTEM03.
Definition sound.h:41
void CARDGAME_updateSprites(CardScreen *screen, CardScreenItems *items)
Animates the sprites, then draws them: the moving ones first.
Definition sprites.c:577
s16 targetX
Definition screen.h:213
s16 blinkTime
Definition screen.h:215
s16 targetY
Definition screen.h:214
u8 duration
Definition screen.h:217
s16 startX
Definition screen.h:211
s16 startY
Definition screen.h:212
Draws the cards' images (CardImage), from files 0x7E7-0x7EB.
Definition gfx.h:193
void(* setCard)()
(id)
Definition gfx.h:205
CardImage * card
Definition gfx.h:194
s16 state
Definition screen.h:227
s16 from
Definition screen.h:223
s16 time
Definition screen.h:225
s16 value
Definition screen.h:228
s16 duration
Definition screen.h:226
s16 to
Definition screen.h:224
u8 hp
Definition gfx.h:175
u8 color
from 1
Definition gfx.h:173
u8 ap
Definition gfx.h:174
u8 kind
an index in CARD_KINDS
Definition gfx.h:176
u8 tim[0x620]
its header, a 256-colour CLUT block and the image block
Definition gfx.h:185
u8 points
what it adds to its colour
Definition gfx.h:179
u8 prompt
what it asks: 0 nothing, else a choice with the cursor
Definition screen.h:257
s16 choice
the cursor's row
Definition screen.h:254
u8 state
1 opening, 2 open, 4 confirmed, 5 closing
Definition screen.h:256
s32 place
in CARDGAME_messageWindowPositions
Definition screen.h:249
s16 event
for a frame, until CARDGAME_slidePanel clears it: 2 the panel started sliding in, 1 it slid out; noth...
Definition screen.h:138
s16 time
Definition screen.h:135
s16 duration
Definition screen.h:136
u8 handCount
Definition screen.h:147
s16 hpTotal
Definition screen.h:143
s16 apTotal
the values shown (CARDGAME_setPanelValue)
Definition screen.h:142
s16 boxY
Definition screen.h:149
s32 discardCount
Definition screen.h:151
u8 points[5]
one per card colour
Definition screen.h:145
CardPanelScale scale
Definition screen.h:159
s16 x
Definition screen.h:140
s16 state
Definition screen.h:137
s16 y
Definition screen.h:141
s16 winsX
where the rounds won are shown
Definition screen.h:155
s16 winsY
Definition screen.h:156
u8 deckCount
Definition screen.h:146
s16 boxX
the discards' box, which slides on its own
Definition screen.h:148
u8 flags[10]
Definition screen.h:153
The battle screen's task items.
Definition screen.h:87
TextWindow * panelTexts[2]
the label under each side's panel (CARDGAME_drawPanelIcon)
Definition screen.h:90
TextWindow * moreTexts[8]
Definition screen.h:91
TextWindow * texts[3]
Definition screen.h:89
Cursor * cursor
Definition screen.h:88
The battle screen (created by CARDGAME_createScreen): the two panels, the cards on the table and the ...
Definition screen.h:263
CardMessageWindow message
Definition screen.h:274
CardBlinker blinkers[12]
Definition screen.h:272
void(* setSpriteCard)(struct CardScreen *screen, s32 sprite, s32 index)
Definition screen.h:324
void(* openWindow)(struct CardScreen *screen, s32 index, s16 layout, s32 value, s32 x, s32 y)
Definition screen.h:288
s32 state
Definition screen.h:264
void(* closePanel)(struct CardScreen *screen, s32 side)
Definition screen.h:292
s16 * cards
the battle's card list
Definition screen.h:265
s32(* startFly)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Definition screen.h:313
u32 time
Definition screen.h:267
void(* dealSprites)(struct CardScreen *screen, s16 duration, s16 count, s32 x, s32 y)
Definition screen.h:310
void(* openMenu)(struct CardScreen *screen, s16 row)
Definition screen.h:306
void(* setPanelValue)(struct CardScreen *screen, s32 side, u32 which, s32 value)
Definition screen.h:285
void(* scaleSprite)(struct CardScreen *screen, s32 index, s32 duration, s32 scaleX, s32 scaleY)
Definition screen.h:318
s32(* getCardColor)(struct CardScreen *screen, s32 index)
Definition screen.h:325
void(* setPanelFlags)(struct CardScreen *screen, s32 bits)
Definition screen.h:291
void(* nextState)(struct CardScreen *task)
Definition screen.h:264
void(* clearPanelFlags)(struct CardScreen *screen)
Definition screen.h:290
CardGauge gauges[3]
Definition screen.h:273
void(* startMove)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Definition screen.h:311
void(* resetPanels)(struct CardScreen *screen)
Definition screen.h:296
void(* openPanels)(struct CardScreen *screen)
Definition screen.h:295
void(* setMessageChoice)(struct CardScreen *screen, s32 choice)
Definition screen.h:305
s32(* startShake)(struct CardScreen *screen, s32 index)
Definition screen.h:321
CardSprite sprites[40]
Definition screen.h:271
void(* openMessage)(struct CardScreen *screen, s32 message, s32 prompt, s16 choice, s32 place)
Definition screen.h:302
s32(* getHandOffset)(s32 count, s32 index)
Definition screen.h:299
void(* closeMenu)(struct CardScreen *screen)
Definition screen.h:307
void(* confirmMessage)(struct CardScreen *screen)
Definition screen.h:304
s32(* removeSprite)(struct CardScreen *screen, s32 index)
Definition screen.h:315
s32(* startEffect)(struct CardScreen *screen, s32 index, s32 which)
Definition screen.h:323
void(* setSpriteScale)(struct CardScreen *screen, s32 index, s32 scaleX, s32 scaleY)
Definition screen.h:317
void(* closePanels)(struct CardScreen *screen)
Definition screen.h:294
s32(* startJitter)(struct CardScreen *screen, s32 index)
Definition screen.h:320
void(* openPanelIcon)(struct CardScreen *screen, s32 side)
Definition screen.h:297
CardWindow windows[6]
Definition screen.h:281
void(* closeMessage)(struct CardScreen *screen)
Definition screen.h:303
s32 spriteFlags
this frame: bit 0 a sprite is animated, bit 1 a flying one landed
Definition screen.h:266
s16 menuState
Definition screen.h:280
void(* closeWindow)(struct CardScreen *screen, s32 index)
Definition screen.h:289
s32(* loadCardImages)(s16 *dst, s16 *player, s16 *opponent)
Definition screen.h:326
s32(* startBlink)(struct CardScreen *screen, s32 index)
Definition screen.h:316
s16 menuTime
Definition screen.h:276
void(* confirmMenu)(struct CardScreen *screen)
Definition screen.h:308
void(* closeGauge)(struct CardScreen *screen, s32 index)
Definition screen.h:287
s32(* showBlinker)(struct CardScreen *screen, s32 index, s16 x, s16 y)
Definition screen.h:300
s16 menuRow
Definition screen.h:278
s32(* startFlip)(struct CardScreen *screen, s32 index)
Definition screen.h:319
void(* setMenuRow)(struct CardScreen *screen, s16 row)
Definition screen.h:309
void(* closePanelIcon)(struct CardScreen *screen, s32 side)
Definition screen.h:298
void(* openGauge)(struct CardScreen *screen, s32 index, s16 value)
Definition screen.h:286
s32(* addSprite)(struct CardScreen *screen, s32 index, s32 x, s32 y)
Definition screen.h:314
void(* startSlide)(struct CardScreen *screen, s32 index, s32 duration, s32 x, s32 y)
Definition screen.h:312
void(* openPanel)(struct CardScreen *screen, s32 side)
Definition screen.h:293
s16 menuDuration
Definition screen.h:277
s32(* startBlinkerMove)(struct CardScreen *screen, s32 index, u8 duration, s16 x, s32 y)
Definition screen.h:301
CardPanel panels[2]
Definition screen.h:270
s32(* startRecovery)(struct CardScreen *screen, s32 index)
Definition screen.h:322
A card on the battle screen (CardScreen.sprites)
Definition screen.h:163
s32 growTime
the frames it grows for before it flies (CARDGAME_flySprite)
Definition screen.h:180
s16 index
in the battle's card list
Definition screen.h:183
s16 moving
Definition screen.h:177
u8 ap
the values shown, which count towards the slot's
Definition screen.h:188
s16 targetScaleY
Definition screen.h:173
s32 duration
Definition screen.h:179
u8 dimmed
Definition screen.h:194
s16 color
the card's colour, from 0
Definition screen.h:182
s32 startY
Definition screen.h:169
s32 startX
Definition screen.h:168
s16 targetScaleX
Definition screen.h:172
s16 startScaleX
Definition screen.h:174
s16 slot
Definition screen.h:176
s32 targetY
Definition screen.h:167
s32 time
Definition screen.h:178
u8 points
the card's
Definition screen.h:186
u8 visible
Definition screen.h:190
s16 isKind16
Definition screen.h:184
s16 startScaleY
Definition screen.h:175
s32 targetX
Definition screen.h:166
s16 scaleX
Definition screen.h:170
u8 effect
1-4, drawn by CARDGAME_drawSpriteEffect
Definition screen.h:192
s16 scaleY
Definition screen.h:171
s16 time
Definition screen.h:237
s16 duration
Definition screen.h:238
s16 from
Definition screen.h:235
s32 value
by its layout: a string, a card, or points | colour << 4
Definition screen.h:241
s16 layout
in CARDGAME_windowLayouts
Definition screen.h:239
void(* setVisible)()
(cursor, visible)
Definition text.h:33
s32(* getFrameTime)(void)
Definition gfx.h:32
GfxFuncs funcs
Definition gfx.h:77
void(* zero)(void *ptr, s32 size)
Definition heap.h:32
short(* playSound)(s32 id)
returns the voice of a key-on
Definition sound.h:187
void(* setLines)()
no prototype: callers would truncate u8 args
Definition text.h:184
Uploads TIM images to VRAM (initTimLoader); acts on TIM_LOADER.
Definition gfx.h:325
void(* setClutPos)()
(x, y)
Definition gfx.h:337
void(* setImagePos)()
(x, y)
Definition gfx.h:336
void(* load)()
(TIM)
Definition gfx.h:335
void * createTask(void(*update)(), s32 size, s32 childrenSize)
createTaskWithId for a task nothing needs to find
Definition task.c:105
TextWindow * createTextWindow(s16 layerId, s16 style, s16 x, s16 y)
A text window on a layer, in a font style, at (x, y)
void initTimLoader(TimLoader *obj)
Clears a TIM loader, gives it its methods and binds it.
Definition tim_loader.c:119
void CARDGAME_updateWindows(CardScreen *screen, CardScreenItems *items)
Runs and draws the six windows.
Definition windows.c:322
void CARDGAME_drawBackground(CardScreen *screen)
Draws the scrolling background, which fades in through its palettes (fadeState 1) and then stays.
Definition windows.c:7
void CARDGAME_updateGauges(CardScreen *screen, CardScreenItems *items)
Runs and draws the three gauges.
Definition windows.c:105