Files
V2TMUMemTester/Draw.c
2026-03-09 01:10:56 +01:00

93 lines
2.4 KiB
C

/* V2MemTest - A CLI Tool to test & fix Voodoo² TMU System
* Copyright (C) 2026 ChaCha
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "cvg.h"
#include "glide.h"
#include "sst1init.h"
#include "Draw.h"
static inline uint32_t f32u(const float f)
{
const union { float f; uint32_t u;} v = {.f = f};
return v.u;
}
void
drawRect( const SstRegs * const sst,
const int16_t x,
const int16_t y,
const int16_t tSizeX,
const int16_t tSizeY)
{
ISET(sst->sARGB,0xFFFFFFFF);
ISET(sst->sOowfbi,f32u(1.0f));
ISET(sst->sVx, f32u((float)x));
ISET(sst->sVy, f32u((float)y));
ISET(sst->sSow0,f32u(0.0f));
ISET(sst->sTow0,f32u(0.0f));
/* 0b10 0000 (Update only S0/T0), doc page 76 */
ISET(sst->sSetupMode, 0x0020);
ISET(sst->sBeginTriCMD, 1);
ISET(sst->sVx, f32u((float)(x+tSizeX)));
ISET(sst->sVy, f32u((float)y));
ISET(sst->sSow0,f32u((float)tSizeX));
ISET(sst->sTow0,f32u(0.0f));
ISET(sst->sDrawTriCMD, 1);
ISET(sst->sVx, f32u((float)x));
ISET(sst->sVy, f32u((float)y+tSizeY));
ISET(sst->sSow0,f32u(0.0f));
ISET(sst->sTow0,f32u((float)tSizeY));
ISET(sst->sDrawTriCMD, 1);
ISET(sst->sVx, f32u((float)x+tSizeX));
ISET(sst->sVy, f32u((float)y+tSizeY));
ISET(sst->sSow0,f32u((float)tSizeX));
ISET(sst->sTow0,f32u((float)tSizeY));
ISET(sst->sDrawTriCMD, 1);
ISET(sst->nopCMD, 0x1);
}
void
clearScreen( const SstRegs * const sst,
const uint32_t u32Color,
const int16_t u16SizeX,
const int16_t u16SizeY)
{
ISET(sst->clipLeftRight, u16SizeX);
ISET(sst->clipBottomTop, u16SizeY);
ISET(sst->zaColor, u32Color);
//ISET(sst->zaColor, 0x0000);
const uint32_t fbz_saved = IGET(sst->fbzMode);
ISET(sst->c1,u32Color);
ISET(sst->c0,0x0);
ISET(sst->zaColor,0x0);
ISET(sst->fbzMode, SST_RGBWRMASK | SST_ZAWRMASK);
ISET(sst->fastfillCMD, 0);
ISET(sst->nopCMD, 0x1);
ISET(sst->fbzMode, fbz_saved);
}