GarbAGE (Garbage Accurate GameBoy Emulator)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
3.7 KiB

#+TITLE: Terminology
#+AUTHOR: Riyyi
#+LANGUAGE: en
#+OPTIONS: toc:nil
GameBoy terminology.
** Terminology
*** Hardware
| Name | Modern equivalent | Description |
|-----------------+-------------------+-------------------------------------------|
| APU | Sound card | Audio Processing Unit |
| PPU | GPU | Pixel Processing Unit |
| Bootrom | BIOS | |
| HRAM (High RAM) | CPU cache | Embedded memory inside the CPU, 127 bytes |
| WRAM (Work RAM) | RAM | |
*** Flags
The half-carry flag ~H~ is set when an arithmetic operation on two numbers
causes a carry from bit #3 to bit #4 for 8-bit operations or a carry from bit
#11 to bit #12 for 16-bit operations. For 16-bit operation this indicates the
lower 4 bits of the *second* byte[[#references][(3)]].
We start counting from the right as bit *#0*!
*** Opcode
| Name | Bits | Sign | Mnemonics | [[https://gbdev.io/gb-opcodes/optables/][1]] | [[https://rgbds.gbdev.io/docs/v0.5.2/gbz80.7/][2]] | [[https://gekkio.fi/files/gb-docs/gbctr.pdf][3]]/[[http://marc.rawer.de/Gameboy/Docs/GBCPUman.pdf][3]] | [[https://gbdev.io/pandocs/CPU_Instruction_Set.html][4]] | Description | Note |
|-----------+------+----------+-----------+------+-----+------+-----+------------------------------+-------------------|
| | | | | <r> | <r> | <r> | <r> | | |
| immediate | 8 | unsigned | i8 | d8 | n8 | n | | Next byte in memory | |
| immediate | 16 | unsigned | i16 | d16 | n16 | nn | | Next byte in memory | little-endian |
| register | 8 | unsigned | r8 | | r8 | r | | Any of the registers | |
| register | 16 | unsigned | r16 | | r16 | rr | | Any of the registers | little-endian |
| address | 8 | unsigned | a8 | | | (n) | | Address at value | |
| address | 16 | unsigned | a16 or () | a16 | n16 | (nn) | nn | Address at value | little-endian |
| immediate | 8 | signed | s8 | r8 | e8 | e | dd | Next byte in memory | |
| immediate | 8 | unsigned | io8 | (a8) | n16 | (n) | n | 0xff00 + next byte in memory | write to I/O-port |
| condition | | | <ZNHC> | NZ | cc | | f | Execute if condition met | |
d = data \\
n = constant
**** Flag conditions
Flag conditions, sometimes referred to as ~cc~, are the state the flags need to
be in to execute the opcode. There are four possible checks[[#references][(4)]]:
| Code | Meaning | State |
|------+---------------------+-------|
| C | Carry flag is set | 1 |
| NC | Carry flag is unset | 0 |
| Z | Zero flag is set | 1 |
| NZ | Zero flag is unset | 0 |
*** Variables
| Name | Meaning |
|--------+--------------------|
| length | amount of elements |
| size | amount of bytes |
|--------+--------------------|
| lhs | left hand side |
| rhs | right hand side |
** References
1. https://gbdev.io/pandocs/Memory_Map.html
2. https://gbdev.io/pandocs/Specifications.html
3. [[https://robdor.com/2016/08/10/gameboy-emulator-half-carry-flag/]["A Visual Guide to the Gameboy's Half-Carry Flag"]]. robdor.com. Retrieved 24 Aug 2022.
4. [[http://www.devrs.com/gb/files/opcodes.html]["GameBoy Opcode Summary"]]. devrs.com. Retrieved 25 Aug 2022.