#INCLUDE "occSDL.module"
#INCLUDE "course.module"

PROC simple.surface(CHAN BYTE kyb?, scr!, err!)
  INT result:
  SDL.Surface surface:
  TIMER tim:
  INT t:
  INT32 pixel:
  SEQ
    out.string("SDL SIMPLE_SURFACE: from occam*c*n", 0, scr!)
    out.string("(c) 2003 Christian L. Jacobsen*c*n*n", 0, scr!)
    occ.SDL.Init(result, SDL.INIT.EVERYTHING)
    IF
      result <> 0
        VAL INT max.str IS 100:
        [100]BYTE err.str:
        INT err.len:
        SEQ
          out.string("SDL initialisation failed: ", 0, scr!)
          occ.SDL.GetError(err.str, max.str, err.len)
          out.string([err.str FOR err.len], 0, scr!)
          out.string("*c*n", 0, scr!)
      TRUE
        SEQ
          VAL INT w IS 150:
          VAL INT h IS 200:
          VAL INT depth IS 32:
          SDL.SetVideoMode(surface, w, h, depth, (SDL.SWSURFACE \/ SDL.ANYFORMAT))
          IF
            surface = 0
              SEQ
                out.string("surface pointer is: ", 0, scr!)
                out.hex(INT (surface), 0, scr!)
                out.string("*c*n", 0, scr!)
            TRUE
              SEQ
                --occ.SDL.MapRGB(surface[pixels.ptr], 255, 255, 255, pixel)
                tim ? t
                tim ? AFTER t PLUS 10000000
    SDL.Quit()
:
