Skip to content

Commit

Permalink
Update source to beta5.4
Browse files Browse the repository at this point in the history
  • Loading branch information
NuVanDibe committed Apr 6, 2022
1 parent a07a863 commit 8cce1c0
Show file tree
Hide file tree
Showing 46 changed files with 557 additions and 188 deletions.
4 changes: 2 additions & 2 deletions bm2ppm.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def readfile(name):

def toRGB(pixel):
color = unpack("<h", pixel)[0]
red = ((color>>10)&31)<<3
red = ((color>>0)&31)<<3
green = ((color>>5)&31)<<3
blue = ((color>>0)&31)<<3
blue = ((color>>10)&31)<<3
return chr(red) + chr(green) + chr(blue)

if __name__ == "__main__":
Expand Down
Binary file modified libfc_visoly_xg1/libflashcart.a
Binary file not shown.
Binary file modified libfc_xrom/libflashcart.a
Binary file not shown.
Binary file modified libpogo/lib/libpogo.a
Binary file not shown.
Binary file modified libpogo/lib/libpogod.a
Binary file not shown.
2 changes: 1 addition & 1 deletion shell2/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ WIDGETS = widgets/textbar.o widgets/tricontainer.o widgets/listview.o widgets/te

CART_OBJFILES = main.o filetype.o filesys.o

FULL_OBJFILES = bmpview.o jpgview.o jpeg.o iwram.o sram_convert.o widgets/textreader.o
FULL_OBJFILES = bmview.o bmpview.o jpgview.o jpeg.o iwram.o sram_convert.o widgets/textreader.o

COMMON_OBJFILES = crt0.o text.o unapack.o bitmap.o window.o backdrop.o \
guiparser.o savesystem.o rle.o msgbox.o users.o \
Expand Down
Binary file modified shell2/bitmap.o
Binary file not shown.
Binary file modified shell2/bmpview.o
Binary file not shown.
135 changes: 135 additions & 0 deletions shell2/bmview.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@

#include <pogo.h>
#include "misc.h"

#define BM 0x4D42
#define BMHEADERSIZE 8

void bm_view(char *fname);

static uint16 *bm_ptr;
static int bm_h;
static int bm_w;
static int bm_size;

int prepare_bm(uint16 *ptr)
{
int sfd;

if (!ptr || ptr[0] != BM || ptr[1] != 0x10)
return 1;

bm_w = ptr[2];
bm_h = ptr[3];

if (bm_size != bm_w * bm_h * 2 + BMHEADERSIZE)
return 2;

sfd = open("/dev/screen", 0);
ioctl(sfd, SC_SETMODE, 2);
close(sfd);

bm_ptr = &ptr[4];
return 0;
}

#define MIN(a,b) (a<b ? a : b)
#define MAX(a,b) (a>b ? a : b)

void render_bm(int x, int y)
{
int wi;
uint16 *src, *dst;

int w = MIN(bm_w, 240);
int h = MIN(bm_h, 160);

if((x+240) > bm_w)
x = (bm_w-240);
if((y+160) > bm_h)
y = (bm_h-160);

if(x < 0) x = 0;
if(y < 0) y = 0;

src = &bm_ptr[y*bm_w+x];
dst = (uint16 *)0x06000000; //vram

while(h--)
{
wi = w;
while(wi--)
*dst++ = *src++;
dst += (240 - w);
}
}

