/************************************
 * SCRNTST - Test C02 screen module *
 ************************************/
 
//use -h amd -s options on command line
#include <screen.h02>

char col, row, wdth, hght;
char mode, modex;
char a, c, f, i, m;
char aa, yy;

const char modes = {#SMTEXT, #SMWIDE};

void prtaxy(aa,yy) {
  if (aa & $F0) prbyte(aa); else prhex(aa);
  putchr('X');
  if (yy & $F0) prbyte(yy); else prhex(yy);
}

void putlin() {putstr(); newlin();}

main:

  for (modex=0; modex<@modes; modex++) {
  
    mode = modes[modex];
    if (mode == $FF) continue; //Unsupported Mode
 
    if (setscr(mode)=$FF) putlin("ERROR IN SETSCR()");
    m = getscr();
    if (m <> mode) putlin("ERROR IN GETSCR()");
    putstr("MODE="); prbyte(m); newlin();

    wdth, hght = getsiz(); //Get Screen Width & Height
    prtaxy(wdth,hght); newlin();
 
    for (i=1; i<6; i++) putchr('.');
    col, row = getpos(); //Get Cursor Position
    prtaxy(col,row); 
    crsrhm(); prtaxy(getpos());
    getchr(); newlin(); //Wait For keypress
        
    clrscr(); //Clear Screen
    col, row = getpos(); //Get Cursor Position
    prtaxy(col, row);
    f = (col == 255) ? 0 : $FF;
    getchr(); 
    
    if (f) clrscr(); else newlin();
    
    if (wdth:- or hght:-) goto exit;
    for (c='@'; c<'`'; c++) {
        if (!f) newlin();
        for (row=hght-2; row; row--) {
        if (!f) putchr(' ');
        for (col=wdth-2; col; col--) {
            if (f) setpos(col,row); 
            putchr(c);
        }
        if (!f) newlin();
        if (getkey() == #ESCKEY) goto exit;
        }
        if (!f) getchr();
    }
    if (f) getchr();  //Wait For keypress
    newlin();

  } //for modex

  goto exit;
