Skip to content

Commit d57052e

Browse files
authored
Merge pull request #365 from libretro/dev
v0.32.0
2 parents 67e775e + e022a72 commit d57052e

14 files changed

+159
-96
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,18 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be
44
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
66

7+
## 0.32.0 - 2019-03-10
8+
### Features
9+
- [BunnyMark](examples/bunnymark) to test performance
10+
11+
### Chores
12+
- ChaiLove now requires content to run
13+
- Updated ChaiScript_Extras for more string methods
14+
- Updated PhysFS
15+
- Updated libretro-common
16+
- Updated random to fix a gcc 7.3+ error
17+
- Updated stb
18+
719
## 0.31.0 - 2018-12-24
820
### Chores
921
- Update to use the libretro audio callback

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ retroarch -L chailove_libretro.so FloppyBird.chailove
4040

4141
## API
4242

43-
The [ChaiLove API](https://rawgit.com/libretro/libretro-chailove/docs/) is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a [simple Hello World example](examples/simple/main.chai):
43+
The [ChaiLove API](https://raw.githack.com/libretro/libretro-chailove/docs/index.html) is roughly inspired by the [LÖVE API](https://love2d.org/wiki/Main_Page). The following `main.chai` is a [simple Hello World example](examples/simple/main.chai):
4444

4545
``` lua
4646
global logo
@@ -66,7 +66,7 @@ To run it, execute the following:
6666
retroarch -L chailove_libretro.so main.chai
6767
```
6868

69-
See the [ChaiLove API](https://rawgit.com/libretro/libretro-chailove/docs/) for coverage of all the callbacks and methods in ChaiLove.
69+
See the [ChaiLove API](https://raw.githack.com/libretro/libretro-chailove/docs/index.html) for coverage of all the callbacks and methods in ChaiLove.
7070

7171
## Development
7272

@@ -96,7 +96,7 @@ retroarch -L chailove_libretro.so test/main.chai
9696

9797
### Documentation
9898

99-
See the [ChaiLove API documentation](https://rawgit.com/libretro/libretro-chailove/docs/). Build it through [Doxygen](http://www.stack.nl/~dimitri/doxygen/) by using:
99+
See the [ChaiLove API documentation](https://raw.githack.com/libretro/libretro-chailove/docs/index.html). Build it through [Doxygen](http://www.stack.nl/~dimitri/doxygen/) by using:
100100

101101
```
102102
make docs

docs/Doxyfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API"
2323
# This could be handy for archiving the generated documentation or
2424
# if some version control system is used.
2525

26-
PROJECT_NUMBER = "0.31.0"
26+
PROJECT_NUMBER = "0.32.0"
2727

2828
# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
2929
# base path where the generated documentation will be put.

examples/bunnymark/bunny.png

449 Bytes
Loading

examples/bunnymark/main.chai

+120
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
// Copyright (c) 2018 KANO Computing Ltd.
2+
// Licensed under the GNU GPL v2
3+
//
4+
// Original by Iain Lobb
5+
// Inspired by PixieJS
6+
// Bunny Image by Amanda Lobb
7+
// https://github.com/rishavs/love2d-bunnymark
8+
// ChaiLove version by Rob Loach
9+
10+
def conf(t) {
11+
t.console = true
12+
t.window.title = "Bunnymark Mark II ; a little better!"
13+
t.window.width = 800
14+
t.window.height = 600
15+
}
16+
17+
def load() {
18+
global bunnies = List()
19+
global gravity = 0.98f
20+
21+
global maxX = love.graphics.getWidth( )
22+
global minX = 0
23+
24+
global maxY = love.graphics.getHeight( )
25+
global minY = 0
26+
27+
// optimise the bunny size for embedded devices
28+
global baseLitterSize = 50
29+
global litterSizeIncrement = 50
30+
global litterSize = baseLitterSize
31+
32+
global stdOutText = ""
33+
34+
global bunnyImg = love.graphics.newImage("bunny.png")
35+
procreate(0, 0)
36+
}
37+
38+
def draw() {
39+
love.graphics.print(to_string(bunnies.size()) + " Total Bunnies", 20, 10)
40+
love.graphics.print(to_string(litterSize) + " bunnies in each Litter", 20, 20)
41+
42+
// print the current memory usage
43+
// rounding down mem to three dig: math.floor(mem+0.5) / math.pow(10,dig)
44+
//love.graphics.print(floor(collectgarbage("count") + 0.5)/pow(10,3) + " MB Mem Usage", 20, 30)
45+
love.graphics.print("Current FPS: " + to_string(love.timer.getFPS()), 20, 40)
46+
//love.graphics.print(string.format("Elapsed clock cycles: " + to_string(%.4f", (os.clock() - x) *1000), 20, 50)
47+
48+
for (bunny : bunnies) {
49+
love.graphics.draw(bunnyImg, bunny[0], bunny[1])
50+
}
51+
}
52+
53+
def mousepressed(x, y, button) {
54+
for (var i = 0; i < litterSize; ++i) {
55+
procreate(x, y)
56+
}
57+
}
58+
59+
def joystickpressed(joystick, button) {
60+
for (var i = 0; i < litterSize; ++i) {
61+
procreate(love.graphics.getWidth() / 2.0f, love.graphics.getHeight() / 8.0f)
62+
}
63+
}
64+
65+
def update(dt) {
66+
// Initialize variables once per cycle.
67+
var tempBunnyPosX = 0.0f
68+
var tempBunnyPosY = 0.0f
69+
var tempBunnySpeedX = 0.0f
70+
var tempBunnySpeedY = 0.0f
71+
72+
for (bunny : bunnies) {
73+
// Retrieve the bunny values.
74+
tempBunnyPosX = bunny[0]
75+
tempBunnyPosY = bunny[1]
76+
tempBunnySpeedX = bunny[2]
77+
tempBunnySpeedY = bunny[3]
78+
79+
// Move the bunny.
80+
tempBunnyPosX = tempBunnyPosX + tempBunnySpeedX;
81+
tempBunnyPosY = tempBunnyPosY + tempBunnySpeedY;
82+
83+
// Adjust coordinates with world.
84+
tempBunnySpeedY = tempBunnySpeedY + gravity;
85+
if (tempBunnyPosX > maxX) {
86+
tempBunnySpeedX = tempBunnySpeedX * -0.9f;
87+
tempBunnyPosX = maxX;
88+
} else if (tempBunnyPosX < minX) {
89+
tempBunnySpeedX = tempBunnySpeedX * -0.9f;
90+
tempBunnyPosX = minX;
91+
}
92+
if (tempBunnyPosY > maxY) {
93+
tempBunnySpeedY = tempBunnySpeedY * -0.9f;
94+
tempBunnyPosY = maxY;
95+
} else if (tempBunnyPosY < minY) {
96+
tempBunnySpeedY = tempBunnySpeedY * -0.9f;
97+
tempBunnyPosY = minY;
98+
}
99+
100+
// Update the bunny
101+
bunny[0] = tempBunnyPosX
102+
bunny[1] = tempBunnyPosY
103+
bunny[2] = tempBunnySpeedX
104+
bunny[3] = tempBunnySpeedY
105+
}
106+
}
107+
108+
//------------------------------------------------
109+
// Custom functions
110+
//------------------------------------------------
111+
112+
def procreate(x,y) {
113+
var bunnyPosX = x
114+
var bunnyPosY = y
115+
var bunnySpeedX = love.math.random(-5.0f, 5.0f)
116+
var bunnySpeedY = love.math.random(-5.0f, 5.0f)
117+
var bunny = [bunnyPosX, bunnyPosY, bunnySpeedX, bunnySpeedY]
118+
119+
bunnies.push_back_ref(bunny)
120+
}

src/ChaiLove.cpp

-65
Original file line numberDiff line numberDiff line change
@@ -103,71 +103,6 @@ bool ChaiLove::load(const std::string& file, const void* data) {
103103
return true;
104104
}
105105

106-
std::string ChaiLove::demo() {
107-
// Provides a demo screen that's presented when the core is loaded without content.
108-
std::string output = R"DEMO(
109-
global defaultFont
110-
global text = "ChaiLove - No Game"
111-
global x = 50.0f
112-
global y = 50.0f
113-
global radius = 20.0f
114-
global xSpeed = 35.0f
115-
global ySpeed = 35.0f
116-
117-
def load() {
118-
defaultFont = love.graphics.getFont()
119-
x = love.graphics.getWidth() / 2.0f
120-
y = love.graphics.getHeight() / 2.0f
121-
}
122-
123-
def conf(t) {
124-
t.window.width = 320
125-
t.window.height = 240
126-
t.console = true
127-
}
128-
129-
def draw() {
130-
love.graphics.setBackgroundColor(0, 138, 255)
131-
132-
// Draw a little circle.
133-
love.graphics.setColor(230, 88, 160)
134-
love.graphics.circle("fill", x, y, radius)
135-
love.graphics.setColor(0, 0, 0)
136-
love.graphics.circle("line", x, y, radius)
137-
138-
// Draw the text.
139-
love.graphics.setColor(255, 255, 255)
140-
love.graphics.print(text, 10, love.graphics.getHeight() / 2.0f - 100)
141-
var ver = love.system.getVersionString()
142-
love.graphics.print(ver, love.graphics.getWidth() - defaultFont.getWidth(ver), love.graphics.getHeight() - defaultFont.getHeight(ver) * 2.0f)
143-
144-
love.graphics.print("FPS: " + to_string(love.timer.getFPS()), 10, love.graphics.getHeight() - defaultFont.getHeight(ver) * 2.0f)
145-
}
146-
147-
def update(dt) {
148-
x = x + xSpeed * dt
149-
y = y + ySpeed * dt
150-
if (x + radius > love.graphics.getWidth()) {
151-
x = love.graphics.getWidth() - radius
152-
xSpeed = xSpeed * -1
153-
}
154-
if (x - radius < 0) {
155-
x = radius
156-
xSpeed = abs(xSpeed)
157-
}
158-
if (y + radius > love.graphics.getHeight()) {
159-
y = love.graphics.getHeight() - radius
160-
ySpeed = ySpeed * -1
161-
}
162-
if (y - radius < 0) {
163-
y = radius
164-
ySpeed = abs(ySpeed)
165-
}
166-
}
167-
)DEMO";
168-
return output;
169-
}
170-
171106
void ChaiLove::update() {
172107
// Update and poll all the events.
173108
event.update();

src/ChaiLove.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@
4545
#define SRC_CHAILOVE_H_
4646

4747
#define CHAILOVE_VERSION_MAJOR 0
48-
#define CHAILOVE_VERSION_MINOR 31
48+
#define CHAILOVE_VERSION_MINOR 32
4949
#define CHAILOVE_VERSION_PATCH 0
50-
#define CHAILOVE_VERSION_STRING "0.31.0"
50+
#define CHAILOVE_VERSION_STRING "0.32.0"
5151

5252
#include "SDL.h"
5353
#include "libretro.h"
@@ -99,7 +99,6 @@ class ChaiLove {
9999
love::math math;
100100
love::window window;
101101
love::event event;
102-
std::string demo();
103102

104103
~ChaiLove();
105104
void quit(void);

src/libretro.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ void retro_set_environment(retro_environment_t cb) {
5757
// Set the environment callback.
5858
ChaiLove::environ_cb = cb;
5959

60-
// The core supports having no game.
61-
bool no_rom = true;
60+
// The core requires content.
61+
bool no_rom = false;
6262
cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_rom);
6363

6464
// Set the Variables.
@@ -208,7 +208,7 @@ void retro_get_system_av_info(struct retro_system_av_info *info) {
208208
info->geometry.base_width = width;
209209
info->geometry.base_height = height;
210210
info->geometry.max_width = width;
211-
info->geometry.max_height = width;
211+
info->geometry.max_height = height;
212212
info->geometry.aspect_ratio = static_cast<float>(width) / static_cast<float>(height);
213213

214214
info->timing.fps = 60.0;

src/love/script.cpp

+13-16
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,13 @@ script::script(const std::string& file) {
115115
// ChaiScript Standard Library Additions
116116
// This adds some basic type definitions to ChaiScript.
117117
chai.add(bootstrap::standard_library::vector_type<std::vector<int>>("VectorInt"));
118+
chai.add(bootstrap::standard_library::vector_type<std::vector<float>>("VectorFloat"));
118119
chai.add(bootstrap::standard_library::vector_type<std::vector<std::string>>("StringVector"));
119120
chai.add(bootstrap::standard_library::map_type<std::map<std::string, bool>>("StringBoolMap"));
121+
chai.add(bootstrap::standard_library::map_type<std::map<std::string, int>>("StringIntMap"));
122+
chai.add(bootstrap::standard_library::map_type<std::map<std::string, float>>("StringFloatMap"));
120123

124+
// ChaiScript_Extras: String Methods
121125
auto stringmethods = chaiscript::extras::string_methods::bootstrap();
122126
chai.add(stringmethods);
123127

@@ -413,23 +417,16 @@ script::script(const std::string& file) {
413417
// Ensure the love namespace is imported and ready.
414418
chai.import("love");
415419

416-
// Load the desired main.chai file.
417-
if (file.empty()) {
418-
// When no content is provided, display a No Game demo.
419-
eval(app->demo(), "demo.chai");
420-
mainLoaded = true;
421-
} else {
422-
// Load the main.chai file.
423-
require("conf");
420+
// Load the main.chai file.
421+
require("conf");
424422

425-
std::string extension(app->filesystem.getFileExtension(file));
426-
if (extension == "chailove" || extension == "chaigame") {
427-
mainLoaded = require("main");
428-
} else {
429-
// Otherwise, load the actual file.
430-
std::string filename(app->filesystem.getBasename(file));
431-
mainLoaded = require(filename);
432-
}
423+
std::string extension(app->filesystem.getFileExtension(file));
424+
if (extension == "chailove" || extension == "chaigame") {
425+
mainLoaded = require("main");
426+
} else {
427+
// Otherwise, load the actual file.
428+
std::string filename(app->filesystem.getBasename(file));
429+
mainLoaded = require(filename);
433430
}
434431

435432
// Find the game functions.

vendor/libretro-common

Submodule libretro-common updated 161 files

vendor/random

0 commit comments

Comments
 (0)