graph.c
1.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*---------------------------------------------------------------------
Copyright (C) 1998 Nintendo.
File cont.h
Coded by Koji Mitsunari. Oct 2, 1997.
Modified by Koji Mitsunari. Oct 27, 1998.
Comments functions for graphics
$Id:
---------------------------------------------------------------------*/
#include <ultra64.h>
#include "nu64sys.h"
#include "graph.h"
/*---------------------------------------------------------------------
Display character on the screen
---------------------------------------------------------------------*/
void
putc(u16 *p, int x, int y, u16 color, u8 c)
{
int i, j;
u8 *pc = pat[c-0x20];
p = p + x+y*SCREEN_WD;
for (j = 0; j < CHAR_HT; j ++, pc++) {
for (i = CHAR_WD - 1; i >= 0; i --) {
if (*pc & (1 << i)) {
*p = color;
} else {
*p = 0;
}
p ++;
}
p += SCREEN_WD - CHAR_WD;
}
}
/*---------------------------------------------------------------------
Display string on the screen
---------------------------------------------------------------------*/
void
prints(u16 *p, int x, int y, u16 color, u8 *s)
{
int i;
for (i = 0 ; *s != NULL; i ++, x+=CHAR_WD) {
putc(p, x , y, color, *s++);
}
}
/*---------------------------------------------------------------------
Clear the screen
---------------------------------------------------------------------*/
void
gcls(u16 *p){
int i;
u16 *ptr = p;
for (i = 0; i < SCREEN_WD*SCREEN_HT; i ++) {
*ptr++ = BGCOLOR;
}
}