

  include '%fasminc%\win32a.inc'
  include '%fasminc%\APIA\GDI32.INC'
  include '%fasminc%\APIA\KERNEL32.INC'
  include '%fasminc%\APIA\USER32.INC'
  include 'general defs.inc'
  include 'Windows defs.inc'
  include 'black box.inc'

  .data

    BB_DebugMode = ON

    ProgramTitle db 'Black box test program', 0
    LoopCount db 'Main loop rep. number #h', 0
    label CountChar byte at LoopCount + $16

  .code

  start:

  Init:

    BB_Activate "BlackBoxTest.log", "BB activation message"
    BB_BreakPoint 0, "The black box was just activated."
    BB_Monitor Char, BB_1Byte, "Char"

    stdcall InitCount, Char

    BB_BreakPoint 0, "InitCount was just called.  The main loop is now starting."

  MainLoop:

    BB_BreakPoint 0, "This is the top of the main loop."

    stdcall IncLoopCount, Char

    BB_BreakPoint 0, "IncLoopCount was just called."
    BB_DontMonitor Char
    BB_BreakPoint 0, "BB_DontMonitor Char was just called."
    BB_Monitor Char
    BB_BreakPoint 0, "Now BB_Monitor Char was called again."

    invoke  MessageBox, HWND_DESKTOP, LoopCount, ProgramTitle, MB_OK

    BB_BreakPoint 0, "MessageBox was just called.  The main loop will now restart."

    cmp     [Char], 'F'
    jne     MainLoop

  ..BB_AbortProgram:

    BB_BreakPoint 0, "The main loop just ended."

  Termination:

    BB_Deactivate "BB deactivation message"

    invoke  ExitProcess,0

  ; End of the program



  proc InitCount

    enter
    BB_EnteredProc "InitCount"
    BB_UseNewWindow "InitCount"
    BB_BreakPoint 0, "This is the beginning of InitCount."

    mov     [CountChar], '0'

    BB_BreakPoint 0, "This is the end of InitCount."
    BB_DiscardWindow
    BB_LeftProc
  return

  proc IncLoopCount, Char
    enter

    BB_EnteredProc "IncLoopCount"
    BB_UseNewWindow "IncLoopCount"
    BB_BreakPoint 0, "This is the beginning of IncLoopCount."

    cmp     [Char], '9'
    je	    .ConvertToAlphaCount
    cmp     [Char], 'F'
    je	    .ConvertToNumeralCount
      inc     [Char]
      jmp     .Done
    .ConvertToAlphaCount:
      mov     [Char], 'A'
      jmp     .Done
    .ConvertToNumeralCount:
      mov     [Char], '0'
  .Done:

    BB_BreakPoint 0, "This is the end of IncLoopCount."
    BB_DiscardWindow
    BB_LeftProc
  return
