From dcf97b15572434240de665f3b32ac6abb4be5f1b Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sat, 28 Sep 2019 23:36:27 +0200 Subject: [PATCH 1/2] Change Mother 2 cartridge to EB cartridge --- src/c/ext.c | 4 ++- src/c/vwf.c | 21 +++++++++++++++ src/c/vwf.h | 7 +++++ src/data/m12-cartridge-palettes-dimmed.bin | Bin 0 -> 160 bytes src/data/m2-cartridge-arrangements.bin | Bin 0 -> 6144 bytes src/data/m2-cartridge-palettes.bin | Bin 0 -> 512 bytes src/data/m2-cartridge-tiles.bin | Bin 0 -> 32768 bytes src/m2-hack.asm | 20 ++++++++++++++ src/m2-vwf-entries.asm | 29 +++++++++++++++++++++ 9 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 src/data/m12-cartridge-palettes-dimmed.bin create mode 100644 src/data/m2-cartridge-arrangements.bin create mode 100644 src/data/m2-cartridge-palettes.bin create mode 100644 src/data/m2-cartridge-tiles.bin diff --git a/src/c/ext.c b/src/c/ext.c index 80c808d..302e89b 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -1,6 +1,7 @@ #include "window.h" void __attribute__((naked)) cpufastset(void *source, void *dest, int mode) {} +void __attribute__((naked)) cpuset(void *source, void *dest, int mode) {} byte* __attribute__((naked)) m2_strlookup(int *offset_table, byte *strings, int index) {} int __attribute__((naked)) bin_to_bcd(int value, int* digit_count) {} int __attribute__((naked)) m2_drawwindow(WINDOW* window) {} @@ -20,4 +21,5 @@ int __attribute__((naked)) m2_clearwindowtiles(WINDOW* window) {} int __attribute__((naked)) customcodes_parse_generic(int code, char* parserAddress, WINDOW* window, int* dest) {} void __attribute__((naked)) m2_printstr(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight) {} void __attribute__((naked)) m2_setupbattlename(short value) {} -void __attribute__((naked)) store_pixels_overworld() {} \ No newline at end of file +void __attribute__((naked)) store_pixels_overworld() {} +void __attribute__((naked)) m12_dim_palette(short* palette, int total, int dimmingFactor) {} \ No newline at end of file diff --git a/src/c/vwf.c b/src/c/vwf.c index 1accc09..6858075 100644 --- a/src/c/vwf.c +++ b/src/c/vwf.c @@ -2120,6 +2120,27 @@ void store_pixels_overworld_buffer(int totalYs) } } +void eb_cartridge_palette_change(bool background) +{ + unsigned short *paletteDest = (unsigned short*)0x5000040; + if(background) + { + if(BUILD_PALETTE) + { + //Makes the game do the palette work. Copy the result in a bin file and use that instead in order to make the swap fast + unsigned short palettes[0x50]; + cpuset(paletteDest, palettes, 0x50); + for(int i = 0; i < 5; i++) + m12_dim_palette(&palettes[i * 0x10], 0x10, 0x800); + cpuset(palettes, paletteDest, 0x50); + } + else + cpuset(m12_cartridge_palettes_dimmed, paletteDest, 0x50); + } + else + cpuset(&m12_cartridge_palettes[0x20], paletteDest, 0x50); +} + void store_pixels_overworld_buffer_totalTiles(int totalTiles) { int tile = *tile_offset; diff --git a/src/c/vwf.h b/src/c/vwf.h index 84cfd31..b22b26f 100644 --- a/src/c/vwf.h +++ b/src/c/vwf.h @@ -27,6 +27,8 @@ #define CUSTOMCC_SET_X 0x5F #define CUSTOMCC_ADD_X 0x60 +#define BUILD_PALETTE false + byte decode_character(byte chr); byte encode_ascii(char chr); int get_tile_number(int x, int y); @@ -124,6 +126,7 @@ unsigned short printstr_hlight_pixels_buffer(WINDOW* window, byte* str, unsigned void load_pixels_overworld_buffer(); void store_pixels_overworld_buffer(int totalYs); void store_pixels_overworld_buffer_totalTiles(int totalTiles); +void eb_cartridge_palette_change(bool background); extern unsigned short m2_coord_table_fast_progression[]; extern unsigned short m2_coord_table[]; @@ -142,12 +145,16 @@ extern byte m12_other_str7[]; extern byte m12_other_str8[]; extern byte m2_cstm_last_printed[]; extern byte *m2_script_readability; +extern unsigned short m12_cartridge_palettes[]; +extern unsigned short m12_cartridge_palettes_dimmed[]; extern int overworld_buffer; extern PC m2_ness_data[]; extern int m2_arrow_tile[]; extern bool m2_isequipped(int item_index); extern void cpufastset(void *source, void *dest, int mode); +extern void cpuset(void *source, void *dest, int mode); +extern void m12_dim_palette(unsigned short* palette, int total, int dimmingFactor); extern byte* m2_strlookup(int *offset_table, byte *strings, int index); extern void m2_formatnumber(int value, byte* strDest, int length); extern int bin_to_bcd(int value, int* digit_count); diff --git a/src/data/m12-cartridge-palettes-dimmed.bin b/src/data/m12-cartridge-palettes-dimmed.bin new file mode 100644 index 0000000000000000000000000000000000000000..89be87b082c8ef0ad2ee54524cf181dac683ded1 GIT binary patch literal 160 zcmZRuWnegGnPYfdMU%moK~K^_)Qx8yuPaBI1_Oh)E~h4gtuKQnP=%i4I$n1UkSth~ z!BO|MmX&Sx^AQRGg h7#KJ;&slOPx&q}vdO>!$@wkC)g}8@-;k_*g0svYHB2xeW literal 0 HcmV?d00001 diff --git a/src/data/m2-cartridge-arrangements.bin b/src/data/m2-cartridge-arrangements.bin new file mode 100644 index 0000000000000000000000000000000000000000..37a6e93c73d3560b6432426b62c000ecc067c584 GIT binary patch literal 6144 zcmeH`Wsp?c6-K{rU)n;O@=~?(Y6@ch>}WcTI42*ChQq zuc()qse1X9s#LmH)vY?W&pNfw>goUx0te9$9Wf9Su@D<^5Et~{`02c1LCVdsc*)H&uHcTPAbom0+f z=ZtgKIp-8aArwXt6!rPVP#h%?f|9uD+;VO^cbvPva@jK>5_#3W3{6imf5Oven& z#4ODA`ExN3^RWO6u?UN?1WU0D%drA0u?nlP25Yen>#+eFu?d^81zWKV+pz;XvCHT0 z#vbg&KJ3Q<9K<0U#t|IFF&xJUoWv=d#u=Q&Ih@A@T*M_@#uZ$}HC)FHpMMj#a2t1U z7x!=<5AYC=@EA|<6wmM+FYpqt@EULM7Vq#LAMg>M@EKq572kY5ND3WBV|2z~OvYkt z#$jB>V|*rHLMCEjDqSXFQYK?^reI2@Vrr&gTK;rE00Wth#`Mg zojI73xtN>5%)`9Q$NVh7f-JNj_kzF?82_> z#_sIFp6tcm?8Cl3zaRT^00(jq2XhFAau|nm1V?fdM{^9vavaBV0w;13Cvys?avG;| z24`{>XZ!rQoX7cG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JZ&mld90zFX#5WvgwCMeG+46d1JD0=>^)W1V+bK&1W= T&-1VS1^fm41^fm6I|cp;_AWxz literal 0 HcmV?d00001 diff --git a/src/data/m2-cartridge-palettes.bin b/src/data/m2-cartridge-palettes.bin new file mode 100644 index 0000000000000000000000000000000000000000..849dba88cafc0db29f92c91ee540062ec21c8b56 GIT binary patch literal 512 zcmYc=Iw8TS$SW(Lm}6+H%D`~mwp>@xZI@w5(Dpd1?7ig)MjJ$Sv)txkV5sKZE%;kB zT5PsdoSn3MweoKD`{w`s8R{4q=9b?`>hmmSnaxmRv_Nl-OpSb($e92JmT7T9K@4@X z8H!ovme&~7$gdLt$$~{07Hjo+o(cG(0+FwguQ6I9b42fh!rXG8PKKKJ3lgh=s!vKV z)B(){>J?QzCvhfVHp2qFwKDHz7#M_t=9UXMtpdt}^n&bIBeND{D}w^qJ&G*u(&_byooY0U6qo5XVTtVJXUTlfYaCaE(H-!j&Qft_^RwdN{TLsp85stPdh; ztwqZfBI_}hr5152(kt32B1a-M;U}YxLr_YgxQSjv2QA>(fw}x(Cm)JPOVkmt9~yA` z`<**?_U`OFmdhkgj2`mLx%Zy?n7MO)_uPADc6Y^!WSU8#+A=An`c(BYo3Eudkdnb~ zf1y@e0M`~ERCsZ*QmZX4E-X|k!WAVUDo6?_rTSELWq!U~soX4A%9Q0YqGhH*lyBa| zA%%v}x+lEEn)uKBXCOmb3a+qQh3d?cUGJ2)`x z;Gkt+CX?yIfikOQKf;XjkU}=7yW6&Nka-*^yOAK_ZpM#kW zjp9rF$!x|CQ#27; zp`Mkq!6vG)e(0*KDT1oCDo+q~KtvHLhOSr*6=!BLEemoiB>Ot0y){!rQ z^qIw+T|6%;UgtKG&TS$wLZh z_;(H z-6xFy#pSlI=I3fgz8K8PTMsO^eY7+WzA1BfOx!D&v_pU}k4ISM@%|j1;V`w?{y55k z$H&W(q|^GqZ8Q5A_fVmXjPqlMDYP@y!cWuZ_ijTVq3=~xED(Qzt{!@(cN zVbYiM_lz@r5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z1^%)Jh+th0Vl{@o59&Us`=IVyzrG^VT&>S!DixzyKUnXt_2|Q|qW}H|{RpO{Dd_cO zKf)$UI>*Fp_M@6R^6|s#Mn0^$#g88@9{jLo+rO1{r{9l}YXel?Uqc_pGJfHt`F!gs z?1SHa2`%9*w2zQXHi`PMJ%#nW&OTfxI8xsFYBpPY$Q`+btAi}w!qwH*+xD%6N~X3b z{ojG+8yIcyy-Z>2-pWHOu+d|#^Ud(DDx3g)#!UME@TaH;%&{^mth{3zNBK=S{;*sF zF;1=u*MHLvQAvkRsUR_&_{I6-aQuZl`IS6`B{OxtUQ&>$int_K`HOR?sjg?JO08cD z)rjLiASoHyevl;yRO>YdX@1-MeN5C_tEp4aYFtbWmE(5+spX$)O6z@zdPPI2+mM7B zf7Mfd9#8#b9%4wU6Lb5T23gOcLg-Zls_0&xpIL+Gkx-NJtj|9K+zCX2GiF&{gG!N7 z@dv&fiVs47AtQcY^HT(+Kg&y@&rYKFJL_wdl^>)jRmDU@B~Ur+tXf4fji{NJ3Q$&Y z1dClk)TxS~!7#?Ujv9dzj2R?W+Nj5G%rZZ-H5)t2NTHob0npjTPVM?ZJ3WlsIuE0pw S`UJ^+!X)~$1kI=Dr2h|=NC9a8 literal 0 HcmV?d00001 diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 4305bee..5e1d7f8 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1667,6 +1667,21 @@ nop .org 0x82D92D4 :: dw moved_graphics_table :: dw moved_graphics_table + 0x1CD2C .org 0x82D9BBC :: dw moved_graphics_table + 0x26618 :: dw moved_graphics_table + 0x3F818 +//============================================================================== +// Cartridge choosing screen hacks +//============================================================================== + +.org 0x8013C62 :: bl change_palette_needed_foreground +.org 0x8013CAA :: bl change_palette_needed_background + +.org 0x86DD794 :: .incbin "data/m2-cartridge-tiles.bin" +.org 0x8706994 :: .incbin "data/m2-cartridge-arrangements.bin" + +.org 0x8705794 + +m12_cartridge_palettes: +.incbin "data/m2-cartridge-palettes.bin" + //============================================================================== // Data files //============================================================================== @@ -1786,6 +1801,9 @@ m2_coord_table_file: optimized_byte_4bpp_to_1bpp_table: .incbin "data/optimized-byte-4bpp-to-1bpp-table.bin" +m12_cartridge_palettes_dimmed: +.incbin "data/m12-cartridge-palettes-dimmed.bin" + //============================================================================== // Existing subroutines/data @@ -1822,6 +1840,7 @@ optimized_byte_4bpp_to_1bpp_table: .definelabel m2_change_naming_space ,0x8004E08 .definelabel m2_copy_name_temp_mem ,0x8004E34 .definelabel m2_insert_default_name ,0x8005708 +.definelabel m12_dim_palette ,0x80137DC .definelabel m2_enable_script ,0x80A1F6C .definelabel m2_sub_a334c ,0x80A334C .definelabel m2_sub_a3384 ,0x80A3384 @@ -1855,6 +1874,7 @@ optimized_byte_4bpp_to_1bpp_table: .definelabel m2_stat_symb_checker ,0x8B0EDA4 .definelabel m2_div ,0x80F49D8 .definelabel m2_remainder ,0x80F4A70 +.definelabel cpuset ,0x80F47C0 .definelabel m2_items ,0x8B1D62C .definelabel m2_default_names ,0x82B9330 .definelabel m2_psi_print_table ,0x8B2A9C0 diff --git a/src/m2-vwf-entries.asm b/src/m2-vwf-entries.asm index ad0d718..59558fe 100644 --- a/src/m2-vwf-entries.asm +++ b/src/m2-vwf-entries.asm @@ -3331,6 +3331,35 @@ mov r0,#0xA bl store_pixels_overworld_buffer pop {r0-r3,pc} +//============================================================================== +//Change tile only if need be (it's different) - foreground call +change_palette_needed_foreground: +push {lr} +mov r3,#0 +bl change_palette_needed +pop {pc} + +//============================================================================== +//Change tile only if need be (it's different) - background call +change_palette_needed_background: +push {lr} +mov r3,#1 +bl change_palette_needed +pop {pc} + +//============================================================================== +//Change tile only if need be (it's different), r3 contains whether the EB cart is in the background or not +change_palette_needed: +push {lr} +ldrh r2,[r1,#0] +ldrh r1,[r0,#0] +cmp r1,r2 +beq @@end +mov r0,r3 +bl eb_cartridge_palette_change +@@end: +pop {pc} + //============================================================================== //Prints the sick tiles and then the names sick_name: From 468ba9afed67d5da2783c41be182be53dd52de51 Mon Sep 17 00:00:00 2001 From: Lorenzooone Date: Sun, 29 Sep 2019 22:26:24 +0200 Subject: [PATCH 2/2] Fix issues with tenda village naming screen --- src/c/ext.c | 3 ++- src/c/vwf.c | 29 +---------------------------- src/c/vwf.h | 2 +- src/m2-hack.asm | 1 + 4 files changed, 5 insertions(+), 30 deletions(-) diff --git a/src/c/ext.c b/src/c/ext.c index 302e89b..bfc5e83 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -22,4 +22,5 @@ int __attribute__((naked)) customcodes_parse_generic(int code, char* parserAddre void __attribute__((naked)) m2_printstr(WINDOW* window, byte* str, unsigned short x, unsigned short y, bool highlight) {} void __attribute__((naked)) m2_setupbattlename(short value) {} void __attribute__((naked)) store_pixels_overworld() {} -void __attribute__((naked)) m12_dim_palette(short* palette, int total, int dimmingFactor) {} \ No newline at end of file +void __attribute__((naked)) m12_dim_palette(short* palette, int total, int dimmingFactor) {} +int __attribute__((naked)) m2_jump_to_offset(byte* character) {} \ No newline at end of file diff --git a/src/c/vwf.c b/src/c/vwf.c index 6858075..3565d5b 100644 --- a/src/c/vwf.c +++ b/src/c/vwf.c @@ -1276,33 +1276,6 @@ void setStuffWindow_Graphics() (*(address + 2)) = 0; } -int jumpToOffset(byte* character) -{ - int returnOffset = 0; - int baseOffset = 0; - if((*(character + 1)) != 0xFF) - return 0; - int code = 0xFFFF009F + ((*character) | 0xFF00); - - switch(code) - { - case 0x25: - returnOffset += 2; - baseOffset = returnOffset; - for(int i = 0; i < 4; i++) - returnOffset = returnOffset + ((*(character + baseOffset + i)) << (8 * i)); - byte* totalJumps = (byte*)0x3005078; - byte** oldOffsets = (byte**)0x3005080; - oldOffsets[*totalJumps] = character + 6; - (*totalJumps)++; - break; - default: - return 0; - } - - return returnOffset; -} - byte print_character_with_codes(WINDOW* window, byte* dest) { int delay = window->delay--; @@ -1422,7 +1395,7 @@ byte print_character_with_codes(WINDOW* window, byte* dest) break; default: if(code >= 0x60) - window->text_offset += jumpToOffset(character); + window->text_offset += m2_jump_to_offset(character); else { returnedLength = customcodes_parse_generic(code, character, window, dest); diff --git a/src/c/vwf.h b/src/c/vwf.h index b22b26f..56da11f 100644 --- a/src/c/vwf.h +++ b/src/c/vwf.h @@ -102,7 +102,6 @@ void clear_tile_buffer(int x, int y, byte* dest); int buffer_drawwindow(WINDOW* window, byte* dest); void scrolltext_buffer(WINDOW* window, byte* dest); void properScroll(WINDOW* window, byte* dest); -int jumpToOffset(byte* character); void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, byte *dest); void copy_tile_up_buffer(int x, int y, byte *dest); void setStuffWindow_Graphics(); @@ -166,6 +165,7 @@ extern int m2_remainder(int dividend, int divisor); extern void m2_soundeffect(int index); 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, byte* dest); +extern int m2_jump_to_offset(byte* character); extern void m2_sub_d3c50(); extern void m2_sub_d6844(); extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height); diff --git a/src/m2-hack.asm b/src/m2-hack.asm index 5e1d7f8..7f50dc1 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1844,6 +1844,7 @@ m12_cartridge_palettes_dimmed: .definelabel m2_enable_script ,0x80A1F6C .definelabel m2_sub_a334c ,0x80A334C .definelabel m2_sub_a3384 ,0x80A3384 +.definelabel m2_jump_to_offset ,0x80A6C24 .definelabel m2_get_selected_item ,0x80A469C .definelabel m2_psitargetwindow ,0x80B8AE0 .definelabel m2_isequipped ,0x80BC670