Skip to content

Commit 6632afc

Browse files
authored
Merge pull request #53 from KSSBrawl/asciimanager2
Implement more of AsciiManager
2 parents acce820 + 36b2a9b commit 6632afc

2 files changed

Lines changed: 285 additions & 14 deletions

File tree

src/AsciiManager.cpp

Lines changed: 283 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -210,25 +210,27 @@ int AsciiManager::AddFormatText2(D3DXVECTOR3 *position, const char *fmt, ...)
210210
return strlen(buf);
211211
}
212212

213+
#pragma var_order(spaceWidth, i, curString, text, isGui, vector)
213214
void AsciiManager::OnDrawLowPrioImpl()
214215
{
215216
D3DXVECTOR3 vector;
216217
ZunBool isGui = TRUE;
217218
int i;
218-
int t1 = this->numStrings;
219219
AsciiManagerString *curString = &this->strings[0];
220-
const char *text;
220+
u8 *text;
221221
float spaceWidth;
222222

223223
this->largeText.prefix.visible = true;
224224
this->largeText.prefix.anchor = 3;
225225

226-
for (i = 0; i < this->numStrings; i++)
226+
for (i = 0; i < this->numStrings; i++, curString++)
227227
{
228228
this->largeText.pos = curString->position;
229229

230-
text = curString->text;
230+
text = (u8 *)curString->text;
231231

232+
this->largeText.prefix.scale.x = curString->scaleX;
233+
this->largeText.prefix.scale.y = curString->scaleY;
232234
spaceWidth = this->spaceWidth * curString->scaleX;
233235

234236
if (isGui != curString->isGui)
@@ -259,7 +261,7 @@ void AsciiManager::OnDrawLowPrioImpl()
259261
{
260262
if (*text == '\n')
261263
{
262-
this->largeText.pos.y += curString->scaleY * 16.0f;
264+
this->largeText.pos.y += 16.0f * curString->scaleY;
263265
this->largeText.pos.x = curString->position.x;
264266
}
265267
else if (*text == ' ')
@@ -268,15 +270,15 @@ void AsciiManager::OnDrawLowPrioImpl()
268270
}
269271
else
270272
{
271-
if (curString->isSelected)
273+
if (!curString->isSelected)
272274
{
273-
this->largeText.loadedSprite = this->asciiAnm->GetSprite((u8)*text + (170 - ' '));
274-
this->largeText.prefix.color1.d3dColor = 0xffffffff;
275+
this->largeText.loadedSprite = this->asciiAnm->GetSprite(*text + (31 - ' '));
276+
this->largeText.prefix.color1.d3dColor = curString->color;
275277
}
276278
else
277279
{
278-
this->largeText.loadedSprite = this->asciiAnm->GetSprite((u8)*text + (31 - ' '));
279-
this->largeText.prefix.color1.d3dColor = this->color;
280+
this->largeText.loadedSprite = this->asciiAnm->GetSprite(*text + (170 - ' '));
281+
this->largeText.prefix.color1.d3dColor = 0xffffffff;
280282
}
281283

282284
g_AnmManager->DrawNoRotation(&this->largeText);
@@ -285,25 +287,294 @@ void AsciiManager::OnDrawLowPrioImpl()
285287

286288
text++;
287289
}
290+
}
288291

289-
curString++;
292+
if (isGui)
293+
{
294+
g_AnmManager->FlushVertexBuffer();
295+
g_Supervisor.viewport.X = 0;
296+
g_Supervisor.viewport.Y = 0;
297+
g_Supervisor.viewport.Width = 640;
298+
g_Supervisor.viewport.Height = 480;
299+
g_Supervisor.d3dDevice->SetViewport(&g_Supervisor.viewport);
300+
}
301+
302+
for (i = 0; i < ARRAY_SIZE_SIGNED(this->bossMarkers); i++)
303+
{
304+
if (this->bossMarkers[i].pos.x >= 56.0f && this->bossMarkers[i].pos.x <= 392.0f)
305+
{
306+
// TODO: This line is not done! The player position is needed in this calculation
307+
spaceWidth = fabsf(this->bossMarkers[i].pos.x - 32.0f);
308+
309+
this->bossMarkers[i].loadedSprite = this->asciiAnm->GetSprite(157);
310+
311+
switch (this->bossMarkerStates[i])
312+
{
313+
case 0:
314+
no_flicker:
315+
this->bossMarkers[i].prefix.color1.r = 255;
316+
this->bossMarkers[i].prefix.color1.g = 255;
317+
this->bossMarkers[i].prefix.color1.b = 255;
318+
if (spaceWidth < 64.0f)
319+
{
320+
this->bossMarkers[i].prefix.color1.a = (spaceWidth * 64.0f) / 64.0f + 96.0f;
321+
}
322+
else
323+
{
324+
this->bossMarkers[i].prefix.color1.a = 160;
325+
}
326+
break;
327+
case 1:
328+
this->bossMarkers[i].prefix.color1.a = 128;
329+
this->bossMarkers[i].prefix.color1.r = 255;
330+
this->bossMarkers[i].prefix.color1.g = 64;
331+
this->bossMarkers[i].prefix.color1.b = 64;
332+
break;
333+
case 2:
334+
if (this->unk_8284 % 8 == 0)
335+
{
336+
this->bossMarkers[i].loadedSprite = this->asciiAnm->GetSprite(158);
337+
this->bossMarkers[i].prefix.color1.a = 255;
338+
this->bossMarkers[i].prefix.color1.r = 255;
339+
this->bossMarkers[i].prefix.color1.g = 255;
340+
this->bossMarkers[i].prefix.color1.b = 255;
341+
}
342+
else
343+
{
344+
goto no_flicker;
345+
}
346+
break;
347+
case 3:
348+
if (this->unk_8284 % 4 == 0)
349+
{
350+
this->bossMarkers[i].loadedSprite = this->asciiAnm->GetSprite(158);
351+
this->bossMarkers[i].prefix.color1.a = 255;
352+
this->bossMarkers[i].prefix.color1.r = 255;
353+
this->bossMarkers[i].prefix.color1.g = 255;
354+
this->bossMarkers[i].prefix.color1.b = 255;
355+
}
356+
else
357+
{
358+
goto no_flicker;
359+
}
360+
break;
361+
case 4:
362+
if (this->unk_8284 % 2 == 0)
363+
{
364+
this->bossMarkers[i].loadedSprite = this->asciiAnm->GetSprite(158);
365+
this->bossMarkers[i].prefix.color1.a = 255;
366+
this->bossMarkers[i].prefix.color1.r = 255;
367+
this->bossMarkers[i].prefix.color1.g = 255;
368+
this->bossMarkers[i].prefix.color1.b = 255;
369+
}
370+
else
371+
{
372+
goto no_flicker;
373+
}
374+
break;
375+
}
376+
377+
g_AnmManager->DrawNoRotation(&this->bossMarkers[i]);
378+
}
290379
}
291380
}
292381

