Си диез / Говнокод #28377 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
  66. 66
  67. 67
  68. 68
  69. 69
  70. 70
  71. 71
  72. 72
  73. 73
  74. 74
  75. 75
  76. 76
  77. 77
  78. 78
  79. 79
  80. 80
  81. 81
  82. 82
  83. 83
  84. 84
  85. 85
  86. 86
  87. 87
  88. 88
  89. 89
private delegate void XFXOPDO(byte cmd);

	private delegate void FXCBOPDO(byte cmd, ushort adr);

	private delegate void ALUALGORITHM(byte src);

	public delegate byte MEMREADER(ushort ADDR);

	public ulong Tact;

	public Registers regs = new Registers();

	public bool HALTED;

	public bool IFF1;

	public bool IFF2;

	public byte IM;

	public bool BlockINT;

	public OPFX FX;

	public OPXFX XFX;

	public bool INT;

	public bool NMI;

	public bool RST;

	public byte FreeBUS = byte.MaxValue;

	public OnRDMEM ReadMemory;

	public OnWRMEM WriteMemory;

	public OnRDPORT ReadPort;

	public OnWRPORT WritePort;

	public OnCALLBACK OnCycle;

	private XFXOPDO[] opTABLE;

	private XFXOPDO[] fxopTABLE;

	private XFXOPDO[] edopTABLE;

	private XFXOPDO[] cbopTABLE;

	private FXCBOPDO[] fxcbopTABLE;

	private static byte[] conds = new byte[4] { 64, 1, 4, 128 };

	private static ALUALGORITHM[] alualg;

	private ALUALGORITHM[] alulogic;

	private static readonly string[] DirectZ80Code = new string[256]
	{
		"NOP", "LD     BC,$W", "LD     (BC),A", "INC    BC", "INC    B", "DEC    B", "LD     B,$N", "RLCA", "EX     AF,AF'", "ADD    HL,BC",
		"LD     A,(BC)", "DEC    BC", "INC    C", "DEC    C", "LD     C,$N", "RRCA", "DJNZ   $DIS", "LD     DE,$W", "LD     (DE),A", "INC    DE",
		"INC    D", "DEC    D", "LD     D,$N", "RLA", "JR     $DIS", "ADD    HL,DE", "LD     A,(DE)", "DEC    DE", "INC    E", "DEC    E",
		"LD     E,$N", "RRA", "JR     NZ,$DIS", "LD     HL,$W", "LD     ($W),HL", "INC    HL", "INC    H", "DEC    H", "LD     H,$N", "DAA",
		"JR     Z,$DIS", "ADD    HL,HL", "LD     HL,($W)", "DEC    HL", "INC    L", "DEC    L", "LD     L,$N", "CPL", "JR     NC,$DIS", "LD     SP,$W",
		"LD     ($W),A", "INC    SP", "INC    (HL)", "DEC    (HL)", "LD     (HL),$N", "SCF", "JR     C,$DIS", "ADD    HL,SP", "LD     A,($W)", "DEC    SP",
		"INC    A", "DEC    A", "LD     A,$N", "CCF", "LD     B,B", "LD     B,C", "LD     B,D", "LD     B,E", "LD     B,H", "LD     B,L",
		"LD     B,(HL)", "LD     B,A", "LD     C,B", "LD     C,C", "LD     C,D", "LD     C,E", "LD     C,H", "LD     C,L", "LD     C,(HL)", "LD     C,A",
		"LD     D,B", "LD     D,C", "LD     D,D", "LD     D,E", "LD     D,H", "LD     D,L", "LD     D,(HL)", "LD     D,A", "LD     E,B", "LD     E,C",
		"LD     E,D", "LD     E,E", "LD     E,H", "LD     E,L", "LD     E,(HL)", "LD     E,A", "LD     H,B", "LD     H,C", "LD     H,D", "LD     H,E",
		"LD     H,H", "LD     H,L", "LD     H,(HL)", "LD     H,A", "LD     L,B", "LD     L,C", "LD     L,D", "LD     L,E", "LD     L,H", "LD     L,L",
		"LD     L,(HL)", "LD     L,A", "LD     (HL),B", "LD     (HL),C", "LD     (HL),D", "LD     (HL),E", "LD     (HL),H", "LD     (HL),L", "HALT", "LD     (HL),A",
		"LD     A,B", "LD     A,C", "LD     A,D", "LD     A,E", "LD     A,H", "LD     A,L", "LD     A,(HL)", "LD     A,A", "ADD    A,B", "ADD    A,C",
		"ADD    A,D", "ADD    A,E", "ADD    A,H", "ADD    A,L", "ADD    A,(HL)", "ADD    A,A", "ADC    A,B", "ADC    A,C", "ADC    A,D", "ADC    A,E",
		"ADC    A,H", "ADC    A,L", "ADC    A,(HL)", "ADC    A,A", "SUB    B", "SUB    C", "SUB    D", "SUB    E", "SUB    H", "SUB    L",
		"SUB    (HL)", "SUB    A", "SBC    A,B", "SBC    A,C", "SBC    A,D", "SBC    A,E", "SBC    A,H", "SBC    A,L", "SBC    A,(HL)", "SBC    A,A",
		"AND    B", "AND    C", "AND    D", "AND    E", "AND    H", "AND    L", "AND    (HL)", "AND    A", "XOR    B", "XOR    C",
		"XOR    D", "XOR    E", "XOR    H", "XOR    L", "XOR    (HL)", "XOR    A", "OR     B", "OR     C", "OR     D", "OR     E",
		"OR     H", "OR     L", "OR     (HL)", "OR     A", "CP     B", "CP     C", "CP     D", "CP     E", "CP     H", "CP     L",
		"CP     (HL)", "CP     A", "RET    NZ", "POP    BC", "JP     NZ,$W", "JP     $W", "CALL   NZ,$W", "PUSH   BC", "ADD    A,$N", "RST    $T",
		"RET    Z", "RET", "JP     Z,$W", "*CB", "CALL   Z,$W", "CALL   $W", "ADC    A,$N", "RST    $T", "RET    NC", "POP    DE",
		"JP     NC,$W", "OUT    ($N),A", "CALL   NC,$W", "PUSH   DE", "SUB    $N", "RST    $T", "RET    C", "EXX", "JP     C,$W", "IN     A,($N)",
		"CALL   C,$W", "*IX", "SBC    A,$N", "RST    $T", "RET    PO", "POP    HL", "JP     PO,$W", "EX     (SP),HL", "CALL   PO,$W", "PUSH   HL",
		"AND    $N", "RST    $T", "RET    PE", "JP     (HL)", "JP     PE,$W", "EX     DE,HL", "CALL   PE,$W", "*ED", "XOR    $N", "RST    $T",
		"RET    P", "POP    AF", "JP     P,$W", "DI", "CALL   P,$W", "PUSH   AF", "OR     $N", "RST    $T", "RET    M", "LD     SP,HL",
		"JP     M,$W", "EI", "CALL   M,$W", "*IY", "CP     $N", "RST    $T"
	};

