HFO4 / gameboy.live

🕹️ A basic gameboy emulator with terminal "Cloud Gaming" support
MIT License
4.69k stars 232 forks source link

What is 60h - FFh used for in the ROM #6

Closed tilkinsc closed 5 years ago

tilkinsc commented 5 years ago

Can't find information in the docs

D9 is the opcode for RETI (return enable interrupt)

image

HFO4 commented 5 years ago

Usually, 60h is used for joypad interrupt vector, according to the pan docs:

INT 60 - Joypad Interrupt Joypad interrupt is requested when any of the above Input lines changes from High to Low. Generally this should happen when a key becomes pressed (provided that the button/direction key is enabled by above Bit4/5), however, because of switch bounce, one or more High to Low transitions are usually produced both when pressing or releasing a key.

tilkinsc commented 5 years ago

As I read but incorrectly documented. As I suspected.

tilkinsc commented 5 years ago

Ok then what about everything after 60h? That is what I meant. Is this for other interrupts?

tilkinsc commented 5 years ago

$0000-$00FF - Restart and Interrupt Vector Table The first 255 byte area in the Gameboy address space is reserved for Interrupt Vectors and Restart Vectors. Interrupts are a break in program code generated by a piece of the hardware when a certain condition is met. These conditions can be set by the programmer. There are several different types of interrupts, and when an interrupt is generated, the program stops where it is, and jumps to one of the specified locations in the Vector Table. The types of interrups are:

V-Blank - This interrupt can be generated when the LCD has drawn the last line on the screen and gone into the vertical blanking period. When this Interrupt is triggered, the CPU stores the current point of execution on the Stack, and jumps to $0040, which will usually contain another jump to the location of the code you want executed during the v-blank period.
LCDC - This interrupt can be generated by the LCD controller chip on various conditions, the most commonly used being the LYC condition, which is an interrupt generated when the LCD begins to draw a certain scanline. The scanline it generates an interrupt on is selectable. When triggered, this interrupt forces the CPU to jump to address $0048. For more information, see the section on I/O registers.
Timer - The system timer can be set to count at specified frequencies, and will increment a count register. When this register overflows, an interrupt is generated and the CPU jumps to $0050. More information in the I/O register section.
Serial - Generated by the serial link controller. The CPU jumps to $0058 when this interrupt is triggered. More info in the I/O register section.
Joypad - Generated when a key is pressed. Due to button "bounce", this interrupt may occur several times when a button is pressed. More info in the I/O register section.
tilkinsc commented 5 years ago

https://github.com/tilkinsc/gbheaderview I written a program based off this information. 1026 lines of code :X. Does this:

C:\programming\gbheader>test "Pokemon Yellow.gb"
rst00h - ff 00 00 00 00 00 00 00
rst08h - ff 00 00 00 00 00 00 00
rst10h - ff 00 00 00 00 00 00 00
rst18h - ff 00 00 00 00 00 00 00
rst20h - ff 00 00 00 00 00 00 00
rst28h - ff 00 00 00 00 00 00 00
rst30h - ff 00 00 00 00 00 00 00
rst38h - ff 00 00 00 00 00 00 00

int40h - c3 e5 1d 00 00 00 00 00
int48h - c3 ac 15 00 00 00 00 00
int50h - c3 6a 21 00 00 00 00 00
int58h - c3 79 1f 00 00 00 00 00
int60h - d9 af e0 0f f0 ff 47 cb
int68h - 87 e0 ff f0 44 fe 91 20
int70h - fa f0 40 e6 7f e0 40 78
int78h - e0 ff c9 f0 40 cb ff e0
int80h - 40 c9 af 21 00 c3 06 a0
int88h - 22 05 20 fc c9 3e a0 21
int90h - 00 c3 11 04 00 06 28 77
int98h - 19 05 20 fb c9 ea 22 d1
intA0h - f0 b8 f5 fa 22 d1 cd 7e
intA8h - 3e cd b1 00 f1 cd 7e 3e
intB0h - c9 78 a7 28 0c 79 a7 28
intB8h - 01 04 cd c1 00 05 20 fa
intC0h - c9 2a 12 13 0d 20 fa c9
intC8h - f0 40 cb 7f c2 fe 15 e5
intD0h - 62 6b d1 78 f5 cb 31 3e
intD8h - 0f a1 47 3e f0 a1 4f f1
intE0h - c3 9d 00 f0 40 cb 7f c2
intE8h - 36 16 d5 54 5d 78 f5 26
intF0h - 00 69 29 29 29 44 4d f1
intF8h - e1 c3 d4 15 00 00 00 00

Entry Point - 00 c3 ab 01

Title - POKEMON YELLOW\0

CGB Flag - 80 (CGB and GB)
New Licensee Code - (ASCII) 01 (Nintendo)
SGB Flag - 03 (SGB Functions)

Cartridge Type - 1b (MBC5+RAM+BATTERY)
Rom Size - 05 (1MByte (64 banks) - only 63 banks used by MBC1)
Ram Size - 03 (32 KByte (4 banks * 8 KByte))

Destination Code - 01 (Non-Japanese)
Old Licensee Code - 33 (GBC - See Above)
ROM Version - 00

Header Checksum - 97
Global Checksum - 04 7c
tilkinsc commented 5 years ago

GBROMtxt.7z.zip This is a list of all the headers of most all of the gb and gbc roms. If you want to run something statistical. It is actually a .7z file not a .zip.