vault backup: 2025-04-20 13:20:44

This commit is contained in:
sShemet
2025-04-20 13:20:44 +05:00
parent 8517a599ff
commit 0b741a6aec
2 changed files with 153 additions and 4 deletions

View File

@@ -41,12 +41,12 @@
"state": {
"type": "markdown",
"state": {
"file": "PERSONAL PROJECTS/PS1 DOCS/PSX code - Load texture from SECTOR!.md",
"file": "PERSONAL PROJECTS/PS1 DOCS/PSX code logo show.md",
"mode": "source",
"source": false
},
"icon": "lucide-file",
"title": "PSX code - Load texture from SECTOR!"
"title": "PSX code logo show"
}
}
],
@@ -207,6 +207,8 @@
},
"active": "dd912cc876184c4f",
"lastOpenFiles": [
"PERSONAL PROJECTS/PS1 DOCS/PSX code - Load texture from SECTOR!.md",
"PERSONAL PROJECTS/PS1 DOCS/PSX code logo show.md",
"WORK & PROJECTS/Mol/Code Chunks/TipTap Plugin.md",
"PERSONAL PROJECTS/PS1 DOCS/PS1 Gamepad.md",
"PERSONAL PROJECTS/P2EP/pseudoCode/FUN_800453e0 SystemEventManager.md",
@@ -230,14 +232,12 @@
"PERSONAL PROJECTS/PS1 DOCS/PSX code inline asm.md",
"PERSONAL PROJECTS/PS1 DOCS/PSX code - Texture show from file.md",
"PERSONAL PROJECTS/PS1 DOCS/PSX code - modules load and exec.md",
"PERSONAL PROJECTS/PS1 DOCS/PSX code - Load texture from SECTOR!.md",
"PERSONAL PROJECTS/PS1 DOCS/PS1 Vblank.md",
"PERSONAL PROJECTS/PS1 DOCS/PS1 DMA CD-ROM.md",
"WORK & PROJECTS/Mol/Ideas/Все идеи для Моли.md",
"WORK & PROJECTS/Mol/Серверы/mail.mol-soft.ru.md",
"WORK & PROJECTS/Mol/Документы для ТЗ ЛИМС/СМК/КУек_лист_10_ошибок_УД_скачивание.pdf",
"WORK & PROJECTS/Mol/Документы для ТЗ ЛИМС/СМК",
"WORK & PROJECTS/Mol/Планы и диаграммы/Разработка - ЭПИКИ.md",
"WORK & PROJECTS/Mol/Планы и диаграммы/00001_Редакторорм/Таблицы нумератора и документов.canvas",
"WORK & PROJECTS/Mol/Планы и диаграммы/Схема связей юрлиц и адресов.canvas",
"WORK & PROJECTS/Mol/Планы и диаграммы/00001_Редакторорм/Архитектура редактора и генератора (Alfa + Mol).canvas",

View File

@@ -0,0 +1,149 @@
Here's the rewritten code with detailed English comments, following PlayStation 1 (PS1) hardware constraints and PsyQ SDK best practices:
---
### 1. `RDLogo_DrawFramePadCheck()` - Renders Frame and Handles Pad Input
```c
#include <sys/types.h>
#include <psxgpu.h>
#include <psxpad.h>
/**
* Renders logo frame and checks controller input
*
* @param isCheckPadBtn If 1, checks for button press to skip animation
* @return 1 if button pressed (and isCheckPadBtn=1), otherwise 0
*/
int RDLogo_DrawFramePadCheck(int isCheckPadBtn) {
static int currentBuffer = 0; // Double buffer index (0/1)
PADTYPE padStatus; // PS1 controller status struct
int padPressed = 0; // Button press flag
// (1) Get current buffer and set OT
currentBuffer = GsGetActiveBuff();
GsSetWorkBase((u_long*)&gpu_ot[currentBuffer]); // Set OT for current buffer
// (2) Clear ordering table for new frame
GsClearOt(0, 0, &gpu_ot[currentBuffer]);
// (3) Add logo sprites to OT
// PS1 hardware limitation: Max sprite width = 256px, so logo is split
GsSortFastSprite(&leftLogoPart, &gpu_ot[currentBuffer], 0); // Left 256px
GsSortFastSprite(&rightLogoPart, &gpu_ot[currentBuffer], 0); // Right 64px
// (4) Wait for GPU and VBlank sync
DrawSync(0); // Wait for drawing completion
VSync(0); // Sync to vertical refresh
// (5) Read controller input
PadRead(&padStatus); // Poll controller
padPressed = (padStatus.btns != 0); // Any button pressed
// (6) Skip input check or no button pressed
if ((isCheckPadBtn == 0) || (padPressed == 0)) {
GsSwapDispBuff(); // Flip buffers
GsSortClear(0, 0, 0, &gpu_ot[currentBuffer]); // Clear screen
GsDrawOt(&gpu_ot[currentBuffer]); // Render OT
return 0; // No button pressed
}
return 1; // Button pressed (only if isCheckPadBtn=1)
}
```
---
### 2. `RDLogo_show()` - Main Logo Display Function
```c
#include <psxgpu.h>
#include <psxcd.h>
// Global sprite definitions (split due to PS1's 256px width limit)
GsSPRITE leftLogoPart; // Left 256px of logo (texture + attributes)
GsSPRITE rightLogoPart; // Right 64px of logo (320px total width)
u_long gpu_ot[2][OTSIZE]; // Double buffered ordering tables
/**
* Displays logo with fade-in/out animation
* Splits rendering due to PS1 hardware limitations:
* - Maximum single sprite width: 256px
* - 15-bit color (RGB555)
* - Requires manual VRAM management
*/
void RDLogo_show(void) {
int alpha; // Transparency value (0=transparent, 128=opaque)
int i;
// (1) Initialize graphics
SetDispMask(0); // Disable display
ResetGraph(1); // Reset GPU
GsInitGraph(320, 240, 4, 1, 0); // 320x240, 16-bit color
GsDefDispBuff(0, 0, 0, 240); // Setup double buffering
// (2) Load logo from CD-ROM
CdInit(); // Initialize CD drive
// Read raw sector containing logo (bypass filesystem for speed)
CdRead(104798, (u_long*)&leftLogoPart, 2048); // Sector 104798
// (3) Configure split sprites
// Left part: 256px wide, positioned left of center (-160px)
GsSetSprite(&leftLogoPart, -160, -120, 256, 240, 5); // Palette slot 5
// Right part: 64px wide, positioned right of center (+160px)
GsSetSprite(&rightLogoPart, 160, -120, 64, 240, 7); // Palette slot 7
// (4) Fade-in animation
for (alpha = 0; alpha < 128; alpha += 4) {
leftLogoPart.r = alpha; // Set transparency (PS1 uses .r for blending)
rightLogoPart.r = alpha;
RDLogo_DrawFramePadCheck(0); // Render without input check
}
// (5) Display pause (120 frames) with skip option
for (i = 0; i < 120; i++) {
if (RDLogo_DrawFramePadCheck(1)) break; // Check for button press
}
// (6) Fade-out animation
for (alpha = 128; alpha >= 0; alpha -= 4) {
leftLogoPart.r = alpha;
rightLogoPart.r = alpha;
RDLogo_DrawFramePadCheck(0);
}
SetDispMask(0); // Disable display before exiting
}
```
---
### Key Hardware Considerations:
1. **Sprite Width Limit**:
```c
// PS1 GPU cannot render >256px wide sprites in one operation
GsSetSprite(&leftLogoPart, ..., 256, ...); // Max allowed width
```
2. **VRAM Management**:
```c
CdRead(104798, ...); // Bypass filesystem for direct sector access
```
3. **15-bit Color**:
```c
GsInitGraph(..., 4, ...); // 4 = 16-bit color mode (RGB555)
```
4. **Ordering Table (OT)**:
```c
GsClearOt(0, 0, &gpu_ot[currentBuffer]); // Critical for proper z-sorting
```
---
### Compilation Notes:
1. Requires PsyQ SDK (`libpsxgpu.a`, `libpsxcd.a`)
2. Link with `-lpsxetc -lpsxgpu -lpsxcd`
3. MIPS R3000 compiler needed (e.g., `mipsel-unknown-elf-gcc`)
This implementation respects all PS1 hardware limitations while maintaining readability. The logo splitting is mandatory due to the GPU's 256px render width constraint.