Where to get started
Posted by: Torchickens
Date: 2019-04-25 12:52:39
https://iimarckus.org/etc/asmopcodes.txt
https://max-m.github.io/gb-docs/optables/
https://github.com/pret/pokered/blob/master/wram.asm
http://gameboy.mongenel.com/dmg/asmmemmap.html
You can start with simple instructions like
ld a, 15
ld [$d059] ,a
ret
(3E 15 EA 59 D0 C9) to encounter Mew, and other 'RAM write' codes and modify them. The tables linked also tell you what a byte / opcode / operand maps to which item / quantity. In Yellow, a lot of addresses are shifted by 1, so in that example you would use ld [$d058], a instead for Yellow Mew.https://glitchcity.info/wiki/The_Big_HEX_List
If you use BGB's debugger, you can compile opcodes without doing it by hand, and see their byte representation. (right-click the screen, Other -> Debugger, use Ctrl+G to reach destinations quickly)
You can also set a breakpoint (double-click a location in the code panel, or use F2) at address $D322 (which corresponds to item 3's ID), or wherever your bootstrap code is, to see how it affects the registers and the memory. The step into (F7) and step over (F3) commands allow stepping through the execution one line at a time.
The game will keep running fine if you alter the value of all registers except sp, so feel free to use "padding" instructions such as "inc b" (maps to a Poké Ball) to make your code easier to set up and avoid rare/glitch items.
Later you can start reading the document ISSOtm posted for things like calling other addresses and setting conditions in your code. For example, when you want to call other functions, you can use the "call" instruction with the pointer (based on above memory map link) of your choice. Some functions in the ROM can be found here https://sites.google.com/site/torchickens2/sym-files and require certain conditions. One of the most common, the bank switch (located at address $35d6) requires b and hl to be set to a specific value (which you can do with "ld b, xx" etc.), then when you use call 35d6 the address at b:hl is executed.
Hope this helps. ^_^
(EDIT by ISSOtm: fixed and clarified wording, changed resource links.)