PHP Class GameBoy\Core

Mostra file Open project: gabrielrcouto/php-terminal-gameboy-emulator Class Usage Examples

Public Properties

Property Type Description
$CPUTicks The number of clock cycles emulated.
$DAATable
$DIVTicks DIV Ticks Counter (Invisible lower 8-bit)
$FCarry bit 4 - Carry
$FHalfCarry bit 5 - Half Carry
$FSubtract bit 6 - Sub
$FZero bit 7 - Zero
$GBCMemory GBC main RAM Banks
$IME Are interrupts enabled?
$JoyPad Joypad State (two four-bit states actually)
$LCDTicks ScanLine Counter
$MBC1Mode MBC1 Type (4/32, 16/8)
$MBCRAMBanksEnabled MBC RAM Access Control.
$MBCRam Switchable RAM (Used by games for more RAM) for the main memory range 0xA000 - 0xC000.
$RAMBanks Used to map the RAM banks to maximum size the MBC used can do.
$ROM The full ROM file dumped to an array.
$ROMBank1offs Offset of the ROM bank switching.
$ROMBanks 1 Bank = 16 KBytes = 256 Kbits
$ROMImage The game's ROM.
$RTCDayOverFlow
$RTCDays
$RTCHALT
$RTCHours
$RTCMinutes
$RTCSeconds
$RTCisLatched
$SecondaryTICKTable
$TACClocker Timer Max Ticks
$TICKTable
$TIMAEnabled
$VRAM Extra VRAM bank for GBC.
$audioTicks Used to sample the audio system every x CPU instructions.
$bgEnabled
$cCamera
$cGBC GameBoy Color detection.
$cHuC1
$cHuC3
$cMBC1 Does the cartridge use MBC1?
$cMBC2 Does the cartridge use MBC2?
$cMBC3 Does the cartridge use MBC3?
$cMBC5 Does the cartridge use MBC5?
$cMMMO1
$cRUMBLE Does the cartridge use the RUMBLE addressing (modified MBC5)?
$cSRAM Does the cartridge use save RAM?
$cTAMA5
$cTIMER Added
$canvasBuffer
$cartridgeType Cartridge Type
$colorCount
$colors "Classic" GameBoy palette colors.
$currMBCRAMBank MBC Currently Indexed RAM Bank
$currMBCRAMBankPosition MBC Position Adder;
$currVRAMBank Current VRAM bank for GBC.
$currentROMBank The parsed current ROM bank selection.
$drawContext LCD Context
$drewBlank To prevent the repeating of drawing a blank screen.
$emulatorTicks Times for how many instructions to execute before ending the loop.
$ffxxDump
$frameBuffer
$frameCount Frame skip tracker
$fromSaveState A boolean to see if this was loaded in as a save state.
$gameCode Game code (Suffix for older games)
$gbColorizedPalette
$gbPalette
$gbcPalette
$gbcRamBank Currently Switched GameBoy Color ram bank
$gbcRamBankPosition GBC RAM offset from address start.
$gbcRamBankPositionECHO GBC RAM (ECHO mirroring) offset from address start.
$gbcRawPalette
$gfxBackgroundX
$gfxBackgroundY
$gfxSpriteDouble
$gfxSpriteShow
$gfxWindowDisplay
$gfxWindowY
$halt Has the CPU been suspended until the next interrupt?
$hdmaRunning HDMA Transfer Flag - GBC only
$height
$inBootstrap Whether we're in the GBC boot ROM.
$lastIteration The last time we iterated the main loop.
$latchedHDays
$latchedHours
$latchedLDays
$latchedMinutes
$latchedSeconds
$lcdController lcdControllerler object
$memory Main Core Memory
$multiplier GBC Speed Multiplier
$name Name of the game
$numRAMBanks How many RAM banks were actually allocated?
$palette Pointer to the current palette we're using (Used for palette switches during boot or so it can be done anytime)
$pixelCount
$programCounter Program Counter
$registerA Accumulator (default is GB mode)
$registerB Register B
$registerC Register C
$registerD Register D
$registerE Register E
$registersHL Registers H and L
$rgbCount
$savedStateFileName When loaded in as a save state, this will not be empty.
$skipPCIncrement Did we trip the DMG Halt bug?
$spritePriorityEnabled
$stackPointer Stack Pointer
$stopEmulator Has the emulation been paused or a frame has ended?
$tileCount GB: 384, GBC: 384 * 2
$tileCountInvalidator
$tileData tile data arrays
$tileReadState true if there are any images to be invalidated
$timerTicks Timer Ticks Count
$transparentCutoff min "attrib" value where transparency can occur (Default is 4 (GB mode))
$untilEnable Are the interrupts on queue to be enabled?
$weaveLookup
$width
$windowSourceLine

