o cleanup

o refactor debug function
o add ifeq platform to makefile
o get crc working on bank 0
This commit is contained in:
optixx
2009-04-26 11:00:02 +02:00
parent 4a083cbea3
commit 369667e154
10 changed files with 199 additions and 664 deletions

View File

@@ -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

View File

@@ -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

View File

View File

@@ -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

View File

@@ -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];
}

View File

@@ -1,2 +1,5 @@
void initDebugMap(void);
void debug(void);
void debug(void);
void int2hex(word i, char *buf);
void writeln(char* line,word y);
void enableDebugScreen(void);

View File

@@ -5,20 +5,18 @@
#include "ressource.h";
#include "PPU.h"
#include "debug.h"
#include "crc.h"
#include <stdlib.h>
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);
}

View File

@@ -1,3 +0,0 @@
#!/bin/sh
wine $*
exit 0