From 641a43cbf9b4f4c4f545218e201fb58bbe15fcd7 Mon Sep 17 00:00:00 2001 From: KiritoDv Date: Sun, 24 Mar 2024 02:01:28 -0600 Subject: [PATCH] First compilation, we just need more stupid assets --- .gitignore | 4 +- CMakeLists.txt | 440 +++ include/PR/R4300.h | 453 --- include/PR/controller.h | 59 +- include/PR/gbi.h | 4384 -------------------------- include/PR/os.h | 108 - include/PR/os_ai.h | 92 - include/PR/os_cache.h | 96 - include/PR/os_cont.h | 208 -- include/PR/os_convert.h | 111 - include/PR/os_debug.h | 117 - include/PR/os_eeprom.h | 107 - include/PR/os_error.h | 86 - include/PR/os_exception.h | 86 - include/PR/os_flash.h | 77 - include/PR/os_gbpak.h | 107 - include/PR/os_gio.h | 86 - include/PR/os_host.h | 166 - include/PR/os_internal.h | 119 - include/PR/os_libc.h | 100 - include/PR/os_message.h | 162 - include/PR/os_motor.h | 84 - include/PR/os_pfs.h | 200 -- include/PR/os_pi.h | 221 -- include/PR/os_rdp.h | 92 - include/PR/os_reg.h | 90 - include/PR/os_rsp.h | 86 - include/PR/os_si.h | 86 - include/PR/os_system.h | 118 - include/PR/os_thread.h | 161 - include/PR/os_time.h | 114 - include/PR/os_tlb.h | 107 - include/PR/os_version.h | 28 - include/PR/os_vi.h | 298 -- include/PR/os_voice.h | 108 - include/PR/rcp.h | 888 ------ include/PR/ultratypes.h | 90 - include/PR/xstdio.h | 24 +- include/fox_map.h | 2 +- include/fox_option.h | 2 +- include/functions.h | 9 +- include/gfx.h | 12 +- include/global.h | 3 +- include/i1.h | 2 +- include/i2.h | 2 +- include/i3.h | 2 +- include/i4.h | 2 +- include/i5.h | 2 +- include/i6.h | 2 +- include/libc/math.h | 60 +- include/libc/stddef.h | 2 +- include/libc/stdint.h | 2 +- include/libc/stdlib.h | 2 +- include/libc/string.h | 2 +- include/libultra/ultra64.h | 40 - include/macros.h | 14 +- include/sf64audio_provisional.h | 8 +- include/{context.h => sf64context.h} | 0 include/sf64dma.h | 28 +- include/sf64math.h | 6 +- include/sf64mesg.h | 4 +- include/sf64object.h | 210 +- include/sf64save.h | 2 +- include/sf64thread.h | 2 +- include/structs.h | 2 +- include/sys.h | 16 +- include/variables.h | 2 + src/audio/audio_general.c | 2 +- src/audio/audio_load.c | 33 +- src/audio/audio_synthesis.c | 8 +- src/audio/audio_thread.c | 36 +- src/buffers.c | 1 - src/dmatable.c | 156 +- src/engine/fox_360.c | 6 +- src/engine/fox_load.c | 35 +- src/engine/fox_load_inits.c | 9 +- src/engine/fox_save.c | 12 +- src/engine/guPerspectiveF.c | 40 + src/engine/lookat.c | 73 + src/libc_sprintf.c | 46 +- src/libultra/gu/cosf.c | 2 +- src/libultra/gu/lookat.c | 2 +- src/libultra/gu/mtxutil.c | 3 +- src/libultra/gu/ortho.c | 3 +- src/libultra/gu/perspective.c | 2 +- src/libultra/gu/sinf.c | 2 +- src/libultra/gu/sqrtf.c | 4 +- src/libultra/io/ai.c | 2 +- src/libultra/io/aisetfreq.c | 2 +- src/libultra/libc/ldiv.c | 2 +- src/libultra/libc/string.c | 2 +- src/libultra/libc/xldtob.c | 4 +- src/libultra/libc/xlitob.c | 4 +- src/libultra/libc/xprintf.c | 4 +- src/overlays/ovl_i4/fox_bo.c | 2 +- src/overlays/ovl_menu/fox_title.h | 2 +- src/port/Engine.cpp | 119 + src/port/Engine.h | 32 + src/port/GBIMiddleware.cpp | 45 + src/port/Game.cpp | 31 + src/port/Variables.cpp | 6 + src/port/ui/ImguiUI.cpp | 508 +++ src/port/ui/ImguiUI.h | 16 + src/port/ui/ResolutionEditor.cpp | 422 +++ src/port/ui/ResolutionEditor.h | 19 + src/port/ui/UIWidgets.cpp | 1033 ++++++ src/port/ui/UIWidgets.h | 209 ++ src/sys/sys_fault.c | 2 +- src/sys/sys_joybus.c | 24 +- src/sys/sys_lib.c | 13 +- src/sys/sys_main.c | 217 +- src/sys/sys_matrix.c | 44 +- src/sys/sys_timer.c | 4 +- 113 files changed, 3537 insertions(+), 10111 deletions(-) create mode 100644 CMakeLists.txt delete mode 100644 include/PR/R4300.h delete mode 100644 include/PR/gbi.h delete mode 100644 include/PR/os.h delete mode 100644 include/PR/os_ai.h delete mode 100644 include/PR/os_cache.h delete mode 100644 include/PR/os_cont.h delete mode 100644 include/PR/os_convert.h delete mode 100644 include/PR/os_debug.h delete mode 100644 include/PR/os_eeprom.h delete mode 100644 include/PR/os_error.h delete mode 100644 include/PR/os_exception.h delete mode 100644 include/PR/os_flash.h delete mode 100644 include/PR/os_gbpak.h delete mode 100644 include/PR/os_gio.h delete mode 100644 include/PR/os_host.h delete mode 100644 include/PR/os_internal.h delete mode 100644 include/PR/os_libc.h delete mode 100644 include/PR/os_message.h delete mode 100644 include/PR/os_motor.h delete mode 100644 include/PR/os_pfs.h delete mode 100644 include/PR/os_pi.h delete mode 100644 include/PR/os_rdp.h delete mode 100644 include/PR/os_reg.h delete mode 100644 include/PR/os_rsp.h delete mode 100644 include/PR/os_si.h delete mode 100644 include/PR/os_system.h delete mode 100644 include/PR/os_thread.h delete mode 100644 include/PR/os_time.h delete mode 100644 include/PR/os_tlb.h delete mode 100644 include/PR/os_version.h delete mode 100644 include/PR/os_vi.h delete mode 100644 include/PR/os_voice.h delete mode 100644 include/PR/rcp.h delete mode 100644 include/PR/ultratypes.h delete mode 100644 include/libultra/ultra64.h rename include/{context.h => sf64context.h} (100%) create mode 100644 src/engine/guPerspectiveF.c create mode 100644 src/engine/lookat.c create mode 100644 src/port/Engine.cpp create mode 100644 src/port/Engine.h create mode 100644 src/port/GBIMiddleware.cpp create mode 100644 src/port/Game.cpp create mode 100644 src/port/Variables.cpp create mode 100644 src/port/ui/ImguiUI.cpp create mode 100644 src/port/ui/ImguiUI.h create mode 100644 src/port/ui/ResolutionEditor.cpp create mode 100644 src/port/ui/ResolutionEditor.h create mode 100644 src/port/ui/UIWidgets.cpp create mode 100644 src/port/ui/UIWidgets.h diff --git a/.gitignore b/.gitignore index 8a58deea..198c71ef 100644 --- a/.gitignore +++ b/.gitignore @@ -23,4 +23,6 @@ debug/ .venv/ m2cfiles/ TempComp.bin.mio0 -torch.hash.yml \ No newline at end of file +torch.hash.yml +cmake-build-*/ +.idea/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..d3b1a6e0 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,440 @@ +cmake_minimum_required(VERSION 3.16.0 FATAL_ERROR) + +# Set the project version and language +project(Lylat64 VERSION 0.1.0 LANGUAGES C CXX ASM) + +if(APPLE) + enable_language(OBJCXX) +endif() + +# Set the minimum version of CMake and the deployment target for macOS +set(CMAKE_OSX_DEPLOYMENT_TARGET "10.15" CACHE STRING "Minimum OS X deployment version") + +# Set the C++ standard and enable the MSVC parallel build option +set(CMAKE_CXX_STANDARD 20 CACHE STRING "The C++ standard to use") +set(CMAKE_C_STANDARD 11 CACHE STRING "The C standard to use") +#add_compile_options(-fsanitize=address) +#add_link_options(-fsanitize=address) + +# Add a custom module path to locate additional CMake modules +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/") +include(FindFontconfig) + +if (WIN32) +include(cmake/automate-vcpkg.cmake) +# Forced to use MSVC +set(MSVC ON) + +if(MSVC) +set(VCPKG_TRIPLET x64-windows-static) +set(VCPKG_TARGET_TRIPLET x64-windows-static) +else() +set(VCPKG_TRIPLET x64-mingw-static) +set(VCPKG_TARGET_TRIPLET x64-mingw-static) +endif() + +vcpkg_bootstrap() +vcpkg_install_packages(fontconfig sdl2 zlib bzip2 libpng getopt dirent libusb pthread glew glfw3) +endif() + +if (MSVC) +set(CPP "${CMAKE_C_COMPILER}" "/EP") +else() +set(CPP "${CMAKE_C_COMPILER}" "-E" "-P" "-Wno-trigraphs" "-x" "c") +endif() + +# Set game compilation version +set(VERSION us) +set(USE_NETWORKING ON) + +# Add compile definitions for the target +add_compile_definitions( + VERSION_US=1 + ENABLE_RUMBLE=1 + F3DEX_GBI=1 + _LANGUAGE_C + _USE_MATH_DEFINES + CIMGUI_DEFINE_ENUMS_AND_STRUCTS + NON_MATCHING=1 + NON_EQUIVALENT=1 +) + +# Find necessary libraries +if (UNIX AND NOT APPLE) +find_package(OpenGL REQUIRED) +endif() + +# Include directories +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include + ${CMAKE_CURRENT_SOURCE_DIR}/src +) + +# Collect source files to build the executable +file(GLOB_RECURSE ALL_FILES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + "src/libultra/io/aisetfreq.c" + "src/libultra/gu/sqrtf.c" + "src/libultra/gu/mtxutil.c" + "src/libultra/gu/ortho.c" + "src/main/*.c" + "src/main/*.h" + "src/port/*.h" + "src/port/*.cpp" + "src/assets/*.c" + "src/overlays/*.c" + "src/port/importer/*.cpp" + "src/port/importer/types/*.cpp" +) + +# Exclude specific files from the ALL_FILES list +list(FILTER ALL_FILES EXCLUDE REGEX ".*.inc.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_context.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_effects.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_general.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_heap.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_load.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_playback.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_seqplayer.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_synthesis.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audio_thread.c") +# list(FILTER ALL_FILES EXCLUDE REGEX "src/main/audiotables.c") +list(FILTER ALL_FILES EXCLUDE REGEX "src/main/sys_fault.c") + +add_executable(${PROJECT_NAME} ${ALL_FILES} ${GENERATED_SOURCES}) + +################################################################################ +# MSVC runtime library +################################################################################ +if (MSVC) + if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + get_property(MSVC_RUNTIME_LIBRARY_DEFAULT TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY) + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + string(CONCAT "MSVC_RUNTIME_LIBRARY_STR" + $<$: + MultiThreadedDebug + > + $<$: + MultiThreaded + > + $<$,$>>:${MSVC_RUNTIME_LIBRARY_DEFAULT}> + ) + endif() + set_target_properties(${PROJECT_NAME} PROPERTIES MSVC_RUNTIME_LIBRARY ${MSVC_RUNTIME_LIBRARY_STR}) + endif() +endif() + +#==============================================================================# +# Libultraship Integration # +#==============================================================================# + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/src + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/include/libultraship + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/log + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/debug + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/menu + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/utils/binarytools + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/type + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/resource/factory + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/audio + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/window/gui + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/config + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/libultra + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/public/bridge + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/extern/tinyxml2 + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/libjpeg/include/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/libultraship/Lib/spdlog/include/ + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic/Fast3D/U64/PR + ${CMAKE_CURRENT_SOURCE_DIR}/libultraship/src/graphic + ${SDL2_INCLUDE_DIRS} + ${GLEW_INCLUDE_DIRS} +) + +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG;" + "_CRT_SECURE_NO_WARNINGS;" + "ENABLE_DX11;" + ">" + "$<$:" + "NDEBUG" + ">" + "INCLUDE_GAME_PRINTF;" + "UNICODE;" + "_UNICODE" + STORMLIB_NO_AUTO_LINK + "_CRT_SECURE_NO_WARNINGS;" + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "NOINCLUDE_GAME_PRINTF;" + "_DEBUG;" + "_CRT_SECURE_NO_WARNINGS;" + "ENABLE_OPENGL" + ">" + "$<$:" + "NDEBUG;" + ">" + "INCLUDE_GAME_PRINTF;" + "WIN32;" + "UNICODE;" + "_UNICODE" + STORMLIB_NO_AUTO_LINK + ) + endif() +elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG" + ">" + "$<$:" + "NDEBUG" + ">" + "SPDLOG_ACTIVE_LEVEL=3;" + "SPDLOG_NO_THREAD_ID;" + "SPDLOG_NO_TLS;" + "STBI_NO_THREAD_LOCALS;" + ) +elseif ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang|AppleClang") + target_compile_definitions(${PROJECT_NAME} PRIVATE + "$<$:" + "_DEBUG" + ">" + "$<$:" + "NDEBUG" + ">" + "$<$:ENABLE_CROWD_CONTROL>" + "SPDLOG_ACTIVE_LEVEL=0;" + "_CONSOLE;" + "_CRT_SECURE_NO_WARNINGS;" + "ENABLE_OPENGL;" + "UNICODE;" + "_UNICODE" + ) +endif() + +add_subdirectory(libultraship ${CMAKE_CURRENT_SOURCE_DIR}/libultraship) + +add_dependencies(${PROJECT_NAME} libultraship) +target_link_libraries(${PROJECT_NAME} PRIVATE libultraship) + +if(USE_NETWORKING) + if(MSVC) + vcpkg_install_packages(sdl2-net) + endif() + find_package(SDL2_net REQUIRED) + include_directories(${SDL2_NET_INCLUDE_DIRS}) + target_link_libraries(${PROJECT_NAME} PRIVATE SDL2_net::SDL2_net) + target_compile_definitions(${PROJECT_NAME} PRIVATE USE_NETWORKING) +endif() + +################################################################################ +# Compile and link options +################################################################################ +if(MSVC) + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /w; + /Od; + /MTd + > + $<$: + /Oi; + /Gy; + /W3; + /MT + > + /permissive-; + /MP; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + ) + target_compile_options(${PROJECT_NAME} PRIVATE $<$:/ZI;>) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_compile_options(${PROJECT_NAME} PRIVATE + $<$: + /MTd + > + $<$: + /O2; + /Oi; + /Gy; + /MT + > + /permissive-; + /MP; + /w; + ${DEFAULT_CXX_DEBUG_INFORMATION_FORMAT}; + ${DEFAULT_CXX_EXCEPTION_HANDLING} + ) + endif() + if("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64") + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /INCREMENTAL + > + $<$: + /OPT:REF; + /OPT:ICF; + /INCREMENTAL:NO; + /FORCE:MULTIPLE + > + /MANIFEST:NO; + /DEBUG; + /SUBSYSTEM:WINDOWS + ) + elseif("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32") + target_link_options(${PROJECT_NAME} PRIVATE + $<$: + /STACK:8777216 + > + $<$: + /OPT:REF; + /OPT:ICF; + /INCREMENTAL:NO; + /FORCE:MULTIPLE + > + /MANIFEST:NO; + /DEBUG; + /SUBSYSTEM:WINDOWS + ) + endif() + + # Remove /RTC from msvc flags + foreach (fentry + CMAKE_C_FLAGS + CMAKE_CXX_FLAGS + ) + string (REGEX REPLACE "/RTC(su|[1su])" "" ${fentry} "${${fentry}}") + endforeach(fentry) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang|AppleClang") + if (CMAKE_SYSTEM_NAME STREQUAL "Darwin") + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-return-type + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + > + $<$:-fpermissive> + $<$: + -Wno-c++11-narrowing + -Wno-deprecated-enum-enum-conversion + > + -pthread + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + ) + elseif (CMAKE_SYSTEM_NAME STREQUAL "NintendoSwitch") + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-return-type + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + > + $<$:-fpermissive> + $<$: + -Wno-c++11-narrowing + -Wno-deprecated-enum-enum-conversion + > + -pthread + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + ) + elseif (CMAKE_SYSTEM_NAME STREQUAL "CafeOS") + target_compile_options(${PROJECT_NAME} PRIVATE + -O2 + + # disable some warnings to not clutter output + -Wno-multichar + -Wno-return-type + -Wno-narrowing + -Wno-switch-outside-range + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + -Wno-discarded-array-qualifiers + -Wno-discarded-qualifiers + -Wno-int-conversion + -Wno-builtin-declaration-mismatch + -Wno-switch-unreachable + -Wno-stringop-overflow + > + ) + else() + if(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + set(CPU_OPTION -msse2 -mfpmath=sse) + endif() + + target_compile_options(${PROJECT_NAME} PRIVATE + -Wall -Wextra -Wno-error + -Wno-unused-parameter + -Wno-unused-function + -Wno-unused-variable + -Wno-missing-field-initializers + -Wno-parentheses + -Wno-narrowing + -Wno-missing-braces + $<$: + -Werror-implicit-function-declaration + -Wno-incompatible-pointer-types + > + $<$:-fpermissive> + $<$:-Wno-deprecated-enum-enum-conversion> + -pthread + ${CPU_OPTION} + ) + + target_link_options(${PROJECT_NAME} PRIVATE + -pthread + -Wl,-export-dynamic + ) + endif() +endif() diff --git a/include/PR/R4300.h b/include/PR/R4300.h deleted file mode 100644 index 932694d3..00000000 --- a/include/PR/R4300.h +++ /dev/null @@ -1,453 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.13 $ - * $Date: 1997/02/11 08:15:34 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/R4300.h,v $ - * - **************************************************************************/ - -#ifndef __R4300_H__ -#define __R4300_H__ - -#include - -/* - * Segment base addresses and sizes - */ -#define KUBASE 0 -#define KUSIZE 0x80000000 -#define K0BASE 0x80000000 -#define K0SIZE 0x20000000 -#define K1BASE 0xA0000000 -#define K1SIZE 0x20000000 -#define K2BASE 0xC0000000 -#define K2SIZE 0x20000000 - -/* - * Exception vectors - */ -#define SIZE_EXCVEC 0x80 /* Size of an exc. vec */ -#define UT_VEC K0BASE /* utlbmiss vector */ -#define R_VEC (K1BASE+0x1fc00000) /* reset vector */ -#define XUT_VEC (K0BASE+0x80) /* extended address tlbmiss */ -#define ECC_VEC (K0BASE+0x100) /* Ecc exception vector */ -#define E_VEC (K0BASE+0x180) /* Gen. exception vector */ - -/* - * Address conversion macros - */ -#ifdef _LANGUAGE_ASSEMBLY - -#define K0_TO_K1(x) ((x)|0xA0000000) /* kseg0 to kseg1 */ -#define K1_TO_K0(x) ((x)&0x9FFFFFFF) /* kseg1 to kseg0 */ -#define K0_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg0 to physical */ -#define K1_TO_PHYS(x) ((x)&0x1FFFFFFF) /* kseg1 to physical */ -#define KDM_TO_PHYS(x) ((x)&0x1FFFFFFF) /* direct mapped to physical */ -#define PHYS_TO_K0(x) ((x)|0x80000000) /* physical to kseg0 */ -#define PHYS_TO_K1(x) ((x)|0xA0000000) /* physical to kseg1 */ - -#else /* _LANGUAGE_C */ - -#define K0_TO_K1(x) ((u32)(x)|0xA0000000) /* kseg0 to kseg1 */ -#define K1_TO_K0(x) ((u32)(x)&0x9FFFFFFF) /* kseg1 to kseg0 */ -#define K0_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg0 to physical */ -#define K1_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* kseg1 to physical */ -#define KDM_TO_PHYS(x) ((u32)(x)&0x1FFFFFFF) /* direct mapped to physical */ -#define PHYS_TO_K0(x) ((u32)(x)|0x80000000) /* physical to kseg0 */ -#define PHYS_TO_K1(x) ((u32)(x)|0xA0000000) /* physical to kseg1 */ - -#endif /* _LANGUAGE_ASSEMBLY */ - -/* - * Address predicates - */ -#define IS_KSEG0(x) ((u32)(x) >= K0BASE && (u32)(x) < K1BASE) -#define IS_KSEG1(x) ((u32)(x) >= K1BASE && (u32)(x) < K2BASE) -#define IS_KSEGDM(x) ((u32)(x) >= K0BASE && (u32)(x) < K2BASE) -#define IS_KSEG2(x) ((u32)(x) >= K2BASE && (u32)(x) < KPTE_SHDUBASE) -#define IS_KPTESEG(x) ((u32)(x) >= KPTE_SHDUBASE) -#define IS_KUSEG(x) ((u32)(x) < K0BASE) - -/* - * TLB size constants - */ - -#define NTLBENTRIES 31 /* entry 31 is reserved by rdb */ - -#define TLBHI_VPN2MASK 0xffffe000 -#define TLBHI_VPN2SHIFT 13 -#define TLBHI_PIDMASK 0xff -#define TLBHI_PIDSHIFT 0 -#define TLBHI_NPID 255 /* 255 to fit in 8 bits */ - -#define TLBLO_PFNMASK 0x3fffffc0 -#define TLBLO_PFNSHIFT 6 -#define TLBLO_CACHMASK 0x38 /* cache coherency algorithm */ -#define TLBLO_CACHSHIFT 3 -#define TLBLO_UNCACHED 0x10 /* not cached */ -#define TLBLO_NONCOHRNT 0x18 /* Cacheable non-coherent */ -#define TLBLO_EXLWR 0x28 /* Exclusive write */ -#define TLBLO_D 0x4 /* writeable */ -#define TLBLO_V 0x2 /* valid bit */ -#define TLBLO_G 0x1 /* global access bit */ - -#define TLBINX_PROBE 0x80000000 -#define TLBINX_INXMASK 0x3f -#define TLBINX_INXSHIFT 0 - -#define TLBRAND_RANDMASK 0x3f -#define TLBRAND_RANDSHIFT 0 - -#define TLBWIRED_WIREDMASK 0x3f - -#define TLBCTXT_BASEMASK 0xff800000 -#define TLBCTXT_BASESHIFT 23 -#define TLBCTXT_BASEBITS 9 - -#define TLBCTXT_VPNMASK 0x7ffff0 -#define TLBCTXT_VPNSHIFT 4 - -#define TLBPGMASK_4K 0x0 -#define TLBPGMASK_16K 0x6000 -#define TLBPGMASK_64K 0x1e000 - -/* - * Status register - */ -#define SR_CUMASK 0xf0000000 /* coproc usable bits */ - -#define SR_CU3 0x80000000 /* Coprocessor 3 usable */ -#define SR_CU2 0x40000000 /* Coprocessor 2 usable */ -#define SR_CU1 0x20000000 /* Coprocessor 1 usable */ -#define SR_CU0 0x10000000 /* Coprocessor 0 usable */ -#define SR_RP 0x08000000 /* Reduced power (quarter speed) */ -#define SR_FR 0x04000000 /* MIPS III FP register mode */ -#define SR_RE 0x02000000 /* Reverse endian */ -#define SR_ITS 0x01000000 /* Instruction trace support */ -#define SR_BEV 0x00400000 /* Use boot exception vectors */ -#define SR_TS 0x00200000 /* TLB shutdown */ -#define SR_SR 0x00100000 /* Soft reset occured */ -#define SR_CH 0x00040000 /* Cache hit for last 'cache' op */ -#define SR_CE 0x00020000 /* Create ECC */ -#define SR_DE 0x00010000 /* ECC of parity does not cause error */ - -/* - * Interrupt enable bits - * (NOTE: bits set to 1 enable the corresponding level interrupt) - */ -#define SR_IMASK 0x0000ff00 /* Interrupt mask */ -#define SR_IMASK8 0x00000000 /* mask level 8 */ -#define SR_IMASK7 0x00008000 /* mask level 7 */ -#define SR_IMASK6 0x0000c000 /* mask level 6 */ -#define SR_IMASK5 0x0000e000 /* mask level 5 */ -#define SR_IMASK4 0x0000f000 /* mask level 4 */ -#define SR_IMASK3 0x0000f800 /* mask level 3 */ -#define SR_IMASK2 0x0000fc00 /* mask level 2 */ -#define SR_IMASK1 0x0000fe00 /* mask level 1 */ -#define SR_IMASK0 0x0000ff00 /* mask level 0 */ - -#define SR_IBIT8 0x00008000 /* bit level 8 */ -#define SR_IBIT7 0x00004000 /* bit level 7 */ -#define SR_IBIT6 0x00002000 /* bit level 6 */ -#define SR_IBIT5 0x00001000 /* bit level 5 */ -#define SR_IBIT4 0x00000800 /* bit level 4 */ -#define SR_IBIT3 0x00000400 /* bit level 3 */ -#define SR_IBIT2 0x00000200 /* bit level 2 */ -#define SR_IBIT1 0x00000100 /* bit level 1 */ - -#define SR_IMASKSHIFT 8 - -#define SR_KX 0x00000080 /* extended-addr TLB vec in kernel */ -#define SR_SX 0x00000040 /* xtended-addr TLB vec supervisor */ -#define SR_UX 0x00000020 /* xtended-addr TLB vec in user mode */ -#define SR_KSU_MASK 0x00000018 /* mode mask */ -#define SR_KSU_USR 0x00000010 /* user mode */ -#define SR_KSU_SUP 0x00000008 /* supervisor mode */ -#define SR_KSU_KER 0x00000000 /* kernel mode */ -#define SR_ERL 0x00000004 /* Error level, 1=>cache error */ -#define SR_EXL 0x00000002 /* Exception level, 1=>exception */ -#define SR_IE 0x00000001 /* interrupt enable, 1=>enable */ - -/* - * Cause Register - */ -#define CAUSE_BD 0x80000000 /* Branch delay slot */ -#define CAUSE_CEMASK 0x30000000 /* coprocessor error */ -#define CAUSE_CESHIFT 28 - -/* Interrupt pending bits */ -#define CAUSE_IP8 0x00008000 /* External level 8 pending - COMPARE */ -#define CAUSE_IP7 0x00004000 /* External level 7 pending - INT4 */ -#define CAUSE_IP6 0x00002000 /* External level 6 pending - INT3 */ -#define CAUSE_IP5 0x00001000 /* External level 5 pending - INT2 */ -#define CAUSE_IP4 0x00000800 /* External level 4 pending - INT1 */ -#define CAUSE_IP3 0x00000400 /* External level 3 pending - INT0 */ -#define CAUSE_SW2 0x00000200 /* Software level 2 pending */ -#define CAUSE_SW1 0x00000100 /* Software level 1 pending */ - -#define CAUSE_IPMASK 0x0000FF00 /* Pending interrupt mask */ -#define CAUSE_IPSHIFT 8 - -#define CAUSE_EXCMASK 0x0000007C /* Cause code bits */ - -#define CAUSE_EXCSHIFT 2 - -/* Cause register exception codes */ - -#define EXC_CODE(x) ((x)<<2) - -/* Hardware exception codes */ -#define EXC_INT EXC_CODE(0) /* interrupt */ -#define EXC_MOD EXC_CODE(1) /* TLB mod */ -#define EXC_RMISS EXC_CODE(2) /* Read TLB Miss */ -#define EXC_WMISS EXC_CODE(3) /* Write TLB Miss */ -#define EXC_RADE EXC_CODE(4) /* Read Address Error */ -#define EXC_WADE EXC_CODE(5) /* Write Address Error */ -#define EXC_IBE EXC_CODE(6) /* Instruction Bus Error */ -#define EXC_DBE EXC_CODE(7) /* Data Bus Error */ -#define EXC_SYSCALL EXC_CODE(8) /* SYSCALL */ -#define EXC_BREAK EXC_CODE(9) /* BREAKpoint */ -#define EXC_II EXC_CODE(10) /* Illegal Instruction */ -#define EXC_CPU EXC_CODE(11) /* CoProcessor Unusable */ -#define EXC_OV EXC_CODE(12) /* OVerflow */ -#define EXC_TRAP EXC_CODE(13) /* Trap exception */ -#define EXC_VCEI EXC_CODE(14) /* Virt. Coherency on Inst. fetch */ -#define EXC_FPE EXC_CODE(15) /* Floating Point Exception */ -#define EXC_WATCH EXC_CODE(23) /* Watchpoint reference */ -#define EXC_VCED EXC_CODE(31) /* Virt. Coherency on data read */ - -/* C0_PRID Defines */ -#define C0_IMPMASK 0xff00 -#define C0_IMPSHIFT 8 -#define C0_REVMASK 0xff -#define C0_MAJREVMASK 0xf0 -#define C0_MAJREVSHIFT 4 -#define C0_MINREVMASK 0xf - -/* - * Coprocessor 0 operations - */ -#define C0_READI 0x1 /* read ITLB entry addressed by C0_INDEX */ -#define C0_WRITEI 0x2 /* write ITLB entry addressed by C0_INDEX */ -#define C0_WRITER 0x6 /* write ITLB entry addressed by C0_RAND */ -#define C0_PROBE 0x8 /* probe for ITLB entry addressed by TLBHI */ -#define C0_RFE 0x10 /* restore for exception */ - -/* - * 'cache' instruction definitions - */ - -/* Target cache */ -#define CACH_PI 0x0 /* specifies primary inst. cache */ -#define CACH_PD 0x1 /* primary data cache */ -#define CACH_SI 0x2 /* secondary instruction cache */ -#define CACH_SD 0x3 /* secondary data cache */ - -/* Cache operations */ -#define C_IINV 0x0 /* index invalidate (inst, 2nd inst) */ -#define C_IWBINV 0x0 /* index writeback inval (d, sd) */ -#define C_ILT 0x4 /* index load tag (all) */ -#define C_IST 0x8 /* index store tag (all) */ -#define C_CDX 0xc /* create dirty exclusive (d, sd) */ -#define C_HINV 0x10 /* hit invalidate (all) */ -#define C_HWBINV 0x14 /* hit writeback inv. (d, sd) */ -#define C_FILL 0x14 /* fill (i) */ -#define C_HWB 0x18 /* hit writeback (i, d, sd) */ -#define C_HSV 0x1c /* hit set virt. (si, sd) */ - -/* - * Cache size definitions - */ -#define ICACHE_SIZE 0x4000 /* 16K */ -#define ICACHE_LINESIZE 32 /* 8 words */ -#define ICACHE_LINEMASK (ICACHE_LINESIZE-1) - -#define DCACHE_SIZE 0x2000 /* 8K */ -#define DCACHE_LINESIZE 16 /* 4 words */ -#define DCACHE_LINEMASK (DCACHE_LINESIZE-1) - -/* - * C0_CONFIG register definitions - */ -#define CONFIG_CM 0x80000000 /* 1 == Master-Checker enabled */ -#define CONFIG_EC 0x70000000 /* System Clock ratio */ -#define CONFIG_EC_1_1 0x6 /* System Clock ratio 1 :1 */ -#define CONFIG_EC_3_2 0x7 /* System Clock ratio 1.5 :1 */ -#define CONFIG_EC_2_1 0x0 /* System Clock ratio 2 :1 */ -#define CONFIG_EC_3_1 0x1 /* System Clock ratio 3 :1 */ -#define CONFIG_EP 0x0f000000 /* Transmit Data Pattern */ -#define CONFIG_SB 0x00c00000 /* Secondary cache block size */ - -#define CONFIG_SS 0x00200000 /* Split scache: 0 == I&D combined */ -#define CONFIG_SW 0x00100000 /* scache port: 0==128, 1==64 */ -#define CONFIG_EW 0x000c0000 /* System Port width: 0==64, 1==32 */ -#define CONFIG_SC 0x00020000 /* 0 -> 2nd cache present */ -#define CONFIG_SM 0x00010000 /* 0 -> Dirty Shared Coherency enabled*/ -#define CONFIG_BE 0x00008000 /* Endian-ness: 1 --> BE */ -#define CONFIG_EM 0x00004000 /* 1 -> ECC mode, 0 -> parity */ -#define CONFIG_EB 0x00002000 /* Block order:1->sequent,0->subblock */ - -#define CONFIG_IC 0x00000e00 /* Primary Icache size */ -#define CONFIG_DC 0x000001c0 /* Primary Dcache size */ -#define CONFIG_IB 0x00000020 /* Icache block size */ -#define CONFIG_DB 0x00000010 /* Dcache block size */ -#define CONFIG_CU 0x00000008 /* Update on Store-conditional */ -#define CONFIG_K0 0x00000007 /* K0SEG Coherency algorithm */ - -#define CONFIG_UNCACHED 0x00000002 /* K0 is uncached */ -#define CONFIG_NONCOHRNT 0x00000003 -#define CONFIG_COHRNT_EXLWR 0x00000005 -#define CONFIG_SB_SHFT 22 /* shift SB to bit position 0 */ -#define CONFIG_IC_SHFT 9 /* shift IC to bit position 0 */ -#define CONFIG_DC_SHFT 6 /* shift DC to bit position 0 */ -#define CONFIG_BE_SHFT 15 /* shift BE to bit position 0 */ - -/* - * C0_TAGLO definitions for setting/getting cache states and physaddr bits - */ -#define SADDRMASK 0xFFFFE000 /* 31..13 -> scache paddr bits 35..17 */ -#define SVINDEXMASK 0x00000380 /* 9..7: prim virt index bits 14..12 */ -#define SSTATEMASK 0x00001c00 /* bits 12..10 hold scache line state */ -#define SINVALID 0x00000000 /* invalid --> 000 == state 0 */ -#define SCLEANEXCL 0x00001000 /* clean exclusive --> 100 == state 4 */ -#define SDIRTYEXCL 0x00001400 /* dirty exclusive --> 101 == state 5 */ -#define SECC_MASK 0x0000007f /* low 7 bits are ecc for the tag */ -#define SADDR_SHIFT 4 /* shift STagLo (31..13) to 35..17 */ - -#define PADDRMASK 0xFFFFFF00 /* PTagLo31..8->prim paddr bits35..12 */ -#define PADDR_SHIFT 4 /* roll bits 35..12 down to 31..8 */ -#define PSTATEMASK 0x00C0 /* bits 7..6 hold primary line state */ -#define PINVALID 0x0000 /* invalid --> 000 == state 0 */ -#define PCLEANEXCL 0x0080 /* clean exclusive --> 10 == state 2 */ -#define PDIRTYEXCL 0x00C0 /* dirty exclusive --> 11 == state 3 */ -#define PPARITY_MASK 0x0001 /* low bit is parity bit (even). */ - -/* - * C0_CACHE_ERR definitions. - */ -#define CACHERR_ER 0x80000000 /* 0: inst ref, 1: data ref */ -#define CACHERR_EC 0x40000000 /* 0: primary, 1: secondary */ -#define CACHERR_ED 0x20000000 /* 1: data error */ -#define CACHERR_ET 0x10000000 /* 1: tag error */ -#define CACHERR_ES 0x08000000 /* 1: external ref, e.g. snoop*/ -#define CACHERR_EE 0x04000000 /* error on SysAD bus */ -#define CACHERR_EB 0x02000000 /* complicated, see spec. */ -#define CACHERR_EI 0x01000000 /* complicated, see spec. */ -#define CACHERR_SIDX_MASK 0x003ffff8 /* secondary cache index */ -#define CACHERR_PIDX_MASK 0x00000007 /* primary cache index */ -#define CACHERR_PIDX_SHIFT 12 /* bits 2..0 are paddr14..12 */ - -/* R4000 family supports hardware watchpoints: - * C0_WATCHLO: - * bits 31..3 are bits 31..3 of physaddr to watch - * bit 2: reserved; must be written as 0. - * bit 1: when set causes a watchpoint trap on load accesses to paddr. - * bit 0: when set traps on stores to paddr; - * C0_WATCHHI - * bits 31..4 are reserved and must be written as zeros. - * bits 3..0 are bits 35..32 of the physaddr to watch - */ -#define WATCHLO_WTRAP 0x00000001 -#define WATCHLO_RTRAP 0x00000002 -#define WATCHLO_ADDRMASK 0xfffffff8 -#define WATCHLO_VALIDMASK 0xfffffffb -#define WATCHHI_VALIDMASK 0x0000000f - -/* - * Coprocessor 0 registers - */ -#ifdef _LANGUAGE_ASSEMBLY -#define C0_INX $0 -#define C0_RAND $1 -#define C0_ENTRYLO0 $2 -#define C0_ENTRYLO1 $3 -#define C0_CONTEXT $4 -#define C0_PAGEMASK $5 /* page mask */ -#define C0_WIRED $6 /* # wired entries in tlb */ -#define C0_BADVADDR $8 -#define C0_COUNT $9 /* free-running counter */ -#define C0_ENTRYHI $10 -#define C0_SR $12 -#define C0_CAUSE $13 -#define C0_EPC $14 -#define C0_PRID $15 /* revision identifier */ -#define C0_COMPARE $11 /* counter comparison reg. */ -#define C0_CONFIG $16 /* hardware configuration */ -#define C0_LLADDR $17 /* load linked address */ -#define C0_WATCHLO $18 /* watchpoint */ -#define C0_WATCHHI $19 /* watchpoint */ -#define C0_ECC $26 /* S-cache ECC and primary parity */ -#define C0_CACHE_ERR $27 /* cache error status */ -#define C0_TAGLO $28 /* cache operations */ -#define C0_TAGHI $29 /* cache operations */ -#define C0_ERROR_EPC $30 /* ECC error prg. counter */ - -# else /* ! _LANGUAGE_ASSEMBLY */ - -#define C0_INX 0 -#define C0_RAND 1 -#define C0_ENTRYLO0 2 -#define C0_ENTRYLO1 3 -#define C0_CONTEXT 4 -#define C0_PAGEMASK 5 /* page mask */ -#define C0_WIRED 6 /* # wired entries in tlb */ -#define C0_BADVADDR 8 -#define C0_COUNT 9 /* free-running counter */ -#define C0_ENTRYHI 10 -#define C0_SR 12 -#define C0_CAUSE 13 -#define C0_EPC 14 -#define C0_PRID 15 /* revision identifier */ -#define C0_COMPARE 11 /* counter comparison reg. */ -#define C0_CONFIG 16 /* hardware configuration */ -#define C0_LLADDR 17 /* load linked address */ -#define C0_WATCHLO 18 /* watchpoint */ -#define C0_WATCHHI 19 /* watchpoint */ -#define C0_ECC 26 /* S-cache ECC and primary parity */ -#define C0_CACHE_ERR 27 /* cache error status */ -#define C0_TAGLO 28 /* cache operations */ -#define C0_TAGHI 29 /* cache operations */ -#define C0_ERROR_EPC 30 /* ECC error prg. counter */ - -#endif /* _LANGUAGE_ASSEMBLY */ - -/* - * floating-point status register - */ -#define FPCSR_FS 0x01000000 /* flush denorm to zero */ -#define FPCSR_C 0x00800000 /* condition bit */ -#define FPCSR_CE 0x00020000 /* cause: unimplemented operation */ -#define FPCSR_CV 0x00010000 /* cause: invalid operation */ -#define FPCSR_CZ 0x00008000 /* cause: division by zero */ -#define FPCSR_CO 0x00004000 /* cause: overflow */ -#define FPCSR_CU 0x00002000 /* cause: underflow */ -#define FPCSR_CI 0x00001000 /* cause: inexact operation */ -#define FPCSR_EV 0x00000800 /* enable: invalid operation */ -#define FPCSR_EZ 0x00000400 /* enable: division by zero */ -#define FPCSR_EO 0x00000200 /* enable: overflow */ -#define FPCSR_EU 0x00000100 /* enable: underflow */ -#define FPCSR_EI 0x00000080 /* enable: inexact operation */ -#define FPCSR_FV 0x00000040 /* flag: invalid operation */ -#define FPCSR_FZ 0x00000020 /* flag: division by zero */ -#define FPCSR_FO 0x00000010 /* flag: overflow */ -#define FPCSR_FU 0x00000008 /* flag: underflow */ -#define FPCSR_FI 0x00000004 /* flag: inexact operation */ -#define FPCSR_RM_MASK 0x00000003 /* rounding mode mask */ -#define FPCSR_RM_RN 0x00000000 /* round to nearest */ -#define FPCSR_RM_RZ 0x00000001 /* round to zero */ -#define FPCSR_RM_RP 0x00000002 /* round to positive infinity */ -#define FPCSR_RM_RM 0x00000003 /* round to negative infinity */ - -#endif /* __R4300_H */ diff --git a/include/PR/controller.h b/include/PR/controller.h index c443a296..4295422b 100644 --- a/include/PR/controller.h +++ b/include/PR/controller.h @@ -2,19 +2,11 @@ #define _CONTROLLER_H #include "macros.h" -#include "PR/ultratypes.h" -#include "PR/os_internal.h" -#include "PR/os_version.h" -#include "PR/rcp.h" +#include +#define EEPROM_BLOCK_SIZE 8 #define CHNL_ERR(format) (((format).rxsize & CHNL_ERR_MASK) >> 4) -typedef struct -{ - /* 0x0 */ u32 ramarray[15]; - /* 0x3C */ u32 pifstatus; -} OSPifRam; - typedef struct { /* 0x0 */ u8 dummy; @@ -64,45 +56,6 @@ typedef struct /* 0x26 */ u8 datacrc; } __OSContRamReadFormat; -typedef union { - /* 0x0 */ struct - { - /* 0x0 */ u8 bank; - /* 0x1 */ u8 page; - } inode_t; - /* 0x0 */ u16 ipage; -} __OSInodeUnit; - -typedef struct -{ - /* 0x0 */ u32 game_code; - /* 0x4 */ u16 company_code; - /* 0x6 */ __OSInodeUnit start_page; - /* 0x8 */ u8 status; - /* 0x9 */ s8 reserved; - /* 0xA */ u16 data_sum; - /* 0xC */ u8 ext_name[PFS_FILE_EXT_LEN]; - /* 0x10 */ u8 game_name[PFS_FILE_NAME_LEN]; -} __OSDir; - -typedef struct -{ - /* 0x0 */ __OSInodeUnit inode_page[128]; -} __OSInode; - -typedef struct -{ - /* 0x0 */ u32 repaired; - /* 0x4 */ u32 random; - /* 0x8 */ u64 serial_mid; - /* 0x10 */ u64 serial_low; - /* 0x18 */ u16 deviceid; - /* 0x1A */ u8 banks; - /* 0x1B */ u8 version; - /* 0x1C */ u16 checksum; - /* 0x1E */ u16 inverted_checksum; -} __OSPackId; - typedef struct { /* 0x0 */ u8 txsize; @@ -193,14 +146,6 @@ typedef struct #define GB_POWER_ON 0x84 #define GB_POWER_OFF 0xFE - -typedef struct -{ - /* 0x0 */ __OSInode inode; - /* 0x100 */ u8 bank; - /* 0x101 */ u8 map[PFS_INODE_DIST_MAP]; -} __OSInodeCache; - extern s32 __osEepStatus(OSMesgQueue *, OSContStatus *); u16 __osSumcalc(u8 *ptr, int length); s32 __osIdCheckSum(u16 *ptr, u16 *csum, u16 *icsum); diff --git a/include/PR/gbi.h b/include/PR/gbi.h deleted file mode 100644 index f9ef3364..00000000 --- a/include/PR/gbi.h +++ /dev/null @@ -1,4384 +0,0 @@ - -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ -/************************************************************************** - * - * $Revision: 1.128 $ - * $Date: 1997/11/26 00:30:51 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/gbi.h,v $ - * - **************************************************************************/ - -#ifndef _GBI_H_ -#define _GBI_H_ - -/* - * To use the F3DEX ucodes, define F3DEX_GBI before include this file. - * - * #define F3DEX_GBI - * #include - * - * or - * - * cc -c -DF3DEX_GBI -I.... foo.c - * - */ - -/************************************************************************** - * - * Graphics Binary Interface - * - **************************************************************************/ - -/* - * Graphics Commands, 'xxx' parts may be generated from ucode - * - * The command format is - * - * |00xxxxxx| = DMA 0,..,127 - * |10xxxxxx| = Immediate Mode -65,..,-128 - * |11xxxxxx| = RDP cmds -1,..,-64 - * - * Note: in order for the RSP microcode to process RDP commands opaquely, - * we need to further identify those RDP commands that need DRAM address - * "fixup". To do this, we have the dummy command G_RDP_ADDR_FIXUP, and - * all |RDP commands| less than this are commands with embedded DRAM - * addresses. Further, the format of these commands should be similar so - * only one fixup routine is needed. - * - * Further explanation: - * The names of the commands are somewhat misleading. Here is clarification: - * - * - a 'DMA' type command has a pointer to additional data and - * causes a DMA transfer to bring that into DMEM. - * - * - an 'Immediate' type command isn't really 'immediate', in the - * traditional sense. This just means that the entire command fits - * in the 64-bit word, and the ucode can execute it 'immediately' - * without additional memory transfers. - * - * - an 'RDP' command is identified as such because the RDP - * commands can be passed-thru the RSP and sent to the RDP - * directly. One further confusing thing, is that some 'DP' - * macros below actually generate immediate commands, not - * not direct DP commands. - * - * IMPLEMENTATION NOTE: - * There is another group of RDP commands that includes the triangle commands - * generated by the RSP code. These are the raw commands the rasterizer - * hardware chews on, with slope info, etc. They will follow the RDP - * ordering... - * - * IMPLEMENTATION NOTE: - * The RDP hardware has some of these bit patterns wired up. If the hardware - * changes, we must adjust this table, likewise we can't change/add things - * once the hardware is frozen. (actually, the RDP hardware only looks at - * the lower 6 bits of the command byte) - * - */ - -#ifdef F3DEX_GBI_2 -#define G_NOOP 0x00 -#define G_RDPHALF_2 0xf1 -#define G_SETOTHERMODE_H 0xe3 -#define G_SETOTHERMODE_L 0xe2 -#define G_RDPHALF_1 0xe1 -#define G_SPNOOP 0xe0 -#define G_ENDDL 0xdf -#define G_DL 0xde -#define G_LOAD_UCODE 0xdd -#define G_MOVEMEM 0xdc -#define G_MOVEWORD 0xdb -#define G_MTX 0xda -#define G_GEOMETRYMODE 0xd9 -#define G_POPMTX 0xd8 -#define G_TEXTURE 0xd7 -#define G_SUBMODULE 0xd6 - -#define G_VTX 0x01 -#define G_MODIFYVTX 0x02 -#define G_CULLDL 0x03 -#define G_BRANCH_Z 0x04 -#define G_TRI1 0x05 -#define G_TRI2 0x06 -#define G_LINE3D 0x07 -#else /* F3DEX_GBI_2 */ - -/* DMA commands: */ -#define G_SPNOOP 0 /* handle 0 gracefully */ -#define G_MTX 1 -#define G_RESERVED0 2 /* not implemeted */ -#define G_MOVEMEM 3 /* move a block of memory (up to 4 words) to dmem */ -#define G_VTX 4 -#define G_RESERVED1 5 /* not implemeted */ -#define G_DL 6 -#define G_RESERVED2 7 /* not implemeted */ -#define G_RESERVED3 8 /* not implemeted */ -#define G_SPRITE2D_BASE 9 /* sprite command */ - -/* IMMEDIATE commands: */ -#define G_IMMFIRST -65 -#define G_TRI1 (G_IMMFIRST-0) -#define G_CULLDL (G_IMMFIRST-1) -#define G_POPMTX (G_IMMFIRST-2) -#define G_MOVEWORD (G_IMMFIRST-3) -#define G_TEXTURE (G_IMMFIRST-4) -#define G_SETOTHERMODE_H (G_IMMFIRST-5) -#define G_SETOTHERMODE_L (G_IMMFIRST-6) -#define G_ENDDL (G_IMMFIRST-7) -#define G_SETGEOMETRYMODE (G_IMMFIRST-8) -#define G_CLEARGEOMETRYMODE (G_IMMFIRST-9) -#define G_LINE3D (G_IMMFIRST-10) -#define G_RDPHALF_1 (G_IMMFIRST-11) -#define G_RDPHALF_2 (G_IMMFIRST-12) -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define G_MODIFYVTX (G_IMMFIRST-13) -# define G_TRI2 (G_IMMFIRST-14) -# define G_BRANCH_Z (G_IMMFIRST-15) -# define G_LOAD_UCODE (G_IMMFIRST-16) -#else -# define G_RDPHALF_CONT (G_IMMFIRST-13) -#endif - -/* We are overloading 2 of the immediate commands - to keep the byte alignment of dmem the same */ - -#define G_SPRITE2D_SCALEFLIP (G_IMMFIRST-1) -#define G_SPRITE2D_DRAW (G_IMMFIRST-2) - -/* RDP commands: */ -#define G_NOOP 0xc0 /* 0 */ - -#endif /* F3DEX_GBI_2 */ - -/* RDP commands: */ -#define G_SETCIMG 0xff /* -1 */ -#define G_SETZIMG 0xfe /* -2 */ -#define G_SETTIMG 0xfd /* -3 */ -#define G_SETCOMBINE 0xfc /* -4 */ -#define G_SETENVCOLOR 0xfb /* -5 */ -#define G_SETPRIMCOLOR 0xfa /* -6 */ -#define G_SETBLENDCOLOR 0xf9 /* -7 */ -#define G_SETFOGCOLOR 0xf8 /* -8 */ -#define G_SETFILLCOLOR 0xf7 /* -9 */ -#define G_FILLRECT 0xf6 /* -10 */ -#define G_SETTILE 0xf5 /* -11 */ -#define G_LOADTILE 0xf4 /* -12 */ -#define G_LOADBLOCK 0xf3 /* -13 */ -#define G_SETTILESIZE 0xf2 /* -14 */ -#define G_LOADTLUT 0xf0 /* -16 */ -#define G_RDPSETOTHERMODE 0xef /* -17 */ -#define G_SETPRIMDEPTH 0xee /* -18 */ -#define G_SETSCISSOR 0xed /* -19 */ -#define G_SETCONVERT 0xec /* -20 */ -#define G_SETKEYR 0xeb /* -21 */ -#define G_SETKEYGB 0xea /* -22 */ -#define G_RDPFULLSYNC 0xe9 /* -23 */ -#define G_RDPTILESYNC 0xe8 /* -24 */ -#define G_RDPPIPESYNC 0xe7 /* -25 */ -#define G_RDPLOADSYNC 0xe6 /* -26 */ -#define G_TEXRECTFLIP 0xe5 /* -27 */ -#define G_TEXRECT 0xe4 /* -28 */ - - -/* - * The following commands are the "generated" RDP commands; the user - * never sees them, the RSP microcode generates them. - * - * The layout of the bits is magical, to save work in the ucode. - * These id's are -56, -52, -54, -50, -55, -51, -53, -49, ... - * edge, shade, texture, zbuff bits: estz - */ -#define G_TRI_FILL 0xc8 /* fill triangle: 11001000 */ -#define G_TRI_SHADE 0xcc /* shade triangle: 11001100 */ -#define G_TRI_TXTR 0xca /* texture triangle: 11001010 */ -#define G_TRI_SHADE_TXTR 0xce /* shade, texture triangle: 11001110 */ -#define G_TRI_FILL_ZBUFF 0xc9 /* fill, zbuff triangle: 11001001 */ -#define G_TRI_SHADE_ZBUFF 0xcd /* shade, zbuff triangle: 11001101 */ -#define G_TRI_TXTR_ZBUFF 0xcb /* texture, zbuff triangle: 11001011 */ -#define G_TRI_SHADE_TXTR_ZBUFF 0xcf /* shade, txtr, zbuff trngl: 11001111 */ - -/* - * A TRI_FILL triangle is just the edges. You need to set the DP - * to use primcolor, in order to see anything. (it is NOT a triangle - * that gets rendered in 'fill mode'. Triangles can't be rendered - * in 'fill mode') - * - * A TRI_SHADE is a gouraud triangle that has colors interpolated. - * Flat-shaded triangles (from the software) are still gouraud shaded, - * it's just the colors are all the same and the deltas are 0. - * - * Other triangle types, and combinations are more obvious. - */ - -/* masks to build RDP triangle commands: */ -#define G_RDP_TRI_FILL_MASK 0x08 -#define G_RDP_TRI_SHADE_MASK 0x04 -#define G_RDP_TRI_TXTR_MASK 0x02 -#define G_RDP_TRI_ZBUFF_MASK 0x01 - -/* - * HACK: - * This is a dreadful hack. For version 1.0 hardware, there are still - * some 'bowtie' hangs. This parameter can be increased to avoid - * the hangs. Every increase of 4 chops one scanline off of every - * triangle. Values of 4,8,12 should be sufficient to avoid any - * bowtie hang. - * - * Change this value, then recompile ALL of your program (including static - * display lists!) - * - * THIS WILL BE REMOVED FOR HARDWARE VERSION 2.0! - */ -#define BOWTIE_VAL 0 - - -/* gets added to RDP command, in order to test for addres fixup: */ -#define G_RDP_ADDR_FIXUP 3 /* |RDP cmds| <= this, do addr fixup */ -#ifdef _LANGUAGE_ASSEMBLY -#define G_RDP_TEXRECT_CHECK ((-1*G_TEXRECTFLIP)& 0xff) -#endif - -/* macros for command parsing: */ -#define GDMACMD(x) (x) -#define GIMMCMD(x) (G_IMMFIRST-(x)) -#define GRDPCMD(x) (0xff-(x)) - -#define G_DMACMDSIZ 128 -#define G_IMMCMDSIZ 64 -#define G_RDPCMDSIZ 64 - -/* - * Coordinate shift values, number of bits of fraction - */ -#define G_TEXTURE_IMAGE_FRAC 2 -#define G_TEXTURE_SCALE_FRAC 16 -#define G_SCALE_FRAC 8 -#define G_ROTATE_FRAC 16 - -/* - * Parameters to graphics commands - */ - -/* - * Data packing macros - */ - -/* - * Maximum z-buffer value, used to initialize the z-buffer. - * Note : this number is NOT the viewport z-scale constant. - * See the comment next to G_MAXZ for more info. - */ -#define G_MAXFBZ 0x3fff /* 3b exp, 11b mantissa */ - -#define GPACK_RGBA5551(r, g, b, a) ((((r)<<8) & 0xf800) | \ - (((g)<<3) & 0x7c0) | \ - (((b)>>2) & 0x3e) | ((a) & 0x1)) -#define GPACK_ZDZ(z, dz) ((z) << 2 | (dz)) - -/* - * G_MTX: parameter flags - */ -#ifdef F3DEX_GBI_2x -# define G_MTX_MODELVIEW 0x00 /* matrix types */ -# define G_MTX_PROJECTION 0x04 -# define G_MTX_MUL 0x00 /* concat or load */ -# define G_MTX_LOAD 0x02 -# define G_MTX_NOPUSH 0x00 /* push or not */ -# define G_MTX_PUSH 0x01 -#else /* F3DEX_GBI_2 */ -# define G_MTX_MODELVIEW 0x00 /* matrix types */ -# define G_MTX_PROJECTION 0x01 -# define G_MTX_MUL 0x00 /* concat or load */ -# define G_MTX_LOAD 0x02 -# define G_MTX_NOPUSH 0x00 /* push or not */ -# define G_MTX_PUSH 0x04 -#endif /* F3DEX_GBI_2 */ - -/* - * flags for G_SETGEOMETRYMODE - * (this rendering state is maintained in RSP) - * - * DO NOT USE THE LOW 8 BITS OF GEOMETRYMODE: - * The weird bit-ordering is for the micro-code: the lower byte - * can be OR'd in with G_TRI_SHADE (11001100) to construct - * the triangle command directly. Don't break it... - * - * DO NOT USE THE HIGH 8 BITS OF GEOMETRYMODE: - * The high byte is OR'd with 0x703 to form the clip code mask. - * If it is set to 0x04, this will cause near clipping to occur. - * If it is zero, near clipping will not occur. - * - * Further explanation: - * G_SHADE is necessary in order to see the color that you passed - * down with the vertex. If G_SHADE isn't set, you need to set the DP - * appropriately and use primcolor to see anything. - * - * G_SHADING_SMOOTH enabled means use all 3 colors of the triangle. - * If it is not set, then do 'flat shading', where only one vertex color - * is used (and all 3 vertices are set to that same color by the ucode) - * See the man page for gSP1Triangle(). - * - */ -#define G_ZBUFFER 0x00000001 -#define G_TEXTURE_ENABLE 0x00000002 /* Microcode use only */ -#define G_SHADE 0x00000004 /* enable Gouraud interp */ -/* rest of low byte reserved for setup ucode */ -#define G_SHADING_SMOOTH 0x00000200 /* flat or smooth shaded */ -#define G_CULL_FRONT 0x00001000 -#define G_CULL_BACK 0x00002000 -#define G_CULL_BOTH 0x00003000 /* To make code cleaner */ -#define G_FOG 0x00010000 -#define G_LIGHTING 0x00020000 -#define G_TEXTURE_GEN 0x00040000 -#define G_TEXTURE_GEN_LINEAR 0x00080000 -#define G_LOD 0x00100000 /* NOT IMPLEMENTED */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define G_CLIPPING 0x00800000 -#else -# define G_CLIPPING 0x00000000 -#endif - -#ifdef _LANGUAGE_ASSEMBLY -#define G_FOG_H (G_FOG/0x10000) -#define G_LIGHTING_H (G_LIGHTING/0x10000) -#define G_TEXTURE_GEN_H (G_TEXTURE_GEN/0x10000) -#define G_TEXTURE_GEN_LINEAR_H (G_TEXTURE_GEN_LINEAR/0x10000) -#define G_LOD_H (G_LOD/0x10000) /* NOT IMPLEMENTED */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define G_CLIPPING_H (G_CLIPPING/0x10000) -#endif -#endif - -/* Need these defined for Sprite Microcode */ -#ifdef _LANGUAGE_ASSEMBLY -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -#define G_TX_NOMIRROR 0 -#define G_TX_WRAP 0 -#define G_TX_MIRROR 0x1 -#define G_TX_CLAMP 0x2 -#define G_TX_NOMASK 0 -#define G_TX_NOLOD 0 -#endif - -/* - * G_SETIMG fmt: set image formats - */ -#define G_IM_FMT_RGBA 0 -#define G_IM_FMT_YUV 1 -#define G_IM_FMT_CI 2 -#define G_IM_FMT_IA 3 -#define G_IM_FMT_I 4 - -/* - * G_SETIMG siz: set image pixel size - */ -#define G_IM_SIZ_4b 0 -#define G_IM_SIZ_8b 1 -#define G_IM_SIZ_16b 2 -#define G_IM_SIZ_32b 3 - -#define G_IM_SIZ_4b_BYTES 0 -#define G_IM_SIZ_4b_TILE_BYTES G_IM_SIZ_4b_BYTES -#define G_IM_SIZ_4b_LINE_BYTES G_IM_SIZ_4b_BYTES - -#define G_IM_SIZ_8b_BYTES 1 -#define G_IM_SIZ_8b_TILE_BYTES G_IM_SIZ_8b_BYTES -#define G_IM_SIZ_8b_LINE_BYTES G_IM_SIZ_8b_BYTES - -#define G_IM_SIZ_16b_BYTES 2 -#define G_IM_SIZ_16b_TILE_BYTES G_IM_SIZ_16b_BYTES -#define G_IM_SIZ_16b_LINE_BYTES G_IM_SIZ_16b_BYTES - -#define G_IM_SIZ_32b_BYTES 4 -#define G_IM_SIZ_32b_TILE_BYTES 2 -#define G_IM_SIZ_32b_LINE_BYTES 2 - -#define G_IM_SIZ_4b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_8b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_16b_LOAD_BLOCK G_IM_SIZ_16b -#define G_IM_SIZ_32b_LOAD_BLOCK G_IM_SIZ_32b - -#define G_IM_SIZ_4b_SHIFT 2 -#define G_IM_SIZ_8b_SHIFT 1 -#define G_IM_SIZ_16b_SHIFT 0 -#define G_IM_SIZ_32b_SHIFT 0 - -#define G_IM_SIZ_4b_INCR 3 -#define G_IM_SIZ_8b_INCR 1 -#define G_IM_SIZ_16b_INCR 0 -#define G_IM_SIZ_32b_INCR 0 - -/* - * G_SETCOMBINE: color combine modes - */ -/* Color combiner constants: */ -#define G_CCMUX_COMBINED 0 -#define G_CCMUX_TEXEL0 1 -#define G_CCMUX_TEXEL1 2 -#define G_CCMUX_PRIMITIVE 3 -#define G_CCMUX_SHADE 4 -#define G_CCMUX_ENVIRONMENT 5 -#define G_CCMUX_CENTER 6 -#define G_CCMUX_SCALE 6 -#define G_CCMUX_COMBINED_ALPHA 7 -#define G_CCMUX_TEXEL0_ALPHA 8 -#define G_CCMUX_TEXEL1_ALPHA 9 -#define G_CCMUX_PRIMITIVE_ALPHA 10 -#define G_CCMUX_SHADE_ALPHA 11 -#define G_CCMUX_ENV_ALPHA 12 -#define G_CCMUX_LOD_FRACTION 13 -#define G_CCMUX_PRIM_LOD_FRAC 14 -#define G_CCMUX_NOISE 7 -#define G_CCMUX_K4 7 -#define G_CCMUX_K5 15 -#define G_CCMUX_1 6 -#define G_CCMUX_0 31 - -/* Alpha combiner constants: */ -#define G_ACMUX_COMBINED 0 -#define G_ACMUX_TEXEL0 1 -#define G_ACMUX_TEXEL1 2 -#define G_ACMUX_PRIMITIVE 3 -#define G_ACMUX_SHADE 4 -#define G_ACMUX_ENVIRONMENT 5 -#define G_ACMUX_LOD_FRACTION 0 -#define G_ACMUX_PRIM_LOD_FRAC 6 -#define G_ACMUX_1 6 -#define G_ACMUX_0 7 - -/* typical CC cycle 1 modes */ -#define G_CC_PRIMITIVE 0, 0, 0, PRIMITIVE, 0, 0, 0, PRIMITIVE -#define G_CC_SHADE 0, 0, 0, SHADE, 0, 0, 0, SHADE -#define G_CC_MODULATEI TEXEL0, 0, SHADE, 0, 0, 0, 0, SHADE -#define G_CC_MODULATEIA TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0 -#define G_CC_MODULATEIDECALA TEXEL0, 0, SHADE, 0, 0, 0, 0, TEXEL0 -#define G_CC_MODULATERGB G_CC_MODULATEI -#define G_CC_MODULATERGBA G_CC_MODULATEIA -#define G_CC_MODULATERGBDECALA G_CC_MODULATEIDECALA -#define G_CC_MODULATEI_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM TEXEL0, 0, PRIMITIVE, 0, TEXEL0, 0, PRIMITIVE, 0 -#define G_CC_MODULATEIDECALA_PRIM TEXEL0, 0, PRIMITIVE, 0, 0, 0, 0, TEXEL0 -#define G_CC_MODULATERGB_PRIM G_CC_MODULATEI_PRIM -#define G_CC_MODULATERGBA_PRIM G_CC_MODULATEIA_PRIM -#define G_CC_MODULATERGBDECALA_PRIM G_CC_MODULATEIDECALA_PRIM -#define G_CC_DECALRGB 0, 0, 0, TEXEL0, 0, 0, 0, SHADE -#define G_CC_DECALRGBA 0, 0, 0, TEXEL0, 0, 0, 0, TEXEL0 -#define G_CC_BLENDI ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDIA ENVIRONMENT, SHADE, TEXEL0, SHADE, TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDIDECALA ENVIRONMENT, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_BLENDRGBA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDRGBDECALA TEXEL0, SHADE, TEXEL0_ALPHA, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_ADDRGB 1, 0, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_ADDRGBDECALA 1, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_REFLECTRGB ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_REFLECTRGBDECALA ENVIRONMENT, 0, TEXEL0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_HILITERGB PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -#define G_CC_HILITERGBA PRIMITIVE, SHADE, TEXEL0, SHADE, PRIMITIVE, SHADE, TEXEL0, SHADE -#define G_CC_HILITERGBDECALA PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_SHADEDECALA 0, 0, 0, SHADE, 0, 0, 0, TEXEL0 -#define G_CC_BLENDPE PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, TEXEL0, 0, SHADE, 0 -#define G_CC_BLENDPEDECALA PRIMITIVE, ENVIRONMENT, TEXEL0, ENVIRONMENT, 0, 0, 0, TEXEL0 - -/* oddball modes */ -#define _G_CC_BLENDPE ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, TEXEL0, 0, SHADE, 0 -#define _G_CC_BLENDPEDECALA ENVIRONMENT, PRIMITIVE, TEXEL0, PRIMITIVE, 0, 0, 0, TEXEL0 -#define _G_CC_TWOCOLORTEX PRIMITIVE, SHADE, TEXEL0, SHADE, 0, 0, 0, SHADE -/* used for 1-cycle sparse mip-maps, primitive color has color of lowest LOD */ -#define _G_CC_SPARSEST PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0, PRIMITIVE, TEXEL0, LOD_FRACTION, TEXEL0 -#define G_CC_TEMPLERP TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0, TEXEL1, TEXEL0, PRIM_LOD_FRAC, TEXEL0 - -/* typical CC cycle 1 modes, usually followed by other cycle 2 modes */ -#define G_CC_TRILERP TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0, TEXEL1, TEXEL0, LOD_FRACTION, TEXEL0 -#define G_CC_INTERFERENCE TEXEL0, 0, TEXEL1, 0, TEXEL0, 0, TEXEL1, 0 - -/* - * One-cycle color convert operation - */ -#define G_CC_1CYUV2RGB TEXEL0, K4, K5, TEXEL0, 0, 0, 0, SHADE - -/* - * NOTE: YUV2RGB expects TF step1 color conversion to occur in 2nd clock. - * Therefore, CC looks for step1 results in TEXEL1 - */ -#define G_CC_YUV2RGB TEXEL1, K4, K5, TEXEL1, 0, 0, 0, 0 - -/* typical CC cycle 2 modes */ -#define G_CC_PASS2 0, 0, 0, COMBINED, 0, 0, 0, COMBINED -#define G_CC_MODULATEI2 COMBINED, 0, SHADE, 0, 0, 0, 0, SHADE -#define G_CC_MODULATEIA2 COMBINED, 0, SHADE, 0, COMBINED, 0, SHADE, 0 -#define G_CC_MODULATERGB2 G_CC_MODULATEI2 -#define G_CC_MODULATERGBA2 G_CC_MODULATEIA2 -#define G_CC_MODULATEI_PRIM2 COMBINED, 0, PRIMITIVE, 0, 0, 0, 0, PRIMITIVE -#define G_CC_MODULATEIA_PRIM2 COMBINED, 0, PRIMITIVE, 0, COMBINED, 0, PRIMITIVE, 0 -#define G_CC_MODULATERGB_PRIM2 G_CC_MODULATEI_PRIM2 -#define G_CC_MODULATERGBA_PRIM2 G_CC_MODULATEIA_PRIM2 -#define G_CC_DECALRGB2 0, 0, 0, COMBINED, 0, 0, 0, SHADE -/* - * ? -#define G_CC_DECALRGBA2 COMBINED, SHADE, COMBINED_ALPHA, SHADE, 0, 0, 0, SHADE -*/ -#define G_CC_BLENDI2 ENVIRONMENT, SHADE, COMBINED, SHADE, 0, 0, 0, SHADE -#define G_CC_BLENDIA2 ENVIRONMENT, SHADE, COMBINED, SHADE, COMBINED, 0, SHADE, 0 -#define G_CC_CHROMA_KEY2 TEXEL0, CENTER, SCALE, 0, 0, 0, 0, 0 -#define G_CC_HILITERGB2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, SHADE -#define G_CC_HILITERGBA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, ENVIRONMENT, COMBINED, TEXEL0, COMBINED -#define G_CC_HILITERGBDECALA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, TEXEL0 -#define G_CC_HILITERGBPASSA2 ENVIRONMENT, COMBINED, TEXEL0, COMBINED, 0, 0, 0, COMBINED - -/* - * G_SETOTHERMODE_L sft: shift count - */ -#define G_MDSFT_ALPHACOMPARE 0 -#define G_MDSFT_ZSRCSEL 2 -#define G_MDSFT_RENDERMODE 3 -#define G_MDSFT_BLENDER 16 - -/* - * G_SETOTHERMODE_H sft: shift count - */ -#define G_MDSFT_BLENDMASK 0 /* unsupported */ -#define G_MDSFT_ALPHADITHER 4 -#define G_MDSFT_RGBDITHER 6 - -#define G_MDSFT_COMBKEY 8 -#define G_MDSFT_TEXTCONV 9 -#define G_MDSFT_TEXTFILT 12 -#define G_MDSFT_TEXTLUT 14 -#define G_MDSFT_TEXTLOD 16 -#define G_MDSFT_TEXTDETAIL 17 -#define G_MDSFT_TEXTPERSP 19 -#define G_MDSFT_CYCLETYPE 20 -#define G_MDSFT_COLORDITHER 22 /* unsupported in HW 2.0 */ -#define G_MDSFT_PIPELINE 23 - -/* G_SETOTHERMODE_H gPipelineMode */ -#define G_PM_1PRIMITIVE (1 << G_MDSFT_PIPELINE) -#define G_PM_NPRIMITIVE (0 << G_MDSFT_PIPELINE) - -/* G_SETOTHERMODE_H gSetCycleType */ -#define G_CYC_1CYCLE (0 << G_MDSFT_CYCLETYPE) -#define G_CYC_2CYCLE (1 << G_MDSFT_CYCLETYPE) -#define G_CYC_COPY (2 << G_MDSFT_CYCLETYPE) -#define G_CYC_FILL (3 << G_MDSFT_CYCLETYPE) - -/* G_SETOTHERMODE_H gSetTexturePersp */ -#define G_TP_NONE (0 << G_MDSFT_TEXTPERSP) -#define G_TP_PERSP (1 << G_MDSFT_TEXTPERSP) - -/* G_SETOTHERMODE_H gSetTextureDetail */ -#define G_TD_CLAMP (0 << G_MDSFT_TEXTDETAIL) -#define G_TD_SHARPEN (1 << G_MDSFT_TEXTDETAIL) -#define G_TD_DETAIL (2 << G_MDSFT_TEXTDETAIL) - -/* G_SETOTHERMODE_H gSetTextureLOD */ -#define G_TL_TILE (0 << G_MDSFT_TEXTLOD) -#define G_TL_LOD (1 << G_MDSFT_TEXTLOD) - -/* G_SETOTHERMODE_H gSetTextureLUT */ -#define G_TT_NONE (0 << G_MDSFT_TEXTLUT) -#define G_TT_RGBA16 (2 << G_MDSFT_TEXTLUT) -#define G_TT_IA16 (3 << G_MDSFT_TEXTLUT) - -/* G_SETOTHERMODE_H gSetTextureFilter */ -#define G_TF_POINT (0 << G_MDSFT_TEXTFILT) -#define G_TF_AVERAGE (3 << G_MDSFT_TEXTFILT) -#define G_TF_BILERP (2 << G_MDSFT_TEXTFILT) - -/* G_SETOTHERMODE_H gSetTextureConvert */ -#define G_TC_CONV (0 << G_MDSFT_TEXTCONV) -#define G_TC_FILTCONV (5 << G_MDSFT_TEXTCONV) -#define G_TC_FILT (6 << G_MDSFT_TEXTCONV) - -/* G_SETOTHERMODE_H gSetCombineKey */ -#define G_CK_NONE (0 << G_MDSFT_COMBKEY) -#define G_CK_KEY (1 << G_MDSFT_COMBKEY) - -/* G_SETOTHERMODE_H gSetColorDither */ -#define G_CD_MAGICSQ (0 << G_MDSFT_RGBDITHER) -#define G_CD_BAYER (1 << G_MDSFT_RGBDITHER) -#define G_CD_NOISE (2 << G_MDSFT_RGBDITHER) - -#ifndef _HW_VERSION_1 -#define G_CD_DISABLE (3 << G_MDSFT_RGBDITHER) -#define G_CD_ENABLE G_CD_NOISE /* HW 1.0 compatibility mode */ -#else -#define G_CD_ENABLE (1 << G_MDSFT_COLORDITHER) -#define G_CD_DISABLE (0 << G_MDSFT_COLORDITHER) -#endif - -/* G_SETOTHERMODE_H gSetAlphaDither */ -#define G_AD_PATTERN (0 << G_MDSFT_ALPHADITHER) -#define G_AD_NOTPATTERN (1 << G_MDSFT_ALPHADITHER) -#define G_AD_NOISE (2 << G_MDSFT_ALPHADITHER) -#define G_AD_DISABLE (3 << G_MDSFT_ALPHADITHER) - -/* G_SETOTHERMODE_L gSetAlphaCompare */ -#define G_AC_NONE (0 << G_MDSFT_ALPHACOMPARE) -#define G_AC_THRESHOLD (1 << G_MDSFT_ALPHACOMPARE) -#define G_AC_DITHER (3 << G_MDSFT_ALPHACOMPARE) - -/* G_SETOTHERMODE_L gSetDepthSource */ -#define G_ZS_PIXEL (0 << G_MDSFT_ZSRCSEL) -#define G_ZS_PRIM (1 << G_MDSFT_ZSRCSEL) - -/* G_SETOTHERMODE_L gSetRenderMode */ -#define AA_EN 0x8 -#define Z_CMP 0x10 -#define Z_UPD 0x20 -#define IM_RD 0x40 -#define CLR_ON_CVG 0x80 -#define CVG_DST_CLAMP 0 -#define CVG_DST_WRAP 0x100 -#define CVG_DST_FULL 0x200 -#define CVG_DST_SAVE 0x300 -#define ZMODE_OPA 0 -#define ZMODE_INTER 0x400 -#define ZMODE_XLU 0x800 -#define ZMODE_DEC 0xc00 -#define CVG_X_ALPHA 0x1000 -#define ALPHA_CVG_SEL 0x2000 -#define FORCE_BL 0x4000 -#define TEX_EDGE 0x0000 /* used to be 0x8000 */ - -#define G_BL_CLR_IN 0 -#define G_BL_CLR_MEM 1 -#define G_BL_CLR_BL 2 -#define G_BL_CLR_FOG 3 -#define G_BL_1MA 0 -#define G_BL_A_MEM 1 -#define G_BL_A_IN 0 -#define G_BL_A_FOG 1 -#define G_BL_A_SHADE 2 -#define G_BL_1 2 -#define G_BL_0 3 - -#define GBL_c1(m1a, m1b, m2a, m2b) \ - (m1a) << 30 | (m1b) << 26 | (m2a) << 22 | (m2b) << 18 -#define GBL_c2(m1a, m1b, m2a, m2b) \ - (m1a) << 28 | (m1b) << 24 | (m2a) << 20 | (m2b) << 16 - -#define RM_AA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_SURF(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_DECAL(clk) \ - AA_EN | Z_CMP | CVG_DST_WRAP | ALPHA_CVG_SEL | \ - ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_DECAL(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_ZB_OPA_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | CVG_DST_CLAMP | \ - ALPHA_CVG_SEL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_XLU_INTER(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | \ - FORCE_BL | ZMODE_INTER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_XLU_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_DEC_LINE(clk) \ - AA_EN | Z_CMP | IM_RD | CVG_DST_SAVE | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_EDGE(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_TEX_INTER(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_INTER | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_SUB_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_ZB_PCL_SURF(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_OPA_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_TEX_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_ZB_SUB_TERR(clk) \ - AA_EN | Z_CMP | Z_UPD | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_AA_OPA_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_RA_OPA_SURF(clk) \ - AA_EN | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_XLU_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_WRAP | CLR_ON_CVG | FORCE_BL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_XLU_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_DEC_LINE(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | CVG_X_ALPHA | \ - ALPHA_CVG_SEL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_EDGE(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_SUB_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_AA_PCL_SURF(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_OPA_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_TEX_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_CLAMP | \ - CVG_X_ALPHA | ALPHA_CVG_SEL | ZMODE_OPA | TEX_EDGE | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_AA_SUB_TERR(clk) \ - AA_EN | IM_RD | CVG_DST_FULL | \ - ZMODE_OPA | ALPHA_CVG_SEL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - - -#define RM_ZB_OPA_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ALPHA_CVG_SEL | \ - ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OPA_DECAL(clk) \ - Z_CMP | CVG_DST_FULL | ALPHA_CVG_SEL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_A_MEM) - -#define RM_ZB_XLU_DECAL(clk) \ - Z_CMP | IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_CLD_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_XLU | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_OVL_SURF(clk) \ - Z_CMP | IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_DEC | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_ZB_PCL_SURF(clk) \ - Z_CMP | Z_UPD | CVG_DST_FULL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - - -#define RM_OPA_SURF(clk) \ - CVG_DST_CLAMP | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_XLU_SURF(clk) \ - IM_RD | CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_TEX_EDGE(clk) \ - CVG_DST_CLAMP | CVG_X_ALPHA | ALPHA_CVG_SEL | FORCE_BL |\ - ZMODE_OPA | TEX_EDGE | AA_EN | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_CLD_SURF(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_IN, G_BL_CLR_MEM, G_BL_1MA) - -#define RM_PCL_SURF(clk) \ - CVG_DST_FULL | FORCE_BL | ZMODE_OPA | \ - G_AC_DITHER | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -#define RM_ADD(clk) \ - IM_RD | CVG_DST_SAVE | FORCE_BL | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_A_FOG, G_BL_CLR_MEM, G_BL_1) - -#define RM_NOOP(clk) \ - GBL_c##clk(0, 0, 0, 0) - -#define RM_VISCVG(clk) \ - IM_RD | FORCE_BL | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_BL, G_BL_A_MEM) - -/* for rendering to an 8-bit framebuffer */ -#define RM_OPA_CI(clk) \ - CVG_DST_CLAMP | ZMODE_OPA | \ - GBL_c##clk(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - - - -#define G_RM_AA_ZB_OPA_SURF RM_AA_ZB_OPA_SURF(1) -#define G_RM_AA_ZB_OPA_SURF2 RM_AA_ZB_OPA_SURF(2) -#define G_RM_AA_ZB_XLU_SURF RM_AA_ZB_XLU_SURF(1) -#define G_RM_AA_ZB_XLU_SURF2 RM_AA_ZB_XLU_SURF(2) -#define G_RM_AA_ZB_OPA_DECAL RM_AA_ZB_OPA_DECAL(1) -#define G_RM_AA_ZB_OPA_DECAL2 RM_AA_ZB_OPA_DECAL(2) -#define G_RM_AA_ZB_XLU_DECAL RM_AA_ZB_XLU_DECAL(1) -#define G_RM_AA_ZB_XLU_DECAL2 RM_AA_ZB_XLU_DECAL(2) -#define G_RM_AA_ZB_OPA_INTER RM_AA_ZB_OPA_INTER(1) -#define G_RM_AA_ZB_OPA_INTER2 RM_AA_ZB_OPA_INTER(2) -#define G_RM_AA_ZB_XLU_INTER RM_AA_ZB_XLU_INTER(1) -#define G_RM_AA_ZB_XLU_INTER2 RM_AA_ZB_XLU_INTER(2) -#define G_RM_AA_ZB_XLU_LINE RM_AA_ZB_XLU_LINE(1) -#define G_RM_AA_ZB_XLU_LINE2 RM_AA_ZB_XLU_LINE(2) -#define G_RM_AA_ZB_DEC_LINE RM_AA_ZB_DEC_LINE(1) -#define G_RM_AA_ZB_DEC_LINE2 RM_AA_ZB_DEC_LINE(2) -#define G_RM_AA_ZB_TEX_EDGE RM_AA_ZB_TEX_EDGE(1) -#define G_RM_AA_ZB_TEX_EDGE2 RM_AA_ZB_TEX_EDGE(2) -#define G_RM_AA_ZB_TEX_INTER RM_AA_ZB_TEX_INTER(1) -#define G_RM_AA_ZB_TEX_INTER2 RM_AA_ZB_TEX_INTER(2) -#define G_RM_AA_ZB_SUB_SURF RM_AA_ZB_SUB_SURF(1) -#define G_RM_AA_ZB_SUB_SURF2 RM_AA_ZB_SUB_SURF(2) -#define G_RM_AA_ZB_PCL_SURF RM_AA_ZB_PCL_SURF(1) -#define G_RM_AA_ZB_PCL_SURF2 RM_AA_ZB_PCL_SURF(2) -#define G_RM_AA_ZB_OPA_TERR RM_AA_ZB_OPA_TERR(1) -#define G_RM_AA_ZB_OPA_TERR2 RM_AA_ZB_OPA_TERR(2) -#define G_RM_AA_ZB_TEX_TERR RM_AA_ZB_TEX_TERR(1) -#define G_RM_AA_ZB_TEX_TERR2 RM_AA_ZB_TEX_TERR(2) -#define G_RM_AA_ZB_SUB_TERR RM_AA_ZB_SUB_TERR(1) -#define G_RM_AA_ZB_SUB_TERR2 RM_AA_ZB_SUB_TERR(2) - -#define G_RM_RA_ZB_OPA_SURF RM_RA_ZB_OPA_SURF(1) -#define G_RM_RA_ZB_OPA_SURF2 RM_RA_ZB_OPA_SURF(2) -#define G_RM_RA_ZB_OPA_DECAL RM_RA_ZB_OPA_DECAL(1) -#define G_RM_RA_ZB_OPA_DECAL2 RM_RA_ZB_OPA_DECAL(2) -#define G_RM_RA_ZB_OPA_INTER RM_RA_ZB_OPA_INTER(1) -#define G_RM_RA_ZB_OPA_INTER2 RM_RA_ZB_OPA_INTER(2) - -#define G_RM_AA_OPA_SURF RM_AA_OPA_SURF(1) -#define G_RM_AA_OPA_SURF2 RM_AA_OPA_SURF(2) -#define G_RM_AA_XLU_SURF RM_AA_XLU_SURF(1) -#define G_RM_AA_XLU_SURF2 RM_AA_XLU_SURF(2) -#define G_RM_AA_XLU_LINE RM_AA_XLU_LINE(1) -#define G_RM_AA_XLU_LINE2 RM_AA_XLU_LINE(2) -#define G_RM_AA_DEC_LINE RM_AA_DEC_LINE(1) -#define G_RM_AA_DEC_LINE2 RM_AA_DEC_LINE(2) -#define G_RM_AA_TEX_EDGE RM_AA_TEX_EDGE(1) -#define G_RM_AA_TEX_EDGE2 RM_AA_TEX_EDGE(2) -#define G_RM_AA_SUB_SURF RM_AA_SUB_SURF(1) -#define G_RM_AA_SUB_SURF2 RM_AA_SUB_SURF(2) -#define G_RM_AA_PCL_SURF RM_AA_PCL_SURF(1) -#define G_RM_AA_PCL_SURF2 RM_AA_PCL_SURF(2) -#define G_RM_AA_OPA_TERR RM_AA_OPA_TERR(1) -#define G_RM_AA_OPA_TERR2 RM_AA_OPA_TERR(2) -#define G_RM_AA_TEX_TERR RM_AA_TEX_TERR(1) -#define G_RM_AA_TEX_TERR2 RM_AA_TEX_TERR(2) -#define G_RM_AA_SUB_TERR RM_AA_SUB_TERR(1) -#define G_RM_AA_SUB_TERR2 RM_AA_SUB_TERR(2) - -#define G_RM_RA_OPA_SURF RM_RA_OPA_SURF(1) -#define G_RM_RA_OPA_SURF2 RM_RA_OPA_SURF(2) - -#define G_RM_ZB_OPA_SURF RM_ZB_OPA_SURF(1) -#define G_RM_ZB_OPA_SURF2 RM_ZB_OPA_SURF(2) -#define G_RM_ZB_XLU_SURF RM_ZB_XLU_SURF(1) -#define G_RM_ZB_XLU_SURF2 RM_ZB_XLU_SURF(2) -#define G_RM_ZB_OPA_DECAL RM_ZB_OPA_DECAL(1) -#define G_RM_ZB_OPA_DECAL2 RM_ZB_OPA_DECAL(2) -#define G_RM_ZB_XLU_DECAL RM_ZB_XLU_DECAL(1) -#define G_RM_ZB_XLU_DECAL2 RM_ZB_XLU_DECAL(2) -#define G_RM_ZB_CLD_SURF RM_ZB_CLD_SURF(1) -#define G_RM_ZB_CLD_SURF2 RM_ZB_CLD_SURF(2) -#define G_RM_ZB_OVL_SURF RM_ZB_OVL_SURF(1) -#define G_RM_ZB_OVL_SURF2 RM_ZB_OVL_SURF(2) -#define G_RM_ZB_PCL_SURF RM_ZB_PCL_SURF(1) -#define G_RM_ZB_PCL_SURF2 RM_ZB_PCL_SURF(2) - -#define G_RM_OPA_SURF RM_OPA_SURF(1) -#define G_RM_OPA_SURF2 RM_OPA_SURF(2) -#define G_RM_XLU_SURF RM_XLU_SURF(1) -#define G_RM_XLU_SURF2 RM_XLU_SURF(2) -#define G_RM_CLD_SURF RM_CLD_SURF(1) -#define G_RM_CLD_SURF2 RM_CLD_SURF(2) -#define G_RM_TEX_EDGE RM_TEX_EDGE(1) -#define G_RM_TEX_EDGE2 RM_TEX_EDGE(2) -#define G_RM_PCL_SURF RM_PCL_SURF(1) -#define G_RM_PCL_SURF2 RM_PCL_SURF(2) -#define G_RM_ADD RM_ADD(1) -#define G_RM_ADD2 RM_ADD(2) -#define G_RM_NOOP RM_NOOP(1) -#define G_RM_NOOP2 RM_NOOP(2) -#define G_RM_VISCVG RM_VISCVG(1) -#define G_RM_VISCVG2 RM_VISCVG(2) -#define G_RM_OPA_CI RM_OPA_CI(1) -#define G_RM_OPA_CI2 RM_OPA_CI(2) - - -#define G_RM_FOG_SHADE_A GBL_c1(G_BL_CLR_FOG, G_BL_A_SHADE, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_FOG_PRIM_A GBL_c1(G_BL_CLR_FOG, G_BL_A_FOG, G_BL_CLR_IN, G_BL_1MA) -#define G_RM_PASS GBL_c1(G_BL_CLR_IN, G_BL_0, G_BL_CLR_IN, G_BL_1) - -/* - * G_SETCONVERT: K0-5 - */ -#define G_CV_K0 175 -#define G_CV_K1 -43 -#define G_CV_K2 -89 -#define G_CV_K3 222 -#define G_CV_K4 114 -#define G_CV_K5 42 - -/* - * G_SETSCISSOR: interlace mode - */ -#define G_SC_NON_INTERLACE 0 -#define G_SC_ODD_INTERLACE 3 -#define G_SC_EVEN_INTERLACE 2 - -/* flags to inhibit pushing of the display list (on branch) */ -#define G_DL_PUSH 0x00 -#define G_DL_NOPUSH 0x01 - -/* - * BEGIN C-specific section: (typedef's) - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* - * Data Structures - * - * NOTE: - * The DMA transfer hardware requires 64-bit aligned, 64-bit multiple- - * sized transfers. This important hardware optimization is unfortunately - * reflected in the programming interface, with some structures - * padded and alignment enforced. - * - * Since structures are aligned to the boundary of the "worst-case" - * element, we can't depend on the C compiler to align things - * properly. - * - * 64-bit structure alignment is enforced by wrapping structures with - * unions that contain a dummy "long long int". Why this works is - * explained in the ANSI C Spec, or on page 186 of the second edition - * of K&R, "The C Programming Language". - * - * The price we pay for this is a little awkwardness referencing the - * structures through the union. There is no memory penalty, since - * all the structures are at least 64-bits the dummy alignment field - * does not increase the size of the union. - * - * Static initialization of these union structures works because - * the ANSI C spec states that static initialization for unions - * works by using the first union element. We put the dummy alignment - * field last for this reason. - * - * (it's possible a newer 64-bit compiler from MIPS might make this - * easier with a flag, but we can't wait for it...) - * - */ - -/* - * Vertex (set up for use with colors) - */ -typedef struct { - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - unsigned char cn[4]; /* color & alpha */ -} Vtx_t; - -/* - * Vertex (set up for use with normals) - */ -typedef struct { - short ob[3]; /* x, y, z */ - unsigned short flag; - short tc[2]; /* texture coord */ - signed char n[3]; /* normal */ - unsigned char a; /* alpha */ -} Vtx_tn; - -typedef union { - Vtx_t v; /* Use this one for colors */ - Vtx_tn n; /* Use this one for normals */ - long long int force_structure_alignment; -} Vtx; - -/* - * Sprite structure - */ - -typedef struct { - void *SourceImagePointer; - void *TlutPointer; - short Stride; - short SubImageWidth; - short SubImageHeight; - char SourceImageType; - char SourceImageBitSize; - short SourceImageOffsetS; - short SourceImageOffsetT; - /* 20 bytes for above */ - - /* padding to bring structure size to 64 bit allignment */ - char dummy[4]; - -} uSprite_t; - -typedef union { - uSprite_t s; - - /* Need to make sure this is 64 bit aligned */ - long long int force_structure_allignment[3]; -} uSprite; - -/* - * Triangle face - */ -typedef struct { - unsigned char flag; - unsigned char v[3]; -} Tri; - -/* - * 4x4 matrix, fixed point s15.16 format. - * First 8 words are integer portion of the 4x4 matrix - * Last 8 words are the fraction portion of the 4x4 matrix - */ -typedef long Mtx_t[4][4]; - -typedef struct { - u16 i[4][4]; - u16 f[4][4]; -} Mtx_u; - -typedef union { - Mtx_u u; - Mtx_t m; - long long int force_structure_alignment; -} Mtx; - -/* - * Viewport - */ - -/* - * - * This magic value is the maximum INTEGER z-range of the hardware - * (there are also 16-bits of fraction, which are introduced during - * any transformations). This is not just a good idea, it's the law. - * Feeding the hardware eventual z-coordinates (after any transforms - * or scaling) bigger than this, will not work. - * - * This number is DIFFERENT than G_MAXFBZ, which is the maximum value - * you want to use to initialize the z-buffer. - * - * The reason these are different is mildly interesting, but too long - * to explain here. It is basically the result of optimizations in the - * hardware. A more generic API might hide this detail from the users, - * but we don't have the ucode to do that... - * - */ -#define G_MAXZ 0x03ff /* 10 bits of integer screen-Z precision */ - -/* - * The viewport structure elements have 2 bits of fraction, necessary - * to accomodate the sub-pixel positioning scaling for the hardware. - * This can also be exploited to handle odd-sized viewports. - * - * Accounting for these fractional bits, using the default projection - * and viewing matrices, the viewport structure is initialized thusly: - * - * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, G_MAXZ, 0, - * (SCREEN_WD/2)*4, (SCREEN_HT/2)*4, 0, 0, - */ -typedef struct { - short vscale[4]; /* scale, 2 bits fraction */ - short vtrans[4]; /* translate, 2 bits fraction */ - /* both the above arrays are padded to 64-bit boundary */ -} Vp_t; - -typedef union { - Vp_t vp; - long long int force_structure_alignment; -} Vp; - -/* - * MOVEMEM indices - * - * Each of these indexes an entry in a dmem table - * which points to a 1-4 word block of dmem in - * which to store a 1-4 word DMA. - * - */ -#ifdef F3DEX_GBI_2x -/* 0,2,4,6 are reserved by G_MTX */ -# define G_MV_VIEWPORT 8 -# define G_MV_LIGHT 10 -# define G_MV_POINT 12 -# define G_MV_MATRIX 14 /* NOTE: this is in moveword table */ -# define G_MVO_LOOKATX (0*24) -# define G_MVO_LOOKATY (1*24) -# define G_MVO_L0 (2*24) -# define G_MVO_L1 (3*24) -# define G_MVO_L2 (4*24) -# define G_MVO_L3 (5*24) -# define G_MVO_L4 (6*24) -# define G_MVO_L5 (7*24) -# define G_MVO_L6 (8*24) -# define G_MVO_L7 (9*24) -#else /* F3DEX_GBI_2 */ -# define G_MV_VIEWPORT 0x80 -# define G_MV_LOOKATY 0x82 -# define G_MV_LOOKATX 0x84 -# define G_MV_L0 0x86 -# define G_MV_L1 0x88 -# define G_MV_L2 0x8a -# define G_MV_L3 0x8c -# define G_MV_L4 0x8e -# define G_MV_L5 0x90 -# define G_MV_L6 0x92 -# define G_MV_L7 0x94 -# define G_MV_TXTATT 0x96 -# define G_MV_MATRIX_1 0x9e /* NOTE: this is in moveword table */ -# define G_MV_MATRIX_2 0x98 -# define G_MV_MATRIX_3 0x9a -# define G_MV_MATRIX_4 0x9c -#endif /* F3DEX_GBI_2 */ - -/* - * MOVEWORD indices - * - * Each of these indexes an entry in a dmem table - * which points to a word in dmem in dmem where - * an immediate word will be stored. - * - */ -#define G_MW_MATRIX 0x00 /* NOTE: also used by movemem */ -#define G_MW_NUMLIGHT 0x02 -#define G_MW_CLIP 0x04 -#define G_MW_SEGMENT 0x06 -#define G_MW_FOG 0x08 -#define G_MW_LIGHTCOL 0x0a -#ifdef F3DEX_GBI_2x -# define G_MW_FORCEMTX 0x0c -#else /* F3DEX_GBI_2 */ -# define G_MW_POINTS 0x0c -#endif /* F3DEX_GBI_2 */ -#define G_MW_PERSPNORM 0x0e - -/* - * These are offsets from the address in the dmem table - */ -#define G_MWO_NUMLIGHT 0x00 -#define G_MWO_CLIP_RNX 0x04 -#define G_MWO_CLIP_RNY 0x0c -#define G_MWO_CLIP_RPX 0x14 -#define G_MWO_CLIP_RPY 0x1c -#define G_MWO_SEGMENT_0 0x00 -#define G_MWO_SEGMENT_1 0x01 -#define G_MWO_SEGMENT_2 0x02 -#define G_MWO_SEGMENT_3 0x03 -#define G_MWO_SEGMENT_4 0x04 -#define G_MWO_SEGMENT_5 0x05 -#define G_MWO_SEGMENT_6 0x06 -#define G_MWO_SEGMENT_7 0x07 -#define G_MWO_SEGMENT_8 0x08 -#define G_MWO_SEGMENT_9 0x09 -#define G_MWO_SEGMENT_A 0x0a -#define G_MWO_SEGMENT_B 0x0b -#define G_MWO_SEGMENT_C 0x0c -#define G_MWO_SEGMENT_D 0x0d -#define G_MWO_SEGMENT_E 0x0e -#define G_MWO_SEGMENT_F 0x0f -#define G_MWO_FOG 0x00 -#define G_MWO_aLIGHT_1 0x00 -#define G_MWO_bLIGHT_1 0x04 -#define G_MWO_aLIGHT_2 0x20 -#define G_MWO_bLIGHT_2 0x24 -#define G_MWO_aLIGHT_3 0x40 -#define G_MWO_bLIGHT_3 0x44 -#define G_MWO_aLIGHT_4 0x60 -#define G_MWO_bLIGHT_4 0x64 -#define G_MWO_aLIGHT_5 0x80 -#define G_MWO_bLIGHT_5 0x84 -#define G_MWO_aLIGHT_6 0xa0 -#define G_MWO_bLIGHT_6 0xa4 -#define G_MWO_aLIGHT_7 0xc0 -#define G_MWO_bLIGHT_7 0xc4 -#define G_MWO_aLIGHT_8 0xe0 -#define G_MWO_bLIGHT_8 0xe4 -#define G_MWO_MATRIX_XX_XY_I 0x00 -#define G_MWO_MATRIX_XZ_XW_I 0x04 -#define G_MWO_MATRIX_YX_YY_I 0x08 -#define G_MWO_MATRIX_YZ_YW_I 0x0c -#define G_MWO_MATRIX_ZX_ZY_I 0x10 -#define G_MWO_MATRIX_ZZ_ZW_I 0x14 -#define G_MWO_MATRIX_WX_WY_I 0x18 -#define G_MWO_MATRIX_WZ_WW_I 0x1c -#define G_MWO_MATRIX_XX_XY_F 0x20 -#define G_MWO_MATRIX_XZ_XW_F 0x24 -#define G_MWO_MATRIX_YX_YY_F 0x28 -#define G_MWO_MATRIX_YZ_YW_F 0x2c -#define G_MWO_MATRIX_ZX_ZY_F 0x30 -#define G_MWO_MATRIX_ZZ_ZW_F 0x34 -#define G_MWO_MATRIX_WX_WY_F 0x38 -#define G_MWO_MATRIX_WZ_WW_F 0x3c -#define G_MWO_POINT_RGBA 0x10 -#define G_MWO_POINT_ST 0x14 -#define G_MWO_POINT_XYSCREEN 0x18 -#define G_MWO_POINT_ZSCREEN 0x1c - -/* - * Light structure. - * - * Note: only directional (infinite) lights are currently supported. - * - * Note: the weird order is for the DMEM alignment benefit of - * the microcode. - * - */ - -typedef struct { - unsigned char col[3]; /* diffuse light value (rgba) */ - char pad1; - unsigned char colc[3]; /* copy of diffuse light value (rgba) */ - char pad2; - signed char dir[3]; /* direction of light (normalized) */ - char pad3; -} Light_t; - -typedef struct { - unsigned char col[3]; /* ambient light value (rgba) */ - char pad1; - unsigned char colc[3]; /* copy of ambient light value (rgba) */ - char pad2; -} Ambient_t; - -typedef struct { - int x1,y1,x2,y2; /* texture offsets for highlight 1/2 */ -} Hilite_t; - -typedef union { - Light_t l; - long long int force_structure_alignment[2]; -} Light; - -typedef union { - Ambient_t l; - long long int force_structure_alignment[1]; -} Ambient; - -typedef struct { - Ambient a; - Light l[7]; -} Lightsn; - -typedef struct { - Ambient a; - Light l[1]; -} Lights0; - -typedef struct { - Ambient a; - Light l[1]; -} Lights1; - -typedef struct { - Ambient a; - Light l[2]; -} Lights2; - -typedef struct { - Ambient a; - Light l[3]; -} Lights3; - -typedef struct { - Ambient a; - Light l[4]; -} Lights4; - -typedef struct { - Ambient a; - Light l[5]; -} Lights5; - -typedef struct { - Ambient a; - Light l[6]; -} Lights6; - -typedef struct { - Ambient a; - Light l[7]; -} Lights7; - -typedef struct { - Light l[2]; -} LookAt; - -typedef union { - Hilite_t h; - long int force_structure_alignment[4]; -} Hilite; - -#define gdSPDefLights0(ar,ag,ab) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ { 0, 0, 0},0,{ 0, 0, 0},0,{ 0, 0, 0},0}}} } -#define gdSPDefLights1(ar,ag,ab,r1,g1,b1,x1,y1,z1) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}} } -#define gdSPDefLights2(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}} } -#define gdSPDefLights3(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}} } -#define gdSPDefLights4(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}} } -#define gdSPDefLights5(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}} } - - -#define gdSPDefLights6(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}} } - - -#define gdSPDefLights7(ar,ag,ab,r1,g1,b1,x1,y1,z1,r2,g2,b2,x2,y2,z2,r3,g3,b3,x3,y3,z3,r4,g4,b4,x4,y4,z4,r5,g5,b5,x5,y5,z5,r6,g6,b6,x6,y6,z6,r7,g7,b7,x7,y7,z7) \ - { {{ {ar,ag,ab},0,{ar,ag,ab},0}}, \ - {{{ {r1,g1,b1},0,{r1,g1,b1},0,{x1,y1,z1},0}}, \ - {{ {r2,g2,b2},0,{r2,g2,b2},0,{x2,y2,z2},0}}, \ - {{ {r3,g3,b3},0,{r3,g3,b3},0,{x3,y3,z3},0}}, \ - {{ {r4,g4,b4},0,{r4,g4,b4},0,{x4,y4,z4},0}}, \ - {{ {r5,g5,b5},0,{r5,g5,b5},0,{x5,y5,z5},0}}, \ - {{ {r6,g6,b6},0,{r6,g6,b6},0,{x6,y6,z6},0}}, \ - {{ {r7,g7,b7},0,{r7,g7,b7},0,{x7,y7,z7},0}}} } - - -#define gdSPDefLookAt(rightx,righty,rightz,upx,upy,upz) \ - { {{ {{0,0,0},0,{0,0,0},0,{rightx,righty,rightz},0}}, \ - { {{0,0x80,0},0,{0,0x80,0},0,{upx,upy,upz},0}}} } - -/* - * Graphics DMA Packet - */ -typedef struct { - int cmd:8; - unsigned int par:8; - unsigned int len:16; - unsigned int addr; -} Gdma; - -/* - * Graphics Immediate Mode Packet types - */ -typedef struct { - int cmd:8; - int pad:24; - Tri tri; -} Gtri; - -typedef struct { - int cmd:8; - int pad1:24; - int pad2:24; - unsigned char param:8; -} Gpopmtx; - -/* - * typedef struct { - * int cmd:8; - * int pad0:24; - * int pad1:4; - * int number:4; - * int base:24; - * } Gsegment; - */ -typedef struct { - int cmd:8; - int pad0:8; - int mw_index:8; - int number:8; - int pad1:8; - int base:24; -} Gsegment; - -typedef struct { - int cmd:8; - int pad0:8; - int sft:8; - int len:8; - unsigned int data:32; -} GsetothermodeL; - -typedef struct { - int cmd:8; - int pad0:8; - int sft:8; - int len:8; - unsigned int data:32; -} GsetothermodeH; - -typedef struct { - unsigned char cmd; - unsigned char lodscale; - unsigned char tile; - unsigned char on; - unsigned short s; - unsigned short t; -} Gtexture; - -typedef struct { - int cmd:8; - int pad:24; - Tri line; -} Gline3D; - -typedef struct { - int cmd:8; - int pad1:24; - short int pad2; - short int scale; -} Gperspnorm; - - -/* - * RDP Packet types - */ -typedef struct { - int cmd:8; - unsigned int fmt:3; - unsigned int siz:2; - unsigned int pad:7; - unsigned int wd:12; /* really only 10 bits, extra */ - unsigned int dram; /* to account for 1024 */ -} Gsetimg; - -typedef struct { - int cmd:8; - unsigned int muxs0:24; - unsigned int muxs1:32; -} Gsetcombine; - -typedef struct { - int cmd:8; - unsigned char pad; - unsigned char prim_min_level; - unsigned char prim_level; - unsigned long color; -} Gsetcolor; - -typedef struct { - int cmd:8; - int x0:10; - int x0frac:2; - int y0:10; - int y0frac:2; - unsigned int pad:8; - int x1:10; - int x1frac:2; - int y1:10; - int y1frac:2; -} Gfillrect; - -typedef struct { - int cmd:8; - unsigned int fmt:3; - unsigned int siz:2; - unsigned int pad0:1; - unsigned int line:9; - unsigned int tmem:9; - unsigned int pad1:5; - unsigned int tile:3; - unsigned int palette:4; - unsigned int ct:1; - unsigned int mt:1; - unsigned int maskt:4; - unsigned int shiftt:4; - unsigned int cs:1; - unsigned int ms:1; - unsigned int masks:4; - unsigned int shifts:4; -} Gsettile; - -typedef struct { - int cmd:8; - unsigned int sl:12; - unsigned int tl:12; - int pad:5; - unsigned int tile:3; - unsigned int sh:12; - unsigned int th:12; -} Gloadtile; - -typedef Gloadtile Gloadblock; - -typedef Gloadtile Gsettilesize; - -typedef Gloadtile Gloadtlut; - -typedef struct { - unsigned int cmd:8; /* command */ - unsigned int xl:12; /* X coordinate of upper left */ - unsigned int yl:12; /* Y coordinate of upper left */ - unsigned int pad1:5; /* Padding */ - unsigned int tile:3; /* Tile descriptor index */ - unsigned int xh:12; /* X coordinate of lower right */ - unsigned int yh:12; /* Y coordinate of lower right */ - unsigned int s:16; /* S texture coord at top left */ - unsigned int t:16; /* T texture coord at top left */ - unsigned int dsdx:16;/* Change in S per change in X */ - unsigned int dtdy:16;/* Change in T per change in Y */ -} Gtexrect; - -#define MakeTexRect(xh,yh,flip,tile,xl,yl,s,t,dsdx,dtdy) \ - G_TEXRECT, xh, yh, 0, flip, 0, tile, xl, yl, s, t, dsdx, dtdy - -/* - * Textured rectangles are 128 bits not 64 bits - */ -typedef struct { - unsigned long w0; - unsigned long w1; - unsigned long w2; - unsigned long w3; -} TexRect; - -/* - * Generic Gfx Packet - */ -typedef struct { - unsigned int w0; - unsigned int w1; -} Gwords; - -/* - * This union is the fundamental type of the display list. - * It is, by law, exactly 64 bits in size. - */ -typedef union { - Gwords words; - Gdma dma; - Gtri tri; - Gline3D line; - Gpopmtx popmtx; - Gsegment segment; - GsetothermodeH setothermodeH; - GsetothermodeL setothermodeL; - Gtexture texture; - Gperspnorm perspnorm; - Gsetimg setimg; - Gsetcombine setcombine; - Gsetcolor setcolor; - Gfillrect fillrect; /* use for setscissor also */ - Gsettile settile; - Gloadtile loadtile; /* use for loadblock also, th is dxt */ - Gsettilesize settilesize; - Gloadtlut loadtlut; - long long int force_structure_alignment; -} Gfx; - -/* - * Macros to assemble the graphics display list - */ - -/* - * DMA macros - */ -#define gDma0p(pkt, c, s, l) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24); \ - _g->words.w1 = (unsigned int)(s); \ -} - -#define gsDma0p(c, s, l) \ -{ \ - _SHIFTL((c), 24, 8) | _SHIFTL((l), 0, 24), (unsigned int)(s) \ -} - -#define gDma1p(pkt, c, s, l, p) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)); \ - _g->words.w1 = (unsigned int)(s); \ -} - -#define gsDma1p(c, s, l, p) \ -{ \ - (_SHIFTL((c), 24, 8) | _SHIFTL((p), 16, 8) | \ - _SHIFTL((l), 0, 16)), \ - (unsigned int)(s) \ -} - -#define gDma2p(pkt, c, adrs, len, idx, ofs) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ - _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)); \ - _g->words.w1 = (unsigned int)(adrs); \ -} -#define gsDma2p(c, adrs, len, idx, ofs) \ -{ \ - (_SHIFTL((c),24,8)|_SHIFTL((ofs)/8,16,8)| \ - _SHIFTL(((len)-1)/8,8,8)|_SHIFTL((idx),0,8)), \ - (unsigned int)(adrs) \ -} - -#define gSPNoOp(pkt) gDma0p(pkt, G_SPNOOP, 0, 0) -#define gsSPNoOp() gsDma0p(G_SPNOOP, 0, 0) - -#ifdef F3DEX_GBI_2x -# define gSPMatrix(pkt, m, p) \ - gDma2p((pkt),G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) -# define gsSPMatrix(m, p) \ - gsDma2p( G_MTX,(m),sizeof(Mtx),(p)^G_MTX_PUSH,0) -#else /* F3DEX_GBI_2 */ -# define gSPMatrix(pkt, m, p) gDma1p(pkt, G_MTX, m, sizeof(Mtx), p) -# define gsSPMatrix(m, p) gsDma1p(G_MTX, m, sizeof(Mtx), p) -#endif /* F3DEX_GBI_2 */ - -/* - * F3DEX_GBI: G_VTX GBI format was changed to support 64 vertice. - * - * +--------+--------+------+---------------+ - * G_VTX | cmd:8 | v0:8 | n:6 | length:10 | - * +-+---+--+--------+------+---------------+ - * | |seg| address | - * +-+---+----------------------------------+ - */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define gSPVertex(pkt, v, n, v0) \ - gDma1p(pkt, G_VTX, v, ((n)<<10)|(sizeof(Vtx)*(n)-1), (v0)*2) -# define gsSPVertex(v, n, v0) \ - gsDma1p(G_VTX, v, ((n)<<10)|(sizeof(Vtx)*(n)-1), (v0)*2) -#else -# define gSPVertex(pkt, v, n, v0) \ - gDma1p(pkt, G_VTX, v, sizeof(Vtx)*(n),((n)-1)<<4|(v0)) -# define gsSPVertex(v, n, v0) \ - gsDma1p(G_VTX, v, sizeof(Vtx)*(n), ((n)-1)<<4|(v0)) -#endif - - -#ifdef F3DEX_GBI_2x -# define gSPViewport(pkt, v) gDma2p(pkt,G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) -# define gsSPViewport(v) gsDma2p( G_MOVEMEM,v,sizeof(Vp),G_MV_VIEWPORT,0) -#else /* F3DEX_GBI_2 */ -# define gSPViewport(pkt,v) gDma1p(pkt,G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) -# define gsSPViewport(v) gsDma1p( G_MOVEMEM,(v),sizeof(Vp),G_MV_VIEWPORT) -#endif /* F3DEX_GBI_2 */ - -#define gSPDisplayList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_PUSH) -#define gsSPDisplayList( dl) gsDma1p( G_DL,dl,0,G_DL_PUSH) - -#define gSPBranchList(pkt,dl) gDma1p(pkt,G_DL,dl,0,G_DL_NOPUSH) -#define gsSPBranchList( dl) gsDma1p( G_DL,dl,0,G_DL_NOPUSH) - -#define gSPSprite2DBase(pkt, s) gDma1p(pkt, G_SPRITE2D_BASE, s, sizeof(uSprite), 0) -#define gsSPSprite2DBase(s) gsDma1p(G_SPRITE2D_BASE, s, sizeof(uSprite), 0) - -/* - * RSP short command (no DMA required) macros - */ -#define gImmp0(pkt, c) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ -} - -#define gsImmp0(c) \ -{ \ - _SHIFTL((c), 24, 8) \ -} - -#define gImmp1(pkt, c, p0) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = (unsigned int)(p0); \ -} - -#define gsImmp1(c, p0) \ -{ \ - _SHIFTL((c), 24, 8), (unsigned int)(p0) \ -} - -#define gImmp2(pkt, c, p0, p1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8); \ -} - -#define gsImmp2(c, p0, p1) \ -{ \ - _SHIFTL((c), 24, 8), _SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8)\ -} - -#define gImmp3(pkt, c, p0, p1, p2) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL((c), 24, 8); \ - _g->words.w1 = (_SHIFTL((p0), 16, 16) | _SHIFTL((p1), 8, 8) | \ - _SHIFTL((p2), 0, 8)); \ -} - -#define gsImmp3(c, p0, p1, p2) \ -{ \ - _SHIFTL((c), 24, 8), (_SHIFTL((p0), 16, 16) | \ - _SHIFTL((p1), 8, 8) | _SHIFTL((p2), 0, 8))\ -} - -#define gImmp21(pkt, c, p0, p1, dat) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | \ - _SHIFTL((p1), 0, 8)); \ - _g->words.w1 = (unsigned int) (dat); \ -} - -#define gsImmp21(c, p0, p1, dat) \ -{ \ - _SHIFTL((c), 24, 8) | _SHIFTL((p0), 8, 16) | _SHIFTL((p1), 0, 8),\ - (unsigned int) (dat) \ -} - -#ifdef F3DEX_GBI_2x -#define gMoveWd(pkt, index, offset, data) \ - gDma1p((pkt), G_MOVEWORD, data, offset, index) -#define gsMoveWd( index, offset, data) \ - gsDma1p( G_MOVEWORD, data, offset, index) -#else /* F3DEX_GBI_2 */ -#define gMoveWd(pkt, index, offset, data) \ - gImmp21((pkt), G_MOVEWORD, offset, index, data) -#define gsMoveWd( index, offset, data) \ - gsImmp21( G_MOVEWORD, offset, index, data) -#endif /* F3DEX_GBI_2 */ - -/* Sprite immediate macros, there is also a sprite dma macro above */ - -#define gSPSprite2DScaleFlip(pkt, sx, sy, fx, fy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ - _SHIFTL((fx), 8, 8) | \ - _SHIFTL((fy), 0, 8)); \ - _g->words.w1 = (_SHIFTL((sx), 16, 16) | \ - _SHIFTL((sy), 0, 16)); \ -} - -#define gsSPSprite2DScaleFlip(sx, sy, fx, fy) \ -{ \ - (_SHIFTL(G_SPRITE2D_SCALEFLIP, 24, 8) | \ - _SHIFTL((fx), 8, 8) | \ - _SHIFTL((fy), 0, 8)), \ - (_SHIFTL((sx), 16, 16) | \ - _SHIFTL((sy), 0, 16)) \ -} - -#define gSPSprite2DDraw(pkt, px, py) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)); \ - _g->words.w1 = (_SHIFTL((px), 16, 16) | \ - _SHIFTL((py), 0, 16)); \ -} - -#define gsSPSprite2DDraw(px, py) \ -{ \ - (_SHIFTL(G_SPRITE2D_DRAW, 24, 8)), \ - (_SHIFTL((px), 16, 16) | \ - _SHIFTL((py), 0, 16)) \ -} - - -/* - * Note: the SP1Triangle() and line macros multiply the vertex indices - * by 10, this is an optimization for the microcode. - */ -#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) -# define __gsSP1Triangle_w1(v0, v1, v2) \ - (_SHIFTL((v0)*2,16,8)|_SHIFTL((v1)*2,8,8)|_SHIFTL((v2)*2,0,8)) -# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v0): \ - __gsSP1Triangle_w1(v2, v0, v1)) -# define __gsSPLine3D_w1(v0, v1, wd) \ - (_SHIFTL((v0)*2,16,8)|_SHIFTL((v1)*2,8,8)|_SHIFTL((wd),0,8)) -# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ - (((flag) == 0) ? __gsSPLine3D_w1(v0, v1, wd): \ - __gsSPLine3D_w1(v1, v0, wd)) -#else -# define __gsSP1Triangle_w1f(v0, v1, v2, flag) \ - (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ - _SHIFTL((v1)*10, 8,8)|_SHIFTL((v2)*10, 0,8)) -# define __gsSPLine3D_w1f(v0, v1, wd, flag) \ - (_SHIFTL((flag), 24,8)|_SHIFTL((v0)*10,16,8)| \ - _SHIFTL((v1)*10, 8,8)|_SHIFTL((wd), 0,8)) -#endif - -/*** - *** 1 Triangle - ***/ -#define gSP1Triangle(pkt, v0, v1, v2, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_TRI1, 24, 8); \ - _g->words.w1 = __gsSP1Triangle_w1f(v0, v1, v2, flag); \ -} - -#define gsSP1Triangle(v0, v1, v2, flag) \ -{ \ - _SHIFTL(G_TRI1, 24, 8), \ - __gsSP1Triangle_w1f(v0, v1, v2, flag) \ -} - -/*** - *** Line - ***/ -#define gSPLine3D(pkt, v0, v1, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ - _g->words.w1 = __gsSPLine3D_w1f(v0, v1, 0, flag); \ -} - -#define gsSPLine3D(v0, v1, flag) \ -{ \ - _SHIFTL(G_LINE3D, 24, 8), \ - __gsSPLine3D_w1f(v0, v1, 0, flag) \ -} - -/*** - *** LineW - ***/ -/* these macros are the same as SPLine3D, except they have an - * additional parameter for width. The width is added to the "minimum" - * thickness, which is 1.5 pixels. The units for width are in - * half-pixel units, so a width of 1 translates to (.5 + 1.5) or - * a 2.0 pixels wide line. - */ -#define gSPLineW3D(pkt, v0, v1, wd, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_LINE3D, 24, 8); \ - _g->words.w1 = __gsSPLine3D_w1f(v0, v1, wd, flag); \ -} - -#define gsSPLineW3D(v0, v1, wd, flag) \ -{ \ - _SHIFTL(G_LINE3D, 24, 8), \ - __gsSPLine3D_w1f(v0, v1, wd, flag) \ -} - -#if (defined(F3DLP_GBI)||defined(F3DEX_GBI)) -/*** - *** 2 Triangles - ***/ -#define gSP2Triangles(pkt, v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Triangle_w1f(v00, v01, v02, flag0)); \ - _g->words.w1 = __gsSP1Triangle_w1f(v10, v11, v12, flag1); \ -} - -#define gsSP2Triangles(v00, v01, v02, flag0, v10, v11, v12, flag1) \ -{ \ - (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Triangle_w1f(v00, v01, v02, flag0)), \ - __gsSP1Triangle_w1f(v10, v11, v12, flag1) \ -} - -/*** - *** 1 Quadrangle - ***/ -#define __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v1, v2): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v2, v3): \ - ((flag) == 2) ? __gsSP1Triangle_w1(v2, v3, v0): \ - __gsSP1Triangle_w1(v3, v0, v1)) - -#define __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ - (((flag) == 0) ? __gsSP1Triangle_w1(v0, v2, v3): \ - ((flag) == 1) ? __gsSP1Triangle_w1(v1, v3, v0): \ - ((flag) == 2) ? __gsSP1Triangle_w1(v2, v0, v1): \ - __gsSP1Triangle_w1(v3, v1, v2)) - -#define gSP1Quadrangle(pkt, v0, v1, v2, v3, flag) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)); \ - _g->words.w1 = __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag); \ -} - -#define gsSP1Quadrangle(v0, v1, v2, v3, flag) \ -{ \ - (_SHIFTL(G_TRI2, 24, 8)| \ - __gsSP1Quadrangle_w1f(v0, v1, v2, v3, flag)), \ - __gsSP1Quadrangle_w2f(v0, v1, v2, v3, flag) \ -} -#endif /* F3DEX_GBI/F3DLP_GBI */ - -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -#define gSPCullDisplayList(pkt,vstart,vend) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ - _SHIFTL((vstart)*2, 0, 16); \ - _g->words.w1 = _SHIFTL((vend)*2, 0, 16); \ -} - -#define gsSPCullDisplayList(vstart,vend) \ -{ \ - _SHIFTL(G_CULLDL, 24, 8) | _SHIFTL((vstart)*2, 0, 16), \ - _SHIFTL((vend)*2, 0, 16) \ -} - -#else -#define gSPCullDisplayList(pkt,vstart,vend) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CULLDL, 24, 8) | \ - ((0x0f & (vstart))*40); \ - _g->words.w1 = (unsigned int)((0x0f & ((vend)+1))*40); \ -} - -#define gsSPCullDisplayList(vstart,vend) \ -{ \ - _SHIFTL(G_CULLDL, 24, 8) | ((0x0f & (vstart))*40), \ - ((0x0f & ((vend)+1))*40) \ -} -#endif - -#define gSPSegment(pkt, segment, base) \ - gMoveWd(pkt, G_MW_SEGMENT, (segment)*4, base) -#define gsSPSegment(segment, base) \ - gsMoveWd( G_MW_SEGMENT, (segment)*4, base) - -/* - * Clipping Macros - */ -#define FR_NEG_FRUSTRATIO_1 0x00000001 -#define FR_POS_FRUSTRATIO_1 0x0000ffff -#define FR_NEG_FRUSTRATIO_2 0x00000002 -#define FR_POS_FRUSTRATIO_2 0x0000fffe -#define FR_NEG_FRUSTRATIO_3 0x00000003 -#define FR_POS_FRUSTRATIO_3 0x0000fffd -#define FR_NEG_FRUSTRATIO_4 0x00000004 -#define FR_POS_FRUSTRATIO_4 0x0000fffc -#define FR_NEG_FRUSTRATIO_5 0x00000005 -#define FR_POS_FRUSTRATIO_5 0x0000fffb -#define FR_NEG_FRUSTRATIO_6 0x00000006 -#define FR_POS_FRUSTRATIO_6 0x0000fffa -/* - * r should be one of: FRUSTRATIO_1, FRUSTRATIO_2, FRUSTRATIO_3, ... FRUSTRATIO_6 - */ -#define gSPClipRatio(pkt, r) \ -{ \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r); \ - gMoveWd(pkt, G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r); \ -} - -#define gsSPClipRatio(r) \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNX, FR_NEG_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RNY, FR_NEG_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPX, FR_POS_##r), \ - gsMoveWd(G_MW_CLIP, G_MWO_CLIP_RPY, FR_POS_##r) - -/* - * Insert values into Matrix - * - * where = element of matrix (byte offset) - * num = new element (32 bit value replacing 2 int or 2 frac matrix - * componants - */ -#ifdef F3DEX_GBI_2x -ERROR!! gSPInsertMatrix is no longer supported. -#else -#define gSPInsertMatrix(pkt, where, num) \ - gMoveWd(pkt, G_MW_MATRIX, where, num) -#define gsSPInsertMatrix(where, num) \ - gsMoveWd(G_MW_MATRIX, where, num) -#endif - -/* - * Load new matrix directly - * - * mptr = pointer to matrix - */ -#ifdef F3DEX_GBI_2x -#define gSPForceMatrix(pkt, mptr) \ -{ gDma2p((pkt),G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0); \ - gMoveWd((pkt), G_MW_FORCEMTX,0,0x00010000); \ -} -#define gsSPForceMatrix(mptr) \ - gsDma2p(G_MOVEMEM,(mptr),sizeof(Mtx),G_MV_MATRIX,0), \ - gsMoveWd(G_MW_FORCEMTX,0,0x00010000) - -#else /* F3DEX_GBI_2 */ -#define gSPForceMatrix(pkt, mptr) \ -{ \ - gDma1p(pkt, G_MOVEMEM, mptr, 16, G_MV_MATRIX_1); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3); \ - gDma1p(pkt, G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4); \ -} -#define gsSPForceMatrix(mptr) \ - gsDma1p( G_MOVEMEM, mptr, 16, G_MV_MATRIX_1), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+16, 16, G_MV_MATRIX_2), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+32, 16, G_MV_MATRIX_3), \ - gsDma1p( G_MOVEMEM, (char *)(mptr)+48, 16, G_MV_MATRIX_4) -#endif /* F3DEX_GBI_2 */ - -/* - * Insert values into Points - * - * point = point number 0-15 - * where = which element of point to modify (byte offset into point) - * num = new value (32 bit) - */ -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -# define gSPModifyVertex(pkt, vtx, where, val) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_MODIFYVTX,24,8)| \ - _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16)); \ - _g->words.w1 = (unsigned int)(val); \ -} -# define gsSPModifyVertex(vtx, where, val) \ -{ \ - _SHIFTL(G_MODIFYVTX,24,8)| \ - _SHIFTL((where),16,8)|_SHIFTL((vtx)*2,0,16), \ - (unsigned int)(val) \ -} -#else -# define gSPModifyVertex(pkt, vtx, where, val) \ - gMoveWd(pkt, G_MW_POINTS, (vtx)*40+(where), val) -# define gsSPModifyVertex(vtx, where, val) \ - gsMoveWd(G_MW_POINTS, (vtx)*40+(where), val) -#endif - -#if (defined(F3DEX_GBI)||defined(F3DLP_GBI)) -/* - * gSPBranchLessZ Branch DL if (vtx.z) less than or equal (zval). - * - * dl = DL branch to - * vtx = Vertex - * zval = Screen depth - * near = Near plane - * far = Far plane - * flag = G_BZ_PERSP or G_BZ_ORTHO - */ - -#define G_BZ_PERSP 0 -#define G_BZ_ORTHO 1 - -#define G_DEPTOZSrg(zval, near, far, flag, zmin, zmax) \ -(((unsigned int)FTOFIX32(((flag) == G_BZ_PERSP ? \ - (1.0f-(float)(near)/(float)(zval)) / \ - (1.0f-(float)(near)/(float)(far )) : \ - ((float)(zval) - (float)(near)) / \ - ((float)(far ) - (float)(near))))) * \ - (((int)((zmax) - (zmin)))&~1) + (int)FTOFIX32(zmin)) - -#define G_DEPTOZS(zval, near, far, flag) \ - G_DEPTOZSrg(zval, near, far, flag, 0, G_MAXZ) - -#define gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, zmin, zmax) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (unsigned int)(dl); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ - _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ - _g->words.w1 = G_DEPTOZSrg(zval, near, far, flag, zmin, zmax); \ -} - -#define gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, zmin, zmax) \ -{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(dl), }, \ -{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - G_DEPTOZSrg(zval, near, far, flag, zmin, zmax), } - -#define gSPBranchLessZ(pkt, dl, vtx, zval, near, far, flag) \ - gSPBranchLessZrg(pkt, dl, vtx, zval, near, far, flag, 0, G_MAXZ) -#define gsSPBranchLessZ(dl, vtx, zval, near, far, flag) \ - gsSPBranchLessZrg(dl, vtx, zval, near, far, flag, 0, G_MAXZ) - -/* - * gSPBranchLessZraw Branch DL if (vtx.z) less than or equal (raw zval). - * - * dl = DL branch to - * vtx = Vertex - * zval = Raw value of screen depth - */ -#define gSPBranchLessZraw(pkt, dl, vtx, zval) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (unsigned int)(dl); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_BRANCH_Z,24,8)| \ - _SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12)); \ - _g->words.w1 = (unsigned int)(zval); \ -} - -#define gsSPBranchLessZraw(dl, vtx, zval) \ -{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(dl), }, \ -{ _SHIFTL(G_BRANCH_Z,24,8)|_SHIFTL((vtx)*5,12,12)|_SHIFTL((vtx)*2,0,12),\ - (unsigned int)(zval), } - -/* - * gSPLoadUcode RSP loads specified ucode. - * - * uc_start = ucode text section start - * uc_dstart = ucode data section start - */ -#define gSPLoadUcodeEx(pkt, uc_start, uc_dstart, uc_dsize) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_RDPHALF_1,24,8); \ - _g->words.w1 = (unsigned int)(uc_dstart); \ - _g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(G_LOAD_UCODE,24,8)| \ - _SHIFTL((int)(uc_dsize)-1,0,16)); \ - _g->words.w1 = (unsigned int)(uc_start); \ -} - -#define gsSPLoadUcodeEx(uc_start, uc_dstart, uc_dsize) \ -{ _SHIFTL(G_RDPHALF_1,24,8), \ - (unsigned int)(uc_dstart), }, \ -{ _SHIFTL(G_LOAD_UCODE,24,8)| \ - _SHIFTL((int)(uc_dsize)-1,0,16), \ - (unsigned int)(uc_start), } - -#define gSPLoadUcode(pkt, uc_start, uc_dstart) \ - gSPLoadUcodeEx((pkt), (uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) -#define gsSPLoadUcode(uc_start, uc_dstart) \ - gsSPLoadUcodeEx((uc_start), (uc_dstart), SP_UCODE_DATA_SIZE) - -#define gSPLoadUcodeL(pkt, ucode) \ - gSPLoadUcode((pkt), OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) -#define gsSPLoadUcodeL(ucode) \ - gsSPLoadUcode(OS_K0_TO_PHYSICAL(&##ucode##TextStart), \ - OS_K0_TO_PHYSICAL(&##ucode##DataStart)) -#endif - -/* - * Lighting Macros - */ -#ifdef F3DEX_GBI_2x -# define NUML(n) ((n)*24) -#else -# define NUML(n) (((n)+1)*32 + 0x80000000) -#endif -#define NUMLIGHTS_0 1 -#define NUMLIGHTS_1 1 -#define NUMLIGHTS_2 2 -#define NUMLIGHTS_3 3 -#define NUMLIGHTS_4 4 -#define NUMLIGHTS_5 5 -#define NUMLIGHTS_6 6 -#define NUMLIGHTS_7 7 -/* - * n should be one of: NUMLIGHTS_0, NUMLIGHTS_1, ..., NUMLIGHTS_7 - * NOTE: in addition to the number of directional lights specified, - * there is always 1 ambient light - */ -#define gSPNumLights(pkt, n) \ - gMoveWd(pkt, G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) -#define gsSPNumLights(n) \ - gsMoveWd( G_MW_NUMLIGHT, G_MWO_NUMLIGHT, NUML(n)) - -#define LIGHT_1 1 -#define LIGHT_2 2 -#define LIGHT_3 3 -#define LIGHT_4 4 -#define LIGHT_5 5 -#define LIGHT_6 6 -#define LIGHT_7 7 -#define LIGHT_8 8 -/* - * l should point to a Light struct - * n should be one of: LIGHT_1, LIGHT_2, ..., LIGHT_8 - * NOTE: the highest numbered light is always the ambient light (eg if there are - * 3 directional lights defined: gsSPNumLights(NUMLIGHTS_3), then lights - * LIGHT_1 through LIGHT_3 will be the directional lights and light - * LIGHT_4 will be the ambient light. - */ -#ifdef F3DEX_GBI_2x -# define gSPLight(pkt, l, n) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) -# define gsSPLight(l, n) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LIGHT,(n)*3+3) -#else /* F3DEX_GBI_2 */ -# define gSPLight(pkt, l, n) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) -# define gsSPLight(l, n) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),((n)-1)*2+G_MV_L0) -#endif /* F3DEX_GBI_2 */ - -/* - * gSPLightColor changes color of light without recalculating light direction - * col is a 32 bit word with r,g,b,a (alpha is ignored) - * n should be one of LIGHT_1, LIGHT_2, ..., LIGHT_8 - */ -#define gSPLightColor(pkt, n, col) \ -{ \ - gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_a##n, col); \ - gMoveWd(pkt, G_MW_LIGHTCOL, G_MWO_b##n, col); \ -} -#define gsSPLightColor(n, col) \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_a##n, col), \ - gsMoveWd(G_MW_LIGHTCOL, G_MWO_b##n, col) - -/* These macros use a structure "name" which is init'd with the gdSPDefLights macros*/ - -#define gSPSetLights0(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_0); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.a,2); \ -} -#define gsSPSetLights0(name) \ - gsSPNumLights(NUMLIGHTS_0), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.a,2) - -#define gSPSetLights1(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_1); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.a,2); \ -} -#define gsSPSetLights1(name) \ - gsSPNumLights(NUMLIGHTS_1), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.a,2) - -#define gSPSetLights2(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_2); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.a,3); \ -} -#define gsSPSetLights2(name) \ - gsSPNumLights(NUMLIGHTS_2), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.a,3) - -#define gSPSetLights3(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_3); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.a,4); \ -} -#define gsSPSetLights3(name) \ - gsSPNumLights(NUMLIGHTS_3), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.a,4) - -#define gSPSetLights4(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_4); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.a,5); \ -} -#define gsSPSetLights4(name) \ - gsSPNumLights(NUMLIGHTS_4), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.a,5) - -#define gSPSetLights5(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_5); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.a,6); \ -} - -#define gsSPSetLights5(name) \ - gsSPNumLights(NUMLIGHTS_5), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.a,6) - -#define gSPSetLights6(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_6); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.l[5],6); \ - gSPLight(pkt,&name.a,7); \ -} - -#define gsSPSetLights6(name) \ - gsSPNumLights(NUMLIGHTS_6), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.l[5],6), \ - gsSPLight(&name.a,7) - -#define gSPSetLights7(pkt,name) \ -{ \ - gSPNumLights(pkt,NUMLIGHTS_7); \ - gSPLight(pkt,&name.l[0],1); \ - gSPLight(pkt,&name.l[1],2); \ - gSPLight(pkt,&name.l[2],3); \ - gSPLight(pkt,&name.l[3],4); \ - gSPLight(pkt,&name.l[4],5); \ - gSPLight(pkt,&name.l[5],6); \ - gSPLight(pkt,&name.l[6],7); \ - gSPLight(pkt,&name.a,8); \ -} - -#define gsSPSetLights7(name) \ - gsSPNumLights(NUMLIGHTS_7), \ - gsSPLight(&name.l[0],1), \ - gsSPLight(&name.l[1],2), \ - gsSPLight(&name.l[2],3), \ - gsSPLight(&name.l[3],4), \ - gsSPLight(&name.l[4],5), \ - gsSPLight(&name.l[5],6), \ - gsSPLight(&name.l[6],7), \ - gsSPLight(&name.a,8) - -/* - * Reflection/Hiliting Macros - */ -#ifdef F3DEX_GBI_2 -# define gSPLookAtX(pkt, l) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) -# define gsSPLookAtX(l) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATX,0) -# define gSPLookAtY(pkt, l) \ - gDma2p((pkt),G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) -# define gsSPLookAtY(l) \ - gsDma2p( G_MOVEMEM,(l),sizeof(Light),G_MV_LOOKATY,0) -#else /* F3DEX_GBI_2 */ -# define gSPLookAtX(pkt, l) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) -# define gsSPLookAtX(l) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATX) -# define gSPLookAtY(pkt, l) \ - gDma1p(pkt, G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) -# define gsSPLookAtY(l) \ - gsDma1p( G_MOVEMEM, l, sizeof(Light),G_MV_LOOKATY) -#endif /* F3DEX_GBI_2 */ - -#define gSPLookAt(pkt, la) \ -{ \ - gSPLookAtX(pkt,la) \ - gSPLookAtY(pkt,(char *)(la)+16) \ -} -#define gsSPLookAt(la) \ - gsSPLookAtX(la), \ - gsSPLookAtY((char *)(la)+16) - -#define gDPSetHilite1Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) -#define gsDPSetHilite1Tile(tile, hilite, width, height) \ - gsDPSetTileSize(tile, (hilite)->h.x1 & 0xfff, (hilite)->h.y1 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x1) & 0xfff, ((((height)-1)*4)+(hilite)->h.y1) & 0xfff) - -#define gDPSetHilite2Tile(pkt, tile, hilite, width, height) \ - gDPSetTileSize(pkt, tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) -#define gsDPSetHilite2Tile(tile, hilite, width, height) \ - gsDPSetTileSize(tile, (hilite)->h.x2 & 0xfff, (hilite)->h.y2 & 0xfff, \ - ((((width)-1)*4)+(hilite)->h.x2) & 0xfff, ((((height)-1)*4)+(hilite)->h.y2) & 0xfff) - -/* - * FOG macros - * fm = z multiplier - * fo = z offset - * FOG FORMULA: alpha(fog) = (eyespace z) * fm + fo CLAMPED 0 to 255 - * note: (eyespace z) ranges -1 to 1 - * - * Alternate method of setting fog: - * min, max: range 0 to 1000: 0=nearplane, 1000=farplane - * min is where fog begins (usually less than max and often 0) - * max is where fog is thickest (usually 1000) - * - */ -#define gSPFogFactor(pkt, fm, fo) \ - gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) - -#define gsSPFogFactor(fm, fo) \ - gsMoveWd(G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL(fm,16,16) | _SHIFTL(fo,0,16))) - -#define gSPFogPosition(pkt, min, max) \ - gMoveWd(pkt, G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/((max)-(min))),16,16) | \ - _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) - -#define gsSPFogPosition(min, max) \ - gsMoveWd(G_MW_FOG, G_MWO_FOG, \ - (_SHIFTL((128000/((max)-(min))),16,16) | \ - _SHIFTL(((500-(min))*256/((max)-(min))),0,16))) - -/* - * Macros to turn texture on/off - */ -#define gSPTexture(pkt, s, t, level, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | \ - _SHIFTL(BOWTIE_VAL, 16, 8) | \ - _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | \ - _SHIFTL(on, 0, 8)); \ - _g->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ -} - -#define gsSPTexture(s, t, level, tile, on) \ -{ \ - (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(BOWTIE_VAL, 16, 8) | \ - _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | _SHIFTL(on, 0, 8)),\ - (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)) \ -} - -/* - * Different version of SPTexture macro, has an additional parameter - * which is currently reserved in the microcode. - */ -#define gSPTextureL(pkt, s, t, level, xparam, tile, on) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXTURE, 24, 8) | \ - _SHIFTL(xparam, 16, 8) | \ - _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | \ - _SHIFTL(on, 0, 8)); \ - _g->words.w1 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ -} - -#define gsSPTextureL(s, t, level, xparam, tile, on) \ -{ \ - (_SHIFTL(G_TEXTURE, 24, 8) | _SHIFTL(xparam, 16, 8) | \ - _SHIFTL(level, 11, 3) | _SHIFTL(tile, 8, 3) | _SHIFTL(on, 0, 8)),\ - (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)) \ -} - - -#define gSPPerspNormalize(pkt, s) \ - gMoveWd(pkt, G_MW_PERSPNORM, 0, (s)) -#define gsSPPerspNormalize(s) \ - gsMoveWd( G_MW_PERSPNORM, 0, (s)) - -#ifdef F3DEX_GBI_2x -# define gSPPopMatrixN(pkt, n, num) gDma2p((pkt),G_POPMTX,(num)*64,64,2,0) -# define gsSPPopMatrixN(n, num) gsDma2p( G_POPMTX,(num)*64,64,2,0) -# define gSPPopMatrix(pkt, n) gSPPopMatrixN((pkt), (n), 1) -# define gsSPPopMatrix(n) gsSPPopMatrixN( (n), 1) -#else /* F3DEX_GBI_2 */ -# define gSPPopMatrix(pkt, n) gImmp1(pkt, G_POPMTX, n) -# define gsSPPopMatrix(n) gsImmp1( G_POPMTX, n) -#endif /* F3DEX_GBI_2 */ - -#define gSPEndDisplayList(pkt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_ENDDL, 24, 8); \ - _g->words.w1 = 0; \ -} - -#define gsSPEndDisplayList() \ -{ \ - _SHIFTL(G_ENDDL, 24, 8), 0 \ -} - -#ifdef F3DEX_GBI_2x -/* - * One gSPGeometryMode(pkt,c,s) GBI is equal to these two GBIs. - * - * gSPClearGeometryMode(pkt,c) - * gSPSetGeometryMode(pkt,s) - * - * gSPLoadGeometryMode(pkt, word) sets GeometryMode directly. - */ -#define gSPGeometryMode(pkt, c, s) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = _SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24);\ - _g->words.w1 = (u32)(s); \ -} - -#define gsSPGeometryMode(c, s) \ -{ \ - (_SHIFTL(G_GEOMETRYMODE,24,8)|_SHIFTL(~(u32)(c),0,24)),(u32)(s) \ -} -#define gSPSetGeometryMode(pkt, word) gSPGeometryMode((pkt),0,(word)) -#define gsSPSetGeometryMode(word) gsSPGeometryMode(0,(word)) -#define gSPClearGeometryMode(pkt, word) gSPGeometryMode((pkt),(word),0) -#define gsSPClearGeometryMode(word) gsSPGeometryMode((word),0) -#define gSPLoadGeometryMode(pkt, word) gSPGeometryMode((pkt),-1,(word)) -#define gsSPLoadGeometryMode(pkt, word) gsSPGeometryMode(-1,(word)) - -#else /* F3DEX_GBI_2 */ -#define gSPSetGeometryMode(pkt, word) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETGEOMETRYMODE, 24, 8); \ - _g->words.w1 = (unsigned int)(word); \ -} - -#define gsSPSetGeometryMode(word) \ -{ \ - _SHIFTL(G_SETGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -} - -#define gSPClearGeometryMode(pkt, word) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8); \ - _g->words.w1 = (unsigned int)(word); \ -} - -#define gsSPClearGeometryMode(word) \ -{ \ - _SHIFTL(G_CLEARGEOMETRYMODE, 24, 8), (unsigned int)(word) \ -} -#endif /* F3DEX_GBI_2 */ - -#ifdef F3DEX_GBI_2x -#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - _g->words.w0 = (_SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)| \ - _SHIFTL((len)-1,0,8)); \ - _g->words.w1 = (unsigned int)(data); \ -} - -#define gsSPSetOtherMode(cmd, sft, len, data) \ -{ \ - _SHIFTL(cmd,24,8)|_SHIFTL(32-(sft)-(len),8,8)|_SHIFTL((len)-1,0,8), \ - (unsigned int)(data) \ -} -#else -#define gSPSetOtherMode(pkt, cmd, sft, len, data) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | \ - _SHIFTL(len, 0, 8)); \ - _g->words.w1 = (unsigned int)(data); \ -} - -#define gsSPSetOtherMode(cmd, sft, len, data) \ -{ \ - _SHIFTL(cmd, 24, 8) | _SHIFTL(sft, 8, 8) | _SHIFTL(len, 0, 8), \ - (unsigned int)(data) \ -} -#endif - -/* - * RDP setothermode register commands - register shadowed in RSP - */ -#define gDPPipelineMode(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) -#define gsDPPipelineMode(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_PIPELINE, 1, mode) - -#define gDPSetCycleType(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) -#define gsDPSetCycleType(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_CYCLETYPE, 2, type) - -#define gDPSetTexturePersp(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) -#define gsDPSetTexturePersp(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTPERSP, 1, type) - -#define gDPSetTextureDetail(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) -#define gsDPSetTextureDetail(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTDETAIL, 2, type) - -#define gDPSetTextureLOD(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) -#define gsDPSetTextureLOD(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLOD, 1, type) - -#define gDPSetTextureLUT(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) -#define gsDPSetTextureLUT(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTLUT, 2, type) - -#define gDPSetTextureFilter(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) -#define gsDPSetTextureFilter(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTFILT, 2, type) - -#define gDPSetTextureConvert(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) -#define gsDPSetTextureConvert(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_TEXTCONV, 3, type) - -#define gDPSetCombineKey(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) -#define gsDPSetCombineKey(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COMBKEY, 1, type) - -#ifndef _HW_VERSION_1 -#define gDPSetColorDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) -#define gsDPSetColorDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_RGBDITHER, 2, mode) -#else -#define gDPSetColorDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) -#define gsDPSetColorDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_COLORDITHER, 1, mode) -#endif - -#ifndef _HW_VERSION_1 -#define gDPSetAlphaDither(pkt, mode) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) -#define gsDPSetAlphaDither(mode) \ - gsSPSetOtherMode(G_SETOTHERMODE_H, G_MDSFT_ALPHADITHER, 2, mode) -#endif - -/* 'blendmask' is not supported anymore. - * The bits are reserved for future use. - * Fri May 26 13:45:55 PDT 1995 - */ -#define gDPSetBlendMask(pkt, mask) gDPNoOp(pkt) -#define gsDPSetBlendMask(mask) gsDPNoOp() - -#define gDPSetAlphaCompare(pkt, type) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) -#define gsDPSetAlphaCompare(type) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ALPHACOMPARE, 2, type) - -#define gDPSetDepthSource(pkt, src) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) -#define gsDPSetDepthSource(src) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_ZSRCSEL, 1, src) - -#define gDPSetRenderMode(pkt, c0, c1) \ - gSPSetOtherMode(pkt, G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ - (c0) | (c1)) -#define gsDPSetRenderMode(c0, c1) \ - gsSPSetOtherMode(G_SETOTHERMODE_L, G_MDSFT_RENDERMODE, 29, \ - (c0) | (c1)) - -#define gSetImage(pkt, cmd, fmt, siz, width, i) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12); \ - _g->words.w1 = (unsigned int)(i); \ -} - -#define gsSetImage(cmd, fmt, siz, width, i) \ -{ \ - _SHIFTL(cmd, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL((width)-1, 0, 12), \ - (unsigned int)(i) \ -} - -#define gDPSetColorImage(pkt, f, s, w, i) gSetImage(pkt, G_SETCIMG, f, s, w, i) -#define gsDPSetColorImage(f, s, w, i) gsSetImage(G_SETCIMG, f, s, w, i) - - -/* use these for new code */ -#define gDPSetDepthImage(pkt, i) gSetImage(pkt, G_SETZIMG, 0, 0, 1, i) -#define gsDPSetDepthImage(i) gsSetImage(G_SETZIMG, 0, 0, 1, i) -/* kept for compatibility */ -#define gDPSetMaskImage(pkt, i) gDPSetDepthImage(pkt, i) -#define gsDPSetMaskImage(i) gsDPSetDepthImage(i) - -#define gDPSetTextureImage(pkt, f, s, w, i) gSetImage(pkt, G_SETTIMG, f, s, w, i) -#define gsDPSetTextureImage(f, s, w, i) gsSetImage(G_SETTIMG, f, s, w, i) - -/* - * RDP macros - */ - -#define gDPSetCombine(pkt, muxs0, muxs1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24);\ - _g->words.w1 = (unsigned int)(muxs1); \ -} - -#define gsDPSetCombine(muxs0, muxs1) \ -{ \ - _SHIFTL(G_SETCOMBINE, 24, 8) | _SHIFTL(muxs0, 0, 24), \ - (unsigned int)(muxs1) \ -} - -#define GCCc0w0(saRGB0, mRGB0, saA0, mA0) \ - (_SHIFTL((saRGB0), 20, 4) | _SHIFTL((mRGB0), 15, 5) | \ - _SHIFTL((saA0), 12, 3) | _SHIFTL((mA0), 9, 3)) - -#define GCCc1w0(saRGB1, mRGB1) \ - (_SHIFTL((saRGB1), 5, 4) | _SHIFTL((mRGB1), 0, 5)) - -#define GCCc0w1(sbRGB0, aRGB0, sbA0, aA0) \ - (_SHIFTL((sbRGB0), 28, 4) | _SHIFTL((aRGB0), 15, 3) | \ - _SHIFTL((sbA0), 12, 3) | _SHIFTL((aA0), 9, 3)) - -#define GCCc1w1(sbRGB1, saA1, mA1, aRGB1, sbA1, aA1) \ - (_SHIFTL((sbRGB1), 24, 4) | _SHIFTL((saA1), 21, 3) | \ - _SHIFTL((mA1), 18, 3) | _SHIFTL((aRGB1), 6, 3) | \ - _SHIFTL((sbA1), 3, 3) | _SHIFTL((aA1), 0, 3)) - -#define gDPSetCombineLERP(pkt, a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETCOMBINE, 24, 8) | \ - _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ - G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ - GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), \ - 0, 24); \ - _g->words.w1 = (unsigned int)(GCCc0w1(G_CCMUX_##b0, \ - G_CCMUX_##d0, \ - G_ACMUX_##Ab0, \ - G_ACMUX_##Ad0) | \ - GCCc1w1(G_CCMUX_##b1, \ - G_ACMUX_##Aa1, \ - G_ACMUX_##Ac1, \ - G_CCMUX_##d1, \ - G_ACMUX_##Ab1, \ - G_ACMUX_##Ad1)); \ -} - -#define gsDPSetCombineLERP(a0, b0, c0, d0, Aa0, Ab0, Ac0, Ad0, \ - a1, b1, c1, d1, Aa1, Ab1, Ac1, Ad1) \ -{ \ - _SHIFTL(G_SETCOMBINE, 24, 8) | \ - _SHIFTL(GCCc0w0(G_CCMUX_##a0, G_CCMUX_##c0, \ - G_ACMUX_##Aa0, G_ACMUX_##Ac0) | \ - GCCc1w0(G_CCMUX_##a1, G_CCMUX_##c1), 0, 24), \ - (unsigned int)(GCCc0w1(G_CCMUX_##b0, G_CCMUX_##d0, \ - G_ACMUX_##Ab0, G_ACMUX_##Ad0) | \ - GCCc1w1(G_CCMUX_##b1, G_ACMUX_##Aa1, \ - G_ACMUX_##Ac1, G_CCMUX_##d1, \ - G_ACMUX_##Ab1, G_ACMUX_##Ad1)) \ -} - -/* - * SetCombineMode macros are NOT redunant. It allow the C preprocessor - * to substitute single parameter which includes commas in the token and - * rescan for higher parameter count macro substitution. - * - * eg. gsDPSetCombineMode(G_CC_MODULATE, G_CC_MODULATE) turns into - * gsDPSetCombineLERP(TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0, - * TEXEL0, 0, SHADE, 0, TEXEL0, 0, SHADE, 0) - */ - -#define gDPSetCombineMode(pkt, a, b) gDPSetCombineLERP(pkt, a, b) -#define gsDPSetCombineMode(a, b) gsDPSetCombineLERP(a, b) - -#define gDPSetColor(pkt, c, d) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(c, 24, 8); \ - _g->words.w1 = (unsigned int)(d); \ -} - -#define gsDPSetColor(c, d) \ -{ \ - _SHIFTL(c, 24, 8), (unsigned int)(d) \ -} - -#define DPRGBColor(pkt, cmd, r, g, b, a) \ - gDPSetColor(pkt, cmd, \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) -#define sDPRGBColor(cmd, r, g, b, a) \ - gsDPSetColor(cmd, \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8))) - -#define gDPSetEnvColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETENVCOLOR, r,g,b,a) -#define gsDPSetEnvColor(r, g, b, a) \ - sDPRGBColor(G_SETENVCOLOR, r,g,b,a) -#define gDPSetBlendColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETBLENDCOLOR, r,g,b,a) -#define gsDPSetBlendColor(r, g, b, a) \ - sDPRGBColor(G_SETBLENDCOLOR, r,g,b,a) -#define gDPSetFogColor(pkt, r, g, b, a) \ - DPRGBColor(pkt, G_SETFOGCOLOR, r,g,b,a) -#define gsDPSetFogColor(r, g, b, a) \ - sDPRGBColor(G_SETFOGCOLOR, r,g,b,a) -#define gDPSetFillColor(pkt, d) \ - gDPSetColor(pkt, G_SETFILLCOLOR, (d)) -#define gsDPSetFillColor(d) \ - gsDPSetColor(G_SETFILLCOLOR, (d)) - -#define gDPSetPrimDepth(pkt, z, dz) \ - gDPSetColor(pkt, G_SETPRIMDEPTH, \ - _SHIFTL(z, 16, 16) | _SHIFTL(dz, 0, 16)) -#define gsDPSetPrimDepth(z, dz) \ - gsDPSetColor(G_SETPRIMDEPTH, _SHIFTL(z, 16, 16) | \ - _SHIFTL(dz, 0, 16)) - -#define gDPSetPrimColor(pkt, m, l, r, g, b, a) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | \ - _SHIFTL(m, 8, 8) | _SHIFTL(l, 0, 8)); \ - _g->words.w1 = (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | \ - _SHIFTL(b, 8, 8) | _SHIFTL(a, 0, 8)); \ -} - -#define gsDPSetPrimColor(m, l, r, g, b, a) \ -{ \ - (_SHIFTL(G_SETPRIMCOLOR, 24, 8) | _SHIFTL(m, 8, 8) | \ - _SHIFTL(l, 0, 8)), \ - (_SHIFTL(r, 24, 8) | _SHIFTL(g, 16, 8) | _SHIFTL(b, 8, 8) | \ - _SHIFTL(a, 0, 8)) \ -} - -/* - * gDPSetOtherMode (This is for expert user.) - * - * This command makes all othermode parameters set. - * Do not use this command in the same DL with another g*SPSetOtherMode DLs. - * - * [Usage] - * gDPSetOtherMode(pkt, modeA, modeB) - * - * 'modeA' is described all parameters of GroupA GBI command. - * 'modeB' is also described all parameters of GroupB GBI command. - * - * GroupA: - * gDPPipelineMode, gDPSetCycleType, gSPSetTexturePersp, - * gDPSetTextureDetail, gDPSetTextureLOD, gDPSetTextureLUT, - * gDPSetTextureFilter, gDPSetTextureConvert, gDPSetCombineKey, - * gDPSetColorDither, gDPSetAlphaDither - * - * GroupB: - * gDPSetAlphaCompare, gDPSetDepthSource, gDPSetRenderMode - * - * Use 'OR' operation to get modeA and modeB. - * - * modeA = G_PM_* | G_CYC_* | G_TP_* | G_TD_* | G_TL_* | G_TT_* | G_TF_* - * G_TC_* | G_CK_* | G_CD_* | G_AD_*; - * - * modeB = G_AC_* | G_ZS_* | G_RM_* | G_RM_*2; - */ -#define gDPSetOtherMode(pkt, mode0, mode1) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24);\ - _g->words.w1 = (unsigned int)(mode1); \ -} - -#define gsDPSetOtherMode(mode0, mode1) \ -{ \ - _SHIFTL(G_RDPSETOTHERMODE,24,8)|_SHIFTL(mode0,0,24), \ - (unsigned int)(mode1) \ -} - -/* - * Texturing macros - */ - -/* These are also defined defined above for Sprite Microcode */ - -#define G_TX_LOADTILE 7 -#define G_TX_RENDERTILE 0 - -#define G_TX_NOMIRROR 0 -#define G_TX_WRAP 0 -#define G_TX_MIRROR 0x1 -#define G_TX_CLAMP 0x2 -#define G_TX_NOMASK 0 -#define G_TX_NOLOD 0 - - -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -/* - * Dxt is the inverse of the number of 64-bit words in a line of - * the texture being loaded using the load_block command. If - * there are any 1's to the right of the 11th fractional bit, - * dxt should be rounded up. The following macros accomplish - * this. The 4b macros are a special case since 4-bit textures - * are loaded as 8-bit textures. Dxt is fixed point 1.11. RJM - */ -#define G_TX_DXT_FRAC 11 - -/* - * For RCP 2.0, the maximum number of texels that can be loaded - * using a load_block command is 2048. In order to load the total - * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, - * then change the tile to the proper texel size after the load. - * The g*DPLoadTextureBlock macros already do this, so this change - * will be transparent if you use these macros. If you use - * the g*DPLoadBlock macros directly, you will need to handle this - * tile manipulation yourself. RJM. - */ -#ifdef _HW_VERSION_1 -#define G_TX_LDBLK_MAX_TXL 4095 -#else -#define G_TX_LDBLK_MAX_TXL 2047 -#endif /* _HW_VERSION_1 */ - -#define TXL2WORDS(txls, b_txl) MAX(1, ((txls)*(b_txl)/8)) -#define CALC_DXT(width, b_txl) \ - (((1 << G_TX_DXT_FRAC) + TXL2WORDS(width, b_txl) - 1) / \ - TXL2WORDS(width, b_txl)) - -#define TXL2WORDS_4b(txls) MAX(1, ((txls)/16)) -#define CALC_DXT_4b(width) \ - (((1 << G_TX_DXT_FRAC) + TXL2WORDS_4b(width) - 1) / \ - TXL2WORDS_4b(width)) - -#define gDPLoadTileGeneric(pkt, c, tile, uls, ult, lrs, lrt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | \ - _SHIFTL(ult, 0, 12); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | \ - _SHIFTL(lrt, 0, 12); \ -} - -#define gsDPLoadTileGeneric(c, tile, uls, ult, lrs, lrt) \ -{ \ - _SHIFTL(c, 24, 8) | _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12), \ - _SHIFTL(tile, 24, 3) | _SHIFTL(lrs, 12, 12) | _SHIFTL(lrt, 0, 12)\ -} - -#define gDPSetTileSize(pkt, t, uls, ult, lrs, lrt) \ - gDPLoadTileGeneric(pkt, G_SETTILESIZE, t, uls, ult, lrs, lrt) -#define gsDPSetTileSize(t, uls, ult, lrs, lrt) \ - gsDPLoadTileGeneric(G_SETTILESIZE, t, uls, ult, lrs, lrt) -#define gDPLoadTile(pkt, t, uls, ult, lrs, lrt) \ - gDPLoadTileGeneric(pkt, G_LOADTILE, t, uls, ult, lrs, lrt) -#define gsDPLoadTile(t, uls, ult, lrs, lrt) \ - gsDPLoadTileGeneric(G_LOADTILE, t, uls, ult, lrs, lrt) - -#define gDPSetTile(pkt, fmt, siz, line, tmem, tile, palette, cmt, \ - maskt, shiftt, cms, masks, shifts) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) |\ - _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | \ - _SHIFTL(tmem, 0, 9); \ - _g->words.w1 = _SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ - _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ - _SHIFTL(shiftt, 10, 4) |_SHIFTL(cms, 8, 2) | \ - _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4); \ -} - -#define gsDPSetTile(fmt, siz, line, tmem, tile, palette, cmt, \ - maskt, shiftt, cms, masks, shifts) \ -{ \ - (_SHIFTL(G_SETTILE, 24, 8) | _SHIFTL(fmt, 21, 3) | \ - _SHIFTL(siz, 19, 2) | _SHIFTL(line, 9, 9) | _SHIFTL(tmem, 0, 9)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(palette, 20, 4) | \ - _SHIFTL(cmt, 18, 2) | _SHIFTL(maskt, 14, 4) | \ - _SHIFTL(shiftt, 10, 4) | _SHIFTL(cms, 8, 2) | \ - _SHIFTL(masks, 4, 4) | _SHIFTL(shifts, 0, 4)) \ -} - -/* - * For RCP 2.0, the maximum number of texels that can be loaded - * using a load_block command is 2048. In order to load the total - * 4kB of Tmem, change the texel size when loading to be G_IM_SIZ_16b, - * then change the tile to the proper texel size after the load. - * The g*DPLoadTextureBlock macros already do this, so this change - * will be transparent if you use these macros. If you use - * the g*DPLoadBlock macros directly, you will need to handle this - * tile manipulation yourself. RJM. - */ -#define gDPLoadBlock(pkt, tile, uls, ult, lrs, dxt) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_LOADBLOCK, 24, 8) | \ - _SHIFTL(uls, 12, 12) | _SHIFTL(ult, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | \ - _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) |\ - _SHIFTL(dxt, 0, 12)); \ -} - -#define gsDPLoadBlock(tile, uls, ult, lrs, dxt) \ -{ \ - (_SHIFTL(G_LOADBLOCK, 24, 8) | _SHIFTL(uls, 12, 12) | \ - _SHIFTL(ult, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | \ - _SHIFTL((MIN(lrs,G_TX_LDBLK_MAX_TXL)), 12, 12) | \ - _SHIFTL(dxt, 0, 12)) \ -} - -#define gDPLoadTLUTCmd(pkt, tile, count) \ -{ \ - Gfx *_g = (Gfx *)pkt; \ - \ - _g->words.w0 = _SHIFTL(G_LOADTLUT, 24, 8); \ - _g->words.w1 = _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10);\ -} - -#define gsDPLoadTLUTCmd(tile, count) \ -{ \ - _SHIFTL(G_LOADTLUT, 24, 8), \ - _SHIFTL((tile), 24, 3) | _SHIFTL((count), 14, 10) \ -} - -#define gDPLoadTextureBlock(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gDPLoadTextureBlockYuv(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT) -1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * 1)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* Load fix rww 27jun95 */ -/* The S at the end means odd lines are already word Swapped */ - -#define gDPLoadTextureBlockS(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * Allow tmem address and render tile to be specified. - * The S at the end means odd lines are already word Swapped - */ -#define gDPLoadMultiBlockS(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * siz##_LINE_BYTES)+7)>>3, tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - - -#define gDPLoadTextureBlockYuvS(pkt, timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1,0); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, \ - (((width) * 1)+7)>>3, 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address to be specified - */ -#define _gDPLoadTextureBlock(pkt, timg, tmem, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0, cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, G_TX_RENDERTILE, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address and render tile to be specified - */ -#define _gDPLoadTextureBlockTile(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, rtile, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * allows tmem address and render tile to be specified - */ -#define gDPLoadMultiBlock(pkt, timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz##_LOAD_BLOCK, 1, timg); \ - gDPSetTile(pkt, fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0,\ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, siz, (((width) * siz##_LINE_BYTES)+7)>>3, \ - tmem, rtile, pal, cmt, \ - maskt, shiftt, cms, masks, shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gsDPLoadTextureBlock(timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* Here is the static form of the pre-swapped texture block loading */ -/* See gDPLoadTextureBlockS() for reference. Basically, just don't - calculate DxT, use 0 */ - -#define gsDPLoadTextureBlockS(timg, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, 0, G_TX_LOADTILE, 0 , \ - cmt, maskt,shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * Allow tmem address to be specified - */ -#define _gsDPLoadTextureBlock(timg, tmem, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allow tmem address and render_tile to be specified - */ -#define _gsDPLoadTextureBlockTile(timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allow tmem address and render_tile to be specified, useful when loading - * mutilple tiles at a time. - */ -#define gsDPLoadMultiBlock(timg, tmem, rtile, fmt, siz, width, \ - height, pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, \ - 0 , cmt, maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, \ - CALC_DXT(width, siz##_BYTES)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, \ - ((((width) * siz##_LINE_BYTES)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * Allows tmem and render tile to be specified. Useful when loading - * several tiles at a time. - * - * Here is the static form of the pre-swapped texture block loading - * See gDPLoadTextureBlockS() for reference. Basically, just don't - * calculate DxT, use 0 - */ - -#define gsDPLoadMultiBlockS(timg, tmem, rtile, fmt, siz, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, siz##_LOAD_BLOCK, 1, timg), \ - gsDPSetTile(fmt, siz##_LOAD_BLOCK, 0, tmem, G_TX_LOADTILE, 0 , \ - cmt, maskt,shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, \ - (((width)*(height) + siz##_INCR) >> siz##_SHIFT)-1, 0 ),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, siz, ((((width) * siz##_LINE_BYTES)+7)>>3), tmem,\ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -#define gDPLoadTextureBlock_4b(pkt, timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* Load fix rww 27jun95 */ -/* The S at the end means odd lines are already word Swapped */ - -#define gDPLoadTextureBlock_4bS(pkt, timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, 0 ); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * 4-bit load block. Useful when loading multiple tiles - */ -#define gDPLoadMultiBlock_4b(pkt, timg, tmem, rtile, fmt, width, height,\ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -/* - * 4-bit load block. Allows tmem and render tile to be specified. Useful when - * loading multiple tiles. The S means odd lines are already word swapped. - */ -#define gDPLoadMultiBlock_4bS(pkt, timg, tmem, rtile, fmt, width, height,\ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, 0 ); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - - -#define _gDPLoadTextureBlock_4b(pkt, timg, tmem, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, G_IM_SIZ_16b, 1, timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0, \ - cmt, maskt, shiftt, cms, masks, shifts); \ - gDPLoadSync(pkt); \ - gDPLoadBlock(pkt, G_TX_LOADTILE, 0, 0, \ - (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) \ -} - -#define gsDPLoadTextureBlock_4b(timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -#define gsDPLoadTextureBlock_4bS(timg, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, 0, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -/* - * 4-bit load block. Allows tmem address and render tile to be specified. - * Useful when loading multiple tiles. - */ -#define gsDPLoadMultiBlock_4b(timg, tmem, rtile, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * 4-bit load block. Allows tmem address and render tile to be specified. - * Useful when loading multiple tiles. S means odd lines are already swapped. - */ -#define gsDPLoadMultiBlock_4bS(timg, tmem, rtile, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1,0),\ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - - -/* - * Allows tmem address to be specified - */ -#define _gsDPLoadTextureBlock_4b(timg, tmem, fmt, width, height, \ - pal, cms, cmt, masks, maskt, shifts, shiftt) \ - \ - gsDPSetTextureImage(fmt, G_IM_SIZ_16b, 1, timg), \ - gsDPSetTile(fmt, G_IM_SIZ_16b, 0, tmem, G_TX_LOADTILE, 0 , cmt, \ - maskt, shiftt, cms, masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadBlock(G_TX_LOADTILE, 0, 0, (((width)*(height)+3)>>2)-1, \ - CALC_DXT_4b(width)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, ((((width)>>1)+7)>>3), tmem, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, 0, 0, \ - ((width)-1) << G_TEXTURE_IMAGE_FRAC, \ - ((height)-1) << G_TEXTURE_IMAGE_FRAC) - -#ifndef _HW_VERSION_1 - -#define gDPLoadTextureTile(pkt, timg, fmt, siz, width, height, \ - uls, ult, lrs, lrt, pal, \ - cms, cmt, masks, maskt, shifts, shiftt) \ -{ \ - gDPSetTextureImage(pkt, fmt, siz, width, timg); \ - gDPSetTile(pkt, fmt, siz, \ - (((((lrs)-(uls)+1) * siz##_TILE_BYTES)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, \ - (uls)<>3), tmem, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks,\ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, \ - (uls)<>3), \ - tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<>3), \ - tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, \ - (uls)<>1), timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, \ - masks, shifts); \ - gDPSetTileSize(pkt, G_TX_RENDERTILE, \ - (uls)<>1), timg); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_8b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPLoadSync(pkt); \ - gDPLoadTile( pkt, G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)); \ - gDPPipeSync(pkt); \ - gDPSetTile(pkt, fmt, G_IM_SIZ_4b, \ - (((((lrs)-(uls)+1)>>1)+7)>>3), tmem, \ - rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts); \ - gDPSetTileSize(pkt, rtile, \ - (uls)<>1), timg), \ - gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), 0, \ - G_TX_RENDERTILE, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(G_TX_RENDERTILE, \ - (uls)<>1), timg), \ - gsDPSetTile(fmt, G_IM_SIZ_8b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ - tmem, G_TX_LOADTILE, 0 , cmt, maskt, shiftt, cms, \ - masks, shifts), \ - gsDPLoadSync(), \ - gsDPLoadTile( G_TX_LOADTILE, \ - (uls)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (ult)<<(G_TEXTURE_IMAGE_FRAC), \ - (lrs)<<(G_TEXTURE_IMAGE_FRAC-1), \ - (lrt)<<(G_TEXTURE_IMAGE_FRAC)), \ - gsDPPipeSync(), \ - gsDPSetTile(fmt, G_IM_SIZ_4b, (((((lrs)-(uls)+1)>>1)+7)>>3), \ - tmem, rtile, pal, cmt, maskt, shiftt, cms, masks, \ - shifts), \ - gsDPSetTileSize(rtile, \ - (uls)<words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(uly)*4.0F), 0, 12); \ - _g->words.w1 = _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(lry)*4.0F), 0, 12); \ -} - - -#define gDPSetScissorFrac(pkt, mode, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)pkt; \ - \ - _g->words.w0 = _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((ulx)), 12, 12) | \ - _SHIFTL((int)((uly)), 0, 12); \ - _g->words.w1 = _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((lrx)), 12, 12) | \ - _SHIFTL((int)((lry)), 0, 12); \ -} - -#define gsDPSetScissor(mode, ulx, uly, lrx, lry) \ -{ \ - _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((float)(ulx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(uly)*4.0F), 0, 12), \ - _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)((float)(lrx)*4.0F), 12, 12) | \ - _SHIFTL((int)((float)(lry)*4.0F), 0, 12) \ -} - -#define gsDPSetScissorFrac(mode, ulx, uly, lrx, lry) \ -{ \ - _SHIFTL(G_SETSCISSOR, 24, 8) | \ - _SHIFTL((int)((ulx)), 12, 12) | \ - _SHIFTL((int)((uly)), 0, 12), \ - _SHIFTL(mode, 24, 2) | \ - _SHIFTL((int)(lrx), 12, 12) | \ - _SHIFTL((int)(lry), 0, 12) \ -} - -/* Fraction never used in fill */ -#define gDPFillRectangle(pkt, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ - _SHIFTL((lrx), 14, 10) | _SHIFTL((lry), 2, 10));\ - _g->words.w1 = (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10));\ -} - -#define gsDPFillRectangle(ulx, uly, lrx, lry) \ -{ \ - (_SHIFTL(G_FILLRECT, 24, 8) | _SHIFTL((lrx), 14, 10) | \ - _SHIFTL((lry), 2, 10)), \ - (_SHIFTL((ulx), 14, 10) | _SHIFTL((uly), 2, 10)) \ -} - -/* like gDPFillRectangle but accepts negative arguments */ -#define gDPScisFillRectangle(pkt, ulx, uly, lrx, lry) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_FILLRECT, 24, 8) | \ - _SHIFTL(MAX((lrx),0), 14, 10) | \ - _SHIFTL(MAX((lry),0), 2, 10)); \ - _g->words.w1 = (_SHIFTL(MAX((ulx),0), 14, 10) | \ - _SHIFTL(MAX((uly),0), 2, 10)); \ -} - -#define gDPSetConvert(pkt, k0, k1, k2, k3, k4, k5) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETCONVERT, 24, 8) | \ - _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | \ - _SHIFTR(k2, 5, 4)); \ - _g->words.w1 = (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | \ - _SHIFTL(k4, 9, 9) | _SHIFTL(k5, 0, 9)); \ -} - -#define gsDPSetConvert(k0, k1, k2, k3, k4, k5) \ -{ \ - (_SHIFTL(G_SETCONVERT, 24, 8) | \ - _SHIFTL(k0, 13, 9) | _SHIFTL(k1, 4, 9) | _SHIFTL(k2, 5, 4)), \ - (_SHIFTL(k2, 27, 5) | _SHIFTL(k3, 18, 9) | _SHIFTL(k4, 9, 9) | \ - _SHIFTL(k5, 0, 9)) \ -} - -#define gDPSetKeyR(pkt, cR, sR, wR) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(G_SETKEYR, 24, 8); \ - _g->words.w1 = (_SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | \ - _SHIFTL(sR, 0, 8)); \ -} - -#define gsDPSetKeyR(cR, sR, wR) \ -{ \ - _SHIFTL(G_SETKEYR, 24, 8), \ - _SHIFTL(wR, 16, 12) | _SHIFTL(cR, 8, 8) | _SHIFTL(sR, 0, 8) \ -} - -#define gDPSetKeyGB(pkt, cG, sG, wG, cB, sB, wB) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_SETKEYGB, 24, 8) | \ - _SHIFTL(wG, 12, 12) | _SHIFTL(wB, 0, 12)); \ - _g->words.w1 = (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | \ - _SHIFTL(cB, 8, 8) | _SHIFTL(sB, 0, 8)); \ -} - -#define gsDPSetKeyGB(cG, sG, wG, cB, sB, wB) \ -{ \ - (_SHIFTL(G_SETKEYGB, 24, 8) | _SHIFTL(wG, 12, 12) | \ - _SHIFTL(wB, 0, 12)), \ - (_SHIFTL(cG, 24, 8) | _SHIFTL(sG, 16, 8) | _SHIFTL(cB, 8, 8) | \ - _SHIFTL(sB, 0, 8)) \ -} - -#define gDPNoParam(pkt, cmd) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8); \ - _g->words.w1 = 0; \ -} - -#define gsDPNoParam(cmd) \ -{ \ - _SHIFTL(cmd, 24, 8), 0 \ -} - -#define gDPParam(pkt, cmd, param) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = _SHIFTL(cmd, 24, 8); \ - _g->words.w1 = (param); \ -} - -#define gsDPParam(cmd, param) \ -{ \ - _SHIFTL(cmd, 24, 8), (param) \ -} - -/* Notice that textured rectangles are 128-bit commands, therefore - * gsDPTextureRectangle() should not be used in display lists - * under normal circumstances (use gsSPTextureRectangle()). - * That is also why there is no gDPTextureRectangle() macros. - */ -#define gsDPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}, \ -{ \ - _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ - _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -} - -#define gDPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - if (pkt); \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - _g ++; \ - _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ - _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ -} - -#define gsDPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ -}, \ -{ \ - _SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16), \ - _SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16) \ -} - -#define gDPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - if (pkt); \ - _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - _g ++; \ - _g->words.w0 = (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16)); \ - _g->words.w1 = (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)); \ -} - -#define gsSPTextureRectangle(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | _SHIFTL(yh, 0, 12)),\ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ - gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -#define gSPTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy)\ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16)));\ -} - -/* like gSPTextureRectangle but accepts negative position arguments */ -#define gSPScisTextureRectangle(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECT, 24, 8) | \ - _SHIFTL(MAX((s16)(xh),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yh),0), 0, 12)); \ - _g->words.w1 = (_SHIFTL((tile), 24, 3) | \ - _SHIFTL(MAX((s16)(xl),0), 12, 12) | \ - _SHIFTL(MAX((s16)(yl),0), 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, \ - (_SHIFTL(((s) - \ - (((s16)(xl) < 0) ? \ - (((s16)(dsdx) < 0) ? \ - (MAX((((s16)(xl)*(s16)(dsdx))>>7),0)) : \ - (MIN((((s16)(xl)*(s16)(dsdx))>>7),0))) : 0)), \ - 16, 16) | \ - _SHIFTL(((t) - \ - (((yl) < 0) ? \ - (((s16)(dtdy) < 0) ? \ - (MAX((((s16)(yl)*(s16)(dtdy))>>7),0)) : \ - (MIN((((s16)(yl)*(s16)(dtdy))>>7),0))) : 0)), \ - 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL((dsdx), 16, 16) | \ - _SHIFTL((dtdy), 0, 16))); \ -} - -#define gsSPTextureRectangleFlip(xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ - (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) | \ - _SHIFTL(yh, 0, 12)), \ - (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | _SHIFTL(yl, 0, 12)), \ - gsImmp1(G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))), \ - gsImmp1(G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))) - -#define gSPTextureRectangleFlip(pkt, xl, yl, xh, yh, tile, s, t, dsdx, dtdy) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - _g->words.w0 = (_SHIFTL(G_TEXRECTFLIP, 24, 8) | _SHIFTL(xh, 12, 12) |\ - _SHIFTL(yh, 0, 12)); \ - _g->words.w1 = (_SHIFTL(tile, 24, 3) | _SHIFTL(xl, 12, 12) | \ - _SHIFTL(yl, 0, 12)); \ - gImmp1(pkt, G_RDPHALF_1, (_SHIFTL(s, 16, 16) | _SHIFTL(t, 0, 16))); \ - gImmp1(pkt, G_RDPHALF_2, (_SHIFTL(dsdx, 16, 16) | _SHIFTL(dtdy, 0, 16))); \ -} - -#define gsDPWord(wordhi, wordlo) \ - gsImmp1(G_RDPHALF_1, (unsigned int)(wordhi)), \ - gsImmp1(G_RDPHALF_2, (unsigned int)(wordlo)) - -#define gDPWord(pkt, wordhi, wordlo) \ -{ \ - Gfx *_g = (Gfx *)(pkt); \ - \ - gImmp1(pkt, G_RDPHALF_1, (unsigned int)(wordhi)); \ - gImmp1(pkt, G_RDPHALF_2, (unsigned int)(wordlo)); \ -} - -#define gDPFullSync(pkt) gDPNoParam(pkt, G_RDPFULLSYNC) -#define gsDPFullSync() gsDPNoParam(G_RDPFULLSYNC) -#define gDPTileSync(pkt) gDPNoParam(pkt, G_RDPTILESYNC) -#define gsDPTileSync() gsDPNoParam(G_RDPTILESYNC) -#define gDPPipeSync(pkt) gDPNoParam(pkt, G_RDPPIPESYNC) -#define gsDPPipeSync() gsDPNoParam(G_RDPPIPESYNC) -#define gDPLoadSync(pkt) gDPNoParam(pkt, G_RDPLOADSYNC) -#define gsDPLoadSync() gsDPNoParam(G_RDPLOADSYNC) -#define gDPNoOp(pkt) gDPNoParam(pkt, G_NOOP) -#define gsDPNoOp() gsDPNoParam(G_NOOP) -#define gDPNoOpTag(pkt, tag) gDPParam(pkt, G_NOOP, tag) -#define gsDPNoOpTag(tag) gsDPParam(G_NOOP, tag) - -#endif /* _LANGUAGE_C */ - - -#endif /* _GBI_H_ */ diff --git a/include/PR/os.h b/include/PR/os.h deleted file mode 100644 index 5de24017..00000000 --- a/include/PR/os.h +++ /dev/null @@ -1,108 +0,0 @@ - -/*==================================================================== - * os.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os.h,v $ - $Revision: 1.168 $ - $Date: 2000/06/15 06:24:52 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_H_ -#define _OS_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Stack size for I/O device managers: PIM (PI Manager), VIM (VI Manager), - * SIM (SI Manager) - * - */ -#define OS_PIM_STACKSIZE 4096 -#define OS_VIM_STACKSIZE 4096 -#define OS_SIM_STACKSIZE 4096 - -#define OS_MIN_STACKSIZE 72 - -/* - * Leo Disk - */ - -/* transfer mode */ - -#define LEO_BLOCK_MODE 1 -#define LEO_TRACK_MODE 2 -#define LEO_SECTOR_MODE 3 - -/* - * Boot addresses - */ -#define BOOT_ADDRESS_ULTRA 0x80000400 -#define BOOT_ADDRESS_COSIM 0x80002000 -#define BOOT_ADDRESS_EMU 0x20010000 -#define BOOT_ADDRESS_INDY 0x88100000 - - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_H */ diff --git a/include/PR/os_ai.h b/include/PR/os_ai.h deleted file mode 100644 index 93160921..00000000 --- a/include/PR/os_ai.h +++ /dev/null @@ -1,92 +0,0 @@ - -/*==================================================================== - * os_ai.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_ai.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:04 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_AI_H_ -#define _OS_AI_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Audio interface (Ai) */ -extern u32 osAiGetStatus(void); -extern u32 osAiGetLength(void); -extern s32 osAiSetFrequency(u32); -extern s32 osAiSetNextBuffer(void *, u32); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_AI_H_ */ diff --git a/include/PR/os_cache.h b/include/PR/os_cache.h deleted file mode 100644 index 7b8a24bf..00000000 --- a/include/PR/os_cache.h +++ /dev/null @@ -1,96 +0,0 @@ - -/*==================================================================== - * os_cache.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_cache.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:04 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_CACHE_H_ -#define _OS_CACHE_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -#define OS_DCACHE_ROUNDUP_ADDR(x) (void *)(((((u32)(x)+0xf)/0x10)*0x10)) -#define OS_DCACHE_ROUNDUP_SIZE(x) (u32)(((((u32)(x)+0xf)/0x10)*0x10)) - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Cache operations and macros */ - -extern void osInvalDCache(void *, s32); -extern void osInvalICache(void *, s32); -extern void osWritebackDCache(void *, s32); -extern void osWritebackDCacheAll(void); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_CACHE_H_ */ diff --git a/include/PR/os_cont.h b/include/PR/os_cont.h deleted file mode 100644 index 7d1aeec3..00000000 --- a/include/PR/os_cont.h +++ /dev/null @@ -1,208 +0,0 @@ - -/*==================================================================== - * os_cont.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_cont.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:05 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_CONT_H_ -#define _OS_CONT_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for controllers - */ - -typedef struct { - u16 type; /* Controller Type */ - u8 status; /* Controller status */ - u8 errno; -}OSContStatus; - -typedef struct { - u16 button; - s8 stick_x; /* -80 <= stick_x <= 80 */ - s8 stick_y; /* -80 <= stick_y <= 80 */ - u8 errno; -} OSContPad; - -typedef struct { - void *address; /* Ram pad Address: 11 bits */ - u8 databuffer[32]; /* address of the data buffer */ - u8 addressCrc; /* CRC code for address */ - u8 dataCrc; /* CRC code for data */ - u8 errno; -} OSContRamIo; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Controllers number - */ - -#ifndef _HW_VERSION_1 -#define MAXCONTROLLERS 4 -#else -#define MAXCONTROLLERS 6 -#endif - -/* controller errors */ -#define CONT_NO_RESPONSE_ERROR 0x8 -#define CONT_OVERRUN_ERROR 0x4 -#define CONT_RANGE_ERROR -1 -#ifdef _HW_VERSION_1 -#define CONT_FRAME_ERROR 0x2 -#define CONT_COLLISION_ERROR 0x1 -#endif - -/* Controller type */ - -#define CONT_ABSOLUTE 0x0001 -#define CONT_RELATIVE 0x0002 -#define CONT_JOYPORT 0x0004 -#define CONT_EEPROM 0x8000 -#define CONT_EEP16K 0x4000 -#define CONT_TYPE_MASK 0x1f07 -#define CONT_TYPE_NORMAL 0x0005 -#define CONT_TYPE_MOUSE 0x0002 -#define CONT_TYPE_VOICE 0x0100 - -/* Controller status */ - -#define CONT_CARD_ON 0x01 -#define CONT_CARD_PULL 0x02 -#define CONT_ADDR_CRC_ER 0x04 -#define CONT_EEPROM_BUSY 0x80 - -/* Buttons */ - -#define CONT_A 0x8000 -#define CONT_B 0x4000 -#define CONT_G 0x2000 -#define CONT_START 0x1000 -#define CONT_UP 0x0800 -#define CONT_DOWN 0x0400 -#define CONT_LEFT 0x0200 -#define CONT_RIGHT 0x0100 -#define CONT_L 0x0020 -#define CONT_R 0x0010 -#define CONT_E 0x0008 -#define CONT_D 0x0004 -#define CONT_C 0x0002 -#define CONT_F 0x0001 - -/* Nintendo's official button names */ - -#define A_BUTTON CONT_A -#define B_BUTTON CONT_B -#define L_TRIG CONT_L -#define R_TRIG CONT_R -#define Z_TRIG CONT_G -#define START_BUTTON CONT_START -#define U_JPAD CONT_UP -#define L_JPAD CONT_LEFT -#define R_JPAD CONT_RIGHT -#define D_JPAD CONT_DOWN -#define U_CBUTTONS CONT_E -#define L_CBUTTONS CONT_C -#define R_CBUTTONS CONT_F -#define D_CBUTTONS CONT_D - -/* Controller error number */ - -#define CONT_ERR_NO_CONTROLLER PFS_ERR_NOPACK /* 1 */ -#define CONT_ERR_CONTRFAIL CONT_OVERRUN_ERROR /* 4 */ -#define CONT_ERR_INVALID PFS_ERR_INVALID /* 5 */ -#define CONT_ERR_DEVICE PFS_ERR_DEVICE /* 11 */ -#define CONT_ERR_NOT_READY 12 -#define CONT_ERR_VOICE_MEMORY 13 -#define CONT_ERR_VOICE_WORD 14 -#define CONT_ERR_VOICE_NO_RESPONSE 15 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Controller interface */ - -extern s32 osContInit(OSMesgQueue *, u8 *, OSContStatus *); -extern s32 osContReset(OSMesgQueue *, OSContStatus *); -extern s32 osContStartQuery(OSMesgQueue *); -extern s32 osContStartReadData(OSMesgQueue *); -#ifndef _HW_VERSION_1 -extern s32 osContSetCh(u8); -#endif -extern void osContGetQuery(OSContStatus *); -extern void osContGetReadData(OSContPad *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_CONT_H_ */ diff --git a/include/PR/os_convert.h b/include/PR/os_convert.h deleted file mode 100644 index 3797d1b5..00000000 --- a/include/PR/os_convert.h +++ /dev/null @@ -1,111 +0,0 @@ - -/*==================================================================== - * os_convert.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_convert.h,v $ - $Revision: 1.2 $ - $Date: 1999/04/21 02:53:11 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_CONVERT_H_ -#define _OS_CONVERT_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -#define OS_CLOCK_RATE 62500000LL -#define OS_CPU_COUNTER (OS_CLOCK_RATE*3/4) - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -#define OS_NSEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625000LL))/(1000000000LL/15625000LL)) -#define OS_USEC_TO_CYCLES(n) (((u64)(n)*(OS_CPU_COUNTER/15625LL))/(1000000LL/15625LL)) -#define OS_CYCLES_TO_NSEC(c) (((u64)(c)*(1000000000LL/15625000LL))/(OS_CPU_COUNTER/15625000LL)) -#define OS_CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CPU_COUNTER/15625LL)) - -/* OS_K?_TO_PHYSICAL macro bug fix for CodeWarrior */ -#ifndef __MWERKS__ -#define OS_K0_TO_PHYSICAL(x) (u32)(((char *)(x)-0x80000000)) -#define OS_K1_TO_PHYSICAL(x) (u32)(((char *)(x)-0xa0000000)) -#else -#define OS_K0_TO_PHYSICAL(x) ((char *)(x)-0x80000000) -#define OS_K1_TO_PHYSICAL(x) ((char *)(x)-0xa0000000) -#endif - -#define OS_PHYSICAL_TO_K0(x) (void *)(((u32)(x)+0x80000000)) -#define OS_PHYSICAL_TO_K1(x) (void *)(((u32)(x)+0xa0000000)) - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Address translation routines and macros */ - -extern u32 osVirtualToPhysical(void *); -extern void * osPhysicalToVirtual(u32); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_CONVERT_H_ */ diff --git a/include/PR/os_debug.h b/include/PR/os_debug.h deleted file mode 100644 index e8bc8b66..00000000 --- a/include/PR/os_debug.h +++ /dev/null @@ -1,117 +0,0 @@ - -/*==================================================================== - * os_debug.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_debug.h,v $ - $Revision: 1.4 $ - $Date: 1999/06/30 03:04:08 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_DEBUG_H_ -#define _OS_DEBUG_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for Profiler - */ -typedef struct { - u16 *histo_base; /* histogram base */ - u32 histo_size; /* histogram size */ - u32 *text_start; /* start of text segment */ - u32 *text_end; /* end of text segment */ -} OSProf; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Profiler constants - */ -#define PROF_MIN_INTERVAL 50 /* microseconds */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Profiler Interface */ - -extern void osProfileInit(OSProf *, u32 profcnt); -extern void osProfileStart(u32); -extern void osProfileFlush(void); -extern void osProfileStop(void); - -/* Thread Profiler Interface */ -extern void osThreadProfileClear(OSId); -extern void osThreadProfileInit(void); -extern void osThreadProfileStart(void); -extern void osThreadProfileStop(void); -extern u32 osThreadProfileReadCount(OSId); -extern u32 osThreadProfileReadCountTh(OSThread*); -extern OSTime osThreadProfileReadTime(OSId); -extern OSTime osThreadProfileReadTimeTh(OSThread*); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_DEBUG_H_ */ diff --git a/include/PR/os_eeprom.h b/include/PR/os_eeprom.h deleted file mode 100644 index 361803af..00000000 --- a/include/PR/os_eeprom.h +++ /dev/null @@ -1,107 +0,0 @@ - -/*==================================================================== - * os_eeprom.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_eeprom.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:06 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_EEPROM_H_ -#define _OS_EEPROM_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* EEPROM TYPE */ - -#define EEPROM_TYPE_4K 0x01 -#define EEPROM_TYPE_16K 0x02 - -/* definition for EEPROM */ - -#define EEPROM_MAXBLOCKS 64 -#define EEP16K_MAXBLOCKS 256 -#define EEPROM_BLOCK_SIZE 8 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* EEPROM interface */ - -extern s32 osEepromProbe(OSMesgQueue *); -extern s32 osEepromRead(OSMesgQueue *, u8, u8 *); -extern s32 osEepromWrite(OSMesgQueue *, u8, u8 *); -extern s32 osEepromLongRead(OSMesgQueue *, u8, u8 *, int); -extern s32 osEepromLongWrite(OSMesgQueue *, u8, u8 *, int); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_EEPROM_H_ */ diff --git a/include/PR/os_error.h b/include/PR/os_error.h deleted file mode 100644 index 31203e0f..00000000 --- a/include/PR/os_error.h +++ /dev/null @@ -1,86 +0,0 @@ - -/*==================================================================== - * os_error.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_error.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:06 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_ERROR_H_ -#define _OS_ERROR_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_ERROR_H_ */ diff --git a/include/PR/os_exception.h b/include/PR/os_exception.h deleted file mode 100644 index 70c99433..00000000 --- a/include/PR/os_exception.h +++ /dev/null @@ -1,86 +0,0 @@ - -/*==================================================================== - * os_exception.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_exception.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:07 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_EXCEPTION_H_ -#define _OS_EXCEPTION_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include "PR/ultratypes.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -typedef u32 OSIntMask; -typedef u32 OSHWIntr; - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/* Flags for debugging purpose */ - -#define OS_FLAG_CPU_BREAK 1 /* Break exception has occurred */ -#define OS_FLAG_FAULT 2 /* CPU fault has occurred */ - -/* Interrupt masks */ - -#define OS_IM_NONE 0x00000001 -#define OS_IM_RCP 0x00000401 -#define OS_IM_SW1 0x00000501 -#define OS_IM_SW2 0x00000601 -#define OS_IM_CART 0x00000c01 -#define OS_IM_PRENMI 0x00001401 -#define OS_IM_RDBWRITE 0x00002401 -#define OS_IM_RDBREAD 0x00004401 -#define OS_IM_COUNTER 0x00008401 -#define OS_IM_CPU 0x0000ff01 -#define OS_IM_SP 0x00010401 -#define OS_IM_SI 0x00020401 -#define OS_IM_AI 0x00040401 -#define OS_IM_VI 0x00080401 -#define OS_IM_PI 0x00100401 -#define OS_IM_DP 0x00200401 -#define OS_IM_ALL 0x003fff01 -#define RCP_IMASK 0x003f0000 -#define RCP_IMASKSHIFT 16 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* Interrupt operations */ - -extern OSIntMask osGetIntMask(void); -extern OSIntMask osSetIntMask(OSIntMask); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_EXCEPTION_H_ */ diff --git a/include/PR/os_flash.h b/include/PR/os_flash.h deleted file mode 100644 index 734f9216..00000000 --- a/include/PR/os_flash.h +++ /dev/null @@ -1,77 +0,0 @@ -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. - - $RCSfile: os_flash.h,v $ - $Revision: 1.1 $ - $Date: 2000/06/15 06:24:55 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_FLASH_H_ -#define _OS_FLASH_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include "PR/ultratypes.h" -#include "PR/os_pi.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* - * defines for FLASH - */ -#define FLASH_START_ADDR 0x08000000 - -#define FLASH_SIZE 0x20000 - -#define FLASH_LATENCY 0x5 -#define FLASH_PULSE 0x0c -#define FLASH_PAGE_SIZE 0xf -#define FLASH_REL_DURATION 0x2 -#define DEVICE_TYPE_FLASH 8 - -#define FLASH_VERSION_MX_PROTO_A 0x00c20000 -#define FLASH_VERSION_MX_A 0x00c20001 -#define FLASH_VERSION_MX_C 0x00c2001e -#define FLASH_VERSION_MX_B_AND_D 0x00c2001d -#define FLASH_VERSION_MEI 0x003200f1 - -/* OLD_FLASH is MX_PROTO_A, MX_A and MX_C */ -#define OLD_FLASH 0 -/* NEW_FLASH is MX_B_AND_D and MATSUSHITA flash */ -#define NEW_FLASH 1 - -#define FLASH_STATUS_ERASE_BUSY 2 -#define FLASH_STATUS_ERASE_OK 0 -#define FLASH_STATUS_ERASE_ERROR -1 - -#define FLASH_STATUS_WRITE_BUSY 1 -#define FLASH_STATUS_WRITE_OK 0 -#define FLASH_STATUS_WRITE_ERROR -1 - -extern OSPiHandle *osFlashReInit(u8 latency, u8 pulse, - u8 page_size, u8 rel_duration, u32 start); -extern OSPiHandle *osFlashInit(void); -extern void osFlashReadStatus(u8 *flash_status); -extern void osFlashReadId(u32 *flash_type, u32 *flash_maker); -extern void osFlashClearStatus(void); -extern s32 osFlashAllErase(void); -extern s32 osFlashSectorErase(u32 page_num); -extern s32 osFlashWriteBuffer(OSIoMesg *mb, s32 priority, - void *dramAddr, OSMesgQueue *mq); -extern s32 osFlashWriteArray(u32 page_num); -extern s32 osFlashReadArray(OSIoMesg *mb, s32 priority, u32 page_num, - void *dramAddr, u32 n_pages, OSMesgQueue *mq); -extern void osFlashChange(u32 flash_num); -extern void osFlashAllEraseThrough(void); -extern void osFlashSectorEraseThrough(u32 page_num); -extern s32 osFlashCheckEraseEnd(void); - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_FLASH_H_ */ diff --git a/include/PR/os_gbpak.h b/include/PR/os_gbpak.h deleted file mode 100644 index e2a696aa..00000000 --- a/include/PR/os_gbpak.h +++ /dev/null @@ -1,107 +0,0 @@ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. - - $RCSfile: os_gbpak.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:07 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_GBPAK_H_ -#define _OS_GBPAK_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "os_message.h" -#include "os_pfs.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef struct { - u16 fixed1; - u16 start_address; - u8 nintendo_chr[0x30]; - u8 game_title[16]; - u16 company_code; - u8 body_code; - u8 cart_type; - u8 rom_size; - u8 ram_size; - u8 country_code; - u8 fixed2; - u8 version; - u8 isum; - u16 sum; -} OSGbpakId; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* definition for 64GB-PAK */ - -#define OS_GBPAK_POWER 0x01 -#define OS_GBPAK_RSTB_DETECTION 0x04 -#define OS_GBPAK_RSTB_STATUS 0x08 -#define OS_GBPAK_GBCART_PULL 0x40 -#define OS_GBPAK_GBCART_ON 0x80 - -#define OS_GBPAK_POWER_OFF 0x00 /* power of 64GB-PAK */ -#define OS_GBPAK_POWER_ON 0x01 - -#define OS_GBPAK_ROM_ID_SIZE 0x50 /* ID size of GB cartridge */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* 64GB-PAK */ -extern s32 osGbpakInit(OSMesgQueue *, OSPfs *, int); -extern s32 osGbpakPower(OSPfs *, s32); -extern s32 osGbpakGetStatus(OSPfs *, u8 *); -extern s32 osGbpakReadWrite(OSPfs *, u16, u16, u8 *, u16); -extern s32 osGbpakReadId(OSPfs *, OSGbpakId *, u8 *); -extern s32 osGbpakCheckConnector(OSPfs *, u8 *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_GBPAK_H_ */ diff --git a/include/PR/os_gio.h b/include/PR/os_gio.h deleted file mode 100644 index 093b7cb9..00000000 --- a/include/PR/os_gio.h +++ /dev/null @@ -1,86 +0,0 @@ - -/*==================================================================== - * os_gio.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_gio.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:08 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_GIO_H_ -#define _OS_GIO_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_GIO_H_ */ diff --git a/include/PR/os_host.h b/include/PR/os_host.h deleted file mode 100644 index 1e5c29d0..00000000 --- a/include/PR/os_host.h +++ /dev/null @@ -1,166 +0,0 @@ - -/*==================================================================== - * os_host.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_host.h,v $ - $Revision: 1.3 $ - $Date: 1999/06/24 09:23:06 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_HOST_H_ -#define _OS_HOST_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -extern void __osInitialize_common(void); - -#if defined(_FINALROM) - -#define osInitialize() __osInitialize_common() - -#else - -/* PARTNER-N64 */ -#if defined(PTN64) -extern void __osInitialize_kmc(void); -#define osReadHost osReadHost_pt -#define osWriteHost osWriteHost_pt -#define osInitialize() \ -{ \ - __osInitialize_common(); \ - __osInitialize_kmc(); \ -} - -/* MONEGI SMART PACK A */ -#elif defined(MWN64) -extern void __osInitialize_msp(void); -#define osReadHost osReadHost_pt -#define osWriteHost osWriteHost_pt -#define osInitialize() \ -{ \ - __osInitialize_common(); \ - __osInitialize_msp(); \ -} - -/* IS-Viewer(for Debugger) */ -#elif defined(ISV64) -extern void __osInitialize_isv(void); -#define osInitialize() \ -{ \ - __osInitialize_common(); \ - __osInitialize_isv(); \ -} - -/* Emulation board for INDY */ -#elif defined(EMU64) -extern void __osInitialize_emu(void); -#define osInitialize() \ -{ \ - __osInitialize_common(); \ - __osInitialize_emu(); \ -} - -#else -/* Default (auto detect) */ -extern void __osInitialize_autodetect(void); -extern void __osInitialize_msp(void); -extern void __osInitialize_kmc(void); -extern void __osInitialize_isv(void); -extern void __osInitialize_emu(void); -#define osInitialize() \ -{ \ - __osInitialize_common(); \ - __osInitialize_autodetect(); \ -} -#endif - -#endif /* _FINAL_ROM */ - -#if BUILD_VERSION < VERSION_K -#undef osInitialize -#endif - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Game <> Host data transfer functions */ - -extern s32 osTestHost(void); -extern void osReadHost(void *, u32); -extern void osWriteHost(void *, u32); -extern void osAckRamromRead(void); -extern void osAckRamromWrite(void); - -/* RDB port operations */ - -extern void osInitRdb(u8 *sendBuf, u32 sendSize); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_HOST_H_ */ diff --git a/include/PR/os_internal.h b/include/PR/os_internal.h deleted file mode 100644 index c8cbf43b..00000000 --- a/include/PR/os_internal.h +++ /dev/null @@ -1,119 +0,0 @@ -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.18 $ - * $Date: 1997/02/11 08:26:14 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/os_internal.h,v $ - * - **************************************************************************/ - -#ifndef _OS_INTERNAL_H_ -#define _OS_INTERNAL_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_version.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/* Routines to get/fetch coprocessor 0 registers */ - -extern u32 __osGetCause(void); -extern void __osSetCause(u32); -extern u32 __osGetCompare(void); -extern void __osSetCompare(u32); -extern u32 __osGetConfig(void); -extern void __osSetConfig(u32); -extern void __osSetCount(u32); -extern u32 __osGetSR(void); -extern void __osSetSR(u32); -extern u32 __osDisableInt(void); -extern void __osRestoreInt(u32); - -/* Routines to get/set floating-point control and status register */ -extern u32 __osSetFpcCsr(u32); -extern u32 __osGetFpcCsr(void); - -/* Routine for HW interrupt "handler" */ -extern void __osSetHWIntrRoutine(OSHWIntr, s32 (*handler)(void)); - -/* Routine for global interrupt mask */ -extern void __osSetGlobalIntMask(OSHWIntr); -extern void __osResetGlobalIntMask(OSHWIntr); - -/* Routine for global interrupt mask */ -extern s32 __osLeoInterrupt(void); - -/* Routines for fetch TLB info */ - -extern u32 __osGetTLBASID(void); -extern u32 __osGetTLBPageMask(s32); -extern u32 __osGetTLBHi(s32); -extern u32 __osGetTLBLo0(s32); -extern u32 __osGetTLBLo1(s32); - -/* Serial interface (Si) */ - -extern u32 __osSiGetStatus(void); -extern s32 __osSiRawWriteIo(u32, u32); -extern s32 __osSiRawReadIo(u32, u32 *); -extern s32 __osSiRawStartDma(s32, void *); - -/* Signal processor interface (Sp) */ - -extern u32 __osSpGetStatus(void); -extern void __osSpSetStatus(u32); -extern s32 __osSpSetPc(u32); -extern s32 __osSpRawWriteIo(u32, u32); -extern s32 __osSpRawReadIo(u32, u32 *); -extern s32 __osSpRawStartDma(s32, u32, void *, u32); - -/* Error handling */ - -extern void __osError(s16, s16, ...); -extern OSThread * __osGetCurrFaultedThread(void); -extern OSThread * __osGetNextFaultedThread(OSThread *); - -/* Development board functions */ - -extern void __osGIOInit(s32); -extern void __osGIOInterrupt(s32); -extern void __osGIORawInterrupt(s32); - -/* For debugger use */ - -extern OSThread * __osGetActiveQueue(void); - -/* Debug port */ -extern void __osSyncPutChars(int, int, const char *); -extern int __osSyncGetChars(char *); -extern void __osAsyncPutChars(int, int, const char *); -extern int __osAsyncGetChars(char *); -extern int __osAtomicInc(unsigned int *p); -extern int __osAtomicDec(unsigned int *p); - -/* routine for rdb port */ -extern u32 __osRdbSend(u8 *buf, u32 size, u32 type); - - -#endif /* _LANGUAGE_C */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_INTERNAL_H */ diff --git a/include/PR/os_libc.h b/include/PR/os_libc.h deleted file mode 100644 index 0a84badd..00000000 --- a/include/PR/os_libc.h +++ /dev/null @@ -1,100 +0,0 @@ - -/*==================================================================== - * os_libc.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_libc.h,v $ - $Revision: 1.3 $ - $Date: 1999/07/13 01:43:47 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_LIBC_H_ -#define _OS_LIBC_H_ - -#include "os_pfs.h" - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* byte string operations */ - - -extern void bcopy(const void *, void *, int); -extern int bcmp(const void *, const void *, int); -extern void bzero(void *, int); - -/* Printf */ - -extern int sprintf(char *s, const char *fmt, ...); -extern void osSyncPrintf(const char *fmt, ...); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_LIBC_H_ */ diff --git a/include/PR/os_message.h b/include/PR/os_message.h deleted file mode 100644 index 3efbafad..00000000 --- a/include/PR/os_message.h +++ /dev/null @@ -1,162 +0,0 @@ - -/*==================================================================== - * os_message.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_message.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:15 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_MESSAGE_H_ -#define _OS_MESSAGE_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include "PR/ultratypes.h" -#include "PR/os_thread.h" - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef u32 OSEvent; - -/* - * Structure for message - */ -typedef void *OSMesg; - -/* - * Structure for message queue - */ -typedef struct OSMesgQueue_s { - OSThread *mtqueue; /* Queue to store threads blocked on empty mailboxes (receive) */ - OSThread *fullqueue; /* Queue to store threads blocked on full mailboxes (send) */ - s32 validCount; /* Contains number of valid message */ - s32 first; /* Points to first valid message */ - s32 msgCount; /* Contains total # of messages */ - OSMesg *msg; /* Points to message buffer array */ -} OSMesgQueue; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Events */ -#ifdef _FINALROM -#define OS_NUM_EVENTS 15 -#else -#define OS_NUM_EVENTS 23 -#endif - -#define OS_EVENT_SW1 0 /* CPU SW1 interrupt */ -#define OS_EVENT_SW2 1 /* CPU SW2 interrupt */ -#define OS_EVENT_CART 2 /* Cartridge interrupt: used by rmon */ -#define OS_EVENT_COUNTER 3 /* Counter int: used by VI/Timer Mgr */ -#define OS_EVENT_SP 4 /* SP task done interrupt */ -#define OS_EVENT_SI 5 /* SI (controller) interrupt */ -#define OS_EVENT_AI 6 /* AI interrupt */ -#define OS_EVENT_VI 7 /* VI interrupt: used by VI/Timer Mgr */ -#define OS_EVENT_PI 8 /* PI interrupt: used by PI Manager */ -#define OS_EVENT_DP 9 /* DP full sync interrupt */ -#define OS_EVENT_CPU_BREAK 10 /* CPU breakpoint: used by rmon */ -#define OS_EVENT_SP_BREAK 11 /* SP breakpoint: used by rmon */ -#define OS_EVENT_FAULT 12 /* CPU fault event: used by rmon */ -#define OS_EVENT_THREADSTATUS 13 /* CPU thread status: used by rmon */ -#define OS_EVENT_PRENMI 14 /* Pre NMI interrupt */ -#ifndef _FINALROM -#define OS_EVENT_RDB_READ_DONE 15 /* RDB read ok event: used by rmon */ -#define OS_EVENT_RDB_LOG_DONE 16 /* read of log data complete */ -#define OS_EVENT_RDB_DATA_DONE 17 /* read of hostio data complete */ -#define OS_EVENT_RDB_REQ_RAMROM 18 /* host needs ramrom access */ -#define OS_EVENT_RDB_FREE_RAMROM 19 /* host is done with ramrom access */ -#define OS_EVENT_RDB_DBG_DONE 20 -#define OS_EVENT_RDB_FLUSH_PROF 21 -#define OS_EVENT_RDB_ACK_PROF 22 -#endif - -/* Flags to turn blocking on/off when sending/receiving message */ - -#define OS_MESG_NOBLOCK 0 -#define OS_MESG_BLOCK 1 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - -/* Get count of valid messages in queue */ -#define MQ_GET_COUNT(mq) ((mq)->validCount) - -/* Figure out if message queue is empty or full */ -#define MQ_IS_EMPTY(mq) (MQ_GET_COUNT(mq) == 0) -#define MQ_IS_FULL(mq) (MQ_GET_COUNT(mq) >= (mq)->msgCount) - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Message operations */ - -extern void osCreateMesgQueue(OSMesgQueue *, OSMesg *, s32); -extern s32 osSendMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osJamMesg(OSMesgQueue *, OSMesg, s32); -extern s32 osRecvMesg(OSMesgQueue *, OSMesg *, s32); - -/* Event operations */ - -extern void osSetEventMesg(OSEvent, OSMesgQueue *, OSMesg); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_MESSAGE_H_ */ diff --git a/include/PR/os_motor.h b/include/PR/os_motor.h deleted file mode 100644 index d2723e0c..00000000 --- a/include/PR/os_motor.h +++ /dev/null @@ -1,84 +0,0 @@ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. - - $RCSfile: os_motor.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:15 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_MOTOR_H_ -#define _OS_MOTOR_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" -#include "PR/os_pfs.h" -#include "PR/os_version.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Rumble PAK interface */ - -extern s32 osMotorInit(OSMesgQueue *, OSPfs *, int); -#if BUILD_VERSION >= VERSION_J -#define MOTOR_START 1 -#define MOTOR_STOP 0 -#define osMotorStart(x) __osMotorAccess((x), MOTOR_START) -#define osMotorStop(x) __osMotorAccess((x), MOTOR_STOP) -extern s32 __osMotorAccess(OSPfs *, s32); -#else -extern s32 osMotorStop(OSPfs *); -extern s32 osMotorStart(OSPfs *); -#endif - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_MOTOR_H_ */ diff --git a/include/PR/os_pfs.h b/include/PR/os_pfs.h deleted file mode 100644 index bb4403d4..00000000 --- a/include/PR/os_pfs.h +++ /dev/null @@ -1,200 +0,0 @@ - -/*==================================================================== - * os_pfs.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_pfs.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:16 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_PFS_H_ -#define _OS_PFS_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for file system - */ -typedef struct { - int status; - OSMesgQueue *queue; - int channel; - u8 id[32]; - u8 label[32]; - int version; - int dir_size; - int inode_table; /* block location */ - int minode_table; /* mirrioring inode_table */ - int dir_table; /* block location */ - int inode_start_page; /* page # */ - u8 banks; - u8 activebank; -} OSPfs; - -typedef struct { - u32 file_size; /* bytes */ - u32 game_code; - u16 company_code; - char ext_name[4]; - char game_name[16]; -} OSPfsState; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -/* File System size */ -#define OS_PFS_VERSION 0x0200 -#define OS_PFS_VERSION_HI (OS_PFS_VERSION >> 8) -#define OS_PFS_VERSION_LO (OS_PFS_VERSION & 255) - -#define PFS_INODE_SIZE_PER_PAGE 128 -#define PFS_FILE_NAME_LEN 16 -#define PFS_FILE_EXT_LEN 4 -#define BLOCKSIZE 32 /* bytes */ -#define PFS_ONE_PAGE 8 /* blocks */ -#define PFS_MAX_BANKS 62 - -/* File System flag */ - -#define PFS_READ 0 -#define PFS_WRITE 1 -#define PFS_CREATE 2 - -/* File System status */ -#define PFS_INITIALIZED 0x1 -#define PFS_CORRUPTED 0x2 -#define PFS_ID_BROKEN 0x4 -#define PFS_MOTOR_INITIALIZED 0x8 -#define PFS_GBPAK_INITIALIZED 0x10 - -/* Definition for page usage */ -#define PFS_EOF 1 -#define PFS_PAGE_NOT_EXIST 2 -#define PFS_PAGE_NOT_USED 3 - -/* File System error number */ - -#define PFS_ERR_NOPACK 1 /* no memory card is plugged or */ -#define PFS_ERR_NEW_PACK 2 /* ram pack has been changed to a different one */ -#define PFS_ERR_INCONSISTENT 3 /* need to run Pfschecker*/ -#define PFS_ERR_CONTRFAIL CONT_OVERRUN_ERROR -#define PFS_ERR_INVALID 5 /* invalid parameter or file not exist*/ -#define PFS_ERR_BAD_DATA 6 /* the data read from pack are bad*/ -#define PFS_DATA_FULL 7 /* no free pages on ram pack*/ -#define PFS_DIR_FULL 8 /* no free directories on ram pack*/ -#define PFS_ERR_EXIST 9 /* file exists*/ -#define PFS_ERR_ID_FATAL 10 /* dead ram pack */ -#define PFS_ERR_DEVICE 11 /* wrong device type*/ -#define PFS_ERR_NO_GBCART 12 /* no gb cartridge (64GB-PAK) */ -#define PFS_ERR_NEW_GBCART 13 /* gb cartridge may be changed */ - -/* Definition for bank */ -#define PFS_ID_BANK_256K 0 -#define PFS_ID_BANK_1M 4 -#define PFS_BANKS_256K 1 - -#define PFS_WRITTEN 2 -#define DEF_DIR_PAGES 2 - -#define PFS_ID_0AREA 1 -#define PFS_ID_1AREA 3 -#define PFS_ID_2AREA 4 -#define PFS_ID_3AREA 6 -#define PFS_LABEL_AREA 7 -#define PFS_ID_PAGE PFS_ONE_PAGE * 0 - -#define PFS_BANK_LAPPED_BY 8 /* => u8 */ -#define PFS_SECTOR_PER_BANK 32 -#define PFS_INODE_DIST_MAP (PFS_BANK_LAPPED_BY * PFS_SECTOR_PER_BANK) -#define PFS_SECTOR_SIZE (PFS_INODE_SIZE_PER_PAGE/PFS_SECTOR_PER_BANK) - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* file system interface */ - -extern s32 osPfsInitPak(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsRepairId(OSPfs *); -extern s32 osPfsInit(OSMesgQueue *, OSPfs *, int); -extern s32 osPfsReFormat(OSPfs *, OSMesgQueue *, int); -extern s32 osPfsChecker(OSPfs *); -extern s32 osPfsAllocateFile(OSPfs *, u16, u32, u8 *, u8 *, int, s32 *); -extern s32 osPfsFindFile(OSPfs *, u16, u32, u8 *, u8 *, s32 *); -extern s32 osPfsDeleteFile(OSPfs *, u16, u32, u8 *, u8 *); -extern s32 osPfsReadWriteFile(OSPfs *, s32, u8, int, int, u8 *); -extern s32 osPfsFileState(OSPfs *, s32, OSPfsState *); -extern s32 osPfsGetLabel(OSPfs *, u8 *, int *); -extern s32 osPfsSetLabel(OSPfs *, u8 *); -extern s32 osPfsIsPlug(OSMesgQueue *, u8 *); -extern s32 osPfsFreeBlocks(OSPfs *, s32 *); -extern s32 osPfsNumFiles(OSPfs *, s32 *, s32 *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_PFS_H_ */ diff --git a/include/PR/os_pi.h b/include/PR/os_pi.h deleted file mode 100644 index 8043169f..00000000 --- a/include/PR/os_pi.h +++ /dev/null @@ -1,221 +0,0 @@ - -/*==================================================================== - * os_pi.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_pi.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:16 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_PI_H_ -#define _OS_PI_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include "PR/ultratypes.h" -#include "PR/os_thread.h" -#include "PR/os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for Enhanced PI interface - */ - -/* - * OSTranxInfo is set up for Leo Disk DMA. This info will be maintained - * by exception handler. This is how the PIMGR and the ISR communicate. - */ - -typedef struct { - u32 errStatus; /* error status */ - void *dramAddr; /* RDRAM buffer address (DMA) */ - void *C2Addr; /* C2 buffer address */ - u32 sectorSize; /* size of transfering sector */ - u32 C1ErrNum; /* total # of C1 errors */ - u32 C1ErrSector[4]; /* error sectors */ -} __OSBlockInfo; - -typedef struct { - u32 cmdType; /* for disk only */ - u16 transferMode; /* Block, Track, or sector? */ - u16 blockNum; /* which block is transfering */ - s32 sectorNum; /* which sector is transfering */ - u32 devAddr; /* Device buffer address */ - u32 bmCtlShadow; /* asic bm_ctl(510) register shadow ram */ - u32 seqCtlShadow; /* asic seq_ctl(518) register shadow ram */ - __OSBlockInfo block[2]; /* bolck transfer info */ -} __OSTranxInfo; - - -typedef struct OSPiHandle_s { - struct OSPiHandle_s *next; /* point to next handle on the table */ - u8 type; /* DEVICE_TYPE_BULK for disk */ - u8 latency; /* domain latency */ - u8 pageSize; /* domain page size */ - u8 relDuration; /* domain release duration */ - u8 pulse; /* domain pulse width */ - u8 domain; /* which domain */ - u32 baseAddress; /* Domain address */ - u32 speed; /* for roms only */ - /* The following are "private" elements" */ - __OSTranxInfo transferInfo; /* for disk only */ -} OSPiHandle; - -typedef struct { - u8 type; - u32 address; -} OSPiInfo; - -/* - * Structure for I/O message block - */ -typedef struct { - u16 type; /* Message type */ - u8 pri; /* Message priority (High or Normal) */ - u8 status; /* Return status */ - OSMesgQueue *retQueue; /* Return message queue to notify I/O completion */ -} OSIoMesgHdr; - -typedef struct { - OSIoMesgHdr hdr; /* Message header */ - void *dramAddr; /* RDRAM buffer address (DMA) */ - u32 devAddr; /* Device buffer address (DMA) */ - u32 size; /* DMA transfer size in bytes */ - OSPiHandle *piHandle; /* PI device handle */ -} OSIoMesg; - -/* - * Structure for device manager block - */ -typedef struct { - s32 active; /* Status flag */ - OSThread *thread; /* Calling thread */ - OSMesgQueue *cmdQueue; /* Command queue */ - OSMesgQueue *evtQueue; /* Event queue */ - OSMesgQueue *acsQueue; /* Access queue */ - /* Raw DMA routine */ - s32 (*dma)(s32, u32, void *, u32); - s32 (*edma)(OSPiHandle *, s32, u32, void *, u32); -} OSDevMgr; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Flags to indicate direction of data transfer */ - -#define OS_READ 0 /* device -> RDRAM */ -#define OS_WRITE 1 /* device <- RDRAM */ -#define OS_OTHERS 2 /* for Leo disk only */ - -/* - * I/O message types - */ -#define OS_MESG_TYPE_BASE (10) -#define OS_MESG_TYPE_LOOPBACK (OS_MESG_TYPE_BASE + 0) -#define OS_MESG_TYPE_DMAREAD (OS_MESG_TYPE_BASE + 1) -#define OS_MESG_TYPE_DMAWRITE (OS_MESG_TYPE_BASE + 2) -#define OS_MESG_TYPE_VRETRACE (OS_MESG_TYPE_BASE + 3) -#define OS_MESG_TYPE_COUNTER (OS_MESG_TYPE_BASE + 4) -#define OS_MESG_TYPE_EDMAREAD (OS_MESG_TYPE_BASE + 5) -#define OS_MESG_TYPE_EDMAWRITE (OS_MESG_TYPE_BASE + 6) - -/* - * I/O message priority - */ -#define OS_MESG_PRI_NORMAL 0 -#define OS_MESG_PRI_HIGH 1 - -/* - * PI/EPI - */ -#define PI_DOMAIN1 0 -#define PI_DOMAIN2 1 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - -extern OSPiHandle *__osPiTable; /* The head of OSPiHandle link list */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -extern u32 osPiGetStatus(void); -extern s32 osPiGetDeviceType(void); -extern s32 osPiWriteIo(u32, u32); -extern s32 osPiReadIo(u32, u32 *); -extern s32 osPiStartDma(OSIoMesg *, s32, s32, u32, void *, u32, OSMesgQueue *); -extern void osCreatePiManager(OSPri, OSMesgQueue *, OSMesg *, s32); - -/* Enhanced PI interface */ - -extern OSPiHandle *osCartRomInit(void); -extern OSPiHandle *osLeoDiskInit(void); -extern OSPiHandle *osDriveRomInit(void); - -extern s32 osEPiDeviceType(OSPiHandle *, OSPiInfo *); -extern s32 osEPiWriteIo(OSPiHandle *, u32 , u32 ); -extern s32 osEPiReadIo(OSPiHandle *, u32 , u32 *); -extern s32 osEPiStartDma(OSPiHandle *, OSIoMesg *, s32); -extern s32 osEPiLinkHandle(OSPiHandle *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_PI_H_ */ diff --git a/include/PR/os_rdp.h b/include/PR/os_rdp.h deleted file mode 100644 index 198c756a..00000000 --- a/include/PR/os_rdp.h +++ /dev/null @@ -1,92 +0,0 @@ - -/*==================================================================== - * os_rdp.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_rdp.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:16 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_RDP_H_ -#define _OS_RDP_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Display processor interface (Dp) */ -extern u32 osDpGetStatus(void); -extern void osDpSetStatus(u32); -extern void osDpGetCounters(u32 *); -extern s32 osDpSetNextBuffer(void *, u64); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_RDP_H_ */ diff --git a/include/PR/os_reg.h b/include/PR/os_reg.h deleted file mode 100644 index 2049a60a..00000000 --- a/include/PR/os_reg.h +++ /dev/null @@ -1,90 +0,0 @@ - -/*==================================================================== - * os_reg.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_reg.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:17 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_REG_H_ -#define _OS_REG_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Miscellaneous operations */ - -extern u32 osGetCount(void); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_REG_H_ */ diff --git a/include/PR/os_rsp.h b/include/PR/os_rsp.h deleted file mode 100644 index 5c983117..00000000 --- a/include/PR/os_rsp.h +++ /dev/null @@ -1,86 +0,0 @@ - -/*==================================================================== - * os_rsp.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_rsp.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:17 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_RSP_H_ -#define _OS_RSP_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_RSP_H_ */ diff --git a/include/PR/os_si.h b/include/PR/os_si.h deleted file mode 100644 index e1d1d09b..00000000 --- a/include/PR/os_si.h +++ /dev/null @@ -1,86 +0,0 @@ - -/*==================================================================== - * os_si.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_si.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:18 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_SI_H_ -#define _OS_SI_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_SI_H_ */ diff --git a/include/PR/os_system.h b/include/PR/os_system.h deleted file mode 100644 index 96f4f715..00000000 --- a/include/PR/os_system.h +++ /dev/null @@ -1,118 +0,0 @@ - -/*==================================================================== - * os_system.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_system.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:18 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_SYSTEM_H_ -#define _OS_SYSTEM_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Values for osTvType - */ -#define OS_TV_PAL 0 -#define OS_TV_NTSC 1 -#define OS_TV_MPAL 2 - -/* - * Size of buffer the retains contents after NMI - */ -#define OS_APP_NMI_BUFSIZE 64 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - -extern s32 osRomType; /* Bulk or cartridge ROM. 0=cartridge 1=bulk */ -extern void *osRomBase; /* Rom base address of the game image */ -extern s32 osTvType; /* 0 = PAL, 1 = NTSC, 2 = MPAL */ -extern s32 osResetType; /* 0 = cold reset, 1 = NMI */ -extern s32 osCicId; -extern s32 osVersion; -extern u32 osMemSize; /* Memory Size */ -extern s32 osAppNMIBuffer[]; - -extern u64 osClockRate; - -extern OSIntMask __OSGlobalIntMask; /* global interrupt mask */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -extern void osInitialize(void); -extern void osExit(void); -extern u32 osGetMemSize(void); - -/* pre-NMI */ -extern s32 osAfterPreNMI(void); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_SYSTEM_H_ */ diff --git a/include/PR/os_thread.h b/include/PR/os_thread.h deleted file mode 100644 index 2bfed68e..00000000 --- a/include/PR/os_thread.h +++ /dev/null @@ -1,161 +0,0 @@ - -/*==================================================================== - * os_thread.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_thread.h,v $ - $Revision: 1.3 $ - $Date: 1999/06/15 12:39:40 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_THREAD_H_ -#define _OS_THREAD_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef s32 OSPri; -typedef s32 OSId; - -typedef union { - struct { - f32 f_odd; - f32 f_even; - } f; - f64 d; -} __OSfp; - -typedef struct { - u64 at, v0, v1, a0, a1, a2, a3; - u64 t0, t1, t2, t3, t4, t5, t6, t7; - u64 s0, s1, s2, s3, s4, s5, s6, s7; - u64 t8, t9; - u64 gp, sp, s8, ra; - u64 lo, hi; - u32 sr, pc, cause, badvaddr, rcp; - u32 fpcsr; - __OSfp fp0, fp2, fp4, fp6, fp8, fp10, fp12, fp14; - __OSfp fp16, fp18, fp20, fp22, fp24, fp26, fp28, fp30; -} __OSThreadContext; - -typedef struct { - u32 flag; - u32 count; - u64 time; -} __OSThreadprofile_s; - -typedef struct OSThread_s { - struct OSThread_s *next; /* run/mesg queue link */ - OSPri priority; /* run/mesg queue priority */ - struct OSThread_s **queue; /* queue thread is on */ - struct OSThread_s *tlnext; /* all threads queue link */ - u16 state; /* OS_STATE_* */ - u16 flags; /* flags for rmon */ - OSId id; /* id for debugging */ - int fp; /* thread has used fp unit */ - __OSThreadprofile_s *thprof; /* workarea for thread profiler */ - __OSThreadContext context; /* register/interrupt mask */ -} OSThread; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* Thread states */ - -#define OS_STATE_STOPPED (1 << 0) -#define OS_STATE_RUNNABLE (1 << 1) -#define OS_STATE_RUNNING (1 << 2) -#define OS_STATE_WAITING (1 << 3) - -/* Recommended thread priorities for the system threads */ - -#define OS_PRIORITY_MAX 255 -#define OS_PRIORITY_VIMGR 254 -#define OS_PRIORITY_RMON 250 -#define OS_PRIORITY_RMONSPIN 200 -#define OS_PRIORITY_PIMGR 150 -#define OS_PRIORITY_SIMGR 140 -#define OS_PRIORITY_APPMAX 127 -#define OS_PRIORITY_IDLE 0 /* Must be 0 */ - -/* For thread profiler */ -#define THPROF_IDMAX 64 -#define THPROF_STACKSIZE 256 - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Thread operations */ - -extern void osCreateThread(OSThread *, OSId, void (*)(void *), void *, void *, OSPri); -extern void osDestroyThread(OSThread *); -extern void osYieldThread(void); -extern void osStartThread(OSThread *); -extern void osStopThread(OSThread *); -extern OSId osGetThreadId(OSThread *); -extern void osSetThreadPri(OSThread *, OSPri); -extern OSPri osGetThreadPri(OSThread *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_THREAD_H_ */ diff --git a/include/PR/os_time.h b/include/PR/os_time.h deleted file mode 100644 index d6422db5..00000000 --- a/include/PR/os_time.h +++ /dev/null @@ -1,114 +0,0 @@ - -/*==================================================================== - * os_time.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_time.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:19 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_TIME_H_ -#define _OS_TIME_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure for time value - */ -typedef u64 OSTime; - -/* - * Structure for interval timer - */ -typedef struct OSTimer_s { - struct OSTimer_s *next; /* point to next timer in list */ - struct OSTimer_s *prev; /* point to previous timer in list */ - OSTime interval; /* duration set by user */ - OSTime value; /* time remaining before */ - /* timer fires */ - OSMesgQueue *mq; /* Message Queue */ - OSMesg msg; /* Message to send */ -} OSTimer; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Timer interface */ - -extern OSTime osGetTime(void); -extern void osSetTime(OSTime); -extern int osSetTimer(OSTimer *, OSTime, OSTime, - OSMesgQueue *, OSMesg); -extern int osStopTimer(OSTimer *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_TIME_H_ */ diff --git a/include/PR/os_tlb.h b/include/PR/os_tlb.h deleted file mode 100644 index a4ea6fa0..00000000 --- a/include/PR/os_tlb.h +++ /dev/null @@ -1,107 +0,0 @@ - -/*==================================================================== - * os_tlb.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_tlb.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:20 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_TLB_H_ -#define _OS_TLB_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef u32 OSPageMask; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Page size argument for TLB routines - */ -#define OS_PM_4K 0x0000000 -#define OS_PM_16K 0x0006000 -#define OS_PM_64K 0x001e000 -#define OS_PM_256K 0x007e000 -#define OS_PM_1M 0x01fe000 -#define OS_PM_4M 0x07fe000 -#define OS_PM_16M 0x1ffe000 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* TLB management routines */ - -extern void osMapTLB(s32, OSPageMask, void *, u32, u32, s32); -extern void osMapTLBRdb(void); -extern void osUnmapTLB(s32); -extern void osUnmapTLBAll(void); -extern void osSetTLBASID(s32); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_TLB_H_ */ diff --git a/include/PR/os_version.h b/include/PR/os_version.h deleted file mode 100644 index ff53cc9a..00000000 --- a/include/PR/os_version.h +++ /dev/null @@ -1,28 +0,0 @@ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. - - $RCSfile: os_version.h,v $ - $Revision: 1.2 $ - $Date: 1999/06/17 01:33:01 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_VERSION_H_ -#define _OS_VERSION_H_ - -#define VERSION_D 1 -#define VERSION_E 2 -#define VERSION_F 3 -#define VERSION_G 4 -#define VERSION_H 5 -#define VERSION_I 6 -#define VERSION_J 7 -#define VERSION_K 8 -#define VERSION_L 9 - -#define BUILD_VERSION VERSION_H - -#define OS_MAJOR_VERSION BUILD_VERSION_STRING /* major version */ -#define OS_MINOR_VERSION 0 /* patch level */ - -#endif /* !_OS_VERSION_H_ */ diff --git a/include/PR/os_vi.h b/include/PR/os_vi.h deleted file mode 100644 index 7fd3aad9..00000000 --- a/include/PR/os_vi.h +++ /dev/null @@ -1,298 +0,0 @@ - -/*==================================================================== - * os_vi.h - * - * Copyright 1995, Silicon Graphics, Inc. - * All Rights Reserved. - * - * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, - * Inc.; the contents of this file may not be disclosed to third - * parties, copied or duplicated in any form, in whole or in part, - * without the prior written permission of Silicon Graphics, Inc. - * - * RESTRICTED RIGHTS LEGEND: - * Use, duplication or disclosure by the Government is subject to - * restrictions as set forth in subdivision (c)(1)(ii) of the Rights - * in Technical Data and Computer Software clause at DFARS - * 252.227-7013, and/or in similar or successor clauses in the FAR, - * DOD or NASA FAR Supplement. Unpublished - rights reserved under the - * Copyright Laws of the United States. - *====================================================================*/ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. (Originated by SGI) - - $RCSfile: os_vi.h,v $ - $Revision: 1.1 $ - $Date: 1998/10/09 08:01:20 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_VI_H_ -#define _OS_VI_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include -#include "PR/os_thread.h" -#include "PR/os_message.h" - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -/* - * Structure to store VI register values that remain the same between 2 fields - */ -typedef struct { - u32 ctrl; - u32 width; - u32 burst; - u32 vSync; - u32 hSync; - u32 leap; - u32 hStart; - u32 xScale; - u32 vCurrent; -} OSViCommonRegs; - - -/* - * Structure to store VI register values that change between fields - */ -typedef struct { - u32 origin; - u32 yScale; - u32 vStart; - u32 vBurst; - u32 vIntr; -} OSViFieldRegs; - - -/* - * Structure for VI mode - */ -typedef struct { - u8 type; /* Mode type */ - OSViCommonRegs comRegs; /* Common registers for both fields */ - OSViFieldRegs fldRegs[2]; /* Registers for Field 1 & 2 */ -} OSViMode; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* - * Video Interface (VI) mode type - */ -#define OS_VI_NTSC_LPN1 0 /* NTSC */ -#define OS_VI_NTSC_LPF1 1 -#define OS_VI_NTSC_LAN1 2 -#define OS_VI_NTSC_LAF1 3 -#define OS_VI_NTSC_LPN2 4 -#define OS_VI_NTSC_LPF2 5 -#define OS_VI_NTSC_LAN2 6 -#define OS_VI_NTSC_LAF2 7 -#define OS_VI_NTSC_HPN1 8 -#define OS_VI_NTSC_HPF1 9 -#define OS_VI_NTSC_HAN1 10 -#define OS_VI_NTSC_HAF1 11 -#define OS_VI_NTSC_HPN2 12 -#define OS_VI_NTSC_HPF2 13 - -#define OS_VI_PAL_LPN1 14 /* PAL */ -#define OS_VI_PAL_LPF1 15 -#define OS_VI_PAL_LAN1 16 -#define OS_VI_PAL_LAF1 17 -#define OS_VI_PAL_LPN2 18 -#define OS_VI_PAL_LPF2 19 -#define OS_VI_PAL_LAN2 20 -#define OS_VI_PAL_LAF2 21 -#define OS_VI_PAL_HPN1 22 -#define OS_VI_PAL_HPF1 23 -#define OS_VI_PAL_HAN1 24 -#define OS_VI_PAL_HAF1 25 -#define OS_VI_PAL_HPN2 26 -#define OS_VI_PAL_HPF2 27 - -#define OS_VI_MPAL_LPN1 28 /* MPAL - mainly Brazil */ -#define OS_VI_MPAL_LPF1 29 -#define OS_VI_MPAL_LAN1 30 -#define OS_VI_MPAL_LAF1 31 -#define OS_VI_MPAL_LPN2 32 -#define OS_VI_MPAL_LPF2 33 -#define OS_VI_MPAL_LAN2 34 -#define OS_VI_MPAL_LAF2 35 -#define OS_VI_MPAL_HPN1 36 -#define OS_VI_MPAL_HPF1 37 -#define OS_VI_MPAL_HAN1 38 -#define OS_VI_MPAL_HAF1 39 -#define OS_VI_MPAL_HPN2 40 -#define OS_VI_MPAL_HPF2 41 - -#define OS_VI_FPAL_LPN1 42 /* FPAL - Full screen PAL */ -#define OS_VI_FPAL_LPF1 43 -#define OS_VI_FPAL_LAN1 44 -#define OS_VI_FPAL_LAF1 45 -#define OS_VI_FPAL_LPN2 46 -#define OS_VI_FPAL_LPF2 47 -#define OS_VI_FPAL_LAN2 48 -#define OS_VI_FPAL_LAF2 49 -#define OS_VI_FPAL_HPN1 50 -#define OS_VI_FPAL_HPF1 51 -#define OS_VI_FPAL_HAN1 52 -#define OS_VI_FPAL_HAF1 53 -#define OS_VI_FPAL_HPN2 54 -#define OS_VI_FPAL_HPF2 55 - -/* - * Video Interface (VI) special features - */ -#define OS_VI_GAMMA_ON 0x0001 -#define OS_VI_GAMMA_OFF 0x0002 -#define OS_VI_GAMMA_DITHER_ON 0x0004 -#define OS_VI_GAMMA_DITHER_OFF 0x0008 -#define OS_VI_DIVOT_ON 0x0010 -#define OS_VI_DIVOT_OFF 0x0020 -#define OS_VI_DITHER_FILTER_ON 0x0040 -#define OS_VI_DITHER_FILTER_OFF 0x0080 - -/* - * Video Interface (VI) mode attribute bit - */ -#define OS_VI_BIT_NONINTERLACE 0x0001 /* lo-res */ -#define OS_VI_BIT_INTERLACE 0x0002 /* lo-res */ -#define OS_VI_BIT_NORMALINTERLACE 0x0004 /* hi-res */ -#define OS_VI_BIT_DEFLICKINTERLACE 0x0008 /* hi-res */ -#define OS_VI_BIT_ANTIALIAS 0x0010 -#define OS_VI_BIT_POINTSAMPLE 0x0020 -#define OS_VI_BIT_16PIXEL 0x0040 -#define OS_VI_BIT_32PIXEL 0x0080 -#define OS_VI_BIT_LORES 0x0100 -#define OS_VI_BIT_HIRES 0x0200 -#define OS_VI_BIT_NTSC 0x0400 -#define OS_VI_BIT_PAL 0x0800 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - -extern OSViMode osViModeTable[]; /* Global VI mode table */ - -extern OSViMode osViModeNtscLpn1; /* Individual VI NTSC modes */ -extern OSViMode osViModeNtscLpf1; -extern OSViMode osViModeNtscLan1; -extern OSViMode osViModeNtscLaf1; -extern OSViMode osViModeNtscLpn2; -extern OSViMode osViModeNtscLpf2; -extern OSViMode osViModeNtscLan2; -extern OSViMode osViModeNtscLaf2; -extern OSViMode osViModeNtscHpn1; -extern OSViMode osViModeNtscHpf1; -extern OSViMode osViModeNtscHan1; -extern OSViMode osViModeNtscHaf1; -extern OSViMode osViModeNtscHpn2; -extern OSViMode osViModeNtscHpf2; - -extern OSViMode osViModePalLpn1; /* Individual VI PAL modes */ -extern OSViMode osViModePalLpf1; -extern OSViMode osViModePalLan1; -extern OSViMode osViModePalLaf1; -extern OSViMode osViModePalLpn2; -extern OSViMode osViModePalLpf2; -extern OSViMode osViModePalLan2; -extern OSViMode osViModePalLaf2; -extern OSViMode osViModePalHpn1; -extern OSViMode osViModePalHpf1; -extern OSViMode osViModePalHan1; -extern OSViMode osViModePalHaf1; -extern OSViMode osViModePalHpn2; -extern OSViMode osViModePalHpf2; - -extern OSViMode osViModeMpalLpn1; /* Individual VI MPAL modes */ -extern OSViMode osViModeMpalLpf1; -extern OSViMode osViModeMpalLan1; -extern OSViMode osViModeMpalLaf1; -extern OSViMode osViModeMpalLpn2; -extern OSViMode osViModeMpalLpf2; -extern OSViMode osViModeMpalLan2; -extern OSViMode osViModeMpalLaf2; -extern OSViMode osViModeMpalHpn1; -extern OSViMode osViModeMpalHpf1; -extern OSViMode osViModeMpalHan1; -extern OSViMode osViModeMpalHaf1; -extern OSViMode osViModeMpalHpn2; -extern OSViMode osViModeMpalHpf2; - -extern OSViMode osViModeFpalLpn1; /* Individual VI FPAL modes */ -extern OSViMode osViModeFpalLpf1; -extern OSViMode osViModeFpalLan1; -extern OSViMode osViModeFpalLaf1; -extern OSViMode osViModeFpalLpn2; -extern OSViMode osViModeFpalLpf2; -extern OSViMode osViModeFpalLan2; -extern OSViMode osViModeFpalLaf2; -extern OSViMode osViModeFpalHpn1; -extern OSViMode osViModeFpalHpf1; -extern OSViMode osViModeFpalHan1; -extern OSViMode osViModeFpalHaf1; -extern OSViMode osViModeFpalHpn2; -extern OSViMode osViModeFpalHpf2; - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Video interface (Vi) */ -extern u32 osViGetStatus(void); -extern u32 osViGetCurrentMode(void); -extern u32 osViGetCurrentLine(void); -extern u32 osViGetCurrentField(void); -extern void *osViGetCurrentFramebuffer(void); -extern void *osViGetNextFramebuffer(void); -extern void osViSetXScale(f32); -extern void osViSetYScale(f32); -extern void osViExtendVStart(u32); -extern void osViSetSpecialFeatures(u32); -extern void osViSetMode(OSViMode *); -extern void osViSetEvent(OSMesgQueue *, OSMesg, u32); -extern void osViSwapBuffer(void *); -extern void osViBlack(u8); -extern void osViFade(u8, u16); -extern void osViRepeatLine(u8); -extern void osCreateViManager(OSPri); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_VI_H_ */ diff --git a/include/PR/os_voice.h b/include/PR/os_voice.h deleted file mode 100644 index 6273a2cf..00000000 --- a/include/PR/os_voice.h +++ /dev/null @@ -1,108 +0,0 @@ - -/*---------------------------------------------------------------------* - Copyright (C) 1998 Nintendo. - - $RCSfile: os_voice.h,v $ - $Revision: 1.2 $ - $Date: 1999/07/13 08:36:42 $ - *---------------------------------------------------------------------*/ - -#ifndef _OS_VOICE_H_ -#define _OS_VOICE_H_ - -#ifdef _LANGUAGE_C_PLUS_PLUS -extern "C" { -#endif - -#include - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Type definitions - * - */ - -typedef struct { /* Voice Recognition System */ - OSMesgQueue *__mq; /* SI Message Queue */ - int __channel; /* Controller Port # */ - s32 __mode; - u8 cmd_status; /* Command Status */ -} OSVoiceHandle; - -typedef struct { /* Voice Recognition System */ - u16 warning; - u16 answer_num; /* 0...5 */ - u16 voice_level; - u16 voice_sn; - u16 voice_time; - u16 answer[5]; - u16 distance[5]; -} OSVoiceData; - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -/************************************************************************** - * - * Global definitions - * - */ - -/* definition for Voice Recognition System */ - -#define VOICE_WARN_TOO_SMALL 0x0400 -#define VOICE_WARN_TOO_LARGE 0x0800 -#define VOICE_WARN_NOT_FIT 0x4000 -#define VOICE_WARN_TOO_NOISY 0x8000 - -#define VOICE_STATUS_READY 0 -#define VOICE_STATUS_START 1 -#define VOICE_STATUS_CANCEL 3 -#define VOICE_STATUS_BUSY 5 -#define VOICE_STATUS_END 7 - - -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -/************************************************************************** - * - * Macro definitions - * - */ - - -/************************************************************************** - * - * Extern variables - * - */ - - -/************************************************************************** - * - * Function prototypes - * - */ - -/* Voice Recognition System */ -extern s32 osVoiceInit(OSMesgQueue *, OSVoiceHandle *, int); -extern s32 osVoiceCheckWord(u8 *data); -extern s32 osVoiceClearDictionary(OSVoiceHandle *, u8); -extern s32 osVoiceControlGain(OSVoiceHandle *, s32, s32); -extern s32 osVoiceSetWord(OSVoiceHandle *, u8 *); -extern s32 osVoiceStartReadData(OSVoiceHandle *); -extern s32 osVoiceStopReadData(OSVoiceHandle *); -extern s32 osVoiceGetReadData(OSVoiceHandle *, OSVoiceData *); -extern s32 osVoiceMaskDictionary(OSVoiceHandle *, u8 *, int); -extern void osVoiceCountSyllables(u8 *, u32 *); - - -#endif /* defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) */ - -#ifdef _LANGUAGE_C_PLUS_PLUS -} -#endif - -#endif /* !_OS_VOICE_H_ */ diff --git a/include/PR/rcp.h b/include/PR/rcp.h deleted file mode 100644 index 4ee40921..00000000 --- a/include/PR/rcp.h +++ /dev/null @@ -1,888 +0,0 @@ -#ifndef _RCP_H_ -#define _RCP_H_ - -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - -/************************************************************************** - * - * File: rcp.h - * - * This file contains register and bit definitions for RCP memory map. - * $Revision: 1.20 $ - * $Date: 1997/07/23 08:35:21 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/rcp.h,v $ - * - **************************************************************************/ - -#include -#include - -/********************************************************************** - * - * Here is a quick overview of the RCP memory map: - * - -0x0000_0000 .. 0x03ef_ffff RDRAM memory -0x03f0_0000 .. 0x03ff_ffff RDRAM registers - - RCP registers (see below) -0x0400_0000 .. 0x040f_ffff SP registers -0x0410_0000 .. 0x041f_ffff DP command registers -0x0420_0000 .. 0x042f_ffff DP span registers -0x0430_0000 .. 0x043f_ffff MI registers -0x0440_0000 .. 0x044f_ffff VI registers -0x0450_0000 .. 0x045f_ffff AI registers -0x0460_0000 .. 0x046f_ffff PI registers -0x0470_0000 .. 0x047f_ffff RI registers -0x0480_0000 .. 0x048f_ffff SI registers -0x0490_0000 .. 0x04ff_ffff unused - -0x0500_0000 .. 0x05ff_ffff cartridge domain 2 -0x0600_0000 .. 0x07ff_ffff cartridge domain 1 -0x0800_0000 .. 0x0fff_ffff cartridge domain 2 -0x1000_0000 .. 0x1fbf_ffff cartridge domain 1 - -0x1fc0_0000 .. 0x1fc0_07bf PIF Boot Rom (1984 bytes) -0x1fc0_07c0 .. 0x1fc0_07ff PIF (JoyChannel) RAM (64 bytes) -0x1fc0_0800 .. 0x1fcf_ffff Reserved -0x1fd0_0000 .. 0x7fff_ffff cartridge domain 1 -0x8000_0000 .. 0xffff_ffff external SysAD device - -The Indy development board use cartridge domain 1: -0x1000_0000 .. 0x10ff_ffff RAMROM -0x1800_0000 .. 0x1800_0003 GIO interrupt (6 bits valid in 4 bytes) -0x1800_0400 .. 0x1800_0403 GIO sync (6 bits valid in 4 bytes) -0x1800_0800 .. 0x1800_0803 CART interrupt (6 bits valid in 4 bytes) - - - -**************************************************************************/ - - -/************************************************************************* - * RDRAM Memory (Assumes that maximum size is 4 MB) - */ -#define RDRAM_0_START 0x00000000 -#define RDRAM_0_END 0x001FFFFF -#define RDRAM_1_START 0x00200000 -#define RDRAM_1_END 0x003FFFFF - -#define RDRAM_START RDRAM_0_START -#define RDRAM_END RDRAM_1_END - - -/************************************************************************* - * Address predicates - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -#define IS_RDRAM(x) ((unsigned)(x) >= RDRAM_START && \ - (unsigned)(x) < RDRAM_END) -#endif - - -/************************************************************************* - * RDRAM Registers (0x03f0_0000 .. 0x03ff_ffff) - */ -#define RDRAM_BASE_REG 0x03F00000 - -#define RDRAM_CONFIG_REG (RDRAM_BASE_REG+0x00) -#define RDRAM_DEVICE_TYPE_REG (RDRAM_BASE_REG+0x00) -#define RDRAM_DEVICE_ID_REG (RDRAM_BASE_REG+0x04) -#define RDRAM_DELAY_REG (RDRAM_BASE_REG+0x08) -#define RDRAM_MODE_REG (RDRAM_BASE_REG+0x0c) -#define RDRAM_REF_INTERVAL_REG (RDRAM_BASE_REG+0x10) -#define RDRAM_REF_ROW_REG (RDRAM_BASE_REG+0x14) -#define RDRAM_RAS_INTERVAL_REG (RDRAM_BASE_REG+0x18) -#define RDRAM_MIN_INTERVAL_REG (RDRAM_BASE_REG+0x1c) -#define RDRAM_ADDR_SELECT_REG (RDRAM_BASE_REG+0x20) -#define RDRAM_DEVICE_MANUF_REG (RDRAM_BASE_REG+0x24) - -#define RDRAM_0_DEVICE_ID 0 -#define RDRAM_1_DEVICE_ID 1 - -#define RDRAM_RESET_MODE 0 -#define RDRAM_ACTIVE_MODE 1 -#define RDRAM_STANDBY_MODE 2 - -#define RDRAM_LENGTH (2*512*2048) -#define RDRAM_0_BASE_ADDRESS (RDRAM_0_DEVICE_ID*RDRAM_LENGTH) -#define RDRAM_1_BASE_ADDRESS (RDRAM_1_DEVICE_ID*RDRAM_LENGTH) - -#define RDRAM_0_CONFIG 0x00000 -#define RDRAM_1_CONFIG 0x00400 -#define RDRAM_GLOBAL_CONFIG 0x80000 - - -/************************************************************************* - * PIF Physical memory map (total size = 2 KB) - * - * Size Description Mode - * 1FC007FF +-------+-----------------+-----+ - * | 64 B | JoyChannel RAM | R/W | - * 1FC007C0 +-------+-----------------+-----+ - * |1984 B | Boot ROM | * | * = Reserved - * 1FC00000 +-------+-----------------+-----+ - * - */ -#define PIF_ROM_START 0x1FC00000 -#define PIF_ROM_END 0x1FC007BF -#define PIF_RAM_START 0x1FC007C0 -#define PIF_RAM_END 0x1FC007FF - - -/************************************************************************* - * Controller channel - * Each game controller channel has 4 error bits that are defined in bit 6-7 of - * the Rx and Tx data size area bytes. Programmers need to clear these bits - * when setting the Tx/Rx size area values for a channel - */ -#define CHNL_ERR_NORESP 0x80 /* Bit 7 (Rx): No response error */ -#define CHNL_ERR_OVERRUN 0x40 /* Bit 6 (Rx): Overrun error */ -#define CHNL_ERR_FRAME 0x80 /* Bit 7 (Tx): Frame error */ -#define CHNL_ERR_COLLISION 0x40 /* Bit 6 (Tx): Collision error */ - -#define CHNL_ERR_MASK 0xC0 /* Bit 6-7: channel errors */ - - -/************************************************************************* - * External device info - */ -#define DEVICE_TYPE_CART 0 /* ROM cartridge */ -#define DEVICE_TYPE_BULK 1 /* ROM bulk */ -#define DEVICE_TYPE_64DD 2 /* 64 Disk Drive */ -#define DEVICE_TYPE_SRAM 3 /* SRAM */ - -/************************************************************************* - * SP Memory - */ -#define SP_DMEM_START 0x04000000 /* read/write */ -#define SP_DMEM_END 0x04000FFF -#define SP_IMEM_START 0x04001000 /* read/write */ -#define SP_IMEM_END 0x04001FFF - -/************************************************************************* - * SP CP0 Registers - */ - -#define SP_BASE_REG 0x04040000 - -/* SP memory address (R/W): [11:0] DMEM/IMEM address; [12] 0=DMEM,1=IMEM */ -#define SP_MEM_ADDR_REG (SP_BASE_REG+0x00) /* Master */ - -/* SP DRAM DMA address (R/W): [23:0] RDRAM address */ -#define SP_DRAM_ADDR_REG (SP_BASE_REG+0x04) /* Slave */ - -/* SP read DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ -/* direction: I/DMEM <- RDRAM */ -#define SP_RD_LEN_REG (SP_BASE_REG+0x08) /* R/W: read len */ - -/* SP write DMA length (R/W): [11:0] length, [19:12] count, [31:20] skip */ -/* direction: I/DMEM -> RDRAM */ -#define SP_WR_LEN_REG (SP_BASE_REG+0x0C) /* R/W: write len */ - -/* SP status (R/W): [14:0] valid bits; see below for write/read mode */ -#define SP_STATUS_REG (SP_BASE_REG+0x10) - -/* SP DMA full (R): [0] valid bit; dma full */ -#define SP_DMA_FULL_REG (SP_BASE_REG+0x14) - -/* SP DMA busy (R): [0] valid bit; dma busy */ -#define SP_DMA_BUSY_REG (SP_BASE_REG+0x18) - -/* SP semaphore (R/W): Read: [0] semaphore flag (set on read) */ -/* Write: [] clear semaphore flag */ -#define SP_SEMAPHORE_REG (SP_BASE_REG+0x1C) - -/* SP PC (R/W): [11:0] program counter */ -#define SP_PC_REG 0x04080000 - -/* SP MEM address: bit 12 specifies if address is IMEM or DMEM */ -#define SP_DMA_DMEM 0x0000 /* Bit 12: 0=DMEM, 1=IMEM */ -#define SP_DMA_IMEM 0x1000 /* Bit 12: 0=DMEM, 1=IMEM */ - -/* - * Values to clear/set bit in status reg (SP_STATUS_REG - write) - */ -#define SP_CLR_HALT 0x00001 /* Bit 0: clear halt */ -#define SP_SET_HALT 0x00002 /* Bit 1: set halt */ -#define SP_CLR_BROKE 0x00004 /* Bit 2: clear broke */ -#define SP_CLR_INTR 0x00008 /* Bit 3: clear intr */ -#define SP_SET_INTR 0x00010 /* Bit 4: set intr */ -#define SP_CLR_SSTEP 0x00020 /* Bit 5: clear sstep */ -#define SP_SET_SSTEP 0x00040 /* Bit 6: set sstep */ -#define SP_CLR_INTR_BREAK 0x00080 /* Bit 7: clear intr on break */ -#define SP_SET_INTR_BREAK 0x00100 /* Bit 8: set intr on break */ -#define SP_CLR_SIG0 0x00200 /* Bit 9: clear signal 0 */ -#define SP_SET_SIG0 0x00400 /* Bit 10: set signal 0 */ -#define SP_CLR_SIG1 0x00800 /* Bit 11: clear signal 1 */ -#define SP_SET_SIG1 0x01000 /* Bit 12: set signal 1 */ -#define SP_CLR_SIG2 0x02000 /* Bit 13: clear signal 2 */ -#define SP_SET_SIG2 0x04000 /* Bit 14: set signal 2 */ -#define SP_CLR_SIG3 0x08000 /* Bit 15: clear signal 3 */ -#define SP_SET_SIG3 0x10000 /* Bit 16: set signal 3 */ -#define SP_CLR_SIG4 0x20000 /* Bit 17: clear signal 4 */ -#define SP_SET_SIG4 0x40000 /* Bit 18: set signal 4 */ -#define SP_CLR_SIG5 0x80000 /* Bit 19: clear signal 5 */ -#define SP_SET_SIG5 0x100000 /* Bit 20: set signal 5 */ -#define SP_CLR_SIG6 0x200000 /* Bit 21: clear signal 6 */ -#define SP_SET_SIG6 0x400000 /* Bit 22: set signal 6 */ -#define SP_CLR_SIG7 0x800000 /* Bit 23: clear signal 7 */ -#define SP_SET_SIG7 0x1000000 /* Bit 24: set signal 7 */ - -/* - * Patterns to interpret status reg (SP_STATUS_REG - read) - */ -#define SP_STATUS_HALT 0x001 /* Bit 0: halt */ -#define SP_STATUS_BROKE 0x002 /* Bit 1: broke */ -#define SP_STATUS_DMA_BUSY 0x004 /* Bit 2: dma busy */ -#define SP_STATUS_DMA_FULL 0x008 /* Bit 3: dma full */ -#define SP_STATUS_IO_FULL 0x010 /* Bit 4: io full */ -#define SP_STATUS_SSTEP 0x020 /* Bit 5: single step */ -#define SP_STATUS_INTR_BREAK 0x040 /* Bit 6: interrupt on break */ -#define SP_STATUS_SIG0 0x080 /* Bit 7: signal 0 set */ -#define SP_STATUS_SIG1 0x100 /* Bit 8: signal 1 set */ -#define SP_STATUS_SIG2 0x200 /* Bit 9: signal 2 set */ -#define SP_STATUS_SIG3 0x400 /* Bit 10: signal 3 set */ -#define SP_STATUS_SIG4 0x800 /* Bit 11: signal 4 set */ -#define SP_STATUS_SIG5 0x1000 /* Bit 12: signal 5 set */ -#define SP_STATUS_SIG6 0x2000 /* Bit 13: signal 6 set */ -#define SP_STATUS_SIG7 0x4000 /* Bit 14: signal 7 set */ - -/* - * Use of SIG bits - */ -#define SP_CLR_YIELD SP_CLR_SIG0 -#define SP_SET_YIELD SP_SET_SIG0 -#define SP_STATUS_YIELD SP_STATUS_SIG0 -#define SP_CLR_YIELDED SP_CLR_SIG1 -#define SP_SET_YIELDED SP_SET_SIG1 -#define SP_STATUS_YIELDED SP_STATUS_SIG1 -#define SP_CLR_TASKDONE SP_CLR_SIG2 -#define SP_SET_TASKDONE SP_SET_SIG2 -#define SP_STATUS_TASKDONE SP_STATUS_SIG2 -#define SP_CLR_RSPSIGNAL SP_CLR_SIG3 -#define SP_SET_RSPSIGNAL SP_SET_SIG3 -#define SP_STATUS_RSPSIGNAL SP_STATUS_SIG3 -#define SP_CLR_CPUSIGNAL SP_CLR_SIG4 -#define SP_SET_CPUSIGNAL SP_SET_SIG4 -#define SP_STATUS_CPUSIGNAL SP_STATUS_SIG4 - -/* SP IMEM BIST REG (R/W): [6:0] BIST status bits; see below for detail */ -#define SP_IBIST_REG 0x04080004 - -/* - * Patterns to interpret status reg (SP_BIST_REG - write) - */ -#define SP_IBIST_CHECK 0x01 /* Bit 0: BIST check */ -#define SP_IBIST_GO 0x02 /* Bit 1: BIST go */ -#define SP_IBIST_CLEAR 0x04 /* Bit 2: BIST clear */ - -/* - * Patterns to interpret status reg (SP_BIST_REG - read) - */ -/* First 2 bits are same as in write mode: - * Bit 0: BIST check; Bit 1: BIST go - */ -#define SP_IBIST_DONE 0x04 /* Bit 2: BIST done */ -#define SP_IBIST_FAILED 0x78 /* Bit [6:3]: BIST fail */ - - -/************************************************************************* - * DP Command Registers - */ -#define DPC_BASE_REG 0x04100000 - -/* DP CMD DMA start (R/W): [23:0] DMEM/RDRAM start address */ -#define DPC_START_REG (DPC_BASE_REG+0x00) - -/* DP CMD DMA end (R/W): [23:0] DMEM/RDRAM end address */ -#define DPC_END_REG (DPC_BASE_REG+0x04) - -/* DP CMD DMA end (R): [23:0] DMEM/RDRAM current address */ -#define DPC_CURRENT_REG (DPC_BASE_REG+0x08) - -/* DP CMD status (R/W): [9:0] valid bits - see below for definitions */ -#define DPC_STATUS_REG (DPC_BASE_REG+0x0C) - -/* DP clock counter (R): [23:0] clock counter */ -#define DPC_CLOCK_REG (DPC_BASE_REG+0x10) - -/* DP buffer busy counter (R): [23:0] clock counter */ -#define DPC_BUFBUSY_REG (DPC_BASE_REG+0x14) - -/* DP pipe busy counter (R): [23:0] clock counter */ -#define DPC_PIPEBUSY_REG (DPC_BASE_REG+0x18) - -/* DP TMEM load counter (R): [23:0] clock counter */ -#define DPC_TMEM_REG (DPC_BASE_REG+0x1C) - -/* - * Values to clear/set bit in status reg (DPC_STATUS_REG - write) - */ -#define DPC_CLR_XBUS_DMEM_DMA 0x0001 /* Bit 0: clear xbus_dmem_dma */ -#define DPC_SET_XBUS_DMEM_DMA 0x0002 /* Bit 1: set xbus_dmem_dma */ -#define DPC_CLR_FREEZE 0x0004 /* Bit 2: clear freeze */ -#define DPC_SET_FREEZE 0x0008 /* Bit 3: set freeze */ -#define DPC_CLR_FLUSH 0x0010 /* Bit 4: clear flush */ -#define DPC_SET_FLUSH 0x0020 /* Bit 5: set flush */ -#define DPC_CLR_TMEM_CTR 0x0040 /* Bit 6: clear tmem ctr */ -#define DPC_CLR_PIPE_CTR 0x0080 /* Bit 7: clear pipe ctr */ -#define DPC_CLR_CMD_CTR 0x0100 /* Bit 8: clear cmd ctr */ -#define DPC_CLR_CLOCK_CTR 0x0200 /* Bit 9: clear clock ctr */ - -/* - * Patterns to interpret status reg (DPC_STATUS_REG - read) - */ -#define DPC_STATUS_XBUS_DMEM_DMA 0x001 /* Bit 0: xbus_dmem_dma */ -#define DPC_STATUS_FREEZE 0x002 /* Bit 1: freeze */ -#define DPC_STATUS_FLUSH 0x004 /* Bit 2: flush */ -/*#define DPC_STATUS_FROZEN 0x008*/ /* Bit 3: frozen */ -#define DPC_STATUS_START_GCLK 0x008 /* Bit 3: start gclk */ -#define DPC_STATUS_TMEM_BUSY 0x010 /* Bit 4: tmem busy */ -#define DPC_STATUS_PIPE_BUSY 0x020 /* Bit 5: pipe busy */ -#define DPC_STATUS_CMD_BUSY 0x040 /* Bit 6: cmd busy */ -#define DPC_STATUS_CBUF_READY 0x080 /* Bit 7: cbuf ready */ -#define DPC_STATUS_DMA_BUSY 0x100 /* Bit 8: dma busy */ -#define DPC_STATUS_END_VALID 0x200 /* Bit 9: end valid */ -#define DPC_STATUS_START_VALID 0x400 /* Bit 10: start valid */ - - -/************************************************************************* - * DP Span Registers - */ -#define DPS_BASE_REG 0x04200000 - -/* DP tmem bist (R/W): [10:0] BIST status bits; see below for detail */ -#define DPS_TBIST_REG (DPS_BASE_REG+0x00) - -/* DP span test mode (R/W): [0] Span buffer test access enable */ -#define DPS_TEST_MODE_REG (DPS_BASE_REG+0x04) - -/* DP span buffer test address (R/W): [6:0] bits; see below for detail */ -#define DPS_BUFTEST_ADDR_REG (DPS_BASE_REG+0x08) - -/* DP span buffer test data (R/W): [31:0] span buffer data */ -#define DPS_BUFTEST_DATA_REG (DPS_BASE_REG+0x0C) - -/* - * Patterns to interpret status reg (DPS_TMEM_BIST_REG - write) - */ -#define DPS_TBIST_CHECK 0x01 /* Bit 0: BIST check */ -#define DPS_TBIST_GO 0x02 /* Bit 1: BIST go */ -#define DPS_TBIST_CLEAR 0x04 /* Bit 2: BIST clear */ - -/* - * Patterns to interpret status reg (DPS_TMEM_BIST_REG - read) - */ -/* First 2 bits are same as in write mode: - * Bit 0: BIST check; Bit 1: BIST go - */ -#define DPS_TBIST_DONE 0x004 /* Bit 2: BIST done */ -#define DPS_TBIST_FAILED 0x7F8 /* Bit [10:3]: BIST fail */ - - -/************************************************************************* - * MIPS Interface (MI) Registers - */ -#define MI_BASE_REG 0x04300000 - -/* - * MI init mode (W): [6:0] init length, [7] clear init mode, [8] set init mode - * [9/10] clear/set ebus test mode, [11] clear DP interrupt - * (R): [6:0] init length, [7] init mode, [8] ebus test mode - */ -#define MI_INIT_MODE_REG (MI_BASE_REG+0x00) -#define MI_MODE_REG MI_INIT_MODE_REG - -/* - * Values to clear/set bit in mode reg (MI_MODE_REG - write) - */ -#define MI_CLR_INIT 0x0080 /* Bit 7: clear init mode */ -#define MI_SET_INIT 0x0100 /* Bit 8: set init mode */ -#define MI_CLR_EBUS 0x0200 /* Bit 9: clear ebus test */ -#define MI_SET_EBUS 0x0400 /* Bit 10: set ebus test mode */ -#define MI_CLR_DP_INTR 0x0800 /* Bit 11: clear dp interrupt */ -#define MI_CLR_RDRAM 0x1000 /* Bit 12: clear RDRAM reg */ -#define MI_SET_RDRAM 0x2000 /* Bit 13: set RDRAM reg mode */ - -/* - * Patterns to interpret mode reg (MI_MODE_REG - read) - */ -#define MI_MODE_INIT 0x0080 /* Bit 7: init mode */ -#define MI_MODE_EBUS 0x0100 /* Bit 8: ebus test mode */ -#define MI_MODE_RDRAM 0x0200 /* Bit 9: RDRAM reg mode */ - -/* MI version (R): [7:0] io, [15:8] rac, [23:16] rdp, [31:24] rsp */ -#define MI_VERSION_REG (MI_BASE_REG+0x04) -#define MI_NOOP_REG MI_VERSION_REG - -/* MI interrupt (R): [5:0] valid bits - see below for bit patterns */ -#define MI_INTR_REG (MI_BASE_REG+0x08) - -/* - * MI interrupt mask (W): [11:0] valid bits - see below for bit patterns - * (R): [5:0] valid bits - see below for bit patterns - */ -#define MI_INTR_MASK_REG (MI_BASE_REG+0x0C) - -/* - * The following are values to check for interrupt setting (MI_INTR_REG) - */ -#define MI_INTR_SP 0x01 /* Bit 0: SP intr */ -#define MI_INTR_SI 0x02 /* Bit 1: SI intr */ -#define MI_INTR_AI 0x04 /* Bit 2: AI intr */ -#define MI_INTR_VI 0x08 /* Bit 3: VI intr */ -#define MI_INTR_PI 0x10 /* Bit 4: PI intr */ -#define MI_INTR_DP 0x20 /* Bit 5: DP intr */ - -/* - * The following are values to clear/set various interrupt bit mask - * They can be ORed together to manipulate multiple bits - * (MI_INTR_MASK_REG - write) - */ -#define MI_INTR_MASK_CLR_SP 0x0001 /* Bit 0: clear SP mask */ -#define MI_INTR_MASK_SET_SP 0x0002 /* Bit 1: set SP mask */ -#define MI_INTR_MASK_CLR_SI 0x0004 /* Bit 2: clear SI mask */ -#define MI_INTR_MASK_SET_SI 0x0008 /* Bit 3: set SI mask */ -#define MI_INTR_MASK_CLR_AI 0x0010 /* Bit 4: clear AI mask */ -#define MI_INTR_MASK_SET_AI 0x0020 /* Bit 5: set AI mask */ -#define MI_INTR_MASK_CLR_VI 0x0040 /* Bit 6: clear VI mask */ -#define MI_INTR_MASK_SET_VI 0x0080 /* Bit 7: set VI mask */ -#define MI_INTR_MASK_CLR_PI 0x0100 /* Bit 8: clear PI mask */ -#define MI_INTR_MASK_SET_PI 0x0200 /* Bit 9: set PI mask */ -#define MI_INTR_MASK_CLR_DP 0x0400 /* Bit 10: clear DP mask */ -#define MI_INTR_MASK_SET_DP 0x0800 /* Bit 11: set DP mask */ - -/* - * The following are values to check for interrupt mask setting - * (MI_INTR_MASK_REG - read) - */ -#define MI_INTR_MASK_SP 0x01 /* Bit 0: SP intr mask */ -#define MI_INTR_MASK_SI 0x02 /* Bit 1: SI intr mask */ -#define MI_INTR_MASK_AI 0x04 /* Bit 2: AI intr mask */ -#define MI_INTR_MASK_VI 0x08 /* Bit 3: VI intr mask */ -#define MI_INTR_MASK_PI 0x10 /* Bit 4: PI intr mask */ -#define MI_INTR_MASK_DP 0x20 /* Bit 5: DP intr mask */ - - -/************************************************************************* - * Video Interface (VI) Registers - */ -#define VI_BASE_REG 0x04400000 - -/* VI status/control (R/W): [15-0] valid bits: - * [1:0] = type[1:0] (pixel size) - * 0: blank (no data, no sync) - * 1: reserved - * 2: 5/5/5/3 ("16" bit) - * 3: 8/8/8/8 (32 bit) - * [2] = gamma_dither_enable (normally on, unless "special effect") - * [3] = gamma_enable (normally on, unless MPEG/JPEG) - * [4] = divot_enable (normally on if antialiased, unless decal lines) - * [5] = reserved - always off - * [6] = serrate (always on if interlaced, off if not) - * [7] = reserved - diagnostics only - * [9:8] = anti-alias (aa) mode[1:0] - * 0: aa & resamp (always fetch extra lines) - * 1: aa & resamp (fetch extra lines if needed) - * 2: resamp only (treat as all fully covered) - * 3: neither (replicate pixels, no interpolate) - * [11] = reserved - diagnostics only - * [15:12] = reserved - * - */ -#define VI_STATUS_REG (VI_BASE_REG+0x00) -#define VI_CONTROL_REG VI_STATUS_REG - -/* VI origin (R/W): [23:0] frame buffer origin in bytes */ -#define VI_ORIGIN_REG (VI_BASE_REG+0x04) -#define VI_DRAM_ADDR_REG VI_ORIGIN_REG - -/* VI width (R/W): [11:0] frame buffer line width in pixels */ -#define VI_WIDTH_REG (VI_BASE_REG+0x08) -#define VI_H_WIDTH_REG VI_WIDTH_REG - -/* VI vertical intr (R/W): [9:0] interrupt when current half-line = V_INTR */ -#define VI_INTR_REG (VI_BASE_REG+0x0C) -#define VI_V_INTR_REG VI_INTR_REG - -/* - * VI current vertical line (R/W): [9:0] current half line, sampled once per - * line (the lsb of V_CURRENT is constant within a field, and in - * interlaced modes gives the field number - which is constant for non- - * interlaced modes) - * - Any write to this register will clear interrupt line - */ -#define VI_CURRENT_REG (VI_BASE_REG+0x10) -#define VI_V_CURRENT_LINE_REG VI_CURRENT_REG - -/* - * VI video timing (R/W): [ 7: 0] horizontal sync width in pixels, - * [15: 8] color burst width in pixels, - * [19:16] vertical sync width in half lines, - * [29:20] start of color burst in pixels from h-sync - */ -#define VI_BURST_REG (VI_BASE_REG+0x14) -#define VI_TIMING_REG VI_BURST_REG - -/* VI vertical sync (R/W): [9:0] number of half-lines per field */ -#define VI_V_SYNC_REG (VI_BASE_REG+0x18) - -/* VI horizontal sync (R/W): [11: 0] total duration of a line in 1/4 pixel - * [20:16] a 5-bit leap pattern used for PAL only - * (h_sync_period) - */ -#define VI_H_SYNC_REG (VI_BASE_REG+0x1C) - -/* - * VI horizontal sync leap (R/W): [11: 0] identical to h_sync_period - * [27:16] identical to h_sync_period - */ -#define VI_LEAP_REG (VI_BASE_REG+0x20) -#define VI_H_SYNC_LEAP_REG VI_LEAP_REG - -/* - * VI horizontal video (R/W): [ 9: 0] end of active video in screen pixels - * : [25:16] start of active video in screen pixels - */ -#define VI_H_START_REG (VI_BASE_REG+0x24) -#define VI_H_VIDEO_REG VI_H_START_REG - -/* - * VI vertical video (R/W): [ 9: 0] end of active video in screen half-lines - * : [25:16] start of active video in screen half-lines - */ -#define VI_V_START_REG (VI_BASE_REG+0x28) -#define VI_V_VIDEO_REG VI_V_START_REG - -/* - * VI vertical burst (R/W): [ 9: 0] end of color burst enable in half-lines - * : [25:16] start of color burst enable in half-lines - */ -#define VI_V_BURST_REG (VI_BASE_REG+0x2C) - -/* VI x-scale (R/W): [11: 0] 1/horizontal scale up factor (2.10 format) - * [27:16] horizontal subpixel offset (2.10 format) - */ -#define VI_X_SCALE_REG (VI_BASE_REG+0x30) - -/* VI y-scale (R/W): [11: 0] 1/vertical scale up factor (2.10 format) - * [27:16] vertical subpixel offset (2.10 format) - */ -#define VI_Y_SCALE_REG (VI_BASE_REG+0x34) - -/* - * Patterns to interpret VI_CONTROL_REG - */ -#define VI_CTRL_TYPE_16 0x00002 /* [1:0] pixel size: 16 bit */ -#define VI_CTRL_TYPE_32 0x00003 /* [1:0] pixel size: 32 bit */ -#define VI_CTRL_GAMMA_DITHER_ON 0x00004 /* 2: default = on */ -#define VI_CTRL_GAMMA_ON 0x00008 /* 3: default = on */ -#define VI_CTRL_DIVOT_ON 0x00010 /* 4: default = on */ -#define VI_CTRL_SERRATE_ON 0x00040 /* 6: on if interlaced */ -#define VI_CTRL_ANTIALIAS_MASK 0x00300 /* [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_1 0x00100 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_2 0x00200 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_ANTIALIAS_MODE_3 0x00300 /* Bit [9:8] anti-alias mode */ -#define VI_CTRL_PIXEL_ADV_MASK 0x01000 /* [15:12] pixel advance mode? */ -#define VI_CTRL_PIXEL_ADV_1 0x01000 /* Bit [15:12] pixel advance mode? */ -#define VI_CTRL_PIXEL_ADV_2 0x02000 /* Bit [15:12] pixel advance mode? */ -#define VI_CTRL_PIXEL_ADV_3 0x03000 /* Bit [15:12] pixel advance mode? */ -#define VI_CTRL_DITHER_FILTER_ON 0x10000 /* 16: dither-filter mode */ - -/* - * Possible video clocks (NTSC or PAL) - */ -#define VI_NTSC_CLOCK 48681812 /* Hz = 48.681812 MHz */ -#define VI_PAL_CLOCK 49656530 /* Hz = 49.656530 MHz */ -#define VI_MPAL_CLOCK 48628316 /* Hz = 48.628316 MHz */ - - -/************************************************************************* - * Audio Interface (AI) Registers - * - * The address and length registers are double buffered; that is, they - * can be written twice before becoming full. - * The address must be written before the length. - */ -#define AI_BASE_REG 0x04500000 - -/* AI DRAM address (W): [23:0] starting RDRAM address (8B-aligned) */ -#define AI_DRAM_ADDR_REG (AI_BASE_REG+0x00) /* R0: DRAM address */ - -/* AI length (R/W): [14:0] transfer length (v1.0) - Bottom 3 bits are ignored */ -/* [17:0] transfer length (v2.0) - Bottom 3 bits are ignored */ -#define AI_LEN_REG (AI_BASE_REG+0x04) /* R1: Length */ - -/* AI control (W): [0] DMA enable - if LSB == 1, DMA is enabled */ -#define AI_CONTROL_REG (AI_BASE_REG+0x08) /* R2: DMA Control */ - -/* - * AI status (R): [31]/[0] ai_full (addr & len buffer full), [30] ai_busy - * Note that a 1->0 transition in ai_full will set interrupt - * (W): clear audio interrupt - */ -#define AI_STATUS_REG (AI_BASE_REG+0x0C) /* R3: Status */ - -/* - * AI DAC sample period register (W): [13:0] dac rate - * - vid_clock/(dperiod + 1) is the DAC sample rate - * - (dperiod + 1) >= 66 * (aclockhp + 1) must be true - */ -#define AI_DACRATE_REG (AI_BASE_REG+0x10) /* R4: DAC rate 14-lsb*/ - -/* - * AI bit rate (W): [3:0] bit rate (abus clock half period register - aclockhp) - * - vid_clock/(2 * (aclockhp + 1)) is the DAC clock rate - * - The abus clock stops if aclockhp is zero - */ -#define AI_BITRATE_REG (AI_BASE_REG+0x14) /* R5: Bit rate 4-lsb */ - -/* Value for control register */ -#define AI_CONTROL_DMA_ON 0x01 /* LSB = 1: DMA enable*/ -#define AI_CONTROL_DMA_OFF 0x00 /* LSB = 1: DMA enable*/ - -/* Value for status register */ -#define AI_STATUS_FIFO_FULL 0x80000000 /* Bit 31: full */ -#define AI_STATUS_DMA_BUSY 0x40000000 /* Bit 30: busy */ - -/* DAC rate = video clock / audio frequency - * - DAC rate >= (66 * Bit rate) must be true - */ -#define AI_MAX_DAC_RATE 16384 /* 14-bit+1 */ -#define AI_MIN_DAC_RATE 132 - -/* Bit rate <= (DAC rate / 66) */ -#define AI_MAX_BIT_RATE 16 /* 4-bit+1 */ -#define AI_MIN_BIT_RATE 2 - -/* - * Maximum and minimum values for audio frequency based on video clocks - * max frequency = (video clock / min dac rate) - * min frequency = (video clock / max dac rate) - */ -#define AI_NTSC_MAX_FREQ 368000 /* 368 KHz */ -#define AI_NTSC_MIN_FREQ 3000 /* 3 KHz ~ 2971 Hz */ - -#define AI_PAL_MAX_FREQ 376000 /* 376 KHz */ -#define AI_PAL_MIN_FREQ 3050 /* 3 KHz ~ 3031 Hz */ - -#define AI_MPAL_MAX_FREQ 368000 /* 368 KHz */ -#define AI_MPAL_MIN_FREQ 3000 /* 3 KHz ~ 2968 Hz */ - - -/************************************************************************* - * Peripheral Interface (PI) Registers - */ -#define PI_BASE_REG 0x04600000 - -/* PI DRAM address (R/W): [23:0] starting RDRAM address */ -#define PI_DRAM_ADDR_REG (PI_BASE_REG+0x00) /* DRAM address */ - -/* PI pbus (cartridge) address (R/W): [31:0] starting AD16 address */ -#define PI_CART_ADDR_REG (PI_BASE_REG+0x04) - -/* PI read length (R/W): [23:0] read data length */ -#define PI_RD_LEN_REG (PI_BASE_REG+0x08) - -/* PI write length (R/W): [23:0] write data length */ -#define PI_WR_LEN_REG (PI_BASE_REG+0x0C) - -/* - * PI status (R): [0] DMA busy, [1] IO busy, [2], error - * (W): [0] reset controller (and abort current op), [1] clear intr - */ -#define PI_STATUS_REG (PI_BASE_REG+0x10) - -/* PI dom1 latency (R/W): [7:0] domain 1 device latency */ -#define PI_BSD_DOM1_LAT_REG (PI_BASE_REG+0x14) - -/* PI dom1 pulse width (R/W): [7:0] domain 1 device R/W strobe pulse width */ -#define PI_BSD_DOM1_PWD_REG (PI_BASE_REG+0x18) - -/* PI dom1 page size (R/W): [3:0] domain 1 device page size */ -#define PI_BSD_DOM1_PGS_REG (PI_BASE_REG+0x1C) /* page size */ - -/* PI dom1 release (R/W): [1:0] domain 1 device R/W release duration */ -#define PI_BSD_DOM1_RLS_REG (PI_BASE_REG+0x20) - -/* PI dom2 latency (R/W): [7:0] domain 2 device latency */ -#define PI_BSD_DOM2_LAT_REG (PI_BASE_REG+0x24) /* Domain 2 latency */ - -/* PI dom2 pulse width (R/W): [7:0] domain 2 device R/W strobe pulse width */ -#define PI_BSD_DOM2_PWD_REG (PI_BASE_REG+0x28) /* pulse width */ - -/* PI dom2 page size (R/W): [3:0] domain 2 device page size */ -#define PI_BSD_DOM2_PGS_REG (PI_BASE_REG+0x2C) /* page size */ - -/* PI dom2 release (R/W): [1:0] domain 2 device R/W release duration */ -#define PI_BSD_DOM2_RLS_REG (PI_BASE_REG+0x30) /* release duration */ - -#define PI_DOMAIN1_REG PI_BSD_DOM1_LAT_REG -#define PI_DOMAIN2_REG PI_BSD_DOM2_LAT_REG - -#define PI_DOM_LAT_OFS 0x00 -#define PI_DOM_PWD_OFS 0x04 -#define PI_DOM_PGS_OFS 0x08 -#define PI_DOM_RLS_OFS 0x0C - -/* - * PI status register has 3 bits active when read from (PI_STATUS_REG - read) - * Bit 0: DMA busy - set when DMA is in progress - * Bit 1: IO busy - set when IO is in progress - * Bit 2: Error - set when CPU issues IO request while DMA is busy - */ -#define PI_STATUS_ERROR 0x04 -#define PI_STATUS_IO_BUSY 0x02 -#define PI_STATUS_DMA_BUSY 0x01 - -/* PI status register has 2 bits active when written to: - * Bit 0: When set, reset PIC - * Bit 1: When set, clear interrupt flag - * The values of the two bits can be ORed together to both reset PIC and - * clear interrupt at the same time. - * - * Note: - * - The PIC does generate an interrupt at the end of each DMA. CPU - * needs to clear the interrupt flag explicitly (from an interrupt - * handler) by writing into the STATUS register with bit 1 set. - * - * - When a DMA completes, the interrupt flag is set. CPU can issue - * another request even while the interrupt flag is set (as long as - * PIC is idle). However, it is the CPU's responsibility for - * maintaining accurate correspondence between DMA completions and - * interrupts. - * - * - When PIC is reset, if PIC happens to be busy, an interrupt will - * be generated as PIC returns to idle. Otherwise, no interrupt will - * be generated and PIC remains idle. - */ -/* - * Values to clear interrupt/reset PIC (PI_STATUS_REG - write) - */ -#define PI_STATUS_RESET 0x01 -#define PI_SET_RESET PI_STATUS_RESET - -#define PI_STATUS_CLR_INTR 0x02 -#define PI_CLR_INTR PI_STATUS_CLR_INTR - -#define PI_DMA_BUFFER_SIZE 128 - -#define PI_DOM1_ADDR1 0x06000000 /* to 0x07FFFFFF */ -#define PI_DOM1_ADDR2 0x10000000 /* to 0x1FBFFFFF */ -#define PI_DOM1_ADDR3 0x1FD00000 /* to 0x7FFFFFFF */ -#define PI_DOM2_ADDR1 0x05000000 /* to 0x05FFFFFF */ -#define PI_DOM2_ADDR2 0x08000000 /* to 0x0FFFFFFF */ - - -/************************************************************************* - * RDRAM Interface (RI) Registers - */ -#define RI_BASE_REG 0x04700000 - -/* RI mode (R/W): [1:0] operating mode, [2] stop T active, [3] stop R active */ -#define RI_MODE_REG (RI_BASE_REG+0x00) - -/* RI config (R/W): [5:0] current control input, [6] current control enable */ -#define RI_CONFIG_REG (RI_BASE_REG+0x04) - -/* RI current load (W): [] any write updates current control register */ -#define RI_CURRENT_LOAD_REG (RI_BASE_REG+0x08) - -/* RI select (R/W): [2:0] receive select, [2:0] transmit select */ -#define RI_SELECT_REG (RI_BASE_REG+0x0C) - -/* RI refresh (R/W): [7:0] clean refresh delay, [15:8] dirty refresh delay, - * [16] refresh bank, [17] refresh enable - * [18] refresh optimize - */ -#define RI_REFRESH_REG (RI_BASE_REG+0x10) -#define RI_COUNT_REG RI_REFRESH_REG - -/* RI latency (R/W): [3:0] DMA latency/overlap */ -#define RI_LATENCY_REG (RI_BASE_REG+0x14) - -/* RI error (R): [0] nack error, [1] ack error */ -#define RI_RERROR_REG (RI_BASE_REG+0x18) - -/* RI error (W): [] any write clears all error bits */ -#define RI_WERROR_REG (RI_BASE_REG+0x1C) - - -/************************************************************************* - * Serial Interface (SI) Registers - */ -#define SI_BASE_REG 0x04800000 - -/* SI DRAM address (R/W): [23:0] starting RDRAM address */ -#define SI_DRAM_ADDR_REG (SI_BASE_REG+0x00) /* R0: DRAM address */ - -/* SI address read 64B (W): [] any write causes a 64B DMA write */ -#define SI_PIF_ADDR_RD64B_REG (SI_BASE_REG+0x04) /* R1: 64B PIF->DRAM */ - -/* Address SI_BASE_REG + (0x08, 0x0c, 0x14) are reserved */ - -/* SI address write 64B (W): [] any write causes a 64B DMA read */ -#define SI_PIF_ADDR_WR64B_REG (SI_BASE_REG+0x10) /* R4: 64B DRAM->PIF */ - -/* - * SI status (W): [] any write clears interrupt - * (R): [0] DMA busy, [1] IO read busy, [2] reserved - * [3] DMA error, [12] interrupt - */ -#define SI_STATUS_REG (SI_BASE_REG+0x18) /* R6: Status */ - -/* SI status register has the following bits active: - * 0: DMA busy - set when DMA is in progress - * 1: IO busy - set when IO access is in progress - * 3: DMA error - set when there are overlapping DMA requests - * 12: Interrupt - Interrupt set - */ -#define SI_STATUS_DMA_BUSY 0x0001 -#define SI_STATUS_RD_BUSY 0x0002 -#define SI_STATUS_DMA_ERROR 0x0008 -#define SI_STATUS_INTERRUPT 0x1000 - -/************************************************************************* - * Development Board GIO Control Registers - */ - -#define GIO_BASE_REG 0x18000000 - -/* Game to Host Interrupt */ -#define GIO_GIO_INTR_REG (GIO_BASE_REG+0x000) - -/* Game to Host SYNC */ -#define GIO_GIO_SYNC_REG (GIO_BASE_REG+0x400) - -/* Host to Game Interrupt */ -#define GIO_CART_INTR_REG (GIO_BASE_REG+0x800) - - -/************************************************************************* - * Common macros - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) -#define IO_READ(addr) (*(vu32 *)PHYS_TO_K1(addr)) -#define IO_WRITE(addr,data) (*(vu32 *)PHYS_TO_K1(addr)=(u32)(data)) -#define RCP_STAT_PRINT \ - rmonPrintf("current=%x start=%x end=%x dpstat=%x spstat=%x\n", \ - IO_READ(DPC_CURRENT_REG), \ - IO_READ(DPC_START_REG), \ - IO_READ(DPC_END_REG), \ - IO_READ(DPC_STATUS_REG), \ - IO_READ(SP_STATUS_REG)) - -#endif - -#endif /* _RCP_H_ */ diff --git a/include/PR/ultratypes.h b/include/PR/ultratypes.h deleted file mode 100644 index 58fef8bd..00000000 --- a/include/PR/ultratypes.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef _ULTRATYPES_H_ -#define _ULTRATYPES_H_ - - -/************************************************************************** - * * - * Copyright (C) 1995, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - **************************************************************************/ - - -/************************************************************************* - * - * File: ultratypes.h - * - * This file contains various types used in Ultra64 interfaces. - * - * $Revision: 1.6 $ - * $Date: 1997/12/17 04:02:06 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/ultratypes.h,v $ - * - **************************************************************************/ - - - -/********************************************************************** - * General data types for R4300 - */ -#if defined(_LANGUAGE_C) || defined(_LANGUAGE_C_PLUS_PLUS) - -typedef unsigned char u8; /* unsigned 8-bit */ -typedef unsigned short u16; /* unsigned 16-bit */ -typedef unsigned long u32; /* unsigned 32-bit */ -typedef unsigned long long u64; /* unsigned 64-bit */ - -typedef signed char s8; /* signed 8-bit */ -typedef short s16; /* signed 16-bit */ -typedef long s32; /* signed 32-bit */ -typedef long long s64; /* signed 64-bit */ - -typedef volatile unsigned char vu8; /* unsigned 8-bit */ -typedef volatile unsigned short vu16; /* unsigned 16-bit */ -typedef volatile unsigned long vu32; /* unsigned 32-bit */ -typedef volatile unsigned long long vu64; /* unsigned 64-bit */ - -typedef volatile signed char vs8; /* signed 8-bit */ -typedef volatile short vs16; /* signed 16-bit */ -typedef volatile long vs32; /* signed 32-bit */ -typedef volatile long long vs64; /* signed 64-bit */ - -typedef float f32; /* single prec floating point */ -typedef double f64; /* double prec floating point */ - -#if !defined(_SIZE_T) && !defined(_SIZE_T_) && !defined(_SIZE_T_DEF) -#define _SIZE_T -#define _SIZE_T_DEF /* exeGCC size_t define label */ -#if (_MIPS_SZLONG == 32) -typedef unsigned int size_t; -#endif -#if (_MIPS_SZLONG == 64) -typedef unsigned long size_t; -#endif -#endif - -#endif /* _LANGUAGE_C */ - - -/************************************************************************* - * Common definitions - */ -#ifndef TRUE -#define TRUE 1 -#endif - -#ifndef FALSE -#define FALSE 0 -#endif - -#ifndef NULL -#define NULL 0 -#endif - -#endif /* _ULTRATYPES_H_ */ - diff --git a/include/PR/xstdio.h b/include/PR/xstdio.h index 2eb1592c..e54d70ee 100644 --- a/include/PR/xstdio.h +++ b/include/PR/xstdio.h @@ -1,27 +1,7 @@ #ifndef _XSTDIO_H #define _XSTDIO_H -#include "PR/ultratypes.h" -#include "libc/stdlib.h" -#include "libc/stdarg.h" - -typedef struct { - /* 0x0 */ union { - /* 0x0 */ long long ll; - /* 0x0 */ double ld; - } v; - /* 0x8 */ unsigned char* s; - /* 0xC */ int n0; - /* 0x10 */ int nz0; - /* 0x14 */ int n1; - /* 0x18 */ int nz1; - /* 0x1C */ int n2; - /* 0x20 */ int nz2; - /* 0x24 */ int prec; - /* 0x28 */ int width; - /* 0x2C */ size_t nchar; - /* 0x30 */ unsigned int flags; - /* 0x34 */ char qual; -} _Pft; +#include +#include #define FLAGS_SPACE 1 #define FLAGS_PLUS 2 diff --git a/include/fox_map.h b/include/fox_map.h index caabbefa..996a9419 100644 --- a/include/fox_map.h +++ b/include/fox_map.h @@ -1,7 +1,7 @@ #ifndef FOX_MAP_H #define FOX_MAP_H -#include "PR/ultratypes.h" +#include #include "sf64level.h" typedef struct { diff --git a/include/fox_option.h b/include/fox_option.h index 51877be6..ad2a66d3 100644 --- a/include/fox_option.h +++ b/include/fox_option.h @@ -204,7 +204,7 @@ void Option_DrawCardLabel(OptionTexture arg0); bool Option_8019C418(s32* arg0, s32 arg1, bool arg2, s32 arg3, s32 arg4, s32 arg5, s32 arg6, s32 arg7, UnkStruct_D_menu_801B9250* arg8); s32 Option_8019C5A0(s32*); bool Option_8019C66C(f32* arg0, f32 arg1, f32 arg2, UnkStruct_D_menu_801B9250* arg3); -void Option_8019C824(f32*); +void Option_8019C824(f32* ); s32 Option_8019C8C4(void); void Option_8019CAE0(void); void Option_8019CBC0(void); diff --git a/include/functions.h b/include/functions.h index 41678dcd..8e2b7dba 100644 --- a/include/functions.h +++ b/include/functions.h @@ -470,7 +470,7 @@ void func_play_800B2130(Player*); void func_play_800B2574(Player*); void func_play_800B56BC(Player*); void func_play_800B5D30(Player*, s32); -void func_play_800B5FBC(Player*, s32 , bool ); +void func_play_800B5FBC(Player*, s32, bool); void func_play_800B63BC(Player*, s32); void func_play_800B6848(Player*, s32 ); void func_play_800B6BFC(Player*, s32 ); @@ -513,4 +513,11 @@ void Ending_8018AAC4(void); // sf_i5_5 bool Ground_801B49D0(Actor* actor); +// libultra +void gSPSegmentLoadRes(void* value, int segNum, uintptr_t target); +void gSPDisplayList(Gfx* pkt, Gfx* dl); +void gSPDisplayListOffset(Gfx* pkt, Gfx* dl, int offset); +void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0); +void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr); + #endif diff --git a/include/gfx.h b/include/gfx.h index 5702f65f..301d4ff1 100644 --- a/include/gfx.h +++ b/include/gfx.h @@ -1,7 +1,7 @@ #ifndef GFX_H #define GFX_H -#include "libultra/ultra64.h" +#include #include "sf64math.h" #include "libc/stdbool.h" @@ -64,16 +64,12 @@ #define VTX_T(x,y,z,s,t,cr,cg,cb,a) { { x, y, z }, 0, { s, t }, { cr, cg, cb, a } } -typedef struct { - u8 r, g, b; -} Color_RGB8; // size = 0x3 - typedef union { u16 data[SCREEN_HEIGHT * SCREEN_WIDTH]; u16 array[SCREEN_HEIGHT][SCREEN_WIDTH]; } FrameBuffer; // size = 0x25800 -typedef bool (*OverrideLimbDraw)(s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3f* rot, void* this); +typedef bool (*OverrideLimbDraw)(s32 limbIndex, Gfx** dList, Vec3f* pos, Vec3f* rot, void* this); typedef void (*PostLimbDraw)(s32, Vec3f*, void*); typedef struct { @@ -104,12 +100,12 @@ void Graphics_NMIWipe(void); void Lights_SetOneLight(Gfx** dList, s32 dirX, s32 dirY, s32 dirZ, s32 colR, s32 colG, s32 colB, s32 ambR, s32 ambG, s32 ambB); void Lights_SetTwoLights(Gfx** dList, s32 dir1x, s32 dir1y, s32 dir1z, s32 dir2x, s32 dir2y, s32 dir2z, s32 col1r, s32 col1g, - s32 col1b, s32 col2r, s32 col2g, s32 col2b, s32 ambR, s32 ambG, s32 ambB); + s32 col1b, s32 col2r, s32 col2g, s32 col2b, s32 ambR, s32 ambG, s32 ambB); char* Graphics_ClearPrintBuffer(char *buf, s32 fill, s32 len); s32 Graphics_Printf(const char *fmt, ...); void Texture_Scroll(u16 *texture, s32 width, s32 height, u8 mode); -void Texture_Mottle(u16 *dst, u16 *src, u8 mode); +void Texture_Mottle(u16 *dst, u16 *src, u8 mode); s32 Animation_GetLimbIndex(Limb* limb, Limb** skeleton); void Animation_DrawLimb(s32 mode, Limb* limb, Limb* *skeleton, Vec3f* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* data); void Animation_DrawSkeleton(s32 mode, Limb** skeletonSegment, Vec3f* jointTable, OverrideLimbDraw overrideLimbDraw, PostLimbDraw postLimbDraw, void* data, Matrix* transform); diff --git a/include/global.h b/include/global.h index f001ef09..d7cba195 100644 --- a/include/global.h +++ b/include/global.h @@ -6,7 +6,7 @@ #include "sf64audio_external.h" #include "functions.h" #include "variables.h" -#include "context.h" +#include "sf64context.h" #include "structs.h" #include "sf64mesg.h" #include "assets/ast_radio.h" @@ -20,5 +20,6 @@ #include "i5.h" #include "i6.h" #include "assets/ast_common.h" +#include #endif // GLOBAL_H diff --git a/include/i1.h b/include/i1.h index 608abcc8..6d269eeb 100644 --- a/include/i1.h +++ b/include/i1.h @@ -1,7 +1,7 @@ #ifndef I1_H #define I1_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/i2.h b/include/i2.h index c4f43be6..67b0e0b4 100644 --- a/include/i2.h +++ b/include/i2.h @@ -1,7 +1,7 @@ #ifndef I2_H #define I2_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/i3.h b/include/i3.h index 261519fc..9a72a7dd 100644 --- a/include/i3.h +++ b/include/i3.h @@ -1,7 +1,7 @@ #ifndef I3_H #define I3_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/i4.h b/include/i4.h index 1034e586..f3cc5ae6 100644 --- a/include/i4.h +++ b/include/i4.h @@ -1,7 +1,7 @@ #ifndef I4_H #define I4_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/i5.h b/include/i5.h index 4a4fe28a..94014a39 100644 --- a/include/i5.h +++ b/include/i5.h @@ -1,7 +1,7 @@ #ifndef I5_H #define I5_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/i6.h b/include/i6.h index aac0db72..9a4ac8e3 100644 --- a/include/i6.h +++ b/include/i6.h @@ -1,7 +1,7 @@ #ifndef I6_H #define I6_H -#include "libc/stdbool.h" +#include "stdbool.h" #include "structs.h" #include "sf64object.h" #include "sf64thread.h" diff --git a/include/libc/math.h b/include/libc/math.h index 0e63d99b..1f243d23 100644 --- a/include/libc/math.h +++ b/include/libc/math.h @@ -1,7 +1,7 @@ #ifndef LIBC_MATH_H #define LIBC_MATH_H -#include "PR/ultratypes.h" +#include #define M_PI 3.14159265358979323846f #define M_DTOR (M_PI / 180.0f) @@ -28,43 +28,25 @@ typedef union { extern f32 __libm_qnan_f; -float fabsf(float f); -#pragma intrinsic(fabsf) -#ifdef __GNUC__ -#define fabsf(f) __builtin_fabsf((float)(f)) -#endif - -double fabs(double f); -#pragma intrinsic(fabs) -#ifdef __GNUC__ -#define fabs(f) __builtin_fabs((double)(f)) -#endif - -float sqrtf(float f); -#pragma intrinsic(sqrtf) - -double sqrt(double d); -#pragma intrinsic(sqrt) - -f32 __floorf(f32); -f64 __floor(f64); -s32 __lfloorf(f32); -s32 __lfloor(f64); -f32 __ceilf(f32); -f64 __ceil(f64); -s32 __lceilf(f32); -s32 __lceil(f64); -f32 __truncf(f32); -f64 __trunc(f64); -s32 __ltruncf(f32); -s32 __ltrunc(f64); -f32 __roundf(f32); -f64 __round(f64); -s32 __lroundf(f32); -s32 __lround(f64); -f32 __nearbyintf(f32); -f64 __nearbyint(f64); -s32 __lnearbyintf(f32); -s32 __lnearbyint(f64); +#define __floorf floorf +#define __floor floor +#define __lfloorf lfloorf +#define __lfloor lfloor +#define __ceilf ceilf +#define __ceil ceil +#define __lceilf lceilf +#define __lceil lceil +#define __truncf truncf +#define __trunc trunc +#define __ltruncf ltruncf +#define __ltrunc ltrunc +#define __roundf roundf +#define __round round +#define __lroundf lroundf +#define __lround lround +#define __nearbyintf nearbyintf +#define __nearbyint nearbyint +#define __lnearbyintf lnearbyintf +#define __lnearbyint lnearbyint #endif diff --git a/include/libc/stddef.h b/include/libc/stddef.h index d7533961..6206dc8a 100644 --- a/include/libc/stddef.h +++ b/include/libc/stddef.h @@ -1,7 +1,7 @@ #ifndef LIBC_STDDEF_H #define LIBC_STDDEF_H -#include "PR/ultratypes.h" +#include typedef s32 ptrdiff_t; diff --git a/include/libc/stdint.h b/include/libc/stdint.h index 854fd254..3350767e 100644 --- a/include/libc/stdint.h +++ b/include/libc/stdint.h @@ -1,7 +1,7 @@ #ifndef LIBC_STDINT_H #define LIBC_STDINT_H -#include "PR/ultratypes.h" +#include typedef s32 intptr_t; typedef u32 uintptr_t; diff --git a/include/libc/stdlib.h b/include/libc/stdlib.h index ec15b4f6..08d313f4 100644 --- a/include/libc/stdlib.h +++ b/include/libc/stdlib.h @@ -1,7 +1,7 @@ #ifndef LIBC_STDLIB_H #define LIBC_STDLIB_H -#include "libc/stddef.h" +#include "stddef.h" typedef struct { /* 0x0 */ int quot; diff --git a/include/libc/string.h b/include/libc/string.h index 9c6a1cb0..50e13fd1 100644 --- a/include/libc/string.h +++ b/include/libc/string.h @@ -1,7 +1,7 @@ #ifndef LIBC_STRING_H #define LIBC_STRING_H -#include "libc/stddef.h" +#include "stddef.h" const char* strchr(const char* s, int c); diff --git a/include/libultra/ultra64.h b/include/libultra/ultra64.h deleted file mode 100644 index 94e177cc..00000000 --- a/include/libultra/ultra64.h +++ /dev/null @@ -1,40 +0,0 @@ - -/************************************************************************** - * * - * Copyright (C) 1994, Silicon Graphics, Inc. * - * * - * These coded instructions, statements, and computer programs contain * - * unpublished proprietary information of Silicon Graphics, Inc., and * - * are protected by Federal copyright law. They may not be disclosed * - * to third parties or copied or duplicated in any form, in whole or * - * in part, without the prior written consent of Silicon Graphics, Inc. * - * * - *************************************************************************/ - -/************************************************************************** - * - * $Revision: 1.10 $ - * $Date: 1997/02/11 08:37:33 $ - * $Source: /disk6/Master/cvsmdev2/PR/include/ultra64.h,v $ - * - **************************************************************************/ - -#ifndef _ULTRA64_H_ -#define _ULTRA64_H_ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif diff --git a/include/macros.h b/include/macros.h index e1e1e906..27fa2324 100644 --- a/include/macros.h +++ b/include/macros.h @@ -2,6 +2,11 @@ #define MACROS_H #include "alignment.h" +#include "libc/math.h" +#include + +#define __sinf sinf +#define __cosf cosf #define SCREEN_WIDTH 320 #define SCREEN_HEIGHT 240 @@ -34,13 +39,14 @@ #define RAD_TO_DEG(radians) (((radians) * 180.0f) / M_PI) #define DEG_TO_RAD(degrees) (((degrees) / 180.0f) * M_PI) -#define SIN_DEG(angle) __sinf((M_DTOR)*(angle)) -#define COS_DEG(angle) __cosf((M_DTOR)*(angle)) +// TODO: Fix these +#define SIN_DEG(angle) /*sinf*/(M_DTOR * angle) +#define COS_DEG(angle) /*cosf*/(M_DTOR * angle) -#define USEC_TO_CYCLES(n) (((u64)(n)*(osClockRate/15625LL))/(1000000LL/15625LL)) +#define USEC_TO_CYCLES(n) (((u64)(n)*(OS_CLOCK_RATE/15625LL))/(1000000LL/15625LL)) #define MSEC_TO_CYCLES(n) (USEC_TO_CYCLES((n) * 1000LL)) -#define CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(osClockRate/15625LL)) +#define CYCLES_TO_USEC(c) (((u64)(c)*(1000000LL/15625LL))/(OS_CLOCK_RATE/15625LL)) #define CYCLES_TO_MSEC(c) ((s32)CYCLES_TO_USEC(c)/1000) /* diff --git a/include/sf64audio_provisional.h b/include/sf64audio_provisional.h index 48d96686..9ff0ed45 100644 --- a/include/sf64audio_provisional.h +++ b/include/sf64audio_provisional.h @@ -6,7 +6,7 @@ #ifndef SF64_AUDIO_H #define SF64_AUDIO_H -#include "PR/ultratypes.h" +#include #include "sf64audio_external.h" typedef void (*AudioCustomUpdateFunction)(void); @@ -336,7 +336,7 @@ typedef struct { /* 0x00 */ u8 hang : 1; /* 0x00 */ u8 decay : 1; /* 0x00 */ u8 release : 1; - /* 0x00 */ + /* 0x00 */ } s; /* 0x00 */ u8 asByte; } action; @@ -457,7 +457,7 @@ typedef struct SequenceLayer { /* 0x28 */ f32 velocitySquare; /* 0x2C */ f32 noteVelocity; /* 0x30 */ f32 noteFreqMod; - /* 0x34 */ u16 shortNoteDefaultDelay; + /* 0x34 */ u16 shortNoteDefaultDelay; /* 0x36 */ u16 lastDelay; /* 0x38 */ s16 delay; /* 0x3A */ s16 gateDelay; @@ -990,7 +990,7 @@ typedef struct { #define SFX_RANGE_SHIFT(sfxId) (((sfxId) >> 16) & 0xFF) #define SFX_IMPORTANCE_SHIFT(sfxId) (((sfxId) >> 8) & 0xFF) -#define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) +#define SFX_BANK(sfxId) SFX_BANK_SHIFT(SFX_BANK_MASK(sfxId)) #define SFX_STATE(sfxId) SFX_STATE_SHIFT(SFX_STATE_MASK(sfxId)) #define SFX_BIT04(sfxId) ((sfxId) & (1 << 27)) #define SFX_BIT05(sfxId) ((sfxId) & (1 << 26)) diff --git a/include/context.h b/include/sf64context.h similarity index 100% rename from include/context.h rename to include/sf64context.h diff --git a/include/sf64dma.h b/include/sf64dma.h index 541ab4db..6c58fcd6 100644 --- a/include/sf64dma.h +++ b/include/sf64dma.h @@ -1,8 +1,8 @@ #ifndef SF64_DMA #define SF64_DMA -#include "PR/ultratypes.h" -#include "libc/stdbool.h" +#include +#include "stdbool.h" #define DECLARE_VRAM_SEGMENT(name) \ extern u8 name ## _VRAM[]; \ @@ -38,22 +38,26 @@ DECLARE_RODATA_SEGMENT(name); \ DECLARE_BSS_SEGMENT(name) -#define SEGMENT_VRAM_START(segment) (segment ## _VRAM) -#define SEGMENT_VRAM_END(segment) (segment ## _VRAM_END) -#define SEGMENT_VRAM_SIZE(segment) ((uintptr_t)SEGMENT_VRAM_END(segment) - (uintptr_t)SEGMENT_VRAM_START(segment)) +// TODO: Implement file loading +#define SEGMENT_VRAM_START(segment) NULL +#define SEGMENT_VRAM_END(segment) NULL +#define SEGMENT_VRAM_SIZE(segment) NULL -#define SEGMENT_ROM_START(segment) (segment ## _ROM_START) -#define SEGMENT_ROM_END(segment) (segment ## _ROM_END) -#define SEGMENT_ROM_SIZE(segment) ((uintptr_t)SEGMENT_ROM_END(segment) - (uintptr_t)SEGMENT_ROM_START(segment)) +// TODO: Implement file loading +#define SEGMENT_ROM_START(segment) NULL +#define SEGMENT_ROM_END(segment) NULL +#define SEGMENT_ROM_SIZE(segment) NULL +// TODO: Implement file loading #define SEGMENT_TEXT_START(segment) (segment ## _TEXT_START) #define SEGMENT_TEXT_END(segment) (segment ## _TEXT_END) #define SEGMENT_TEXT_SIZE(segment) ((uintptr_t)SEGMENT_TEXT_END(segment) - (uintptr_t)SEGMENT_TEXT_START(segment)) -#define SEGMENT_DATA_START(segment) (segment ## _DATA_START) -#define SEGMENT_DATA_END(segment) (segment ## _DATA_END) -#define SEGMENT_DATA_SIZE(segment) ((uintptr_t)SEGMENT_DATA_END(segment) - (uintptr_t)SEGMENT_DATA_START(segment)) -#define SEGMENT_DATA_SIZE_CONST(segment) (segment ## _DATA_SIZE) +// TODO: Implement file loading +#define SEGMENT_DATA_START(segment) NULL +#define SEGMENT_DATA_END(segment) NULL +#define SEGMENT_DATA_SIZE(segment) NULL +#define SEGMENT_DATA_SIZE_CONST(segment) NULL #define SEGMENT_RODATA_START(segment) (segment ## _RODATA_START) #define SEGMENT_RODATA_END(segment) (segment ## _RODATA_END) diff --git a/include/sf64math.h b/include/sf64math.h index 939d0736..defb41af 100644 --- a/include/sf64math.h +++ b/include/sf64math.h @@ -1,7 +1,7 @@ #ifndef SF64_MATH_H #define SF64_MATH_H -#include "libultra/ultra64.h" +#include typedef struct { /* 0x0 */ f32 x; @@ -95,8 +95,8 @@ f32 Math_FAtan2F(f32, f32); f32 Math_FAsinF(f32); f32 Math_FAcosF(f32); -f32 __sinf(f32); -f32 __cosf(f32); +#define __sinf sinf +#define __cosf cosf s64 __ull_div(s64, s64); s64 __ll_mul(s64, s64); diff --git a/include/sf64mesg.h b/include/sf64mesg.h index 924ba659..30657869 100644 --- a/include/sf64mesg.h +++ b/include/sf64mesg.h @@ -1,8 +1,8 @@ #ifndef SF64_MESG #define SF64_MESG -#include "libultra/ultra64.h" -#include "libc/stdbool.h" +#include +#include "stdbool.h" typedef struct { s32 msgId; diff --git a/include/sf64object.h b/include/sf64object.h index c69e7ecd..4723a2ae 100644 --- a/include/sf64object.h +++ b/include/sf64object.h @@ -1,7 +1,7 @@ #ifndef SF64_OBJECT #define SF64_OBJECT -#include "libultra/ultra64.h" +#include #include "sf64math.h" #define HITBOX_TYPE_2 200000.0f @@ -213,9 +213,9 @@ typedef struct { /* 0x01C */ ObjectInfo info; /* 0x040 */ s32 index; /* 0x044 */ s16 unk_044; - /* 0x046 */ s16 unk_046; - /* 0x048 */ s16 unk_048; - /* 0x04A */ s16 unk_04A; + /* 0x046 */ s16 unk_046; + /* 0x048 */ s16 unk_048; + /* 0x04A */ s16 unk_04A; /* 0x04C */ s16 unk_04C; /* 0x04E */ s16 state; /* 0x050 */ s16 timer_050; @@ -233,7 +233,7 @@ typedef struct { /* 0x068 */ f32 unk_068; /* 0x06C */ Vec3f vel; /* 0x078 */ Vec3f unk_078; - /* 0x084 */ f32 gravity; + /* 0x084 */ f32 gravity; /* 0x088 */ s16 swork[40]; /* 0x0D8 */ f32 fwork[50]; /* 0x1A0 */ Vec3f vwork[50]; @@ -289,106 +289,106 @@ typedef struct { typedef enum ObjectId { /* -1 */ OBJ_INVALID=-1, - /* 0 */ OBJ_80_0, - /* 1 */ OBJ_80_1, - /* 2 */ OBJ_80_2, - /* 3 */ OBJ_80_3, - /* 4 */ OBJ_80_4, - /* 5 */ OBJ_80_5, - /* 6 */ OBJ_80_6, - /* 7 */ OBJ_80_7, - /* 8 */ OBJ_80_8, - /* 9 */ OBJ_80_9, - /* 10 */ OBJ_80_10, - /* 11 */ OBJ_80_11, - /* 12 */ OBJ_80_12, - /* 13 */ OBJ_80_13, - /* 14 */ OBJ_80_14, - /* 15 */ OBJ_80_15, - /* 16 */ OBJ_80_16, - /* 17 */ OBJ_80_17, - /* 18 */ OBJ_80_18, - /* 19 */ OBJ_80_19, - /* 20 */ OBJ_80_20, - /* 21 */ OBJ_80_21, - /* 22 */ OBJ_80_22, - /* 23 */ OBJ_80_23, - /* 24 */ OBJ_80_24, - /* 25 */ OBJ_80_25, - /* 26 */ OBJ_80_26, - /* 27 */ OBJ_80_27, - /* 28 */ OBJ_80_28, - /* 29 */ OBJ_80_29, - /* 30 */ OBJ_80_30, - /* 31 */ OBJ_80_31, - /* 32 */ OBJ_80_32, - /* 33 */ OBJ_80_33, - /* 34 */ OBJ_80_34, - /* 35 */ OBJ_80_35, - /* 36 */ OBJ_80_36, - /* 37 */ OBJ_80_37, - /* 38 */ OBJ_80_38, - /* 39 */ OBJ_80_39, - /* 40 */ OBJ_80_40, - /* 41 */ OBJ_80_41, - /* 42 */ OBJ_80_42, - /* 43 */ OBJ_80_43, - /* 44 */ OBJ_80_44, - /* 45 */ OBJ_80_45, - /* 46 */ OBJ_80_46, - /* 47 */ OBJ_80_47, - /* 48 */ OBJ_80_48, - /* 49 */ OBJ_80_49, - /* 50 */ OBJ_80_50, - /* 51 */ OBJ_80_51, - /* 52 */ OBJ_80_52, - /* 53 */ OBJ_80_53, - /* 54 */ OBJ_80_54, - /* 55 */ OBJ_80_55, - /* 56 */ OBJ_80_56, - /* 57 */ OBJ_80_57, - /* 58 */ OBJ_80_58, - /* 59 */ OBJ_80_59, - /* 60 */ OBJ_80_60, - /* 61 */ OBJ_80_61, - /* 62 */ OBJ_80_62, - /* 63 */ OBJ_80_63, - /* 64 */ OBJ_80_64, - /* 65 */ OBJ_80_65, - /* 66 */ OBJ_80_66, - /* 67 */ OBJ_80_67, - /* 68 */ OBJ_80_68, - /* 69 */ OBJ_80_69, - /* 70 */ OBJ_80_70, - /* 71 */ OBJ_80_71, - /* 72 */ OBJ_80_72, - /* 73 */ OBJ_80_73, - /* 74 */ OBJ_80_74, - /* 75 */ OBJ_80_75, - /* 76 */ OBJ_80_76, - /* 77 */ OBJ_80_77, - /* 78 */ OBJ_80_78, - /* 79 */ OBJ_80_79, - /* 80 */ OBJ_80_80, - /* 81 */ OBJ_80_81, - /* 82 */ OBJ_80_82, - /* 83 */ OBJ_80_83, - /* 84 */ OBJ_80_84, - /* 85 */ OBJ_80_85, - /* 86 */ OBJ_80_86, - /* 87 */ OBJ_80_87, - /* 88 */ OBJ_80_88, - /* 89 */ OBJ_80_89, - /* 90 */ OBJ_80_90, - /* 91 */ OBJ_80_91, - /* 92 */ OBJ_80_92, - /* 93 */ OBJ_80_93, - /* 94 */ OBJ_80_94, - /* 95 */ OBJ_80_95, - /* 96 */ OBJ_80_96, - /* 97 */ OBJ_80_97, - /* 98 */ OBJ_80_98, - /* 99 */ OBJ_80_99, + /* 0 */ OBJ_80_0, + /* 1 */ OBJ_80_1, + /* 2 */ OBJ_80_2, + /* 3 */ OBJ_80_3, + /* 4 */ OBJ_80_4, + /* 5 */ OBJ_80_5, + /* 6 */ OBJ_80_6, + /* 7 */ OBJ_80_7, + /* 8 */ OBJ_80_8, + /* 9 */ OBJ_80_9, + /* 10 */ OBJ_80_10, + /* 11 */ OBJ_80_11, + /* 12 */ OBJ_80_12, + /* 13 */ OBJ_80_13, + /* 14 */ OBJ_80_14, + /* 15 */ OBJ_80_15, + /* 16 */ OBJ_80_16, + /* 17 */ OBJ_80_17, + /* 18 */ OBJ_80_18, + /* 19 */ OBJ_80_19, + /* 20 */ OBJ_80_20, + /* 21 */ OBJ_80_21, + /* 22 */ OBJ_80_22, + /* 23 */ OBJ_80_23, + /* 24 */ OBJ_80_24, + /* 25 */ OBJ_80_25, + /* 26 */ OBJ_80_26, + /* 27 */ OBJ_80_27, + /* 28 */ OBJ_80_28, + /* 29 */ OBJ_80_29, + /* 30 */ OBJ_80_30, + /* 31 */ OBJ_80_31, + /* 32 */ OBJ_80_32, + /* 33 */ OBJ_80_33, + /* 34 */ OBJ_80_34, + /* 35 */ OBJ_80_35, + /* 36 */ OBJ_80_36, + /* 37 */ OBJ_80_37, + /* 38 */ OBJ_80_38, + /* 39 */ OBJ_80_39, + /* 40 */ OBJ_80_40, + /* 41 */ OBJ_80_41, + /* 42 */ OBJ_80_42, + /* 43 */ OBJ_80_43, + /* 44 */ OBJ_80_44, + /* 45 */ OBJ_80_45, + /* 46 */ OBJ_80_46, + /* 47 */ OBJ_80_47, + /* 48 */ OBJ_80_48, + /* 49 */ OBJ_80_49, + /* 50 */ OBJ_80_50, + /* 51 */ OBJ_80_51, + /* 52 */ OBJ_80_52, + /* 53 */ OBJ_80_53, + /* 54 */ OBJ_80_54, + /* 55 */ OBJ_80_55, + /* 56 */ OBJ_80_56, + /* 57 */ OBJ_80_57, + /* 58 */ OBJ_80_58, + /* 59 */ OBJ_80_59, + /* 60 */ OBJ_80_60, + /* 61 */ OBJ_80_61, + /* 62 */ OBJ_80_62, + /* 63 */ OBJ_80_63, + /* 64 */ OBJ_80_64, + /* 65 */ OBJ_80_65, + /* 66 */ OBJ_80_66, + /* 67 */ OBJ_80_67, + /* 68 */ OBJ_80_68, + /* 69 */ OBJ_80_69, + /* 70 */ OBJ_80_70, + /* 71 */ OBJ_80_71, + /* 72 */ OBJ_80_72, + /* 73 */ OBJ_80_73, + /* 74 */ OBJ_80_74, + /* 75 */ OBJ_80_75, + /* 76 */ OBJ_80_76, + /* 77 */ OBJ_80_77, + /* 78 */ OBJ_80_78, + /* 79 */ OBJ_80_79, + /* 80 */ OBJ_80_80, + /* 81 */ OBJ_80_81, + /* 82 */ OBJ_80_82, + /* 83 */ OBJ_80_83, + /* 84 */ OBJ_80_84, + /* 85 */ OBJ_80_85, + /* 86 */ OBJ_80_86, + /* 87 */ OBJ_80_87, + /* 88 */ OBJ_80_88, + /* 89 */ OBJ_80_89, + /* 90 */ OBJ_80_90, + /* 91 */ OBJ_80_91, + /* 92 */ OBJ_80_92, + /* 93 */ OBJ_80_93, + /* 94 */ OBJ_80_94, + /* 95 */ OBJ_80_95, + /* 96 */ OBJ_80_96, + /* 97 */ OBJ_80_97, + /* 98 */ OBJ_80_98, + /* 99 */ OBJ_80_99, /* 100 */ OBJ_80_100, /* 101 */ OBJ_80_101, /* 102 */ OBJ_80_102, diff --git a/include/sf64save.h b/include/sf64save.h index 7be617a8..0de8c4f5 100644 --- a/include/sf64save.h +++ b/include/sf64save.h @@ -1,7 +1,7 @@ #ifndef SF64_SAVE #define SF64_SAVE -#include "PR/ultratypes.h" +#include typedef struct { /* bit 0 */ u8 unk_0 : 3; diff --git a/include/sf64thread.h b/include/sf64thread.h index 407d0f72..6c97ca0c 100644 --- a/include/sf64thread.h +++ b/include/sf64thread.h @@ -1,7 +1,7 @@ #ifndef SF64_THREAD #define SF64_THREAD -#include "libultra/ultra64.h" +#include #include "gfx.h" typedef enum { diff --git a/include/structs.h b/include/structs.h index 332d943c..0b0ee4f5 100644 --- a/include/structs.h +++ b/include/structs.h @@ -1,7 +1,7 @@ #ifndef STRUCTS_H #define STRUCTS_H -#include "libultra/ultra64.h" +#include #include "sf64math.h" typedef struct { diff --git a/include/sys.h b/include/sys.h index 7686ec02..5f11b886 100644 --- a/include/sys.h +++ b/include/sys.h @@ -3,13 +3,14 @@ #include "PR/xstdio.h" #include "PR/controller.h" -#include "libultra/ultra64.h" +#include +#include "math.h" #include "libc/math.h" -#include "libc/stdarg.h" -#include "libc/stdbool.h" -#include "libc/stdint.h" -#include "libc/stddef.h" -#include "libc/string.h" +#include "stdarg.h" +#include "stdbool.h" +#include "stdint.h" +#include "stddef.h" +#include "string.h" #include "macros.h" #include "sf64math.h" #include "gfx.h" @@ -26,7 +27,7 @@ void Lib_vTable(s32 index, void (**table)(s32, s32), s32 arg0, s32 arg1); void Lib_QuickSort(u8* first, u32 length, u32 size, CompareFunc cFunc); void Lib_Perspective(Gfx** dList); void Lib_Ortho(Gfx** dList); -void Lib_DmaRead(void* src, void* dst, s32 size); +void Lib_DmaRead(void* src, void* dst, ptrdiff_t size); void Lib_FillScreen(u8 setFill); void Memory_FreeAll(void); @@ -35,7 +36,6 @@ void* Memory_Allocate(s32); OSPiHandle * func_8001EE60(void); void RdRam_CheckIPL3(void); void Mio0_Decompress(void* header, u8* dst); -s32 vsprintf(char* dst, const char* fmt, va_list args); void Game_Initialize(void); void Game_Update(void); diff --git a/include/variables.h b/include/variables.h index 372884fd..8020ceec 100644 --- a/include/variables.h +++ b/include/variables.h @@ -200,5 +200,7 @@ extern Gfx D_Gfx_800D9688[]; extern u8 D_Tex_800DB4B8[]; extern Gfx D_Gfx_800D94D0[]; +extern OSTime osClockRate; +u32 osViClock = 0x02E6D354; #endif // VARIABLES_H diff --git a/src/audio/audio_general.c b/src/audio/audio_general.c index ff1247ba..1e4f5b00 100644 --- a/src/audio/audio_general.c +++ b/src/audio/audio_general.c @@ -1,6 +1,6 @@ #include "sys.h" #include "sf64audio_provisional.h" -#include "context.h" +#include "sf64context.h" #include "audiothread_cmd.h" #include "audioseq_cmd.h" diff --git a/src/audio/audio_load.c b/src/audio/audio_load.c index 9a87a93b..e74e9ab3 100644 --- a/src/audio/audio_load.c +++ b/src/audio/audio_load.c @@ -296,7 +296,7 @@ s32 AudioLoad_SyncLoadInstrument(s32 fontId, s32 instId, s32 drumId) { void AudioLoad_AsyncLoadSampleBank(s32 sampleBankId, s32 nChunks, s32 retData, OSMesgQueue* retQueue) { if (AudioLoad_AsyncLoadInner(2, AudioLoad_GetLoadTableIndex(2, sampleBankId), nChunks, retData, retQueue) == NULL) { - osSendMesg(retQueue, NULL, 0); + osSendMesg(retQueue, OS_MESG_PTR(NULL), 0); } } @@ -742,7 +742,7 @@ void* AudioLoad_AsyncLoadInner(s32 tableType, s32 id, s32 nChunks, s32 retData, ramAddr = AudioLoad_SearchCaches(tableType, id); if (ramAddr != NULL) { loadStatus = 2; - osSendMesg(retQueue, (void*) (retData << 0x18), 0); + osSendMesg(retQueue, OS_MESG_32(retData << 0x18), 0); } else { table = AudioLoad_GetLoadTable(tableType); size = table->entries[id].size; @@ -842,21 +842,9 @@ void AudioLoad_Init(void) { for (; dwordsLeft >= 0; dwordsLeft--) { *clearContext++ = 0; } - switch (osTvType) { - case OS_TV_PAL: - gMaxTempoTvTypeFactors = 20.03042f; - gRefreshRate = 50; - break; - case OS_TV_MPAL: - gMaxTempoTvTypeFactors = 16.546f; - gRefreshRate = 60; - break; - default: - case OS_TV_NTSC: - gMaxTempoTvTypeFactors = 16.713f; - gRefreshRate = 60; - break; - } + // TODO: osTVType should be unnecessary + gMaxTempoTvTypeFactors = 16.713f; + gRefreshRate = 60; AudioThread_Init(); for (i = 0; i < 3; i++) { gAiBuffLengths[i] = 0xA0; @@ -1084,7 +1072,7 @@ AudioAsyncLoad* AudioLoad_StartAsyncLoad(u32 devAddr, u8* ramAddr, u32 size, s32 asyncLoad->delay = 3; asyncLoad->medium = medium; - asyncLoad->retMsg = retMesg; + asyncLoad->retMsg = OS_MESG_32(retMesg); osCreateMesgQueue(&asyncLoad->msgQueue, &asyncLoad->msg, 1); return asyncLoad; @@ -1128,7 +1116,7 @@ void AudioLoad_ProcessAsyncLoad(AudioAsyncLoad* asyncLoad, s32 resetStatus) { } } if (asyncLoad->bytesRemaining == 0) { - temp = asyncLoad->retMsg; + temp = asyncLoad->retMsg.data32; pad1 = (temp >> 0x10) & 0xFF; sp24 = (temp >> 8) & 0xFF; pad2 = temp & 0xFF; @@ -1352,17 +1340,18 @@ s32 AudioLoad_ProcessSamplePreloads(s32 resetStatus) { s32 sampleAddr; u32 size; s32 nChunks; + OSMesg mesg; if (gPreloadSampleStackTop > 0) { if (resetStatus != 0) { - if (osRecvMesg(&gPreloadSampleQueue, (OSMesg) &preloadIndex, 0)) {} + if (osRecvMesg(&gPreloadSampleQueue, &mesg, 0)) {} gPreloadSampleStackTop = 0; return false; } - if (osRecvMesg(&gPreloadSampleQueue, (OSMesg) &preloadIndex, 0) == -1) { + if (osRecvMesg(&gPreloadSampleQueue, &mesg, 0) == -1) { return false; } - // "Receive %d\n" + preloadIndex = mesg.data32; preloadIndex >>= 0x18; if (gPreloadSampleStack[preloadIndex].isFree == 0) { diff --git a/src/audio/audio_synthesis.c b/src/audio/audio_synthesis.c index 44042134..128c342c 100644 --- a/src/audio/audio_synthesis.c +++ b/src/audio/audio_synthesis.c @@ -1215,22 +1215,22 @@ Acmd* func_8000B51C(Acmd* aList, NoteSubEu* noteSub, NoteSynthesisState* synthSt switch (delaySide) { case 1: aEnvMixer(aList++, dmemSrc, aiBufLen, 0, 0, ((temp_a1 & 0x80) >> 7), - noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x65B1C9E1); + noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x65B1C9E1, 0); break; case 2: aEnvMixer(aList++, dmemSrc, aiBufLen, 0, 0, ((temp_a1 & 0x80) >> 7), - noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x9965C9E1); + noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x9965C9E1, 0); break; default: aEnvMixer(aList++, dmemSrc, aiBufLen, 0, 0, ((temp_a1 & 0x80) >> 7), - noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x99B1C9E1); + noteSub->bitField0.stereoStrongRight, noteSub->bitField0.stereoStrongLeft, 0x99B1C9E1, 0); break; } } else { aEnvSetup1(aList++, (temp_a1 & 0x7F), var_a2, var_t0, var_a3); aEnvSetup2(aList++, temp_t1, temp_t2); aEnvMixer(aList++, dmemSrc, aiBufLen, 0, 0, ((temp_a1 & 0x80) >> 7), noteSub->bitField0.stereoStrongRight, - noteSub->bitField0.stereoStrongLeft, 0x99B1C9E1); + noteSub->bitField0.stereoStrongLeft, 0x99B1C9E1, 0); } return aList; diff --git a/src/audio/audio_thread.c b/src/audio/audio_thread.c index 8d383393..e1e3248e 100644 --- a/src/audio/audio_thread.c +++ b/src/audio/audio_thread.c @@ -49,15 +49,15 @@ SPTask* AudioThread_CreateTask(void) { OSTask_t* task; u16* sp40; s32 pad3C; - u32 sp38; - u32 sp34; + OSMesg sp38; + OSMesg sp34; s32 pad30; gAudioTaskCountQ++; if ((gAudioTaskCountQ % gAudioBufferParams.specUnk4) != 0) { return gWaitingAudioTask; } - osSendMesg(gAudioTaskStartQueue, (OSMesg) gAudioTaskCountQ, 0); + osSendMesg(gAudioTaskStartQueue, OS_MESG_32(gAudioTaskCountQ), 0); gAudioTaskIndexQ ^= 1; gCurAiBuffIndex++; gCurAiBuffIndex %= 3; @@ -71,15 +71,15 @@ SPTask* AudioThread_CreateTask(void) { gCurAudioFrameDmaCount = 0; AudioLoad_DecreaseSampleDmaTtls(); AudioLoad_ProcessLoads(gResetStatus); - if (osRecvMesg(gAudioUnkQueue, (OSMesg) &sp38, 0) != -1) { + if (osRecvMesg(gAudioUnkQueue, &sp38, 0) != -1) { if (gResetStatus == 0) { gResetStatus = 5; } - gAudioSpecId = sp38; + gAudioSpecId = sp38.data32; } if ((gResetStatus != 0) && (AudioHeap_ResetStep() == 0)) { if (gResetStatus == 0) { - osSendMesg(gAudioResetQueue, (OSMesg) (s32) gAudioSpecId, 0); + osSendMesg(gAudioResetQueue, OS_MESG_32((s32) gAudioSpecId), 0); } gWaitingAudioTask = NULL; return NULL; @@ -102,8 +102,8 @@ SPTask* AudioThread_CreateTask(void) { if (gAiBuffLengths[sp4C] > gAudioBufferParams.maxAiBufferLength) { gAiBuffLengths[sp4C] = gAudioBufferParams.maxAiBufferLength; } - while (osRecvMesg(gThreadCmdProcQueue, (OSMesg) &sp34, 0) != -1) { - AudioThread_ProcessCmds(sp34); + while (osRecvMesg(gThreadCmdProcQueue, &sp34, 0) != -1) { + AudioThread_ProcessCmds(sp34.data32); } gCurAbiCmdBuffer = func_80009B64(gCurAbiCmdBuffer, &sp50, sp40, gAiBuffLengths[sp4C]); gAudioRandom = osGetCount() * (gAudioRandom + gAudioTaskCountQ); @@ -112,19 +112,19 @@ SPTask* AudioThread_CreateTask(void) { sp4C = gAudioTaskIndexQ; gAudioCurTask->msgQueue = NULL; - gAudioCurTask->msg = NULL; + gAudioCurTask->msg = OS_MESG_PTR(NULL); task = &gAudioCurTask->task.t; task->type = 2; task->flags = 0; - task->ucode_boot = rspbootTextStart; - task->ucode_boot_size = (uintptr_t) rspbootTextEnd - (uintptr_t) rspbootTextStart; - - task->ucode = aspMainTextStart; - task->ucode_data = aspMainDataStart; - task->ucode_size = SP_UCODE_SIZE; - task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * 8; + // task->ucode_boot = rspbootTextStart; + // task->ucode_boot_size = (uintptr_t) rspbootTextEnd - (uintptr_t) rspbootTextStart; + // + // task->ucode = aspMainTextStart; + // task->ucode_data = aspMainDataStart; + // task->ucode_size = SP_UCODE_SIZE; + // task->ucode_data_size = (aspMainDataEnd - aspMainDataStart) * 8; task->dram_stack = NULL; task->dram_stack_size = 0; @@ -282,7 +282,7 @@ void AudioThread_ScheduleProcessCmds(void) { D_800C7C70 = (u8) (gThreadCmdWritePos - gThreadCmdReadPos + 0x100); } msg = (((gThreadCmdReadPos & 0xFF) << 8) | (gThreadCmdWritePos & 0xFF)); - osSendMesg(gThreadCmdProcQueue, (OSMesg) msg, 0); + osSendMesg(gThreadCmdProcQueue, OS_MESG_32(msg), 0); gThreadCmdReadPos = gThreadCmdWritePos; } @@ -420,7 +420,7 @@ void AudioThread_ResetAudioHeap(s32 specId) { // clang-format on AudioThread_ResetCmdQueue(); - osSendMesg(gAudioUnkQueue, (OSMesg) specId, 0); + osSendMesg(gAudioUnkQueue, OS_MESG_32(specId), 0); } void AudioThread_PreNMIReset(void) { diff --git a/src/buffers.c b/src/buffers.c index 3ca949c8..50ac0cb0 100644 --- a/src/buffers.c +++ b/src/buffers.c @@ -1,6 +1,5 @@ #include "global.h" -u64 gDramStack[SP_DRAM_STACK_SIZE64]; u8 gOSYieldData[OS_YIELD_DATA_SIZE]; FrameBuffer gZBuffer; // z buffer u8 gTaskOutputBuffer[0x30000]; diff --git a/src/dmatable.c b/src/dmatable.c index b2b4f77c..b8231e06 100644 --- a/src/dmatable.c +++ b/src/dmatable.c @@ -6,82 +6,82 @@ { NULL, { NULL, NULL }, false } DmaEntry gDmaTable[90] = { - { SEGMENT_ROM_START(makerom), { SEGMENT_ROM_START(makerom), SEGMENT_ROM_END(makerom) }, false }, - { SEGMENT_ROM_START(main), { SEGMENT_ROM_START(main), SEGMENT_ROM_END(main) }, false }, - { SEGMENT_ROM_START(dma_table), { SEGMENT_ROM_START(dma_table), SEGMENT_ROM_END(dma_table) }, false }, - { SEGMENT_ROM_START(audio_seq), { SEGMENT_ROM_START(audio_seq), SEGMENT_ROM_END(audio_seq) }, false }, - { SEGMENT_ROM_START(audio_bank), { SEGMENT_ROM_START(audio_bank), SEGMENT_ROM_END(audio_bank) }, false }, - { SEGMENT_ROM_START(audio_table), { SEGMENT_ROM_START(audio_table), SEGMENT_ROM_END(audio_table) }, false }, - { SEGMENT_ROM_START(ast_common), { SEGMENT_ROM_START(ast_common), SEGMENT_ROM_END(ast_common) }, false }, - { SEGMENT_ROM_START(ast_bg_space), { SEGMENT_ROM_START(ast_bg_space), SEGMENT_ROM_END(ast_bg_space) }, false }, - { SEGMENT_ROM_START(ast_bg_planet), { SEGMENT_ROM_START(ast_bg_planet), SEGMENT_ROM_END(ast_bg_planet) }, false }, - { SEGMENT_ROM_START(ast_arwing), { SEGMENT_ROM_START(ast_arwing), SEGMENT_ROM_END(ast_arwing) }, false }, - { SEGMENT_ROM_START(ast_landmaster), - { SEGMENT_ROM_START(ast_landmaster), SEGMENT_ROM_END(ast_landmaster) }, - false }, - { SEGMENT_ROM_START(ast_blue_marine), - { SEGMENT_ROM_START(ast_blue_marine), SEGMENT_ROM_END(ast_blue_marine) }, - false }, - { SEGMENT_ROM_START(ast_versus), { SEGMENT_ROM_START(ast_versus), SEGMENT_ROM_END(ast_versus) }, false }, - { SEGMENT_ROM_START(ast_enmy_planet), - { SEGMENT_ROM_START(ast_enmy_planet), SEGMENT_ROM_END(ast_enmy_planet) }, - false }, - { SEGMENT_ROM_START(ast_enmy_space), - { SEGMENT_ROM_START(ast_enmy_space), SEGMENT_ROM_END(ast_enmy_space) }, - false }, - { SEGMENT_ROM_START(ast_great_fox), { SEGMENT_ROM_START(ast_great_fox), SEGMENT_ROM_END(ast_great_fox) }, false }, - { SEGMENT_ROM_START(ast_star_wolf), { SEGMENT_ROM_START(ast_star_wolf), SEGMENT_ROM_END(ast_star_wolf) }, false }, - { SEGMENT_ROM_START(ast_allies), { SEGMENT_ROM_START(ast_allies), SEGMENT_ROM_END(ast_allies) }, false }, - { SEGMENT_ROM_START(ast_corneria), { SEGMENT_ROM_START(ast_corneria), SEGMENT_ROM_END(ast_corneria) }, false }, - { SEGMENT_ROM_START(ast_meteo), { SEGMENT_ROM_START(ast_meteo), SEGMENT_ROM_END(ast_meteo) }, false }, - { SEGMENT_ROM_START(ast_titania), { SEGMENT_ROM_START(ast_titania), SEGMENT_ROM_END(ast_titania) }, false }, - { SEGMENT_ROM_START(ast_7_ti_2), { SEGMENT_ROM_START(ast_7_ti_2), SEGMENT_ROM_END(ast_7_ti_2) }, false }, - { SEGMENT_ROM_START(ast_8_ti), { SEGMENT_ROM_START(ast_8_ti), SEGMENT_ROM_END(ast_8_ti) }, false }, - { SEGMENT_ROM_START(ast_9_ti), { SEGMENT_ROM_START(ast_9_ti), SEGMENT_ROM_END(ast_9_ti) }, false }, - { SEGMENT_ROM_START(ast_A_ti), { SEGMENT_ROM_START(ast_A_ti), SEGMENT_ROM_END(ast_A_ti) }, false }, - { SEGMENT_ROM_START(ast_7_ti_1), { SEGMENT_ROM_START(ast_7_ti_1), SEGMENT_ROM_END(ast_7_ti_1) }, false }, - { SEGMENT_ROM_START(ast_sector_x), { SEGMENT_ROM_START(ast_sector_x), SEGMENT_ROM_END(ast_sector_x) }, false }, - { SEGMENT_ROM_START(ast_sector_z), { SEGMENT_ROM_START(ast_sector_z), SEGMENT_ROM_END(ast_sector_z) }, false }, - { SEGMENT_ROM_START(ast_aquas), { SEGMENT_ROM_START(ast_aquas), SEGMENT_ROM_END(ast_aquas) }, false }, - { SEGMENT_ROM_START(ast_area_6), { SEGMENT_ROM_START(ast_area_6), SEGMENT_ROM_END(ast_area_6) }, false }, - { SEGMENT_ROM_START(ast_venom_1), { SEGMENT_ROM_START(ast_venom_1), SEGMENT_ROM_END(ast_venom_1) }, false }, - { SEGMENT_ROM_START(ast_venom_2), { SEGMENT_ROM_START(ast_venom_2), SEGMENT_ROM_END(ast_venom_2) }, false }, - { SEGMENT_ROM_START(ast_ve1_boss), { SEGMENT_ROM_START(ast_ve1_boss), SEGMENT_ROM_END(ast_ve1_boss) }, false }, - { SEGMENT_ROM_START(ast_bolse), { SEGMENT_ROM_START(ast_bolse), SEGMENT_ROM_END(ast_bolse) }, false }, - { SEGMENT_ROM_START(ast_fortuna), { SEGMENT_ROM_START(ast_fortuna), SEGMENT_ROM_END(ast_fortuna) }, false }, - { SEGMENT_ROM_START(ast_sector_y), { SEGMENT_ROM_START(ast_sector_y), SEGMENT_ROM_END(ast_sector_y) }, false }, - { SEGMENT_ROM_START(ast_solar), { SEGMENT_ROM_START(ast_solar), SEGMENT_ROM_END(ast_solar) }, false }, - { SEGMENT_ROM_START(ast_zoness), { SEGMENT_ROM_START(ast_zoness), SEGMENT_ROM_END(ast_zoness) }, false }, - { SEGMENT_ROM_START(ast_katina), { SEGMENT_ROM_START(ast_katina), SEGMENT_ROM_END(ast_katina) }, false }, - { SEGMENT_ROM_START(ast_macbeth), { SEGMENT_ROM_START(ast_macbeth), SEGMENT_ROM_END(ast_macbeth) }, false }, - { SEGMENT_ROM_START(ast_warp_zone), { SEGMENT_ROM_START(ast_warp_zone), SEGMENT_ROM_END(ast_warp_zone) }, false }, - { SEGMENT_ROM_START(ast_title), { SEGMENT_ROM_START(ast_title), SEGMENT_ROM_END(ast_title) }, false }, - { SEGMENT_ROM_START(ast_map), { SEGMENT_ROM_START(ast_map), SEGMENT_ROM_END(ast_map) }, false }, - { SEGMENT_ROM_START(ast_option), { SEGMENT_ROM_START(ast_option), SEGMENT_ROM_END(ast_option) }, false }, - { SEGMENT_ROM_START(ast_vs_menu), { SEGMENT_ROM_START(ast_vs_menu), SEGMENT_ROM_END(ast_vs_menu) }, false }, - { SEGMENT_ROM_START(ast_font), { SEGMENT_ROM_START(ast_font), SEGMENT_ROM_END(ast_font) }, false }, - { SEGMENT_ROM_START(ast_font_3d), { SEGMENT_ROM_START(ast_font_3d), SEGMENT_ROM_END(ast_font_3d) }, false }, - { SEGMENT_ROM_START(ast_andross), { SEGMENT_ROM_START(ast_andross), SEGMENT_ROM_END(ast_andross) }, false }, - { SEGMENT_ROM_START(ast_logo), { SEGMENT_ROM_START(ast_logo), SEGMENT_ROM_END(ast_logo) }, false }, - { SEGMENT_ROM_START(ast_ending), { SEGMENT_ROM_START(ast_ending), SEGMENT_ROM_END(ast_ending) }, false }, - { SEGMENT_ROM_START(ast_ending_award_front), - { SEGMENT_ROM_START(ast_ending_award_front), SEGMENT_ROM_END(ast_ending_award_front) }, - false }, - { SEGMENT_ROM_START(ast_ending_award_back), - { SEGMENT_ROM_START(ast_ending_award_back), SEGMENT_ROM_END(ast_ending_award_back) }, - false }, - { SEGMENT_ROM_START(ast_ending_expert), - { SEGMENT_ROM_START(ast_ending_expert), SEGMENT_ROM_END(ast_ending_expert) }, - false }, - { SEGMENT_ROM_START(ast_training), { SEGMENT_ROM_START(ast_training), SEGMENT_ROM_END(ast_training) }, false }, - { SEGMENT_ROM_START(ast_radio), { SEGMENT_ROM_START(ast_radio), SEGMENT_ROM_END(ast_radio) }, false }, - { SEGMENT_ROM_START(ovl_i1), { SEGMENT_ROM_START(ovl_i1), SEGMENT_ROM_END(ovl_i1) }, false }, - { SEGMENT_ROM_START(ovl_i2), { SEGMENT_ROM_START(ovl_i2), SEGMENT_ROM_END(ovl_i2) }, false }, - { SEGMENT_ROM_START(ovl_i3), { SEGMENT_ROM_START(ovl_i3), SEGMENT_ROM_END(ovl_i3) }, false }, - { SEGMENT_ROM_START(ovl_i4), { SEGMENT_ROM_START(ovl_i4), SEGMENT_ROM_END(ovl_i4) }, false }, - { SEGMENT_ROM_START(ovl_i5), { SEGMENT_ROM_START(ovl_i5), SEGMENT_ROM_END(ovl_i5) }, false }, - { SEGMENT_ROM_START(ovl_i6), { SEGMENT_ROM_START(ovl_i6), SEGMENT_ROM_END(ovl_i6) }, false }, - { SEGMENT_ROM_START(ovl_menu), { SEGMENT_ROM_START(ovl_menu), SEGMENT_ROM_END(ovl_menu) }, false }, - { SEGMENT_ROM_START(ovl_ending), { SEGMENT_ROM_START(ovl_ending), SEGMENT_ROM_END(ovl_ending) }, false }, - { SEGMENT_ROM_START(ovl_unused), { SEGMENT_ROM_START(ovl_unused), SEGMENT_ROM_END(ovl_unused) }, false }, + // { SEGMENT_ROM_START(makerom), { SEGMENT_ROM_START(makerom), SEGMENT_ROM_END(makerom) }, false }, + // { SEGMENT_ROM_START(main), { SEGMENT_ROM_START(main), SEGMENT_ROM_END(main) }, false }, + // { SEGMENT_ROM_START(dma_table), { SEGMENT_ROM_START(dma_table), SEGMENT_ROM_END(dma_table) }, false }, + // { SEGMENT_ROM_START(audio_seq), { SEGMENT_ROM_START(audio_seq), SEGMENT_ROM_END(audio_seq) }, false }, + // { SEGMENT_ROM_START(audio_bank), { SEGMENT_ROM_START(audio_bank), SEGMENT_ROM_END(audio_bank) }, false }, + // { SEGMENT_ROM_START(audio_table), { SEGMENT_ROM_START(audio_table), SEGMENT_ROM_END(audio_table) }, false }, + // { SEGMENT_ROM_START(ast_common), { SEGMENT_ROM_START(ast_common), SEGMENT_ROM_END(ast_common) }, false }, + // { SEGMENT_ROM_START(ast_bg_space), { SEGMENT_ROM_START(ast_bg_space), SEGMENT_ROM_END(ast_bg_space) }, false }, + // { SEGMENT_ROM_START(ast_bg_planet), { SEGMENT_ROM_START(ast_bg_planet), SEGMENT_ROM_END(ast_bg_planet) }, false }, + // { SEGMENT_ROM_START(ast_arwing), { SEGMENT_ROM_START(ast_arwing), SEGMENT_ROM_END(ast_arwing) }, false }, + // { SEGMENT_ROM_START(ast_landmaster), + // { SEGMENT_ROM_START(ast_landmaster), SEGMENT_ROM_END(ast_landmaster) }, + // false }, + // { SEGMENT_ROM_START(ast_blue_marine), + // { SEGMENT_ROM_START(ast_blue_marine), SEGMENT_ROM_END(ast_blue_marine) }, + // false }, + // { SEGMENT_ROM_START(ast_vs_player), { SEGMENT_ROM_START(ast_vs_player), SEGMENT_ROM_END(ast_vs_player) }, false }, + // { SEGMENT_ROM_START(ast_enmy_planet), + // { SEGMENT_ROM_START(ast_enmy_planet), SEGMENT_ROM_END(ast_enmy_planet) }, + // false }, + // { SEGMENT_ROM_START(ast_enmy_space), + // { SEGMENT_ROM_START(ast_enmy_space), SEGMENT_ROM_END(ast_enmy_space) }, + // false }, + // { SEGMENT_ROM_START(ast_great_fox), { SEGMENT_ROM_START(ast_great_fox), SEGMENT_ROM_END(ast_great_fox) }, false }, + // { SEGMENT_ROM_START(ast_star_wolf), { SEGMENT_ROM_START(ast_star_wolf), SEGMENT_ROM_END(ast_star_wolf) }, false }, + // { SEGMENT_ROM_START(ast_allies), { SEGMENT_ROM_START(ast_allies), SEGMENT_ROM_END(ast_allies) }, false }, + // { SEGMENT_ROM_START(ast_corneria), { SEGMENT_ROM_START(ast_corneria), SEGMENT_ROM_END(ast_corneria) }, false }, + // { SEGMENT_ROM_START(ast_meteo), { SEGMENT_ROM_START(ast_meteo), SEGMENT_ROM_END(ast_meteo) }, false }, + // { SEGMENT_ROM_START(ast_titania), { SEGMENT_ROM_START(ast_titania), SEGMENT_ROM_END(ast_titania) }, false }, + // { SEGMENT_ROM_START(ast_7_ti_2), { SEGMENT_ROM_START(ast_7_ti_2), SEGMENT_ROM_END(ast_7_ti_2) }, false }, + // { SEGMENT_ROM_START(ast_8_ti), { SEGMENT_ROM_START(ast_8_ti), SEGMENT_ROM_END(ast_8_ti) }, false }, + // { SEGMENT_ROM_START(ast_9_ti), { SEGMENT_ROM_START(ast_9_ti), SEGMENT_ROM_END(ast_9_ti) }, false }, + // { SEGMENT_ROM_START(ast_A_ti), { SEGMENT_ROM_START(ast_A_ti), SEGMENT_ROM_END(ast_A_ti) }, false }, + // { SEGMENT_ROM_START(ast_7_ti_1), { SEGMENT_ROM_START(ast_7_ti_1), SEGMENT_ROM_END(ast_7_ti_1) }, false }, + // { SEGMENT_ROM_START(ast_sector_x), { SEGMENT_ROM_START(ast_sector_x), SEGMENT_ROM_END(ast_sector_x) }, false }, + // { SEGMENT_ROM_START(ast_sector_z), { SEGMENT_ROM_START(ast_sector_z), SEGMENT_ROM_END(ast_sector_z) }, false }, + // { SEGMENT_ROM_START(ast_aquas), { SEGMENT_ROM_START(ast_aquas), SEGMENT_ROM_END(ast_aquas) }, false }, + // { SEGMENT_ROM_START(ast_area_6), { SEGMENT_ROM_START(ast_area_6), SEGMENT_ROM_END(ast_area_6) }, false }, + // { SEGMENT_ROM_START(ast_venom_1), { SEGMENT_ROM_START(ast_venom_1), SEGMENT_ROM_END(ast_venom_1) }, false }, + // { SEGMENT_ROM_START(ast_venom_2), { SEGMENT_ROM_START(ast_venom_2), SEGMENT_ROM_END(ast_venom_2) }, false }, + // { SEGMENT_ROM_START(ast_ve1_boss), { SEGMENT_ROM_START(ast_ve1_boss), SEGMENT_ROM_END(ast_ve1_boss) }, false }, + // { SEGMENT_ROM_START(ast_bolse), { SEGMENT_ROM_START(ast_bolse), SEGMENT_ROM_END(ast_bolse) }, false }, + // { SEGMENT_ROM_START(ast_fortuna), { SEGMENT_ROM_START(ast_fortuna), SEGMENT_ROM_END(ast_fortuna) }, false }, + // { SEGMENT_ROM_START(ast_sector_y), { SEGMENT_ROM_START(ast_sector_y), SEGMENT_ROM_END(ast_sector_y) }, false }, + // { SEGMENT_ROM_START(ast_solar), { SEGMENT_ROM_START(ast_solar), SEGMENT_ROM_END(ast_solar) }, false }, + // { SEGMENT_ROM_START(ast_zoness), { SEGMENT_ROM_START(ast_zoness), SEGMENT_ROM_END(ast_zoness) }, false }, + // { SEGMENT_ROM_START(ast_katina), { SEGMENT_ROM_START(ast_katina), SEGMENT_ROM_END(ast_katina) }, false }, + // { SEGMENT_ROM_START(ast_macbeth), { SEGMENT_ROM_START(ast_macbeth), SEGMENT_ROM_END(ast_macbeth) }, false }, + // { SEGMENT_ROM_START(ast_warp_zone), { SEGMENT_ROM_START(ast_warp_zone), SEGMENT_ROM_END(ast_warp_zone) }, false }, + // { SEGMENT_ROM_START(ast_title), { SEGMENT_ROM_START(ast_title), SEGMENT_ROM_END(ast_title) }, false }, + // { SEGMENT_ROM_START(ast_map), { SEGMENT_ROM_START(ast_map), SEGMENT_ROM_END(ast_map) }, false }, + // { SEGMENT_ROM_START(ast_option), { SEGMENT_ROM_START(ast_option), SEGMENT_ROM_END(ast_option) }, false }, + // { SEGMENT_ROM_START(ast_versus), { SEGMENT_ROM_START(ast_versus), SEGMENT_ROM_END(ast_versus) }, false }, + // { SEGMENT_ROM_START(ast_font), { SEGMENT_ROM_START(ast_font), SEGMENT_ROM_END(ast_font) }, false }, + // { SEGMENT_ROM_START(ast_font_3d), { SEGMENT_ROM_START(ast_font_3d), SEGMENT_ROM_END(ast_font_3d) }, false }, + // { SEGMENT_ROM_START(ast_andross), { SEGMENT_ROM_START(ast_andross), SEGMENT_ROM_END(ast_andross) }, false }, + // { SEGMENT_ROM_START(ast_logo), { SEGMENT_ROM_START(ast_logo), SEGMENT_ROM_END(ast_logo) }, false }, + // { SEGMENT_ROM_START(ast_ending), { SEGMENT_ROM_START(ast_ending), SEGMENT_ROM_END(ast_ending) }, false }, + // { SEGMENT_ROM_START(ast_ending_award_front), + // { SEGMENT_ROM_START(ast_ending_award_front), SEGMENT_ROM_END(ast_ending_award_front) }, + // false }, + // { SEGMENT_ROM_START(ast_ending_award_back), + // { SEGMENT_ROM_START(ast_ending_award_back), SEGMENT_ROM_END(ast_ending_award_back) }, + // false }, + // { SEGMENT_ROM_START(ast_ending_expert), + // { SEGMENT_ROM_START(ast_ending_expert), SEGMENT_ROM_END(ast_ending_expert) }, + // false }, + // { SEGMENT_ROM_START(ast_training), { SEGMENT_ROM_START(ast_training), SEGMENT_ROM_END(ast_training) }, false }, + // { SEGMENT_ROM_START(ast_radio), { SEGMENT_ROM_START(ast_radio), SEGMENT_ROM_END(ast_radio) }, false }, + // { SEGMENT_ROM_START(ovl_i1), { SEGMENT_ROM_START(ovl_i1), SEGMENT_ROM_END(ovl_i1) }, false }, + // { SEGMENT_ROM_START(ovl_i2), { SEGMENT_ROM_START(ovl_i2), SEGMENT_ROM_END(ovl_i2) }, false }, + // { SEGMENT_ROM_START(ovl_i3), { SEGMENT_ROM_START(ovl_i3), SEGMENT_ROM_END(ovl_i3) }, false }, + // { SEGMENT_ROM_START(ovl_i4), { SEGMENT_ROM_START(ovl_i4), SEGMENT_ROM_END(ovl_i4) }, false }, + // { SEGMENT_ROM_START(ovl_i5), { SEGMENT_ROM_START(ovl_i5), SEGMENT_ROM_END(ovl_i5) }, false }, + // { SEGMENT_ROM_START(ovl_i6), { SEGMENT_ROM_START(ovl_i6), SEGMENT_ROM_END(ovl_i6) }, false }, + // { SEGMENT_ROM_START(ovl_menu), { SEGMENT_ROM_START(ovl_menu), SEGMENT_ROM_END(ovl_menu) }, false }, + // { SEGMENT_ROM_START(ovl_ending), { SEGMENT_ROM_START(ovl_ending), SEGMENT_ROM_END(ovl_ending) }, false }, + // { SEGMENT_ROM_START(ovl_unused), { SEGMENT_ROM_START(ovl_unused), SEGMENT_ROM_END(ovl_unused) }, false }, }; diff --git a/src/engine/fox_360.c b/src/engine/fox_360.c index 9dbdfa93..2adec923 100644 --- a/src/engine/fox_360.c +++ b/src/engine/fox_360.c @@ -2272,10 +2272,12 @@ void ActorAllRange_Draw(Actor* actor) { break; } } else if (gCurrentLevel == LEVEL_SECTOR_Z) { - gSPDisplayList(gMasterDisp++, D_SZ_6004FE0) Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1); + gSPDisplayList(gMasterDisp++, D_SZ_6004FE0); + Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1); func_edisplay_8005B1E8(actor, 2); } else if (gCurrentLevel == LEVEL_BOLSE) { - gSPDisplayList(gMasterDisp++, D_BO_6008770) Matrix_Push(&gGfxMatrix); + gSPDisplayList(gMasterDisp++, D_BO_6008770); + Matrix_Push(&gGfxMatrix); Matrix_Translate(gGfxMatrix, 0.0f, 0.0f, -60.0f, 1); func_edisplay_8005B1E8(actor, 2); Matrix_Pop(&gGfxMatrix); diff --git a/src/engine/fox_load.c b/src/engine/fox_load.c index 556a6c50..5ad54e8c 100644 --- a/src/engine/fox_load.c +++ b/src/engine/fox_load.c @@ -27,22 +27,21 @@ OverlayInit sCurrentOverlay = { }; void Overlay_LoadSegment(void* vRomAddress, void* dest, ptrdiff_t size) { - s32 i; - - for (i = 0; gDmaTable[i].pRom.end != NULL; i++) { - if (gDmaTable[i].vRomAddress == vRomAddress) { - if (gDmaTable[i].compFlag == 0) { - Lib_DmaRead(gDmaTable[i].pRom.start, dest, size); - } else { - Lib_FillScreen(true); - sFillTimer = 3; - D_game_80161A39 = true; - Lib_DmaRead(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom)); - Mio0_Decompress(gFrameBuffers, dest); - } - break; - } - } + // s32 i; + // for (i = 0; gDmaTable[i].pRom.end != NULL; i++) { + // if (gDmaTable[i].vRomAddress == vRomAddress) { + // if (gDmaTable[i].compFlag == 0) { + // Lib_DmaRead(gDmaTable[i].pRom.start, dest, size); + // } else { + // Lib_FillScreen(true); + // sFillTimer = 3; + // D_80161A39 = true; + // Lib_DmaRead(gDmaTable[i].pRom.start, gFrameBuffers, SEGMENT_SIZE(gDmaTable[i].pRom)); + // Mio0_Decompress(gFrameBuffers, dest); + // } + // break; + // } + // } } u8 Overlay_Init(OverlayInit* ovlInit) { @@ -196,6 +195,6 @@ u8 Overlay_Load(u8 ovlSetup, u8 ovlStage) { } void Overlay_InitDma(void) { - Lib_DmaRead(SEGMENT_ROM_START(dma_table), SEGMENT_VRAM_START(dma_table), SEGMENT_ROM_SIZE(dma_table)); - Overlay_LoadSegment(SEGMENT_ROM_START(ast_radio), SEGMENT_VRAM_START(ast_radio), SEGMENT_ROM_SIZE(ast_radio)); + // Lib_DmaRead(SEGMENT_ROM_START(dma_table), SEGMENT_VRAM_START(dma_table), SEGMENT_ROM_SIZE(dma_table)); + // Overlay_LoadSegment(SEGMENT_ROM_START(ast_radio), SEGMENT_VRAM_START(ast_radio), SEGMENT_ROM_SIZE(ast_radio)); } diff --git a/src/engine/fox_load_inits.c b/src/engine/fox_load_inits.c index 621f718b..580a27c8 100644 --- a/src/engine/fox_load_inits.c +++ b/src/engine/fox_load_inits.c @@ -4,12 +4,7 @@ { NULL, NULL } #define OVERLAY_OFFSETS(file) \ - { \ - { SEGMENT_ROM_START(file), SEGMENT_ROM_END(file) }, { SEGMENT_BSS_START(file), SEGMENT_BSS_END(file) }, \ - { SEGMENT_TEXT_START(file), SEGMENT_TEXT_END(file) }, { \ - SEGMENT_DATA_START(file), SEGMENT_RODATA_END(file) \ - } \ - } + NO_OVERLAY #define NO_OVERLAY \ { \ @@ -19,7 +14,7 @@ } #define ROM_SEGMENT(file) \ - { SEGMENT_ROM_START(file), SEGMENT_ROM_END(file) } + NO_SEGMENT OverlayInit sNoOvl_Logo[1] = { { NO_OVERLAY, diff --git a/src/engine/fox_save.c b/src/engine/fox_save.c index beb3357e..554ab310 100644 --- a/src/engine/fox_save.c +++ b/src/engine/fox_save.c @@ -39,26 +39,26 @@ u16 Save_Checksum(Save* arg0) { } s32 Save_Write(void) { - void* sp1C; + OSMesg sp1C; gSaveFile.save.checksum = Save_Checksum(&gSaveFile.save); gSaveFile.backup = gSaveFile.save; gSaveIOBuffer = gSaveFile; - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_WRITE_SAVE, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_WRITE_SAVE), OS_MESG_PRI_NORMAL); osRecvMesg(&gSaveMsgQueue, &sp1C, OS_MESG_BLOCK); - if (sp1C != (OSMesg) SI_SAVE_SUCCESS) { + if (sp1C.data32 != SI_SAVE_SUCCESS) { return -1; } return 0; } s32 Save_Read(void) { - void* sp24; + OSMesg* sp24; s32 i; - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_READ_SAVE, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_SAVE), OS_MESG_PRI_NORMAL); osRecvMesg(&gSaveMsgQueue, &sp24, OS_MESG_BLOCK); - if ((s32) sp24 != SI_SAVE_SUCCESS) { + if (sp24->data32 != SI_SAVE_SUCCESS) { return -1; } diff --git a/src/engine/guPerspectiveF.c b/src/engine/guPerspectiveF.c new file mode 100644 index 00000000..a7247534 --- /dev/null +++ b/src/engine/guPerspectiveF.c @@ -0,0 +1,40 @@ +#include +#include + +void guPerspectiveF(float mf[4][4], u16 *perspNorm, float fovy, float aspect, float near, float far, + float scale) { + float yscale; + int row; + int col; + guMtxIdentF(mf); + fovy *= GU_PI / 180.0; + yscale = cosf(fovy / 2) / sinf(fovy / 2); + mf[0][0] = yscale / aspect; + mf[1][1] = yscale; + mf[2][2] = (near + far) / (near - far); + mf[2][3] = -1; + mf[3][2] = 2 * near * far / (near - far); + mf[3][3] = 0.0f; + for (row = 0; row < 4; row++) { + for (col = 0; col < 4; col++) { + mf[row][col] *= scale; + } + } + if (perspNorm != NULL) { + if (near + far <= 2.0) { + *perspNorm = 65535; + } else { + *perspNorm = (double) (1 << 17) / (near + far); + if (*perspNorm <= 0) { + *perspNorm = 1; + } + } + } +} + +void guPerspective(Mtx *m, u16 *perspNorm, float fovy, float aspect, float near, float far, + float scale) { + float mat[4][4]; + guPerspectiveF(mat, perspNorm, fovy, aspect, near, far, scale); + guMtxF2L(mat, m); +} diff --git a/src/engine/lookat.c b/src/engine/lookat.c new file mode 100644 index 00000000..e5060d24 --- /dev/null +++ b/src/engine/lookat.c @@ -0,0 +1,73 @@ +#include + +void guLookAtF(float mf[4][4], float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, + float yUp, float zUp) { + float len; + float xLook; + float yLook; + float zLook; + float xRight; + float yRight; + float zRight; + + guMtxIdentF(mf); + + xLook = xAt - xEye; + yLook = yAt - yEye; + zLook = zAt - zEye; + + /* Negate because positive Z is behind us: */ + len = -1.0 / guSqrtf(xLook * xLook + yLook * yLook + zLook * zLook); + xLook *= len; + yLook *= len; + zLook *= len; + + /* Right = Up x Look */ + + xRight = yUp * zLook - zUp * yLook; + yRight = zUp * xLook - xUp * zLook; + zRight = xUp * yLook - yUp * xLook; + len = 1.0 / guSqrtf(xRight * xRight + yRight * yRight + zRight * zRight); + xRight *= len; + yRight *= len; + zRight *= len; + + /* Up = Look x Right */ + + xUp = yLook * zRight - zLook * yRight; + yUp = zLook * xRight - xLook * zRight; + zUp = xLook * yRight - yLook * xRight; + len = 1.0 / guSqrtf(xUp * xUp + yUp * yUp + zUp * zUp); + xUp *= len; + yUp *= len; + zUp *= len; + + mf[0][0] = xRight; + mf[1][0] = yRight; + mf[2][0] = zRight; + mf[3][0] = -(xEye * xRight + yEye * yRight + zEye * zRight); + + mf[0][1] = xUp; + mf[1][1] = yUp; + mf[2][1] = zUp; + mf[3][1] = -(xEye * xUp + yEye * yUp + zEye * zUp); + + mf[0][2] = xLook; + mf[1][2] = yLook; + mf[2][2] = zLook; + mf[3][2] = -(xEye * xLook + yEye * yLook + zEye * zLook); + + mf[0][3] = 0; + mf[1][3] = 0; + mf[2][3] = 0; + mf[3][3] = 1; +} + +void guLookAt(Mtx* m, float xEye, float yEye, float zEye, float xAt, float yAt, float zAt, float xUp, float yUp, + float zUp) { + float mf[4][4]; + + guLookAtF(mf, xEye, yEye, zEye, xAt, yAt, zAt, xUp, yUp, zUp); + + guMtxF2L(mf, m); +} diff --git a/src/libc_sprintf.c b/src/libc_sprintf.c index 0b2e506f..60af7d6e 100644 --- a/src/libc_sprintf.c +++ b/src/libc_sprintf.c @@ -6,26 +6,26 @@ void* proutSprintf(void* dst, const char* fmt, size_t size) { return (void*) ((uintptr_t) memcpy(dst, fmt, size) + size); } -s32 vsprintf(char* dst, const char* fmt, va_list args) { - s32 ret = _Printf((outfun*) proutSprintf, dst, fmt, args); - - if (ret > -1) { - dst[ret] = 0; - } - return ret; -} - -int sprintf(char* s, const char* fmt, ...) { - s32 ret; - va_list args; - va_start(args, fmt); - - ret = _Printf((outfun*) proutSprintf, s, fmt, args); - - if (ret >= 0) { - s[ret] = 0; - } - va_end(args); - - return ret; -} +// s32 vsprintf(char* dst, const char* fmt, va_list args) { +// s32 ret = _Printf((outfun*) proutSprintf, dst, fmt, args); +// +// if (ret > -1) { +// dst[ret] = 0; +// } +// return ret; +// } +// +// int sprintf(char* s, const char* fmt, ...) { +// s32 ret; +// va_list args; +// va_start(args, fmt); +// +// ret = _Printf((outfun*) proutSprintf, s, fmt, args); +// +// if (ret >= 0) { +// s[ret] = 0; +// } +// va_end(args); +// +// return ret; +// } diff --git a/src/libultra/gu/cosf.c b/src/libultra/gu/cosf.c index e67d5485..4e250569 100644 --- a/src/libultra/gu/cosf.c +++ b/src/libultra/gu/cosf.c @@ -10,7 +10,7 @@ * * **************************************************************************/ -#include "PR/ultratypes.h" +#include #include "PR/guint.h" /* ==================================================================== diff --git a/src/libultra/gu/lookat.c b/src/libultra/gu/lookat.c index df591319..9086aad8 100644 --- a/src/libultra/gu/lookat.c +++ b/src/libultra/gu/lookat.c @@ -1,4 +1,4 @@ -#include "PR/ultratypes.h" +#include #include "PR/gbi.h" #include "PR/gu.h" diff --git a/src/libultra/gu/mtxutil.c b/src/libultra/gu/mtxutil.c index 66dc44c3..e4521bb1 100644 --- a/src/libultra/gu/mtxutil.c +++ b/src/libultra/gu/mtxutil.c @@ -10,8 +10,7 @@ * * **************************************************************************/ -#include "PR/ultratypes.h" -#include "PR/guint.h" +#include void guMtxF2L(float mf[4][4], Mtx* m) { int i, j; diff --git a/src/libultra/gu/ortho.c b/src/libultra/gu/ortho.c index f389ab26..3ce76557 100644 --- a/src/libultra/gu/ortho.c +++ b/src/libultra/gu/ortho.c @@ -1,5 +1,4 @@ -#include "PR/ultratypes.h" -#include "PR/gu.h" +#include void guOrthoF(float mf[4][4], float l, float r, float b, float t, float n, float f, float scale) { int i; diff --git a/src/libultra/gu/perspective.c b/src/libultra/gu/perspective.c index 9b54e888..850289d7 100644 --- a/src/libultra/gu/perspective.c +++ b/src/libultra/gu/perspective.c @@ -11,7 +11,7 @@ * * **************************************************************************/ -#include "PR/ultratypes.h" +#include #include "PR/guint.h" extern f32 __cosf(f32); diff --git a/src/libultra/gu/sinf.c b/src/libultra/gu/sinf.c index b10dece6..f5264e7f 100644 --- a/src/libultra/gu/sinf.c +++ b/src/libultra/gu/sinf.c @@ -10,7 +10,7 @@ * * **************************************************************************/ -#include "PR/ultratypes.h" +#include #include "PR/guint.h" /* ==================================================================== diff --git a/src/libultra/gu/sqrtf.c b/src/libultra/gu/sqrtf.c index 57df68b3..fd51829c 100644 --- a/src/libultra/gu/sqrtf.c +++ b/src/libultra/gu/sqrtf.c @@ -1,5 +1,5 @@ -#include "PR/ultratypes.h" -#include "libc/math.h" +#include +#include "math.h" f32 guSqrtf(f32 value) { return sqrtf(value); diff --git a/src/libultra/io/ai.c b/src/libultra/io/ai.c index f297634f..b6c55165 100644 --- a/src/libultra/io/ai.c +++ b/src/libultra/io/ai.c @@ -1,4 +1,4 @@ -#include "libc/stdbool.h" +#include "stdbool.h" #include "PR/rcp.h" s32 __osAiDeviceBusy(void) { diff --git a/src/libultra/io/aisetfreq.c b/src/libultra/io/aisetfreq.c index 6225e1ee..c1bc23db 100644 --- a/src/libultra/io/aisetfreq.c +++ b/src/libultra/io/aisetfreq.c @@ -1,4 +1,4 @@ -#include "PR/rcp.h" +#include extern s32 osViClock; diff --git a/src/libultra/libc/ldiv.c b/src/libultra/libc/ldiv.c index 2f6dace1..20be8d7a 100644 --- a/src/libultra/libc/ldiv.c +++ b/src/libultra/libc/ldiv.c @@ -1,4 +1,4 @@ -#include "libc/stdlib.h" +#include "stdlib.h" lldiv_t lldiv(long long numer, long long denom) { lldiv_t val; diff --git a/src/libultra/libc/string.c b/src/libultra/libc/string.c index dc92907c..96aec169 100644 --- a/src/libultra/libc/string.c +++ b/src/libultra/libc/string.c @@ -1,4 +1,4 @@ -#include "PR/ultratypes.h" +#include void* memcpy(void* s1, const void* s2, size_t n) { unsigned char* su1 = (unsigned char*) s1; diff --git a/src/libultra/libc/xldtob.c b/src/libultra/libc/xldtob.c index 0327cc66..c5987284 100644 --- a/src/libultra/libc/xldtob.c +++ b/src/libultra/libc/xldtob.c @@ -1,5 +1,5 @@ -#include "libc/stdlib.h" -#include "libc/string.h" +#include "stdlib.h" +#include "string.h" #include "PR/xstdio.h" // TODO: these come from headers diff --git a/src/libultra/libc/xlitob.c b/src/libultra/libc/xlitob.c index c74fd7ff..bbe26398 100644 --- a/src/libultra/libc/xlitob.c +++ b/src/libultra/libc/xlitob.c @@ -1,6 +1,6 @@ #include "PR/xstdio.h" -#include "libc/string.h" -#include "libc/stdlib.h" +#include "string.h" +#include "stdlib.h" #define BUFF_LEN 0x18 diff --git a/src/libultra/libc/xprintf.c b/src/libultra/libc/xprintf.c index f338f662..6fe74631 100644 --- a/src/libultra/libc/xprintf.c +++ b/src/libultra/libc/xprintf.c @@ -1,6 +1,6 @@ #include "macros.h" -#include "libc/string.h" -#include "libc/stdarg.h" +#include "string.h" +#include "stdarg.h" #include "PR/xstdio.h" // TODO: these come from headers diff --git a/src/overlays/ovl_i4/fox_bo.c b/src/overlays/ovl_i4/fox_bo.c index 73ea0119..c4211d01 100644 --- a/src/overlays/ovl_i4/fox_bo.c +++ b/src/overlays/ovl_i4/fox_bo.c @@ -2216,7 +2216,7 @@ void Bolse_80192264(void) { gDPLoadTileTexture(gMasterDisp++, D_BO_600AD80, G_IM_FMT_RGBA, G_IM_SIZ_16b, 32, 32); } Matrix_SetGfxMtx(&gMasterDisp); - gSPDisplayList(gMasterDisp++, D_BO_600BEC0) + gSPDisplayList(gMasterDisp++, D_BO_600BEC0); } Matrix_Pop(&gGfxMatrix); } diff --git a/src/overlays/ovl_menu/fox_title.h b/src/overlays/ovl_menu/fox_title.h index f75cf80c..741224e1 100644 --- a/src/overlays/ovl_menu/fox_title.h +++ b/src/overlays/ovl_menu/fox_title.h @@ -219,7 +219,7 @@ void Title_8018DF0C(f32 arg0); void Title_8018E058(void); void Title_8018E200(void); bool Title_8018EDC8(s32, Gfx **, Vec3f *, Vec3f *, void *); -void Title_8018E67C(s32); +void Title_8018E67C(s32); void Title_8018F438(void); void Title_80190144(void); void Title_801903B8(void); diff --git a/src/port/Engine.cpp b/src/port/Engine.cpp new file mode 100644 index 00000000..b6a1f636 --- /dev/null +++ b/src/port/Engine.cpp @@ -0,0 +1,119 @@ +#include "Engine.h" +#include "ui/ImguiUI.h" +#include "ZAPDUtils/Utils/StringHelper.h" +#include "libultraship/src/Context.h" + +#include +#include +#include + +#include + +extern "C" { +float gInterpolationStep = 0.0f; +} + +GameEngine* GameEngine::Instance; + +GameEngine::GameEngine() { + std::vector OTRFiles; + if (const std::string cube_path = LUS::Context::GetPathRelativeToAppDirectory("smcube.otr"); std::filesystem::exists(cube_path)) { + OTRFiles.push_back(cube_path); + } + if (const std::string sm64_otr_path = LUS::Context::GetPathRelativeToAppBundle("lylat.otr"); std::filesystem::exists(sm64_otr_path)) { + OTRFiles.push_back(sm64_otr_path); + } + if (const std::string patches_path = LUS::Context::GetPathRelativeToAppDirectory("mods"); !patches_path.empty() && std::filesystem::exists(patches_path)) { + if (std::filesystem::is_directory(patches_path)) { + for (const auto&p: std::filesystem::recursive_directory_iterator(patches_path)) { + if (StringHelper::IEquals(p.path().extension().string(), ".otr")) { + OTRFiles.push_back(p.path().generic_string()); + } + } + } + } + this->context = LUS::Context::CreateInstance("Lylat64", "sf64", "lylat.cfg.json", OTRFiles, + {0xFF2B5A63, 0xE3DAA4E}, 3); + // this->context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory( + // LUS::ResourceType::SAnim, "Animation", std::make_shared()); +} + +void GameEngine::Create(){ + const auto instance = Instance = new GameEngine(); + GameUI::SetupGuiElements(); +} + +void GameEngine::Destroy(){ + +} + +bool ShouldClearTextureCacheAtEndOfFrame = false; + +void GameEngine::StartFrame() const{ + using LUS::KbScancode; + const int32_t dwScancode = this->context->GetWindow()->GetLastScancode(); + this->context->GetWindow()->SetLastScancode(-1); + + switch (dwScancode) { + case KbScancode::LUS_KB_TAB: { + // Toggle HD Assets + CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0)); + ShouldClearTextureCacheAtEndOfFrame = true; + break; + } + default: break; + } + this->context->GetWindow()->StartFrame(); +} + +void GameEngine::ProcessFrame(void (*run_one_game_iter)()) const { + this->context->GetWindow()->MainLoop(run_one_game_iter); +} + +void GameEngine::RunCommands(Gfx* Commands) { + gfx_run(Commands, {}); + gfx_end_frame(); + + if (ShouldClearTextureCacheAtEndOfFrame) { + gfx_texture_cache_clear(); + ShouldClearTextureCacheAtEndOfFrame = false; + } +} + +void GameEngine::ProcessGfxCommands(Gfx* commands) { + RunCommands(commands); + Instance->context->GetWindow()->SetTargetFps(30); + Instance->context->GetWindow()->SetMaximumFrameLatency(1); +} + +extern "C" uint32_t GameEngine_GetSampleRate() { + auto player = LUS::Context::GetInstance()->GetAudio()->GetAudioPlayer(); + if (player == nullptr) { + return 0; + } + + if (!player->IsInitialized()) { + return 0; + } + + return player->GetSampleRate(); +} + +extern "C" uint32_t GameEngine_GetSamplesPerFrame(){ + return SAMPLES_PER_FRAME; +} + +// End + +extern "C" float GameEngine_GetAspectRatio() { + return gfx_current_dimensions.aspect_ratio; +} + +extern "C" uint32_t GameEngine_GetGameVersion() { + return 0x00000001; +} + +extern "C" int GameEngine_OTRSigCheck(const char* data) { + static const char* sOtrSignature = "__OTR__"; + return strncmp(data, sOtrSignature, strlen(sOtrSignature)) == 0; +} \ No newline at end of file diff --git a/src/port/Engine.h b/src/port/Engine.h new file mode 100644 index 00000000..85c8cd01 --- /dev/null +++ b/src/port/Engine.h @@ -0,0 +1,32 @@ +#pragma once +#include "libultraship/src/Context.h" + +#ifdef __cplusplus +#include +#include + +#define SAMPLES_HIGH 544 +#define SAMPLES_LOW 528 +#define AUDIO_FRAMES_PER_UPDATE 2 +#define NUM_AUDIO_CHANNELS 2 +#define SAMPLES_PER_FRAME (SAMPLES_HIGH * NUM_AUDIO_CHANNELS * 2) + +class GameEngine { + public: + static GameEngine* Instance; + + std::shared_ptr context; + + GameEngine(); + static void Create(); + void StartFrame() const; + static void RunCommands(Gfx* Commands); + void ProcessFrame(void (*run_one_game_iter)()) const; + static void Destroy(); + void ProcessGfxCommands(Gfx* commands); +}; +#else +void GameEngine_ProcessGfxCommands(Gfx* commands); +float GameEngine_GetAspectRatio(); +int GameEngine_OTRSigCheck(char* imgData); +#endif \ No newline at end of file diff --git a/src/port/GBIMiddleware.cpp b/src/port/GBIMiddleware.cpp new file mode 100644 index 00000000..ab8f0e0a --- /dev/null +++ b/src/port/GBIMiddleware.cpp @@ -0,0 +1,45 @@ +#include + +#include "Engine.h" +#include "DisplayList.h" +#include "Array.h" + +extern "C" int GameEngine_OTRSigCheck(const char* data); + +extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) { + char* imgData = (char*)dl; + + if (GameEngine_OTRSigCheck(imgData) == 1) { + auto resource = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + auto res = std::static_pointer_cast(resource); + dl = &res->Instructions[0]; + } + + __gSPDisplayList(pkt, dl); +} + +extern "C" void gSPVertex(Gfx* pkt, uintptr_t v, int n, int v0) { + + if (GameEngine_OTRSigCheck((char*)v) == 1) { + v = (uintptr_t) ResourceGetDataByName((char *) v); + } + + __gSPVertex(pkt, v, n, v0); +} + +extern "C" void gSPInvalidateTexCache(Gfx* pkt, uintptr_t texAddr) { + char* imgData = (char*)texAddr; + + if (texAddr != 0 && GameEngine_OTRSigCheck(imgData)) { + auto res = LUS::Context::GetInstance()->GetResourceManager()->LoadResource(imgData); + + if (res->GetInitData()->Type == LUS::ResourceType::DisplayList) + texAddr = (uintptr_t)&((std::static_pointer_cast(res))->Instructions[0]); + else if (res->GetInitData()->Type == LUS::ResourceType::Array) + texAddr = (uintptr_t)(std::static_pointer_cast(res))->Vertices.data(); + else { + texAddr = (uintptr_t) res->GetRawPointer(); + } + } + __gSPInvalidateTexCache(pkt, texAddr); +} diff --git a/src/port/Game.cpp b/src/port/Game.cpp new file mode 100644 index 00000000..ca47f686 --- /dev/null +++ b/src/port/Game.cpp @@ -0,0 +1,31 @@ +#include + +#include +#include "Engine.h" + +extern "C" +// void exec_display_list(SPTask *spTask) { +// GameEngine::ProcessGfxCommands((Gfx *) spTask->task.t.data_ptr); +// } + +void push_frame() { + // GameEngine::StartAudioFrame(); + GameEngine::Instance->StartFrame(); + // thread5_iteration(); + // GameEngine::EndAudioFrame(); +} + +#ifdef _WIN32 +int SDL_main(int argc, char **argv) { +#else +int main(){ +#endif + GameEngine::Create(); + // alloc_pool(); + // audio_init(); + // sound_init(); + // thread5_game_loop(); + GameEngine::Instance->ProcessFrame(push_frame); + GameEngine::Instance->Destroy(); + return 0; +} \ No newline at end of file diff --git a/src/port/Variables.cpp b/src/port/Variables.cpp new file mode 100644 index 00000000..f7ccf0eb --- /dev/null +++ b/src/port/Variables.cpp @@ -0,0 +1,6 @@ +#include +#include + +extern "C" { + +} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.cpp b/src/port/ui/ImguiUI.cpp new file mode 100644 index 00000000..f4639cf4 --- /dev/null +++ b/src/port/ui/ImguiUI.cpp @@ -0,0 +1,508 @@ +#include "ImguiUI.h" +#include "UIWidgets.h" +#include "ResolutionEditor.h" + +#include +#include +#define IMGUI_DEFINE_MATH_OPERATORS +#include "libultraship/src/Context.h" + +#include +#include +#include +#include "port/Engine.h" + +namespace GameUI { +std::shared_ptr mGameMenuBar; +std::shared_ptr mConsoleWindow; +std::shared_ptr mStatsWindow; +std::shared_ptr mInputEditorWindow; +std::shared_ptr mGfxDebuggerWindow; +std::shared_ptr mAdvancedResolutionSettingsWindow; + +void SetupGuiElements() { + auto gui = LUS::Context::GetInstance()->GetWindow()->GetGui(); + + auto& style = ImGui::GetStyle(); + style.FramePadding = ImVec2(4.0f, 6.0f); + style.ItemSpacing = ImVec2(8.0f, 6.0f); + style.Colors[ImGuiCol_MenuBarBg] = UIWidgets::Colors::DarkGray; + + mGameMenuBar = std::make_shared("gOpenMenuBar", CVarGetInteger("gOpenMenuBar", 0)); + gui->SetMenuBar(mGameMenuBar); + mStatsWindow = gui->GetGuiWindow("Stats"); + if (mStatsWindow == nullptr) { + SPDLOG_ERROR("Could not find stats window"); + } + + mConsoleWindow = gui->GetGuiWindow("Console"); + if (mConsoleWindow == nullptr) { + SPDLOG_ERROR("Could not find console window"); + } + + mInputEditorWindow = gui->GetGuiWindow("Input Editor"); + if (mInputEditorWindow == nullptr) { + SPDLOG_ERROR("Could not find input editor window"); + return; + } + + mGfxDebuggerWindow = gui->GetGuiWindow("GfxDebuggerWindow"); + if (mGfxDebuggerWindow == nullptr) { + SPDLOG_ERROR("Could not find input GfxDebuggerWindow"); + } + + mAdvancedResolutionSettingsWindow = std::make_shared("gAdvancedResolutionEditorEnabled", "Advanced Resolution Settings"); + gui->AddGuiWindow(mAdvancedResolutionSettingsWindow); +} + +void Destroy() { + mAdvancedResolutionSettingsWindow = nullptr; + mConsoleWindow = nullptr; + mStatsWindow = nullptr; + mInputEditorWindow = nullptr; +} + +std::string GetWindowButtonText(const char* text, bool menuOpen) { + char buttonText[100] = ""; + if (menuOpen) { + strcat(buttonText, ICON_FA_CHEVRON_RIGHT " "); + } + strcat(buttonText, text); + if (!menuOpen) { strcat(buttonText, " "); } + return buttonText; +} +} + +static const char* filters[3] = { +#ifdef __WIIU__ + "", +#else + "Three-Point", +#endif + "Linear", "None" +}; + +void DrawSettingsMenu(){ + if(UIWidgets::BeginMenu("Settings")){ + // if (UIWidgets::BeginMenu("Audio")) { + // UIWidgets::CVarSliderFloat("Master Volume", "gGameMasterVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // }); + // if (UIWidgets::CVarSliderFloat("Main Music Volume", "gMainMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_LEVEL, CVarGetFloat("gMainMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Sound Effects Volume", "gSFXMusicVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_SFX, CVarGetFloat("gSFXMusicVolume", 1.0f)); + // } + // if (UIWidgets::CVarSliderFloat("Environment Volume", "gEnvironmentVolume", 0.0f, 1.0f, 1.0f, { + // .format = "%.0f%%", + // .isPercentage = true, + // })) { + // audio_set_player_volume(SEQ_PLAYER_ENV, CVarGetFloat("gEnvironmentVolume", 1.0f)); + // } + // + // static std::unordered_map audioBackendNames = { + // { LUS::AudioBackend::WASAPI, "Windows Audio Session API" }, + // { LUS::AudioBackend::PULSE, "PulseAudio" }, + // { LUS::AudioBackend::SDL, "SDL" }, + // }; + // + // ImGui::Text("Audio API (Needs reload)"); + // auto currentAudioBackend = LUS::Context::GetInstance()->GetAudio()->GetAudioBackend(); + // + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + // } + // if (ImGui::BeginCombo("##AApi", audioBackendNames[currentAudioBackend])) { + // for (uint8_t i = 0; i < LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size(); i++) { + // auto backend = LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->data()[i]; + // if (ImGui::Selectable(audioBackendNames[backend], backend == currentAudioBackend)) { + // LUS::Context::GetInstance()->GetAudio()->SetAudioBackend(backend); + // } + // } + // ImGui::EndCombo(); + // } + // if (LUS::Context::GetInstance()->GetAudio()->GetAvailableAudioBackends()->size() <= 1) { + // UIWidgets::ReEnableComponent(""); + // } + // + // ImGui::EndMenu(); + // } + + UIWidgets::Spacer(0); + + if (UIWidgets::BeginMenu("Controller")) { + UIWidgets::WindowButton("Controller Mapping", "gInputEditorWindow", GameUI::mInputEditorWindow); + + UIWidgets::Spacer(0); + +#ifndef __SWITCH__ + UIWidgets::CVarCheckbox("Menubar Controller Navigation", "gControlNav", { + .tooltip = "Allows controller navigation of the SOH menu bar (Settings, Enhancements,...)\nCAUTION: This will disable game inputs while the menubar is visible.\n\nD-pad to move between items, A to select, and X to grab focus on the menu bar" + }); +#endif + UIWidgets::CVarCheckbox("Show Inputs", "gInputEnabled", { + .tooltip = "Shows currently pressed inputs on the bottom right of the screen" + }); + if (CVarGetInteger("gInputEnabled", 0)) { + UIWidgets::CVarSliderFloat("Input Scale", "gInputScale", 1.0f, 3.0f, 1.0f, { + .tooltip = "Sets the on screen size of the displayed inputs from the Show Inputs setting", + .format = "%.1fx", + }); + } + + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } + + ImGui::SetCursorPosY(0.0f); + if (UIWidgets::BeginMenu("Graphics")) { + UIWidgets::WindowButton("Resolution Editor", "gAdvancedResolutionEditorEnabled", GameUI::mAdvancedResolutionSettingsWindow); + + UIWidgets::Spacer(0); + + // Previously was running every frame, and nothing was setting it? Maybe a bad copy/paste? + // LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + // UIWidgets::Tooltip("Multiplies your output resolution by the value inputted, as a more intensive but effective form of anti-aliasing"); +#ifndef __WIIU__ + if (UIWidgets::CVarSliderInt("MSAA: %d", "gMSAAValue", 1, 8, 1, { + .tooltip = "Activates multi-sample anti-aliasing when above 1x up to 8x for 8 samples for every pixel" + })) { + LUS::Context::GetInstance()->GetWindow()->SetMsaaLevel(CVarGetInteger("gMSAAValue", 1)); + } +#endif + + { // FPS Slider + const int minFps = 30; + static int maxFps; + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + maxFps = 360; + } else { + maxFps = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + } + int currentFps = 0; + #ifdef __WIIU__ + UIWidgets::Spacer(0); + // only support divisors of 60 on the Wii U + if (currentFps > 60) { + currentFps = 60; + } else { + currentFps = 60 / (60 / currentFps); + } + + int fpsSlider = 1; + if (currentFps == 30) { + ImGui::Text("FPS: Original (30)"); + } else { + ImGui::Text("FPS: %d", currentFps); + if (currentFps == 30) { + fpsSlider = 2; + } else { // currentFps == 60 + fpsSlider = 3; + } + } + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (ImGui::Button(" - ##WiiUFPS")) { + fpsSlider--; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + + UIWidgets::Spacer(0); + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - 60.0f), 260.0f)); + ImGui::SliderInt("##WiiUFPSSlider", &fpsSlider, 1, 3, "", ImGuiSliderFlags_AlwaysClamp); + ImGui::PopItemWidth(); + + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(" + ##WiiUFPS")) { + fpsSlider++; + } + + if (CVarGetInteger("gMatchRefreshRate", 0)) { + UIWidgets::ReEnableComponent(""); + } + if (fpsSlider > 3) { + fpsSlider = 3; + } else if (fpsSlider < 1) { + fpsSlider = 1; + } + + if (fpsSlider == 1) { + currentFps = 20; + } else if (fpsSlider == 2) { + currentFps = 30; + } else if (fpsSlider == 3) { + currentFps = 60; + } + CVarSetInteger("gInterpolationFPS", currentFps); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + #else + bool matchingRefreshRate = + CVarGetInteger("gMatchRefreshRate", 0) && LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() != LUS::WindowBackend::DX11; + UIWidgets::CVarSliderInt((currentFps == 20) ? "FPS: Original (20)" : "FPS: %d", "gInterpolationFPS", minFps, maxFps, 1, { + .disabled = matchingRefreshRate + }); + #endif + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc.\n\n" + "A higher target FPS than your monitor's refresh rate will waste resources, and might give a worse result." + ); + } else { + UIWidgets::Tooltip( + "Uses Matrix Interpolation to create extra frames, resulting in smoother graphics. This is purely " + "visual and does not impact game logic, execution of glitches etc." + ); + } + } // END FPS Slider + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::Spacer(0); + if (ImGui::Button("Match Refresh Rate")) { + int hz = LUS::Context::GetInstance()->GetWindow()->GetCurrentRefreshRate(); + if (hz >= 30 && hz <= 360) { + CVarSetInteger("gInterpolationFPS", hz); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } else { + UIWidgets::PaddedEnhancementCheckbox("Match Refresh Rate", "gMatchRefreshRate", true, false); + } + + UIWidgets::Tooltip("Matches interpolation value to the current game's window refresh rate"); + + if (LUS::Context::GetInstance()->GetWindow()->GetWindowBackend() == LUS::WindowBackend::DX11) { + UIWidgets::PaddedEnhancementSliderInt(CVarGetInteger("gExtraLatencyThreshold", 80) == 0 ? "Jitter fix: Off" : "Jitter fix: >= %d FPS", + "##ExtraLatencyThreshold", "gExtraLatencyThreshold", 0, 360, "", 80, true, true, false); + UIWidgets::Tooltip("When Interpolation FPS setting is at least this threshold, add one frame of input lag (e.g. 16.6 ms for 60 FPS) in order to avoid jitter. This setting allows the CPU to work on one frame while GPU works on the previous frame.\nThis setting should be used when your computer is too slow to do CPU + GPU work in time."); + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + + static std::unordered_map windowBackendNames = { + { LUS::WindowBackend::DX11, "DirectX" }, + { LUS::WindowBackend::SDL_OPENGL, "OpenGL"}, + { LUS::WindowBackend::SDL_METAL, "Metal" }, + { LUS::WindowBackend::GX2, "GX2"} + }; + + ImGui::Text("Renderer API (Needs reload)"); + LUS::WindowBackend runningWindowBackend = LUS::Context::GetInstance()->GetWindow()->GetWindowBackend(); + LUS::WindowBackend configWindowBackend; + int configWindowBackendId = LUS::Context::GetInstance()->GetConfig()->GetInt("Window.Backend.Id", -1); + if (configWindowBackendId != -1 && configWindowBackendId < static_cast(LUS::WindowBackend::BACKEND_COUNT)) { + configWindowBackend = static_cast(configWindowBackendId); + } else { + configWindowBackend = runningWindowBackend; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + if (ImGui::BeginCombo("##RApi", windowBackendNames[configWindowBackend])) { + for (size_t i = 0; i < LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size(); i++) { + auto backend = LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->data()[i]; + if (ImGui::Selectable(windowBackendNames[backend], backend == configWindowBackend)) { + LUS::Context::GetInstance()->GetConfig()->SetInt("Window.Backend.Id", static_cast(backend)); + LUS::Context::GetInstance()->GetConfig()->SetString("Window.Backend.Name", + windowBackendNames[backend]); + LUS::Context::GetInstance()->GetConfig()->Save(); + } + } + ImGui::EndCombo(); + } + if (LUS::Context::GetInstance()->GetWindow()->GetAvailableWindowBackends()->size() <= 1) { + UIWidgets::ReEnableComponent(""); + } + + if (LUS::Context::GetInstance()->GetWindow()->CanDisableVerticalSync()) { + UIWidgets::PaddedEnhancementCheckbox("Enable Vsync", "gVsyncEnabled", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->SupportsWindowedFullscreen()) { + UIWidgets::PaddedEnhancementCheckbox("Windowed fullscreen", "gSdlWindowedFullscreen", true, false); + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->SupportsViewports()) { + UIWidgets::PaddedEnhancementCheckbox("Allow multi-windows", "gEnableMultiViewports", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); + UIWidgets::Tooltip("Allows windows to be able to be dragged off of the main game window. Requires a reload to take effect."); + } + + // If more filters are added to LUS, make sure to add them to the filters list here + ImGui::Text("Texture Filter (Needs reload)"); + + UIWidgets::EnhancementCombobox("gTextureFilter", filters, 0); + + UIWidgets::Spacer(0); + + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()->DrawSettings(); + + ImGui::EndMenu(); + } +} + +void DrawMenuBarIcon() { + static bool gameIconLoaded = false; + if (!gameIconLoaded) { + // LUS::Context::GetInstance()->GetWindow()->GetGui()->LoadTexture("Game_Icon", "textures/icons/gIcon.png"); + gameIconLoaded = false; + } + + if (LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon")) { +#ifdef __SWITCH__ + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.0f; +#elif defined(__WIIU__) + ImVec2 iconSize = ImVec2(16.0f * 2, 16.0f * 2); + float posScale = 2.0f; +#else + ImVec2 iconSize = ImVec2(20.0f, 20.0f); + float posScale = 1.5f; +#endif + ImGui::SetCursorPos(ImVec2(5, 2.5f) * posScale); + ImGui::Image(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetTextureByName("Game_Icon"), iconSize); + ImGui::SameLine(); + ImGui::SetCursorPos(ImVec2(25, 0) * posScale); + } +} + +void DrawGameMenu() { + if (UIWidgets::BeginMenu("Ghostship")) { + if (UIWidgets::MenuItem("Reset", +#ifdef __APPLE__ + "Command-R" +#else + "Ctrl+R" +#endif + )) { + std::reinterpret_pointer_cast(LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGuiWindow("Console"))->Dispatch("reset"); + } +#if !defined(__SWITCH__) && !defined(__WIIU__) + + if (UIWidgets::MenuItem("Toggle Fullscreen", "F9")) { + LUS::Context::GetInstance()->GetWindow()->ToggleFullscreen(); + } + + if (UIWidgets::MenuItem("Quit")) { + LUS::Context::GetInstance()->GetWindow()->Close(); + } +#endif + ImGui::EndMenu(); + } +} + +void DrawEnhancementsMenu() { + if (UIWidgets::BeginMenu("Enhancements")) { + + if (UIWidgets::BeginMenu("Gameplay")) { + UIWidgets::CVarCheckbox("No Level of Detail (LOD)", "gDisableLOD", { + .tooltip = "Disable Level of Detail (LOD) to avoid models using lower poly versions at a distance" + }); + UIWidgets::CVarCheckbox("Select any star from menu", "gSelectAllStars", { + .tooltip = "Let's you select any star from the menu regardless of the courses completion status." + }); + UIWidgets::CVarCheckbox("Collecting Stars Will Not Exit Level", "gStarNoExit", { + .tooltip = "Stars act like the 100 coin star and will not take you out of the level" + }); + UIWidgets::CVarCheckbox("Avoid playing peach cutscene", "gDisablePeachCutscene", { + .tooltip = "Avoid playing the peach cutscene when starting a new game" + }); + ImGui::EndMenu(); + } + + ImGui::EndMenu(); + } +} + +void DrawCheatsMenu() { + if (UIWidgets::BeginMenu("Cheats")) { + UIWidgets::CVarCheckbox("Infinite Health", "gInfiniteHealth"); + UIWidgets::CVarCheckbox("Infinite Lives", "gInfiniteLives"); + + ImGui::EndMenu(); + } +} + +const char* debugInfoPages[6] = { + "Object", + "Check Surface", + "Map", + "Stage", + "Effect", + "Enemy", +}; + +void DrawDebugMenu() { + if (UIWidgets::BeginMenu("Developer")) { + UIWidgets::WindowButton("Gfx Debugger", "gGfxDebuggerEnabled", GameUI::mGfxDebuggerWindow, { + .tooltip = "Enables the Gfx Debugger window, allowing you to input commands, type help for some examples" + }); + + UIWidgets::CVarCheckbox("Debug mode", "gEnableDebugMode", { + .tooltip = "Various debug features, including a level selector from the main menu" + }); + + UIWidgets::CVarCheckbox("Better Level Select", "gDeveloper.BetterLevelSelect", { + .tooltip = "Tweaks to the level select screen, like naming and allowing C-buttons to be used" + }); + + UIWidgets::CVarCheckbox("Draw DebugInfo", "gDeveloper.DrawDebugInfo"); + if (CVarGetInteger("gDeveloper.DrawDebugInfo", 0)) { + UIWidgets::CVarCombobox("DebugInfo mode", "gDeveloper.DebugInfoPage", debugInfoPages, { + .defaultIndex = 0, + }); + } + UIWidgets::Spacer(0); + + UIWidgets::WindowButton("Stats", "gStatsEnabled", GameUI::mStatsWindow, { + .tooltip = "Shows the stats window, with your FPS and frametimes, and the OS you're playing on" + }); + UIWidgets::WindowButton("Console", "gConsoleEnabled", GameUI::mConsoleWindow, { + .tooltip = "Enables the console window, allowing you to input commands, type help for some examples" + }); + + ImGui::EndMenu(); + } +} + +void GameMenuBar::DrawElement() { + if(ImGui::BeginMenuBar()){ + DrawMenuBarIcon(); + + DrawGameMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawSettingsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawEnhancementsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawCheatsMenu(); + + ImGui::SetCursorPosY(0.0f); + + DrawDebugMenu(); + + ImGui::EndMenuBar(); + } +} \ No newline at end of file diff --git a/src/port/ui/ImguiUI.h b/src/port/ui/ImguiUI.h new file mode 100644 index 00000000..2d233f4c --- /dev/null +++ b/src/port/ui/ImguiUI.h @@ -0,0 +1,16 @@ +#pragma once +#include + +namespace GameUI { + void SetupGuiElements(); + void Destroy(); +} + +class GameMenuBar : public LUS::GuiMenuBar { + public: + using LUS::GuiMenuBar::GuiMenuBar; + protected: + void DrawElement() override; + void InitElement() override {}; + void UpdateElement() override {}; +}; \ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.cpp b/src/port/ui/ResolutionEditor.cpp new file mode 100644 index 00000000..01995a3c --- /dev/null +++ b/src/port/ui/ResolutionEditor.cpp @@ -0,0 +1,422 @@ +#include "ResolutionEditor.h" +#include "UIWidgets.h" +#include "libultraship/src/Context.h" + +#include +#include +#include + +/* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled") + + The following CVars are used in Libultraship and can be edited here: + - Enabled - Turns Advanced Resolution Mode on. + - AspectRatioX, AspectRatioY - Aspect ratio controls. To toggle off, set either to zero. + - VerticalPixelCount, VerticalResolutionToggle - Resolution controls. + - PixelPerfectMode, IntegerScale.Factor - Pixel Perfect Mode a.k.a. integer scaling controls. + (Waiting on a second PR merge on LUS for this to fully function.): + - IntegerScale.FitAutomatically - Automatic resizing for Pixel Perfect Mode. + - IntegerScale.NeverExceedBounds - Prevents manual resizing from exceeding screen bounds. + + The following CVars are also implemented in LUS for niche use cases: + - IgnoreAspectCorrection - Stretch framebuffer to fill screen. + This is something of a power-user setting for niche setups that most people won't need or care about, + but may be useful if playing the Switch/Wii U ports on a 4:3 television. + - IntegerScale.ExceedBoundsBy - Offset the max screen bounds, usually by +1. + This isn't that useful at the moment. +*/ + +namespace AdvancedResolutionSettings { + enum setting { UPDATE_aspectRatioX, UPDATE_aspectRatioY, UPDATE_verticalPixelCount }; + + const char* aspectRatioPresetLabels[] = { + "Off", "Custom", "Original (4:3)", "Widescreen (16:9)", "Nintendo 3DS (5:3)", "16:10 (8:5)", "Ultrawide (21:9)" + }; + const float aspectRatioPresetsX[] = { 0.0f, 12.0f, 4.0f, 16.0f, 5.0f, 16.0f, 21.0f }; + const float aspectRatioPresetsY[] = { 0.0f, 9.0f, 3.0f, 9.0f, 3.0f, 10.0f, 9.0f }; + const int default_aspectRatio = 1; // Default combo list option + + const char* pixelCountPresetLabels[] = { "Custom", "Native N64 (240p)", "2x (480p)", "3x (720p)", "4x (960p)", + "5x (1200p)", "6x (1440p)", "Full HD (1080p)", "4K (2160p)" }; + const int pixelCountPresets[] = { 480, 240, 480, 720, 960, 1200, 1440, 1080, 2160, 480 }; + const int default_pixelCount = 0; // Default combo list option + + const uint32_t minVerticalPixelCount = 240; // see: LUS::AdvancedResolution() + const uint32_t maxVerticalPixelCount = 4320; + + const unsigned short default_maxIntegerScaleFactor = 6; // Default size of Integer scale factor slider. + + const float enhancementSpacerHeight = 19.0f; +// This will need to be determined more intelligently when Hi-DPI UI support is added. + + void AdvancedResolutionSettingsWindow::InitElement() { + } + + void AdvancedResolutionSettingsWindow::DrawElement() { + ImGui::SetNextWindowSize(ImVec2(497, 532), ImGuiCond_FirstUseEver); + if (ImGui::Begin("Advanced Resolution Settings", &mIsVisible)) { + // Initialise update flags. + bool update[sizeof(setting)]; + for (unsigned short i = 0; i < sizeof(setting); i++) + update[i] = false; + static short updateCountdown = 0; + short countdownStartingValue = CVarGetInteger("gInterpolationFPS", 20) / 2; // half of a second, in frames. + + // Initialise integer scale bounds. + short max_integerScaleFactor = default_maxIntegerScaleFactor; // default value, which may or may not get + // overridden depending on viewport res + + short integerScale_maximumBounds = 1; // can change when window is resized + // This is mostly just for UX purposes, as Fit Automatically logic is part of LUS. + if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) > + ((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) { + // Scale to window height + integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height; + } else { + // Scale to window width + integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width; + } + // Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS. + // Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded. + if (default_maxIntegerScaleFactor < integerScale_maximumBounds) { + max_integerScaleFactor = + integerScale_maximumBounds + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + } + + // Stored Values for non-UIWidgets elements + static float aspectRatioX = CVarGetFloat("gAdvancedResolution.AspectRatioX", 16.0f); + static float aspectRatioY = CVarGetFloat("gAdvancedResolution.AspectRatioY", 9.0f); + static int verticalPixelCount = CVarGetInteger("gAdvancedResolution.VerticalPixelCount", 480); + // Combo List defaults + static int item_aspectRatio = default_aspectRatio; + static int item_pixelCount = default_pixelCount; + // Additional settings + static bool showHorizontalResField = false; + static int horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + +#ifdef __APPLE__ + ImGui::Text("Note: these settings may behave incorrectly on Apple Retina Displays."); + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); +#endif + + // The original resolution slider (for convenience) + if (UIWidgets::EnhancementSliderFloat("Internal Resolution: %d %%", "##IMul", "gInternalResolution", 0.5f, 2.0f, + "", 1.0f, true, true, + (CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0) && + CVarGetInteger("gAdvancedResolution.Enabled", 0)) || + CVarGetInteger("gLowResMode", 0))) { + LUS::Context::GetInstance()->GetWindow()->SetResolutionMultiplier(CVarGetFloat("gInternalResolution", 1)); + } + UIWidgets::Tooltip("Multiplies your output resolution by the value entered, as a more intensive but effective " + "form of anti-aliasing"); // Description pulled from SohMenuBar.cpp + + // N64 Mode toggle (again for convenience) + // UIWidgets::PaddedEnhancementCheckbox("(Enhancements>Graphics) N64 Mode", "gLowResMode", false, false, false, + // "", UIWidgets::CheckboxGraphics::Cross, false); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + // Activator + UIWidgets::PaddedEnhancementCheckbox("Enable advanced settings.", "gAdvancedResolution.Enabled", false, false, + false, "", UIWidgets::CheckboxGraphics::Cross, false); + // Error/Warning display + if (!CVarGetInteger("gLowResMode", 0)) { + if (IsDroppingFrames()) { // Significant frame drop warning + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, + ICON_FA_EXCLAMATION_TRIANGLE " Significant frame rate (FPS) drops may be occuring."); + UIWidgets::Spacer(2); + } else { // No warnings + UIWidgets::Spacer(enhancementSpacerHeight); + } + } else { // N64 Mode warning + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"N64 Mode\" is overriding these settings."); + ImGui::SameLine(); + if (ImGui::Button("Click to disable")) { + CVarSetInteger("gLowResMode", (int)false); + CVarSave(); + } + } + // Resolution visualiser + ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width, + gfx_current_game_window_viewport.height); + ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height); + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Aspect Ratio + ImGui::Text("Force aspect ratio:"); + ImGui::SameLine(); + ImGui::TextColored({ 0.75f, 0.75f, 0.75f, 1.0f }, "(Select \"Off\" to disable.)"); + if (ImGui::Combo(" ", &item_aspectRatio, aspectRatioPresetLabels, + IM_ARRAYSIZE(aspectRatioPresetLabels)) && + item_aspectRatio != default_aspectRatio) { // don't change anything if "Custom" is selected. + aspectRatioX = aspectRatioPresetsX[item_aspectRatio]; + aspectRatioY = aspectRatioPresetsY[item_aspectRatio]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + if (item_aspectRatio == default_aspectRatio && !showHorizontalResField) { + // Declaring the Y input interaction in particular as a variable beforehand + // will prevent a bug where the Y field would disappear when modifying X. + bool inputX = ImGui::InputFloat("X", &aspectRatioX, 0.1f, 1.0f, "%.3f"); + bool inputY = ImGui::InputFloat("Y", &aspectRatioY, 0.1f, 1.0f, "%.3f"); + if (inputX || inputY) { + item_aspectRatio = default_aspectRatio; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + } + } else if (showHorizontalResField) { // Show calculated aspect ratio + if (item_aspectRatio) { + UIWidgets::Spacer(2); + float resolvedAspectRatio = (float)gfx_current_dimensions.height / gfx_current_dimensions.width; + ImGui::Text("Aspect ratio: %.4f", resolvedAspectRatio); + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + } + + UIWidgets::Spacer(0); + // Vertical Resolution + UIWidgets::PaddedEnhancementCheckbox("Set fixed vertical resolution (disables Resolution slider)", + "gAdvancedResolution.VerticalResolutionToggle", true, false, false, "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip( + "Override the resolution scale slider and use the settings below, irrespective of window size."); + if (ImGui::Combo("Pixel Count Presets", &item_pixelCount, pixelCountPresetLabels, + IM_ARRAYSIZE(pixelCountPresetLabels)) && + item_pixelCount != default_pixelCount) { // don't change anything if "Custom" is selected. + verticalPixelCount = pixelCountPresets[item_pixelCount]; + update[UPDATE_verticalPixelCount] = true; + + if (showHorizontalResField) { + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + // Horizontal Resolution, if visibility is enabled for it. + if (showHorizontalResField) { + // Only show the field if Aspect Ratio is being enforced. + if ((aspectRatioX > 0.0f) && (aspectRatioY > 0.0f)) { + // So basically we're "faking" this one by setting aspectRatioX instead. + if (ImGui::InputInt("Horiz. Pixel Count", &horizontalPixelCount, 8, 320)) { + item_aspectRatio = default_aspectRatio; + if (horizontalPixelCount < (minVerticalPixelCount / 3.0f) * 4.0f) { + horizontalPixelCount = (minVerticalPixelCount / 3.0f) * 4.0f; + } + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } else { // Display a notice instead. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + ICON_FA_QUESTION_CIRCLE " \"Force aspect ratio\" required."); + // ImGui::Text(" "); + ImGui::SameLine(); + if (ImGui::Button("Click to resolve")) { + item_aspectRatio = default_aspectRatio; // Set it to Custom + aspectRatioX = aspectRatioPresetsX[2]; // but use the 4:3 defaults + aspectRatioY = aspectRatioPresetsY[2]; + update[UPDATE_aspectRatioX] = true; + update[UPDATE_aspectRatioY] = true; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } + } + } + // Vertical Resolution part 2 + if (ImGui::InputInt("Vertical Pixel Count", &verticalPixelCount, 8, 240)) { + item_pixelCount = default_pixelCount; + update[UPDATE_verticalPixelCount] = true; + + // Account for the natural instinct to enter horizontal first. + // Ignore vertical resolutions that are below the lower clamp constant. + if (showHorizontalResField && !(verticalPixelCount < minVerticalPixelCount)) { + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + update[UPDATE_aspectRatioX] = true; + } + } + + UIWidgets::Spacer(0); + // UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Integer scaling settings group + if (ImGui::CollapsingHeader("Integer Scaling Settings")) { + // Pixel-perfect Mode + UIWidgets::PaddedEnhancementCheckbox("Pixel-perfect Mode", "gAdvancedResolution.PixelPerfectMode", true, + true, + !CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Don't scale image to fill window."); + if (!CVarGetInteger("gAdvancedResolution.VerticalResolutionToggle", 0)) { + CVarSetInteger("gAdvancedResolution.PixelPerfectMode", (int)false); + CVarSave(); + } + + // Integer Scaling + UIWidgets::EnhancementSliderInt("Integer scale factor: %d", "##ARSIntScale", + "gAdvancedResolution.IntegerScale.Factor", 1, max_integerScaleFactor, "%d", + 1, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)); + UIWidgets::Tooltip("Integer scales the image. Only available in pixel-perfect mode."); + // Display warning if size is being clamped or if framebuffer is larger than viewport. + if (CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) && + (CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) && + CVarGetInteger("gAdvancedResolution.IntegerScale.Factor", 1) > integerScale_maximumBounds)) { + ImGui::SameLine(); + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, ICON_FA_EXCLAMATION_TRIANGLE " Window exceeded."); + } + + UIWidgets::PaddedEnhancementCheckbox("Automatically scale image to fit viewport", + "gAdvancedResolution.IntegerScale.FitAutomatically", true, true, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + UIWidgets::Tooltip("Automatically sets scale factor to fit window. Only available in pixel-perfect mode."); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0)) { + // This is just here to update the value shown on the slider. + // The function in LUS to handle this setting will ignore IntegerScaleFactor while active. + CVarSetInteger("gAdvancedResolution.IntegerScale.Factor", integerScale_maximumBounds); + // CVarSave(); + } + } + + UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f); + + // Collapsible panel for additional settings + if (ImGui::CollapsingHeader("Additional Settings")) { + UIWidgets::Spacer(0); +#if defined(__SWITCH__) || defined(__WIIU__) + // Disable aspect correction, stretching the framebuffer to fill the viewport. + // This option is only really needed on systems limited to 16:9 TV resolutions, such as consoles. + // The associated CVar is still functional on PC platforms if you want to use it though. + UIWidgets::PaddedEnhancementCheckbox("Disable aspect correction and stretch the output image.\n" + "(Might be useful for 4:3 televisions!)\n" + "Not available in Pixel Perfect Mode.", + "gAdvancedResolution.IgnoreAspectCorrection", false, true, + CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); +#else + if (CVarGetInteger("gAdvancedResolution.IgnoreAspectCorrection", 0)) { + // This setting is intentionally not exposed on PC platforms, + // but may be accidentally activated for varying reasons. + // Having this button should hopefully prevent support headaches. + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, ICON_FA_QUESTION_CIRCLE + " If the image is stretched and you don't know why, click this."); + if (ImGui::Button("Click to reenable aspect correction.")) { + CVarSetInteger("gAdvancedResolution.IgnoreAspectCorrection", (int)false); + CVarSave(); + } + UIWidgets::Spacer(2); + } +#endif + + if (ImGui::Checkbox("Show a horizontal resolution field.", &showHorizontalResField)) { + if (!showHorizontalResField && (aspectRatioX > 0.0f)) { // when turning this setting off + // Refresh relevant values + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + } else { // when turning this setting on + item_aspectRatio = default_aspectRatio; + if (aspectRatioX > 0.0f) { + // Refresh relevant values in the opposite order + horizontalPixelCount = (verticalPixelCount / aspectRatioY) * aspectRatioX; + aspectRatioX = aspectRatioY * horizontalPixelCount / verticalPixelCount; + } + } + update[UPDATE_aspectRatioX] = true; + } + + UIWidgets::PaddedEnhancementCheckbox( + "Don't allow integer scaling to exceed screen bounds.\n" + "(Makes screen bounds take priority over specified factor.)", + "gAdvancedResolution.IntegerScale.NeverExceedBounds", true, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0) || + CVarGetInteger("gAdvancedResolution.IntegerScale.FitAutomatically", 0), + "", UIWidgets::CheckboxGraphics::Cross, true); + + if (!CVarGetInteger("gAdvancedResolution.IntegerScale.NeverExceedBounds", 1) || + CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + // Another helpful button for an unused CVar. + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + if (ImGui::Button("Click to reset an unused CVar that may be causing this.")) { + CVarSetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0); + CVarSave(); + } + } + } else { + UIWidgets::Spacer(enhancementSpacerHeight); + } + + // I've ended up dummying this one out because it doesn't function in a satisfactory way. + // Consider this idea on the table, but I don't deem it an important enough feature to push for. + /* + UIWidgets::PaddedEnhancementCheckbox("Allow integer scale factor to go 1x above maximum screen bounds.", + "gAdvancedResolution.IntegerScale.ExceedBoundsBy", false, false, + !CVarGetInteger("gAdvancedResolution.PixelPerfectMode", 0), "", + UIWidgets::CheckboxGraphics::Cross, false); + if (CVarGetInteger("gAdvancedResolution.IntegerScale.ExceedBoundsBy", 0)) { + ImGui::TextColored({ 0.0f, 0.85f, 0.85f, 1.0f }, + " " ICON_FA_QUESTION_CIRCLE + " A scroll bar may become visible if screen bounds are exceeded."); + }*/ + + } // end of Additional Settings + + // Clamp and update the CVars that don't use UIWidgets + if (IsBoolArrayTrue(update)) { + if (update[UPDATE_aspectRatioX]) { + if (aspectRatioX < 0.0f) { + aspectRatioX = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioX", aspectRatioX); + } + if (update[UPDATE_aspectRatioY]) { + if (aspectRatioY < 0.0f) { + aspectRatioY = 0.0f; + } + CVarSetFloat("gAdvancedResolution.AspectRatioY", aspectRatioY); + } + if (update[UPDATE_verticalPixelCount]) { + // There's a upper and lower clamp on the Libultraship side too, + // so clamping it here is purely visual, so the vertical resolution field reflects it. + if (verticalPixelCount < minVerticalPixelCount) { + verticalPixelCount = minVerticalPixelCount; + } + if (verticalPixelCount > maxVerticalPixelCount) { + verticalPixelCount = maxVerticalPixelCount; + } + CVarSetInteger("gAdvancedResolution.VerticalPixelCount", verticalPixelCount); + } + // Delay saving this set of CVars by a predetermined length of time, in frames. + updateCountdown = countdownStartingValue; + } + if (updateCountdown > 0) { + updateCountdown--; + } else { + CVarSave(); + } + } + ImGui::End(); + } + + void AdvancedResolutionSettingsWindow::UpdateElement() { + } + + bool AdvancedResolutionSettingsWindow::IsDroppingFrames() { + // a rather imprecise way of checking for frame drops. + // but it's mostly there to inform the player of large drops. + const short targetFPS = CVarGetInteger("gInterpolationFPS", 20); + const float threshold = targetFPS / 20.0f + 4.1f; + return ImGui::GetIO().Framerate < targetFPS - threshold; + } + + bool AdvancedResolutionSettingsWindow::IsBoolArrayTrue(bool* foo) { + for (unsigned short i = 0; i < sizeof(&foo); i++) + if (&foo[i]) + return true; + return false; + } +} // namespace AdvancedResolutionSettings \ No newline at end of file diff --git a/src/port/ui/ResolutionEditor.h b/src/port/ui/ResolutionEditor.h new file mode 100644 index 00000000..38af5607 --- /dev/null +++ b/src/port/ui/ResolutionEditor.h @@ -0,0 +1,19 @@ +#pragma once +#include + +namespace AdvancedResolutionSettings { + class AdvancedResolutionSettingsWindow : public LUS::GuiWindow { + private: + bool IsDroppingFrames(); + + protected: + bool IsBoolArrayTrue(bool*); + + public: + using LUS::GuiWindow::GuiWindow; + + void InitElement() override; + void DrawElement() override; + void UpdateElement() override; + }; +} // namespace AdvancedResolutionSettings \ No newline at end of file diff --git a/src/port/ui/UIWidgets.cpp b/src/port/ui/UIWidgets.cpp new file mode 100644 index 00000000..3375e79a --- /dev/null +++ b/src/port/ui/UIWidgets.cpp @@ -0,0 +1,1033 @@ +// +// UIWidgets.cpp +// soh +// +// Created by David Chavez on 25.08.22. +// + +#include "UIWidgets.h" + +#define IMGUI_DEFINE_MATH_OPERATORS +#include "libultraship/src/Context.h" + +#include +#include +#include + +namespace UIWidgets { + + // MARK: - Layout Helper + + // Automatically adds newlines to break up text longer than a specified number of characters + // Manually included newlines will still be respected and reset the line length + // If line is midword when it hits the limit, text should break at the last encountered space + char* WrappedText(const char* text, unsigned int charactersPerLine) { + std::string newText(text); + const size_t tipLength = newText.length(); + int lastSpace = -1; + int currentLineLength = 0; + for (unsigned int currentCharacter = 0; currentCharacter < tipLength; currentCharacter++) { + if (newText[currentCharacter] == '\n') { + currentLineLength = 0; + lastSpace = -1; + continue; + } else if (newText[currentCharacter] == ' ') { + lastSpace = currentCharacter; + } + + if ((currentLineLength >= charactersPerLine) && (lastSpace >= 0)) { + newText[lastSpace] = '\n'; + currentLineLength = currentCharacter - lastSpace - 1; + lastSpace = -1; + } + currentLineLength++; + } + + return strdup(newText.c_str()); + } + + char* WrappedText(const std::string& text, unsigned int charactersPerLine) { + return WrappedText(text.c_str(), charactersPerLine); + } + + void SetLastItemHoverText(const std::string& text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void SetLastItemHoverText(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + // Adds a "?" next to the previous ImGui item with a custom tooltip + void InsertHelpHoverText(const std::string& text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + void InsertHelpHoverText(const char* text) { + ImGui::SameLine(); + ImGui::TextColored(ImVec4(0.7f, 0.7f, 0.7f, 1.0f), "?"); + if (ImGui::IsItemHovered()) { + ImGui::BeginTooltip(); + ImGui::Text("%s", WrappedText(text, 60)); + ImGui::EndTooltip(); + } + } + + + // MARK: - UI Elements + + void Tooltip(const char* text) { + if (ImGui::IsItemHovered()) { + ImGui::SetTooltip("%s", WrappedText(text)); + } + } + + void Spacer(float height) { + ImGui::Dummy(ImVec2(0.0f, height)); + } + + void PaddedSeparator(bool padTop, bool padBottom, float extraVerticalTopPadding, float extraVerticalBottomPadding) { + if (padTop) { + Spacer(extraVerticalTopPadding); + } + ImGui::Separator(); + if (padBottom) { + Spacer(extraVerticalBottomPadding); + } + } + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz) { + float thickness = ImMax(sz / 5.0f, 1.0f); + sz -= thickness * 0.5f; + pos += ImVec2(thickness * 0.25f, thickness * 0.25f); + + draw_list->PathLineTo(ImVec2(pos.x, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + + draw_list->PathLineTo(ImVec2(pos.x + sz, pos.y)); + draw_list->PathLineTo(ImVec2(pos.x, pos.y + sz)); + draw_list->PathStroke(col, 0, thickness); + } + + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic) { + ImGuiWindow* window = ImGui::GetCurrentWindow(); + if (window->SkipItems) { + return false; + } + + ImGuiContext& g = *GImGui; + const ImGuiStyle& style = g.Style; + const ImGuiID id = window->GetID(label); + const ImVec2 label_size = ImGui::CalcTextSize(label, NULL, true); + + const float square_sz = ImGui::GetFrameHeight(); + const ImVec2 pos = window->DC.CursorPos; + const ImRect total_bb(pos, pos + ImVec2(square_sz + (label_size.x > 0.0f ? style.ItemInnerSpacing.x + label_size.x : 0.0f), label_size.y + style.FramePadding.y * 2.0f)); + ImGui::ItemSize(total_bb, style.FramePadding.y); + if (!ImGui::ItemAdd(total_bb, id)) { + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return false; + } + + bool hovered, held; + bool pressed = ImGui::ButtonBehavior(total_bb, id, &hovered, &held); + if (pressed) { + *v = !(*v); + ImGui::MarkItemEdited(id); + } + + const ImRect check_bb(pos, pos + ImVec2(square_sz, square_sz)); + ImGui::RenderNavHighlight(total_bb, id); + ImGui::RenderFrame(check_bb.Min, check_bb.Max, ImGui::GetColorU32((held && hovered) ? ImGuiCol_FrameBgActive : hovered ? ImGuiCol_FrameBgHovered : ImGuiCol_FrameBg), true, style.FrameRounding); + ImU32 check_col = ImGui::GetColorU32(ImGuiCol_CheckMark); + ImU32 cross_col = ImGui::GetColorU32(ImVec4(0.50f, 0.50f, 0.50f, 1.00f)); + bool mixed_value = (g.LastItemData.InFlags & ImGuiItemFlags_MixedValue) != 0; + if (mixed_value) { + // Undocumented tristate/mixed/indeterminate checkbox (#2644) + // This may seem awkwardly designed because the aim is to make ImGuiItemFlags_MixedValue supported by all widgets (not just checkbox) + ImVec2 pad(ImMax(1.0f, IM_FLOOR(square_sz / 3.6f)), ImMax(1.0f, IM_FLOOR(square_sz / 3.6f))); + window->DrawList->AddRectFilled(check_bb.Min + pad, check_bb.Max - pad, check_col, style.FrameRounding); + } else if ((!disabled && *v) || (disabled && disabledGraphic == CheckboxGraphics::Checkmark)) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + ImGui::RenderCheckMark(window->DrawList, check_bb.Min + ImVec2(pad, pad), check_col, square_sz - pad * 2.0f); + } else if (disabled && disabledGraphic == CheckboxGraphics::Cross) { + const float pad = ImMax(1.0f, IM_FLOOR(square_sz / 6.0f)); + RenderCross(window->DrawList, check_bb.Min + ImVec2(pad, pad), cross_col, square_sz - pad * 2.0f); + } + + ImVec2 label_pos = ImVec2(check_bb.Max.x + style.ItemInnerSpacing.x, check_bb.Min.y + style.FramePadding.y); + if (g.LogEnabled) { + ImGui::LogRenderedText(&label_pos, mixed_value ? "[~]" : *v ? "[x]" : "[ ]"); + } + if (label_size.x > 0.0f) { + ImGui::RenderText(label_pos, label); + } + + IMGUI_TEST_ENGINE_ITEM_INFO(id, label, g.LastItemData.StatusFlags | ImGuiItemStatusFlags_Checkable | (*v ? ImGuiItemStatusFlags_Checked : 0)); + return pressed; + } + + void ReEnableComponent(const char* disabledTooltipText) { + // End of disable region of previous component + ImGui::PopStyleVar(1); + if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(disabledTooltipText, "") != 0) { + ImGui::SetTooltip("%s", disabledTooltipText); + } + ImGui::PopItemFlag(); + } + + void DisableComponent(const float alpha) { + ImGui::PushItemFlag(ImGuiItemFlags_Disabled, true); + ImGui::PushStyleVar(ImGuiStyleVar_Alpha, alpha); + } + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + bool changed = false; + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + bool val = (bool)CVarGetInteger(cvarName, defaultValue); + if (CustomCheckbox(text, &val, disabled, disabledGraphic)) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + return changed; + } + + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText, CheckboxGraphics disabledGraphic, bool defaultValue) { + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + bool changed = EnhancementCheckbox(text, cvarName, disabled, disabledTooltipText, disabledGraphic, defaultValue); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementCombobox(const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + bool changed = false; + if (defaultIndex <= 0) { + defaultIndex = 0; + } + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + uint8_t selected = CVarGetInteger(cvarName, defaultIndex); + std::string comboName = std::string("##") + std::string(cvarName); + if (ImGui::BeginCombo(comboName.c_str(), comboArray[selected])) { + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == selected)) { + CVarSetInteger(cvarName, i); + selected = i; + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + } + ImGui::EndCombo(); + } + + if (disabled) { + ReEnableComponent(disabledTooltipText); + + if (disabledValue >= 0 && selected != disabledValue) { + CVarSetInteger(cvarName, disabledValue); + changed = true; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + } + + return changed; + } + + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled, const char* disabledTooltipText, uint8_t disabledValue) { + ImGui::Text(label); + s32 currentValue = CVarGetInteger(cvarName, defaultIndex); + +#ifdef __WIIU__ + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 40.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 60.0f); +#else + ImGui::SameLine(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize(comboArray[currentValue]).x + 20.0f)); + ImGui::PushItemWidth(ImGui::CalcTextSize(comboArray[currentValue]).x + 30.0f); +#endif + + bool changed = EnhancementCombobox(cvarName, comboArray, defaultIndex, disabled, disabledTooltipText, disabledValue); + + ImGui::PopItemWidth(); + return changed; + } + + void PaddedText(const char* text, bool padTop, bool padBottom) { + if (padTop) Spacer(0); + + ImGui::Text("%s", text); + + if (padBottom) Spacer(0); + } + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + int val = CVarGetInteger(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + ImGui::Text(text, val); + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + val--; + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderInt(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) + { + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + val++; + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetInteger(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool disabled, const char* disabledTooltipText) { + bool changed = false; + float val = CVarGetFloat(cvarName, defaultValue); + + if (disabled) { + DisableComponent(ImGui::GetStyle().Alpha * 0.5f); + } + + if (!isPercentage) { + ImGui::Text(text, val); + } else { + ImGui::Text(text, static_cast(100 * val)); + } + Spacer(0); + + ImGui::BeginGroup(); + if (PlusMinusButton) { + std::string MinusBTNName = " - ##" + std::string(cvarName); + if (ImGui::Button(MinusBTNName.c_str())) { + if (isPercentage) { + val -= 0.01f; + } else { + val -= 0.1f; + } + changed = true; + } + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + } + + ImGui::PushItemWidth(std::min((ImGui::GetContentRegionAvail().x - (PlusMinusButton ? sliderButtonWidth : 0.0f)), maxSliderWidth)); + if (ImGui::SliderFloat(id, &val, min, max, format, ImGuiSliderFlags_AlwaysClamp)) { + if (isPercentage) { + val = roundf(val * 100) / 100; + } + changed = true; + } + ImGui::PopItemWidth(); + + if (PlusMinusButton) { + std::string PlusBTNName = " + ##" + std::string(cvarName); + ImGui::SameLine(); + ImGui::SetCursorPosX(ImGui::GetCursorPosX() - 7.0f); + if (ImGui::Button(PlusBTNName.c_str())) { + if (isPercentage) { + val += 0.01f; + } else { + val += 0.1f; + } + changed = true; + } + } + ImGui::EndGroup(); + + if (disabled) { + ReEnableComponent(disabledTooltipText); + } + + if (val < min) { + val = min; + changed = true; + } + + if (val > max) { + val = max; + changed = true; + } + + if (changed) { + CVarSetFloat(cvarName, val); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + + return changed; + } + + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderInt(text, id, cvarName, min, max, format, defaultValue, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton, bool padTop, bool padBottom, bool disabled, const char* disabledTooltipText) { + bool changed = false; + ImGui::BeginGroup(); + if (padTop) Spacer(0); + + changed = EnhancementSliderFloat(text, id, cvarName, min, max, format, defaultValue, isPercentage, PlusMinusButton, disabled, disabledTooltipText); + + if (padBottom) Spacer(0); + ImGui::EndGroup(); + return changed; + } + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id) { + /*Usage : + EnhancementRadioButton("My Visible Name","gMyCVarName", MyID); + First arg is the visible name of the Radio button + Second is the cvar name where MyID will be saved. + Note: the CVar name should be the same to each Buddies. + Example : + EnhancementRadioButton("English", "gLanguages", LANGUAGE_ENG); + EnhancementRadioButton("German", "gLanguages", LANGUAGE_GER); + EnhancementRadioButton("French", "gLanguages", LANGUAGE_FRA); + */ + std::string make_invisible = "##" + std::string(text) + std::string(cvarName); + + bool ret = false; + int val = CVarGetInteger(cvarName, 0); + if (ImGui::RadioButton(make_invisible.c_str(), id == val)) { + CVarSetInteger(cvarName, id); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + ret = true; + } + ImGui::SameLine(); + ImGui::Text("%s", text); + + return ret; + } + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha) { + bool changed = false; + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Reset##" + std::string(cvarName) + "Reset"; + if (ImGui::Button(MakeInvisible.c_str())) { + colors->x = defaultcolors.x; + colors->y = defaultcolors.y; + colors->z = defaultcolors.z; + colors->w = has_alpha ? defaultcolors.w : 255.0f; + + Color_RGBA8 colorsRGBA; + colorsRGBA.r = defaultcolors.x; + colorsRGBA.g = defaultcolors.y; + colorsRGBA.b = defaultcolors.z; + colorsRGBA.a = has_alpha ? defaultcolors.w : 255.0f; + + CVarSetColor(cvarName, colorsRGBA); + CVarSetInteger(Cvar_RBM.c_str(), 0); //On click disable rainbow mode. + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + changed = true; + } + Tooltip("Revert colors to the game's original colors (GameCube version)\nOverwrites previously chosen color"); + return changed; + } + + void DrawLockColorCheckbox(const char* cvarName) { + std::string Cvar_Lock = std::string(cvarName) + "Lock"; + s32 lock = CVarGetInteger(Cvar_Lock.c_str(), 0); + std::string FullName = "Lock##" + Cvar_Lock; + EnhancementCheckbox(FullName.c_str(), Cvar_Lock.c_str()); + Tooltip("Prevents this color from being changed upon selecting \"Randomize all\""); + } + + void RainbowColor(const char* cvarName, ImVec4* colors) { + std::string Cvar_RBM = std::string(cvarName) + "RBM"; + std::string MakeInvisible = "Rainbow##" + std::string(cvarName) + "Rainbow"; + + EnhancementCheckbox(MakeInvisible.c_str(), Cvar_RBM.c_str()); + Tooltip("Cycles through colors on a timer\nOverwrites previously chosen color"); + } + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha) { + Color_RGBA8 defaultColors; + defaultColors.r = default_colors.x; + defaultColors.g = default_colors.y; + defaultColors.b = default_colors.z; + defaultColors.a = default_colors.w; + + Color_RGBA8 cvarColor = CVarGetColor(cvarname, defaultColors); + + ColorArray.x = cvarColor.r / 255.0; + ColorArray.y = cvarColor.g / 255.0; + ColorArray.z = cvarColor.b / 255.0; + ColorArray.w = cvarColor.a / 255.0; + } + + void DrawFlagArray32(const std::string& name, uint32_t& flags) { + ImGui::PushID(name.c_str()); + for (int32_t flagIndex = 0; flagIndex < 32; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint32_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray16(const std::string& name, uint16_t& flags) { + ImGui::PushID(name.c_str()); + for (int16_t flagIndex = 0; flagIndex < 16; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint16_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + void DrawFlagArray8(const std::string& name, uint8_t& flags) { + ImGui::PushID(name.c_str()); + for (int8_t flagIndex = 0; flagIndex < 8; flagIndex++) { + if ((flagIndex % 8) != 0) { + ImGui::SameLine(); + } + ImGui::PushID(flagIndex); + uint8_t bitMask = 1 << flagIndex; + bool flag = (flags & bitMask) != 0; + if (ImGui::Checkbox("##check", &flag)) { + if (flag) { + flags |= bitMask; + } else { + flags &= ~bitMask; + } + } + ImGui::PopID(); + } + ImGui::PopID(); + } + + // V2 + + void PushStyleMenu(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_PopupBg, UIWidgets::Colors::DarkGray); + ImGui::PushStyleColor(ImGuiCol_Border, UIWidgets::Colors::DarkGray); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8.0f, 15.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 3.0f); + } + + void PopStyleMenu() { + ImGui::PopStyleVar(2); + ImGui::PopStyleColor(4); + } + + bool BeginMenu(const char* label, const ImVec4& color) { + bool dirty = false; + PushStyleMenu(color); + if (ImGui::BeginMenu(label)) { + dirty = true; + } + PopStyleMenu(); + return dirty; + } + + void PushStyleMenuItem(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(20.0f, 15.0f)); + } + + void PopStyleMenuItem() { + ImGui::PopStyleVar(1); + ImGui::PopStyleColor(1); + } + + bool MenuItem(const char* label, const char* shortcut, const ImVec4& color) { + bool dirty = false; + PushStyleMenuItem(color); + if (ImGui::MenuItem(label, shortcut)) { + dirty = true; + } + PopStyleMenuItem(); + return dirty; + } + + void PushStyleButton(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleButton() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(4); + } + + bool Button(const char* label, const ButtonOptions& options) { + ImGui::BeginDisabled(options.disabled); + PushStyleButton(options.color); + bool dirty = ImGui::Button(label, options.size); + PopStyleButton(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + return dirty; + } + + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options) { + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0, 0)); + std::string buttonText = label; + bool dirty = false; + if (CVarGetInteger(cvarName, 0)) { + buttonText = ICON_FA_WINDOW_CLOSE " " + buttonText; + } else { + buttonText = ICON_FA_EXTERNAL_LINK_SQUARE " " + buttonText; + } + if (Button(buttonText.c_str(), options)) { + windowPtr->ToggleVisibility(); + dirty = true; + } + ImGui::PopStyleVar(); + return dirty; + } + + void PushStyleCheckbox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.0f, 0.0f, 0.0f, 0.3f)); + ImGui::PushStyleColor(ImGuiCol_CheckMark, ImVec4(1.0f, 1.0f, 1.0f, 0.7f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 5.0f); + } + + void PopStyleCheckbox() { + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(5); + } + + bool Checkbox(const char* label, bool* value, const CheckboxOptions& options) { + ImGui::PushID(label); + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::BeginDisabled(options.disabled); + PushStyleCheckbox(options.color); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } else if (options.labelPosition == LabelPosition::Above) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + } + } + dirty = ImGui::Checkbox(invisibleLabel, value); + if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().FramePadding.x * 2 - ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(); + ImGui::SetCursorPosX(startX); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } + PopStyleCheckbox(); + ImGui::EndDisabled(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options) { + bool dirty = false; + bool value = (bool)CVarGetInteger(cvarName, options.defaultValue); + if (Checkbox(label, &value, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleCombobox(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(color.x, color.y, color.z, 0.8f)); + ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(color.x, color.y, color.z, 0.5f)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(color.x, color.y, color.z, 0.6f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_PopupBorderSize, 0.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 6.0f)); + } + + void PopStyleCombobox() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(9); + } + + bool Combobox(const char* label, uint8_t* value, std::span comboArray, const ComboboxOptions& options) { + bool dirty = false; + float startX = ImGui::GetCursorPosX(); + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleCombobox(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x - ImGui::GetStyle().ItemSpacing.x * 2); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + ImGui::SetNextItemWidth(ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4 + ImGui::GetStyle().ItemSpacing.x); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(ImGui::CalcTextSize(label).x + ImGui::GetStyle().ItemSpacing.x * 2); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } else if (options.labelPosition == LabelPosition::Far || options.labelPosition == LabelPosition::None) { + float width = ImGui::CalcTextSize(comboArray[*value]).x + ImGui::GetStyle().FramePadding.x * 4; + ImGui::SameLine(ImGui::GetContentRegionAvail().x - width); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + } + if (ImGui::BeginCombo(invisibleLabel, comboArray[*value], options.flags)) { + ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10.0f, 10.0f)); + for (uint8_t i = 0; i < comboArray.size(); i++) { + if (strlen(comboArray[i]) > 1) { + if (ImGui::Selectable(comboArray[i], i == *value)) { + *value = i; + dirty = true; + } + } + } + ImGui::PopStyleVar(); + ImGui::EndCombo(); + } + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Near) { + ImGui::SameLine(); + ImGui::Text(label); + } else if (options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Near || options.labelPosition == LabelPosition::Far) { + ImGui::SameLine(startX); + ImGui::Text(label); + } + } + PopStyleCombobox(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarCombobox(const char* label, const char* cvarName, std::span comboArray, const ComboboxOptions& options) { + bool dirty = false; + uint8_t value = (uint8_t)CVarGetInteger(cvarName, options.defaultIndex); + if (Combobox(label, &value, comboArray, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + void PushStyleSlider(const ImVec4& color) { + ImGui::PushStyleColor(ImGuiCol_FrameBg, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgHovered, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_FrameBgActive, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(color.x, color.y, color.z, 1.0f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrab, ImVec4(1.0, 1.0, 1.0, 0.4f)); + ImGui::PushStyleColor(ImGuiCol_SliderGrabActive, ImVec4(1.0, 1.0, 1.0, 0.5f)); + ImGui::PushStyleVar(ImGuiStyleVar_GrabRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 3.0f); + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10.0f, 8.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f); + } + + void PopStyleSlider() { + ImGui::PopStyleVar(4); + ImGui::PopStyleColor(6); + } + + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, *value); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, *value); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_S32, value, &min, &max, options.format, options.flags)) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options) { + bool dirty = false; + int32_t value = CVarGetInteger(cvarName, defaultValue); + if (SliderInt(label, &value, min, max, options)) { + CVarSetInteger(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } + + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options) { + bool dirty = false; + std::string invisibleLabelStr = "##" + std::string(label); + const char* invisibleLabel = invisibleLabelStr.c_str(); + float valueToDisplay = options.isPercentage ? *value * 100.0f : *value; + float maxToDisplay = options.isPercentage ? max * 100.0f : max; + float minToDisplay = options.isPercentage ? min * 100.0f : min; + ImGui::PushID(label); + ImGui::BeginGroup(); + ImGui::BeginDisabled(options.disabled); + PushStyleSlider(options.color); + if (options.alignment == ComponentAlignment::Left) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::Text(label, valueToDisplay); + } + } else if (options.alignment == ComponentAlignment::Right) { + if (options.labelPosition == LabelPosition::Above) { + ImGui::NewLine(); + ImGui::SameLine(ImGui::GetContentRegionAvail().x - ImGui::CalcTextSize(label).x); + ImGui::Text(label, valueToDisplay); + } + } + if (options.showButtons) { + if (Button("-", { .color = options.color, .size = Sizes::Inline }) && *value > min) { + *value -= options.step; + if (*value < min) *value = min; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x - (ImGui::CalcTextSize("+").x + 20.0f + 3.0f)); + } else { + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + } + if (ImGui::SliderScalar(invisibleLabel, ImGuiDataType_Float, &valueToDisplay, &minToDisplay, &maxToDisplay, options.format, options.flags)) { + *value = options.isPercentage ? valueToDisplay / 100.0f : valueToDisplay; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + if (options.showButtons) { + ImGui::SameLine(0, 3.0f); + ImGui::SetNextItemWidth(ImGui::GetContentRegionAvail().x); + if (Button("+", { .color = options.color, .size = Sizes::Inline }) && *value < max) { + *value += options.step; + if (*value > max) *value = max; + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + } + PopStyleSlider(); + ImGui::EndDisabled(); + ImGui::EndGroup(); + if (options.disabled && ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.disabledTooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.disabledTooltip)); + } else if (ImGui::IsItemHovered(ImGuiHoveredFlags_AllowWhenDisabled) && strcmp(options.tooltip, "") != 0) { + ImGui::SetTooltip("%s", WrappedText(options.tooltip)); + } + ImGui::PopID(); + return dirty; + } + + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options) { + bool dirty = false; + float value = CVarGetFloat(cvarName, defaultValue); + if (SliderFloat(label, &value, min, max, options)) { + CVarSetFloat(cvarName, value); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + dirty = true; + } + return dirty; + } +} diff --git a/src/port/ui/UIWidgets.h b/src/port/ui/UIWidgets.h new file mode 100644 index 00000000..2d398f61 --- /dev/null +++ b/src/port/ui/UIWidgets.h @@ -0,0 +1,209 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +namespace UIWidgets { + + struct TextFilters { + static int FilterNumbers(ImGuiInputTextCallbackData* data) { + if (data->EventChar < 256 && strchr("1234567890", (char)data->EventChar)) { + return 0; + } + return 1; + } + + static int FilterAlphaNum(ImGuiInputTextCallbackData* data) { + const char* alphanum = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWYZ0123456789"; + if (data->EventChar < 256 && strchr(alphanum, (char)data->EventChar)) { + return 0; + } + return 1; + } + + }; + + // MARK: - Enums + + enum class CheckboxGraphics { + Cross, + Checkmark, + None + }; + constexpr float maxSliderWidth = 260.0f; +#ifdef __SWITCH__ + constexpr float sliderButtonWidth = 42.0f; +#elif defined(__WIIU__) + constexpr float sliderButtonWidth = 60.0f; +#else + constexpr float sliderButtonWidth = 30.0f; +#endif + + char* WrappedText(const char* text, unsigned int charactersPerLine = 60); + char* WrappedText(const std::string& text, unsigned int charactersPerLine); + + void SetLastItemHoverText(const std::string& text); + void SetLastItemHoverText(const char* text); + + void InsertHelpHoverText(const std::string& text); + void InsertHelpHoverText(const char* text); + + void Tooltip(const char* text); + void Spacer(float height); + void PaddedSeparator(bool padTop = true, bool padBottom = true, float extraVerticalTopPadding = 0.0f, float extraVerticalBottomPadding = 0.0f); + + void RenderCross(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz); + bool CustomCheckbox(const char* label, bool* v, bool disabled, CheckboxGraphics disabledGraphic); + + void ReEnableComponent(const char* disabledTooltipText); + void DisableComponent(const float alpha); + + bool EnhancementCheckbox(const char* text, const char* cvarName, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + bool PaddedEnhancementCheckbox(const char* text, const char* cvarName, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = "", CheckboxGraphics disabledGraphic = CheckboxGraphics::Cross, bool defaultValue = false); + + bool EnhancementCombobox(const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + bool LabeledRightAlignedEnhancementCombobox(const char* label, const char* cvarName, std::span comboArray, uint8_t defaultIndex, bool disabled = false, const char* disabledTooltipText = "", uint8_t disabledValue = -1); + + void PaddedText(const char* text, bool padTop = true, bool padBottom = true); + + bool EnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderInt(const char* text, const char* id, const char* cvarName, int min, int max, const char* format, int defaultValue = 0, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + bool EnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool disabled = false, const char* disabledTooltipText = ""); + bool PaddedEnhancementSliderFloat(const char* text, const char* id, const char* cvarName, float min, float max, const char* format, float defaultValue, bool isPercentage, bool PlusMinusButton = true, bool padTop = true, bool padBottom = true, bool disabled = false, const char* disabledTooltipText = ""); + + bool EnhancementRadioButton(const char* text, const char* cvarName, int id); + + bool DrawResetColorButton(const char* cvarName, ImVec4* colors, ImVec4 defaultcolors, bool has_alpha); + bool DrawRandomizeColorButton(const char* cvarName, ImVec4* colors); + void DrawLockColorCheckbox(const char* cvarName); + void RainbowColor(const char* cvarName, ImVec4* colors); + + void LoadPickersColors(ImVec4& ColorArray, const char* cvarname, const ImVec4& default_colors, bool has_alpha); + bool EnhancementColor(const char* text, const char* cvarName, ImVec4 ColorRGBA, ImVec4 default_colors, bool allow_rainbow = true, bool has_alpha = false, bool TitleSameLine = false); + + void DrawFlagArray32(const std::string& name, uint32_t& flags); + void DrawFlagArray16(const std::string& name, uint16_t& flags); + void DrawFlagArray8(const std::string& name, uint8_t& flags); + + // V2 + namespace Colors { + const ImVec4 White = ImVec4(1.0f, 1.0f, 1.0f, 1.0f); + const ImVec4 Gray = ImVec4(0.4f, 0.4f, 0.4f, 1.0f); + const ImVec4 DarkGray = ImVec4(0.1f, 0.1f, 0.1f, 1.0f); + const ImVec4 Indigo = ImVec4(0.24f, 0.31f, 0.71f, 1.0f); + const ImVec4 Red = ImVec4(0.5f, 0.0f, 0.0f, 1.0f); + const ImVec4 DarkRed = ImVec4(0.3f, 0.0f, 0.0f, 1.0f); + const ImVec4 LightGreen = ImVec4(0.0f, 0.7f, 0.0f, 1.0f); + const ImVec4 Green = ImVec4(0.0f, 0.5f, 0.0f, 1.0f); + const ImVec4 DarkGreen = ImVec4(0.0f, 0.3f, 0.0f, 1.0f); + const ImVec4 Yellow = ImVec4(1.0f, 0.627f, 0.0f, 1.0f); + }; + + namespace Sizes { + const ImVec2 Inline = ImVec2(0.0f, 0.0f); + const ImVec2 Fill = ImVec2(-1.0f, 0.0f); + } + + enum LabelPosition { + Near, + Far, + Above, + None, + Within, + }; + + enum ComponentAlignment { + Left, + Right, + }; + + void PushStyleMenu(const ImVec4& color = Colors::Indigo); + void PopStyleMenu(); + bool BeginMenu(const char* label, const ImVec4& color = Colors::Indigo); + + void PushStyleMenuItem(const ImVec4& color = Colors::Indigo); + void PopStyleMenuItem(); + bool MenuItem(const char* label, const char* shortcut = NULL, const ImVec4& color = Colors::Indigo); + + struct ButtonOptions { + const ImVec4 color = Colors::Gray; + const ImVec2 size = Sizes::Fill; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + }; + + void PushStyleButton(const ImVec4& color = Colors::Gray); + void PopStyleButton(); + bool Button(const char* label, const ButtonOptions& options = {}); + bool WindowButton(const char* label, const char* cvarName, std::shared_ptr windowPtr, const ButtonOptions& options = {}); + + struct CheckboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool defaultValue = false; // Only applicable to CVarCheckbox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Near; + }; + + void PushStyleCheckbox(const ImVec4& color = Colors::Indigo); + void PopStyleCheckbox(); + bool Checkbox(const char* label, bool* v, const CheckboxOptions& options = {}); + bool CVarCheckbox(const char* label, const char* cvarName, const CheckboxOptions& options = {}); + + struct ComboboxOptions { + const ImVec4 color = Colors::Indigo; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + uint32_t defaultIndex = 0; // Only applicable to CVarCombobox + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + ImGuiComboFlags flags = 0; + }; + + void PushStyleCombobox(const ImVec4& color = Colors::Indigo); + void PopStyleCombobox(); + bool Combobox(const char* label, uint8_t* value, std::span comboArray, const ComboboxOptions& options = {}); + bool CVarCombobox(const char* label, const char* cvarName, std::span comboArray, const ComboboxOptions& options = {}); + + struct IntSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%d"; + const uint32_t step = 1; + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + struct FloatSliderOptions { + const ImVec4 color = Colors::Gray; + const char* tooltip = ""; + bool disabled = false; + const char* disabledTooltip = ""; + bool showButtons = true; + ImGuiSliderFlags flags = 0; + const char* format = "%f"; + const float step = 0.01f; + bool isPercentage = false; // Multiplies visual value by 100 + ComponentAlignment alignment = ComponentAlignment::Left; + LabelPosition labelPosition = LabelPosition::Above; + }; + + void PushStyleSlider(const ImVec4& color = Colors::Indigo); + void PopStyleSlider(); + bool SliderInt(const char* label, int32_t* value, int32_t min, int32_t max, const IntSliderOptions& options = {}); + bool CVarSliderInt(const char* label, const char* cvarName, int32_t min, int32_t max, const int32_t defaultValue, const IntSliderOptions& options = {}); + bool SliderFloat(const char* label, float* value, float min, float max, const FloatSliderOptions& options = {}); + bool CVarSliderFloat(const char* label, const char* cvarName, float min, float max, const float defaultValue, const FloatSliderOptions& options = {}); +} \ No newline at end of file diff --git a/src/sys/sys_fault.c b/src/sys/sys_fault.c index 14a322e2..f73e1396 100644 --- a/src/sys/sys_fault.c +++ b/src/sys/sys_fault.c @@ -242,7 +242,7 @@ void Fault_ThreadEntry(void* arg0) { func_8000762C(300, 10, "-"); gControllerPlugged[0] = 1; while (var_s5 == 0) { - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_READ_CONTROLLER, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL); osRecvMesg(&gControllerMsgQueue, NULL, OS_MESG_BLOCK); Controller_UpdateInput(); switch (var_s0) { diff --git a/src/sys/sys_joybus.c b/src/sys/sys_joybus.c index fb6ad5ac..890961ce 100644 --- a/src/sys/sys_joybus.c +++ b/src/sys/sys_joybus.c @@ -63,7 +63,7 @@ void Controller_UpdateInput(void) { s32 i; for (i = 0; i < 4; i++) { - if (gControllerPlugged[i] == 1 && sNextController[i].errno == 0) { + if (gControllerPlugged[i] == 1 && sNextController[i].err_no == 0) { sPrevController[i] = gControllerHold[i]; gControllerHold[i] = sNextController[i]; gControllerPress[i].button = @@ -71,8 +71,8 @@ void Controller_UpdateInput(void) { Controller_AddDeadZone(i); } else { gControllerHold[i].button = gControllerHold[i].stick_x = gControllerHold[i].stick_y = - gControllerHold[i].errno = gControllerPress[i].button = gControllerPress[i].stick_x = - gControllerPress[i].stick_y = gControllerPress[i].errno = 0; + gControllerHold[i].err_no = gControllerPress[i].button = gControllerPress[i].stick_x = + gControllerPress[i].stick_y = gControllerPress[i].err_no = 0; } } } @@ -84,41 +84,41 @@ void Controller_ReadData(void) { gControllerLock--; for (i = 0; i < 4; i++) { sNextController[i].button = sNextController[i].stick_x = sNextController[i].stick_y = - sNextController[i].errno = 0; + sNextController[i].err_no = 0; } } else { osContStartReadData(&gSerialEventQueue); osRecvMesg(&gSerialEventQueue, NULL, OS_MESG_BLOCK); osContGetReadData(sNextController); } - osSendMesg(&gControllerMsgQueue, (OSMesg) SI_CONT_READ_DONE, OS_MESG_PRI_NORMAL); + osSendMesg(&gControllerMsgQueue, OS_MESG_32(SI_CONT_READ_DONE), OS_MESG_PRI_NORMAL); } void Save_ReadData(void) { if ((gStartNMI == 0) && (Save_ReadEeprom(&gSaveIOBuffer) == 0)) { - osSendMesg(&gSaveMsgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_PRI_NORMAL); + osSendMesg(&gSaveMsgQueue, OS_MESG_32(SI_SAVE_SUCCESS), OS_MESG_PRI_NORMAL); return; } - osSendMesg(&gSaveMsgQueue, (OSMesg) SI_SAVE_FAILED, OS_MESG_PRI_NORMAL); + osSendMesg(&gSaveMsgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL); } void Save_WriteData(void) { if ((gStartNMI == 0) && (Save_WriteEeprom(&gSaveIOBuffer) == 0)) { - osSendMesg(&gSaveMsgQueue, (OSMesg) SI_SAVE_SUCCESS, OS_MESG_PRI_NORMAL); + osSendMesg(&gSaveMsgQueue, OS_MESG_32(SI_SAVE_SUCCESS), OS_MESG_PRI_NORMAL); return; } - osSendMesg(&gSaveMsgQueue, (OSMesg) SI_SAVE_FAILED, OS_MESG_PRI_NORMAL); + osSendMesg(&gSaveMsgQueue, OS_MESG_32(SI_SAVE_FAILED), OS_MESG_PRI_NORMAL); } void Controller_Rumble(void) { s32 i; - osContStartQuery(&gSerialEventQueue); + // osContStartQuery(&gSerialEventQueue); osRecvMesg(&gSerialEventQueue, NULL, OS_MESG_BLOCK); - osContGetQuery(sControllerStatus); + // osContGetQuery(sControllerStatus); for (i = 0; i < 4; i++) { - if ((gControllerPlugged[i] != 0) && (sControllerStatus[i].errno == 0)) { + if ((gControllerPlugged[i] != 0) && (sControllerStatus[i].err_no == 0)) { if (sControllerStatus[i].status & 1) { if (gControllerRumble[i] == 0) { if (osMotorInit(&gSerialEventQueue, &sControllerMotor[i], i)) { diff --git a/src/sys/sys_lib.c b/src/sys/sys_lib.c index ffb3cb91..1f528aa0 100644 --- a/src/sys/sys_lib.c +++ b/src/sys/sys_lib.c @@ -120,24 +120,25 @@ void Lib_DmaRead(void* src, void* dst, ptrdiff_t size) { void Lib_FillScreen(u8 setFill) { s32 i; + // TODO: Implement fill screen gFillScreenColor |= 1; if (setFill == true) { if (gFillScreen == false) { if (gFillScreenColor == 1) { - osViBlack(1); + // osViBlack(1); } else { for (i = 0; i < 3 * SCREEN_WIDTH; i++) { gFillBuffer[i] = gFillScreenColor; } - osWritebackDCacheAll(); - osViSwapBuffer(&gFillBuffer[SCREEN_WIDTH]); - osViRepeatLine(1); + // osWritebackDCacheAll(); + // osViSwapBuffer(&gFillBuffer[SCREEN_WIDTH]); + // osViRepeatLine(1); } gFillScreen = true; } } else if (gFillScreen == true) { - osViRepeatLine(0); - osViBlack(0); + // osViRepeatLine(0); + // osViBlack(0); gFillScreen = false; } } diff --git a/src/sys/sys_main.c b/src/sys/sys_main.c index da8e19bd..4b0d0147 100644 --- a/src/sys/sys_main.c +++ b/src/sys/sys_main.c @@ -108,46 +108,46 @@ void Audio_ThreadEntry(void* arg0) { task = AudioThread_CreateTask(); if (task != NULL) { task->msgQueue = &gAudioTaskMsgQueue; - task->msg = (OSMesg) TASK_MESG_1; + task->msg = OS_MESG_32(TASK_MESG_1); osWritebackDCacheAll(); - osSendMesg(&gTaskMsgQueue, task, OS_MESG_PRI_NORMAL); + osSendMesg(&gTaskMsgQueue, OS_MESG_PTR(task), OS_MESG_PRI_NORMAL); } while (1) { task = AudioThread_CreateTask(); if (task != NULL) { task->msgQueue = &gAudioTaskMsgQueue; - task->msg = (OSMesg) TASK_MESG_1; + task->msg = OS_MESG_32(TASK_MESG_1); osWritebackDCacheAll(); } osRecvMesg(&gAudioTaskMsgQueue, NULL, OS_MESG_NOBLOCK); if (task != NULL) { - osSendMesg(&gTaskMsgQueue, task, OS_MESG_PRI_NORMAL); + osSendMesg(&gTaskMsgQueue, OS_MESG_PTR(task), OS_MESG_PRI_NORMAL); } osRecvMesg(&gAudioVImsgQueue, NULL, OS_MESG_BLOCK); } } void Graphics_SetTask(void) { - gGfxTask->msgQueue = &gGfxTaskMsgQueue; - gGfxTask->msg = (OSMesg) TASK_MESG_2; - gGfxTask->task.t.type = M_GFXTASK; - gGfxTask->task.t.flags = 0; - gGfxTask->task.t.ucode_boot = rspbootTextStart; - gGfxTask->task.t.ucode_boot_size = (uintptr_t) rspbootTextEnd - (uintptr_t) rspbootTextStart; - gGfxTask->task.t.ucode = gspF3DEX_fifoTextStart; - gGfxTask->task.t.ucode_size = SP_UCODE_SIZE; - gGfxTask->task.t.ucode_data = (u64*) &gspF3DEX_fifoDataStart; - gGfxTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE; - gGfxTask->task.t.dram_stack = gDramStack; - gGfxTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8; - gGfxTask->task.t.output_buff = (u64*) gTaskOutputBuffer; - gGfxTask->task.t.output_buff_size = (u64*) gAudioHeap; - gGfxTask->task.t.data_ptr = (u64*) gGfxPool->masterDL; - gGfxTask->task.t.data_size = (gMasterDisp - gGfxPool->masterDL) * sizeof(Gfx); - gGfxTask->task.t.yield_data_ptr = (u64*) &gOSYieldData; - gGfxTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE; - osWritebackDCacheAll(); - osSendMesg(&gTaskMsgQueue, gGfxTask, OS_MESG_PRI_NORMAL); + // gGfxTask->msgQueue = &gGfxTaskMsgQueue; + // gGfxTask->msg = (OSMesg) TASK_MESG_2; + // gGfxTask->task.t.type = M_GFXTASK; + // gGfxTask->task.t.flags = 0; + // gGfxTask->task.t.ucode_boot = rspbootTextStart; + // gGfxTask->task.t.ucode_boot_size = (uintptr_t) rspbootTextEnd - (uintptr_t) rspbootTextStart; + // gGfxTask->task.t.ucode = gspF3DEX_fifoTextStart; + // gGfxTask->task.t.ucode_size = SP_UCODE_SIZE; + // gGfxTask->task.t.ucode_data = (u64*) &gspF3DEX_fifoDataStart; + // gGfxTask->task.t.ucode_data_size = SP_UCODE_DATA_SIZE; + // gGfxTask->task.t.dram_stack = gDramStack; + // gGfxTask->task.t.dram_stack_size = SP_DRAM_STACK_SIZE8; + // gGfxTask->task.t.output_buff = (u64*) gTaskOutputBuffer; + // gGfxTask->task.t.output_buff_size = (u64*) gAudioHeap; + // gGfxTask->task.t.data_ptr = (u64*) gGfxPool->masterDL; + // gGfxTask->task.t.data_size = (gMasterDisp - gGfxPool->masterDL) * sizeof(Gfx); + // gGfxTask->task.t.yield_data_ptr = (u64*) &gOSYieldData; + // gGfxTask->task.t.yield_data_size = OS_YIELD_DATA_SIZE; + // osWritebackDCacheAll(); + // osSendMesg(&gTaskMsgQueue, gGfxTask, OS_MESG_PRI_NORMAL); } void Graphics_InitializeTask(u32 frameCount) { @@ -176,23 +176,23 @@ void Main_SetVIMode(void) { (gControllerHold[3].button & R_TRIG) && (gControllerHold[3].button & Z_TRIG)) { sGammaMode = 1 - sGammaMode; } - switch (osTvType) { - case OS_TV_PAL: - osViSetMode(&osViModePalLan1); - break; - case OS_TV_MPAL: - osViSetMode(&osViModeMpalLan1); - break; - default: - case OS_TV_NTSC: - osViSetMode(&osViModeNtscLan1); - break; - } - if (sGammaMode != 0) { - osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_DIVOT_OFF | OS_VI_GAMMA_ON | OS_VI_GAMMA_DITHER_ON); - } else { - osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_DIVOT_OFF | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF); - } + // switch (osTvType) { + // case OS_TV_PAL: + // osViSetMode(&osViModePalLan1); + // break; + // case OS_TV_MPAL: + // osViSetMode(&osViModeMpalLan1); + // break; + // default: + // case OS_TV_NTSC: + // osViSetMode(&osViModeNtscLan1); + // break; + // } + // if (sGammaMode != 0) { + // osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_DIVOT_OFF | OS_VI_GAMMA_ON | OS_VI_GAMMA_DITHER_ON); + // } else { + // osViSetSpecialFeatures(OS_VI_DITHER_FILTER_ON | OS_VI_DIVOT_OFF | OS_VI_GAMMA_OFF | OS_VI_GAMMA_DITHER_OFF); + // } } void SerialInterface_ThreadEntry(void* arg0) { @@ -202,7 +202,7 @@ void SerialInterface_ThreadEntry(void* arg0) { while (1) { osRecvMesg(&gSerialThreadMsgQueue, &sp34, OS_MESG_BLOCK); - switch ((s32) sp34) { + switch (sp34.data32) { case SI_READ_CONTROLLER: Controller_ReadData(); break; @@ -220,11 +220,11 @@ void SerialInterface_ThreadEntry(void* arg0) { } void Timer_ThreadEntry(void* arg0) { - void* sp24; + OSMesg sp24; while (1) { osRecvMesg(&gTimerTaskMsgQueue, &sp24, OS_MESG_BLOCK); - Timer_CompleteTask(sp24); + Timer_CompleteTask(sp24.ptr); } } @@ -234,7 +234,7 @@ void Graphics_ThreadEntry(void* arg0) { u8 var_v2; Game_Initialize(); - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_READ_CONTROLLER, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL); Graphics_InitializeTask(gSysFrameCount); { gSPSegment(gUnkDisp1++, 0, 0); @@ -251,9 +251,9 @@ void Graphics_ThreadEntry(void* arg0) { gSysFrameCount++; Graphics_InitializeTask(gSysFrameCount); osRecvMesg(&gControllerMsgQueue, NULL, OS_MESG_BLOCK); - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_RUMBLE, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_RUMBLE), OS_MESG_PRI_NORMAL); Controller_UpdateInput(); - osSendMesg(&gSerialThreadMsgQueue, (OSMesg) SI_READ_CONTROLLER, OS_MESG_PRI_NORMAL); + osSendMesg(&gSerialThreadMsgQueue, OS_MESG_32(SI_READ_CONTROLLER), OS_MESG_PRI_NORMAL); if (gControllerPress[3].button & U_JPAD) { Main_SetVIMode(); } @@ -275,7 +275,7 @@ void Graphics_ThreadEntry(void* arg0) { if (gFillScreen == 0) { osViSwapBuffer(&gFrameBuffers[(gSysFrameCount - 1) % 3]); } - func_80007FE4(&gFrameBuffers[(gSysFrameCount - 1) % 3], SCREEN_WIDTH, 16); + // func_80007FE4(&gFrameBuffers[(gSysFrameCount - 1) % 3], SCREEN_WIDTH, 16); var_v1 = MIN(D_80137E78, 4); var_v2 = MAX(var_v1, gGfxVImsgQueue.validCount + 1); @@ -295,12 +295,12 @@ void Main_InitMesgQueues(void) { osCreateMesgQueue(&gGfxVImsgQueue, sGfxVImsgBuff, ARRAY_COUNT(sGfxVImsgBuff)); osCreateMesgQueue(&gGfxTaskMsgQueue, sGfxTaskMsgBuff, ARRAY_COUNT(sGfxTaskMsgBuff)); osCreateMesgQueue(&gSerialEventQueue, sSerialEventBuff, ARRAY_COUNT(sSerialEventBuff)); - osSetEventMesg(OS_EVENT_SI, &gSerialEventQueue, NULL); + osSetEventMesg(OS_EVENT_SI, &gSerialEventQueue, OS_MESG_PTR(NULL)); osCreateMesgQueue(&gMainThreadMsgQueue, sMainThreadMsgBuff, ARRAY_COUNT(sMainThreadMsgBuff)); - osViSetEvent(&gMainThreadMsgQueue, (OSMesg) EVENT_MESG_VI, 1); - osSetEventMesg(OS_EVENT_SP, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_SP); - osSetEventMesg(OS_EVENT_DP, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_DP); - osSetEventMesg(OS_EVENT_PRENMI, &gMainThreadMsgQueue, (OSMesg) EVENT_MESG_PRENMI); + osViSetEvent(&gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_VI), 1); + osSetEventMesg(OS_EVENT_SP, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_SP)); + osSetEventMesg(OS_EVENT_DP, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_DP)); + osSetEventMesg(OS_EVENT_PRENMI, &gMainThreadMsgQueue, OS_MESG_32(EVENT_MESG_PRENMI)); osCreateMesgQueue(&gTimerTaskMsgQueue, sTimerTaskMsgBuff, ARRAY_COUNT(sTimerTaskMsgBuff)); osCreateMesgQueue(&gTimerWaitMsgQueue, sTimerWaitMsgBuff, ARRAY_COUNT(sTimerWaitMsgBuff)); osCreateMesgQueue(&gSerialThreadMsgQueue, sSerialThreadMsgBuff, ARRAY_COUNT(sSerialThreadMsgBuff)); @@ -323,22 +323,22 @@ void Main_HandleRDP(void) { } void Main_HandleRSP(void) { - SPTask* task = gCurrentTask; - - gCurrentTask = NULL; - if (task->state == SPTASK_STATE_INTERRUPTED) { - if (osSpTaskYielded(&task->task) == 0) { - task->state = SPTASK_STATE_FINISHED; - } - } else { - task->state = SPTASK_STATE_FINISHED; - if (task->task.t.type == M_AUDTASK) { - if (task->msgQueue != NULL) { - osSendMesg(task->msgQueue, task->msg, OS_MESG_PRI_NORMAL); - } - sAudioTasks[0] = NULL; - } - } + // SPTask* task = gCurrentTask; + // + // gCurrentTask = NULL; + // if (task->state == SPTASK_STATE_INTERRUPTED) { + // if (osSpTaskYielded(&task->task) == 0) { + // task->state = SPTASK_STATE_FINISHED; + // } + // } else { + // task->state = SPTASK_STATE_FINISHED; + // if (task->task.t.type == M_AUDTASK) { + // if (task->msgQueue != NULL) { + // osSendMesg(task->msgQueue, task->msg, OS_MESG_PRI_NORMAL); + // } + // sAudioTasks[0] = NULL; + // } + // } } void Main_GetNewTasks(void) { @@ -362,7 +362,7 @@ void Main_GetNewTasks(void) { var_s0_2 = sNewAudioTasks; var_s1_2 = sNewGfxTasks; while (osRecvMesg(&gTaskMsgQueue, &sp40, OS_MESG_NOBLOCK) != MSG_QUEUE_EMPTY) { - sp3C = (SPTask*) sp40; + sp3C = (SPTask*) sp40.ptr; sp3C->state = SPTASK_STATE_NOT_STARTED; switch (sp3C->task.t.type) { @@ -403,50 +403,50 @@ void Main_StartNextTask(void) { if (gCurrentTask != NULL) { if (gCurrentTask->task.t.type == M_GFXTASK) { gCurrentTask->state = SPTASK_STATE_INTERRUPTED; - osSpTaskYield(); + // osSpTaskYield(); } } else { gCurrentTask = sAudioTasks[0]; - osSpTaskLoad(&gCurrentTask->task); - osSpTaskStartGo(&gCurrentTask->task); + // osSpTaskLoad(&gCurrentTask->task); + // osSpTaskStartGo(&gCurrentTask->task); gCurrentTask->state = SPTASK_STATE_RUNNING; } } else if ((gCurrentTask == NULL) && (sGfxTasks[0] != NULL) && (sGfxTasks[0]->state != SPTASK_STATE_FINISHED)) { gCurrentTask = sGfxTasks[0]; - osDpSetStatus(DPC_CLR_TMEM_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_CMD_CTR | DPC_CLR_CLOCK_CTR); - osSpTaskLoad(&gCurrentTask->task); - osSpTaskStartGo(&gCurrentTask->task); + // osDpSetStatus(DPC_CLR_TMEM_CTR | DPC_CLR_PIPE_CTR | DPC_CLR_CMD_CTR | DPC_CLR_CLOCK_CTR); + // osSpTaskLoad(&gCurrentTask->task); + // osSpTaskStartGo(&gCurrentTask->task); gCurrentTask->state = SPTASK_STATE_RUNNING; } } void Main_ThreadEntry(void* arg0) { OSMesg ogMsg; - u8 mesg; + u32 mesg; - osCreateThread(&gAudioThread, THREAD_ID_AUDIO, Audio_ThreadEntry, arg0, - gAudioThreadStack + sizeof(gAudioThreadStack), 80); - osStartThread(&gAudioThread); - osCreateThread(&gGraphicsThread, THREAD_ID_GRAPHICS, Graphics_ThreadEntry, arg0, - gGraphicsThreadStack + sizeof(gGraphicsThreadStack), 40); - osStartThread(&gGraphicsThread); - osCreateThread(&gTimerThread, THREAD_ID_TIMER, Timer_ThreadEntry, arg0, - gTimerThreadStack + sizeof(gTimerThreadStack), 60); - osStartThread(&gTimerThread); - osCreateThread(&gSerialThread, THREAD_ID_SERIAL, SerialInterface_ThreadEntry, arg0, - gSerialThreadStack + sizeof(gSerialThreadStack), 20); - osStartThread(&gSerialThread); + // osCreateThread(&gAudioThread, THREAD_ID_AUDIO, Audio_ThreadEntry, arg0, + // gAudioThreadStack + sizeof(gAudioThreadStack), 80); + // osStartThread(&gAudioThread); + // osCreateThread(&gGraphicsThread, THREAD_ID_GRAPHICS, Graphics_ThreadEntry, arg0, + // gGraphicsThreadStack + sizeof(gGraphicsThreadStack), 40); + // osStartThread(&gGraphicsThread); + // osCreateThread(&gTimerThread, THREAD_ID_TIMER, Timer_ThreadEntry, arg0, + // gTimerThreadStack + sizeof(gTimerThreadStack), 60); + // osStartThread(&gTimerThread); + // osCreateThread(&gSerialThread, THREAD_ID_SERIAL, SerialInterface_ThreadEntry, arg0, + // gSerialThreadStack + sizeof(gSerialThreadStack), 20); + // osStartThread(&gSerialThread); Main_InitMesgQueues(); while (true) { osRecvMesg(&gMainThreadMsgQueue, &ogMsg, OS_MESG_BLOCK); - mesg = (u32) ogMsg; + mesg = ogMsg.data32; switch (mesg) { case EVENT_MESG_VI: - osSendMesg(&gAudioVImsgQueue, (OSMesg) EVENT_MESG_VI, OS_MESG_PRI_NORMAL); - osSendMesg(&gGfxVImsgQueue, (OSMesg) EVENT_MESG_VI, OS_MESG_PRI_NORMAL); + osSendMesg(&gAudioVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL); + osSendMesg(&gGfxVImsgQueue, OS_MESG_32(EVENT_MESG_VI), OS_MESG_PRI_NORMAL); Main_GetNewTasks(); break; case EVENT_MESG_SP: @@ -466,24 +466,25 @@ void Main_ThreadEntry(void* arg0) { } void Idle_ThreadEntry(void* arg0) { - osCreateViManager(OS_PRIORITY_VIMGR); - Main_SetVIMode(); - Lib_FillScreen(1); - osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQueue, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); - osCreateThread(&gMainThread, THREAD_ID_MAIN, &Main_ThreadEntry, arg0, sMainThreadStack + sizeof(sMainThreadStack), - 100); - osStartThread(&gMainThread); - Fault_Init(); - osSetThreadPri(NULL, OS_PRIORITY_IDLE); -loop_1: - goto loop_1; + // TODO: Implement idle thread + // osCreateViManager(OS_PRIORITY_VIMGR); + // Main_SetVIMode(); + // Lib_FillScreen(1); + // osCreatePiManager(OS_PRIORITY_PIMGR, &gPiMgrCmdQueue, sPiMgrCmdBuff, ARRAY_COUNT(sPiMgrCmdBuff)); + // osCreateThread(&gMainThread, THREAD_ID_MAIN, &Main_ThreadEntry, arg0, sMainThreadStack + sizeof(sMainThreadStack), + // 100); + // osStartThread(&gMainThread); + // Fault_Init(); + // osSetThreadPri(NULL, OS_PRIORITY_IDLE); +// loop_1: +// goto loop_1; } void bootproc(void) { - RdRam_CheckIPL3(); - osInitialize(); + // RdRam_CheckIPL3(); + // osInitialize(); Main_Initialize(); - osCreateThread(&sIdleThread, THREAD_ID_IDLE, &Idle_ThreadEntry, NULL, sIdleThreadStack + sizeof(sIdleThreadStack), - 255); - osStartThread(&sIdleThread); + // osCreateThread(&sIdleThread, THREAD_ID_IDLE, &Idle_ThreadEntry, NULL, sIdleThreadStack + sizeof(sIdleThreadStack), + // 255); + // osStartThread(&sIdleThread); } diff --git a/src/sys/sys_matrix.c b/src/sys/sys_matrix.c index f50cfb64..2722bfb5 100644 --- a/src/sys/sys_matrix.c +++ b/src/sys/sys_matrix.c @@ -1,19 +1,19 @@ #include "sys.h" -Mtx gIdentityMtx = { { - { +Mtx gIdentityMtx = { + .intPart = { { 1, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 1 }, }, - { + .fracPart = { { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, }, -} }; +}; Matrix gIdentityMatrix = { { { 1.0f, 0.0f, 0.0f, 0.0f }, @@ -332,8 +332,8 @@ void Matrix_RotateAxis(Matrix* mtx, f32 angle, f32 axisX, f32 axisY, f32 axisZ, // Converts the current Gfx matrix to a Mtx void Matrix_ToMtx(Mtx* dest) { s32 intVal; - u16(*iPart)[4] = dest->u.i; - u16(*fPart)[4] = dest->u.f; + u16(*iPart)[4] = dest->intPart; + u16(*fPart)[4] = dest->fracPart; Matrix* src = gGfxMatrix; intVal = src->m[0][0] * 0x10000; @@ -403,22 +403,22 @@ void Matrix_ToMtx(Mtx* dest) { // Converts the Mtx src to a Matrix, putting the result in dest void Matrix_FromMtx(Mtx* src, Matrix* dest) { - dest->m[0][0] = ((src->u.i[0][0] << 0x10) | src->u.f[0][0]) * (1.0f / 0x10000); - dest->m[0][1] = ((src->u.i[0][1] << 0x10) | src->u.f[0][1]) * (1.0f / 0x10000); - dest->m[0][2] = ((src->u.i[0][2] << 0x10) | src->u.f[0][2]) * (1.0f / 0x10000); - dest->m[0][3] = ((src->u.i[0][3] << 0x10) | src->u.f[0][3]) * (1.0f / 0x10000); - dest->m[1][0] = ((src->u.i[1][0] << 0x10) | src->u.f[1][0]) * (1.0f / 0x10000); - dest->m[1][1] = ((src->u.i[1][1] << 0x10) | src->u.f[1][1]) * (1.0f / 0x10000); - dest->m[1][2] = ((src->u.i[1][2] << 0x10) | src->u.f[1][2]) * (1.0f / 0x10000); - dest->m[1][3] = ((src->u.i[1][3] << 0x10) | src->u.f[1][3]) * (1.0f / 0x10000); - dest->m[2][0] = ((src->u.i[2][0] << 0x10) | src->u.f[2][0]) * (1.0f / 0x10000); - dest->m[2][1] = ((src->u.i[2][1] << 0x10) | src->u.f[2][1]) * (1.0f / 0x10000); - dest->m[2][2] = ((src->u.i[2][2] << 0x10) | src->u.f[2][2]) * (1.0f / 0x10000); - dest->m[2][3] = ((src->u.i[2][3] << 0x10) | src->u.f[2][3]) * (1.0f / 0x10000); - dest->m[3][0] = ((src->u.i[3][0] << 0x10) | src->u.f[3][0]) * (1.0f / 0x10000); - dest->m[3][1] = ((src->u.i[3][1] << 0x10) | src->u.f[3][1]) * (1.0f / 0x10000); - dest->m[3][2] = ((src->u.i[3][2] << 0x10) | src->u.f[3][2]) * (1.0f / 0x10000); - dest->m[3][3] = ((src->u.i[3][3] << 0x10) | src->u.f[3][3]) * (1.0f / 0x10000); + dest->m[0][0] = ((src->intPart[0][0] << 0x10) | src->fracPart[0][0]) * (1.0f / 0x10000); + dest->m[0][1] = ((src->intPart[0][1] << 0x10) | src->fracPart[0][1]) * (1.0f / 0x10000); + dest->m[0][2] = ((src->intPart[0][2] << 0x10) | src->fracPart[0][2]) * (1.0f / 0x10000); + dest->m[0][3] = ((src->intPart[0][3] << 0x10) | src->fracPart[0][3]) * (1.0f / 0x10000); + dest->m[1][0] = ((src->intPart[1][0] << 0x10) | src->fracPart[1][0]) * (1.0f / 0x10000); + dest->m[1][1] = ((src->intPart[1][1] << 0x10) | src->fracPart[1][1]) * (1.0f / 0x10000); + dest->m[1][2] = ((src->intPart[1][2] << 0x10) | src->fracPart[1][2]) * (1.0f / 0x10000); + dest->m[1][3] = ((src->intPart[1][3] << 0x10) | src->fracPart[1][3]) * (1.0f / 0x10000); + dest->m[2][0] = ((src->intPart[2][0] << 0x10) | src->fracPart[2][0]) * (1.0f / 0x10000); + dest->m[2][1] = ((src->intPart[2][1] << 0x10) | src->fracPart[2][1]) * (1.0f / 0x10000); + dest->m[2][2] = ((src->intPart[2][2] << 0x10) | src->fracPart[2][2]) * (1.0f / 0x10000); + dest->m[2][3] = ((src->intPart[2][3] << 0x10) | src->fracPart[2][3]) * (1.0f / 0x10000); + dest->m[3][0] = ((src->intPart[3][0] << 0x10) | src->fracPart[3][0]) * (1.0f / 0x10000); + dest->m[3][1] = ((src->intPart[3][1] << 0x10) | src->fracPart[3][1]) * (1.0f / 0x10000); + dest->m[3][2] = ((src->intPart[3][2] << 0x10) | src->fracPart[3][2]) * (1.0f / 0x10000); + dest->m[3][3] = ((src->intPart[3][3] << 0x10) | src->fracPart[3][3]) * (1.0f / 0x10000); } // Applies the transform matrix mtx to the vector src, putting the result in dest diff --git a/src/sys/sys_timer.c b/src/sys/sys_timer.c index 6e33932e..7b11b71d 100644 --- a/src/sys/sys_timer.c +++ b/src/sys/sys_timer.c @@ -23,7 +23,7 @@ s32 Timer_CreateTask(u64 time, TimerAction action, s32* address, s32 value) { task->action = action; task->address = address; task->value = value; - return osSetTimer(&task->timer, time, 0, &gTimerTaskMsgQueue, task); + return osSetTimer(&task->timer, time, 0, &gTimerTaskMsgQueue, OS_MESG_PTR(task)); } void Timer_Increment(s32* address, s32 value) { @@ -45,6 +45,6 @@ void Timer_Wait(u64 time) { OSTimer timer; OSMesg dummy; - osSetTimer(&timer, time, 0, &gTimerWaitMsgQueue, NULL); + osSetTimer(&timer, time, 0, &gTimerWaitMsgQueue, OS_MESG_PTR(NULL)); osRecvMesg(&gTimerWaitMsgQueue, &dummy, OS_MESG_BLOCK); }