snd: init and test of noise sound
[swan-dev] / src / main.c
index 9be5eeb..5a18283 100644 (file)
@@ -7,8 +7,12 @@
  */
 #include <memory.h>
 #include <video.h>
+#include <dma_snd.h>
+#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,
@@ -44,11 +48,26 @@ void outport(unsigned char portnr, unsigned char val)
                :);
 }
 
-__attribute__ ((naked)) void * dummy_isr(void)
+unsigned char inport(unsigned char portnr)
+{
+       unsigned char val;
+       __asm__(
+               "mov %1, %%dl\n\t"
+               "in (%%dx), %%al\n\t"
+               "mov %%al, %0"
+               : "=r"(val)
+               : "r"(portnr)
+               :);
+
+       return val;
+}
+
+void setup_audio(void)
 {
-       int a = 2;
-       a *= 2;
-       while(1);
+       outport(IO_AUDIO_CTRL, AUDIO_4_NOISE | AUDIO_4_ON);
+       outport(IO_AUDIO_NOISE_CTRL, NOISE_RESET | NOISE_ENABLE | 0x2);
+       outport(IO_AUDIO4_VOL, 0x22);
+
 }
 
 void setup_ivec(void)
@@ -56,32 +75,76 @@ 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)
 {
 }
 
 int main(void)
 {
-       lol[0] = 0xDD;
-       lol[1] = 0xDD;
+       outport(0x15, 0x99);
+       unsigned char ret = inport(0x15);
+       
+       lol[0] = 0xAA;
+       lol[1] = ret;
 
        blaat[0] = 0xEE;
        blaat[1] = 0xEE;
        blaat[32] = 0xEE;
 
+
        setup_ivec();
        init_video();
+       setup_audio();
        outport(IO_VIDEO_MODE, VMODE_16C_CHK | VMODE_CLEANINIT);
-       outport(IO_FGBG_MAP, 0x40);
+       unsigned short base = 0x3000; /* screens pos */
+       unsigned short sprite_pos = base - (MAP_SIZE*2) - SPR_TABLE_SIZE;
+       unsigned short scr1_pos = base - (MAP_SIZE*2); /* 0x2000 */
+       unsigned short scr2_pos = base - MAP_SIZE; /* 0x2800 */
+       outport(IO_MAP_BASE, FG_MAP(scr2_pos) | BG_MAP(scr1_pos));
+       outport(IO_SPR_TABLE, SPR_TABLE(sprite_pos));
+
+       outport(IO_FG_WIN_X0, 10);
+       outport(IO_FG_WIN_Y0, 10);
+       outport(IO_FG_WIN_X1, SCREEN_WIDTH - 10);
+       outport(IO_FG_WIN_Y1, SCREEN_HEIGHT - 10);
+
+       /* icons */
        outport(0x15, 0xEE);
-       
+
        unsigned char * ptr = PALETTE_T;
        for (int i = 0; i < sizeof(bgtile_pal); ++i) {
                *ptr++ = bgtile_pal[i];
@@ -92,7 +155,10 @@ int main(void)
                *ptr++ = bgtile_gfx[i];
        }
        
-       outport(IO_DISPLAY_CTRL, BG_ON);
+       outport(IO_DISPLAY_CTRL, FG_OUT_WIN | FG_ON);
+
+       int a = 0;
+       a++;
 
        while(1) {
        }