293382
void AsciiManager::CreateScorePopup(D3DXVECTOR3 *position, i32 number, D3DCOLOR color)
294383
{
384+
AsciiManagerPopup *popup;
385+
int characterCount;
386+
387+
if (this->nextScorePopupIndex >= ASCII_MAX_SCORE_POPUPS)
388+
{
389+
this->nextScorePopupIndex = 0;
390+
}
391+
popup = &this->scorePopups[nextScorePopupIndex];
392+
popup->inUse = true;
393+
394+
characterCount = 0;
395+
if (number >= 0)
396+
{
397+
while (number != 0)
398+
{
399+
popup->text[characterCount] = number % 10;
400+
characterCount++;
401+
number /= 10;
402+
}
403+
}
404+
else
405+
{
406+
popup->text[characterCount] = 10;
407+
characterCount++;
408+
}
409+
410+
if (characterCount == 0)
411+
{
412+
popup->text[characterCount] = 0;
413+
characterCount++;
414+
}
415+
416+
popup->characterCount = characterCount;
417+
popup->color = color;
418+
popup->timer = 0;
419+
popup->position = *position;
420+
popup->position.x += g_GameManager.arcadeRegionTopLeftPos.x;
421+
popup->position.y += g_GameManager.arcadeRegionTopLeftPos.y;
422+
this->nextScorePopupIndex++;
295423
}
296424

297425
void AsciiManager::CreatePlayerPointPopup(D3DXVECTOR3 *position, i32 number, D3DCOLOR color)
298426
{
427+
AsciiManagerPopup *popup;
428+
int characterCount;
429+
430+
if (this->nextPlayerPointPopupIndex >= ASCII_MAX_PLAYER_POPUPS)
431+
{
432+
this->nextPlayerPointPopupIndex = 0;
433+
}
434+
popup = &this->scorePopups[ASCII_MAX_SCORE_POPUPS + nextPlayerPointPopupIndex];
435+
popup->inUse = true;
436+
437+
characterCount = 0;
438+
if (number >= 0)
439+
{
440+
while (number != 0)
441+
{
442+
popup->text[characterCount] = number % 10;
443+
characterCount++;
444+
number /= 10;
445+
}
446+
}
447+
else
448+
{
449+
popup->text[characterCount] = 10;
450+
characterCount++;
451+
}
452+
453+
if (characterCount == 0)
454+
{
455+
popup->text[characterCount] = 0;
456+
characterCount++;
457+
}
458+
459+
popup->characterCount = characterCount;
460+
popup->color = color;
461+
popup->timer = 0;
462+
popup->position = *position;
463+
popup->position.x += g_GameManager.arcadeRegionTopLeftPos.x;
464+
popup->position.y += g_GameManager.arcadeRegionTopLeftPos.y;
465+
this->nextPlayerPointPopupIndex++;
299466
}
300467

