Me preguntaba como usar el mod_file en Dreamcast.
http://wiki.bennugd.org/index.php?title=Mod_file
Un pequeño ejemplo funcional de cómo lo hago para sacar datos de un archivo texto::
import "mod_file"
import "mod_say"
import "mod_video"
import "mod_text"
import "mod_ttf"
import "mod_map"
Process Main()
Private
int handle; // handle for the loaded file
string first_line; // here's where the first line of the file will go
int fuente; // Variable contenedora, creo
Begin
set_mode(640,480,16);
set_text_color(rgb(255,255,255));
// Open the file "file.txt"
if (os_id == 5); // si es Dreamcast
handle=fopen("/cd/file.txt",O_READ);
else // de lo contrario cambia la ruta
handle=fopen("file.txt",O_READ);
end
if (handle == 0)
say( "Could not open file" );
return;
end
// Read the first line form the file
first_line = fgets(handle);
// Output the read line
say( "Read from file:" );
say('"' + first_line + '"'); // Lo printea mal, no saca ñ y demas tema... :
write(0,20,30,0, "Esto es lo que saca del txt:");
write(0,21,42,0,'' + first_line + ' ');
// Close the file (important!)
fclose(handle);
loop
frame;
end
End
import "mod_say"
import "mod_video"
import "mod_text"
import "mod_ttf"
import "mod_map"
Process Main()
Private
int handle; // handle for the loaded file
string first_line; // here's where the first line of the file will go
int fuente; // Variable contenedora, creo
Begin
set_mode(640,480,16);
set_text_color(rgb(255,255,255));
// Open the file "file.txt"
if (os_id == 5); // si es Dreamcast
handle=fopen("/cd/file.txt",O_READ);
else // de lo contrario cambia la ruta
handle=fopen("file.txt",O_READ);
end
if (handle == 0)
say( "Could not open file" );
return;
end
// Read the first line form the file
first_line = fgets(handle);
// Output the read line
say( "Read from file:" );
say('"' + first_line + '"'); // Lo printea mal, no saca ñ y demas tema... :
write(0,20,30,0, "Esto es lo que saca del txt:");
write(0,21,42,0,'' + first_line + ' ');
// Close the file (important!)
fclose(handle);
loop
frame;
end
End
Solo hay una cosa, el archivo de texto tiene que tener una codificación específica que es con la que trabaja internamente BennuGD para poder mostrar acentos y demás, luego la especifico que ahora no recuerdo.
Lo pongo aquí por si le sirve a alguien más...