ASICRegisters

struct ASICRegisters

This struct holds 0x804 bytes of data.  They are the special registers accessed in the 0x4000000 address class.  This is only useful to give a name to those bytes.  Its sizeof might be greater, but it doesn’t really matters.  This might create problems with endianess.  It is supposed to work only with little endian processors

See Also

Memory DMAChannels OAMSprites Timers CPU Palettes PPU

Summary
ASICRegistersThis struct holds 0x804 bytes of data.
Variables
MemoryMasksMemory masks for all the address space “zones”.
MemoryRepresents the entire address space of the GBA.
Variables
biosThe bios memory.
ewramThe external working ram.
iwramThe internal working ram.
ioramIORegisters memory.
pramThe Palette Ram.
vramVideoRAM.
oamSprites Memory.
gba_romCartridge emulated ROM.
gba_rom_sizeThe size of the ROM.
cart_ramCartridge RAM.
mem_ptrsPointers to memory areas where the index is the most significant byte of an address.
timer0ReloadTimer reload value.
timer1ReloadTimer reload value.
timer2ReloadTimer reload value.
timer3ReloadTimer reload value.
dummyValueDummy value to readdress null writes.
lastAccessZoneID of the last memory zone that has been accessed.
cartridgeStoNAccessCartridge ROM has sequential and non-sequential accesses.
ppuAccessingMemoryTrue when the ppu is accessing memory.
ioMemAccessedTurned on if the previous operation accessed IOMemory.
haltModeOnTurned on if the GBA is in halt-mode (waiting for interrupt).
prevVcountThe previous VCount register is stored here.
usedWaitCntWhich wait-control has been used?
drawFlagUsed by the rendering engine thread to signal it is rendering, so the cpu shall not get into VBLANK.
shallBreakSwitch used to generate breakpoints from the video-output window.
Functions
MemoryBuilds memory.
GetAddressReturns the in-system address associated to the emulated address.
GetIORamGets IORam converted to the <ASICRegister> structure.
CheckIOAccessDoes all the operations needed after an IO access.
Read8Reads 8 bit at the given emulated address.
Read16Reads 16 bit at the given emulated address.
Read32Reads 32 bit at the given emulated address.
Write8Writes 8 bit at the given emulated address.
Write16Writes 16 bit at the given emulated address.
Write32Writes 32 bit at the given emulated address.
getWSCount
ComputeWaitStatesComputes the wait states of the last memory access.
SetAccessAddrSets last access zone according to the address.
ComputeWaitStatesABComputes the WaitStates given an address.
GetSizeComputes the size of the emulated memory.

Variables

MemoryMasks

extern uint32_t MemoryMasks[16]

Memory masks for all the address space “zones”.  The zone n is 0x0n000000-0x0nFFFFFF.

Memory

struct Memory

Represents the entire address space of the GBA.

See Also

CPU PPU ASICRegisters OAMSprites Palettes DMAChannels GBA Timers Tile4 Tile8

