refactor: use for ia86-elf-gcc toolchain + linker file
[swan-dev] / src / main.c
index 3763f3c..502d63c 100644 (file)
-/* #include <code16bit.h> */
-#include <memory.h>
 
-void outport(c)
-       unsigned c;
-{
-#asm
-       xor dx, dx
-       mov dx, ax
-       shr dx, 8
-       out dx, al
-       ;out 0x15, al
-#endasm
-}
-
-static unsigned char data[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
+/* sprite data */
+unsigned char bgtile_gfx[] = {
+  0x31, 0x22, 0x31, 0x32, 0x22, 0x31, 0x23, 0x21, 0x13, 0x13, 0x31, 0x32,
+  0x32, 0x31, 0x23, 0x12, 0x21, 0x32, 0x13, 0x23, 0x23, 0x13, 0x31, 0x31,
+  0x12, 0x32, 0x13, 0x22, 0x23, 0x13, 0x22, 0x13
 };
 
-static unsigned char data2[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
+/* palette data */
+unsigned char bgtile_pal[] = {
+  0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f,
+  0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
+  0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
 };
 
-static unsigned char data3[] = {
-0x65, 0x06, 0x67, 0x06, 0x79, 0x07, 0x8c, 0x08, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f,
-0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f, 0xff, 0x0f
-};
-       
 
+/* data */
+unsigned char lol[5] = { 0xAA, 0x2, 0x3, 0x4, 0x5};
+unsigned char lol2[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
+unsigned char lol3[5] = { 0x1, 0x2, 0x3, 0x4, 0x5};
+#define PALETTE (*(volatile unsigned *)0xFE00)
+#define PALETTE_T (volatile unsigned *)0xFE00
+#define SPRITE_T (volatile unsigned *)0x4000
 
-unsigned short *memcpy(dest, src, cnt)
-       unsigned short *dest;
-       unsigned short *src;
-       int cnt;
-{
-
-       int i;
-#asm
-       ;push ds
-       ;push es
-       mov ax, 0x0
-       mov ds, ax
-       xor ax, ax
-       mov es, ax
-#endasm
-       for (i = 0; i < cnt; ++i) {
-               *dest++ = *src++;
-               //*dest++ = 0x66;
-       }
-#asm   
-       ;pop es
-       ;pop ds
-       mov ds, 0xF000
-#endasm
-       return dest;
-}
-
-void test_copy()
-{
-#asm 
-       ;mov ds, 0
-#endasm
-      
-//     unsigned short dest = 0xFE00;
-//     unsigned * ptr = dest;
-//     *ptr++ = 0xDEAD;
-//     *ptr++ = 0xAAAA;
-//     *ptr++ = 0xDEAD;
-       memcpy(0xFE00, 0x1000, 16);
-#asm 
-       ;mov ds, 0xF000
-#endasm
-       //wmemcpy(WSC_PALETTES, 0x2F000, 32);
-       return;
-}
+/* bss */
+static unsigned char blaat[100];
 
-int main()
+int main(void)
 {
-       unsigned short data_seg = 0xF000;
-       unsigned short data_ram = 0x1000;
-       unsigned short rel_ram = data_seg - data_ram;
+       lol[0] = 0xDD;
+       lol[1] = 0xDD;
 
-       /* dummy */
-       memcpy(0x0, 0x0, 0);
-
-       memcpy(0xFE00, data - rel_ram, 16);
-       //memcpy(0xFE00, data_seg + data, 16);
+       blaat[0] = 0xEE;
+       blaat[1] = 0xEE;
+       blaat[32] = 0xEE;
        
-       //while(1) {
-       //      /* outport(0x15EE); */
-       //      unsigned reg = 0x15;
-       //      unsigned val = 0xEE;
-       //      outport((reg << 8) | val);
-
-       //}
+       unsigned char * ptr = PALETTE_T;
+       for (int i = 0; i < sizeof(bgtile_pal); ++i) {
+               *ptr++ = bgtile_pal[i];
+       }
+       
+       ptr = SPRITE_T;
+       for (int i = 0; i < sizeof(bgtile_gfx); ++i) {
+               *ptr++ = bgtile_gfx[i];
+       }
 
+       while(1) {
+       }
 
        return 0;
 }