diff --git a/Makefile b/Makefile index a228d27..12e50b9 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ bootinfo.txt: load.fth echo "" >> 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 diff --git a/boot.c b/boot.c index 5f68c3e..a767215 100644 --- a/boot.c +++ b/boot.c @@ -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++; + } } diff --git a/memory.h b/memory.h deleted file mode 100644 index e3191a0..0000000 --- a/memory.h +++ /dev/null @@ -1,6 +0,0 @@ -#define beige_vram 0x80000000 -#define mac99_vram 0x81000000 - -unsigned char IO_TYPE; - -unsigned char* vram_ptr; diff --git a/start.s b/start.s index 449991d..8e167f6 100644 --- a/start.s +++ b/start.s @@ -1,3 +1,3 @@ .globl _start _start: -b begin +b main