;########################################################################### ;########################################################################### ; ABOUT ASM_2_HTM: ; This is a basic conversion program. It turns any ASM source file ; into an internet ready HTML document. The user can configure the ; colors that it uses based on their own preferences, and set it to ; make all keywords, registers, psuedo-ops, and types capital letters. ; ;########################################################################### ; Program Info: ; This program requires nothing special. It just runs once the user ; selects a source file to convert to HTML. ; ;########################################################################### ;########################################################################### ;########################################################################### ;########################################################################### ; THE COMPILER OPTIONS ;########################################################################### ;########################################################################### .386 .model flat, stdcall option casemap :none ; case sensitive ;########################################################################### ;########################################################################### ; THE INCLUDES SECTION ;########################################################################### ;########################################################################### include \masm32\include\windows.inc include \masm32\include\comctl32.inc include \masm32\include\comdlg32.inc include \masm32\include\shell32.inc include \masm32\include\user32.inc include \masm32\include\kernel32.inc include \masm32\include\gdi32.inc includelib \masm32\lib\comctl32.lib includelib \masm32\lib\comdlg32.lib includelib \masm32\lib\shell32.lib includelib \masm32\lib\gdi32.lib includelib \masm32\lib\user32.lib includelib \masm32\lib\kernel32.lib ;########################################################################### ;########################################################################### ; LOCAL MACROS ;########################################################################### ;########################################################################### szText MACRO Name, Text:VARARG LOCAL lbl jmp lbl Name db Text,0 lbl: ENDM m2m MACRO M1, M2 push M2 pop M1 ENDM return MACRO arg mov eax, arg ret ENDM RGB MACRO red, green, blue xor eax,eax mov ah,blue shl eax,8 mov ah,green mov al,red ENDM hWrite MACRO handle, buffer, size mov edi, handle add edi, Dest_index mov ecx, 0 mov cx, size add Dest_index, ecx mov esi, buffer movsb ENDM hRead MACRO handle, buffer, size mov edi, handle add edi, Spot mov ecx, 0 mov cx, size add Spot, ecx mov esi, buffer movsb ENDM ;################################################################################# ;################################################################################# ; LOCAL PROTOTYPES ;################################################################################# ;################################################################################# ;================================== ; Main Program Procedures ;================================== WinMain PROTO :DWORD,:DWORD,:DWORD,:DWORD WndProc PROTO :DWORD,:DWORD,:DWORD,:DWORD Open PROTO ConvertFile PROTO IsKeyword PROTO :DWORD,:BYTE IsPsuedo PROTO :DWORD,:BYTE IsType PROTO :DWORD,:BYTE IsComment PROTO :DWORD,:BYTE IsReg PROTO :DWORD,:BYTE WriteChar PROTO :BYTE Output PROTO UpdateScreen PROTO UpdateMenu PROTO AboutProc PROTO :DWORD,:DWORD,:DWORD,:DWORD ColorProc PROTO :DWORD,:DWORD,:DWORD,:DWORD MiscCenterWnd PROTO :DWORD,:DWORD ;################################################################################# ;################################################################################# ; BEGIN INITIALIZED DATA ;################################################################################# ;################################################################################# .data ;============================== ;Text for the Window Title ;============================== szDisplayName db "ASM_2_HTM",0 ;============================== ;Windows handles and Misc ;============================== CommandLine dd 0 ; for the commandline params hRGN dd 0 ; Handle to a region hOBJ dd 0 ; Handle to an object hBRUSH dd 0 ; Handle to the Brush hDC dd 0 ; Handle to device context hMainWnd dd 0 ; Handle to the main window hMenu dd 0 ; Handle to the menu hWnd dd 0 ; Handle to a second window hInst dd 0 ; Handle to an Instance hIcon dd 0 ; Handle to the icon hFile dd 0 ; Handle to the file that we open Dest_Amount dd 0 ; Holds the index into Dest mem Spot dd 0 ; Holds offset into source for expand written dd 0 ; Holds our output bytes hConv dd 0 ; Holds icon's handle ;======================================================== ; This is used to pass arguments to wvsprintfA it can ; hold up to 4 different args ;======================================================== dwArgs dd 4 dup (0) ;======================================== ; Used to let us know it's processing ; and if we need to make caps ;======================================== Processing db 0 MakeCaps db 0 ;=========================================== ; This is for adjusting the Working string ;=========================================== Time_Count db 0 ;======================================================== ; For the Source & Destination files used in Conversion ;======================================================== hSrc_Memory dd 0 ; Handle to the source file's memory hDest_Memory dd 0 ; Handle to the dest. file's memory Dest_Size dd 0 ; Holds the true size of the dest file Src_Size dd 0 ; Handle to the size of the source file Amount_Read dd 0 ; Pointer to the amount read ;=============================== ; Strings for the application ;=============================== szClassName db "ASM_Class",0 NoHomePage db "Unable to open www.fastsoftware.com!",0 Homepage db "Http://www.fastsoftware.com/",0 OpenErr db "Unable to Open file!",0 OutputErr db "Error Writing HTML File!",0 ConvertErr db "Error Converting File!",0 szConvert db "Select a file to convert to HTML!",0 szMakeSure db "Error. Make sure you have 6 Hex characters!",0 HowUse db "ASM_2_HTM is a conversion program for programmers, or any",13,10 db "body who has an assembly language source file that they",13,10 db "would like to convert to HTML. To use this program just",13,10 db "open up any assembly language source file and it will auto-",13,10 db "matically convert that file to an fully internet ready HTML",13,10 db "document. You can adjust the colors that it uses with the",13,10 db "Options menu. And you can set it to make all of your",13,10 db "KEYWORDS, PSUEDO-OPS, and TYPES capital letters ",13,10 db "with Make Caps......Have fun.",13,10,13,10 db " - Chris Hobbs",0 ;======================================================= ; To open a file ;======================================================= szFile db 300 dup(0) szFileTitle db 300 dup(0) ofn OPENFILENAME ;===================================================== ;Initialize the Font structure for generic app then ; change what is necessary before calls ;===================================================== Font LOGFONT <14,0,0,0,FW_NORMAL,\ 0,0,0,ANSI_CHARSET,OUT_DEFAULT_PRECIS,\ CLIP_STROKE_PRECIS,DEFAULT_QUALITY,\ DEFAULT_PITCH or FF_SWISS,"MS Sans Serif"> ;=============================================== ; Our buffer to hold result of wvsprintf call ; for header placements,font, and menu stuff ;=============================================== szHeaderBuffer db 95 dup (0) szFontBuffer db 25 dup (0) szBoldBuffer db 25 dup (0) szMenuBuffer db 25 dup (0) szColorBuffer db 10 dup (0) szHoldArea db 10 dup (0) ;=================================== ; This is the maximum size that a ; word can be ;=================================== szWord db 41 dup (0) ;=================================== ; These are for testing keywords ;=================================== szTestString db 20 dup (0) ;==================================================== ; These are the color defaults these get changed ;==================================================== szDEFAULT_COMMENT db "#00FF00",0 szDEFAULT_BACKGROUND db "#000000",0 szDEFAULT_TEXT db "#FFFFFF",0 szDEFAULT_PSUEDO db "#FF00FF",0 szDEFAULT_STRING db "#0000FF",0 szDEFAULT_TYPE db "#FF0000",0 szDEFAULT_REG db "#FFFF00",0 ;################################################################################# ;################################################################################# ; BEGIN CONSTANTS ;################################################################################# ;################################################################################# ;================================================ ; These are for opening and saving files ;================================================ szOpenFilter SBYTE "Asm Files (*.asm)",0,"*.asm",0,0 szSaveFilter SBYTE "HTML Files (*.htm)",0,"*.htm",0,0 szDefExt SBYTE "htm",0 ;==================================================================== ; These are the templates we use for writing out the HTML stuff ;==================================================================== szHeaderTemp1 SBYTE "",13,10 SBYTE "",13,10 SBYTE " %s ",13,10,0 szHeaderTemp2 SBYTE "",13,10 SBYTE "
",13,10,0

