Replace header ifdef guards with #pragma once

This commit is contained in:
Arceveti
2021-09-25 11:08:11 -07:00
parent 0649427337
commit 3a6c577a41
367 changed files with 651 additions and 1765 deletions

View File

@@ -1,156 +1,153 @@
#ifndef UNFL_DEBUG_H
#define UNFL_DEBUG_H
#pragma once
/*********************************
Settings macros
*********************************/
/*********************************
Settings macros
*********************************/
// Settings
#define DEBUG_MODE 1 // Enable/Disable debug mode
#define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized
#define USE_FAULTTHREAD 1 // Create a fault detection thread (libultra only)
#define OVERWRITE_OSPRINT 1 // Replaces osSyncPrintf calls with debug_printf (libultra only)
#define MAX_COMMANDS 25 // The max amount of user defined commands possible
// Settings
#define DEBUG_MODE 1 // Enable/Disable debug mode
#define DEBUG_INIT_MSG 1 // Print a message when debug mode has initialized
#define USE_FAULTTHREAD 1 // Create a fault detection thread (libultra only)
#define OVERWRITE_OSPRINT 1 // Replaces osSyncPrintf calls with debug_printf (libultra only)
#define MAX_COMMANDS 25 // The max amount of user defined commands possible
// Fault thread definitions (libultra only)
#define FAULT_THREAD_ID 13
#define FAULT_THREAD_PRI 125
#define FAULT_THREAD_STACK 0x2000
// Fault thread definitions (libultra only)
#define FAULT_THREAD_ID 13
#define FAULT_THREAD_PRI 125
#define FAULT_THREAD_STACK 0x2000
// USB thread definitions (libultra only)
#define USB_THREAD_ID 14
#define USB_THREAD_PRI 126
#define USB_THREAD_STACK 0x2000
// USB thread definitions (libultra only)
#define USB_THREAD_ID 14
#define USB_THREAD_PRI 126
#define USB_THREAD_STACK 0x2000
/*********************************
Debug Functions
*********************************/
/*********************************
Debug Functions
*********************************/
#if DEBUG_MODE
#if DEBUG_MODE
/*==============================
debug_initialize
Initializes the debug and USB library.
==============================*/
/*==============================
debug_initialize
Initializes the debug and USB library.
==============================*/
extern void debug_initialize();
extern void debug_initialize();
/*==============================
debug_printf
Prints a formatted message to the developer's command prompt.
Supports up to 256 characters.
@param A string to print
@param variadic arguments to print as well
==============================*/
/*==============================
debug_printf
Prints a formatted message to the developer's command prompt.
Supports up to 256 characters.
@param A string to print
@param variadic arguments to print as well
==============================*/
extern void debug_printf(const char* message, ...);
extern void debug_printf(const char* message, ...);
/*==============================
debug_dumpbinary
Dumps a binary file through USB
@param The file to dump
@param The size of the file
==============================*/
/*==============================
debug_dumpbinary
Dumps a binary file through USB
@param The file to dump
@param The size of the file
==============================*/
extern void debug_dumpbinary(void* file, int size);
extern void debug_dumpbinary(void* file, int size);
/*==============================
debug_screenshot
Sends the currently displayed framebuffer through USB.
DOES NOT PAUSE DRAWING THREAD! Using outside the drawing
thread may lead to a screenshot with visible tearing
==============================*/
/*==============================
debug_screenshot
Sends the currently displayed framebuffer through USB.
DOES NOT PAUSE DRAWING THREAD! Using outside the drawing
thread may lead to a screenshot with visible tearing
==============================*/
extern void debug_screenshot();
extern void debug_screenshot();
/*==============================
debug_assert
Halts the program if the expression fails.
@param The expression to test
==============================*/
/*==============================
debug_assert
Halts the program if the expression fails.
@param The expression to test
==============================*/
#define debug_assert(expr) (expr) ? ((void)0) : _debug_assert(#expr, __FILE__, __LINE__)
#define debug_assert(expr) (expr) ? ((void)0) : _debug_assert(#expr, __FILE__, __LINE__)
/*==============================
debug_pollcommands
Check the USB for incoming commands.
==============================*/
/*==============================
debug_pollcommands
Check the USB for incoming commands.
==============================*/
extern void debug_pollcommands();
extern void debug_pollcommands();
/*==============================
debug_addcommand
Adds a command for the USB to read.
@param The command name
@param The command description
@param The function pointer to execute
==============================*/
/*==============================
debug_addcommand
Adds a command for the USB to read.
@param The command name
@param The command description
@param The function pointer to execute
==============================*/
extern void debug_addcommand(char* command, char* description, char*(*execute)());
extern void debug_addcommand(char* command, char* description, char*(*execute)());
/*==============================
debug_parsecommand
Stores the next part of the incoming command into the provided buffer.
Make sure the buffer can fit the amount of data from debug_sizecommand!
If you pass NULL, it skips this command.
@param The buffer to store the data in
==============================*/
/*==============================
debug_parsecommand
Stores the next part of the incoming command into the provided buffer.
Make sure the buffer can fit the amount of data from debug_sizecommand!
If you pass NULL, it skips this command.
@param The buffer to store the data in
==============================*/
extern void debug_parsecommand(void* buffer);
extern void debug_parsecommand(void* buffer);
/*==============================
debug_sizecommand
Returns the size of the data from this part of the command.
@return The size of the data in bytes, or 0
==============================*/
/*==============================
debug_sizecommand
Returns the size of the data from this part of the command.
@return The size of the data in bytes, or 0
==============================*/
extern int debug_sizecommand();
extern int debug_sizecommand();
/*==============================
debug_printcommands
Prints a list of commands to the developer's command prompt.
==============================*/
/*==============================
debug_printcommands
Prints a list of commands to the developer's command prompt.
==============================*/
extern void debug_printcommands();
extern void debug_printcommands();
// Ignore this, use the macro instead
extern void _debug_assert(const char* expression, const char* file, int line);
// Ignore this, use the macro instead
extern void _debug_assert(const char* expression, const char* file, int line);
// Include usb.h automatically
#include "usb.h"
// Include usb.h automatically
#include "usb.h"
#else
#else
// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf(__VA_ARGS__)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
#define debug_addcommand(a, b, c)
#define debug_parsecommand() NULL
#define debug_sizecommand() 0
#define debug_printcommands()
#define usb_initialize() 0
#define usb_getcart() 0
#define usb_write(a, b, c)
#define usb_poll() 0
#define usb_read(a, b)
#define usb_skip(a)
#define usb_rewind(a)
#define usb_purge()
// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf(__VA_ARGS__)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
#define debug_addcommand(a, b, c)
#define debug_parsecommand() NULL
#define debug_sizecommand() 0
#define debug_printcommands()
#define usb_initialize() 0
#define usb_getcart() 0
#define usb_write(a, b, c)
#define usb_poll() 0
#define usb_read(a, b)
#define usb_skip(a)
#define usb_rewind(a)
#define usb_purge()
#endif
#endif
#endif

