mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-03 10:03:20 +08:00
增加更多的颜色(2)
This commit is contained in:
@@ -176,10 +176,17 @@ color.bim : color.obj a_nask.obj Makefile
|
||||
color.hrb : color.bim Makefile
|
||||
$(BIM2HRB) color.bim color.hrb 56k
|
||||
|
||||
color2.bim : color2.obj a_nask.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:color2.bim stack:1k map:color2.map \
|
||||
color2.obj a_nask.obj
|
||||
|
||||
color2.hrb : color2.bim Makefile
|
||||
$(BIM2HRB) color2.bim color2.hrb 56k
|
||||
|
||||
haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
hello.hrb hello2.hrb a.hrb hello3.hrb hello4.hrb hello5.hrb \
|
||||
winhelo.hrb winhelo2.hrb winhelo3.hrb star1.hrb stars.hrb stars2.hrb \
|
||||
lines.hrb walk.hrb noodle.hrb beepdown.hrb beepup.hrb color.hrb
|
||||
lines.hrb walk.hrb noodle.hrb beepdown.hrb beepup.hrb color.hrb color2.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:haribote.sys to:@: \
|
||||
@@ -203,6 +210,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
copy from:beepdown.hrb to:@: \
|
||||
copy from:beepup.hrb to:@: \
|
||||
copy from:color.hrb to:@: \
|
||||
copy from:color2.hrb to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
# 其他指令
|
||||
|
||||
42
25_day/color2.c
Normal file
42
25_day/color2.c
Normal file
@@ -0,0 +1,42 @@
|
||||
int api_openwin(char *buf, int xsiz, int ysiz, int col_inv, char *title);
|
||||
void api_initmalloc(void);
|
||||
char *api_malloc(int size);
|
||||
void api_refreshwin(int win, int x0, int y0, int x1, int y1);
|
||||
void api_linewin(int win, int x0, int y0, int x1, int y1, int col);
|
||||
int api_getkey(int mode);
|
||||
void api_end(void);
|
||||
|
||||
unsigned char rgb2pal(int r, int g, int b, int x, int y);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
char *buf;
|
||||
int win, x, y;
|
||||
api_initmalloc();
|
||||
buf = api_malloc(144 * 164);
|
||||
win = api_openwin(buf, 144, 164, -1, "color2");
|
||||
for (y = 0; y < 128; y++) {
|
||||
for (x = 0; x < 128; x++) {
|
||||
buf[(x + 8) + (y + 28) * 144] = rgb2pal(x * 2, y * 2, 0, x, y);
|
||||
}
|
||||
}
|
||||
api_refreshwin(win, 8, 28, 136, 156);
|
||||
api_getkey(1); /*等待按下任意键*/
|
||||
api_end();
|
||||
}
|
||||
|
||||
unsigned char rgb2pal(int r, int g, int b, int x, int y)
|
||||
{
|
||||
static int table[4] = { 3, 1, 0, 2 };
|
||||
int i;
|
||||
x &= 1; /*判断是偶数还是奇数*/
|
||||
y &= 1;
|
||||
i = table[x + y * 2]; /*用来生成中间色的常量*/
|
||||
r = (r * 21) / 256; /* r为0~20*/
|
||||
g = (g * 21) / 256;
|
||||
b = (b * 21) / 256;
|
||||
r = (r + i) / 4; /* r为0~5*/
|
||||
g = (g + i) / 4;
|
||||
b = (b + i) / 4;
|
||||
return 16 + r + g * 6 + b * 36;
|
||||
}
|
||||
Reference in New Issue
Block a user