Merge branch 'master' into custom_codes_related
This commit is contained in:
commit
1c21a8d2eb
|
@ -1,7 +1,5 @@
|
|||
Hacking, script tool, script compiler/decompiler:
|
||||
JeffMan
|
||||
|
||||
Hacking:
|
||||
JeffMan
|
||||
Lorenzooone
|
||||
PhoenixBound
|
||||
|
||||
|
@ -25,5 +23,25 @@ Text conversion:
|
|||
Normmatt
|
||||
KillThad
|
||||
|
||||
Graphics:
|
||||
JeffMan
|
||||
surrashubound
|
||||
Masaru
|
||||
|
||||
Testing:
|
||||
Eevs
|
||||
John Enigma
|
||||
CloverCharBoyBound
|
||||
|
||||
Graphics:
|
||||
JeffMan
|
||||
surrashubound
|
||||
Masaru
|
||||
|
||||
Testing:
|
||||
Eevs
|
||||
John Enigma
|
||||
CloverCharBoyBound
|
||||
|
||||
Special thanks:
|
||||
TragicManner
|
||||
|
|
|
@ -26,6 +26,7 @@ $input_c_files =
|
|||
"src/c/battle.c",
|
||||
"src/c/equip.c",
|
||||
"src/c/psi.c",
|
||||
"src/c/title.c",
|
||||
"src/c/luminehall.c",
|
||||
"src/c/custom_codes.c"
|
||||
|
||||
|
|
|
@ -0,0 +1,255 @@
|
|||
// Load intro screen
|
||||
|
||||
// 82D6AA8: structs of size 0x38
|
||||
// Offset Length Description
|
||||
// ------------------------------------
|
||||
// 0 4 BG0 graphics pointer (compressed)
|
||||
// 4 4 Sprite graphics pointer (compressed)
|
||||
// 8 4 BG palette pointer (compressed)
|
||||
// C 4 Sprite palette pointer (compressed)
|
||||
// 10 4 BG0 tilemap pointer (compressed)
|
||||
// 14 2 BG0 attributes
|
||||
// 16 2 Unused?
|
||||
// 18 4 BG1 tilemap pointer (compressed)
|
||||
// 1C 2 BG1 attributes
|
||||
// 1E 2 Unused?
|
||||
// 20 2 DISPCNT
|
||||
// 22 2 Some kind of index into a jump table (negative values are special)
|
||||
// 24 4 Unused?
|
||||
// 28 16 Four-entry jump table
|
||||
// [0]: called at the start of the animation
|
||||
// [1,2]: called for each frame (seems to be setup and then commit)
|
||||
// [3]: called at the end of the animation
|
||||
|
||||
// Dump:
|
||||
// -----
|
||||
// # BG0gfx OBJgfx BGpal OBJpal BG0map BG0attr BG1map BG1attr DISP jump - Start Setup Commit End
|
||||
// ------------------------------------------------------------------------------------------------------------------------------------
|
||||
// [0] 08714840 00000000 087147E4 00000000 087143FC 000B 0000 00000000 0000 0000 1100 0000 00000000 0801200D 080120B1 08012035 08012011
|
||||
// [1] 00000000 00000000 00000000 00000000 08714538 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011
|
||||
// [2] 00000000 00000000 00000000 00000000 08714688 000B 0000 00000000 0000 0000 1100 0001 00000000 0801200D 080120B1 08012035 08012011
|
||||
// [3] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1000 FFFF 00000000 080113F5 080115A9 08011499 08011495
|
||||
// [4] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011F05 08011499 08011495
|
||||
// [5] 0870F580 08711280 087126CC 087127E8 087128EC 000A 0000 08712CD8 010B 0000 1300 0001 00000000 080113F5 08011BFD 08011499 08011495
|
||||
// [6] 0871325C 00000000 08713210 00000000 08712FB8 000A 0000 00000000 0000 0000 0100 0001 00000000 0801200D 0801214D 08012035 08012011
|
||||
|
||||
// r0: screen key
|
||||
// 0 = Nintendo
|
||||
// 1 = APE
|
||||
// 2 = HALKEN
|
||||
// 3 = Title screen (full)
|
||||
// 5 = Title screen (quick)
|
||||
|
||||
// 0x18 byte struct: ($2028008)
|
||||
// Offset Length Description
|
||||
// ------------------------------------
|
||||
// 0 4 Animation number
|
||||
// 4 4 Current frame
|
||||
// 8 4 ?
|
||||
// C 4 ?
|
||||
// 10 4 ?
|
||||
// 14 4 Pointer to giant 0x2E0 byte struct used in $80113F5
|
||||
|
||||
080111D0 (T) push r4-r7,r14
|
||||
080111D2 (T) mov r7,r9
|
||||
080111D4 (T) mov r6,r8
|
||||
080111D6 (T) push r6,r7
|
||||
080111D8 (T) add sp,-4h
|
||||
080111DA (T) mov r5,r0
|
||||
080111DC (T) ldr r4,=3000370h
|
||||
080111DE (T) mov r0,18h
|
||||
080111E0 (T) bl 8005B9Ch // malloc 0x18 bytes for some struct
|
||||
080111E4 (T) str r0,[r4]
|
||||
080111E6 (T) str r5,[r0]
|
||||
080111E8 (T) mov r7,0h
|
||||
080111EA (T) str r7,[r0,14h]
|
||||
080111EC (T) str r7,[r0,4h]
|
||||
080111EE (T) str r7,[r0,10h] // zero out the struct
|
||||
080111F0 (T) ldr r6,=82D6AA8h
|
||||
080111F2 (T) lsl r0,r5,3h
|
||||
080111F4 (T) sub r0,r0,r5
|
||||
080111F6 (T) lsl r4,r0,3h // r4 = r5 * 0x38
|
||||
080111F8 (T) add r0,r4,r6
|
||||
080111FA (T) ldr r0,[r0]
|
||||
080111FC (T) cmp r0,0h
|
||||
080111FE (T) beq 801120Ch
|
||||
08011200 (T) mov r1,80h
|
||||
08011202 (T) lsl r1,r1,12h
|
||||
08011204 (T) mov r2,40h
|
||||
08011206 (T) lsl r2,r2,8h
|
||||
08011208 (T) bl 8005D34h
|
||||
0801120C (T) add r0,r6,4
|
||||
0801120E (T) add r0,r4,r0
|
||||
08011210 (T) ldr r0,[r0]
|
||||
08011212 (T) cmp r0,0h
|
||||
08011214 (T) beq 8011220h
|
||||
08011216 (T) ldr r1,=2008000h
|
||||
08011218 (T) mov r2,80h
|
||||
0801121A (T) lsl r2,r2,8h
|
||||
0801121C (T) bl 8005D34h
|
||||
08011220 (T) mov r0,r6
|
||||
08011222 (T) add r0,8h
|
||||
08011224 (T) add r0,r4,r0
|
||||
08011226 (T) ldr r3,[r0]
|
||||
08011228 (T) cmp r3,0h
|
||||
0801122A (T) beq 801126Ch
|
||||
0801122C (T) mov r0,1h
|
||||
0801122E (T) neg r0,r0
|
||||
08011230 (T) cmp r3,r0
|
||||
08011232 (T) bne 8011260h
|
||||
08011234 (T) str r7,[sp]
|
||||
08011236 (T) ldr r1,=40000D4h
|
||||
08011238 (T) mov r0,r13
|
||||
0801123A (T) str r0,[r1]
|
||||
0801123C (T) ldr r0,=2010000h
|
||||
0801123E (T) str r0,[r1,4h]
|
||||
08011240 (T) ldr r0,=85000080h
|
||||
08011242 (T) str r0,[r1,8h]
|
||||
08011244 (T) ldr r0,[r1,8h]
|
||||
08011246 (T) b 801126Ch
|
||||
08011248 (T) lsl r0,r6,0Dh
|
||||
0801124A (T) lsl r0,r0,0Ch
|
||||
0801124C (T) ldr r0,[r5,28h]
|
||||
0801124E (T) lsr r5,r5,20h
|
||||
08011250 (T) strh r0,[r0]
|
||||
08011252 (T) lsl r0,r0,8h
|
||||
08011254 (T) lsl r4,r2,3h
|
||||
08011256 (T) lsl r0,r0,10h
|
||||
08011258 (T) lsl r0,r0,0h
|
||||
0801125A (T) lsl r1,r0,8h
|
||||
0801125C (T) lsl r0,r0,2h
|
||||
0801125E (T) strh r0,[r0,28h]
|
||||
08011260 (T) ldr r1,=2010000h
|
||||
08011262 (T) mov r2,80h
|
||||
08011264 (T) lsl r2,r2,2h
|
||||
08011266 (T) mov r0,r3
|
||||
08011268 (T) bl 8005D34h
|
||||
0801126C (T) ldr r1,=82D6AA8h
|
||||
0801126E (T) mov r9,r1
|
||||
08011270 (T) lsl r0,r5,3h
|
||||
08011272 (T) sub r0,r0,r5
|
||||
08011274 (T) lsl r7,r0,3h
|
||||
08011276 (T) mov r0,r9
|
||||
08011278 (T) add r0,0Ch
|
||||
0801127A (T) add r0,r7,r0
|
||||
0801127C (T) ldr r0,[r0]
|
||||
0801127E (T) cmp r0,0h
|
||||
08011280 (T) beq 801128Ch
|
||||
08011282 (T) ldr r1,=2010200h
|
||||
08011284 (T) mov r2,80h
|
||||
08011286 (T) lsl r2,r2,2h
|
||||
08011288 (T) bl 8005D34h
|
||||
0801128C (T) mov r0,r9
|
||||
0801128E (T) add r0,10h
|
||||
08011290 (T) add r0,r7,r0
|
||||
08011292 (T) ldr r0,[r0]
|
||||
08011294 (T) cmp r0,0h
|
||||
08011296 (T) beq 80112A2h
|
||||
08011298 (T) ldr r1,=2010400h
|
||||
0801129A (T) mov r2,80h
|
||||
0801129C (T) lsl r2,r2,4h
|
||||
0801129E (T) bl 8005D34h
|
||||
080112A2 (T) mov r0,r9
|
||||
080112A4 (T) add r0,18h
|
||||
080112A6 (T) add r0,r7,r0
|
||||
080112A8 (T) ldr r0,[r0]
|
||||
080112AA (T) cmp r0,0h
|
||||
080112AC (T) beq 80112B8h
|
||||
080112AE (T) ldr r1,=2010C00h
|
||||
080112B0 (T) mov r2,80h
|
||||
080112B2 (T) lsl r2,r2,4h
|
||||
080112B4 (T) bl 8005D34h
|
||||
080112B8 (T) ldr r0,=2010000h
|
||||
080112BA (T) mov r8,r0
|
||||
080112BC (T) mov r0,0h
|
||||
080112BE (T) mov r1,r8
|
||||
080112C0 (T) strh r0,[r1]
|
||||
080112C2 (T) bl 80F47E4h
|
||||
080112C6 (T) bl 800E5E4h
|
||||
080112CA (T) ldr r4,=40000D4h
|
||||
080112CC (T) mov r0,80h
|
||||
080112CE (T) lsl r0,r0,12h
|
||||
080112D0 (T) str r0,[r4]
|
||||
080112D2 (T) ldr r0,=6008000h
|
||||
080112D4 (T) str r0,[r4,4h]
|
||||
080112D6 (T) ldr r5,=84001000h
|
||||
080112D8 (T) str r5,[r4,8h]
|
||||
080112DA (T) ldr r0,[r4,8h]
|
||||
080112DC (T) ldr r6,=4000006h
|
||||
080112DE (T) ldrh r0,[r6]
|
||||
080112E0 (T) bl 80F47E4h
|
||||
080112E4 (T) bl 800E5E4h
|
||||
080112E8 (T) ldr r0,=2004000h
|
||||
080112EA (T) str r0,[r4]
|
||||
080112EC (T) ldr r0,=600C000h
|
||||
080112EE (T) str r0,[r4,4h]
|
||||
080112F0 (T) str r5,[r4,8h]
|
||||
080112F2 (T) ldr r0,[r4,8h]
|
||||
080112F4 (T) ldrh r0,[r6]
|
||||
080112F6 (T) bl 80F47E4h
|
||||
080112FA (T) bl 800E5E4h
|
||||
080112FE (T) ldr r1,=4000008h
|
||||
08011300 (T) mov r0,r9
|
||||
08011302 (T) add r5,r7,r0
|
||||
08011304 (T) ldrh r0,[r5,14h]
|
||||
08011306 (T) strh r0,[r1]
|
||||
08011308 (T) add r1,2h
|
||||
0801130A (T) ldrh r0,[r5,1Ch]
|
||||
0801130C (T) strh r0,[r1]
|
||||
0801130E (T) mov r1,r8
|
||||
08011310 (T) str r1,[r4]
|
||||
08011312 (T) mov r0,0A0h
|
||||
08011314 (T) lsl r0,r0,13h
|
||||
08011316 (T) str r0,[r4,4h]
|
||||
08011318 (T) ldr r0,=84000080h
|
||||
0801131A (T) mov r9,r0
|
||||
0801131C (T) str r0,[r4,8h]
|
||||
0801131E (T) ldr r0,[r4,8h]
|
||||
08011320 (T) ldr r0,=2010400h
|
||||
08011322 (T) str r0,[r4]
|
||||
08011324 (T) mov r0,0C0h
|
||||
08011326 (T) lsl r0,r0,13h
|
||||
08011328 (T) str r0,[r4,4h]
|
||||
0801132A (T) ldr r1,=84000200h
|
||||
0801132C (T) mov r8,r1
|
||||
0801132E (T) str r1,[r4,8h]
|
||||
08011330 (T) ldr r0,[r4,8h]
|
||||
08011332 (T) ldrh r0,[r6]
|
||||
08011334 (T) bl 80F47E4h
|
||||
08011338 (T) bl 800E5E4h
|
||||
0801133C (T) ldr r0,=2008000h
|
||||
0801133E (T) str r0,[r4]
|
||||
08011340 (T) ldr r0,=6010000h
|
||||
08011342 (T) str r0,[r4,4h]
|
||||
08011344 (T) ldr r0,=84002000h
|
||||
08011346 (T) str r0,[r4,8h]
|
||||
08011348 (T) ldr r0,[r4,8h]
|
||||
0801134A (T) ldrh r0,[r6]
|
||||
0801134C (T) bl 80F47E4h
|
||||
08011350 (T) bl 800E5E4h
|
||||
08011354 (T) mov r1,80h
|
||||
08011356 (T) lsl r1,r1,13h
|
||||
08011358 (T) ldrh r0,[r5,20h]
|
||||
0801135A (T) strh r0,[r1]
|
||||
0801135C (T) ldr r0,=2010200h
|
||||
0801135E (T) str r0,[r4]
|
||||
08011360 (T) ldr r0,=5000200h
|
||||
08011362 (T) str r0,[r4,4h]
|
||||
08011364 (T) mov r0,r9
|
||||
08011366 (T) str r0,[r4,8h]
|
||||
08011368 (T) ldr r0,[r4,8h]
|
||||
0801136A (T) ldr r0,=2010C00h
|
||||
0801136C (T) str r0,[r4]
|
||||
0801136E (T) ldr r0,=6000800h
|
||||
08011370 (T) str r0,[r4,4h]
|
||||
08011372 (T) mov r1,r8
|
||||
08011374 (T) str r1,[r4,8h]
|
||||
08011376 (T) ldr r0,[r4,8h]
|
||||
08011378 (T) ldrh r0,[r6]
|
||||
0801137A (T) add sp,4h
|
||||
0801137C (T) pop r3,r4
|
||||
0801137E (T) mov r8,r3
|
||||
08011380 (T) mov r9,r4
|
||||
08011382 (T) pop r4-r7
|
||||
08011384 (T) pop r0
|
||||
08011386 (T) bx r0
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,27 @@
|
|||
712F10
|
||||
------
|
||||
Title text sprite entry table. First word is OAM source pointer, second word is number of sprites to load.
|
||||
|
||||
68 2E 71 08 02 00 00 00 M (2 sprites)
|
||||
78 2E 71 08 06 00 00 00 O (6 sprites)
|
||||
A8 2E 71 08 02 00 00 00 T (2 sprites)
|
||||
B8 2E 71 08 02 00 00 00 H (2 sprites)
|
||||
C8 2E 71 08 02 00 00 00 E (2 sprites)
|
||||
D8 2E 71 08 02 00 00 00 R (2 sprites)
|
||||
E8 2E 71 08 04 00 00 00 Subtitle (4 sprites)
|
||||
08 2F 71 08 01 00 00 00 (R) (1 sprites)
|
||||
|
||||
We have nine letters to do but there's only room in the table for eight; will figure out how to expand it later.
|
||||
|
||||
We'll use 32x64 sprites so that we only need one sprite for each letter (the Japanese version uses 2-6 sprites for each letter).
|
||||
|
||||
Final text positions:
|
||||
|
||||
18 -> 0E
|
||||
38 -> 22
|
||||
68 -> 38
|
||||
80 -> 4A
|
||||
A0 -> 5C
|
||||
B8 -> 8C
|
||||
98 -> A0
|
||||
D2 -> B5
|
|
@ -27,3 +27,6 @@ void __attribute__((naked)) load_pixels_overworld() {}
|
|||
void __attribute__((naked)) generic_reprinting_first_menu_talk_to_highlight() {}
|
||||
void __attribute__((naked)) m12_dim_palette(short* palette, int total, int dimmingFactor) {}
|
||||
int __attribute__((naked)) m2_jump_to_offset(byte* character) {}
|
||||
byte* __attribute__((naked)) m2_malloc(int size) {}
|
||||
void __attribute__((naked)) m2_title_teardown() {}
|
||||
void __attribute__((naked)) vblank() {}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
#include "title.h"
|
||||
|
||||
void title_text_sequence(
|
||||
TITLE_CONTROL *control,
|
||||
TITLE_EXTENDED *ext,
|
||||
TITLE_COORD_TABLE *coords)
|
||||
{
|
||||
int duration = 140; // approximate length of EB's animation,
|
||||
// from the first frame that H is visible
|
||||
// until all letters have stopped moving
|
||||
int frame = control->frame;
|
||||
|
||||
if (frame > duration)
|
||||
{
|
||||
control->frame = -1;
|
||||
ext->sequence++;
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < 9; i++)
|
||||
{
|
||||
int x_start = coords->x_start[i];
|
||||
int x_end = coords->x_end[i];
|
||||
int x_delta = x_end - x_start;
|
||||
int x_new = (m2_div((x_delta * frame) << 12, duration) >> 12) + x_start;
|
||||
|
||||
// X coordinate is only 9 bits signed, so clamp the values to a reasonable range
|
||||
if (x_new < -250)
|
||||
x_new = -250;
|
||||
if (x_new > 250)
|
||||
x_new = 250;
|
||||
|
||||
ext->sprites[i].x = x_new;
|
||||
ext->sprites[i].y = coords->y_end[i]; // we're not translating the sprites vertically
|
||||
}
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
#ifndef HEADER_TITLE_INCLUDED
|
||||
#define HEADER_TITLE_INCLUDED
|
||||
|
||||
#include "types.h"
|
||||
|
||||
typedef struct TITLE_COORD_TABLE {
|
||||
int unknown_a[3];
|
||||
int y_end[9];
|
||||
int y_start[9];
|
||||
int x_end[9];
|
||||
int x_start[9];
|
||||
} TITLE_COORD_TABLE;
|
||||
|
||||
typedef struct TITLE_SPRITE {
|
||||
struct TITLE_SPRITE *prev;
|
||||
void *anim_table;
|
||||
void *oam_entry_table;
|
||||
void *unknown_table;
|
||||
int unknown_a[5];
|
||||
int x;
|
||||
int y;
|
||||
int unknown_b[5];
|
||||
} TITLE_SPRITE;
|
||||
|
||||
typedef struct TITLE_EXTENDED {
|
||||
unsigned short *pal_buffer[5];
|
||||
byte unknown_a[0x70];
|
||||
int sequence;
|
||||
TITLE_SPRITE sprites[9];
|
||||
int unknown[0x16];
|
||||
} TITLE_EXTENDED;
|
||||
|
||||
typedef struct TITLE_CONTROL {
|
||||
int unknown_a;
|
||||
int frame;
|
||||
int unknown_b[3];
|
||||
TITLE_EXTENDED *ext;
|
||||
int unknown_c[2];
|
||||
} TITLE_CONTROL;
|
||||
|
||||
void title_text_sequence(
|
||||
TITLE_CONTROL *control,
|
||||
TITLE_EXTENDED *ext,
|
||||
TITLE_COORD_TABLE *coords);
|
||||
|
||||
extern int m2_div(int dividend, int divisor);
|
||||
|
||||
#endif
|
126
src/c/vwf.c
126
src/c/vwf.c
|
@ -72,10 +72,9 @@ byte reduce_bit_depth(int row, int foregroundRow)
|
|||
|
||||
//The order is swapped in order to make this faster
|
||||
//Doing the bottom tile directly saves some cycles
|
||||
void reduce_bit_depth_sp(int* TileRows, int* bufferValues)
|
||||
void reduce_bit_depth_sp(int* TileRows, int* bufferValues, int* bottomBufferValues)
|
||||
{
|
||||
int* bottomTileRows = TileRows + (0x20 * 8);
|
||||
int* bottomBufferValues = bufferValues + 0x40;
|
||||
const int andValue = 0x11111111;
|
||||
|
||||
//First value
|
||||
|
@ -479,6 +478,19 @@ byte print_character_with_callback(byte chr, int x, int y, int font, int foregro
|
|||
return virtualWidth;
|
||||
}
|
||||
|
||||
int convert_tile_address_buffer(int tile)
|
||||
{
|
||||
//Allows using tiles with different size to make the buffer smaller
|
||||
tile -= *tile_offset;
|
||||
int inner_line = tile & 0x3F;
|
||||
int lines = (tile >> 6) << 5;
|
||||
int returned_address = ((*tile_offset) * TILESET_OFFSET_BUFFER_MULTIPLIER) + (lines * DEFAULT_DOUBLE_TILE_HEIGHT);
|
||||
|
||||
if(inner_line >= 0x20)
|
||||
return returned_address + (0x20 * 8) + ((inner_line & 0x1F) * (DEFAULT_DOUBLE_TILE_HEIGHT - 8));
|
||||
return returned_address + (inner_line * 8);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -526,7 +538,7 @@ byte print_character_with_callback_1bpp_buffer(byte chr, int x, int y, byte *des
|
|||
|
||||
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 canvasRow = dest[convert_tile_address_buffer(realTileIndex) + ((row + offsetY - sumRemoved) & 7)] + (dest[convert_tile_address_buffer(realTileIndexRight) + ((row + offsetY - sumRemoved) & 7)] << 8);
|
||||
unsigned short glyphRow = glyphRows[row + (dTileY * 8 * tileWidth) + (dTileX * 8)] << offsetX;
|
||||
|
||||
unsigned short tmpCanvasRow = canvasRow;
|
||||
|
@ -535,8 +547,8 @@ byte print_character_with_callback_1bpp_buffer(byte chr, int x, int y, byte *des
|
|||
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;
|
||||
dest[convert_tile_address_buffer(realTileIndex) + ((row + offsetY - sumRemoved) & 7)] = canvasRow;
|
||||
dest[convert_tile_address_buffer(realTileIndexRight) + ((row + offsetY - sumRemoved) & 7)] = canvasRow >> 8;
|
||||
|
||||
if((row + offsetY - sumRemoved) == limit)
|
||||
{
|
||||
|
@ -1739,9 +1751,10 @@ void clear_tile_buffer(int x, int y, byte* dest)
|
|||
{
|
||||
// Clear pixels
|
||||
int tileIndex = get_tile_number_buffer(x, y) + *tile_offset;
|
||||
int *destTileInt = (int*)&dest[(tileIndex) * 8];
|
||||
int *destTileInt = (int*)&dest[convert_tile_address_buffer(tileIndex)];
|
||||
destTileInt[0] = 0;
|
||||
destTileInt[1] = 0;
|
||||
if(((tileIndex - *tile_offset) & 0x20) == 0)
|
||||
destTileInt[1] = 0;
|
||||
|
||||
// Reset the tilemap (e.g. get rid of equip or SMAAAASH!! tiles)
|
||||
(*tilemap_pointer)[x + (y * 32)] = (get_tile_number(x, y) + (*tile_offset)) | *palette_mask;
|
||||
|
@ -1940,6 +1953,27 @@ void printCashWindow()
|
|||
m2_sub_d3c50();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
// x, y, width: tile coordinates
|
||||
void print_blankstr_buffer(int x, int y, int width, byte *dest)
|
||||
{
|
||||
|
@ -2004,11 +2038,25 @@ int print_alphabet_buffer(WINDOW* window)
|
|||
}
|
||||
}
|
||||
|
||||
int check_overworld_buffer()
|
||||
{
|
||||
int address = *((int*)(OVERWORLD_BUFFER_POINTER));
|
||||
if(address == 0)
|
||||
{
|
||||
int tmp_counter = m2_buffer_counter;
|
||||
address = (int)m2_malloc(OVERWORLD_BUFFER_SIZE);
|
||||
*((int*)(OVERWORLD_BUFFER_POINTER)) = address;
|
||||
m2_buffer_counter = tmp_counter;
|
||||
}
|
||||
return address;
|
||||
}
|
||||
|
||||
void load_pixels_overworld_buffer()
|
||||
{
|
||||
int tile = *tile_offset;
|
||||
byte* buffer = (byte*)(OVERWORLD_BUFFER - (tile * TILESET_OFFSET_BUFFER_MULTIPLIER));
|
||||
int* topBufferValues = (int*)(&buffer[tile * 8]);
|
||||
int* bottomBufferValues = topBufferValues + 0x40;
|
||||
int* topTilePointer;
|
||||
int nextValue = 0x20;
|
||||
int i = 0;
|
||||
|
@ -2022,24 +2070,28 @@ void load_pixels_overworld_buffer()
|
|||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues = bottomBufferValues;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
//Using "reduce_bit_depth_sp" reduced the total amount of cycles from 300k to 162k
|
||||
reduce_bit_depth_sp(topTilePointer, topBufferValues);
|
||||
reduce_bit_depth_sp(topTilePointer, topBufferValues, bottomBufferValues);
|
||||
topTilePointer += 8;
|
||||
topBufferValues += 2;
|
||||
bottomBufferValues++;
|
||||
while(remainingTiles > 0)
|
||||
{
|
||||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues = bottomBufferValues;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
reduce_bit_depth_sp(topTilePointer, topBufferValues);
|
||||
reduce_bit_depth_sp(topTilePointer, topBufferValues, bottomBufferValues);
|
||||
topTilePointer += 8;
|
||||
topBufferValues += 2;
|
||||
bottomBufferValues++;
|
||||
remainingTiles--;
|
||||
}
|
||||
}
|
||||
|
@ -2079,7 +2131,7 @@ void store_pixels_overworld_buffer(int totalYs)
|
|||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues += 0x20;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
|
@ -2100,7 +2152,6 @@ void store_pixels_overworld_buffer(int totalYs)
|
|||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x10) & 0xFF];
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x18) & 0xFF];
|
||||
//Since those are unused
|
||||
bottomBufferValues++;
|
||||
bottomTilePointer += 4;
|
||||
/* The game doesn't use these
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(second_half >> 0) & 0xFF];
|
||||
|
@ -2114,7 +2165,7 @@ void store_pixels_overworld_buffer(int totalYs)
|
|||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues += 0x20;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
|
@ -2135,7 +2186,6 @@ void store_pixels_overworld_buffer(int totalYs)
|
|||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x10) & 0xFF];
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x18) & 0xFF];
|
||||
//Since those are unused
|
||||
bottomBufferValues++;
|
||||
bottomTilePointer += 4;
|
||||
/* The game doesn't use these
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(second_half >> 0) & 0xFF];
|
||||
|
@ -2148,27 +2198,6 @@ 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;
|
||||
|
@ -2201,7 +2230,7 @@ void store_pixels_overworld_buffer_totalTiles(int totalTiles)
|
|||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues += 0x20;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
|
@ -2222,7 +2251,6 @@ void store_pixels_overworld_buffer_totalTiles(int totalTiles)
|
|||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x10) & 0xFF];
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x18) & 0xFF];
|
||||
//Since those are unused
|
||||
bottomBufferValues++;
|
||||
bottomTilePointer += 4;
|
||||
/* The game doesn't use these
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(second_half >> 0) & 0xFF];
|
||||
|
@ -2236,7 +2264,7 @@ void store_pixels_overworld_buffer_totalTiles(int totalTiles)
|
|||
if(i == nextValue)
|
||||
{
|
||||
nextValue += 0x20;
|
||||
topBufferValues += 0x40;
|
||||
topBufferValues += 0x20;
|
||||
bottomBufferValues += 0x40;
|
||||
}
|
||||
i++;
|
||||
|
@ -2257,7 +2285,6 @@ void store_pixels_overworld_buffer_totalTiles(int totalTiles)
|
|||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x10) & 0xFF];
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(first_half >> 0x18) & 0xFF];
|
||||
//Since those are unused
|
||||
bottomBufferValues++;
|
||||
bottomTilePointer += 4;
|
||||
/* The game doesn't use these
|
||||
*(bottomTilePointer++) = bits_to_nybbles_pointer[(second_half >> 0) & 0xFF];
|
||||
|
@ -2281,10 +2308,23 @@ void copy_tile_buffer(int xSource, int ySource, int xDest, int yDest, byte *dest
|
|||
{
|
||||
int sourceTileIndex = get_tile_number_buffer(xSource, ySource) + *tile_offset;
|
||||
int destTileIndex = get_tile_number_buffer(xDest, yDest) + *tile_offset;
|
||||
int* sourceTile = (int*)&dest[sourceTileIndex * 8];
|
||||
int* destTile = (int*)&dest[destTileIndex * 8];
|
||||
int* sourceTile = (int*)&dest[convert_tile_address_buffer(sourceTileIndex)];
|
||||
int* destTile = (int*)&dest[convert_tile_address_buffer(destTileIndex)];
|
||||
|
||||
//Copy the first part, no matter what
|
||||
destTile[0] = sourceTile[0];
|
||||
destTile[1] = sourceTile[1];
|
||||
//Handle the 4 different cases
|
||||
if(((sourceTileIndex - *tile_offset) & 0x20) == 0)
|
||||
{
|
||||
if(((destTileIndex - *tile_offset) & 0x20) == 0)
|
||||
destTile[1] = sourceTile[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if(((destTileIndex - *tile_offset) & 0x20) == 0)
|
||||
destTile[1] = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// x,y: tile coordinates
|
||||
|
|
10
src/c/vwf.h
10
src/c/vwf.h
|
@ -8,6 +8,7 @@
|
|||
#define FALSE 0
|
||||
|
||||
#define TILESET_OFFSET_BUFFER_MULTIPLIER 0x8
|
||||
#define DEFAULT_DOUBLE_TILE_HEIGHT 0xC
|
||||
#define CHAR_OFFSET 0x50
|
||||
#define CHAR_END 0x60
|
||||
#define YOUWON_START 0x64
|
||||
|
@ -22,7 +23,9 @@
|
|||
#define WINDOW_HEADER_Y 0x11
|
||||
#define WINDOW_HEADER_TILE (WINDOW_HEADER_X + (WINDOW_HEADER_Y * 32))
|
||||
|
||||
#define OVERWORLD_BUFFER 0x200F200
|
||||
#define OVERWORLD_BUFFER_POINTER 0x2028008
|
||||
#define OVERWORLD_BUFFER_SIZE 0xA80
|
||||
#define OVERWORLD_BUFFER check_overworld_buffer()
|
||||
|
||||
#define CUSTOMCC_SET_X 0x5F
|
||||
#define CUSTOMCC_ADD_X 0x60
|
||||
|
@ -41,7 +44,7 @@ int count_pixels_to_tiles(byte *str, int length, int startingPos);
|
|||
int count_pixels_to_tiles_normal_string(byte *str, int startingPos);
|
||||
int expand_bit_depth(byte row, byte foreground);
|
||||
byte reduce_bit_depth(int row, int foregroundRow);
|
||||
void reduce_bit_depth_sp(int* TileRows, int* bufferValues);
|
||||
void reduce_bit_depth_sp(int* TileRows, int* bufferValues, int* bottomBufferValues);
|
||||
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_to_window(byte chr, WINDOW* window);
|
||||
|
@ -125,6 +128,7 @@ int highlight_string(WINDOW* window, byte* str, unsigned short x, unsigned short
|
|||
void highlight_talk_to();
|
||||
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);
|
||||
int check_overworld_buffer();
|
||||
void load_pixels_overworld_buffer();
|
||||
void store_pixels_overworld_buffer(int totalYs);
|
||||
void store_pixels_overworld_buffer_totalTiles(int totalTiles);
|
||||
|
@ -133,6 +137,7 @@ void eb_cartridge_palette_change(bool background);
|
|||
extern unsigned short m2_coord_table_fast_progression[];
|
||||
extern unsigned short m2_coord_table[];
|
||||
extern byte m2_ness_name[];
|
||||
extern int m2_buffer_counter;
|
||||
extern int m2_bits_to_nybbles[];
|
||||
extern int m2_bits_to_nybbles_fast[];
|
||||
extern byte m2_nybbles_to_bits[];
|
||||
|
@ -173,3 +178,4 @@ extern void m2_sub_d6844();
|
|||
extern int m2_setupwindow(WINDOW* window, short window_x, short window_y, short window_width, short window_height);
|
||||
extern void m2_setupbattlename(short value);
|
||||
extern void store_pixels_overworld();
|
||||
extern byte* m2_malloc();
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
283
src/m2-hack.asm
283
src/m2-hack.asm
|
@ -51,6 +51,12 @@ mov r3,6
|
|||
|
||||
.org 0x800027A :: bl m12_intro_screen
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Allocate the printing buffer when the content previously allocated is reset
|
||||
//---------------------------------------------------------
|
||||
|
||||
.org 0x8005B80 :: bl _05b80_alloc_buffer_pointer
|
||||
|
||||
//---------------------------------------------------------
|
||||
// C0A5C hacks (status window)
|
||||
//---------------------------------------------------------
|
||||
|
@ -1764,6 +1770,226 @@ nop
|
|||
//Add an extra event for the "?" in "THE END..."
|
||||
.org 0x80A5F5C :: bl extra_event_end_question_mark
|
||||
|
||||
//==============================================================================
|
||||
// M2 Title hacks
|
||||
//==============================================================================
|
||||
|
||||
.definelabel m2_title_sequence_00, 0x80117E0
|
||||
.definelabel m2_title_sequence_01, 0x8011802
|
||||
.definelabel m2_title_sequence_02, 0x801182A
|
||||
.definelabel m2_title_sequence_03, 0x8011858
|
||||
.definelabel m2_title_sequence_04, 0x80118FA
|
||||
.definelabel m2_title_sequence_05, 0x80118FE
|
||||
.definelabel m2_title_sequence_06, 0x801195C
|
||||
.definelabel m2_title_sequence_07, 0x8011972
|
||||
.definelabel m2_title_sequence_08, 0x80119BA
|
||||
.definelabel m2_title_sequence_09, 0x80119DE
|
||||
.definelabel m2_title_sequence_0A, 0x8011A02
|
||||
.definelabel m2_title_sequence_0B, 0x8011A1A
|
||||
.definelabel m2_title_sequence_0C, 0x8011A80
|
||||
.definelabel m2_title_sequence_0D, 0x8011A8A
|
||||
.definelabel m2_title_sequence_0E, 0x8011AAA
|
||||
.definelabel m2_title_sequence_0F, 0x8011B58
|
||||
.definelabel m2_title_sequence_10, 0x8011B66
|
||||
.definelabel m2_title_sequence_11, 0x8011B76
|
||||
|
||||
// m2_title_background_pal_copyright: File has two palettes separated by six palettes
|
||||
// worth of nullspace. First palette is the copyright palette,
|
||||
// last palette is a placeholder for the glow palette
|
||||
// m2_title_background_pal_glow: 20 frames, glow effect
|
||||
// m2_title_text_pal_animated: 14 frames, white horizontal line scrolling top to bottom
|
||||
// m2_title_text_pal_static: 1 frame, white text on black background
|
||||
|
||||
// BG0 will be used for the B, the glow, and copyright info
|
||||
// OAM will be used for the other letters
|
||||
|
||||
// Background palette RAM layout:
|
||||
// [0]: copyright
|
||||
// [1-6]: (blank)
|
||||
// [7]: glow
|
||||
// [8]: B
|
||||
// [9-15]: (blank)
|
||||
|
||||
// Frame states (BG0), from EarthBound:
|
||||
// Start Duration State
|
||||
// --------------------------
|
||||
// 0 g Black
|
||||
// g 1 1/32 grey B
|
||||
// g+1 2 2/32 grey B
|
||||
// g+3 2 3/32 grey B
|
||||
// g+5 2 4/32 grey B
|
||||
// g+7 2 5/32 grey B
|
||||
// g+9 2 6/32 grey B
|
||||
// g+11 2 7/32 grey B
|
||||
// g+13 2 8/32 grey B
|
||||
// g+15 2 9/32 grey B
|
||||
// g+17 2 10/32 grey B
|
||||
// g+19 2 11/32 grey B
|
||||
// g+21 2 12/32 grey B
|
||||
// g+23 2 13/32 grey B
|
||||
// g+25 2 14/32 grey B
|
||||
// g+27 2 15/32 grey B
|
||||
// g+29 1 16/32 grey B
|
||||
// g+30 2 17/32 grey B
|
||||
|
||||
// --- Animation 3 (full title screen) ---
|
||||
.org 0x82D6B64 :: dh 0x008A // Enable 8-bit BG0
|
||||
|
||||
// Initializer hacks:
|
||||
|
||||
// Point to new compressed palettes
|
||||
.org 0x801147C
|
||||
dw m2_title_text_pal_animated + 4
|
||||
dw m2_title_text_pal_static + 4
|
||||
dw m2_title_background_pal_copyright + 4
|
||||
dw m2_title_background_pal_glow + 4
|
||||
|
||||
// The new palettes have different sizes (8, 20, 14, 1 palettes respectively), so encode the proper buffer pointers
|
||||
.org 0x801146C
|
||||
dw 0x2011500
|
||||
dw 0x2011780
|
||||
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]
|
||||
.org 0x801142C :: ldr r2,[r0,r5]
|
||||
.org 0x8011436 :: ldr r2,[r0,r5]
|
||||
.org 0x8011440 :: ldr r2,[r0,r5]
|
||||
|
||||
// Point to custom initializer routine
|
||||
.org 0x82D6B78 :: dw title_initializer + 1
|
||||
|
||||
// Setup hacks:
|
||||
|
||||
// Fade BG0 instead of OBJ
|
||||
.org 0x80117E6 :: mov r0,0xC1
|
||||
|
||||
// Point to sequence hacks
|
||||
.org 0x8011798 :: dw title_sequence_00
|
||||
.org 0x801179C :: dw title_sequence_01
|
||||
.org 0x80117A4 :: dw title_sequence_03
|
||||
.org 0x80117A8 :: dw title_sequence_04
|
||||
.org 0x80117AC :: dw title_sequence_05
|
||||
.org 0x80117B4 :: dw title_sequence_07
|
||||
.org 0x80117B8 :: dw title_sequence_08
|
||||
.org 0x80117BC :: dw title_sequence_09
|
||||
.org 0x80117C4 :: dw title_sequence_0B
|
||||
.org 0x80117C8 :: dw title_sequence_0C
|
||||
.org 0x80117CC :: dw title_sequence_0D
|
||||
.org 0x80117D0 :: dw title_sequence_0D
|
||||
.org 0x80117D4 :: dw title_sequence_0D
|
||||
.org 0x80117D8 :: dw title_sequence_0D
|
||||
|
||||
// Clamp initial X values for text
|
||||
.org 0x80116F0 :: bl title_setup_clamp
|
||||
|
||||
// Show all eight text sprites from the start
|
||||
.org 0x8011B94 :: mov r6,8
|
||||
.org 0x8011BAC :: b 0x8011BDC
|
||||
|
||||
// Allocate space for nine sprites
|
||||
.org 0x80113F8 :: mov r0,0xC8
|
||||
.org 0x80115B2 :: add sp,-0xA4
|
||||
.org 0x8011BE6 :: add sp,0xA4
|
||||
|
||||
.org 0x80115CC
|
||||
ldmia [r0]!,r2,r4,r7
|
||||
stmia [r1]!,r2,r4,r7
|
||||
add r6,sp,0x30
|
||||
|
||||
.org 0x80115DE
|
||||
ldmia [r0]!,r2,r4,r7
|
||||
stmia [r1]!,r2,r4,r7
|
||||
add r5,sp,0x54
|
||||
|
||||
.org 0x80115F0
|
||||
ldmia [r0]!,r2,r4,r7
|
||||
stmia [r1]!,r2,r4,r7
|
||||
add r4,sp,0x78
|
||||
|
||||
.org 0x8011602
|
||||
ldmia [r0]!,r2,r3,r7
|
||||
stmia [r1]!,r2,r3,r7
|
||||
|
||||
.org 0x8011646 :: ldr r1,[sp,0x5C]
|
||||
.org 0x801166A :: add r1,0x60 :: str r1,[sp,0x9C]
|
||||
.org 0x8011670 :: add r2,0x84 :: str r2,[sp,0xA0]
|
||||
.org 0x8011686 :: ldr r0,[sp,0xA0]
|
||||
.org 0x801168A :: str r0,[sp,0xA0] :: ldr r2,[sp,0x9C]
|
||||
.org 0x8011690 :: str r2,[sp,0x9C]
|
||||
.org 0x80116CC :: add r7,sp,0x30
|
||||
.org 0x80116D0 :: add r7,sp,0x78
|
||||
.org 0x8011704 :: cmp r6,8
|
||||
|
||||
// Relocate stuff from after the sprite data
|
||||
.org 0x8011634 :: mov r1,0xB2
|
||||
.org 0x8011640 :: mov r2,0xC2
|
||||
.org 0x801164E :: mov r1,0xBE
|
||||
.org 0x801165C :: mov r7,0xC2
|
||||
.org 0x8011662 :: mov r5,0xC3
|
||||
.org 0x8011674 :: mov r3,0xB2
|
||||
.org 0x801167C :: mov r4,0xB3
|
||||
.org 0x8011696 :: mov r0,0xBE
|
||||
.org 0x8011838 :: mov r1,0xB6
|
||||
|
||||
// Commit hacks:
|
||||
|
||||
// Commit all things on every sequence
|
||||
.org 0x8011500 :: b 0x8011516
|
||||
|
||||
// --- Animation 5 (quick title screen) ---
|
||||
.org 0x82D6BD4 :: dh 0x008A // Enable 8-bit BG0
|
||||
.org 0x82D6BE0 :: dh 0x1100 // Disable BG1
|
||||
.org 0x82D6BC8 :: dw m2_title_quick_background_pal
|
||||
.org 0x82D6BCC :: dw m2_title_quick_foreground_pal
|
||||
|
||||
// Initializer hacks
|
||||
|
||||
// Make it so the first entry of the first palette isn't cleared
|
||||
.org 0x80112BE :: bl _112be_remove_pal_blanking_quick_title
|
||||
|
||||
// Point to custom initializer routine
|
||||
.org 0x82D6BE8 :: dw title_initializer + 1
|
||||
|
||||
// Setup hacks:
|
||||
|
||||
// Remove the M2's shines
|
||||
.org 0x8011D9C :: nop :: mov r0,#1
|
||||
.org 0x8011DD2 :: nop :: mov r0,#1
|
||||
|
||||
// Change the amount of loaded letters
|
||||
.org 0x8011C86 :: cmp r6,#8
|
||||
.org 0x8011E14 :: mov r6,#8
|
||||
|
||||
// Change how the letters coords are loaded
|
||||
.org 0x8011C04 :: add sp,#-0x48
|
||||
.org 0x8011E2E :: add sp,#0x48
|
||||
.org 0x8011C12 :: ldmia [r0]!,r2-r4 :: stmia [r1]!,r2-r4
|
||||
.org 0x8011C16 :: add r4,sp,#0x24
|
||||
.org 0x8011C26 :: ldmia [r0]!,r2-r4 :: stmia [r1]!,r2-r4
|
||||
|
||||
// Change the location of the coords
|
||||
.org 0x8011C8C :: dw m2_title_quick_text_coords_y :: dw m2_title_quick_text_coords_x
|
||||
|
||||
.org 0x801170C :: dw m2_title_text_constants
|
||||
.org 0x8011710 :: dw m2_title_text_constants + 12
|
||||
.org 0x8011714 :: dw m2_title_text_constants + 12 + 36
|
||||
.org 0x8011718 :: dw m2_title_text_constants + 12 + 36 + 36
|
||||
.org 0x801171C :: dw m2_title_text_constants + 12 + 36 + 36 + 36
|
||||
.org 0x870F580 :: .incbin "data/m2-title-background.bin"
|
||||
.org 0x8711280 :: .incbin "data/m2-title-text.bin"
|
||||
.org 0x87126CC :: .incbin "data/m2-title-background-pal-empty.bin"
|
||||
.org 0x87128EC :: .incbin "data/m2-title-background-map.bin"
|
||||
.org 0x8712E68 :: .incbin "data/m2-title-text-oam.bin"
|
||||
.org 0x8712F10 :: .incbin "data/m2-title-text-oam-entries.bin"
|
||||
.org 0x8712FB0 :: dw m2_title_text_params, m2_title_text_params + 0x6C
|
||||
|
||||
//==============================================================================
|
||||
// Move stuff around in order to make space for the code
|
||||
//==============================================================================
|
||||
|
@ -2024,9 +2250,58 @@ m2_end_frame1:
|
|||
optimized_byte_4bpp_to_1bpp_table:
|
||||
.incbin "data/optimized-byte-4bpp-to-1bpp-table.bin"
|
||||
|
||||
.align 4
|
||||
m12_cartridge_palettes_dimmed:
|
||||
.incbin "data/m12-cartridge-palettes-dimmed.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_quick_background_pal:
|
||||
.incbin "data/m2-title-quick-background-pal.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_quick_foreground_pal:
|
||||
.incbin "data/m2-title-quick-foreground-pal.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_quick_text_coords_x:
|
||||
.incbin "data/m2-title-quick-text-coords-x.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_quick_text_coords_y:
|
||||
.incbin "data/m2-title-quick-text-coords-y.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_background_pal_copyright:
|
||||
dw 0x100 :: .incbin "data/m2-title-background-pal-copyright.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_background_pal_glow:
|
||||
dw 0x280 :: .incbin "data/m2-title-background-pal-glow.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_text_pal_animated:
|
||||
dw 0x1C0 :: .incbin "data/m2-title-text-pal-animated.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_text_pal_static:
|
||||
dw 0x20 :: .incbin "data/m2-title-text-pal-static.c.bin"
|
||||
|
||||
.align 4
|
||||
m2_title_text_constants:
|
||||
.incbin "data/m2-title-text-constants.bin"
|
||||
|
||||
m2_title_text_params:
|
||||
.incbin "data/m2-title-text-params.bin"
|
||||
.org m2_title_text_params + 0x6C :: dw m2_title_text_params + 0x48
|
||||
.org m2_title_text_params + 0x74 :: dw m2_title_text_params + 0x4C
|
||||
.org m2_title_text_params + 0x7C :: dw m2_title_text_params + 0x50
|
||||
.org m2_title_text_params + 0x84 :: dw m2_title_text_params + 0x54
|
||||
.org m2_title_text_params + 0x8C :: dw m2_title_text_params + 0x58
|
||||
.org m2_title_text_params + 0x94 :: dw m2_title_text_params + 0x5C
|
||||
.org m2_title_text_params + 0x9C :: dw m2_title_text_params + 0x60
|
||||
.org m2_title_text_params + 0xA4 :: dw m2_title_text_params + 0x64
|
||||
.org m2_title_text_params + 0xAC :: dw m2_title_text_params + 0x68
|
||||
|
||||
.org 0x8FEE000
|
||||
disclaimer_palette:
|
||||
.incbin "data/intro-screen-pal.bin"
|
||||
|
@ -2037,13 +2312,11 @@ disclaimer_graphics:
|
|||
disclaimer_map:
|
||||
.incbin "data/intro-screen-map.bin"
|
||||
|
||||
|
||||
//==============================================================================
|
||||
// Existing subroutines/data
|
||||
//==============================================================================
|
||||
|
||||
.definelabel buffer_subtractor ,0x0000800
|
||||
.definelabel overworld_buffer ,0x200F200
|
||||
.definelabel m2_btl_enemies_size ,0x2025038
|
||||
.definelabel m2_hall_line_size ,0x3000374
|
||||
.definelabel m2_source_pc ,0x30009FB
|
||||
|
@ -2065,6 +2338,7 @@ disclaimer_map:
|
|||
.definelabel m2_cstm_last_pc ,0x3001F4E
|
||||
.definelabel m2_cstm_last_printed ,0x3001F4F
|
||||
.definelabel m2_player1 ,0x3001F50
|
||||
.definelabel m2_buffer_counter ,0x3002A4C
|
||||
.definelabel m2_script_readability ,0x3004F08
|
||||
.definelabel m2_psi_exist ,0x300525C
|
||||
.definelabel m2_active_window_pc ,0x3005264
|
||||
|
@ -2080,7 +2354,9 @@ disclaimer_map:
|
|||
.definelabel m2_change_naming_space ,0x8004E08
|
||||
.definelabel m2_copy_name_temp_mem ,0x8004E34
|
||||
.definelabel m2_insert_default_name ,0x8005708
|
||||
.definelabel m2_malloc ,0x8005B9C
|
||||
.definelabel m2_get_hall_address ,0x800D7BC
|
||||
.definelabel m2_title_quick_setup ,0x8011BFC
|
||||
.definelabel m12_dim_palette ,0x80137DC
|
||||
.definelabel m2_enable_script ,0x80A1F6C
|
||||
.definelabel m2_store_to_win_memory ,0x80A334C
|
||||
|
@ -2115,6 +2391,7 @@ disclaimer_map:
|
|||
.definelabel m2_sub_daf84 ,0x80DAF84
|
||||
.definelabel m2_setupbattlename ,0x80DCD00
|
||||
.definelabel m2_stat_symb_checker ,0x8B0EDA4
|
||||
.definelabel vblank ,0x80F47E4
|
||||
.definelabel m2_div ,0x80F49D8
|
||||
.definelabel m2_remainder ,0x80F4A70
|
||||
.definelabel cpuset ,0x80F47C0
|
||||
|
@ -2122,6 +2399,7 @@ disclaimer_map:
|
|||
.definelabel m2_items ,0x8B1D62C
|
||||
.definelabel m2_default_names ,0x82B9330
|
||||
.definelabel m2_psi_print_table ,0x8B2A9C0
|
||||
.definelabel m2_title_teardown ,0x8000C28
|
||||
|
||||
//==============================================================================
|
||||
// Code files
|
||||
|
@ -2138,5 +2416,6 @@ disclaimer_map:
|
|||
.include "m2-compiled.asm"
|
||||
.include "m2-flyover.asm"
|
||||
.include "m12-intro.asm"
|
||||
.include "m2-title.asm"
|
||||
|
||||
.close
|
||||
|
|
|
@ -0,0 +1,510 @@
|
|||
//---------------------------------------------------------
|
||||
title_initializer:
|
||||
|
||||
// Normally the game enables BG0 in sequence 8, but we want
|
||||
// it enabled from the start so copy that code to here
|
||||
|
||||
push {r1}
|
||||
ldr r0,=0x3001B20
|
||||
mov r1,8 // BG0 X offset
|
||||
strh r1,[r0]
|
||||
ldr r0,=0x30012DC
|
||||
mov r1,8*6 // BG0 Y offset
|
||||
strh r1,[r0]
|
||||
ldr r0,=0x3000370
|
||||
ldr r1,[r0,#0]
|
||||
add r1,0x98
|
||||
mov r0,0x88
|
||||
lsl r0,r0,5
|
||||
strh r0,[r1]
|
||||
pop {r1}
|
||||
ldr r0,=0x80113F4
|
||||
mov pc,r0 // Run the existing routine
|
||||
|
||||
//---------------------------------------------------------
|
||||
_112be_remove_pal_blanking_quick_title:
|
||||
|
||||
// Normally the game clears the first entry of the first palette
|
||||
// when showing animations. We don't want that for the quick version
|
||||
// of the title.
|
||||
|
||||
cmp r5,#5 // Is it the quick version of the title?
|
||||
beq @@rmv_pal_qt_end
|
||||
mov r1,r8 // If not, blank out the first entry
|
||||
strh r0,[r1,#0]
|
||||
|
||||
@@rmv_pal_qt_end:
|
||||
bx lr
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_setup_clamp:
|
||||
mov r1,250
|
||||
cmp r0,r1
|
||||
bgt @@clamp
|
||||
neg r1,r1
|
||||
cmp r0,r1
|
||||
blt @@clamp
|
||||
b @@clamp_end
|
||||
|
||||
@@clamp:
|
||||
mov r0,r1
|
||||
|
||||
@@clamp_end:
|
||||
str r0,[r5,4]
|
||||
mov r1,r8 // clobbered code
|
||||
bx lr
|
||||
|
||||
//---------------------------------------------------------
|
||||
// r3 has 2028008
|
||||
// [r3+14] has 2028028
|
||||
// [2028028+10] has pointer to our palette buffer, 0x200 bytes after which
|
||||
// we have some free space to use for things
|
||||
// Let's allocate some variables:
|
||||
// +0x00: Sequence 01 -- initial delay flag
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_return:
|
||||
ldr r0,=0x8011B8C
|
||||
mov pc,r0
|
||||
|
||||
//---------------------------------------------------------
|
||||
// In: r0 = pointer to pointer to little struct
|
||||
// Out: r0 = pointer to our buffer area (0x2011B60)
|
||||
title_get_buffer:
|
||||
push {r1,lr}
|
||||
ldr r0,[r0]
|
||||
ldr r1,[r0,0x14]
|
||||
ldr r0,[r1,0x10]
|
||||
ldr r1,=0x200
|
||||
add r0,r0,r1
|
||||
pop {r1,pc}
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_00:
|
||||
|
||||
push {r3}
|
||||
|
||||
// Copy static palette to BG pal 8
|
||||
ldr r3,[r3]
|
||||
ldr r3,[r3,0x14]
|
||||
ldr r1,=0x40000D4
|
||||
ldr r2,[r3,0xC] // m2_title_text_pal_static
|
||||
str r2,[r1]
|
||||
ldr r0,=0x5000100
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x84000008
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
// Copy to OBJ pal 0 as well for the text
|
||||
str r2,[r1]
|
||||
ldr r0,=0x5000200
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x84000008
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
pop {r3}
|
||||
|
||||
// Return to old sequence 0 code
|
||||
ldr r0,=m2_title_sequence_00
|
||||
mov pc,r0
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_01:
|
||||
|
||||
// EB has a 38 frame delay between starting the music
|
||||
// and starting the fade-in
|
||||
mov r0,r3
|
||||
bl title_get_buffer
|
||||
|
||||
// Check if we've set our delay flag yet
|
||||
ldr r1,[r0]
|
||||
cmp r1,0
|
||||
beq @@unset
|
||||
|
||||
@@set:
|
||||
|
||||
// Skip our code and return to the old sequence 1 code
|
||||
ldr r0,=m2_title_sequence_01
|
||||
mov pc,r0
|
||||
|
||||
@@unset:
|
||||
|
||||
// Count to 0x26 before starting the fade-in
|
||||
ldr r3,[r3]
|
||||
ldr r1,[r3,4]
|
||||
cmp r1,0x26
|
||||
bge @@unset_start_fade
|
||||
b @@end
|
||||
|
||||
@@unset_start_fade:
|
||||
mov r1,0
|
||||
str r1,[r3,4]
|
||||
mov r1,1
|
||||
str r1,[r0]
|
||||
|
||||
@@end:
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_03:
|
||||
|
||||
push {r0-r3}
|
||||
mov r0,r2 // 0x2028008
|
||||
mov r1,r9 // 0x2028028
|
||||
mov r2,sp
|
||||
add r2,0x10 // coord table on the stack
|
||||
bl title_text_sequence
|
||||
pop {r0-r3}
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_04:
|
||||
|
||||
// Just need to reset the frame counter
|
||||
ldr r2,[r3]
|
||||
mov r0,1
|
||||
neg r0,r0 // This gets incremented before calling the sequence subroutines,
|
||||
// and we want it to be 0 on the first frame for sequence 5,
|
||||
// so start it at -1
|
||||
str r0,[r2,4]
|
||||
|
||||
ldr r0,=m2_title_sequence_04
|
||||
mov pc,r0
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_05:
|
||||
|
||||
push {r4}
|
||||
ldr r3,[r3]
|
||||
mov r4,r3
|
||||
ldr r0,[r4,4] // frame number
|
||||
|
||||
// Frame 0-1: inverted colours
|
||||
cmp r0,1
|
||||
bhi @@next1
|
||||
|
||||
// Only change the palette on frame 0
|
||||
cmp r0,1
|
||||
beq @@advance_frame
|
||||
|
||||
@@inverted:
|
||||
|
||||
// Load inverted BG palettes
|
||||
// (all white for BG pal 0-7,
|
||||
// all black for BG pal 8-F)
|
||||
ldr r1,=0x40000D4
|
||||
mov r2,1
|
||||
neg r2,r2
|
||||
push {r2}
|
||||
mov r2,sp
|
||||
str r2,[r1]
|
||||
ldr r0,=0x5000000
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x85000040
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
mov r2,0
|
||||
str r2,[sp]
|
||||
|
||||
mov r2,sp
|
||||
str r2,[r1]
|
||||
ldr r0,=0x5000100
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x85000040
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
// Black for OBJ pal 0
|
||||
str r2,[r1]
|
||||
ldr r0,=0x5000200
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x85000040
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
pop {r2}
|
||||
b @@advance_frame
|
||||
|
||||
@@next1:
|
||||
// Frame 2-29: animated text, 2 frames per palette change
|
||||
cmp r0,29
|
||||
bhi @@next2
|
||||
|
||||
// Only change palette on the even frames
|
||||
sub r0,2
|
||||
lsl r1,r0,0x1F
|
||||
bmi @@advance_frame
|
||||
|
||||
// On frame 2, we need to reset BG pal 0-7 to black
|
||||
cmp r0,0
|
||||
bne @@skip_black_palettes
|
||||
ldr r1,=0x40000D4
|
||||
push {r0}
|
||||
mov r2,sp
|
||||
str r2,[r1]
|
||||
ldr r2,=0x5000000
|
||||
str r2,[r1,4]
|
||||
ldr r2,=0x85000040
|
||||
str r2,[r1,8]
|
||||
ldr r2,[r1,8]
|
||||
add sp,4
|
||||
|
||||
@@skip_black_palettes:
|
||||
// Get source palette address
|
||||
ldr r3,[r3,0x14]
|
||||
ldr r1,[r3,8] // m2_title_text_pal_animated
|
||||
lsl r0,r0,4
|
||||
add r0,r0,r1
|
||||
|
||||
// Copy to BG pal 8
|
||||
mov r4,r0
|
||||
ldr r1,=0x40000D4
|
||||
str r0,[r1]
|
||||
ldr r0,=0x5000100
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x84000008
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
// Copy to OBJ pal 0
|
||||
str r4,[r1]
|
||||
ldr r0,=0x5000200
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x84000008
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
|
||||
b @@advance_frame
|
||||
|
||||
@@next2:
|
||||
// For now let's just go to the next sequence, not sure what to do next yet
|
||||
mov r0,0
|
||||
str r0,[r4,4]
|
||||
mov r0,6
|
||||
ldr r1,[r4,0x14]
|
||||
add r1,0x84
|
||||
str r0,[r1]
|
||||
pop {r4}
|
||||
b title_return
|
||||
|
||||
@@advance_frame:
|
||||
pop {r4}
|
||||
ldr r0,[r4,4]
|
||||
add r0,1
|
||||
str r0,[r4,4]
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_07:
|
||||
|
||||
// We're not moving the text so just do a delay for this sequence
|
||||
ldr r3,[r3]
|
||||
ldr r0,[r3,4]
|
||||
cmp r0,0x2C
|
||||
bgt @@nextsequence
|
||||
b title_return
|
||||
|
||||
@@nextsequence:
|
||||
mov r0,8
|
||||
mov r4,r10
|
||||
str r0,[r4]
|
||||
mov r0,0
|
||||
str r0,[r3,4]
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_08:
|
||||
|
||||
// We're not messing with the video registers so just do a delay for this sequence
|
||||
ldr r3,[r3]
|
||||
ldr r0,[r3,4]
|
||||
cmp r0,0x2C
|
||||
bgt @@nextsequence
|
||||
b title_return
|
||||
|
||||
@@nextsequence:
|
||||
mov r0,9
|
||||
mov r4,r10
|
||||
str r0,[r4]
|
||||
mov r0,1
|
||||
neg r0,r0 // want to start the next sequence on frame 0
|
||||
str r0,[r3,4]
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_09:
|
||||
|
||||
// Copyright palette fade in
|
||||
push {r4-r7}
|
||||
ldr r3,[r3]
|
||||
mov r4,r3
|
||||
ldr r0,[r3,4] // frame number
|
||||
|
||||
// Frame 0-215: re-calculate palette every frame
|
||||
cmp r0,215
|
||||
bgt @@nextsequence
|
||||
|
||||
add sp,-16
|
||||
str r0,[sp]
|
||||
ldr r1,=215
|
||||
str r1,[sp,4]
|
||||
ldr r5,[r4,0x14]
|
||||
ldr r5,[r5] // copyright palette source
|
||||
mov r6,5
|
||||
lsl r6,r6,24 // copyright palette dest
|
||||
mov r7,0
|
||||
|
||||
@@loop:
|
||||
// Scale R
|
||||
ldrh r1,[r5]
|
||||
lsl r1,r1,27
|
||||
lsr r1,r1,9
|
||||
ldr r0,[sp]
|
||||
mul r0,r1
|
||||
ldr r1,[sp,4]
|
||||
bl m2_div
|
||||
lsr r0,r0,18
|
||||
str r0,[sp,8]
|
||||
|
||||
// Scale G
|
||||
ldrh r1,[r5]
|
||||
lsr r1,r1,5
|
||||
lsl r1,r1,27
|
||||
lsr r1,r1,9
|
||||
ldr r0,[sp]
|
||||
mul r0,r1
|
||||
ldr r1,[sp,4]
|
||||
bl m2_div
|
||||
lsr r0,r0,18
|
||||
str r0,[sp,12]
|
||||
|
||||
// Scale B
|
||||
ldrh r1,[r5]
|
||||
lsr r1,r1,10
|
||||
lsl r1,r1,27
|
||||
lsr r1,r1,9
|
||||
ldr r0,[sp]
|
||||
mul r0,r1
|
||||
ldr r1,[sp,4]
|
||||
bl m2_div
|
||||
lsr r0,r0,18
|
||||
|
||||
// Pack colours and store
|
||||
lsl r0,r0,10
|
||||
ldr r1,[sp,12]
|
||||
lsl r1,r1,5
|
||||
orr r0,r1
|
||||
ldr r1,[sp,8]
|
||||
orr r0,r1
|
||||
strh r0,[r6]
|
||||
|
||||
// Copy background colour to the glow palette
|
||||
cmp r7,0
|
||||
bgt @@next
|
||||
mov r1,0
|
||||
add r6,0xE0
|
||||
@@copyloop:
|
||||
strh r0,[r6]
|
||||
add r6,2
|
||||
add r1,1
|
||||
cmp r1,16
|
||||
blt @@copyloop
|
||||
sub r6,0xE0
|
||||
sub r6,0x20
|
||||
|
||||
@@next:
|
||||
add r5,2
|
||||
add r6,2
|
||||
add r7,1
|
||||
cmp r7,16
|
||||
blt @@loop
|
||||
|
||||
add sp,16
|
||||
pop {r4-r7}
|
||||
b title_return
|
||||
|
||||
@@nextsequence:
|
||||
mov r0,0
|
||||
str r0,[r4,4]
|
||||
mov r0,0xA
|
||||
mov r4,r10
|
||||
str r0,[r4]
|
||||
pop {r4-r7}
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_0B:
|
||||
|
||||
// Background palette fade in
|
||||
push {r4}
|
||||
ldr r3,[r3]
|
||||
mov r4,r3
|
||||
ldr r0,[r3,4] // frame number
|
||||
|
||||
// Frame 0-159: change palette every 8 frames
|
||||
lsl r3,r0,29
|
||||
lsr r3,r3,29
|
||||
cmp r3,0
|
||||
bne @@end
|
||||
|
||||
lsr r0,r0,3 // source palete index
|
||||
cmp r0,20
|
||||
bge @@nextsequence
|
||||
|
||||
lsl r0,r0,5 // source palette offset
|
||||
ldr r3,[r4,0x14]
|
||||
ldr r3,[r3,4] // source palette buffer
|
||||
add r0,r0,r3
|
||||
|
||||
// Copy palette
|
||||
ldr r1,=0x40000D4
|
||||
str r0,[r1]
|
||||
ldr r0,=0x50000E0
|
||||
str r0,[r1,4]
|
||||
ldr r0,=0x84000008
|
||||
str r0,[r1,8]
|
||||
ldr r0,[r1,8]
|
||||
b @@end
|
||||
|
||||
@@nextsequence:
|
||||
mov r0,1
|
||||
neg r0,r0 // want to start the next sequence on frame 0
|
||||
str r0,[r4,4]
|
||||
mov r0,0xC
|
||||
mov r4,r10
|
||||
str r0,[r4]
|
||||
|
||||
@@end:
|
||||
pop {r4}
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_0C:
|
||||
|
||||
ldr r3,[r3]
|
||||
ldr r0,[r3,4]
|
||||
cmp r0,0x2C
|
||||
bgt @@nextsequence
|
||||
b title_return
|
||||
|
||||
@@nextsequence:
|
||||
mov r0,0xD
|
||||
mov r4,r10
|
||||
str r0,[r4]
|
||||
mov r0,1
|
||||
neg r0,r0
|
||||
str r0,[r3,4]
|
||||
b title_return
|
||||
|
||||
//---------------------------------------------------------
|
||||
title_sequence_0D:
|
||||
|
||||
mov r4,r10
|
||||
ldr r0,[r4]
|
||||
add r0,1
|
||||
str r0,[r4]
|
||||
b title_return
|
||||
|
||||
.pool
|
|
@ -490,8 +490,10 @@ cmp r0,0
|
|||
beq @@next
|
||||
|
||||
// If flag 0x10 is set, clear the PSI window
|
||||
bl check_overworld_buffer
|
||||
ldr r1,=#buffer_subtractor
|
||||
sub r1,r0,r1
|
||||
ldr r0,[r5,0x1C] // PSI window
|
||||
ldr r1,=#overworld_buffer - buffer_subtractor
|
||||
bl clear_window_buffer
|
||||
|
||||
@@next:
|
||||
|
@ -748,8 +750,10 @@ ldr r0,=0x3002500
|
|||
ldrh r0,[r0]
|
||||
cmp r0,0
|
||||
beq @@next
|
||||
bl check_overworld_buffer
|
||||
ldr r1,=#buffer_subtractor
|
||||
sub r1,r0,r1
|
||||
ldr r0,=#0x3005230
|
||||
ldr r1,=#overworld_buffer - buffer_subtractor
|
||||
ldr r0,[r0,0x1C]
|
||||
bl clear_window_buffer
|
||||
|
||||
|
@ -2478,10 +2482,12 @@ ldrb r1,[r4,#0x3] //If it is, sets vwf_skip to true, clears the window and up
|
|||
mov r2,#1
|
||||
orr r2,r1
|
||||
strb r2,[r4,#0x3]
|
||||
mov r3,r0
|
||||
push {r0}
|
||||
bl check_overworld_buffer
|
||||
ldr r1,=#buffer_subtractor
|
||||
sub r1,r0,r1
|
||||
mov r0,r4
|
||||
ldr r1,=#overworld_buffer - buffer_subtractor
|
||||
mov r4,r3
|
||||
pop {r4}
|
||||
bl clear_window_buffer
|
||||
mov r0,r4
|
||||
bl psiTargetWindow_buffer
|
||||
|
@ -2770,7 +2776,11 @@ pop {r4,pc}
|
|||
//Prints blankstr in the buffer
|
||||
bb21c_print_blankstr_buffer:
|
||||
push {lr}
|
||||
ldr r3,=#overworld_buffer - buffer_subtractor
|
||||
push {r0-r2}
|
||||
bl check_overworld_buffer
|
||||
ldr r3,=#buffer_subtractor
|
||||
sub r3,r0,r3
|
||||
pop {r0-r2}
|
||||
bl print_blankstr_buffer
|
||||
pop {pc}
|
||||
|
||||
|
@ -2778,7 +2788,11 @@ pop {pc}
|
|||
//Prints blankstr in the buffer and stores it
|
||||
bb21c_print_blankstr_buffer_store:
|
||||
push {lr}
|
||||
ldr r3,=#overworld_buffer - buffer_subtractor
|
||||
push {r0-r2}
|
||||
bl check_overworld_buffer
|
||||
ldr r3,=#buffer_subtractor
|
||||
sub r3,r0,r3
|
||||
pop {r0-r2}
|
||||
bl print_blankstr_buffer
|
||||
bl store_pixels_overworld
|
||||
pop {pc}
|
||||
|
@ -3166,6 +3180,19 @@ bl store_pixels_overworld
|
|||
@@end:
|
||||
pop {pc}
|
||||
|
||||
//==============================================================================
|
||||
//Allocs the printing buffer's pointer. It needs 4 bytes
|
||||
_05b80_alloc_buffer_pointer:
|
||||
push {lr}
|
||||
|
||||
mov r0,#4
|
||||
bl 0x8005B9C
|
||||
|
||||
ldr r0,=#0x3002A4C
|
||||
str r4,[r0,#0]
|
||||
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)
|
||||
load_pixels_overworld:
|
||||
|
|
Loading…
Reference in New Issue