gb

package
v0.0.0-...-67df9fb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CBCycles = []int{} //0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f

/* 256 elements not displayed */
View Source
var DAATable = []uint16{}/* 2048 elements not displayed */

Reference: https://github.com/gabrielrcouto/php-terminal-gameboy-emulator/blob/master/src/Data.php

View Source
var OPCodeFunctionMap = [0x100]OPCodeUnit{}/* 245 elements not displayed */
View Source
var RamBankMap = map[byte]uint8{
	byte(0x00): 0,
	byte(0x01): 1,
	byte(0x02): 1,
	byte(0x03): 4,
}

RAM bank number is linked to the RAM Size byte (0149).

1 bank = 8 KBytes

0x00 means no bank required.

View Source
var RomBankMap = map[byte]uint8{
	byte(0x00): 2,
	byte(0x01): 4,
	byte(0x02): 8,
	byte(0x03): 16,
	byte(0x04): 32,
	byte(0x05): 64,
	byte(0x06): 128,
	byte(0x52): 72,
	byte(0x53): 80,
	byte(0x54): 96,
}

ROM bank number is linked to the ROM Size byte (0148).

1 bank = 16 KBytes

0x00 means no bank required.

Functions

This section is empty.

Types

type CPU

type CPU struct {
	Registers Registers
	Flags     Flags
	Halt      bool
}

func (*CPU) Compare

func (cpu *CPU) Compare(val1 byte, val2 byte)

type Cartridge

type Cartridge struct {
	Props *CartridgeProps
	MBC   MBC
}

type CartridgeProps

type CartridgeProps struct {
	MBCType   string
	ROMLength int
	ROMBank   uint8
	RAMBank   uint8
}

Cartridge props

type Channel

type Channel struct {
	Freq int
	// contains filtered or unexported fields
}

func (*Channel) Envelope

func (channel *Channel) Envelope()

func (Channel) Err

func (channel Channel) Err() error

func (Channel) Stream

func (channel Channel) Stream(samples [][2]float64) (n int, ok bool)

func (*Channel) Sweep

func (channel *Channel) Sweep()

type Core

type Core struct {
	Cartridge Cartridge
	CPU       CPU
	Memory    Memory
	Sound     Sound

	/*
	   +++++++++++++++++++++++
	   +     Serial Port     +
	   +++++++++++++++++++++++
	*/
	Serial         driver.ChannelIO
	SerialByte     byte
	InterruptCount int

	/*
	   +++++++++++++++++++++++
	   +        Joypad       +
	   +++++++++++++++++++++++
	*/
	Controller   driver.ControllerDriver
	JoypadStatus byte

	//Screen pixel data
	Screen     [160][144][3]uint8
	ScanLineBG [160]bool
	//Display driver
	DisplayDriver driver.DisplayDriver
	// Signal to tell display driver to draw
	DrawSignal chan bool

	/*
	  +++++++++++++++++++++++++++
	  + Clock and speed options +
	  +++++++++++++++++++++++++++
	*/
	//Frames per-second
	FPS int
	//CPU clock
	Clock int
	//in CBG mode, clock might change to twice as original
	SpeedMultiple int

	/*
	  ++++++++++++++++++++++++++
	  +  Development options   +
	  ++++++++++++++++++++++++++
	*/
	//Debug mode
	Debug bool
	//Commands num to be executed in DEBUG mode
	DebugControl uint16

	StepExe int

	/*
	  ++++++++++++++++++++++++++
	  +      Other options     +
	  ++++++++++++++++++++++++++
	*/
	ToggleSound bool
	/*
		Timer
	*/
	Timer     Timer
	Exit      bool
	GameTitle string
	RamURI    fyne.URI
	// contains filtered or unexported fields
}

func (*Core) BIT

func (core *Core) BIT(pos byte, getter func() byte)

func (*Core) Break

func (core *Core) Break(code byte)

Break execution and print register/dump memory information for debug purpose.

func (*Core) DoDMA

func (core *Core) DoDMA(data byte)

Perform DMA transfer. The written value specifies the transfer source address divided by 100h, ie. source & destination are:

Source:      XX00-XX9F   ;XX in range from 00-F1h
Destination: FE00-FE9F

func (*Core) DrawScanLine

func (core *Core) DrawScanLine()

Draw the current scan line

func (*Core) ExecuteNextOPCode

func (core *Core) ExecuteNextOPCode() int

Execute the next OPCode and return used CPU clock

func (*Core) ExecuteOPCode

func (core *Core) ExecuteOPCode(code byte) int

Execute given OPCode and return used CPU clock

func (*Core) GetColour

func (core *Core) GetColour(colourNum byte, address uint16) int

Get colour id via colour palette and colour Num

0 - WHITE
1 - LIGHT_GRAY
2 - DARK_GRAY
3 - BLACK

TODO: GCB mode

func (*Core) GetJoypadStatus

func (core *Core) GetJoypadStatus() byte

func (*Core) Init

func (core *Core) Init(romData []byte, u fyne.URI)

Initialize emulator

func (*Core) IsLCDEnabled

func (core *Core) IsLCDEnabled() bool

Check if LCD is enabled

func (*Core) OP00

func (core *Core) OP00() int

