ios

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2026 License: GPL-3.0 Imports: 8 Imported by: 0

README

EblituiIOS

A shared iOS frontend framework for retro console emulators. Provides a complete SwiftUI application shell - library management, game detail views, settings, Metal rendering, audio, touch controls, gamepad support, save states, and SRAM persistence - so that individual emulator cores only need to implement a thin bridge layer.

Requirements

  • iOS 17.0+
  • Swift 5.9+
  • Emulator core built as an XCFramework via gomobile

Integration

Each emulator provides two conformances:

EmulatorEngine

Instance-level emulator operations. Wraps the gomobile-generated framework calls for a single emulation session.

class MyEmulatorEngine: EmulatorEngine {
    func loadROM(path: String) -> Bool { ... }
    func runFrame() { ... }
    func getFrameBuffer() -> FrameData? { ... }
    func getAudioSamples() -> Data? { ... }
    func setInput(player: Int, buttons: Int) { ... }
    // ... save states, SRAM, options
}
EmulatorBridgeProvider

Static factory operations. Provides system metadata and creates engine instances.

struct MyBridgeProvider: EmulatorBridgeProvider {
    static var systemInfo: SystemInfo { ... }
    static func createEngine() -> EmulatorEngine { ... }
    static func crc32(ofPath path: String) -> UInt32? { ... }
    static func detectRegion(path: String) -> Int { ... }
    static func extractAndStoreROM(srcPath: String, destDir: String) -> ROMImportResult? { ... }
}
App Entry Point

Register the provider at launch and hand off to the shared ContentView:

import EblituiIOS

@main
struct MyApp: App {
    init() {
        EmulatorBridge.register(MyBridgeProvider.self)
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

Package Structure

Sources/EblituiIOS/
  App/            - AppState, ContentView (navigation)
  Controls/       - Touch controls overlay
  Emulator/       - EmulatorBridge protocol, AudioEngine, MetalRenderer
  Metadata/       - ROM database parsing, artwork downloading
  Storage/        - Library, save states, SRAM, config persistence
  Utilities/      - Logging
  Views/          - Library, game detail, gameplay, settings views
  SystemInfo.swift

License

See repository root for license information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close releases the emulator.

func DetectRegionFromPath

func DetectRegionFromPath(path string) int

DetectRegionFromPath detects the region for a ROM file (0=NTSC, 1=PAL).

func ExtractAndStoreROM

func ExtractAndStoreROM(srcPath, destDir string) (string, error)

ExtractAndStoreROM extracts a ROM from an archive, calculates its CRC32, and stores it as {CRC32}.{first extension} in destDir. Returns JSON with "crc" (hex string) and "name" (ROM filename without extension).

func FrameHeight

func FrameHeight() int

FrameHeight returns the active display height.

func FrameStride

func FrameStride() int

FrameStride returns the framebuffer stride in bytes per row.

func FrameWidth

func FrameWidth() int

FrameWidth returns the display width in pixels.

func GetAudioData

func GetAudioData() []byte

GetAudioData returns audio as int16 stereo PCM little-endian bytes.

func GetCRC32FromPath

func GetCRC32FromPath(path string) int64

GetCRC32FromPath calculates the CRC32 checksum of a ROM file. Returns -1 on error.

func GetFPS

func GetFPS() int

GetFPS returns the frames per second for the current emulator state.

func GetFrameData

func GetFrameData() []byte

GetFrameData returns the frame buffer for the active display area.

func HasSRAM

func HasSRAM() bool

HasSRAM returns whether the current ROM uses battery-backed save.

func HasSaveStates

func HasSaveStates() bool

HasSaveStates returns whether the emulator supports save states.

func Init

func Init(path string, regionCode int) bool

Init creates an emulator from a ROM file path. regionCode: 0=NTSC, 1=PAL Returns true on success.

func LoadSRAM

func LoadSRAM(data []byte)

LoadSRAM loads SRAM data into the emulator.

func LoadState

func LoadState(data []byte) bool

LoadState loads a save state. Returns true on success.

func PrepareSRAM

func PrepareSRAM()

PrepareSRAM copies SRAM to internal buffer.

func Region

func Region() int

Region returns the current region (0=NTSC, 1=PAL).

func RegisterFactory

func RegisterFactory(f coreif.CoreFactory)

RegisterFactory sets the CoreFactory. Called by core's init().

func RunFrame

func RunFrame()

RunFrame executes one frame of emulation.

func SRAMByte

func SRAMByte(i int) int

SRAMByte returns a single byte from SRAM at index i.

func SRAMLen

func SRAMLen() int

SRAMLen returns the SRAM length.

func SaveState

func SaveState() bool

SaveState creates a save state. Returns true on success.

func SetInput

func SetInput(player int, buttons int)

SetInput sets controller state as a button bitmask for the given player.

func SetOption

func SetOption(key string, value string)

SetOption applies a core option change to the emulator.

func Start added in v0.3.0

func Start()

Start finalizes emulator state after all options are applied. Must be called after SetOption and before the first RunFrame.

func StateByte

func StateByte(i int) int

StateByte returns a single byte from the saved state at index i.

func StateLen

func StateLen() int

StateLen returns the length of the last saved state.

func SystemInfoJSON

func SystemInfoJSON() string

SystemInfoJSON returns the system info as a JSON string. CoreOptionCategory values are serialized as display strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL