more simplification/updating of dspspy

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3231 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Shawn Hoffman 2009-05-14 10:54:48 +00:00
parent 9331b644a3
commit c64f73d4f7
6 changed files with 102 additions and 4896 deletions

View File

@ -0,0 +1,49 @@
#ifndef _CONSOLEHELPER_H_
#define _CONSOLEHELPER_H_
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#define CON_BLACK 0
#define CON_RED 1
#define CON_GREEN 2
#define CON_YELLOW 3
#define CON_BLUE 4
#define CON_MAGENTA 5
#define CON_CYAN 6
#define CON_WHITE 7
#define CON_BRIGHT 8
#define CON_BRIGHT_BLACK CON_BLACK | CON_BRIGHT
#define CON_BRIGHT_RED CON_RED | CON_BRIGHT
#define CON_BRIGHT_GREEN CON_GREEN | CON_BRIGHT
#define CON_BRIGHT_YELLOW CON_YELLOW | CON_BRIGHT
#define CON_BRIGHT_BLUE CON_BLUE | CON_BRIGHT
#define CON_BRIGHT_MAGENTA CON_MAGENTA | CON_BRIGHT
#define CON_BRIGHT_CYAN CON_CYAN | CON_BRIGHT
#define CON_BRIGHT_WHITE CON_WHITE | CON_BRIGHT
void CON_Printf(int x, int y, const char* fmt, ...)
{
char tmpbuf[255];
va_list marker;
va_start(marker,fmt);
vsprintf(tmpbuf, fmt, marker);
va_end(marker);
printf("\x1b[%d;%dH%s", y, x, tmpbuf);
}
void CON_SetColor(u8 foreground, u8 background)
{
u8 bright = foreground & 8 ? 1 : 0;
if (bright)
foreground &= ~CON_BRIGHT;
printf("\x1b[%d;%d;%dm", 30+foreground, bright, 40+background);
}
#endif

View File

@ -19,7 +19,7 @@
</ToolFiles>
<Configurations>
<Configuration
Name="Wii|x64"
Name="Wii|Win32"
OutputDirectory="build"
IntermediateDirectory="build"
ConfigurationType="0"
@ -42,30 +42,7 @@
/>
</Configuration>
<Configuration
Name="GC|x64"
OutputDirectory="build"
IntermediateDirectory="build"
ConfigurationType="0"
CharacterSet="2"
WholeProgramOptimization="1"
BuildLogFile="build\BuildLogGC.htm"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make -f MakefileGC"
ReBuildCommandLine="make clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make -f MakefileGC"
CleanCommandLine="make clean"
Output="DSPSpyGC.dol"
PreprocessorDefinitions=""
IncludeSearchPath="$(ProjectDir);C:\devkitPro\libogc\include"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
<Configuration
Name="Wii|Win32"
Name="Wii|x64"
OutputDirectory="build"
IntermediateDirectory="build"
ConfigurationType="0"
@ -110,6 +87,29 @@
CompileAsManaged=""
/>
</Configuration>
<Configuration
Name="GC|x64"
OutputDirectory="build"
IntermediateDirectory="build"
ConfigurationType="0"
CharacterSet="2"
WholeProgramOptimization="1"
BuildLogFile="build\BuildLogGC.htm"
>
<Tool
Name="VCNMakeTool"
BuildCommandLine="..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_test.ds&#x0D;&#x0A;make -f MakefileGC"
ReBuildCommandLine="make clean&#x0D;&#x0A;..\..\Binary\$(PlatformName)\DSPTool.exe -h dsp_code tests\dsp_code.ds&#x0D;&#x0A;make -f MakefileGC"
CleanCommandLine="make clean"
Output="DSPSpyGC.dol"
PreprocessorDefinitions=""
IncludeSearchPath="$(ProjectDir);C:\devkitPro\libogc\include"
ForcedIncludes=""
AssemblySearchPath=""
ForcedUsingAssemblies=""
CompileAsManaged=""
/>
</Configuration>
</Configurations>
<References>
</References>
@ -119,15 +119,7 @@
>
</File>
<File
RelativePath=".\display.cpp"
>
</File>
<File
RelativePath=".\display.h"
>
</File>
<File
RelativePath=".\display_font.cpp"
RelativePath=".\ConsoleHelper.h"
>
</File>
<File

View File

