ros:expert_guides:disasm05
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | ros:expert_guides:disasm05 [2025/03/20 14:09] (current) – created mariofan2468 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | === Disassembly Tutorial 05: Strings and Tables with Item Names === | ||
+ | |||
+ | I want to take a look at '' | ||
+ | |||
+ | The contents of '' | ||
+ | |||
+ | The third structure is a list of strings. We can see that each of the strings are 16 characters long and have a label. | ||
+ | |||
+ | The second structure is a character map. Character maps are a way to convert characters in a string to bytes of data. Which byte a character needs to be depends on where the font is loaded in VRAM, and by consequent, what tile id is used for that character. The strings in the third structure are using this '' | ||
+ | |||
+ | The first structure is a table of pointers to the strings in the list of strings. Pointer tables are useful when the distance between each entry' | ||
+ | In this case, there is always $10 bytes between each string, so the pointer table is not needed. All you'd have to do to access any string is to start at the first string and add $10 however many times you need to reach the one you want. | ||
+ | |||
+ | Challenge: Go ahead and modify some strings. What happens if a string has more than 16 characters? What if a string has less than 16 characters? 0 characters? | ||
+ | |||
+ | Have you ever noticed that the item text is not centered? The Game Boy's screen is 20 tiles wide, so given that the 16 characters in the string are drawn starting at the left edge of the screen, 4 tiles are left untouched on the right. Let's fix that by increasing the quantity of characters drawn. | ||
+ | |||
+ | Challenge: Find where '' | ||
+ | |||
+ | Let's look at what the code does. All of the code is setup for a call to '' | ||
+ | |||
+ | First, the bank in the switchable ROM bank slot is switched to bank 1, so that '' | ||
+ | |||
+ | Then, the index of the string to load is extracted from the door token' | ||
+ | |||
+ | The index is loaded into '' | ||
+ | |||
+ | The pointer is then dereferenced, | ||
+ | This value is then used as the source address for the graphics transfer. | ||
+ | The constant '' | ||
+ | |||
+ | We can change the length to $0014, and increase the size of all strings to 20 characters. Now the text can be properly centered. | ||
+ | |||
+ | Extra challenge: Remove the pointer table, and have the text drawing code calculate where the strings' |
ros/expert_guides/disasm05.txt · Last modified: 2025/03/20 14:09 by mariofan2468