Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
nesbox committed Oct 22, 2023
2 parents b743434 + 0937023 commit f9e3229
Show file tree
Hide file tree
Showing 31 changed files with 876 additions and 896 deletions.
8 changes: 8 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,14 @@ jobs:
runs-on: windows-2019

steps:
# https://github.com/actions/runner-images/issues/2642#issuecomment-774988591
- name: configure Pagefile
uses: al-cheb/[email protected]
with:
minimum-size: 16GB
maximum-size: 16GB
disk-root: "C:"

- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
Expand Down
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
*.ipch
*.opendb
*.suo
compile_commands.json
compile_flags.txt
sexit
.vscode/
build/install_manifest.txt
Expand Down Expand Up @@ -179,4 +181,4 @@ build/mruby_vendor-prefix/
**/zig-cache
**/zig-out
.cache
*~
*~
39 changes: 12 additions & 27 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,39 +397,24 @@ target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/squirrel)
target_include_directories(squirrel PRIVATE ${SQUIRREL_DIR}/sqstdlib)

################################
# PocketPy (Python)
# pocketpy (Python)
################################

set(POCKETPY_DIR ${THIRDPARTY_DIR}/pocketpy)
add_subdirectory(${THIRDPARTY_DIR}/pocketpy)
target_compile_definitions(pocketpy PRIVATE PK_ENABLE_OS=0)
include_directories(${THIRDPARTY_DIR}/pocketpy/include)

if (${CMAKE_VERSION} VERSION_LESS "3.12.0")
set(Python3_EXECUTABLE "python3")
else()
find_package(Python3 COMPONENTS Interpreter)
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(pocketpy PRIVATE -Wno-psabi)
endif()

add_custom_command(
OUTPUT ${POCKETPY_DIR}/src/_generated.h
COMMAND ${Python3_EXECUTABLE} preprocess.py
WORKING_DIRECTORY ${POCKETPY_DIR}
DEPENDS ${POCKETPY_DIR}/preprocess.py
)

add_library(python STATIC
${POCKETPY_DIR}/src/_generated.h
${POCKETPY_DIR}/c_bindings/pocketpy_c.cpp
)

set_target_properties(python PROPERTIES LINKER_LANGUAGE CXX)
target_compile_definitions(python PRIVATE PK_ENABLE_OS=0)
target_include_directories(python
PRIVATE ${POCKETPY_DIR}/src
PUBLIC ${POCKETPY_DIR}/c_bindings)
# alias pocketpy to python for next steps
set_target_properties(pocketpy PROPERTIES OUTPUT_NAME python)
add_library(python ALIAS pocketpy)

if (${CMAKE_VERSION} VERSION_LESS "3.8.0")
set_target_properties(python PROPERTIES COMPILE_FLAGS "--std=c++17")
else()
target_compile_features(python PRIVATE cxx_std_17)
if(EMSCRIPTEN)
# exceptions must be enabled for emscripten
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fexceptions")
endif()

