Skip to content

Commit

Permalink
增加更多的颜色(1)
Browse files Browse the repository at this point in the history
  • Loading branch information
yourtion committed May 13, 2016
1 parent d84bab7 commit 908570a
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 3 deletions.
10 changes: 9 additions & 1 deletion 25_day/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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:@: \
Expand All @@ -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

# 其他指令
Expand Down
27 changes: 27 additions & 0 deletions 25_day/color.c
Original file line number Diff line number Diff line change
@@ -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();
}
14 changes: 12 additions & 2 deletions 25_day/graphic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 908570a

Please sign in to comment.