open-index/open-npm huggingface dataset:
npm package: @gba-kit/arm-emulator
Description: ARM7TDMI CPU emulator supporting Thumb and ARM instruction sets
Author: macabeus
Latest version: 0.1.0

# @gba-kit/arm-emulator

Pure ARM7TDMI CPU emulator supporting both Thumb (16-bit) and ARM (32-bit) instruction sets.

> Note: It doesn't include any GBA-specific logic. The CPU accepts a `MemoryBus` interface and an optional SWI handler callback, so it can be embedded in any ARM7TDMI-based system.

## Install

```bash
npm install @gba-kit/arm-emulator
```

## Usage

### ARM CPU

```typescript
import { GbaMemory } from '@gba-kit/arm-emulator';
import { ArmCpu } from '@gba-kit/arm-emulator/arm-cpu';

const memory = new GbaMemory();
const cpu = new ArmCpu(memory, {
  swiHandler: (cpu, swiNumber) => {
    // Platform-specific SWI handling
  },
});

cpu.registers[15] = 0x08000000; // set PC
cpu.step(); // execute one instruction
```

### Disassembly

```typescript
import { disassembleArm, disassembleThumb } from '@gba-kit/arm-emulator/disassembler';

const mnemonic = disassembleThumb(0x4770, 0x08000000);
// "bx lr"
```

## Exports

### Main entry (`@gba-kit/arm-emulator`)

| Export                            | Type  | Description                     |
| --------------------------------- | ----- | ------------------------------- |
| `GbaMemory`                       | class | Memory bus with region dispatch |
| `PC`, `LR`, `SP`, `SENTINEL_ADDR` | const | Register index constants        |

Types: `CpsrFlags`, `DebugAction`, `DebugHooks`, `ExecutionResult`, `ExternalCall`, `MemoryBus`, `MemoryWrite`, `CpuSnapshot`

### Subpath exports

| Subpath                              | Description                                                          |
| ------------------------------------ | -------------------------------------------------------------------- |
| `@gba-kit/arm-emulator/arm-cpu`      | `ArmCpu` class — full ARM7TDMI with mode switching, banked registers |
| `@gba-kit/arm-emulator/disassembler` | `disassembleArm()`, `disassembleThumb()` functions                   |
| `@gba-kit/arm-emulator/cpu-snapshot` | `CpuSnapshot` interface for serializable CPU state                   |

## Testing

```bash
pnpm test
```
npm package: @gba-kit/gba-browser
Description: Browser runtime for GBA emulation
Author: macabeus
Latest version: 0.1.0

# @gba-kit/gba-browser

Framework-agnostic browser runtime for GBA emulation.

Provides `EmulatorBridge`, a class that connects the GBA emulator to a browser canvas with keyboard input, save states, breakpoints, disassembly, and IndexedDB-backed save state persistence.

## Install

```bash
npm install @gba-kit/gba-browser
```

## Usage

### EmulatorBridge

The core class that wraps `@gba-kit/gba-emulator` for browser use:

```typescript
import { EmulatorBridge } from '@gba-kit/gba-browser';

const emulator = new EmulatorBridge();

// Attach a canvas for rendering
emulator.attachCanvas(document.querySelector('canvas')!);

// Load a ROM and start emulation
emulator.loadRom(romArrayBuffer);
emulator.run();

// Pause / step
emulator.pause();
emulator.stepInstruction();

// Keyboard input (wire to your own event listeners)
window.addEventListener('keydown', (e) => emulator.handleKeyDown(e));
window.addEventListener('keyup', (e) => emulator.handleKeyUp(e));

// Breakpoints
emulator.addBreakpoint(0x08001234);

// Save/load states
const { snapshot, thumbnail } = await emulator.saveState();
emulator.loadState(snapshot);

// Disassembly
const instructions = emulator.disassembleAt(0x08000000, 20);

// Memory access
const data = emulator.readMemory(0x03000000, 256);
```

### Save State Persistence

IndexedDB-backed storage for save states with thumbnail previews:

```typescript
import { computeRomHash, deleteState, listByRom, loadState, saveState } from '@gba-kit/gba-browser';

const hash = await computeRomHash(romArrayBuffer);

const id = await saveState(hash, snapshot, thumbnailBlob, 'My Save');

const saves = await listByRom(hash);

const record = await loadState(id);
```

## Exports

| Export             | Description                                                                  |
| ------------------ | ---------------------------------------------------------------------------- |
| `EmulatorBridge`   | Browser GBA emulator wrapper with canvas, keyboard, breakpoints, save states |
| `computeRomHash()` | SHA-256 hash of ROM header for identity                                      |
| `saveState()`      | Save snapshot + thumbnail to IndexedDB                                       |
| `loadState()`      | Load a save state record by ID                                               |
| `deleteState()`    | Delete a save state by ID                                                    |
| `renameState()`    | Rename a save state                                                          |
| `listByRom()`      | List save state metadata for a ROM                                           |

Types: `EmulatorState`, `EmulatorCallbacks`, `Breakpoint`, `SaveStateRecord`, `SaveStateMeta`

## See Also

