Browse Source

add some irq testing in c code

david 15 years ago
parent
commit
4f8e258710
3 changed files with 44 additions and 11 deletions
  1. 20 3
      snes/fatfstest/StartupSnes.asm
  2. 19 6
      snes/fatfstest/main.c
  3. 5 2
      tools/bsnes/chip/cmmio/cmmio.cpp

+ 20 - 3
snes/fatfstest/StartupSnes.asm

@@ -124,8 +124,8 @@ START:
     cli             ; Enable interrupts
 
 
-        ;lda     #$81
-        ;sta     $4200   
+        ;;lda     #$01
+        ;;sta     $4200
 
 	rep     #$30
 	longa	on
@@ -136,7 +136,19 @@ START:
 
 	XDEF IRQ
 IRQ:	
-	XREF ~~IRQHandler
+    ;LONGA   ON
+    ;LONGI   ON
+    rep #$10
+    sep #$20
+    lda #65
+    sta $3000
+    rep #$30
+    ;LONGA   OFF
+    ;LONGI   OFF
+    rti
+
+
+    XREF ~~IRQHandler
 	LONGA	ON
 	LONGI	ON
 	rep	#$30
@@ -151,6 +163,11 @@ IRQ:
 	
 	XDEF	NMI
 NMI:
+    rep #$30
+    lda #66
+    sta $3000
+    sep     #$30    ; X,Y,A are 8 bit numbers
+    rti
 	XREF	~~NMIHandler
 	LONGA	ON
 	LONGI	ON

+ 19 - 6
snes/fatfstest/main.c

@@ -94,7 +94,9 @@ void preInit(void)
 
     // For testing purpose ... 
     // Insert code here to be executed before register init
-} DWORD get_fattime()
+}
+
+DWORD get_fattime()
 {
     time_t rawtime;
     struct tm *ptm;
@@ -184,19 +186,30 @@ void boot(DWORD addr)
     *(byte *) 0x2100 = 0x0f;    // enable background
 
     debug_enable();
-    printfc("SNES::main: Try to init disk\n");
-    put_rc(f_mount((BYTE) 0, &fatfs[0]));
-
+    printfc("SNES::main: init\n");
 #if 0
+    i = 0;
+    printfc("SNES::main: wait for irq\n");
     while(1){
         if (irq_triggered)
             handle_irq();
         if (nmi_triggered)
             handle_nmi();
+        /*
+        if (i++==30){
+          printfc("SNES::main: poll\n");
+          i=0;
+        }
+        waitForVBlank();
+        */
     }
 #endif
 
-#if 0
+    printfc("SNES::main: Try to init disk\n");
+    put_rc(f_mount((BYTE) 0, &fatfs[0]));
+
+
+#if 1
     printfs(0, "FATFS OPTIXX.ORG ");
     printfc("SNES::main: Try to get free\n");
     
@@ -236,7 +249,7 @@ void boot(DWORD addr)
 #if 0
     printfc("SNES::main: read dir\n");
     for (;;) {
-        res = f_readdir(&dir, &finfo);
+        res = f_readdir(&dir, &finfo);make
         if ((res != FR_OK) || !finfo.fname[0])
             break;
         if (finfo.fattrib & AM_DIR) {

+ 5 - 2
tools/bsnes/chip/cmmio/cmmio.cpp

@@ -28,19 +28,22 @@ uint8 CMMIO::mmio_read(unsigned addr) {
 
 void CMMIO::mmio_write(unsigned addr, uint8 data) {
   addr &= 0xffff;
-  //printf("CMMIO::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
   //fflush(stdout);
+  //printf("CMMIO::mmio_write 0x%04x 0x%02x (%i)\n",addr,data,data);
   /* debug to stderr */
   if (addr == 0x3000){
       fprintf(stderr,"%c",data);
       fflush(stderr);
+      
   }
+
+#if 0
   if (addr == 0x3001){
       fprintf(stderr,"Trigger IRQ\n");
       fflush(stderr);
       cpu.triggerIRQ();
   }
-
+#endif
 }
 
 CMMIO::CMMIO() {