Last active
August 29, 2015 14:21
-
-
Save Yepoleb/4a0d947447cf83a9e954 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// structs taken from github.com/dkreuter/firered/ fbox.c | |
// assembler from github.com/shinyquagsire23/DisFire | |
struct fbox { | |
void *function; //0 | |
char field_4; //4 | |
char x; //5 | |
char y; //6 | |
char field_7; //7 | |
char w; //8 | |
char h; //9 | |
u16 field_A; //A | |
}; | |
struct remosub { | |
union { | |
char font_type; | |
struct { | |
u8 ft_lo : 4; | |
u8 ft_hi : 4; | |
}; | |
} | |
char field_1; | |
u16 frames_visible_counter; | |
int field_4; | |
}; | |
struct remo { | |
void *char_cursor; //0 | |
u8 rbox_id; //4 | |
u8 fbox_id; //5 | |
u8 menu_cursor_1a; //6 | |
u8 menu_cursor_1b; //7 | |
u8 menu_cursor_2a; //8 | |
u8 menu_cursor_2b; //9 | |
u8 field_A; //A | |
u8 field_B; //B | |
u8 field_C; //C | |
u8 field_D; //D | |
u8 gap_E[2]; //E | |
u32 field_10; //10 | |
remosub sub; //14 | |
u8 mode; // 1C | |
u8 text_speed; //1D | |
u8 field_1E; //1E | |
u8 field_1F; //1F | |
u8 field_20; //20 | |
u8 japanese; //21 | |
}; | |
font_render_b(remo* rm) | |
{ | |
switch (rm->mode) | |
{ | |
default: | |
return 1; | |
case 0: //remo_x1C_0 | |
if (!(*(u16*)(0x30030F0 + 0x2C) & 3)) { //loc_80057E6 | |
if (rm->sub.font_type & (1 << 4)) { | |
rm->field_1E = 0; | |
} | |
} | |
if (rm->field_1E == 0 || rm->mode == 0) { //loc_8005828 | |
if (!(*(u8*)(0x3003E50) & (1 << 2))) { //loc_800583C | |
rm->field_1E = rm->text_speed; | |
} else { | |
rm->field_1E = 1; | |
} | |
//loc_800583E+1 | |
unsigned char curc = *(rm->char_cursor); | |
rm->char_cursor++; | |
switch(curc) { | |
default: //def_80058C4 | |
break; | |
case 0xF8: //ctrl_F8 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
u8 a = sub_80063C8(rm->rbox_id, nextc2, | |
rm->menu_cursor_2a, rm->menu_cursor_2b); | |
*(0x3003DA0 + 256) = a; | |
//loc_8005C4A | |
rm->menu_cursor_2a += rm->field_A; | |
return 0; | |
case 0xF9: //ctrl_F9 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
curc = nextc2 | (1 << 9); // curc is actually 32bit in a register | |
break; //def_80058C4 | |
case 0xFA: //ctrl_FA | |
rm->mode = 3; | |
sub_80054C8(rm); | |
//loc_8005B30 | |
return 3; | |
case 0xFB: //ctrl_FB | |
rm->mode = 2; | |
sub_80054C8(rm); | |
//loc_8005B30 | |
return 3; | |
case 0xFC: //ctrl_FC | |
unsigned char nextc = *(rm->char_cursor); | |
rm->char_cursor++; | |
switch(nextc) { | |
default: //def_80058C4 | |
break; | |
case 0x1: //xFC_01 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->mode = (rm->mode & 0xF) | (nextc2 << 4); | |
//loc_80059D2 | |
sub_8002EA8(nextc2, rm->field_D & 0xF, rm->field_D >> 4); | |
//xFC_07 | |
return 2; | |
case 0x2: //xFC_02 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->field_D = (rm->field_D & ~(1 << 4)) | (nextc2 & 0xF); | |
//loc_80059D2 | |
sub_8002EA8(rm->field_C >> 4, rm->field_D & 0xF, rm->field_D << 4); | |
//xFC_07 | |
return 2; | |
case 0x3: //xFC_03 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->field_D = (rm->field_D & 0xF) | (nextc << 4); | |
//loc_80059CA | |
sub_8002EA8(nextc2, rm->field_D & 0xF, rm->field_D >> 4); | |
//xFC_07 | |
return 2; | |
case 0x4: //xFC_04 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->field_C = (rm->field_C & 0xF) | (nextc2 << 4); | |
unsigned char nextc3 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm-field_D = (rm->field_D & ~(1 << 4)) | (nextc3 & 0xF); | |
unsigned char nextc4 = *(rm->char_cursor); | |
rm->char_cursor++; | |
field_D = (rm->field_D & 0xF) | (nextc4 << 4); | |
//loc_80059CA | |
sub_8002EA8(rm->field_C >> 4, rm->field_D & 0xF, rm->field_D >> 4); | |
//xFC_07 | |
return 2; | |
case 0x5: //xFC_05 | |
//loc_8005B0A | |
rm->char_cursor++; | |
return 2; | |
case 0x6: //xFC_06 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->sub.font_type = (rm->sub.font_type & ~(1 << 4)) | (nextc2 & 0xF); | |
//loc_8005B0A | |
rm->char_cursor++; | |
return 2; | |
case 0x7: //xFC_07 | |
return 2; | |
case 0x8: //xFC_08 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->field_1E = nextc2; | |
rm->mode = 6; | |
//xFC_07 | |
return 2; | |
case 0x9: //xFC_09 | |
rm->field_C = 1; | |
if (*(u8*)(0x3003E50) & (1 << 2)) { | |
*(0x3003E50 + 2) = 0; | |
} | |
//loc_8005B30 | |
return 3; | |
case 0xA: //xFC_0A | |
//loc_8005D52 | |
rm->mode = 5; | |
return 3; | |
case 0xB: //xFC_0B | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
unsigned char nextc3 = *(rm->char_cursor); | |
rm->char_cursor++; | |
if(*(u8*)(0x203ADFA) - 2 > 1) { | |
song_play_for_text((nextc3 << 8) | nextc2); | |
} | |
//xFC_07 | |
return 2; | |
case 0xC: //xFC_0C | |
unsigned char nextc3 = *(rm->char_cursor + 1); | |
rm->char_cursor++; | |
curc = nextc3 | |
break; //def_80058C4 | |
case 0xD: //xFC_0D | |
unsigned char nextc2 = *(rm->char_cursor); | |
//loc_8005AD2 | |
rm->char_cursor++; | |
rm->menu_cursor_2a = rm->menu_cursor_1a + nextc2; | |
//xFC_07 | |
return 2; | |
case 0xE: //xFC_0E | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; //loc_8005AD6 | |
rm->menu_cursor_2b = rm->menu_cursor_1b + nextc2; | |
//xFC_07 | |
return 2; | |
case 0xF: //xFC_0F | |
u8 a = ((rm->field_D & 0xF) << 4) | (rm->field_D & 0xF) | |
rboxid_clear_pixels(rm->rbox_id, a); | |
//xFC_07 | |
return 2; | |
case 0x10: //xFC_10 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
unsigned char nextc3 = *(rm->char_cursor); | |
rm->char_cursor++; | |
audio_play((nextc3 << 8) | nextc2); | |
//xFC_07 | |
return 2; | |
case 0x11: //xFC_11 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
if (nextc2) { | |
nullsub_2(rm, nextc2); | |
// r0 = rm->menu_cursor_2a + nextc2 | |
//loc_8005C4E | |
} | |
//xFC_07 | |
return 2; | |
case 0x12: //xFC_12 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
rm->menu_cursor_2a = menu_cursor_1a + nextc2; | |
//xFC_07 | |
return 2; | |
case 0x13: //xFC_13_menu_arrow | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; | |
u8 a = rm->menu_cursor_1a - rm->menu_cursor_2a + nextc2; | |
if (a) { | |
nullsub_2(rm, a); | |
//loc_8005C4E | |
rm->menu_cursor_2a += a; | |
return 0; | |
} | |
return 2; | |
case 0x14: //xFC_14 | |
unsigned char nextc2 = *(rm->char_cursor); | |
rm->char_cursor++; //loc_8005B0A | |
rm->field_20 = nextc2; | |
return 2; | |
case 0x15: //xFC_15 | |
rm->japanese = 1; | |
return 2; | |
case 0x16: //xFC_16 | |
rm->japanese = 0; | |
return 2; | |
case 0x17: //xFC_17 | |
MPlayStop_rev01(0x3007300); | |
return 2; | |
case 0x18: //xFC_18 | |
m4aMPlayContinue(0x3007300); | |
return 2; | |
} | |
break; | |
case 0xFD: //ctrl_FD | |
//loc_8005B0A | |
rm->char_cursor++; | |
return 2; | |
case 0xFE: //ctrl_FE | |
rm->menu_cursor_2a = rm->menu_cursor_1a; | |
u8 fbox_5 = (rm->fbox_id * 16 + *(0x3003D90) + 5); | |
rm->menu_cursor_2b = fbox_5 + rm->field_B + rm->menu_cursor2b; | |
return 2; | |
} | |
switch(rm->sub.font_type & 0xF) | |
{ | |
case 0: //loc_8005B9C | |
font_render_tiny_en_jp(curc, rm->japanese); | |
break; | |
case 1: //loc_8005BAA | |
font_render_other_en_jp(curc, rm->japanese); | |
break; | |
case 2: //loc_8005BB8 | |
font_render_black_en_jp(curc, rm->japanese); | |
break; | |
case 3: //loc_8005BC6 | |
sub_8006724(curc, rm->japanese); | |
break; | |
case 4: //loc_8005BD4 | |
font_render_blue_en_jp(curc, rm->japanese); | |
break; | |
case 5: //loc_8005BE2 | |
font_render_red_en_jp(curc, rm->japanese); | |
break; | |
default: | |
break; | |
} | |
sub_8003014(rm); | |
u8 a = *(0x3003DA0 + 256) | |
if (!rm->field_20) { //loc_8005C28 | |
if (!rm->japanese) { //loc_8005C44 | |
rm->menu_cursor_2a += a | |
} else { //loc_8005C4C | |
rm->menu_cursor_2a += a + field_A; | |
} | |
return 0; | |
} | |
rm->menu_cursor_2a += a; | |
if (rm->field_20 - a < 1) { //loc_8005C50 | |
return 0; | |
} | |
nullsub_2(rm, a); | |
//loc_8005C4E | |
rm->menu_cursor_2a += a; | |
return 0; | |
} | |
rm->field_1E--; | |
if (*(u8*)(0x3003E50) & 1) { //loc_8005804 | |
if (*(u16)(0x30030F0 + 0x2E) & 3) { //loc_8005810 | |
rm->sub.font_type |= (1 << 4); | |
rm->field_1E = 0; | |
} | |
} | |
//loc_8005B30 | |
return 3; | |
case 1: //remo_x1C_1 | |
if (remo_is_it_time_to_continue(rm)) { //loc_8005C66 | |
rm->mode = 0; | |
} | |
return 3; | |
case 2: //remo_x1C_2 | |
if (remo_is_it_time_to_continue_plus_80054F8(rm)) { //loc_8005C7A | |
u8 a = ((rm->field_D & 0xF) << 4) | (rm->field_D & 0xF); | |
rboxid_clear_pixels(rm->rbox_id, a); | |
rm->menu_cursor_2a = rm->menu_cursor_1a; | |
rm->menu_cursor_2b = rm->menu_cursor_1b; | |
rm->mode = 0; | |
} | |
return 3; | |
case 3: //remo_x1C_3 | |
if (remo_is_it_time_to_continue_plus_80054F8(rm)) { //loc_8005CA6 | |
void* a = *(u32*)(0x3003D90) + fbox_id * 12; | |
rm->field_1F = *(u8)(a + 5) + rm->field_B; | |
rm->menu_cursor_2a = rm->menu_cursor_1a; | |
rm->mode = 4; | |
} | |
return 3; | |
case 4: //remo_x1C_4_scrolling | |
if (!rm->field_1F) { //loc_8005D40 | |
rm->mode = rm->field_1F; | |
return 3; | |
} | |
u8 a = *(0x300500C + 0x14); | |
u8 b = ((rm->field_D & 0xF) << 4) | (rm->field_D & 0xF); | |
if (*(u8*)(text_speeds + (a & 0b111)) >= rm->field_1F) { //loc_8005D0C | |
u8 c = *(text_speeds + (rm->rbox_id & 0b111)); | |
sub_80044A8(rm->rbox_id, rm->field_D, c, b); | |
rm->field_1F = *(text_speeds + (rm->sub.font_type & 0b111)); | |
} else { | |
sub_80044A8(rm->rbox_id, rm->field_D, rm->field_1F, b); | |
rm->field_1F = 0; | |
} | |
//remo_tileset_to_vram | |
rboxid_to_vram(rm->rbox_id, 2); | |
return 3; | |
case 5: //remo_x1C_5 | |
u8 a = sub_80723E0(); | |
if (a) { | |
rm->mode = a; | |
} | |
return 3; | |
case 6: //remo_x1C_6 | |
if (rm->field_1E) { | |
rm->field_1E--; | |
} else { | |
rm->mode = rm->field_1E; | |
} | |
return 3; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment