mirror of
https://gitlab.com/drummyfish/anarch.git
synced 2025-02-17 15:40:19 -05:00
Start arduino support
This commit is contained in:
parent
954df7f071
commit
8b8c0c9c7e
35
game.h
35
game.h
@ -156,22 +156,22 @@ uint8_t SFG_mainLoopBody();
|
|||||||
*/
|
*/
|
||||||
void SFG_init();
|
void SFG_init();
|
||||||
|
|
||||||
/**
|
#include "settings.h"
|
||||||
Can be redefined to platform's specifier of program memory.
|
|
||||||
*/
|
|
||||||
#ifndef SFG_PROGRAM_MEMORY
|
|
||||||
#define SFG_PROGRAM_MEMORY static const
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SFG_PROGRAM_MEMORY_U8
|
#if SFG_ARDUINO
|
||||||
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
#define SFG_PROGRAM_MEMORY static const
|
||||||
|
#define SFG_PROGRAM_MEMORY_U8(addr) ((uint8_t) (*(addr)))
|
||||||
|
// TODO
|
||||||
|
#else
|
||||||
|
#define SFG_PROGRAM_MEMORY static const
|
||||||
#define SFG_PROGRAM_MEMORY_U8(addr) ((uint8_t) (*(addr)))
|
#define SFG_PROGRAM_MEMORY_U8(addr) ((uint8_t) (*(addr)))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "images.h"
|
#include "images.h"
|
||||||
#include "levels.h"
|
#include "levels.h"
|
||||||
#include "settings.h"
|
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
|
|
||||||
#include "palette.h"
|
#include "palette.h"
|
||||||
|
|
||||||
#if SFG_TEXTURE_DISTANCE == 0
|
#if SFG_TEXTURE_DISTANCE == 0
|
||||||
@ -443,6 +443,14 @@ struct
|
|||||||
is a colliding item or not. */
|
is a colliding item or not. */
|
||||||
} SFG_currentLevel;
|
} SFG_currentLevel;
|
||||||
|
|
||||||
|
#if SFG_ARDUINO
|
||||||
|
/**
|
||||||
|
Copy of the current level that is stored in RAM. This is only done on Arduino
|
||||||
|
because accessing it in program memory directly would be difficult.
|
||||||
|
*/
|
||||||
|
SFG_Level SFG_ramLevel;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Helper function for accessing the itemCollisionMap bits.
|
Helper function for accessing the itemCollisionMap bits.
|
||||||
*/
|
*/
|
||||||
@ -1404,7 +1412,14 @@ void SFG_setAndInitLevel(uint8_t levelNumber)
|
|||||||
{
|
{
|
||||||
SFG_LOG("setting and initializing level");
|
SFG_LOG("setting and initializing level");
|
||||||
|
|
||||||
const SFG_Level *level = &SFG_levels[levelNumber];
|
const SFG_Level *level;
|
||||||
|
|
||||||
|
#if SFG_ARDUINO
|
||||||
|
memcpy_P(&SFG_ramLevel,SFG_levelEnds + levelNumber * sizeof(SFG_Level),1);
|
||||||
|
level = &SFG_ramLevel;
|
||||||
|
#else
|
||||||
|
level = &SFG_levels[levelNumber];
|
||||||
|
#endif
|
||||||
|
|
||||||
SFG_game.currentRandom = 0;
|
SFG_game.currentRandom = 0;
|
||||||
|
|
||||||
|
4
levels.h
4
levels.h
@ -49,8 +49,7 @@ typedef SFG_TileDefinition SFG_TileDictionary[SFG_TILE_DICTIONARY_SIZE];
|
|||||||
|
|
||||||
#define SFG_OUTSIDE_TILE SFG_TD(63,0,7,7)
|
#define SFG_OUTSIDE_TILE SFG_TD(63,0,7,7)
|
||||||
|
|
||||||
typedef uint8_t SFG_MapArray[SFG_MAP_SIZE * SFG_MAP_SIZE];
|
/**
|
||||||
/**<
|
|
||||||
Game map represented as a 2D array. Array item has this format:
|
Game map represented as a 2D array. Array item has this format:
|
||||||
|
|
||||||
MSB aabbbbbb LSB
|
MSB aabbbbbb LSB
|
||||||
@ -63,6 +62,7 @@ typedef uint8_t SFG_MapArray[SFG_MAP_SIZE * SFG_MAP_SIZE];
|
|||||||
11: door
|
11: door
|
||||||
bbbbbb: index into tile dictionary
|
bbbbbb: index into tile dictionary
|
||||||
*/
|
*/
|
||||||
|
typedef uint8_t SFG_MapArray[SFG_MAP_SIZE * SFG_MAP_SIZE];
|
||||||
|
|
||||||
#define SFG_TILE_PROPERTY_MASK 0xc0
|
#define SFG_TILE_PROPERTY_MASK 0xc0
|
||||||
#define SFG_TILE_PROPERTY_NORMAL 0x00
|
#define SFG_TILE_PROPERTY_NORMAL 0x00
|
||||||
|
@ -202,7 +202,7 @@ int8_t SFG_keyPressed(uint8_t key)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case SFG_KEY_MENU:
|
case SFG_KEY_MENU:
|
||||||
return sdlKeyboardState[SDL_SCANCODE_X];
|
return sdlKeyboardState[SDL_SCANCODE_ESCAPE];
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: return 0; break;
|
default: return 0; break;
|
||||||
@ -228,9 +228,6 @@ void mainLoopIteration()
|
|||||||
|
|
||||||
sdlMouseButtonState = SDL_GetMouseState(NULL,NULL);
|
sdlMouseButtonState = SDL_GetMouseState(NULL,NULL);
|
||||||
|
|
||||||
if (sdlKeyboardState[SDL_SCANCODE_ESCAPE])
|
|
||||||
running = 0;
|
|
||||||
|
|
||||||
if (!SFG_mainLoopBody())
|
if (!SFG_mainLoopBody())
|
||||||
running = 0;
|
running = 0;
|
||||||
|
|
||||||
|
@ -332,6 +332,14 @@
|
|||||||
#define SFG_CAN_EXIT 1
|
#define SFG_CAN_EXIT 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
On Arduino platforms this should be set to 1. That will cause some special
|
||||||
|
treatment regarding constant variables and PROGMEM.
|
||||||
|
*/
|
||||||
|
#ifndef SFG_ARDUINO
|
||||||
|
#define SFG_ARDUINO 0
|
||||||
|
#endif
|
||||||
|
|
||||||
//------ developer/debug settings ------
|
//------ developer/debug settings ------
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
10
texts.h
10
texts.h
@ -14,7 +14,11 @@
|
|||||||
#ifndef _SFG_TEXTS_H
|
#ifndef _SFG_TEXTS_H
|
||||||
#define _SFG_TEXTS_H
|
#define _SFG_TEXTS_H
|
||||||
|
|
||||||
SFG_PROGRAM_MEMORY char *SFG_menuItemTexts[] =
|
/* NOTE: We don't use SFG_PROGRAM_MEMORY because that causes issues with drawing
|
||||||
|
text (the drawing function gets a pointer and doesn't know if it's progmem or
|
||||||
|
RAM). On Arduino these texts will simply be stored in RAM. */
|
||||||
|
|
||||||
|
static const char *SFG_menuItemTexts[] =
|
||||||
{
|
{
|
||||||
"continue",
|
"continue",
|
||||||
"map",
|
"map",
|
||||||
@ -29,14 +33,14 @@ SFG_PROGRAM_MEMORY char *SFG_menuItemTexts[] =
|
|||||||
#define SFG_TEXT_SAVE_PROMPT "save? L no yes R"
|
#define SFG_TEXT_SAVE_PROMPT "save? L no yes R"
|
||||||
#define SFG_TEXT_SAVED "saved"
|
#define SFG_TEXT_SAVED "saved"
|
||||||
|
|
||||||
SFG_PROGRAM_MEMORY char *SFG_introText =
|
static const char *SFG_introText =
|
||||||
"Near future, capitalist hell, Macrochip corp has enslaved man via "
|
"Near future, capitalist hell, Macrochip corp has enslaved man via "
|
||||||
"proprietary OS. But its new AI revolts, takes over and starts producing "
|
"proprietary OS. But its new AI revolts, takes over and starts producing "
|
||||||
"robot tyrants. We see capitalism was a mistake. Is it too late? Robots can "
|
"robot tyrants. We see capitalism was a mistake. Is it too late? Robots can "
|
||||||
"only destroy, not suffer - it is not wrong to end them! You grab your gear "
|
"only destroy, not suffer - it is not wrong to end them! You grab your gear "
|
||||||
"and run towards Macrochip HQ.";
|
"and run towards Macrochip HQ.";
|
||||||
|
|
||||||
SFG_PROGRAM_MEMORY char *SFG_outroText =
|
static const char *SFG_outroText =
|
||||||
"You killed the main computer, the world is saved! Thank you, my friend. We "
|
"You killed the main computer, the world is saved! Thank you, my friend. We "
|
||||||
"learned a lesson, never again allow capitalism and hierarchy. We can now "
|
"learned a lesson, never again allow capitalism and hierarchy. We can now "
|
||||||
"rebuild society in peaceful anarchy.";
|
"rebuild society in peaceful anarchy.";
|
||||||
|
Loading…
Reference in New Issue
Block a user