Public Methods

Method Description
MBCRAMUtilized ( )
ROMLoad ( )
VRAMReadGFX ( $address, $gbcBank )
__construct ( $ROMImage, $drawContext )
arrayPad ( $length, $defaultValue )
checkPaletteType ( )
clockUpdate ( )
decodePalette ( $startIndex, $data )
disableBootROM ( )
displayShowOff ( )
drawBackgroundForLine ( $line, $windowLeft, $priority )
drawPartBgSprite ( $tileIndex, $x, $y, $sourceLine, $attribs )
drawPartCopy ( $tileIndex, $x, $y, $sourceLine, $attribs )
drawPartFgSprite ( $tileIndex, $x, $y, $sourceLine, $attribs )
drawSpritesForLine ( $line )
drawToCanvas ( )
executeIteration ( )
fromTypedArray ( $baseArray )
getTypedArray ( $length, $defaultValue, $numberType )
initBootstrap ( )
initLCD ( )
initMemory ( )
initSkipBootstrap ( )
invalidateAll ( $pal )
joyPadEvent ( $key, $down )
memoryRead ( $address ) Memory Reading:
memoryWrite ( $address, $data ) Memory Writing:
nswtuw ( $uword )
performHdma ( )
returnFromState ( $returnedFrom )
run ( )
runInterrupt ( )
saveState ( )
setCurrentMBC1ROMBank ( )
setCurrentMBC2AND3ROMBank ( )
setCurrentMBC5ROMBank ( )
setGBCPalette ( $address_, $data )
setGBCPalettePre ( $address_, $data )
setupRAM ( )
start ( )
toTypedArray ( $baseArray, $bit32, $unsigned )
unsbtub ( $ubyte )
unswtuw ( $uword )
updateCore ( )
updateImage ( $tileIndex, $attribs )
usbtsb ( $ubyte ) Helper Functions

Method Details

MBCRAMUtilized() public method

public MBCRAMUtilized ( )

ROMLoad() public method

public ROMLoad ( )

VRAMReadGFX() public method

public VRAMReadGFX ( $address, $gbcBank )

__construct() public method

public __construct ( $ROMImage, $drawContext )

arrayPad() public method

public arrayPad ( $length, $defaultValue )

checkPaletteType() public method

public checkPaletteType ( )

clockUpdate() public method

public clockUpdate ( )

decodePalette() public method

public decodePalette ( $startIndex, $data )

disableBootROM() public method

public disableBootROM ( )

displayShowOff() public method

public displayShowOff ( )

drawBackgroundForLine() public method

public drawBackgroundForLine ( $line, $windowLeft, $priority )

drawPartBgSprite() public method

public drawPartBgSprite ( $tileIndex, $x, $y, $sourceLine, $attribs )

drawPartCopy() public method

public drawPartCopy ( $tileIndex, $x, $y, $sourceLine, $attribs )

drawPartFgSprite() public method

public drawPartFgSprite ( $tileIndex, $x, $y, $sourceLine, $attribs )

drawSpritesForLine() public method

public drawSpritesForLine ( $line )

drawToCanvas() public method

public drawToCanvas ( )

executeIteration() public method

public executeIteration ( )

fromTypedArray() public method

public fromTypedArray ( $baseArray )

getTypedArray() public method

public getTypedArray ( $length, $defaultValue, $numberType )

initBootstrap() public method

public initBootstrap ( )

initLCD() public method

public initLCD ( )

initMemory() public method

public initMemory ( )

initSkipBootstrap() public method

public initSkipBootstrap ( )

invalidateAll() public method

public invalidateAll ( $pal )

joyPadEvent() public method

public joyPadEvent ( $key, $down )

memoryRead() public method

Memory Reading:
public memoryRead ( $address )

memoryWrite() public method

Memory Writing:
public memoryWrite ( $address, $data )

nswtuw() public method

public nswtuw ( $uword )

performHdma() public method

public performHdma ( )

returnFromState() public method

public returnFromState ( $returnedFrom )

run() public method

public run ( )

runInterrupt() public method

public runInterrupt ( )

saveState() public method

public saveState ( )

setCurrentMBC1ROMBank() public method

setCurrentMBC2AND3ROMBank() public method

setCurrentMBC5ROMBank() public method

setGBCPalette() public method

public setGBCPalette ( $address_, $data )

setGBCPalettePre() public method

public setGBCPalettePre ( $address_, $data )

setupRAM() public method

public setupRAM ( )