@ -1,211 +0,0 @@
#include <stdlib.h>
#include <string.h>
#include <reent.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#undef errno
extern int errno;
#include <ogc/color.h>
#include <ogc/machine/asm.h>
#include <ogc/machine/processor.h>
#define FONT_XSIZE 8
#define FONT_YSIZE 16
#define FONT_XFACTOR 1
#define FONT_YFACTOR 1
#define FONT_XGAP 2
#define FONT_YGAP 0
typedef struct _display_data_s {
u8 *framebuffer;
u8 *font;
int xres,yres,stride;
int cursor_x,cursor_y;
int border_left,border_right,border_top,border_bottom;
int scrolled_lines;
unsigned int foreground,background;
} display_data_s;
int displ_open(struct _reent *r, const char *path, int flags,int mode);
int displ_write(struct _reent *r, int fd, const char *ptr, int len);
static struct _display_data_s dsp_displ;
static struct _display_data_s *displ = &dsp_displ;
extern u8 display_font_8x16[];
static void __display_drawc(int xpos, int ypos, int c)
{
xpos >>= 1;
int ax, ay;
unsigned int *ptr = (unsigned int*)(displ->framebuffer + displ->stride * ypos + xpos * 4);
for (ay = 0; ay < FONT_YSIZE; ay++)
#if FONT_XFACTOR == 2
for (ax = 0; ax < 8; ax++)
{
unsigned int color;
if ((displ->font[c * FONT_YSIZE + ay] << ax) & 0x80)
color = displ->foreground;
else
color = displ->background;
#if FONT_YFACTOR == 2
// pixel doubling: we write u32
ptr[ay * 2 * displ->stride/4 + ax] = color;
// line doubling
ptr[(ay * 2 +1) * displ->stride/4 + ax] = color;
#else
ptr[ay * displ->stride/4 + ax] = color;
#endif
}
#else
for (ax = 0; ax < 4; ax ++)
{
unsigned int color[2];
int bits = (displ->font[c * FONT_YSIZE + ay] << (ax*2));
if (bits & 0x80)
color[0] = displ->foreground;
else
color[0] = displ->background;
if (bits & 0x40)
color[1] = displ->foreground;
else
color[1] = displ->background;
ptr[ay * displ->stride/4 + ax] = (color[0] & 0xFFFF00FF) | (color[1] & 0x0000FF00);
}
#endif
}
void ds_init(void *framebuffer,int xstart,int ystart,int xres,int yres,int stride)
{
unsigned int level;
_CPU_ISR_Disable(level);
displ->framebuffer = (u8 *)framebuffer;
displ->xres = xres;
displ->yres = yres;
displ->border_left = xstart;
displ->border_top = ystart;
displ->border_right = displ->xres;
displ->border_bottom = displ->yres;
displ->stride = stride;
displ->cursor_x = xstart;
displ->cursor_y = ystart;
displ->font = display_font_8x16;
displ->foreground = COLOR_WHITE;
displ->background = COLOR_BLACK;
displ->scrolled_lines = 0;
unsigned int c = (displ->xres*displ->yres)/2;
unsigned int *p = (unsigned int*)displ->framebuffer;
while(c--)
*p++ = displ->background;
_CPU_ISR_Restore(level);
}
void ds_clear(void)
{
unsigned int c = (displ->xres*displ->yres)/2;
unsigned int *p = (unsigned int*)displ->framebuffer;
c /= 2;
p += c;
while(c--)
*p++ = displ->background;
}
int display_putc(int c)
{
if(!displ) return -1;
switch(c)
{
case '\n':
displ->cursor_y += FONT_YSIZE*FONT_YFACTOR+FONT_YGAP;
displ->cursor_x = displ->border_left;
break;
default:
__display_drawc(displ->cursor_x,displ->cursor_y,c);
displ->cursor_x += FONT_XSIZE*FONT_XFACTOR+FONT_XGAP;
if((displ->cursor_x+FONT_XSIZE*FONT_XFACTOR)>displ->border_right) {
displ->cursor_y += FONT_YSIZE*FONT_YFACTOR+FONT_YGAP;
displ->cursor_x = displ->border_left;
}
}
if((displ->cursor_y+FONT_YSIZE*FONT_YFACTOR)>=displ->border_bottom) {
memcpy(displ->framebuffer,
displ->framebuffer+displ->stride*(FONT_YSIZE*FONT_YFACTOR+FONT_YGAP),
displ->stride*displ->yres-FONT_YSIZE);
unsigned int cnt = (displ->stride * (FONT_YSIZE * FONT_YFACTOR + FONT_YGAP))/4;
unsigned int *ptr = (unsigned int*)(displ->framebuffer + displ->stride * (displ->yres - FONT_YSIZE));
while(cnt--)
*ptr++ = displ->background;
displ->cursor_y -= FONT_YSIZE * FONT_YFACTOR + FONT_YGAP;
}
return 1;
}
int displ_write(struct _reent *r,int fd, const char *ptr,int len)
{
int i, count = 0;
char *tmp = (char*)ptr;
if(!tmp || len<=0) return -1;
i = 0;
while(*tmp!='\0' && i<len) {
count += display_putc(*tmp++);
i++;
}
return count;
}
void ds_text_out(int xpos, int ypos, const char *str)
{
ypos *= (FONT_YSIZE * FONT_YFACTOR + FONT_YGAP);
xpos *= (FONT_XSIZE * FONT_XFACTOR + FONT_XGAP);
while(*str != '\0')
{
__display_drawc(xpos, ypos, *str++);
xpos += (FONT_XSIZE * FONT_XFACTOR + FONT_XGAP);
};
}
void ds_printf(int x, int y, const char *fmt, ...)
{
char tmpbuf[255];
va_list marker;
va_start(marker,fmt);
vsprintf(tmpbuf, fmt, marker );
va_end(marker);
ds_text_out(x, y, tmpbuf);
}
void ds_set_colour(int f, int b)
{
displ->background = b;
displ->foreground = f;
}
void ds_underline(int xpos, int ypos, int len, int col)
{
int i;
ypos = (ypos + 1) * (FONT_YSIZE * FONT_YFACTOR + FONT_YGAP) - 1;
xpos *= (FONT_XSIZE * FONT_XFACTOR + FONT_XGAP)/2;
len *= (FONT_XSIZE * FONT_XFACTOR + FONT_XGAP)/2;
unsigned int *ptr = (unsigned int*)(displ->framebuffer + displ->stride * ypos + xpos * 4);
for(i=0 ; i < len ; i++)
ptr[i] = col;
}

