private void processCommand(NetCommands cmd, byte[] data) { switch (cmd) { case NetCommands.Image: int currentX = 0; int currentY = 0; for (int i = 0; i < data.Length; i++) { C64.vic.Screen[currentX, currentY] = C64.palette.MapColorValue((byte)(data[i] >> 4)); currentX++; if (currentX == 403) { currentX = 0; currentY++; } C64.vic.Screen[currentX, currentY] = C64.palette.MapColorValue((byte)(data[i] & 0xF)); currentX++; if (currentX == 403) { currentX = 0; currentY++; } } screenReceived(this, null); socket.SendToAll(new byte[] { (byte)NetCommands.ImageReady, 0, 0, 0, 0 }); break; case NetCommands.ImageReady: imageReady = true; break; case NetCommands.KeyEvent: KeyboardEventArgs kd = new KeyboardEventArgs( (Key)data[0], (ModifierKeys)(data[1] != 0 ? Key.LeftShift : 0), data[2] == 1 ); keyEventReceived(null, kd); break; case NetCommands.JoyEvent: JoyEventArgs jd = new JoyEventArgs( data[0], (JoystickFunction)data[1], data[2] == 1 ); joyEventReceived(null, jd); break; } }
private void network_joyEventReceived(object sender, JoyEventArgs j) { C64.cia1.JoyEvent(j.JoystickNumber, j.Function, j.Pressed); }