]> Git repositories of Nishi - tewi.git/commitdiff
just generate pkg containing the config
authorNishi <nishi@nishi.boats>
Sun, 29 Sep 2024 07:13:35 +0000 (07:13 +0000)
committerNishi <nishi@nishi.boats>
Sun, 29 Sep 2024 07:13:35 +0000 (07:13 +0000)
git-svn-id: file:///raid/svn-personal/tewi/trunk@197 8739d7e6-ffea-ec47-b151-bdff447c6205

Makefile
Platform/ps3.mk
Server/Makefile
Server/main.c
ps3.sh [deleted file]

index 4e10966ee963033f76af3b0afe3c7dc0d3b0dedc..deea9d371ece044b469ab9319836a788fe29cd7f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ FLAGS = PWD=$(PWD) PLATFORM=$(PLATFORM) PREFIX=$(PREFIX)
 
 .PHONY: all format clean ./Server ./Common ./Module get-version
 
-all: ./Server $(MODULE) ./Tool/genconf ./Tool/itworks
+all: ./Server $(MODULE)
 
 ./Tool/option: ./Tool/option.c config.h
        cc -o $@ ./Tool/option.c
@@ -22,7 +22,7 @@ all: ./Server $(MODULE) ./Tool/genconf ./Tool/itworks
 ./Tool/itworks: ./Tool/itworks.c config.h
        cc -o $@ ./Tool/itworks.c
 
-./Server:: ./Common ./Tool/option
+./Server:: ./Common ./Tool/option ./Tool/genconf ./Tool/itworks
        $(MAKE) -C $@ $(FLAGS) EXTOBJS="`./Tool/option objs ../`" EXTLIBS="`./Tool/option libs ../`" EXTCFLAGS="`./Tool/option cflags ../`" EXTLDFLAGS="`./Tool/option ldflags ../`"
 
 ./Module:: ./Common
index ba0e58ac3e2ce39e5c9f438b89678f3374843d32..55ebc8e6fb947a4f1f50036d012c876403f70ea2 100644 (file)
@@ -4,9 +4,9 @@ PREFIX = /dev_hdd0/game/TEWI_00-0/USRDIR
 
 CC = ppu-gcc
 AR = ppu-ar
-CFLAGS = -g -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/ps3dev/ppu/include
-LDFLAGS = -L /usr/local/ps3dev/ppu/lib
-LIBS = -lnet -lsysmodule -lsysutil -lrt -llv2 -lrsx -lgcm_sys
+CFLAGS = -g -DPREFIX=\"$(PREFIX)\" -I $(PWD)/Common -I /usr/local/ps3dev/ppu/include -I /usr/local/ps3dev/portlibs/ppu/include
+LDFLAGS = -L /usr/local/ps3dev/ppu/lib -L /usr/local/ps3dev/portlibs/ppu/lib 
+LIBS = -lnet -lsysmodule -lsysutil -lrt -llv2 -lrsx -lgcm_sys -lpng -lm -lz
 EXEC = .elf
 LIB = .so
 MODULE =
index fe49d7ecfa48bee3e37de721582521da1af9cc7c..b726d4a8063eaee1e6f23e144f7b82feb69a1f31 100644 (file)
@@ -27,8 +27,13 @@ tewi.self: tewi_strip$(EXEC)
        fself tewi_strip$(EXEC) tewi.fake.self
 
 tewi.pkg: tewi.self
-       mkdir -p pkg/USRDIR
+       mkdir -p pkg/USRDIR/etc
+       mkdir -p pkg/USRDIR/www
        cp ../Binary/ps3.png pkg/ICON0.PNG
