ssnfont.c 2.5 KB
#include <ultra64.h>
#include "ssnfont.h"
#include "font5x7.h"
#include "dldriver.h"

extern void *cfb_ptrs[2];
extern int draw_buffer;

char ssnstr[256];
void SsnPrintfxy(int chrx,int chry,char *ssnstr);
/*void SsnPutOneChar(int,int,int,unsigned char );*/
void SsnFontShow(void);


int col[8]={SSNCOL0,SSNCOL1,SSNCOL2,SSNCOL3,SSNCOL4,SSNCOL5,SSNCOL6,SSNCOL7};

void SsnPrintf(locate* loc,char* ssnstr){
  int i=0;
  while (ssnstr[i]!='\0') {

		switch (ssnstr[i]){
			case '\n':
	      loc->x=0;
	      loc->y++;
				i++;
				break;

			case '\\':
	      i++;
	      switch (ssnstr[i]){
	        case 'c':
	          i++;
	          loc->c=col[(char)ssnstr[i++]-'0'];
	          break;
	        default:
	          break;
	      }
				break;

			default:
      	SsnPutOneChar(loc->c,loc->x++,loc->y,ssnstr[i++]);
				break;	
    }
  }
}
/*
void SsnPrintf(locate* loc,char* ssnstr){
	int i=0;
	while (ssnstr[i]!='\0') {

		if (ssnstr[i] =='\n') {
			loc->x=0;
			loc->y++;
		}

		if (ssnstr[i] =='\\') {
			i++;
			switch (ssnstr[i]){
			  case 'c':
					i++;
					loc->c=col[(char)ssnstr[i++]-'0'];
					break;
				default:
					break;
			}
		} else {
			SsnPutOneChar(loc->c,loc->x++,loc->y,ssnstr[i++]);
		}
	}
}
*/
void SsnPrintfxy(int chrx,int chry,char *ssnstr){
        int i=0;
        while (ssnstr[i]!='\0') SsnPutOneChar(0xffff,chrx++,chry,ssnstr[i++]);
}

void SsnPutOneChar(int filter,int chrx,int chry,unsigned char c){
	unsigned short *cfbPtr;
        int x,y,d;

	cfbPtr = cfb_ptrs[draw_buffer];

        for (y=0;y<SSNFONTSIZEY;y++){
          for (x=0;x<SSNFONTSIZEX;x++){
            d = font5x7[SSNFONTSIZEXX*(y+SSNFONTSIZEY*(SSNFONTCHRY-c/SSNFONTCHRX))+x+(c%SSNFONTCHRX)*SSNFONTSIZEX] & filter;
/*
            if (d != 0x0001 ) cfb_16[draw_buffer][(SCREEN_WD*(chry*SSNFONTSIZEY+(SSNFONTSIZEY-y)+SSNSCROFSTY))+chrx*SSNFONTSIZEX+x+SSNSCROFSTX]
*/
            if (d != 0x0001 ) cfbPtr[(SCREEN_WD*(chry*SSNFONTSIZEY+(SSNFONTSIZEY-y)+SSNSCROFSTY))+chrx*SSNFONTSIZEX+x+SSNSCROFSTX]
              =font5x7[SSNFONTSIZEXX*(y+SSNFONTSIZEY*(SSNFONTCHRY-c/SSNFONTCHRX))+x+(c%SSNFONTCHRX)*SSNFONTSIZEX] & filter;
          }
        }

}

void SsnFontShow(void){
	int x,y;
	unsigned short *cfbPtr;

	cfbPtr = cfb_ptrs[draw_buffer];

        for (y=0;y<SSNFONTSIZEYY;y++){
          for (x=0;x<SSNFONTSIZEXX;x++){
/*
            cfb_16[draw_buffer][(SCREEN_WD*(100+(SSNFONTSIZEYY-y)))+x+SSNSCROFSTX]=font5x7[y*(SSNFONTSIZEXX)+x];
*/
            cfbPtr[(SCREEN_WD*(100+(SSNFONTSIZEYY-y)))+x+SSNSCROFSTX]=font5x7[y*(SSNFONTSIZEXX)+x];
          }
        }
}