start() public method

public start ( )

toTypedArray() public method

public toTypedArray ( $baseArray, $bit32, $unsigned )

unsbtub() public method

public unsbtub ( $ubyte )

unswtuw() public method

public unswtuw ( $uword )

updateCore() public method

public updateCore ( )

updateImage() public method

public updateImage ( $tileIndex, $attribs )

usbtsb() public method

Helper Functions
public usbtsb ( $ubyte )

Property Details

$CPUTicks public_oe property

The number of clock cycles emulated.
public $CPUTicks

$DAATable public_oe property

public $DAATable

$DIVTicks public_oe property

DIV Ticks Counter (Invisible lower 8-bit)
public $DIVTicks

$FCarry public_oe property

bit 4 - Carry
public $FCarry

$FHalfCarry public_oe property

bit 5 - Half Carry
public $FHalfCarry

$FSubtract public_oe property

bit 6 - Sub
public $FSubtract

$FZero public_oe property

bit 7 - Zero
public $FZero

$GBCMemory public_oe property

GBC main RAM Banks
public $GBCMemory

$IME public_oe property

Are interrupts enabled?
public $IME

$JoyPad public_oe property

Joypad State (two four-bit states actually)
public $JoyPad

$LCDTicks public_oe property

ScanLine Counter
public $LCDTicks

$MBC1Mode public_oe property

MBC1 Type (4/32, 16/8)
public $MBC1Mode

$MBCRAMBanksEnabled public_oe property

MBC RAM Access Control.
public $MBCRAMBanksEnabled

$MBCRam public_oe property

Switchable RAM (Used by games for more RAM) for the main memory range 0xA000 - 0xC000.
public $MBCRam

$RAMBanks public_oe property

Used to map the RAM banks to maximum size the MBC used can do.
public $RAMBanks

$ROM public_oe property

The full ROM file dumped to an array.
public $ROM

$ROMBank1offs public_oe property

Offset of the ROM bank switching.
public $ROMBank1offs

$ROMBanks public_oe property

1 Bank = 16 KBytes = 256 Kbits
public $ROMBanks

$ROMImage public_oe property

The game's ROM.
public $ROMImage

$RTCDayOverFlow public_oe property

public $RTCDayOverFlow

$RTCDays public_oe property

public $RTCDays

$RTCHALT public_oe property

public $RTCHALT

$RTCHours public_oe property

public $RTCHours

$RTCMinutes public_oe property

public $RTCMinutes

$RTCSeconds public_oe property

public $RTCSeconds

$RTCisLatched public_oe property

public $RTCisLatched

$SecondaryTICKTable public_oe property

public $SecondaryTICKTable

$TACClocker public_oe property

Timer Max Ticks
public $TACClocker

$TICKTable public_oe property

public $TICKTable

$TIMAEnabled public_oe property

public $TIMAEnabled

$VRAM public_oe property

Extra VRAM bank for GBC.
public $VRAM

$audioTicks public_oe property

Used to sample the audio system every x CPU instructions.
public $audioTicks

$bgEnabled public_oe property

public $bgEnabled

$cCamera public_oe property

public $cCamera

$cGBC public_oe property

GameBoy Color detection.
public $cGBC

$cHuC1 public_oe property

public $cHuC1

$cHuC3 public_oe property

public $cHuC3

$cMBC1 public_oe property

Does the cartridge use MBC1?
public $cMBC1

$cMBC2 public_oe property

Does the cartridge use MBC2?
public $cMBC2

$cMBC3 public_oe property

Does the cartridge use MBC3?
public $cMBC3

$cMBC5 public_oe property

Does the cartridge use MBC5?
public $cMBC5

$cMMMO1 public_oe property

public $cMMMO1

$cRUMBLE public_oe property

Does the cartridge use the RUMBLE addressing (modified MBC5)?
public $cRUMBLE

$cSRAM public_oe property

Does the cartridge use save RAM?
public $cSRAM

$cTAMA5 public_oe property

public $cTAMA5

$cTIMER public_oe property

Added
public $cTIMER

$canvasBuffer public_oe property

public $canvasBuffer

$cartridgeType public_oe property

Cartridge Type
public $cartridgeType

$colorCount public_oe property

public $colorCount

$colors public_oe property

"Classic" GameBoy palette colors.
public $colors

$currMBCRAMBank public_oe property

MBC Currently Indexed RAM Bank
public $currMBCRAMBank

$currMBCRAMBankPosition public_oe property

MBC Position Adder;
public $currMBCRAMBankPosition

$currVRAMBank public_oe property

Current VRAM bank for GBC.
public $currVRAMBank