void bm_view(char *fname)
{
int c, l, r, fd, quit = 0;
int x=0, y=0;
int dx=0, dy=0;
int speed = 8;
uint16 *bm;
uint32 *p = (uint32 *)0x06000000;

fd = open(fname, 0);
bm = (uint16 *)lseek(fd, 0, SEEK_MEM);
bm_size = lseek(fd, 0, SEEK_END);
close(fd);

r = prepare_bm(bm);

if (r) {
l = 120*160;
while(l--)
*p++ = 0x7fff7fff;
} else {
l = 120*160;
while(l--)
*p++ = 0;
while(!quit)
{
render_bm(x, y);

c = getchar();

switch(c&0x7F)
{
case RAWKEY_L:
speed = c&0x80 ? 8 : 128;
break;
case RAWKEY_RIGHT:
dx = c&0x80 ? 0 : speed;
break;
case RAWKEY_LEFT:
dx = c&0x80 ? 0 : -speed;
break;
case RAWKEY_UP:
dy = c&0x80 ? 0 : -speed;
break;
case RAWKEY_DOWN:
dy = c&0x80 ? 0 : speed;
break;
case RAWKEY_A:
case RAWKEY_B:
if(c != (RAWKEY_A|0x80))
quit = 1;
break;
}
x += dx;
y += dy;
if((x+240) > bm_w)
x = (bm_w-240);
if((y+160) > bm_h)
y = (bm_h-160);

if(x < 0) x = 0;
if(y < 0) y = 0;
}
}

fd = open("/dev/screen", 0);
ioctl(fd, SC_SETMODE, 2);
close(fd);
}
Binary file added shell2/bmview.o
Binary file not shown.
11 changes: 3 additions & 8 deletions shell2/filesys.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,9 @@ void qsort(void *array, int count, int size, int cf(void *a, void *b))
static int get_dir(char *name, DirList *list)
{
int i;
char *p;
DIR *dir;
struct dirent *result;
struct stat sbuf;
//struct stat sbuf;

i = 0;
dir = opendir(name);
Expand All @@ -97,14 +96,10 @@ static int get_dir(char *name, DirList *list)
if(settings_get(SF_HIDEDOT) && list[i].entry.d_name[0] == '.')
i--;
else {
p = &name[strlen(name)];
*p = '/';
strcpy(p+1, list[i].entry.d_name);
stat(name, &sbuf);
//fprintf(stderr, "get_dir(%s, %p); // (%s, %d)\n", name, list, list[i].entry.d_name, list[i].entry.d_size);
//fprintf(stderr, "stat(%s, ...); // (..., %hd, ...)\n", name, sbuf.st_mode);
*p = '\0';
list[i].type = (sbuf.st_mode & S_IFDIR) ? 1 : 0;
//*p = '\0';
list[i].type = (list[i].entry.d_size & 0x80000000) ? 1 : 0;
}
}
closedir(dir);
Expand Down
94 changes: 80 additions & 14 deletions shell2/filetype.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern int clipsize;
extern uint16 marked;

int execute_mb_joined(char *fname, int decompression, int keys);
void bm_view(char *fname);
void bmp_view(char *fname);
void bmz_view(char *fname);
void bmap_view(char *fname);
Expand All @@ -24,9 +25,11 @@ void jpe_view(char *fname);
extern void reset(void);

static BitMap **icon_set;
static BitMap *settings_icn = NULL;
static int settings_iconidx = -1;

static int ftcount = 1;
static FileType *filetypes[50];
static FileType *filetypes[100];

extern ListView *MainList;
//extern TextBar *StatusBar;
Expand Down Expand Up @@ -244,6 +247,13 @@ int show_text(char *cmd, char *fname, int keys)
return 1;
}

int showbm(char *cmd, char *fname, int keys)
{
bm_view(fname);
MainScreen->firstWindow->widget->flags |= WFLG_REDRAW;
return 2;
}

int showbmp(char *cmd, char *fname, int keys)
{
bmp_view(fname);
Expand Down Expand Up @@ -326,6 +336,7 @@ void filetype_readtypes(FILE *fp)
f->command = NULL;
f->compare_func = check_extention;
f->handle_func = NULL;
f->textcolor = NULL;
f->saver = 0;

ptr[-1] = 0;
Expand All @@ -340,10 +351,8 @@ void filetype_readtypes(FILE *fp)
i = atoi(ptr);
//fprintf(stderr, "ICON:%d\n", i);

if (icon_set)
f->icon = icon_set[i];
else
f->icon = NULL;
f->iconidx = i;
f->icon = NULL;
while(isdigit(*ptr++));
}
else
Expand All @@ -355,6 +364,7 @@ void filetype_readtypes(FILE *fp)
//fp2 = fopen(p, "rb");
//f->icon = bitmap_readbm(fp2);
//fclose(fp2);
f->iconidx = -1;
f->icon = bitmap_loadbm(p);
}