View File

@@ -1,121 +1,118 @@
#ifndef UNFL_USB_H
#define UNFL_USB_H
#pragma once
/*********************************
DataType macros
*********************************/
/*********************************
DataType macros
*********************************/
// UNCOMMENT THE #DEFINE IF USING LIBDRAGON
//#define LIBDRAGON
// UNCOMMENT THE #DEFINE IF USING LIBDRAGON
//#define LIBDRAGON
// Settings
#define USE_OSRAW 0 // Use if you're doing USB operations without the PI Manager (libultra only)
#define DEBUG_ADDRESS_SIZE 8*1024*1024 // Max size of USB I/O. The bigger this value, the more ROM you lose!
// Settings
#define USE_OSRAW 0 // Use if you're doing USB operations without the PI Manager (libultra only)
#define DEBUG_ADDRESS_SIZE 8*1024*1024 // Max size of USB I/O. The bigger this value, the more ROM you lose!
// Cart definitions
#define CART_NONE 0
#define CART_64DRIVE 1
#define CART_EVERDRIVE 2
#define CART_SC64 3
// Cart definitions
#define CART_NONE 0
#define CART_64DRIVE 1
#define CART_EVERDRIVE 2
#define CART_SC64 3
// Data types defintions
#define DATATYPE_TEXT 0x01
#define DATATYPE_RAWBINARY 0x02
#define DATATYPE_HEADER 0x03
#define DATATYPE_SCREENSHOT 0x04
// Data types defintions
#define DATATYPE_TEXT 0x01
#define DATATYPE_RAWBINARY 0x02
#define DATATYPE_HEADER 0x03
#define DATATYPE_SCREENSHOT 0x04
extern int usb_datatype;
extern int usb_datasize;
extern int usb_dataleft;
extern int usb_readblock;
extern int usb_datatype;
extern int usb_datasize;
extern int usb_dataleft;
extern int usb_readblock;
/*********************************
Convenience macros
*********************************/
/*********************************
Convenience macros
*********************************/
// Use these to conveniently read the header from usb_poll()
#define USBHEADER_GETTYPE(header) ((header & 0xFF000000) >> 24)
#define USBHEADER_GETSIZE(header) ((header & 0x00FFFFFF))
// Use these to conveniently read the header from usb_poll()
#define USBHEADER_GETTYPE(header) ((header & 0xFF000000) >> 24)
#define USBHEADER_GETSIZE(header) ((header & 0x00FFFFFF))
/*********************************
USB Functions
*********************************/
/*********************************
USB Functions
*********************************/
/*==============================
usb_initialize
Initializes the USB buffers and pointers
@return 1 if the USB initialization was successful, 0 if not
==============================*/
/*==============================
usb_initialize
Initializes the USB buffers and pointers
@return 1 if the USB initialization was successful, 0 if not
==============================*/
extern char usb_initialize();
extern char usb_initialize();
/*==============================
usb_getcart
Returns which flashcart is currently connected
@return The CART macro that corresponds to the identified flashcart
==============================*/
/*==============================
usb_getcart
Returns which flashcart is currently connected
@return The CART macro that corresponds to the identified flashcart
==============================*/
extern char usb_getcart();
extern char usb_getcart();
/*==============================
usb_write
Writes data to the USB.
Will not write if there is data to read from USB
@param The DATATYPE that is being sent
@param A buffer with the data to send
@param The size of the data being sent
==============================*/
/*==============================
usb_write
Writes data to the USB.
Will not write if there is data to read from USB
@param The DATATYPE that is being sent
@param A buffer with the data to send
@param The size of the data being sent
==============================*/
extern void usb_write(int datatype, const void* data, int size);
extern void usb_write(int datatype, const void* data, int size);
/*==============================
usb_poll
Returns the header of data being received via USB
The first byte contains the data type, the next 3 the number of bytes left to read
@return The data header, or 0
==============================*/
/*==============================
usb_poll
Returns the header of data being received via USB
The first byte contains the data type, the next 3 the number of bytes left to read
@return The data header, or 0
==============================*/
extern unsigned long usb_poll();
extern unsigned long usb_poll();
/*==============================
usb_read
Reads bytes from USB into the provided buffer
@param The buffer to put the read data in
@param The number of bytes to read
==============================*/
/*==============================
usb_read
Reads bytes from USB into the provided buffer
@param The buffer to put the read data in
@param The number of bytes to read
==============================*/
extern void usb_read(void* buffer, int size);
extern void usb_read(void* buffer, int size);
/*==============================
usb_skip
Skips a USB read by the specified amount of bytes
@param The number of bytes to skip
==============================*/
/*==============================
usb_skip
Skips a USB read by the specified amount of bytes
@param The number of bytes to skip
==============================*/
extern void usb_skip(int nbytes);
extern void usb_skip(int nbytes);
/*==============================
usb_rewind
Rewinds a USB read by the specified amount of bytes
@param The number of bytes to rewind
==============================*/
/*==============================
usb_rewind
Rewinds a USB read by the specified amount of bytes
@param The number of bytes to rewind
==============================*/
extern void usb_rewind(int nbytes);
extern void usb_rewind(int nbytes);
/*==============================
usb_purge
Purges the incoming USB data
==============================*/
/*==============================
usb_purge
Purges the incoming USB data
==============================*/
extern void usb_purge();
#endif
extern void usb_purge();