$currentROMBank public_oe property

The parsed current ROM bank selection.
public $currentROMBank

$drawContext public_oe property

LCD Context
public $drawContext

$drewBlank public_oe property

To prevent the repeating of drawing a blank screen.
public $drewBlank

$emulatorTicks public_oe property

Times for how many instructions to execute before ending the loop.
public $emulatorTicks

$ffxxDump public_oe property

public $ffxxDump

$frameBuffer public_oe property

public $frameBuffer

$frameCount public_oe property

Frame skip tracker
public $frameCount

$fromSaveState public_oe property

A boolean to see if this was loaded in as a save state.
public $fromSaveState

$gameCode public_oe property

Game code (Suffix for older games)
public $gameCode

$gbColorizedPalette public_oe property

public $gbColorizedPalette

$gbPalette public_oe property

public $gbPalette

$gbcPalette public_oe property

public $gbcPalette

$gbcRamBank public_oe property

Currently Switched GameBoy Color ram bank
public $gbcRamBank

$gbcRamBankPosition public_oe property

GBC RAM offset from address start.
public $gbcRamBankPosition

$gbcRamBankPositionECHO public_oe property

GBC RAM (ECHO mirroring) offset from address start.
public $gbcRamBankPositionECHO

$gbcRawPalette public_oe property

public $gbcRawPalette

$gfxBackgroundX public_oe property

public $gfxBackgroundX

$gfxBackgroundY public_oe property

public $gfxBackgroundY

$gfxSpriteDouble public_oe property

public $gfxSpriteDouble

$gfxSpriteShow public_oe property

public $gfxSpriteShow

$gfxWindowDisplay public_oe property

public $gfxWindowDisplay

$gfxWindowY public_oe property

public $gfxWindowY

$halt public_oe property

Has the CPU been suspended until the next interrupt?
public $halt

$hdmaRunning public_oe property

HDMA Transfer Flag - GBC only
public $hdmaRunning

$height public_oe property

public $height

$inBootstrap public_oe property

Whether we're in the GBC boot ROM.
public $inBootstrap

$lastIteration public_oe property

The last time we iterated the main loop.
public $lastIteration

$latchedHDays public_oe property

public $latchedHDays

$latchedHours public_oe property

public $latchedHours

$latchedLDays public_oe property

public $latchedLDays

$latchedMinutes public_oe property

public $latchedMinutes

$latchedSeconds public_oe property

public $latchedSeconds

$lcdController public_oe property

lcdControllerler object
public $lcdController

$memory public_oe property

Main Core Memory
public $memory

$multiplier public_oe property

GBC Speed Multiplier
public $multiplier

$name public_oe property

Name of the game
public $name

$numRAMBanks public_oe property

How many RAM banks were actually allocated?
public $numRAMBanks

$palette public_oe property

Pointer to the current palette we're using (Used for palette switches during boot or so it can be done anytime)
public $palette

$pixelCount public_oe property

public $pixelCount

$programCounter public_oe property

Program Counter
public $programCounter

$registerA public_oe property

Accumulator (default is GB mode)
public $registerA

$registerB public_oe property

Register B
public $registerB

$registerC public_oe property

Register C
public $registerC

$registerD public_oe property

Register D
public $registerD

$registerE public_oe property

Register E
public $registerE

$registersHL public_oe property

Registers H and L
public $registersHL

$rgbCount public_oe property

public $rgbCount

$savedStateFileName public_oe property

When loaded in as a save state, this will not be empty.
public $savedStateFileName

$skipPCIncrement public_oe property

Did we trip the DMG Halt bug?
public $skipPCIncrement

$spritePriorityEnabled public_oe property

public $spritePriorityEnabled

$stackPointer public_oe property

Stack Pointer
public $stackPointer

$stopEmulator public_oe property

Has the emulation been paused or a frame has ended?
public $stopEmulator

$tileCount public_oe property

GB: 384, GBC: 384 * 2
public $tileCount

$tileCountInvalidator public_oe property

public $tileCountInvalidator

$tileData public_oe property

tile data arrays
public $tileData

$tileReadState public_oe property

true if there are any images to be invalidated
public $tileReadState

$timerTicks public_oe property

Timer Ticks Count
public $timerTicks

$transparentCutoff public_oe property

min "attrib" value where transparency can occur (Default is 4 (GB mode))
public $transparentCutoff

$untilEnable public_oe property

Are the interrupts on queue to be enabled?
public $untilEnable

$weaveLookup public_oe property

public $weaveLookup

$width public_oe property

public $width

$windowSourceLine public_oe property

public $windowSourceLine