Hopefully the last adjustments before the first release.

This commit is contained in:
lephe 2017-07-11 13:51:56 +02:00
parent 34e42a03a6
commit 79b78b5345
24 changed files with 480 additions and 315 deletions

7
TODO
View file

@ -14,11 +14,14 @@ Things to do before 1.0:
Things to do later:
- bopti: Implement blending modes for monochrome bitmaps
- clock: Only measure if requires as option, otherwise trust {FTune}
- clock: Handle overclock (relaunch clocks when overclocking)
- clock: Split code into several files, change clock_config_t type
- core: Change interrupt priority using the gint API
- core: Register more interrupts (and understand their parameters)
- core: Remove redundant code linked to environment saves
- core: Review interrupt system (again) - this one is too slow
- display: Try to make this module lighter (lots of code in text section)
- errno: Introduce errno and use it more or less everywhere
- esper: Cleaner playback, synthesizing
- events: Allow customization of keyboard event system (option to return
@ -26,10 +29,12 @@ Things to do later:
- events: Generate keyboard events on-the-fly by reading state arrays,
| allowing both a faster interrupt and avoiding supressing other
| events inside getkey() and multigetkey()
- gray: Same as display, it's quite heavy
- serial: Implement a driver
- stdio: More serious formatted printing functions
- stdio: More serious formatted printing functions and headers
- string: Use cmp/str to implement memchr() (assembler examples)
- string: Do some tests for memcmp() and memcpy()
- string: Lighter functions?
- usb: Implement a driver
Things to investigate:

6
configure vendored
View file

@ -52,11 +52,11 @@ Options that affect the behavior of the library:
use this option when using both the gray engine and --no-syscalls.
Options that customize size limits:
$Cr--atexit-max$C0=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
$Cr--atexit-max=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
Number of exit handlers that can be registered by atexit().
$Cr--timer-slots$C0=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
$Cr--timer-slots=$Cy<integer>$Cg [default:$Cp 16$Cg]$C0
Number of virtual timers that may be registered at the same time.
$Cr--events-queue-size$C0=$Cy<integer>$Cg [default:$Cp 64$Cg]$C0
$Cr--events-queue-size=$Cy<integer>$Cg [default:$Cp 64$Cg]$C0
Number of events simultaneously stored in the event queue.
EOF

View file

@ -1,56 +0,0 @@
# int BFile_Remove(const uint16_t *file)
.global _BFile_Remove
_BFile_Remove:
mov.l 1f, r0
mov.l 2f, r1
jmp @r1
mov #0, r5
1: .long 0x0439
# int BFile_Create(const uint16_t *file, enum { file = 1, folder = 5 },
# int *size)
.global _BFile_Create
_BFile_Create:
mov.l 1f, r0
mov.l 2f, r1
jmp @r1
nop
1: .long 0x0434
# int BFile_Open(const uint16_t *file, int mode)
.global _BFile_Open
_BFile_Open:
mov.l 1f, r0
mov.l 2f, r1
jmp @r1
mov #0, r6
1: .long 0x042c
# int BFile_Close(int handle)
.global _BFile_Close
_BFile_Close:
mov.l 1f, r0
mov.l 2f, r1
jmp @r1
nop
1: .long 0x042d
# int BFile_Write(int handle, void *ram_buffer, int even_size)
.global _BFile_Write
_BFile_Write:
mov.l 1f, r0
mov.l 2f, r1
jmp @r1
nop
1: .long 0x0435
.align 4
# Syscall branch address
2: .long 0x80010070

View file

@ -54,154 +54,6 @@ void printf_test(void)
}
*/
/*
static const unsigned char screen[1024] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 7, 159, 0, 0, 1, 192, 0, 0, 0, 0, 0, 121, 240, 0, 0, 0,
31, 191, 192, 0, 3, 224, 27, 216, 0, 0, 1, 251, 252, 0, 0, 0, 57, 247, 222,
30, 7, 240, 36, 36, 62, 25, 131, 159, 24, 255, 129, 224, 0, 227, 142, 126, 1,
192, 45, 172, 127, 127, 192, 14, 1, 255, 199, 224, 0, 227, 140, 240, 1, 192,
26, 88, 115, 127, 224, 14, 57, 221, 207, 0, 0, 227, 13, 192, 1, 192, 34, 68,
120, 30, 0, 14, 25, 156, 220, 0, 0, 227, 253, 252, 1, 192, 36, 36, 126, 28,
0, 14, 219, 156, 223, 192, 0, 227, 253, 252, 1, 192, 36, 36, 31, 12, 0, 46,
27, 140, 223, 192, 0, 227, 141, 193, 193, 192, 40, 20, 7, 140, 0, 206, 25, 140,
220, 28, 0, 227, 140, 225, 129, 199, 24, 24, 99, 156, 1, 14, 25, 204, 206, 24,
0, 227, 142, 127, 1, 195, 39, 228, 255, 156, 2, 14, 24, 237, 199, 240, 1, 247,
222, 62, 1, 198, 44, 44, 223, 30, 2, 31, 28, 237, 131, 224, 1, 224, 0, 0, 3,
254, 27, 216, 0, 0, 4, 30, 0, 0, 0, 0, 3, 192, 0, 0, 7, 252, 0, 0, 0, 0, 4,
60, 1, 249, 240, 0, 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, 4, 0, 97, 240, 56, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 224, 28, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
4, 0, 47, 192, 30, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 32, 255, 128, 63, 128,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 32, 255, 0, 48, 78, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 15, 176, 255, 0, 112, 49, 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, 8, 56, 255, 0,
96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 98, 8, 60, 255, 0, 224, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 130, 56, 126, 255, 3, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 192,
62, 255, 15, 224, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 14, 191, 255, 192, 0,
0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 6, 129, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1, 0, 0, 6, 0, 255, 192, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 7, 128, 63, 192,
0, 0, 96, 1, 224, 1, 0, 0, 0, 2, 0, 0, 7, 0, 31, 192, 0, 0, 95, 1, 11, 68, 88,
0, 0, 4, 0, 0, 7, 128, 31, 192, 0, 1, 192, 129, 204, 85, 100, 0, 0, 8, 0, 0,
15, 128, 63, 224, 0, 0, 95, 1, 8, 85, 68, 0, 1, 144, 0, 0, 31, 128, 143, 224,
64, 0, 96, 1, 232, 41, 68, 0, 2, 96, 0, 31, 255, 129, 7, 248, 96, 0, 0, 0, 0,
0, 0, 0, 4, 0, 0, 96, 254, 129, 7, 254, 96, 0, 0, 0, 0, 0, 0, 0, 4, 0, 1, 128,
254, 131, 135, 255, 224, 0, 0, 1, 192, 64, 16, 0, 8, 0, 7, 0, 254, 131, 255,
63, 224, 0, 0, 1, 38, 113, 208, 0, 8, 0, 13, 0, 222, 147, 254, 31, 224, 0, 0,
1, 41, 74, 80, 0, 8, 0, 25, 0, 222, 67, 254, 31, 160, 0, 0, 1, 41, 74, 80, 0,
12, 0, 49, 0, 222, 19, 254, 62, 48, 0, 0, 1, 198, 113, 208, 0, 2, 0, 32, 128,
222, 195, 255, 252, 56, 0, 0, 0, 0, 0, 0, 0, 2, 0, 124, 64, 220, 151, 135, 248,
127, 0, 0, 0, 0, 0, 0, 0, 2, 0, 66, 32, 221, 223, 7, 240, 255, 0, 0, 0, 0, 0,
0, 0, 2, 0, 129, 23, 93, 159, 15, 241, 131, 0, 0, 0, 0, 0, 0, 0, 4, 0, 128,
136, 217, 95, 3, 226, 9, 0, 0, 1, 240, 0, 0, 0, 4, 0, 128, 72, 89, 95, 129,
228, 18, 0, 0, 0, 0, 0, 0, 0, 4, 1, 0, 72, 73, 127, 128, 224, 36, 0, 0, 0, 0,
0, 0, 0, 28, 1, 0, 76, 129, 127, 192, 96, 8, 0, 0, 0, 0, 0, 0, 0, 16, 1, 0,
231, 203, 124, 96, 64, 0, 0, 0, 0, 0, 0, 0, 0, 16, 1, 1, 28, 123, 240, 12, 64,
1, 0, 0, 0, 0, 0, 0, 0, 16, 1, 2, 28, 143, 128, 15, 192, 7, 0, 0, 0, 0, 0, 0,
0, 16, 1, 4, 17, 143, 24, 15, 192, 14, 0, 0, 0, 0, 0, 0, 0, 28, 1, 4, 1, 135,
24, 31, 192, 24, 0, 0, 0, 0, 0, 0, 0, 18, 1, 62, 1, 135, 248, 63, 224, 192,
0, 0, 0, 0, 0, 0, 0, 35, 1, 195, 1, 135, 128, 254, 126, 1, 0, 0, 0, 0, 0, 0,
0, 35, 193, 131, 195, 135, 255, 248, 112, 1, 0, 0, 0, 0, 0, 0, 0, 67, 241, 131,
14, 207, 255, 192, 224, 3, 0, 0, 0, 0, 0, 0, 3, 67, 15, 143, 56, 255, 7, 1,
224, 7, 0, 0, 0, 0, 0, 0, 28, 130, 7, 255, 112, 204, 7, 131, 224, 31, 0, 0,
0, 0, 0, 0, 32, 134, 30, 29, 120, 156, 7, 255, 224, 127, 0, 0, 0, 0, 0, 63,
197, 206, 60, 56, 192, 248, 15, 255, 248, 255, 0, 0, 0, 0, 0, 120, 5, 227, 248,
56, 195, 248, 127, 191, 254, 63, 0, 0, 0, 0, 7, 254, 255, 193, 255, 15, 193,
255, 15, 31, 252, 31 };
void ML_bmp_or_cl(const unsigned char *bmp, int x, int y, int width, int height)
{
unsigned short line;
char shift, *screen, *p;
int i, j, real_width, begin_x, end_x, begin_y, end_y;
char bool1=1, bool2=1, bool3;
if(!bmp || x<1-width || x>127 || y<1-height || y>63 || height<1 || width<1) return;
p = (char*)&line;
real_width = (width-1>>3<<3)+8;
if(y < 0) begin_y = -y;
else begin_y = 0;
if(y+height > 64) end_y = 64-y;
else end_y = height;
shift = 8-(x&7);
if(x<0)
{
begin_x = -x>>3;
if(shift != 8) bool1 = 0;
} else begin_x = 0;
if(x+real_width > 128) end_x = 15-(x>>3), bool2 = 0;
else end_x = real_width-1>>3;
bool3 = (end_x == real_width-1>>3);
screen = display_getCurrentVRAM()+(y+begin_y<<4)+(x>>3);
for(i=begin_y ; i<end_y ; i++)
{
if(begin_x < end_x)
{
line = bmp[i*(real_width>>3)+begin_x] << shift;
if(bool1) screen[begin_x] |= *p;
if(shift!=8) screen[begin_x+1] |= *(p+1);
for(j=begin_x+1 ; j<end_x ; j++)
{
line = bmp[i*(real_width>>3)+j] << shift;
screen[j] |= *p;
if(shift!=8) screen[j+1] |= *(p+1);
}
}
line = bmp[i*(real_width>>3)+end_x];
if(bool3) line &= -1<<real_width-width;
line <<= shift;
if(begin_x < end_x || bool1) screen[end_x] |= *p;
if(bool2) screen[end_x+1] |= *(p+1);
screen += 16;
}
}
#include <internals/timer.h>
void debug(void)
{
extern Image res_screen_start;
struct mod_tmu *timer;
int time1, time2;
int i;
timer_get(TIMER_USER, &timer, NULL);
dclear();
ML_bmp_or_cl(screen, 1, 1, 128, 64);
dupdate();
getkey();
dclear();
dimage(&res_screen_start, 1, 1);
dupdate();
getkey();
dclear();
dtext("ML...", 2, 2);
dupdate();
timer_start2(TIMER_USER, 0x0fffffff, TIMER_Po_4, NULL, 0);
for(i = 0; i < 1000; i++) ML_bmp_or_cl(screen, 1, 1, 128, 64);
time1 = timer->TCNT;
timer_stop(TIMER_USER);
time1 = 0x0fffffff - time1;
dclear();
dtext("gint...", 2, 2);
dupdate();
timer_start2(TIMER_USER, 0x0fffffff, TIMER_Po_4, NULL, 0);
for(i = 0; i < 1000; i++) dimage(&res_screen_start, 1, 1);
time2 = timer->TCNT;
timer_stop(TIMER_USER);
time2 = 0x0fffffff - time2;
dclear();
print_hex(time1, 2, 2);
print_hex(time2, 2, 9);
dupdate();
while(getkey() != KEY_EXIT);
}
*/
/*
tlb_debug()
Displays the TLB contents and some information. Only available for
@ -311,15 +163,13 @@ void main_menu(int *category, int *app)
"Clocks and timers",
NULL
};
/*
const char *list_perfs[] = {
"Image rendering",
"Text rendering",
NULL
};
const char *list_debug[] = {
"View TLB (SH3 only)",
NULL
};
*/
const char **list = NULL;
int list_len = 0;
@ -367,22 +217,17 @@ void main_menu(int *category, int *app)
locate(1, 1, "Test list");
list = list_tests;
break;
/*
case 2:
locate(1, 1, "Performance");
list = list_perfs;
break;
case 3:
locate(1, 1, "Debug");
list = list_debug;
break;
*/
default:
print(1, 1, "Tab %d", tab);
break;
}
dimage(0, 56, &res_opt_menu);
dimage_part(0, 56, &res_opt_menu, 0, 0, 42, 8);
if(list)
{
@ -422,22 +267,17 @@ void main_menu(int *category, int *app)
index = 0;
scroll = 0;
break;
case KEY_F3:
/* case KEY_F3:
*category = 2;
*app = 1;
return;
*/
/* case KEY_F3:
if(tab == 2) break;
tab = 2;
index = 0;
scroll = 0;
break;
case KEY_F4:
if(tab == 3) break;
tab = 3;
index = 0;
scroll = 0;
break;
/* case KEY_F6:;
void screen(void);
screen();
break;
*/
case KEY_UP:
if(list && list_len > 1)
@ -514,36 +354,18 @@ int main(void)
case 0x0105: test_rtc(); break;
case 0x0106: test_timer(); break;
case 0x0201: /* perf_bopti(); */ break;
case 0x0201: perf_bopti(); break;
case 0x0202: /* perf_tales(); */ break;
case 0x0301: /* if(isSH3()) debug_tlb(); */ break;
}
}
return 0;
}
static void crash(void)
/*
#include <bfile.h>
void screen(void)
{
__asm__(
"mov #0, r0 \n\t"
"ldc r0, vbr \n\t"
"trapa #1 "
);
}
static void screen(void)
{
enum { File = 1, Folder = 5 };
enum { Read = 0x01, Write = 0x02, ReadWrite = Read | Write };
int BFile_Remove(const uint16_t *file);
int BFile_Create(const uint16_t *file, int type, int *size);
int BFile_Open(const uint16_t *file, int mode);
int BFile_Close(int handle);
int BFile_Write(int handle, const void *ram_buffer, int even_size);
const uint8_t bmp_header[0x7e] = {
0x42, 0x4d, 0x7e, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x6c, 0x00,
@ -567,8 +389,8 @@ static void screen(void)
int size = 0x7e + 1024;
BFile_Remove(file);
BFile_Create(file, File, &size);
int handle = BFile_Open(file, Write);
BFile_Create(file, BFile_File, &size);
int handle = BFile_Open(file, BFile_WriteOnly);
BFile_Write(handle, bmp_header, 0x7e);
void *vram = (void *)display_getCurrentVRAM() + 1024;
for(int i = 1; i <= 64; i++)
@ -577,3 +399,58 @@ static void screen(void)
}
BFile_Close(handle);
}
void screengray(void)
{
const uint8_t bmp_header[0x7e] = {
0x42, 0x4d, 0x7e, 0x04, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x6c, 0x00,
0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x40, 0x00,
0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x13, 0x0b,
0x00, 0x00, 0x13, 0x0b, 0x00, 0x00, 0x01, 0x00,
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x42, 0x47,
0x52, 0x73, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xff, 0xff, 0xff, 0x00,
};
uint16_t file[] = { '\\', '\\', 'f', 'l', 's', '0', '\\', 'g', 's',
'c', 'r', 'e', 'e', 'n', '#', '.', 'b', 'm', 'p', 0x00 };
int size = 0x7e + 1024;
void *vram;
int handle;
gupdate();
file[14] = 'l';
BFile_Remove(file);
BFile_Create(file, BFile_File, &size);
handle = BFile_Open(file, BFile_WriteOnly);
BFile_Write(handle, bmp_header, 0x7e);
vram = (void *)gray_lightVRAM() + 1024;
for(int i = 1; i <= 64; i++)
{
BFile_Write(handle, vram - 16 * i, 16);
}
BFile_Close(handle);
file[14] = 'd';
BFile_Remove(file);
BFile_Create(file, BFile_File, &size);
handle = BFile_Open(file, BFile_WriteOnly);
BFile_Write(handle, bmp_header, 0x7e);
vram = (void *)gray_darkVRAM() + 1024;
for(int i = 1; i <= 64; i++)
{
BFile_Write(handle, vram - 16 * i, 16);
}
BFile_Close(handle);
gupdate();
}
*/

