Skip to content

Commit 483394f

Browse files
committed
Merge 'Rando-specific display buffer and simplified text printing implementation' (OoTRandomizer#2258)
2 parents 71c52fd + c8b6a5e commit 483394f

22 files changed

Lines changed: 31675 additions & 31690 deletions

ASM/build/asm_symbols.txt

Lines changed: 636 additions & 624 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/build/bundle.o

-116 Bytes
Binary file not shown.

ASM/build/c_symbols.txt

Lines changed: 629 additions & 621 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ASM/c/debug.c

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,6 @@ void draw_debug_float(int whichNumber, float numberToShow) {
116116

117117
void debug_utilities(z64_disp_buf_t *db)
118118
{
119-
120-
if (!DEBUG_MODE){
121-
return;
122-
}
123-
124119
// Press L to levitate
125120
// Shoutouts to glankk
126121
if (z64_game.common.input[0].raw.pad.l) {
@@ -340,16 +335,14 @@ void draw_debug_menu(z64_disp_buf_t *db) {
340335
menu_category_t *d = &(menu_categories[i]);
341336
int top = start_top + ((icon_size + padding) * i) + 1;
342337
if (i != current_menu_indexes.main_index) {
343-
text_print_size(d->name, left, top, font_width);
338+
text_print_size(db, d->name, left, top, font_width, font_height);
344339
}
345340
}
346-
text_flush_size(db, font_width, font_height, 0, 0);
347341

348342
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10 , 0xFF);
349343
menu_category_t *d = &(menu_categories[current_menu_indexes.main_index]);
350344
int top = start_top + ((icon_size + padding) * current_menu_indexes.main_index) + 1;
351-
text_print_size(d->name, left, top, font_width);
352-
text_flush_size(db, font_width, font_height, 0, 0);
345+
text_print_size(db, d->name, left, top, font_width, font_height);
353346
}
354347
else {
355348
switch (current_menu_indexes.main_index)
@@ -360,16 +353,14 @@ void draw_debug_menu(z64_disp_buf_t *db) {
360353
warp_t *d = &(dungeon_warps[i]);
361354
int top = start_top + ((icon_size + padding) * i) + 1;
362355
if (i != current_menu_indexes.dungeon_index) {
363-
text_print_size(d->name, left, top, font_width);
356+
text_print_size(db, d->name, left, top, font_width, font_height);
364357
}
365358
}
366-
text_flush_size(db, font_width, font_height, 0, 0);
367359

368360
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10, 0xFF);
369361
warp_t *d = &(dungeon_warps[current_menu_indexes.dungeon_index]);
370362
int top = start_top + ((icon_size + padding) * current_menu_indexes.dungeon_index) + 1;
371-
text_print_size(d->name, left, top, font_width);
372-
text_flush_size(db, font_width, font_height, 0, 0);
363+
text_print_size(db, d->name, left, top, font_width, font_height);
373364
break;
374365

375366
case 1: // Overworld
@@ -379,31 +370,27 @@ void draw_debug_menu(z64_disp_buf_t *db) {
379370
warp_t *d = &(overworld_warps[i]);
380371
int top = start_top + ((icon_size + padding) * i) + 1;
381372
if (i != current_menu_indexes.overworld_index) {
382-
text_print_size(d->name, left, top, font_width);
373+
text_print_size(db, d->name, left, top, font_width, font_height);
383374
}
384375
}
385-
text_flush_size(db, font_width, font_height, 0, 0);
386376
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10, 0xFF);
387377
d = &(overworld_warps[current_menu_indexes.overworld_index]);
388378
top = start_top + ((icon_size + padding) * current_menu_indexes.overworld_index) + 1;
389-
text_print_size(d->name, left, top, font_width);
390-
text_flush_size(db, font_width, font_height, 0, 0);
379+
text_print_size(db, d->name, left, top, font_width, font_height);
391380
}
392381
else {
393382
for (int i = 0; i < 9; i++) {
394383
warp_t *d = &(overworld_warps[i + 10]);
395384
int top = start_top + ((icon_size + padding) * i) + 1;
396385
if (i + 10 != current_menu_indexes.overworld_index) {
397-
text_print_size(d->name, left, top, font_width);
386+
text_print_size(db, d->name, left, top, font_width, font_height);
398387
}
399388
}
400-
text_flush_size(db, font_width, font_height, 0, 0);
401389

402390
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10, 0xFF);
403391
d = &(overworld_warps[current_menu_indexes.overworld_index]);
404392
top = start_top + ((icon_size + padding) * (current_menu_indexes.overworld_index - 10)) + 1;
405-
text_print_size(d->name, left, top, font_width);
406-
text_flush_size(db, font_width, font_height, 0, 0);
393+
text_print_size(db, d->name, left, top, font_width, font_height);
407394
}
408395
break;
409396
case 2: // Bosses
@@ -412,16 +399,14 @@ void draw_debug_menu(z64_disp_buf_t *db) {
412399
warp_t *d = &(bosses_warps[i]);
413400
int top = start_top + ((icon_size + padding) * i) + 1;
414401
if (i != current_menu_indexes.boss_index) {
415-
text_print_size(d->name, left, top, font_width);
402+
text_print_size(db, d->name, left, top, font_width, font_height);
416403
}
417404
}
418-
text_flush_size(db, font_width, font_height, 0, 0);
419405

