Skip to content

Commit

Permalink
Add wingetopt
Browse files Browse the repository at this point in the history
  • Loading branch information
emmachase committed Aug 24, 2022
1 parent 880c7ef commit 693aa90
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 7 deletions.
105 changes: 105 additions & 0 deletions libs/include/getopt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#ifndef __GETOPT_H__
/**
* DISCLAIMER
* This file has no copyright assigned and is placed in the Public Domain.
* This file is a part of the w64 mingw-runtime package.
*
* The w64 mingw-runtime package and its code is distributed in the hope that it
* will be useful but WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESSED OR
* IMPLIED ARE HEREBY DISCLAIMED. This includes but is not limited to
* warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/

#define __GETOPT_H__

/* All the headers include this file. */
#include <crtdefs.h>

#if defined( WINGETOPT_SHARED_LIB )
# if defined( BUILDING_WINGETOPT_DLL )
# define WINGETOPT_API __declspec(dllexport)
# else
# define WINGETOPT_API __declspec(dllimport)
# endif
#else
# define WINGETOPT_API
#endif

#ifdef __cplusplus
extern "C" {
#endif

WINGETOPT_API extern int optind; /* index of first non-option in argv */
WINGETOPT_API extern int optopt; /* single option character, as parsed */
WINGETOPT_API extern int opterr; /* flag to enable built-in diagnostics... */
/* (user may set to zero, to suppress) */

WINGETOPT_API extern char *optarg; /* pointer to argument of current option */

extern int getopt(int nargc, char * const *nargv, const char *options);

#ifdef _BSD_SOURCE
/*
* BSD adds the non-standard `optreset' feature, for reinitialisation
* of `getopt' parsing. We support this feature, for applications which
* proclaim their BSD heritage, before including this header; however,
* to maintain portability, developers are advised to avoid it.
*/
# define optreset __mingw_optreset
extern int optreset;
#endif
#ifdef __cplusplus
}
#endif
/*
* POSIX requires the `getopt' API to be specified in `unistd.h';
* thus, `unistd.h' includes this header. However, we do not want
* to expose the `getopt_long' or `getopt_long_only' APIs, when
* included in this manner. Thus, close the standard __GETOPT_H__
* declarations block, and open an additional __GETOPT_LONG_H__
* specific block, only when *not* __UNISTD_H_SOURCED__, in which
* to declare the extended API.
*/
#endif /* !defined(__GETOPT_H__) */

#if !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__)
#define __GETOPT_LONG_H__

#ifdef __cplusplus
extern "C" {
#endif

struct option /* specification for a long form option... */
{
const char *name; /* option name, without leading hyphens */
int has_arg; /* does it take an argument? */
int *flag; /* where to save its status, or NULL */
int val; /* its associated status value */
};

enum /* permitted values for its `has_arg' field... */
{
no_argument = 0, /* option never takes an argument */
required_argument, /* option always requires an argument */
optional_argument /* option may take an argument */
};

extern int getopt_long(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
extern int getopt_long_only(int nargc, char * const *nargv, const char *options,
const struct option *long_options, int *idx);
/*
* Previous MinGW implementation had...
*/
#ifndef HAVE_DECL_GETOPT
/*
* ...for the long form API only; keep this for compatibility.
*/
# define HAVE_DECL_GETOPT 1
#endif

#ifdef __cplusplus
}
#endif

#endif /* !defined(__UNISTD_H_SOURCED__) && !defined(__GETOPT_LONG_H__) */
Binary file added libs/libwingetopt.a
Binary file not shown.
22 changes: 15 additions & 7 deletions scripts/home/games/tetris/main.rlua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ local nextPieces = 5 -- 2--
local animationMultiplier = 1

local bigMode = false
-- tileScale = tileScale * 2
if bigMode then
-- boardWidth = boardWidth / 2
boardWidth = boardWidth / 2
boardHeight = boardHeight / 2
visibleBoard = visibleBoard / 2
tileScale = tileScale * 2
end

local gameOptions = {
Expand Down Expand Up @@ -1024,7 +1024,7 @@ function _update(dt)
end

if gameState.controller.reset and not heldReset then
drawState.resetBar = drawState.resetBar + (1.1 - drawState.resetBar)*0.05
drawState.resetBar = drawState.resetBar + 0.025 -- (1.1 - drawState.resetBar)*0.05
if drawState.resetBar >= 1 then
drawState.resetBar = 0
heldReset = true
Expand Down Expand Up @@ -1075,6 +1075,14 @@ local function writeRight(str, bw, y, c, cb)
write(str, x, y, c)
end

local function normalNaN(x)
if x ~= x then
return 0
else
return x
end
end

function _draw()
cls()

Expand All @@ -1087,16 +1095,16 @@ function _draw()
local amult = animationMultiplier

local shake = amult * drawState.shake * (tileScale / 5)
drawState.shake = drawState.shake * (0.9 / amult)
drawState.shake = drawState.shake * normalNaN(0.9 / amult)
trans(math.random(-shake, shake), math.random(-shake, shake))

trans(amult*drawState.push.x, amult*drawState.push.y)
if not drawState.pushing then
drawState.push.x = drawState.push.x * (0.9 / amult)
drawState.push.y = drawState.push.y * (0.9 / amult)
drawState.push.x = drawState.push.x * normalNaN(0.9 / amult)
drawState.push.y = drawState.push.y * normalNaN(0.9 / amult)
end

drawState.rotate = drawState.rotate * (0.9 / amult)
drawState.rotate = drawState.rotate * normalNaN(0.9 / amult)

-- These ghosts go first because they're really noisy
for ghost in values(drawState.tileGhosts) do
Expand Down
2 changes: 2 additions & 0 deletions src/core/rikoProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

#ifndef __WINDOWS__
#include <getopt.h>
#else
#include "getopt.h"
#endif

#include "engine/audio.h"
Expand Down

0 comments on commit 693aa90

Please sign in to comment.