//Pascal used on the 2DS & 3DS NinjaHax platform // // Copyright (c) 2013, 2015, 2017 Kenny D. Lee // all rights reserved // {$ifdef 3dsintf} Type gxCommandS=array[0..7] of u32; {* * @file gspgpu.h * @brief GSPGPU service. } function GSPGPU_REBASE_REG(r : longint) : longint; {/ Framebuffer information. } {/< Active framebuffer. (0 = first, 1 = second) } {/< Framebuffer virtual address, for the main screen this is the 3D left framebuffer. } {/< For the main screen: 3D right framebuffer address. } {/< Value for 0x1EF00X90, controls framebuffer width. } {/< Framebuffer format, this u16 is written to the low u16 for LCD register 0x1EF00X70. } {/< Value for 0x1EF00X78, controls which framebuffer is displayed. } {/< Unknown. } type GSPGPU_FramebufferInfo = record active_framebuf : u32; framebuf0_vaddr : ^u32; framebuf1_vaddr : ^u32; framebuf_widthbytesize : u32; format : u32; framebuf_dispselect : u32; unk : u32; end; PGSPGPU_FramebufferInfo = ^GSPGPU_FramebufferInfo; {/ Framebuffer format. } {/< RGBA8. (4 bytes) } {/< BGR8. (3 bytes) } {/< RGB565. (2 bytes) } {/< RGB5A1. (2 bytes) } {/< RGBA4. (2 bytes) } GSPGPU_FramebufferFormats = (GSP_RGBA8_OES := 0,GSP_BGR8_OES := 1, GSP_RGB565_OES := 2,GSP_RGB5_A1_OES := 3, GSP_RGBA4_OES := 4); {/ Capture info entry. } {/< Left framebuffer. } {/< Right framebuffer. } {/< Framebuffer format. } {/< Framebuffer pitch. } GSPGPU_CaptureInfoEntry = record framebuf0_vaddr : ^u32; framebuf1_vaddr : ^u32; format : u32; framebuf_widthbytesize : u32; end; {/ Capture info. } {/< Capture info entries, one for each screen. } GSPGPU_CaptureInfo = record screencapture : array[0..1] of GSPGPU_CaptureInfoEntry; end; PGSPGPU_CaptureInfo = ^GSPGPU_CaptureInfo; {/ GSPGPU events. } {/< Memory fill completed. } {/< TODO } {/< TODO } {/< TODO } {/< Display transfer finished. } {/< Command list processing finished. } {/< TODO } {/< Used to know how many events there are. } GSPGPU_Event = (GSPGPU_EVENT_PSC0 := 0,GSPGPU_EVENT_PSC1, GSPGPU_EVENT_VBlank0,GSPGPU_EVENT_VBlank1, GSPGPU_EVENT_PPF,GSPGPU_EVENT_P3D,GSPGPU_EVENT_DMA, GSPGPU_EVENT_MAX); {/ Initializes GSPGPU. } function gspInit:s32;cdecl;external; {/ Exits GSPGPU. } procedure gspExit;cdecl;external; {* * @brief Configures a callback to run when a GSPGPU event occurs. * @param id ID of the event. * @param cb Callback to run. * @param data Data to be passed to the callback. * @param oneShot When true, the callback is only executed once. When false, the callback is executed every time the event occurs. } procedure gspSetEventCallback(id:GSPGPU_Event; cb:ThreadFunc; data:pointer; oneShot:bool);cdecl;external; {* * @brief Initializes the GSPGPU event handler. * @param gspEvent Event handle to use. * @param gspSharedMem GSP shared memory. * @param gspThreadId ID of the GSP thread. } function gspInitEventHandler(gspEvent:Handle; gspSharedMem:Pu8; gspThreadId:u8):s32;cdecl;external; //gspSharedMem:Pvu8; {/ Exits the GSPGPU event handler. } procedure gspExitEventHandler;cdecl;external; {* * @brief Waits for a GSPGPU event to occur. * @param id ID of the event. * @param nextEvent Whether to discard the current event and wait for the next event. } procedure gspWaitForEvent(id:GSPGPU_Event; nextEvent:bool);cdecl;external; {* * @brief Waits for any GSPGPU event to occur. * @return The ID of the event that occurred. * * The function returns immediately if there are unprocessed events at the time of call. } function gspWaitForAnyEvent:GSPGPU_Event;cdecl;external; procedure gspWaitForPSC0; procedure gspWaitForPSC1; procedure gspWaitForVBlank; procedure gspWaitForVBlank0; procedure gspWaitForVBlank1; procedure gspWaitForPPF; procedure gspWaitForP3D; procedure gspWaitForDMA; {* * @brief Submits a GX command. * @param sharedGspCmdBuf Command buffer to use. * @param gxCommand GX command to execute. } function gspSubmitGxCommand(sharedGspCmdBuf:Pu32; gxCommand: gxCommands):s32;cdecl;external; {* * @brief Acquires GPU rights. * @param flags Flags to acquire with. } function GSPGPU_AcquireRight(flags:u8):s32;cdecl;external; {/ Releases GPU rights. } function GSPGPU_ReleaseRight:s32;cdecl;external; {* * @brief Retrieves display capture info. * @param captureinfo Pointer to output capture info to. } function GSPGPU_ImportDisplayCaptureInfo(captureinfo:PGSPGPU_CaptureInfo):s32;cdecl;external; {/ Sames the VRAM sys area. } function GSPGPU_SaveVramSysArea:s32;cdecl;external; {/ Restores the VRAM sys area. } function GSPGPU_RestoreVramSysArea:s32;cdecl;external; {* * @brief Sets whether to force the LCD to black. * @param flags Whether to force the LCD to black. (0 = no, non-zero = yes) } function GSPGPU_SetLcdForceBlack(flags:u8):s32;cdecl;external; {* * @brief Updates a screen's framebuffer state. * @param screenid ID of the screen to update. * @param framebufinfo Framebuffer information to update with. } function GSPGPU_SetBufferSwap(screenid:u32; framebufinfo:PGSPGPU_FramebufferInfo):s32;cdecl;external; {* * @brief Flushes memory from the data cache. * @param adr Address to flush. * @param size Size of the memory to flush. } (* Const before type ignored *) function GSPGPU_FlushDataCache(adr:pointer; size:u32):s32;cdecl;external; {* * @brief Invalidates memory in the data cache. * @param adr Address to invalidate. * @param size Size of the memory to invalidate. } (* Const before type ignored *) function GSPGPU_InvalidateDataCache(adr:pointer; size:u32):s32;cdecl;external; {* * @brief Writes to GPU hardware registers. * @param regAddr Register address to write to. * @param data Data to write. * @param size Size of the data to write. } function GSPGPU_WriteHWRegs(regAddr:u32; data:Pu32; size:u8):s32;cdecl;external; {* * @brief Writes to GPU hardware registers with a mask. * @param regAddr Register address to write to. * @param data Data to write. * @param datasize Size of the data to write. * @param maskdata Data of the mask. * @param masksize Size of the mask. } function GSPGPU_WriteHWRegsWithMask(regAddr:u32; data:Pu32; datasize:u8; maskdata:Pu32; masksize:u8):s32;cdecl;external; {* * @brief Reads from GPU hardware registers. * @param regAddr Register address to read from. * @param data Buffer to read data to. * @param size Size of the buffer. } function GSPGPU_ReadHWRegs(regAddr:u32; data:Pu32; size:u8):s32;cdecl;external; {* * @brief Registers the interrupt relay queue. * @param eventHandle Handle of the GX command event. * @param flags Flags to register with. * @param outMemHandle Pointer to output the shared memory handle to. * @param threadID Pointer to output the GSP thread ID to. } function GSPGPU_RegisterInterruptRelayQueue(eventHandle:Handle; flags:u32; outMemHandle:PHandle; threadID:Pu8):s32;cdecl;external; {/ Unregisters the interrupt relay queue. } function GSPGPU_UnregisterInterruptRelayQueue:s32;cdecl;external; {/ Triggers a handling of commands written to shared memory. } function GSPGPU_TriggerCmdReqQueue:s32;cdecl;external; {$endif 3dsintf} {$ifdef 3dsimpl} { was #define dname(params) para_def_expr } function GSPGPU_REBASE_REG(r : longint) : longint; begin GSPGPU_REBASE_REG:= (r - $1EB00000); end; procedure gspWaitForPSC0; begin gspWaitForEvent(GSPGPU_EVENT_PSC0,false); end; procedure gspWaitForPSC1; begin gspWaitForEvent(GSPGPU_EVENT_PSC1,false); end; procedure gspWaitForVBlank; begin gspWaitForVBlank0; end; procedure gspWaitForVBlank0; begin gspWaitForEvent(GSPGPU_EVENT_VBlank0,true); end; procedure gspWaitForVBlank1; begin gspWaitForEvent(GSPGPU_EVENT_VBlank1,true); end; procedure gspWaitForPPF; begin gspWaitForEvent(GSPGPU_EVENT_PPF,false); end; procedure gspWaitForP3D; begin gspWaitForEvent(GSPGPU_EVENT_P3D,false); end; procedure gspWaitForDMA; begin gspWaitForEvent(GSPGPU_EVENT_DMA,false); end; {$endif 3dsimpl}