View File

@ -1,12 +0,0 @@
#ifndef _DISPLAY_H
#define _DISPLAY_H
void ds_text_out(int xpos, int ypos, const char *str);
void ds_set_colour(int f, int b);
void ds_init(void *framebuffer, int xstart, int ystart, int xres, int yres, int stride);
void ds_underline(int xpos, int ypos, int len, int col);
void ds_printf(int x, int y, const char *fmt, ...);
void ds_clear(void);
#endif

File diff suppressed because it is too large Load Diff

View File

@ -16,13 +16,14 @@
#include <fat.h>
#include <fcntl.h>
#include <ogc/color.h>
#include <ogc/consol.h>
#include <ogc/dsp.h>
#include <ogc/irq.h>
#include <ogc/machine/asm.h>
#include <ogc/machine/processor.h>
#include <wiiuse/wpad.h>
#include "display.h"
#include "ConsoleHelper.h"
// Pull in some constants etc from DSPCore.
#include "../Core/DSPCore/Src/gdsp_registers.h"
@ -133,28 +134,28 @@ void print_reg_block(int x, int y, int sel, const u16 *regs, const u16 *compare_
{
// Do not even display the loop stack registers.
const int reg = j * 8 + i;
ds_set_colour(sel == reg ? COLOR_YELLOW : COLOR_GREEN, COLOR_BLACK);
ds_printf(x + j * 8, i + y, "%02x ", reg);
CON_SetColor(sel == reg ? CON_YELLOW : CON_GREEN, CON_BLACK);
CON_Printf(x + j * 8, i + y, "%02x ", reg);
if (j != 1 || i < 4)
{
u32 color1 = regs_equal(reg, regs[reg], compare_regs[reg]) ? COLOR_WHITE : COLOR_RED;
u8 color1 = regs_equal(reg, regs[reg], compare_regs[reg]) ? CON_WHITE : CON_RED;
for (int k = 0; k < 4; k++)
{
if (sel == reg && k == small_cursor_x && ui_mode == UIM_EDIT_REG)
ds_set_colour(COLOR_BLACK, color1);
CON_SetColor(CON_BLACK, color1);
else
ds_set_colour(color1, COLOR_BLACK);
ds_printf(x + 3 + j * 8 + k, i + y, "%01x", (regs[reg] >> ((3 - k) * 4)) & 0xf);
CON_SetColor(color1, CON_BLACK);
CON_Printf(x + 3 + j * 8 + k, i + y, "%01x", (regs[reg] >> ((3 - k) * 4)) & 0xf);
}
}
}
}
ds_set_colour(COLOR_WHITE, COLOR_BLACK);
CON_SetColor(CON_WHITE, CON_BLACK);
ds_printf(x+2, y+9, "ACC0: %02x %04x %04x", regs[DSP_REG_ACH0]&0xff, regs[DSP_REG_ACM0], regs[DSP_REG_ACL0]);
ds_printf(x+2, y+10, "ACC1: %02x %04x %04x", regs[DSP_REG_ACH1]&0xff, regs[DSP_REG_ACM1], regs[DSP_REG_ACL1]);
ds_printf(x+2, y+11, "AX0: %04x %04x", regs[DSP_REG_AXH0], regs[DSP_REG_AXL0]);
ds_printf(x+2, y+12, "AX1: %04x %04x", regs[DSP_REG_AXH1], regs[DSP_REG_AXL1]);
CON_Printf(x+2, y+9, "ACC0: %02x %04x %04x", regs[DSP_REG_ACH0]&0xff, regs[DSP_REG_ACM0], regs[DSP_REG_ACL0]);
CON_Printf(x+2, y+10, "ACC1: %02x %04x %04x", regs[DSP_REG_ACH1]&0xff, regs[DSP_REG_ACM1], regs[DSP_REG_ACL1]);
CON_Printf(x+2, y+11, "AX0: %04x %04x", regs[DSP_REG_AXH0], regs[DSP_REG_AXL0]);
CON_Printf(x+2, y+12, "AX1: %04x %04x", regs[DSP_REG_AXH1], regs[DSP_REG_AXL1]);
}
void print_regs(int _step, int _dsp_steps)
@ -165,22 +166,22 @@ void print_regs(int _step, int _dsp_steps)
print_reg_block(0, 2, _step == 0 ? cursor_reg : -1, regs, regs2);
print_reg_block(33, 2, -1, regs2, regs);
ds_set_colour(COLOR_WHITE, COLOR_BLACK);
ds_printf(33, 17, "%i / %i ", _step + 1, _dsp_steps);
CON_SetColor(CON_WHITE, CON_BLACK);
CON_Printf(33, 17, "%i / %i ", _step + 1, _dsp_steps);
return;
static int count = 0;
int x = 0, y = 16;
if (count > 2)
ds_clear();
printf("\x1b[2J"); // Clear
count = 0;
ds_set_colour(COLOR_WHITE, COLOR_BLACK);
CON_SetColor(CON_WHITE, CON_BLACK);
for (int i = 0x0; i < 0xf70 ; i++)
{
if (dspbufC[i] != mem_dump[i])
{
ds_printf(x, y, "%04x=%04x", i, dspbufC[i]);
CON_Printf(x, y, "%04x=%04x", i, dspbufC[i]);
count++;
x += 10;
if (x >= 60) {
@ -189,7 +190,7 @@ void print_regs(int _step, int _dsp_steps)
}
}
}
ds_printf(4, 25, "%08x", count);
CON_Printf(4, 25, "%08x", count);
}
void ui_pad_sel(void)
@ -286,7 +287,7 @@ void my_send_task(void *addr, u16 iram_addr, u16 len, u16 start)
int main()
{
init_video();
ds_init(xfb, 20, 64, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2);
CON_Init(xfb, 20, 64, rmode->fbWidth, rmode->xfbHeight, rmode->fbWidth * 2);
ui_mode = UIM_SEL;
@ -322,7 +323,7 @@ int main()
if (DSP_CheckMailFrom())
{
u32 mail = DSP_ReadMailFrom();
ds_printf(2, 1, "Last mail: %08x", mail);
CON_Printf(2, 1, "Last mail: %08x", mail);
if (mail == 0x8071feed)
{
@ -376,13 +377,13 @@ int main()
print_regs(show_step, dsp_steps);
ds_printf(2, 18, "Controls:");
ds_printf(4, 19, "+/- to move");
ds_printf(4, 20, "B to start over");
ds_printf(4, 21, "Home to exit");
ds_printf(4, 22, "2 to dump results to SD");
CON_Printf(2, 18, "Controls:");
CON_Printf(4, 19, "+/- to move");
CON_Printf(4, 20, "B to start over");
CON_Printf(4, 21, "Home to exit");
CON_Printf(4, 22, "2 to dump results to SD");
ds_printf(4, 24, last_message);
CON_Printf(4, 24, last_message);
switch (ui_mode)
{