global _start extern exit extern glfwGetKey extern glfwSwapBuffers extern glfwPollEvents extern glfwGetTime extern glfwSetKeyCallback extern glfwSetFramebufferSizeCallback extern glfwSetWindowCloseCallback extern glfwMakeContextCurrent extern glfwCreateWindow extern glfwGetPrimaryMonitor extern glfwGetVideoMode extern glfwInit extern glfwSetErrorCallback extern glfwSetWindowTitle extern glfwSetTime extern glViewport extern glMatrixMode extern glLoadIdentity extern glOrtho extern glLineStipple extern glEnable extern glClearColor extern glGetError extern glFlush extern glRectd extern glColor3d extern glEnd extern glVertex2d extern glClear extern glBegin extern strcat extern snprintf extern lround extern strcpy extern sincos extern round extern sin extern cos section .text handleError: push ebp mov ebp, esp sub esp, 20 push 1 call exit handleWindowClose: push ebp mov ebp, esp sub esp, 20 push 0 call exit handleKey: push ebp mov ebp, esp push ebx push eax mov edx, DWORD [ebp+20] mov ecx, DWORD [ebp+12] mov ebx, DWORD [ebp+8] cmp edx, 1 sete al cmp ecx, 256 jne L6 test al, al je L6 sub esp, 12 push 0 call exit L6: cmp BYTE [app+10], 0 je L7 cmp ecx, 65 jne L8 test al, al jne L30 test edx, edx jne L5 push eax push eax push 90 push ebx call glfwGetKey add esp, 16 dec eax jne L14 movsd xmm0, QWORD [player1+40] movsd QWORD [player1+32], xmm0 jmp L5 L8: cmp ecx, 90 jne L7 test al, al je L12 movsd xmm1, QWORD [player1+40] movsd QWORD [player1+32], xmm1 jmp L5 L12: test edx, edx jne L5 push ecx push ecx push 65 push ebx call glfwGetKey add esp, 16 dec eax jne L14 L30: fld QWORD [player1+40] fchs fstp QWORD [player1+32] jmp L5 L14: fldz fstp QWORD [player1+32] jmp L5 L7: cmp ecx, 39 jne L15 test al, al jne L31 test edx, edx jne L5 push edx push edx push 47 push ebx call glfwGetKey add esp, 16 dec eax jne L22 movsd xmm2, QWORD [player2+40] movsd QWORD [player2+32], xmm2 jmp L5 L15: cmp ecx, 47 jne L5 test al, al je L21 movsd xmm3, QWORD [player2+40] movsd QWORD [player2+32], xmm3 jmp L5 L21: test edx, edx jne L5 push eax push eax push 39 push ebx call glfwGetKey add esp, 16 dec eax jne L22 L31: fld QWORD [player2+40] fchs fstp QWORD [player2+32] jmp L5 L22: fldz fstp QWORD [player2+32] L5: mov ebx, DWORD [ebp-4] leave ret handleFramebufferSize: push ebp mov ebp, esp sub esp, 8 mov edx, DWORD [ebp+16] mov eax, DWORD [ebp+12] push edx push eax push 0 push 0 mov DWORD [app], eax mov DWORD [app+4], edx call glViewport mov DWORD [esp], 5889 call glMatrixMode call glLoadIdentity push eax push eax fld1 fst QWORD [esp] push -1074790400 push 0 sub esp, 32 fldz fst QWORD [esp+24] fxch st1 fst QWORD [esp+16] fstp QWORD [esp+8] fstp QWORD [esp] call glOrtho add esp, 64 leave ret fps: push ebp mov ebp, esp sub esp, 8 call glfwGetTime fst QWORD [time.15415] fld QWORD [time_old.15416] fsubr st0, st1 fld1 fdivrp st1, st0 fst QWORD [ret_val.15417] fxch st1 fstp QWORD [time_old.15416] leave ret reset: push ebp mov ebp, esp sub esp, 16 fld QWORD [LC4] fst QWORD [ball] fstp QWORD [ball+8] push 0 fld QWORD [LC7] fst QWORD [player1+8] push 0 fstp QWORD [player2+8] mov DWORD [ball+40], 1202590843 mov DWORD [ball+44], 1065646817 mov DWORD [ball+32], -1717986918 mov DWORD [ball+36], 1069128089 call glfwSetTime add esp, 16 leave ret calcLineY: push ebp mov ebp, esp mov eax, DWORD [ebp+8] fld QWORD [eax+8] fadd QWORD [eax+32] fldz fucomi st0, st1 ja L42 fstp st0 fld QWORD [eax+24] fld st1 fadd st0, st1 fld1 fxch st1 fucomip st0, st1 jbe L45 fstp st2 fxch st1 fsubrp st1, st0 jmp L40 L42: fstp st1 jmp L40 L45: fstp st0 fstp st0 L40: fstp QWORD [eax+8] pop ebp ret flipY: push ebp mov ebp, esp fld QWORD [ebp+8] fchs pop ebp ret flipX: push ebp fld QWORD [LC8] mov ebp, esp fsub QWORD [ebp+8] pop ebp ret calcBall: push ebp mov ebp, esp push ebx sub esp, 36 mov ebx, DWORD [ebp+8] lea edx, [ebp-24] lea eax, [ebp-16] fld QWORD [ebx+32] push edx push eax push eax push eax fst QWORD [esp] fstp QWORD [ebp-32] call sincos add esp, 16 fld QWORD [ebp-16] fld QWORD [ebx+40] fld QWORD [ebp-24] fmul st0, st1 fadd QWORD [ebx] fld QWORD [ebx+8] fldz fucomi st0, st2 fld QWORD [ebp-32] jbe L64 fstp st0 fstp st0 fstp st0 fstp st0 fstp st0 fstp st0 inc DWORD [player1+48] jmp L70 L64: fld1 fld QWORD [ebx+16] fsubr st0, st1 fxch st5 fucomi st0, st5 fstp st5 jbe L65 fstp st0 fstp st0 fstp st0 fstp st0 fstp st0 fstp st0 fstp st0 inc DWORD [player2+48] L70: mov ebx, DWORD [ebp-4] leave jmp reset L65: fxch st6 fmul st0, st5 faddp st3, st0 fxch st3 fstp QWORD [ebx] fucomip st0, st1 ja L71 fxch st3 fsub QWORD [ebx+24] fxch st3 fucomi st0, st3 fstp st3 jbe L67 fstp st2 fxch st1 jmp L69 L71: fstp st0 fstp st2 fxch st1 L69: fchs fstp QWORD [ebx+32] jmp L57 L67: fstp st0 fxch st1 fstp QWORD [ebx+8] L57: fadd QWORD [ebx+48] fstp QWORD [ebx+40] mov ebx, DWORD [ebp-4] leave ret intersects: push ebp mov ebp, esp mov eax, DWORD [ebp+12] mov edx, DWORD [ebp+8] fld QWORD [eax] fld QWORD [edx] fld QWORD [edx+16] fadd st0, st1 fucomip st0, st2 jbe L87 fxch st1 fadd QWORD [eax+16] fucomip st0, st1 fstp st0 jbe L85 fld QWORD [eax+8] fld QWORD [edx+8] fld QWORD [edx+24] fadd st0, st1 fucomip st0, st2 jbe L88 fxch st1 fadd QWORD [eax+24] fucomip st0, st1 fstp st0 seta al jmp L73 L87: fstp st0 fstp st0 jmp L85 L88: fstp st0 fstp st0 L85: xor eax, eax L73: pop ebp ret getRelDistFromCenter: push ebp mov ebp, esp mov edx, DWORD [ebp+8] mov eax, DWORD [ebp+12] pop ebp fld QWORD [edx+24] fld DWORD [LC9] fld st1 fmul st0, st1 fadd QWORD [edx+8] fxch st1 fmul QWORD [eax+24] fadd QWORD [eax+8] fsubp st1, st0 fdivrp st1, st0 ret calc: push ebp mov ebp, esp sub esp, 8 cmp BYTE [app+10], 0 jne L92 fld QWORD [ball+8] fld QWORD [player1+8] fucomi st0, st1 jbe L110 fstp st0 fstp st0 fld QWORD [player1+40] fchs fdiv QWORD [LC10] jmp L113 L110: fxch st1 fadd QWORD [ball+24] fxch st1 fadd QWORD [player1+24] fxch st1 fucomip st0, st1 fstp st0 jbe L111 fld QWORD [LC10] fdivr QWORD [player1+40] L113: fstp QWORD [player1+32] jmp L92 L111: fldz fstp QWORD [player1+32] L92: push eax push dword player1 call calcLineY mov DWORD [esp], dword player2 call calcLineY pop eax pop edx call glfwGetTime fld1 fxch st1 fucomip st0, st1 fstp st0 jbe L97 sub esp, 12 push dword ball call calcBall add esp, 16 L97: push eax push eax push dword ball push dword player1 call intersects add esp, 16 test al, al je L99 push eax push eax push dword ball push dword player1 call getRelDistFromCenter add esp, 16 fmul DWORD [LC11] fstp QWORD [ball+32] L99: push ecx push ecx push dword ball push dword player2 call intersects add esp, 16 test al, al je L91 push edx push edx push dword ball push dword player2 call getRelDistFromCenter add esp, 16 fadd st0, st0 fadd QWORD [LC8] fstp QWORD [ball+32] L91: leave ret draw: push ebp mov ebp, esp sub esp, 52 push 16384 call glClear sub esp, 16 fld QWORD [LC12] fst QWORD [esp+16] fld QWORD [LC13] fst QWORD [esp+8] fstp QWORD [ebp-40] fstp QWORD [esp] call glColor3d add esp, 20 push 1 call glBegin sub esp, 16 fldz fst QWORD [esp+8] fstp QWORD [ebp-32] fld DWORD [LC9] fst QWORD [esp] fstp QWORD [ebp-24] call glVertex2d add esp, 16 fld1 fst QWORD [esp+8] fstp QWORD [ebp-16] fld QWORD [ebp-24] fstp QWORD [esp] call glVertex2d call glEnd sub esp, 16 fld QWORD [ebp-40] fst QWORD [esp+16] fst QWORD [esp+8] fstp QWORD [esp] call glColor3d add esp, 16 fld QWORD [player1+8] fadd QWORD [player1+24] fstp QWORD [esp+8] fld QWORD [player1] fadd QWORD [player1+16] fstp QWORD [esp] push DWORD [player1+12] push DWORD [player1+8] push DWORD [player1+4] push DWORD [player1] call glRectd add esp, 16 fld QWORD [player2+8] fadd QWORD [player2+24] fstp QWORD [esp+8] fld QWORD [player2] fadd QWORD [player2+16] fstp QWORD [esp] push DWORD [player2+12] push DWORD [player2+8] push DWORD [player2+4] push DWORD [player2] call glRectd fld QWORD [ebp-32] fst QWORD [esp+16] fld QWORD [ebp-16] fstp QWORD [esp+8] fstp QWORD [esp] call glColor3d add esp, 16 fld QWORD [ball+8] fadd QWORD [ball+24] fstp QWORD [esp+8] fld QWORD [ball] fadd QWORD [ball+16] fstp QWORD [esp] push DWORD [ball+12] push DWORD [ball+8] push DWORD [ball+4] push DWORD [ball] call glRectd add esp, 32 call glFlush leave jmp glGetError setTitle: push ebp mov ebp, esp push esi push ebx sub esp, 136 push dword LC14 lea ebx, [ebp-108] push ebx call strcpy pop esi pop eax lea esi, [ebp-124] push dword LC15 push ebx call strcat pop eax pop edx push dword LC16 push ebx call strcat call fps fstp QWORD [esp] call lround push eax push dword LC17 push 6 push esi call snprintf add esp, 24 push esi push ebx call strcat pop ecx pop esi lea esi, [ebp-118] push dword LC18 push ebx call strcat pop eax push DWORD [player2+48] push DWORD [player1+48] push dword LC19 push 10 push esi call snprintf add esp, 24 push esi push ebx call strcat pop eax pop edx push ebx push DWORD [ebp+8] call glfwSetWindowTitle add esp, 16 lea esp, [ebp-8] pop ebx pop esi pop ebp ret _start: lea ecx, [esp+4] and esp, -16 push DWORD [ecx-4] push ebp mov ebp, esp push ebx push ecx sub esp, 12 push dword handleError call glfwSetErrorCallback call glfwInit add esp, 16 test eax, eax jne L119 sub esp, 12 push 1 call exit L119: cmp BYTE [app+8], 0 je L120 sub esp, 12 push 0 push 0 jmp L124 L120: call glfwGetPrimaryMonitor sub esp, 12 push eax call glfwGetVideoMode mov edx, DWORD [eax] mov eax, DWORD [eax+4] mov DWORD [app], edx mov DWORD [app+4], eax call glfwGetPrimaryMonitor mov DWORD [esp], 0 push eax L124: push dword LC14 push DWORD [app+4] push DWORD [app] call glfwCreateWindow add esp, 32 sub esp, 12 push eax mov ebx, eax call glfwMakeContextCurrent add esp, 12 push DWORD [app+4] push DWORD [app] push ebx call handleFramebufferSize pop ecx pop eax push dword handleWindowClose push ebx call glfwSetWindowCloseCallback pop eax pop edx push dword handleFramebufferSize push ebx call glfwSetFramebufferSizeCallback pop ecx pop eax push dword handleKey push ebx call glfwSetKeyCallback push 0x00000000 push 0x3dcccccd push 0x3dcccccd push 0x3dcccccd call glClearColor add esp, 20 push 2852 call glEnable pop eax pop edx push 65280 push 1 call glLineStipple call reset L125: add esp, 16 sub esp, 12 push ebx call setTitle call glfwPollEvents call calc call draw mov DWORD [esp], ebx call glfwSwapBuffers jmp L125 common ret_val.15417 8:8 common time_old.15416 8:8 common time.15415 8:8 section .bss ball: resd 3092376453 resd 1071613214 resd 3092376453 resd 1071613214 resd 3951369912 resd 1066317905 resd 3951369912 resd 1066317905 resd 2576980378 resd 1069128089 resd 1202590843 resd 1065646817 resd 2296604913 resd 1055193269 player2: resd 2405181686 resd 1072494018 resd 3435973837 resd 1071434956 resd 1202590843 resd 1065646817 resd 2576980378 resd 1069128089 resd 0 resd 0 resd 3951369912 resd 1066317905 resd 0 player1: resd 2233382994 resd 1069044203 resd 3435973837 resd 1071434956 resd 1202590843 resd 1065646817 resd 2576980378 resd 1069128089 resd 0 resd 0 resd 3951369912 resd 1066317905 resd 0 app: resd 800 resd 600 resb 1 resb 1 resb 0 resb 1 section .data align 8 LC4: dd 3092376453 dd 1071613214 align 8 LC7: dd 3435973837 dd 1071434956 align 8 LC8: dd 1413754136 dd 1074340347 align 4 LC9: dd 1056964608 align 8 LC10: dd 2576980378 dd 1072798105 align 4 LC11: dd 3221225472 align 8 LC12: dd 2576980378 dd 1070176665 align 8 LC13: dd 3435973837 dd 1072483532 LC14: db "" LC15: db "Pong clone " LC16: db "FPS: " LC17: db "%d " LC18: db "Score: " LC19: db "%d:%d "