fix: correction couleurs vers 32 bits maximum, mise en place du deboguage pas a pas.

This commit is contained in:
Nicolas Hordé 2018-10-16 21:56:39 +02:00
parent d0d125bbf8
commit f4b3ea6c10
12 changed files with 86 additions and 62 deletions

View File

@ -2,7 +2,7 @@ target remote localhost:1234
set disassembly-flavor intel
set architecture i386
symbol-file ./system/system.sys
break main
break system.c:50
cont
clear main
clear system.c:50
display/20i $pc

View File

@ -4,11 +4,10 @@
#include "types.h"
typedef struct vertex2d{
u32 x;
u32 y;
u16 x;
u16 y;
} vertex2d __attribute__ ((packed));
void linev(vertex2d *A, vertex2d *B, u8 color);
void hline(u32 x1, u32 x2, u32 y, u8 color);
void trianglefilled(vertex2d *A, vertex2d *B, vertex2d *C, u8 color);
void triangle(vertex2d *A, vertex2d *B, vertex2d *C, u8 color);
void linev(vertex2d *A, vertex2d *B, u32 color);
void trianglefilled(vertex2d *A, vertex2d *B, vertex2d *C, u32 color);
void triangle(vertex2d *A, vertex2d *B, vertex2d *C, u32 color);

View File

@ -26,8 +26,6 @@
})
#define dumpcpu() asm("\
mov $0x6666666, %%eax \n \
mov $0x8888888, %%ebx \n \
pushal \n \
pushf \n \
pushl %%cs\n \

View File

@ -96,7 +96,8 @@ void showchar (u16 coordx, u16 coordy, u8 thechar, u8 attrib);
u8 getchar (u16 coordx, u16 coordy);
u8 getattrib (u16 coordx, u16 coordy);
void writepxl (u16 x, u16 y, u32 color);
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color);
void line(u32 x1, u32 y1, u32 x2, u32 y2, u32 color);
void hline(u16 x1, u16 x2, u16 y, u32 color);
void changemode(u8 mode);
u32 egatorgb(u8 ega);
u8 egatovga(u8 ega);

View File

