This commit is contained in:
parent
5d10a37920
commit
046bdf0530
7 changed files with 775 additions and 8 deletions
|
@ -85,7 +85,8 @@ system_src := main \
|
||||||
vid \
|
vid \
|
||||||
dbg \
|
dbg \
|
||||||
vsprintf \
|
vsprintf \
|
||||||
clickcount
|
clickcount \
|
||||||
|
except
|
||||||
|
|
||||||
utils_src := utils \
|
utils_src := utils \
|
||||||
sincos
|
sincos
|
||||||
|
@ -94,7 +95,8 @@ utils_src_mip := quatmip \
|
||||||
mathmip \
|
mathmip \
|
||||||
replace
|
replace
|
||||||
|
|
||||||
system_src_mip := gp \
|
system_src_mip := except_a \
|
||||||
|
gp \
|
||||||
lnkopt \
|
lnkopt \
|
||||||
$(VERSION)/$(TERRITORY)/$(FILE_SYSTEM)/info
|
$(VERSION)/$(TERRITORY)/$(FILE_SYSTEM)/info
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ cleaningamefx :
|
||||||
ingamefx: $(INGAMEFX_GFX_TEX_IN)
|
ingamefx: $(INGAMEFX_GFX_TEX_IN)
|
||||||
|
|
||||||
$(INGAMEFX_GFX_TEX_OUT) : $(INGAMEFX_GFX_TEX_IN)
|
$(INGAMEFX_GFX_TEX_OUT) : $(INGAMEFX_GFX_TEX_IN)
|
||||||
@parkgrab -c+ -z+ ${INGAMEFX_GFX_TRANS_IN} -c+ -z- ${INGAMEFX_GFX_NONTRANS_IN} -b+ -t:9,4,1 -l:$(REPORT_DIR)/ingamefx.lbm -o:$(INGAMEFX_GFX_TEX_OUT) -k:$(INGAMEFX_GFX_REP_FILE)
|
@parkgrab -c+ -z+ ${INGAMEFX_GFX_TRANS_IN} -c+ -z- ${INGAMEFX_GFX_NONTRANS_IN} -b+ -t:8,4,1 -l:$(REPORT_DIR)/ingamefx.lbm -o:$(INGAMEFX_GFX_TEX_OUT) -k:$(INGAMEFX_GFX_REP_FILE)
|
||||||
@$(MV) -f $(INGAMEFX_GFX_OUT_DIR)/ingamefx.h $(INGAMEFX_GFX_HDR_FILE)
|
@$(MV) -f $(INGAMEFX_GFX_OUT_DIR)/ingamefx.h $(INGAMEFX_GFX_HDR_FILE)
|
||||||
|
|
||||||
GRAF_DIRS_TO_MAKE += $(INGAMEFX_GFX_OUT_DIR)
|
GRAF_DIRS_TO_MAKE += $(INGAMEFX_GFX_OUT_DIR)
|
||||||
|
|
442
source/system/except.cpp
Normal file
442
source/system/except.cpp
Normal file
|
@ -0,0 +1,442 @@
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <libetc.h>
|
||||||
|
#include <libgte.h>
|
||||||
|
#include <libgpu.h>
|
||||||
|
#include "system\global.h"
|
||||||
|
#include "except.h"
|
||||||
|
#include "pad\pads.h"
|
||||||
|
|
||||||
|
#define NTSC_PAL 1
|
||||||
|
|
||||||
|
enum {
|
||||||
|
OFS_AT,OFS_V0,OFS_V1,OFS_A0,OFS_A1,OFS_A2,OFS_A3,OFS_T0,OFS_T1,OFS_T2,OFS_T3,
|
||||||
|
OFS_T4,OFS_T5,OFS_T6,OFS_T7,OFS_S0,OFS_S1,OFS_S2,OFS_S3,OFS_S4,OFS_S5,OFS_S6,
|
||||||
|
OFS_S7,OFS_T8,OFS_T9,OFS_GP,OFS_SP,OFS_FP,OFS_RA,OFS_HI,OFS_LO,OFS_SR,OFS_CA,
|
||||||
|
OFS_EPC};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
DRAWENV draw;
|
||||||
|
DISPENV disp;
|
||||||
|
} EXC_DB;
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
PAGE_REGS,
|
||||||
|
PAGE_DUMP,
|
||||||
|
PAGE_VALUES,
|
||||||
|
|
||||||
|
NUM_PAGES
|
||||||
|
};
|
||||||
|
|
||||||
|
static void exc_swap(void);
|
||||||
|
static void print_adr(int *adr);
|
||||||
|
|
||||||
|
static void cls();
|
||||||
|
static void print(char *_string);
|
||||||
|
|
||||||
|
static void displayTitle();
|
||||||
|
static void displayCause();
|
||||||
|
static void displayRegs();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static EXC_DB exc_db[2];
|
||||||
|
static int padWait;
|
||||||
|
int number=0;
|
||||||
|
static int mem_size;
|
||||||
|
static int exc_id;
|
||||||
|
|
||||||
|
static char *exc_txt[]={
|
||||||
|
"external interrupt",
|
||||||
|
"tlb modification exception",
|
||||||
|
"tlb miss (load or fetch)",
|
||||||
|
"tlb miss (store)",
|
||||||
|
"address error (load or fetch)",
|
||||||
|
"address error (store)",
|
||||||
|
"bus error (fetch)",
|
||||||
|
"bus error (load or store)",
|
||||||
|
"syscall",
|
||||||
|
"break",
|
||||||
|
"reserved instruction",
|
||||||
|
"coprocessor unusable",
|
||||||
|
"arithmetic overflow",
|
||||||
|
"unknown exception",
|
||||||
|
"unknown exception",
|
||||||
|
"unknown exception"};
|
||||||
|
|
||||||
|
static char *break_txt[]={
|
||||||
|
"6 (overflow)",
|
||||||
|
"7 (div by zero)"};
|
||||||
|
|
||||||
|
static char str_reg[1200];
|
||||||
|
static char str_dump[1200];
|
||||||
|
static char *p_sr;
|
||||||
|
static char *p_sd;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int currentPage=PAGE_REGS;
|
||||||
|
|
||||||
|
#include "gfx\font.h"
|
||||||
|
FontBank *excFont;
|
||||||
|
extern void installExceptionHandler()
|
||||||
|
{
|
||||||
|
install_exc();
|
||||||
|
excFont=new ("ExcFont") FontBank();
|
||||||
|
excFont->initialise( &standardFont );
|
||||||
|
excFont->setColour( 255, 255 , 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* --------------------------------- exc_c ---------------------------------- */
|
||||||
|
extern void exc_c(void) {
|
||||||
|
|
||||||
|
int i,*p_exc,*cur_exc,*p_sp,*cur_sp;//,pad;
|
||||||
|
|
||||||
|
ResetCallback();
|
||||||
|
ResetGraph(0);
|
||||||
|
PadInit(0);
|
||||||
|
SetGraphDebug(0);
|
||||||
|
SetVideoMode(NTSC_PAL==0 ? MODE_NTSC: MODE_PAL);
|
||||||
|
SetDispMask(1);
|
||||||
|
|
||||||
|
FntLoad(640,0);
|
||||||
|
SetDumpFnt(FntOpen(8,8,320-8,240-8,0,1024));
|
||||||
|
|
||||||
|
SetDefDispEnv(&exc_db[0].disp, 0, 0,512,256);
|
||||||
|
SetDefDrawEnv(&exc_db[0].draw, 0,256,512,256);
|
||||||
|
SetDefDispEnv(&exc_db[1].disp, 0,256,512,256);
|
||||||
|
SetDefDrawEnv(&exc_db[1].draw, 0, 0,512,256);
|
||||||
|
|
||||||
|
exc_db[0].draw.isbg=exc_db[1].draw.isbg=1;
|
||||||
|
exc_db[0].disp.screen.x=exc_db[1].disp.screen.x=4;
|
||||||
|
exc_db[0].disp.screen.y=exc_db[1].disp.screen.y=24;
|
||||||
|
setRGB0(&exc_db[0].draw,104,0,0);
|
||||||
|
setRGB0(&exc_db[1].draw,104,0,0);
|
||||||
|
|
||||||
|
if(dev_kit==1)
|
||||||
|
mem_size=0x800000;
|
||||||
|
else
|
||||||
|
mem_size=0x200000;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*---- cause ----*/
|
||||||
|
/*
|
||||||
|
p_sr=str_reg;
|
||||||
|
|
||||||
|
p_exc=(int *)reg_lst[OFS_EPC];
|
||||||
|
|
||||||
|
p_sr+=sprintf(p_sr," %s",exc_txt[reg_lst[OFS_CA]>>2&0x1f]);
|
||||||
|
|
||||||
|
if((reg_lst[OFS_CA]>>2&0x1f)==9) {
|
||||||
|
i=(*p_exc>>16)-6;
|
||||||
|
if(i==0||i==1)
|
||||||
|
p_sr+=sprintf(p_sr," %s",break_txt[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
p_sr+=sprintf(p_sr,"\n at %08x",(int)p_exc);
|
||||||
|
|
||||||
|
if((reg_lst[OFS_CA]&0x80000000)==0x80000000)
|
||||||
|
p_sr+=sprintf(p_sr," in branch delay slot\n\n");
|
||||||
|
else
|
||||||
|
p_sr+=sprintf(p_sr,"\n\n");
|
||||||
|
|
||||||
|
*/
|
||||||
|
/*---- mem-dump ----*/
|
||||||
|
/*
|
||||||
|
#define NR_DUMP 9
|
||||||
|
|
||||||
|
exc_id=1;
|
||||||
|
|
||||||
|
p_sp=(int *)reg_lst[OFS_SP];
|
||||||
|
cur_sp=p_sp+(NR_DUMP-1);
|
||||||
|
cur_exc=p_exc+(-NR_DUMP/2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
padWait=100;
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
|
||||||
|
while(DrawSync(1));
|
||||||
|
// DrawSync(0);
|
||||||
|
// while(DrawSync(1));
|
||||||
|
VSync(0);
|
||||||
|
exc_id=exc_id? 0: 1;
|
||||||
|
exc_swap();
|
||||||
|
cls();
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(padWait>0)
|
||||||
|
{
|
||||||
|
padWait--;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int pad=PadRead(1);
|
||||||
|
if(pad&PADRup)currentPage=PAGE_REGS;
|
||||||
|
if(pad&PADRdown)currentPage=PAGE_DUMP;
|
||||||
|
if(pad&PADRleft)currentPage=PAGE_VALUES;
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
// PadUpdate();
|
||||||
|
/*
|
||||||
|
if(wait_pad==0) {
|
||||||
|
pad=PadRead(1);
|
||||||
|
|
||||||
|
if(pad&PADRdown&&++currentPage==NUM_PAGES)currentPage=0;
|
||||||
|
|
||||||
|
#define STEP_MEM 256
|
||||||
|
|
||||||
|
if(pad&PADL1) cur_exc+=STEP_MEM;
|
||||||
|
if(pad&PADL2) cur_exc-=STEP_MEM;
|
||||||
|
if(pad&PADLup) cur_exc--;
|
||||||
|
if(pad&PADLdown) cur_exc++;
|
||||||
|
if(pad&PADR1) cur_sp-=STEP_MEM;
|
||||||
|
if(pad&PADR2) cur_sp+=STEP_MEM;
|
||||||
|
if(pad&PADRup) cur_sp++;
|
||||||
|
if(pad&PADRdown) cur_sp--;
|
||||||
|
|
||||||
|
if(pad&PADstart) {
|
||||||
|
cur_sp=p_sp+(NR_DUMP-1);
|
||||||
|
cur_exc=p_exc+(-NR_DUMP/2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
wait_pad--;
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
p_sd=str_dump;
|
||||||
|
|
||||||
|
p_sd+=sprintf(p_sd,"\n pc: stack:\n\n");
|
||||||
|
for(i=0;i<NR_DUMP;i++) {
|
||||||
|
// pc-dump
|
||||||
|
if(cur_exc+i==p_exc)
|
||||||
|
p_sd+=sprintf(p_sd,">");
|
||||||
|
else
|
||||||
|
p_sd+=sprintf(p_sd," ");
|
||||||
|
print_adr(cur_exc+i);
|
||||||
|
p_sd+=sprintf(p_sd," ");
|
||||||
|
// stack-dump
|
||||||
|
print_adr(cur_sp-i);
|
||||||
|
if(cur_sp-i==p_sp)
|
||||||
|
p_sd+=sprintf(p_sd,"<\n");
|
||||||
|
else
|
||||||
|
p_sd+=sprintf(p_sd," \n");
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
p_sd+=sprintf(p_sd,"\n");
|
||||||
|
|
||||||
|
|
||||||
|
displayTitle();
|
||||||
|
displayCause();
|
||||||
|
switch(currentPage)
|
||||||
|
{
|
||||||
|
case PAGE_REGS:
|
||||||
|
displayRegs();
|
||||||
|
break;
|
||||||
|
case PAGE_DUMP:
|
||||||
|
break;
|
||||||
|
case PAGE_VALUES:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//int len=0;
|
||||||
|
//len+=strlen(str_reg);
|
||||||
|
//len+=strlen(str_dump);
|
||||||
|
// FntPrint(str_reg);
|
||||||
|
// print(str_reg);
|
||||||
|
// FntPrint(str_dump);
|
||||||
|
// print(str_dump);
|
||||||
|
// if(wait_pad==0)
|
||||||
|
// FntPrint(" scroll through mem with pad");
|
||||||
|
// print(" scroll through mem with pad");
|
||||||
|
// FntFlush(-1);
|
||||||
|
PrimDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------ print_adr ------------------------------- */
|
||||||
|
static void print_adr(int *adr) {
|
||||||
|
|
||||||
|
int chk,dummy_mem,error;
|
||||||
|
|
||||||
|
chk=(int)adr;
|
||||||
|
|
||||||
|
dummy_mem=chk&0xf0000000;
|
||||||
|
chk&=0x0ffffffc;
|
||||||
|
error=1;
|
||||||
|
if(chk<mem_size)
|
||||||
|
error=0;
|
||||||
|
if(chk>0x1f800000&&chk<0x1f800400)
|
||||||
|
error=0;
|
||||||
|
adr=(int *)(chk|dummy_mem);
|
||||||
|
|
||||||
|
if(error==0)
|
||||||
|
p_sd+=sprintf(p_sd,"%08x=%08x",(int)(adr),*adr);
|
||||||
|
else
|
||||||
|
p_sd+=sprintf(p_sd,"%08x=XXXXXXXX",(int)(adr));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* ------------------------------- exc_swap ------------------------------ */
|
||||||
|
static void exc_swap(void) {
|
||||||
|
|
||||||
|
PutDrawEnv(&exc_db[exc_id].draw);
|
||||||
|
PutDispEnv(&exc_db[exc_id].disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static int fontx;
|
||||||
|
static int fonty;
|
||||||
|
static const int LEFTMARGIN=5;
|
||||||
|
static const int TOPMARGIN=5;
|
||||||
|
static const int CHARWIDTH=11;
|
||||||
|
static const int CHARHEIGHT=10;
|
||||||
|
static void cls()
|
||||||
|
{
|
||||||
|
fontx=LEFTMARGIN;
|
||||||
|
fonty=TOPMARGIN;
|
||||||
|
}
|
||||||
|
static void print(char *_string)
|
||||||
|
{
|
||||||
|
char text[2]="?";
|
||||||
|
while(*_string)
|
||||||
|
{
|
||||||
|
char _next=*_string;
|
||||||
|
if(_next=='\n')
|
||||||
|
{
|
||||||
|
fontx=LEFTMARGIN;
|
||||||
|
fonty+=CHARHEIGHT;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text[0]=*_string;
|
||||||
|
excFont->print(fontx+((CHARWIDTH-excFont->getCharWidth(text[0]))/2),fonty,text);
|
||||||
|
fontx+=CHARWIDTH;
|
||||||
|
}
|
||||||
|
_string++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void displayTitle()
|
||||||
|
{
|
||||||
|
print("[");
|
||||||
|
switch(currentPage)
|
||||||
|
{
|
||||||
|
case PAGE_REGS:
|
||||||
|
print("Registers");
|
||||||
|
break;
|
||||||
|
case PAGE_DUMP:
|
||||||
|
print("Dumps");
|
||||||
|
break;
|
||||||
|
case PAGE_VALUES:
|
||||||
|
print("Values");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
print("]\n");
|
||||||
|
}
|
||||||
|
static void displayCause()
|
||||||
|
{
|
||||||
|
char textBuf[100];
|
||||||
|
int *exc;
|
||||||
|
|
||||||
|
exc=(int*)reg_lst[OFS_EPC];
|
||||||
|
sprintf(textBuf,"%s",exc_txt[reg_lst[OFS_CA]>>2&0x1f]);
|
||||||
|
print(textBuf);
|
||||||
|
|
||||||
|
if((reg_lst[OFS_CA]>>2&0x1f)==9)
|
||||||
|
{
|
||||||
|
int i=(*exc>>16)-6;
|
||||||
|
if(i==0||i==1)
|
||||||
|
sprintf(textBuf," %s",break_txt[i]);
|
||||||
|
print(textBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
sprintf(textBuf,"\nPC=%08x",(int)exc);
|
||||||
|
print(textBuf);
|
||||||
|
|
||||||
|
if((reg_lst[OFS_CA]&0x80000000)==0x80000000)
|
||||||
|
print(" in branch delay slot");
|
||||||
|
print("\n\n");
|
||||||
|
|
||||||
|
sprintf(textBuf,"(%d)\n",number++);
|
||||||
|
print(textBuf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void displayRegs()
|
||||||
|
{
|
||||||
|
char textBuf[100];
|
||||||
|
/* ---- reg-dump ---- */
|
||||||
|
/*
|
||||||
|
zr t0 s0 t8 hi
|
||||||
|
at t1 s1 t9 lo
|
||||||
|
v0 t2 s2 k0
|
||||||
|
v1 t3 s3 k1 SR
|
||||||
|
a0 t4 s4 gp
|
||||||
|
a1 t5 s5 sp Ca
|
||||||
|
a2 t6 s6 fp
|
||||||
|
a3 t7 s7 ra
|
||||||
|
|
||||||
|
pc
|
||||||
|
*/
|
||||||
|
|
||||||
|
sprintf(textBuf,"zr=%08x t0=%08x s0=%08x t8=%08x hi=%08x\n", 0,reg_lst[OFS_T0],reg_lst[OFS_S0],reg_lst[OFS_T8],reg_lst[OFS_HI]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"at=%08x t1=%08x s1=%08x t9=%08x lo=%08x\n",reg_lst[OFS_AT],reg_lst[OFS_T1],reg_lst[OFS_S1],reg_lst[OFS_T9],reg_lst[OFS_LO]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"v0=%08x t2=%08x s2=%08x ko=%08x" ,reg_lst[OFS_V0],reg_lst[OFS_T2],reg_lst[OFS_S2], 0);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"v1=%08x t3=%08x s3=%08x k1=%08x SR=%08x\n",reg_lst[OFS_V1],reg_lst[OFS_T3],reg_lst[OFS_S3], 0,reg_lst[OFS_SR]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"a0=%08x t4=%08x s4=%08x gp=%08x" ,reg_lst[OFS_A0],reg_lst[OFS_T4],reg_lst[OFS_S4],reg_lst[OFS_GP]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"a1=%08x t5=%08x s5=%08x sp=%08x Ca=%08x\n",reg_lst[OFS_A1],reg_lst[OFS_T5],reg_lst[OFS_S5],reg_lst[OFS_SP],reg_lst[OFS_CA]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"a2=%08x t6=%08x s6=%08x fp=%08x" ,reg_lst[OFS_A2],reg_lst[OFS_T6],reg_lst[OFS_S6],reg_lst[OFS_FP]);
|
||||||
|
print(textBuf);
|
||||||
|
sprintf(textBuf,"a3=%08x t7=%08x s7=%08x ra=%08x" ,reg_lst[OFS_A3],reg_lst[OFS_T7],reg_lst[OFS_S7],reg_lst[OFS_RA]);
|
||||||
|
print(textBuf);
|
||||||
|
|
||||||
|
/*
|
||||||
|
p_sr+=sprintf(p_sr," at=%08x t4=%08x s7=%08x\n",
|
||||||
|
reg_lst[OFS_AT],reg_lst[OFS_T4],reg_lst[OFS_S7]);
|
||||||
|
p_sr+=sprintf(p_sr," v0=%08x t5=%08x t8=%08x\n",
|
||||||
|
reg_lst[OFS_V0],reg_lst[OFS_T5],reg_lst[OFS_T8]);
|
||||||
|
p_sr+=sprintf(p_sr," v1=%08x t6=%08x t9=%08x\n",
|
||||||
|
reg_lst[OFS_V1],reg_lst[OFS_T6],reg_lst[OFS_T9]);
|
||||||
|
p_sr+=sprintf(p_sr," a0=%08x t7=%08x gp=%08x\n",
|
||||||
|
reg_lst[OFS_A0],reg_lst[OFS_T7],reg_lst[OFS_GP]);
|
||||||
|
p_sr+=sprintf(p_sr," a1=%08x s0=%08x sp=%08x\n",
|
||||||
|
reg_lst[OFS_A1],reg_lst[OFS_S0],reg_lst[OFS_SP]);
|
||||||
|
p_sr+=sprintf(p_sr," a2=%08x s1=%08x fp=%08x\n",
|
||||||
|
reg_lst[OFS_A2],reg_lst[OFS_S1],reg_lst[OFS_FP]);
|
||||||
|
p_sr+=sprintf(p_sr," a3=%08x s2=%08x ra=%08x\n",
|
||||||
|
reg_lst[OFS_A3],reg_lst[OFS_S2],reg_lst[OFS_RA]);
|
||||||
|
p_sr+=sprintf(p_sr," t0=%08x s3=%08x hi=%08x\n",
|
||||||
|
reg_lst[OFS_T0],reg_lst[OFS_S3],reg_lst[OFS_HI]);
|
||||||
|
p_sr+=sprintf(p_sr," t1=%08x s4=%08x lo=%08x\n",
|
||||||
|
reg_lst[OFS_T1],reg_lst[OFS_S4],reg_lst[OFS_LO]);
|
||||||
|
p_sr+=sprintf(p_sr," t2=%08x s5=%08x sr=%08x\n",
|
||||||
|
reg_lst[OFS_T2],reg_lst[OFS_S5],reg_lst[OFS_SR]);
|
||||||
|
p_sr+=sprintf(p_sr," t3=%08x s6=%08x ca=%08x\n",
|
||||||
|
reg_lst[OFS_T3],reg_lst[OFS_S6],reg_lst[OFS_CA]);
|
||||||
|
*/
|
||||||
|
}
|
16
source/system/except.h
Normal file
16
source/system/except.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef __SYSTEM_EXCEPT_H__
|
||||||
|
#define __SYSTEM_EXCEPT_H__
|
||||||
|
|
||||||
|
extern void installExceptionHandler();
|
||||||
|
|
||||||
|
|
||||||
|
extern "C" void exc_c(void);
|
||||||
|
extern "C" void install_exc(void);
|
||||||
|
extern "C" void uninstall_exc(void);
|
||||||
|
|
||||||
|
extern int *reg_lst;
|
||||||
|
extern int dev_kit;
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
271
source/system/except_a.mip
Normal file
271
source/system/except_a.mip
Normal file
|
@ -0,0 +1,271 @@
|
||||||
|
opt at-,c+
|
||||||
|
|
||||||
|
xref exc_c
|
||||||
|
|
||||||
|
xdef install_exc
|
||||||
|
xdef uninstall_exc
|
||||||
|
xdef reg_lst
|
||||||
|
xdef dev_kit
|
||||||
|
|
||||||
|
rsreset
|
||||||
|
|
||||||
|
OFS_AT rw 1
|
||||||
|
OFS_V0 rw 1
|
||||||
|
OFS_V1 rw 1
|
||||||
|
OFS_A0 rw 1
|
||||||
|
OFS_A1 rw 1
|
||||||
|
OFS_A2 rw 1
|
||||||
|
OFS_A3 rw 1
|
||||||
|
OFS_T0 rw 1
|
||||||
|
OFS_T1 rw 1
|
||||||
|
OFS_T2 rw 1
|
||||||
|
OFS_T3 rw 1
|
||||||
|
OFS_T4 rw 1
|
||||||
|
OFS_T5 rw 1
|
||||||
|
OFS_T6 rw 1
|
||||||
|
OFS_T7 rw 1
|
||||||
|
OFS_S0 rw 1
|
||||||
|
OFS_S1 rw 1
|
||||||
|
OFS_S2 rw 1
|
||||||
|
OFS_S3 rw 1
|
||||||
|
OFS_S4 rw 1
|
||||||
|
OFS_S5 rw 1
|
||||||
|
OFS_S6 rw 1
|
||||||
|
OFS_S7 rw 1
|
||||||
|
OFS_T8 rw 1
|
||||||
|
OFS_T9 rw 1
|
||||||
|
OFS_GP rw 1
|
||||||
|
OFS_SP rw 1
|
||||||
|
OFS_FP rw 1
|
||||||
|
OFS_RA rw 1
|
||||||
|
OFS_HI rw 1
|
||||||
|
OFS_LO rw 1
|
||||||
|
OFS_SR rw 1
|
||||||
|
OFS_CA rw 1
|
||||||
|
OFS_EPC rw 1
|
||||||
|
|
||||||
|
section .text
|
||||||
|
|
||||||
|
;-------------------------------- install_exc ----------------------------
|
||||||
|
install_exc
|
||||||
|
|
||||||
|
la t0,exc_onoff
|
||||||
|
lw t1,0(t0)
|
||||||
|
nop
|
||||||
|
beqz t1,exc_off
|
||||||
|
nop
|
||||||
|
jr ra
|
||||||
|
nop
|
||||||
|
exc_off li t1,1
|
||||||
|
sw t1,0(t0)
|
||||||
|
|
||||||
|
;detect dev_kit
|
||||||
|
la t0,dev_kit
|
||||||
|
lw t1,0(t0)
|
||||||
|
nop
|
||||||
|
bgez t1,dev_2 ;just chk once
|
||||||
|
nop
|
||||||
|
lw t1,$80(zero)
|
||||||
|
move t2,zero
|
||||||
|
lui t3,$3c1a
|
||||||
|
or t3,t3,$1fa0
|
||||||
|
beq t1,t3,dev_0 ;DTL-H2000
|
||||||
|
lui t3,$3c1a
|
||||||
|
or t3,t3,$1fc2
|
||||||
|
beq t1,t3,dev_0 ;DTL-H2500
|
||||||
|
nop
|
||||||
|
b dev_1
|
||||||
|
nop
|
||||||
|
dev_0 li t2,1
|
||||||
|
dev_1 sw t2,0(t0)
|
||||||
|
dev_2
|
||||||
|
|
||||||
|
;install new exception-handler
|
||||||
|
|
||||||
|
; mfc0 v0,SR
|
||||||
|
dw $40026000
|
||||||
|
lui at,$ffff
|
||||||
|
or at,at,$00fc ;mask off IM,KUc,IEc
|
||||||
|
and at,at,v0
|
||||||
|
; mtc0 at,SR
|
||||||
|
dw $40816000
|
||||||
|
nop
|
||||||
|
|
||||||
|
li t0,$80
|
||||||
|
la t1,old_handler
|
||||||
|
|
||||||
|
lw t2,0(t0)
|
||||||
|
lw t3,4(t0)
|
||||||
|
lw t4,8(t0)
|
||||||
|
lw t5,12(t0)
|
||||||
|
sw t2,0(t1)
|
||||||
|
sw t3,4(t1)
|
||||||
|
sw t4,8(t1)
|
||||||
|
sw t5,12(t1)
|
||||||
|
la t1,new_exc_code
|
||||||
|
lw t2,0(t1)
|
||||||
|
lw t3,4(t1)
|
||||||
|
lw t4,8(t1)
|
||||||
|
lw t5,12(t1)
|
||||||
|
sw t2,0(t0)
|
||||||
|
sw t3,4(t0)
|
||||||
|
sw t4,8(t0)
|
||||||
|
sw t5,12(t0)
|
||||||
|
|
||||||
|
; mtc0 v0,SR ;restore irq
|
||||||
|
dw $40826000
|
||||||
|
nop
|
||||||
|
jr ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
new_exc_code
|
||||||
|
la k0,exc_asm
|
||||||
|
jr k0
|
||||||
|
nop
|
||||||
|
|
||||||
|
;------------------------------- uninstall_exc ----------------------------
|
||||||
|
uninstall_exc
|
||||||
|
|
||||||
|
la t0,exc_onoff
|
||||||
|
lw t1,0(t0)
|
||||||
|
nop
|
||||||
|
bnez t1,exc_on
|
||||||
|
nop
|
||||||
|
jr ra
|
||||||
|
nop
|
||||||
|
exc_on li t1,0
|
||||||
|
sw t1,0(t0)
|
||||||
|
|
||||||
|
; mfc0 v0,SR
|
||||||
|
dw $40026000
|
||||||
|
lui at,$ffff
|
||||||
|
or at,at,$00fc ;mask off IM,KUc,IEc
|
||||||
|
and at,at,v0
|
||||||
|
; mtc0 at,SR
|
||||||
|
dw $40816000
|
||||||
|
nop
|
||||||
|
|
||||||
|
la t0,old_handler
|
||||||
|
li t1,$80
|
||||||
|
|
||||||
|
lw t2,0(t0)
|
||||||
|
lw t3,4(t0)
|
||||||
|
lw t4,8(t0)
|
||||||
|
lw t5,12(t0)
|
||||||
|
sw t2,0(t1)
|
||||||
|
sw t3,4(t1)
|
||||||
|
sw t4,8(t1)
|
||||||
|
sw t5,12(t1)
|
||||||
|
|
||||||
|
; mtc0 v0,SR ;restore irq
|
||||||
|
dw $40826000
|
||||||
|
nop
|
||||||
|
jr ra
|
||||||
|
nop
|
||||||
|
|
||||||
|
;------------------------------- exc_asm ----------------------------
|
||||||
|
exc_asm
|
||||||
|
|
||||||
|
; mfc0 k0,Cause
|
||||||
|
dw $401a6800
|
||||||
|
nop
|
||||||
|
li k1,%1111011111110
|
||||||
|
|
||||||
|
srl k0,k0,2
|
||||||
|
andi k0,k0,$1f
|
||||||
|
srlv k1,k1,k0
|
||||||
|
|
||||||
|
andi k1,k1,1
|
||||||
|
beqz k1,old_handler
|
||||||
|
nop
|
||||||
|
|
||||||
|
;chk break
|
||||||
|
li k1,9
|
||||||
|
bne k0,k1,go_on
|
||||||
|
nop
|
||||||
|
; mfc0 k0,EPC
|
||||||
|
dw $401a7000
|
||||||
|
nop
|
||||||
|
lw k0,0(k0)
|
||||||
|
nop
|
||||||
|
srl k0,k0,16
|
||||||
|
li k1,6
|
||||||
|
beq k0,k1,go_on
|
||||||
|
li k1,7
|
||||||
|
beq k0,k1,go_on
|
||||||
|
nop
|
||||||
|
|
||||||
|
old_handler
|
||||||
|
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
|
||||||
|
go_on la k0,reg_save
|
||||||
|
|
||||||
|
sw at,OFS_AT(k0)
|
||||||
|
sw v0,OFS_V0(k0)
|
||||||
|
sw v1,OFS_V1(k0)
|
||||||
|
sw a0,OFS_A0(k0)
|
||||||
|
sw a1,OFS_A1(k0)
|
||||||
|
sw a2,OFS_A2(k0)
|
||||||
|
sw a3,OFS_A3(k0)
|
||||||
|
sw t0,OFS_T0(k0)
|
||||||
|
sw t1,OFS_T1(k0)
|
||||||
|
sw t2,OFS_T2(k0)
|
||||||
|
sw t3,OFS_T3(k0)
|
||||||
|
sw t4,OFS_T4(k0)
|
||||||
|
sw t5,OFS_T5(k0)
|
||||||
|
sw t6,OFS_T6(k0)
|
||||||
|
sw t7,OFS_T7(k0)
|
||||||
|
sw s0,OFS_S0(k0)
|
||||||
|
sw s1,OFS_S1(k0)
|
||||||
|
sw s2,OFS_S2(k0)
|
||||||
|
sw s3,OFS_S3(k0)
|
||||||
|
sw s4,OFS_S4(k0)
|
||||||
|
sw s5,OFS_S5(k0)
|
||||||
|
sw s6,OFS_S6(k0)
|
||||||
|
sw s7,OFS_S7(k0)
|
||||||
|
sw t8,OFS_T8(k0)
|
||||||
|
sw t9,OFS_T9(k0)
|
||||||
|
sw gp,OFS_GP(k0)
|
||||||
|
sw sp,OFS_SP(k0)
|
||||||
|
sw fp,OFS_FP(k0)
|
||||||
|
sw ra,OFS_RA(k0)
|
||||||
|
mfhi k1
|
||||||
|
nop
|
||||||
|
sw k1,OFS_HI(k0)
|
||||||
|
mflo k1
|
||||||
|
nop
|
||||||
|
sw k1,OFS_LO(k0)
|
||||||
|
; mfc0 k1,SR
|
||||||
|
dw $401b6000
|
||||||
|
nop
|
||||||
|
sw k1,OFS_SR(k0)
|
||||||
|
|
||||||
|
; mfc0 k1,Cause
|
||||||
|
dw $401b6800
|
||||||
|
nop
|
||||||
|
sw k1,OFS_CA(k0)
|
||||||
|
|
||||||
|
; mfc0 k1,EPC
|
||||||
|
dw $401b7000
|
||||||
|
nop
|
||||||
|
nop
|
||||||
|
sw k1,OFS_EPC(k0)
|
||||||
|
|
||||||
|
la k0,exc_c
|
||||||
|
jr k0
|
||||||
|
nop
|
||||||
|
|
||||||
|
section .data
|
||||||
|
|
||||||
|
dev_kit dw -1 ;-1=undefined, 0=playstation, 1=devkit
|
||||||
|
exc_onoff dw 0 ;internal exc-handler status onoff-flag
|
||||||
|
reg_lst dw reg_save
|
||||||
|
|
||||||
|
section .bss
|
||||||
|
|
||||||
|
reg_save dsw 34
|
||||||
|
|
|
@ -29,15 +29,19 @@
|
||||||
#include "sound\sound.h"
|
#include "sound\sound.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#define SCREEN_GRAB
|
|
||||||
|
|
||||||
#ifdef __USER_paul__
|
#ifdef __USER_paul__
|
||||||
#include "paul\paul.h"
|
#include "paul\paul.h"
|
||||||
CPaulScene s_paulScene;
|
CPaulScene s_paulScene;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef __SYSTEM_EXCEPT_H__
|
||||||
|
#include "system\except.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define SCREEN_GRAB
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
@ -65,6 +69,10 @@ void InitSystem() // reordered to reduce black screen (hope all is well
|
||||||
TPInit();
|
TPInit();
|
||||||
VidInit();
|
VidInit();
|
||||||
|
|
||||||
|
#ifdef __USER_paul__
|
||||||
|
installExceptionHandler(); // Where is the earliest we can do this?
|
||||||
|
#endif
|
||||||
|
|
||||||
setRndSeed( VidGetTickCount() );
|
setRndSeed( VidGetTickCount() );
|
||||||
|
|
||||||
SetDispMask(1);
|
SetDispMask(1);
|
||||||
|
@ -81,7 +89,8 @@ s_paulScene.init();
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
int thing=50;
|
||||||
|
int bug=0;
|
||||||
static int s_time = 0;
|
static int s_time = 0;
|
||||||
void dumpDebugMem();
|
void dumpDebugMem();
|
||||||
|
|
||||||
|
@ -113,6 +122,9 @@ void MainLoop()
|
||||||
|
|
||||||
DbgPollHost();
|
DbgPollHost();
|
||||||
|
|
||||||
|
bug=100/thing;
|
||||||
|
thing--;
|
||||||
|
|
||||||
#if defined(__VERSION_DEBUG__)
|
#if defined(__VERSION_DEBUG__)
|
||||||
|
|
||||||
#if defined(__DEBUG_MEM__)
|
#if defined(__DEBUG_MEM__)
|
||||||
|
|
|
@ -313,6 +313,10 @@ SOURCE=..\..\..\source\system\gp.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\system\gp.mip
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\system\gstate.cpp
|
SOURCE=..\..\..\source\system\gstate.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -333,6 +337,10 @@ SOURCE=..\..\..\source\system\lnkopt.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\system\lnkopt.mip
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\system\main.cpp
|
SOURCE=..\..\..\source\system\main.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -365,6 +373,10 @@ SOURCE=..\..\..\source\utils\fixed.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\utils\gpu.inc
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\utils\gtemisc.h
|
SOURCE=..\..\..\source\utils\gtemisc.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -373,6 +385,10 @@ SOURCE=..\..\..\source\utils\mathmip.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\utils\mathmip.mip
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\utils\mathtab.H
|
SOURCE=..\..\..\source\utils\mathtab.H
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
@ -381,10 +397,18 @@ SOURCE=..\..\..\source\utils\quat.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\utils\quatmip.mip
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\utils\replace.h
|
SOURCE=..\..\..\source\utils\replace.h
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
||||||
|
SOURCE=..\..\..\source\utils\replace.mip
|
||||||
|
# End Source File
|
||||||
|
# Begin Source File
|
||||||
|
|
||||||
SOURCE=..\..\..\source\utils\sincos.cpp
|
SOURCE=..\..\..\source\utils\sincos.cpp
|
||||||
# End Source File
|
# End Source File
|
||||||
# Begin Source File
|
# Begin Source File
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue