Loading save files done.

This commit is contained in:
2025-03-11 19:03:11 -05:00
parent 85f643ef10
commit 60db15e932
19 changed files with 489 additions and 76 deletions

View File

@@ -1,18 +1,11 @@
import { useEffect, useRef, useState } from 'react';
import styles from './Emulator.module.scss';
type EmulatorSystem = (
'gb' | 'gbc' | 'gba'
);
type EmulatorCore = (
'gambatte' | 'mgba'
);
import { GAME_SYSTEM_CORES, GameSystem, GameSystemCore } from '@/lib/game';
type SendEmulatorMessageInit = {
message:'init';
core:EmulatorCore;
system:EmulatorSystem;
core:GameSystemCore;
system:GameSystem;
gameId:string;
gameName:string;
}
@@ -35,13 +28,9 @@ type ReceiveEmulatorMessage = (
);
export type EmulatorProps = {
system:EmulatorSystem;
};
const EMULATOR_SYSTEM_CORES:{ [key in EmulatorSystem]:EmulatorCore } = {
'gb': 'gambatte',
'gbc': 'gambatte',
'gba': 'mgba'
system:GameSystem;
gameId:string;
gameName:string;
};
export const Emulator:React.FC<EmulatorProps> = props => {
@@ -58,13 +47,13 @@ export const Emulator:React.FC<EmulatorProps> = props => {
send({
message: 'init',
core: EMULATOR_SYSTEM_CORES[props.system],
core: GAME_SYSTEM_CORES[props.system],
system: props.system,
gameId: '0',
gameName: 'Pokemon - Crystal Version'
gameId: props.gameId,
gameName: props.gameName
});
window.onmessage = (e) => {
window.onmessage = e => {
if(!e.data) {
console.error('Invalid message received:', e.data);
return;