2017-09-26 08:59:34 +02:00
|
|
|
// MIT License
|
|
|
|
|
|
|
|
// Copyright (c) 2017 Vadim Grigoruk @nesbox // grigoruk@gmail.com
|
|
|
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in all
|
|
|
|
// copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
// SOFTWARE.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "studio.h"
|
|
|
|
|
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
CART_SAVE_OK,
|
|
|
|
CART_SAVE_ERROR,
|
|
|
|
CART_SAVE_MISSING_NAME,
|
|
|
|
} CartSaveResult;
|
|
|
|
|
|
|
|
typedef struct HistoryItem HistoryItem;
|
|
|
|
|
|
|
|
struct HistoryItem
|
|
|
|
{
|
|
|
|
char* value;
|
|
|
|
HistoryItem* prev;
|
|
|
|
HistoryItem* next;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct Console Console;
|
|
|
|
|
|
|
|
struct Console
|
|
|
|
{
|
|
|
|
struct Config* config;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
s32 x;
|
|
|
|
s32 y;
|
|
|
|
s32 delay;
|
|
|
|
} cursor;
|
|
|
|
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
s32 pos;
|
|
|
|
s32 start;
|
2017-10-16 05:03:05 +02:00
|
|
|
|
2017-09-26 08:59:34 +02:00
|
|
|
bool active;
|
|
|
|
} scroll;
|
|
|
|
|
2017-10-16 05:03:05 +02:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
char fileName[FILENAME_MAX];
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
void(*reload)(Console*, char*);
|
|
|
|
} codeLiveReload;
|
|
|
|
|
2017-09-26 08:59:34 +02:00
|
|
|
char* buffer;
|
|
|
|
u8* colorBuffer;
|
|
|
|
|
|
|
|
char inputBuffer[STUDIO_TEXT_BUFFER_WIDTH * STUDIO_TEXT_BUFFER_HEIGHT];
|
|
|
|
size_t inputPosition;
|
|
|
|
|
|
|
|
tic_mem* tic;
|
|
|
|
|
|
|
|
struct FileSystem* fs;
|
|
|
|
|
|
|
|
char romName[FILENAME_MAX];
|
|
|
|
char appPath[FILENAME_MAX];
|
|
|
|
|
|
|
|
HistoryItem* history;
|
|
|
|
HistoryItem* historyHead;
|
|
|
|
|
|
|
|
u32 tickCounter;
|
|
|
|
bool active;
|
|
|
|
bool showGameMenu;
|
2017-11-20 10:00:59 +01:00
|
|
|
bool startSurf;
|
2017-09-26 08:59:34 +02:00
|
|
|
|
|
|
|
void(*load)(Console*, const char* name);
|
2017-11-23 13:26:39 +01:00
|
|
|
bool(*loadProject)(Console*, const char* name, const char* data, s32 size, tic_cartridge* dst);
|
2017-11-21 17:47:36 +01:00
|
|
|
void(*updateProject)(Console*);
|
2017-09-26 08:59:34 +02:00
|
|
|
void(*error)(Console*, const char*);
|
|
|
|
void(*trace)(Console*, const char*, u8 color);
|
|
|
|
void(*tick)(Console*);
|
|
|
|
|
|
|
|
CartSaveResult(*save)(Console*);
|
|
|
|
};
|
|
|
|
|
|
|
|
void initConsole(Console*, tic_mem*, struct FileSystem* fs, struct Config* config, s32 argc, char **argv);
|