mirror of
https://github.com/yourtion/30dayMakeOS.git
synced 2026-02-02 17:49:01 +08:00
增加更多的颜色(1)
This commit is contained in:
@@ -169,10 +169,17 @@ beepup.bim : beepup.obj a_nask.obj Makefile
|
||||
beepup.hrb : beepup.bim Makefile
|
||||
$(BIM2HRB) beepup.bim beepup.hrb 40k
|
||||
|
||||
color.bim : color.obj a_nask.obj Makefile
|
||||
$(OBJ2BIM) @$(RULEFILE) out:color.bim stack:1k map:color.map \
|
||||
color.obj a_nask.obj
|
||||
|
||||
color.hrb : color.bim Makefile
|
||||
$(BIM2HRB) color.bim color.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
|
||||
lines.hrb walk.hrb noodle.hrb beepdown.hrb beepup.hrb color.hrb
|
||||
$(EDIMG) imgin:../z_tools/fdimg0at.tek \
|
||||
wbinimg src:ipl10.bin len:512 from:0 to:0 \
|
||||
copy from:haribote.sys to:@: \
|
||||
@@ -195,6 +202,7 @@ haribote.img : ipl10.bin haribote.sys Makefile \
|
||||
copy from:noodle.hrb to:@: \
|
||||
copy from:beepdown.hrb to:@: \
|
||||
copy from:beepup.hrb to:@: \
|
||||
copy from:color.hrb to:@: \
|
||||
imgout:haribote.img
|
||||
|
||||
# 其他指令
|
||||
|
||||
27
25_day/color.c
Normal file
27
25_day/color.c
Normal file
@@ -0,0 +1,27 @@
|
||||
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);
|
||||
|
||||
void HariMain(void)
|
||||
{
|
||||
char *buf;
|
||||
int win, x, y, r, g, b;
|
||||
api_initmalloc();
|
||||
buf = api_malloc(144 * 164);
|
||||
win = api_openwin(buf, 144, 164, -1, "color");
|
||||
for (y = 0; y < 128; y++) {
|
||||
for (x = 0; x < 128; x++) {
|
||||
r = x * 2;
|
||||
g = y * 2;
|
||||
b = 0;
|
||||
buf[(x + 8) + (y + 28) * 144] = 16 + (r / 43) + (g / 43) * 6 + (b / 43) * 36;
|
||||
}
|
||||
}
|
||||
api_refreshwin(win, 8, 28, 136, 156);
|
||||
api_getkey(1); /*等待按下任意键*/
|
||||
api_end();
|
||||
}
|
||||
@@ -22,10 +22,20 @@ void init_palette(void)
|
||||
0x00, 0x84, 0x84, /* 14:浅暗蓝 */
|
||||
0x84, 0x84, 0x84 /* 15:暗灰 */
|
||||
};
|
||||
unsigned char table2[216 * 3];
|
||||
int r, g, b;
|
||||
set_palette(0, 15, table_rgb);
|
||||
for (b = 0; b < 6; b++) {
|
||||
for (g = 0; g < 6; g++) {
|
||||
for (r = 0; r < 6; r++) {
|
||||
table2[(r + g * 6 + b * 36) * 3 + 0] = r * 51;
|
||||
table2[(r + g * 6 + b * 36) * 3 + 1] = g * 51;
|
||||
table2[(r + g * 6 + b * 36) * 3 + 2] = b * 51;
|
||||
}
|
||||
}
|
||||
}
|
||||
set_palette(16, 231, table2);
|
||||
return;
|
||||
|
||||
/* C语言中的static char语句只能用于数据,相当于汇编中的DB指令 */
|
||||
}
|
||||
|
||||
void set_palette(int start, int end, unsigned char *rgb)
|
||||
|
||||
Reference in New Issue
Block a user