Documentation ¶
Index ¶
- Variables
- func ASetAddressRegister(m *Memory, opcode uint16)
- func BJumpToV0(m *Memory, opcode uint16)
- func CSetToRandomNumber(m *Memory, opcode uint16)
- func DWrapsOnScreen(m *Memory, opcode uint16)
- func EDispatcher(m *Memory, opcode uint16)
- func ESkipIfKeyNotPress(m *Memory, opcode uint16)
- func ESkipIfKeyPress(m *Memory, opcode uint16)
- func EightDispatcher(m *Memory, opcode uint16)
- func EightFiveSub(m *Memory, opcode uint16)
- func EightFourAdd(m *Memory, opcode uint16)
- func EightFourteenLeftShift(m *Memory, opcode uint16)
- func EightOneORSet(m *Memory, opcode uint16)
- func EightSevenMinus(m *Memory, opcode uint16)
- func EightSixRightShift(m *Memory, opcode uint16)
- func EightThreeXORSet(m *Memory, opcode uint16)
- func EightTwoANDSet(m *Memory, opcode uint16)
- func EightZeroSet(m *Memory, opcode uint16)
- func FAddVXToI(m *Memory, opcode uint16)
- func FBCD(m *Memory, opcode uint16)
- func FDispatcher(m *Memory, opcode uint16)
- func FGoToSprite(m *Memory, opcode uint16)
- func FReadMemory(m *Memory, opcode uint16)
- func FSetDelayTimerToVX(m *Memory, opcode uint16)
- func FSetSoundTimerToVX(m *Memory, opcode uint16)
- func FSetVXtoDelayTimer(m *Memory, opcode uint16)
- func FWaitKeyPress(m *Memory, opcode uint16)
- func FWriteMemory(m *Memory, opcode uint16)
- func FiveEqSkip(m *Memory, opcode uint16)
- func FourNeqSkip(m *Memory, opcode uint16)
- func NineNeqSkip(m *Memory, opcode uint16)
- func OneJumpTo(m *Memory, opcode uint16)
- func SevenAddToRegister(m *Memory, opcode uint16)
- func SixSetRegister(m *Memory, opcode uint16)
- func ThreeEqSkip(m *Memory, opcode uint16)
- func TwoCallSubRoutine(m *Memory, opcode uint16)
- func WaitForInput(m *Memory) byte
- func ZeroClearScreen(m *Memory, opcode uint16)
- func ZeroDispatcher(m *Memory, opcode uint16)
- func ZeroReturnFromSubRoutine(m *Memory, opcode uint16)
- type Memory
Constants ¶
This section is empty.
Variables ¶
var CheckInputs = func(m *Memory) (bool, byte) { for i := range m.Key { m.Key[i] = false } ev := termbox.PollEvent() if ev.Type == termbox.EventKey { str := string(ev.Ch) if str >= "A" { str = strings.ToLower(str) } switch str { case "3": m.Key[0] = true return true, 0 case "4": m.Key[1] = true return true, 1 case "5": m.Key[2] = true return true, 2 case "6": m.Key[3] = true return true, 3 case "e": m.Key[4] = true return true, 4 case "r": m.Key[5] = true return true, 5 case "t": m.Key[6] = true return true, 6 case "y": m.Key[7] = true return true, 7 case "d": m.Key[8] = true return true, 8 case "f": m.Key[9] = true return true, 9 case "g": m.Key[10] = true return true, 10 case "h": m.Key[11] = true return true, 11 case "c": m.Key[12] = true return true, 12 case "v": m.Key[13] = true return true, 13 case "b": m.Key[14] = true return true, 14 case "n": m.Key[15] = true return true, 15 } } return false, 0 }
CheckInputs verify if there is a key pressed and then set the Key array accordingly
Functions ¶
func ASetAddressRegister ¶
ASetAddressRegister is the ANNN opcode which set the Address register I to NNN
func CSetToRandomNumber ¶
CSetToRandomNumber is the CXNN opcode which set VX to a random number and NN
func DWrapsOnScreen ¶
DWrapsOnScreen is the DXYN opcode which draw sprites
func EDispatcher ¶
EDispatcher is the E??? opcodes dispatcher
func ESkipIfKeyNotPress ¶
ESkipIfKeyNotPress is the EXA1 opcode which skip the next instruction if the key stored in VX is not pressed
func ESkipIfKeyPress ¶
ESkipIfKeyPress is the EX9E opcode which skip the next instruction if the key stored in VX is pressed
func EightDispatcher ¶
EightDispatcher is the dispatcher for 8XY? opcodes
func EightFiveSub ¶
EightFiveSub is the 8XY5 opcode which set VX to VX-VY
func EightFourAdd ¶
EightFourAdd is the 8XY4 opcode which Adds VY to VX. VF is set to 1 when there's a carry, and to 0 when there isn't
func EightFourteenLeftShift ¶
EightFourteenLeftShift is the 8XYE opcode which shifts VX left by one
func EightOneORSet ¶
EightOneORSet is the 8XY1 opcode which sets VX to VX OR VY
func EightSevenMinus ¶
EightSevenMinus is the 8XY7 opcode which set VX to VY-VX
func EightSixRightShift ¶
EightSixRightShift is the 8XY6 opcode which shifts VX right by one
func EightThreeXORSet ¶
EightThreeXORSet is the 8XY3 opcode which sets VX to VX XOR VY
func EightTwoANDSet ¶
EightTwoANDSet is the 8XY2 opcode which sets VX to VX AND VY
func EightZeroSet ¶
EightZeroSet is the 8XY0 opcode which sets VX to the value of VY
func FBCD ¶
FBCD is the FX33 opcode which stores the Binary-coded decimal representation of VX, with the most significant of three digits at the address in I, the middle digit at I plus 1, and the least significant digit at I plus 2.
func FDispatcher ¶
FDispatcher is the dispatcher for FNNN opcodes
func FGoToSprite ¶
FGoToSprite is the FX29 opcode which sets I to the location of the sprite for the character in VX
func FReadMemory ¶
FReadMemory is the FX65 opcode which fills V0 to VX with values from memory starting at address I
func FSetDelayTimerToVX ¶
FSetDelayTimerToVX is the FX15 opcode which sets the delay timer to VX
func FSetSoundTimerToVX ¶
FSetSoundTimerToVX is the FX18 opcode which sets the sound timer to VX
func FSetVXtoDelayTimer ¶
FSetVXtoDelayTimer is the FX07 opcode which sets VX to the value of the delay timer
func FWaitKeyPress ¶
FWaitKeyPress is the FX0A opcode which wait a key press and then stores it in VX
func FWriteMemory ¶
FWriteMemory is the FX55 opcode which stores V0 to VX in memory starting at address I
func FiveEqSkip ¶
FiveEqSkip is the 5XY0 opcode which skips the next instruction if VX equals VY.
func FourNeqSkip ¶
FourNeqSkip is the 4XNN opcode which skips the next instruction if VX not equals NN
func NineNeqSkip ¶
NineNeqSkip is the 9XY0 opcode which skips the next instruction if VX doesn't equal VY
func SevenAddToRegister ¶
SevenAddToRegister is the 7XNN opcode which add NN to VX
func SixSetRegister ¶
SixSetRegister is the 6XNN opcode which set VX to NN
func ThreeEqSkip ¶
ThreeEqSkip is the 3XNN opcode which skip the next instruction if VX equals NN
func TwoCallSubRoutine ¶
TwoCallSubRoutine is the 2NNN opcode which call the subroutine at the NNN address
func WaitForInput ¶
WaitForInput wait for an input and then returns it
func ZeroClearScreen ¶
ZeroClearScreen is 00E0 opcode which clear the screen
func ZeroDispatcher ¶
ZeroDispatcher is the 0??? opcodes dispatcher
func ZeroReturnFromSubRoutine ¶
ZeroReturnFromSubRoutine is the 00EE opcode which return from a subroutine
Types ¶
type Memory ¶
type Memory struct { I uint16 PC uint16 SP uint16 DelayTimer byte SoundTimer byte Key [16]bool Screen [][]bool V [16]byte CallStack [256]uint16 Memory [4096]byte }
Memory represents the internal memory of the CHIP-8 emulator
func (*Memory) Init ¶
func (m *Memory) Init()
Init must be called when right after you create a Memory variable it initialize the screen array and set some values
func (*Memory) PrintMemoryValues ¶
func (m *Memory) PrintMemoryValues()
PrintMemoryValues print chip8 state value