mirror of
				https://github.com/N64Recomp/N64ModernRuntime.git
				synced 2025-10-30 08:02:29 +00:00 
			
		
		
		
	Convert indentation to spaces (#3)
This commit is contained in:
		
							parent
							
								
									b47b52f540
								
							
						
					
					
						commit
						7f55d26948
					
				
					 7 changed files with 143 additions and 143 deletions
				
			
		| 
						 | 
					@ -1,30 +1,30 @@
 | 
				
			||||||
#include "recomp.h"
 | 
					#include "recomp.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
enum class RDPStatusBit {
 | 
					enum class RDPStatusBit {
 | 
				
			||||||
	XbusDmem = 0,
 | 
					    XbusDmem = 0,
 | 
				
			||||||
	Freeze = 1,
 | 
					    Freeze = 1,
 | 
				
			||||||
	Flush = 2,
 | 
					    Flush = 2,
 | 
				
			||||||
	CommandBusy = 6,
 | 
					    CommandBusy = 6,
 | 
				
			||||||
	BufferReady = 7,
 | 
					    BufferReady = 7,
 | 
				
			||||||
	DmaBusy = 8,
 | 
					    DmaBusy = 8,
 | 
				
			||||||
	EndValid = 9,
 | 
					    EndValid = 9,
 | 
				
			||||||
	StartValid = 10,
 | 
					    StartValid = 10,
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
constexpr void update_bit(uint32_t& state, uint32_t flags, RDPStatusBit bit) {
 | 
					constexpr void update_bit(uint32_t& state, uint32_t flags, RDPStatusBit bit) {
 | 
				
			||||||
	int set_bit_pos = (int)bit * 2 + 0;
 | 
					    int set_bit_pos = (int)bit * 2 + 0;
 | 
				
			||||||
	int reset_bit_pos = (int)bit * 2 + 1;
 | 
					    int reset_bit_pos = (int)bit * 2 + 1;
 | 
				
			||||||
	bool set = (flags & (1U << set_bit_pos)) != 0;
 | 
					    bool set = (flags & (1U << set_bit_pos)) != 0;
 | 
				
			||||||
	bool reset = (flags & (1U << reset_bit_pos)) != 0;
 | 
					    bool reset = (flags & (1U << reset_bit_pos)) != 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (set ^ reset) {
 | 
					    if (set ^ reset) {
 | 
				
			||||||
		if (set) {
 | 
					        if (set) {
 | 
				
			||||||
			state |= (1U << (int)bit);
 | 
					            state |= (1U << (int)bit);
 | 
				
			||||||
		}
 | 
					        }
 | 
				
			||||||
		else {
 | 
					        else {
 | 
				
			||||||
			state &= ~(1U << (int)bit);
 | 
					            state &= ~(1U << (int)bit);
 | 
				
			||||||
		}
 | 
					        }
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
uint32_t rdp_state = 1 << (int)RDPStatusBit::BufferReady;
 | 
					uint32_t rdp_state = 1 << (int)RDPStatusBit::BufferReady;
 | 
				
			||||||
| 
						 | 
					@ -34,11 +34,11 @@ extern "C" void osDpSetNextBuffer_recomp(uint8_t* rdram, recomp_context* ctx) {
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osDpGetStatus_recomp(uint8_t* rdram, recomp_context* ctx) {
 | 
					extern "C" void osDpGetStatus_recomp(uint8_t* rdram, recomp_context* ctx) {
 | 
				
			||||||
	ctx->r2 = rdp_state;
 | 
					    ctx->r2 = rdp_state;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osDpSetStatus_recomp(uint8_t* rdram, recomp_context* ctx) {
 | 
					extern "C" void osDpSetStatus_recomp(uint8_t* rdram, recomp_context* ctx) {
 | 
				
			||||||
	update_bit(rdp_state, ctx->r4, RDPStatusBit::XbusDmem);
 | 
					    update_bit(rdp_state, ctx->r4, RDPStatusBit::XbusDmem);
 | 
				
			||||||
	update_bit(rdp_state, ctx->r4, RDPStatusBit::Freeze);
 | 
					    update_bit(rdp_state, ctx->r4, RDPStatusBit::Freeze);
 | 
				
			||||||
	update_bit(rdp_state, ctx->r4, RDPStatusBit::Flush);
 | 
					    update_bit(rdp_state, ctx->r4, RDPStatusBit::Flush);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -21,22 +21,22 @@ void save_clear(uint32_t start, uint32_t size, char value);
 | 
				
			||||||
std::array<char, page_size> write_buffer;
 | 
					std::array<char, page_size> write_buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashInit_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashInit_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = ultramodern::flash_handle;
 | 
					    ctx->r2 = ultramodern::flash_handle;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashReadStatus_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashReadStatus_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	PTR(u8) flash_status = ctx->r4;
 | 
					    PTR(u8) flash_status = ctx->r4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	MEM_B(0, flash_status) = 0;
 | 
					    MEM_B(0, flash_status) = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashReadId_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashReadId_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	PTR(u32) flash_type = ctx->r4;
 | 
					    PTR(u32) flash_type = ctx->r4;
 | 
				
			||||||
	PTR(u32) flash_maker = ctx->r5;
 | 
					    PTR(u32) flash_maker = ctx->r5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Mimic a real flash chip's type and maker, as some games actually check if one is present.
 | 
					    // Mimic a real flash chip's type and maker, as some games actually check if one is present.
 | 
				
			||||||
	MEM_W(0, flash_type) = 0x11118001;
 | 
					    MEM_W(0, flash_type) = 0x11118001;
 | 
				
			||||||
	MEM_W(0, flash_maker) = 0x00C2001E;
 | 
					    MEM_W(0, flash_maker) = 0x00C2001E;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashClearStatus_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashClearStatus_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
| 
						 | 
					@ -44,98 +44,98 @@ extern "C" void osFlashClearStatus_recomp(uint8_t * rdram, recomp_context * ctx)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashAllErase_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashAllErase_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	save_clear(0, ultramodern::save_size, 0xFF);
 | 
					    save_clear(0, ultramodern::save_size, 0xFF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashAllEraseThrough_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashAllEraseThrough_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	save_clear(0, ultramodern::save_size, 0xFF);
 | 
					    save_clear(0, ultramodern::save_size, 0xFF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// This function is named sector but really means page.
 | 
					// This function is named sector but really means page.
 | 
				
			||||||
extern "C" void osFlashSectorErase_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashSectorErase_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	uint32_t page_num = (uint32_t)ctx->r4;
 | 
					    uint32_t page_num = (uint32_t)ctx->r4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Prevent out of bounds erase
 | 
					    // Prevent out of bounds erase
 | 
				
			||||||
	if (page_num >= page_count) {
 | 
					    if (page_num >= page_count) {
 | 
				
			||||||
		ctx->r2 = -1;
 | 
					        ctx->r2 = -1;
 | 
				
			||||||
		return;
 | 
					        return;
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	save_clear(page_num * page_size, page_size, 0xFF);
 | 
					    save_clear(page_num * page_size, page_size, 0xFF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Same naming issue as above.
 | 
					// Same naming issue as above.
 | 
				
			||||||
extern "C" void osFlashSectorEraseThrough_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashSectorEraseThrough_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	uint32_t page_num = (uint32_t)ctx->r4;
 | 
					    uint32_t page_num = (uint32_t)ctx->r4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Prevent out of bounds erase
 | 
					    // Prevent out of bounds erase
 | 
				
			||||||
	if (page_num >= page_count) {
 | 
					    if (page_num >= page_count) {
 | 
				
			||||||
		ctx->r2 = -1;
 | 
					        ctx->r2 = -1;
 | 
				
			||||||
		return;
 | 
					        return;
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	save_clear(page_num * page_size, page_size, 0xFF);
 | 
					    save_clear(page_num * page_size, page_size, 0xFF);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashCheckEraseEnd_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashCheckEraseEnd_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	// All erases are blocking in this implementation, so this should always return OK.
 | 
					    // All erases are blocking in this implementation, so this should always return OK.
 | 
				
			||||||
	ctx->r2 = 0; // FLASH_STATUS_ERASE_OK
 | 
					    ctx->r2 = 0; // FLASH_STATUS_ERASE_OK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashWriteBuffer_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashWriteBuffer_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	OSIoMesg* mb = TO_PTR(OSIoMesg, ctx->r4);
 | 
					    OSIoMesg* mb = TO_PTR(OSIoMesg, ctx->r4);
 | 
				
			||||||
	int32_t pri = ctx->r5;
 | 
					    int32_t pri = ctx->r5;
 | 
				
			||||||
	PTR(void) dramAddr = ctx->r6;
 | 
					    PTR(void) dramAddr = ctx->r6;
 | 
				
			||||||
	PTR(OSMesgQueue) mq = ctx->r7;
 | 
					    PTR(OSMesgQueue) mq = ctx->r7;
 | 
				
			||||||
	
 | 
					    
 | 
				
			||||||
	// Copy the input data into the write buffer
 | 
					    // Copy the input data into the write buffer
 | 
				
			||||||
	for (size_t i = 0; i < page_size; i++) {
 | 
					    for (size_t i = 0; i < page_size; i++) {
 | 
				
			||||||
		write_buffer[i] = MEM_B(i, dramAddr);
 | 
					        write_buffer[i] = MEM_B(i, dramAddr);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Send the message indicating write completion
 | 
					    // Send the message indicating write completion
 | 
				
			||||||
	osSendMesg(PASS_RDRAM mq, 0, OS_MESG_NOBLOCK);
 | 
					    osSendMesg(PASS_RDRAM mq, 0, OS_MESG_NOBLOCK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashWriteArray_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashWriteArray_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	uint32_t page_num = ctx->r4;
 | 
					    uint32_t page_num = ctx->r4;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Copy the write buffer into the save file
 | 
					    // Copy the write buffer into the save file
 | 
				
			||||||
	save_write_ptr(write_buffer.data(), page_num * page_size, page_size);
 | 
					    save_write_ptr(write_buffer.data(), page_num * page_size, page_size);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashReadArray_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashReadArray_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	OSIoMesg* mb = TO_PTR(OSIoMesg, ctx->r4);
 | 
					    OSIoMesg* mb = TO_PTR(OSIoMesg, ctx->r4);
 | 
				
			||||||
	int32_t pri = ctx->r5;
 | 
					    int32_t pri = ctx->r5;
 | 
				
			||||||
	uint32_t page_num = ctx->r6;
 | 
					    uint32_t page_num = ctx->r6;
 | 
				
			||||||
	PTR(void) dramAddr = ctx->r7;
 | 
					    PTR(void) dramAddr = ctx->r7;
 | 
				
			||||||
	uint32_t n_pages = MEM_W(0x10, ctx->r29);
 | 
					    uint32_t n_pages = MEM_W(0x10, ctx->r29);
 | 
				
			||||||
	PTR(OSMesgQueue) mq = MEM_W(0x14, ctx->r29);
 | 
					    PTR(OSMesgQueue) mq = MEM_W(0x14, ctx->r29);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	uint32_t offset = page_num * page_size;
 | 
					    uint32_t offset = page_num * page_size;
 | 
				
			||||||
	uint32_t count = n_pages * page_size;
 | 
					    uint32_t count = n_pages * page_size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Read from the save file into the provided buffer
 | 
					    // Read from the save file into the provided buffer
 | 
				
			||||||
	save_read(PASS_RDRAM dramAddr, offset, count);
 | 
					    save_read(PASS_RDRAM dramAddr, offset, count);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Send the message indicating read completion
 | 
					    // Send the message indicating read completion
 | 
				
			||||||
	osSendMesg(PASS_RDRAM mq, 0, OS_MESG_NOBLOCK);
 | 
					    osSendMesg(PASS_RDRAM mq, 0, OS_MESG_NOBLOCK);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ctx->r2 = 0;
 | 
					    ctx->r2 = 0;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osFlashChange_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osFlashChange_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	assert(false);
 | 
					    assert(false);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3,33 +3,33 @@
 | 
				
			||||||
#include <ultramodern/ultramodern.hpp>
 | 
					#include <ultramodern/ultramodern.hpp>
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsInitPak_recomp(uint8_t * rdram, recomp_context* ctx) {
 | 
					extern "C" void osPfsInitPak_recomp(uint8_t * rdram, recomp_context* ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsFreeBlocks_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsFreeBlocks_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsAllocateFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsAllocateFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsDeleteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsDeleteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsFileState_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsFileState_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsFindFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsFindFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsReadWriteFile_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osPfsChecker_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
					extern "C" void osPfsChecker_recomp(uint8_t * rdram, recomp_context * ctx) {
 | 
				
			||||||
	ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
					    ctx->r2 = 1; // PFS_ERR_NOPACK
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,5 +7,5 @@
 | 
				
			||||||
void load_special_overlay(const SectionTableEntry& section, int32_t ram);
 | 
					void load_special_overlay(const SectionTableEntry& section, int32_t ram);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void load_patch_functions() {
 | 
					void load_patch_functions() {
 | 
				
			||||||
	load_special_overlay(section_table[0], section_table[0].ram_addr);
 | 
					    load_special_overlay(section_table[0], section_table[0].ram_addr);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -7,32 +7,32 @@ static uint32_t sample_rate = 48000;
 | 
				
			||||||
static ultramodern::audio_callbacks_t audio_callbacks;
 | 
					static ultramodern::audio_callbacks_t audio_callbacks;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void set_audio_callbacks(const ultramodern::audio_callbacks_t& callbacks) {
 | 
					void set_audio_callbacks(const ultramodern::audio_callbacks_t& callbacks) {
 | 
				
			||||||
	audio_callbacks = callbacks;
 | 
					    audio_callbacks = callbacks;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ultramodern::init_audio() {
 | 
					void ultramodern::init_audio() {
 | 
				
			||||||
	// Pick an initial dummy sample rate; this will be set by the game later to the true sample rate.
 | 
					    // Pick an initial dummy sample rate; this will be set by the game later to the true sample rate.
 | 
				
			||||||
	set_audio_frequency(48000);
 | 
					    set_audio_frequency(48000);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ultramodern::set_audio_frequency(uint32_t freq) {
 | 
					void ultramodern::set_audio_frequency(uint32_t freq) {
 | 
				
			||||||
	if (audio_callbacks.set_frequency) {
 | 
					    if (audio_callbacks.set_frequency) {
 | 
				
			||||||
		audio_callbacks.set_frequency(freq);
 | 
					        audio_callbacks.set_frequency(freq);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
	sample_rate = freq;
 | 
					    sample_rate = freq;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
void ultramodern::queue_audio_buffer(RDRAM_ARG PTR(int16_t) audio_data_, uint32_t byte_count) {
 | 
					void ultramodern::queue_audio_buffer(RDRAM_ARG PTR(int16_t) audio_data_, uint32_t byte_count) {
 | 
				
			||||||
	// Ensure that the byte count is an integer multiple of samples.
 | 
					    // Ensure that the byte count is an integer multiple of samples.
 | 
				
			||||||
	assert((byte_count & 1) == 0);
 | 
					    assert((byte_count & 1) == 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Calculate the number of samples from the number of bytes.
 | 
					    // Calculate the number of samples from the number of bytes.
 | 
				
			||||||
	uint32_t sample_count = byte_count / sizeof(int16_t);
 | 
					    uint32_t sample_count = byte_count / sizeof(int16_t);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Queue the swapped audio data.
 | 
					    // Queue the swapped audio data.
 | 
				
			||||||
	if (audio_callbacks.queue_samples) {
 | 
					    if (audio_callbacks.queue_samples) {
 | 
				
			||||||
		audio_callbacks.queue_samples(TO_PTR(int16_t, audio_data_), sample_count);
 | 
					        audio_callbacks.queue_samples(TO_PTR(int16_t, audio_data_), sample_count);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// For SDL2
 | 
					// For SDL2
 | 
				
			||||||
| 
						 | 
					@ -44,24 +44,24 @@ float buffer_offset_frames = 0.5f;
 | 
				
			||||||
// the remaining sample count and reporting a number that's too high here can lead to issues.
 | 
					// the remaining sample count and reporting a number that's too high here can lead to issues.
 | 
				
			||||||
// Reporting a number that's too low can lead to audio lag in some games.
 | 
					// Reporting a number that's too low can lead to audio lag in some games.
 | 
				
			||||||
uint32_t ultramodern::get_remaining_audio_bytes() {
 | 
					uint32_t ultramodern::get_remaining_audio_bytes() {
 | 
				
			||||||
	// Get the number of remaining buffered audio bytes.
 | 
					    // Get the number of remaining buffered audio bytes.
 | 
				
			||||||
	uint32_t buffered_byte_count;
 | 
					    uint32_t buffered_byte_count;
 | 
				
			||||||
	if (audio_callbacks.get_frames_remaining != nullptr) {
 | 
					    if (audio_callbacks.get_frames_remaining != nullptr) {
 | 
				
			||||||
		buffered_byte_count = audio_callbacks.get_frames_remaining() * 2 * sizeof(int16_t);
 | 
					        buffered_byte_count = audio_callbacks.get_frames_remaining() * 2 * sizeof(int16_t);
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
	else {
 | 
					    else {
 | 
				
			||||||
		buffered_byte_count = 100;
 | 
					        buffered_byte_count = 100;
 | 
				
			||||||
	}
 | 
					    }
 | 
				
			||||||
	 // Adjust the reported count to be some number of refreshes in the future, which helps ensure that
 | 
					     // Adjust the reported count to be some number of refreshes in the future, which helps ensure that
 | 
				
			||||||
	 // there are enough samples even if the audio thread experiences a small amount of lag. This prevents
 | 
					     // there are enough samples even if the audio thread experiences a small amount of lag. This prevents
 | 
				
			||||||
	 // audio popping on games that use the buffered audio byte count to determine how many samples
 | 
					     // audio popping on games that use the buffered audio byte count to determine how many samples
 | 
				
			||||||
	 // to generate.
 | 
					     // to generate.
 | 
				
			||||||
	 uint32_t samples_per_vi = (sample_rate / 60);
 | 
					     uint32_t samples_per_vi = (sample_rate / 60);
 | 
				
			||||||
	 if (buffered_byte_count > static_cast<uint32_t>(buffer_offset_frames * sizeof(int16_t) * samples_per_vi)) {
 | 
					     if (buffered_byte_count > static_cast<uint32_t>(buffer_offset_frames * sizeof(int16_t) * samples_per_vi)) {
 | 
				
			||||||
	 	buffered_byte_count -= static_cast<uint32_t>(buffer_offset_frames * sizeof(int16_t) * samples_per_vi);
 | 
					         buffered_byte_count -= static_cast<uint32_t>(buffer_offset_frames * sizeof(int16_t) * samples_per_vi);
 | 
				
			||||||
	 }
 | 
					     }
 | 
				
			||||||
	 else {
 | 
					     else {
 | 
				
			||||||
	 	buffered_byte_count = 0;
 | 
					         buffered_byte_count = 0;
 | 
				
			||||||
	 }
 | 
					     }
 | 
				
			||||||
	 return buffered_byte_count;
 | 
					     return buffered_byte_count;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -458,14 +458,14 @@ extern "C" void osViSetMode(RDRAM_ARG PTR(OSViMode) mode_) {
 | 
				
			||||||
#define VI_CTRL_PIXEL_ADV_3         0x03000
 | 
					#define VI_CTRL_PIXEL_ADV_3         0x03000
 | 
				
			||||||
#define VI_CTRL_DITHER_FILTER_ON    0x10000
 | 
					#define VI_CTRL_DITHER_FILTER_ON    0x10000
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define	OS_VI_GAMMA_ON          0x0001
 | 
					#define OS_VI_GAMMA_ON          0x0001
 | 
				
			||||||
#define	OS_VI_GAMMA_OFF         0x0002
 | 
					#define OS_VI_GAMMA_OFF         0x0002
 | 
				
			||||||
#define	OS_VI_GAMMA_DITHER_ON   0x0004
 | 
					#define OS_VI_GAMMA_DITHER_ON   0x0004
 | 
				
			||||||
#define	OS_VI_GAMMA_DITHER_OFF  0x0008
 | 
					#define OS_VI_GAMMA_DITHER_OFF  0x0008
 | 
				
			||||||
#define	OS_VI_DIVOT_ON          0x0010
 | 
					#define OS_VI_DIVOT_ON          0x0010
 | 
				
			||||||
#define	OS_VI_DIVOT_OFF         0x0020
 | 
					#define OS_VI_DIVOT_OFF         0x0020
 | 
				
			||||||
#define	OS_VI_DITHER_FILTER_ON  0x0040
 | 
					#define OS_VI_DITHER_FILTER_ON  0x0040
 | 
				
			||||||
#define	OS_VI_DITHER_FILTER_OFF 0x0080
 | 
					#define OS_VI_DITHER_FILTER_OFF 0x0080
 | 
				
			||||||
 | 
					
 | 
				
			||||||
extern "C" void osViSetSpecialFeatures(uint32_t func) {
 | 
					extern "C" void osViSetSpecialFeatures(uint32_t func) {
 | 
				
			||||||
    if ((func & OS_VI_GAMMA_ON) != 0) {
 | 
					    if ((func & OS_VI_GAMMA_ON) != 0) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,12 +1,12 @@
 | 
				
			||||||
#include "ultra64.h"
 | 
					#include "ultra64.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define	K0BASE		0x80000000
 | 
					#define K0BASE        0x80000000
 | 
				
			||||||
#define	K1BASE		0xA0000000
 | 
					#define K1BASE        0xA0000000
 | 
				
			||||||
#define	K2BASE		0xC0000000
 | 
					#define K2BASE        0xC0000000
 | 
				
			||||||
#define	IS_KSEG0(x)	((u32)(x) >= K0BASE && (u32)(x) < K1BASE)
 | 
					#define IS_KSEG0(x)   ((u32)(x) >= K0BASE && (u32)(x) < K1BASE)
 | 
				
			||||||
#define	IS_KSEG1(x)	((u32)(x) >= K1BASE && (u32)(x) < K2BASE)
 | 
					#define IS_KSEG1(x)   ((u32)(x) >= K1BASE && (u32)(x) < K2BASE)
 | 
				
			||||||
#define	K0_TO_PHYS(x)	((u32)(x)&0x1FFFFFFF)	/* kseg0 to physical */
 | 
					#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF)
 | 
				
			||||||
#define	K1_TO_PHYS(x)	((u32)(x)&0x1FFFFFFF)	/* kseg1 to physical */
 | 
					#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
u32 osVirtualToPhysical(PTR(void) addr) {
 | 
					u32 osVirtualToPhysical(PTR(void) addr) {
 | 
				
			||||||
    uintptr_t addr_val = (uintptr_t)addr;
 | 
					    uintptr_t addr_val = (uintptr_t)addr;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue