diff options
| -rw-r--r-- | libpsn00b/cmake/internal_setup.cmake | 34 | ||||
| -rw-r--r-- | libpsn00b/include/psxapi.h | 10 | ||||
| -rw-r--r-- | libpsn00b/include/psxgpu.h | 4 | ||||
| -rw-r--r-- | libpsn00b/include/psxpad.h | 12 | ||||
| -rw-r--r-- | libpsn00b/include/stdlib.h | 8 | ||||
| -rw-r--r-- | libpsn00b/libc/_start.s | 3 | ||||
| -rw-r--r-- | libpsn00b/libc/abort.c | 36 | ||||
| -rw-r--r-- | libpsn00b/libc/abs.c | 7 | ||||
| -rw-r--r-- | libpsn00b/libc/clz.s | 70 | ||||
| -rw-r--r-- | libpsn00b/libc/memset.s | 3 | ||||
| -rw-r--r-- | libpsn00b/libc/misc.c | 53 | ||||
| -rw-r--r-- | libpsn00b/libc/rand.s | 38 | ||||
| -rw-r--r-- | libpsn00b/libc/setjmp.s | 6 | ||||
| -rw-r--r-- | libpsn00b/psxapi/_initcd.s | 37 | ||||
| -rw-r--r-- | libpsn00b/psxapi/_syscalls.s | 33 | ||||
| -rw-r--r-- | libpsn00b/psxetc/_dl_resolve_wrapper.s | 3 | ||||
| -rw-r--r-- | libpsn00b/psxgpu/font.c | 151 | ||||
| -rw-r--r-- | libpsn00b/psxpress/vlc.s | 6 |
18 files changed, 227 insertions, 287 deletions
diff --git a/libpsn00b/cmake/internal_setup.cmake b/libpsn00b/cmake/internal_setup.cmake index e34ff63..e24595a 100644 --- a/libpsn00b/cmake/internal_setup.cmake +++ b/libpsn00b/cmake/internal_setup.cmake @@ -38,6 +38,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/libpsn00b.cmake OPTIONAL) if(TARGET psn00bsdk) link_libraries(psn00bsdk) endif() +link_libraries(-lgcc) # DON'T CHANGE THE ORDER or you'll break the libraries' internal dependencies. set( @@ -93,38 +94,7 @@ find_program(ELF2CPE elf2cpe HINTS ${PSN00BSDK_TOOLS}) find_program(SMXLINK smxlink HINTS ${PSN00BSDK_TOOLS}) find_program(LZPACK lzpack HINTS ${PSN00BSDK_TOOLS}) find_program(MKPSXISO mkpsxiso HINTS ${PSN00BSDK_TOOLS}) - -## libgcc - -# Use the toolchain path to find libgcc. Of course different installers, -# packages and distros have different opinions when it comes to deciding where -# to install toolchains, so we have to bruteforce multiple combinations of -# paths. -if(CMAKE_C_COMPILER_VERSION) - string(REGEX MATCH "^([0-9]+)\." _dummy ${CMAKE_C_COMPILER_VERSION}) - - find_library( - PSN00BSDK_LIBGCC gcc #REQUIRED - HINTS - ${PSN00BSDK_TC}/lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION} - ${PSN00BSDK_TC}/lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1} - ${PSN00BSDK_TC}/lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION} - ${PSN00BSDK_TC}/lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1} - ${PSN00BSDK_TC}/../lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION} - ${PSN00BSDK_TC}/../lib/gcc-cross/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1} - ${PSN00BSDK_TC}/../lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_C_COMPILER_VERSION} - ${PSN00BSDK_TC}/../lib/gcc/${PSN00BSDK_TARGET}/${CMAKE_MATCH_1} - NO_DEFAULT_PATH - DOC "Path to libgcc (bundled with the GCC toolchain)" - ) - if(PSN00BSDK_LIBGCC STREQUAL "PSN00BSDK_LIBGCC-NOTFOUND") - message(FATAL_ERROR "Failed to find libgcc in the GCC toolchain's files. Check your toolchain settings, or set the path to libgcc using -DPSN00BSDK_LIBGCC.") - endif() - - add_library (gcc STATIC IMPORTED) - set_target_properties(gcc PROPERTIES IMPORTED_LOCATION ${PSN00BSDK_LIBGCC}) - link_libraries (gcc) -endif() +#find_program(PSXAVENC psxavenc HINTS ${PSN00BSDK_TOOLS}) ## Target helpers diff --git a/libpsn00b/include/psxapi.h b/libpsn00b/include/psxapi.h index 49d1620..d24976f 100644 --- a/libpsn00b/include/psxapi.h +++ b/libpsn00b/include/psxapi.h @@ -221,6 +221,15 @@ typedef struct _INT_RP { extern "C" { #endif +#if 0 +static inline void _InitCd(void) { + uint32_t old_dpcr = DMA_DPCR & 0xffff0fff; + + _96_init(); + DMA_DPCR |= old_dpcr; +} +#endif + void SysEnqIntRP(int pri, INT_RP *rp); void SysDeqIntRP(int pri, INT_RP *rp); @@ -261,7 +270,6 @@ void ExitCriticalSection(void); int SwEnterCriticalSection(void); void SwExitCriticalSection(void); -void _InitCd(void); void _96_init(void); void _96_remove(void); diff --git a/libpsn00b/include/psxgpu.h b/libpsn00b/include/psxgpu.h index d7f1ad5..f1e5de8 100644 --- a/libpsn00b/include/psxgpu.h +++ b/libpsn00b/include/psxgpu.h @@ -626,10 +626,10 @@ DISPENV *SetDefDispEnv(DISPENV *env, int x, int y, int w, int h); DRAWENV *SetDefDrawEnv(DRAWENV *env, int x, int y, int w, int h); void FntLoad(int x, int y); -char *FntSort(uint32_t *ot, char *pri, int x, int y, const char *text); +void *FntSort(uint32_t *ot, void *pri, int x, int y, const char *text); int FntOpen(int x, int y, int w, int h, int isbg, int n); int FntPrint(int id, const char *fmt, ...); -char *FntFlush(int id); +void *FntFlush(int id); #ifdef __cplusplus } diff --git a/libpsn00b/include/psxpad.h b/libpsn00b/include/psxpad.h index 09f28c4..040b890 100644 --- a/libpsn00b/include/psxpad.h +++ b/libpsn00b/include/psxpad.h @@ -10,7 +10,7 @@ * * Reference: https://gist.github.com/scanlime/5042071 */ - + #pragma once #include <stdint.h> @@ -37,8 +37,8 @@ typedef enum { PAD_SQUARE = 1 << 15, // Mouse - MOUSE_LEFT = 1 << 10, - MOUSE_RIGHT = 1 << 11, + MOUSE_RIGHT = 1 << 10, + MOUSE_LEFT = 1 << 11, // neGcon NCON_START = 1 << 3, @@ -46,9 +46,9 @@ typedef enum { NCON_RIGHT = 1 << 5, NCON_DOWN = 1 << 6, NCON_LEFT = 1 << 7, - NCON_R = 1 << 8, - NCON_B = 1 << 9, - NCON_A = 1 << 10, + NCON_R = 1 << 11, + NCON_B = 1 << 12, + NCON_A = 1 << 13, // Guncon GCON_A = 1 << 3, diff --git a/libpsn00b/include/stdlib.h b/libpsn00b/include/stdlib.h index 19761df..c754c29 100644 --- a/libpsn00b/include/stdlib.h +++ b/libpsn00b/include/stdlib.h @@ -27,17 +27,15 @@ typedef struct _HeapUsage { extern "C" { #endif -extern int __argc; -extern const char **__argv; +extern int __argc; +extern const char **__argv; void abort(void); +int abs(int value); int rand(void); void srand(int seed); -int abs(int j); -long labs(long i); - long strtol(const char *str, char **str_end, int base); long long strtoll(const char *str, char **str_end, int base); //float strtof(const char *str, char **str_end); diff --git a/libpsn00b/libc/_start.s b/libpsn00b/libc/_start.s index fcd4c4c..35a4eaa 100644 --- a/libpsn00b/libc/_start.s +++ b/libpsn00b/libc/_start.s @@ -7,10 +7,11 @@ .set noreorder -.section .text._start +.section .text._start, "ax", @progbits .global _start .type _start, @function .weak _start + _start: la $gp, _gp j _start_inner diff --git a/libpsn00b/libc/abort.c b/libpsn00b/libc/abort.c deleted file mode 100644 index 0a3c325..0000000 --- a/libpsn00b/libc/abort.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * PSn00bSDK assert macro and internal logging - * (C) 2022 spicyjpeg - MPL licensed - */ - -#undef SDK_LIBRARY_NAME - -#include <assert.h> -#include <psxapi.h> - -/* Internal function used by assert() macro */ - -void _assert_abort(const char *file, int line, const char *expr) { - _sdk_log("%s:%d: assert(%s)\n", file, line, expr); - - for (;;) - __asm__ volatile(""); -} - -/* Standard abort */ - -void abort(void) { - _sdk_log("abort()\n"); - - for (;;) - __asm__ volatile(""); -} - -/* Pure virtual function call (C++) */ - -void __cxa_pure_virtual(void) { - _sdk_log("__cxa_pure_virtual()\n"); - - for (;;) - __asm__ volatile(""); -} diff --git a/libpsn00b/libc/abs.c b/libpsn00b/libc/abs.c deleted file mode 100644 index a972cad..0000000 --- a/libpsn00b/libc/abs.c +++ /dev/null @@ -1,7 +0,0 @@ -int abs(int i) { - return (i < 0) ? (-i) : i; -} - -long labs(long i) { - return (i < 0) ? (-i) : i; -} diff --git a/libpsn00b/libc/clz.s b/libpsn00b/libc/clz.s index 28a28eb..1ccff2e 100644 --- a/libpsn00b/libc/clz.s +++ b/libpsn00b/libc/clz.s @@ -1,43 +1,53 @@ # PSn00bSDK leading zero count intrinsics -# (C) 2022 spicyjpeg - MPL licensed +# (C) 2022-2023 spicyjpeg - MPL licensed # -# libgcc provides two functions used internally by GCC to count the number of -# leading zeroes or ones in a value, _clzsi2() (32-bit) and _clzdi2() (64-bit). -# This file overrides them with faster implementations that make use of the -# GTE's LZCS/LZCR registers. +# libgcc provides two functions used internally by GCC to count the number of +# leading zeroes in a value, __clzsi2() (32-bit) and __clzdi2() (64-bit). This +# file overrides them with smaller implementations that make use of the GTE's +# LZCS/LZCR registers. .set noreorder -.section .text._clzsi2 -.global _clzsi2 -.type _clzsi2, @function -_clzsi2: - mtc2 $a0, $30 - nop - nop - mfc2 $v0, $31 +.set LZCS, $30 +.set LZCR, $31 - jr $ra - nop +.section .text.__clzsi2, "ax", @progbits +.global __clzsi2 +.type __clzsi2, @function -.section .text._clzdi2 -.global _clzdi2 -.type _clzdi2, @function -_clzdi2: - bnez $a1, .Lhas_msb +__clzsi2: + mtc2 $a0, LZCS + bltz $a0, .Lreturn # if (value & (1 << 31)) return 0 + li $v0, 0 + mfc2 $v0, LZCR # else return GTE_CLZ(value) + +.Lreturn: + jr $ra nop - mtc2 $a0, $30 # if (!msb) return 32 + clz(lsb) - b .Lreturn - li $v1, 32 +.section .text.__clzdi2, "ax", @progbits +.global __clzdi2 +.type __clzdi2, @function -.Lhas_msb: - mtc2 $a1, $30 # if (msb) return 0 + clz(msb) +__clzdi2: + mtc2 $a1, LZCS + bltz $a1, .Lreturn2 # if (msb & (1 << 31)) return 0 + li $v0, 0 + bnez $a1, .LreturnMSB # else if (msb) return GTE_CLZ(msb) nop - li $v1, 0 -.Lreturn: - mfc2 $v0, $31 +.LnoMSB: + mtc2 $a0, LZCS + bltz $a0, .Lreturn2 # else if (lsb & (1 << 31)) return 32 + li $v0, 32 + mfc2 $v0, LZCR # else return 32 + GTE_CLZ(lsb) + + jr $ra + addiu $v0, 32 - jr $ra - addu $v0, $v1 +.LreturnMSB: + mfc2 $v0, LZCR + +.Lreturn2: + jr $ra + nop diff --git a/libpsn00b/libc/memset.s b/libpsn00b/libc/memset.s index 6ef84ec..59cb10b 100644 --- a/libpsn00b/libc/memset.s +++ b/libpsn00b/libc/memset.s @@ -3,9 +3,10 @@ .set noreorder -.section .text.memset +.section .text.memset, "ax", @progbits .global memset .type memset, @function + memset: # If more than 16 bytes have to be written then take the "large" path, # otherwise use the code below. diff --git a/libpsn00b/libc/misc.c b/libpsn00b/libc/misc.c new file mode 100644 index 0000000..d1fd9d3 --- /dev/null +++ b/libpsn00b/libc/misc.c @@ -0,0 +1,53 @@ +/* + * PSn00bSDK standard library (misc. functions) + * (C) 2022-2023 spicyjpeg - MPL licensed + */ + +#undef SDK_LIBRARY_NAME + +#include <assert.h> +#include <stdlib.h> + +/* Abort functions */ + +void _assert_abort(const char *file, int line, const char *expr) { + _sdk_log("%s:%d: assert(%s)\n", file, line, expr); + + for (;;) + __asm__ volatile(""); +} + +void abort(void) { + _sdk_log("abort()\n"); + + for (;;) + __asm__ volatile(""); +} + +void __cxa_pure_virtual(void) { + _sdk_log("__cxa_pure_virtual()\n"); + + for (;;) + __asm__ volatile(""); +} + +/* abs() */ + +int abs(int value) { + return (value < 0) ? (-value) : value; +} + +/* Pseudorandom number generator */ + +static int _random_seed = 0; + +int rand(void) { + _random_seed *= 0x41c64e6d; + _random_seed += 12345; + + return (_random_seed >> 16) & RAND_MAX; +} + +void srand(int seed) { + _random_seed = seed; +} diff --git a/libpsn00b/libc/rand.s b/libpsn00b/libc/rand.s deleted file mode 100644 index a502e87..0000000 --- a/libpsn00b/libc/rand.s +++ /dev/null @@ -1,38 +0,0 @@ -.set noreorder -.set noat - -.section .text - - -.global rand -.type rand, @function -rand: - - la $at, _randseed - lw $v0, 0($at) - li $v1, 0x41c64e6d - - multu $v0, $v1 - mflo $v0 - nop - addiu $v0, 12345 - sw $v0, 0($at) - - jr $ra - andi $v0, 0x7fff - - -.global srand -.type srand, @function -srand: - la $at, _randseed - jr $ra - sw $a0, 0($at) - - -.section .data - -.type _randseed, @object -_randseed: - .word 1 -
\ No newline at end of file diff --git a/libpsn00b/libc/setjmp.s b/libpsn00b/libc/setjmp.s index 465a712..fb0dc6b 100644 --- a/libpsn00b/libc/setjmp.s +++ b/libpsn00b/libc/setjmp.s @@ -7,9 +7,10 @@ .set noreorder -.section .text.setjmp +.section .text.setjmp, "ax", @progbits .global setjmp .type setjmp, @function + setjmp: sw $ra, 0x00($a0) sw $sp, 0x04($a0) @@ -27,9 +28,10 @@ setjmp: jr $ra li $v0, 0 -.section .text.longjmp +.section .text.longjmp, "ax", @progbits .global longjmp .type longjmp, @function + longjmp: lw $ra, 0x00($a0) lw $sp, 0x04($a0) diff --git a/libpsn00b/psxapi/_initcd.s b/libpsn00b/psxapi/_initcd.s deleted file mode 100644 index 600d686..0000000 --- a/libpsn00b/psxapi/_initcd.s +++ /dev/null @@ -1,37 +0,0 @@ -.section .text -.set noreorder - -.include "hwregs_a.inc" - -.global _InitCd -.type _InitCd, @function -_InitCd: - addiu $sp, -8 - sw $ra, 0($sp) - - lui $a0, IOBASE # Load IOBASE value - - lw $v0, DMA_DPCR($a0) # Get current DMA settings - nop - sw $v0, 4($sp) # Save to stack - - jal _96_init # Init CD subsystem - nop - - lui $a0, IOBASE # Load IOBASE again - - lw $v0, 4($sp) # Get old DMA control settings - lw $v1, DMA_DPCR($a0) # Get DMA settings by _96_init() - - lui $a1, 0xffff # Mask out settings for CD DMA - ori $a1, 0x0f00 - and $v0, $a1 - - or $v0, $v1 # Merge and set new DMA settings - sw $v0, DMA_DPCR($a0) - - lw $ra, 0($sp) - addiu $sp, 8 - jr $ra - nop -
\ No newline at end of file diff --git a/libpsn00b/psxapi/_syscalls.s b/libpsn00b/psxapi/_syscalls.s index 5062b15..cef349d 100644 --- a/libpsn00b/psxapi/_syscalls.s +++ b/libpsn00b/psxapi/_syscalls.s @@ -5,9 +5,10 @@ ## Interrupt enable/disable -.section .text.EnterCriticalSection +.section .text.EnterCriticalSection, "ax", @progbits .global EnterCriticalSection .type EnterCriticalSection, @function + EnterCriticalSection: li $a0, 0x01 syscall 0 @@ -15,9 +16,10 @@ EnterCriticalSection: jr $ra nop -.section .text.ExitCriticalSection +.section .text.ExitCriticalSection, "ax", @progbits .global ExitCriticalSection .type ExitCriticalSection, @function + ExitCriticalSection: li $a0, 0x02 syscall 0 @@ -25,9 +27,10 @@ ExitCriticalSection: jr $ra nop -.section .text.SwEnterCriticalSection +.section .text.SwEnterCriticalSection, "ax", @progbits .global SwEnterCriticalSection .type SwEnterCriticalSection, @function + SwEnterCriticalSection: mfc0 $a0, $12 # cop0r12 &= ~0x401 li $a1, -1026 @@ -39,9 +42,10 @@ SwEnterCriticalSection: jr $ra xori $v0, 1 -.section .text.SwExitCriticalSection +.section .text.SwExitCriticalSection, "ax", @progbits .global SwExitCriticalSection .type SwExitCriticalSection, @function + SwExitCriticalSection: mfc0 $a0, $12 # cop0r12 |= 0x401 nop @@ -54,18 +58,20 @@ SwExitCriticalSection: ## PCDRV (host file access) API -.section .text.PCinit +.section .text.PCinit, "ax", @progbits .global PCinit .type PCinit, @function + PCinit: break 0, 0x101 # () -> error jr $ra nop -.section .text.PCcreat +.section .text.PCcreat, "ax", @progbits .global PCcreat .type PCcreat, @function + PCcreat: li $a2, 0 move $a1, $a0 @@ -78,9 +84,10 @@ PCcreat: jr $ra # return fd move $v0, $v1 -.section .text.PCopen +.section .text.PCopen, "ax", @progbits .global PCopen .type PCopen, @function + PCopen: move $a2, $a1 move $a1, $a0 @@ -93,9 +100,10 @@ PCopen: jr $ra # return fd move $v0, $v1 -.section .text.PCclose +.section .text.PCclose, "ax", @progbits .global PCclose .type PCclose, @function + PCclose: move $a1, $a0 break 0, 0x104 # (fd, fd) -> error @@ -103,9 +111,10 @@ PCclose: jr $ra nop -.section .text.PCread +.section .text.PCread, "ax", @progbits .global PCread .type PCread, @function + PCread: move $a3, $a1 move $a1, $a0 @@ -118,9 +127,10 @@ PCread: jr $ra # return length move $v0, $v1 -.section .text.PCwrite +.section .text.PCwrite, "ax", @progbits .global PCwrite .type PCwrite, @function + PCwrite: move $a3, $a1 move $a1, $a0 @@ -133,9 +143,10 @@ PCwrite: jr $ra # return length move $v0, $v1 -.section .text.PClseek +.section .text.PClseek, "ax", @progbits .global PClseek .type PClseek, @function + PClseek: move $a3, $a2 move $a2, $a1 diff --git a/libpsn00b/psxetc/_dl_resolve_wrapper.s b/libpsn00b/psxetc/_dl_resolve_wrapper.s index a0944c6..b715720 100644 --- a/libpsn00b/psxetc/_dl_resolve_wrapper.s +++ b/libpsn00b/psxetc/_dl_resolve_wrapper.s @@ -12,9 +12,10 @@ .set noreorder -.section .text._dl_resolve_wrapper +.section .text._dl_resolve_wrapper, "ax", @progbits .global _dl_resolve_wrapper .type _dl_resolve_wrapper, @function + _dl_resolve_wrapper: # Save the arguments being passed to the function to be resolved. addiu $sp, -20 diff --git a/libpsn00b/psxgpu/font.c b/libpsn00b/psxgpu/font.c index c9d60f1..ce45874 100644 --- a/libpsn00b/psxgpu/font.c +++ b/libpsn00b/psxgpu/font.c @@ -1,4 +1,5 @@ #include <stdint.h> +#include <stdarg.h> #include <assert.h> #include <stdio.h> #include <string.h> @@ -28,76 +29,76 @@ void FntLoad(int x, int y) { RECT pos; TIM_IMAGE tim; - + GetTimInfo((const uint32_t *) _gpu_debug_font, &tim); - + // Load font image pos = *tim.prect; pos.x = x; pos.y = y; - + _font_tpage = getTPage(0, 0, pos.x, pos.y); - + LoadImage(&pos, tim.paddr); DrawSync(0); - + // Load font clut pos = *tim.crect; pos.x = x; pos.y = y+tim.prect->h; - + _font_clut = getClut(pos.x, pos.y); - + LoadImage(&pos, tim.caddr); DrawSync(0); - + // Clear previously opened text streams if( _nstreams ) { - + int i; - + for( i=0; i<_nstreams; i++ ) { free(_stream[i].txtbuff); free(_stream[i].pribuff); } - + _nstreams = 0; - + } - + } int FntOpen(int x, int y, int w, int h, int isbg, int n) { _sdk_validate_args((w > 0) && (h > 0) && (n > 0), -1); int i; - + // Initialize a text stream _stream[_nstreams].x = x; _stream[_nstreams].y = y; _stream[_nstreams].w = w; _stream[_nstreams].h = h; - + _stream[_nstreams].txtbuff = (char*)malloc(n+1); - + i = (sizeof(SPRT_8)*n)+sizeof(DR_TPAGE); - + if( isbg ) { i += sizeof(TILE); } - + _stream[_nstreams].pribuff = (char*)malloc(i); _stream[_nstreams].maxchars = n; - + _stream[_nstreams].txtbuff[0] = 0x0; _stream[_nstreams].txtnext = _stream[_nstreams].txtbuff; _stream[_nstreams].bg = isbg; - + n = _nstreams; _nstreams++; - + return n; - + } int FntPrint(int id, const char *fmt, ...) { @@ -108,26 +109,26 @@ int FntPrint(int id, const char *fmt, ...) { if( id < 0 ) id = _nstreams-1; - + n = strlen(_stream[id].txtbuff); - + if( n >= _stream[id].maxchars ) { return n; } - + va_start(ap, fmt); - + n = vsnprintf(_stream[id].txtnext, _stream[id].maxchars-n, fmt, ap); - + _stream[id].txtnext += n; - + va_end(ap); - + return strlen(_stream[id].txtbuff); - + } -char *FntFlush(int id) { +void *FntFlush(int id) { _sdk_validate_args(id < _nstreams, 0); char *opri; @@ -135,68 +136,68 @@ char *FntFlush(int id) { DR_TPAGE *tpage; char *text; int i,sx,sy; - + if( id < 0 ) id = _nstreams-1; - + sx = _stream[id].x; sy = _stream[id].y; - + text = _stream[id].txtbuff; - + opri = _stream[id].pribuff; - + // Create TPage primitive tpage = (DR_TPAGE*)opri; setDrawTPage(tpage, 0, 0, _font_tpage); - + // Create a black rectangle background when enabled if( _stream[id].bg ) { - + TILE *tile; opri += sizeof(DR_TPAGE); tile = (TILE*)opri; - + setTile(tile); - + if( _stream[id].bg == 2 ) setSemiTrans(tile, 1); - + setXY0(tile, _stream[id].x, _stream[id].y); setWH(tile, _stream[id].w, _stream[id].h); setRGB0(tile, 0, 0, 0); setaddr(tpage, tile); opri = (char*)tile; - + sprt = (SPRT_8*)(opri+sizeof(TILE)); - + } else { - + sprt = (SPRT_8*)(opri+sizeof(DR_TPAGE)); - + } - + // Create the sprite primitives while( *text != 0 ) { - + if( ( *text == '\n' ) || ( ( sx-_stream[id].x ) > _stream[id].w-8 ) ) { sx = _stream[id].x; sy += 8; - + if( *text == '\n' ) text++; - + continue; } - + if( ( sy-_stream[id].y ) > _stream[id].h-8 ) { break; } - + i = toupper( *text )-32; - + if( i > 0 ) { - + i--; setSprt8(sprt); setShadeTex(sprt, 1); @@ -207,42 +208,42 @@ char *FntFlush(int id) { setaddr(opri, sprt); opri = (char*)sprt; sprt++; - + } - + sx += 8; text++; - + } - + // Set a terminator value to the last primitive termPrim(opri); - + // Draw the primitives DrawSync(0); DrawOTag((uint32_t*)_stream[id].pribuff); DrawSync(0); - + _stream[id].txtnext = _stream[id].txtbuff; _stream[id].txtbuff[0] = 0; - - return _stream[id].pribuff; - + + return (void *) _stream[id].pribuff; + } -char *FntSort(uint32_t *ot, char *pri, int x, int y, const char *text) { +void *FntSort(uint32_t *ot, void *pri, int x, int y, const char *text) { _sdk_validate_args(ot && pri, 0); DR_TPAGE *tpage; SPRT_8 *sprt = (SPRT_8*)pri; int i; - + while( *text != 0 ) { - + i = toupper( *text )-32; - + if( i > 0 ) { - + i--; setSprt8(sprt); setShadeTex(sprt, 1); @@ -252,23 +253,23 @@ char *FntSort(uint32_t *ot, char *pri, int x, int y, const char *text) { sprt->clut = _font_clut; addPrim(ot, sprt); sprt++; - + } - + x += 8; text++; - + } - + pri = (char*)sprt; - + tpage = (DR_TPAGE*)pri; tpage->code[0] = _font_tpage; setlen(tpage, 1); setcode(tpage, 0xe1); addPrim(ot, pri); pri += sizeof(DR_TPAGE); - - return pri; - + + return (void *) pri; + } diff --git a/libpsn00b/psxpress/vlc.s b/libpsn00b/psxpress/vlc.s index 2de22f7..2b059c1 100644 --- a/libpsn00b/psxpress/vlc.s +++ b/libpsn00b/psxpress/vlc.s @@ -58,9 +58,10 @@ .set VLC_Table_dc, 0x2a4 .set VLC_Table_dc_len, 0x324 -.section .text.DecDCTvlcStart +.section .text.DecDCTvlcStart, "ax", @progbits .global DecDCTvlcStart .type DecDCTvlcStart, @function + DecDCTvlcStart: addiu $sp, -16 sw $s0, 0($sp) @@ -101,9 +102,10 @@ DecDCTvlcStart: j _vlc_skip_context_load addiu input, 16 # input = &(bs->data[2]) -.section .text.DecDCTvlcContinue +.section .text.DecDCTvlcContinue, "ax", @progbits .global DecDCTvlcContinue .type DecDCTvlcContinue, @function + DecDCTvlcContinue: addiu $sp, -16 sw $s0, 0($sp) |
