Compare commits
3
Commits
5d89883d15
...
4cc21a1c3a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4cc21a1c3a | ||
|
|
ab5d9cbe69 | ||
|
|
077ba70a16 |
@@ -0,0 +1,46 @@
|
|||||||
|
#+TITLE: Terminology
|
||||||
|
#+AUTHOR: Riyyi
|
||||||
|
#+LANGUAGE: en
|
||||||
|
#+OPTIONS: toc:nil
|
||||||
|
|
||||||
|
GameBoy terminology.
|
||||||
|
|
||||||
|
** Terminology
|
||||||
|
|
||||||
|
*** Hardware
|
||||||
|
|
||||||
|
https://gbdev.io/pandocs/Specifications.html
|
||||||
|
https://gbdev.io/pandocs/Memory_Map.html
|
||||||
|
|
||||||
|
| Name | Modern equivalent | Description |
|
||||||
|
|-----------------+-------------------+-------------------------------------------|
|
||||||
|
| APU | | 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 | |
|
||||||
|
|
||||||
|
*** Opcode
|
||||||
|
|
||||||
|
| Name | Bits | Sign | Mnemonics | 1 | 2 | 3 | 4 | Description | Note |
|
||||||
|
|-----------+------+----------+-----------+------+-----+------+-----+------------------------------+-------------------|
|
||||||
|
| | | | | <r> | <r> | <r> | <r> | | |
|
||||||
|
| immediate | 8 | unsigned | | d8 | n8 | n | | Next byte in memory | |
|
||||||
|
| immediate | 16 | unsigned | | d16 | n16 | nn | | Next byte in memory | little-endian |
|
||||||
|
| register | 8 | unsigned | | | r8 | r | | Any of the registers | |
|
||||||
|
| register | 16 | unsigned | | | r16 | rr | | Any of the registers | little-endian |
|
||||||
|
| address | 8 | unsigned | | | | (n) | | Address at value | |
|
||||||
|
| address | 16 | unsigned | | a16 | n16 | (nn) | nn | Address at value | little-endian |
|
||||||
|
| immediate | 8 | signed | | r8 | e8 | e | dd | Next byte in memory | |
|
||||||
|
| immediate | 8 | unsigned | | (a8) | n16 | (n) | n | 0xff00 + next byte in memory | write to I/O-port |
|
||||||
|
| condition | | | | NZ | cc | | f | Execute if condition met | |
|
||||||
|
|
||||||
|
d = data
|
||||||
|
n = constant
|
||||||
|
|
||||||
|
*** Variables
|
||||||
|
|
||||||
|
| Name | Meaning |
|
||||||
|
|--------+--------------------|
|
||||||
|
| size | amount of bytes |
|
||||||
|
| length | amount of elements |
|
||||||
@@ -55,7 +55,7 @@ private:
|
|||||||
uint8_t peekMemory(int32_t offset = 0) const;
|
uint8_t peekMemory(int32_t offset = 0) const;
|
||||||
uint8_t consumeMemory();
|
uint8_t consumeMemory();
|
||||||
|
|
||||||
uint32_t immediate16() { return (consumeMemory() << 8) | consumeMemory(); }
|
uint32_t immediate16() { return consumeMemory() | (consumeMemory() << 8); }
|
||||||
|
|
||||||
void setBc(uint32_t value);
|
void setBc(uint32_t value);
|
||||||
void setDe(uint32_t value);
|
void setDe(uint32_t value);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "emu.h"
|
#include "emu.h"
|
||||||
#include "ppu.h"
|
#include "ppu.h"
|
||||||
|
#include "ruc/file.h"
|
||||||
#include "ruc/format/print.h"
|
#include "ruc/format/print.h"
|
||||||
#include "ruc/timer.h"
|
#include "ruc/timer.h"
|
||||||
|
|
||||||
@@ -40,6 +41,17 @@ int main(int argc, char* argv[])
|
|||||||
Emu::the().addMemorySpace("OAM", 0xfe00, 0xfe9f, 1); // 160B, Object Attribute Memory (VRAM Sprite Attribute Table)
|
Emu::the().addMemorySpace("OAM", 0xfe00, 0xfe9f, 1); // 160B, Object Attribute Memory (VRAM Sprite Attribute Table)
|
||||||
Emu::the().addMemorySpace("HRAM", 0xff80, 0xfffe, 1); // 127B, High RAM (CPU cache)
|
Emu::the().addMemorySpace("HRAM", 0xff80, 0xfffe, 1); // 127B, High RAM (CPU cache)
|
||||||
|
|
||||||
|
// Load bootrom
|
||||||
|
auto bootrom = ruc::File("gbc_bios.bin").data();
|
||||||
|
for (size_t i = 0; i < bootrom.length(); ++i) {
|
||||||
|
// Skip cartridge header memory range
|
||||||
|
if (i >= 0x0100 && i <= 0x01ff) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Emu::the().writeMemory(i, bootrom[i]);
|
||||||
|
}
|
||||||
|
|
||||||
// Get shared register
|
// Get shared register
|
||||||
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a"));
|
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("a"));
|
||||||
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("b"));
|
print("{}\n", *Emu::the().processingUnit("cpu")->sharedRegister("b"));
|
||||||
|
|||||||
Reference in New Issue
Block a user