Skip to content

Commit

Permalink
debug header fixes for non debug + 64Drive 0 padding
Browse files Browse the repository at this point in the history
  • Loading branch information
buu342 committed May 13, 2023
1 parent 806f3f9 commit 38203ce
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 17 deletions.
8 changes: 6 additions & 2 deletions Examples/Libdragon/1. Hello World/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
8 changes: 6 additions & 2 deletions Examples/Libdragon/3. Command Interpreter/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
8 changes: 6 additions & 2 deletions Examples/Libultra/1. Hello World/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
6 changes: 5 additions & 1 deletion Examples/Libultra/1. Hello World/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static u32 usb_64drive_cui_read(u32 offset)

static void usb_64drive_write(int datatype, const void* data, int size)
{
u32 left = size;
s32 left = size;
u32 pi_address = D64_BASE + DEBUG_ADDRESS;

// Return if previous transfer timed out
Expand All @@ -942,6 +942,10 @@ static void usb_64drive_write(int datatype, const void* data, int size)

// Copy data to PI DMA aligned buffer
memcpy(usb_buffer, data, block);

// Pad the buffer with zeroes if it wasn't 4 byte aligned
while (block%4)
usb_buffer[block++] = 0;

// Copy block of data from RDRAM to SDRAM
usb_dma_write(usb_buffer, pi_address, ALIGN(block, 2));
Expand Down
8 changes: 6 additions & 2 deletions Examples/Libultra/2. Thread Faults/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
6 changes: 5 additions & 1 deletion Examples/Libultra/2. Thread Faults/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static u32 usb_64drive_cui_read(u32 offset)

static void usb_64drive_write(int datatype, const void* data, int size)
{
u32 left = size;
s32 left = size;
u32 pi_address = D64_BASE + DEBUG_ADDRESS;

// Return if previous transfer timed out
Expand All @@ -942,6 +942,10 @@ static void usb_64drive_write(int datatype, const void* data, int size)

// Copy data to PI DMA aligned buffer
memcpy(usb_buffer, data, block);

// Pad the buffer with zeroes if it wasn't 4 byte aligned
while (block%4)
usb_buffer[block++] = 0;

// Copy block of data from RDRAM to SDRAM
usb_dma_write(usb_buffer, pi_address, ALIGN(block, 2));
Expand Down
6 changes: 5 additions & 1 deletion Examples/Libultra/3. USB Read/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static u32 usb_64drive_cui_read(u32 offset)

static void usb_64drive_write(int datatype, const void* data, int size)
{
u32 left = size;
s32 left = size;
u32 pi_address = D64_BASE + DEBUG_ADDRESS;

// Return if previous transfer timed out
Expand All @@ -942,6 +942,10 @@ static void usb_64drive_write(int datatype, const void* data, int size)

// Copy data to PI DMA aligned buffer
memcpy(usb_buffer, data, block);

// Pad the buffer with zeroes if it wasn't 4 byte aligned
while (block%4)
usb_buffer[block++] = 0;

// Copy block of data from RDRAM to SDRAM
usb_dma_write(usb_buffer, pi_address, ALIGN(block, 2));
Expand Down
8 changes: 6 additions & 2 deletions Examples/Libultra/4. Command Interpreter/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
6 changes: 5 additions & 1 deletion Examples/Libultra/4. Command Interpreter/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static u32 usb_64drive_cui_read(u32 offset)

static void usb_64drive_write(int datatype, const void* data, int size)
{
u32 left = size;
s32 left = size;
u32 pi_address = D64_BASE + DEBUG_ADDRESS;

// Return if previous transfer timed out
Expand All @@ -942,6 +942,10 @@ static void usb_64drive_write(int datatype, const void* data, int size)

// Copy data to PI DMA aligned buffer
memcpy(usb_buffer, data, block);

// Pad the buffer with zeroes if it wasn't 4 byte aligned
while (block%4)
usb_buffer[block++] = 0;

// Copy block of data from RDRAM to SDRAM
usb_dma_write(usb_buffer, pi_address, ALIGN(block, 2));
Expand Down
8 changes: 6 additions & 2 deletions USB+Debug Library/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
Settings macros
*********************************/
// Enable/Disable debug
#ifndef DEBUG_MODE
#define DEBUG_MODE 1 // Enable/Disable debug mode
#endif

// 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)
Expand Down Expand Up @@ -144,7 +148,7 @@

// Overwrite library functions with useless macros if debug mode is disabled
#define debug_initialize()
#define debug_printf
#define debug_printf (void)
#define debug_screenshot(a, b, c)
#define debug_assert(a)
#define debug_pollcommands()
Expand Down
6 changes: 5 additions & 1 deletion USB+Debug Library/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,7 +921,7 @@ static u32 usb_64drive_cui_read(u32 offset)

static void usb_64drive_write(int datatype, const void* data, int size)
{
u32 left = size;
s32 left = size;
u32 pi_address = D64_BASE + DEBUG_ADDRESS;

// Return if previous transfer timed out
Expand All @@ -942,6 +942,10 @@ static void usb_64drive_write(int datatype, const void* data, int size)

// Copy data to PI DMA aligned buffer
memcpy(usb_buffer, data, block);

// Pad the buffer with zeroes if it wasn't 4 byte aligned
while (block%4)
usb_buffer[block++] = 0;

// Copy block of data from RDRAM to SDRAM
usb_dma_write(usb_buffer, pi_address, ALIGN(block, 2));
Expand Down

0 comments on commit 38203ce

Please sign in to comment.