@@ -225,8 +225,8 @@ export class Emulator extends React.Component<{}, EmulatorState> {
225
225
{ this . renderInfo ( ) }
226
226
{ this . renderUI ( ) }
227
227
< div id = "emulator" >
228
- < div > </ div >
229
- < canvas > </ canvas >
228
+ < div id = "emulator-text-screen" > </ div >
229
+ < canvas id = "emulator-canvas" > </ canvas >
230
230
</ div >
231
231
</ >
232
232
) ;
@@ -263,11 +263,9 @@ export class Emulator extends React.Component<{}, EmulatorState> {
263
263
*/
264
264
public showDiskImage ( ) {
265
265
// Contents/Resources/app/dist/static
266
- const imagePath = path . join ( __dirname , "../../images/windows95.img" ) ;
266
+ console . log ( `Showing disk image in ${ CONSTANTS . IMAGE_PATH } ` ) ;
267
267
268
- console . log ( `Showing disk image in ${ imagePath } ` ) ;
269
-
270
- shell . showItemInFolder ( imagePath ) ;
268
+ shell . showItemInFolder ( CONSTANTS . IMAGE_PATH ) ;
271
269
}
272
270
273
271
/**
@@ -281,7 +279,8 @@ export class Emulator extends React.Component<{}, EmulatorState> {
281
279
memory_size : 128 * 1024 * 1024 ,
282
280
vga_memory_size : 64 * 1024 * 1024 ,
283
281
screen_container : document . getElementById ( "emulator" ) ,
284
- preserve_mac_from_state_image : true ,
282
+ // preserve_mac_from_state_image: true,
283
+ use_graphical_text : true ,
285
284
net_device : {
286
285
relay_url : "fetch" ,
287
286
type : "ne2k" ,
@@ -364,6 +363,7 @@ export class Emulator extends React.Component<{}, EmulatorState> {
364
363
this . unlockMouse ( ) ;
365
364
await emulator . stop ( ) ;
366
365
this . setState ( { isRunning : false } ) ;
366
+ this . resetCanvas ( ) ;
367
367
368
368
document . body . classList . add ( "paused" ) ;
369
369
ipcRenderer . send ( IPC_COMMANDS . MACHINE_STOPPED ) ;
@@ -405,23 +405,25 @@ export class Emulator extends React.Component<{}, EmulatorState> {
405
405
* Restores state to the emulator.
406
406
*/
407
407
private async restoreState ( ) {
408
- const { emulator } = this . state ;
408
+ const { emulator, isBootingFresh } = this . state ;
409
409
const state = await this . getState ( ) ;
410
410
411
- // Nothing to do with if we don't have a state
412
- if ( ! state ) {
411
+ if ( isBootingFresh ) {
412
+ console . log ( `restoreState: Booting fresh, not restoring.` ) ;
413
+ return ;
414
+ } else if ( ! state ) {
413
415
console . log ( `restoreState: No state present, not restoring.` ) ;
414
- }
415
-
416
- if ( ! emulator ) {
416
+ return ;
417
+ } else if ( ! emulator ) {
417
418
console . log ( `restoreState: No emulator present` ) ;
419
+ return ;
418
420
}
419
421
420
422
try {
421
423
await this . state . emulator . restore_state ( state ) ;
422
424
} catch ( error ) {
423
425
console . log (
424
- `State : Could not read state file. Maybe none exists?` ,
426
+ `restoreState : Could not read state file. Maybe none exists?` ,
425
427
error ,
426
428
) ;
427
429
}
@@ -441,6 +443,8 @@ export class Emulator extends React.Component<{}, EmulatorState> {
441
443
442
444
if ( fs . existsSync ( statePath ) ) {
443
445
return fs . readFileSync ( statePath ) . buffer ;
446
+ } else {
447
+ console . log ( `getState: No state file found at ${ statePath } ` ) ;
444
448
}
445
449
446
450
return null ;
@@ -504,4 +508,16 @@ export class Emulator extends React.Component<{}, EmulatorState> {
504
508
this . state . emulator . keyboard_send_scancodes ( scancodes ) ;
505
509
}
506
510
}
511
+
512
+ /**
513
+ * Reset the canvas
514
+ */
515
+ private resetCanvas ( ) {
516
+ const canvas = document . getElementById ( "emulator-canvas" ) ;
517
+
518
+ if ( canvas instanceof HTMLCanvasElement ) {
519
+ const ctx = canvas . getContext ( '2d' ) ;
520
+ ctx ?. clearRect ( 0 , 0 , canvas . width , canvas . height ) ;
521
+ }
522
+ }
507
523
}
0 commit comments