;reserve space for bmp template             and write it
bmpTime: rb bmp32.szStruc + width*height*4  &&  bmp32 bmpTime width height

;11x22 bitmap font
bmpFont: rb bmp32.szStruc + 24*256 *32 *4
  ReadFileA(bmpFont .file 0 ($-bmpFont))
  bmp32.pqFlipY(bmpFont)
  .file: ub '../inc/bitmap/fonts/font24x32X256.win1251.bmp',0


  ;formating, see later
  format: ub '%u',0
  buffer: rb 128
align 4
  argptr: rb 4

  ;bitmap center and Hour,Minute,Second arrows
  centerX==width/2
  centerY==height/2
  if centerX<centerY
    radius==centerX
  else
    radius==centerY
  end if
  radiusS==radius *64/100
  radiusM==radius *48/100
  radiusH==radius *32/100

loop:
DrawOff;SYNC.bmp32.screen.disable

  bmp32.flush bmpTime 0x00'00'1e

  ;second arrow
  x==radiusS*ClockArrowSinCos('cos' time.second) +centerX
  y==radiusS*ClockArrowSinCos('sin' time.second) +centerY
  bmp32.pqLineTo 0x00'00'ff bmpTime centerX centerY x y

  ui32[argptr]=time.second  &&  printfA(buffer 128 format argptr)
  bmp32.pqFont.TextOut(bmpTime x y bmpFont 0x'00'00'ff buffer 2)

  ;minute arrow
  x==radiusM*ClockArrowSinCos('cos' time.minute) +centerX
  y==radiusM*ClockArrowSinCos('sin' time.minute) +centerY
  bmp32.pqLineTo 0x00'ff'00 bmpTime  centerX     centerY     x y
  bmp32.pqLineTo 0x00'ee'00 bmpTime (centerX+1) (centerY+1)  x y

  ui32[argptr]=time.minute  &&  printfA(buffer 128 format argptr)
  bmp32.pqFont.TextOut(bmpTime x y bmpFont 0x00'ff'00 buffer 2)

  ;hour arrow
  x==radiusH*ClockArrowSinCos('cos' (time.hour mod 12 * 5)) +centerX
  y==radiusH*ClockArrowSinCos('sin' (time.hour mod 12 * 5)) +centerY
  bmp32.pqLineTo 0x'ee'00'00 bmpTime (centerX-2) (centerY-2) x y
  bmp32.pqLineTo 0x'ff'00'00 bmpTime  centerX     centerY    x y
  bmp32.pqLineTo 0x'ee'00'00 bmpTime (centerX+2) (centerY+2) x y

  ui32[argptr]=time.hour  &&  printfA(buffer 128 format argptr)
  bmp32.pqFont.TextOut(bmpTime x y bmpFont 0x'ff'00'00 buffer 2)

  bmp32.screen bmpTime
  sleep 1000
  goto loop
