From 5dd4904f9c2af60b12159dd900cc36daf712f68f Mon Sep 17 00:00:00 2001 From: David Voswinkel Date: Wed, 20 May 2009 00:16:30 +0200 Subject: [PATCH] o add mmio to trigger cart irq o add snes irq handlers o add inline printf asm --- snes/irqtest/debug.asm | 30 ++- snes/irqtest/header.inc | 20 +- snes/irqtest/irqtest.asm | 46 ++-- snesram.tmproj | 387 ++++++++++--------------------- tools/bsnes/chip/cmmio/cmmio.cpp | 6 + tools/bsnes/cpu/scpu/scpu.cpp | 4 + tools/bsnes/cpu/scpu/scpu.hpp | 5 +- 7 files changed, 199 insertions(+), 299 deletions(-) diff --git a/snes/irqtest/debug.asm b/snes/irqtest/debug.asm index 7dc67b2..6f2d6cf 100644 --- a/snes/irqtest/debug.asm +++ b/snes/irqtest/debug.asm @@ -1,22 +1,34 @@ -.define debug_pointer $0080 +.define debug_pointer $080 -.MACRO printf - ldy.w #\1 ; load add of the string +.MACRO printdb + ldy.w #\1 ; load addr of the marco arg string sty.w debug_pointer ; store address in defined mem area - ldy #0 ; zero y + ldy #0 ; zero y index jsr do_printf .ENDM +.MACRO prints + + ldy.w #++ ; load addr of the marco arg string + sty.w debug_pointer ; store address in defined mem area + ldy #0 ; zero y index + jsr do_printf + jmp +++ +++: + .db \1,10,0 ++++: + +.ENDM .BANK 0 .SECTION "debug" SEMIFREE do_printf: - lda (debug_pointer),y ; get address of string - sta $3000 ; write to MMIO debug reg - iny - cmp #0 ; len 5 - bne do_printf + lda (debug_pointer),y ; get address of string via indirect mem area + sta $3000 ; write to MMIO debug reg + iny ; inc index + cmp #0 ; look for null byte + bne do_printf rts .ENDs diff --git a/snes/irqtest/header.inc b/snes/irqtest/header.inc index b2482a1..172047f 100644 --- a/snes/irqtest/header.inc +++ b/snes/irqtest/header.inc @@ -34,19 +34,19 @@ .ENDSNES .SNESNATIVEVECTOR ; Define Native Mode interrupt vector table - COP EmptyHandler - BRK EmptyHandler - ABORT EmptyHandler - NMI EmptyHandler - IRQ EmptyHandler + COP COPHandler + BRK BRKHandler + ABORT ABRTHandler + NMI NMIHandler + IRQ IRQHandler .ENDNATIVEVECTOR .SNESEMUVECTOR ; Define Emulation Mode interrupt vector table - COP EmptyHandler - ABORT EmptyHandler - NMI EmptyHandler - RESET Start - IRQBRK EmptyHandler + COP EmptyHandler + ABORT EmptyHandler + NMI EmptyHandler + RESET Start + IRQBRK EmptyHandler .ENDEMUVECTOR .BANK 0 SLOT 0 ; Defines the ROM bank and the slot it is inserted in memory. diff --git a/snes/irqtest/irqtest.asm b/snes/irqtest/irqtest.asm index ba8ed8e..dc3603e 100644 --- a/snes/irqtest/irqtest.asm +++ b/snes/irqtest/irqtest.asm @@ -45,23 +45,17 @@ Start_do: ; Setup Video modes and other stuff, then turn on the screen jsr SetupVideo + + sei + cop + prints "Init done" + stz $3001 - lda #65 - sta $3000 - lda #66 - sta $3000 - lda #67 - sta $3000 - - printf str_COP - - lda #65 - sta $3000 - lda #66 - sta $3000 - lda #67 - sta $3000 + cop + lda #$81 + sta $4200 + Infinity: jmp Infinity ; bwa hahahahaha @@ -98,6 +92,28 @@ SetupVideo: plp rts +;.ENDS + +;.SECTION "IRQHandlers" + +COPHandler: + prints "COPHandler" + rti + +BRKHandler: + prints "BRKHandler" + rti +ABRTHandler: + prints "ABRTHandler" + rti +NMIHandler: + ;prints "NMIHandler" + rti + +IRQHandler: + prints "IRQHandler" + rti + str_COP: .db "COP",10,0 diff --git a/snesram.tmproj b/snesram.tmproj index 8f8d7a9..10cd867 100644 --- a/snesram.tmproj +++ b/snesram.tmproj @@ -3,7 +3,7 @@ currentDocument - tools/bsnes/ppu/bppu/bppu_mmio.cpp + snes/irqtest/debug.asm documents @@ -63,20 +63,6 @@ firstVisibleLine 0 - snes/banktest/header.inc - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - snes/banktest/init.inc caret @@ -91,21 +77,79 @@ firstVisibleLine 211 - snes/banktest/vram2.asm + snes/irqtest/LoadGraphics.asm caret column 0 line - 91 + 45 firstVisibleColumn 0 firstVisibleLine - 43 + 0 - snes/mmio/data.h + snes/irqtest/debug.asm + + caret + + column + 0 + line + 22 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/irqtest/header.inc + + caret + + column + 0 + line + 36 + + firstVisibleColumn + 0 + firstVisibleLine + 9 + + snes/irqtest/init.inc + + caret + + column + 0 + line + 248 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 211 + selectFrom + + column + 0 + line + 246 + + selectTo + + column + 0 + line + 248 + + + snes/irqtest/intro.asm caret @@ -119,47 +163,19 @@ firstVisibleLine 0 - snes/mmio/debug.c + snes/irqtest/irqtest.asm caret column 0 line - 4 + 67 firstVisibleColumn 0 firstVisibleLine - 0 - - snes/mmio/debug.h - - caret - - column - 10 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - snes/mmio/main.c - - caret - - column - 0 - line - 7 - - firstVisibleColumn - 0 - firstVisibleLine - 5 + 49 tools/bsnes/cart/cart.cpp @@ -189,149 +205,67 @@ firstVisibleLine 24 - tools/bsnes/cc.sh + tools/bsnes/chip/cmmio/cmmio.cpp caret column - 0 + 1 line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/bsnes/memory/memory.cpp - - caret - - column - 4 - line - 37 - - firstVisibleColumn - 0 - firstVisibleLine - 4 - - tools/bsnes/memory/memory.hpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/bsnes/memory/smemory/mapper/chip.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/bsnes/memory/smemory/mapper/generic.cpp - - caret - - column - 42 - line - 93 - - firstVisibleColumn - 0 - firstVisibleLine - 39 - - tools/bsnes/memory/smemory/mapper/system.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/bsnes/memory/smemory/smemory.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - tools/bsnes/ppu/bppu/bppu.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 67 - - tools/bsnes/ppu/bppu/bppu.hpp - - caret - - column - 13 - line - 166 + 17 columnSelection firstVisibleColumn 0 firstVisibleLine - 134 + 0 selectFrom column - 9 + 0 line - 166 + 17 selectTo column - 13 + 1 line - 166 + 17 - tools/bsnes/ppu/bppu/bppu_mmio.cpp + tools/bsnes/cpu/scpu/memory/memory.cpp + + caret + + column + 1 + line + 56 + + columnSelection + + firstVisibleColumn + 0 + firstVisibleLine + 56 + selectFrom + + column + 0 + line + 56 + + selectTo + + column + 2 + line + 56 + + + tools/bsnes/cpu/scpu/memory/memory.hpp caret @@ -343,30 +277,30 @@ firstVisibleColumn 0 firstVisibleLine - 220 + 0 - tools/bsnes/ppu/bppu/bppu_render_mode7.cpp + tools/bsnes/cpu/scpu/mmio/mmio.cpp caret column - 32 + 0 line - 33 + 485 firstVisibleColumn 0 firstVisibleLine - 0 + 459 - tools/bsnes/ppu/ppu.cpp + tools/bsnes/memory/memory.cpp caret column - 0 + 6 line - 0 + 22 firstVisibleColumn 0 @@ -376,94 +310,21 @@ openDocuments + snes/irqtest/debug.asm + tools/bsnes/cpu/scpu/mmio/mmio.cpp + tools/bsnes/chip/cmmio/cmmio.cpp + tools/bsnes/cpu/scpu/memory/memory.cpp tools/bsnes/memory/memory.cpp - tools/bsnes/ppu/ppu.cpp - tools/bsnes/ppu/bppu/bppu.cpp - tools/bsnes/ppu/bppu/bppu_mmio.cpp - tools/bsnes/ppu/bppu/bppu.hpp - tools/bsnes/ppu/bppu/bppu_render_mode7.cpp - tools/bsnes/cc.sh - snes/mmio/main.c - snes/mmio/data.h - snes/mmio/debug.h - snes/mmio/debug.c - tools/bsnes/memory/memory.hpp + tools/bsnes/cpu/scpu/memory/memory.hpp + snes/irqtest/irqtest.asm + snes/irqtest/intro.asm + snes/irqtest/LoadGraphics.asm + snes/irqtest/init.inc + snes/irqtest/header.inc showFileHierarchyDrawer - showFileHierarchyPanel - - treeState - - snesram - - isExpanded - - subItems - - snes - - isExpanded - - subItems - - - tools - - isExpanded - - subItems - - bsnes - - isExpanded - - subItems - - lib - - isExpanded - - subItems - - - memory - - isExpanded - - subItems - - - ppu - - isExpanded - - subItems - - bppu - - isExpanded - - subItems - - - - - ui_qt - - isExpanded - - subItems - - - - - - - - - windowFrame - {{0, 58}, {720, 820}} + {{0, 59}, {895, 819}} diff --git a/tools/bsnes/chip/cmmio/cmmio.cpp b/tools/bsnes/chip/cmmio/cmmio.cpp index a71485b..6a1c791 100644 --- a/tools/bsnes/chip/cmmio/cmmio.cpp +++ b/tools/bsnes/chip/cmmio/cmmio.cpp @@ -35,6 +35,12 @@ void CMMIO::mmio_write(unsigned addr, uint8 data) { fprintf(stderr,"%c",data); fflush(stderr); } + if (addr == 0x3001){ + fprintf(stderr,"Trigger IRQ\n"); + fflush(stderr); + cpu.triggerIRQ(); + } + } CMMIO::CMMIO() { diff --git a/tools/bsnes/cpu/scpu/scpu.cpp b/tools/bsnes/cpu/scpu/scpu.cpp index 2927cd5..42ef6b6 100755 --- a/tools/bsnes/cpu/scpu/scpu.cpp +++ b/tools/bsnes/cpu/scpu/scpu.cpp @@ -23,6 +23,10 @@ void sCPU::power() { reset(); } +void sCPU::triggerIRQ() { + status.irq_pending = true; +} + void sCPU::reset() { CPU::reset(); diff --git a/tools/bsnes/cpu/scpu/scpu.hpp b/tools/bsnes/cpu/scpu/scpu.hpp index 3be415f..9c32a0f 100755 --- a/tools/bsnes/cpu/scpu/scpu.hpp +++ b/tools/bsnes/cpu/scpu/scpu.hpp @@ -1,4 +1,4 @@ -class sCPU : public CPU { +class sCPU : public CPU { public: void enter(); @@ -47,7 +47,7 @@ public: bool hdma_mode; //0 = init, 1 = run DmaState dma_state; - //MMIO + //MMIO //$2181-$2183 uint32 wram_addr; @@ -88,6 +88,7 @@ public: void power(); void reset(); + void triggerIRQ(); sCPU(); ~sCPU();