301468
void AsciiManager::CreateTimePopup(D3DXVECTOR3 *position, i32 number, i32 param3, D3DCOLOR color)
302469
{
470+
AsciiManagerPopup *popup;
471+
int characterCount;
472+
473+
if (this->nextTimePopupIndex >= ASCII_MAX_TIME_POPUPS)
474+
{
475+
this->nextTimePopupIndex = 0;
476+
}
477+
popup = &this->timePopups[nextTimePopupIndex];
478+
popup->inUse = true;
479+
480+
characterCount = 0;
481+
if (param3 > 0)
482+
{
483+
popup->text[characterCount] = 15;
484+
characterCount++;
485+
while (param3 != 0)
486+
{
487+
popup->text[characterCount] = param3 % 10;
488+
characterCount++;
489+
param3 /= 10;
490+
}
491+
popup->text[characterCount] = 14;
492+
characterCount++;
493+
}
494+
495+
if (number > 0)
496+
{
497+
while (number != 0)
498+
{
499+
popup->text[characterCount] = number % 10;
500+
characterCount++;
501+
number /= 10;
502+
}
503+
}
504+
else
505+
{
506+
popup->text[characterCount] = 0;
507+
characterCount++;
508+
}
509+
510+
popup->text[characterCount] = 13;
511+
characterCount++;
512+
513+
popup->characterCount = characterCount;
514+
popup->color = color;
515+
popup->timer = 0;
516+
popup->position = *position;
517+
popup->position.x += g_GameManager.arcadeRegionTopLeftPos.x;
518+
popup->position.y += g_GameManager.arcadeRegionTopLeftPos.y;
519+
popup->scaleX = this->scaleX;
520+
popup->scaleY = this->scaleY;
521+
this->nextTimePopupIndex++;
303522
}
304523

305-
void AsciiManager::CreateFamiliarPopup(D3DXVECTOR3 *position, i32 param1, i32 param2)
524+
void AsciiManager::CreateFamiliarPopup(D3DXVECTOR3 *position, i32 number, i32 param3, D3DCOLOR color)
306525
{
526+
AsciiManagerPopup *popup;
527+
int characterCount;
528+
529+
if (this->nextTimePopupIndex >= ASCII_MAX_TIME_POPUPS)
530+
{
531+
this->nextTimePopupIndex = 0;
532+
}
533+
popup = &this->timePopups[nextTimePopupIndex];
534+
popup->inUse = true;
535+
536+
characterCount = 0;
537+
if (param3 > 0)
538+
{
539+
popup->text[characterCount] = 15;
540+
characterCount++;
541+
while (param3 != 0)
542+
{
543+
popup->text[characterCount] = param3 % 10;
544+
characterCount++;
545+
param3 /= 10;
546+
}
547+
popup->text[characterCount] = 14;
548+
characterCount++;
549+
}
550+
551+
if (number > 0)
552+
{
553+
while (number != 0)
554+
{
555+
popup->text[characterCount] = number % 10;
556+
characterCount++;
557+
number /= 10;
558+
}
559+
}
560+
else
561+
{
562+
popup->text[characterCount] = 0;
563+
characterCount++;
564+
}
565+
566+
popup->text[characterCount] = 13;
567+
characterCount++;
568+
569+
popup->characterCount = characterCount;
570+
popup->color = color;
571+
popup->timer = 88;
572+
popup->position = *position;
573+
popup->position.x += g_GameManager.arcadeRegionTopLeftPos.x + 3.5f * characterCount;
574+
popup->position.y += g_GameManager.arcadeRegionTopLeftPos.y;
575+
popup->scaleX = this->scaleX;
576+
popup->scaleY = this->scaleY;
577+
this->nextTimePopupIndex++;
307578
}
308579

309580
i32 PauseMenu::OnUpdate()

src/AsciiManager.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct AsciiManager
9090
void CreateScorePopup(D3DXVECTOR3 *position, i32 number, D3DCOLOR color);
9191
void CreatePlayerPointPopup(D3DXVECTOR3 *position, i32 number, D3DCOLOR color);
9292
void CreateTimePopup(D3DXVECTOR3 *position, i32 number, i32 param3, D3DCOLOR color);
93-
void CreateFamiliarPopup(D3DXVECTOR3 *position, i32 param1, i32 param2);
93+
void CreateFamiliarPopup(D3DXVECTOR3 *position, i32 number, i32 param3, D3DCOLOR color);
9494
void OnDrawHighPrioImpl();
9595
void DrawPercentage(i32 param1, i32 param2, D3DCOLOR color);
9696
void UpdateVms();
@@ -128,7 +128,7 @@ struct AsciiManager
128128

129129
i32 gaugeInterrupt;
130130
i32 spaceWidth;
131-
i32 unk_8284;
131+
u32 unk_8284;
132132

133133
AnmLoaded *asciiAnm;
134134
AnmLoaded *captureAnm;

0 commit comments

Comments
 (0)