420406
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10, 0xFF);
421407
d = &(bosses_warps[current_menu_indexes.boss_index]);
422408
top = start_top + ((icon_size + padding) * current_menu_indexes.boss_index) + 1;
423-
text_print_size(d->name, left, top, font_width);
424-
text_flush_size(db, font_width, font_height, 0, 0);
409+
text_print_size(db, d->name, left, top, font_width, font_height);
425410
break;
426411
case 3: // Items
427412
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
@@ -430,48 +415,42 @@ void draw_debug_menu(z64_disp_buf_t *db) {
430415
item_t *dd = &(items_debug[i]);
431416
int top = start_top + ((icon_size + padding) * i) + 1;
432417
if (i != current_menu_indexes.item_index) {
433-
text_print_size(dd->name, left, top, font_width);
418+
text_print_size(db, dd->name, left, top, font_width, font_height);
434419
}
435420
}
436-
text_flush_size(db, font_width, font_height, 0, 0);
437421

438422
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10, 0xFF);
439423
item_t *dd = &(items_debug[current_menu_indexes.item_index]);
440424
top = start_top + ((icon_size + padding) * current_menu_indexes.item_index) + 1;
441-
text_print_size(dd->name, left, top, font_width);
442-
text_flush_size(db, font_width, font_height, 0, 0);
425+
text_print_size(db, dd->name, left, top, font_width, font_height);
443426
}
444427
if (current_menu_indexes.item_index > 9 && current_menu_indexes.item_index < 20) {
445428
for (int i = 0; i < 10; i++) {
446429
item_t *dd = &(items_debug[i + 10]);
447430
int top = start_top + ((icon_size + padding) * i) + 1;
448431
if (i + 10 != current_menu_indexes.item_index) {
449-
text_print_size(dd->name, left, top, font_width);
432+
text_print_size(db, dd->name, left, top, font_width, font_height);
450433
}
451434
}
452-
text_flush_size(db, font_width, font_height, 0, 0);
453435

454436
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10 , 0xFF);
455437
item_t *dd = &(items_debug[current_menu_indexes.item_index]);
456438
top = start_top + ((icon_size + padding) * (current_menu_indexes.item_index - 10)) + 1;
457-
text_print_size(dd->name, left, top, font_width);
458-
text_flush_size(db, font_width, font_height, 0, 0);
439+
text_print_size(db, dd->name, left, top, font_width, font_height);
459440
}
460441
if (current_menu_indexes.item_index > 19 && current_menu_indexes.item_index < 28) {
461442
for (int i = 0; i < 9; i++) {
462443
item_t *dd = &(items_debug[i + 20]);
463444
int top = start_top + ((icon_size + padding) * i) + 1;
464445
if (i + 20 != current_menu_indexes.item_index) {
465-
text_print_size(dd->name, left, top, font_width);
446+
text_print_size(db, dd->name, left, top, font_width, font_height);
466447
}
467448
}
468-
text_flush_size(db, font_width, font_height, 0, 0);
469449

470450
gDPSetPrimColor(db->p++, 0, 0, 0xE0, 0xE0, 0x10 , 0xFF);
471451
item_t *dd = &(items_debug[current_menu_indexes.item_index]);
472452
top = start_top + ((icon_size + padding) * (current_menu_indexes.item_index - 20)) + 1;
473-
text_print_size(dd->name, left, top, font_width);
474-
text_flush_size(db, font_width, font_height, 0, 0);
453+
text_print_size(db, dd->name, left, top, font_width, font_height);
475454
}
476455
break;
477456
default:
@@ -506,8 +485,7 @@ int draw_int_helper(z64_disp_buf_t *db, int32_t number, int16_t left, int16_t to
506485
// Set the color
507486
gDPSetPrimColor(db->p++, 0, 0, color.r, color.g, color.b, color.a);
508487
if (isNegative) {
509-
text_print_size("-", left - rupee_digit_sprite.tile_w, top, 8);
510-
text_flush_size(db, 8, 16, 0, 0);
488+
text_print_size(db, "-", left - rupee_digit_sprite.tile_w, top, 8, 16);
511489
}
512490
// Draw each digit
513491
for (uint8_t c = j; c > 0; c--) {
@@ -575,8 +553,7 @@ void draw_debug_numbers(z64_disp_buf_t *db) {
575553

576554
colorRGBA8_t color = { debug_text_color.r, debug_text_color.g, debug_text_color.b, 0xFF};
577555
int numberDigit = draw_int_helper(db, entireValue, debug_text_x_placement, height + offsetY, color);
578-
text_print_size(".", debug_text_x_placement + numberDigit * rupee_digit_sprite.tile_w, height + offsetY, rupee_digit_sprite.tile_w);
579-
text_flush_size(db, rupee_digit_sprite.tile_w, rupee_digit_sprite.tile_h, 0, 0);
556+
text_print_size(db, ".", debug_text_x_placement + numberDigit * rupee_digit_sprite.tile_w, height + offsetY, rupee_digit_sprite.tile_w, rupee_digit_sprite.tile_h);
580557
draw_int_helper(db, decimalValue, debug_text_x_placement + numberDigit * rupee_digit_sprite.tile_w + font_sprite.tile_w,
581558
height + offsetY, color);
582559
}

ASM/c/dungeon_info.c

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,8 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
298298
for (int i = 0; i < rows; i++) {
299299
dungeon_entry_t* d = &(dungeons[i]);
300300
int top = start_top + ((icon_size + padding) * i) + 1;
301-
text_print_size(d->name, left, top, font_width);
301+
text_print_size(db, d->name, left, top, font_width, font_height);
302302
}
303-
text_flush_size(db, font_width, font_height, 0, 0);
304303

305304
left += ((SHUFFLE_CHEST_GAME == 1 ? 11 : 8) * font_width) + padding;
306305

@@ -326,9 +325,8 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
326325
if (current_keys > 0) count[0] = current_keys + '0';
327326
if (total_keys > 0) count[2] = total_keys + '0';
328327
int top = start_top + ((icon_size + padding) * i) + 1;
329-
text_print_size(count, left, top, font_width);
328+
text_print_size(db, count, left, top, font_width, font_height);
330329
}
331-
text_flush_size(db, font_width, font_height, 0, 0);
332330

333331
left += (4 * font_width) + padding;
334332

@@ -426,12 +424,11 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
426424
}
427425
char* str = CFG_DUNGEON_IS_MQ[d->index] ? "MQ" : "Normal";
428426
int top = start_top + ((icon_size + padding) * i) + 1;
429-
text_print_size(str, left, top, font_width);
427+
text_print_size(db, str, left, top, font_width, font_height);
430428
}
431429