Вот так раньше писали эмуляторы ZX Spectrum

DartPower DartPower, (Updated )

Комментарии (8, +8)

Си диез / Говнокод #28327 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
  53. 53
  54. 54
  55. 55
  56. 56
  57. 57
  58. 58
  59. 59
  60. 60
  61. 61
  62. 62
  63. 63
  64. 64
  65. 65
public static void Mein()
	{
		Govno8_Main.random_0 = new Random();
		Govno8_Main.doubleBufferForm_0 = new Govno8.DoubleBufferForm();
		Govno8_Main.byte_0 = ArrayModule.Create<byte>(4096, 0);
		Govno8_Main.ushort_0 = 512;
		Govno8_Main.string_0 = string.Empty;
		Govno8_Main.openFileDialog_0 = new OpenFileDialog();
		Govno8.OpenBinDialog.Title = "Open Chip-8 ROM File";
		Govno8.OpenBinDialog.Filter = "Chip-8 ROM Files|*.ch8|All files|*.*";
		switch (Govno8.OpenBinDialog.ShowDialog())
		{
			case DialogResult.OK:
				{
					byte[] array = File.ReadAllBytes(Govno8.OpenBinDialog.FileName);
					if (array.Length != 0 && array.Length <= 3583)
					{
						Govno8.RomName = Govno8.OpenBinDialog.FileName;
						array.CopyTo(Govno8.Memory, (int)Govno8.PC);
					}
					else
					{
						MessageBox.Show("Invalid ROM file", "FATAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Hand);
						Environment.Exit(1);
					}
					break;
				}
			default:
				Environment.Exit(1);
				break;
		}
		Govno8_Main.byte_1 = new byte[]
		{
				240, 144, 144, 144, 240, 32, 96, 32, 32, 112,
				240, 16, 240, 128, 240, 240, 16, 240, 16, 240,
				144, 144, 240, 16, 16, 240, 128, 240, 16, 240,
				240, 128, 240, 144, 240, 240, 16, 32, 64, 64,
				240, 144, 240, 144, 240, 240, 144, 240, 16, 240,
				240, 144, 240, 144, 144, 224, 144, 224, 144, 224,
				240, 128, 128, 128, 240, 224, 144, 144, 144, 224,
				240, 128, 240, 128, 240, 240, 128, 240, 128, 128
		};
		Govno8.Fontset.CopyTo(Govno8.Memory, 0);
		Govno8_Main.ushort_1 = 0;
		Govno8_Main.byte_2 = ArrayModule.Create<byte>(16, 0);
		Govno8_Main.ushort_2 = 0;
		Govno8_Main.ushort_3 = ArrayModule.Create<ushort>(16, 0);
		Govno8_Main.ushort_4 = 0;
		Govno8_Main.byte_3 = ArrayModule.Create<byte>(16, 0);
		Govno8_Main.byte_4 = ArrayModule.Create<byte>(2048, 0);
		Govno8_Main.byte_5 = 0;
		Govno8_Main.byte_6 = 0;
		Govno8_Main.dateTime_0 = DateTime.Now;
		Govno8_Main.dateTime_1 = DateTime.Now;
		Govno8_Main.fsharpAsync_0 = ExtraTopLevelOperators.DefaultAsyncBuilder.Delay<Unit>(Govno8.Class6.class6_0);
		Govno8.Form.ClientSize = new Size(1024, 512);
		CommonExtensions.AddToObservable<EventArgs>(Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.CreateEvent<EventHandler, EventArgs>(Govno8.Class7.class7_0, Govno8.Class8.class8_0, Govno8.Class10.class10_0), Govno8.Class11.class11_0);
		CommonExtensions.AddToObservable<PaintEventArgs>(Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.CreateEvent<PaintEventHandler, PaintEventArgs>(Govno8.Class12.class12_0, Govno8.Class13.class13_0, Govno8.Class15.class15_0), Govno8.Class16.class16_0);
		CommonExtensions.AddToObservable<KeyEventArgs>(Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.CreateEvent<KeyEventHandler, KeyEventArgs>(Govno8.Class17.class17_0, Govno8.Class18.class18_0, Govno8.Class20.class20_0), Govno8.Class21.class21_0);
		CommonExtensions.AddToObservable<KeyEventArgs>(Microsoft.FSharp.Core.CompilerServices.RuntimeHelpers.CreateEvent<KeyEventHandler, KeyEventArgs>(Govno8.Class22.class22_0, Govno8.Class23.class23_0, Govno8.Class25.class25_0), Govno8.Class26.class26_0);
		Govno8.Form.Text = string.Format("{0} - Chip-F Emulator", Govno8.RomName);
		Govno8.Form.MaximizeBox = false;
		Govno8.Form.FormBorderStyle = FormBorderStyle.FixedSingle;
		Application.Run(Govno8.Form);
	}

Три раза переваренный кал...
Скомпилен F# код, затем декомпиленный в C# и подправленный чутка)))
А, ну и ещё деобфускатором прошелся прикола ради, перед декомпиляцией.

P.S. Кстати капча ниже содержала 666... Как иронично...

DartPower DartPower, (Updated )

Комментарии (2, +2)

Си диез / Говнокод #28316 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
public class WeaponHold : MonoBehaviour
{
    public bool equip;
    public float distance = 0.3f;
    public RaycastHit2D hit;
    public Transform holdPoint; //Здесь задаются координаты дочернего объекта у игрока
    public float put = 1f;
 
    public void Update()
    {
        if (Input.GetKeyDown(KeyCode.F))
        {
            if (!equip)
            {
                Physics2D.queriesStartInColliders = false;
                hit = Physics2D.Raycast(transform.position, Vector2.right * transform.localScale.x, distance);
 
                if (hit.collider != null && hit.collider.tag == "Gun")
                {
                    equip = true;
                    Debug.Log("Оружие видно");
                }
            }
        }
        else
        {
            equip = false;
 
            if (hit.collider.gameObject.GetComponent<Rigidbody2D>() != null)
            {
                hit.collider.gameObject.GetComponent<Rigidbody2D>().velocity = new Vector2(transform.localScale.x, 1) * put;
            } 
        }
        if (equip)
        {
            Debug.Log("Оружие перемещено");
            hit.collider.gameObject.transform.position = holdPoint.position;  //Здесь мы поднимаем дробовик, перемещая его к дочернему объекту
        }
    }
 
    private void OnDrawGizmos()
    {
        Gizmos.color = Color.red; //Прорисовка RayCast
        Gizmos.DrawLine(transform.position, transform.position + Vector3.right * transform.localScale.x * distance);
    }
}

Подбирание и выкидывание оружия

govnotochkar govnotochkar, (Updated )

Комментарии (9, +9)

Си диез / Говнокод #28175 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
  34. 34
  35. 35
  36. 36
  37. 37
  38. 38
  39. 39
  40. 40
  41. 41
  42. 42
  43. 43
  44. 44
  45. 45
  46. 46
  47. 47
  48. 48
  49. 49
  50. 50
  51. 51
  52. 52
using System;
using System.Linq;
using System.Text;
using AAAAA = System.Single;
using AAAAAA = System.Boolean;
using AAAAAAA = System.Int32;
using AAAAAAAA = System.Char;
using AAAAAAAAA = System.Byte;
using AAAAAAAAAA = System.String;
public interface IA<AAAA> where AAAA : AA<AAAA>, new()
{
    AA<AAAA> A();
}
public class AAA : AA<AAA>
{
    public AAA() { }
    public AAA(IA<AAA> AAAA) : base(AAAA) { }
}
public class AA<AAAAAAAAAAAAAAAAAAAA> : IA<AAAAAAAAAAAAAAAAAAAA> where AAAAAAAAAAAAAAAAAAAA : AA<AAAAAAAAAAAAAAAAAAAA>, new()
{
    const AAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAA = 0;
    const AAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = "AAAA";
    const AAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA = "UTF-8";
    public AA() { }
    AA<AAAAAAAAAAAAAAAAAAAA> IA<AAAAAAAAAAAAAAAAAAAA>.A() {
        return (AA<AAAAAAAAAAAAAAAAAAAA>)A((AAAAAA)new AA<AAAAAAAAAAAAAAAAAAAA>(this));
    }
    public AA(IA<AAAAAAAAAAAAAAAAAAAA> AAAA) {
        var AAAAAAAAAAAAAAAAAAAAAAAA = (AA<AAAAAAAAAAAAAAAAAAAA>)AAAA;
        AAAAAAAAAAAAAAAAAAAAAAAA.E();
    }
    public AA<AAAAAAAAAAAAAAAAAAAA> A(AAAAAA A) {
        if (true) return this;
    }
    public static AAA AAAA(string AAAAAAAAAA) {
        var AAAAAAAAAAAAAAA = AAAAAAAAAA.ToArray<AAAAAAAA>();
        return A(Encoding.GetEncoding(AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA).GetBytes(AAAAAAAAAAAAAAA));
    }
    private static AAA A(AAAAAAAAA[] AAA) {
        return A(BitConverter.ToSingle(AAA, AAAAAAAAAAAAAAAAAAAAAAAAAAAA));
    }
    private static AAA A(AAAAA A) {
        if (A == 12.078431f)
            return new AAA(new AA<AAA>());
        else
            throw new FUCKYOUException();
    }
    public static implicit operator AAAAAA(AA<AAAAAAAAAAAAAAAAAAAA> a) => true;
    private void E() => Console.WriteLine("E");
}

class FUCKYOUException : Exception { }

kcalbCube kcalbCube, (Updated )

Комментарии (10, +10)

Си диез / Говнокод #27965 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
  23. 23
  24. 24
  25. 25
  26. 26
  27. 27
  28. 28
  29. 29
  30. 30
  31. 31
  32. 32
  33. 33
using System;
					
public class Program
{
	public static void Main()
	{
		69.Doeb();
		typeof(Ext).Doeb();
	}
}

public static class Ext
{
	public static void Doeb(this object o)
	{
		string s;
		Type type = o.GetType();
		s = type.ToString();
		while(type != null)
		{
			type = type.BaseType;
			try
			{
				s += $" > {type.ToString()}";
			}
			catch
			{
				break;
			}
		}
		Console.WriteLine(s);
	}
}

Ты с какого района? Чьих будешь?

SystemGCCollect SystemGCCollect, (Updated )

Комментарии (6, +6)

Си диез / Говнокод #27920 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. 14
  15. 15
  16. 16
  17. 17
  18. 18
  19. 19
  20. 20
  21. 21
  22. 22
using KoKo.Property;

namespace MyProject {

    public class Person {

        private StoredProperty<string> FirstName { get; }
        private StoredProperty<string> LastName { get; }
        public Property<string> FullName { get; }

        public Person(string firstName, string lastName) {
            FirstName = new StoredProperty<string>(firstName);
            LastName = new StoredProperty<string>(lastName);
            FullName = DerivedProperty<string>.Create(FirstName, LastName, (first, last) => $"{first} {last}");
        }

        public void SetFirstName(string firstName) {
            FirstName.Value = firstName;
        }

    }
}

3_dar 3_dar, (Updated )

Комментарии (80, +80)

Си диез / Говнокод #27773 Ссылка на оригинал

0

  1. 1
  2. 2
  3. 3
  4. 4
  5. 5
  6. 6
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
private List<OutputData> AddSomeSpecialStateToFoo(
            List<OutputData> foos,
            IDictionary<Guid, SomeSpecialState> fooStates)
        {
            foreach(var foo in foos)
            {
                foo .State = fooStates.FirstOrDefault(x => x.Key == cam.FooId).Value;
            }

            return foos;
        }

Митируем листы и юзаем словарь правильно.

LozorcevDiyosha LozorcevDiyosha, (Updated )

Комментарии (9, +9)