From 3f965e101f44f69d99b03fa0bf0b5ef691dc02a3 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 23 Feb 2020 05:01:46 +0100 Subject: [PATCH] Implement buffer in shop --- src/c/goods.c | 10 +-- src/m2-hack.asm | 3 + working/m12-strings-english.txt | 120 ++++++++++++++++---------------- 3 files changed, 69 insertions(+), 64 deletions(-) diff --git a/src/c/goods.c b/src/c/goods.c index 50319bb..16f9240 100644 --- a/src/c/goods.c +++ b/src/c/goods.c @@ -539,20 +539,22 @@ void shop_print_items(WINDOW *window, unsigned char *items, int y_offset, int it { int x_offset = 0; byte *item_str = m2_strlookup(m2_items_offsets, m2_items_strings, item); - print_string(item_str, x + x_offset, y); + print_string_in_buffer(item_str, x + x_offset, y, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER))); int digit_count; int bcd = bin_to_bcd(getPrice(item), &digit_count); //Get the price in bcd, so it can be printed int base = 120; - print_character(decode_character(0x56), x + base, y); //00, it will be at the end, always at the same position - print_character(decode_character(0x54), x + base - 6 - (digit_count * 6), y); //dollar, it must be before all digits + print_character_formatted_buffer(decode_character(0x56), x + base, y, 0, 0xF, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER))); //00, it will be at the end, always at the same position + print_character_formatted_buffer(decode_character(0x54), x + base - 6 - (digit_count * 6), y, 0, 0xF, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER))); //dollar, it must be before all digits // Write the digits for (int j = 0; j < digit_count; j++) { byte digit = ((bcd >> ((digit_count - 1 - j) * 4)) & 0xF) + ZERO; - print_character(decode_character(digit), x + base - 6 - ((digit_count - j - 1) * 6), y); //write a single digit + print_character_formatted_buffer(decode_character(digit), x + base - 6 - ((digit_count - j - 1) * 6), y, 0, 0xF, (byte*)(OVERWORLD_BUFFER - ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER))); //write a single digit } } } + + store_pixels_overworld(); } //Load proper give text into str and then go to it diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 2ebbcaa..0314637 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1009,6 +1009,9 @@ pop {pc} //--------------------------------------------------------- // C7CA4 hacks (Shop) //--------------------------------------------------------- +.org 0x80C7C90 +bl clearWindowTiles_buffer //Setup the buffer + .org 0x80C7CA4 mov r0,r8 //Window ldr r1,[sp,#0xC] //Items in shop diff --git a/working/m12-strings-english.txt b/working/m12-strings-english.txt index 9a82fae..1b2346a 100644 --- a/working/m12-strings-english.txt +++ b/working/m12-strings-english.txt @@ -2553,7 +2553,7 @@ ^L2687^@I noticed you didn't pay![02 FF][86 FF _L2688_][81 FF _L2161_]^L2685^@You won this confrontation.[02 FF]@But the good side of you must[01 FF] ache with regret. Ha ha ha.[1D FF][08 FF 43 00][00 FF] ^L2688^[C6 FF][A7 FF B3 01][00 FF] ^L2689^@(Thanks for your support over[01 FF] the years.[02 FF]@The food stand is going out of[01 FF] business due to personal[01 FF] reasons.)[1D FF][00 FF] -^L2690^@(We trust you. Feel free to[01 FF] shop here.)[02 FF]@What would you like to buy?[02 FF][9C FF][69 FF][94 FF 30][82 FF _L5284_][87 FF][91 FF FF][82 FF _L5285_][88 FF]@How much do you want to pay?[01 FF][C8 FF 04 01][87 FF][82 FF _L5284_][88 FF][99 FF 00 00 00 00][81 FF _L5286_][89 FF][87 FF][82 FF _L5287_][87 FF][9A FF E3 00][81 FF _L5288_][DD FF 0C 00 00 00 01 00 00 00][82 FF _L5289_][80 FF _L5290_] +^L2690^@(We trust you. Feel free to[01 FF] shop here.)[02 FF]@What would you like to buy?[02 FF][9C FF][69 FF][5C FF][94 FF 30][5B FF][5A FF][82 FF _L5284_][87 FF][91 FF FF][82 FF _L5285_][88 FF]@How much do you want to pay?[01 FF][C8 FF 04 01][87 FF][82 FF _L5284_][88 FF][99 FF 00 00 00 00][81 FF _L5286_][89 FF][87 FF][82 FF _L5287_][87 FF][9A FF E3 00][81 FF _L5288_][DD FF 0C 00 00 00 01 00 00 00][82 FF _L5289_][80 FF _L5290_] ^L2691^@I woke up from the dream.[1D FF][00 FF] ^L2692^@I too was wrong in many ways.[1D FF][00 FF] ^L2695^@Don't you think the mental[01 FF] health of everyone in the village[01 FF] is improved?[1D FF][00 FF] @@ -3850,65 +3850,65 @@ ^L4325^[09 FF 91 02][86 FF _L4939_]^L4961^[03 FF 0D 00][04 FF _L4940_][05 FF _L4941_]^L4959^[1C FF 91 02 _L4942_][86 FF _L4943_][00 FF]^L4942^[86 FF _L4944_][09 FF 91 02][00 FF] ^L4326^[09 FF 91 02][86 FF _L4939_]^L4968^[86 FF _L4945_][9C FF][69 FF][86 FF _L4946_][82 FF _L4964_][88 FF][91 FF FF][82 FF _L4965_][89 FF][86 FF _L4948_][86 FF _L4950_][1C FF E0 00 _L4966_][80 FF _L4967_] ^L4327^[09 FF 91 02][86 FF _L4939_]^L4973^[86 FF _L4945_][9C FF][69 FF][86 FF _L4946_][82 FF _L4970_][88 FF][91 FF FF][82 FF _L4971_][89 FF][86 FF _L4948_][86 FF _L4950_][1C FF E0 00 _L4972_][00 FF] -^L4328^[94 FF 01][00 FF] -^L4329^[94 FF 02][00 FF] -^L4330^[94 FF 04][00 FF] -^L4331^[94 FF 04][00 FF] -^L4332^[94 FF 05][00 FF] -^L4333^[94 FF 06][00 FF] -^L4334^[94 FF 07][00 FF] -^L4335^[94 FF 08][00 FF] -^L4336^[94 FF 09][00 FF] -^L4337^[94 FF 0B][00 FF] -^L4338^[94 FF 0E][00 FF] -^L4339^[94 FF 36][00 FF] -^L4340^[94 FF 0F][00 FF] -^L4341^[94 FF 37][00 FF] -^L4342^[94 FF 10][00 FF] -^L4343^[94 FF 11][00 FF] -^L4344^[94 FF 12][00 FF] -^L4345^[94 FF 13][00 FF] -^L4346^[94 FF 14][00 FF] -^L4347^[94 FF 16][00 FF] -^L4348^[1C FF D7 00 _L4386_][94 FF 40][00 FF] -^L4349^[94 FF 38][00 FF] -^L4350^[94 FF 17][00 FF] -^L4351^[94 FF 32][00 FF] -^L4352^[94 FF 39][00 FF] -^L4353^[94 FF 18][00 FF] -^L4354^[94 FF 3A][00 FF] -^L4355^[94 FF 3B][00 FF] -^L4356^[94 FF 19][00 FF] -^L4357^[94 FF 1A][00 FF] -^L4358^[94 FF 1B][00 FF] -^L4359^[94 FF 1C][00 FF] -^L4360^[94 FF 1D][00 FF] -^L4361^[94 FF 1F][00 FF] -^L4362^[94 FF 20][00 FF] -^L4363^[94 FF 21][00 FF] -^L4364^[94 FF 1E][00 FF] -^L4365^[94 FF 22][00 FF] -^L4366^[94 FF 23][00 FF] -^L4367^[94 FF 26][00 FF] -^L4368^[94 FF 28][00 FF] -^L4369^[94 FF 27][00 FF] -^L4370^[94 FF 03][00 FF] -^L4371^[94 FF 0A][00 FF] -^L4372^[94 FF 3D][00 FF] -^L4373^[94 FF 29][00 FF] -^L4374^[94 FF 2B][00 FF] -^L4375^[94 FF 2C][00 FF] -^L4376^[94 FF 2D][00 FF] -^L4377^[94 FF 3F][00 FF] -^L4378^[94 FF 3E][00 FF] -^L4379^[94 FF 15][00 FF] -^L4380^[94 FF 33][00 FF] -^L4381^[94 FF 2E][00 FF] -^L4382^[94 FF 34][00 FF] -^L4383^[94 FF 35][00 FF] -^L4384^[94 FF 24][00 FF] -^L4385^[94 FF 3C][00 FF] -^L4386^[94 FF 41][00 FF] +^L4328^[5C FF][94 FF 01][5B FF][5A FF][00 FF] +^L4329^[5C FF][94 FF 02][5B FF][5A FF][00 FF] +^L4330^[5C FF][94 FF 04][5B FF][5A FF][00 FF] +^L4331^[5C FF][94 FF 04][5B FF][5A FF][00 FF] +^L4332^[5C FF][94 FF 05][5B FF][5A FF][00 FF] +^L4333^[5C FF][94 FF 06][5B FF][5A FF][00 FF] +^L4334^[5C FF][94 FF 07][5B FF][5A FF][00 FF] +^L4335^[5C FF][94 FF 08][5B FF][5A FF][00 FF] +^L4336^[5C FF][94 FF 09][5B FF][5A FF][00 FF] +^L4337^[5C FF][94 FF 0B][5B FF][5A FF][00 FF] +^L4338^[5C FF][94 FF 0E][5B FF][5A FF][00 FF] +^L4339^[5C FF][94 FF 36][5B FF][5A FF][00 FF] +^L4340^[5C FF][94 FF 0F][5B FF][5A FF][00 FF] +^L4341^[5C FF][94 FF 37][5B FF][5A FF][00 FF] +^L4342^[5C FF][94 FF 10][5B FF][5A FF][00 FF] +^L4343^[5C FF][94 FF 11][5B FF][5A FF][00 FF] +^L4344^[5C FF][94 FF 12][5B FF][5A FF][00 FF] +^L4345^[5C FF][94 FF 13][5B FF][5A FF][00 FF] +^L4346^[5C FF][94 FF 14][5B FF][5A FF][00 FF] +^L4347^[5C FF][94 FF 16][5B FF][5A FF][00 FF] +^L4348^[1C FF D7 00 _L4386_][5C FF][94 FF 40][5B FF][5A FF][00 FF] +^L4349^[5C FF][94 FF 38][5B FF][5A FF][00 FF] +^L4350^[5C FF][94 FF 17][5B FF][5A FF][00 FF] +^L4351^[5C FF][94 FF 32][5B FF][5A FF][00 FF] +^L4352^[5C FF][94 FF 39][5B FF][5A FF][00 FF] +^L4353^[5C FF][94 FF 18][5B FF][5A FF][00 FF] +^L4354^[5C FF][94 FF 3A][5B FF][5A FF][00 FF] +^L4355^[5C FF][94 FF 3B][5B FF][5A FF][00 FF] +^L4356^[5C FF][94 FF 19][5B FF][5A FF][00 FF] +^L4357^[5C FF][94 FF 1A][5B FF][5A FF][00 FF] +^L4358^[5C FF][94 FF 1B][5B FF][5A FF][00 FF] +^L4359^[5C FF][94 FF 1C][5B FF][5A FF][00 FF] +^L4360^[5C FF][94 FF 1D][5B FF][5A FF][00 FF] +^L4361^[5C FF][94 FF 1F][5B FF][5A FF][00 FF] +^L4362^[5C FF][94 FF 20][5B FF][5A FF][00 FF] +^L4363^[5C FF][94 FF 21][5B FF][5A FF][00 FF] +^L4364^[5C FF][94 FF 1E][5B FF][5A FF][00 FF] +^L4365^[5C FF][94 FF 22][5B FF][5A FF][00 FF] +^L4366^[5C FF][94 FF 23][5B FF][5A FF][00 FF] +^L4367^[5C FF][94 FF 26][5B FF][5A FF][00 FF] +^L4368^[5C FF][94 FF 28][5B FF][5A FF][00 FF] +^L4369^[5C FF][94 FF 27][5B FF][5A FF][00 FF] +^L4370^[5C FF][94 FF 03][5B FF][5A FF][00 FF] +^L4371^[5C FF][94 FF 0A][5B FF][5A FF][00 FF] +^L4372^[5C FF][94 FF 3D][5B FF][5A FF][00 FF] +^L4373^[5C FF][94 FF 29][5B FF][5A FF][00 FF] +^L4374^[5C FF][94 FF 2B][5B FF][5A FF][00 FF] +^L4375^[5C FF][94 FF 2C][5B FF][5A FF][00 FF] +^L4376^[5C FF][94 FF 2D][5B FF][5A FF][00 FF] +^L4377^[5C FF][94 FF 3F][5B FF][5A FF][00 FF] +^L4378^[5C FF][94 FF 3E][5B FF][5A FF][00 FF] +^L4379^[5C FF][94 FF 15][5B FF][5A FF][00 FF] +^L4380^[5C FF][94 FF 33][5B FF][5A FF][00 FF] +^L4381^[5C FF][94 FF 2E][5B FF][5A FF][00 FF] +^L4382^[5C FF][94 FF 34][5B FF][5A FF][00 FF] +^L4383^[5C FF][94 FF 35][5B FF][5A FF][00 FF] +^L4384^[5C FF][94 FF 24][5B FF][5A FF][00 FF] +^L4385^[5C FF][94 FF 3C][5B FF][5A FF][00 FF] +^L4386^[5C FF][94 FF 41][5B FF][5A FF][00 FF] ^L4387^[D4 FF 78 00][00 FF] ^L4388^@Hi, come in, come in![02 FF]@What can I do for you today?[00 FF] ^L4389^@Hello there![01 FF] How may I help you?[00 FF]