/*

OP:0X00 NOP

func (*Core) OP01

func (core *Core) OP01() int

OP:0x01 LD BC,d16

func (*Core) OP02

func (core *Core) OP02() int

OP:0x02 LD (BC),A

func (*Core) OP03

func (core *Core) OP03() int

OP:0x03 INC BC

func (*Core) OP04

func (core *Core) OP04() int

OP:0x04 INC B

func (*Core) OP05

func (core *Core) OP05() int

OP:0X05 DEC B

func (*Core) OP06

func (core *Core) OP06() int

OP:0X06 LD B,d8

func (*Core) OP07

func (core *Core) OP07() int

OP:0x07 RLCA

func (*Core) OP08

func (core *Core) OP08() int

OP:0x08 LD (a16),SP

func (*Core) OP09

func (core *Core) OP09() int

OP:0x09 ADD HL,BC

func (*Core) OP0A

func (core *Core) OP0A() int

OP:0x0A LD A,(BC)

func (*Core) OP0B

func (core *Core) OP0B() int

OP:0x0B DEC BC

func (*Core) OP0C

func (core *Core) OP0C() int

OP:0x0C INC C

func (*Core) OP0D

func (core *Core) OP0D() int

OP:0X0D DEC C

func (*Core) OP0E

func (core *Core) OP0E() int

OP:0X0E LD C,d8

func (*Core) OP0F

func (core *Core) OP0F() int

OP:0x0F RRCA

func (*Core) OP10

func (core *Core) OP10() int

OP:0x10 STOP 0

func (*Core) OP11

func (core *Core) OP11() int

OP:0x11 LD DE,d16

func (*Core) OP12

func (core *Core) OP12() int

OP:0x12 LD (DE),A

func (*Core) OP13

func (core *Core) OP13() int

OP:0x13 INC DE

func (*Core) OP14

func (core *Core) OP14() int

OP:0x14 INC D

func (*Core) OP15

func (core *Core) OP15() int

OP:0x15 DEC D

func (*Core) OP16

func (core *Core) OP16() int

OP:0x16 LD D,d8

func (*Core) OP17

func (core *Core) OP17() int

OP:0x17 RLA

func (*Core) OP18

func (core *Core) OP18() int

OP:0x18 JR r8

func (*Core) OP19

func (core *Core) OP19() int

OP:0x19 ADD HL,DE

func (*Core) OP1A

func (core *Core) OP1A() int

OP:0x1A LD A,(DE)

func (*Core) OP1B

func (core *Core) OP1B() int

OP:0x1B DEC DE

func (*Core) OP1C

func (core *Core) OP1C() int

OP:0x1C INC E

func (*Core) OP1D

func (core *Core) OP1D() int

OP:0x1D DEC E

func (*Core) OP1E

func (core *Core) OP1E() int

OP:0x1E LD E,d8

func (*Core) OP1F

func (core *Core) OP1F() int

OP:0X1F RRA

func (*Core) OP20

func (core *Core) OP20() int

OP:0X20 JR NZ,r8

func (*Core) OP21

func (core *Core) OP21() int

OP:0X21 LD HL,d16

func (*Core) OP22

func (core *Core) OP22() int

OP:0x22 LD (HL+),A

func (*Core) OP23

func (core *Core) OP23() int

OP:0x23 INC HL

func (*Core) OP24

func (core *Core) OP24() int

OP:0x24 INC H

func (*Core) OP25

func (core *Core) OP25() int

OP:0x25 DEC H

func (*Core) OP26

func (core *Core) OP26() int

OP:0x26 LD H,d8

func (*Core) OP27

func (core *Core) OP27() int

OP:0x27 DAA

func (*Core) OP28

func (core *Core) OP28() int

OP:0x28 JR Z,r8

func (*Core) OP29

func (core *Core) OP29() int

OP:0x29 ADD HL,HL

func (*Core) OP2A

func (core *Core) OP2A() int

OP:0x2A LD A,(HL+)

func (*Core) OP2B

func (core *Core) OP2B() int

OP:0x2B DEC HL

func (*Core) OP2C

func (core *Core) OP2C() int

OP:0x2C INC L

func (*Core) OP2D

func (core *Core) OP2D() int

OP:0x2D DEC L

func (*Core) OP2E

func (core *Core) OP2E() int

OP:0x2E LD L,d8

func (*Core) OP2F

func (core *Core) OP2F() int

OP:0x2F CPL

func (*Core) OP30

func (core *Core) OP30() int

OP:0x30 JR NC,r8

func (*Core) OP31

func (core *Core) OP31() int

OP:0x31 LD SP,d16

func (*Core) OP32

func (core *Core) OP32() int

OP:0X32 LD (HL-),A

func (*Core) OP33

func (core *Core) OP33() int

OP:0x33 INC SP

func (*Core) OP34

func (core *Core) OP34() int

OP:0x34 INC (HL)

func (*Core) OP35

func (core *Core) OP35() int

OP:0x35 DEC (HL)

func (*Core) OP36

func (core *Core) OP36() int

OP:0x36 LD (HL),d8

func (*Core) OP37

func (core *Core) OP37() int

OP:0x37 SCF

func (*Core) OP38

func (core *Core) OP38() int

OP:0x38 JR C,r8

func (*Core) OP39

func (core *Core) OP39() int

OP:0x39 ADD HL,SP

func (*Core) OP3A

func (core *Core) OP3A() int

OP:0x3A LD A,(HL-)

func (*Core) OP3B

func (core *Core) OP3B() int

OP:0x3B DEC SP

func (*Core) OP3C

func (core *Core) OP3C() int

OP:0x3C INC A

func (*Core) OP3D

func (core *Core) OP3D() int

OP:0x3D DEC A

func (*Core) OP3E

func (core *Core) OP3E() int

OP:0x3E LD A,d8

func (*Core) OP3F

func (core *Core) OP3F() int

OP:0x3F CCF

func (*Core) OP40

func (core *Core) OP40() int

OP:0x40 LD B,B

func (*Core) OP41

func (core *Core) OP41() int

OP:0x41 LD B,C

func (*Core) OP42

func (core *Core) OP42() int

OP:0x42 LD B,D

func (*Core) OP43

func (core *Core) OP43() int

OP:0x43 LD B,E

func (*Core) OP44

func (core *Core) OP44() int

OP:0x44 LD B,H

func (*Core) OP45

func (core *Core) OP45() int

OP:0x45 LD B,L

func (*Core) OP46

func (core *Core) OP46() int

OP:0x46 LD B,(HL)

func (*Core) OP47

func (core *Core) OP47() int

OP:0x47 LD B,A

func (*Core) OP48

func (core *Core) OP48() int

OP:0x48 LD C,B

func (*Core) OP49

func (core *Core) OP49() int

OP:0x49 LD C,C

func (*Core) OP4A

func (core *Core) OP4A() int

OP:0x4A LD C,D

func (*Core) OP4B

func (core *Core) OP4B() int

OP:0x4B LD C,E

func (*Core) OP4C

func (core *Core) OP4C() int

OP:0x4C LD C,H

func (*Core) OP4D

func (core *Core) OP4D() int

OP:0x4D LD C,L

func (*Core) OP4E

func (core *Core) OP4E() int

OP:0x4E LD C,(HL)

func (*Core) OP4F

func (core *Core) OP4F() int

OP:0x4F LD C,A

func (*Core) OP50

func (core *Core) OP50() int

OP:0x50 LD D,B

func (*Core) OP51

func (core *Core) OP51() int

OP:0x51 LD D,C

func (*Core) OP52

func (core *Core) OP52() int

OP:0x52 LD D,D

func (*Core) OP53

func (core *Core) OP53() int

OP:0x53 LD D,E

func (*Core) OP54

func (core *Core) OP54() int

OP:0x54 LD D,H

func (*Core) OP55

func (core *Core) OP55() int

OP:0x55 LD D,L

func (*Core) OP56

func (core *Core) OP56() int

OP:0x56 LD D,(HL)

func (*Core) OP57

func (core *Core) OP57() int

OP:0x57 LD D,A

func (*Core) OP58

func (core *Core) OP58() int

OP:0x58 LD E,B

func (*Core) OP59

func (core *Core) OP59() int

OP:0x59 LD E,C

func (*Core) OP5A

func (core *Core) OP5A() int

OP:0x5A LD E,D

func (*Core) OP5B

func (core *Core) OP5B() int

OP:0x5B LD E,E

func (*Core) OP5C

func (core *Core) OP5C() int

OP:0x5C LD E,H

func (*Core) OP5D

func (core *Core) OP5D() int

OP:0x5D LD E,L

func (*Core) OP5E

func (core *Core) OP5E() int

OP:0x5E LD E,(HL)

func (*Core) OP5F

func (core *Core) OP5F() int

OP:0x5F LD E,A

func (*Core) OP60

func (core *Core) OP60() int

OP:0x60 LD H,B

func (*Core) OP61

func (core *Core) OP61() int

OP:0x61 LD H,C

func (*Core) OP62

func (core *Core) OP62() int

OP:0x62 LD H,D

func (*Core) OP63

func (core *Core) OP63() int

OP:0x63 LD H,e

func (*Core) OP64

func (core *Core) OP64() int

OP:0x64 LD H,H

func (*Core) OP65

func (core *Core) OP65() int

OP:0x65 LD H,L

func (*Core) OP66

func (core *Core) OP66() int

OP:0x66 LD H,(HL)

func (*Core) OP67

func (core *Core) OP67() int

OP:0x67 LD H,A

func (*Core) OP68

func (core *Core) OP68() int

OP:0x68 LD L,B

func (*Core) OP69

func (core *Core) OP69() int

OP:0x69 LD L,C

func (*Core) OP6A

func (core *Core) OP6A() int

OP:0x6A LD L,D

func (*Core) OP6B

func (core *Core) OP6B() int

OP:0x6B LD L,E

func (*Core) OP6C

func (core *Core) OP6C() int

OP:0x6C LD L,H

func (*Core) OP6D

func (core *Core) OP6D() int

OP:0x6D LD L,L

func (*Core) OP6E

func (core *Core) OP6E() int

OP:0x6E LD L,(HL)

func (*Core) OP6F

func (core *Core) OP6F() int

OP:0x6F LD L,A

func (*Core) OP70

func (core *Core) OP70() int

OP:0x70 LD (HL),B

func (*Core) OP71

func (core *Core) OP71() int

OP:0x71 LD (HL),C

func (*Core) OP72

func (core *Core) OP72() int

OP:0x72 LD (HL),D

func (*Core) OP73

func (core *Core) OP73() int

OP:0x73 LD (HL),E

func (*Core) OP74

func (core *Core) OP74() int

OP:0x74 LD (HL),H

func (*Core) OP75

func (core *Core) OP75() int

OP:0x75 LD (HL),L

func (*Core) OP76

func (core *Core) OP76() int

OP:0x76 HALT

func (*Core) OP77

func (core *Core) OP77() int

OP:0x77 LD (HL),A

func (*Core) OP78

func (core *Core) OP78() int

OP:0x78 LD A,B

func (*Core) OP79

func (core *Core) OP79() int

OP:0x79 LD A,C

func (*Core) OP7A

func (core *Core) OP7A() int

OP:0x7A LD A,D

func (*Core) OP7B

func (core *Core) OP7B() int

OP:0x7B LD A,E

func (*Core) OP7C

func (core *Core) OP7C() int

OP:0x7C LD A,H

func (*Core) OP7D

func (core *Core) OP7D() int

OP:0x7D LD A,L

func (*Core) OP7E

func (core *Core) OP7E() int

OP:0x7E LD A,(HL)

func (*Core) OP7F

func (core *Core) OP7F() int

OP:0x7F LD A,A

func (*Core) OP80

func (core *Core) OP80() int

OP:0x80 ADD A,B

func (*Core) OP81

func (core *Core) OP81() int

OP:0x81 ADD A,C

func (*Core) OP82

func (core *Core) OP82() int

OP:0x82 ADD A,D

func (*Core) OP83

func (core *Core) OP83() int

OP:0x83 ADD A,E

func (*Core) OP84

func (core *Core) OP84() int

OP:0x84 ADD A,H

func (*Core) OP85

func (core *Core) OP85() int

OP:0x85 ADD A,L

func (*Core) OP86

func (core *Core) OP86() int

OP:0x86 ADD A,(HL)

func (*Core) OP87

func (core *Core) OP87() int

OP:0x87 ADD A,A

func (*Core) OP88

func (core *Core) OP88() int

OP:0x88 ADC A,B

func (*Core) OP89

func (core *Core) OP89() int

OP:0x89 ADC A,C

func (*Core) OP8A

func (core *Core) OP8A() int

OP:0x8A ADC A,F

func (*Core) OP8B

func (core *Core) OP8B() int

OP:0x8B ADC A,E

func (*Core) OP8C

func (core *Core) OP8C() int

OP:0x8C ADC A,H

func (*Core) OP8D

func (core *Core) OP8D() int

OP:0x8D ADC A,L

func (*Core) OP8E

func (core *Core) OP8E() int

OP:0x8E ADC A,(HL)

func (*Core) OP8F

func (core *Core) OP8F() int

OP:0x8F ADC A,A

func (*Core) OP90

func (core *Core) OP90() int

OP:0x90 SUB B

func (*Core) OP91

func (core *Core) OP91() int

OP:0x91 SUB C

func (*Core) OP92

func (core *Core) OP92() int

OP:0x92 SUB D

func (*Core) OP93

func (core *Core) OP93() int

OP:0x93 SUB E

func (*Core) OP94

func (core *Core) OP94() int

OP:0x94 SUB H

func (*Core) OP95

func (core *Core) OP95() int

OP:0x95 SUB L

func (*Core) OP96

func (core *Core) OP96() int

OP:0x96 SUB (HL)

func (*Core) OP97

func (core *Core) OP97() int

OP:0x97 SUB A

func (*Core) OP98

func (core *Core) OP98() int

OP:0x98 SBC A,B

func (*Core) OP99

func (core *Core) OP99() int

OP:0x99 SBC A,C

func (*Core) OP9A

func (core *Core) OP9A() int

OP:0x9A SBC A,D

func (*Core) OP9B

func (core *Core) OP9B() int

OP:0x9B SBC A,E

func (*Core) OP9C

func (core *Core) OP9C() int

OP:0x9C SBC A,H

func (*Core) OP9D

func (core *Core) OP9D() int

OP:0x9D SBC A,L

func (*Core) OP9E

func (core *Core) OP9E() int

OP:0x9E SBC A,(HL)

func (*Core) OP9F

func (core *Core) OP9F() int

OP:0x9F SBC A,A

func (*Core) OPA0

func (core *Core) OPA0() int

OP:0xA0 AND B

func (*Core) OPA1

func (core *Core) OPA1() int

OP:0xA1 AND C

func (*Core) OPA2

func (core *Core) OPA2() int

OP:0xA2 AND D

func (*Core) OPA3

func (core *Core) OPA3() int

OP:0xA3 AND E

func (*Core) OPA4

func (core *Core) OPA4() int

OP:0xA4 AND H

func (*Core) OPA5

func (core *Core) OPA5() int

OP:0xA5 AND L

func (*Core) OPA6

func (core *Core) OPA6() int

OP:0xA6 AND (HL)

func (*Core) OPA7

func (core *Core) OPA7() int

OP:0xA7 AND A

func (*Core) OPA8

func (core *Core) OPA8() int

OP:0xA8 XOR B

func (*Core) OPA9

func (core *Core) OPA9() int

OP:0xA9 XOR C

func (*Core) OPAA

func (core *Core) OPAA() int

OP:0xAA XOR F

func (*Core) OPAB

func (core *Core) OPAB() int

OP:0xAB XOR E

func (*Core) OPAC

func (core *Core) OPAC() int

OP:0xAC XOR H

func (*Core) OPAD

func (core *Core) OPAD() int

OP:0xAD XOR L

func (*Core) OPAE

func (core *Core) OPAE() int

OP:0xAE XOR (HL)

func (*Core) OPAF

func (core *Core) OPAF() int

OP:0XAF XOR A

func (*Core) OPB0

func (core *Core) OPB0() int

OP:0xB0 OR B

func (*Core) OPB1

func (core *Core) OPB1() int

OP:0xB1 OR C

func (*Core) OPB2

func (core *Core) OPB2() int

OP:0xB2 OR D

func (*Core) OPB3

func (core *Core) OPB3() int

OP:0xB3 OR E

func (*Core) OPB4

func (core *Core) OPB4() int

OP:0xB4 OR H

func (*Core) OPB5

func (core *Core) OPB5() int

OP:0xB5 OR L

func (*Core) OPB6

func (core *Core) OPB6() int

OP:0xB6 OR (HL)

func (*Core) OPB7

func (core *Core) OPB7() int

OP:0xB7 OR A

func (*Core) OPB8

func (core *Core) OPB8() int

OP:0xB8 CP B

func (*Core) OPB9

func (core *Core) OPB9() int

OP:0xB9 CP C

func (*Core) OPBA

func (core *Core) OPBA() int

OP:0xBA CP D

func (*Core) OPBB

func (core *Core) OPBB() int

OP:0xBB CP E

func (*Core) OPBC

func (core *Core) OPBC() int

OP:0xBC CP H

func (*Core) OPBD

func (core *Core) OPBD() int

OP:0xBD CP L

func (*Core) OPBE

func (core *Core) OPBE() int

OP:0xBE CP (HL)

func (*Core) OPBF

func (core *Core) OPBF() int

OP:0xBF CP A

func (*Core) OPC0

func (core *Core) OPC0() int

OP:0xC0 RET NZ

func (*Core) OPC1

func (core *Core) OPC1() int

OP:0xC1 POP BC

func (*Core) OPC2

func (core *Core) OPC2() int

OP:0xC2 JP NZ,a16

func (*Core) OPC3

func (core *Core) OPC3() int

OP:0XC3 JP a16

func (*Core) OPC4

func (core *Core) OPC4() int

OP:0xC4 CALL NZ,a16

func (*Core) OPC5

func (core *Core) OPC5() int

OP:0xC5 PUSH BC

func (*Core) OPC6

func (core *Core) OPC6() int

OP:0xC6 ADD A,d8

func (*Core) OPC7

func (core *Core) OPC7() int

OP:0xC7 RST 00H

func (*Core) OPC8

func (core *Core) OPC8() int

OP:0xC8 RET Z

func (*Core) OPC9

func (core *Core) OPC9() int

OP:0xC9 RET

func (*Core) OPCA

func (core *Core) OPCA() int

OP:0xCA JP Z,a16

func (*Core) OPCB

func (core *Core) OPCB() int

OP:0xCB PREFIX CB

func (*Core) OPCC

func (core *Core) OPCC() int

OP:0xCC CALL Z,a16

func (*Core) OPCD

func (core *Core) OPCD() int

OP:0xCD CALL a16

func (*Core) OPCE

func (core *Core) OPCE() int

OP:0xCE ADC ADC A,d8

func (*Core) OPCF

func (core *Core) OPCF() int

OP:0xCF RST 08H

func (*Core) OPD0

func (core *Core) OPD0() int

OP:0xD0 RET NC

func (*Core) OPD1

func (core *Core) OPD1() int

OP:0xD1 POP DE

func (*Core) OPD2

func (core *Core) OPD2() int

OP:0xD2 JP NC,a16

func (*Core) OPD4

func (core *Core) OPD4() int

OP:0xD4 CALL NC,a16

func (*Core) OPD5

func (core *Core) OPD5() int

OP:0xD5 PUSH DE

func (*Core) OPD6

func (core *Core) OPD6() int

OP:0xD6 SUB d8

func (*Core) OPD7

func (core *Core) OPD7() int

OP:0xD7 RST RST 10H

func (*Core) OPD8

func (core *Core) OPD8() int

OP:0xD8 RET C

func (*Core) OPD9

func (core *Core) OPD9() int

OP:0xD9 RETI

func (*Core) OPDA

func (core *Core) OPDA() int

OP:0xDA JP C,a16

func (*Core) OPDC

func (core *Core) OPDC() int

OP:0xDB CALL C,a16

func (*Core) OPDE

func (core *Core) OPDE() int

OP:0xDE SBC A,d8

func (*Core) OPDF

func (core *Core) OPDF() int

OP:0xDF RST 18H

func (*Core) OPE0

func (core *Core) OPE0() int

OP:0xE0 LDH (a8),A

func (*Core) OPE1

func (core *Core) OPE1() int

OP:0xE1 POP HL

func (*Core) OPE2

func (core *Core) OPE2() int

OP:0xE2 LD (C),A

func (*Core) OPE5

func (core *Core) OPE5() int

OP:0xE5 PUSH HL

func (*Core) OPE6

func (core *Core) OPE6() int

OP:0xE6 AND d8

func (*Core) OPE7

func (core *Core) OPE7() int

OP:0xE7 RST 20H

func (*Core) OPE8

func (core *Core) OPE8() int

OP:0xE8 ADD SP,r8

func (*Core) OPE9

func (core *Core) OPE9() int

OP:0xE9 JP (HL)

func (*Core) OPEA

func (core *Core) OPEA() int

OP:0xEA LD (a16),A

func (*Core) OPEE

func (core *Core) OPEE() int

OP:0xEE XOR d8

func (*Core) OPEF

func (core *Core) OPEF() int

OP:0xEF RST 28H

func (*Core) OPF0

func (core *Core) OPF0() int

OP:0xF0 LDH LDH A,(a8)

func (*Core) OPF1

func (core *Core) OPF1() int

OP:0xF1 POP AF

func (*Core) OPF2

func (core *Core) OPF2() int

OP:0xF2 LD A,(C)

func (*Core) OPF3

func (core *Core) OPF3() int

OP:0xF3 DI

func (*Core) OPF5

func (core *Core) OPF5() int

OP:0xF5 PUSH AF

func (*Core) OPF6

func (core *Core) OPF6() int

OP:0xF6 OR d8

func (*Core) OPF7

func (core *Core) OPF7() int

OP:0xf7 RST 30H

func (*Core) OPF8

func (core *Core) OPF8() int

OP:0xF8 LD HL,SP+r8

func (*Core) OPF9

func (core *Core) OPF9() int

OP:0xF9 LD SP,HL

func (*Core) OPFA

func (core *Core) OPFA() int

OP:0xC0 LD A,(a16)

func (*Core) OPFB

func (core *Core) OPFB() int

OP:0xFB EI

func (*Core) OPFE

func (core *Core) OPFE() int

OP:0xFE CP d8

func (*Core) OPFF

func (core *Core) OPFF() int

OP:0xff RST 38H

func (*Core) Pause

func (core *Core) Pause()

func (*Core) RL

func (core *Core) RL(getter func() byte, setter func(byte))

func (*Core) RLC

func (core *Core) RLC(getter func() byte, setter func(byte))

func (*Core) RR

func (core *Core) RR(getter func() byte, setter func(byte))

func (*Core) RRC

func (core *Core) RRC(getter func() byte, setter func(byte))

func (*Core) ReadMemory

func (core *Core) ReadMemory(address uint16) byte

func (*Core) RenderScreen

func (core *Core) RenderScreen()

func (*Core) RenderSprites

func (core *Core) RenderSprites()

Render Sprites

func (*Core) RenderTiles

func (core *Core) RenderTiles()

Render Tiles for the current scan line

func (*Core) Resume

func (core *Core) Resume()

func (*Core) Run

func (core *Core) Run()

Start the emulation loop

func (*Core) SLA

func (core *Core) SLA(getter func() byte, setter func(byte))

func (*Core) SRA

func (core *Core) SRA(getter func() byte, setter func(byte))

func (*Core) SRL

func (core *Core) SRL(getter func() byte, setter func(byte))

func (*Core) SWAP

func (core *Core) SWAP(getter func() byte, setter func(byte))

func (*Core) SaveRAM

func (core *Core) SaveRAM()

func (*Core) SetLCDStatus

func (core *Core) SetLCDStatus()

* FF41 - STAT - LCDC Status (R/W)

  Bit 6 - LYC=LY Coincidence Interrupt (1=Enable) (Read/Write)
  Bit 5 - Mode 2 OAM Interrupt         (1=Enable) (Read/Write)
  Bit 4 - Mode 1 V-Blank Interrupt     (1=Enable) (Read/Write)
  Bit 3 - Mode 0 H-Blank Interrupt     (1=Enable) (Read/Write)
  Bit 2 - Coincidence Flag  (0:LYC<>LY, 1:LYC=LY) (Read Only)
  Bit 1-0 - Mode Flag       (Mode 0-3, see below) (Read Only)
			0: During H-Blank
			1: During V-Blank
			2: During Searching OAM-RAM
			3: During Transfering Data to LCD Driver

The two lower STAT bits show the current status of the LCD controller.

  Mode 0: The LCD controller is in the H-Blank period and
		  the CPU can access both the display RAM (8000h-9FFFh)
		  and OAM (FE00h-FE9Fh)

  Mode 1: The LCD contoller is in the V-Blank period (or the
		  display is disabled) and the CPU can access both the
		  display RAM (8000h-9FFFh) and OAM (FE00h-FE9Fh)

  Mode 2: The LCD controller is reading from OAM memory.
		  The CPU <cannot> access OAM memory (FE00h-FE9Fh)
		  during this period.

  Mode 3: The LCD controller is reading from both OAM and VRAM,
		  The CPU <cannot> access OAM and VRAM during this period.
		  CGB Mode: Cannot access Palette Data (FF69,FF6B) either.

The following are typical when the display is enabled:

Mode 2  2_____2_____2_____2_____2_____2___________________2____
Mode 3  _33____33____33____33____33____33__________________3___
Mode 0  ___000___000___000___000___000___000________________000
Mode 1  ____________________________________11111111111111_____

The Mode Flag goes through the values 0, 2, and 3 at a cycle of about 109uS. 0 is present about 48.6uS, 2 about 19uS, and 3 about 41uS. This is interrupted every 16.6ms by the VBlank (1). The mode flag stays set at 1 for about 1.08 ms.

Mode 0 is present between 201-207 clks, 2 about 77-83 clks, and 3 about 169-175 clks. A complete cycle through these states takes 456 clks. VBlank lasts 4560 clks. A complete screen refresh occurs every 70224 clks.)

func (*Core) StackPop

func (core *Core) StackPop() uint16

Pop a word into stack and update SP

func (*Core) StackPush

func (core *Core) StackPush(val uint16)

Push a word into stack and update SP

func (*Core) UpdateGraphics

func (core *Core) UpdateGraphics(cycles int)

Scan line and draw line

func (*Core) WriteMemory

func (core *Core) WriteMemory(address uint16, data byte)

type Flags

type Flags struct {
	Zero      bool
	Sub       bool
	HalfCarry bool
	Carry     bool
	//	IME - Interrupt Master Enable Flag (Write Only)
	//  	0 - Disable all Interrupts
	//  	1 - Enable all Interrupts that are enabled in IE Register (FFFF)
	InterruptMaster bool

	PendingInterruptEnabled bool
}

The Flag Register (lower 8bit of AF register)

Bit  Name  Set Clr  Expl.
7    zf    Z   NZ   Zero Flag
6    n     -   -    Add/Sub-Flag (BCD)
5    h     -   -    Half Carry Flag (BCD)
4    cy    C   NC   Carry Flag
3-0  -     -   -    Not used (always zero)

Contains the result from the recent instruction which has affected flags.

type MBC

type MBC interface {
	ReadRom(uint16) byte
	ReadRomBank(uint16) byte
	ReadRamBank(uint16) byte
	WriteRamBank(uint16, byte)
	HandleBanking(uint16, byte)
	SaveRam(fyne.URI)
}

type MBC1

type MBC1 struct {
	CurrentROMBank byte
	RAMBank        []byte
	CurrentRAMBank byte
	EnableRAM      bool
	ROMBankingMode bool
	// contains filtered or unexported fields
}

====================================

MBC1

func (*MBC1) DoChangeHiRomBank

func (mbc *MBC1) DoChangeHiRomBank(val byte)

func (*MBC1) DoChangeLoROMBank

func (mbc *MBC1) DoChangeLoROMBank(val byte)

func (*MBC1) DoChangeROMRAMMode

func (mbc *MBC1) DoChangeROMRAMMode(val byte)

func (*MBC1) DoRAMBankChange

func (mbc *MBC1) DoRAMBankChange(val byte)

func (*MBC1) DoRamBankEnable

func (mbc *MBC1) DoRamBankEnable(address uint16, val byte)

func (*MBC1) HandleBanking

func (mbc *MBC1) HandleBanking(address uint16, val byte)

func (*MBC1) ReadRamBank

func (mbc *MBC1) ReadRamBank(address uint16) byte

A000-BFFF - RAM Bank 00-03, if any (Read/Write)

This area is used to address external RAM in the cartridge (if any).
External RAM is often battery buffered, allowing to store game positions
or high score tables, even if the gameboy is turned off, or if the cartridge
is removed from the gameboy. Available RAM sizes are: 2KByte (at A000-A7FF),
8KByte (at A000-BFFF), and 32KByte (in form of four 8K banks at A000-BFFF).

func (*MBC1) ReadRom

func (mbc *MBC1) ReadRom(address uint16) byte

func (*MBC1) ReadRomBank

func (mbc *MBC1) ReadRomBank(address uint16) byte

4000-7FFF - ROM Bank 01-7F (Read Only)

This area may contain any of the further 16KByte banks of the ROM,
allowing to address up to 125 ROM Banks (almost 2MByte). As described below,
bank numbers 20h, 40h, and 60h cannot be used, resulting in the odd amount of
125 banks.

func (*MBC1) SaveRam

func (mbc *MBC1) SaveRam(path fyne.URI)

func (*MBC1) WriteRamBank

func (mbc *MBC1) WriteRamBank(address uint16, data byte)

type MBC2

type MBC2 struct {
	CurrentROMBank byte
	RAMBank        []byte
	CurrentRAMBank byte
	EnableRAM      bool
	ROMBankingMode bool
	// contains filtered or unexported fields
}

====================================

MBC2

func (*MBC2) DoChangeHiRomBank

func (mbc *MBC2) DoChangeHiRomBank(val byte)

func (*MBC2) DoChangeLoROMBank

func (mbc *MBC2) DoChangeLoROMBank(val byte)

func (*MBC2) DoChangeROMRAMMode

func (mbc *MBC2) DoChangeROMRAMMode(val byte)

func (*MBC2) DoRAMBankChange

func (mbc *MBC2) DoRAMBankChange(val byte)

func (*MBC2) DoRamBankEnable

func (mbc *MBC2) DoRamBankEnable(address uint16, val byte)

func (*MBC2) HandleBanking

func (mbc *MBC2) HandleBanking(address uint16, val byte)

func (*MBC2) ReadRamBank

func (mbc *MBC2) ReadRamBank(address uint16) byte

func (*MBC2) ReadRom

func (mbc *MBC2) ReadRom(address uint16) byte

func (*MBC2) ReadRomBank

func (mbc *MBC2) ReadRomBank(address uint16) byte

func (*MBC2) SaveRam

func (mbc *MBC2) SaveRam(path fyne.URI)

func (*MBC2) WriteRamBank

func (mbc *MBC2) WriteRamBank(address uint16, data byte)

type MBC3

type MBC3 struct {
	CurrentROMBank byte
	RAMBank        []byte
	CurrentRAMBank byte
	EnableRAM      bool
	// contains filtered or unexported fields
}

====================================

MBC3

func (*MBC3) DoChangeHiRomBank

func (mbc *MBC3) DoChangeHiRomBank(val byte)

func (*MBC3) DoChangeLoROMBank

func (mbc *MBC3) DoChangeLoROMBank(val byte)

func (*MBC3) DoChangeROMRAMMode

func (mbc *MBC3) DoChangeROMRAMMode(val byte)

func (*MBC3) DoRAMBankChange

func (mbc *MBC3) DoRAMBankChange(val byte)

func (*MBC3) DoRamBankEnable

func (mbc *MBC3) DoRamBankEnable(address uint16, val byte)

func (*MBC3) HandleBanking

func (mbc *MBC3) HandleBanking(address uint16, val byte)

func (*MBC3) ReadRamBank

func (mbc *MBC3) ReadRamBank(address uint16) byte

func (*MBC3) ReadRom

func (mbc *MBC3) ReadRom(address uint16) byte

func (*MBC3) ReadRomBank

func (mbc *MBC3) ReadRomBank(address uint16) byte

func (*MBC3) SaveRam

func (mbc *MBC3) SaveRam(path fyne.URI)

func (*MBC3) WriteRamBank

func (mbc *MBC3) WriteRamBank(address uint16, data byte)

type MBCRom

type MBCRom struct {

	// Current ROM-Bank number
	CurrentROMBank byte
	RAMBank        [0x8000]byte
	// Current RAM-Bank number
	CurrentRAMBank byte
	EnableRAM      bool
	// contains filtered or unexported fields
}

==================================== Single ROM without MBC

func (*MBCRom) HandleBanking

func (mbc *MBCRom) HandleBanking(address uint16, val byte)

func (*MBCRom) ReadRamBank

func (mbc *MBCRom) ReadRamBank(address uint16) byte

* Read a byte from RAM bank. In ROM only cartridge, RAM is not supported.

func (*MBCRom) ReadRom

func (mbc *MBCRom) ReadRom(address uint16) byte

* Read a byte from raw rom via address

func (*MBCRom) ReadRomBank

func (mbc *MBCRom) ReadRomBank(address uint16) byte

* Read a byte from ROM bank. In ROM only cartridge, ROM banking is not supported.

func (*MBCRom) SaveRam

func (mbc *MBCRom) SaveRam(path fyne.URI)

func (*MBCRom) WriteRamBank

func (mbc *MBCRom) WriteRamBank(address uint16, data byte)

* Write a byte from RAM bank. In ROM only cartridge, RAM is not supported.

type Memory

type Memory struct {
	MainMemory [0x10000]byte
	// contains filtered or unexported fields
}

General Memory Map

0000-3FFF   16KB ROM Bank 00     (in cartridge, fixed at bank 00)
4000-7FFF   16KB ROM Bank 01..NN (in cartridge, switchable bank number)
8000-9FFF   8KB Video RAM (VRAM) (switchable bank 0-1 in CGB Mode)
A000-BFFF   8KB External RAM     (in cartridge, switchable bank, if any)
C000-CFFF   4KB Work RAM Bank 0 (WRAM)
D000-DFFF   4KB Work RAM Bank 1 (WRAM)  (switchable bank 1-7 in CGB Mode)
E000-FDFF   Same as C000-DDFF (ECHO)    (typically not used)
FE00-FE9F   Sprite Attribute Table (OAM)
FEA0-FEFF   Not Usable
FF00-FF7F   I/O Ports
FF80-FFFE   High RAM (HRAM)
FFFF        Interrupt Enable Register

func (*Memory) Dump

func (memory *Memory) Dump(path string)

type OPCodeUnit

type OPCodeUnit struct {
	Func  func(*Core) int
	Clock int
	OP    string
}

type Registers

type Registers struct {
	A  byte
	B  byte
	C  byte
	D  byte
	E  byte
	F  byte
	HL uint16
	PC uint16
	SP uint16
}

Registers

16bit Hi   Lo   Name/Function
AF    A    -    Accumulator & Flags
BC    B    C    BC
DE    D    E    DE
HL    H    L    HL
SP    -    -    Stack Pointer
PC    -    -    Program Counter/Pointer

type Sound

type Sound struct {
	Channel4 Channel
	Channel3 Channel
	Channel2 Channel
	Channel1 Channel

	VRAMCache   []byte
	SampleCache [32]float64
	// contains filtered or unexported fields
}

func (*Sound) Init

func (sound *Sound) Init()

func (*Sound) Play

func (sound *Sound) Play()

func (*Sound) Trigger

func (sound *Sound) Trigger(address uint16, val byte, vram []byte)

When sound related memory is writen, this function will be called to update sound props.

type Timer

type Timer struct {
	TimerCounter    int
	DividerRegister int
	ScanlineCounter int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL