Skip to content

Commit

Permalink
Emprolijo game.c , isr.asm y imprimir.mac
Browse files Browse the repository at this point in the history
  • Loading branch information
lbadell committed Jul 10, 2016
1 parent b54d89d commit c9a26e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 89 deletions.
40 changes: 13 additions & 27 deletions entregable/src/game.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,26 @@ int juegoEstaIniciado = 0;
int tareasEnJuego[2];
int vidasAzul;
int vidasRojas;
char pila[3040]; // Mi idea es usar este registro como pila de la pantalla
unsigned int ack[25]; // Mi Idea es usar este registro como pila para los valores de debug
char pila[3040];


unsigned int dameack()
{

return (unsigned int) &ack;
}


void copiar()
{ //Quiero que esta funcion copie el buffer del video
{ /*Lo que hace esta fumcion, es guardar en el array pila la parte de la pantalla
que se pisa cuando cae una excepcion en el modo debug*/
char * video = (char*) 0xB8000;
int pos = 0 ;

//video +=1280;
//pila[0] = *video;

int i = 8;
for (i = 5; i < 43; ++i)
{
int j = 19;
for (j = 19; j < 59; ++j)
{
//*(video+(160*i)+(2*j))=pila[pos];
pila[pos]=*(video+(160*i)+(2*j));
pos ++;
//*(video+(160*i)+(2*j)+1)=pila[pos];
pila[pos]=*((video+1)+(160*i)+(2*j));
pos++;
}
Expand All @@ -60,23 +52,19 @@ void copiar()


void pegar()
{
{ /*Esta funcion deja la pantalla como estaba antes de que salga una excepcion */
char * video = (char*) 0xB8000;
int pos = 0 ;

//video +=1280;
//pila[0] = *video;
int i = 8;
for (i = 5; i < 43; ++i)
{
int j = 19;
for (j = 19; j < 59; ++j)
{
*(video+(160*i)+(2*j))=pila[pos];
//pila[pos]=*(video+(160*i)+(2*j));
pos ++;
*(video+(160*i)+(2*j)+1)=pila[pos];
//pila[pos]=*((video+1)+(160*i)+(2*j));
pos++;
}

Expand Down Expand Up @@ -128,9 +116,8 @@ void pintarRecuadroDebug(){
print("a",58,fila,C_FG_BLACK | C_BG_BLACK );
}

//Ahora pintamos , el texto
//Ahora pintamos el texto
int flag= tareaActual->dueno;
//tareaActul->dueno ; 0 ; 1 ; 2 Rojo ; Azul ; Verde
int i ;
if (flag==0) // Esto es para pintar rojo
{
Expand Down Expand Up @@ -168,7 +155,6 @@ void atenderdebug(unsigned int cr0, unsigned int cr2, unsigned int cr3, unsigned
unsigned int edi, unsigned int ebp, unsigned int ds,unsigned int es, unsigned int fs, unsigned int gs,
unsigned int ss, unsigned int esp, unsigned int eflags, unsigned int cs, unsigned int eip,unsigned int eax)
{
//char * video = (char*) 0xB8000;
if (debugActivado==1) // Si esta activado...
{
copiar();
Expand Down Expand Up @@ -238,7 +224,7 @@ void iniciarGame(){
debugActivado=0; // 0 Desactivado , 1 Activado
puntajeAzul = 0;
puntajeRojo = 0;
muestraInfo = 0;
muestraInfo = 0;
print("Yo no manejo el rating, yo manejo un rolls-royce", 14, 0, (C_BG_BLACK | C_FG_WHITE));
juegoEstaIniciado = 1;
tareasEnJuego[0] = 0;
Expand All @@ -249,14 +235,14 @@ void iniciarGame(){
vidasRojas = 15;
print_int(vidasRojas, 44, 48, (C_BG_BLACK | C_FG_WHITE));
print_int(vidasAzul, 63, 48, (C_BG_BLACK | C_FG_WHITE));
print("TAREAS", 68, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print("TAREAS", 34, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print_int(0, 70, 48, (C_BG_BLACK | C_FG_WHITE));
print_int(0, 36, 48, (C_BG_BLACK | C_FG_WHITE));
print("TAREAS", 68, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print("TAREAS", 34, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print_int(0, 70, 48, (C_BG_BLACK | C_FG_WHITE));
print_int(0, 36, 48, (C_BG_BLACK | C_FG_WHITE));
print_int(0, 51, 47, (C_BG_RED | C_FG_WHITE));
print_int(0, 57, 47, (C_BG_BLUE | C_FG_WHITE));
print("<A", 13, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print("B>", 22, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print("<A", 13, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
print("B>", 22, 46, (C_BG_BLACK | C_FG_LIGHT_GREY));
}

int juegoIniciado(){
Expand Down
4 changes: 2 additions & 2 deletions entregable/src/imprimir.mac
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ pop eax ; EAX = Caracter
pop ebx ; EBX = Atributos
mov ecx , 0x000B8000 ; ECX = Donde Arranca Buffer Video
add ecx , 158 ; Offset para la ultima columna de la primera fila
mov byte [ECX] , AL
mov [ECX] , AL
inc ecx
mov byte [ECX] , BL
mov [ECX] , BL
popad
%endmacro

Expand Down
61 changes: 1 addition & 60 deletions entregable/src/isr.asm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
%define VIRUS_ROJO 0x841
%define VIRUS_AZUL 0x325

extern dameack
extern habilitarDebug
extern atenderdebug
extern volverDeExcepcion
Expand Down Expand Up @@ -233,61 +232,6 @@ ISR 19
;; Rutina de atención del RELOJ
;; -------------------------------------------------------------------------- ;;

salvarRegs:
push eax ; Como lo voy a pisar , primero lo guardo
call dameack ; Ahora EAX tiene donde arranca el array ; Esta en Game.c
;Dejo 4 para poner EAX al principio, esto lo voy a hacer al final
mov dword [eax+4] , ebx
add eax ,4
mov dword [EAX],ECX
add eax , 4
mov dword [EAX] , EDX
add eax , 4
mov dword [EAX], ESI
add eax , 4
mov dword [EAX] , EDI
add eax , 4
mov dword [EAX] , EBP
add eax , 4
mov dword [EAX] , ESP
add eax , 4
mov dword [EAX] , EBX ; Aca iria EIP pero ni idea como hacerlo
add eax , 4
mov [EAX] , CS
add eax , 4
mov [EAX] , DS
add eax , 4
mov [EAX] , FS
add eax , 4
mov [EAX] , GS
add eax , 4
mov [EAX] , SS
add eax , 4
;pushfd ; Pusheo EFlags
;pop ebx ; Levanto EFLAGS em EBX ; Las Flags se pushean ?
mov dword [EAX] , EBX ; Aca iria EFLAGS ,
add eax , 4 ; Faltan los CR
mov ebx , CR0
mov dword [EAX] , EBX ; CR0
add eax , 4
mov ebx , CR1
mov dword [EAX] , ebx ; CR1
add eax ,4
mov ebx , CR2
mov dword [EAX] , EBX ; CR2
add eax , 4
mov ebx , CR3
mov dword [EAX] , EBX ; CR3
add eax , 4
mov EBX , CR4
mov [EAX] , EBX ; CR4
add eax , 4
mov ebx , eax ; Ahora ebx tiene el puntero
sub ebx , 76d ; 19 * 4 ; Hice 19 add si no manquee al contar
pop eax
mov [EBX] , EAX
;Queda EIP de la tarea cuando exploto , creo que eso se pushea a la pila , sera [EBP+X]
ret

_isr32:
pushad
Expand All @@ -300,7 +244,6 @@ _isr32:
je .salirDeReloj
call pintarTareasH
call sched_proximo_indice
;xchg bx, bx
shl eax, 3

mov [selector], ax
Expand Down Expand Up @@ -340,7 +283,7 @@ _isr33:
Palpatine ebx, 0x4
push 0xA33 ; 0xA33 = ARB del game.h
push 0 ;
call game_mover_cursor ; En 32 bits, los parametros se pasan por la pila
call game_mover_cursor
pop ebx
pop ebx
jmp .fin
Expand Down Expand Up @@ -443,11 +386,9 @@ _isr33:
mov ebx ,"R"
Palpatine ebx, 0x9
push 1
; xchg bx, bx
call game_lanzar
pop ebx
jmp .fin
; Me queda hacer la interrupcion de la y, el modo debug mencionado en la sec 3.4
; Si llego aca es que se apreto alguna tecla no valida
.teclaY:
cmp al , Y
Expand Down

0 comments on commit c9a26e4

Please sign in to comment.