main: attribute naked not working, use .s instead
[swan-dev] / src / main.c
index 43289fc..7690c66 100644 (file)
@@ -10,6 +10,8 @@
 #include <config.h>
 #include <interrupt.h>
 
+extern void * dummyS_isr;
+
 /* sprite data */
 unsigned char bgtile_gfx[] = {
   0x31, 0x22, 0x31, 0x32, 0x22, 0x31, 0x23, 0x21, 0x13, 0x13, 0x31, 0x32,
@@ -59,25 +61,69 @@ unsigned char inport(unsigned char portnr)
        return val;
 }
 
-__attribute__ ((naked)) void * dummy_isr(void)
+static void __attribute__((used)) dummy() 
 {
-       int a = 2;
-       a *= 2;
-       while(1);
+       __asm__("iret");
 }
 
+//__attribute__((naked)) void dummy_isr(void)
+//{
+//     __asm__("push %ax\n\t"
+//             "push %bx\n\t"
+//             "popw %bp\n\t" /* HACK: directly pop bp again */
+//            );
+//
+//     //unsigned char val = inport(IO_BG_X);
+//     //val++;
+//
+//     //outport(IO_BG_X, val);
+//     //outport(IO_INT_ACK, INT_VBLANK_START);
+//     __asm__("pop %ax\n\t"
+//             "pop %bx\n\t"
+//            );
+//
+//     __asm__("iret");
+//}
+
 void setup_ivec(void)
 {
        outport(IO_INT_BASE, INT_BASE);
 
        unsigned short * test_vec = (INT_BASE + INTVEC_VBLANK_START) << 2;
-       *test_vec++ = (&dummy_isr);
+       *test_vec++ = (&dummyS_isr);
        *test_vec = (0x2000);
 
+       unsigned short * keyboard_intr = (INT_BASE + INTVEC_KEY_PRESS) << 2;
+       *keyboard_intr++ = (&dummyS_isr);
+       *keyboard_intr = (0x2000);
+
        outport(IO_INT_ENABLE, INT_VBLANK_START);
+       //outport(IO_INT_ENABLE, INT_KEY_PRESS);
        __asm__("sti");
 }
 
+static unsigned cnt = 0;
+
+void scroll_video(void)
+{
+       unsigned char val = inport(IO_FG_X);
+
+       cnt++;
+       if (cnt > 10) {
+               cnt = 0;
+               val++;
+       }
+       
+       outport(IO_FG_X, val);
+       outport(IO_INT_ACK, INT_VBLANK_START);
+       
+       outport(IO_FG_WIN_X0, cnt);
+       outport(IO_FG_WIN_Y0, cnt);
+       outport(IO_FG_WIN_X1, SCREEN_WIDTH - cnt);
+       outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - cnt);
+
+}
+
 void init_video(void)
 {
 }
@@ -125,6 +171,9 @@ int main(void)
        
        outport(IO_DISPLAY_CTRL, FG_OUT_WIN | FG_ON);
 
+       int a = 0;
+       a++;
+
        while(1) {
        }