Summary
Variables
biosThe bios memory.
ewramThe external working ram.
iwramThe internal working ram.
ioramIORegisters memory.
pramThe Palette Ram.
vramVideoRAM.
oamSprites Memory.
gba_romCartridge emulated ROM.
gba_rom_sizeThe size of the ROM.
cart_ramCartridge RAM.
mem_ptrsPointers to memory areas where the index is the most significant byte of an address.
timer0ReloadTimer reload value.
timer1ReloadTimer reload value.
timer2ReloadTimer reload value.
timer3ReloadTimer reload value.
dummyValueDummy value to readdress null writes.
lastAccessZoneID of the last memory zone that has been accessed.
cartridgeStoNAccessCartridge ROM has sequential and non-sequential accesses.
ppuAccessingMemoryTrue when the ppu is accessing memory.
ioMemAccessedTurned on if the previous operation accessed IOMemory.
haltModeOnTurned on if the GBA is in halt-mode (waiting for interrupt).
prevVcountThe previous VCount register is stored here.
usedWaitCntWhich wait-control has been used?
drawFlagUsed by the rendering engine thread to signal it is rendering, so the cpu shall not get into VBLANK.
shallBreakSwitch used to generate breakpoints from the video-output window.
Functions
MemoryBuilds memory.
GetAddressReturns the in-system address associated to the emulated address.
GetIORamGets IORam converted to the <ASICRegister> structure.
CheckIOAccessDoes all the operations needed after an IO access.
Read8Reads 8 bit at the given emulated address.
Read16Reads 16 bit at the given emulated address.
Read32Reads 32 bit at the given emulated address.
Write8Writes 8 bit at the given emulated address.
Write16Writes 16 bit at the given emulated address.
Write32Writes 32 bit at the given emulated address.
getWSCount
ComputeWaitStatesComputes the wait states of the last memory access.
SetAccessAddrSets last access zone according to the address.
ComputeWaitStatesABComputes the WaitStates given an address.
GetSizeComputes the size of the emulated memory.

Variables

bios

int8_t bios [0x4000 ]

The bios memory.  From 0x0 to 0x1fffffff.  Executable, not readable.  16kb size.

ewram

int8_t ewram[0x40000]

The external working ram.  From 0x2000000 to 0x2ffffff are mirrors every 256kb.  16 bit accesses.

iwram

int8_t iwram[0x8000 ]

The internal working ram.  From 0x3000000 to 0x3ffffff are mirrors every 32kb . 32 bit accesses.

ioram

int8_t ioram[0x808 ]

IORegisters memory.  From 0x4000000 to 0x4ffffff are mirrors in strange ways.  (0x04000804 is mirrored everywhere).

See Also

ASICRegisters

pram

int8_t pram [0x400 ]

The Palette Ram.  From 0x50.. to 0x5f... mirrors every 1kb.  Contains palettes.  (first half for backgrounds, second for sprites)

See Also

Palettes Palette

vram

int8_t vram [0x20000]

VideoRAM.  From 0x60.. to 0x6f... mirrored every 0x20000 from 0x6018000 to 0x6020000 there are mirrors of 0x6010000.

See Also

PPU

oam

int8_t oam [0x400 ]

Sprites Memory.  From 0x70.. to 0x7f... mirrored every 1kb.  Object Attribute Memory.  Contains sprites info (eg, transforms).

See Also

OAMSprite OAMSprites OAMTransformGroup

gba_rom

int8_t* gba_rom

Cartridge emulated ROM.  From 0x8000000 to 0x9fff...  Size isn’t fixed.  The cartridge loader thinks at it.  Mirrored in 0x0A000000..0x0BFFFFFF and 0x0C000000..0x0DFFFFFF.  Accesses there have different waitstates though.

gba_rom_size

uint32_t gba_rom_size

The size of the ROM.

cart_ram

int8_t cart_ram[0x10000]

Cartridge RAM.  From 0xE00.. to 0xE0010000.  Cart ram may be sram or fram.  Its size varies between 0-64kb

mem_ptrs

int8_t* mem_ptrs[16]

Pointers to memory areas where the index is the most significant byte of an address.

timer0Reload

uint16_t timer0Reload

Timer reload value.  When the timer count value is written, the write is readdressed here.

timer1Reload

uint16_t timer1Reload

Timer reload value.  When the timer count value is written, the write is readdressed here.

timer2Reload

uint16_t timer2Reload

Timer reload value.  When the timer count value is written, the write is readdressed here.

timer3Reload

uint16_t timer3Reload

Timer reload value.  When the timer count value is written, the write is readdressed here.

dummyValue

uint16_t dummyValue

Dummy value to readdress null writes.

lastAccessZone

int lastAccessZone

ID of the last memory zone that has been accessed.

cartridgeStoNAccess

bool cartridgeStoNAccess