179
demo/perf_bopti.c Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 13 KiB

BIN
demo/resources/town.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

View file

@ -19,7 +19,7 @@
---------------------------------------------------------
zelda.bmp 86 * 280 Mono -
isometric.bmp 37 * 27 Mono Full
Mono Greater
- - Mono Greater
---------------------------------------------------------
*/
@ -60,6 +60,7 @@ static image_t *select(image_t *current)
res_swords,
res_zelda,
res_isometric;
extern image_t res_screen;
struct {
image_t *img;
@ -71,6 +72,7 @@ static image_t *select(image_t *current)
{ &res_swords, "Swords", "Gray Alpha" },
{ &res_zelda, "Zelda", "Mono" },
{ &res_isometric, "Isometric", "Mono Alpha" },
{ &res_screen, "TLT", "Mono" },
{ NULL, NULL, NULL }
};
@ -81,6 +83,7 @@ static image_t *select(image_t *current)
while(images[items].img) items++;
keyboard_setRepeatRate(625, 125);
gray_start();
while(1)
@ -141,8 +144,10 @@ void test_bopti(void)
int black_bg = 0;
int x = 0, y = 0;
while(1)
{
keyboard_setRepeatRate(25, 25);
if(img && (img->format & channel_light))
{
gray_start();
@ -152,8 +157,7 @@ void test_bopti(void)
if(img) gimage(x, y, img);
grect(0, 55, 127, 63, color_white);
gimage(0, 56, &res_opt_bitmap);
gupdate();
gimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8);
}
else if(img)
{
@ -164,8 +168,7 @@ void test_bopti(void)
if(img) dimage(x, y, img);
drect(0, 55, 127, 63, color_white);
dimage(0, 56, &res_opt_bitmap);
dupdate();
dimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8);
}
else
{
@ -174,10 +177,36 @@ void test_bopti(void)
dclear();
locate(3, 3, "No image selected");
dimage(0, 56, &res_opt_bitmap);
dimage_part(0, 56, &res_opt_bitmap, 0, 0, 96, 8);
dupdate();
}
if(img)
{
int width, height;
getwh(img, &width, &height);
if(x < 0) print(1, 4, "\x01");
if(x + width > 128) print(21, 4, "\x02");
if(img->format & channel_light)
{
if(y < 0) gimage_part(61, 0, &res_opt_bitmap,
122, 0, 6, 8);
if(y + height > 64) gimage_part(61, 48,
&res_opt_bitmap, 116, 0, 6, 8);
gupdate();
}
else
{
if(y < 0) dimage_part(61, 0, &res_opt_bitmap,
122, 0, 6, 8);
if(y + height > 64) dimage_part(61, 48,
&res_opt_bitmap, 116, 0, 6, 8);
dupdate();
}
}
do
{
leave = 1;
@ -185,6 +214,7 @@ void test_bopti(void)
switch(getkey())
{
case KEY_EXIT:
keyboard_setRepeatRate(625, 125);
gray_stop();
return;
@ -192,22 +222,14 @@ void test_bopti(void)
img = select(img);
getxy(img, &x, &y);
break;
case KEY_F5:
case KEY_F2:
black_bg = !black_bg;
break;
case KEY_UP:
y--;
break;
case KEY_DOWN:
y++;
break;
case KEY_LEFT:
x--;
break;
case KEY_RIGHT:
x++;
break;
case KEY_UP: y++; break;
case KEY_DOWN: y--; break;
case KEY_LEFT: x++; break;
case KEY_RIGHT: x--; break;
default:
leave = 0;
@ -216,6 +238,7 @@ void test_bopti(void)
while(!leave);
}
keyboard_setRepeatRate(625, 125);
gray_stop();
return;
}