################################
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,14 @@ sudo apt-get install -t jessie-backports liblua5.3-dev
git clone --recursive https://github.com/nesbox/TIC-80 && cd TIC-80/build
cmake ..
make -j4
# install software ubuntu 22.04.3 LTS
sudo apt-get install git build-essential ruby-full libsdl2-dev zlib1g-dev
sudo apt-get install liblua5.3-dev
sudo apt-get install libcurl4-openssl-dev
git clone --recursive https://github.com/nesbox/TIC-80 && cd TIC-80/build
cmake ..
make -j4
```
Install with [Install instructions](#install-instructions)

Expand Down Expand Up @@ -250,3 +258,4 @@ You can find iOS/tvOS version here
* David St-Hilaire - [GitHub @sthilaid](https://github.com/sthilaid)
* Alec Troemel - [Github @alectroemel](https://github.com/AlecTroemel)
* Kolten Pearson - [Github @koltenpearson](https://github.com/koltenpearson)
* Cort Stratton - [Github @cdwfs](https://github.com/cdwfs)
2 changes: 1 addition & 1 deletion build/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ android {
versionCode 10100
versionName "1.01.00"
ndk {
abiFilters 'arm64-v8a'
abiFilters 'arm64-v8a', 'armeabi-v7a'
}
externalNativeBuild {
ndkBuild {
Expand Down
6 changes: 3 additions & 3 deletions build/janet/janetconf.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#define JANETCONF_H

#define JANET_VERSION_MAJOR 1
#define JANET_VERSION_MINOR 29
#define JANET_VERSION_PATCH 1
#define JANET_VERSION_MINOR 31
#define JANET_VERSION_PATCH 0
#define JANET_VERSION_EXTRA ""
#define JANET_VERSION "1.29.1"
#define JANET_VERSION "1.31.0"

/* #define JANET_BUILD "local" */

Expand Down
24 changes: 16 additions & 8 deletions demos/bunny/wasmmark/build.zig
Original file line number Diff line number Diff line change
@@ -1,19 +1,27 @@
const std = @import("std");

pub fn build(b: *std.build.Builder) void {
const mode = b.standardReleaseOptions();
pub fn build(b: *std.Build) !void {
const optimize = b.standardOptimizeOption(.{});

const lib = b.addSharedLibrary(.{
.name = "cart",
.root_source_file = .{ .path = "src/main.zig" },
.target = .{ .cpu_arch = .wasm32, .os_tag = .wasi },
.optimize = optimize,
});

const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned);
lib.setBuildMode(mode);
lib.setTarget(.{ .cpu_arch = .wasm32, .os_tag = .freestanding });
lib.import_memory = true;
lib.stack_size = 8192;
lib.initial_memory = 65536 * 4;
lib.max_memory = 65536 * 4;

lib.export_table = true;

// all the memory below 96kb is reserved for TIC and memory mapped I/O
// so our own usage must start above the 96kb mark
lib.global_base = 96 * 1024;
lib.stack_size = 8192;
lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "SCR", "BOOT" };
lib.install();

lib.export_symbol_names = &[_][]const u8{ "TIC", "OVR", "BDR", "BOOT" };

b.installArtifact(lib);
}
115 changes: 56 additions & 59 deletions demos/bunny/wasmmark/src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@
const tic = @import("tic80.zig");
const std = @import("std");
const RndGen = std.rand.DefaultPrng;
var rnd : std.rand.Random = undefined;
var rnd: std.rand.Random = undefined;

const screenWidth = 240;
const screenHeight = 136;
const toolbarHeight = 6;
var t : u32 = 0;
var t: u32 = 0;

fn randomFloat(lower: f32, greater: f32) f32 {
return rnd.float(f32) * (greater-lower) + lower;
return rnd.float(f32) * (greater - lower) + lower;
}

const Bunny = struct {
Expand All @@ -39,11 +39,7 @@ const Bunny = struct {
}

fn draw(self: Bunny) void {
tic.spr(self.sprite, @floatToInt(i32,self.x), @floatToInt(i32,self.y), .{
.transparent = &.{1},
.w = 4,
.h = 4
});
tic.spr(self.sprite, @intFromFloat(self.x), @intFromFloat(self.y), .{ .transparent = &.{1}, .w = 4, .h = 4 });
}

fn update(self: *Bunny) void {
Expand All @@ -66,7 +62,6 @@ const Bunny = struct {
self.speedY = self.speedY * -1;
}
}

};

const FPS = struct {
Expand All @@ -93,9 +88,9 @@ const FPS = struct {
};

const MAX_BUNNIES = 1200;
var fps : FPS = undefined;
var bunnyCount : usize = 0;
var bunnies : [MAX_BUNNIES]Bunny = undefined;
var fps: FPS = undefined;
var bunnyCount: usize = 0;
var bunnies: [MAX_BUNNIES]Bunny = undefined;

fn addBunny() void {
if (bunnyCount >= MAX_BUNNIES) return;
Expand All @@ -105,81 +100,83 @@ fn addBunny() void {
}

fn removeBunny() void {
if (bunnyCount==0) return;
if (bunnyCount == 0) return;

bunnyCount -= 1;
}

export fn testscreen() void {
var i : usize = 0;

while (i<2000) {
// tic.ZERO.* = 0x99;
tic.FRAMEBUFFER[i]=0x56;
// tic.FRAMEBUFFER2.*[i]=0x67;
// tic.ZERO[i]= 0x56;
// bunnies[i].draw();
i += 1;
var i: usize = 0;

while (i < 2000) {
// tic.ZERO.* = 0x99;
tic.FRAMEBUFFER[i] = 0x56;
// tic.FRAMEBUFFER2.*[i]=0x67;
// tic.ZERO[i]= 0x56;
// bunnies[i].draw();
i += 1;
}
}

export fn BOOT() void {
rnd = RndGen.init(0).random();
var xoshiro = RndGen.init(0);
rnd = xoshiro.random();
fps.initFPS();
addBunny();
}

export fn TIC() void {
if (t==0) {
if (t == 0) {
tic.music(0, .{});
}
if (t == 6*64*2.375) {
if (t == 6 * 64 * 2.375) {
tic.music(1, .{});
}
t = t + 1;


if (tic.btn(0)) {
var i : i32 = 0;
while (i<5) {
addBunny();
i+=1;
if (tic.btn(0)) {
var i: i32 = 0;
while (i < 5) {
addBunny();
i += 1;
}
}
}

if (tic.btn(1)) {
var i : i32 = 0;
while (i<5) {
removeBunny();
i+=1;
if (tic.btn(1)) {
var i: i32 = 0;
while (i < 5) {
removeBunny();
i += 1;
}
}
}

// -- Update
var i : u32 = 0;
while (i<bunnyCount) {
bunnies[i].update();
i += 1;
}

// -- Draw
tic.cls(15);
i = 0;
while (i<bunnyCount) {
bunnies[i].draw();
i += 1;
}
// -- Update
var i: u32 = 0;
while (i < bunnyCount) {
bunnies[i].update();
i += 1;
}

// -- Draw
tic.cls(15);
i = 0;
while (i < bunnyCount) {
bunnies[i].draw();
i += 1;
}

tic.rect(0, 0, screenWidth, toolbarHeight, 9);
tic.rect(0, 0, screenWidth, toolbarHeight, 9);

_ = tic.printf("Bunnies: {d}", .{bunnyCount}, 1, 0, .{.color = 11});
_ = tic.printf("FPS: {d:.4}", .{fps.getValue()}, screenWidth / 2, 0, .{.color = 11});
_ = tic.print("hello people", 10, 10, .{.color = 11});
_ = tic.printf("Bunnies: {d}", .{bunnyCount}, 1, 0, .{ .color = 11 });
_ = tic.printf("FPS: {d:.4}", .{fps.getValue()}, screenWidth / 2, 0, .{ .color = 11 });
_ = tic.print("hello people", 10, 10, .{ .color = 11 });

// var x : u32 = 100000000;
// tic.FRAMEBUFFER[x] = 56;
// var x : u32 = 100000000;
// tic.FRAMEBUFFER[x] = 56;

// testscreen();
// testscreen();
}

export fn BDR() void {}

export fn OVR() void {}
Loading

0 comments on commit f9e3229

Please sign in to comment.