GameBoy\Core::unswtuw PHP Method

unswtuw() public method

public unswtuw ( $uword )
    public function unswtuw($uword)
    {
        //Keep an unsigned word unsigned:
        if ($uword < 0) {
            $uword += 0x10000;
        }
        return $uword;
        //If this function is called, no wrapping requested.
    }

Usage Example

 /**
  * Opcode #0xFF.
  *
  * RST 0x38
  *
  * @param Core $core
  */
 public static function opcode255(Core $core)
 {
     $core->stackPointer = $core->unswtuw($core->stackPointer - 1);
     $core->memoryWrite($core->stackPointer, $core->programCounter >> 8);
     $core->stackPointer = $core->unswtuw($core->stackPointer - 1);
     $core->memoryWrite($core->stackPointer, $core->programCounter & 0xff);
     $core->programCounter = 0x38;
 }