max_process y correccion de bug

This commit is contained in:
Gabriel Lorenzo 2002-09-24 21:13:13 +00:00
parent 17321e69a8
commit fbe03ef4e8
10 changed files with 46 additions and 282 deletions

View file

@ -7,6 +7,7 @@ begin
load_bmp("hola.bmp");
load_fnt("system.fnt");
write_int(1,0,0,0,&numprocs);
define_region(1,0,10,320,190);
loop
if(key(_space)) cosa(); numprocs++; end
if(key(_w)) delete_text(all_text); end
@ -21,6 +22,8 @@ begin
x=rand(0,319);
y=rand(0,199);
region=1;
loop
frame;
x+=rand(-1,1);

View file

@ -98,8 +98,8 @@ void dll_error(int error, ...)
printf("%s\n",mensaje);
#endif
/*printf("\n");
n_errors++;*/
//printf("\n");
//n_errors++;
exit(-1);
}

View file

@ -32,7 +32,7 @@
#include "extern.h"
#include "edivfont.h"
#include "kernel.h"
//#include "kernel.h"
#include "inte.h"
#include "main.h"
#include "dll.h"
@ -144,7 +144,7 @@ int interprete()
Call_Entrypoint(EDIV_frame);
}else
{
stub_quit() ;
stub_quit(0) ;
}
@ -310,11 +310,12 @@ int proceso( int num )
mem[pila[sp--]]=pila[reserved("param_offset",procs_s[num_proc].id)++];
break;
case ltyp://32
procs_s[num_proc].id = mem[2] + ( num_proc * iloc_len ) ;
reserved("process_id",procs_s[num_proc].id)=procs_s[num_proc].id;
memcpy(&mem[procs_s[num_proc].id],&mem[iloc],iloc_pub_len<<2);
if ( procs_s[num_proc].tipo != 0 )
critical_error(3); // redefinición del tipo de proceso
procs_s[num_proc].id = mem[2] + ( num_proc * iloc_len ) ;
if(procs_s[num_proc].id>imem_max-iloc_len) critical_error(8); // demasiados procesos en ejecución
reserved("process_id",procs_s[num_proc].id)=procs_s[num_proc].id;
memcpy(&mem[procs_s[num_proc].id],&mem[iloc],iloc_pub_len<<2);
procs_s[num_proc].tipo = mem[ imem++ ] ;
reserved("process_type",procs_s[num_proc].id) = procs_s[num_proc].tipo ;
inicio_privadas=mem[6];

View file

