Implement 1bpp buffer instead of 4bpp.

This commit is contained in:
Lorenzooone 2019-09-17 20:03:02 +02:00
parent b4e613326f
commit f10f326db2
10 changed files with 357 additions and 185 deletions

View File

@ -26,15 +26,15 @@ void printTargetOfAttack(short a, short target)
byte val = *(pointer2 + target); byte val = *(pointer2 + target);
unsigned short ailmentTile = ailmentTileSetup((byte*)(0x2020CCF + (val * 0x94)), 0); unsigned short ailmentTile = ailmentTileSetup((byte*)(0x2020CCF + (val * 0x94)), 0);
if(ailmentTile >= 1) if(ailmentTile >= 1)
{ {
map_tile(ailmentTile, window->window_x + 0x13, window->window_y); map_tile(ailmentTile, window->window_x + 0x13, window->window_y);
map_tile(ailmentTile + 0x20, window->window_x + 0x13, window->window_y + 1); map_tile(ailmentTile + 0x20, window->window_x + 0x13, window->window_y + 1);
} }
else else
{ {
map_tile(0x1FF, window->window_x + 0x13, window->window_y); map_tile(0x1FF, window->window_x + 0x13, window->window_y);
map_tile(0x1FF, window->window_x + 0x13, window->window_y + 1); map_tile(0x1FF, window->window_x + 0x13, window->window_y + 1);
} }
} }
else else
{ {
@ -55,10 +55,10 @@ void printBattleMenu(byte validXs, byte validYs, byte highlighted)
{ {
if(validYs & 1) if(validYs & 1)
{ {
print_blankstr_buffer(2,1,5,(int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(2,1,5,(byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if((*drawValue) == 2) if((*drawValue) == 2)
{ {
print_blankstr_buffer(7,1,5,(int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(7,1,5,(byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
str = m12_battle_commands_str10; //Do Nothing str = m12_battle_commands_str10; //Do Nothing
} }
else if((*drawValue) == 1) else if((*drawValue) == 1)
@ -70,7 +70,7 @@ void printBattleMenu(byte validXs, byte validYs, byte highlighted)
if(validYs & 2) if(validYs & 2)
{ {
print_blankstr_buffer(2,3,5,(int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(2,3,5,(byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if((*active_window_party_member) != 2) if((*active_window_party_member) != 2)
printstr_hlight_buffer(window, m12_battle_commands_str3, 1, 1, highlighted & 2); //PSI printstr_hlight_buffer(window, m12_battle_commands_str3, 1, 1, highlighted & 2); //PSI
else else
@ -84,14 +84,14 @@ void printBattleMenu(byte validXs, byte validYs, byte highlighted)
{ {
if((*drawValue) != 2) if((*drawValue) != 2)
{ {
print_blankstr_buffer(7,1,5,(int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(7,1,5,(byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
printstr_hlight_buffer(window, m12_battle_commands_str1, 6, 0, highlighted & 4); //Goods printstr_hlight_buffer(window, m12_battle_commands_str1, 6, 0, highlighted & 4); //Goods
} }
} }
if(validYs & 2) if(validYs & 2)
{ {
print_blankstr_buffer(7,3,5,(int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(7,3,5,(byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if((*drawValue) != 2) if((*drawValue) != 2)
{ {
printstr_hlight_buffer(window, m12_battle_commands_str4, 6, 1, highlighted & 8); //Defend printstr_hlight_buffer(window, m12_battle_commands_str4, 6, 1, highlighted & 8); //Defend

View File

@ -266,7 +266,7 @@ int equippableReadInput(WINDOW* window) //Manages input in equipment-choice inne
int counter = 0; int counter = 0;
//Loads the total amount of items //Loads the total amount of items
if(possibleEquippablesCount > 6) if(possibleEquippablesCount > 6)
counter = 7; counter = 7;
else if(weird_value > 0) else if(weird_value > 0)
@ -327,7 +327,7 @@ int equippableReadInput(WINDOW* window) //Manages input in equipment-choice inne
window->counter = 0xFFFF; window->counter = 0xFFFF;
if(freeSpace[window->cursor_y] == 0xFE) if(freeSpace[window->cursor_y] == 0xFE)
{ {
m2_soundeffect(0x12D); //Do the sound only if we're changing the page. Otherwise the original code will do the appropriate sound m2_soundeffect(0x12D); //Do the sound only if we're changing the page. Otherwise the original code will do the appropriate sound
window->counter = 0; window->counter = 0;
window->cursor_x_base++; window->cursor_x_base++;
if(m2_div(window->cursor_x, 5) < window->cursor_x_base) if(m2_div(window->cursor_x, 5) < window->cursor_x_base)
@ -362,19 +362,19 @@ int equippableReadInput(WINDOW* window) //Manages input in equipment-choice inne
//Simplified inner equip routine (The original routine had a pointer to a table of valid cursor positions as a parameter) //Simplified inner equip routine (The original routine had a pointer to a table of valid cursor positions as a parameter)
int innerEquipInput(WINDOW* window) int innerEquipInput(WINDOW* window)
{ {
bool printing = !window->vwf_skip; bool printing = !window->vwf_skip;
window->vwf_skip = true; window->vwf_skip = true;
PAD_STATE state = *pad_state; PAD_STATE state = *pad_state;
PAD_STATE state_shadow = *pad_state_shadow; PAD_STATE state_shadow = *pad_state_shadow;
short previousY = window->cursor_y; short previousY = window->cursor_y;
short currentY = window->cursor_y; short currentY = window->cursor_y;
// Clear cursor tiles // Clear cursor tiles
map_tile(0x1FF, window->window_x, window->window_y + window->cursor_y * 2); map_tile(0x1FF, window->window_x, window->window_y + window->cursor_y * 2);
map_tile(0x1FF, window->window_x, window->window_y + window->cursor_y * 2 + 1); map_tile(0x1FF, window->window_x, window->window_y + window->cursor_y * 2 + 1);
if(state.up) //This has been simplified if(state.up) //This has been simplified
{ {
currentY--; currentY--;
@ -398,16 +398,16 @@ int innerEquipInput(WINDOW* window)
currentY = 0; currentY = 0;
} }
} }
//The game does stuff when pressing left or right, however for the equipment window this is not needed //The game does stuff when pressing left or right, however for the equipment window this is not needed
if(state.right) //This routine in particular did both the main overworld window and the inner equip window if(state.right) //This routine in particular did both the main overworld window and the inner equip window
{ {
} }
if(state.left) if(state.left)
{ {
} }
if(state_shadow.up || state_shadow.down) if(state_shadow.up || state_shadow.down)
{ {
@ -419,24 +419,24 @@ int innerEquipInput(WINDOW* window)
} }
else else
window->hold = false; window->hold = false;
if((state.b || state.select) && (!printing)) if((state.b || state.select) && (!printing))
{ {
window->counter = 0; window->counter = 0;
m2_soundeffect(0x12E); m2_soundeffect(0x12E);
window->vwf_skip = false; window->vwf_skip = false;
return ACTION_STEPOUT; return ACTION_STEPOUT;
} }
if((state.a || state.l) && (!printing)) if((state.a || state.l) && (!printing))
{ {
window->counter = 0xFFFF; window->counter = 0xFFFF;
m2_soundeffect(0x12D); m2_soundeffect(0x12D);
window->vwf_skip = false; window->vwf_skip = false;
return (window->cursor_y << 1) + ACTION_STEPIN; return (window->cursor_y << 1) + ACTION_STEPIN;
} }
if (window->counter != 0xFFFF) if (window->counter != 0xFFFF)
{ {
window->counter++; window->counter++;
@ -449,8 +449,8 @@ int innerEquipInput(WINDOW* window)
if (window->counter > 0x10) if (window->counter > 0x10)
window->counter = 0; window->counter = 0;
} }
return ACTION_NONE; return ACTION_NONE;
} }
void equipPrint(WINDOW* window) //Prints equipment void equipPrint(WINDOW* window) //Prints equipment
@ -467,25 +467,25 @@ void equipPrint(WINDOW* window) //Prints equipment
byte *item; byte *item;
//Clear the previous equipment //Clear the previous equipment
print_blankstr_buffer(window->window_x + 6, 1, 0xC, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(window->window_x + 6, 1, 0xC, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
print_blankstr_buffer(window->window_x + 6, 3, 0xC, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(window->window_x + 6, 3, 0xC, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
print_blankstr_buffer(window->window_x + 6, 5, 0xC, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(window->window_x + 6, 5, 0xC, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
print_blankstr_buffer(window->window_x + 6, 7, 0xC, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(window->window_x + 6, 7, 0xC, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
//Clear the previous numbers //Clear the previous numbers
print_blankstr_buffer(8, 0xB, 0x8, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(8, 0xB, 0x8, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
print_blankstr_buffer(8, 0xD, 0x8, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(8, 0xD, 0x8, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
//Reprint the ":"s //Reprint the ":"s
print_character_with_callback(decode_character(0x6A), ((window->window_x + 6) << 3), (0x1 << 3), 0, 0xF, (int*)(OVERWORLD_BUFFER - 0x2000), &get_tile_number_with_offset, *tilemap_pointer, 32, 0xC); print_character_with_callback_1bpp_buffer(decode_character(0x6A), ((window->window_x + 6) << 3), (0x1 << 3), (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)), &get_tile_number_with_offset, 0, *tilemap_pointer, 32, 0xC);
print_character_with_callback(decode_character(0x6A), ((window->window_x + 6) << 3), (0x3 << 3), 0, 0xF, (int*)(OVERWORLD_BUFFER - 0x2000), &get_tile_number_with_offset, *tilemap_pointer, 32, 0xC); print_character_with_callback_1bpp_buffer(decode_character(0x6A), ((window->window_x + 6) << 3), (0x3 << 3), (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)), &get_tile_number_with_offset, 0, *tilemap_pointer, 32, 0xC);
print_character_with_callback(decode_character(0x6A), ((window->window_x + 6) << 3), (0x5 << 3), 0, 0xF, (int*)(OVERWORLD_BUFFER - 0x2000), &get_tile_number_with_offset, *tilemap_pointer, 32, 0xC); print_character_with_callback_1bpp_buffer(decode_character(0x6A), ((window->window_x + 6) << 3), (0x5 << 3), (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)), &get_tile_number_with_offset, 0, *tilemap_pointer, 32, 0xC);
print_character_with_callback(decode_character(0x6A), ((window->window_x + 6) << 3), (0x7 << 3), 0, 0xF, (int*)(OVERWORLD_BUFFER - 0x2000), &get_tile_number_with_offset, *tilemap_pointer, 32, 0xC); print_character_with_callback_1bpp_buffer(decode_character(0x6A), ((window->window_x + 6) << 3), (0x7 << 3), (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)), &get_tile_number_with_offset, 0, *tilemap_pointer, 32, 0xC);
//Print the equipment //Print the equipment
if(character_data->equipment[0] == 0) //Weapon if(character_data->equipment[0] == 0) //Weapon
print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x1) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x1) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
else else
{ {
item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[0] - 1]); item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[0] - 1]);
@ -494,7 +494,7 @@ void equipPrint(WINDOW* window) //Prints equipment
} }
if(character_data->equipment[1] == 0) //Body if(character_data->equipment[1] == 0) //Body
print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x3) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x3) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
else else
{ {
item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[1] - 1]); item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[1] - 1]);
@ -503,7 +503,7 @@ void equipPrint(WINDOW* window) //Prints equipment
} }
if(character_data->equipment[2] == 0) //Arms if(character_data->equipment[2] == 0) //Arms
print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x5) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x5) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
else else
{ {
item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[2] - 1]); item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[2] - 1]);
@ -512,7 +512,7 @@ void equipPrint(WINDOW* window) //Prints equipment
} }
if(character_data->equipment[3] == 0) //Other if(character_data->equipment[3] == 0) //Other
print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x7) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(nothing, (((window->window_x + 7)) << 3) - 2, (0x7) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
else else
{ {
item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[3] - 1]); item = m2_strlookup((int*)0x8B1AF94, (byte*)0x8B1A694, character_data->goods[character_data->equipment[3] - 1]);
@ -524,24 +524,24 @@ void equipPrint(WINDOW* window) //Prints equipment
//Prints the numbers in the window in a formatted way //Prints the numbers in the window in a formatted way
void printNumberEquip(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight) void printNumberEquip(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight)
{ {
while((*str) == 0x50) while((*str) == 0x50)
{ {
x += 6; x += 6;
str++; str++;
} }
printstr_hlight_pixels_buffer(window, str, x, y, highlight); printstr_hlight_pixels_buffer(window, str, x, y, highlight);
} }
//Prints Offense: and Defense: //Prints Offense: and Defense:
void printEquipWindowNumberText(WINDOW* window) void printEquipWindowNumberText(WINDOW* window)
{ {
handle_first_window_buffer(window, (int*)(OVERWORLD_BUFFER - ((*tile_offset) * 32))); handle_first_window_buffer(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
printstr_hlight_pixels_buffer(window, window->text_start, 0, 3, false); printstr_hlight_pixels_buffer(window, window->text_start, 0, 3, false);
} }
//Prints the arrow for the numbers in the Offense/Defense menu //Prints the arrow for the numbers in the Offense/Defense menu
void printEquipNumbersArrow(WINDOW* window) void printEquipNumbersArrow(WINDOW* window)
{ {
printTinyArrow((window->window_x + 9) << 3, (window->window_y + 0) << 3); printTinyArrow((window->window_x + 9) << 3, (window->window_y + 0) << 3);
printTinyArrow((window->window_x + 9) << 3, (window->window_y + 2) << 3); printTinyArrow((window->window_x + 9) << 3, (window->window_y + 2) << 3);
} }

View File

@ -135,7 +135,7 @@ void psiPrint_buffer(byte value, WINDOW* window, bool printPSILine, PSIPrintInfo
if(PSIID == 1) if(PSIID == 1)
{ {
str = (byte*)(m2_ness_name + (7 * 4) + (8 * 2)); //Go to Rockin's name str = (byte*)(m2_ness_name + (7 * 4) + (8 * 2)); //Go to Rockin's name
print_string_in_buffer(str, 0x71, ((printInfo->YPrinting) + window->window_y) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(str, 0x71, ((printInfo->YPrinting) + window->window_y) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
} }
} }
@ -455,7 +455,7 @@ int PSITargetInput(WINDOW* window)
if(!window->vwf_skip) if(!window->vwf_skip)
{ {
clear_window_buffer(getWindow(9), (int*)(OVERWORLD_BUFFER - 0x2000)); clear_window_buffer(getWindow(9), (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
psiTargetWindow_buffer(target); psiTargetWindow_buffer(target);
window->vwf_skip = true; window->vwf_skip = true;
} }

View File

@ -9,17 +9,17 @@ void printNumberOfStatus(int maxLength, int value, int blankX, int y, int strX,
int end = setNumber_getLength(value, str, maxLength); int end = setNumber_getLength(value, str, maxLength);
str[end] = 0; str[end] = 0;
str[end + 1] = 0xFF; str[end + 1] = 0xFF;
print_blankstr_buffer(blankX, y, width, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(blankX, y, width, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
int x = (strX - (end * 6)); int x = (strX - (end * 6));
print_string_in_buffer(str, x, y << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(str, x, y << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
} }
void printStatusSymbolArrangement(unsigned short symbolTile, WINDOW* window) void printStatusSymbolArrangement(unsigned short symbolTile, WINDOW* window)
{ {
map_tile(symbolTile, window->window_x + 0xA, window->window_y + 2); map_tile(symbolTile, window->window_x + 0xA, window->window_y + 2);
if(symbolTile == 0x1FF) if(symbolTile == 0x1FF)
symbolTile -= 0x20; symbolTile -= 0x20;
map_tile(symbolTile + 0x20, window->window_x + 0xA, window->window_y + 3); map_tile(symbolTile + 0x20, window->window_x + 0xA, window->window_y + 3);
} }
void printStatusString(WINDOW* window, int value) void printStatusString(WINDOW* window, int value)
@ -57,7 +57,7 @@ int statusNumbersPrint(WINDOW* window, bool doNotPrint)
printNumberOfStatus(7, experienceLevelUp - character_data->experience, 2, 0xD, 0x3D, 6); printNumberOfStatus(7, experienceLevelUp - character_data->experience, 2, 0xD, 0x3D, 6);
} }
else else
print_blankstr_buffer(2, 0xD, 6, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(2, 0xD, 6, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
printNumberOfStatus(3, character_data->offense_effective, 0x19, 0x1, 0xE1, 4); printNumberOfStatus(3, character_data->offense_effective, 0x19, 0x1, 0xE1, 4);
printNumberOfStatus(3, character_data->defense_effective, 0x19, 0x3, 0xE1, 4); printNumberOfStatus(3, character_data->defense_effective, 0x19, 0x3, 0xE1, 4);
printNumberOfStatus(3, character_data->speed_effective, 0x19, 0x5, 0xE1, 4); printNumberOfStatus(3, character_data->speed_effective, 0x19, 0x5, 0xE1, 4);
@ -65,13 +65,13 @@ int statusNumbersPrint(WINDOW* window, bool doNotPrint)
printNumberOfStatus(3, character_data->vitality_effective, 0x19, 0x9, 0xE1, 4); printNumberOfStatus(3, character_data->vitality_effective, 0x19, 0x9, 0xE1, 4);
printNumberOfStatus(3, character_data->iq_effective, 0x19, 0xB, 0xE1, 4); printNumberOfStatus(3, character_data->iq_effective, 0x19, 0xB, 0xE1, 4);
printNumberOfStatus(3, character_data->luck_effective, 0x19, 0xD, 0xE1, 4); printNumberOfStatus(3, character_data->luck_effective, 0x19, 0xD, 0xE1, 4);
print_blankstr_buffer(5, 0xF, 0x14, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(5, 0xF, 0x14, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if((*active_window_party_member) != JEFF) if((*active_window_party_member) != JEFF)
{ {
byte *str = m2_strlookup((int*)0x8B17EE4, (byte*)0x8B17424, 0x13); byte *str = m2_strlookup((int*)0x8B17EE4, (byte*)0x8B17424, 0x13);
print_string_in_buffer(str, 0x2C, (0xF) << 3, (int*)(OVERWORLD_BUFFER - 0x2000)); print_string_in_buffer(str, 0x2C, (0xF) << 3, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
} }
print_blankstr_buffer(1, 0x3, 0xA, (int*)(OVERWORLD_BUFFER - 0x2000)); print_blankstr_buffer(1, 0x3, 0xA, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
unsigned short symbolTile = ailmentTileSetup(&(character_data->ailment), 0); unsigned short symbolTile = ailmentTileSetup(&(character_data->ailment), 0);
if(symbolTile == 0) if(symbolTile == 0)
{ {
@ -223,18 +223,18 @@ int statusWindowNumbers(WINDOW* window, bool doNotPrint)
int statusWindowText(WINDOW* window) int statusWindowText(WINDOW* window)
{ {
if(window->redraw) if(window->redraw)
buffer_drawwindow(window, (int*)(OVERWORLD_BUFFER - 0x2000)); buffer_drawwindow(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if(window->loaded_code != 0 && ((*script_readability) == 0)) if(window->loaded_code != 0 && ((*script_readability) == 0))
{ {
window->delay = 0; window->delay = 0;
while(true) while(true)
{ {
while(window->text_y >= window->window_height || window->window_y + window->text_y > 0x1F) while(window->text_y >= window->window_height || window->window_y + window->text_y > 0x1F)
properScroll(window, (int*)(OVERWORLD_BUFFER - 0x2000)); properScroll(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
byte *str = window->text_start + window->text_offset; byte *str = window->text_start + window->text_offset;
if((*(str + 1)) == 0xFF) if((*(str + 1)) == 0xFF)
{ {
int returnedLength = customcodes_parse_generic(*str, str, window, (int*)(OVERWORLD_BUFFER - 0x2000)); int returnedLength = customcodes_parse_generic(*str, str, window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
if(returnedLength != 0) if(returnedLength != 0)
{ {
if(returnedLength < 0) if(returnedLength < 0)
@ -265,7 +265,7 @@ int statusWindowText(WINDOW* window)
window->text_y += 2; window->text_y += 2;
window->text_x = 0; window->text_x = 0;
} }
weld_entry_custom_buffer(window, str, 0, 0xF, (int*)(OVERWORLD_BUFFER - 0x2000)); weld_entry_custom_buffer(window, str, 0, 0xF, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
window->text_offset++; window->text_offset++;
} }
} }

View File

@ -24,25 +24,39 @@ int get_tile_number(int x, int y)
return m2_coord_table[x + ((y >> 1) * 28)] + (y & 1) * 32; return m2_coord_table[x + ((y >> 1) * 28)] + (y & 1) * 32;
} }
int get_tile_number_buffer(int x, int y)
{
x--;
y--;
int totalLenght = x + ((y >> 1) * 28);
int addedValue = (totalLenght >> 5) << 6;
return (totalLenght & 0x1F) + addedValue + (y & 1) * 32;
}
int get_tile_number_with_offset(int x, int y) int get_tile_number_with_offset(int x, int y)
{ {
return get_tile_number(x, y) + *tile_offset; return get_tile_number(x, y) + *tile_offset;
} }
int get_tile_number_with_offset_buffer(int x, int y)
{
return get_tile_number_buffer(x, y) + *tile_offset;
}
int get_tile_number_grid(int x, int y) int get_tile_number_grid(int x, int y)
{ {
return x + (y * 32); return x + (y * 32);
} }
int expand_bit_depth(byte row, int foreground) int expand_bit_depth(byte row, byte foreground)
{ {
foreground &= 0xF; foreground &= 0xF;
return m2_bits_to_nybbles[row + (foreground * 256)]; return m2_bits_to_nybbles[row + (foreground * 256)];
} }
byte reduce_bit_depth(int row, int foreground) //The foregroundRow is given as a parameter in order to make this faster
byte reduce_bit_depth(int row, int foregroundRow)
{ {
int foregroundRow = row * 0x11111111;
row ^= foregroundRow; row ^= foregroundRow;
int lower = m2_nybbles_to_bits[row & 0xFFFF]; int lower = m2_nybbles_to_bits[row & 0xFFFF];
@ -352,6 +366,105 @@ byte print_character_with_callback(byte chr, int x, int y, int font, int foregro
return virtualWidth; return virtualWidth;
} }
byte print_character_with_callback_1bpp_buffer(byte chr, int x, int y, byte *dest, int (*getTileCallback)(int, int), int font,
unsigned short *tilemapPtr, int tilemapWidth, byte doubleTileHeight)
{
int tileWidth = m2_font_widths[font];
int tileHeight = m2_font_heights[font];
int widths = m2_widths_table[font][chr];
int paletteMask = *palette_mask;
byte *glyphRows = &m2_font_table[font][chr * tileWidth * tileHeight * 8];
int virtualWidth = widths & 0xFF;
int tileX = x >> 3;
int tileY = y >> 3;
int offsetY = y & 7;
int offsetX = x & 7;
if((tileY & 1) == 0 && offsetY >= doubleTileHeight - 0x8)
{
tileY++;
offsetY -= (doubleTileHeight - 0x8);
}
int nextY = offsetY;
for (int dTileY = 0; dTileY < tileHeight; dTileY++) // dest tile Y
{
int dTileX = 0;
int renderedWidth = widths >> 8;
offsetY = nextY;
bool changed = false;
while (renderedWidth > 0)
{
// Glue the leftmost part of the glyph onto the rightmost part of the canvas
int tileIndex = get_tile_number_with_offset_buffer(tileX + dTileX, tileY + dTileY);
int tileIndexRight = get_tile_number_with_offset_buffer(tileX + dTileX + 1, tileY + dTileY);
bool availableSwap = (dTileY != (tileHeight - 1));
bool usedRight = false;
int realTileIndex = tileIndex;
int realTileIndexRight = tileIndexRight;
bool useful = false; //Maybe we go over the maximum tile height, let's make sure the extra tile is properly set IF it's useful
int tmpTileY = dTileY;
int limit = ((tmpTileY + tileY) & 1) == 0 ? doubleTileHeight - 8 - 1: 7;
int sumRemoved = 0;
for (int row = 0; row < 8; row++)
{
unsigned short canvasRow = dest[(realTileIndex * 8) + ((row + offsetY - sumRemoved) & 7)] + (dest[(realTileIndexRight * 8) + ((row + offsetY - sumRemoved) & 7)] << 8);
unsigned short glyphRow = glyphRows[row + (dTileY * 8 * tileWidth) + (dTileX * 8)] << offsetX;
unsigned short tmpCanvasRow = canvasRow;
canvasRow |= glyphRow;
if((canvasRow >> 8) != (tmpCanvasRow >> 8))
usedRight = true;
if(!availableSwap && ((row + offsetY) >> 3) == 1 && canvasRow != tmpCanvasRow) //This changed the canvas, then it's useful... IF it's the extra vertical tile
useful = true;
dest[(realTileIndex * 8) + ((row + offsetY - sumRemoved) & 7)] = canvasRow;
dest[(realTileIndexRight * 8) + ((row + offsetY - sumRemoved) & 7)] = canvasRow >> 8;
if((row + offsetY - sumRemoved) == limit)
{
tmpTileY++;
realTileIndex = get_tile_number_with_offset_buffer(tileX + dTileX, tileY + tmpTileY);
realTileIndexRight = get_tile_number_with_offset_buffer(tileX + 1 + dTileX, tileY + tmpTileY);
sumRemoved += limit + 1;
if(!changed)
{
nextY = (nextY + limit + 1) & 7;
changed = true;
}
limit = ((tmpTileY + tileY) & 1) == 0 ? doubleTileHeight - 8 - 1: 7;
}
}
if (tilemapPtr != NULL)
{
tilemapPtr[tileX + dTileX + ((tileY + dTileY) * tilemapWidth)] = paletteMask | getTileCallback(tileX + dTileX, tileY + dTileY);
if(usedRight)
tilemapPtr[tileX + dTileX + 1 + ((tileY + dTileY) * tilemapWidth)] = paletteMask | getTileCallback(tileX + dTileX + 1, tileY + dTileY);
if(useful)
{
tilemapPtr[tileX + dTileX + ((tileY + tmpTileY) * tilemapWidth)] = paletteMask | getTileCallback(tileX + dTileX, tileY + tmpTileY);
if(usedRight)
tilemapPtr[tileX + dTileX + 1 + ((tileY + tmpTileY) * tilemapWidth)] = paletteMask | getTileCallback(tileX + dTileX + 1, tileY + tmpTileY);
}
}
renderedWidth -= 8;
dTileX++;
}
}
return virtualWidth;
}
int print_window_header_string(int *dest, byte *str, int x, int y) int print_window_header_string(int *dest, byte *str, int x, int y)
{ {
int pixelX = x & 7; int pixelX = x & 7;
@ -895,7 +1008,7 @@ int get_pointer_jump_back(byte *character)
return (str - character - 2); return (str - character - 2);
} }
void print_letter_in_buffer(WINDOW* window, byte* character, int* dest) void print_letter_in_buffer(WINDOW* window, byte* character, byte* dest)
{ {
m2_cstm_last_printed[0] = (*character); m2_cstm_last_printed[0] = (*character);
weld_entry_custom_buffer(window, character, 0, 0xF, dest); weld_entry_custom_buffer(window, character, 0, 0xF, dest);
@ -927,13 +1040,13 @@ int print_window_with_buffer(WINDOW* window)
while(window->loaded_code !=0) while(window->loaded_code !=0)
{ {
window->delay = delay; window->delay = delay;
print_character_with_codes(window, (int*)(OVERWORLD_BUFFER - ((*tile_offset) * 32))); print_character_with_codes(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
} }
} }
return 0; return 0;
} }
void scrolltext_buffer(WINDOW* window, int* dest) void scrolltext_buffer(WINDOW* window, byte* dest)
{ {
unsigned short empty_tile = ((*tile_offset) + 0x1FF) | (*palette_mask); unsigned short empty_tile = ((*tile_offset) + 0x1FF) | (*palette_mask);
unsigned short *arrangementBase = (*tilemap_pointer); unsigned short *arrangementBase = (*tilemap_pointer);
@ -946,7 +1059,7 @@ void scrolltext_buffer(WINDOW* window, int* dest)
for(int x = 0; x < window->window_width && x + window->window_x <= 0x1F; x++) for(int x = 0; x < window->window_width && x + window->window_x <= 0x1F; x++)
{ {
arrangementBase[start + x + (y * 32)] = empty_tile; arrangementBase[start + x + (y * 32)] = empty_tile;
clear_tile_buffer(x + window->window_x, y + window->window_y, 0x44444444, dest); clear_tile_buffer(x + window->window_x, y + window->window_y, dest);
} }
} }
} }
@ -980,11 +1093,11 @@ void scrolltext_buffer(WINDOW* window, int* dest)
for(int x = 0; x < window->window_width && x + window->window_x <= 0x1F; x++) for(int x = 0; x < window->window_width && x + window->window_x <= 0x1F; x++)
{ {
arrangementBase[start + x + (y * 32)] = empty_tile; arrangementBase[start + x + (y * 32)] = empty_tile;
clear_tile_buffer(x + window->window_x, y + window->window_y, 0x44444444, dest); clear_tile_buffer(x + window->window_x, y + window->window_y, dest);
} }
} }
void properScroll(WINDOW* window, int* dest) void properScroll(WINDOW* window, byte* dest)
{ {
scrolltext_buffer(window, dest); scrolltext_buffer(window, dest);
window->text_y = window->text_y - 2; window->text_y = window->text_y - 2;
@ -1030,7 +1143,7 @@ int jumpToOffset(byte* character)
return returnOffset; return returnOffset;
} }
byte print_character_with_codes(WINDOW* window, int* dest) byte print_character_with_codes(WINDOW* window, byte* dest)
{ {
int delay = window->delay--; int delay = window->delay--;
if(delay > 0) if(delay > 0)
@ -1164,7 +1277,7 @@ byte print_character_with_codes(WINDOW* window, int* dest)
} }
else else
{ {
handle_first_window_buffer(window, (int*)(OVERWORLD_BUFFER - ((*tile_offset) * 32))); handle_first_window_buffer(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
window->delay = window->delay_between_prints; window->delay = window->delay_between_prints;
if(x > 0x1F) if(x > 0x1F)
{ {
@ -1181,7 +1294,7 @@ byte print_character_with_codes(WINDOW* window, int* dest)
return 0; return 0;
} }
byte print_character_formatted_buffer(byte chr, int x, int y, int font, int foreground, int *dest) byte print_character_formatted_buffer(byte chr, int x, int y, int font, int foreground, byte *dest)
{ {
// 0x64 to 0x6C (inclusive) is YOU WON // 0x64 to 0x6C (inclusive) is YOU WON
if ((chr >= YOUWON_START) && (chr <= YOUWON_END)) if ((chr >= YOUWON_START) && (chr <= YOUWON_END))
@ -1197,10 +1310,10 @@ byte print_character_formatted_buffer(byte chr, int x, int y, int font, int fore
return 9; return 9;
} }
return print_character_with_callback(chr, x, y, font, foreground, dest, &get_tile_number_with_offset, *tilemap_pointer, 32, 0xC); return print_character_with_callback_1bpp_buffer(chr, x, y, dest, &get_tile_number_with_offset, font, *tilemap_pointer, 32, 0xC);
} }
void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foreground, int* dest) void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foreground, byte* dest)
{ {
int chr = decode_character(*str); int chr = decode_character(*str);
@ -1213,7 +1326,7 @@ void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foregroun
window->text_x = (x >> 3) - window->window_x; window->text_x = (x >> 3) - window->window_x;
} }
void handle_first_window_buffer(WINDOW* window, int* dest) void handle_first_window_buffer(WINDOW* window, byte* dest)
{ {
if (*first_window_flag == 1) if (*first_window_flag == 1)
{ {
@ -1227,26 +1340,26 @@ void handle_first_window_buffer(WINDOW* window, int* dest)
} }
} }
void clear_window_buffer(WINDOW *window, int* dest) void clear_window_buffer(WINDOW *window, byte* dest)
{ {
clear_rect_buffer(window->window_x, window->window_y, clear_rect_buffer(window->window_x, window->window_y,
window->window_width, window->window_height, window->window_width, window->window_height,
WINDOW_AREA_BG, dest); dest);
} }
// x,y: tile coordinates // x,y: tile coordinates
void clear_rect_buffer(int x, int y, int width, int height, int pixels, int* dest) void clear_rect_buffer(int x, int y, int width, int height, byte* dest)
{ {
for (int tileY = 0; tileY < height; tileY++) for (int tileY = 0; tileY < height; tileY++)
{ {
for (int tileX = 0; tileX < width; tileX++) for (int tileX = 0; tileX < width; tileX++)
{ {
clear_tile_buffer(x + tileX, y + tileY, pixels, dest); clear_tile_buffer(x + tileX, y + tileY, dest);
} }
} }
} }
int print_string_in_buffer(byte *str, int x, int y, int *dest) int print_string_in_buffer(byte *str, int x, int y, byte *dest)
{ {
if (str == NULL) if (str == NULL)
return 0; return 0;
@ -1257,19 +1370,19 @@ int print_string_in_buffer(byte *str, int x, int y, int *dest)
while (str[1] != 0xFF || str[0] != 0) while (str[1] != 0xFF || str[0] != 0)
{ {
if(str[1] == 0xFF && str[0] == 1) if(str[1] == 0xFF && str[0] == 1)
{ {
x = initial_x; x = initial_x;
str += 2; str += 2;
y+= 0x10; y+= 0x10;
} }
else if(str[1] != 0xFF) else if(str[1] != 0xFF)
{ {
x += print_character_formatted_buffer(decode_character(*str++), x, y, 0, 0xF, dest); x += print_character_formatted_buffer(decode_character(*str++), x, y, 0, 0xF, dest);
charCount++; charCount++;
} }
else else
break; break;
} }
int totalWidth = x - initial_x; int totalWidth = x - initial_x;
@ -1301,7 +1414,7 @@ int printstr_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short
while(output != 1) while(output != 1)
{ {
window->delay = 0; window->delay = 0;
output = print_character_with_codes(window, (int*)(OVERWORLD_BUFFER - ((*tile_offset) * 32))); output = print_character_with_codes(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
} }
int retValue = (window->text_x << 3) + window->pixel_x; int retValue = (window->text_x << 3) + window->pixel_x;
window->text_start = tmpTextStart; window->text_start = tmpTextStart;
@ -1329,7 +1442,7 @@ unsigned short printstr_hlight_pixels_buffer(WINDOW* window, byte* str, unsigned
palette_mask_highlight += 0x1000; palette_mask_highlight += 0x1000;
(*palette_mask) = palette_mask_highlight; (*palette_mask) = palette_mask_highlight;
unsigned short printed_Characters = print_string_in_buffer(str, printX, printY, (int*)(OVERWORLD_BUFFER - ((*tile_offset) * 32))); unsigned short printed_Characters = print_string_in_buffer(str, printX, printY, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
(*palette_mask) = tmpPaletteMsk; (*palette_mask) = tmpPaletteMsk;
@ -1357,29 +1470,31 @@ int initWindow_buffer(WINDOW* window, byte* text_start, unsigned short delay_bet
window->flags_unknown1 |= 1; window->flags_unknown1 |= 1;
window->redraw = true; window->redraw = true;
if(text_start == NULL) if(text_start == NULL)
buffer_drawwindow(window, (int*)(OVERWORLD_BUFFER - 0x2000)); buffer_drawwindow(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
return 0; return 0;
} }
void clearWindowTiles_buffer(WINDOW* window) void clearWindowTiles_buffer(WINDOW* window)
{ {
clear_window_buffer(window, (int*)(OVERWORLD_BUFFER - 0x2000)); clear_window_buffer(window, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8)));
window->text_x = 0; window->text_x = 0;
window->text_y = 0; window->text_y = 0;
} }
// x,y: tile coordinates // x,y: tile coordinates
void clear_tile_buffer(int x, int y, int pixels, int* dest) void clear_tile_buffer(int x, int y, byte* dest)
{ {
// Clear pixels // Clear pixels
int tileIndex = get_tile_number(x, y) + *tile_offset; int tileIndex = get_tile_number_buffer(x, y) + *tile_offset;
cpufastset(&pixels, &dest[tileIndex * 8], CPUFASTSET_FILL | 8); int *destTileInt = (int*)&dest[(tileIndex) * 8];
destTileInt[0] = 0;
destTileInt[1] = 0;
// Reset the tilemap (e.g. get rid of equip or SMAAAASH!! tiles) // Reset the tilemap (e.g. get rid of equip or SMAAAASH!! tiles)
(*tilemap_pointer)[x + (y * 32)] = tileIndex | *palette_mask; (*tilemap_pointer)[x + (y * 32)] = (get_tile_number(x, y) + (*tile_offset)) | *palette_mask;
} }
int buffer_reset_window(WINDOW* window, bool skip_redraw, int* dest) int buffer_reset_window(WINDOW* window, bool skip_redraw, byte* dest)
{ {
window->delay = 0; window->delay = 0;
byte code = window->loaded_code - 0xD; byte code = window->loaded_code - 0xD;
@ -1395,9 +1510,12 @@ int buffer_reset_window(WINDOW* window, bool skip_redraw, int* dest)
return 0; return 0;
} }
int buffer_drawwindow(WINDOW* window, int* dest) int buffer_drawwindow(WINDOW* window, byte* dest)
{ {
clear_window_buffer(window, dest); if((int*)dest == vram)
clear_window(window);
else
clear_window_buffer(window, dest);
unsigned short empty_tile = (0x1FF + (*tile_offset)) | (*palette_mask); unsigned short empty_tile = (0x1FF + (*tile_offset)) | (*palette_mask);
int baseOfWindow = ((window->window_y - 1) * 32) + window->window_x - 1; int baseOfWindow = ((window->window_y - 1) * 32) + window->window_x - 1;
unsigned short *arrangementBase = (*tilemap_pointer); unsigned short *arrangementBase = (*tilemap_pointer);
@ -1555,7 +1673,7 @@ unsigned short ailmentTileSetup(byte *ailmentBase, unsigned short defaultVal)
void printTinyArrow(int x, int y) void printTinyArrow(int x, int y)
{ {
print_special_character_buffer(0x9F, x, y); print_special_character_buffer(0x9F, x, y);
} }
void printCashWindow() void printCashWindow()
@ -1570,21 +1688,66 @@ void printCashWindow()
} }
// x, y, width: tile coordinates // x, y, width: tile coordinates
void print_blankstr_buffer(int x, int y, int width, int *dest) void print_blankstr_buffer(int x, int y, int width, byte *dest)
{ {
clear_rect_buffer(x, y, width, 2, WINDOW_AREA_BG, dest); clear_rect_buffer(x, y, width, 2, dest);
}
void load_pixels_overworld_buffer()
{
byte* buffer = (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8));
for(int y = 0; y < 0x10; y++)
for(int x = 0; x < 0x1C; x++)
{
int tile_buffer = get_tile_number_with_offset_buffer(x + 1, y + 1);
int tile = get_tile_number_with_offset(x + 1, y + 1);
int foregroundRow = 0xFFFFFFFF;
buffer[(tile_buffer * 8) + 0] = reduce_bit_depth(vram[(tile * 8) + 0], foregroundRow);
buffer[(tile_buffer * 8) + 1] = reduce_bit_depth(vram[(tile * 8) + 1], foregroundRow);
buffer[(tile_buffer * 8) + 2] = reduce_bit_depth(vram[(tile * 8) + 2], foregroundRow);
buffer[(tile_buffer * 8) + 3] = reduce_bit_depth(vram[(tile * 8) + 3], foregroundRow);
buffer[(tile_buffer * 8) + 4] = reduce_bit_depth(vram[(tile * 8) + 4], foregroundRow);
buffer[(tile_buffer * 8) + 5] = reduce_bit_depth(vram[(tile * 8) + 5], foregroundRow);
buffer[(tile_buffer * 8) + 6] = reduce_bit_depth(vram[(tile * 8) + 6], foregroundRow);
buffer[(tile_buffer * 8) + 7] = reduce_bit_depth(vram[(tile * 8) + 7], foregroundRow);
}
}
void store_pixels_overworld_buffer(int totalYs)
{
byte* buffer = (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * 8));
for(int y = 0; y < totalYs; y++)
for(int x = 0; x < 0x1C; x++)
{
int tile = get_tile_number_with_offset(x + 1, y + 1);
int tile_buffer = get_tile_number_with_offset_buffer(x + 1, y + 1);
int* bufferValues = (int*)(&buffer[(tile_buffer * 8)]);
unsigned int first_half = bufferValues[0];
unsigned int second_half = bufferValues[1];
vram[(tile * 8) + 0] = m2_bits_to_nybbles_fast[(first_half >> 0) & 0xFF];
vram[(tile * 8) + 1] = m2_bits_to_nybbles_fast[(first_half >> 8) & 0xFF];
vram[(tile * 8) + 2] = m2_bits_to_nybbles_fast[(first_half >> 0x10) & 0xFF];
vram[(tile * 8) + 3] = m2_bits_to_nybbles_fast[(first_half >> 0x18) & 0xFF];
vram[(tile * 8) + 4] = m2_bits_to_nybbles_fast[(second_half >> 0) & 0xFF];
vram[(tile * 8) + 5] = m2_bits_to_nybbles_fast[(second_half >> 8) & 0xFF];
vram[(tile * 8) + 6] = m2_bits_to_nybbles_fast[(second_half >> 0x10) & 0xFF];
vram[(tile * 8) + 7] = m2_bits_to_nybbles_fast[(second_half >> 0x18) & 0xFF];
}
} }
// x,y: tile coordinates // x,y: tile coordinates
void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, int *dest) void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, byte *dest)
{ {
int sourceTileIndex = get_tile_number(xSource, ySource) + *tile_offset; int sourceTileIndex = get_tile_number_buffer(xSource, ySource) + *tile_offset;
int destTileIndex = get_tile_number(xDest, yDest) + *tile_offset; int destTileIndex = get_tile_number_buffer(xDest, yDest) + *tile_offset;
cpufastset(&dest[sourceTileIndex * 8], &dest[destTileIndex * 8], 8); int* sourceTile = (int*)&dest[sourceTileIndex * 8];
int* destTile = (int*)&dest[destTileIndex * 8];
destTile[0] = sourceTile[0];
destTile[1] = sourceTile[1];
} }
// x,y: tile coordinates // x,y: tile coordinates
void copy_tile_up_buffer(int x, int y, int *dest) void copy_tile_up_buffer(int x, int y, byte *dest)
{ {
copy_tile_buffer(x, y, x, y - 2, dest); copy_tile_buffer(x, y, x, y - 2, dest);
} }

View File

@ -21,7 +21,7 @@
#define WINDOW_HEADER_Y 0x11 #define WINDOW_HEADER_Y 0x11
#define WINDOW_HEADER_TILE (WINDOW_HEADER_X + (WINDOW_HEADER_Y * 32)) #define WINDOW_HEADER_TILE (WINDOW_HEADER_X + (WINDOW_HEADER_Y * 32))
#define OVERWORLD_BUFFER 0x200C000 #define OVERWORLD_BUFFER 0x200F200
#define CUSTOMCC_SET_X 0x5F #define CUSTOMCC_SET_X 0x5F
#define CUSTOMCC_ADD_X 0x60 #define CUSTOMCC_ADD_X 0x60
@ -30,11 +30,13 @@ byte decode_character(byte chr);
byte encode_ascii(char chr); byte encode_ascii(char chr);
int get_tile_number(int x, int y); int get_tile_number(int x, int y);
int get_tile_number_with_offset(int x, int y); int get_tile_number_with_offset(int x, int y);
int get_tile_number_buffer(int x, int y);
int get_tile_number_with_offset_buffer(int x, int y);
int ascii_strlen(char *str); int ascii_strlen(char *str);
int wrapper_count_pixels_to_tiles(byte *str, int length); int wrapper_count_pixels_to_tiles(byte *str, int length);
int count_pixels_to_tiles(byte *str, int length, int startingPos); int count_pixels_to_tiles(byte *str, int length, int startingPos);
int expand_bit_depth(byte row, int foreground); int expand_bit_depth(byte row, byte foreground);
byte reduce_bit_depth(int row, int foreground); byte reduce_bit_depth(int row, int foregroundRow);
byte print_character(byte chr, int x, int y); byte print_character(byte chr, int x, int y);
byte print_character_formatted(byte chr, int x, int y, int font, int foreground); byte print_character_formatted(byte chr, int x, int y, int font, int foreground);
byte print_character_to_window(byte chr, WINDOW* window); byte print_character_to_window(byte chr, WINDOW* window);
@ -43,6 +45,8 @@ void map_special_character(unsigned short tile, int x, int y);
void map_tile(unsigned short tile, int x, int y); void map_tile(unsigned short tile, int x, int y);
byte print_character_with_callback(byte chr, int x, int y, int font, int foreground, byte print_character_with_callback(byte chr, int x, int y, int font, int foreground,
int *dest, int (*getTileCallback)(int, int), unsigned short *tilemapPtr, int tilemapWidth, byte doubleTileHeight); int *dest, int (*getTileCallback)(int, int), unsigned short *tilemapPtr, int tilemapWidth, byte doubleTileHeight);
byte print_character_with_callback_1bpp_buffer(byte chr, int x, int y, byte *dest, int (*getTileCallback)(int, int), int font,
unsigned short *tilemapPtr, int tilemapWidth, byte doubleTileHeight);
byte print_character_to_ram(byte chr, int *dest, int xOffset, int font, int foreground); byte print_character_to_ram(byte chr, int *dest, int xOffset, int font, int foreground);
int print_window_header_string(int *dest, byte *str, int x, int y); int print_window_header_string(int *dest, byte *str, int x, int y);
void clear_window_header(int *dest, int length, int x, int y); void clear_window_header(int *dest, int length, int x, int y);
@ -78,39 +82,42 @@ byte getSex(byte character);
void getPossessive(byte character, byte *str, int *index); void getPossessive(byte character, byte *str, int *index);
void getPronoun(byte character, byte *str, int *index); void getPronoun(byte character, byte *str, int *index);
int get_pointer_jump_back(byte *character); int get_pointer_jump_back(byte *character);
void print_letter_in_buffer(WINDOW* window, byte* character, int *dest); void print_letter_in_buffer(WINDOW* window, byte* character, byte *dest);
void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foreground, int* dest); void weld_entry_custom_buffer(WINDOW *window, byte *str, int font, int foreground, byte* dest);
byte print_character_formatted_buffer(byte chr, int x, int y, int font, int foreground, int *dest); byte print_character_formatted_buffer(byte chr, int x, int y, int font, int foreground, byte *dest);
int print_window_with_buffer(WINDOW* window); int print_window_with_buffer(WINDOW* window);
byte print_character_with_codes(WINDOW* window, int* dest); byte print_character_with_codes(WINDOW* window, byte* dest);
int buffer_reset_window(WINDOW* window, bool skip_redraw, int* dest); int buffer_reset_window(WINDOW* window, bool skip_redraw, byte* dest);
void handle_first_window_buffer(WINDOW* window, int* dest); void handle_first_window_buffer(WINDOW* window, byte* dest);
void clear_window_buffer(WINDOW *window, int* dest); void clear_window_buffer(WINDOW *window, byte* dest);
void clear_rect_buffer(int x, int y, int width, int height, int pixels, int* dest); void clear_rect_buffer(int x, int y, int width, int height, byte* dest);
void clear_tile_buffer(int x, int y, int pixels, int* dest); void clear_tile_buffer(int x, int y, byte* dest);
int buffer_drawwindow(WINDOW* window, int* dest); int buffer_drawwindow(WINDOW* window, byte* dest);
void scrolltext_buffer(WINDOW* window, int* dest); void scrolltext_buffer(WINDOW* window, byte* dest);
void properScroll(WINDOW* window, int* dest); void properScroll(WINDOW* window, byte* dest);
int jumpToOffset(byte* character); int jumpToOffset(byte* character);
void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, int *dest); void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, byte *dest);
void copy_tile_up_buffer(int x, int y, int *dest); void copy_tile_up_buffer(int x, int y, byte *dest);
void setStuffWindow_Graphics(); void setStuffWindow_Graphics();
void clearWindowTiles_buffer(WINDOW* window); void clearWindowTiles_buffer(WINDOW* window);
int initWindow_buffer(WINDOW* window, byte* text_start, unsigned short delay_between_prints); int initWindow_buffer(WINDOW* window, byte* text_start, unsigned short delay_between_prints);
void print_blankstr_buffer(int x, int y, int width, int *dest); void print_blankstr_buffer(int x, int y, int width, byte *dest);
unsigned short ailmentTileSetup(byte *ailmentBase, unsigned short defaultVal); unsigned short ailmentTileSetup(byte *ailmentBase, unsigned short defaultVal);
int setNumber_getLength(int value, byte *str, int maxLength); int setNumber_getLength(int value, byte *str, int maxLength);
int print_string_in_buffer(byte *str, int x, int y, int *dest); int print_string_in_buffer(byte *str, int x, int y, byte *dest);
void printCashWindow(); void printCashWindow();
WINDOW* getWindow(int index); WINDOW* getWindow(int index);
void printTinyArrow(int x, int y); void printTinyArrow(int x, int y);
int printstr_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight); int printstr_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight);
unsigned short printstr_hlight_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight); unsigned short printstr_hlight_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight);
unsigned short printstr_hlight_pixels_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight); unsigned short printstr_hlight_pixels_buffer(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight);
void load_pixels_overworld_buffer();
void store_pixels_overworld_buffer(int totalYs);
extern unsigned short m2_coord_table[]; extern unsigned short m2_coord_table[];
extern byte m2_ness_name[]; extern byte m2_ness_name[];
extern int m2_bits_to_nybbles[]; extern int m2_bits_to_nybbles[];
extern int m2_bits_to_nybbles_fast[];
extern byte m2_nybbles_to_bits[]; extern byte m2_nybbles_to_bits[];
extern byte *m2_font_table[]; extern byte *m2_font_table[];
extern byte m2_font_widths[]; extern byte m2_font_widths[];
@ -138,7 +145,7 @@ extern int m2_div(int dividend, int divisor);
extern int m2_remainder(int dividend, int divisor); extern int m2_remainder(int dividend, int divisor);
extern void m2_soundeffect(int index); extern void m2_soundeffect(int index);
extern void m2_printstr(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight); extern void m2_printstr(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight);
extern int customcodes_parse_generic(int code, char* parserAddress, WINDOW* window, int* dest); extern int customcodes_parse_generic(int code, char* parserAddress, WINDOW* window, byte* dest);
extern void m2_sub_d3c50(); extern void m2_sub_d3c50();
extern void m2_sub_d6844(); extern void m2_sub_d6844();
extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height); extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height);

View File

@ -0,0 +1 @@
DDDDODDDôDDD˙DDDDODDOODDôODD˙ODDDôDDOôDDôôDD˙ôDDD˙DDO˙DDô˙DD˙˙DDDDODODODôDOD˙DODDOODOOODôOOD˙OODDôODOôODôôOD˙ôODD˙ODO˙ODô˙OD˙˙ODDDôDODôDôDôD˙DôDDOôDOOôDôOôD˙OôDDôôDOôôDôôôD˙ôôDD˙ôDO˙ôDô˙ôD˙˙ôDDD˙DOD˙DôD˙D˙D˙DDO˙DOO˙DôO˙D˙O˙DDô˙DOô˙Dôô˙D˙ô˙DD˙˙DO˙˙Dô˙˙D˙˙˙DDDDOODDOôDDO˙DDODODOOODOôODO˙ODODôDOOôDOôôDO˙ôDOD˙DOO˙DOô˙DO˙˙DODDOOODOOôDOO˙DOODOOOOOOOôOOO˙OOODôOOOôOOôôOO˙ôOOD˙OOO˙OOô˙OO˙˙OODDôOODôOôDôO˙DôODOôOOOôOôOôO˙OôODôôOOôôOôôôO˙ôôOD˙ôOO˙ôOô˙ôO˙˙ôODD˙OOD˙OôD˙O˙D˙ODO˙OOO˙OôO˙O˙O˙ODô˙OOô˙Oôô˙O˙ô˙OD˙˙OO˙˙Oô˙˙O˙˙˙ODDDôODDôôDDô˙DDôDODôOODôôODô˙ODôDôDôOôDôôôDô˙ôDôD˙DôO˙Dôô˙Dô˙˙DôDDOôODOôôDOô˙DOôDOOôOOOôôOOô˙OOôDôOôOôOôôôOô˙ôOôD˙OôO˙Oôô˙Oô˙˙OôDDôôODôôôDôô˙DôôDOôôOOôôôOôô˙OôôDôôôOôôôôôôô˙ôôôD˙ôôO˙ôôô˙ôô˙˙ôôDD˙ôOD˙ôôD˙ô˙D˙ôDO˙ôOO˙ôôO˙ô˙O˙ôDô˙ôOô˙ôôô˙ô˙ô˙ôD˙˙ôO˙˙ôô˙˙ô˙˙˙ôDDD˙ODD˙ôDD˙˙DD˙DOD˙OOD˙ôOD˙˙OD˙DôD˙OôD˙ôôD˙˙ôD˙D˙D˙O˙D˙ô˙D˙˙˙D˙DDO˙ODO˙ôDO˙˙DO˙DOO˙OOO˙ôOO˙˙OO˙DôO˙OôO˙ôôO˙˙ôO˙D˙O˙O˙O˙ô˙O˙˙˙O˙DDô˙ODô˙ôDô˙˙Dô˙DOô˙OOô˙ôOô˙˙Oô˙Dôô˙Oôô˙ôôô˙˙ôô˙D˙ô˙O˙ô˙ô˙ô˙˙˙ô˙DD˙˙OD˙˙ôD˙˙˙D˙˙DO˙˙OO˙˙ôO˙˙˙O˙˙Dô˙˙Oô˙˙ôô˙˙˙ô˙˙D˙˙˙O˙˙˙ô˙˙˙˙˙˙˙

View File

@ -1,5 +1,5 @@
//============================================================================== //==============================================================================
// void parse_generic(int code, char* parserAddress, WINDOW* window, int* dest) // void parse_generic(int code, char* parserAddress, WINDOW* window, byte* dest)
// In: // In:
// r0: code // r0: code
// r1: parser address // r1: parser address

View File

@ -1660,6 +1660,9 @@ m2_widths_tiny:
m2_bits_to_nybbles: m2_bits_to_nybbles:
.incbin "data/m2-bits-to-nybbles.bin" .incbin "data/m2-bits-to-nybbles.bin"
m2_bits_to_nybbles_fast:
.incbin "data/m2-bits-to-nybbles-fast.bin"
m2_nybbles_to_bits: m2_nybbles_to_bits:
.incbin "data/m2-nybbles-to-bits.bin" .incbin "data/m2-nybbles-to-bits.bin"
@ -1698,7 +1701,7 @@ m2_coord_table_file:
// Existing subroutines/data // Existing subroutines/data
//============================================================================== //==============================================================================
.definelabel overworld_buffer ,0x200C000 .definelabel overworld_buffer ,0x200F200
.definelabel m2_ness_data ,0x3001D54 .definelabel m2_ness_data ,0x3001D54
.definelabel m2_ness_name ,0x3001F10 .definelabel m2_ness_name ,0x3001F10
.definelabel m2_old_paula_name ,0x3001F16 .definelabel m2_old_paula_name ,0x3001F16

View File

@ -491,7 +491,7 @@ beq @@next
// If flag 0x10 is set, clear the PSI window // If flag 0x10 is set, clear the PSI window
ldr r0,[r5,0x1C] // PSI window ldr r0,[r5,0x1C] // PSI window
ldr r1,=#overworld_buffer - 0x2000 ldr r1,=#overworld_buffer - 0x800
bl clear_window_buffer bl clear_window_buffer
@@next: @@next:
@ -749,7 +749,7 @@ ldrh r0,[r0]
cmp r0,0 cmp r0,0
beq @@next beq @@next
ldr r0,=#0x3005230 ldr r0,=#0x3005230
ldr r1,=#overworld_buffer - 0x2000 ldr r1,=#overworld_buffer - 0x800
ldr r0,[r0,0x1C] ldr r0,[r0,0x1C]
bl clear_window_buffer bl clear_window_buffer
@ -2304,7 +2304,7 @@ orr r2,r1
strb r2,[r4,#0x3] strb r2,[r4,#0x3]
mov r3,r0 mov r3,r0
mov r0,r4 mov r0,r4
ldr r1,=#overworld_buffer - 0x2000 ldr r1,=#overworld_buffer - 0x800
mov r4,r3 mov r4,r3
bl clear_window_buffer bl clear_window_buffer
mov r0,r4 mov r0,r4
@ -2594,7 +2594,7 @@ pop {r4,pc}
//Prints blankstr in the buffer //Prints blankstr in the buffer
bb21c_print_blankstr_buffer: bb21c_print_blankstr_buffer:
push {lr} push {lr}
ldr r3,=#overworld_buffer - 0x2000 ldr r3,=#overworld_buffer - 0x800
bl print_blankstr_buffer bl print_blankstr_buffer
pop {pc} pop {pc}
@ -2602,7 +2602,7 @@ pop {pc}
//Prints blankstr in the buffer and stores it //Prints blankstr in the buffer and stores it
bb21c_print_blankstr_buffer_store: bb21c_print_blankstr_buffer_store:
push {lr} push {lr}
ldr r3,=#overworld_buffer - 0x2000 ldr r3,=#overworld_buffer - 0x800
bl print_blankstr_buffer bl print_blankstr_buffer
bl store_pixels_overworld bl store_pixels_overworld
pop {pc} pop {pc}
@ -2969,44 +2969,42 @@ pop {pc}
//============================================================================== //==============================================================================
//Loads the vram into the buffer, it's called each time there is only the main file_select window active (a good way to set the whole thing up) //Loads the vram into the buffer, it's called each time there is only the main file_select window active (a good way to set the whole thing up)
load_pixels_overworld: load_pixels_overworld:
push {r0-r1,lr} push {r0-r3,lr}
ldr r1,=#0x40000C8 //DMA transfer 2 bl load_pixels_overworld_buffer
ldr r0,=#0x6002000 //Source pop {r0-r3,pc}
str r0,[r1]
ldr r0,=#overworld_buffer //Target
str r0,[r1,#4]
ldr r0,=#0xA4001000 //Store 0x4000 bytes - When HBlank and in words of 32 bits
str r0,[r1,#8]
ldr r0,[r1,#8]
pop {r0-r1,pc}
//============================================================================== //==============================================================================
//Stores the buffer into the vram. This avoids screen tearing. //Stores the buffer into the vram. This avoids screen tearing.
store_pixels_overworld: store_pixels_overworld:
push {r0-r1,lr} push {r0-r3,lr}
ldr r1,=#0x40000C8 //DMA transfer 2 //ldr r1,=#0x40000C8 //DMA transfer 2, store the arrangements in order to avoid screen tearing ---> (Was actually caused by the VBlank below)
ldr r0,=#overworld_buffer //Source //ldr r0,=#0x3005270
str r0,[r1] //ldr r0,[r0,#0] //Source
ldr r0,=#0x6002000 //Target //str r0,[r1]
str r0,[r1,#4] //ldr r0,=#0x30051E4
ldr r0,=#0x94001000 //Store 0x4000 bytes - When VBlank and in words of 32 bits //mov r2,#0
str r0,[r1,#8] //ldsh r0,[r0,r2]
ldr r0,[r1,#8] //lsl r0,r0,#0xB
pop {r0-r1,pc} //mov r2,#0xC0
//lsl r2,r2,#0x13
//add r0,r0,r2 //Target
//str r0,[r1,#4]
//ldr r0,=#0x94000200 //Store 0x800 bytes - When in VBlank and in words of 32 bits
//str r0,[r1,#8]
//ldr r0,[r1,#8]
//swi #5 //Do this during VBlank
mov r0,#0x10
bl store_pixels_overworld_buffer
pop {r0-r3,pc}
//============================================================================== //==============================================================================
//Stores the buffer into the vram. This avoids screen tearing. //Stores the buffer into the vram. This avoids screen tearing.
store_pixels_overworld_psi_window: store_pixels_overworld_psi_window:
push {r0-r1,lr} push {r0-r3,lr}
ldr r1,=#0x40000C8 //DMA transfer 2 //swi #5 //Do this during VBlank
ldr r0,=#overworld_buffer //Source mov r0,#0xA
str r0,[r1] bl store_pixels_overworld_buffer
ldr r0,=#0x6002000 //Target pop {r0-r3,pc}
str r0,[r1,#4]
ldr r0,=#0x94000800 //Store 0x1800 bytes - When VBlank and in words of 32 bits
str r0,[r1,#8]
ldr r0,[r1,#8]
pop {r0-r1,pc}
//============================================================================== //==============================================================================
//Prints the sick tiles and then the names //Prints the sick tiles and then the names