432430
left += (6 * font_width) + padding;
433431
}
434-
text_flush_size(db, font_width, font_height, 0, 0);
435432

436433
if (CFG_DUNGEON_INFO_SILVER_RUPEES) {
437434
// Draw silver rupee icons
@@ -605,7 +602,7 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
605602
world_text[3] = world % 10 + '0';
606603
}
607604
int top = start_top + ((icon_size + padding) * i) + 1;
608-
text_print(world_text, left, top);
605+
text_print(db, world_text, left, top);
609606
}
610607
left += 5 * font_sprite.tile_w;
611608
}
@@ -639,7 +636,7 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
639636
continue;
640637
}
641638
int top = start_top + ((icon_size + padding) * i) + 1;
642-
text_print(CFG_DUNGEON_REWARD_AREAS[i], left, top);
639+
text_print(db, CFG_DUNGEON_REWARD_AREAS[i], left, top);
643640
}
644641
}
645642

@@ -675,7 +672,7 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
675672
for (int i = 0; i < rows; i++) {
676673
dungeon_entry_t* d = &(dungeons[d_right_dungeon_idx(i)]); // skip Deku/DC/Jabu/Ice dynamically
677674
int top = start_top + ((icon_size + padding) * i) + 1;
678-
text_print(d->name, left, top);
675+
text_print(db, d->name, left, top);
679676
}
680677