Cartridge ROM has sequential and non-sequential accesses.  Sometimes sequential accesses become non-sequential for weird reasons.  Those times, this becomes true.

ppuAccessingMemory

bool ppuAccessingMemory

True when the ppu is accessing memory.  When this happens, the cpu has more waitstates while accessing vram.

ioMemAccessed

bool ioMemAccessed

Turned on if the previous operation accessed IOMemory.

haltModeOn

bool haltModeOn

Turned on if the GBA is in halt-mode (waiting for interrupt).

prevVcount

uint32_t prevVcount

The previous VCount register is stored here.

usedWaitCnt

uint32_t usedWaitCnt

Which wait-control has been used?

drawFlag

bool drawFlag

Used by the rendering engine thread to signal it is rendering, so the cpu shall not get into VBLANK.

shallBreak

bool shallBreak

Switch used to generate breakpoints from the video-output window.

Functions

Memory

Memory()

Builds memory.  Sets default values.

GetAddress

inline void* GetAddress(uint32_t addr)

Returns the in-system address associated to the emulated address.

Parameters

addrThe emulated address.

Returns

The address that represents the emulated address.

GetIORam

inline ASICRegisters* GetIORam()

Gets IORam converted to the <ASICRegister> structure.  (It actually is a reinterpret_cast).

Returns

The IORam.

CheckIOAccess

inline void CheckIOAccess()

Does all the operations needed after an IO access.

Read8

inline uint8_t Read8(uint32_t addr)

Reads 8 bit at the given emulated address.

Parameters

addrThe emulated address.

Returns

The read value.

Read16

inline uint16_t Read16(uint32_t addr)

Reads 16 bit at the given emulated address.

Parameters

addrThe emulated address.

Returns

The read value.

Read32

inline uint32_t Read32(uint32_t addr)

Reads 32 bit at the given emulated address.

Parameters

addrThe emulated address.

Returns

The read value.

Write8

inline void Write8(uint32_t addr,
uint8_t v)

Writes 8 bit at the given emulated address.

Parameters

addrThe emulated address.
vThe value that will be written.

Write16

inline void Write16(uint32_t addr,
uint16_t v)

Writes 16 bit at the given emulated address.

Parameters

addrThe emulated address.
vThe value that will be written.

Write32

inline void Write32(uint32_t addr,
uint32_t v)

Writes 32 bit at the given emulated address.

Parameters

addrThe emulated address.
vThe value that will be written.

getWSCount

inline int getWSCount(int id)

Parameters

idThe waitstates id.

Returns

The Waitstates Count.

ComputeWaitStates

inline int ComputeWaitStates(int cyclesS,  
int cyclesN,  
int accessWidth = 2)

Computes the wait states of the last memory access.

Parameters

cyclesSNumber of sequential cycles
cyclesNNumber of non-sequential cycles
accessWidthThe width of the access (0=8bit, 1=16bit, 2=32bit)

Returns

The number of wait cycles.

SetAccessAddr

inline void SetAccessAddr(uint32_t addr)

Sets last access zone according to the address.

Parameters

addrThe address.

ComputeWaitStatesAB

inline int ComputeWaitStatesAB(uint32_t addr,  
int cyclesS,  
int cyclesN,  
int accessWidth = 2)

Computes the WaitStates given an address.

Parameters

addrThe address.
cyclesSNumber of sequential cycles
cyclesNNumber of non-sequential cycles
accessWidthThe width of the access (0=8bit, 1=16bit, 2=32bit)

Returns

The number of wait cycles.

GetSize

uint32_t GetSize()

Computes the size of the emulated memory.

Returns

The size of the emulated memory.

