From 60d533203340b4e17726fe90a504451908d17efd Mon Sep 17 00:00:00 2001 From: tracer-ics2023 Date: Wed, 25 Sep 2024 19:51:16 +0800 Subject: [PATCH] =?UTF-8?q?>=20=20compile=20NEMU=20221220000=20=E5=BC=A0?= =?UTF-8?q?=E4=B8=89=20Linux=20zzy=205.15.146.1-microsoft-standard-WSL2=20?= =?UTF-8?q?#1=20SMP=20Thu=20Jan=2011=2004:09:03=20UTC=202024=20x86=5F64=20?= =?UTF-8?q?x86=5F64=20x86=5F64=20GNU/Linux=20=2019:51:16=20up=207=20days,?= =?UTF-8?q?=2019:51,=20=201=20user,=20=20load=20average:=200.13,=200.21,?= =?UTF-8?q?=200.18?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nanos-lite/src/proc.c | 2 +- navy-apps/Makefile | 4 ++-- navy-apps/apps/nslider/slides/convert.sh | 1 + navy-apps/apps/nslider/src/main.cpp | 2 +- navy-apps/libs/libminiSDL/src/video.c | 17 +++++++++++++++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/nanos-lite/src/proc.c b/nanos-lite/src/proc.c index f769d34..1a55beb 100644 --- a/nanos-lite/src/proc.c +++ b/nanos-lite/src/proc.c @@ -26,7 +26,7 @@ void init_proc() { // load program here void naive_uload(PCB *pcb, const char *filename); - naive_uload(NULL, "/bin/bmp-test"); + naive_uload(NULL, "/bin/nslider"); } diff --git a/navy-apps/Makefile b/navy-apps/Makefile index 4603f5a..544bf07 100644 --- a/navy-apps/Makefile +++ b/navy-apps/Makefile @@ -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 +LIBS += libc libos libndl libbmp libminiSDL 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 = +APPS = nslider TESTS = dummy hello file-test timer-test event-test bmp-test fsimg: $(addprefix apps/, $(APPS)) $(addprefix tests/, $(TESTS)) diff --git a/navy-apps/apps/nslider/slides/convert.sh b/navy-apps/apps/nslider/slides/convert.sh index 1335310..1c58661 100644 --- a/navy-apps/apps/nslider/slides/convert.sh +++ b/navy-apps/apps/nslider/slides/convert.sh @@ -1,5 +1,6 @@ #!/bin/bash +# sudo vim /etc/ImageMagick-6/policy.xml convert slides.pdf \ -sharpen "0x1.0" \ -type truecolor -resize 400x300\! slides.bmp diff --git a/navy-apps/apps/nslider/src/main.cpp b/navy-apps/apps/nslider/src/main.cpp index 40e29a0..8280473 100644 --- a/navy-apps/apps/nslider/src/main.cpp +++ b/navy-apps/apps/nslider/src/main.cpp @@ -12,7 +12,7 @@ // gg - first page // number of slides -const int N = 10; +const int N = 42; // slides path pattern (starts from 0) const char *path = "/share/slides/slides-%d.bmp"; diff --git a/navy-apps/libs/libminiSDL/src/video.c b/navy-apps/libs/libminiSDL/src/video.c index fdd319a..fb9338e 100644 --- a/navy-apps/libs/libminiSDL/src/video.c +++ b/navy-apps/libs/libminiSDL/src/video.c @@ -7,12 +7,29 @@ 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); + SDL_Rect rect = { + .w = srcrect == NULL ? src->w : srcrect->w, + .h = srcrect == NULL ? src->h : srcrect->h, + .x = dstrect == NULL ? 0 : dstrect->x, + .y = dstrect == NULL ? 0 : dstrect->y, + }; + + for (int i = 0; i < rect.h; i ++) { + memcpy(dst->pixels + (rect.y + i) * dst->w + rect.x, + src->pixels + (srcrect->y + i) * src->w + srcrect->x, rect.w); + } } void SDL_FillRect(SDL_Surface *dst, SDL_Rect *dstrect, uint32_t color) { } void SDL_UpdateRect(SDL_Surface *s, int x, int y, int w, int h) { + assert(s->format->BitsPerPixel == 32); + if (x == 0 && y == 0 && w == 0 && h == 0) { + w = s->w; + h = s->h; + } + NDL_DrawRect((uint32_t*)s->pixels, x, y, w, h); } // APIs below are already implemented.