View file

@ -8,10 +8,9 @@
Lets the user set the gray delays and see the results.
*/
static void draw(int delay1, int delay2, int selected)
static void draw(int delay1, int delay2, int selected, int gran)
{
extern image_t res_opt_gray;
extern font_t res_font_modern;
uint32_t *vl = gray_lightVRAM();
uint32_t *vd = gray_darkVRAM();
@ -25,15 +24,16 @@ static void draw(int delay1, int delay2, int selected)
vd[offset] = -(i < 32);
}
text_configure(&res_font_modern, color_black);
gtext(13, 17, "light");
gtext(13, 31, "dark");
print(2, 3, "light %d", delay1);
print(2, 4, " dark %d", delay2);
print(2, 6, "Mode: \x04%d", gran);
text_configure(NULL, color_black);
print(4, 4, "%d", delay1);
print(4, 6, "%d", delay2);
locate(3, selected ? 6 : 4, "\x02");
int lengths[2] = {
4 - (delay1 < 1000),
4 - (delay2 < 1000)
};
print(8, 3 + selected, "\x01");
print(9 + lengths[selected], 3 + selected, "\x02");
gimage(0, 56, &res_opt_gray);
gupdate();
@ -44,6 +44,7 @@ void test_gray(void)
int delays[2]; // { light, dark }
int key, changed = 1;
int selected = 0;
int gran = 1;
gray_getDelays(delays, delays + 1);
gray_start();
@ -53,11 +54,11 @@ void test_gray(void)
if(changed)
{
gray_setDelays(delays[0], delays[1]);
draw(delays[0], delays[1], selected);
draw(delays[0], delays[1], selected, gran);
}
changed = 0;
key = getkey_opt(getkey_repeat_arrow_keys, 25);
key = getkey_opt(getkey_default, 25);
if(key == KEY_EXIT) break;
changed = 1;
@ -65,31 +66,33 @@ void test_gray(void)
switch(key)
{
case KEY_F1:
selected = !selected;
break;
case KEY_F2:
delays[0] = 912;
delays[1] = 1343;
break;
case KEY_F3:
case KEY_F2:
delays[0] = 993;
delays[1] = 1609;
break;
case KEY_F4:
case KEY_F3:
delays[0] = 860;
delays[1] = 1298;
break;
case KEY_F5:
if(gran >= 100) gran = 1;
else gran *= 10;
case KEY_UP:
delays[selected] += 10;
selected = 0;
break;
case KEY_DOWN:
if(delays[selected] >= 110) delays[selected] -= 10;
break;
case KEY_RIGHT:
delays[selected]++;
selected = 1;
break;
case KEY_LEFT:
if(delays[selected] >= 101) delays[selected]--;
if(delays[selected] - gran >= 100)
delays[selected] -= gran;
break;
case KEY_RIGHT:
if(delays[selected] + gran < 10000)
delays[selected] += gran;
break;
default:
changed = 0;

BIN
gscreen.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
gscreend.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
gscreenl.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

74
include/bfile.h Normal file
View file

@ -0,0 +1,74 @@
//---
//
// gint core module: BFile interface
//
// Syscall-based interface to the BFile driver (which I would never dare
// to re-write considering how much the storage memory filesystem is an
// awful mess).
//
//---
#ifndef _BFILE_H
#define _BFILE_H
/*
BFile_Remove()
Remove a file from the filesystem. The path must be encoded as two-byte
fontcharacters!
*/
int BFile_Remove(const uint16_t *file);
/*
BFile_Create()
Creates an entry in the filesystem (two-byte fontcharacter path) of the
given type. The size pointer must point to the file size for files, and
may be NULL for folders.
*/
enum BFile_EntryType
{
BFile_File = 1,
BFile_Folder = 5,
};
int BFile_Create(const uint16_t *file, enum BFile_EntryType type, int *size);
/*
BFile_Open()
Opens an existing file (two-byte fontcharacter path) with the required
mode, and returns a handle (positive integer) on success, or an
negative integer on error.
*/
enum BFile_OpenMode
{
BFile_ReadOnly = 0x01,
BFile_WriteOnly = 0x02,
BFile_ReadWrite = BFile_ReadOnly | BFile_WriteOnly,
};
int BFile_Open(const uint16_t *file, enum BFile_OpenMode mode);
/*
BFile_Close()
Closes an open file.
*/
int BFile_Close(int handle);
/*
BFile_Write()
Writes data to a file. The data is taken from the second-argument
buffer. The size to write is given as third argument.
WARNING: Always write an even number of bytes or you're in for trouble!
*/
int BFile_Write(int handle, const void *ram_buffer, int even_size);
/*
BFile_Read()
Reads from an open file. The second and third arguments indicate where
to store data and how much to read. The location from where the data is
read depends on the value of `whence`:
- If `whence` >= 0, it is considered as the absolute location (in
bytes) of the requested data in the file;
- If `whence` == -1, BFile_Read() reads from the current virtual
position in the file.
*/
int BFile_Read(int handle, void *ram_buffer, int size, int whence);
#endif // _BFILE_H

View file

@ -1,6 +1,9 @@
//---
//
// gint core module: syscalls
//
// Some of the functionality still requires interacting with the system.
//
//---
#ifndef _INTERNALS_SYSCALLS_H

View file

@ -177,6 +177,9 @@ typedef enum
// Shorthand for the four previous properties.
getkey_repeat_all_keys = 0xf0,
// Default combination of getkey().
getkey_default = 0x1f,
} getkey_option_t;
/*

View file

@ -1,5 +1,5 @@
#ifndef _MODULES_INTERRUPTS
#define _MODULES_INTERRUPTS
#ifndef _MODULES_INTERRUPTS_H
#define _MODULES_INTERRUPTS_H
#include <modules/macros.h>
#include <stdint.h>
@ -685,4 +685,4 @@ typedef union
// Here's what you'll need to use.
extern mod_intc_t INTC;
#endif // _MODULE_INTERRUPTS
#endif // _MODULE_INTERRUPTS_H

View file

@ -22,8 +22,18 @@
/* Return to menu */
.global ___system_menu
/* Storage memory filesystem */
.global _BFile_Remove
.global _BFile_Create
.global _BFile_Open
.global _BFile_Close
.global _BFile_Write
.global _BFile_Read
/* Dynamic memory allocation */
___malloc:
mov.l syscall_table, r2
mov.l 1f, r0
@ -45,6 +55,8 @@ ___realloc:
nop
1: .long 0xe6d
/* OS version access */
___get_os_version:
mov.l syscall_table, r2
mov.l 1f, r0
@ -126,6 +138,58 @@ ___system_menu:
.memcpy:
.long _memcpy
/* BFile driver */
# int BFile_Remove(const uint16_t *file)
_BFile_Remove:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
mov #0, r5
1: .long 0x0439
# int BFile_Create(const uint16_t *file, enum { file = 1, folder = 5 },
# int *size)
_BFile_Create:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
nop
1: .long 0x0434
# int BFile_Open(const uint16_t *file, int mode)
_BFile_Open:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
mov #0, r6
1: .long 0x042c
# int BFile_Close(int handle)
_BFile_Close:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
nop
1: .long 0x042d
# int BFile_Write(int handle, const void *ram_buffer, int even_size)
_BFile_Write:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
nop
1: .long 0x0435
# int BFile_Read(int handle, void *ram_buffer, int size, int whence)
_BFile_Read:
mov.l 1f, r0
mov.l syscall_table, r1
jmp @r1
nop
1: .long 0x0432
.align 4

