2026-02-20 15:40:31 -08:00
2026-02-20 14:00:40 -08:00
2026-02-20 15:40:31 -08:00
2026-02-20 14:00:40 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 14:00:40 -08:00
2026-02-20 10:16:03 -08:00
2026-02-20 15:40:31 -08:00
2026-02-20 14:00:40 -08:00
2026-02-20 14:00:40 -08:00

King's Quest IV: The Perils of Rosella - Interaction Documentation

A comprehensive documentation of all game interactions extracted from the decompiled SCI (Sierra's Creative Interpreter) source code. This project documents the logic, conditions, state changes, and dependencies for recreating King's Quest IV as a modern point-and-click adventure.

Repository Structure

/
├── rooms/                          # Room-specific documentation (one directory per room)
│   ├── kq4-001-beach/             # Beach (starting room)
│   │   ├── 001-beach.md           # Room documentation
│   │   ├── pic_001_visual.png     # Background visual
│   │   ├── pic_001_control.png    # Control (walkable areas)
│   │   └── pic_001_priority.png   # Priority (z-ordering)
│   ├── kq4-002-meadow/            # Meadow (with Satyr/Pan)
│   ├── kq4-010-forest-path/      # Forest Path
│   └── ...                        # One directory per room
├── docs/scripts/                   # Non-room script documentation
│   └── non-room-scripts.md        # Core, region, and interaction scripts
├── KQ4_v1.006.004_int0.000.502_SRC_(6)/
│   └── src/                        # Decompiled SCI scripts
│       ├── Main.sc                 # Game engine & global handlers
│       ├── Game.sc                 # Core game classes
│       ├── Feature.sc              # Object interaction framework
│       ├── InvI.sc                 # Inventory system
│       ├── rm1.sc - rm99.sc        # Room scripts
│       └── *.sc                    # Various utility scripts
└── README.md                       # This file

Source Code Overview

File Types

  • .sc files: Sierra Script source code (main logic)
  • .sco files: Compiled script object files (not human-readable)
  • game.sh: Header file with game constants and defines

Key Source Files

File Purpose
Main.sc Global game state, inventory, death handlers, sound management
Game.sc Core Game class, save/load system, event handling
Feature.sc Base classes for interactive objects (Feature, View, Actor)
InvI.sc Inventory item definitions and display logic
Class_255_0.sc Low-level system procedures and kernel functions
rm##.sc Individual room scripts (rooms 1-99)
*Reg.sc Region scripts (shared logic for multiple rooms)

Room Script Anatomy

Each room script (rm##.sc) typically contains:

Room## of Rm                    # Room class definition
├── Properties
│   └── picture                 # Background image number
├── Methods
│   ├── init()                  # Room initialization
│   │   ├── north/south/east/west  # Exit directions
│   │   ├── horizon             # Walkable area boundary
│   │   ├── setRegions:         # Apply shared region logic
│   │   ├── Props/Actors/Views  # Interactive objects
│   │   └── gEgo positioning    # Player start position
│   ├── doit()                  # Per-frame logic (rarely used)
│   ├── handleEvent()           # Text parser input handling
│   └── dispose()               # Cleanup when leaving room
└── Instances
    ├── Scripts                 # Multi-step sequences
    ├── Props                   # Animated objects
    ├── Views                   # Static scenery
    └── Sounds                  # Audio effects

Game Systems

Parser Commands

The original game uses a text parser with verb-noun structure:

  • Said 'look/grass' - Player typed "look at grass"
  • Said 'use/key' - Player typed "use key"
  • Said 'take/diamond' - Player typed "take diamond"
  • Said '[<around][/room]' - "look around" or "look room"

State Management

Global variables track game state:

Variable Purpose
gEgo Player character object
gRoom Current room instance
gPrevRoomNum Previous room number
gInv Inventory collection
global100 Unknown flag (weather/time?)
global101 Room has been visited
global116 Story progression state
global105 Multi-path room state

Inventory System

Items referenced by index in gInv at: ##:

Index Item
1 Diamonds
17 Fishing pole
... (others documented per-room)

Message System

Text displayed via Print scriptNum messageNum:

  • Print 1 0 = Message 0 from script 1
  • Messages stored separately in RESOURCE files
  • To be extracted and added to room documentation

Looking Up Text in the Strings Directory

Message text is extracted and stored in the strings/ directory:

File Pattern Contents
strings/script_XXX_strings.txt Script-specific strings (room names, object names)
strings/text_XXX.txt In-game dialog and message text

To look up a message:

  1. Identify the script number from the Print command (e.g., Print 2 1 = script 2, message 1)
  2. Open strings/text_XXX.txt where XXX matches the script number
  3. Find the entry with the matching message number (e.g., [0001])

Example:

Print 2 1  →  Look in strings/text_002.txt, line [0001]
Result: "You see a river in the distance to the north."

Note: Message numbers in the code start from 0 and are displayed in brackets (e.g., [0001] = message 1).

Room Documentation Format

Each room file follows this structure:

# Room ##: [Room Name]

## Overview
- **Room Number**: ##
- **Picture**: ###
- **Region**: [Beach/Forest/Castle/etc.]
- **Exits**: North→#, South→#, East→#, West→#

## Objects

### [Object Name]
- **Type**: Prop/View/Actor
- **Position**: (x, y)
- **View**: ### (sprite/animation resource)
- **States**: [list of possible states]

#### Interactions

**Look**:
- Condition: [when visible]
- Text: "Message from game"
- Logic: [simplified state check]

**Use [Item]**:
- Condition: [inventory check]
- Effect: [what happens]
- State Change: [global or local variable changes]

## NPCs

### [Character Name]
- **Type**: Actor
- **Behavior**: [wandering, stationary, scripted]

#### Dialogue
- **Greeting**: [initial interaction]
- **Topics**: [what player can ask about]
- **Conditions**: [when available]

## Scripts

### [Script Name]
- **Trigger**: [what starts it]
- **Steps**: [sequence of actions]
- **State Changes**: [what it modifies]

## Walkthrough Integration

- **Critical Path**: [essential interactions]
- **Optional**: [side content]
- **Deaths**: [ways to die in this room]

Conversion Notes for Point-and-Click

When adapting to a KQ5-style interface (walk, look, hand, talk, inventory):

  1. Walk: Automated - player clicks destination, character walks there
  2. Look: Maps to Said 'look/object' commands
  3. Hand: Maps to Said 'use/object', Said 'take/object', Said 'open/object'
  4. Talk: Maps to Said 'talk/person' or Said 'ask/person/about'
  5. Inventory: Click item, then click target (replaces Said 'use/item/on/target')

Simplifications Made

  • Auto-walking: No manual positioning needed
  • Context-sensitive: Combine look/take/use based on object type
  • Smart defaults: Auto-select appropriate verb for known object types
  • Inventory drag: Drag item to target instead of typing commands

Message Extraction Status

Status Description
Pending Text resources not yet extracted from RESOURCE.### files
📝 Documented Text added to room files

Text messages referenced as Print scriptNum messageNum will be extracted from the game's RESOURCE files and added to each room's documentation.

Generating Room Visuals

Each room directory contains rendered PNG images of the game's PIC resources:

Using sci_pic_render

./sci_pic_render <room_number> "<path_to_game>" <output_directory>

Example:

./sci_pic_render 1 "King's Quest IV - The Perils of Rosella (1988)/KQ4" rooms/kq4-001-beach

This generates three PNG files in the room directory:

  • pic_###_visual.png - The background visual
  • pic_###_control.png - Control (walkable areas)
  • pic_###_priority.png - Priority (z-ordering)

Directory Structure

rooms/
├── kq4-001-beach/
│   ├── 001-beach.md           # Room documentation
│   ├── pic_001_visual.png    # Background
│   ├── pic_001_control.png   # Walkable areas
│   └── pic_001_priority.png  # Z-ordering
└── kq4-010-forest-path/
    └── ...

Contributing

When adding room documentation:

  1. Read the corresponding rm##.sc file
  2. Document all handleEvent interactions
  3. Note all Props, Views, and Actors
  4. Track state dependencies (global variables)
  5. Include original text when available
  6. Describe simplified logic for point-and-click adaptation

Progress

Room Number Room Description Status
001 Beach pic_001_visual.png DONE
002 Meadow (with Satyr/Pan) pic_002_visual.png DONE
003 Fountain Pool pic_003_visual.png DONE
004 Ogre's Cottage Exterior pic_004_visual.png DONE
005 Forest Grove pic_005_visual.png DONE
006 Cave Entrance pic_006_visual.png DONE
007 Fisherman's Shack Exterior pic_007_visual.png DONE
008 Back of Fisherman's Shack pic_008_visual.png DONE
009 Shady Wooded Area pic_009_visual.png DONE
010 Forest Path pic_010_visual.png DONE
011 Enchanted Grove pic_011_visual.png DONE
012 Haunted Forest pic_012_visual.png DONE
013 Beach pic_013_visual.png DONE
014 Green Meadow pic_014_visual.png DONE
015 The Frog Pond pic_015_visual.png DONE
016 Graveyard pic_016_visual.png DONE
017 Spooky House Exterior pic_017_visual.png DONE
018 Cemetery pic_018_visual.png DONE
019 Coastal Cliffs pic_019_visual.png DONE
020 Meadow pic_020_visual.png DONE
021 Bridge Over Stream pic_021_visual.png DONE
022 Gnome's Cottage pic_022_visual.png DONE
023 Forest Path with Cottage pic_023_visual.png DONE
024 Waterfall and Pool pic_024_visual.png DONE
025 Beach at River Delta pic_025_visual.png DONE
026 River Meadow pic_026_visual.png DONE
027 Forest Path pic_027_visual.png DONE
028 Mine Entrance pic_028_visual.png DONE
029 Dense Forest pic_029_visual.png DONE
030 Mountain Pass pic_030_visual.png DONE
031 Open Ocean pic_031_visual.png DONE
032 Ocean Near Island pic_032_visual.png DONE
033 Enchanted Island Beach pic_033_visual.png DONE
034 Island Beach pic_034_visual.png DONE
035 Island Beach pic_035_visual.png DONE
036 Island Garden Pond pic_036_visual.png DONE
037 Fairy Island pic_037_visual.png DONE
038 Island Garden pic_038_visual.png DONE
039 Island Beach pic_039_visual.png DONE
040 Island Beach (East) pic_040_visual.png DONE
041 Island Shore pic_041_visual.png DONE
042 Fisherman's Cottage Interior pic_042_visual.png DONE
043 Desert Island pic_043_visual.png DONE
044 Inside Whale pic_044_visual.png DONE
045 Genesta's Bed Chamber pic_045_visual.png DONE
046 Tower Stairway pic_046_visual.png DONE
047 Genesta's Palace Entry Hall pic_047_visual.png DONE
048 Ogre's Bedroom pic_048_visual.png DONE
049 Ogre's Cottage pic_049_visual.png DONE
050 Ogress's Kitchen pic_050_visual.png DONE
051 Ogre's Closet pic_051_visual.png DONE
052 N/A (doesn't exist)
053 Seven Dwarfs' Bedroom pic_053_visual.png DONE
054 Seven Dwarfs' Cottage pic_054_visual.png DONE
055 Seven Dwarfs Diamond Mine pic_055_visual.png DONE
056 Seven Dwarfs' Diamond Mine (West) pic_056_visual.png DONE
057 Witches' Cave pic_057_visual.png DONE
058 Tower Organ Room pic_058_visual.png DONE
059 Baby Nursery pic_059_visual.png DONE
060 Bedroom pic_060_visual.png DONE
061 Tower Stairs pic_061_visual.png DONE
062 Bedroom pic_062_visual.png DONE
063 Attic pic_063_visual.png DONE
064 Old Dining Room pic_064_visual.png DONE
065 Old Kitchen pic_065_visual.png DONE
066 Secret Tower pic_066_visual.png DONE
067 The Parlor pic_067_visual.png DONE
068 The Foyer pic_068_visual.png DONE
069 The Crypt pic_069_visual.png DONE
070 Waterfall Cave pic_070_visual.png DONE
071 Cave Entrance pic_071_visual.png DONE
072 Dark Cave Passage pic_072_visual.png DONE
073 Cave Exit pic_073_visual.png DONE
074 Troll Cave pic_074_visual.png DONE
075 Troll Cave Passage pic_075_visual.png DONE
076 Dark Chasm pic_076_visual.png DONE
077 Swamp pic_077_visual.png DONE
078 Swamp Island pic_078_visual.png DONE
079 Mountain Path to Dark Castle pic_079_visual.png DONE
080 Lolotte's Castle Entrance pic_080_visual.png DONE
081 Edgar's Tower Bedroom pic_081_visual.png DONE
082 Lolotte's Tower Bedroom pic_082_visual.png DONE
083 Castle Dungeon Cell pic_083_visual.png DONE
084 Cottage Front pic_084_visual.png DONE
085 Dark Tower Stairs pic_085_visual.png DONE
086 Dim Hallway (West End) pic_086_visual.png DONE
087 East End of Hallway pic_087_visual.png DONE
088 Stone Tower Stairs pic_088_visual.png DONE
089 Castle Kitchen pic_089_visual.png DONE
090 West Tower Bottom pic_090_visual.png DONE
091 Castle Dining Room pic_091_visual.png DONE
092 Lolotte's Throne Room pic_092_visual.png DONE
093 Bottom of East Tower pic_093_visual.png DONE
094 Unicorn Stable pic_094_visual.png DONE
095 Fisherman's Pier pic_095_visual.png DONE
096 N/A (doesn't exist)
097 N/A (doesn't exist)
098 Transitional Room DONE
099 Transitional Room DONE

Non-Room Scripts

In addition to room-specific documentation, this project also documents the game's non-room scripts including core system scripts, region scripts, and interaction scripts.

Category Description Documentation
Core System Main.sc, Game.sc, Feature.sc, InvI.sc, Sound.sc, etc. Non-Room Scripts
Region Scripts BeachReg.sc, Forest Region.sc, GhostWander.sc, etc. Non-Room Scripts
Interaction Scripts PlayFlute.sc, ShootBow.sc, ReadBook.sc, etc. Non-Room Scripts
Special/Cutscene Intro.sc, CopyProtect.sc, EndMusic.sc Non-Room Scripts

Credits

  • Original Game: Sierra On-Line (1988)
  • Decompilation: Unknown decompiler tools
  • Source Code: King's Quest IV v1.006.004
  • Documentation: Created for remake project

License

This documentation is for educational and preservation purposes. King's Quest IV is a trademark of Sierra On-Line/Activision.

Description
No description provided
Readme 10 MiB
Languages
Scala 90.1%
Python 4%
C 2.9%
Csound Score 2.1%
DIGITAL Command Language 0.4%
Other 0.5%