; _______________________________________________________________________________________
;|                                                                                       |
;| ..::FreshLib::..  Free, open source. Licensed under "Fresh artistic license."         |
;|_______________________________________________________________________________________|
;
;  Description: Macro library for displaying compile time messages.
;
;  Target OS: Any (FASM compiler)
;
;  Dependencies:
;
;  Notes:
;_________________________________________________________________________________________

iconWarning = 1
iconError = 2
iconInfo = 3
iconFind = 4
iconNone  = 5
iconDebug = 6


macro __digit num
{
   if num < 10
    display '0'+num
   else
    display 'A'+num-10
   end if
}


macro _disp arg1, arg2
{
   if arg2 eq
    display arg1
   else
    local ..tmp
    ..tmp = arg1
    virtual at 0
     repeat 32
      if ..tmp > 0
       db ..tmp mod arg2
       ..tmp = ..tmp / arg2
      end if
     end repeat
     repeat $
      load ..tmp byte from $-%
      __digit ..tmp
     end repeat
     if $ = 0
      display '0'
     end if
    end virtual
   end if
}

macro disp [arg] { _disp arg }


macro DispSize Text, Sz {
  local size, suffix
  size = Sz;
  if defined options.ShowSizes & options.ShowSizes
    if Text eqtype "A"
      disp 3,"Sizeof [", Text, "] is: "
    else
      disp 3,"Sizeof [", `Text, "] is: "
    end if

    suffix = 'bytes'
    if Sz>10000
      size = size / 1024
      disp <size,10>, 'K',$0d,$0a
    else
      disp <size,10>, ' bytes.',$0d,$0a
    end if
  end if
}
