void Chip8CPU::Reset() { // Get the current time to use as seed for RNG and as // init for DT and ST decrement. const auto now = Chip8Helper::GetNowDuration(); InitializeRegisters(); lastStepTime_ = now; ResetTimerDecrement(); assert(InitializeDefaultSprites()); // Seed the CPU random number generator with current time. rnd_ = std::mt19937(static_cast<unsigned int>(now.count())); display_.Reset(CHIP8_DISPLAY_WIDTH, CHIP8_DISPLAY_HEIGHT); isInHiresMode_ = false; if (beeper_ != nullptr) { // Make sure the beeper isn't already beeping. beeper_->SetBeeping(false); } isWaitingForInput_ = false; lastOp_ = 0; }
b2Contact* b2Contact::Create(b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator) { if (s_initialized == false) { InitializeRegisters(); s_initialized = true; } b2Shape::Type type1 = fixtureA->GetType(); b2Shape::Type type2 = fixtureB->GetType(); b2Assert(0 <= type1 && type1 < b2Shape::e_typeCount); b2Assert(0 <= type2 && type2 < b2Shape::e_typeCount); b2ContactCreateFcn* createFcn = s_registers[type1][type2].createFcn; if (createFcn) { if (s_registers[type1][type2].primary) { return createFcn(fixtureA, indexA, fixtureB, indexB, allocator); } else { return createFcn(fixtureB, indexB, fixtureA, indexA, allocator); } } else { return NULL; } }