From 369667e154137d3eefa6c3474a30980a0a0baae2 Mon Sep 17 00:00:00 2001 From: optixx Date: Sun, 26 Apr 2009 11:00:02 +0200 Subject: [PATCH] o cleanup o refactor debug function o add ifeq platform to makefile o get crc working on bank 0 --- scripts/crc_xmodem.py | 4 +- snes/crc/Makefile | 38 +++-- snes/crc/TMPA264.TMP | 183 ----------------------- snes/crc/TMPA701.TMP | 0 snes/crc/TMPA737.TMP | 183 ----------------------- snes/crc/debug.c | 58 ++------ snes/crc/debug.h | 5 +- snes/crc/main.c | 56 +++---- snes/crc/wine.sh | 3 - snesram.tmproj | 333 +++++++++++++++++------------------------- 10 files changed, 199 insertions(+), 664 deletions(-) delete mode 100644 snes/crc/TMPA264.TMP delete mode 100644 snes/crc/TMPA701.TMP delete mode 100644 snes/crc/TMPA737.TMP delete mode 100755 snes/crc/wine.sh diff --git a/scripts/crc_xmodem.py b/scripts/crc_xmodem.py index 3e3ed73..af764bd 100644 --- a/scripts/crc_xmodem.py +++ b/scripts/crc_xmodem.py @@ -34,7 +34,7 @@ def test_performance(): def test_algo(): data='david' - data='d' + data='da' print "%x" % do_crc(data) @@ -60,7 +60,7 @@ def main(): #print result if __name__ == '__main__': - test_algo() + #test_algo() main() diff --git a/snes/crc/Makefile b/snes/crc/Makefile index 7108b66..1d21492 100644 --- a/snes/crc/Makefile +++ b/snes/crc/Makefile @@ -1,31 +1,25 @@ # SDK Config -# Linux Wine -SDK=/home/david/.wine/drive_c/65xx_FreeSDK -WINE=wine -EMU=zsnes -EMU_DEBUG=/home/david/Devel/arch/snes/tools/zsnes_linux_debug151/src/zsnesd -d +PLATFORM=mac -# OSX Crossover Office -SDK=/Users/david/.wine/drive_c/65xx_FreeSDK -CC=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDC816CC.exe -AS=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDC816AS.exe -LD=/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/bin/wineloader winewrapper.exe --wait-children --start -- C:/65xx_FreeSDK/bin/WDCLN.exe -EMU=zsnes +ifeq ($(PLATFORM),linux) + + # Linux Wine + SDK=/home/david/.wine/drive_c/65xx_FreeSDK + WINE=wine + EMU=zsnes + EMU_DEBUG=/home/david/Devel/arch/snes/tools/zsnes_linux_debug151/src/zsnesd -d +else + # Mac Wine + SDK=/Users/david/.wine/drive_c/65xx_FreeSDK + WINE=wine + EMU=zsnes +endif -# Mac Wine -SDK=/Users/david/.wine/drive_c/65xx_FreeSDK -WINE=wine -EMU=zsnes CC=$(WINE) $(SDK)/bin/WDC816CC.exe AS=$(WINE) $(SDK)/bin/WDC816AS.exe LD=$(WINE) $(SDK)/bin/WDCLN.exe - - - - - PADBIN=$(WINE) tools/padbin.exe PCX2SNES=$(WINE) tools/Pcx2Snes.exe @@ -33,7 +27,7 @@ PCX2SNES=$(WINE) tools/Pcx2Snes.exe INC=$(SDK)/include LIBS=$(SDK)/lib/cs #OBJS=StartupSnes.obj main.obj pad.obj event.obj myEvents.obj PPU.obj debug.obj ressource.obj -OBJS=StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj crc.obj +OBJS=StartupSnes.obj main.obj pad.obj PPU.obj debug.obj ressource.obj crc.obj APP=crc.smc GFX=kungfu debugfont @@ -51,6 +45,8 @@ upload: sync diskutil unmount /Volumes/SNES +crc: + python ../../scripts/crc_xmodem.py $(APP) kungfu: $(PCX2SNES) ressource/kungfu -n -c16 -screen diff --git a/snes/crc/TMPA264.TMP b/snes/crc/TMPA264.TMP deleted file mode 100644 index c9b19d6..0000000 --- a/snes/crc/TMPA264.TMP +++ /dev/null @@ -1,183 +0,0 @@ -;:ts=8 -R0 equ 1 -R1 equ 5 -R2 equ 9 -R3 equ 13 - code - xdef __initInternalRegisters - func -__initInternalRegisters: - longa on - longi on - tsc - sec - sbc #L2 - tcs - phd - tcd - stz |__characterLocation - stz |__characterLocation+2 - stz |__characterLocation+4 - stz |__characterLocation+6 - jsr __initDebugMap -L4: - pld - tsc - clc - adc #L2 - tcs - rts -L2 equ 0 -L3 equ 1 - ends - efunc - code - xdef __preInit - func -__preInit: - longa on - longi on - tsc - sec - sbc #L5 - tcs - phd - tcd -L7: - pld - tsc - clc - adc #L5 - tcs - rts -L5 equ 0 -L6 equ 1 - ends - efunc - code - xdef __main - func -__main: - longa on - longi on - tsc - sec - sbc #L8 - tcs - phd - tcd - jsr __initInternalRegisters - pea #<$0 - pea #<$0 - pea #<$1000 - jsr __setTileMapLocation - pea #<$0 - pea #<$2000 - jsr __setCharacterLocation - pea #<$100 - pea #<$0 - lda #<__title_pal - pha - jsr __CGRAMLoad - sep #$20 - longa off - lda #$1 - sta |8453 - rep #$20 - longa on - sep #$20 - longa off - lda #$1 - sta |8492 - rep #$20 - longa on - sep #$20 - longa off - lda #$0 - sta |8493 - rep #$20 - longa on - sep #$20 - longa off - lda #$f - sta |8448 - rep #$20 - longa on - stz |__currentScrollEvent - stz |__scrollValue - jsr __debug -L10001: - brl L10001 -L8 equ 0 -L9 equ 1 - ends - efunc - code - xdef __IRQHandler - func -__IRQHandler: - longa on - longi on - tsc - sec - sbc #L10 - tcs - phd - tcd -L12: - pld - tsc - clc - adc #L10 - tcs - rts -L10 equ 0 -L11 equ 1 - ends - efunc - code - xdef __NMIHandler - func -__NMIHandler: - longa on - longi on - tsc - sec - sbc #L13 - tcs - phd - tcd -L15: - pld - tsc - clc - adc #L13 - tcs - rts -L13 equ 0 -L14 equ 1 - ends - efunc - xref __debug - xref __initDebugMap - xref __CGRAMLoad - xref __setCharacterLocation - xref __setTileMapLocation - udata - xdef __scrollValue -__scrollValue - ds 2 - ends - udata - xdef __currentScrollEvent -__currentScrollEvent - ds 2 - ends - udata - xdef __pad1 -__pad1 - ds 2 - ends - xref __characterLocation - xref __title_pal - end diff --git a/snes/crc/TMPA701.TMP b/snes/crc/TMPA701.TMP deleted file mode 100644 index e69de29..0000000 diff --git a/snes/crc/TMPA737.TMP b/snes/crc/TMPA737.TMP deleted file mode 100644 index c9b19d6..0000000 --- a/snes/crc/TMPA737.TMP +++ /dev/null @@ -1,183 +0,0 @@ -;:ts=8 -R0 equ 1 -R1 equ 5 -R2 equ 9 -R3 equ 13 - code - xdef __initInternalRegisters - func -__initInternalRegisters: - longa on - longi on - tsc - sec - sbc #L2 - tcs - phd - tcd - stz |__characterLocation - stz |__characterLocation+2 - stz |__characterLocation+4 - stz |__characterLocation+6 - jsr __initDebugMap -L4: - pld - tsc - clc - adc #L2 - tcs - rts -L2 equ 0 -L3 equ 1 - ends - efunc - code - xdef __preInit - func -__preInit: - longa on - longi on - tsc - sec - sbc #L5 - tcs - phd - tcd -L7: - pld - tsc - clc - adc #L5 - tcs - rts -L5 equ 0 -L6 equ 1 - ends - efunc - code - xdef __main - func -__main: - longa on - longi on - tsc - sec - sbc #L8 - tcs - phd - tcd - jsr __initInternalRegisters - pea #<$0 - pea #<$0 - pea #<$1000 - jsr __setTileMapLocation - pea #<$0 - pea #<$2000 - jsr __setCharacterLocation - pea #<$100 - pea #<$0 - lda #<__title_pal - pha - jsr __CGRAMLoad - sep #$20 - longa off - lda #$1 - sta |8453 - rep #$20 - longa on - sep #$20 - longa off - lda #$1 - sta |8492 - rep #$20 - longa on - sep #$20 - longa off - lda #$0 - sta |8493 - rep #$20 - longa on - sep #$20 - longa off - lda #$f - sta |8448 - rep #$20 - longa on - stz |__currentScrollEvent - stz |__scrollValue - jsr __debug -L10001: - brl L10001 -L8 equ 0 -L9 equ 1 - ends - efunc - code - xdef __IRQHandler - func -__IRQHandler: - longa on - longi on - tsc - sec - sbc #L10 - tcs - phd - tcd -L12: - pld - tsc - clc - adc #L10 - tcs - rts -L10 equ 0 -L11 equ 1 - ends - efunc - code - xdef __NMIHandler - func -__NMIHandler: - longa on - longi on - tsc - sec - sbc #L13 - tcs - phd - tcd -L15: - pld - tsc - clc - adc #L13 - tcs - rts -L13 equ 0 -L14 equ 1 - ends - efunc - xref __debug - xref __initDebugMap - xref __CGRAMLoad - xref __setCharacterLocation - xref __setTileMapLocation - udata - xdef __scrollValue -__scrollValue - ds 2 - ends - udata - xdef __currentScrollEvent -__currentScrollEvent - ds 2 - ends - udata - xdef __pad1 -__pad1 - ds 2 - ends - xref __characterLocation - xref __title_pal - end diff --git a/snes/crc/debug.c b/snes/crc/debug.c index 1aa1f7b..f204fff 100644 --- a/snes/crc/debug.c +++ b/snes/crc/debug.c @@ -5,7 +5,6 @@ #include "crc.h" word debugMap[0x400]; - void initDebugMap(void) { word i; for(i=0; i<0x400; i++) { @@ -13,7 +12,6 @@ void initDebugMap(void) { } } - void int2hex(word i, char *buf) { word a; @@ -27,54 +25,20 @@ void int2hex(word i, char *buf) buf[a] = 0; } -void debug(void) { - word i,j; - word crc01; - word crc02; - padStatus pad1; - char line_header[32] = "BANK CRC ADDR 123456789ABCDEF"; - char line[32] = " "; - char test_buffer[] = "da"; - void *pointer; - +void writeln(char *buffer,word y){ + char i; + waitForVBlank(); + for(i=0; i<32; i++) { + waitForVBlank(); + VRAMByteWrite((byte) (buffer[i]-32), (word) (0x4000+i+(y*0x20))); + } +} + +void enableDebugScreen(void){ VRAMLoad((word) debugFont_pic, 0x5000, 2048); CGRAMLoad((word) debugFont_pal, (byte) 0x00, (word) 16); VRAMLoad((word) debugMap, 0x4000, 0x0800); setTileMapLocation(0x4000, (byte) 0x00, (byte) 0); setCharacterLocation(0x5000, (byte) 0); *(byte*) 0x2100 = 0x0f; // enable background - - j=0; - waitForVBlank(); - for(i=0; i<32; i++) { - waitForVBlank(); - VRAMByteWrite((byte) (line_header[i]-32), (word) (0x4000+i+(j*0x20))); - } - - while(1){ - pointer = (void*)0x8000; - crc02 = crc_update(test_buffer,2); - //crc01 = crc_update(pointer,255); - for(j=0; j<8; j++) { - crc01 = crc_update(pointer,0x8000); - int2hex(j,&line[0]); - int2hex(crc01,&line[5]); - int2hex((word)pointer,&line[10]); - waitForVBlank(); - for(i=0; i<32; i++) { - waitForVBlank(); - VRAMByteWrite((byte) (line[i]-32), (word) (0x4000+i+((j+1)*0x20))); - } - //pointer+=0x010000; - } - while(!pad1.start) { - waitForVBlank(); - pad1 = readPad((byte) 0); - } - } - -} - -#pragma section CODE=BANK3,offset $3:0000 -char far dummy[128]; - +} \ No newline at end of file diff --git a/snes/crc/debug.h b/snes/crc/debug.h index c2f9c83..2580ade 100644 --- a/snes/crc/debug.h +++ b/snes/crc/debug.h @@ -1,2 +1,5 @@ void initDebugMap(void); -void debug(void); \ No newline at end of file +void debug(void); +void int2hex(word i, char *buf); +void writeln(char* line,word y); +void enableDebugScreen(void); \ No newline at end of file diff --git a/snes/crc/main.c b/snes/crc/main.c index 4cc3c22..2d99cd3 100644 --- a/snes/crc/main.c +++ b/snes/crc/main.c @@ -5,20 +5,18 @@ #include "ressource.h"; #include "PPU.h" #include "debug.h" +#include "crc.h" + #include padStatus pad1; -event *currentScrollEvent; -word scrollValue; - void initInternalRegisters(void) { characterLocation[0] = 0x0000; characterLocation[1] = 0x0000; characterLocation[2] = 0x0000; characterLocation[3] = 0x0000; - initDebugMap(); } @@ -28,38 +26,42 @@ void preInit(void) { } void main(void) { + word i,j; + word crc01; + word crc02; + padStatus pad1; + char line_header[32] = "BANK CRC 123456789ABCDEF"; + char line[32] = " "; + char test_buffer[] = "da"; + char *pointer; initInternalRegisters(); - // Screen map data @ VRAM location $1000 - setTileMapLocation(0x1000, (byte) 0x00, (byte) 0); - //*(byte*) 0x2107 = 0x10; - - // Plane 0 Tile graphics @ $2000 - setCharacterLocation(0x2000, (byte) 0); - //*(byte*) 0x210b = 0x02; - - //VRAMLoad((word) title_pic, 0x2000, 0x1BE0); - //VRAMLoad((word) title_map, 0x1000, 0x0800); - CGRAMLoad((word) title_pal, (byte) 0x00, (word) 256); - - // TODO sitwch to mode 0 for trying *(byte*) 0x2105 = 0x01; // MODE 1 value - *(byte*) 0x212c = 0x01; // Plane 0 (bit one) enable register *(byte*) 0x212d = 0x00; // All subPlane disable - *(byte*) 0x2100 = 0x0f; // enable background - currentScrollEvent = NULL; - scrollValue = 0; + enableDebugScreen(); - //initEvents(); - //enablePad(); - debug(); - //addEvent(&NMIReadPad, 1); - - // Loop forever + writeln(line_header,0); + + while(1){ + pointer = (void*)0x8000; + crc02 = crc_update(test_buffer,2); + //crc01 = crc_update(pointer,255); + for(j=0; j<8; j++) { + crc01 = crc_update(pointer,0x8000); + int2hex(j,&line[0]); + int2hex(crc01,&line[5]); + //int2hex((word)pointer,&line[10]); + writeln(line,j+1); + } + while(!pad1.start) { + waitForVBlank(); + pad1 = readPad((byte) 0); + } + } while(1); } diff --git a/snes/crc/wine.sh b/snes/crc/wine.sh deleted file mode 100755 index a3a05ac..0000000 --- a/snes/crc/wine.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -wine $* -exit 0 diff --git a/snesram.tmproj b/snesram.tmproj index e81a9a5..221b8ce 100644 --- a/snesram.tmproj +++ b/snesram.tmproj @@ -3,7 +3,7 @@ currentDocument - poc/avr_sdcard/main.c + poc/avr_sdcard/mmc.c documents @@ -21,70 +21,14 @@ 200 metaData - bsnes/cpu/cpu.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - - bsnes/cpu/cpu.hpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 23 - - bsnes/cpu/scpu/scpu.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 10 - - bsnes/cpu/scpu/timing/timing.cpp - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - poc/avr_sdcard/fat.c caret column - 3 + 9 line - 281 + 307 firstVisibleColumn 0 @@ -110,9 +54,9 @@ caret column - 9 + 0 line - 62 + 0 firstVisibleColumn 0 @@ -124,14 +68,14 @@ caret column - 0 + 23 line - 0 + 38 firstVisibleColumn 0 firstVisibleLine - 0 + 4 poc/avr_sdcard/mmc.h @@ -166,9 +110,9 @@ caret column - 7 + 4 line - 24 + 23 firstVisibleColumn 0 @@ -189,64 +133,6 @@ firstVisibleLine 0 - scripts/rom.py - - caret - - column - 25 - line - 144 - - firstVisibleColumn - 0 - firstVisibleLine - 140 - - snes/ascii/header.inc - - caret - - column - 13 - line - 55 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 14 - selectFrom - - column - 12 - line - 55 - - selectTo - - column - 13 - line - 55 - - - snes/ascii/main.asm - - caret - - column - 0 - line - 8 - - firstVisibleColumn - 0 - firstVisibleLine - 0 - snes/banktest/LoadGraphics.asm caret @@ -303,37 +189,7 @@ firstVisibleLine 43 - snes/simpletest/sprite.asm - - caret - - column - 0 - line - 166 - - columnSelection - - firstVisibleColumn - 0 - firstVisibleLine - 158 - selectFrom - - column - 0 - line - 162 - - selectTo - - column - 0 - line - 166 - - - zsnes/docs/README.LINUX + snes/crc/PPU.c caret @@ -347,7 +203,7 @@ firstVisibleLine 0 - zsnes/docs/README.SVN + snes/crc/PPU.h caret @@ -361,7 +217,21 @@ firstVisibleLine 0 - zsnes/docs/authors.txt + snes/crc/crc.c + + caret + + column + 22 + line + 10 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/crc/crc.h caret @@ -375,21 +245,7 @@ firstVisibleLine 0 - zsnes/docs/install.txt - - caret - - column - 0 - line - 0 - - firstVisibleColumn - 0 - firstVisibleLine - 132 - - zsnes/docs/license.txt + snes/crc/data.h caret @@ -403,7 +259,21 @@ firstVisibleLine 0 - zsnes/docs/opengl.txt + snes/crc/debug.c + + caret + + column + 2 + line + 48 + + firstVisibleColumn + 0 + firstVisibleLine + 22 + + snes/crc/debug.h caret @@ -417,21 +287,49 @@ firstVisibleLine 0 - zsnes/src/chips/dsp4emu.c + snes/crc/event.c caret column 0 line - 0 + 24 firstVisibleColumn 0 firstVisibleLine - 113 + 2 - zsnes/src/chips/seta10.c + snes/crc/main.c + + caret + + column + 17 + line + 54 + + firstVisibleColumn + 0 + firstVisibleLine + 20 + + snes/crc/pad.c + + caret + + column + 35 + line + 8 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + snes/crc/rom.map caret @@ -443,31 +341,26 @@ firstVisibleColumn 0 firstVisibleLine - 453 + 11 openDocuments - snes/simpletest/sprite.asm - snes/ascii/main.asm - snes/ascii/header.inc - scripts/rom.py - poc/avr_sdcard/main.c - scripts/crc_xmodem.py - bsnes/cpu/cpu.cpp - bsnes/cpu/cpu.hpp - bsnes/cpu/scpu/scpu.cpp - bsnes/cpu/scpu/timing/timing.cpp + snes/crc/debug.h + snes/crc/debug.c + snes/crc/rom.map scripts/b.py - snes/banktest/vram2.asm - poc/avr_sdcard/mmc.h - snes/banktest/header.inc - snes/banktest/init.inc - snes/banktest/LoadGraphics.asm - poc/avr_sdcard/fat.h poc/avr_sdcard/fat.c - poc/avr_sdcard/uart.c + snes/crc/PPU.h + snes/crc/PPU.c + snes/crc/data.h + snes/crc/crc.h + snes/crc/crc.c + snes/crc/event.c + snes/crc/main.c poc/avr_sdcard/mmc.c + poc/avr_sdcard/main.c + snes/crc/pad.c showFileHierarchyDrawer @@ -480,10 +373,56 @@ isExpanded subItems - + + poc + + isExpanded + + subItems + + avr_sdcard + + isExpanded + + subItems + + + + + scripts + + isExpanded + + subItems + + + snes + + isExpanded + + subItems + + crc + + isExpanded + + subItems + + tools + + isExpanded + + subItems + + + + + + + windowFrame - {{2, 60}, {738, 818}} + {{4, 60}, {738, 818}}