-
Notifications
You must be signed in to change notification settings - Fork 0
/
hello-openshift.c
101 lines (81 loc) · 2.17 KB
/
hello-openshift.c
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/* simple Hello World for OpenShift nes-s2i builder for cc65, for NES
* Based on example code by Doug Fraker
* using neslib
*/
#include "neslib.h"
#include "MoreLib.c"
#define PPU_CTRL *((unsigned char*)0x2000)
#define PPU_MASK *((unsigned char*)0x2001)
#define PPU_STATUS *((unsigned char*)0x2002)
#define SCROLL *((unsigned char*)0x2005)
#define PPU_ADDRESS *((unsigned char*)0x2006)
#define PPU_DATA *((unsigned char*)0x2007)
#define FP_BITS 4
const unsigned char palette[16]={ 0x0f,0x00,0x16,0x30,0x0f,0x01,0x21,0x31,0x0f,0x06,0x16,0x26,0x0f,0x09,0x19,0x29 };
int index;
void write_str(unsigned char x, unsigned char y, unsigned char *str) {
while( *str != 0) {
vram_adr(NTADR_A(x, y));
PPU_DATA = *str;
++str;
++x;
}
}
void render_logo(unsigned int x, unsigned int y) {
unsigned char *tile = (unsigned char *) 0x80; // start of logo in charset A
unsigned int left = 16; // width of logo
vram_adr(NTADR_A(x, y));
while(tile <= (unsigned char *) 0xFF) { // end of logo in charset A
PPU_DATA = tile;
++tile;
--left;
if(left == 0) {
y++;
vram_adr(NTADR_A(x, y));
left = 16;
}
}
}
unsigned char buf[256]={};
void type_str(unsigned char x, unsigned char y, unsigned char *str, unsigned char _delay) {
while( *str != 0) {
buf[0] = MSB(NTADR_A(x,y))|NT_UPD_HORZ;
buf[1] = LSB(NTADR_A(x,y));
buf[2] = 1; // 1 write
buf[3] = *str; // tile #
buf[4] = NT_UPD_EOF;
set_vram_update(buf);
++str;
++x;
if(_delay > 0) {
delay(_delay);
} else {
delay(1);
}
}
set_vram_update(NULL);
}
void clear_line(unsigned char row) {
type_str(1, row, " ", 0);
}
unsigned int s;
void main (void) {
pal_bg(palette);
render_logo(1, 1);
ppu_on_all();
scroll(0, 0);
while (1) {
delay(40);
type_str(1, 10, (unsigned char *) "Red Hat [ OpenShift", 3); // square bracket is actually defined as dash symbol in tileset
type_str(1, 12, (unsigned char *) "s2i NES builder example", 3);
delay(40);
clear_line(10);
clear_line(12);
s=0;
while(s<256) {
delay(1);
scroll(s, 0);
++s;
}
}
};