uint16_t CPUState::getIndexY() { if (areFlagsSet(MEMORY_SELECT)) { //if the flag is set, the indexY uses the lower 8 bit return (m_IndexY & 0x00FF); } else { //if the flag is not set, the indexY uses 16 bit return m_IndexY; } }
uint16_t CPUState::getIndexX() { if (areFlagsSet(INDEX_SELECT)) { //if the flag is set, the indexX uses the lower 8 bit return (m_IndexX & 0x00FF); } else { //if the flag is not set, the indexX uses 16 bit return m_IndexX; } }
uint16_t CPUState::getAccumulator() { if (areFlagsSet(MEMORY_SELECT)) { //if the flag is set, the accumulator uses the lower 8 bit return (m_Accumulator & 0x00FF); } else { //if the flag is not set, the accumulator uses 16 bit return m_Accumulator; } }
void CPUState::setIndexY(uint16_t newValue, bool ignoreRegisterSize) { if (ignoreRegisterSize) { m_IndexY = newValue; } else { if (areFlagsSet(INDEX_SELECT)) { //set only the lower byte of m_Accumulator m_IndexY = (m_IndexY & 0xFF00) + (newValue & 0x00FF); } else { m_IndexY = newValue; } } }
void CPUState::setAccumulator(uint16_t newValue, bool ignoreRegisterSize) { if (ignoreRegisterSize) { m_Accumulator = newValue; } else { if (areFlagsSet(MEMORY_SELECT)) { //set only the lower byte of m_Accumulator m_Accumulator = (m_Accumulator & 0xFF00) + (newValue & 0x00FF); } else { m_Accumulator = newValue; } } }
/**jsdoc * <p>A KeyboardModifiers value is used to specify which modifier keys on the keyboard are pressed. The value is the sum * (bitwise OR) of the relevant combination of values from the following table:</p> * <table> * <thead> * <tr><th>Key</th><th>Hexadecimal value</th><th>Decimal value</th><th>Description</th></tr> * </thead> * <tbody> * <tr><td>Shift</td><td><code>0x02000000</code></td><td><code>33554432</code></td> * <td>A Shift key on the keyboard is pressed.</td></tr> * <tr><td>Control</td><td><code>0x04000000</code></td><td><code>67108864</code></td> * <td>A Control key on the keyboard is pressed.</td></tr> * <tr><td>Alt</td><td><code>0x08000000</code></td><td><code>134217728</code></td> * <td>An Alt key on the keyboard is pressed.</td></tr> * <tr><td>Meta</td><td><code>0x10000000</code></td><td><code>268435456</code></td> * <td>A Meta or Windows key on the keyboard is pressed.</td></tr> * <tr><td>Keypad</td><td><code>0x20000000</code></td><td><code>536870912</code></td> * <td>A keypad button is pressed.</td></tr> * <tr><td>Group</td><td><code>0x40000000</code></td><td><code>1073741824</code></td> * <td>X11 operating system only: An AltGr / Mode_switch key on the keyboard is pressed.</td></tr> * </tbody> * </table> * @typedef {number} KeyboardModifiers */ QScriptValue PointerEvent::toScriptValue(QScriptEngine* engine, const PointerEvent& event) { QScriptValue obj = engine->newObject(); switch (event._type) { case Press: obj.setProperty("type", "Press"); break; case DoublePress: obj.setProperty("type", "DoublePress"); break; case Release: obj.setProperty("type", "Release"); break; default: case Move: obj.setProperty("type", "Move"); break; }; obj.setProperty("id", event._id); QScriptValue pos2D = engine->newObject(); pos2D.setProperty("x", event._pos2D.x); pos2D.setProperty("y", event._pos2D.y); obj.setProperty("pos2D", pos2D); QScriptValue pos3D = engine->newObject(); pos3D.setProperty("x", event._pos3D.x); pos3D.setProperty("y", event._pos3D.y); pos3D.setProperty("z", event._pos3D.z); obj.setProperty("pos3D", pos3D); QScriptValue normal = engine->newObject(); normal.setProperty("x", event._normal.x); normal.setProperty("y", event._normal.y); normal.setProperty("z", event._normal.z); obj.setProperty("normal", normal); QScriptValue direction = engine->newObject(); direction.setProperty("x", event._direction.x); direction.setProperty("y", event._direction.y); direction.setProperty("z", event._direction.z); obj.setProperty("direction", direction); bool isPrimaryButton = false; bool isSecondaryButton = false; bool isTertiaryButton = false; switch (event._button) { case NoButtons: obj.setProperty("button", "None"); break; case PrimaryButton: obj.setProperty("button", "Primary"); isPrimaryButton = true; break; case SecondaryButton: obj.setProperty("button", "Secondary"); isSecondaryButton = true; break; case TertiaryButton: obj.setProperty("button", "Tertiary"); isTertiaryButton = true; break; } if (isPrimaryButton) { obj.setProperty("isPrimaryButton", isPrimaryButton); obj.setProperty("isLeftButton", isPrimaryButton); } if (isSecondaryButton) { obj.setProperty("isSecondaryButton", isSecondaryButton); obj.setProperty("isRightButton", isSecondaryButton); } if (isTertiaryButton) { obj.setProperty("isTertiaryButton", isTertiaryButton); obj.setProperty("isMiddleButton", isTertiaryButton); } obj.setProperty("isPrimaryHeld", areFlagsSet(event._buttons, PrimaryButton)); obj.setProperty("isSecondaryHeld", areFlagsSet(event._buttons, SecondaryButton)); obj.setProperty("isTertiaryHeld", areFlagsSet(event._buttons, TertiaryButton)); obj.setProperty("keyboardModifiers", QScriptValue(event.getKeyboardModifiers())); return obj; }