View file

@ -20,7 +20,7 @@ void grect(int x1, int y1, int x2, int y2, color_t operator)
// Doing things in this order will be slower, but man, I can't stand
// writing that many lines of code for such a simple task. It will be
// terribly heavy in the binary file...
while(lvideo > lbase) for(int i = 0; i < 4; i++) switch(operator)
while(lvideo > lbase) for(int i = 3; i >= 0; i--) switch(operator)
{
case color_white:
*--lvideo &= ~masks[i];

View file

@ -8,6 +8,7 @@
#include <display.h>
#include <internals/init.h>
#include <internals/modules.h>
#include <modules/interrupts.h>
/* We need some more functionality to generate these */
#ifdef GINT_STARTUP_LOG
@ -15,7 +16,6 @@
#include <clock.h>
#include <events.h>
#include <internals/keyboard.h>
#include <modules/interrupts.h>
#ifndef GINT_NO_SYSCALLS
#include <internals/syscalls.h>
@ -226,7 +226,7 @@ __attribute__((section(".pretext.entry"))) int start(void)
init();
#ifdef GINT_STARTUP_LOG
/* Keep this visible for a second or so */
/* Keep this visible if a key is kept pressed */
keyboard_interrupt();
if(pollevent().type != event_none) getkey();
#endif

View file

@ -12,17 +12,7 @@
*/
int getkey(void)
{
return getkey_opt(
getkey_shift_modifier |
getkey_alpha_modifier |
getkey_manage_backlight |
#ifndef GINT_NO_SYSCALLS
getkey_task_switch |
#endif
getkey_repeat_arrow_keys,
0
);
return getkey_opt(getkey_default, 0);
}
/*

View file

@ -1 +1 @@
beta-0.9-581
beta-0.9-584