Finished getting JerryScript on all the platforms.

This commit is contained in:
2026-04-28 13:59:46 -05:00
parent 73e7d6c7f3
commit bd4200e707
15 changed files with 210 additions and 10 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ endif()
if(NOT jerryscript_FOUND)
find_package(jerryscript REQUIRED)
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PUBLIC
target_link_libraries(${DUSK_LIBRARY_TARGET_NAME} PRIVATE
jerryscript::core
jerryscript::ext
jerryscript::port
+1 -1
View File
@@ -53,7 +53,7 @@ void timeUpdate(void) {
dusktimeepoch_t epoch = timeGetEpoch();
char_t buffer[256];
timeEpochFormat(epoch, "%Y-%m-%d %H:%M:%S", buffer, sizeof(buffer));
consolePrint("Real Time: %s", buffer);
// consolePrint("Real Time: %s", buffer);
}
dusktimeepoch_t timeGetEpoch(void) {
+1 -2
View File
@@ -7,14 +7,13 @@
#pragma once
#include "timeepoch.h"
#include "time/timeplatform.h"
#ifndef DUSK_TIME_STEP
#define DUSK_TIME_STEP (16.0f / 1000.0f)
#endif
#ifdef DUSK_TIME_DYNAMIC
#include "time/timeplatform.h"
#ifndef timeTickPlatform
#error "DUSK_TIME_DYNAMIC needs tick method defined"
#endif
+2 -1
View File
@@ -20,4 +20,5 @@ add_subdirectory(log)
add_subdirectory(display)
add_subdirectory(input)
add_subdirectory(network)
add_subdirectory(system)
add_subdirectory(system)
add_subdirectory(time)
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
timedolphin.c
)
+24
View File
@@ -0,0 +1,24 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "time/timedolphin.h"
double_t timeGetRealDolphin(void) {
// "Returns time in ticks since 2000"
u64 timeInMillis = PPCTicksToMs(SYS_Time());
double_t timeSeconds = (double_t)timeInMillis / 1000.0;
// Time to adjust time from 2000 to 1970, in seconds
double_t timeOffset = 946684800.0;
timeSeconds += timeOffset;
return timeSeconds;
}
double_t timeGetRealTimeZoneDolphin(void) {
return 0.0;
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
/**
* Returns the real current time, in seconds since January 1, 1970.
*
* @return The real current time, in seconds since January 1, 1970.
*/
double_t timeGetRealDolphin(void);
/**
* Returns the real time zone offset in seconds from UTC.
*
* @return The real time zone offset in seconds from UTC.
*/
double_t timeGetRealTimeZoneDolphin(void);
+12
View File
@@ -0,0 +1,12 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "time/timedolphin.h"
#define timeGetRealPlatform timeGetRealDolphin
#define timeGetRealTimeZonePlatform timeGetRealTimeZoneDolphin
+2 -1
View File
@@ -19,4 +19,5 @@ add_subdirectory(asset)
add_subdirectory(input)
add_subdirectory(log)
add_subdirectory(network)
add_subdirectory(system)
add_subdirectory(system)
add_subdirectory(time)
+9
View File
@@ -0,0 +1,9 @@
# Copyright (c) 2026 Dominic Masters
#
# This software is released under the MIT License.
# https://opensource.org/licenses/MIT
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
timepsp.c
)
+15
View File
@@ -0,0 +1,15 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "time/timesdl2.h"
#include "time/timepsp.h"
#define timeTickPlatform timeTickSDL2
#define timeGetDeltaPlatform timeGetDeltaSDL2
#define timeGetRealPlatform timeGetRealPSP
#define timeGetRealTimeZonePlatform timeGetRealTimeZonePSP
+40
View File
@@ -0,0 +1,40 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "time/timepsp.h"
#include <time.h>
#include <psptypes.h>
#include <psprtc.h>
double_t timeGetRealPSP(void) {
u64 utc_ticks = 0;
if(sceRtcGetCurrentTick(&utc_ticks) < 0) return 0.0;
/*
PSP RTC ticks are microseconds.
Return seconds since 1970-01-01 UTC.
*/
return (double_t)utc_ticks / 1000000.0;
}
double_t timeGetRealTimeZonePSP(void) {
u64 utc_ticks = 0;
u64 local_ticks = 0;
if(sceRtcGetCurrentTick(&utc_ticks) < 0) return 0.0;
if(sceRtcConvertUtcToLocalTime(&utc_ticks, &local_ticks) < 0) return 0.0;
/*
Return timezone offset in hours.
Example:
UTC-6 => -6.0
UTC+2 => 2.0
*/
int64_t offset_us = (int64_t)local_ticks - (int64_t)utc_ticks;
return (double_t)offset_us / (1000000.0 * 60.0 * 60.0);
}
+23
View File
@@ -0,0 +1,23 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
/**
* Returns the real current time, in seconds since January 1, 1970.
*
* @return The real current time, in seconds since January 1, 1970.
*/
double_t timeGetRealPSP(void);
/**
* Returns the real time zone offset in seconds from UTC.
*
* @return The real time zone offset in seconds from UTC.
*/
double_t timeGetRealTimeZonePSP(void);