; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "BSD 2-clause" license."          |
;|_______________________________________________________________________________________|
;
;  Description: SimpleDebug library.
;
;  Target OS: Win32
;
;  Dependencies: Not dependent on other libraries.
;
;  Notes:
;_________________________________________________________________________________________

DBG_CHAR_NEWLINE equ $0d, $0a

uglobal
  if used debug_con_handle
    debug_con_handle dd ?
  end if
endg


iglobal
  if used cConsoleTitle
    cConsoleTitle du 'Fresh simple debug console.', 0
  end if
endg


if (defined options.DebugMode & options.DebugMode) | used Output
initialize InitDebugConsole
begin
        invoke  AllocConsole
        invoke  GetStdHandle, STD_ERROR_HANDLE
        mov     [debug_con_handle], eax
        invoke  SetConsoleTitleW, cConsoleTitle
        return
endp
end if



proc Output, .ptrStr
.dummy dd ?
begin
        pushad

        stdcall __simpStrLength, [.ptrStr]
        lea     eax, [.dummy]

if GlobalAPI eq ascii
        invoke  WriteConsole, [debug_con_handle], [.ptrStr], ecx, eax, 0
else
        invoke  WriteConsoleA, [debug_con_handle], [.ptrStr], ecx, eax, 0
end if


        popad
        return
endp



proc GetTimestamp
begin
        pushad
        invoke  GetTickCount
        mov     [esp+4*regEAX], eax
        popad
        return
endp