struct ASICRegisters
This struct holds 0x804 bytes of data.
extern uint32_t MemoryMasks[16]
Memory masks for all the address space “zones”.
struct Memory
Represents the entire address space of the GBA.
int8_t bios [0x4000 ]
The bios memory.
int8_t ewram[0x40000]
The external working ram.
int8_t iwram[0x8000 ]
The internal working ram.
int8_t ioram[0x808 ]
IORegisters memory.
int8_t pram [0x400 ]
The Palette Ram.
int8_t vram [0x20000]
VideoRAM.
int8_t oam [0x400 ]
Sprites Memory.
int8_t* gba_rom
Cartridge emulated ROM.
uint32_t gba_rom_size
The size of the ROM.
int8_t cart_ram[0x10000]
Cartridge RAM.
int8_t* mem_ptrs[16]
Pointers to memory areas where the index is the most significant byte of an address.
uint16_t timer0Reload
Timer reload value.
uint16_t timer1Reload
Timer reload value.
uint16_t timer2Reload
Timer reload value.
uint16_t timer3Reload
Timer reload value.
uint16_t dummyValue
Dummy value to readdress null writes.
int lastAccessZone
ID of the last memory zone that has been accessed.
bool cartridgeStoNAccess
Cartridge ROM has sequential and non-sequential accesses.
bool ppuAccessingMemory
True when the ppu is accessing memory.
bool ioMemAccessed
Turned on if the previous operation accessed IOMemory.
bool haltModeOn
Turned on if the GBA is in halt-mode (waiting for interrupt).
uint32_t prevVcount
The previous VCount register is stored here.
uint32_t usedWaitCnt
Which wait-control has been used?
bool drawFlag
Used by the rendering engine thread to signal it is rendering, so the cpu shall not get into VBLANK.
bool shallBreak
Switch used to generate breakpoints from the video-output window.
Memory()
Builds memory.
inline void* GetAddress(uint32_t addr)
Returns the in-system address associated to the emulated address.
inline ASICRegisters* GetIORam()
Gets IORam converted to the ASICRegister structure.
inline void CheckIOAccess()
Does all the operations needed after an IO access.
inline uint8_t Read8(uint32_t addr)
Reads 8 bit at the given emulated address.
inline uint16_t Read16(uint32_t addr)
Reads 16 bit at the given emulated address.
inline uint32_t Read32(uint32_t addr)
Reads 32 bit at the given emulated address.
inline void Write8(uint32_t addr,
uint8_t v)
Writes 8 bit at the given emulated address.
inline void Write16(uint32_t addr,
uint16_t v)
Writes 16 bit at the given emulated address.
inline void Write32(uint32_t addr,
uint32_t v)
Writes 32 bit at the given emulated address.
inline int getWSCount(int id)
inline int ComputeWaitStates(int cyclesS,  
int cyclesN,  
int accessWidth = 2)
Computes the wait states of the last memory access.
inline void SetAccessAddr(uint32_t addr)
Sets last access zone according to the address.
inline int ComputeWaitStatesAB(uint32_t addr,  
int cyclesS,  
int cyclesN,  
int accessWidth = 2)
Computes the WaitStates given an address.
uint32_t GetSize()
Computes the size of the emulated memory.
class DMAChannels
DMA stands for Direct Memory Access.
class OAMSprites
Builds and handles all OAMSprites and OAMTransformGroups contained in OAM memory.
class Timers
Easy interface to do operations with timers and their registers.
class CPU
This class represents an ARM7TDMI CPU running at 16.78MHZ with 32 bit registers and two execution modes (ARM32bit, THUMB16bit).
class Palettes
Represents the full set of palettes.
class PPU
This class represents the Picture Processing Unit of the GBA Functions in here are mostly inline utilities to make code inside renderers understandable.
class GBA
This is the class representing the entire device.
struct Tile4
32 bytes Tile, 4 bit depth.
struct Tile8
64 bytes Tile, 8 bit depth.
struct Palette
Represent a palette entry (the name “Palette” is not proper here).
struct OAMSprite
Represents a Sprite in OAM memory.
struct OAMTransformGroup
OAM (Object Attribute Memory) contains both sprite attributes and transformation groups.
Close