+       ../Tool/genconf /dev_hdd0/game/TEWI_00-0/USRDIR lib/tewi so > pkg/USRDIR/etc/tewi.conf
+       cp ../Binary/pbtewi.gif pkg/USRDIR/www/
+       convert '../Binary/pbtewi.gif[0]' pkg/USRDIR/pbtewi.png
+       ../Tool/itworks > pkg/USRDIR/www/index.html
        make_self_npdrm tewi_strip$(EXEC) pkg/USRDIR/EBOOT.BIN UP0001-TEWI_00-0000000000000000
        sfo.py --title "Tewi HTTPd" --appid "TEWI" -f /usr/local/ps3dev/bin/sfo.xml pkg/PARAM.SFO
        pkg.py --contentid UP0001-TEWI_00-0000000000000000 pkg/ $@
index 3af5b8d219c8ae0e9552068eaff29f86958bb0ae..75ae059c475fd269f607676ab3f74eaa1ae5c454 100644 (file)
@@ -53,6 +53,7 @@ PSP_MAIN_THREAD_ATTR(PSP_THREAD_ATTR_USER);
 #include <malloc.h>
 #include <sys/thread.h>
 #include <stdarg.h>
+#include <png.h>
 
 #define printf(...) tt_printf(__VA_ARGS__)
 #define STDERR_LOG(...) tt_printf(__VA_ARGS__)
@@ -329,7 +330,7 @@ void tt_putstr(const char* str) {
                                }
                        }
                        for(x = 0; x < tt_width; x++) {
-                               tvram[(tt_height - 1) * tt_width + x] = 0;
+                               tvram[(tt_height - 1) * tt_width + x] = 0x20;
                        }
                }
        }