@ -1,191 +0,0 @@
/*
* eDiv Compiler
* Copyleft (C) 2000-2002 Sion Entertainment
* http://www.sion-e.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Este fichero contien el codigo del Kernel del eDiv
* by Riseven
*
*/
// se supone ke todo esto sirve para algo? (Er_Makina)
#include <stdio.h>
#include <string.h>
#ifdef WIN32
#include <windows.h>
#endif
#include <SDL/SDL.h>
#include "edivfont.h"
#include "kernel.h"
#include "inte.h"
#include "extern.h"
#include "main.h"
struct _k_error_s k_error_s[50] ;
int ini_kernel()
{
//FILE *fp ; // AHORA FP ES OTRA COSA MAS IMPORTANTE XDDD
FILE *im ;
char *pool ;
fpos_t pos ;
// EDIV NOID
/*
fp = fopen("fuente.fnt", "r" ) ;
im = fopen("tempo.bmp", "w" ) ;
printf( "\n%i\n" , ftell( fp ) ) ;
printf( "\nsizeof control:%i\n" , sizeof(fuente_control_s[0]) ) ;
//printf( "leido:%i\n" , (int)fread( &fuente_control_s[0] , 1 , sizeof(fuente_control_s[0]) , fp ) ) ;
printf( "leido:%i\n" , (int)fread( &fuente_control_s[0] , 1 , 1393 , fp ) ) ;
printf( "Sizeof imagen: %i" , fuente_control_s[0].size_imagen ) ;
if (!(pool = malloc(fuente_control_s[0].size_imagen + 1 ) ) )
printf("Error: Memoria insuficiente" ) ;
pos = fuente_control_s[0].offset_imagen + 10;
fsetpos(fp , &pos ) ;
printf( "\n%i\n%i\n" , ftell( fp ), fuente_control_s[0].offset_imagen ) ;
printf( "leido:%i\n" , fread( pool , 1 , fuente_control_s[0].size_imagen , fp ) ) ;
//fwrite( &fuente_control_s , 1 , 2060 , fp ) ;
printf( "\n%i\n%i\n" , ftell( fp ), fuente_control_s[0].size_imagen ) ;
getchar() ;
fwrite( pool , 1 , fuente_control_s[0].size_imagen , im ) ;
free( pool ) ;
fclose( im ) ;
fclose(fp) ;
// Sacamos la fuente
fuente_control_s[0].imagen = SDL_LoadBMP("tempo.bmp") ;
// Escribimos A
textos_s[0].cadena = SDL_CreateRGBSurface(SDL_HWSURFACE, fuente_control_s[0].rect[173].w, fuente_control_s[0].rect[173].h, 24, 0xFF0000, 0x00FF00, 0x0000FF, 0x000000);
SDL_BlitSurface( fuente_control_s[0].imagen , &fuente_control_s[0].rect[173] , textos_s[0].cadena , NULL ) ;
textos_s[0].x = 20 ;
textos_s[0].y = 20 ;
textos_s[0].existe = 1 ;
imgs[0] = SDL_LoadBMP( "BG.bmp" ) ;
if ( imgs[0] == NULL )
exit(0);
imgs[1] = SDL_LoadBMP( "bola.bmp" ) ;
if ( imgs[1] == NULL )
exit(0);
imgs[2] = SDL_LoadBMP( "barra.bmp" ) ;
if ( imgs[2] == NULL )
exit(0);
*/
/*
//Cargamos bola.bmp PROVISIONAL mientras se hace Load_BMP()
imgs[0] = SDL_LoadBMP( "bola.bmp" ) ;
if ( imgs[0] == NULL )
exit(0) ;
*/
strcpy( k_error_s[K_ERR_SDL_INIT].cadena , "NO SE PUDO INICIALIZAR LA SDL" );
k_error_s[K_ERR_SDL_INIT].nivel = 1000 ;
strcpy( k_error_s[K_ERR_SDL_SET_VIDEO_MODE].cadena , "NO SE PUDO ESTABLECER EL MODO GRAFICO" );
k_error_s[K_ERR_SDL_SET_VIDEO_MODE].nivel = 900 ;
strcpy( k_error_s[K_ERR_KERNEL].cadena , "ERROR DURANTE LA EJECUCION DEL KERNEL" );
k_error_s[K_ERR_KERNEL].nivel = 400 ;
strcpy( k_error_s[K_ERR_INTERPRETE].cadena , "ERROR DURANTE LA EJECUCION DEL INTERPRETE" );
k_error_s[K_ERR_INTERPRETE].nivel = 1000 ;
strcpy( k_error_s[K_ERR_INI_INTERPRETE].cadena , "ERROR DURANTE LA INICIALIZACION DEL INTERPRETE" );
k_error_s[K_ERR_INI_INTERPRETE].nivel = 1000 ;
return 0;
}
// KERNEL
// Se encarga de los procesos internos del stub
// by Riseven
int kernel()
{
int i ;
// SDL_Rect dst_rect;
// SDL_Rect src_rect ;
/*
// Para el testeo
for ( i = 0 ; i < num_proc_orden ; i++ )
{
lista_draw_proc_s[0].imagen = imgs[0] ;
lista_draw_proc_s[0].x = mem[procs_s[proc_orden[i]].id + _X -1 ] ;
lista_draw_proc_s[0].y = mem[procs_s[proc_orden[i]].id + _Y -1 ] ;
}
num_draw_proc = i ;
// Se dibujan los graficos que proceden de procesos
for ( i = 0 ; i < num_draw_proc ; i++ )
{
dst_rect.x = lista_draw_proc_s[i].x ;
dst_rect.y = lista_draw_proc_s[i].y ;
dst_rect.w = lista_draw_proc_s[i].imagen->w ;
dst_rect.h = lista_draw_proc_s[i].imagen->h ;
SDL_BlitSurface( lista_draw_proc_s[i].imagen , NULL , screen , &dst_rect ) ;
}
*/
/*
// Se escriben los textos ( ESTO SE TENDRA K MEZCLAR CON LO ANTERIOR
for ( i = 0 ; i < 256 ; i++ )
{
if ( textos_s[i].existe == 1 )
{
dst_rect.x = textos_s[i].x ;
dst_rect.y = textos_s[i].y ;
dst_rect.w = textos_s[i].cadena->w ;
dst_rect.h = textos_s[i].cadena->h ;
SDL_BlitSurface( textos_s[i].cadena , NULL , screen , &dst_rect ) ;
}
}
*/
//SDL_Flip(screen) ;
return 1 ;
}
void k_error( int codigo )
{
fprintf(stdout, k_error_s[codigo].cadena ) ;
if ( k_error_s[codigo].nivel >= K_ERROR_EXIT )
exit(0) ;
}

