Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f3c1cf8
Showing
11 changed files
with
687 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
SUBDIRS = installer launcher demo | ||
|
||
all: subdirs | ||
|
||
subdirs: | ||
for dir in $(SUBDIRS); do \ | ||
$(MAKE) -C $$dir; \ | ||
done | ||
|
||
clean: subdirs_clean | ||
|
||
subdirs_clean: | ||
for dir in $(SUBDIRS); do \ | ||
$(MAKE) -C $$dir clean; \ | ||
done | ||
|
||
.PHONY: subdirs subdirs_clean $(SUBDIRS) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
BASELIBC = ../../Baselibc | ||
|
||
CC = mipsel-sde-elf-gcc | ||
LD = $(CC) | ||
CFLAGS = -G0 -mno-gpopt -Wall -W -march=mips32r2 | ||
LDFLAGS = -G0 -nostartfiles -nostdlib -T actsemi.ld -Wl,-n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include ../config.mk | ||
TARGET = demo.elf | ||
|
||
CFLAGS += -O2 -I$(BASELIBC)/include | ||
LIBS = -L$(BASELIBC) -lc | ||
OBJS = demo.o | ||
|
||
$(TARGET): $(OBJS) | ||
$(LD) $(LDFLAGS) -o $@ $< $(LIBS) | ||
|
||
clean: | ||
rm -f $(OBJS) $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ENTRY(_init_proc) | ||
|
||
SECTIONS | ||
{ | ||
. = 0x51400000; | ||
/* . = 0x52000000; */ | ||
.init : { *(.init) } | ||
.text : { *(.text) } | ||
.fini : { *(.fini) } | ||
. = ALIGN(4); | ||
.dlsym : { *(.dlsym) } | ||
.dlstr : { *(.dlstr) } | ||
. = ALIGN(0x20000); | ||
.ctors : { *(.ctors) } | ||
.dtors : { *(.dtors) } | ||
. = ALIGN(4); | ||
.data : { *(.data); *(.sdata); *(.rodata*) } | ||
. = ALIGN(4); | ||
.sbss : { KEEP(*(.sbss)); *(.scommon) } | ||
. = ALIGN(4); | ||
/* _bss_start = .; */ | ||
.bss : { KEEP(*(.bss)) } | ||
/* _bss_end = .; */ | ||
end = .; _end = .; __end = .; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,230 @@ | ||
#include <stdint.h> | ||
#include <string.h> | ||
#include <stdio.h> | ||
|
||
#define VERSION "R1.02" | ||
|
||
//#define DEBUG_VERBOSE | ||
|
||
int open(const char *pathname, int flags, ...); | ||
int write(int fd, const void *buf, unsigned int count); | ||
int close(int fd); | ||
|
||
int usleep(int usecs); | ||
|
||
void api_install(int id, void **apitbl); | ||
unsigned int get_count(void); | ||
|
||
#define O_WRONLY 0x0001 | ||
#define O_CREAT 0x0200 | ||
#define O_TRUNC 0x0400 | ||
|
||
#define SEEK_END 2 | ||
|
||
int p1CoreLoop(void); | ||
void p1EnqueueKey(void *input); | ||
int p1_control(int cmd, void *data); | ||
|
||
void *p1apitbl[] = { | ||
p1CoreLoop, | ||
p1EnqueueKey, | ||
p1_control | ||
}; | ||
const void *p1apitbl_p = p1apitbl; | ||
|
||
char t[256]; /* text buffer */ | ||
int fd; /* debug output fd */ | ||
|
||
void __attribute__ ((section (".init"))) _init_proc(void) | ||
{ | ||
fd = open("/mnt/disk0/test.txt", O_WRONLY | O_CREAT | O_TRUNC); | ||
#define HELLO_WORLD "Hello, World, version " VERSION "!\n" | ||
write(fd, HELLO_WORLD, sizeof(HELLO_WORLD) - 1); | ||
|
||
api_install(7, p1apitbl); | ||
} | ||
|
||
void __attribute__ ((section (".fini"))) _term_proc(void) | ||
{ | ||
} | ||
|
||
uint32_t general_plugin_info = 0; | ||
uint32_t *get_plugin_info(void) | ||
{ | ||
return &general_plugin_info; | ||
} | ||
|
||
const char *P1_SO_VERSION = VERSION; | ||
|
||
struct rect { | ||
uint32_t w; | ||
uint32_t h; | ||
}; | ||
|
||
struct rect screen_size; | ||
uint16_t *screen_fb; | ||
int redraw = 0; | ||
|
||
int p1CoreLoop(void) | ||
{ | ||
static unsigned int last_run = 0; | ||
unsigned int elapsed = get_count() - last_run; | ||
if (elapsed < 16) { | ||
//if (elapsed < 6) | ||
// usleep(5000); | ||
return 0; | ||
} | ||
last_run = get_count(); | ||
static int y = 0; | ||
static int dir = 1; | ||
#ifdef DEBUG_VERBOSE | ||
sprintf(t, "loop at %u\n", last_run); | ||
write(fd, t, strlen(t)); | ||
#endif | ||
memset(screen_fb, 0, 320 * 240 * 2); | ||
memset(screen_fb + y * 320, 0xff, 20 * 320 * 2); | ||
y += dir; | ||
if (y >= 220 || y == 0) | ||
dir = -dir; | ||
redraw = 1; | ||
return 0; | ||
} | ||
|
||
void p1EnqueueKey(void *input) | ||
{ | ||
#ifdef DEBUG_VERBOSE | ||
write(fd, "key\n", 4); | ||
#endif | ||
} | ||
|
||
struct cmd_22 { | ||
uint32_t key_code_mode; | ||
uint32_t key_code[0x10]; | ||
uint32_t key_file_len; | ||
}; | ||
|
||
int cmd_22(struct cmd_22 *data) | ||
{ | ||
return 0; | ||
} | ||
|
||
int max_screen_dimensions(struct rect *r) | ||
{ | ||
sprintf(t, "screen size %d/%d\n", (int)r->w, (int)r->h); | ||
write(fd, t, strlen(t)); | ||
screen_size = *r; | ||
return 0; | ||
} | ||
|
||
struct rect_form { | ||
uint32_t w; | ||
uint32_t h; | ||
uint32_t format; | ||
}; | ||
|
||
int get_our_dimensions(struct rect_form *rf) | ||
{ | ||
rf->w = 320; | ||
rf->h = 240; | ||
rf->format = 1; | ||
return 0; | ||
} | ||
|
||
int p1_control(int cmd, void *data) | ||
{ | ||
int ret; | ||
#ifdef DEBUG_VERBOSE | ||
sprintf(t, "cmd %d data 0x%x\n", cmd, (unsigned int)data); | ||
write(fd, t, strlen(t)); | ||
#endif | ||
|
||
switch (cmd) { | ||
case 0: /* init */ | ||
return 0; | ||
case 1: /* reset */ | ||
write(fd, "reset!\n", 7); | ||
return 0; | ||
case 2: /* game name? */ | ||
sprintf(t, "name %s\n", (char *)data); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
case 3: | ||
write(fd, "shutdown\n", 9); | ||
close(fd); | ||
return 0; | ||
case 4: | ||
sprintf(t, "another name %s\n", (char *)data); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
case 7: /* sound enable */ | ||
sprintf(t, "sound enable %d\n", *((int *)data)); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
case 13: /* get our dimensions, format */ | ||
return get_our_dimensions((struct rect_form *)data); | ||
case 14: | ||
#ifdef DEBUG_VERBOSE | ||
sprintf(t, "framebuffer addr 0x%x\n", *((unsigned int *)data)); | ||
write(fd, t, strlen(t)); | ||
#endif | ||
screen_fb = *((uint16_t **)data); | ||
return 0; | ||
case 15: | ||
return max_screen_dimensions((struct rect*)data); | ||
case 16: /* screen mode */ | ||
sprintf(t, "screen mode %d\n", *((int *)data)); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
case 17: /* get redraw flag */ | ||
#ifdef DEBUG_VERBOSE | ||
sprintf(t, "redraw?\n"); | ||
write(fd, t, strlen(t)); | ||
#endif | ||
ret = redraw; | ||
redraw = 0; | ||
return ret; | ||
case 18: /* input mode */ | ||
sprintf(t, "input mode %d\n", *((int *)data)); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
case 22: | ||
return cmd_22((struct cmd_22 *)data); | ||
default: | ||
sprintf(t, "unknown command %d, data 0x%x\n", cmd, (unsigned int)data); | ||
write(fd, t, strlen(t)); | ||
return 0; | ||
} | ||
} | ||
|
||
#define SYSCALL(name, no) \ | ||
asm(".global " #name "\n" \ | ||
#name ":\n" \ | ||
"li $v1, " #no "\n" \ | ||
"syscall 0\n"); | ||
|
||
SYSCALL(open, 0x60000) | ||
SYSCALL(write, 0x60003) | ||
SYSCALL(lseek, 0x60004) | ||
SYSCALL(close, 0x60001) | ||
SYSCALL(api_install, 0x10028) | ||
//SYSCALL(malloc, 0x1003a) | ||
//SYSCALL(free, 0x1003b) | ||
SYSCALL(get_count, 0x10038) | ||
SYSCALL(usleep, 0x70084) | ||
|
||
asm( | ||
".section .dlsym,\"a\"\n" | ||
".word P1_SO_VERSION\n" | ||
".word _dlstr_P1_SO_VERSION\n" | ||
".word get_plugin_info\n" | ||
".word _dlstr_get_plugin_info\n" | ||
".word p1apitbl\n" | ||
".word _dlstr_api_table\n" | ||
".section .dlstr,\"a\"\n" | ||
"_dlstr_P1_SO_VERSION:\n" | ||
".string \"P1_SO_VERSION\\0\"\n" | ||
"_dlstr_get_plugin_info:\n" | ||
".string \"get_plugin_info\\0\"\n" | ||
"_dlstr_api_table:\n" | ||
".string \"api_table\\0\"\n" | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
include ../config.mk | ||
TARGET = installer.elf | ||
|
||
CFLAGS += -O2 -I$(BASELIBC)/include | ||
LIBS = -L$(BASELIBC) -lc | ||
OBJS = installer.o | ||
|
||
$(TARGET): $(OBJS) | ||
$(LD) $(LDFLAGS) -o $@ $< $(LIBS) | ||
|
||
clean: | ||
rm -f $(OBJS) $(TARGET) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ENTRY(_init_proc) | ||
|
||
SECTIONS | ||
{ | ||
. = 0x51400000; | ||
.init : { *(.init) } | ||
.text : { *(.text) } | ||
.fini : { *(.fini) } | ||
. = ALIGN(4); | ||
.dlsym : { *(.dlsym) } | ||
.dlstr : { *(.dlstr) } | ||
. = ALIGN(0x20000); | ||
.ctors : { *(.ctors) } | ||
.dtors : { *(.dtors) } | ||
. = ALIGN(4); | ||
.data : { *(.data); *(.sdata); *(.rodata*) } | ||
. = ALIGN(4); | ||
.sbss : { KEEP(*(.sbss)); *(.scommon) } | ||
. = ALIGN(4); | ||
/* _bss_start = .; */ | ||
.bss : { KEEP(*(.bss)) } | ||
/* _bss_end = .; */ | ||
end = .; _end = .; __end = .; | ||
} |
Oops, something went wrong.