szFontTemp		SBYTE "",0
szEndFont		SBYTE "",0
szBoldTemp		SBYTE "%s",0

	;================================
	; This is how we end every file
	;================================
szEnding		SBYTE	"
",0 ;================================================ ; These hold the templates for the menu strings ;================================================ szMenuBackTemp SBYTE "Background: %s",0 szMenuTextTemp SBYTE "Text: %s",0 szMenuCommentTemp SBYTE "Comments: %s",0 szMenuStringTemp SBYTE "Strings: %s",0 szMenuTypeTemp SBYTE "Types: %s",0 szMenuPsuedoTemp SBYTE "Psuedo-Op: %s",0 szMenuRegTemp SBYTE "Registers: %s",0 ;========================================================= ; This is the template for when they specify a new color ;========================================================= szColorTemp SBYTE "#%s",0 ;================================================ ; These hold the defaults for restoration ; DO NOT ALTER IN CODE ;================================================ DEFAULT_COMMENT SBYTE "#00FF00",0 DEFAULT_BACKGROUND SBYTE "#000000",0 DEFAULT_TEXT SBYTE "#FFFFFF",0 DEFAULT_PSUEDO SBYTE "#FF00FF",0 DEFAULT_STRING SBYTE "#0000FF",0 DEFAULT_TYPE SBYTE "#FF0000",0 DEFAULT_REGS SBYTE "#FFFF00",0 ;================================== ; These are for the special signs ;================================== GREATER_SIGN SBYTE ">",0 LESS_SIGN SBYTE "<",0 AMPERSAND_SIGN SBYTE "&",0 ;================================= ; This is so they know we haven't ; locked up and are processing ;================================= Working SBYTE "Working....." ;################################################################################# ;################################################################################# ; BEGIN EQUATES ;################################################################################# ;################################################################################# ;================= ;Utility Equates ;================= FALSE equ 0 TRUE equ 1 ;================ ; resource IDs ;================ IDI_ASM equ 500 IDM_MENU equ 600 IDD_ABOUT equ 700 IDD_COLOR equ 800 ID_COLOR equ 9000 ;================ ; Menu ID's ;================ IDM_CONVERT equ 1000 IDM_EXIT equ 1500 IDM_BACKGROUND equ 2000 IDM_TEXT equ 2010 IDM_COMMENT equ 2020 IDM_STRING equ 2030 IDM_TYPE equ 2040 IDM_PSUEDO equ 2050 IDM_REG equ 2060 IDM_RESTORE equ 2500 IDM_MAKECAPS equ 2600 IDM_HOW equ 3400 IDM_ABOUT equ 3500 ;================ ; STRING TABLES ;================ COMMENT_BASE equ 1000h STRING_BASE equ 2000h PSUEDO_BASE equ 3000h KEYWORD_BASE equ 4000h TYPE_BASE equ 5000h REG_BASE equ 6000h ;================ ; Number of each ;================ NUM_KEYWORD equ 192 NUM_PSUEDO equ 88 NUM_TYPE equ 18 NUM_REG equ 28 ;================= ; Max size of word ;================= MAX_WORD_SIZE equ 40 ;################################################################################# ;################################################################################# ; BEGIN THE CODE SECTION ;################################################################################# ;################################################################################# .code start: invoke GetModuleHandle, NULL mov hInst, eax invoke GetCommandLine mov CommandLine, eax invoke WinMain,hInst,NULL,CommandLine,SW_SHOWDEFAULT invoke ExitProcess,eax ;######################################################################### WinMain proc hInstance :DWORD, hPrevInst :DWORD, CmdLine :DWORD, CmdShow :DWORD ;==================== ; Put LOCALs on stack ;==================== LOCAL wc :WNDCLASSEX LOCAL msg :MSG LOCAL B_RECT :RECT ; a rectangle struct LOCAL hFONT :DWORD ; handle to the font LOCAL Wwd :DWORD LOCAL Wht :DWORD LOCAL Wtx :DWORD LOCAL Wty :DWORD ;================================================== ; Fill WNDCLASSEX structure with required variables ;================================================== mov wc.cbSize,sizeof WNDCLASSEX mov wc.style,CS_HREDRAW or CS_VREDRAW \ or CS_BYTEALIGNWINDOW mov wc.lpfnWndProc,offset WndProc mov wc.cbClsExtra,NULL mov wc.cbWndExtra,NULL m2m wc.hInstance,hInst ;<< NOTE: macro not mnemonic mov wc.hbrBackground,COLOR_BACKGROUND mov wc.lpszMenuName,NULL mov wc.lpszClassName,offset szClassName invoke LoadIcon,hInst,IDI_ASM ; icon ID mov hIcon,eax mov wc.hIcon,eax invoke LoadCursor,NULL,IDC_ARROW mov wc.hCursor,eax mov wc.hIconSm,0 invoke RegisterClassEx, ADDR wc ;================================ ; Create window at following size ;================================ mov Wwd, 250 mov Wht, 200 ;=========================================== ; Create the main screen ;=========================================== invoke CreateWindowEx,NULL, ADDR szClassName, ADDR szDisplayName, WS_POPUP or WS_SYSMENU or\ WS_MINIMIZEBOX or WS_CAPTION, Wtx,Wty,Wwd,Wht, NULL,NULL, hInst,NULL ;=========================================== ; Put the window handle in for future uses ;=========================================== mov hMainWnd,eax ;============================================ ;Load the menu ;============================================ invoke LoadMenu,hInst,IDM_MENU ; menu ID mov hMenu, eax invoke SetMenu,hMainWnd,hMenu ;================================ ; Load the icon ;================================ ;================================= ; Load all of the icons ;================================= invoke LoadIcon,hInst,IDI_ASM ; icon ID mov hConv,eax ;======================================== ; Set processing, and Make caps to false ;======================================== mov Processing, FALSE mov MakeCaps, FALSE ;================================ ; Update the menu ;================================ invoke UpdateMenu ;================================ ; Update the screen ;================================ invoke UpdateScreen ;================================ ; Show the window ;================================ invoke ShowWindow,hMainWnd,SW_SHOWNORMAL invoke UpdateWindow,hMainWnd ;================================ ; Center window at following size ;================================ invoke GetDesktopWindow invoke MiscCenterWnd, hMainWnd, eax ;=================================== ; Loop until PostQuitMessage is sent ;=================================== StartLoop: invoke GetMessage,ADDR msg,NULL,0,0 cmp eax, 0 je ExitLoop invoke TranslateMessage, ADDR msg invoke DispatchMessage, ADDR msg jmp StartLoop ExitLoop: return msg.wParam WinMain endp ;######################################################################### WndProc proc hWin :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD ;======================================== ; LOCAL VARIABLES ;========================================= .if uMsg == WM_COMMAND ;======== menu commands ======== .if wParam == IDM_CONVERT ;==The open and convert code=== ;======================== ; Get the open file name ;======================== mov eax, offset szOpenFilter mov ofn.lpstrFilter, eax mov ofn.lpstrDefExt, NULL mov szFile, NULL invoke GetOpenFileName, ADDR ofn ;======================== ; Test for file ;======================== .if (eax) ;======================== ; jump to open code ;======================== invoke Open ;======================== ; Test for an error ;======================== .if eax == 0 ;================== ; Give error msg ;================== invoke MessageBox, hWin, ADDR OpenErr,\ NULL,MB_OK jmp release .endif ;============================ ; We were good so convert ;============================ invoke ConvertFile ;=========================== ; Test for an error ;=========================== .if eax == 0 ;=================== ; Give Message ;=================== invoke MessageBox, hWin, ADDR ConvertErr,\ NULL,MB_OK jmp release .endif ;========================== ; Now write the file out ;========================== mov eax, offset szSaveFilter mov ofn.lpstrFilter, eax mov eax, offset szDefExt mov ofn.lpstrDefExt, eax mov szFile, NULL invoke Output ;=========================== ; Test for an error ;=========================== .if eax == 0 ;=================== ; Give Message ;=================== invoke MessageBox, hWin, ADDR OutputErr,\ NULL,MB_OK .endif release: ;=============================== ; Release the allocated memory ;=============================== invoke GlobalFree, hSrc_Memory invoke GlobalFree, hDest_Memory .endif .elseif wParam == IDM_EXIT ;=========================== ; THIS IS THE FILE-EXIT ;=========================== invoke SendMessage,hWin,WM_SYSCOMMAND,SC_CLOSE,NULL .elseif wParam == IDM_BACKGROUND ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_BACKGROUND, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_TEXT ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_TEXT, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_COMMENT ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_COMMENT, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_STRING ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_STRING, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_TYPE ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_TYPE, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_PSUEDO ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_PSUEDO, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_REG ;========================================== ; Activate the Color Selection Dialog Box ;========================================== invoke DialogBoxParam, hInst, IDD_COLOR, hMainWnd, ADDR ColorProc, NULL ;========================================== ; If it succeded in selecting a new color ;========================================== .if eax == TRUE ;============================== ; Yes so copy into default var ;============================== invoke lstrcpy, ADDR szDEFAULT_REG, ADDR szColorBuffer ;============================== ; Update the menu ;============================== invoke UpdateMenu .endif .elseif wParam == IDM_RESTORE ;========================================== ; Restore the default colors into our vars ;========================================== invoke lstrcpy, ADDR szDEFAULT_BACKGROUND, ADDR DEFAULT_BACKGROUND invoke lstrcpy, ADDR szDEFAULT_TEXT, ADDR DEFAULT_TEXT invoke lstrcpy, ADDR szDEFAULT_COMMENT, ADDR DEFAULT_COMMENT invoke lstrcpy, ADDR szDEFAULT_TYPE, ADDR DEFAULT_TYPE invoke lstrcpy, ADDR szDEFAULT_STRING, ADDR DEFAULT_STRING invoke lstrcpy, ADDR szDEFAULT_PSUEDO, ADDR DEFAULT_PSUEDO invoke lstrcpy, ADDR szDEFAULT_REG, ADDR DEFAULT_REGS ;=================== ; Turn Makecaps off ;=================== mov MakeCaps, FALSE ;====================================== ; Update the menu ;====================================== invoke UpdateMenu .elseif wParam == IDM_MAKECAPS ;============================== ; Turn the make caps on or off ;============================== .if MakeCaps == FALSE ;============= ; Make true ;============= mov MakeCaps, TRUE .else ;============= ; Make false ;============= mov MakeCaps, FALSE .endif ;========================= ; Update the menu ;========================= invoke UpdateMenu .elseif wParam == IDM_HOW ;============================ ; This will tell the user ; how to use it ;============================ invoke MessageBox, hMainWnd, ADDR HowUse,ADDR szDisplayName,MB_OK .elseif wParam == IDM_ABOUT ;=========================== ;THIS IS THE HELP-ABOUT ;=========================== invoke DialogBoxParam, hInst, IDD_ABOUT, hMainWnd, ADDR AboutProc, NULL .endif ;====== end menu commands ====== .elseif uMsg == WM_PAINT ;=========================== ; Call to update screen ;=========================== invoke UpdateScreen .elseif uMsg == WM_DESTROY ;=========================== ; Kill the application ;=========================== invoke PostQuitMessage,NULL return 0 .endif invoke DefWindowProc,hWin,uMsg,wParam,lParam ret WndProc endp ;######################################################################## ; End of Main Windows Callback Procedure ;######################################################################## ;######################################################################## ;######################################################################## ; MY FUNCTIONS ;######################################################################## ;######################################################################## ;######################################################################## ; Open Function ;######################################################################## Open proc ;================================================ ; Code to open the document and read into mem ;================================================ ;================================= ; Create the file ;================================= invoke CreateFile, offset szFile, GENERIC_READ or GENERIC_WRITE, \ FILE_SHARE_READ, NULL,OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,NULL mov hFile, eax ;=============================== ; Test for an error ;=============================== .if eax == INVALID_HANDLE_VALUE jmp err .endif ;=============================== ; Get the file size ;=============================== invoke GetFileSize, hFile, NULL mov Src_Size, eax ;================================ ; test for an error ;================================ .if eax == -1 jmp err .endif ;============================================== ; Allocate enough memeory to hold the file ;============================================== invoke GlobalAlloc, GMEM_FIXED, Src_Size mov hSrc_Memory, eax mov Spot, 0 ;=================================== ; test for an error ;=================================== .if eax == 0 jmp err .endif ;============================================== ; Allocate a worst case scenario memory ; for compression program ;============================================== mov eax, Src_Size shl eax, 4 invoke GlobalAlloc, GMEM_FIXED, eax mov hDest_Memory, eax ;=============================== ; test for an error ;=============================== .if eax == 0 jmp err .endif ;=================================== ; Put the file into memory ;=================================== invoke ReadFile, hFile, hSrc_Memory, Src_Size, offset Amount_Read, NULL ;=============================== ; test for an error ;=============================== .if eax == 0 jmp err .endif ;============================ ; Close the handle ;============================ invoke CloseHandle,hFile ;=================================== ; Set the number written to zero ;=================================== mov written, 0 done: return 1 err: ;============================ ; Close the handle ;============================ invoke CloseHandle,hFile return 0 Open endp ;######################################################################## ; END of Open ;######################################################################## ;######################################################################## ; ConvertFile Function ;######################################################################## ConvertFile proc ;===================================== ; Code to convert the chosen file ;===================================== ;===================================== ; Local Variables ;===================================== LOCAL ending_spot:DWORD LOCAL Word_Spot:BYTE LOCAL Count:DWORD ;===================================== ; Initialize our ending and word spot ;===================================== mov eax, hSrc_Memory add eax, Src_Size mov ending_spot, eax mov Word_Spot, 0 ;===================================== ; Set the count to zero ;===================================== mov Count, 0 ;===================================== ; Update the screen ;===================================== invoke UpdateScreen ;===================================== ; Clear out our Word buffer ;===================================== mov cl, 0 mov eax, offset szWord .while cl <= MAX_WORD_SIZE mov BYTE PTR [eax], 0 inc eax inc cl .endw ;======================================== ; Set processing to TRUE, Time Count 0 ;======================================== mov Processing, TRUE mov Time_Count, 0 ;===================================== ; Copy into header one the first part ; we will write to the file's memory ; this consists of the file title ;===================================== mov dwArgs, offset szFileTitle invoke wvsprintfA,ADDR szHeaderBuffer,ADDR szHeaderTemp1, offset dwArgs ;===================================== ; Now write out our first header ;===================================== invoke wvsprintfA, hDest_Memory, ADDR szHeaderBuffer,0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;===================================== ; Place the defualt color for the ; background into the string. If they ; have selected a different color it ; will have replaced that string ;===================================== mov dwArgs+0, offset szDEFAULT_BACKGROUND mov dwArgs+4, offset szDEFAULT_TEXT invoke wvsprintfA,ADDR szHeaderBuffer,ADDR szHeaderTemp2, offset dwArgs ;===================================== ; Now write out our final part of the ; header to the file ;===================================== invoke wvsprintfA, hDest_Memory, ADDR szHeaderBuffer,0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;===================================== ; This is the start of our main loop ; it will parse our file and write out ; the necassary info to the ; destination memory ;===================================== top: ;==================================== ; Increment the count ;==================================== inc Count ;==================================== ; If count == 2000 update the screen ;==================================== .if Count == 2000 ;========================== ; Update it ;========================== invoke UpdateScreen ;========================= ; Increment Time Count ;========================= inc Time_Count ;========================= ; Reset if greter than 4 ;========================= .if Time_Count > 4 mov Time_Count, 0 .endif ;========================= ; Reset the Count ;========================= mov Count, 0 .endif ;===================================== ; Parse until the end test ;===================================== mov eax, ending_spot .if hSrc_Memory <= eax ;============================ ; Put the character into the ; Word at pos Word_Spot ;============================ mov eax, offset szWord add al, Word_Spot mov ecx, hSrc_Memory xor ebx, ebx mov bl, BYTE PTR [ecx] mov BYTE PTR [eax], bl ;============================ ; Increment our source memory ; and the word spot ;============================ inc hSrc_Memory inc Word_Spot ;======================================== ; Start with the larger tests for the ; keywords, psuedo-ops, types, and the ; multi line comment. If this fails try ; the single character things ;======================================== ;=========================================== ; First lets' do a few tests to skip over if ; not needed to the smaller stuff ;=========================================== mov al, Word_Spot .if al < 2 ;====================== ; Jump over this stuff ;====================== jmp skipbig .endif ;=================================== ; Perform the second test by seeing ; if the next char is a terminator ;=================================== mov eax, hSrc_Memory mov bl, BYTE PTR [eax] .if bl == 32 || bl == 9 || bl == 10 || bl == 13 || bl == 44 || bl == 93 ;=================================== ; Do nothing it means we ; have a word to test against ;=================================== .else ;====================== ; Jump over this stuff ;====================== jmp skipbig .endif ;========================================== ; Start this off by checking the keywords ;========================================== invoke IsKeyword, offset szWord, Word_Spot ;========================================== ; If it wasn't a keyword then try a psuedo ;========================================== .if eax == 0 ;================================ ; Try the psuedo op ;================================ invoke IsPsuedo, offset szWord, Word_Spot ;================================ ; Did this fail also???? ;================================ .if eax == 0 ;========================== ; Well then try a type ;========================== invoke IsType, offset szWord, Word_Spot ;============================= ; Did this one fail too?? ;============================= .if eax == 0 ;========================== ; Try a register test ;========================== invoke IsReg, offset szWord, Word_Spot ;============================= ; Did we fail this?? ;============================== .if eax == 0 ;========================== ; Finally try a comment ;========================== invoke IsComment, offset szWord, Word_Spot ;============================= ; Did this one fail too?? ;============================= .if eax == 0 ;========================== ; Do nothing last test ;========================== .else ;===================================== ; Reset Word_Spot to zero ;===================================== mov Word_Spot, 0 ;=================== ; Back to the top ;=================== jmp top .endif .else ;============================= ; Reset Word_Spot to zero ;============================= mov Word_Spot, 0 ;=================== ; Back to the top ;=================== jmp top .endif .else ;===================================== ; Reset Word_Spot to zero ;===================================== mov Word_Spot, 0 ;=================== ; Back to the top ;=================== jmp top .endif .else ;===================================== ; Reset Word_Spot to zero ;===================================== mov Word_Spot, 0 ;=================== ; Back to the top ;=================== jmp top .endif .else ;===================================== ; Reset Word_Spot to zero ;===================================== mov Word_Spot, 0 ;=================== ; Back to the top ;=================== jmp top .endif skipbig: ;======================================== ; Make the tests for any of the single ; char stuff: strings, and comments ;======================================== mov eax, offset szWord add al, Word_Spot dec eax xor ebx, ebx mov bl, BYTE PTR [eax] .if bl == ';' ;====================================== ; Process a single line comment ;====================================== ;====================================== ; If buffer has more than one char then ; empty it ;====================================== .if Word_Spot > 1 ;======================= ; Has chars so empty it ;======================= mov eax, 0 xor edx, edx mov dl, Word_Spot dec dl .while al < dl ;============================ ; Write them out to the file ;============================ push eax mov ebx, offset szWord add ebx, eax mov cl, BYTE PTR [ebx] mov BYTE PTR [ebx], 0 push edx invoke WriteChar, cl pop edx pop eax inc al .endw .endif ;====================================== ; Setup and write out the comment color ; and the delimiter ;====================================== mov dwArgs, offset szDEFAULT_COMMENT invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;====================================== ; Write out the comment symbol ;====================================== mov ebx, offset szWord add bl, Word_Spot dec ebx mov al, BYTE PTR [ebx] mov ecx, hDest_Memory mov BYTE PTR [ecx], al ;===================================== ; Increment the pointers ;===================================== inc written inc hDest_Memory ;====================================== ; Set the final char in buffer to zero ;====================================== mov ebx, offset szWord add bl, Word_Spot mov BYTE PTR [ebx], 0 ;=============================== ; Set the Word_Spot to zero ;=============================== mov Word_Spot, 0 ;=============================== ; Buffer is empty so we can now ; process the comment ;=============================== mov ebx, hSrc_Memory mov al, BYTE PTR [ebx] .while al != 13 ;====================== ; Write the char out ;====================== invoke WriteChar, al ;====================== ; Increment source mem ;====================== inc hSrc_Memory ;======================= ; Get the character ;======================= mov ebx, hSrc_Memory mov al, BYTE PTR [ebx] .endw ;================================== ; We are finished with the comment ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax .elseif bl == 34 || bl == 39 ;================================= ; Process a string ;================================= ;==================================== ; Save our character so we know what ; to test against later on ;==================================== push ebx ;====================================== ; If buffer has more than one char then ; empty it ;====================================== .if Word_Spot > 1 ;======================= ; Has chars so empty it ;======================= mov eax, 0 xor edx, edx mov dl, Word_Spot dec dl .while al < dl ;============================ ; Write them out to the file ;============================ push eax mov ebx, offset szWord add ebx, eax mov cl, BYTE PTR [ebx] mov BYTE PTR [ebx], 0 push edx invoke WriteChar, cl pop edx pop eax inc al .endw .endif ;====================================== ; Setup and write out the string color ; and the delimiter ;====================================== mov dwArgs, offset szDEFAULT_STRING invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;====================================== ; Write out the string symbol ;====================================== mov ebx, offset szWord add bl, Word_Spot dec ebx mov al, BYTE PTR [ebx] mov ecx, hDest_Memory mov BYTE PTR [ecx], al ;===================================== ; Increment the pointers ;===================================== inc written inc hDest_Memory ;====================================== ; Set the final char in buffer to zero ;====================================== mov ebx, offset szWord add bl, Word_Spot mov BYTE PTR [ebx], 0 ;=============================== ; Set the Word_Spot to zero ;=============================== mov Word_Spot, 0 ;=============================== ; Put our old charcter into ecx ;=============================== pop ecx ;=============================== ; Buffer is empty so we can now ; process the string ;=============================== mov ebx, hSrc_Memory mov al, BYTE PTR [ebx] .while al != cl ;====================== ; Save the character ;====================== push ecx ;====================== ; Write the char out ;====================== invoke WriteChar, al ;====================== ; Increment source mem ;====================== inc hSrc_Memory ;======================= ; Get the character ;======================= mov ebx, hSrc_Memory mov al, BYTE PTR [ebx] ;======================== ; Restore the charcter ;======================== pop ecx .endw ;====================== ; Write the final char ; of the string out ;====================== invoke WriteChar, al ;====================== ; Increment source mem ;====================== inc hSrc_Memory ;================================== ; We are finished with the string ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;====================================================== ; Did we hit a non alphanumeric or special char? ;====================================================== ;============================== ; Eliminate Non AlphaNumeric ;============================== .elseif (bl < 64 || bl > 90) && (bl < 97 || bl > 122) && \ (bl < 48 || bl > 57) && bl != 95 && bl != 46 ;===================================== ; No it wasn't so empty the buffer ;===================================== mov eax, 0 xor edx, edx mov dl, Word_Spot .while al < dl ;============================ ; Write them out to the file ;============================ push eax mov ebx, offset szWord add bl, al mov cl, BYTE PTR [ebx] mov BYTE PTR [ebx], 0 push edx invoke WriteChar, cl pop edx pop eax inc al .endw ;===================================== ; Set Word Spot to zero ;===================================== mov Word_Spot, 0 .endif ;======================================= ; If the buffer has reached it's limit ; then empty it ;======================================= .if Word_Spot == (MAX_WORD_SIZE) ;======================================== ; We have so write out the chars and set ; everything to zero ;======================================== xor ecx, ecx mov cl, 0 mov ebx, offset szWord .while cl < MAX_WORD_SIZE push ebx push ecx invoke WriteChar, BYTE PTR [ebx] pop ecx pop ebx mov BYTE PTR [ebx], 0 inc ebx inc cl .endw ;================================ ; Set the Word_spot to zero ;================================ mov Word_Spot, 0 .endif ;====================================== ; Go back to the top and do again ;====================================== jmp top .endif ;====================================== ; If buffer has any chars in it ; then empty it ;====================================== .if Word_Spot != 0 ;======================= ; Has chars so empty it ;======================= mov eax, 0 xor edx, edx mov dl, Word_Spot dec dl dec dl .while al < dl ;============================ ; Write them out to the file ;============================ push eax mov ebx, offset szWord add bl, al mov cl, BYTE PTR [ebx] mov BYTE PTR [ebx], 0 push edx invoke WriteChar, cl pop edx pop eax inc al .endw .endif ;===================================== ; Now write out our finishing header ;===================================== invoke wvsprintfA, hDest_Memory, ADDR szEnding,0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;======================================== ; Set processing to false ;======================================== mov Processing, FALSE done: return 1 err: return 0 ConvertFile endp ;######################################################################## ; END of ConvertFile ;######################################################################## ;######################################################################## ; IsKeyword Function ;######################################################################## IsKeyword proc string:DWORD, str_size:BYTE ;================================================ ; This tests the passed string to see if it is ; a keyword that needs highlighting or not ; if so it highlights the string it and ; writes it out if not it returns zero ;================================================ ;================================ ; Local variables ;================================ LOCAL Base:BYTE ;================================ ; Initialize Base to zero ;================================ mov Base, 0 ;================================ ; Loop until we reach the end of ; the keywords ;================================ .while Base < NUM_KEYWORD ;================================================ ; Load in our current keyword we want to test ;================================================ mov eax, KEYWORD_BASE add al, Base invoke LoadString, hInst, eax, ADDR szTestString, 15 ;========================================== ; Compare it to the string that was passed ;========================================== invoke lstrcmpi, string, offset szTestString ;==================================================== ; If we succceeded write it out and clear the buffer ;==================================================== .if eax == 0 ;===================================== ; Do we need to make the string caps ;===================================== .if MakeCaps == TRUE ;============================== ; Yes so make a call and do it ;============================== invoke CharUpper, string mov string, eax .endif ;===================================== ; Set the string into the buffer ;===================================== mov eax, string mov dwArgs, eax invoke wvsprintfA, ADDR szBoldBuffer, ADDR szBoldTemp, offset dwArgs ;===================================== ; Now write out our first header ;===================================== invoke wvsprintfA, hDest_Memory, ADDR szBoldBuffer,0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================= ; Clear out the chars ;================================= xor eax, eax .while al < str_size ;======================== ; Setup the current char ;======================== mov ebx, string add bl, al ;============================ ; Set Cur Char back to 0 ;============================ mov BYTE PTR [ebx], 0 ;============================== ; increment the counter ;============================== inc eax .endw ;================================== ; Jump to found and leave function ;================================== jmp found .else ;==================== ; NOPE GOTO NEXT ONE ;==================== .endif ;=============================== ; Increment the base pointer ;=============================== inc Base .endw done: return 0 found: return 1 IsKeyword endp ;######################################################################## ; END of IsKeyword ;######################################################################## ;######################################################################## ; IsPsuedo Function ;######################################################################## IsPsuedo proc string:DWORD, str_size:BYTE ;================================================ ; This tests the passed string to see if it is ; a psuedo-op that needs highlighting or not ; if so it highlights the string it and ; writes it out if not it returns zero ;================================================ ;================================ ; Local variables ;================================ LOCAL Base:BYTE ;================================ ; Initialize Base to zero ;================================ mov Base, 0 ;================================ ; Loop until we reach the end of ; the types ;================================ .while Base < NUM_PSUEDO ;================================================ ; Load in our current type we want to test ;================================================ mov eax, PSUEDO_BASE add al, Base invoke LoadString, hInst, eax, ADDR szTestString, 15 ;========================================== ; Compare it to the string that was passed ;========================================== invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, \ string, -1, offset szTestString, -1 ;==================================================== ; If we succceeded write it out and clear the buffer ;==================================================== .if eax == 2 ;================================= ; Write out the font color stuff ;================================= mov dwArgs, offset szDEFAULT_PSUEDO invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================= ; Write it out ;================================= xor eax, eax .while al < str_size ;======================== ; Setup the current char ;======================== mov ebx, string add bl, al ;=========================== ; Move char to register ; for passing to WriteChar ;=========================== xor ecx, ecx mov cl, BYTE PTR [ebx] ;============================ ; Set Cur Char back to 0 ;============================ mov BYTE PTR [ebx], 0 ;============================ ; Preserve our register ;============================ push eax ;============================= ; If needed convert to upper ;============================= .if MakeCaps == TRUE ;====================== ; Yes so make the call ;====================== invoke CharUpper, ecx mov cl, al .endif ;============================ ; Make the call to WriteChar ;============================ invoke WriteChar, cl ;============================== ; Restore and inc the counter ;============================== pop eax inc eax .endw ;================================== ; We are finished with the psuedo ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================== ; Jump to found and leave function ;================================== jmp found .else ;==================== ; NOPE GOTO NEXT ONE ;==================== .endif ;=============================== ; Increment the base pointer ;=============================== inc Base .endw done: return 0 found: return 1 IsPsuedo endp ;######################################################################## ; END of IsPsuedo ;######################################################################## ;######################################################################## ; IsType Function ;######################################################################## IsType proc string:DWORD, str_size:BYTE ;================================================ ; This tests the passed string to see if it is ; a type declaraion if so it highlights it and ; writes it out if not it returns zero ;================================================ ;================================ ; Local variables ;================================ LOCAL Base:BYTE ;================================ ; Initialize Base to zero ;================================ mov Base, 0 ;================================ ; Loop until we reach the end of ; the types ;================================ .while Base < NUM_TYPE ;================================================ ; Load in our current type we want to test ;================================================ mov eax, TYPE_BASE add al, Base invoke LoadString, hInst, eax, ADDR szTestString, 15 ;========================================== ; Compare it to the string that was passed ;========================================== invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, \ string, -1, offset szTestString, -1 ;==================================================== ; If we succceeded write it out and clear the buffer ;==================================================== .if eax == 2 ;================================= ; Write out the font color stuff ;================================= mov dwArgs, offset szDEFAULT_TYPE invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================= ; Write it out ;================================= xor eax, eax .while al < str_size ;======================== ; Setup the current char ;======================== mov ebx, string add bl, al ;=========================== ; Move char to register ; for passing to WriteChar ;=========================== xor ecx, ecx mov cl, BYTE PTR [ebx] ;============================ ; Set Cur Char back to 0 ;============================ mov BYTE PTR [ebx], 0 ;============================ ; Preserve our register ;============================ push eax ;============================= ; If needed convert to upper ;============================= .if MakeCaps == TRUE ;====================== ; Yes so make the call ;====================== invoke CharUpper, ecx mov cl, al .endif ;============================ ; Make the call to WriteChar ;============================ invoke WriteChar, cl ;============================== ; Restore and inc the counter ;============================== pop eax inc eax .endw ;================================== ; We are finished with the type ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================== ; Jump to found and leave function ;================================== jmp found .else ;==================== ; NOPE GOTO NEXT ONE ;==================== .endif ;=============================== ; Increment the base pointer ;=============================== inc Base .endw done: return 0 found: return 1 IsType endp ;######################################################################## ; END of IsType ;######################################################################## ;######################################################################## ; IsComment Function ;######################################################################## IsComment proc string:DWORD, str_size:BYTE ;================================================ ; This tests the passed string to see if it is ; a multi line comment that needs highlighting ; if so it highlights the linesit and ; writes it out if not it returns zero ;================================================ ;========================== ; Local Variables ;========================== LOCAL Delimiter:BYTE ;================================================ ; Load in our current type we want to test ;================================================ mov eax, COMMENT_BASE invoke LoadString, hInst, eax, ADDR szTestString, 15 ;========================================== ; Compare it to the string that was passed ;========================================== invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, \ string, -1, offset szTestString, -1 ;==================================================== ; If we succceeded write it out, clear the buffer, ; and get the delimter we need to test for ;==================================================== .if eax == 2 ;================================= ; Write out the font color stuff ;================================= mov dwArgs, offset szDEFAULT_COMMENT invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================= ; Write it out ;================================= xor eax, eax .while al < str_size ;======================== ; Setup the current char ;======================== mov ebx, string add bl, al ;=========================== ; Move char to register ; for passing to WriteChar ;=========================== xor ecx, ecx mov cl, BYTE PTR [ebx] ;============================ ; Set Cur Char back to 0 ;============================ mov BYTE PTR [ebx], 0 ;============================ ; Preserve our register ;============================ push eax ;============================ ; Make the call to WriteChar ;============================ invoke WriteChar, cl ;============================== ; Restore and inc the counter ;============================== pop eax inc eax .endw ;=================================== ; Now we need to get the delimiter ;=================================== again: mov eax, hSrc_Memory mov bl, BYTE PTR [eax] inc hSrc_Memory .if bl == 32 || bl == 9 || bl == 13 || bl == 10 ;============================ ; Wasn't our delimiter so ; write it out and go to ; the next byte for testing ;============================ invoke WriteChar, bl jmp again .else ;============================ ; It was our delimiter so set ; it as such and write it out ;============================ mov Delimiter, bl invoke WriteChar, bl .endif ;======================================== ; Go until we find the delimiter again ;======================================== another: mov eax, hSrc_Memory mov bl, BYTE PTR [eax] inc hSrc_Memory .if bl == Delimiter ;========================== ; Write it out ;========================== invoke WriteChar, bl ;========================== ; Go until End of Line ;========================== waitEOL: mov eax, hSrc_Memory mov bl, BYTE PTR [eax] inc hSrc_Memory .if bl == 13 ;============================ ; Write it out we are done ;============================ invoke WriteChar, bl .else ;=========================== ; Write it out ;=========================== invoke WriteChar, bl ;=========================== ; Jump and do again ;=========================== jmp waitEOL .endif .else ;========================== ; Write it out ;========================== invoke WriteChar, bl ;========================== ; Goto the next character ;========================== jmp another .endif ;================================== ; We are finished with the type ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================== ; Jump to found and leave function ;================================== jmp found .else ;==================== ; NOPE TRY NEXT TIME ;==================== .endif done: return 0 found: return 1 IsComment endp ;######################################################################## ; END of IsComment ;######################################################################## ;######################################################################## ; IsReg Function ;######################################################################## IsReg proc string:DWORD, str_size:BYTE ;================================================ ; This tests the passed string to see if it is ; a register that needs highlighting or not ; if so it highlights the string it and ; writes it out if not it returns zero ;================================================ ;================================ ; Local variables ;================================ LOCAL Base:BYTE ;================================ ; Initialize Base to zero ;================================ mov Base, 0 ;================================ ; Loop until we reach the end of ; the types ;================================ .while Base < NUM_REG ;================================================ ; Load in our current type we want to test ;================================================ mov eax, REG_BASE add al, Base invoke LoadString, hInst, eax, ADDR szTestString, 15 ;========================================== ; Compare it to the string that was passed ;========================================== invoke CompareString, LOCALE_USER_DEFAULT, NORM_IGNORECASE, \ string, -1, offset szTestString, -1 ;==================================================== ; If we succceeded write it out and clear the buffer ;==================================================== .if eax == 2 ;================================= ; Write out the font color stuff ;================================= mov dwArgs, offset szDEFAULT_REG invoke wvsprintfA,ADDR szFontBuffer,ADDR szFontTemp, offset dwArgs invoke wvsprintfA, hDest_Memory, ADDR szFontBuffer, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================= ; Write it out ;================================= xor eax, eax .while al < str_size ;======================== ; Setup the current char ;======================== mov ebx, string add bl, al ;=========================== ; Move char to register ; for passing to WriteChar ;=========================== xor ecx, ecx mov cl, BYTE PTR [ebx] ;============================ ; Set Cur Char back to 0 ;============================ mov BYTE PTR [ebx], 0 ;============================ ; Preserve our register ;============================ push eax ;============================= ; If needed convert to upper ;============================= .if MakeCaps == TRUE ;====================== ; Yes so make the call ;====================== invoke CharUpper, ecx mov cl, al .endif ;============================ ; Make the call to WriteChar ;============================ invoke WriteChar, cl ;============================== ; Restore and inc the counter ;============================== pop eax inc eax .endw ;================================== ; We are finished with the register ; so close the font color ;================================== invoke wvsprintfA, hDest_Memory, ADDR szEndFont, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax ;================================== ; Jump to found and leave function ;================================== jmp found .else ;==================== ; NOPE GOTO NEXT ONE ;==================== .endif ;=============================== ; Increment the base pointer ;=============================== inc Base .endw done: return 0 found: return 1 IsReg endp ;######################################################################## ; END of IsReg ;######################################################################## ;######################################################################## ; WriteChar Function ;######################################################################## WriteChar proc character:BYTE ;================================================ ; This writes the character out to memory for the ; file later on. It tests for special codes ; that we have to output instead of the actaul ; character that it passes, also. ;================================================ ;===================================== ; Is it a special symbol ;===================================== .if character == 60 ;================================= ; Write out the less than sign ;================================= invoke wvsprintfA, hDest_Memory, ADDR LESS_SIGN, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax .elseif character == 62 ;================================= ; Write out the greater than sign ;================================= invoke wvsprintfA, hDest_Memory, ADDR GREATER_SIGN, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax .elseif character == 38 ;================================= ; Write out the ampersand ;================================= invoke wvsprintfA, hDest_Memory, ADDR AMPERSAND_SIGN, 0 ;===================================== ; Add the number written and advance ; the memory handle by that amount ;===================================== add written, eax add hDest_Memory, eax .else ;===================================== ; Now write out our char by moving it ; into destination memory ;===================================== mov al, character mov ebx, hDest_Memory mov BYTE PTR [ebx], al ;===================================== ; Increment our pointers ;===================================== inc written inc hDest_Memory .endif done: return 1 err: return 0 WriteChar endp ;######################################################################## ; END of WriteChar ;######################################################################## ;######################################################################## ; Output Function ;######################################################################## Output proc ;===================================== ; Code to save file out ;===================================== ;====================================== ; Setup the filename to write out to ;====================================== invoke GetSaveFileName, ADDR ofn ;========================== ; End if they cancel ;========================== .if eax == 0 jmp done .endif ;====================================== ; Create the file to write to ;====================================== invoke CreateFile, offset szFile, GENERIC_READ or GENERIC_WRITE, \ FILE_SHARE_READ, NULL,OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL,NULL mov hFile, eax ;=============================== ; Test for an error ;=============================== .if eax == INVALID_HANDLE_VALUE jmp err .endif ;====================================== ; Write to the file after adjusting the ; memory location by the amount written ;====================================== mov eax, written sub hDest_Memory, eax invoke WriteFile, hFile, hDest_Memory, written, offset Dest_Amount, NULL ;====================================== ; Test for an error ;====================================== .if eax == 0 ;========================= ; Jump to error ;========================= jmp err .endif ;====================================== ; Close the handle to the file ;====================================== invoke CloseHandle, hFile done: return 1 err: return 0 Output endp ;######################################################################## ; END of Output ;######################################################################## ;######################################################################## ; UpdateScreen Function ;######################################################################## UpdateScreen proc ;============================================ ; Code to update the display it is called ; while we are processing the file and in the ; paint message ;============================================ ;================================= ; Erase the screen ;================================= invoke RedrawWindow, hMainWnd, NULL, NULL,\ RDW_ERASE or RDW_INVALIDATE invoke RedrawWindow, hMainWnd, NULL, NULL,\ RDW_ERASENOW ;============================ ; get the DC ;============================ invoke GetDC, hMainWnd mov hDC, eax ;============================ ; Set text and bkgnd mode ;============================ invoke SetTextColor, hDC, 00000000h invoke SetBkMode, hDC, TRANSPARENT ;============================ ; Output the text ;============================ invoke TextOut,hDC,18,30,ADDR szConvert,SIZEOF szConvert - 1 ;====================================================== ; Draw the Icon as an image at the specified location ;====================================================== invoke DrawIconEx,hDC,85,60,hConv,64,64,NULL,\ NULL,DI_NORMAL ;======================================= ; Only if Processing a file do this ;======================================= .if Processing == TRUE ;====================================== ; Set the Text color to a dark green ;====================================== RGB 0,128,0 invoke SetTextColor, hDC, eax ;================================ ; Output the text based on the ; character adjuster ;================================ .if Time_Count == 0 invoke TextOut,hDC,20,140,ADDR Working,SIZEOF Working - 4 .elseif Time_Count == 1 invoke TextOut,hDC,20,140,ADDR Working,SIZEOF Working - 3 .elseif Time_Count == 2 invoke TextOut,hDC,20,140,ADDR Working,SIZEOF Working - 2 .elseif Time_Count == 3 invoke TextOut,hDC,20,140,ADDR Working,SIZEOF Working - 1 .elseif Time_Count == 4 invoke TextOut,hDC,20,140,ADDR Working,SIZEOF Working .endif .endif ;================================ ; release the device context ;================================ invoke ReleaseDC, hMainWnd, hDC done: return 1 err: return 0 UpdateScreen endp ;######################################################################## ; END of UpdateScreen ;######################################################################## ;######################################################################## ; UpdateMenu Function ;######################################################################## UpdateMenu proc ;================================================ ; Code to update the menu strings for the colors ;================================================ ;===================================== ; Copy the current color into ; the menu buffer for background ;===================================== mov dwArgs, offset szDEFAULT_BACKGROUND invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuBackTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_BACKGROUND, MF_BYCOMMAND or MF_STRING, IDM_BACKGROUND, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for the text ;===================================== mov dwArgs, offset szDEFAULT_TEXT invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuTextTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_TEXT, MF_BYCOMMAND or MF_STRING, IDM_TEXT, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for comments ;===================================== mov dwArgs, offset szDEFAULT_COMMENT invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuCommentTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_COMMENT, MF_BYCOMMAND or MF_STRING, IDM_COMMENT, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for strings ;===================================== mov dwArgs, offset szDEFAULT_STRING invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuStringTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_STRING, MF_BYCOMMAND or MF_STRING, IDM_STRING, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for Types ;===================================== mov dwArgs, offset szDEFAULT_TYPE invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuTypeTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_TYPE, MF_BYCOMMAND or MF_STRING, IDM_TYPE, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for Psuedo-Ops ;===================================== mov dwArgs, offset szDEFAULT_PSUEDO invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuPsuedoTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_PSUEDO, MF_BYCOMMAND or MF_STRING, IDM_PSUEDO, ADDR szMenuBuffer ;===================================== ; Copy the current color into ; the menu buffer for Registers ;===================================== mov dwArgs, offset szDEFAULT_REG invoke wvsprintfA, ADDR szMenuBuffer, ADDR szMenuRegTemp, offset dwArgs ;===================================== ; Make that the new menu item ;===================================== invoke ModifyMenu, hMenu, IDM_REG, MF_BYCOMMAND or MF_STRING, IDM_REG, ADDR szMenuBuffer ;===================================== ; Check or uncheck the make caps item ;===================================== .if MakeCaps == FALSE ;============================= ; Make sure item is unchecked ;============================= invoke CheckMenuItem,hMenu,IDM_MAKECAPS,MF_BYCOMMAND or MF_UNCHECKED .else ;============================ ; Tis' true so check it ;============================ invoke CheckMenuItem,hMenu,IDM_MAKECAPS,MF_BYCOMMAND or MF_CHECKED .endif done: return 1 err: return 0 UpdateMenu endp ;######################################################################## ; END of UpdateMenu ;######################################################################## ;######################################################################## ; Handle the about box ;######################################################################## AboutProc proc hDlg :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD ;================================= ; The equate for the homepage code ;================================= IDHOME equ 2 ;========================= ; Get the message into eax ;========================= mov eax, uMsg .IF (eax == WM_INITDIALOG) invoke MiscCenterWnd, hDlg, hMainWnd .ELSEIF (eax == WM_COMMAND) && (wParam == IDOK) invoke EndDialog, hDlg, TRUE .ELSEIF (eax == WM_COMMAND) && (wParam == IDHOME) invoke EndDialog, hDlg, TRUE ;=================================== ; Execute our homepage ;=================================== invoke ShellExecute,0,0,ADDR Homepage,0,0,0 .if eax <= 32 ;====================== ; Tell them we can't ; open the homepage ;====================== invoke MessageBox, hMainWnd, offset NoHomePage, NULL, MB_OK .endif .ELSE mov eax, FALSE ; show message not processed jmp Return .ENDIF mov eax, TRUE ; show message was processed Return: ret AboutProc endp ;######################################################################## ; END ABOUTPROC ;######################################################################## ;######################################################################## ; Handle the coloring dialog box ;######################################################################## ColorProc proc hDlg :DWORD, uMsg :DWORD, wParam :DWORD, lParam :DWORD ;========================= ; Get the message into eax ;========================= mov eax, uMsg .IF (eax == WM_INITDIALOG) ;============================= ; Center the Dialog Box ;============================= invoke MiscCenterWnd, hDlg, hMainWnd .ELSEIF (eax == WM_COMMAND) && (wParam == IDOK) ;===================================== ; Get the text that is in the box ;===================================== invoke GetDlgItemText, hDlg, ID_COLOR, ADDR szHoldArea, 7 ;===================================== ; If we failed just return zero and ; give a message box ;===================================== .if eax != 6 ;======================= ; Give them the message ;======================= invoke MessageBox, hDlg, ADDR szMakeSure, NULL, MB_OK ;====================== ; Return from this ;====================== return 0 .endif ;==================================== ; Loop through and find out if they ; entered Hex character ;==================================== mov al, 0 .while al < 6 ;======================== ; Was it a Hex character ;======================== mov ebx, offset szHoldArea add bl, al mov cl, BYTE PTR [ebx] .if (cl > 47 && cl < 58) || (cl > 64 && cl < 71) ;============================ ; Was Hex so do nothing ;============================ .else ;========================== ; It wasn't a hex value ;========================== invoke MessageBox, hDlg, ADDR szMakeSure, NULL, MB_OK ;====================== ; Return from this ;====================== return 0 .endif ;============================ ; We are still good so inc ;============================ inc al .endw ;================================ ; Put it into the color buffer ;================================ mov dwArgs, offset szHoldArea invoke wvsprintfA, ADDR szColorBuffer, ADDR szColorTemp, offset dwArgs ;================================ ; End the Dialog Proc ;================================ invoke EndDialog, hDlg, TRUE .ELSEIF (eax == WM_COMMAND) && (wParam == IDCANCEL) invoke EndDialog, hDlg, FALSE .ELSE mov eax, FALSE ; show message not processed jmp Return .ENDIF mov eax, TRUE ; show message was processed Return: ret ColorProc endp ;######################################################################## ; END ColorProc ;######################################################################## ;######################################################################## ; Misc Center Window from SIB by Steve Gibson. Thanks Steve! ;######################################################################## MiscCenterWnd proc hChild:DWORD, hParent:DWORD ; Define the local variables LOCAL rcP:RECT, rcC:RECT, xNew:DWORD, yNew:DWORD invoke GetWindowRect, hParent, ADDR rcP .IF (eax) invoke GetWindowRect, hChild, ADDR rcC .IF (eax) mov eax, rcP.right ;center horizontally sub eax, rcP.left ;x=Px+(Pdx-Cdx)/2 sub eax, rcC.right add eax, rcC.left sar eax, 1 add eax, rcP.left ; check if off screen at left .IF (sign?) mov eax, 0 .ENDIF mov xNew, eax invoke GetSystemMetrics, SM_CXFULLSCREEN sub eax, rcC.right add eax, rcC.left ; check if off screen at right .IF (eax < xNew) mov xNew, eax .ENDIF mov eax, rcP.bottom ; center vertically sub eax, rcP.top ; y=Py+(Pdy-Cdy)/2 sub eax, rcC.bottom add eax, rcC.top sar eax, 1 add eax, rcP.top ; check if off screen at top .IF (sign?) mov eax, 0 .ENDIF mov yNew,eax invoke GetSystemMetrics, SM_CYFULLSCREEN sub eax, rcC.bottom add eax, rcC.top .IF (eax < yNew) mov yNew, eax .ENDIF invoke SetWindowPos, hChild, NULL, xNew, yNew, 0, 0, SWP_NOSIZE + SWP_NOZORDER .ENDIF .ENDIF Return: ret MiscCenterWnd ENDP ;######################################################################## ; END MISC CENTER WINDOW ;######################################################################## ;###################################### ; THIS IS THE END OF THE PROGRAM CODE # ;###################################### end start