Skip to content

Commit 2e97259

Browse files
the owl lives
1 parent 3514938 commit 2e97259

17 files changed

Lines changed: 222 additions & 25 deletions

File tree

CMakeLists.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,13 @@ copy_config(limine.sys limine/limine.sys)
5151
copy_config(limine-cd.bin limine/limine-cd.bin)
5252
copy_config(limine-efi.bin limine/limine-cd-efi.bin)
5353

54-
copy_image(brainbox.png brainbox.png)
55-
copy_image(brainbox.gif brainbox.gif)
56-
copy_image(computer.jpg computer.jpg)
54+
file(GLOB image_list ${CMAKE_SOURCE_DIR}/os/images/*)
55+
set(IMAGE_TARGETS "")
56+
foreach (image ${image_list})
57+
get_filename_component(image_name ${image} NAME)
58+
copy_image(${image_name} ${image_name})
59+
list(APPEND IMAGE_TARGETS "img_${image_name}")
60+
endforeach()
5761

5862
symbols("kernel.sym" "kernel.bin")
5963

@@ -71,9 +75,11 @@ foreach (basic_library ${basic_library_list})
7175
copy_basic_lib(${basic_name} ${basic_name})
7276
endforeach()
7377
file(GLOB keymap_list ${CMAKE_SOURCE_DIR}/os/system/keymaps/*.keymap)
78+
set(KEYMAP_TARGETS "")
7479
foreach (keymap ${keymap_list})
7580
get_filename_component(keymap_name ${keymap} NAME)
7681
copy_system_keymap(${keymap_name} ${keymap_name})
82+
list(APPEND KEYMAP_TARGETS "keymap_${keymap_name}")
7783
endforeach()
7884
set(TIMEZONE_TARGETS "")
7985
file(GLOB_RECURSE timezone_list RELATIVE ${CMAKE_SOURCE_DIR}/os/system/timezones ${CMAKE_SOURCE_DIR}/os/system/timezones/*)

cmake/custom_targets.cmake

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -136,20 +136,10 @@ function(symbols TARGETFILE SOURCEFILE)
136136
add_dependencies(SYMBOLS "kernel.bin")
137137
endfunction()
138138

139-
function(symbols TARGETFILE SOURCEFILE)
140-
set(FILENAME "${CMAKE_BINARY_DIR}/iso/kernel.bin")
141-
set(OUTNAME "${CMAKE_BINARY_DIR}/iso/${TARGETFILE}")
142-
add_custom_command(OUTPUT ${OUTNAME}
143-
COMMAND /bin/nm -a "${CMAKE_BINARY_DIR}/iso/kernel.bin" | sort -d > "${CMAKE_BINARY_DIR}/iso/kernel.sym"
144-
DEPENDS ${FILENAME})
145-
add_custom_target(SYMBOLS ALL DEPENDS ${OUTNAME})
146-
add_dependencies(SYMBOLS "kernel.bin")
147-
endfunction()
148-
149139
function(iso TARGETFILE SOURCEFILE)
150140
set(OUTNAME "${CMAKE_BINARY_DIR}/${TARGETFILE}")
151141
add_custom_command(OUTPUT ${OUTNAME}
152142
COMMAND php ../build-boot-image.php && xorriso -as mkisofs --quiet -b limine-cd.bin -joliet -no-emul-boot -boot-load-size 4 -boot-info-table -V "RETROROCKET" --protective-msdos-label "${CMAKE_BINARY_DIR}/iso" -o "${CMAKE_BINARY_DIR}/rr.iso"
153-
DEPENDS SYMBOLS "kernel.bin" "RUN_run.sh" "DEBUG_debug.sh" ${basic_program_list} ${basic_library_list} ${keymap_list} ${TIMEZONE_TARGETS})
143+
DEPENDS SYMBOLS "kernel.bin" "RUN_run.sh" "DEBUG_debug.sh" ${basic_program_list} ${basic_library_list} ${KEYMAP_TARGETS} ${TIMEZONE_TARGETS} ${IMAGE_TARGETS})
154144
add_dependencies(ISO SYMBOLS "kernel.bin" "RUN_run.sh" "DEBUG_debug.sh" "config_limine.cfg")
155145
endfunction()

include/basic/datetime.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,3 +102,7 @@ char* basic_time(struct basic_ctx* ctx);
102102
* @param ctx The BASIC context.
103103
*/
104104
void settimezone_statement(struct basic_ctx* ctx);
105+
106+
char* basic_get_upstr(struct basic_ctx* ctx);
107+
108+
int64_t basic_getupsecs(struct basic_ctx* ctx);

include/clock.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,3 +165,5 @@ uint64_t day_of_year(uint64_t year, uint8_t month, uint8_t day);
165165
* @return Weekday index (0–6).
166166
*/
167167
int get_weekday_from_date(datetime_t* dt);
168+
169+
uint64_t uptime_secs();

include/installer.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
/**
2+
* @file installer.h
3+
* @author Craig Edwards
4+
* @brief Installer functions and definitions
5+
* @copyright Copyright (c) 2012-2025
6+
*/
17
#pragma once
28
#include <kernel.h>
39

os/images/owl.png

2.85 KB
Loading

os/programs/about.rrbasic

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
SPRITELOAD brain,"/images/owl.png"
2+
AUTOFLIP FALSE
3+
SPRTOP=CURRENTY*16
4+
COLOUR 14
5+
PRINT " Retro Rocket"
6+
COLOUR 7
7+
PRINT " ────────────"
8+
COLOUR 14
9+
PRINT " OS: ";
10+
COLOUR 7
11+
PRINT "Retro Rocket 1.0"
12+
COLOUR 14
13+
PRINT " Kernel: ";
14+
COLOUR 7
15+
PRINT "1.0"
16+
COLOUR 14
17+
PRINT " Uptime: ";
18+
COLOUR 7
19+
PRINT UPTIME$
20+
COLOUR 14
21+
PRINT " Shell: ";
22+
COLOUR 7
23+
PRINT "rocketsh-2.0"
24+
COLOUR 14
25+
PRINT " Memory: ";
26+
COLOUR 7
27+
M_MEGS = MEMFREE / 1024 / 1024
28+
MT_MEGS = MEMORY / 1024 / 1024
29+
PRINT M_MEGS; "MiB / "; MT_MEGS ; "MiB"
30+
PRINT " ";
31+
GRADLEFT=CURRENTX*9
32+
GRADTOP=CURRENTY*16+16
33+
FOR N = 0 TO 9
34+
PRINT ""
35+
NEXT
36+
PLOT brain,32,SPRTOP
37+
X = GRADLEFT
38+
W = 128
39+
H = 32
40+
FOR I = 0 TO W - 1
41+
P = (I * 1530) / (W - 1)
42+
SEG = P / 255
43+
T = P - (SEG * 255)
44+
IF SEG = 0 THEN
45+
R = 255
46+
G = T
47+
B = 0
48+
ENDIF
49+
IF SEG = 1 THEN
50+
R = 255 - T
51+
G = 255
52+
B = 0
53+
ENDIF
54+
IF SEG = 2 THEN
55+
R = 0
56+
G = 255
57+
B = T
58+
ENDIF
59+
IF SEG = 3 THEN
60+
R = 0
61+
G = 255 - T
62+
B = 255
63+
ENDIF
64+
IF SEG = 4 THEN
65+
R = T
66+
G = 0
67+
B = 255
68+
ENDIF
69+
IF SEG = 5 THEN
70+
R = 255
71+
G = 0
72+
B = 255 - T
73+
ENDIF
74+
GCOL RGB(R, G, B)
75+
LINE X, GRADTOP, X, GRADTOP + H
76+
X = X + 1
77+
NEXT
78+
AUTOFLIP TRUE

src/basic/datetime.c

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,74 @@ int64_t basic_gethour(struct basic_ctx* ctx)
2424
return date.hour;
2525
}
2626

