vram manipulation

This commit is contained in:
thamugadi 2021-09-30 18:18:01 +01:00
parent f475c30c27
commit 91adcf4588
4 changed files with 64 additions and 29 deletions

View File

@ -16,7 +16,7 @@ bootinfo.txt: load.fth
echo "</boot-script></chrp-boot>" >> bootinfo.txt
kernel.elf: start.elf boot.elf
$(PPC)-ld -Ttext=0x200000 start.elf boot.elf -o kernel.elf
boot.elf: boot.c memory.h
boot.elf: boot.c
$(PPC)-gcc -c boot.c -o boot.elf
start.elf: start.s
$(PPC)-as -c start.s -o start.elf

83
boot.c
View File

@ -1,30 +1,71 @@
#include "memory.h"
#define beige 0xBE
#define mac99 0x5A
#define beige 0xBE
#define mac99 0x5A
#define __VRAM__BEIGE 0x80000000
#define __VRAM__MAC99 0x81000000
#define __BIOS__BEIGE 0xFFC00000
#define __BIOS__MAC99 0xFFF00000
void begin(void)
unsigned char IO_TYPE;
unsigned char* p_vram;
unsigned char* p_bios;
void get_io_type(void)
{
unsigned char *ptr_beige = 0x80000000;
unsigned char *ptr_mac99 = 0x81000000;
if (*ptr_beige == beige) IO_TYPE = beige;
if (*ptr_mac99 == mac99) IO_TYPE = mac99;
init_ptr();
clearscreen();
if (*(unsigned char*)__VRAM__BEIGE == beige) IO_TYPE = beige;
else if (*(unsigned char*)__VRAM__MAC99 == mac99) IO_TYPE = mac99;
}
void init(void)
{
if (IO_TYPE == beige)
{
p_vram = __VRAM__BEIGE;
p_bios = __BIOS__BEIGE;
}
else if (IO_TYPE == mac99)
{
p_vram = __VRAM__MAC99;
p_bios = __BIOS__MAC99;
}
}
void main(void)
{
get_io_type();
init();
clearscreen(0x81, 0x83);
for(;;);
}
void init_ptr(void)
void clearscreen(unsigned char a, unsigned char b)
{
if (IO_TYPE == beige) vram_ptr = beige_vram;
if (IO_TYPE == mac99) vram_ptr = mac99_vram;
}
void clearscreen(void)
{
for (int i = 0; i<10000000; i++)
init();
for (unsigned int i = 0; i<0x100000; i++)
{
*vram_ptr = 0xFF;
i++;
vram_ptr++;
*p_vram = a;
p_vram++;
*p_vram = b;
p_vram++;
}
}
void noisescreen(void)
{
init();
switch(IO_TYPE)
{
case beige: p_vram = __VRAM__BEIGE;
case mac99: p_vram = __VRAM__MAC99;
}
for (unsigned int i = 0; i<0x200000; i++)
{
*p_vram = *(p_bios+0x2F0000+i);
p_vram++;
}
}

View File

@ -1,6 +0,0 @@
#define beige_vram 0x80000000
#define mac99_vram 0x81000000
unsigned char IO_TYPE;
unsigned char* vram_ptr;

View File

@ -1,3 +1,3 @@
.globl _start
_start:
b begin
b main