@ -10,12 +10,12 @@
/******************************************************************************/
/* Affiche une ligne entre les points spécifiés */
void linev(vertex2d * A, vertex2d * B, u8 color)
void linev(vertex2d * A, vertex2d * B, u32 color)
{
line(A->x, A->y, B->x, B->y, color);
}
void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color)
void line(u32 x1, u32 y1, u32 x2, u32 y2, u32 color)
{
s32 dx, dy, sdx, sdy;
u32 i, dxabs, dyabs, x, y, px, py;
@ -60,7 +60,7 @@ void line(u32 x1, u32 y1, u32 x2, u32 y2, u8 color)
/******************************************************************************/
/* Affiche un triangle rempli entre les points spécifiés */
void trianglefilled(vertex2d * AA, vertex2d * BB, vertex2d * CC, u8 color)
void trianglefilled(vertex2d * AA, vertex2d * BB, vertex2d * CC, u32 color)
{
vertex2d *A, *B, *C, *TEMP;
u32 a, b, y, last;
@ -132,7 +132,7 @@ void swapvertex(vertex2d * A, vertex2d * B)
/******************************************************************************/
/* Affiche un triangle entre les points spécifiés */
void triangle(vertex2d * AA, vertex2d * BB, vertex2d * CC, u8 color)
void triangle(vertex2d * AA, vertex2d * BB, vertex2d * CC, u32 color)
{
line(AA->x, AA->y, BB->x, BB->y, color);
line(BB->x, BB->y, CC->x, CC->y, color);

View File

@ -25,10 +25,10 @@ void cleardebugreg(u8* address)
u8* getdebugreg(u8 number)
{
u8* address;
if (number==0) asm("mov %%eax,%%dr0; movl %%eax,%[address]":[address] "=m" (address)::);
else if (number==1) asm("mov %%eax,%%dr1; movl %%eax,%[address]":[address] "=m" (address)::);
else if (number==2) asm("mov %%eax,%%dr2; movl %%eax,%[address]":[address] "=m" (address)::);
else if (number==3) asm("mov %%eax,%%dr3; movl %%eax,%[address]":[address] "=m" (address)::);
if (number==0) asm("mov %%dr0,%%eax; mov %%eax,%[address]":[address] "=m" (address)::);
else if (number==1) asm("mov %%dr1,%%eax; movl %%eax,%[address]":[address] "=m" (address)::);
else if (number==2) asm("mov %%dr2,%%eax; movl %%eax,%[address]":[address] "=m" (address)::);
else if (number==3) asm("mov %%dr0,%%eax; movl %%eax,%[address]":[address] "=m" (address)::);
return address;
}
@ -195,7 +195,7 @@ u16 decodeModSM(bool show, u8 *a, u8 *op, u16 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
} else{
switch(*b & 0xc7){
@ -368,7 +368,7 @@ u16 decodeModSM(bool show, u8 *a, u8 *op, u16 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
}
@ -521,7 +521,7 @@ u32 decodeModSM_float(bool show, u8 *a, u8 *op, u32 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
} else{
switch(*b & 0xc7){
@ -694,7 +694,7 @@ u32 decodeModSM_float(bool show, u8 *a, u8 *op, u32 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
}
@ -823,7 +823,7 @@ u32 decodeModSM_memonly(bool show, u8 *a, u8 *op, u32 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
} else{
switch(*b&0xc7){
@ -972,7 +972,7 @@ u32 decodeModSM_memonly(bool show, u8 *a, u8 *op, u32 order, u32 Gsz, u32 Esz){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
}
@ -1054,7 +1054,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
if(*b == 0x0f){
if (show) print("Extended opcodes not implimented.\r\n");
return;
return 1000;
} else{
@ -1606,7 +1606,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", %x", *(u8 *)++b);
@ -1640,7 +1640,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
if(flip_imm_sz){
@ -1680,7 +1680,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", %x", *(u8 *)++b);
@ -1714,7 +1714,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", %x", *(u8 *)++b);
@ -2056,7 +2056,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", %x", *(u8 *)++b);
@ -2090,7 +2090,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", %x", *(u8 *)++b);
@ -2188,7 +2188,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", 1");
@ -2222,7 +2222,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", 1");
@ -2256,7 +2256,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", cl");
@ -2290,7 +2290,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
len = strlen(op1);
snprintf(op1+len, sizeof(op1)-len, ", cl");
@ -2352,7 +2352,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
}
break;
@ -2485,7 +2485,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
break;
case 0xf7:
@ -2533,7 +2533,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
break;
case 0xf8:
@ -2562,7 +2562,7 @@ u32 disasm(u8 *a, u8 *string, bool show){
s = "dec";
} else{
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
break;
case 0xff:
@ -2597,12 +2597,12 @@ u32 disasm(u8 *a, u8 *string, bool show){
break;
default:
if (show) print("Invalid Mod R/M byte.");
return;
return 1000;
}
break;
default:
if (show) print("invalid opcode\r\n");
return;
return 1000;
}
strcompressdelimiter(s,' ');
if (show)

View File

@ -185,20 +185,41 @@ void exception1()
cli();
dumpcpu();
save_stack *dump = getESP();
exception_stack_noerror *current = getESP()+36;
exception_stack_noerror *current;
dump->eip=getdebugreg(0);
for(u32 *addr=dump;addr<KERNEL_STACK_ADDR;addr++)
{
if (*addr==dump->eip && *(addr+1)==SEL_KERNEL_CODE)
{
current = addr;
break;
}
}
dump->eip=current->eip;
dump->cs=current->cs;
dump->oldesp=(current+1);
changevc(6);
clearscreen();
show_lightcpu(&dump);
setdebugreg(0,0, DBG_CLEAR);
show_lightcpu(dump);
printf("\r\n\033[7m[P]\033[0m PAS A PAS \033[7m D \033[0m PAS A PAS DETAILLE \033[7m C \033[0m CONTINUER \033[7m S \033[0m STOPPER \033[7m V \033[0m VOIR \033[7m S \033[0m SCINDER");
sti();
waitascii();
u8 ascii=waitascii();
cli();
if (ascii=='P' || ascii=='p')
setdebugreg(0,current->eip+disasm(current->eip, NULL, false), DBG_EXEC);
if (ascii=='D' || ascii=='d')
setdebugreg(0,0, DBG_CLEAR);
else if (ascii=='C' || ascii=='c')
setdebugreg(0,0, DBG_CLEAR);
else if (ascii=='S' || ascii=='s')
{
changevc(0);
sti();
initselectors(retry_address);
}
changevc(0);
restcpu();
asm("addl $0x01C, %esp;");
asm("addl $0x028, %esp;popl %ebx;");
iret();
}

View File

@ -113,8 +113,9 @@ void mouse(void)
if (mousey >= 65535) {
mousey = 65535;
}
u16 newx = (u32) mousex * getwidth() / 65536;
u16 newy = (u32) mousey * getheight() / 65536;
videoinfos *info=getvideo_info();
u16 newx = (u32) mousex * info->currentwidth / 65536;
u16 newy = (u32) mousey * info->currentheight / 65536;
// Retrieve mouse button status from packet
mousebut1 = mpacket[0] & 1;
@ -123,15 +124,9 @@ void mouse(void)
// printf("RX:%d\tRY:%d\tX:%d\tY:%d\tB1:%d\tB2:%d\tB3:%d\t\r\n",changex,changey,mousex,mousey,mousebut1,mousebut2,mousebut3);
if ((newx != oldx) || (newy != oldy)) {
showchar(oldx, oldy, oldchar, oldattr);
oldx = newx;
oldy = newy;
oldchar = getchar(oldx, oldy);
oldattr = getattrib(oldx, oldy);
if (!info->isgraphic)
showchar(newx, newy, 0xDB, 0x0F);
}
}
endofint:
irqendmaster();
irqendslave();