@@ -337,17 +338,18 @@ void tt_putstr(const char* str) {
 
 void tt_putchar(struct rsx_buffer* buffer, int x, int y, uint8_t c) {
        int i, j;
+       if(c == 0) return;
        if(c < 0x20) c = 0x20;
        if(c >= 0x7f) c = 0x20;
-       for(i = 0; i < 7; i++) {
-               uint8_t l = font[(c - 0x20) * 8 + i];
-               for(j = 0; j < 5; j++) {
-                       uint32_t c = 0;
+       for(i = 0; i < 8; i++) {
+               uint8_t l = i == 7 ? 0 : font[(c - 0x20) * 8 + i];
+               for(j = 0; j < 6; j++) {
+                       uint32_t col = 0;
                        if(l & (1 << 7)) {
-                               c = 0xffffff;
+                               col = 0xffffff;
                        }
                        l = l << 1;
-                       buffer->ptr[(y * 8 + i) * buffer->width + x * 6 + j] = c;
+                       buffer->ptr[(y * 8 + i) * buffer->width + x * 6 + j] = col;
                }
        }
 }
@@ -362,7 +364,7 @@ void draw(struct rsx_buffer* buffer, int current) {
        }
 }
 
-#define BUFFERS 2
+#define BUFFERS 1
 gcmContextData* ctx;
 struct rsx_buffer buffers[BUFFERS];
 
@@ -413,6 +415,66 @@ void tt_printf(const char* tmpl, ...) {
        tt_putstr(log);
 }
 
+void show_png(void) {
+       FILE* f = fopen(PREFIX "/pbtewi.png", "rb");
+       if(f == NULL) {
+               f = fopen(PREFIX "/../ICON0.PNG", "rb");
+       }
+       if(f == NULL) return;
+       png_structp png = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
+       png_infop info = png_create_info_struct(png);
+       if(setjmp(png_jmpbuf(png))) {
+               png_destroy_read_struct(&png, &info, NULL);
+               fclose(f);
+               return;
+       }
+
+       png_init_io(png, f);
+       png_read_info(png, info);
+
+       int width = png_get_image_width(png, info);
+       int height = png_get_image_height(png, info);
+       int depth = png_get_bit_depth(png, info);
+       int type = png_get_color_type(png, info);
+
+       if(depth == 16) png_set_strip_16(png);
+       if(type == PNG_COLOR_TYPE_PALETTE) png_set_palette_to_rgb(png);
+       if(type == PNG_COLOR_TYPE_GRAY && depth < 8) png_set_expand_gray_1_2_4_to_8(png);
+       if(png_get_valid(png, info, PNG_INFO_tRNS)) png_set_tRNS_to_alpha(png);
+       if(type == PNG_COLOR_TYPE_RGB || type == PNG_COLOR_TYPE_GRAY || type == PNG_COLOR_TYPE_PALETTE) png_set_filler(png, 0xFF, PNG_FILLER_AFTER);
+       if(type == PNG_COLOR_TYPE_GRAY || type == PNG_COLOR_TYPE_GRAY_ALPHA) png_set_gray_to_rgb(png);
+       png_read_update_info(png, info);
+       png_bytep* rows = (png_bytep*)malloc(sizeof(*rows) * (height));
+
+       int i;
+
+       for(i = 0; i < height; i++) {
+               rows[i] = (png_byte*)malloc(png_get_rowbytes(png, info));
+       }
+
+       png_read_image(png, rows);
+
+       for(i = 0; i < height; i++) {
+               int j;
+               for(j = 0; j < width; j++) {
+                       png_bytep byte = &(rows[i][j * 4]);
+                       uint32_t col = (byte[0] << 16) | (byte[1] << 8) | (byte[2]);
+                       int k;
+                       for(k = 0; k < BUFFERS; k++) {
+                               buffers[k].ptr[buffers[k].width * i - width + j] = col;
+                       }
+               }
+       }
+
+       png_destroy_read_struct(&png, &info, NULL);
+       fclose(f);
+
+       for(i = 0; i < height; i++) {
+               free(rows[i]);
+       }
+       free(rows);
+}
+
 #endif
 
 int main(int argc, char** argv) {
@@ -560,6 +622,7 @@ int main(int argc, char** argv) {
        sys_ppu_thread_t id;
        sysThreadCreate(&id, text_thread, NULL, 1500, 0x1000, THREAD_JOINABLE, "TextThread");
        printf("PS3 Bootstrap, Tewi/%s\n", tw_get_version());
+       show_png();
        netInitialize();
 #elif defined(__ps2sdk__)
        SifInitRpc(0);
diff --git a/ps3.sh b/ps3.sh
deleted file mode 100755 (executable)
index b9a89cc..0000000
--- a/ps3.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-# $Id$
-export PS3DEV="/usr/local/ps3dev"
-export PSL1GHT=$PS3DEV
-export PATH=$PATH:${PS3DEV}/bin:${PS3DEV}/ppu/bin:${PS3DEV}/spu/bin
-cat config.h.tmpl | sed -E 's/#undef (NO_SSL)/#define \1/g' > config.h
-rm -rf TEWI_00-0
-make PLATFORM=ps3 DESTDIR=TEWI_00-0/ install || exit 1
-mkdir -p TEWI_00-0/USRDIR
-mv TEWI_00-0/dev_hdd0/game/TEWI_00-0/USRDIR/* TEWI_00-0/USRDIR/
-rm -rf TEWI_00-0/USRDIR/lib TEWI_00-0/USRDIR/bin
-rm -rf TEWI_00-0/dev_hdd0
-make_self_npdrm Server/tewi_strip.elf TEWI_00-0/USRDIR/EBOOT.BIN UP0001-TEWI_00-0000000000000000
-sfo.py --title "Tewi HTTPd" --appid "TEWI" -f /usr/local/ps3dev/bin/sfo.xml TEWI_00-0/PARAM.SFO
-cp Binary/ps3.png TEWI_00-0/ICON0.PNG
-echo "Tewi HTTPd $(make get-version) for PS3" > TEWI_00-0/README
-echo "========================" >> TEWI_00-0/README
-echo "To install, just copy this \`TEWI_00-0' folder into your /game of PS3 HDD0." >> TEWI_00-0/README
-cat TEWI_00-0/README
-rm -f tewidist.zip
-zip -rv tewidist.zip TEWI_00-0
-rm -rf TEWI_00-0