Code Monkey home page Code Monkey logo

p8advent's Introduction

p8advent

This will eventually be an adventure game toolkit for the Pico-8 virtual console. Right now it's just some data format and workflow experiments. :)

Currently the only thing here are some experiments with packing text strings into cart data. The p8advent tool (see tool.py) uses a specially-marked Lua source file to create a Pico-8 cart with string literals extracted into the cart data region, packed using a given text packing library.

textlib was an early attempt at a dictionary-based packing library that focused on English words, inspired by methods used by old text adventure games. It stores both the code stream and the dictionary in cart data, and so requires minimal RAM to access strings. In the context of Pico-8, it's not very satisfying: the compression rate for a long wordy text (A Tale of Two Cities by Charles Dickens) only compressed to about 75% the original size. Simply packing the 6-bit character set into 8-bit strings (a reasonable method not yet implemented here) would be as effective, so a fancier algorithm has to do better than this.

lzwlib uses the LZW compression algorithm with variable-width codes. All strings share the same dictionary to maximize packing, but are stored byte-aligned with headers so they can be accessed directly. This requires that the Lua code reconstruct the dictionary in RAM before accessing any strings. The Dickens test text compresses to 48% when using as much Lua RAM as possible for the largest possible dictionary. Capping the dictionary at 4,096 entries bumps this up to about 60% for this text.

Of course, ToTC is not a typical text corpus for a game, even a large text-based game. I'll need to make an actual game that uses a lot of text to demonstrate that fancy packing techniques are actually profitable. It seems likely that a game that uses both text and graphics and wants to store strings could simply use a bit stream of 6-bit characters.

p8advent's People

Contributors

dansanderson avatar greay avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.