+ All Categories
Home > Documents > Td Win32asm 070.Asm

Td Win32asm 070.Asm

Date post: 13-Apr-2018
Category:
Upload: z4rm4r
View: 234 times
Download: 1 times
Share this document with a friend

of 13

Transcript
  • 7/21/2019 Td Win32asm 070.Asm

    1/13

    td_win32asm_070.asm;==============================================================================; Test Departments WINDOWS 32 BIT x86 ASSEMBLY examples 070;==============================================================================

    ;==============================================================================; ==> how to work with joysticks, (update !!!);------------------------------------------------------------------------------

    ; High, waiting for your man ?;; Here I am,; a lot of people don't know how to work with joysticks.; Because it could be quite simple, I think the main problem is that windows; doesn't provide y/x client or screen coordinates ...; If you only need a hint if a joystick is moved up/down/left or right this; source is for you.;;

    ; Thank you.;;; TD [email protected];;; This is an update because the joycaps structure was wrong (size=404 Bytes).

    ;==============================================================================; Assembler directives;------------------------------------------------------------------------------

    .386 ; specifies the processor our program want run on

    .Model Flat ,StdCall ; always the same for Win95 (32 Bit)option casemap:none ; case sensitive !!!

    ;==============================================================================; Include all files where API functins resist you want use, set correct path;------------------------------------------------------------------------------includelib kernel32.libincludelib user32.libincludelib gdi32.lib

    includelib winmm.lib;==============================================================================; Declaration of used API functions,take a look into WIN32.HLP and *.inc files;------------------------------------------------------------------------------GetModuleHandleA PROTO :DWORDLoadIconA PROTO :DWORD,:DWORDLoadCursorA PROTO :DWORD,:DWORDLoadImageA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORDRegisterClassExA PROTO :DWORDCreateSolidBrush PROTO :DWORD

    CreateWindowExA PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD, :DWORD,:DWORD,:DWORD,:DWORD,:DWORDShowWindow PROTO :DWORD,:DWORDUpdateWindow PROTO :DWORD

    Page 1

  • 7/21/2019 Td Win32asm 070.Asm

    2/13

    td_win32asm_070.asmInvalidateRect PROTO :DWORD,:DWORD,:DWORDMoveWindow PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

    GetMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORDTranslateMessage PROTO :DWORDDispatchMessageA PROTO :DWORDPostQuitMessage PROTO :DWORD

    DefWindowProcA PROTO :DWORD,:DWORD,:DWORD,:DWORDExitProcess PROTO :DWORD

    MessageBoxA PROTO :DWORD,:DWORD,:DWORD,:DWORDSendMessageA PROTO :DWORD,:DWORD,:DWORD,:DWORD

    LoadBitmapA PROTO :DWORD,:DWORDDeleteObject PROTO :DWORD

    CreateRectRgn PROTO :DWORD,:DWORD,:DWORD,:DWORDCombineRgn PROTO :DWORD,:DWORD,:DWORD,:DWORDSetWindowRgn PROTO :DWORD,:DWORD,:DWORD

    timeGetDevCaps PROTO :DWORD,:DWORDtimeSetEvent PROTO :DWORD,:DWORD,:DWORD,:DWORD,:DWORDtimeKillEvent PROTO :DWORD

    joyGetNumDevs PROTOjoyGetDevCapsA PROTO :DWORD,:DWORD,:DWORDjoyGetPos PROTO :DWORD,:DWORD

    joyGetPosEx PROTO :DWORD,:DWORDjoyReleaseCapture PROTO :DWORDjoySetCapture PROTO :DWORD,:DWORD,:DWORD,:DWORDjoySetThreshold PROTO :DWORD,:DWORD

    ;==============================================================================.const ;defined and fixed;------------------------------------------------------------------------------; - Parameter MAIN WINDOW CallBack Procedure ( API=RegisterClassExA ) -WP1_CallBack equ [ebp+4] ;return address

    WP1_hWnd equ [ebp+8] ;handle of window who receives messageWP1_uMsg equ [ebp+12] ;the message numberWP1_wParam equ [ebp+16] ;extra info about the messageWP1_lParam equ [ebp+20] ;extra info about the message

    ;==============================================================================.Data ;defined but not fixed;------------------------------------------------------------------------------CN db "TD_joystick",0WN db "Joystick example - Done by Test Department",0URL_TD db "http://www.crahkob.com/td",0

    StaticClassName db "STATIC",0 ;predefined classMBx_Title db "Error",0MB0_Title db "Attention please",0MB0_Text db "Please center and release joystick 1",0

    Page 2

  • 7/21/2019 Td Win32asm 070.Asm

    3/13

  • 7/21/2019 Td Win32asm 070.Asm

    4/13

    td_win32asm_070.asmhbrBackground dd ?lpszMenuName dd ?lpszClassName dd ?hIconSm dd ?

    ; - Msg Structure ( API=GetMessageA ) - member POINT = POINT structurehWnd dd ?

    message dd ?wParam dd ?lParam dd ?time dd ?xpt dd ?ypt dd ?

    ; - TIMECAPS structure -wPeriodMin dd ?wPeriodMax dd ?

    ; - JOYCAPS structure -joycaps_wMid dw ?joycaps_wPid dw ?joycaps_szPname db 32 dup (?) ;[MAXPNAMELEN]joycaps_wXmin dd ?joycaps_wXmax dd ?joycaps_wYmin dd ?joycaps_wYmax dd ?joycaps_wZmin dd ?joycaps_wZmax dd ?

    joycaps_wNumButtons dd ?joycaps_wPeriodMin dd ?joycaps_wPeriodMax dd ?joycaps_wRmin dd ?joycaps_wRmax dd ?joycaps_wUmin dd ?joycaps_wUmax dd ?joycaps_wVmin dd ?joycaps_wVmax dd ?joycaps_wCaps dd ?

    joycaps_wMaxAxes dd ?joycaps_wNumAxes dd ?joycaps_wMaxButtons dd ?joycaps_szRegKey db 32 dup (?) ;[MAXPNAMELEN]joycaps_szOEMVxD db 260 dup (?) ;[MAX_JOYSTICKOEMVXDNAME]

    ; - JOYINFOEX structure -joyinfoex_dwSize dd ?joyinfoex_dwFlags dd ?joyinfoex_dwXpos dd ?joyinfoex_dwYpos dd ?

    joyinfoex_dwZpos dd ?joyinfoex_dwRpos dd ?joyinfoex_dwUpos dd ?joyinfoex_dwVpos dd ?

    Page 4

  • 7/21/2019 Td Win32asm 070.Asm

    5/13

  • 7/21/2019 Td Win32asm 070.Asm

    6/13

  • 7/21/2019 Td Win32asm 070.Asm

    7/13

  • 7/21/2019 Td Win32asm 070.Asm

    8/13

  • 7/21/2019 Td Win32asm 070.Asm

    9/13

    td_win32asm_070.asmjae JoyDowncmp Ypos_image,4 ;limit topjbe TP1_returndec Ypos_image ;y=y-1jmp Image_MoveJoyDown:cmp eax,Ymax_joy ;test if joystick moves down

    jbe JoyLeftcmp Ypos_image,252 ;limit bottomjae TP1_returninc Ypos_image ;y=y+1jmp Image_MoveJoyLeft:cmp ebx,Xmin_joy ;test if joystick moves leftjae JoyRightcmp Xpos_image,4 ;limit leftjbe TP1_returndec Xpos_image ;x=x-1jmp Image_MoveJoyRight:cmp ebx,Xmax_joy ;test if jostick moves rightjbe TP1_return ;notting happened, notting to do !cmp Xpos_image,372 ;limit rightjae TP1_returninc Xpos_image ;x=x+1jmp Image_Move;------------------------------------------------------------------------------Image_Move: ; ==> move image to new position

    ;------------------------------------------------------------------------------push 01h ;bRepaint, repaint flagpush Ymax_image ;nHeight, heightpush Xmax_image ;nWidth, widthpush Ypos_image ;Y, vertical positionpush Xpos_image ;X, horizontal positionpush hWnd_image ;hWnd, handle of windowcall MoveWindow ;- API Function -;------------------------------------------------------------------------------TP1_return: ; ==> say ciao;------------------------------------------------------------------------------popad ;pop all register back from stackmov esp,ebp ;delete stack framepop ebp ;ret 14h ;return and clear stack (14h !!!);##############################################################################

    ;******************************************************************************; My subroutine(s) for a compacter code resist here ...;------------------------------------------------------------------------------My_CreateImage: ;create window and region

    ;------------------------------------------------------------------------------push 0h ;lpParam, extra pointer data 0=no datapush hInstance ;hInstance, handle of our programpush 800 ;hMenu, the child-window ID

    Page 9

  • 7/21/2019 Td Win32asm 070.Asm

    10/13

    td_win32asm_070.asmpush WP1_hWnd ;hWndParent, handle parent window 0=nopush Ymax_image ;intnHeight, window height pixelpush Xmax_image ;intnWidth, window width pixelpush Ypos_image ;inty, vertical position windowpush Xpos_image ;intx, horizontal position windowpush 5400000Eh ;dwStyle, SS_BITMAP = 0Ehpush 0h ;lpWindowName, pointer to window name

    push OFFSET StaticClassName ;lpClassName, pointer to class namepush 0h ;dwExStylecall CreateWindowExA ;- API Function -mov hWnd_image,eax ;hwnd, store handle of windowpush 1800 ;lpBitmapName, bitmap resource IDpush hInstance ;hInstance, handle of modul instancecall LoadBitmapA ;- API Function -mov hImg_image,eax ;hObject, handle of graphic objectpush hImg_image ;push handle of the bitmappush 0h ;wParam, fImageType, IMAGE_BITMAP=0hpush 172h ;uMsg, STM_SETIMAGE=172hpush hWnd_image ;hwnd, handle of destination windowcall SendMessageA ;- API Function -cmp reg_image_max,0h ;create the regionje My_CreateImgRgn_returnmov esi,0hmov ebx,OFFSET i00_0000000000push [ebx+12]push [ebx+08]push [ebx+04]push [ebx+00]

    call CreateRectRgnmov edi,eaxinc esicmp reg_image_max,1hje My_CreateImgRgn_setMy_CreateImgRgn_combine:add ebx,16push [ebx+12]push [ebx+08]push [ebx+04]push [ebx+00]call CreateRectRgnpush eaxpush 2hpush eaxpush edipush edicall CombineRgncall DeleteObjectinc esicmp esi,reg_image_max

    jb My_CreateImgRgn_combineMy_CreateImgRgn_set:mov hRgn_image,edipush 1h

    Page 10

  • 7/21/2019 Td Win32asm 070.Asm

    11/13

  • 7/21/2019 Td Win32asm 070.Asm

    12/13

  • 7/21/2019 Td Win32asm 070.Asm

    13/13


Recommended