Custom control codes force a window draw
Also made the cash window one tile shorter
This commit is contained in:
parent
bc46af1253
commit
6ca5f8543a
|
@ -1,5 +1,7 @@
|
|||
typedef unsigned char byte;
|
||||
#include "window.h"
|
||||
|
||||
void __attribute__((naked)) cpufastset(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) {}
|
||||
int __attribute__((naked)) m2_resetwindow(WINDOW* window, bool skip_redraw) {}
|
||||
|
|
|
@ -522,3 +522,26 @@ void format_cash_window(int value, int padding, byte* str)
|
|||
*str++ = 0;
|
||||
*str++ = 0xFF;
|
||||
}
|
||||
|
||||
// The game draws windows lazily: no window will be drawn to the screen until
|
||||
// a renderable token is encountered. So it's possible to have text that
|
||||
// does stuff in the background without ever showing a window. Lots of doors
|
||||
// and hotspots do this for example.
|
||||
// When the game first encounters a renderable token, it checks two things:
|
||||
// - If the flag at 0x30051F0 is 1, then call m2_resetwindow and set the flag to 0
|
||||
// - If the window has flag 0x20 set, then call m2_drawwindow (which unsets the
|
||||
// window flag)
|
||||
// See 80CA2C2 for an example. We want to replicate this behaviour sometimes,
|
||||
// e.g. for custom control codes that are considered renderable.
|
||||
void handle_first_window(WINDOW* window)
|
||||
{
|
||||
if (*first_window_flag == 1)
|
||||
{
|
||||
m2_resetwindow(window, false);
|
||||
*first_window_flag = 0;
|
||||
}
|
||||
else if (window->flags & 0x20)
|
||||
{
|
||||
m2_drawwindow(window);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#define CUSTOMCC_ADD_X 0x60
|
||||
|
||||
unsigned short *tile_offset = (unsigned short*)0x30051EC;
|
||||
int *first_window_flag = (int*)0x30051F0;
|
||||
unsigned short *palette_mask = (unsigned short*)0x3005228;
|
||||
unsigned short **tilemap_pointer = (unsigned short**)0x3005270;
|
||||
int *vram = (int*)0x6000000;
|
||||
|
@ -63,6 +64,7 @@ void print_number_menu(WINDOW* window, int style);
|
|||
void print_number_menu_current(byte digit, WINDOW* window);
|
||||
void clear_number_menu(WINDOW* window);
|
||||
void format_cash_window(int value, int padding, byte* str);
|
||||
void handle_first_window(WINDOW* window);
|
||||
|
||||
extern unsigned short m2_coord_table[];
|
||||
extern int m2_bits_to_nybbles[];
|
||||
|
@ -79,3 +81,5 @@ extern byte m12_other_str8[];
|
|||
extern void cpufastset(void *source, void *dest, int mode);
|
||||
extern byte* m2_strlookup(int *offset_table, byte *strings, int index);
|
||||
extern int bin_to_bcd(int value, int* digit_count);
|
||||
extern int m2_drawwindow(WINDOW* window);
|
||||
extern int m2_resetwindow(WINDOW* window, bool skip_redraw);
|
||||
|
|
|
@ -18,6 +18,13 @@ mov r4,r0
|
|||
// 60 FF XX: Add XX pixels to the renderer
|
||||
cmp r4,0x60
|
||||
bne @@next
|
||||
|
||||
// 60 FF should be treated as a renderable code
|
||||
push {r0-r3}
|
||||
mov r0,r5
|
||||
bl handle_first_window
|
||||
pop {r0-r3}
|
||||
|
||||
mov r3,3
|
||||
|
||||
// Get the current X offset
|
||||
|
@ -50,6 +57,13 @@ b @@end
|
|||
// 5F FF XX: Set the X value of the renderer
|
||||
cmp r4,0x5F
|
||||
bne @@next2
|
||||
|
||||
// 5F FF should be treated as a renderable code
|
||||
push {r0-r3}
|
||||
mov r0,r5
|
||||
bl handle_first_window
|
||||
pop {r0-r3}
|
||||
|
||||
mov r3,3
|
||||
|
||||
// Get the new X value
|
||||
|
|
|
@ -530,11 +530,12 @@ b 0x80D3A14
|
|||
|
||||
.org 0x80B8A06
|
||||
mov r2,r1
|
||||
mov r1,0x38 // right-align to 56 pixels
|
||||
mov r1,0x30 // right-align to 48 pixels
|
||||
bl format_cash_window
|
||||
b 0x80B8A2E
|
||||
|
||||
.org 0x80B785C :: mov r0,0xC // allocate 2 extra bytes for cash window string
|
||||
.org 0x80B786C :: mov r3,6 // make window 1 fewer tiles wide
|
||||
|
||||
//---------------------------------------------------------
|
||||
// [68 FF] - clear window
|
||||
|
@ -800,6 +801,7 @@ m2_enemy_attributes:
|
|||
.definelabel m2_scrolltext ,0x80CA4BC
|
||||
.definelabel m2_clearwindowtiles ,0x80CA834
|
||||
.definelabel m2_menuwindow ,0x80C1C98
|
||||
.definelabel m2_resetwindow ,0x80BE490
|
||||
|
||||
//==============================================================================
|
||||
// Code files
|
||||
|
|
|
@ -61,6 +61,7 @@ Hard-coded characters:
|
|||
0x30023D4: current ATM balance
|
||||
0x3002500: buttons being pressed
|
||||
0x30051EC: tile offset (usually 0x100)
|
||||
0x30051F0: flag? gets set to 1 when you change rooms, goes back to 0 the first time you open a text window
|
||||
0x3005224: menu depth
|
||||
0x3005228: current text palette, << 0xC
|
||||
0x3005230: addresses of all 11 windows
|
||||
|
|
Loading…
Reference in New Issue