View File

@ -420,10 +420,14 @@ int rebootnow()
int test2d()
{
changemode(0x83);
videoinfos *vinfo=getvideo_info();
if (!vinfo->isgraphic) {
print("Mode graphique necessaire afin de lancer ce programme\r\n");
return 1;
}
struct vertex2d a, b, c;
randomize();
u32 color;
for (int i = 0; i < 3000; i++) {
a.x = random(0, vinfo->currentwidth);
a.y = random(0, vinfo->currentheight);
@ -431,8 +435,14 @@ int test2d()
b.y = random(0, vinfo->currentheight);
c.x = random(0, vinfo->currentwidth);
c.y = random(0, vinfo->currentheight);
trianglefilled(&a, &b, &c, random(0, 16));
triangle(&a, &b, &c, 2);
if (vinfo->currentdepth>24)
color=egatorgb(random(0,16));
else if (vinfo->currentdepth==8)
color=random(0,256);
else
color=random(0,16);
trianglefilled(&a, &b, &c, color);
triangle(&a, &b, &c, color);
}
return 0;
}

View File

@ -114,8 +114,7 @@ u32 VESA_mem_to_video (void *src,u32 dst, u32 size, bool increment_src) {
case 32:
if (!increment_src)
{
u32 pattern = (u32) src;
stosd(pattern,realdst,size);
stosd(src,realdst,size);
}
else
{

View File

@ -1133,7 +1133,7 @@ u8 getattrib (u16 coordx, u16 coordy)
/******************************************************************************/
/* Affiche une ligne horizontale entre les points spécifiés */
void hline(u32 x1, u32 x2, u32 y, u8 color)
void hline(u16 x1, u16 x2, u16 y, u32 color)
{
if (vinfo->isgraphic)
{

View File

@ -103,5 +103,6 @@ int main(u32 magic, u32 addr)
ok();
retry:
sti();
shell();
}