add framebuffer, framebuffer_shaded, vo_border_col

This commit is contained in:
Zack Buhman 2025-08-20 21:56:42 -05:00
parent 3fc18fa1b7
commit 7886a60ef2
3 changed files with 93 additions and 0 deletions

36
framebuffer.c Normal file
View File

@ -0,0 +1,36 @@
#include <stdint.h>
void main()
{
volatile uint32_t * texture_memory32 = (volatile uint32_t *)(0x05000000 | 0xA0000000);
int blue = 0x0000ff;
for (int i = 0; i < 640 * 480; i++) {
texture_memory32[i] = blue;
}
volatile uint32_t * FB_R_CTRL = (volatile uint32_t*)(0x005F8044 | 0xA0000000);
int vclk_div = 1;
int fb_depth = 0x3; // 0888 RGB 32 bit
int fb_enable = 1;
*FB_R_CTRL
= (vclk_div << 23)
| (fb_depth << 2 )
| (fb_enable << 0 );
volatile uint32_t * FB_R_SOF1 = (volatile uint32_t*)(0x005F8050 | 0xA0000000);
// the framebuffer is at the start of texture memory (texture memory address 0)
*FB_R_SOF1 = 0;
volatile uint32_t * FB_R_SIZE = (volatile uint32_t*)(0x005F805C | 0xA0000000);
int fb_modulus = 1;
int fb_y_size = 480 - 1;
int bytes_per_pixel = 4;
int fb_x_size = ((640 * bytes_per_pixel) / 4) - 1;
*FB_R_SIZE
= (fb_modulus << 20)
| (fb_y_size << 10)
| (fb_x_size << 0 );
}

39
framebuffer_shaded.c Normal file
View File

@ -0,0 +1,39 @@
#include <stdint.h>
void main()
{
volatile uint32_t * texture_memory32 = (volatile uint32_t *)(0x05000000 | 0xA0000000);
for (int y = 0; y < 480; y++) {
for (int x = 0; x < 640; x++) {
int red = (y % 255);
int blue = (x % 255);
texture_memory32[y * 640 + x] = (red << 16) | (blue << 0);
}
}
volatile uint32_t * FB_R_CTRL = (volatile uint32_t*)(0x005F8044 | 0xA0000000);
int vclk_div = 1;
int fb_depth = 0x3; // 0888 RGB 32 bit
int fb_enable = 1;
*FB_R_CTRL
= (vclk_div << 23)
| (fb_depth << 2 )
| (fb_enable << 0 );
volatile uint32_t * FB_R_SOF1 = (volatile uint32_t*)(0x005F8050 | 0xA0000000);
// the framebuffer is at the start of texture memory (texture memory address 0)
*FB_R_SOF1 = 0;
volatile uint32_t * FB_R_SIZE = (volatile uint32_t*)(0x005F805C | 0xA0000000);
int fb_modulus = 1;
int fb_y_size = 480 - 1;
int bytes_per_pixel = 4;
int fb_x_size = ((640 * bytes_per_pixel) / 4) - 1;
*FB_R_SIZE
= (fb_modulus << 20)
| (fb_y_size << 10)
| (fb_x_size << 0 );
}

18
vo_border_col.c Normal file
View File

@ -0,0 +1,18 @@
#include <stdint.h>
typedef volatile uint32_t reg32;
void main()
{
reg32 * VO_BORDER_COL = (reg32 *)(0x005F8040 | 0xA0000000);
reg32 * FB_R_CTRL = (reg32 *)(0x005F8044 | 0xA0000000);
int vclk_div = 1;
int fb_enable = 0;
*FB_R_CTRL
= (vclk_div << 23)
| (fb_enable << 0);
int green = 0x00ff00;
*VO_BORDER_COL = green;
}