summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorXavi Del Campo <xavi.dcr@tutanota.com>2020-03-03 18:10:15 +0100
committerXavi Del Campo <xavi.dcr@tutanota.com>2020-03-03 18:10:27 +0100
commitb28059d49afce8524361fa7597adcc9e108f4eab (patch)
tree5041d37aa9571ac738ced4b9f16388550d0e8f78 /include
parentbf3bb8cdc590a18195e25c38f4f4db11e8bcd1c4 (diff)
downloadopensend-b28059d49afce8524361fa7597adcc9e108f4eab.tar.gz
Renamed folders to lowercase
Diffstat (limited to 'include')
-rw-r--r--include/EndAnimation.h25
-rw-r--r--include/Font.h44
-rw-r--r--include/GameStructures.h57
-rw-r--r--include/Gfx.h109
-rw-r--r--include/Global_Inc.h41
-rw-r--r--include/LoadMenu.h29
-rw-r--r--include/Serial.h49
-rw-r--r--include/System.h118
8 files changed, 472 insertions, 0 deletions
diff --git a/include/EndAnimation.h b/include/EndAnimation.h
new file mode 100644
index 0000000..edb7b07
--- /dev/null
+++ b/include/EndAnimation.h
@@ -0,0 +1,25 @@
+#ifndef __END_SCREEN_HEADER__
+#define __END_SCREEN_HEADER__
+
+/* **************************************
+ * Includes *
+ * **************************************/
+
+#include "Global_Inc.h"
+#include "Gfx.h"
+
+/* **************************************
+ * Defines *
+ * **************************************/
+
+/* **************************************
+ * Global Prototypes *
+ * **************************************/
+
+void EndAnimation(void);
+
+/* **************************************
+ * Global Variables *
+ * **************************************/
+
+#endif // __END_SCREEN_HEADER__
diff --git a/include/Font.h b/include/Font.h
new file mode 100644
index 0000000..5a7d6b5
--- /dev/null
+++ b/include/Font.h
@@ -0,0 +1,44 @@
+#ifndef __FONT_HEADER__
+#define __FONT_HEADER__
+
+/* *************************************
+ * Includes
+ * *************************************/
+
+#include "Global_Inc.h"
+#include "System.h"
+#include "Gfx.h"
+#include "GameStructures.h"
+#include <stdarg.h>
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+#define FONT_DEFAULT_CHAR_SIZE 16
+#define FONT_DEFAULT_INIT_CHAR '!'
+
+/* **************************************
+ * Structs and enums *
+ * *************************************/
+
+/* *************************************
+ * Global prototypes
+ * *************************************/
+
+bool FontLoadImage(char* strPath, TYPE_FONT * ptrFont);
+void FontSetSize(TYPE_FONT * ptrFont, short size, short bitshift);
+void FontPrintText(TYPE_FONT *ptrFont, short x, short y, char* str, ...);
+void FontSetInitChar(TYPE_FONT * ptrFont, char c);
+void FontSetFlags(TYPE_FONT * ptrFont, FONT_FLAGS flags);
+void FontCyclic(void);
+void FontSetSpacing(TYPE_FONT* ptrFont, short spacing);
+
+/* *************************************
+ * Global variables
+ * *************************************/
+
+TYPE_FONT RadioFont;
+TYPE_FONT SmallFont;
+
+#endif //__FONT_HEADER__
diff --git a/include/GameStructures.h b/include/GameStructures.h
new file mode 100644
index 0000000..e092e1d
--- /dev/null
+++ b/include/GameStructures.h
@@ -0,0 +1,57 @@
+#ifndef __GAME_STRUCTURES__HEADER__
+#define __GAME_STRUCTURES__HEADER__
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+#define CHEAT_ARRAY_SIZE 16
+
+/* *************************************
+ * Structs and enums
+ * *************************************/
+
+typedef enum t_fontflags
+{
+ FONT_NOFLAGS = 0,
+ FONT_CENTERED = 0x01,
+ FONT_WRAP_LINE = 0x02,
+ FONT_BLEND_EFFECT = 0x04,
+ FONT_1HZ_FLASH = 0x08,
+ FONT_2HZ_FLASH = 0x10,
+ FONT_H_CENTERED = 0x20
+}FONT_FLAGS;
+
+typedef struct t_Font
+{
+ GsSprite spr;
+ short char_spacing;
+ short char_w;
+ short char_w_bitshift;
+ short char_h;
+ char init_ch;
+ uint8_t char_per_row;
+ uint8_t max_ch_wrap;
+ FONT_FLAGS flags;
+ short spr_w;
+ short spr_h;
+ short spr_u;
+ short spr_v;
+}TYPE_FONT;
+
+typedef struct t_Timer
+{
+ uint32_t time;
+ uint32_t orig_time;
+ bool repeat_flag;
+ bool busy;
+ void (*Timeout_Callback)(void);
+}TYPE_TIMER;
+
+typedef struct t_Cheat
+{
+ unsigned short Combination[CHEAT_ARRAY_SIZE];
+ void (*Callback)(void);
+}TYPE_CHEAT;
+
+#endif // __GAME_STRUCTURES__HEADER__
diff --git a/include/Gfx.h b/include/Gfx.h
new file mode 100644
index 0000000..b2b8295
--- /dev/null
+++ b/include/Gfx.h
@@ -0,0 +1,109 @@
+#ifndef __GFX_HEADER__
+#define __GFX_HEADER__
+
+/* *************************************
+ * Includes
+ * *************************************/
+
+#include "Global_Inc.h"
+#include "System.h"
+
+
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+#define X_SCREEN_RESOLUTION 384
+#define Y_SCREEN_RESOLUTION 240
+#define VRAM_W 1024
+#define VRAM_H 512
+#define MAX_SIZE_FOR_GSSPRITE 256
+#define GFX_TPAGE_WIDTH 64
+#define GFX_TPAGE_HEIGHT 256
+#define GFX_1HZ_FLASH (1<<7)
+#define GFX_2HZ_FLASH (1<<8)
+#define FULL_LUMINANCE 0xFF
+
+/* *************************************
+ * Global prototypes
+ * *************************************/
+
+void GfxInitDrawEnv(void);
+void GfxInitDispEnv(void);
+void GfxSetPrimitiveList(void);
+
+// Renders new scene. Use this function unless you know what you are doing!
+void GfxDrawScene(void);
+
+// Blocking version. Calls GfxDrawScene() and then adds a while(GfxIsBusy() )
+// after it.
+void GfxDrawScene_Slow(void);
+
+void GfxDrawScene_NoSwap(void);
+
+void GfxSwapBuffers(void);
+
+// Only renders screen and does not update any pad data or timer data.
+// To be used in ISR!
+void GfxDrawScene_Fast(void);
+
+// Repotedly, tells is GPU is ready for a DMA transfer.
+bool GfxReadyForDMATransfer(void);
+
+// Fills a GsSprite structure with information from a TIM file.
+bool GfxSpriteFromFile(char* fname, GsSprite * spr);
+
+// Reportedly, loads CLUT data from a TIM image (image data is discarded)
+bool GfxCLUTFromFile(char* fname);
+
+// Returns true if current object is within screen limits, false otherwise.
+bool GfxIsInsideScreenArea(short x, short y, short w, short h);
+
+// Function overload for GsSprite structures.
+bool GfxIsSpriteInsideScreenArea(GsSprite * spr);
+
+// Used to know whether GPU operation can be done.
+bool GfxIsGPUBusy(void);
+
+// Draws a sprite on screen. First, it checks whether sprite is inside
+// screen limits.
+void GfxSortSprite(GsSprite * spr);
+
+uint8_t GfxGetGlobalLuminance(void);
+
+void GfxSetGlobalLuminance(uint8_t value);
+
+void GfxIncreaseGlobalLuminance(int8_t step);
+
+void GfxButtonSetFlags(uint8_t flags);
+
+void GfxButtonRemoveFlags(uint8_t flags);
+
+int GfxRotateFromDegrees(int deg);
+
+void GfxDrawButton(short x, short y, unsigned short btn);
+
+// Sends current display data on a specific VRAM section and fills
+// sprite structure pointed to by "spr".
+void GfxSaveDisplayData(GsSprite *spr);
+
+// Fills GsSprite structure pointed to by "spr" with texture page and U/V
+// offset data given a position in VRAM.
+bool GfxTPageOffsetFromVRAMPosition(GsSprite * spr, short x, short y);
+
+void GfxSetSplitScreen(uint8_t playerIndex);
+
+void GfxDisableSplitScreen(void);
+
+void GfxDrawScene_NoSwap(void);
+
+void GfxDevMenuEnable(void);
+
+/* *************************************
+ * Global variables
+ * *************************************/
+
+extern GsSprite PSXButtons;
+
+#endif //__GFX_HEADER__
diff --git a/include/Global_Inc.h b/include/Global_Inc.h
new file mode 100644
index 0000000..0c8f446
--- /dev/null
+++ b/include/Global_Inc.h
@@ -0,0 +1,41 @@
+#ifndef __GLOBAL_INC__H__
+#define __GLOBAL_INC__H__
+
+/* *************************************
+ * Includes
+ * *************************************/
+
+#include <psx.h>
+#include <stdio.h>
+#include <psxsio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <types.h>
+#include <fixmath.h>
+#include <runexe.h>
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+#define REFRESH_FREQUENCY 50 //50 Hz PAL / 60 Hz NTSC
+#define DEBUG_PRINT_VAR(var) dprintf(#var " = %d\n", var);
+
+#ifndef bool
+ typedef enum
+ {
+ false = 0,
+ true = 1
+ }bool;
+#endif
+
+#if (PSXSDK_VERSION != 0x0599)
+#error "Wrong PSXSDK version! Please use version 0.5.99."
+#endif
+
+/* Test for GCC > 5.2.0 */
+#if ( (__GNUC__ != 5) || (__GNUC_MINOR__ != 2) || (__GNUC_PATCHLEVEL__ != 0) )
+#error "Wrong GCC version! Please use version 5.2.0."
+#endif
+
+#endif // __GLOBAL_INC__H__
diff --git a/include/LoadMenu.h b/include/LoadMenu.h
new file mode 100644
index 0000000..8afc373
--- /dev/null
+++ b/include/LoadMenu.h
@@ -0,0 +1,29 @@
+#ifndef __LOAD_MENU_HEADER__
+#define __LOAD_MENU_HEADER__
+
+/* *************************************
+ * Includes
+ * *************************************/
+
+#include "Global_Inc.h"
+#include "Gfx.h"
+#include "System.h"
+#include "Font.h"
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+/* *************************************
+ * Global prototypes
+ * *************************************/
+
+void LoadMenuInit(void);
+
+void LoadMenu( char* fileList[],
+ void * dest[],
+ uint8_t szFileList , uint8_t szDestList);
+
+void LoadMenuEnd(void);
+
+#endif //__LOAD_MENU_HEADER__
diff --git a/include/Serial.h b/include/Serial.h
new file mode 100644
index 0000000..da2c4ce
--- /dev/null
+++ b/include/Serial.h
@@ -0,0 +1,49 @@
+#ifndef __SERIAL_HEADER__
+#define __SERIAL_HEADER__
+
+/* *************************************
+ * Includes
+ * *************************************/
+
+#include "Global_Inc.h"
+#include "System.h"
+#include "Gfx.h"
+#include "Font.h"
+
+/* *************************************
+ * Defines
+ * *************************************/
+
+#define ACK_BYTE_STRING "b"
+
+/* **************************************
+ * Structs and enums *
+ * *************************************/
+
+typedef enum
+{
+ SERIAL_STATE_INIT = 0,
+ SERIAL_STATE_STANDBY,
+ SERIAL_STATE_WRITING_ACK,
+ SERIAL_STATE_READING_HEADER,
+ SERIAL_STATE_READING_EXE_SIZE,
+ SERIAL_STATE_READING_EXE_DATA,
+ SERIAL_STATE_WAITING_USER_INPUT,
+ SERIAL_STATE_CLEANING_MEMORY,
+}SERIAL_STATE;
+
+/* *************************************
+ * Global prototypes
+ * *************************************/
+
+void SerialInit(void);
+bool SerialRead(uint8_t* ptrArray, size_t nBytes);
+bool SerialWrite(void* ptrArray, size_t nBytes);
+void ISR_Serial(void);
+void SerialSetState(SERIAL_STATE state);
+void SerialSetPCAddress(uint32_t addr);
+void SerialSetRAMDestAddress(uint32_t addr);
+void SerialSetExeSize(size_t size);
+void SerialSetExeBytesReceived(uint32_t bytes_read);
+
+#endif // __SERIAL_HEADER__
diff --git a/include/System.h b/include/System.h
new file mode 100644
index 0000000..2994366
--- /dev/null
+++ b/include/System.h
@@ -0,0 +1,118 @@
+#ifndef __SYSTEM_HEADER__
+#define __SYSTEM_HEADER__
+
+/* **************************************
+ * Includes *
+ * **************************************/
+
+#include "Global_Inc.h"
+#include "Gfx.h"
+#include "Serial.h"
+
+/* **************************************
+ * Defines *
+ * **************************************/
+
+#define TIMER_PRESCALER_1_SECOND 10
+#define TIMER_PRESCALER_1_MINUTE (TIMER_PRESCALER_1_SECOND * 60)
+
+/* **************************************
+ * Global Prototypes *
+ * **************************************/
+
+// Calls PSXSDK init routines
+void SystemInit(void);
+
+// Sets default VSync (only sets flag to true and increases global_timer)
+void ISR_SystemDefaultVBlank(void);
+
+void SystemSetBusyFlag(bool value);
+
+// Calls srand() using current global_timer value as seed
+void SystemSetRandSeed(void);
+
+// Returns VSync flag value
+bool SystemRefreshNeeded(void);
+
+// Loads a file into system's internal buffer
+bool SystemLoadFile(char*fname);
+
+// Loads a file into desired buffer
+bool SystemLoadFileToBuffer(char* fname, uint32_t init_pos, uint8_t* buffer, uint32_t szBuffer);
+
+// Clears VSync flag after each frame
+void SystemDisableScreenRefresh(void);
+
+// Returns file buffer address
+uint8_t* SystemGetBufferAddress(void);
+
+// Tells whether srand() has been called using a pseudo-random value
+bool SystemIsRandSeedSet(void);
+
+// Stops program flow during X cycles
+void SystemWaitCycles(uint32_t cycles);
+
+// 1 cycle-length flag with a frequency of 1 Hz
+bool System1SecondTick(void);
+
+// 1 cycle-length flag with a frequency of 2 Hz
+bool System500msTick(void);
+
+// 1 cycle-length flag with a frequency of 10 Hz
+bool System100msTick(void);
+
+// Returns random value between given minimum and maximum values
+uint32_t SystemRand(uint32_t min, uint32_t max);
+
+// Increases global timer by 1 step
+void SystemIncreaseGlobalTimer(void);
+
+// Sets value to emergency mode flag
+void SystemSetEmergencyMode(bool value);
+
+// Returns emergency mode flag state
+bool SystemGetEmergencyMode(void);
+
+// (Experimental)
+uint64_t SystemGetGlobalTimer(void);
+
+// Returns whether critical section of code is being entered
+volatile bool SystemIsBusy(void);
+
+// Returns whether indicated value is contained inside buffer
+bool SystemContains_u8(uint8_t value, uint8_t* buffer, size_t sz);
+
+// Overload for uint16_t
+bool SystemContains_u16(uint16_t value, uint16_t* buffer, size_t sz);
+
+// Reportedly, sets all timer data to zero.
+void SystemResetTimers(void);
+
+// To be called every cycle (i.e.: inside GfxDrawScene() ).
+void SystemUserTimersHandler(void);
+
+// Looks for string "str" inside a string array pointed to by "array".
+// Returns index inside string array on success, -1 if not found.
+int32_t SystemIndexOfStringArray(char* str, char** array);
+
+// Function overload for uint16_t data type.
+int32_t SystemIndexOf_U16(uint16_t value, uint16_t* array, uint32_t sz);
+
+// Function overload for uint8_t data type.
+int32_t SystemIndexOf_U8(uint8_t value, uint8_t* array, uint32_t from, uint32_t sz);
+
+void SystemCyclicHandler(void);
+
+size_t SystemGetBufferSize(void);
+
+void SystemClearBuffer(void);
+
+void SystemDisableVBlankInterrupt(void);
+
+void SystemEnableVBlankInterrupt(void);
+
+/* **************************************
+ * Global Variables *
+ * **************************************/
+
+#endif //__SYSTEM_HEADER__