progress!

This commit is contained in:
dylan 2024-03-29 02:02:40 -07:00
parent 2721848afa
commit d4d436f34a
13 changed files with 178 additions and 4628 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 442 B

View File

@ -1,72 +0,0 @@
SOFTWARE LICENSE AGREEMENT FOR PICO-8
This license agreement is between you, the end user, and Lexaloffle Games LLP ("LEXALOFFLE GAMES"). The software licensed under this agreement is PICO-8 ("THE SOFTWARE"), including all data files, executables, documentation and design. By distributing, copying, executing, or otherwise using THE SOFTWARE, you agree to be bound by the terms of this license agreement.
THE SOFTWARE is owned by LEXALOFFLE GAMES. LEXALOFFLE GAMES reserves the exclusive copyright and all rights not expressly granted.
You may install and use THE SOFTWARE on any computers for which you are the primary user. You may additionally install and use THE SOFTWARE concurrently on any number of computers belonging to a single household or educational organisation, including libraries, clubs, schools and universities.
Unless express consent is granted by LEXALOFFLE GAMES, you may not distribute all of or any part of THE SOFTWARE to any other party, create derivative works based on THE SOFTWARE, or sell, resell, rent or lease THE SOFTWARE.
EXPORTED CARTRIDGES
Files generated by exporting a cartridge with PICO-8 (Javascript, HTML, executeables and data files) may be used for any purpose, including commercial applications, and to alter them and redistribute them freely, provided that permission to do so is also granted by the authors of the cartridge.
DISCLAIMER
THE SOFTWARE IS PROVIDED "AS-IS" WITHOUT WARRANTY OF ANY KIND. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, LEXALOFFLE GAMES DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, IN NO EVENT SHALL LEXALOFFLE GAMES BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING BUT NOT LIMITED TO ANY LOSS OF PRODUCTIVITY, LOSS OF DATA, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF, OR INABILITY TO USE THE SOFTWARE, EVEN IF LEXALOFFLE GAMES HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
========================================================================================
PICO-8 is built with Lua 5.2
http://www.lua.org
----- Software License and Copyright Notice for Lua follows -----
Lua 5.2 Copyright © 19942015 Lua.org, PUC-Rio.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
========================================================================================
PICO-8 is built with rpi_ws281x
https://github.com/jgarff/rpi_ws281x
----- Software License and Copyright Notice for rpi_ws281x follows -----
Copyright (c) 2014, jgarff
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,50 +0,0 @@
:: PICO-8 Linux Builds
On many linux distributions, PICO-8 will run out of the box (just unzip and run pico8), but it does
require wget to perform BBS downloads. To make sure wget is installed:
$ sudo apt-get install wget
You may need to ensure the pico8 file is executable:
$ sudo chmod +x pico8
There are two different builds in this archive:
pico8 // statically linked sdl2
pico8_dyn // dynamically linked sdl2
pico8_dyn can be used if you would like to provide your own sdl2, or to use the sdl2 built for your distribution:
$ sudo apt-get install libsdl2-dev
:: Video Configuration
By default, PICO-8 runs fullscreen using OpenGL to blit (via SDL2). A software blitter can be used instead:
$ pico8 -software_blit 1
Alt+Enter can be used to toggle fullscreen, or the -windowed switch can be used to start up in in a window:
$ pico8 -windowed 1
There are several methods for blitting to fullscreen:
$ pico8 -fullscreen_method 0 // Maximized Window (default) // SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_MAXIMIZED | SDL_WINDOW_INPUT_GRABBED;
$ pico8 -fullscreen_method 1 // Borderless Desktop-sized window // SDL_WINDOW_FULLSCREEN_DESKTOP
$ pico8 -fullscreen_method 2 // Hardware Fullscreen (erratic behaviour under some drivers)
0 and 1 are very similar, but might behave differently on some distributions. 2 is normally not recommended or needed.
These options can also be set in ~/.lexaloffle/pico-8/config.txt, which is generated when PICO-8 closes.

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,29 @@
// @ts-ignore
import renderCart from "./build/rawRenderCart.js";
type PicoBool = 0 | 1;
type RenderCart = (Module: {canvas: HTMLCanvasElement}, cartNames: string[], cartDatas: number[][]) => {
p8_touch_detected?: PicoBool;
p8_dropped_cart?: string;
p8_dropped_cart_name?: string;
pico8_state?: Partial<{
frame_number: number;
has_focus: PicoBool;
is_paused: PicoBool;
request_pointer_lock: PicoBool;
require_page_navigate_confirmation: PicoBool;
show_dpad: PicoBool;
shutdown_requested: PicoBool;
sound_volume: number;
}>;
pico8_buttons?: [number, number, number, number, number, number, number, number];
pico8_gamepads?: {count: number};
pico8_gpio?: number[]; // should be 128 length
pico8_audio_context?: AudioContext;
pico8_mouse?: [number, number, number];
}
const typedRenderCart = renderCart as RenderCart;
export {typedRenderCart as renderCart}