681678
left += ((SHUFFLE_CHEST_GAME == 1 ? 11 : 8) * font_sprite.tile_w) + padding;
@@ -702,7 +699,7 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
702699
if (current_keys > 0) count[0] = current_keys + '0';
703700
if (total_keys > 0) count[2] = total_keys + '0';
704701
int top = start_top + ((icon_size + padding) * i) + 1;
705-
text_print(count, left, top);
702+
text_print(db, count, left, top);
706703
}
707704

708705
left += (4 * font_sprite.tile_w) + padding;
@@ -839,7 +836,7 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
839836
for (int i = 0; i < 12; i++) {
840837
dungeon_entry_t* d = &(dungeons[i + (i > 9 ? 1 : 0)]); // skip Hideout
841838
int top = start_top + ((icon_size + padding) * i) + 1;
842-
text_print(d->name, left, top);
839+
text_print(db, d->name, left, top);
843840
}
844841

845842
left += (8 * font_sprite.tile_w) + padding;
@@ -906,15 +903,14 @@ void draw_dungeon_info(z64_disp_buf_t* db) {
906903
}
907904
char* str = CFG_DUNGEON_IS_MQ[d->index] ? "MQ" : "Normal";
908905
int top = start_top + ((icon_size + padding) * i) + 1;
909-
text_print(str, left, top);
906+
text_print(db, str, left, top);
910907
}
911908

912909
left += icon_size + padding;
913910
}
914911
}
915912

916913
// Finish
917-
text_flush(db);
918914
}
919915

920916
int dungeon_info_is_drawn() {

ASM/c/file_icons.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -654,8 +654,7 @@ static void draw_triforce_count_fileselect(z64_disp_buf_t* db, const uint8_t* di
654654
}
655655

656656
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, bright_alpha);
657-
text_print_size("/", get_left(dataCurrent->pos) + 4, top, 8);
658-
text_flush_size(db, 8, 8, 0, 0);
657+
text_print_size(db, "/", get_left(dataCurrent->pos) + 4, top, 8, 8);
659658

660659
sprite_load(db, &item_digit_sprite, 0, 10);
661660
// Triforce goal number is always in yellow.

ASM/c/file_message.c

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ static uint8_t get_alpha(const z64_menudata_t* menu_data) {
3434
return (uint8_t)(alpha <= 0xFF ? alpha : 0xFF);
3535
}
3636