27+
int64_t basic_getupsecs(struct basic_ctx* ctx)
28+
{
29+
return uptime_secs();
30+
}
31+
32+
char* basic_get_upstr(struct basic_ctx* ctx)
33+
{
34+
uint64_t s = uptime_secs();
35+
const uint64_t MIN = 60ULL;
36+
const uint64_t HOUR = 60ULL * MIN;
37+
const uint64_t DAY = 24ULL * HOUR;
38+
const uint64_t YEAR = 365ULL * DAY;
39+
40+
uint64_t yr = s / YEAR;
41+
s %= YEAR;
42+
uint64_t day = s / DAY;
43+
s %= DAY;
44+
uint64_t hr = s / HOUR;
45+
s %= HOUR;
46+
uint64_t min = s / MIN;
47+
s %= MIN;
48+
uint64_t sec = s;
49+
50+
struct { uint64_t v; const char *label; } parts[] = {
51+
{ yr, "yr" },
52+
{ day, "day" },
53+
{ hr, "hr" },
54+
{ min, "min" },
55+
{ sec, "sec" }
56+
};
57+
58+
char buffer[MAX_STRINGLEN];
59+
size_t pos = 0;
60+
int started = 0;
61+
62+
for (size_t i = 0; i < sizeof(parts)/sizeof(parts[0]); i++) {
63+
if (!parts[i].v) {
64+
continue;
65+
}
66+
67+
if (started && pos < sizeof(buffer) - 1) {
68+
buffer[pos++] = ' ';
69+
}
70+
71+
int n = snprintf(buffer + pos, sizeof(buffer) - pos,
72+
"%lu %s",
73+
parts[i].v, parts[i].label);
74+
if (n < 0) {
75+
n = 0;
76+
}
77+
if (n >= sizeof(buffer) - pos) {
78+
pos = sizeof(buffer) - 1;
79+
break;
80+
}
81+
pos += n;
82+
started = 1;
83+
}
84+
85+
if (!started) {
86+
(void)snprintf(buffer, sizeof(buffer), "0 sec");
87+
} else {
88+
buffer[pos] = '\0';
89+
}
90+
91+
return (char*)gc_strdup(ctx, buffer);
92+
}
93+
94+
2795
int64_t basic_getminute(struct basic_ctx* ctx)
2896
{
2997
PARAMS_START;

src/basic/function.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct basic_int_fn builtin_int[] =
5454
{ basic_sgn, "SGN" },
5555
{ basic_int, "INT" },
5656
{ basic_gethour, "HOUR" },
57+
{ basic_getupsecs, "UPSECS" },
5758
{ basic_getminute, "MINUTE" },
5859
{ basic_getsecond, "SECOND" },
5960
{ basic_getepoch, "EPOCH" },
@@ -125,6 +126,7 @@ struct basic_str_fn builtin_str[] =
125126
{ basic_upper, "UPPER$" },
126127
{ basic_date, "DATE$" },
127128
{ basic_time, "TIME$" },
129+
{ basic_get_upstr, "UPTIME$" },
128130
{ NULL, NULL },
129131
};
130132

src/clock.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
static datetime_t current_datetime = { 0 };
66
static unsigned char* tzdata = NULL;
7+
static time_t system_boot = 0;
78

89
const char* weekday_map[7] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
910
const char* month_map[12] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
@@ -133,6 +134,10 @@ int is_leap_year(int year, int month) {
133134
return 0;
134135
}
135136

137+
uint64_t uptime_secs() {
138+
return time(NULL) - system_boot;
139+
}
140+
136141
/*
137142
* Given a date, calculate it's weekday, using the algorithm described here:
138143
* http://blog.artofmemory.com/how-to-calculate-the-day-of-the-week-4203.html
@@ -175,6 +180,7 @@ const char* get_datetime_str() {
175180

176181
void init_realtime_clock() {
177182
rtc_read_datetime();
183+
system_boot = time(NULL);
178184
kprintf("System boot time (UTC): %s\n", get_datetime_str());
179185
}
180186

0 commit comments

Comments
 (0)