From c43b2d8f2dfb10c7343fdad3a71533abd32f0146 Mon Sep 17 00:00:00 2001 From: jeffman Date: Wed, 11 Sep 2019 23:21:54 -0400 Subject: [PATCH] WIP new title screen code All it does right now is play the title screen sound for 5 seconds --- build.ps1 | 3 ++- src/c/ext.c | 4 +++- src/c/locs.c | 1 + src/c/locs.h | 1 + src/c/title.c | 32 ++++++++++++++++++++++++++++++++ src/c/title.h | 10 ++++++++++ src/m2-hack.asm | 11 +++++++++++ 7 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/c/title.c create mode 100644 src/c/title.h diff --git a/build.ps1 b/build.ps1 index a59f039..1d87443 100644 --- a/build.ps1 +++ b/build.ps1 @@ -18,7 +18,8 @@ $input_c_files = "src/c/fileselect.c", "src/c/status.c", "src/c/battle.c", - "src/c/psi.c" + "src/c/psi.c", + "src/c/title.c" $base_c_address = 0x83755B8; $scripttool_cmd = "bin/ScriptTool/ScriptTool.dll" diff --git a/src/c/ext.c b/src/c/ext.c index 7544fb9..9b8b769 100644 --- a/src/c/ext.c +++ b/src/c/ext.c @@ -19,4 +19,6 @@ int __attribute__((naked)) m2_setupwindow(WINDOW* window, short window_x, short 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) {} \ No newline at end of file +void __attribute__((naked)) m2_setupbattlename(short value) {} +void __attribute__((naked)) m2_title_teardown() {} +void __attribute__((naked)) vblank() {} diff --git a/src/c/locs.c b/src/c/locs.c index b4fb7c9..12ffb2b 100644 --- a/src/c/locs.c +++ b/src/c/locs.c @@ -27,3 +27,4 @@ int *m2_items_offsets = (int*) 0x8B1AF94; byte *m2_items_strings = (byte*) 0x8B1A694; unsigned short *name_header_tiles = (unsigned short*) 0x8B1B8B0; PSIPrintInfo *psi_print_info = (PSIPrintInfo*) 0x8B2A9C0; +int *title_counter = (int*) 0x2011B60; diff --git a/src/c/locs.h b/src/c/locs.h index 0a49495..fc44869 100644 --- a/src/c/locs.h +++ b/src/c/locs.h @@ -34,5 +34,6 @@ extern byte *m2_items_strings; extern unsigned short *name_header_tiles; extern byte *character_general_data; extern PSIPrintInfo *psi_print_info; +extern int *title_counter; #endif diff --git a/src/c/title.c b/src/c/title.c new file mode 100644 index 0000000..aceed30 --- /dev/null +++ b/src/c/title.c @@ -0,0 +1,32 @@ +#include "title.h" +#include "locs.h" + +int title_frame_first() +{ + if (*title_counter == 0) + { + m2_soundeffect(0xAF); + } + + (*title_counter)++; + + if (*title_counter == 5 * 60) + { + m2_title_teardown(); + return -1; + } + + return 0; +} + +int title_frame_second() +{ + vblank(); + + if (*title_counter == 5 * 60) + { + m2_title_teardown(); + } + + return 0; +} diff --git a/src/c/title.h b/src/c/title.h new file mode 100644 index 0000000..29c4e79 --- /dev/null +++ b/src/c/title.h @@ -0,0 +1,10 @@ +#ifndef HEADER_TITLE_INCLUDED +#define HEADER_TITLE_INCLUDED + +int title_frame_first(); +int title_frame_second(); +extern void m2_title_teardown(); +extern void m2_soundeffect(int index); +extern void vblank(); + +#endif diff --git a/src/m2-hack.asm b/src/m2-hack.asm index e6768b4..5e0ab4e 100644 --- a/src/m2-hack.asm +++ b/src/m2-hack.asm @@ -1542,6 +1542,10 @@ nop dw 0x2011940 dw 0x2011960 + // Expand the null area after the fifth palette buffer (gives us 0x2A0 bytes of nullspace + // starting at 0x2011B60) + .org 0x8011490 :: dw 0x85000128 + // Define the proper expected uncompressed sizes .org 0x801141E :: mov r5,4 :: neg r5,r5 .org 0x8011422 :: ldr r2,[r0,r5] @@ -1549,6 +1553,11 @@ nop .org 0x8011436 :: ldr r2,[r0,r5] .org 0x8011440 :: ldr r2,[r0,r5] + // Replace per-frame functions + .org 0x82D6B7C + dw title_frame_first + 1 + dw title_frame_second + 1 + // --- Animation 5 (quick title screen) --- .org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0 .org 0x82D6BE0 :: dh 0x1100 // Disable BG1 @@ -1749,11 +1758,13 @@ dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin" .definelabel m2_sub_d6844 ,0x80D6844 .definelabel m2_setupbattlename ,0x80DCD00 .definelabel m2_stat_symb_checker ,0x8B0EDA4 +.definelabel vblank ,0x80F47E4 .definelabel m2_div ,0x80F49D8 .definelabel m2_remainder ,0x80F4A70 .definelabel m2_items ,0x8B1D62C .definelabel m2_default_names ,0x82B9330 .definelabel m2_psi_print_table ,0x8B2A9C0 +.definelabel m2_title_teardown ,0x8000C28 //============================================================================== // Code files