/* Copyright 1996 Acorn Computers Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
/*56 instructions*/

#include <kernel.h>

#include "colourtrans.h"
#include "font.h"
#include "os.h"
#include "pdriver.h"

_kernel_oserror *x (int page, char *t)

{  bool more;
   os_box req;
   _kernel_oserror *oserror = NULL;
   _kernel_swi_regs swi_regs;

   swi_regs.r [0] = 1;
   swi_regs.r [1] = (int) &req;
   swi_regs.r [2] = page;
   swi_regs.r [3] = (int) NULL;

   if ((oserror = _kernel_swi (PDriver_DrawPage, &swi_regs, &swi_regs)) !=
         NULL)
      goto finish;

   while (more)
   {  swi_regs.r [0] = os_COLOUR_BLACK;
      swi_regs.r [3] = colourtrans_SET_FG_GCOL;
      swi_regs.r [4] = os_ACTION_OVERWRITE;

      if ((oserror = _kernel_swi (ColourTrans_SetGCOL, &swi_regs, &swi_regs))
            != NULL)
         goto finish;

      swi_regs.r [1] = (int) t;
      swi_regs.r [2] = NONE;
      swi_regs.r [3] = 0;
      swi_regs.r [4] = 0;

      if ((oserror = _kernel_swi (Font_Paint, &swi_regs, &swi_regs)) != NULL)
         goto finish;

      swi_regs.r [1] = (int) &req;

      if ((oserror = _kernel_swi (PDriver_GetRectangle, &swi_regs,
            &swi_regs)) != NULL)
         goto finish;

      more = swi_regs.r [0];
   }

finish:
  return oserror;
}