37-
static void print_msg(const char* s, int* top) {
37+
static void print_msg(z64_disp_buf_t* db, const char* s, int* top) {
3838
if (*s != '\0') {
39-
text_print_size(s, 0x80, *top, TEXT_WIDTH);
39+
text_print_size(db, s, 0x80, *top, TEXT_WIDTH, TEXT_HEIGHT);
4040
*top += TEXT_HEIGHT + 1;
4141
}
4242
else {
@@ -53,9 +53,8 @@ void draw_file_message(z64_disp_buf_t* db, const z64_menudata_t* menu_data) {
5353
int width = (icon_count * icon_size) + ((icon_count - 1) * padding);
5454
int left = (Z64_SCREEN_WIDTH + width) / 2 + padding;
5555

56-
text_print_size("World", left, 24 - TEXT_HEIGHT, TEXT_WIDTH);
57-
text_print_size(WORLD_STRING_TXT, left, 24, TEXT_WIDTH);
58-
text_flush_size(db, TEXT_WIDTH, TEXT_HEIGHT, 0, 0);
56+
text_print_size(db, "World", left, 24 - TEXT_HEIGHT, TEXT_WIDTH, TEXT_HEIGHT);
57+
text_print_size(db, WORLD_STRING_TXT, left, 24, TEXT_WIDTH, TEXT_HEIGHT);
5958
}
6059

6160
if (CFG_SHOW_SETTING_INFO) {
@@ -65,29 +64,28 @@ void draw_file_message(z64_disp_buf_t* db, const z64_menudata_t* menu_data) {
6564
int top = 0x71;
6665
int doblank = 0;
6766
if (*CFG_CUSTOM_MESSAGE_1) {
68-
print_msg(CFG_CUSTOM_MESSAGE_1, &top);
67+
print_msg(db, CFG_CUSTOM_MESSAGE_1, &top);
6968
doblank = 1;
7069
}
7170
if (*CFG_CUSTOM_MESSAGE_2) {
72-
print_msg(CFG_CUSTOM_MESSAGE_2, &top);
71+
print_msg(db, CFG_CUSTOM_MESSAGE_2, &top);
7372
doblank = 1;
7473
}
7574
if (doblank) {
76-
print_msg("", &top);
75+
print_msg(db, "", &top);
7776
}
78-
print_msg("Generated with OoTR", &top);
79-
print_msg(VERSION_STRING_TXT, &top);
80-
print_msg(TIME_STRING_TXT, &top);
81-
print_msg("", &top);
77+
print_msg(db, "Generated with OoTR", &top);
78+
print_msg(db, VERSION_STRING_TXT, &top);
79+
print_msg(db, TIME_STRING_TXT, &top);
80+
print_msg(db, "", &top);
8281

8382
if (SPOILER_AVAILABLE) {
84-
print_msg("Spoiler available", &top);
83+
print_msg(db, "Spoiler available", &top);
8584
}
8685
if (PLANDOMIZER_USED) {
87-
print_msg("Plandomizer", &top);
86+
print_msg(db, "Plandomizer", &top);
8887
}
8988

90-
text_flush_size(db, TEXT_WIDTH, TEXT_HEIGHT, 0, 0);
9189
}
9290
}
9391
}

ASM/c/file_select.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,8 @@ void manage_password(z64_disp_buf_t* db, z64_menudata_t* menu_data) {
122122
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
123123
sprite_load(db, &quest_items_sprite, 17, 1);
124124
sprite_draw(db, &quest_items_sprite, 0, left, top - 2, BUTTON_WIDTH, BUTTON_HEIGHT);
125-
text_print_size("Password locked", left + TEXT_HEIGHT + padding, top, TEXT_WIDTH);
125+
text_print_size(db, "Password locked", left + TEXT_HEIGHT + padding, top, TEXT_WIDTH, TEXT_HEIGHT);
126126
sprite_draw(db, &quest_items_sprite, 0, left + TEXT_WIDTH + 2 * padding + 15 * font_sprite.tile_w, top - 2, BUTTON_WIDTH, BUTTON_HEIGHT);
127-
text_flush_size(db, TEXT_WIDTH, TEXT_HEIGHT, 0, 0);
128127
}
129128
if (menu_data->menu_transition == SM_CONFIRM_FILE) {
130129
if (password_index < 0) {
@@ -168,8 +167,7 @@ void manage_password(z64_disp_buf_t* db, z64_menudata_t* menu_data) {
168167
gDPPipeSync(db->p++);
169168
gDPSetCombineMode(db->p++, G_CC_MODULATEIA_PRIM, G_CC_MODULATEIA_PRIM);
170169
gDPSetPrimColor(db->p++, 0, 0, 0xFF, 0xFF, 0xFF, 0xFF);
171-
text_print_size("Enter Password", left_password, top_password, TEXT_WIDTH);
172-
text_flush_size(db, TEXT_WIDTH, TEXT_HEIGHT, 0, 0);
170+
text_print_size(db, "Enter Password", left_password, top_password, TEXT_WIDTH, TEXT_HEIGHT);
173171

174172
if (is_buffer_password_clear()) {
175173
password_index = -1;

0 commit comments

Comments
 (0)