diff options
| author | emilybrooks <emilybrooksemilybrooks@gmail.com> | 2024-01-02 11:14:05 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-01-02 11:14:05 -0700 |
| commit | ebd97e9fd1cd8bb02a397ca8b0982bc0e2b076ae (patch) | |
| tree | 7f7b0e0b67284e74a0178a384f9c85b909589971 /src/code/sys_initial_check.c | |
| parent | 72514d5aae62cc9789b2de0d3d3ba764be2c168d (diff) | |
sys_initial_check OK (#129)
* initial commit
* almost matching, need to figure out segment stuff
* fully matching
* file description
* m_std_dma
Diffstat (limited to 'src/code/sys_initial_check.c')
| -rw-r--r-- | src/code/sys_initial_check.c | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/src/code/sys_initial_check.c b/src/code/sys_initial_check.c new file mode 100644 index 0000000..dbaf917 --- /dev/null +++ b/src/code/sys_initial_check.c @@ -0,0 +1,82 @@ +/** + * @file sys_initial_check.c + * Functions for checking the TV type (PAL/NTSC/MPAL), and printing an error message to the screen if it's not NTSC + */ + +#include "color.h" +#include "macros.h" +#include "m_std_dma.h" +#include "segment_symbols.h" +#include "fault.h" + +void Check_WriteRGBA16Pixel(u16* buffer, u32 x, u32 y, u32 value) { + if (value & RGBA16_PIXEL_OPAQUE) { + (&buffer[x])[y * SCREEN_WIDTH] = value; + } +} + +void Check_WriteI4Pixel(u16* buffer, u32 x, u32 y, u32 value) { + Check_WriteRGBA16Pixel(buffer, x, y, value * GPACK_RGBA5551(16, 16, 16, 0) + GPACK_RGBA5551(12, 12, 12, 1)); +} + +void Check_DrawI4Texture(u16* buffer, s32 x, s32 y, s32 width, s32 height, u8* texture) { + s32 v; + s32 u; + u8 pixelPair; + u8* pixelPairPointer = texture; + + for (v = 0; v < height; v++) { + for (u = 0; u < width; u += 2, pixelPairPointer++) { + pixelPair = *pixelPairPointer; + Check_WriteI4Pixel(buffer, x + u, y + v, pixelPair >> 4); + pixelPair = *pixelPairPointer; + Check_WriteI4Pixel(buffer, x + u + 1, y + v, pixelPair & 0xF); + } + } +} + +void Check_ClearRGBA16(u16* buffer) { + u32 x; + u32 y; + + for (y = 0; y < SCREEN_HEIGHT; y++) { + for (x = 0; x < SCREEN_WIDTH; x++) { + Check_WriteRGBA16Pixel(buffer, x, y, 1); + } + } +} + +#define ERROR_TEXTURE_WIDTH 208 +#define ERROR_TEXTURE_HEIGHT 16 +#define ERROR_TEXTURE_SIZE (ERROR_TEXTURE_WIDTH * ERROR_TEXTURE_HEIGHT / 2) +#define ERROR_TEXTURE_VRAM (u8*)((uintptr_t)FAULT_FB_ADDRESS - ERROR_TEXTURE_SIZE) +u8 Check_ErrorTextureYCoords[] = { 112, 0 }; + +void Check_DrawRegionLockErrorMessage(void) { + s32 i; + + DmaMgr_RequestSyncDebug(ERROR_TEXTURE_VRAM, SEGMENT_ROM_START(locerrmsg), SEGMENT_VRAM_SIZE(locerrmsg), + "../sys_initial_check.c", 130); + Check_ClearRGBA16(FAULT_FB_ADDRESS); + for (i = 0; i < 1; i++) { + Check_DrawI4Texture(FAULT_FB_ADDRESS, 56, Check_ErrorTextureYCoords[i], ERROR_TEXTURE_WIDTH, + ERROR_TEXTURE_HEIGHT, ERROR_TEXTURE_VRAM + i * ERROR_TEXTURE_SIZE); + } + osWritebackDCacheAll(); + osViSwapBuffer(FAULT_FB_ADDRESS); + osViBlack(false); +} + +void Check_RegionIsSupported(void) { + s32 regionSupported = false; + + if (osTvType == OS_TV_NTSC) { + regionSupported = true; + } + + if (!regionSupported) { + Check_DrawRegionLockErrorMessage(); + osDestroyThread(NULL); + while (true) {}; + } +} |