View File

@ -0,0 +1,126 @@
import { renderCart as rawRenderCart } from "./rawRenderCart";
type PicoCart = {
name: string;
data: string; // TODO: ideally, accept png data url as well (or even just actual url?)
}
type PlayerButtons = {
left: boolean;
right: boolean;
up: boolean;
down: boolean;
o: boolean;
x: boolean;
menu: boolean;
}
type PicoPlayerHandle = {
// external things
readonly canvas: HTMLCanvasElement;
// i/o
setButtons: (buttons: PlayerButtons[]) => void;
setMouse: (mouse: {
x: number;
y: number;
leftClick: boolean;
rightClick: boolean;
}) => void;
setGamepadCount: (count: number) => void;
readonly gpio: number[]; // read + write (should be 256-tuple)
// audio
setAudioContext: (audioContext: AudioContext) => void;
// state (all communicated out)
readonly state: {
readonly frameNumber: number;
readonly isPaused: boolean;
readonly hasFocus: boolean;
readonly requestPointerLock: boolean;
readonly requirePageNavigateConfirmation: boolean;
readonly showDpad: boolean;
readonly shutdownRequested: boolean;
readonly soundVolume: number;
};
// misc?
setTouchDetected: (touchDetected: boolean) => void;
dropCart: (cart: PicoCart) => void;
}
const imageToNumbers = async (url: string): Promise<number[]> => {
return [];
}
const bitfield = (...args: boolean[]): number => {
if (!args.length) {
return 0;
}
return (args[0]?1:0)+2*bitfield(...args.slice(1));
}
export const makePlayer = async (carts: PicoCart[]): Promise<PicoPlayerHandle> => {
const canvas = document.createElement("canvas");
canvas.style.imageRendering = "pixelated";
const Module = {canvas};
const handle = rawRenderCart(Module, carts.map(cart => cart.name), await Promise.all(carts.map(cart => imageToNumbers(cart.data))));
handle.pico8_state = {};
handle.pico8_buttons = [0,0,0,0,0,0,0,0];
handle.pico8_mouse = [0,0,0];
handle.pico8_gpio = [
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
];
handle.pico8_gamepads = {count: 0};
return {
canvas,
state: {
frameNumber: handle.pico8_state.frame_number!,
isPaused: !!handle.pico8_state.is_paused!,
hasFocus: !!handle.pico8_state.has_focus!,
requestPointerLock: !!handle.pico8_state.request_pointer_lock!,
requirePageNavigateConfirmation: !!handle.pico8_state.require_page_navigate_confirmation!,
showDpad: !!handle.pico8_state.show_dpad!,
shutdownRequested: !!handle.pico8_state.shutdown_requested!,
soundVolume: handle.pico8_state.sound_volume!,
},
gpio: handle.pico8_gpio,
setMouse({x, y, leftClick, rightClick}) {
handle.pico8_mouse = [x, y, bitfield(leftClick, rightClick)];
},
setButtons(buttons) {
// TODO: pad this properly here instead of casting
handle.pico8_buttons = buttons.map(({left, right, up, down, o, x, menu}) => bitfield(left, right, up, down, o, x, menu)) as any;
},
setGamepadCount(count) {
handle.pico8_gamepads = {count};
},
setTouchDetected(touchDetected) {
handle.p8_touch_detected = touchDetected ? 1 : 0;
},
dropCart(cart) {
handle.p8_dropped_cart_name = cart.name;
// TODO: make sure this is a dataURL first, and if not, load it and then pass it in
handle.p8_dropped_cart = cart.data;
},
setAudioContext(audioContext) {
handle.pico8_audio_context = audioContext;
}
}
}

File diff suppressed because one or more lines are too long

View File

@ -24,15 +24,15 @@ const execPico = async (args: string[]) => {
}
export const pico8 = {
async export(fileIn: string, fileOut: string) {
async export(filesIn: string[], fileOut: string) {
try {
// console.log((await cmd("ls", ["-la", "/app/pico8"]) as any).stdout)
return await execPico([fileIn, "-export", fileOut]);
return await execPico([...filesIn, "-export", fileOut]);
} catch (err) {
console.log("CAUGHT ERROR", err);
}
}
}
// const result = await pico8.export("/home/dylan/.lexaloffle/pico-8/carts/my-pico-project/mygame.p8", "/home/dylan/repos/picobook/sample.p8.png");
// const result = await pico8.export(["/home/dylan/.lexaloffle/pico-8/carts/my-pico-project/mygame.p8","/home/dylan/.lexaloffle/pico-8/carts/my-pico-project/secondcart.p8"], "/home/dylan/repos/picobook/sample2.js");
// console.log(result);

View File

@ -2,6 +2,7 @@
"compilerOptions": {
"target": "es2017",
"module": "es2022",
"lib": ["DOM"],
"moduleResolution": "node",
"jsx": "react-jsx",
"allowImportingTsExtensions": true,