Expand All @@ -372,15 +382,31 @@ void filetype_readtypes(FILE *fp)
//fprintf(stderr, "SAVER:%d\n", f->saver);
while(isdigit(*q++));
*ptr = 0;
ptr = q-1;
ptr = q - 1;
}

if(*ptr == ' ' && *(ptr+1) == '$')
{
*ptr = 0;
ptr += 2;
i = gethex(ptr);
while (isalnum(*ptr++));
q = ptr--;
f->textcolor = malloc(sizeof(Color));
f->textcolor->r = (i>>16) & 0xff;
f->textcolor->g = (i>>8) & 0xff;
f->textcolor->b = i & 0xff;
f->textcolor->a = 0;
}

/* The rest of the line is the description, if it exists */
while((*q != 10) && (*q != 13)) q++;
*q = 0;
f->desc = malloc(strlen(ptr+1)+1);
strcpy(f->desc, ptr+1);
//fprintf(stderr, "DESC:%s\n", ptr+1);
if (*q && *q != 10 && *q != 13) {
/* The rest of the line is the description, if it exists */
while ((*q != 10) && (*q != 13)) q++;
*q = 0;
f->desc = malloc(strlen(ptr+1)+1);
strcpy(f->desc, ptr+1);
//fprintf(stderr, "DESC:%s\n", ptr+1);
}
}
*ptr = 0;
/* Set correct internal handler for filetype */
Expand All @@ -401,8 +427,9 @@ void filetype_readtypes(FILE *fp)
}
else
if(strcmp(p, "SET") == 0)
{
settings_icon(f->icon);
{
settings_icn = f->icon;
settings_iconidx = f->iconidx;
ftcount--;
}
else
Expand Down Expand Up @@ -430,6 +457,9 @@ void filetype_readtypes(FILE *fp)
if(strcmp(p, "FNT") == 0)
f->handle_func = set_font;
else
if(strcmp(p, "BM") == 0)
f->handle_func = showbm;
else
if(strcmp(p, "BMP") == 0)
f->handle_func = showbmp;
else
Expand Down Expand Up @@ -464,6 +494,37 @@ void filetype_set_iconset(BitMap **icons)
icon_set = icons;
}

void filetype_set_icons(void)
{
FileType *f;
int i;
for (i=1; i<ftcount; i++)
{
f = filetypes[i];
if (f->iconidx >= 0 && icon_set)
f->icon = icon_set[f->iconidx];
}
if (settings_iconidx >= 0 && icon_set) {
settings_icn = icon_set[settings_iconidx];
}
settings_icon(settings_icn);
}

int filetype_font(DirList *entry)
{
return (filetypes[filetype_lookup(entry)]->handle_func == set_font);
}

int filetype_bm(DirList *entry)
{
return (filetypes[filetype_lookup(entry)]->handle_func == showbm);
}

int filetype_theme(DirList *entry)
{
return (filetypes[filetype_lookup(entry)]->handle_func == set_theme);
}

int filetype_lookup(DirList *entry)
{
int i;
Expand Down Expand Up @@ -496,3 +557,8 @@ BitMap *filetype_icon(int type)
{
return filetypes[type]->icon;
}

Color *filetype_textcolor(int type)
{
return filetypes[type]->textcolor;
}
7 changes: 7 additions & 0 deletions shell2/filetype.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

typedef struct
{
int iconidx;
BitMap *icon;
Color *textcolor;
int (*handle_func)(char *data, char *fname, int keys);
char data[8];
int (*compare_func)(char *data, DirList *entry);
Expand All @@ -17,11 +19,16 @@ typedef struct
} FileType;

void filetype_register(char *ext, BitMap *bm, int handler);
int filetype_bm(DirList *entry);
int filetype_font(DirList *entry);
int filetype_theme(DirList *entry);
int filetype_lookup(DirList *entry);
int filetype_handle(char *fname, int type, int keys);

BitMap *filetype_icon(int type);
Color *filetype_textcolor(int type);
void filetype_readtypes(FILE *fp);
void filetype_set_iconset(BitMap **icons);
void filetype_set_icons(void);

#endif
Loading

0 comments on commit 8cce1c0

Please sign in to comment.