> compile NEMU
221220000 张三 Linux zzy 5.15.146.1-microsoft-standard-WSL2 #1 SMP Thu Jan 11 04:09:03 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux 00:53:25 up 8 days, 53 min, 1 user, load average: 0.32, 0.28, 0.27
This commit is contained in:
@ -26,7 +26,7 @@ void init_proc() {
|
||||
|
||||
// load program here
|
||||
void naive_uload(PCB *pcb, const char *filename);
|
||||
naive_uload(NULL, "/bin/nslider");
|
||||
naive_uload(NULL, "/bin/menu");
|
||||
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ ARCHIVE = $(WORK_DIR)/build/$(NAME)-$(ISA).a
|
||||
|
||||
### Add default libraries for ISA != native
|
||||
ifneq ($(ISA), native)
|
||||
LIBS += libc libos libndl libbmp libminiSDL
|
||||
LIBS += libc libos libndl libbmp libminiSDL libbdf
|
||||
CFLAGS += -U_FORTIFY_SOURCE # fix compile error in Newlib on ubuntu
|
||||
else
|
||||
WL = -Wl,
|
||||
@ -166,7 +166,7 @@ $(CLEAN_ALL):
|
||||
.PHONY: clean-all $(CLEAN_ALL)
|
||||
|
||||
### Build fsimg and ramdisk for Nanos-lite
|
||||
APPS = nslider
|
||||
APPS = nslider menu
|
||||
TESTS = dummy hello file-test timer-test event-test bmp-test
|
||||
|
||||
fsimg: $(addprefix apps/, $(APPS)) $(addprefix tests/, $(TESTS))
|
||||
|
@ -6,24 +6,43 @@
|
||||
|
||||
void SDL_BlitSurface(SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, SDL_Rect *dstrect) {
|
||||
assert(dst && src);
|
||||
assert(dst->format->BitsPerPixel == src->format->BitsPerPixel == 32);
|
||||
assert(dst->format->BitsPerPixel == src->format->BitsPerPixel);
|
||||
|
||||
SDL_Rect rect = {
|
||||
.w = srcrect ? srcrect->w : src->w,
|
||||
.h = srcrect ? srcrect->h : src->h,
|
||||
.x = dstrect ? dstrect->x : 0,
|
||||
.y = dstrect ? dstrect->y : 0,
|
||||
.x = srcrect ? srcrect->x : 0,
|
||||
.y = srcrect ? srcrect->y : 0,
|
||||
};
|
||||
// TODO NOT FULL VERSION
|
||||
|
||||
int byte_per_pixel = src->format->BytesPerPixel;
|
||||
for (int i = 0; i < rect.h; i ++) {
|
||||
memcpy(
|
||||
(uint32_t*)dst->pixels + NDL_SCREEN_IDX(rect.x, rect.y, dst->w, dst->h),
|
||||
(uint32_t*)src->pixels + NDL_SCREEN_IDX(srcrect->x, srcrect->y, rect.x, rect.y),
|
||||
rect.w * sizeof(uint32_t));
|
||||
dst->pixels + byte_per_pixel * NDL_SCREEN_IDX(
|
||||
dstrect ? dstrect->x : 0, (dstrect ? dstrect->y : 0) + i, dst->w, dst->h),
|
||||
src->pixels + byte_per_pixel * NDL_SCREEN_IDX(
|
||||
rect.x, rect.y + i, src->w, src->h),
|
||||
rect.w * byte_per_pixel);
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, uint32_t color) {
|
||||
assert(0);
|
||||
SDL_Rect rect = {
|
||||
.w = dstrect ? dstrect->w : dst->w,
|
||||
.h = dstrect ? dstrect->h : dst->h,
|
||||
.x = dstrect ? dstrect->x : 0,
|
||||
.y = dstrect ? dstrect->y : 0,
|
||||
};
|
||||
int byte_per_pixel = dst->format->BytesPerPixel;
|
||||
for (int i = 0; i < rect.h; i ++) {
|
||||
for (int j = 0; j < rect.w; j ++) {
|
||||
memcpy(
|
||||
dst->pixels + byte_per_pixel * NDL_SCREEN_IDX(rect.x + j, rect.y + i, dst->w, dst->h),
|
||||
&color,
|
||||
byte_per_pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void SDL_UpdateRect(SDL_Surface *s, int x, int y, int w, int h) {
|
||||
|
@ -23,7 +23,7 @@ int NDL_PollEvent(char *buf, int len) {
|
||||
exit(-1);
|
||||
}
|
||||
size_t ret = fread(buf, 1, len, fd);
|
||||
if (ret) printf("NDL_PollEvent read %d bytes is %s", ret, buf);
|
||||
// if (ret) printf("NDL_PollEvent read %d bytes is %s", ret, buf);
|
||||
fclose(fd);
|
||||
return ret;
|
||||
}
|
||||
@ -77,6 +77,8 @@ void NDL_OpenCanvas(int *w, int *h) {
|
||||
_get_screen(&dev_w, &dev_h);
|
||||
screen_w = (*w == 0 || *w > dev_w) ? dev_w : *w;
|
||||
screen_h = (*h == 0 || *h > dev_h) ? dev_h : *h;
|
||||
*w = screen_w;
|
||||
*h = screen_h;
|
||||
// printf("NDL_OpenCanvas: %d,%d, dev %d,%d\n", screen_w, screen_h, dev_w, dev_h);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user