Commit 7c37cd90 authored by Jack's avatar Jack
Browse files

Merge branch 'master' of github.com:Jakz/retro8

parents 26b11781 f1e6e1c0
......@@ -509,7 +509,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
}
case '+': {
next(ls);
if (check_next1(ls, '='))
if (check_next1(ls, '='))
return TK_ASSADD;
else return '+';
}
......@@ -550,7 +550,7 @@ static int llex (LexState *ls, SemInfo *seminfo) {
case 0xE2:
case 0xF0:
{
static char down_arrow[] = { 0xe2, 0xac, 0x87, 0xef, 0xb8, 0x8f };
static char up_arrow[] = { 0xe2, 0xac, 0x86, 0xef, 0xb8, 0x8f };
static char left_arrow[] = { 0xe2, 0xac, 0x85, 0xef, 0xb8, 0x8f };
......@@ -569,7 +569,8 @@ static int llex (LexState *ls, SemInfo *seminfo) {
save_and_next(ls);
anyValid = 0;
for (int i = 0; i < sizeof(keys) / sizeof(keys[0]); ++i)
int i;
for (i = 0; i < sizeof(keys) / sizeof(keys[0]); ++i)
{
if (memcmp(ls->buff->buffer, keys[i], ls->buff->n) == 0)
{
......@@ -631,4 +632,3 @@ int luaX_lookahead (LexState *ls) {
ls->lookahead.token = llex(ls, &ls->lookahead.seminfo);
return ls->lookahead.token;
}
......@@ -1505,7 +1505,7 @@ static int test_then_block (LexState *ls, int *escapelist) {
while (testnext(ls, ';')) {} /* skip colons */
if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
leaveblock(fs);
return 0; /* and that is it */
return; /* and that is it */
}
else /* must skip over 'then' part if condition is false */
jf = luaK_jump(fs);
......
......@@ -6,6 +6,8 @@
#include <functional>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#pragma warning(push)
#pragma warning(disable: 4244)
......@@ -445,7 +447,7 @@ namespace math
assert(lua_isnumber(L, 1));
real_t angle = lua_tonumber(L, 1);
real_t value = ::cos(angle * 2 * PI);
real_t value = std::cos(angle * 2 * PI);
lua_pushnumber(L, value);
return 1;
......@@ -456,7 +458,7 @@ namespace math
assert(lua_isnumber(L, 1));
real_t angle = lua_tonumber(L, 1);
real_t value = ::sin(-angle * 2 * PI);
real_t value = std::sin(-angle * 2 * PI);
lua_pushnumber(L, value);
return 1;
......@@ -468,7 +470,7 @@ namespace math
//TODO: check if behavior is same as PICO-8
real_t dx = lua_tonumber(L, 1);
real_t dy = lua_tonumber(L, 2);
real_t value = ::atan2(dx, -dy);
real_t value = std::atan2(dx, -dy);
lua_pushnumber(L, value);
return 1;
......@@ -498,7 +500,7 @@ namespace math
assert(lua_isnumber(L, 1));
real_t value = lua_tonumber(L, 1);
lua_pushnumber(L, ::floor(value));
lua_pushnumber(L, std::floor(value));
return 1;
}
......@@ -508,7 +510,7 @@ namespace math
assert(lua_isnumber(L, 1));
real_t value = lua_tonumber(L, 1);
lua_pushnumber(L, ::ceil(value));
lua_pushnumber(L, std::ceil(value));
return 1;
}
......@@ -704,7 +706,7 @@ namespace string
//TODO implement
static char buffer[20];
switch (lua_type(L, 1))
{
case LUA_TBOOLEAN: lua_pushstring(L, lua_toboolean(L, 1) ? "true" : "false"); break;
......
#include "machine.h"
#include <algorithm>
using namespace retro8;
void Machine::flip()
......@@ -10,14 +12,14 @@ void Machine::flip()
for (size_t i = 0; i < gfx::BYTES_PER_SCREEN; ++i)
{
const gfx::color_byte_t* pixels = data + i;
const gfx::color_byte_t* pixels = data + i;
const auto rc1 = retro8::gfx::ColorTable::get(screenPalette->get((pixels)->low()));
const auto rc2 = retro8::gfx::ColorTable::get(screenPalette->get((pixels)->high()));
*(dest) = rc1;
*((dest)+1) = rc2;
(dest) += 2;
//RASTERIZE_PIXEL_PAIR((*this), dest, pixels);
}
}
......@@ -145,7 +147,7 @@ void Machine::circ(coord_t xc, coord_t yc, amount_t r, color_t color)
coord_t x = 0, y = r;
float d = 3 - 2 * r;
circHelper(xc, yc, x, y, color);
while (y >= x)
{
x++;
......@@ -195,7 +197,7 @@ void Machine::circfill(coord_t xc, coord_t yc, amount_t r, color_t color)
}
void Machine::spr(index_t idx, coord_t x, coord_t y)
{
{
const gfx::sprite_t* sprite = _memory.spriteAt(idx);
const gfx::palette_t* palette = _memory.paletteAt(gfx::DRAW_PALETTE_INDEX);
......@@ -211,20 +213,20 @@ void Machine::spr(index_t idx, coord_t x, coord_t y)
void Machine::spr(index_t idx, coord_t bx, coord_t by, float sw, float sh, bool flipX, bool flipY)
{
const gfx::palette_t* palette = _memory.paletteAt(gfx::DRAW_PALETTE_INDEX);
coord_t w = sw * gfx::SPRITE_WIDTH;
coord_t h = sh * gfx::SPRITE_HEIGHT;
/* we bypass spriteAt since we can use directly the address */
const gfx::color_byte_t* base = reinterpret_cast<const gfx::color_byte_t*>(_memory.spriteAt(idx));
for (coord_t y = 0; y < h; ++y)
{
for (coord_t x = 0; x < w; ++x)
{
coord_t fx = flipX ? (w - x - 1) : x;
coord_t fy = flipY ? (h - y - 1) : y;
//TODO: optimize by fetching only once if we need to read next pixel?
const gfx::color_byte_t pair = *(base + y * gfx::SPRITE_SHEET_PITCH + x / gfx::PIXEL_TO_BYTE_RATIO);
const color_t color = pair.get(x);
......@@ -287,7 +289,7 @@ void Machine::print(const std::string& string, coord_t x, coord_t y, color_t col
for (size_t i = 0; i < string.length(); ++i)
{
auto c = string[i];
const bool isSpecial = std::find(Prefixes.begin(), Prefixes.end(), c) != Prefixes.end();
auto specialGlyph = std::find_if(SpecialGlyphs.begin(), SpecialGlyphs.end(), [&string, &i](const SpecialGlyph& glyph) {
......@@ -343,6 +345,3 @@ void Machine::map(coord_t cx, coord_t cy, coord_t x, coord_t y, amount_t cw, amo
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment