Project: fixed several small bugs and changed the implementation of the line drawing algorythm for the braille display to one that actually works
This commit is contained in:
parent
fd86df806b
commit
19deb0581c
2
Makefile
2
Makefile
@ -28,7 +28,7 @@ first: ${OBJECT_FILES}
|
|||||||
|
|
||||||
%.rom:%.asm first
|
%.rom:%.asm first
|
||||||
$(QUIET_FAS)
|
$(QUIET_FAS)
|
||||||
${Q}./first -i test.asm -a test.rom
|
${Q}./first -i $< -a $@
|
||||||
|
|
||||||
%.o:%.c
|
%.o:%.c
|
||||||
${QUIET_CC}
|
${QUIET_CC}
|
||||||
|
@ -328,8 +328,8 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
|||||||
while(line[x]==' ')x++;
|
while(line[x]==' ')x++;
|
||||||
if(line[x]==0||line[x]=='#')
|
if(line[x]==0||line[x]=='#')
|
||||||
return -1;//empty line or comment
|
return -1;//empty line or comment
|
||||||
if( ((call=strncmp(line,"JMP ",4))==0) || (strncmp(line,"CALL ",5)==0) ){
|
if( (strncmp(line,"JMP,",4)==0) || (strncmp(line,"JMP ",4)==0) || ((call=strncmp(line,"CALL ",5))==0) ){
|
||||||
if(call){
|
if(!call){
|
||||||
x=4;
|
x=4;
|
||||||
opcode=0x10;
|
opcode=0x10;
|
||||||
}else{
|
}else{
|
||||||
@ -652,7 +652,7 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
|||||||
}else{
|
}else{
|
||||||
temp=imm->value;
|
temp=imm->value;
|
||||||
free(imm);
|
free(imm);
|
||||||
return temp;
|
return (temp&0xFF000000)>>24|(temp&0x00FF0000)>>8|(temp&0x0000FF00)<<8|(temp&0x000000FF>>24);
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
return -2;
|
return -2;
|
||||||
|
5
cpu.c
5
cpu.c
@ -82,6 +82,7 @@ int decode(struct simdata_t *simdata){
|
|||||||
simdata->exec_data->in_op1->data=op1;
|
simdata->exec_data->in_op1->data=op1;
|
||||||
simdata->exec_data->in_op2->data=op2;
|
simdata->exec_data->in_op2->data=op2;
|
||||||
switch(opcode){
|
switch(opcode){
|
||||||
|
case 0x00:
|
||||||
case 0x01:
|
case 0x01:
|
||||||
case 0x02:
|
case 0x02:
|
||||||
case 0x03:
|
case 0x03:
|
||||||
@ -274,8 +275,8 @@ int exec(struct simdata_t *simdata){
|
|||||||
break;
|
break;
|
||||||
case ALU_SUB:
|
case ALU_SUB:
|
||||||
case ALU_CMP:
|
case ALU_CMP:
|
||||||
result = simdata->registers->GPR[simdata->exec_data->in_op1->data] -
|
result = simdata->registers->GPR[simdata->exec_data->in_op2->data] -
|
||||||
simdata->registers->GPR[simdata->exec_data->in_op2->data];
|
simdata->registers->GPR[simdata->exec_data->in_op1->data];
|
||||||
simdata->registers->FLAGS=(simdata->registers->FLAGS&0xFFFFFFFD)|
|
simdata->registers->FLAGS=(simdata->registers->FLAGS&0xFFFFFFFD)|
|
||||||
(simdata->registers->GPR[simdata->exec_data->out_op->data] > simdata->registers->GPR[simdata->exec_data->in_op1->data])<<1;
|
(simdata->registers->GPR[simdata->exec_data->out_op->data] > simdata->registers->GPR[simdata->exec_data->in_op1->data])<<1;
|
||||||
break;
|
break;
|
||||||
|
35
gui.c
35
gui.c
@ -574,27 +574,20 @@ int print_braille_frame_buffer(WINDOW* win,uint8_t *buffer,int width,int height)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void braille_frame_buffer_line(uint8_t *buffer,int buffer_width,int buffer_height,int x0, int y0, int x1, int y1){
|
void braille_frame_buffer_line(uint8_t *buffer,int buffer_width,int buffer_height,int x0, int y0, int x1, int y1){
|
||||||
int dx,dy,p,x,y;
|
|
||||||
dx=x1-x0;
|
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
|
||||||
dy=y1-y0;
|
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
|
||||||
x=x0;
|
int err = (dx>dy ? dx : -dy)/2, e2;
|
||||||
y=y0;
|
|
||||||
p=2*dy-dx;
|
|
||||||
uint32_t addr;
|
uint32_t addr;
|
||||||
while(x<x1){
|
for(;;){
|
||||||
if(p>=0){
|
addr=x0+y0*buffer_width;
|
||||||
addr=x+y*buffer_width;
|
if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x0<buffer_width&&x0>0)
|
||||||
if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x<buffer_width&&x>0)
|
|
||||||
buffer[addr]=1;
|
buffer[addr]=1;
|
||||||
y=y+1;
|
if (x0==x1 && y0==y1) break;
|
||||||
p=p+2*dy-2*dx;
|
e2 = err;
|
||||||
}else{
|
if (e2 >-dx) { err -= dy; x0 += sx; }
|
||||||
addr=x+y*buffer_width;
|
if (e2 < dy) { err += dx; y0 += sy; }
|
||||||
if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x<buffer_width&&x>0)
|
|
||||||
buffer[addr]=1;
|
|
||||||
p=p+2*dy;
|
|
||||||
}
|
|
||||||
x=x+1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -613,8 +606,8 @@ int update_general_terminal_output(struct simdata_t *simdata){
|
|||||||
|
|
||||||
int vfb_width=(width-2)*2;
|
int vfb_width=(width-2)*2;
|
||||||
int vfb_height=(height-2)*4;
|
int vfb_height=(height-2)*4;
|
||||||
for(uint64_t i=0;i < simdata->terminal_output_size;i+=4){
|
for(uint64_t i=0;i < simdata->terminal_output_size/4;i++){
|
||||||
uint32_t c=simdata->terminal_output[i/4];
|
uint32_t c=simdata->terminal_output[i];
|
||||||
if(vector){
|
if(vector){
|
||||||
float x0,y0,x1,y1;
|
float x0,y0,x1,y1;
|
||||||
switch(vstate){
|
switch(vstate){
|
||||||
|
18
test.asm
18
test.asm
@ -42,20 +42,20 @@ MOV %R1,(%R0)
|
|||||||
MOV $0x0000,%R1l
|
MOV $0x0000,%R1l
|
||||||
MOV $0x0000,%R1h
|
MOV $0x0000,%R1h
|
||||||
MOV %R1,(%R0)
|
MOV %R1,(%R0)
|
||||||
MOV $0xcccd,%R1l
|
MOV $0x0000,%R1l
|
||||||
MOV $0xbf4c,%R1h
|
MOV $0xbf80,%R1h
|
||||||
MOV %R1,(%R0)
|
MOV %R1,(%R0)
|
||||||
MOV $0xcccd,%R1l
|
MOV $0x0000,%R1l
|
||||||
MOV $0xbf4c,%R1h
|
MOV $0xbf80,%R1h
|
||||||
MOV %R1,(%R0)
|
MOV %R1,(%R0)
|
||||||
MOV $0xcccd,%R1l
|
MOV $0x0000,%R1l
|
||||||
MOV $0x3f4c,%R1h
|
MOV $0x0000,%R1h
|
||||||
|
MOV %R1,(%R0)
|
||||||
|
MOV $0x0000,%R1l
|
||||||
|
MOV $0x3f80,%R1h
|
||||||
MOV %R1,(%R0)
|
MOV %R1,(%R0)
|
||||||
|
|
||||||
#Test Indirect read/writes
|
#Test Indirect read/writes
|
||||||
MOV $0xcccd,%R1l
|
|
||||||
MOV $0x3f4c,%R1h
|
|
||||||
MOV %R1,(%R0)
|
|
||||||
MOV $>TR_LOW,%R0l
|
MOV $>TR_LOW,%R0l
|
||||||
MOV $<TR_LOW,%R0h
|
MOV $<TR_LOW,%R0h
|
||||||
MOV %R1,(%R0)
|
MOV %R1,(%R0)
|
||||||
|
Loading…
Reference in New Issue
Block a user