diff --git a/doc/doxyfile b/doc/doxyfile index 579e5f2d..29464dc5 100644 --- a/doc/doxyfile +++ b/doc/doxyfile @@ -96,84 +96,98 @@ WARN_LOGFILE = "D:\apps\SGDK\cb\doc\doxygen.log" # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = \ + "..\..\src\pal.c" \ + "..\..\inc\font.h" \ + "..\..\inc\xgm.h" \ "..\..\src\sprite_eng.c" \ - "..\..\inc\vdp_spr.h" \ - "..\..\inc\vram.h" \ - "..\..\src\vdp_dma.c" \ + "..\..\inc\tab_vol.h" \ "..\..\src\bmp.c" \ - "..\..\src\maths3D.c" \ - "..\..\inc\xgm.h" \ - "..\..\src\dma.c" \ - "..\..\src\sram.c" \ - "..\..\inc\ym2612.h" \ - "..\..\src\map.c" \ - "..\..\inc\z80_ctrl.h" \ - "..\..\src\mapper.c" \ - "..\..\inc\bmp.h" \ - "..\..\inc\map.h" \ - "..\..\src\tab_sin.c" \ - "..\..\src\pal.c" \ - "..\..\inc\asm.h" \ - "..\..\inc\sram.h" \ - "..\..\src\fat16.c" \ - "..\..\inc\config.h" \ - "..\..\inc\pal.h" \ + "..\..\src\vdp.c" \ + "..\..\src\tab_cnv.c" \ + "..\..\inc\task.h" \ + "..\..\src\vdp_bg.c" \ "..\..\inc\dma.h" \ - "..\..\inc\maths.h" \ - "..\..\inc\everdrive.h" \ - "..\..\inc\maths3D.h" \ + "..\..\src\tab_sin.c" \ + "..\..\inc\vram.h" \ + "..\..\src\ext\mw\16c550.c" \ + "..\..\src\sys.c" \ + "..\..\inc\kdebug.h" \ + "..\..\inc\smp_null_pcm.h" \ + "..\..\src\types.c" \ + "..\..\inc\ext\fat16.h" \ + "..\..\inc\sound.h" \ "..\..\src\maths.c" \ - "..\..\src\string.c" \ - "..\..\inc\fat16.h" \ - "..\..\inc\types.h" \ + "..\..\inc\sprite_eng.h" \ + "..\..\src\ext\mw\lsd.c" \ + "..\..\src\z80_ctrl.c" \ + "..\..\src\vdp_dma.c" \ + "..\..\inc\pal.h" \ + "..\..\src\timer.c" \ + "..\..\inc\string.h" \ + "..\..\src\asm_mac.cpp" \ "..\..\src\vdp_pal.c" \ - "..\..\src\memory.c" \ - "..\..\src\tab_log2.c" \ "..\..\inc\sys.h" \ - "..\..\src\vram.c" \ - "..\..\src\psg.c" \ - "..\..\src\vdp_tile.c" \ + "..\..\src\ext\fat16.c" \ + "..\..\src\maths3D.c" \ + "..\..\src\ym2612.c" \ "..\..\inc\joy.h" \ - "..\..\inc\vdp_bg.h" \ - "..\..\src\vdp_bg.c" \ + "..\..\inc\ym2612.h" \ + "..\..\inc\mapper.h" \ + "..\..\src\dma.c" \ + "..\..\inc\ext\everdrive.h" \ + "..\..\inc\maths3D.h" \ + "..\..\src\ext\mw\json.c" \ + "..\..\src\tab_log2.c" \ + "..\..\inc\vdp.h" \ + "..\..\src\ext\mw\megawifi.c" \ + "..\..\inc\ext\mw\gamejolt.h" \ "..\..\src\tools.c" \ - "..\..\inc\genesis.h" \ + "..\..\inc\ext\mw\16c550.h" \ + "..\..\inc\vdp_bg.h" \ + "..\..\src\map.c" \ + "..\..\inc\ext\mw\jsmn.h" \ + "..\..\src\tab_vol.c" \ "..\..\inc\vdp_dma.h" \ - "..\..\src\timer.c" \ - "..\..\inc\kdebug.h" \ + "..\..\src\ext\everdrive.c" \ + "..\..\inc\ext\mw\lsd.h" \ + "..\..\src\vdp_tile.c" \ + "..\..\inc\map.h" \ + "..\..\src\joy.c" \ + "..\..\inc\ext\mw\megawifi.h" \ + "..\..\src\psg.c" \ + "..\..\inc\genesis.h" \ + "..\..\inc\ext\mw\mw-msg.h" \ "..\..\src\sound.c" \ - "..\..\src\tab_sqrt.c" \ - "..\..\inc\font.h" \ - "..\..\src\sys.c" \ - "..\..\inc\sound.h" \ - "..\..\src\tab_cnv.c" \ - "..\..\inc\memory.h" \ - "..\..\src\types.c" \ - "..\..\inc\tab_cnv.h" \ - "..\..\res\libres.h" \ - "..\..\src\tab_log10.c" \ - "..\..\inc\smp_null_pcm.h" \ - "..\..\src\xgm.c" \ + "..\..\inc\maths.h" \ + "..\..\inc\smp_null.h" \ + "..\..\src\mapper.c" \ + "..\..\src\string.c" \ "..\..\inc\timer.h" \ - "..\..\src\asm_mac.cpp" \ "..\..\inc\vdp_pal.h" \ - "..\..\src\vdp.c" \ - "..\..\inc\sprite_eng.h" \ + "..\..\inc\config.h" \ + "..\..\src\tab_log10.c" \ + "..\..\inc\tools.h" \ + "..\..\inc\memory.h" \ + "..\..\inc\asm.h" \ + "..\..\inc\task_cst.h" \ + "..\..\src\xgm.c" \ + "..\..\inc\tab_cnv.h" \ + "..\..\src\memory.c" \ + "..\..\inc\sram.h" \ "..\..\src\boot\rom_head.c" \ - "..\..\inc\vdp_tile.h" \ - "..\..\src\ym2612.c" \ - "..\..\inc\vdp.h" \ - "..\..\src\everdrive.c" \ - "..\..\inc\string.h" \ "..\..\src\vdp_spr.c" \ - "..\..\inc\tools.h" \ - "..\..\inc\tab_vol.h" \ - "..\..\src\tab_vol.c" \ - "..\..\inc\smp_null.h" \ - "..\..\src\joy.c" \ - "..\..\inc\mapper.h" \ - "..\..\src\z80_ctrl.c" \ - "..\..\inc\psg.h" + "..\..\inc\psg.h" \ + "..\..\inc\bmp.h" \ + "..\..\inc\types.h" \ + "..\..\res\libres.h" \ + "..\..\inc\z80_ctrl.h" \ + "..\..\src\sram.c" \ + "..\..\inc\vdp_spr.h" \ + "..\..\src\ext\mw\gamejolt.c" \ + "..\..\src\vram.c" \ + "..\..\inc\ext\mw\json.h" \ + "..\..\inc\vdp_tile.h" \ + "..\..\src\tab_sqrt.c" INPUT_ENCODING = UTF-8 FILE_PATTERNS = RECURSIVE = NO diff --git a/doc/html/16c550_8h_source.html b/doc/html/16c550_8h_source.html new file mode 100644 index 00000000..a1c0b582 --- /dev/null +++ b/doc/html/16c550_8h_source.html @@ -0,0 +1,215 @@ + + +
+ +
+ sgdk
+ |
+
00001 /************************************************************************/ +00010 #ifndef _16C550_H_ +00011 #define _16C550_H_ +00012 +00013 #include "types.h" +00014 +00015 #if (MODULE_MEGAWIFI != 0) +00016 +00018 #define UART_BASE 0xA130C1 +00019 +00021 #define UART_CLK 24000000LU +00022 +00025 #define UART_BR 1500000LU +00026 //#define UART_BR 500000LU +00027 //#define UART_BR 750000LU +00028 //#define UART_BR 115200 +00029 +00031 #define UART_TX_FIFO_LEN 16 +00032 +00034 #define DivWithRounding(dividend, divisor) ((((dividend)*2/(divisor))+1)/2) +00035 +00036 #define UART_DLM_VAL (DivWithRounding(UART_CLK, 16 * UART_BR)>>8) +00037 //#define UART_DLM_VAL ((UART_CLK/16/UART_BR)>>8) +00039 #define UART_DLL_VAL (DivWithRounding(UART_CLK, 16 * UART_BR) & 0xFF) +00040 //#define UART_DLL_VAL ((UART_CLK/16/UART_BR)&0xFF) +00041 +00049 +00050 #define UART_RHR (*((volatile uint8_t*)(UART_BASE + 0))) +00051 +00052 #define UART_THR (*((volatile uint8_t*)(UART_BASE + 0))) +00053 +00054 #define UART_IER (*((volatile uint8_t*)(UART_BASE + 2))) +00055 +00056 #define UART_FCR (*((volatile uint8_t*)(UART_BASE + 4))) +00057 +00058 #define UART_ISR (*((volatile uint8_t*)(UART_BASE + 4))) +00059 +00060 #define UART_LCR (*((volatile uint8_t*)(UART_BASE + 6))) +00061 +00062 #define UART_MCR (*((volatile uint8_t*)(UART_BASE + 8))) +00063 +00064 #define UART_LSR (*((volatile uint8_t*)(UART_BASE + 10))) +00065 +00066 #define UART_MSR (*((volatile uint8_t*)(UART_BASE + 12))) +00067 +00068 #define UART_SPR (*((volatile uint8_t*)(UART_BASE + 14))) +00069 +00070 #define UART_DLL (*((volatile uint8_t*)(UART_BASE + 0))) +00071 +00072 #define UART_DLM (*((volatile uint8_t*)(UART_BASE + 2))) +00073 +00075 +00076 typedef struct { +00077 uint8_t IER; +00078 uint8_t FCR; +00079 uint8_t LCR; +00080 uint8_t MCR; +00081 } UartShadow; +00082 +00084 extern UartShadow sh; +00085 +00090 #define UART_MCR__DTR 0x01 ///< Data Terminal Ready. +00091 #define UART_MCR__RTS 0x02 ///< Request To Send. +00092 #define UART_MCR__OUT1 0x04 ///< GPIO pin 1. +00093 #define UART_MCR__OUT2 0x08 ///< GPIO pin 2. +00094 +00099 #define UART_MSR__DSR 0x20 ///< Data Set Ready +00100 +00102 /************************************************************************/ +00107 void uart_init(void); +00108 +00109 /************************************************************************/ +00115 #define uart_tx_ready() (UART_LSR & 0x20) +00116 +00117 /************************************************************************/ +00122 #define uart_rx_ready() (UART_LSR & 0x01) +00123 +00124 /************************************************************************/ +00130 #define uart_putc(c) do{UART_RHR = (c);}while(0); +00131 +00132 /************************************************************************/ +00138 #define uart_getc() (UART_RHR) +00139 +00140 /************************************************************************/ +00146 #define uart_set(reg, val) do{sh.reg = (val);UART_##reg = (val);}while(0) +00147 +00148 /************************************************************************/ +00154 #define uart_get(reg) (sh.reg) +00155 +00156 /************************************************************************/ +00162 #define uart_set_bits(reg, val) do{sh.reg |= (val); \ +00163 UART_##reg = sh.reg;}while(0) +00164 +00165 /************************************************************************/ +00171 #define uart_clr_bits(reg, val) do{sh.reg &= ~(val); \ +00172 UART_##reg = sh.reg;}while(0) +00173 +00174 /************************************************************************/ +00177 #define uart_reset_fifos() uart_set_bits(FCR, 0x07) +00178 +00179 #endif // MODULE_MEGAWIFI +00180 +00181 #endif /*_16C550_H_*/ +00182 +
Basic SGDK library configuration file.
@@ -166,7 +174,7 @@Go to the source code of this file.
-Defines | |
-#define | _SS 0 |
-#define | _FULL_SPEED 1 |
-#define | _SPI16 2 |
-#define | _GAME_MODE 3 |
-#define | _SMS_MODE 4 |
-#define | _HARD_RESET 5 |
-#define | _RAM_MODE_1 6 |
-#define | _RAM_ON 7 |
-#define | _VBL_CATCH 8 |
-#define | _MEGAKEY_ON 9 |
-#define | _MEGAKEY_REGION_1 10 |
-#define | _SSF_MODE_ON 11 |
-#define | _RAM_FS 12 |
-#define | _CART 13 |
-#define | _SPI_READY 0 |
-#define | _RY 1 |
-#define | _SMS_KEY 2 |
-#define | _SD_CART 3 |
-#define | SPI_PORT *((volatile u16*) (0xA13000)) |
-#define | CFG_PORT *((volatile u16*) (0xA13002)) |
-#define | VBL_PORT *((volatile u16*) (0xA13004)) |
-#define | SRAM_BANK_PORT *((volatile u16*) (0xA13006)) |
-#define | VER_PORT *((volatile u16*) (0xA13008)) |
-#define | ROM_MAP_PORT *((volatile u16*) (0xA1300a)) |
-#define | CFGC(bit) (cfg &= ~(1 << bit), CFG_PORT = cfg) |
-#define | CFGS(bit) (cfg |= (1 << bit), CFG_PORT = cfg) |
-#define | IS_RY (CFG_PORT & (1 << _RY)) |
-#define | IS_SPI_READY (CFG_PORT & (1 << _SPI_READY)) |
-#define | IS_SMS_KEY_PRESSED (CFG_PORT & (1 << _SMS_KEY)) |
-#define | IS_SD_SLOT_EMPTY (CFG_PORT & (1 << _SD_CART)) |
-#define | SPI_HI_SPEED_ON CFGS(_FULL_SPEED) |
-#define | SPI_HI_SPEED_OFF CFGC(_FULL_SPEED) |
-#define | SPI16_ON CFGS(_SPI16); |
-#define | SPI16_OFF CFGC(_SPI16); |
-#define | SS_ON CFGC(_SS) |
-#define | SS_OFF CFGS(_SS) |
-#define | CART_ON CFGC(_CART) |
-#define | CART_OFF CFGS(_CART) |
-#define | RAM_ON CFGS(_RAM_ON); |
-#define | RAM_OFF CFGC(_RAM_ON); |
-#define | VBL_CATCH_ON CFGS(_VBL_CATCH); |
-#define | VBL_CATCH_OFF CFGC(_VBL_CATCH); |
-#define | SPI_BUSY while(!IS_SPI_READY) |
-#define | EPR_BUSY while(!IS_RY) |
-Functions | |
-u8 | evd_mmcInit () |
-u8 | evd_mmcRdBlock (u32 mmc_addr, u8 *stor) |
-u8 | evd_mmcWrBlock (u32 mmc_addr, u8 *data_ptr) |
-void | evd_eprEraseBlock (u32 rom_addr) |
-void | evd_eprProgBlock (u16 *data, u32 rom_addr, u32 len) |
-void | evd_init (u16 def_rom_bank, u8 _is_ram_app) |
-Variables | |
-u16 | cfg |
Everdrive support.
@@ -210,7 +99,7 @@16c550.h [code] | |
asm.h [code] | Assembly helper |
bmp.h [code] | Software bitmap engine |
config.h [code] | Basic SGDK library configuration file |
everdrive.h [code] | Everdrive support |
fat16.h [code] | FAT16 file system support |
font.h [code] | SGDK system Font |
gamejolt.h [code] | GameJolt Game API implementation for MegaWiFi |
genesis.h [code] | |
joy.h [code] | General controller support |
jsmn.h [code] | |
json.h [code] | JSON implementation, based on jsmn by Serge Zaitsev |
kdebug.h [code] | Gens KMod debug methods |
libres.h [code] | |
lsd.h [code] | |
map.h [code] | MAP (large background map) management unit |
mapper.h [code] | Mapper / bank switch methods |
maths.h [code] | Mathematical methods |
maths3D.h [code] | 3D math engine |
megawifi.h [code] | MegaWiFi API implementation |
memory.h [code] | Memory handling methods |
mw-msg.h [code] | MegaWiFi command message definitions |
pal.h [code] | Palette support (herited from vdp_pal.h unit) |
psg.h [code] | PSG support |
smp_null.h [code] | |
sys.h [code] | Entry point unit / Interrupt callback / System |
tab_cnv.h [code] | |
tab_vol.h [code] | |
task.h [code] | User task support |
task_cst.h [code] | User task constantes definition |
timer.h [code] | Timer support |
tools.h [code] | Misc tools methods |
types.h [code] | Types definition |
+ sgdk
+ |
+
GameJolt Game API implementation for MegaWiFi. +More...
+#include "types.h"
Go to the source code of this file.
+GameJolt Game API implementation for MegaWiFi.
+
+ sgdk
+ |
+
00001 /************************************************************************/ +00024 #ifndef _GAMEJOLT_H_ +00025 #define _GAMEJOLT_H_ +00026 +00027 #include "types.h" +00028 +00029 #if (MODULE_MEGAWIFI != 0) +00030 +00036 enum gj_error { +00037 GJ_ERR_NONE = 0, +00038 GJ_ERR_PARAM = -1, +00039 GJ_ERR_REQUEST = -2, +00040 GJ_ERR_RECEPTION = -3, +00041 GJ_ERR_RESPONSE = -4, +00042 GJ_ERR_PARSE = -5 +00043 }; +00044 +00046 enum gj_trophy_difficulty { +00047 GJ_TROPHY_TYPE_BRONZE = 0, +00048 GJ_TROPHY_TYPE_SILVER, +00049 GJ_TROPHY_TYPE_GOLD, +00050 GJ_TROPHY_TYPE_PLATINUM, +00051 GJ_TROPHY_TYPE_UNKNOWN +00052 }; +00053 +00055 enum gj_data_store_update_operation { +00056 GJ_OP_ADD = 0, +00057 GJ_OP_SUBTRACT, +00058 GJ_OP_MULTIPLY, +00059 GJ_OP_DIVIDE, +00060 GJ_OP_APPEND, +00061 GJ_OP_PREPEND, +00062 GJ_OP_MAX +00063 }; +00064 +00066 #define GJ_TROPHY_RESPONSE_TABLE(X_MACRO) \ +00067 X_MACRO(id, string, char*) \ +00068 X_MACRO(title, string, char*) \ +00069 X_MACRO(difficulty, trophy_difficulty, enum gj_trophy_difficulty) \ +00070 X_MACRO(description, string, char*) \ +00071 X_MACRO(image_url, string, char*) \ +00072 X_MACRO(achieved, string, char*) +00073 +00075 #define GJ_TIME_RESPONSE_TABLE(X_MACRO) \ +00076 X_MACRO(timestamp, string, char*) \ +00077 X_MACRO(timezone, string, char*) \ +00078 X_MACRO(day, string, char*) \ +00079 X_MACRO(hour, string, char*) \ +00080 X_MACRO(minute, string, char*) \ +00081 X_MACRO(second, string, char*) +00082 +00084 #define GJ_SCORE_RESPONSE_TABLE(X_MACRO) \ +00085 X_MACRO(score, string, char*) \ +00086 X_MACRO(sort, string, char*) \ +00087 X_MACRO(extra_data, string, char*) \ +00088 X_MACRO(user, string, char*) \ +00089 X_MACRO(user_id, string, char*) \ +00090 X_MACRO(guest, string, char*) \ +00091 X_MACRO(stored, string, char*) \ +00092 X_MACRO(stored_timestamp, string, char*) +00093 +00095 #define GJ_SCORE_TABLE_RESPONSE_TABLE(X_MACRO) \ +00096 X_MACRO(id, string, char*) \ +00097 X_MACRO(name, string, char*) \ +00098 X_MACRO(description, string, char*) \ +00099 X_MACRO(primary, bool_num, bool) +00100 +00102 #define GJ_SCORE_GETRANK_RESPONSE_TABLE(X_MACRO) \ +00103 X_MACRO(message, string, char*) \ +00104 X_MACRO(rank, string, char*) +00105 +00107 #define GJ_USER_RESPONSE_TABLE(X_MACRO) \ +00108 X_MACRO(id, string, char*) \ +00109 X_MACRO(type, string, char*) \ +00110 X_MACRO(username, string, char*) \ +00111 X_MACRO(avatar_url, string, char*) \ +00112 X_MACRO(signed_up, string, char*) \ +00113 X_MACRO(signed_up_timestamp, string, char*) \ +00114 X_MACRO(last_logged_in, string, char*) \ +00115 X_MACRO(last_logged_in_timestamp, string, char*) \ +00116 X_MACRO(status, string, char*) \ +00117 X_MACRO(developer_name, string, char*) \ +00118 X_MACRO(developer_website, string, char*) \ +00119 X_MACRO(developer_description, string, char*) +00120 +00122 #define X_AS_STRUCT(field, decoder, type) \ +00123 type field; +00124 +00126 struct gj_trophy { +00127 GJ_TROPHY_RESPONSE_TABLE(X_AS_STRUCT); +00128 bool secret; +00129 }; +00130 +00132 struct gj_time { +00133 GJ_TIME_RESPONSE_TABLE(X_AS_STRUCT); +00134 }; +00135 +00137 struct gj_score { +00138 GJ_SCORE_RESPONSE_TABLE(X_AS_STRUCT); +00139 }; +00140 +00142 struct gj_score_table { +00143 GJ_SCORE_TABLE_RESPONSE_TABLE(X_AS_STRUCT); +00144 }; +00145 +00147 struct gj_user { +00148 GJ_USER_RESPONSE_TABLE(X_AS_STRUCT); +00149 }; +00150 +00151 /************************************************************************/ +00174 bool gj_init(const char *endpoint, const char *game_id, const char *private_key, +00175 const char *username, const char *user_token, char *reply_buf, +00176 uint16_t buf_len, uint16_t tout_frames); +00177 +00178 /************************************************************************/ +00186 enum gj_error gj_get_error(void); +00187 +00188 /************************************************************************/ +00198 char *gj_trophies_fetch(bool achieved, const char *trophy_id); +00199 +00200 /************************************************************************/ +00214 char *gj_trophy_get_next(char *pos, struct gj_trophy *trophy); +00215 +00216 /************************************************************************/ +00223 bool gj_trophy_add_achieved(const char *trophy_id); +00224 +00225 /************************************************************************/ +00232 bool gj_trophy_remove_achieved(const char *trophy_id); +00233 +00234 /************************************************************************/ +00242 const char *gj_trophy_difficulty_str(enum gj_trophy_difficulty difficulty); +00243 +00244 /************************************************************************/ +00251 bool gj_time(struct gj_time *time); +00252 +00253 /************************************************************************/ +00268 char *gj_scores_fetch(const char *limit, const char *table_id, +00269 const char *guest, const char *better_than, +00270 const char *worse_than, bool only_user); +00271 +00272 /************************************************************************/ +00286 char *gj_score_get_next(char *pos, struct gj_score *score); +00287 +00288 /************************************************************************/ +00294 char *gj_scores_tables_fetch(void); +00295 +00296 /************************************************************************/ +00310 char *gj_score_table_get_next(char *pos, struct gj_score_table *score_table); +00311 +00312 /************************************************************************/ +00320 char *gj_scores_get_rank(const char *sort, const char *table_id); +00321 +00322 /************************************************************************/ +00333 bool gj_scores_add(const char *score, const char *sort, const char *table_id, +00334 const char *guest, const char *extra_data); +00335 +00336 /************************************************************************/ +00346 bool gj_data_store_set(const char *key, const char *data, bool user_store); +00347 +00348 /************************************************************************/ +00359 char *gj_data_store_keys_fetch(const char *pattern, bool user_store); +00360 +00361 /************************************************************************/ +00375 char *gj_data_store_key_next(char *pos, char **key); +00376 +00377 /************************************************************************/ +00387 char *data_store_fetch(const char *key, bool user_store); +00388 +00389 /************************************************************************/ +00400 char *gj_data_store_update(const char *key, +00401 enum gj_data_store_update_operation operation, +00402 const char *value, bool user_store); +00403 +00404 /************************************************************************/ +00413 bool gj_data_store_remove(const char *key, bool user_store); +00414 +00415 /************************************************************************/ +00420 bool gj_sessions_open(void); +00421 +00422 /************************************************************************/ +00430 bool gj_sessions_ping(bool active); +00431 +00432 /************************************************************************/ +00446 bool gj_sessions_check(const char *username, const char *user_token); +00447 +00448 /************************************************************************/ +00453 bool gj_sessions_close(void); +00454 +00455 /************************************************************************/ +00468 char *gj_users_fetch(const char *username, const char *user_id); +00469 +00470 /************************************************************************/ +00484 char *gj_user_get_next(char *pos, struct gj_user *user); +00485 +00486 /************************************************************************/ +00495 bool gj_users_auth(void); +00496 +00497 /************************************************************************/ +00503 char *gj_friends_fetch(void); +00504 +00505 /************************************************************************/ +00519 char *gj_friend_get_next(char *pos, char **user_id); +00520 +00521 /************************************************************************/ +00537 char *gj_request(const char **path, uint8_t num_paths, const char **key, +00538 const char **value, uint8_t num_kv_pairs, uint32_t *out_len); +00539 +00540 #endif // MODULE_MEGAWIFI +00541 +00542 #endif /*_GAMEJOLT_H_*/ +00543 +
00001 #ifndef _GENESIS_H_ 00002 #define _GENESIS_H_ 00003 -00004 -00005 #define SGDK_VERSION 1.65 -00006 -00007 #include "config.h" -00008 #include "asm.h" -00009 #include "types.h" -00010 -00011 #include "sys.h" -00012 #include "sram.h" -00013 #include "mapper.h" -00014 #include "memory.h" -00015 #include "tools.h" -00016 -00017 #include "font.h" -00018 #include "string.h" -00019 -00020 #include "tab_cnv.h" +00004 #define SGDK_VERSION 1.65 +00005 +00006 #include "types.h" +00007 +00008 #define SGDK TRUE +00009 +00010 #include "config.h" +00011 #include "asm.h" +00012 +00013 #include "sys.h" +00014 #include "sram.h" +00015 #include "mapper.h" +00016 #include "memory.h" +00017 #include "tools.h" +00018 +00019 #include "font.h" +00020 #include "string.h" 00021 -00022 #include "maths.h" -00023 #include "maths3D.h" -00024 -00025 #include "vdp.h" -00026 #include "vdp_bg.h" -00027 #include "vdp_dma.h" -00028 #include "vdp_spr.h" -00029 #include "vdp_tile.h" -00030 #include "vdp_pal.h" -00031 -00032 #include "pal.h" +00022 #include "tab_cnv.h" +00023 +00024 #include "maths.h" +00025 #include "maths3D.h" +00026 +00027 #include "vdp.h" +00028 #include "vdp_bg.h" +00029 #include "vdp_dma.h" +00030 #include "vdp_spr.h" +00031 #include "vdp_tile.h" +00032 #include "vdp_pal.h" 00033 -00034 #include "vram.h" -00035 #include "dma.h" -00036 -00037 #include "map.h" +00034 #include "pal.h" +00035 +00036 #include "vram.h" +00037 #include "dma.h" 00038 -00039 #include "bmp.h" -00040 #include "sprite_eng.h" -00041 -00042 #include "sound.h" -00043 #include "xgm.h" -00044 #include "z80_ctrl.h" -00045 #include "ym2612.h" -00046 #include "psg.h" -00047 #include "joy.h" -00048 #include "timer.h" -00049 -00050 // preserve compatibility with old resources name -00051 #define logo_lib sgdk_logo -00052 #define font_lib font_default -00053 #define font_pal_lib font_pal_default -00054 -00055 #endif // _GENESIS_H_ +00039 #include "map.h" +00040 +00041 #include "bmp.h" +00042 #include "sprite_eng.h" +00043 +00044 #include "sound.h" +00045 #include "xgm.h" +00046 #include "z80_ctrl.h" +00047 #include "ym2612.h" +00048 #include "psg.h" +00049 #include "joy.h" +00050 #include "timer.h" +00051 +00052 #include "task.h" +00053 +00054 // modules +00055 #if (MODULE_EVERDRIVE != 0) +00056 #include "ext/everdrive.h" +00057 #endif +00058 +00059 #if (MODULE_FAT16 != 0) +00060 #include "ext/fat16.h" +00061 #endif +00062 +00063 #if (MODULE_MEGAWIFI != 0) +00064 #include "ext/mw/megawifi.h" +00065 #endif +00066 +00067 // preserve compatibility with old resources name +00068 #define logo_lib sgdk_logo +00069 #define font_lib font_default +00070 #define font_pal_lib font_pal_default +00071 +00072 #endif // _GENESIS_H_
+ sgdk
+ |
+
+ sgdk
+ |
+
+ sgdk
+ |
+
Simple 16C550 UART chip driver. +More...
+Simple 16C550 UART chip driver.
+
+ sgdk
+ |
+
GameJolt Game API implementation for MegaWiFi. +More...
+GameJolt Game API implementation for MegaWiFi.
+Implementation of the version 1.2 of the GameJolt Game API, supporting scoreboards, trophies, friends, etc. For more information, read the original GameJolt Game API documentation: https://gamejolt.com/game-api/doc
+
+ sgdk
+ |
+
JSON implementation, based on jsmn by Serge Zaitsev. +More...
+JSON implementation, based on jsmn by Serge Zaitsev.
+This module just adds some helper functions to jsmn to ease navigating the JSON structure and extracting values.
+
+ sgdk
+ |
+
Local Symmetric Data-link. Implements an extremely simple protocol to link two full-duplex devices, multiplexing the data link. +More...
+Local Symmetric Data-link. Implements an extremely simple protocol to link two full-duplex devices, multiplexing the data link.
+The multiplexing facility allows having up to LSD_MAX_CH simultaneous channels on the serial link.
+The module has synchronous functions to send/receive data (easy to use, but due to polling hang the console until transfer is complete) and their asyncronous counterparts. The asynchronous functions return immediately, but require calling frequently lsd_process() to actually send/receive data. Once the asynchronous functions complete sending/receiving data, the specified callback is run.
+
+ sgdk
+ |
+
MegaWiFi API implementation. +More...
+MegaWiFi API implementation.
+API to communicate with the wifi module and the Internet. API calls are documented and most of them are self explanatory. Mostly the only weird thing about the API is UDP reuse mode. If you enable reuse mode (setting the dst_addr and/or dst_port to NULL in the mw_udp_set() call), received data will prepend the IP and port of the peer (using mw_reuse_payload data structure), and data to be sent also requires the IP and port to be prepended to the payload.
+
+ sgdk
+ |
+
MegaWiFi command message definitions. +More...
+MegaWiFi command message definitions.
+Contains the definition of the command codes and the data structures conforming the command message queries and responses. Usually this module is not directly used by the application, but by megawifi internally.
+
+ sgdk
+ |
+
00001 /* +00002 * MIT License +00003 * +00004 * Copyright (c) 2010 Serge Zaitsev +00005 * +00006 * Permission is hereby granted, free of charge, to any person obtaining a copy +00007 * of this software and associated documentation files (the "Software"), to deal +00008 * in the Software without restriction, including without limitation the rights +00009 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +00010 * copies of the Software, and to permit persons to whom the Software is +00011 * furnished to do so, subject to the following conditions: +00012 * +00013 * The above copyright notice and this permission notice shall be included in +00014 * all copies or substantial portions of the Software. +00015 * +00016 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +00017 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +00018 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +00019 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +00020 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +00021 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +00022 * SOFTWARE. +00023 */ +00024 #ifndef JSMN_H +00025 #define JSMN_H +00026 +00027 #include "types.h" +00028 +00029 #if (MODULE_MEGAWIFI != 0) +00030 +00031 #ifdef __cplusplus +00032 extern "C" { +00033 #endif +00034 +00035 #ifdef JSMN_STATIC +00036 #define JSMN_API static +00037 #else +00038 #define JSMN_API extern +00039 #endif +00040 +00048 typedef enum { +00049 JSMN_UNDEFINED = 0, +00050 JSMN_OBJECT = 1, +00051 JSMN_ARRAY = 2, +00052 JSMN_STRING = 3, +00053 JSMN_PRIMITIVE = 4 +00054 } jsmntype_t; +00055 +00056 enum jsmnerr { +00057 /* Not enough tokens were provided */ +00058 JSMN_ERROR_NOMEM = -1, +00059 /* Invalid character inside JSON string */ +00060 JSMN_ERROR_INVAL = -2, +00061 /* The string is not a full JSON packet, more bytes expected */ +00062 JSMN_ERROR_PART = -3 +00063 }; +00064 +00071 typedef struct { +00072 jsmntype_t type; +00073 int start; +00074 int end; +00075 int size; +00076 #ifdef JSMN_PARENT_LINKS +00077 int parent; +00078 #endif +00079 } jsmntok_t; +00080 +00085 typedef struct { +00086 unsigned int pos; /* offset in the JSON string */ +00087 unsigned int toknext; /* next token to allocate */ +00088 int toksuper; /* superior token node, e.g. parent object or array */ +00089 } jsmn_parser; +00090 +00094 JSMN_API void jsmn_init(jsmn_parser *parser); +00095 +00101 JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const unsigned int len, +00102 jsmntok_t *tokens, const unsigned int num_tokens); +00103 +00104 #ifndef JSMN_HEADER +00105 +00108 static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, jsmntok_t *tokens, +00109 const unsigned int num_tokens) { +00110 jsmntok_t *tok; +00111 if (parser->toknext >= num_tokens) { +00112 return NULL; +00113 } +00114 tok = &tokens[parser->toknext++]; +00115 tok->start = tok->end = -1; +00116 tok->size = 0; +00117 #ifdef JSMN_PARENT_LINKS +00118 tok->parent = -1; +00119 #endif +00120 return tok; +00121 } +00122 +00126 static void jsmn_fill_token(jsmntok_t *token, const jsmntype_t type, +00127 const int start, const int end) { +00128 token->type = type; +00129 token->start = start; +00130 token->end = end; +00131 token->size = 0; +00132 } +00133 +00137 static int jsmn_parse_primitive(jsmn_parser *parser, const char *js, +00138 const unsigned int len, jsmntok_t *tokens, +00139 const unsigned int num_tokens) { +00140 jsmntok_t *token; +00141 int start; +00142 +00143 start = parser->pos; +00144 +00145 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { +00146 switch (js[parser->pos]) { +00147 #ifndef JSMN_STRICT +00148 /* In strict mode primitive must be followed by "," or "}" or "]" */ +00149 case ':': +00150 #endif +00151 case '\t': +00152 case '\r': +00153 case '\n': +00154 case ' ': +00155 case ',': +00156 case ']': +00157 case '}': +00158 goto found; +00159 default: +00160 /* to quiet a warning from gcc*/ +00161 break; +00162 } +00163 if (js[parser->pos] < 32 || js[parser->pos] >= 127) { +00164 parser->pos = start; +00165 return JSMN_ERROR_INVAL; +00166 } +00167 } +00168 #ifdef JSMN_STRICT +00169 /* In strict mode primitive must be followed by a comma/object/array */ +00170 parser->pos = start; +00171 return JSMN_ERROR_PART; +00172 #endif +00173 +00174 found: +00175 if (tokens == NULL) { +00176 parser->pos--; +00177 return 0; +00178 } +00179 token = jsmn_alloc_token(parser, tokens, num_tokens); +00180 if (token == NULL) { +00181 parser->pos = start; +00182 return JSMN_ERROR_NOMEM; +00183 } +00184 jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); +00185 #ifdef JSMN_PARENT_LINKS +00186 token->parent = parser->toksuper; +00187 #endif +00188 parser->pos--; +00189 return 0; +00190 } +00191 +00195 static int jsmn_parse_string(jsmn_parser *parser, const char *js, +00196 const unsigned int len, jsmntok_t *tokens, +00197 const unsigned int num_tokens) { +00198 jsmntok_t *token; +00199 +00200 int start = parser->pos; +00201 +00202 parser->pos++; +00203 +00204 /* Skip starting quote */ +00205 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { +00206 char c = js[parser->pos]; +00207 +00208 /* Quote: end of string */ +00209 if (c == '\"') { +00210 if (tokens == NULL) { +00211 return 0; +00212 } +00213 token = jsmn_alloc_token(parser, tokens, num_tokens); +00214 if (token == NULL) { +00215 parser->pos = start; +00216 return JSMN_ERROR_NOMEM; +00217 } +00218 jsmn_fill_token(token, JSMN_STRING, start + 1, parser->pos); +00219 #ifdef JSMN_PARENT_LINKS +00220 token->parent = parser->toksuper; +00221 #endif +00222 return 0; +00223 } +00224 +00225 /* Backslash: Quoted symbol expected */ +00226 if (c == '\\' && parser->pos + 1 < len) { +00227 int i; +00228 parser->pos++; +00229 switch (js[parser->pos]) { +00230 /* Allowed escaped symbols */ +00231 case '\"': +00232 case '/': +00233 case '\\': +00234 case 'b': +00235 case 'f': +00236 case 'r': +00237 case 'n': +00238 case 't': +00239 break; +00240 /* Allows escaped symbol \uXXXX */ +00241 case 'u': +00242 parser->pos++; +00243 for (i = 0; i < 4 && parser->pos < len && js[parser->pos] != '\0'; +00244 i++) { +00245 /* If it isn't a hex character we have an error */ +00246 if (!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ +00247 (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ +00248 (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ +00249 parser->pos = start; +00250 return JSMN_ERROR_INVAL; +00251 } +00252 parser->pos++; +00253 } +00254 parser->pos--; +00255 break; +00256 /* Unexpected symbol */ +00257 default: +00258 parser->pos = start; +00259 return JSMN_ERROR_INVAL; +00260 } +00261 } +00262 } +00263 parser->pos = start; +00264 return JSMN_ERROR_PART; +00265 } +00266 +00270 JSMN_API int jsmn_parse(jsmn_parser *parser, const char *js, const unsigned int len, +00271 jsmntok_t *tokens, const unsigned int num_tokens) { +00272 int r; +00273 int i; +00274 jsmntok_t *token; +00275 int count = parser->toknext; +00276 +00277 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { +00278 char c; +00279 jsmntype_t type; +00280 +00281 c = js[parser->pos]; +00282 switch (c) { +00283 case '{': +00284 case '[': +00285 count++; +00286 if (tokens == NULL) { +00287 break; +00288 } +00289 token = jsmn_alloc_token(parser, tokens, num_tokens); +00290 if (token == NULL) { +00291 return JSMN_ERROR_NOMEM; +00292 } +00293 if (parser->toksuper != -1) { +00294 jsmntok_t *t = &tokens[parser->toksuper]; +00295 #ifdef JSMN_STRICT +00296 /* In strict mode an object or array can't become a key */ +00297 if (t->type == JSMN_OBJECT) { +00298 return JSMN_ERROR_INVAL; +00299 } +00300 #endif +00301 t->size++; +00302 #ifdef JSMN_PARENT_LINKS +00303 token->parent = parser->toksuper; +00304 #endif +00305 } +00306 token->type = (c == '{' ? JSMN_OBJECT : JSMN_ARRAY); +00307 token->start = parser->pos; +00308 parser->toksuper = parser->toknext - 1; +00309 break; +00310 case '}': +00311 case ']': +00312 if (tokens == NULL) { +00313 break; +00314 } +00315 type = (c == '}' ? JSMN_OBJECT : JSMN_ARRAY); +00316 #ifdef JSMN_PARENT_LINKS +00317 if (parser->toknext < 1) { +00318 return JSMN_ERROR_INVAL; +00319 } +00320 token = &tokens[parser->toknext - 1]; +00321 for (;;) { +00322 if (token->start != -1 && token->end == -1) { +00323 if (token->type != type) { +00324 return JSMN_ERROR_INVAL; +00325 } +00326 token->end = parser->pos + 1; +00327 parser->toksuper = token->parent; +00328 break; +00329 } +00330 if (token->parent == -1) { +00331 if (token->type != type || parser->toksuper == -1) { +00332 return JSMN_ERROR_INVAL; +00333 } +00334 break; +00335 } +00336 token = &tokens[token->parent]; +00337 } +00338 #else +00339 for (i = parser->toknext - 1; i >= 0; i--) { +00340 token = &tokens[i]; +00341 if (token->start != -1 && token->end == -1) { +00342 if (token->type != type) { +00343 return JSMN_ERROR_INVAL; +00344 } +00345 parser->toksuper = -1; +00346 token->end = parser->pos + 1; +00347 break; +00348 } +00349 } +00350 /* Error if unmatched closing bracket */ +00351 if (i == -1) { +00352 return JSMN_ERROR_INVAL; +00353 } +00354 for (; i >= 0; i--) { +00355 token = &tokens[i]; +00356 if (token->start != -1 && token->end == -1) { +00357 parser->toksuper = i; +00358 break; +00359 } +00360 } +00361 #endif +00362 break; +00363 case '\"': +00364 r = jsmn_parse_string(parser, js, len, tokens, num_tokens); +00365 if (r < 0) { +00366 return r; +00367 } +00368 count++; +00369 if (parser->toksuper != -1 && tokens != NULL) { +00370 tokens[parser->toksuper].size++; +00371 } +00372 break; +00373 case '\t': +00374 case '\r': +00375 case '\n': +00376 case ' ': +00377 break; +00378 case ':': +00379 parser->toksuper = parser->toknext - 1; +00380 break; +00381 case ',': +00382 if (tokens != NULL && parser->toksuper != -1 && +00383 tokens[parser->toksuper].type != JSMN_ARRAY && +00384 tokens[parser->toksuper].type != JSMN_OBJECT) { +00385 #ifdef JSMN_PARENT_LINKS +00386 parser->toksuper = tokens[parser->toksuper].parent; +00387 #else +00388 for (i = parser->toknext - 1; i >= 0; i--) { +00389 if (tokens[i].type == JSMN_ARRAY || tokens[i].type == JSMN_OBJECT) { +00390 if (tokens[i].start != -1 && tokens[i].end == -1) { +00391 parser->toksuper = i; +00392 break; +00393 } +00394 } +00395 } +00396 #endif +00397 } +00398 break; +00399 #ifdef JSMN_STRICT +00400 /* In strict mode primitives are: numbers and booleans */ +00401 case '-': +00402 case '0': +00403 case '1': +00404 case '2': +00405 case '3': +00406 case '4': +00407 case '5': +00408 case '6': +00409 case '7': +00410 case '8': +00411 case '9': +00412 case 't': +00413 case 'f': +00414 case 'n': +00415 /* And they must not be keys of the object */ +00416 if (tokens != NULL && parser->toksuper != -1) { +00417 const jsmntok_t *t = &tokens[parser->toksuper]; +00418 if (t->type == JSMN_OBJECT || +00419 (t->type == JSMN_STRING && t->size != 0)) { +00420 return JSMN_ERROR_INVAL; +00421 } +00422 } +00423 #else +00424 /* In non-strict mode every unquoted value is a primitive */ +00425 default: +00426 #endif +00427 r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); +00428 if (r < 0) { +00429 return r; +00430 } +00431 count++; +00432 if (parser->toksuper != -1 && tokens != NULL) { +00433 tokens[parser->toksuper].size++; +00434 } +00435 break; +00436 +00437 #ifdef JSMN_STRICT +00438 /* Unexpected char in strict mode */ +00439 default: +00440 return JSMN_ERROR_INVAL; +00441 #endif +00442 } +00443 } +00444 +00445 if (tokens != NULL) { +00446 for (i = parser->toknext - 1; i >= 0; i--) { +00447 /* Unmatched opened object or array */ +00448 if (tokens[i].start != -1 && tokens[i].end == -1) { +00449 return JSMN_ERROR_PART; +00450 } +00451 } +00452 } +00453 +00454 return count; +00455 } +00456 +00461 JSMN_API void jsmn_init(jsmn_parser *parser) { +00462 parser->pos = 0; +00463 parser->toknext = 0; +00464 parser->toksuper = -1; +00465 } +00466 +00467 #endif /* JSMN_HEADER */ +00468 +00469 #ifdef __cplusplus +00470 } +00471 #endif +00472 +00473 #endif // MODULE_MEGAWIFI +00474 +00475 #endif /* JSMN_H */ +
+ sgdk
+ |
+
JSON implementation, based on jsmn by Serge Zaitsev. +More...
+#include "types.h"
Go to the source code of this file.
+JSON implementation, based on jsmn by Serge Zaitsev.
+
+ sgdk
+ |
+
00001 /************************************************************************/ +00020 #ifndef _JSON_H_ +00021 #define _JSON_H_ +00022 +00023 #include "types.h" +00024 +00025 #if (MODULE_MEGAWIFI != 0) +00026 +00028 #define JSMN_STATIC +00029 #include "jsmn.h" +00030 +00033 #define json_item(json_str, obj_tok, idx) (idx) < 0 ? NULL : \ +00034 &((json_str)[(obj_tok)[idx].start]) +00035 +00036 /************************************************************************/ +00048 int json_null_terminate(char *json_str, const jsmntok_t *obj_tok, int num_tok); +00049 +00050 /************************************************************************/ +00060 bool json_is_key(const jsmntok_t *json_tok, int obj_idx, int num_tok); +00061 +00062 /************************************************************************/ +00074 int json_object_next(const jsmntok_t *obj_tok, int obj_idx, int parent_idx, +00075 int num_tok); +00076 +00077 /************************************************************************/ +00088 int json_key_next(const jsmntok_t *json_tok, int obj_idx, int parent_idx, +00089 int num_tok); +00090 +00091 /************************************************************************/ +00106 int json_key_search(const char *key, const char *json_str, +00107 const jsmntok_t *json_tok, int obj_idx, int parent_idx, +00108 int num_tok); +00109 +00110 /************************************************************************/ +00119 int json_bool_get(const char *json_str, const jsmntok_t *json_tok, int obj_idx); +00120 +00121 #endif // MODULE_MEGAWIFI +00122 +00123 #endif /*_JSON_H_*/ +00124 +
+ sgdk
+ |
+
00001 /************************************************************************/ +00032 /* +00033 * Frame format is: +00034 * +00035 * STX : CH-LENH : LENL : DATA : ETX +00036 * +00037 * - STX and ETX are the start/end of transmission characters (1 byte each). +00038 * - CH-LENH is the channel number (first 4 bits) and the 4 high bits of the +00039 * data length. +00040 * - LENL is the low 8 bits of the data length. +00041 * - DATA is the payload, of the previously specified length. +00042 */ +00043 #ifndef _LSD_H_ +00044 #define _LSD_H_ +00045 +00046 #include "16c550.h" +00047 #include "mw-msg.h" +00048 +00049 #if (MODULE_MEGAWIFI != 0) +00050 +00052 #define LSD_OVERHEAD 4 +00053 +00055 #define LSD_MAX_CH 4 +00056 +00058 #define LSD_MAX_LEN 4095 +00059 +00061 #define LSD_BUF_FRAMES 2 +00062 +00064 enum lsd_status { +00065 LSD_STAT_ERR_FRAMING = -5, +00066 LSD_STAT_ERR_INVALID_CH = -4, +00067 LSD_STAT_ERR_FRAME_TOO_LONG = -3, +00068 LSD_STAT_ERR_IN_PROGRESS = -2, +00069 LSD_STAT_ERROR = -1, +00070 LSD_STAT_COMPLETE = 0, +00071 LSD_STAT_BUSY = 1 +00072 }; +00073 +00075 typedef void (*lsd_send_cb)(enum lsd_status stat, void *ctx); +00077 typedef void (*lsd_recv_cb)(enum lsd_status stat, uint8_t ch, +00078 char *data, uint16_t len, void *ctx); +00079 +00080 /************************************************************************/ +00083 void lsd_init(void); +00084 +00085 /************************************************************************/ +00092 int lsd_ch_enable(uint8_t ch); +00093 +00094 /************************************************************************/ +00101 int lsd_ch_disable(uint8_t ch); +00102 +00103 +00104 /************************************************************************/ +00118 enum lsd_status lsd_send(uint8_t ch, const char *data, int16_t len, +00119 void *ctx, lsd_send_cb send_cb); +00120 +00121 /************************************************************************/ +00131 enum lsd_status lsd_send_sync(uint8_t ch, const char *data, int16_t len); +00132 +00133 /************************************************************************/ +00143 enum lsd_status lsd_recv(char *buf, int16_t len, void *ctx, +00144 lsd_recv_cb recv_cb); +00145 +00146 /************************************************************************/ +00158 enum lsd_status lsd_recv_sync(char *buf, uint16_t *len, uint8_t *ch); +00159 +00160 /************************************************************************/ +00166 void lsd_process(void); +00167 +00168 /************************************************************************/ +00175 void lsd_line_sync(void); +00176 +00177 #endif // MODULE_MEGAWIFI +00178 +00179 #endif //_LSD_H_ +00180 +
void MAP_scrollToEx | +( | +Map * | +map, | +
+ | + | u32 | +x, | +
+ | + | u32 | +y, | +
+ | + | bool | +forceRedraw | +
+ | ) | ++ |
Exactly as MAP_scrollTo(..) except we can force complete map drawing.
+map | Map structure containing map information. |
x | view position X we want to scroll on |
y | view position Y we want to scroll on |
forceRedraw | Set to TRUE to force a complete map redraw (take more time) |
Return next pow2 value which is greater than specified 32 bits unsigned value. Ex:
+ getNextPow2(700) = 1024
+ getNextPow2(18) = 32
+
value | value to return next pow2 |
+ sgdk
+ |
+
MegaWiFi API implementation. +More...
+ +Go to the source code of this file.
+MegaWiFi API implementation.
+
+ sgdk
+ |
+
00001 /************************************************************************/ +00026 #ifndef _MEGAWIFI_H_ +00027 #define _MEGAWIFI_H_ +00028 +00029 #include "16c550.h" +00030 #include "mw-msg.h" +00031 #include "lsd.h" +00032 +00033 #if (MODULE_MEGAWIFI != 0) +00034 +00035 +00037 #define MW_API_VERSION_MAJOR 1 +00038 +00040 #define MW_API_VERSION_MINOR 5 +00041 +00043 #define MW_COMMAND_TOUT_MS 1000 +00044 +00045 #define MW_CONNECT_TOUT_MS 10000 +00046 +00047 #define MW_HTTP_OPEN_TOUT_MS 10000 +00048 +00049 #define MW_SCAN_TOUT_MS 10000 +00050 +00051 #define MW_ASSOC_TOUT_MS 20000 +00052 +00053 #define MW_ASSOC_WAIT_SLEEP_MS 5000 +00054 +00055 #define MW_UPGRADE_TOUT_MS 180000 +00056 +00057 #define MW_STAT_POLL_MS 250 +00058 +00060 enum mw_err { +00061 MW_ERR_NONE = 0, +00062 MW_ERR, +00063 MW_ERR_NOT_READY, +00064 MW_ERR_BUFFER_TOO_SHORT, +00065 MW_ERR_PARAM, +00066 MW_ERR_SEND, +00067 MW_ERR_RECV +00068 }; +00069 +00071 enum mw_http_method { +00072 MW_HTTP_METHOD_GET = 0, +00073 MW_HTTP_METHOD_POST, +00074 MW_HTTP_METHOD_PUT, +00075 MW_HTTP_METHOD_PATCH, +00076 MW_HTTP_METHOD_DELETE, +00077 MW_HTTP_METHOD_HEAD, +00078 MW_HTTP_METHOD_NOTIFY, +00079 MW_HTTP_METHOD_SUBSCRIBE, +00080 MW_HTTP_METHOD_UNSUBSCRIBE, +00081 MW_HTTP_METHOD_OPTIONS, +00082 MW_HTTP_METHOD_MAX, +00083 }; +00084 +00088 #define MW__RESET UART_MCR__OUT1 ///< Reset out. +00089 #define MW__PRG UART_MCR__OUT2 ///< Program out. +00090 #define MW__PD UART_MCR__DTR ///< Power Down out. +00091 #define MW__DAT UART_MSR__DSR ///< Data request in. +00092 +00094 +00095 #define MW_SSID_MAXLEN 32 +00096 +00097 #define MW_PASS_MAXLEN 64 +00098 +00099 #define MW_NTP_POOL_MAXLEN 80 +00100 +00101 #define MW_NUM_CFG_SLOTS 3 +00102 +00103 #define MW_NUM_DNS_SERVERS 2 +00104 +00105 #define MW_FSM_QUEUE_LEN 8 +00106 +00107 #define MW_MAX_SOCK 3 +00108 +00109 #define MW_CTRL_CH 0 +00110 +00111 #define MW_HTTP_CH LSD_MAX_CH - 1 +00112 +00116 #define MW_CMD_MIN_BUFLEN 168 +00117 +00119 struct mw_ap_data { +00120 enum mw_security auth; +00121 uint8_t channel; +00122 int8_t rssi; +00123 uint8_t ssid_len; +00124 char *ssid; +00125 }; +00126 +00128 enum mw_if_type { +00129 MW_IF_STATION = 0, +00130 MW_IF_SOFTAP, +00131 MW_IF_MAX +00132 }; +00133 +00134 /************************************************************************/ +00143 int16_t mw_init(char *cmd_buf, uint16_t buf_len); +00144 +00145 /************************************************************************/ +00153 static inline void mw_process(void) {lsd_process();} +00154 +00155 /************************************************************************/ +00165 void mw_cmd_data_cb_set(lsd_recv_cb cmd_recv_cb); +00166 +00167 /************************************************************************/ +00177 enum mw_err mw_detect(uint8_t *major, uint8_t *minor, char **variant); +00178 +00179 /************************************************************************/ +00187 enum mw_err mw_version_get(uint8_t version[3], char **variant); +00188 +00189 /************************************************************************/ +00196 uint8_t *mw_bssid_get(enum mw_if_type interface_type); +00197 +00198 /************************************************************************/ +00206 enum mw_err mw_default_cfg_set(void); +00207 +00208 /************************************************************************/ +00223 enum mw_err mw_ap_cfg_set(uint8_t slot, const char *ssid, const char *pass, +00224 enum mw_phy_type phy_type); +00225 +00226 /************************************************************************/ +00240 enum mw_err mw_ap_cfg_get(uint8_t slot, char **ssid, char **pass, +00241 enum mw_phy_type *phy_type); +00242 +00243 /************************************************************************/ +00254 enum mw_err mw_ip_cfg_set(uint8_t slot, const struct mw_ip_cfg *ip); +00255 +00256 /************************************************************************/ +00264 enum mw_err mw_ip_cfg_get(uint8_t slot, struct mw_ip_cfg **ip); +00265 +00266 /************************************************************************/ +00282 enum mw_err mw_wifi_adv_cfg_set(const struct mw_wifi_adv_cfg *wifi); +00283 +00284 /************************************************************************/ +00289 struct mw_wifi_adv_cfg *mw_wifi_adv_cfg_get(void); +00290 +00291 /************************************************************************/ +00296 enum mw_err mw_cfg_save(void); +00297 +00298 /************************************************************************/ +00305 enum mw_err mw_ip_current(struct mw_ip_cfg **ip); +00306 +00307 /************************************************************************/ +00318 int16_t mw_ap_scan(enum mw_phy_type phy_type, char **ap_data, uint8_t *aps); +00319 +00320 /************************************************************************/ +00336 int16_t mw_ap_fill_next(const char *ap_data, uint16_t pos, +00337 struct mw_ap_data *apd, uint16_t data_len); +00338 +00339 /************************************************************************/ +00346 enum mw_err mw_ap_assoc(uint8_t slot); +00347 +00348 /************************************************************************/ +00358 enum mw_err mw_ap_assoc_wait(int16_t tout_frames); +00359 +00360 /************************************************************************/ +00370 enum mw_err mw_def_ap_cfg(uint8_t slot); +00371 +00372 /************************************************************************/ +00377 enum mw_err mw_ap_disassoc(void); +00378 +00379 /************************************************************************/ +00384 int16_t mw_def_ap_cfg_get(void); +00385 +00386 /************************************************************************/ +00397 enum mw_err mw_tcp_connect(uint8_t ch, const char *dst_addr, +00398 const char *dst_port, const char *src_port); +00399 +00400 /************************************************************************/ +00410 enum mw_err mw_close(uint8_t ch); +00411 +00413 #define mw_tcp_disconnect(ch) mw_close(ch) +00414 +00415 /************************************************************************/ +00427 enum mw_err mw_udp_set(uint8_t ch, const char *dst_addr, const char *dst_port, +00428 const char *src_port); +00429 +00431 #define mw_udp_unset(ch) mw_close(ch) +00432 +00433 /************************************************************************/ +00443 enum mw_err mw_tcp_bind(uint8_t ch, uint16_t port); +00444 +00445 /************************************************************************/ +00455 enum mw_err mw_sock_conn_wait(uint8_t ch, int16_t tout_frames); +00456 +00457 /************************************************************************/ +00467 static inline enum lsd_status mw_recv(char *buf, int16_t len, void *ctx, +00468 lsd_recv_cb recv_cb) +00469 { +00470 return lsd_recv(buf, len, ctx, recv_cb); +00471 } +00472 +00473 /************************************************************************/ +00484 static inline enum lsd_status mw_udp_reuse_recv(struct mw_reuse_payload *data, +00485 int16_t len, void *ctx, lsd_recv_cb recv_cb) +00486 { +00487 return lsd_recv((char*)data, len, ctx, recv_cb); +00488 } +00489 +00490 /************************************************************************/ +00502 static inline enum lsd_status mw_udp_reuse_send(uint8_t ch, +00503 const struct mw_reuse_payload *data, int16_t len, void *ctx, +00504 lsd_send_cb send_cb) +00505 { +00506 return lsd_send(ch, (const char*)data, len, ctx, send_cb); +00507 } +00508 +00509 /************************************************************************/ +00527 static inline enum lsd_status mw_send(uint8_t ch, const char *data, int16_t len, +00528 void *ctx, lsd_send_cb send_cb) +00529 { +00530 return lsd_send(ch, data, len, ctx, send_cb); +00531 } +00532 +00533 /************************************************************************/ +00547 enum mw_err mw_recv_sync(uint8_t *ch, char *buf, int16_t *buf_len, +00548 int16_t tout_frames); +00549 +00550 /************************************************************************/ +00565 enum mw_err mw_send_sync(uint8_t ch, const char *data, uint16_t len, +00566 int16_t tout_frames); +00567 +00568 /************************************************************************/ +00573 union mw_msg_sys_stat *mw_sys_stat_get(void); +00574 +00575 /************************************************************************/ +00582 enum mw_sock_stat mw_sock_stat_get(uint8_t ch); +00583 +00584 /************************************************************************/ +00596 enum mw_err mw_sntp_cfg_set(const char *tz_str, const char *server[3]); +00597 +00598 /************************************************************************/ +00607 enum mw_err mw_sntp_cfg_get(char **tz_str, char *server[3]); +00608 +00609 /************************************************************************/ +00619 char *mw_date_time_get(uint32_t dt_bin[2]); +00620 +00621 /************************************************************************/ +00629 enum mw_err mw_flash_id_get(uint8_t *man_id, uint16_t *dev_id); +00630 +00631 /************************************************************************/ +00639 enum mw_err mw_flash_sector_erase(uint16_t sect); +00640 +00641 /************************************************************************/ +00650 enum mw_err mw_flash_write(uint32_t addr, uint8_t *data, uint16_t data_len); +00651 +00652 /************************************************************************/ +00660 uint8_t *mw_flash_read(uint32_t addr, uint16_t data_len); +00661 +00662 /************************************************************************/ +00665 #define mw_module_reset() do{uart_set_bits(MCR, MW__RESET);}while(0) +00666 +00667 /************************************************************************/ +00670 #define mw_module_start() do{uart_clr_bits(MCR, MW__RESET);}while(0) +00671 +00672 /************************************************************************/ +00683 enum mw_err mw_gamertag_set(uint8_t slot, const struct mw_gamertag *gamertag); +00684 +00685 /************************************************************************/ +00692 struct mw_gamertag *mw_gamertag_get(uint8_t slot); +00693 +00694 /************************************************************************/ +00701 enum mw_err mw_log(const char *msg); +00702 +00703 /************************************************************************/ +00709 enum mw_err mw_factory_settings(void); +00710 +00711 /************************************************************************/ +00717 void mw_power_off(void); +00718 +00719 /************************************************************************/ +00724 void mw_sleep(int16_t frames); +00725 +00726 /************************************************************************/ +00733 enum mw_err mw_http_url_set(const char *url); +00734 +00735 /************************************************************************/ +00742 enum mw_err mw_http_method_set(enum mw_http_method method); +00743 +00744 /************************************************************************/ +00752 enum mw_err mw_http_header_add(const char *key, const char *value); +00753 +00754 /************************************************************************/ +00761 enum mw_err mw_http_header_del(const char *key); +00762 +00763 /************************************************************************/ +00775 enum mw_err mw_http_open(uint32_t content_len); +00776 +00777 /************************************************************************/ +00795 int16_t mw_http_finish(uint32_t *content_len, int16_t tout_frames); +00796 +00797 /************************************************************************/ +00803 uint32_t mw_http_cert_query(void); +00804 +00805 /************************************************************************/ +00822 enum mw_err mw_http_cert_set(uint32_t cert_hash, const char *cert, +00823 uint16_t cert_len); +00824 +00825 /************************************************************************/ +00830 int16_t mw_http_cleanup(void); +00831 +00832 /************************************************************************/ +00837 char *mw_def_server_get(void); +00838 +00839 /************************************************************************/ +00849 enum mw_err mw_def_server_set(const char *server_url); +00850 +00851 /************************************************************************/ +00859 uint8_t *mw_hrng_get(uint16_t rnd_len); +00860 +00861 /************************************************************************/ +00873 enum mw_err mw_ga_endpoint_set(const char *endpoint, const char *priv_key); +00874 +00875 /************************************************************************/ +00893 enum mw_err mw_ga_key_value_add(const char **key, const char **value, +00894 uint16_t num_pairs); +00895 +00896 /************************************************************************/ +00926 int16_t mw_ga_request(enum mw_http_method method, const char **path, +00927 uint8_t num_paths, const char **key, const char **value, +00928 uint8_t num_kv_pairs, uint32_t *content_len, +00929 int16_t tout_frames); +00930 +00931 /************************************************************************/ +00939 enum mw_err mw_fw_upgrade(const char *name); +00940 +00941 /****** THE FOLLOWING COMMANDS ARE LOWER LEVEL AND USUALLY NOT NEEDED ******/ +00942 +00943 /************************************************************************/ +00952 static inline enum lsd_status mw_cmd_send(mw_cmd *cmd, void *ctx, +00953 lsd_send_cb send_cb) +00954 { +00955 // Send data on control channel (0). +00956 return lsd_send(MW_CTRL_CH, cmd->packet, cmd->data_len + 4, +00957 ctx, send_cb); +00958 } +00959 +00960 /************************************************************************/ +00969 static inline enum lsd_status mw_cmd_recv(mw_cmd *rep, void *ctx, +00970 lsd_recv_cb recv_cb) { +00971 return lsd_recv(rep->packet, sizeof(mw_cmd), ctx, recv_cb); +00972 } +00973 +00974 #endif // MODULE_MEGAWIFI +00975 +00976 #endif /*_MEGAWIFI_H_*/ +00977 +
+ sgdk
+ |
+
+ sgdk
+ |
+
MegaWiFi command message definitions. +More...
+#include "types.h"
Go to the source code of this file.
+MegaWiFi command message definitions.
+
+ sgdk
+ |
+
00001 /************************************************************************/ +00017 #ifndef _MW_MSG_H_ +00018 #define _MW_MSG_H_ +00019 +00020 #include "types.h" +00021 +00022 #if (MODULE_MEGAWIFI != 0) +00023 +00025 #define PACKED __attribute__((__packed__)) +00026 +00028 #define MW_MSG_MAX_BUFLEN 512 +00029 +00031 #define MW_CMD_HEADLEN (2 * sizeof(uint16_t)) +00032 +00034 #define MW_CMD_MAX_BUFLEN (MW_MSG_MAX_BUFLEN - MW_CMD_HEADLEN) +00035 +00037 #define MW_SSID_MAXLEN 32 +00038 +00039 #define MW_PASS_MAXLEN 64 +00040 +00042 #define MW_GT_NICKNAME_MAX 32 +00043 +00044 #define MW_GT_SECURITY_MAX 32 +00045 +00046 #define MW_GT_TAGLINE_MAX 32 +00047 +00048 #define MW_GT_AVATAR_WIDTH 32 +00049 +00050 #define MW_GT_AVATAR_HEIGHT 48 +00051 +00052 #define MW_GT_TG_TOKEN_MAX 64 +00053 +00055 enum PACKED mw_command { +00056 MW_CMD_OK = 0, +00057 MW_CMD_VERSION = 1, +00058 MW_CMD_ECHO = 2, +00059 MW_CMD_AP_SCAN = 3, +00060 MW_CMD_AP_CFG = 4, +00061 MW_CMD_AP_CFG_GET = 5, +00062 MW_CMD_IP_CURRENT = 6, +00063 // Reserved +00064 MW_CMD_IP_CFG = 8, +00065 MW_CMD_IP_CFG_GET = 9, +00066 MW_CMD_DEF_AP_CFG = 10, +00067 MW_CMD_DEF_AP_CFG_GET = 11, +00068 MW_CMD_AP_JOIN = 12, +00069 MW_CMD_AP_LEAVE = 13, +00070 MW_CMD_TCP_CON = 14, +00071 MW_CMD_TCP_BIND = 15, +00072 // Reserved +00073 MW_CMD_CLOSE = 17, +00074 MW_CMD_UDP_SET = 18, +00075 // Reserved (for setting socket options) +00076 MW_CMD_SOCK_STAT = 20, +00077 MW_CMD_PING = 21, +00078 MW_CMD_SNTP_CFG = 22, +00079 MW_CMD_SNTP_CFG_GET = 23, +00080 MW_CMD_DATETIME = 24, +00081 MW_CMD_DT_SET = 25, +00082 MW_CMD_FLASH_WRITE = 26, +00083 MW_CMD_FLASH_READ = 27, +00084 MW_CMD_FLASH_ERASE = 28, +00085 MW_CMD_FLASH_ID = 29, +00086 MW_CMD_SYS_STAT = 30, +00087 MW_CMD_DEF_CFG_SET = 31, +00088 MW_CMD_HRNG_GET = 32, +00089 MW_CMD_BSSID_GET = 33, +00090 MW_CMD_GAMERTAG_SET = 34, +00091 MW_CMD_GAMERTAG_GET = 35, +00092 MW_CMD_LOG = 36, +00093 MW_CMD_FACTORY_RESET = 37, +00094 MW_CMD_SLEEP = 38, +00095 MW_CMD_HTTP_URL_SET = 39, +00096 MW_CMD_HTTP_METHOD_SET = 40, +00097 MW_CMD_HTTP_CERT_QUERY = 41, +00098 MW_CMD_HTTP_CERT_SET = 42, +00099 MW_CMD_HTTP_HDR_ADD = 43, +00100 MW_CMD_HTTP_HDR_DEL = 44, +00101 MW_CMD_HTTP_OPEN = 45, +00102 MW_CMD_HTTP_FINISH = 46, +00103 MW_CMD_HTTP_CLEANUP = 47, +00104 // Reserved +00105 MW_CMD_SERVER_URL_GET = 49, +00106 MW_CMD_SERVER_URL_SET = 50, +00107 MW_CMD_WIFI_ADV_GET = 51, +00108 MW_CMD_WIFI_ADV_SET = 52, +00109 MW_CMD_NV_CFG_SAVE = 53, +00110 MW_CMD_UPGRADE_LIST = 54, +00111 MW_CMD_UPGRADE_PERFORM = 55, +00112 MW_CMD_GAME_ENDPOINT_SET = 56, +00113 MW_CMD_GAME_KEYVAL_ADD = 57, +00114 MW_CMD_GAME_REQUEST = 58, +00115 MW_CMD_ERROR = 255 +00116 }; +00117 +00119 enum PACKED mw_security { +00120 MW_SEC_OPEN = 0, +00121 MW_SEC_WEP, +00122 MW_SEC_WPA_PSK, +00123 MW_SEC_WPA2_PSK, +00124 MW_SEC_WPA_WPA2_PSK, +00125 MW_SEC_UNKNOWN +00126 }; +00127 +00129 enum PACKED mw_phy_type { +00130 MW_PHY_11B = 1, +00131 MW_PHY_11BG = 3, +00132 MW_PHY_11BGN = 7 +00133 }; +00134 +00136 union ip_addr { +00137 uint32_t addr; +00138 uint8_t byte[4]; +00139 }; +00140 +00142 struct mw_msg_in_addr { +00143 char dst_port[6]; +00144 char src_port[6]; +00145 uint8_t channel; +00146 +00147 char dst_addr[]; +00148 }; +00149 +00151 struct mw_ip_cfg { +00152 union ip_addr addr; +00153 union ip_addr mask; +00154 union ip_addr gateway; +00155 union ip_addr dns1; +00156 union ip_addr dns2; +00157 }; +00158 +00162 // string will not be NULL terminated. +00163 struct mw_msg_ap_cfg { +00164 uint8_t cfg_num; +00165 enum mw_phy_type phy_type; +00166 char ssid[MW_SSID_MAXLEN]; +00167 char pass[MW_PASS_MAXLEN]; +00168 }; +00169 +00171 struct mw_msg_ip_cfg { +00172 uint8_t cfg_slot; +00173 uint8_t reserved[3]; +00174 struct mw_ip_cfg ip; +00175 }; +00176 +00178 struct mw_msg_sntp_cfg { +00179 uint16_t up_delay; +00180 int8_t tz; +00181 uint8_t dst; +00182 +00183 +00184 char servers[MW_CMD_MAX_BUFLEN - 4]; +00185 }; +00186 +00188 struct mw_msg_date_time { +00189 uint32_t dt_bin[2]; +00190 +00191 char dt_str[MW_CMD_MAX_BUFLEN - 2 * sizeof(uint32_t)]; +00192 }; +00193 +00195 struct mw_msg_flash_data { +00196 uint32_t addr; +00197 +00198 uint8_t data[MW_CMD_MAX_BUFLEN - sizeof(uint32_t)]; +00199 }; +00200 +00202 struct mw_msg_flash_range { +00203 uint32_t addr; +00204 uint16_t len; +00205 }; +00206 +00208 struct mw_msg_bind { +00209 uint32_t reserved; +00210 uint16_t port; +00211 uint8_t channel; +00212 }; +00213 +00215 struct mw_wifi_adv_cfg { +00216 uint8_t qos_enable; +00217 uint8_t ampdu_rx_enable; +00218 uint8_t rx_ba_win; +00219 uint8_t rx_ampdu_buf_num; +00220 uint32_t rx_ampdu_buf_len; +00221 uint32_t rx_max_single_pkt_len; +00222 uint32_t rx_buf_len; +00223 uint8_t amsdu_rx_enable; +00224 uint8_t rx_buf_num; +00225 uint8_t rx_pkt_num; +00226 uint8_t left_continuous_rx_buf_num; +00227 uint8_t tx_buf_num; +00228 uint8_t reserved[3]; +00229 }; +00230 +00232 struct mw_gamertag { +00234 int id; +00236 char nickname[MW_GT_NICKNAME_MAX]; +00238 char security[MW_GT_SECURITY_MAX]; +00240 char tagline[MW_GT_TAGLINE_MAX]; +00242 char tg_token[MW_GT_TG_TOKEN_MAX]; +00244 uint8_t avatar_tiles[MW_GT_AVATAR_WIDTH * MW_GT_AVATAR_HEIGHT / 2]; +00246 uint8_t avatar_pal[32]; +00247 }; +00248 +00250 struct mw_gamertag_set_msg { +00251 uint8_t slot; +00252 uint8_t reserved[3]; +00253 struct mw_gamertag gamertag; +00254 }; +00255 +00257 enum mw_state { +00258 MW_ST_INIT = 0, +00259 MW_ST_IDLE, +00260 MW_ST_AP_JOIN, +00261 MW_ST_SCAN, +00262 MW_ST_READY, +00263 MW_ST_TRANSPARENT, +00264 MW_ST_MAX +00265 }; +00266 +00268 enum mw_sock_stat { +00269 MW_SOCK_NONE = 0, +00270 MW_SOCK_TCP_LISTEN, +00271 MW_SOCK_TCP_EST, +00272 MW_SOCK_UDP_READY +00273 }; +00274 +00276 union mw_msg_sys_stat { +00277 uint32_t st_flags; +00278 struct { +00279 #if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ +00280 enum mw_state sys_stat:8; +00281 uint8_t online:1; +00282 uint8_t cfg_ok:1; +00283 uint8_t dt_ok:1; +00284 uint8_t cfg:2; +00285 uint16_t reserved:3; +00286 uint16_t ch_ev:16; +00287 #else +00288 uint16_t ch_ev:16; +00289 uint16_t reserved:3; +00290 uint8_t cfg:2; +00291 uint8_t dt_ok:1; +00292 uint8_t cfg_ok:1; +00293 uint8_t online:1; +00294 enum mw_state sys_stat:8; +00295 #endif +00296 }; +00297 }; +00298 +00300 struct mw_flash_id { +00301 uint16_t device; +00302 uint8_t manufacturer; +00303 }; +00304 +00306 struct mw_ga_request { +00307 uint8_t method; +00308 uint8_t num_paths; +00309 uint8_t num_kv_pairs; +00310 char req[]; +00311 }; +00312 +00314 typedef union mw_cmd { +00315 char packet[MW_CMD_MAX_BUFLEN + 2 * sizeof(uint16_t)]; +00316 struct { +00317 uint16_t cmd; +00318 uint16_t data_len; +00319 // If datalen is nonzero, additional command data goes here until +00320 // filling datalen bytes. +00321 union { +00322 uint8_t ch; +00323 +00324 uint8_t data[MW_CMD_MAX_BUFLEN]; +00326 uint16_t w_data[MW_CMD_MAX_BUFLEN / sizeof(uint16_t)]; +00328 uint32_t dw_data[MW_CMD_MAX_BUFLEN / sizeof(uint32_t)]; +00329 struct mw_msg_in_addr in_addr; +00330 struct mw_msg_ap_cfg ap_cfg; +00331 struct mw_msg_ip_cfg ip_cfg; +00332 struct mw_msg_sntp_cfg sntp_cfg; +00333 struct mw_msg_date_time date_time; +00334 struct mw_msg_flash_data fl_data; +00335 struct mw_msg_flash_range fl_range; +00336 struct mw_msg_bind bind; +00337 union mw_msg_sys_stat sys_stat; +00338 struct mw_gamertag_set_msg gamertag_set; +00339 struct mw_gamertag gamertag_get; +00340 struct mw_wifi_adv_cfg wifi_adv_cfg; +00341 struct mw_flash_id flash_id; +00342 struct mw_ga_request ga_request; +00343 uint16_t fl_sect; +00344 uint32_t fl_id; +00345 uint16_t rnd_len; +00346 }; +00347 }; +00348 } mw_cmd; +00349 +00356 struct mw_reuse_payload { +00357 uint32_t remote_ip; +00358 uint16_t remote_port; +00359 +00360 char payload[MW_CMD_MAX_BUFLEN - 4 - 2]; +00361 }; +00362 +00363 #endif // MODULE_MEGAWIFI +00364 +00365 #endif //_MW_MSG_H_ +00366 +
#define RGB3_3_3_TO_VDPCOLOR | +( | ++ | r, | +
+ | + | + | g, | +
+ | + | + | b | +
+ | ) | +((((r) & 7) << VDPPALETTE_REDSFT) | (((g) & 7) << VDPPALETTE_GREENSFT) | (((b) & 7) << VDPPALETTE_BLUESFT)) | +
Convert a RGB333 color to VDP color (VDP uses RGB333 internally)
+r | Red intensity (0-7) |
g | Green intensity (0-7) |
b | Blue intensity (0-7) |
#define RGB8_8_8_TO_VDPCOLOR | +( | ++ | r, | +
+ | + | + | g, | +
+ | + | + | b | +
+ | ) | +RGB24_TO_VDPCOLOR(((((b) << 0) & 0xFF) | (((g) & 0xFF) << 8) | (((r) & 0xFF) << 16))) | +
Convert a RGB888 color to VDP color (VDP uses RGB333 internally)
+r | Red intensity (0-255) |
g | Green intensity (0-255) |
b | Blue intensity (0-255) |