- [`@gba-kit/gba-react`](../gba-react) — React hooks that wrap this package
- [`@gba-kit/gba-node`](../gba-node) — Headless Node.js runtime for scripted emulation
npm package: @gba-kit/gba-node
Description: Headless Node.js runtime for scripted GBA emulation
Author: macabeus
Latest version: 0.1.0

# @gba-kit/gba-node

Headless GBA emulator runtime for Node.js. Load a ROM, execute JavaScript scripts against the emulator, and capture screenshots, memory snapshots, and save states to disk.

## Install

```bash
npm install @gba-kit/gba-node
```

## Usage

### Headless Runtime

```typescript
import { HeadlessRuntime } from '@gba-kit/gba-node';

const runtime = await HeadlessRuntime.create({
  romPath: './game.gba',
  outputDir: './output',
  logFn: console.log,
});

// Execute a script against the emulator
await runtime.executeScript(`
  await wait({ frames: 60 });
  await press('start');
  await wait({ frames: 30 });
  await takeScreenshot({ name: 'title' });
`);

// Write final save state
await runtime.writeFinalSaveState();
```

### Script API

Scripts run inside a sandboxed `vm.Context` with these functions available.

See the **[Scripting Guide](https://github.com/macabeus/gba-kit/blob/main/docs/scripting.md)** for the full API reference and examples.

### Snapshot Serialization

Convert `GbaSnapshot` objects (with TypedArrays) to/from JSON using base64 encoding:

```typescript
import { deserializeSnapshot, serializeSnapshot } from '@gba-kit/gba-node';

// Save to JSON
const json = JSON.stringify(serializeSnapshot(snapshot));

// Restore from JSON
const snapshot = deserializeSnapshot(JSON.parse(json));
```

### Custom Scripting Host

Implement `ScriptingHost` to control where screenshots and snapshots are written:

```typescript
import { NodeScriptingHost } from '@gba-kit/gba-node';

const host = new NodeScriptingHost('./output', console.log);
// host.generatedFiles — list of files written during the session
```

## Exports

| Export                  | Type     | Description                                                               |
| ----------------------- | -------- | ------------------------------------------------------------------------- |
| `HeadlessRuntime`       | class    | Main runtime — loads ROM, executes scripts, manages GBA instance          |
| `NodeScriptingHost`     | class    | File-system scripting host (PNG screenshots via fast-png, JSON snapshots) |
| `serializeSnapshot()`   | function | Convert `GbaSnapshot` to JSON-safe object (base64 TypedArrays)            |
| `deserializeSnapshot()` | function | Restore `GbaSnapshot` from serialized JSON                                |

Type: `HeadlessRuntimeOptions`
npm package: @gbalbuena/aws-node-simple-http-endpoint
Description: Example demonstrates how to setup a simple HTTP GET endpoint
Author: gbalbuena
Latest version: 1.0.2

<!--
title: 'AWS Simple HTTP Endpoint example in NodeJS'
description: 'This example demonstrates how to setup a simple HTTP GET endpoint. Once you ping it, it will reply with the current time.'
layout: Doc
framework: v1
platform: AWS
language: nodeJS
authorLink: 'https://github.com/rupakg'
authorName: 'Rupak Ganguly'
authorAvatar: 'https://avatars0.githubusercontent.com/u/8188?v=4&s=140'
-->
# Simple HTTP Endpoint Example

This example demonstrates how to setup a simple HTTP GET endpoint. Once you ping it, it will reply with the current time. While the internal function is name `currentTime` the HTTP endpoint is exposed as `ping`.

## Use Cases

- Wrapping an existing internal or external endpoint/service

## Invoke the function locally

```bash
serverless invoke local --function currentTime
```

Which should result in:

```bash
Serverless: Your function ran successfully.

{
    "statusCode": 200,
    "body": "{\"message\":\"Hello, the current time is 12:49:06 GMT+0100 (CET).\"}"
}
```

## Package

```bash
serverless package
```



## Deploy

In order to deploy the endpoint, simply run:

```bash
serverless deploy
```

The expected result should be similar to:

```bash
Serverless: Packaging service…
Serverless: Uploading CloudFormation file to S3…
Serverless: Uploading service .zip file to S3…
Serverless: Updating Stack…
Serverless: Checking Stack update progress…
...........................
Serverless: Stack update finished…

Service Information
service: serverless-simple-http-endpoint
stage: dev
region: us-east-1
api keys:
  None
endpoints:
  GET - https://2e16njizla.execute-api.us-east-1.amazonaws.com/dev/ping
functions:
  serverless-simple-http-endpoint-dev-currentTime: arn:aws:lambda:us-east-1:488110005556:function:serverless-simple-http-endpoint-dev-currentTime
```

## Usage

You can now invoke the Lambda directly and even see the resulting log via

```bash
serverless invoke --function currentTime --log
```

or as send an HTTP request directly to the endpoint using a tool like curl

```bash
curl https://XXXXXXX.execute-api.us-east-1.amazonaws.com/dev/ping
```

## Scaling

By default, AWS Lambda limits the total concurrent executions across all functions within a given region to 100. The default limit is a safety limit that protects you from costs due to potential runaway or recursive functions during initial development and testing. To increase this limit above the default, follow the steps in [To request a limit increase for concurrent executions](http://docs.aws.amazon.com/lambda/latest/dg/concurrent-executions.html#increase-concurrent-executions-limit).