📄 old screen.cpp
字号:
if (pixels[4]) scrstart[4] = pixels[4] | ctmap->pal_or;
if (pixels[5]) scrstart[5] = pixels[5] | ctmap->pal_or;
if (pixels[6]) scrstart[6] = pixels[6] | ctmap->pal_or;
if (pixels[7]) scrstart[7] = pixels[7] | ctmap->pal_or;
}
}
void doframedraw()
{
int temp = screen_scanline, y;
clearscreen (0);
resetscreenframe ();
screen_scanline = 0;
for (y = 0; y < 4; y++) {
getbgframeinfo (y);
getbglineinfo (y);
setcolor (0);
curbg = &bg[y];
printf8 (201, 51+(curbg->bgnum*10), "%d(%d,%d)", curbg->bgnum, curbg->scrollx, curbg->scrolly);
setcolor (messagecolor);
printf8 (200, 50+(curbg->bgnum*10), "%d(%d,%d)", curbg->bgnum, curbg->scrollx, curbg->scrolly);
debug0 ("bgnum=%d scrollstartx=%d scrollstarty=%d tile16x16=%d cgoffs=%d cdepth=%d width64=%d height=%d",
curbg->bgnum, curbg->scrollx, curbg->scrolly, curbg->tile16x16, curbg->cgoffs, curbg->cdepth, curbg->width64, curbg->height64);
debug0 ("BG: width8x8=%d width8x8and=%d height8x8=%d height8x8and=%d tchars=%d tcharshift=%d",
curbg->width8x8, curbg->width8x8and, curbg->height8x8, curbg->height8x8and, curbg->tcharbase, curbg->tcharshift);
}
while (screen_scanline < scans_before_vbl()) {
drawnextscanline ();
//copyscreen ();
screen_scanline++;
}
screen_scanline = temp;
}
#define DEBUGLINES 27
struct debugline {
char text [55];
boolean showregs;
struct regpack reg;
char asterisk;
int color;
} line [DEBUGLINES];
int debuglines = 1;
void deletefirstdebugline ()
{
int x;
for (x = 0; x < debuglines; x++) {
line[x] = line[x + 1];
}
debuglines--;
}
void adddebugline (char *text, boolean showregs, char asterisk)
{
dword opbyte;
debug0 ("debug A%0.4X X%0.4X Y%0.4X P%0.2X PC$%X OP$%X %c%s", reg.A, reg.X, reg.Y, reg.P, reg.PC, *SNESMEM(reg.PC), asterisk, text);
if (debuglines == DEBUGLINES - 1)
deletefirstdebugline ();
line[debuglines].reg = reg;
//line[debuglines].reg.PC = PC; line[debuglines].reg.DBR = DBR;
//line[debuglines].reg.Y = Y; line[debuglines].reg.X = X;
//line[debuglines].reg.D = D; line[debuglines].reg.A = A;
//line[debuglines].reg.P = P; line[debuglines].reg.E = E;
//line[debuglines].reg.S = S;
line[debuglines].showregs = showregs;
line[debuglines].asterisk = asterisk;
line[debuglines].color = 127;
strcpy (line[debuglines].text, text);
if (showregs && debuglines != 0 && line[debuglines-1].asterisk == ' ') {
if (line[debuglines-1].reg.PC >= reg.PC)
line[debuglines-1].asterisk = 30;
opbyte = *SNESMEM (line[debuglines-1].reg.PC);
if (line[debuglines-1].reg.PC + opcodelist[opbyte].bytes + 1 < reg.PC)
line[debuglines-1].asterisk = 31;
}
debuglines++;
}
#define DEBUG_SETREGCOLOR(index,field) setcolor ((index) == debuglines - 1 ? 45 : (line[index].reg.field) == (line[index+1].reg.field) ? 15 : 123)
void drawdebugline (int x, boolean regs2)
{
int b;
setcolor (line[x].color);
printf8 (42, 27 + x*8, "%s", line[x].text);
printf8 (0, 27 + x*8, "%c", line[x].asterisk);
if (line[x].showregs) {
setcolor (30);
printf8 (8, 27+x*8, "%0.6X", line[x].reg.PC);
DEBUG_SETREGCOLOR (x, A);
if (line[x].reg.P & 0x20)
drawbox (115, 26+x*8, 123, 33+x*8, 7);
printf8 (115, 27+x*8, "%0.4X", line[x].reg.A);
if (line[x].reg.P & 0x10) {
drawbox (140, 26+x*8, 148, 33+x*8, 7);
drawbox (165, 26+x*8, 173, 33+x*8, 7);
}
DEBUG_SETREGCOLOR (x, X);
printf8 (140, 27+x*8, "%0.4X", line[x].reg.X);
DEBUG_SETREGCOLOR (x, Y);
printf8 (165, 27+x*8, "%0.4X", line[x].reg.Y);
if (!regs2) {
DEBUG_SETREGCOLOR (x, S);
printf8 (190, 27+x*8, "%0.4X", line[x].reg.S);
DEBUG_SETREGCOLOR (x, D);
printf8 (215, 27+x*8, "%0.4X", line[x].reg.D);
DEBUG_SETREGCOLOR (x, P);
printf8 (240, 27+x*8, "%0.2X", line[x].reg.P);
} else {
DEBUG_SETREGCOLOR (x, DBR);
printf8 (197, 27+x*8, "%0.2X", line[x].reg.DBR);
for (b = 0; b < 8; b++) {
setcolor (x == debuglines - 1 ? 45 : \
((line[x].reg.P >> b) & 1) == ((line[x+1].reg.P >> b) & 1) ? 15 : 123);
printf8 (211 + (7-b) * 5, 27+x*8, "%d", (line[x].reg.P >> b) & 1);
}
if (line[x].reg.D != 0) {
DEBUG_SETREGCOLOR (x, D);
printf8 (189, 27+x*8, "d", line[x].reg.D);
}
}
} else if (line[x].asterisk == '*') {
setcolor (21);
printf8 (8, 27+x*8, "%0.6X", line[x].reg.PC);
}
}
void drawmemdump (byte *area, char *s, int offs)
{
int y, x;
clearscreen ();
setcolor (15);
printf8 (0,0,"Debugger Instr:%0.8d Scanline:%0.3d Cyc/scan:%0.3d/%0.3d", debug_instr, screen_scanline, scan_cycles, cycles_per_scan);
printf8 (0,8,"Total frames:%0.4d Memory dump view", total_frames);
printf8 (0,16,"%s (Starting at offset %d)", s, offs);
for (y = -2; y < 25; y++) {
setcolor (174);
if (y < 0) setcolor (165);
printf8(0,42+y*8,"%0.6X", offs + y*12);
setcolor (15);
if (y < 0) setcolor (6);
for (x = 0; x < 12; x++) {
setcolor (15);
if (debugscreen == 4 && vramcmpfn[0] != '\0') {
if (y*12 + x + vramdumpoffset > 0x10000 || y*12 + x + vramdumpoffset < 0)
continue;
if (area [y * 12 + x] != debug_vram [y * 12 + x + vramdumpoffset]) {
setcolor (24);
printf8 (37+x*15, 43+y*8, "%0.2X", debug_vram [y * 12 + x + vramdumpoffset]);
setcolor (124);
}
}
if (((offs + y*12 + x) & 0xFF0000) == (offs & 0xFF0000))
printf8 (35+x*15, 42+y*8, "%0.2X", area [y * 12 + x]);
}
}
}
void drawdebug (int which)
{
int x, y, x2, y2;
dword opdata;
char *fmt;
union cachetile *tile;
if (which == 0) {
doframedraw ();
} else if (which == 1 || which == 2) {
clearscreen ();
setcolor (15);
printf8 (0,0,"Debugger Instr:%0.8d Scanline:%0.3d Cyc/scan:%0.3d/%0.3d", debug_instr, screen_scanline, scan_cycles, cycles_per_scan);
printf8 (0,8,"Total frames:%0.4d Type ? for command list", total_frames);
opdata = *(dword*)SNESMEM (reg.PC);
fmt = opcodelist[(byte)opdata].format;
printf8 (0,16,"%c%c%c: %s", fmt[0], fmt[1], fmt[2], getdescr ((byte)opdata));
setcolor (30);
printf8 (8,26,"PC");
printf8 (115,26,"A");
printf8 (140,26,"X");
printf8 (165,26,"Y");
if (which == 2) {
printf8 (197,26,"DB");
printf8 (210,26,"NVMXDIZC");
} else {
printf8 (190,26,"S");
printf8 (215,26,"D");
printf8 (240,26,"P");
}
for (x = 1; x < debuglines; x++) {
drawdebugline (x, which == 2 ? true : false);
}
} else if (which == 3) {
drawmemdump (SNESMEM (memdumpoffset), "65c816 Memory Dump", memdumpoffset);
} else if (which == 4) {
drawmemdump (vram + vramdumpoffset, "VRAM Memory Dump", vramdumpoffset);
} else if (which == 5) { // CGRAM dump
drawmemdump (cgram + cgramdumpoffset, "CGRAM Memory Dump", cgramdumpoffset);
} else if (which == 6) {
drawmemdump (oam + oamdumpoffset, "OAM Memory Dump", oamdumpoffset);
} else if (which == 7) {
clearscreen ();
setcolor (15);
printf8 (0, 0, "Common Registers [ptrs: VRAM:%X OAM:%X CG:%X]", state.vrampointer, state.oampointer, state.colorpointer);
printf8 (0, 8, "$2100($%X) b7:1=screen off b0-3:bright", *REG2100);
printf8 (0,16, "$2105($%X) b0-2:mode b4-7:16x16 b3:BG3 priority", *REG2105);
printf8 (0,24, "$2107($%X) b0-1:Sc.size b2-7:base(BG1) $%X", *REG2107(0), (*REG2107(0) & ~3) << 9);
printf8 (0,32, "$2108($%X) b0-1:Sc.size b2-7:base(BG2) $%X", *REG2107(1), (*REG2107(1) & ~3) << 9);
printf8 (0,40, "$2109($%X) b0-1:Sc.size b2-7:base(BG3) $%X", *REG2107(2), (*REG2107(2) & ~3) << 9);
printf8 (0,48, "$210A($%X) b0-1:Sc.size b2-7:base(BG4) $%X", *REG2107(3), (*REG2107(3) & ~3) << 9);
printf8 (0,56, "$210B($%X) b0-3:BG1 ch base $%X b4-7:BG2 $%X", *(byte*)REG210B, (*(byte*)REG210B & 15) << 13, (*(byte*)REG210B >> 4) << 13);
printf8 (0,64, "$210C($%X) b0-3:BG3 ch base $%X b4-7:BG4 $%X", *(((byte*)REG210B) + 1), (*(((byte*)REG210B) + 1) & 15) << 13, (*(((byte*)REG210B) + 1) >> 4) << 13);
printf8 (0,72, "$210D($%X/%d) $210E($%X/%d) BG1 Scroll H/V", state.scrollreg[0].scroll, state.scrollreg[0].hipointer, state.scrollreg[1].scroll, state.scrollreg[1].hipointer);
printf8 (0,80, "$210F($%X/%d) $2110($%X/%d) BG1 Scroll H/V", state.scrollreg[2].scroll, state.scrollreg[2].hipointer, state.scrollreg[3].scroll, state.scrollreg[3].hipointer);
printf8 (0,88, "$2111($%X/%d) $2112($%X/%d) BG1 Scroll H/V", state.scrollreg[4].scroll, state.scrollreg[4].hipointer, state.scrollreg[5].scroll, state.scrollreg[5].hipointer);
printf8 (0,96, "$2113($%X/%d) $2114($%X/%d) BG1 Scroll H/V", state.scrollreg[6].scroll, state.scrollreg[6].hipointer, state.scrollreg[7].scroll, state.scrollreg[7].hipointer);
printf8 (0,104, "$2115(%X) b7:inc@$2119? b0-1:Inc.rate b2-3:Full gr.", *REG2115);
printf8 (0,112, "$2116(%X)*2 initial VRAM address", *REG2116);
printf8 (0,120, "$2118(%X) VRAM data write", *REG2118);
printf8 (0,128, "$212C(%X)/$212D(%X) Main/Sub screen designation", *REG212C, *REG212D);
printf8 (0,136, "$211A(%X)/$211B(%X)/$211C(%X)/$211D(%X)/$211E(%X) Mode7", *REG211A, state.m7vars.cosx, state.m7vars.sinx, state.m7vars.cosy, state.m7vars.siny);
printf8 (0,144, "$211F(%X/%d)/$2120(%X/%d) Setup,Cos&SinX,Cos&SinY,Center X/Y", state.m7vars.x, state.m7vars.hipointer[4], state.m7vars.y, state.m7vars.hipointer[5]);
printf8 (0,152, "$2133(%X) b6:extbg b3:psd-512 b2:239-line b1:int.OBJ b0:int", *REG2133);
printf8 (0,160, "$2180(%X=%X) WRAM byte 1: data byte 2-4: address", *(dword*)REG2181 & 0xFFFFFF, *(byte*)REG2180);
printf8 (0,168, "$213C(%X)/$213D(%X) Scanline location (H/V) (dbl)", *REG213C, *REG213D);
printf8 (0,176, "$4200(%X) Enable b7:NMI b5:V.Counter b4:H.Counter b0:joypad", *REG4200);
printf8 (0,184, "$4207(%X)/$4209(%X) When to make IRQ int (H/V count)", *REG4207, *REG4209);
printf8 (0,192, "$420B(%X)/$420C(%X) DMA/HDMA Transfer Initiate", *REG420B, *REG420C);
printf8 (0,200, "$43?0(%X/%X/%X/%X / %X/%X/%X/%X) DMA Control", *REG4300(0), *REG4300(1), *REG4300(2), *REG4300(3), *REG4300(4), *REG4300(5), *REG4300(6), *REG4300(7));
printf8 (0,208, "b7:PPU>CPU b6:HDMA ind b4:Dec b3:Fixed b0-2:Mode");
printf8 (0,216, "$2101(%X) $2102(%X) OAM Size b0-2:base b5-7:size / Addr", *REG2101, *REG2102);
printf8 (0,232, "OAM byte0:X 1:Y 2:Char 3:b0=CharMSB b1-3=Pal b4-5=Pri b6-7:flip");
} else if (which == 8) {
clearscreen ();
for (y = 0; y < 56; y++) {
for (x = 0; x < 16; x++) {
if (vramblitoffset + (vramblitcdepth+1)*16*(y*16+x) >= 0x10000) {
for (y2 = 0; y2 < 8; y2++)
for (x2 = 0; x2 < 8; x2++)
if (y < 28)
vs[(y*8+y2) * xres + x*8+x2] = 30;
else
vs[((y-28)*8+y2) * xres + x*8+x2 + 128] = 30;
continue;
}
tile = getcachetile ((vramblitoffset>>4) + (vramblitcdepth+1)*(y*16+x), vramblitcdepth, 0);
for (y2 = 0; y2 < 8; y2++) {
if (y < 28) {
for (x2 = 0; x2 < 8; x2++) {
vs[(y*8+y2) * xres + x*8+x2] = tile->pixel[y2*8+x2];
}
} else {
for (x2 = 0; x2 < 8; x2++) {
vs[((y-28)*8+y2) * xres + x*8+x2 + 128] = tile->pixel[y2*8+x2];
}
}
}
}
}
for (y = 0; y < 244; y++) {
vs[y*xres+128] = messagecolor;
}
setcolor (46);
printf8 (5, 230, "VRAM Blit: cdepth %d offs %d", vramblitcdepth, vramblitoffset);
printf8 (5, 5, "$%X", vramblitoffset);
printf8 (133, 5, "$%X", vramblitoffset + (vramblitcdepth+1)*16*28*16);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -