Skip to content

Conversation

@mattgodbolt
Copy link
Owner

Summary

  • Implement save state functionality for jsbeeb
  • Add B-Em .snp file format compatibility for testing and snapshot migration
  • Create a comprehensive save state architecture for future enhancements

Features

  • Core SaveState class for managing component state serialization
  • TimeTravel class for implementing rewind functionality
  • SaveStateStorage class for browser localStorage integration
  • B-Em snapshot import/export for compatibility and testing
  • Unit and integration tests for all components

Closes #74

🤖 Generated with Claude Code

mattgodbolt and others added 15 commits April 8, 2025 17:59
This commit includes:
- A comprehensive design document describing the save state implementation plan
- Initial skeleton code for the save state functionality
- Support for serialization, time travel, and local storage

Part of the work for issue #74.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit includes:
- Unit tests for the SaveState class with component state serialization
- Tests for typed array handling in save states
- Tests for the TimeTravel class with buffer management
- Tests for the SaveStateStorage class with localStorage integration

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Add details about:
- Unit testing for core save state components
- Integration testing for the complete system
- Format compatibility testing

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Export Flags class from 6502.js to make it available for testing
- Fix tests that depend on the Flags class
- Remove unused SaveState import in test-6502.js
- Update CLAUDE.md with save state implementation details and best practices
- Add tests for CPU flags state saving/loading

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Added save state methods to VIA, ACIA, SoundChip, DiscDrive, FDC, and CMOS
- Added comprehensive unit tests for all component save state implementations
- Fixed WD-FDC loadState to properly update CPU flags
- Made Via class exported to facilitate better testing
- Ensured all tests are passing with high fidelity state preservation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Created a detailed document describing the B-Em .snp snapshot file format, which will:
- Support potential future compatibility with B-Em snapshots
- Serve as a reference for testing save state implementations
- Document all peripheral state formats in B-Em

The documentation covers file structure, section formats, and detailed layouts
of all major peripheral components including CPU, memory, VIAs, video, and sound.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Implemented BemSnapshotConverter that:
- Imports B-Em .snp files into jsbeeb's SaveState format
- Exports jsbeeb SaveState back to B-Em format
- Handles different B-Em versions and snapshots components

Added both unit and integration tests to verify:
- The B-Em snapshot file format is correctly parsed
- B-Em snapshot data is correctly converted to jsbeeb format
- jsbeeb SaveState data is correctly converted back to B-Em format

This provides compatibility with B-Em snapshots for testing
and allows users to migrate their saved states between emulators.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This addresses the issue #74 where loading the same save state multiple times
causes keyboard unresponsiveness:

1. Fixed scheduler to clear all tasks when loading state to prevent stale tasks
2. Ensured peripherals (VIA, ACIA) save and load their state properly
3. Added proper error handling in snapshot-ui.js for failed state loads
4. Improved B-Em snapshot support with special handling for version 2 format
5. Added documentation about save state load order importance

The key improvement is ensuring the scheduler clears its task queue and
peripheral components are properly restored when loading a save state.
- Added saveState/loadState methods to Music5000, ADC, Serial, and TeletextAdaptor
- Created comprehensive unit tests for each component
- Updated CPU to call the new methods during state saving/loading
- Fixed bug in Serial loadState that was overwriting state values

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Wired up the existing saveState/loadState implementations in the SoundChip and WdFdc components to ensure they're properly saved and loaded as part of the emulator state.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added saveState/loadState methods to the Intel8271 FDC component to properly save and restore disk controller state. Created unit tests to verify the FDC state is correctly persisted and restored.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Simplified SnapshotUI to only require the processor reference, as it handles saving/loading state for all components including the FDC. This fixes the TypeError that occurred when trying to access this.fdc.saveState directly from SnapshotUI.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Added comprehensive saveState and loadState methods to the Tube class to properly save and restore the state of the second processor interface. The implementation preserves all critical tube state including status registers, FIFO buffers, data, and interrupt flags. Created unit tests to verify the Tube state is correctly persisted and restored, and wired up the Tube component to the CPU's state save/load methods.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Update SaveState class to require and store model information
- Add ModelManager for creating models from save state info
- Update UI to pass model to SaveState constructor
- Add model-aware loading process documentation
- Export Model and CpuModel classes for testing
- Update tests to use model in SaveState

TODO: Fix remaining tests to use a mock model for SaveState creation

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mattgodbolt mattgodbolt added the feature A feature request label Jun 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature A feature request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support saved state

2 participants