View file

@ -1,58 +0,0 @@
/*
* eDiv Compiler
* Copyleft (C) 2000-2002 Sion Entertainment
* http://www.sion-e.com
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef __KERNEL_H
#define __KERNEL_H
// CODIGOS DE ERROR DEL KERNEL
#define K_ERR_SDL_INIT 0
#define K_ERR_SDL_SET_VIDEO_MODE 1
#define K_ERR_KERNEL 2
#define K_ERR_INTERPRETE 3
#define K_ERR_INI_INTERPRETE 4
// NIVEL CRITICO DE ERROR DEL KERNEL
#define K_ERROR_EXIT 500
struct _k_error_s {
char cadena[64];
int nivel;
};
struct _lista_draw_proc_s{
SDL_Surface *imagen;
int x,y;
} lista_draw_proc_s[512];
int num_draw_proc;
struct _textos_s {
SDL_Surface *cadena;
int x,y;
int existe;
} textos_s[256];
int ini_kernel();
int kernel();
void k_error(int codigo);
#endif /* __KERNEL_H */

View file

@ -782,7 +782,7 @@ char* translate_runtime_error(int num)
char* translate_critical_error(int num)
{
static char *e[NUM_LANGUAGES][7] = {
static char *e[NUM_LANGUAGES][9] = {
/* 0 - ESPAÑOL */
@ -793,6 +793,8 @@ char* translate_critical_error(int num)
/* 4 */ "No se pudo reservar memoria para la pila",
/* 5 */ "Librería no encontrada: %s",
/* 6 */ "%s no es una librería válida de eDIV",
/* 7 */ "No se pudo inicializar SDL",
/* 8 */ "Demasiados procesos en ejecución"
/* 1 - ITALIANO */
@ -803,6 +805,8 @@ char* translate_critical_error(int num)
/* 4 */ "Non si è potuto riservare memoria per la pila",
/* 5 */ "Libreria non trovata: %s",
/* 6 */ "%s non è una libreria valida di eDIV",
/* 7 */ "No se pudo inicializar SDL", // TODO
/* 8 */ "Demasiados procesos en ejecución", // TODO
/* 2 - PORTUGUÉS (FIXMI: traducir) */
@ -813,6 +817,8 @@ char* translate_critical_error(int num)
/* 4 */ "No se pudo reservar memoria para la pila",
/* 5 */ "Librería no encontrada: %s",
/* 6 */ "%s no es una librería válida de eDIV",
/* 7 */ "No se pudo inicializar SDL",
/* 8 */ "Demasiados procesos en ejecución",
/* 3 - INGLÉS */
@ -823,6 +829,8 @@ char* translate_critical_error(int num)
/* 4 */ "Can't allocate stack memory",
/* 5 */ "Library not found: %s",
/* 6 */ "%s is not a valid eDIV library",
/* 7 */ "Cannot initialize SDL",
/* 8 */ "Too many processes in execution",
/* 4 - CATALÁN */
@ -833,6 +841,8 @@ char* translate_critical_error(int num)
/* 4 */ "No es va poder reservar memòria per a la pila",
/* 5 */ "Llibreria no trobada: %s",
/* 6 */ "%s no és una llibreria vàlida d' eDIV",
/* 7 */ "No se pudo inicializar SDL", // TODO
/* 8 */ "Demasiados procesos en ejecución", // TODO
/* 5 - EUSKERA */
@ -842,7 +852,9 @@ char* translate_critical_error(int num)
/* 3 */ "Prozesu motaren berdefinizioa",
/* 4 */ "Ezin izan da memoriarik erreserbatu pilarentzat",
/* 5 */ "Ezin da liburutegia aurkitu: %s",
/* 6 */ "%s ez da eDIV-en liburutegi zuzen bat"
/* 6 */ "%s ez da eDIV-en liburutegi zuzen bat",
/* 7 */ "No se pudo inicializar SDL", // TODO
/* 8 */ "Demasiados procesos en ejecución", // TODO
};
return e[idioma][num];

View file

@ -85,7 +85,7 @@ int* lin;
void error(int num, ...); // Mensaje de error no crítico (trazable)
void critical_error(int num, ...); // Mensaje de error crítico
void stub_quit(void); // Salir del stub
void stub_quit(int n); // Salir del stub
void* e_malloc(size_t size); // identico a malloc pero con errormsg utomático
#endif /* __MAIN_H */

View file

@ -18,8 +18,6 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <assert.h>
#include <io.h>
#include <fcntl.h>
#include <stdio.h>
@ -31,7 +29,7 @@
#include "extern.h"
#include "main.h"
#include "kernel.h"
//#include "kernel.h"
#include "inte.h"
#include "varindex.h"
#include "fatal.h"
@ -235,19 +233,18 @@ int main(int argc, char* argv[])
// Nota: las DLL's se cargan en el transcurso del programa (las instrucciones
// que ordenan cargar las dll's necesarias se encuentran en el propio bytecode)
if (ini_kernel())
exit (0);
//if (ini_kernel())
// exit (0);
// AHORA TODO ESTO EN LA GRAPHICS.DLL
// SE INICIALIZA LA SDL
if (SDL_Init(SDL_INIT_TIMER))
k_error(K_ERR_SDL_INIT);
critical_error(7); // no puedo inicializar SDL
atexit(stub_quit);
//atexit(stub_quit);
// SE PONE EL MODO GRAFICO 320x200 MODO VENTANA
// Ya se hara el modo full screen
@ -259,8 +256,9 @@ int main(int argc, char* argv[])
if ( screen == NULL )
k_error(K_ERR_SDL_SET_VIDEO_MODE);
*/
if ( !ini_interprete() )
k_error(K_ERR_INI_INTERPRETE) ;
ini_interprete();
/*if ( !ini_interprete() )
k_error(K_ERR_INI_INTERPRETE) ;*/
while (1) {
@ -292,13 +290,14 @@ int main(int argc, char* argv[])
}
if (!interprete())
k_error(K_ERR_INTERPRETE);
interprete();
/*if (!interprete())
k_error(K_ERR_INTERPRETE);*/
// Control de Frames por segundo POR HACER !!!!!!
if (!kernel())
k_error(K_ERR_KERNEL);
/*if (!kernel())
k_error(K_ERR_KERNEL);*/
// tiempo
/*
@ -342,14 +341,18 @@ int main(int argc, char* argv[])
return 0;
}
void stub_quit(void)
#include <assert.h>
void stub_quit(int n)
{
int i;
for(i=0;i<num_indexed_vars;i++)
//assert(0);
for(i=0;i<num_indexed_vars;i++) {
free(varindex[i].nombre);
}
free(varindex);
SDL_Quit();
//atexit(SDL_Quit);
exit(n);
}

Binary file not shown.

View file

@ -222,9 +222,6 @@ makelib.bat win32.dbg
<File
RelativePath="..\..\stub\inte.c">
</File>
<File
RelativePath="..\..\stub\kernel.c">
</File>
<File
RelativePath="..\..\stub\language.c">
</File>
@ -259,9 +256,6 @@ makelib.bat win32.dbg
<File
RelativePath="..\..\stub\inte.h">
</File>
<File
RelativePath="..\..\stub\kernel.h">
</File>
<File
RelativePath="..\..\stub\lower.h">
</File>