Documentation
¶
Index ¶
- Constants
- Variables
- func CheckEeprom(gba *GBA, addr uint32) bool
- func ReadSound(addr uint32, a *apu.Apu) uint8
- func ReplaceByte(value uint32, newByte uint32, byteOffset uint32) uint32
- func UpdateAffineParams(obj *Object, m *Memory)
- func WriteSound(addr uint32, v uint8, a *apu.Apu)
- type Background
- type Blend
- type BlendPalettes
- type DMA
- type Debugger
- type Dispcnt
- type Dispstat
- type GBA
- func (gba *GBA) Close()
- func (gba *GBA) InputHandler(keys []ebiten.Key, buttons []ebiten.StandardGamepadButton)
- func (gba *GBA) LoadBios()
- func (gba *GBA) LoadGame(path string)
- func (gba *GBA) SetIdleAddr()
- func (gba *GBA) Tick(cycles uint32)
- func (gba *GBA) ToggleMute() bool
- func (gba *GBA) TogglePause() bool
- func (gba *GBA) Update(stdFps bool)
- func (gba *GBA) UpdateTimers(cycles uint32)
- func (gba *GBA) VideoUpdate(cycles uint32)
- type Keypad
- type Logger
- type Memory
- func (m *Memory) InitSaveLoop()
- func (m *Memory) Read(addr uint32) uint8
- func (m *Memory) Read8(addr uint32, _ bool) uint32
- func (m *Memory) Read16(addr uint32, _ bool) uint32
- func (m *Memory) Read32(addr uint32, _ bool) uint32
- func (m *Memory) ReadBadRom(addr uint32, bytesRead uint8) uint32
- func (m *Memory) ReadBios(addr uint32) uint8
- func (m *Memory) ReadIO(addr uint32) uint8
- func (m *Memory) ReadIODirect(addr uint32, size uint32) uint32
- func (m *Memory) ReadIODirectByte(addr uint32) uint32
- func (m *Memory) ReadOpenBus(addr uint32) uint8
- func (m *Memory) ReadPtr(addr uint32, _ bool) (unsafe.Pointer, bool)
- func (m *Memory) ReadSoundIO(addr uint32) uint8
- func (m *Memory) Write(addr uint32, v uint8, byteWrite bool)
- func (m *Memory) Write8(addr uint32, v uint8, _ bool)
- func (m *Memory) Write16(addr uint32, v uint16, _ bool)
- func (m *Memory) Write32(addr uint32, v uint32, _ bool)
- func (m *Memory) WriteIO(addr uint32, v uint8)
- func (m *Memory) WritePtr(addr uint32, _ bool) (unsafe.Pointer, bool)
- type Mosaic
- type Object
- type PPU
- type Timer
- type Window
- type Windows
Constants ¶
View Source
const ( INTRWAIT_NONE = 0 INTRWAIT_VBLANK = 1 )
View Source
const ( SYS_SoftReset = 0x00 SYS_RegisterRamReset = 0x01 SYS_Halt = 0x02 SYS_StopSleep = 0x03 SYS_IntrWait = 0x04 SYS_VBlankIntrWait = 0x05 SYS_Div = 0x06 SYS_DivArm = 0x07 SYS_Sqrt = 0x08 SYS_ArcTan = 0x09 SYS_ArcTan2 = 0x0A SYS_CpuSet = 0x0B SYS_CpuFastSet = 0x0C SYS_GetBiosChecksum = 0x0D SYS_BgAffineSet = 0x0E SYS_ObjAffineSet = 0x0F SYS_BitUnPack = 0x10 SYS_LZ77UnCompReadNormalWrite8bit = 0x11 SYS_LZ77UnCompReadNormalWrite16bit = 0x12 SYS_HuffUnCompReadNormal = 0x13 SYS_RLUnCompReadNormalWrite8bit = 0x14 SYS_RLUnCompReadNormalWrite16bit = 0x15 SYS_Diff8bitUnFilterWrite8bit = 0x16 SYS_Diff8bitUnFilterWrite16bit = 0x17 SYS_Diff16bitUnFilter = 0x18 SYS_SoundBias = 0x19 SYS_SoundDriverInit = 0x1A SYS_SoundDriverMode = 0x1B SYS_SoundDriverMain = 0x1C SYS_SoundDriverVSync = 0x1D SYS_SoundChannelClear = 0x1E SYS_MidiKey2Freq = 0x1F SYS_SoundWhatever0 = 0x20 SYS_SoundWhatever1 = 0x21 SYS_SoundWhatever2 = 0x22 SYS_SoundWhatever3 = 0x23 SYS_SoundWhatever4 = 0x24 SYS_MultiBoot = 0x25 SYS_HardReset = 0x26 SYS_CustomHalt = 0x27 SYS_SoundDriverVSyncOff = 0x28 SYS_SoundDriverVSyncOn = 0x29 SYS_SoundGetJumpList = 0x2A )
View Source
const ( DMA_MODE_IMM = 0 DMA_MODE_VBL = 1 DMA_MODE_HBL = 2 DMA_MODE_REF = 3 DMA_ADJ_INC = 0 DMA_ADJ_DEC = 1 DMA_ADJ_NON = 2 DMA_ADJ_RES = 3 IRQ_DMA_0 = 8 IRQ_DMA_1 = 9 IRQ_DMA_2 = 10 IRQ_DMA_3 = 11 )
View Source
const ( PC = 15 SCREEN_WIDTH = 240 SCREEN_HEIGHT = 160 NUM_SCANLINES = SCREEN_HEIGHT + 68 CYCLES_HDRAW = 1006 CYCLES_HBLANK = 226 CYCLES_SCANLINE = CYCLES_HDRAW + CYCLES_HBLANK CYCLES_VDRAW = CYCLES_SCANLINE * SCREEN_HEIGHT CYCLES_VBLANK = CYCLES_SCANLINE * 68 CYCLES_FRAME = CYCLES_VDRAW + CYCLES_VBLANK )
View Source
const ( MAX_HEIGHT = 256 MAX_WIDTH = 512 )
View Source
const ( BLD_MODE_OFF = 0 BLD_MODE_STD = 1 BLD_MODE_WHITE = 2 BLD_MODE_BLACK = 3 )
Variables ¶
View Source
var CURR_INST = uint64(0)
Functions ¶
func CheckEeprom ¶
func UpdateAffineParams ¶
Types ¶
type Background ¶
type Background struct {
Enabled bool
Invalid bool
W, H uint32
Pa, Pb, Pc, Pd uint32
Priority uint32
CharBaseBlock uint32
Mosaic bool
Palette256 bool
ScreenBaseBlock uint32
AffineWrap bool
Size uint32
XOffset, YOffset uint32
Affine bool
//PbCalc, PdCalc float64
OutX, OutY float64
// contains filtered or unexported fields
}
func (*Background) BgAffineReset ¶
func (bg *Background) BgAffineReset()
func (*Background) BgAffineUpdate ¶
func (bg *Background) BgAffineUpdate()
type Blend ¶
type Blend struct {
Mode uint32
// contains filtered or unexported fields
}
blends are [6]... because Bg0, Bg1, Bg2, Bg3, Obj, Bd
type BlendPalettes ¶
type BlendPalettes struct {
Bld *Blend
NoBlendPalette, APalette, BPalette uint32
// contains filtered or unexported fields
}
func NewBlendPalette ¶
func NewBlendPalette(i uint32, bld *Blend, gba *GBA) *BlendPalettes
type DMA ¶
type DMA struct {
Gba *GBA
Idx int
Src uint32
Dst uint32
InitSrc uint32
InitDst uint32
Control uint32
WordCount uint32
DstAdj uint32
SrcAdj uint32
Repeat bool
DRQ bool
Mode uint32
IRQ bool
Enabled bool
Value uint32
// contains filtered or unexported fields
}
func (*DMA) ReadControl ¶
func (*DMA) WriteControl ¶
func (*DMA) WriteCount ¶
type GBA ¶
type GBA struct {
Debugger Debugger
Cartridge cart.Cartridge
Cpu *arm7.Cpu
Mem Memory
PPU PPU
Timers [4]Timer
Dma [4]DMA
Irq cpu.Irq
Apu *apu.Apu
Paused, Muted, Save, Drawn bool
OpenBusOpcode uint32
AccCycles uint32
Keypad Keypad
SoundCycles uint32
SoundCyclesMask uint32
Pixels []byte
Image *ebiten.Image
Frame uint64
// contains filtered or unexported fields
}
func (*GBA) InputHandler ¶
func (gba *GBA) InputHandler(keys []ebiten.Key, buttons []ebiten.StandardGamepadButton)
func (*GBA) SetIdleAddr ¶
func (gba *GBA) SetIdleAddr()
func (*GBA) ToggleMute ¶
func (*GBA) TogglePause ¶
func (*GBA) UpdateTimers ¶
type Logger ¶
type Logger struct {
}
func (d *Debugger) print(i int) {
reg := &d.Gba.Cpu.Reg
p := func(a string, b uint32) { fmt.Printf("% 8s: % 9X\n", a, b) }
s := func(a string) { fmt.Printf("%s\n", a) }
s("-------- --------")
fmt.Printf("inst dec %d\n", uint32(i))
p("inst", uint32(i))
if d.Gba.Cpu.Reg.isThumb {
p("opcode", d.Gba.Mem.Read16(reg.R[15]))
} else {
p("opcode", d.Gba.Mem.Read32(reg.R[15]))
}
mode := d.Gba.Cpu.Reg.getMode()
s("-------- --------")
p("r00", reg.R[0])
p("r01", reg.R[1])
p("r02", reg.R[2])
p("r03", reg.R[3])
p("r04", reg.R[4])
p("r05", reg.R[5])
p("r06", reg.R[6])
p("r07", reg.R[7])
p("r08", reg.R[8])
p("r09", reg.R[9])
p("r10", reg.R[10])
p("r11", reg.R[11])
p("r12", reg.R[12])
p("sp/r13", reg.R[13])
p("lr/r14", reg.R[14])
p("pc/r15", reg.R[15])
s("-------- --------")
p("cpsr", uint32(reg.CPSR))
p("spsr", uint32(reg.SPSR[BANK_ID[mode]]))
p("MODE", BANK_ID[mode])
//p("0x3007FFC", d.Gba.Mem.Read32(0x3007FFC))
//p("0x4000004", d.Gba.Mem.Read16(0x4000004))
p("40000B0", d.Gba.Mem.Read32(0x40000B0))
//p("4000208", d.Gba.Mem.Read16(0x4000208))
//p("4000200", d.Gba.Mem.Read16(0x4000200))
//p("4000004", d.Gba.Mem.Read32(0x4000004))
//p("4000000", d.Gba.Mem.Read32(0x4000000))
//p("3000000", d.Gba.Mem.Read32(0x3000000))
//p("3008000", d.Gba.Mem.Read32(0x3008000))
s("-------- --------")
//for i := range len(reg.LR) {
// p(fmt.Sprintf("LR %02d", i), uint32(reg.LR[uint32(i)]))
//}
//s("-------- --------")
////p(fmt.Sprintf("4744 %08X", i), d.Gba.Mem.Read32(0x802E7A4))
//count := 0x20
//start := 0x6003800 + count*4
//for i := start; i >= start-(count*4); i -= 4 {
// p(fmt.Sprintf("IO %X", i), d.Gba.Mem.Read32(uint32(i)))
//}
//s("-------- --------")
//j := uint32(0x4000208)
//p(fmt.Sprintf("IME %04X", j), d.Gba.Mem.Read16(uint32(j)))
//j = uint32(0x4000204)
//p(fmt.Sprintf("WS %04X", j), d.gba.Mem.Read16(uint32(j)))
//j = uint32(0x4000202)
//p(fmt.Sprintf("IF %04X", j), d.gba.Mem.Read16(uint32(j)))
//j = uint32(0x4000200)
//p(fmt.Sprintf("IE %04X", j), d.gba.Mem.Read16(uint32(j)))
//s("\n\n")
//p(fmt.Sprintf("STACK %X", 0x3007E2E), d.gba.Mem.Read32(0x3007E2E))
//for i := 0x0400_00E0; i >= 0x0400_00D0; i -= 4 {
//start := 0x40000E0
//count := 0x10
//for i := start; i >= start - (count * 4); i -= 4 {
// p(fmt.Sprintf("IO %X", i), d.gba.Mem.Read32(uint32(i)))
//}
//s("------")
//start := 0x3007EB0
//start := 0x30014B0
//start := 0xE000080
//count := 0x20
//for i := start; i >= start - (count * 4); i -= 4 {
// p(fmt.Sprintf("IO %X", i), d.Gba.Mem.Read32(uint32(i)))
//}
}
func (d *Debugger) dump(s, e uint32) {
// fix to buffer some day
tmp := ""
for i := s; i <= e; i += 4 {
tmp += fmt.Sprintf("%08X", d.Gba.Mem.Read32(uint32(i)))
}
f, err := os.Create("./dump")
if err != nil {
panic(err)
}
w := bufio.NewWriter(f)
_, err = w.WriteString(tmp)
if err != nil {
panic(err)
}
w.Flush()
}
type Memory ¶
type Memory struct {
GBA *GBA
BIOS [0x4000]uint8
WRAM1 [0x40000]uint8
WRAM2 [0x8000]uint8
PRAM [0x200]uint16
VRAM [0x18001]uint8
OAM [0x400]uint8
IO [0x400]uint8
BIOS_MODE uint32
Dispstat Dispstat
// contains filtered or unexported fields
}
func (*Memory) InitSaveLoop ¶
func (m *Memory) InitSaveLoop()
func (*Memory) Read16 ¶
Accessing SRAM Area by 16bit/32bit Reading retrieves 8bit value from specified address, multiplied by 0101h (LDRH) or by 01010101h (LDR). Writing changes the 8bit value at the specified address only, being set to LSB of (source_data ROR (address*8)).
func (*Memory) ReadIODirectByte ¶
func (*Memory) ReadOpenBus ¶
func (*Memory) ReadSoundIO ¶
type PPU ¶
type PPU struct {
Dispcnt Dispcnt
Objects [128]Object
Backgrounds [4]Background
Windows Windows
Blend Blend
Mosaic Mosaic
// contains filtered or unexported fields
}
func (*PPU) UpdateAffine ¶
func (*PPU) UpdateBackgrounds ¶
type Timer ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.