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
|
||||
$(QUIET_FAS)
|
||||
${Q}./first -i test.asm -a test.rom
|
||||
${Q}./first -i $< -a $@
|
||||
|
||||
%.o:%.c
|
||||
${QUIET_CC}
|
||||
|
@ -328,8 +328,8 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
||||
while(line[x]==' ')x++;
|
||||
if(line[x]==0||line[x]=='#')
|
||||
return -1;//empty line or comment
|
||||
if( ((call=strncmp(line,"JMP ",4))==0) || (strncmp(line,"CALL ",5)==0) ){
|
||||
if(call){
|
||||
if( (strncmp(line,"JMP,",4)==0) || (strncmp(line,"JMP ",4)==0) || ((call=strncmp(line,"CALL ",5))==0) ){
|
||||
if(!call){
|
||||
x=4;
|
||||
opcode=0x10;
|
||||
}else{
|
||||
@ -652,7 +652,7 @@ int64_t assemble_line(char *line, struct assembler_context_t *assembler_context)
|
||||
}else{
|
||||
temp=imm->value;
|
||||
free(imm);
|
||||
return temp;
|
||||
return (temp&0xFF000000)>>24|(temp&0x00FF0000)>>8|(temp&0x0000FF00)<<8|(temp&0x000000FF>>24);
|
||||
}
|
||||
}else
|
||||
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_op2->data=op2;
|
||||
switch(opcode){
|
||||
case 0x00:
|
||||
case 0x01:
|
||||
case 0x02:
|
||||
case 0x03:
|
||||
@ -274,8 +275,8 @@ int exec(struct simdata_t *simdata){
|
||||
break;
|
||||
case ALU_SUB:
|
||||
case ALU_CMP:
|
||||
result = simdata->registers->GPR[simdata->exec_data->in_op1->data] -
|
||||
simdata->registers->GPR[simdata->exec_data->in_op2->data];
|
||||
result = 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->GPR[simdata->exec_data->out_op->data] > simdata->registers->GPR[simdata->exec_data->in_op1->data])<<1;
|
||||
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){
|
||||
int dx,dy,p,x,y;
|
||||
dx=x1-x0;
|
||||
dy=y1-y0;
|
||||
x=x0;
|
||||
y=y0;
|
||||
p=2*dy-dx;
|
||||
|
||||
int dx = abs(x1-x0), sx = x0<x1 ? 1 : -1;
|
||||
int dy = abs(y1-y0), sy = y0<y1 ? 1 : -1;
|
||||
int err = (dx>dy ? dx : -dy)/2, e2;
|
||||
|
||||
uint32_t addr;
|
||||
while(x<x1){
|
||||
if(p>=0){
|
||||
addr=x+y*buffer_width;
|
||||
if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x<buffer_width&&x>0)
|
||||
for(;;){
|
||||
addr=x0+y0*buffer_width;
|
||||
if(addr>0&&addr<(uint64_t)(buffer_width*buffer_height)&&x0<buffer_width&&x0>0)
|
||||
buffer[addr]=1;
|
||||
y=y+1;
|
||||
p=p+2*dy-2*dx;
|
||||
}else{
|
||||
addr=x+y*buffer_width;
|
||||
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;
|
||||
if (x0==x1 && y0==y1) break;
|
||||
e2 = err;
|
||||
if (e2 >-dx) { err -= dy; x0 += sx; }
|
||||
if (e2 < dy) { err += dx; y0 += sy; }
|
||||
}
|
||||
}
|
||||
|
||||
@ -613,8 +606,8 @@ int update_general_terminal_output(struct simdata_t *simdata){
|
||||
|
||||
int vfb_width=(width-2)*2;
|
||||
int vfb_height=(height-2)*4;
|
||||
for(uint64_t i=0;i < simdata->terminal_output_size;i+=4){
|
||||
uint32_t c=simdata->terminal_output[i/4];
|
||||
for(uint64_t i=0;i < simdata->terminal_output_size/4;i++){
|
||||
uint32_t c=simdata->terminal_output[i];
|
||||
if(vector){
|
||||
float x0,y0,x1,y1;
|
||||
switch(vstate){
|
||||
|
18
test.asm
18
test.asm
@ -42,20 +42,20 @@ MOV %R1,(%R0)
|
||||
MOV $0x0000,%R1l
|
||||
MOV $0x0000,%R1h
|
||||
MOV %R1,(%R0)
|
||||
MOV $0xcccd,%R1l
|
||||
MOV $0xbf4c,%R1h
|
||||
MOV $0x0000,%R1l
|
||||
MOV $0xbf80,%R1h
|
||||
MOV %R1,(%R0)
|
||||
MOV $0xcccd,%R1l
|
||||
MOV $0xbf4c,%R1h
|
||||
MOV $0x0000,%R1l
|
||||
MOV $0xbf80,%R1h
|
||||
MOV %R1,(%R0)
|
||||
MOV $0xcccd,%R1l
|
||||
MOV $0x3f4c,%R1h
|
||||
MOV $0x0000,%R1l
|
||||
MOV $0x0000,%R1h
|
||||
MOV %R1,(%R0)
|
||||
MOV $0x0000,%R1l
|
||||
MOV $0x3f80,%R1h
|
||||
MOV %R1,(%R0)
|
||||
|
||||
#Test Indirect read/writes
|
||||
MOV $0xcccd,%R1l
|
||||
MOV $0x3f4c,%R1h
|
||||
MOV %R1,(%R0)
|
||||
MOV $>TR_LOW,%R0l
|
||||
MOV $<TR_LOW,%R0h
|
||||
MOV %R1,(%R0)
|
||||
|
Loading…
Reference in New Issue
Block a user