/AthenaEnv

A complete Javascript environment for creating homebrew applications and games on PlayStation 2.

Primary LanguageCGNU General Public License v3.0GPL-3.0


Logo

Enhanced JavaScript environment for PlayStation 2™

Table of Contents
  1. About AthenaEnv
  2. Coding
  3. Contributing
  4. License
  5. Contact
  6. Thanks

About AthenaEnv

AthenaEnv is a project that seeks to facilitate and at the same time brings a complete kit for users to create homebrew software for PlayStation 2 using the JavaScript language. It has dozens of built-in functions, both for creating games and apps. The main advantage over using AthenaEnv project instead of the pure PS2SDK is above all the practicality, you will use one of the simplest possible languages to create what you have in mind, besides not having to compile, just script and test, fast and simple.

Modules:

  • System: Files, folders and system stuff.
  • Archive: A simple compressed file extractor and manager.
  • IOP: The PlayStation 2 has an I/O processor to deal with drivers and modules. Take control of it!
  • Image: Image drawing.
  • ImageList: Load and manage multiple images while your code is running, multithreaded loading!
  • Draw: Shape drawing, triangles, circles etc.
  • Render: Basic 3D support.
  • Screen: The entire screen of your project (2D and 3D), being able to change the resolution, enable or disable parameters.
  • Font: Functions that control the texts that appear on the screen, loading texts, drawing and unloading from memory.
  • Pads: Above being able to draw and everything else, A human interface is important. Supports rumble and pressure sensitivity.
  • Keyboard: Basic USB keyboard support.
  • Mouse: Basic USB mouse support.
  • Timer: Control the time precisely in your code, it contains several timing functions.
  • Sound: Sound functions, supporting WAV, OGG and ADPCM.
  • Network: Net basics and web requests :D.
  • Socket: Well, sockets.

New types are always being added and this list can grow a lot over time, so stay tuned.

Built With

Coding

In this section you will have some information about how to code using AthenaEnv, from prerequisites to useful functions and information about the language.

Prerequisites

Using AthenaEnv you only need one way to code and one way to test your code, that is, if you want, you can even create your code on PS2, but I'll leave some recommendations below.

  • PC: Visual Studio Code(with JavaScript extension) and PCSX2(1.7.0 or above, enabled HostFS is required) or PS2Client for test.

  • How to enable HostFS on PCSX2 1.7.0:
    • (old) WxWidgets:
    image

    • Qt version:
    image

Qt recommendation: Enable console output
console0

  • Android: QuickEdit and a PS2 with wLE for test.

Oh, and I also have to mention that an essential prerequisite for using AthenaEnv is knowing how to code in JavaScript.

Quick start with Athena

Hello World:

const font = new Font("default");

os.setInterval(() => { // Basically creates an infinite loop, similar to while true(you can use it too).
  Screen.clear(); // Clear screen for the next frame.
  font.print(0, 0, "Hello World!"); // x, y, text
  Screen.flip(); // Updates the screen.
}, 0);

See more examples at AthenaEnv samples.

Features

AthenaEnv uses a slightly modified version of the QuickJS interpreter for JavaScript language, which means that it brings almost modern JavaScript features so far.

Float32

This project introduces a (old)new data type for JavaScript: single floats. Despite being less accurate than the classic doubles for number semantics, they are important for performance on the PS2, as the console only processes 32-bit floats on its FPU.

You can write single floats on AthenaEnv following the syntax below:

let test_float = 15.0f; // The 'f' suffix makes QuickJS recognizes it as a single float.

or

let test_float = Math.fround(15.0); // Math.fround returns real single floats on Athena.

How to run it

Athena is basically a JavaScript loader, so it loads .js files. It runs "main.js" by default, but you can run other file names by passing it as the first argument when launching the ELF file.

If you try to just download it on releases tab and run it, that's what you will see: _50bda816_20230409025946

That's the default dashboard, coded in default main.js file. It searchs JavaScript files with the first line containing the following structure:

// {"name": "App name", "author": "Who did it?", "version": "04012023", "icon": "app_icon.png", "file": "my_app.js"}
// Now you can freely code below:

Once it was found, it will appear on the dashboard app list.

Error reporting system

Athena has a consistent error system, which is capable of pointing the error type, custom message, files, lines and it even has a color code.

EvalError:
_50bda816_20230409024828

SyntaxError:
_50bda816_20230409024849

TypeError:
_50bda816_20230409024911

ReferenceError:
_50bda816_20230409024944

RangeError:
_50bda816_20230409025004

InternalError:
_50bda816_20230409025029

URIError:
_50bda816_20230409025053

AggregateError:
_50bda816_20230409025131

Functions, classes and consts

Below is the list of usable functions of AthenaEnv project currently, this list is constantly being updated.

P.S.: Italic parameters refer to optional parameters

std module

The std module provides wrappers to the libc stdlib.h and stdio.h and a few other utilities.

Available exports:

  • std.evalScript(str, options = undefined) - Evaluate the string str as a script (global eval). options is an optional object containing the following optional properties: • std.backtrace_barrier - Boolean (default = false). If true, error backtraces do not list the stack frames below the evalScript.
  • std.loadScript(filename) - Evaluate the file filename as a script (global eval).
  • let fstr = std.loadFile(filename) - Load the file filename and return it as a string assuming UTF-8 encoding. Return null in case of I/O error.
  • let file = std.open(filename, flags, errorObj = undefined) - Open a file (wrapper to the libc fopen()). Return the FILE object or null in case of I/O error. If errorObj is not undefined, set its errno property to the error code or to 0 if no error occured.
  • std.fdopen(fd, flags, errorObj = undefined) - Open a file from a file handle (wrapper to the libc fdopen()). Return the FILE object or null in case of I/O error. If errorObj is not undefined, set its errno property to the error code or to 0 if no error occured.
  • std.tmpfile(errorObj = undefined) - Open a temporary file. Return the FILE object or null in case of I/O error. If errorObj is not undefined, set its errno property to the error code or to 0 if no error occured.
  • std.puts(str) - Equivalent to std.out.puts(str).
  • std.printf(fmt, ...args) - Equivalent to std.out.printf(fmt, ...args).
  • std.sprintf(fmt, ...args) - Equivalent to the libc sprintf().
  • std.in, std.out, std.err - Wrappers to the libc file stdin, stdout, stderr.
  • std.SEEK_SET, std.SEEK_CUR, std.SEEK_END - Constants for seek().

Enumeration object containing the integer value of common errors (additional error codes may be defined):

  • std.EINVAL

  • std.EIO

  • std.EACCES

  • std.EEXIST

  • std.ENOSPC

  • std.ENOSYS

  • std.EBUSY

  • std.ENOENT

  • std.EPERM

  • std.EPIPE

  • std.strerror(errno) - Return a string that describes the error errno.

  • std.gc() - Manually invoke the cycle removal algorithm. The cycle removal algorithm is automatically started when needed, so this function is useful in case of specific memory constraints or for testing.

  • std.parseExtJSON(str) - Parse str using a superset of JSON.parse. The following extensions are accepted:
    • Single line and multiline comments
    • unquoted properties (ASCII-only Javascript identifiers)
    • trailing comma in array and object definitions
    • single quoted strings
    • \f and \v are accepted as space characters
    • leading plus in numbers
    • octal (0o prefix) and hexadecimal (0x prefix) numbers

FILE prototype:

Construction:

  • let file = std.open(filename, flags);
    filename - Path to the file, E.g.: "samples/test.txt".
    flags - File mode, E.g.: "w", "r", "wb", "rb", etc.
let file = std.open("test.txt", "w");
  • close() - Close the file. Return 0 if OK or -errno in case of I/O error.

  • puts(str) - Outputs the string with the UTF-8 encoding.

  • printf(fmt, ...args) - Formatted printf. • The same formats as the standard C library printf are supported. Integer format types (e.g. %d) truncate the Numbers or BigInts to 32 bits. Use the l modifier (e.g. %ld) to truncate to 64 bits.

  • flush() - Flush the buffered file.

  • seek(offset, whence) - Seek to a give file position (whence is std.SEEK_*). offset can be a number or a bigint. Return 0 if OK or -errno in case of I/O error.

  • tell() - Return the current file position.

  • tello() - Return the current file position as a bigint.

  • eof() - Return true if end of file.

  • fileno() - Return the associated OS handle.

  • error() - Return true if there was an error.

  • clearerr() - Clear the error indication.

  • read(buffer, position, length) - Read length bytes from the file to the ArrayBuffer buffer at byte position position (wrapper to the libc fread).

  • write(buffer, position, length) - Write length bytes to the file from the ArrayBuffer buffer at byte position position (wrapper to the libc fwrite).

  • getline() - Return the next line from the file, assuming UTF-8 encoding, excluding the trailing line feed.

  • readAsString(max_size = undefined) - Read max_size bytes from the file and return them as a string assuming UTF-8 encoding. If max_size is not present, the file is read up its end.

  • getByte() - Return the next byte from the file. Return -1 if the end of file is reached.

  • putByte(c) - Write one byte to the file.

os module

The os module provides Operating System specific functions:

  • low level file access
  • signals
  • timers
  • asynchronous I/O The OS functions usually return 0 if OK or an OS specific negative error code.

Available exports:

  • let fd = os.open(filename, flags, mode = 0o666) - Open a file. Return a handle or < 0 if error. Flags:
    • os.O_RDONLY
    • os.O_WRONLY
    • os.O_RDWR
    • os.O_APPEND
    • os.O_CREAT
    • os.O_EXCL
    • os.O_TRUNC
    POSIX open flags.

  • os.close(fd) - Close the file handle fd.

  • os.seek(fd, offset, whence) - Seek in the file. Use std.SEEK_* for whence. offset is either a number or a bigint. If offset is a bigint, a bigint is returned too.

  • os.read(fd, buffer, offset, length) - Read length bytes from the file handle fd to the ArrayBuffer buffer at byte position offset. Return the number of read bytes or < 0 if error.

  • os.write(fd, buffer, offset, length) - Write length bytes to the file handle fd from the ArrayBuffer buffer at byte position offset. Return the number of written bytes or < 0 if error.

  • os.remove(filename) - Remove a file. Return 0 if OK or -errno.

  • os.rename(oldname, newname) - Rename a file. Return 0 if OK or -errno.

  • os.realpath(path) - Return [str, err] where str is the canonicalized absolute pathname of path and err the error code.

  • os.getcwd() - Return [str, err] where str is the current working directory and err the error code.

  • os.chdir(path) - Change the current directory. Return 0 if OK or -errno.

  • os.mkdir(path, mode = 0o777) - Create a directory at path. Return 0 if OK or -errno.

  • os.stat(path), os.lstat(path) - Return [obj, err] where obj is an object containing the file status of path. err is the error code. The following fields are defined in obj: dev, ino, mode, nlink, uid, gid, rdev, size, blocks, atime, mtime, ctime. The times are specified in milliseconds since 1970. lstat() is the same as stat() excepts that it returns information about the link itself.
    Constants to interpret the mode property returned by stat(). They have the same value as in the C system header sys/stat.h.
    • os.S_IFMT
    • os.S_IFIFO
    • os.S_IFCHR
    • os.S_IFDIR
    • os.S_IFBLK
    • os.S_IFREG
    • os.S_IFSOCK
    • os.S_IFLNK
    • os.S_ISGID
    • os.S_ISUID

  • os.utimes(path, atime, mtime) - Change the access and modification times of the file path. The times are specified in milliseconds since 1970. Return 0 if OK or -errno.

  • os.readdir(path) - Return [array, err] where array is an array of strings containing the filenames of the directory path. err is the error code.

  • os.setReadHandler(fd, func) - Add a read handler to the file handle fd. func is called each time there is data pending for fd. A single read handler per file handle is supported. Use func = null to remove the handler.

  • os.setWriteHandler(fd, func) - Add a write handler to the file handle fd. func is called each time data can be written to fd. A single write handler per file handle is supported. Use func = null to remove the handler.

  • os.sleep(delay_ms) - Sleep during delay_ms milliseconds.

  • os.setTimeout(func, delay) - Call the function func after delay ms. Return a handle to the timer.

  • os.setInterval(func, interval) - Call the function func at specified intervals (in milliseconds). Return a handle to the timer.

  • os.setImmediate(func) - Executes a given function immediately.

  • os.clearTimeout(handle) - Cancel a timer.

  • os.clearInterval(handle) - Cancel a interval.

  • os.clearImmediate(handle) - Cancel a immediate execution.

  • os.platform - Return a string representing the platform: "linux", "darwin", "win32", "ps2" or "js".

Color module

  • var col = Color.new(r, g, b, a) - Returns a color object from the specified RGB(A) parameters.
  • var r = Color.getR(col) - Get red intensity of the color.
  • var g = Color.getG(col) - Get green intensity of the color.
  • var b = Color.getB(col) - Get blue intensity of the color.
  • var a = Color.getA(col) - Get alpha intensity of the color.
  • Color.setR(col, r) - Set red intensity of the color.
  • Color.setG(col, g) - Set green intensity of the color.
  • Color.setB(col, g) - Set blue intensity of the color.
  • Color.setA(col, a) - Set alpha intensity of the color.

Image Module

Construction:

  • var image = new Image(path, mode, async_list);
    path - Path to the file, E.g.: "images/test.png".
    mode - Choose between storing the image between RAM or VRAM, default value is RAM.
    async_list - Gets a ImageList object, which is a asynchronous image loading list, if you want to load images in the background.
var test = new Image("owl.png", VRAM); 

Properties:

  • width, height - Image drawing size, default value is the original image size.
  • startx, starty - Beginning of the area that will be drawn from the image, the default value is 0.0.
  • endx, endy - End of the area that will be drawn from the image, the default value is the original image size.
  • angle - Define image rotation angle, default value is 0.0.
  • color - Define image tinting, default value is Color.new(255, 255, 255, 128).
  • filter - Choose between LINEAR or NEAREST, default value is NEAREST.

Methods:

  • draw(x, y) - Draw loaded image onscreen(call it every frame). Example: image.draw(15.0, 100.0);
  • ready() - Returns true if an asynchronous image was successfully loaded in memory.
var loaded = image.ready();  

ImageList

Construction:

var async_list = new ImageList(); // This constructor creates a new thread and a queue to load images in background, avoid building multiple ImageList objects.

Methods:

  • process() - This method starts the thread and loads added images on the queue.
async_list.process();

Draw module

  • Draw.point(x, y, color) - Draws a pixel on the specified color and position on the screen.
  • Draw.rect(x, y, width, height, color) - Draws a rectangle on the specified color, position and size on the screen.
  • Draw.line(x, y, x2, y2, color) - Draws a line on the specified colors and position on the screen.
  • Draw.circle(x, y, radius, color, filled) - Draws a circle on the specified color, position, radius and fill on the screen.
  • Draw.triangle(x, y, x2, y2, x3, y3, color, color2, color3) - Draws a triangle on the specified points positions and colors on the screen.
  • Draw.quad(x, y, x2, y2, x3, y3, x4, y4 color, color2, color3, color4) - Draws a quad on the specified points positions and colors on the screen.

Render module

• Remember to enable zbuffering on screen mode, put the line of code below
• Default NTSC mode(3D enabled):

const canvas = Screen.getMode();
canvas.zbuffering = true;
canvas.psmz = Z16S;

Screen.setMode(canvas);
  • Render.init(aspect) - Initializes rendering routines. *default aspect is 4/3, widescreen is 16/9
  • var model = Render.loadOBJ(path, texture) - Load simple obj 3d data files. MTL not supported yet. Actually it only supports a single texture that you have to load using Image class and pass as a second argument if you want to use it.
  • Render.drawOBJ(model, pos_x, pos_y, pos_z, rot_x, rot_y, rot_z) - Draws the loaded OBJ on the screen.
  • Render.freeOBJ(model) - Frees the model from memory.

Camera

  • Camera.position(x, y, z)
  • Camera.rotation(x, y, z)

Lights

  • Lights.create(count)
  • Lights.set(light, dir_x, dir_y, dir_z, r, g, b, type)
    • Avaiable light types: AMBIENT, DIRECTIONAL

Screen module

  • Screen.clear(color) - Clears screen with the specified color. If you don't specify any argument, it will use black as default.
  • Screen.flip() - Run the render queue and jump to the next frame, i.e.: Updates your screen.
  • var freevram = Screen.getFreeVRAM() - Returns the total of free Video Memory.
  • Screen.setVSync(bool) - Toggles VSync, which makes the framerate stable in 15, 30, 60(depending on the mode) on screen.
  • Screen.setFrameCounter(bool) - Toggles frame counting and FPS collecting.
  • Screen.waitVblankStart() - Waits for a vertical sync.
  • var fps = Screen.getFPS(frame_interval) - Get Frames per second measure within the specified frame_interval in msec. Dependant on Screen.setFrameCounter(true) to work.
  • const canvas = Screen.getMode() - Get actual video mode parameters. Returns an object. • canvas.mode - Available modes: NTSC, DTV_480p, PAL, DTV_576p, DTV_720p, DTV_1080i.
    • canvas.width - Screen width. Default: 640.
    • canvas.height - Screen height. Default: 448 on NTSC consoles, 512 on PAL consoles.
    • canvas.psm - Color mode. Available colormodes: CT16, CT16S, CT24, CT32.
    • canvas.interlace - Available interlaces: INTERLACED, PROGRESSIVE.
    • canvas.field - Available fields: FIELD, FRAME.
    • canvas.double_buffering - Enable or disable double buffering(bool).
    • canvas.zbuffering - Enable or disable Z buffering (3D buffering)(bool).
    • canvas.psmz - ZBuffering color mode. Available zbuffer colormodes: Z16, Z16S, Z24, Z32.
  • Screen.setMode(canvas) - Set the current video mode, get an video mode object as an argument.

Font module

Construction:

var font = new Font(path);  // It supports png, bmp, jpg, otf, ttf.

path - Path to a font file, E.g.: "images/atlas.png", "fonts/font.png".

var osdfnt = new Font();  //Load BIOS font, not available for all console models  
var font = new Font("Segoe UI.ttf"); //Load trueType font 

Properties:

  • color - Define font tinting, default value is Color.new(255, 255, 255, 128).
  • scale - Proportional scale, default: 1.0f

Methods:

  • print(x, y, text) - Draw text on screen(call it every frame). Example: font.print(10.0, 10.0, "Hello world!));
  • getTextSize(text) - Returns text absolute size in pixels (width, height). Example: const size = font.getTextSize("Hello world!");

Pads module

  • var pad = Pads.get(port) - Returns a pad object containing the following properties:
    • pad.btns - Buttons
    • pad.lx - Left analog horizontal position (left = -127, default = 0, right = 128)
    • pad.ly - Left analog vertical position (up = -127, default = 0, down = 128)
    • pad.rx - Right analog horizontal position (left = -127, default = 0, right = 128)
    • pad.ry - Right analog vertical position (up = -127, default = 0, down = 128)

    analog_graph

  • var type = Pads.getType(port) - Gets gamepad type in the specified port. • Pads.DIGITAL
    • Pads.ANALOG
    • Pads.DUALSHOCK

  • var press = Pads.getPressure(port, button) - Get button pressure level.

  • Pads.rumble(port, big, small) - Rumble your gamepad.

  • var ret = Pads.check(pad, button) - Check if the button was pressed on the specified pad.

  • Buttons list:
    • Pads.SELECT
    • Pads.START
    • Pads.UP
    • Pads.RIGHT
    • Pads.DOWN
    • Pads.LEFT
    • Pads.TRIANGLE
    • Pads.CIRCLE
    • Pads.CROSS
    • Pads.SQUARE
    • Pads.L1
    • Pads.R1
    • Pads.L2
    • Pads.R2
    • Pads.L3
    • Pads.R3

Keyboard module

  • Keyboard.init() - Initialize keyboard routines.
  • var c = Keyboard.get() - Get keyboard current char.
  • Keyboard.setRepeatRate(msec) - Set keyboard repeat rate.
  • Keyboard.setBlockingMode(mode) - Sets keyboard to block(or not) the thread waiting for the next key to be pressed.
  • Keyboard.deinit() - Destroy keyboard routines.

Mouse module

  • Mouse.init() - Initialize mouse routines.
  • var mouse = Mouse.get() - Returns mouse actual properties on the object format below:
    • mouse.x
    • mouse.y
    • mouse.wheel
    • mouse.buttons
  • Mouse.setBoundary(minx, maxx, miny, maxy) - Set mouse x and y bounds.
  • var mode = Mouse.getMode() - Get mouse mode(absolute or relative).
  • Mouse.setMode(mode) - Set mouse mode.
  • var accel = Mouse.getAccel() - Get mouse acceleration.
  • Mouse.setAccel(val) - Set mouse acceleration.
  • Mouse.setPosition(x, y) - Set mouse pointer position.

System module

  • var fd = System.openFile(path, type)

  • Types list:
    • System.FREAD
    • System.FWRITE
    • System.FCREATE
    • System.FRDWR

  • var buffer = System.readFile(file, size)

  • System.writeFile(fd, data, size)

  • System.closeFile(fd)

  • System.seekFile(fd, pos, type)

  • Types list:
    • System.SET
    • System.CUR
    • System.END

  • var size = System.sizeFile(fd)

  • System.doesFileExist(path)

  • System.CurrentDirectory(path) *if path given, it sets the current dir, else it gets the current dir

  • var listdir = System.listDir(path) • listdir[index].name - return file name on indicated index(string)
    • listdir[index].size - return file size on indicated index(integer)
    • listdir[index].directory - return if indicated index is a file or a directory(bool)

  • System.createDirectory(path)

  • System.removeDirectory(path)

  • System.removeFile(path)

  • System.copyFile(source, dest)

  • System.moveFile(source, dest)

  • System.rename(source, dest)

  • System.sleep(sec)

  • var freemem = System.getFreeMemory()

  • System.exitToBrowser()

  • System.setDarkMode(value)

  • var temps = System.getTemperature() // It only works with SCPH-500XX and later models.

  • var info = System.getMCInfo(slot)
    • info.type
    • info.freemem
    • info.format

  • var ee_info = System.getCPUInfo()
    • ee_info.implementation
    • ee_info.revision
    • ee_info.FPUimplementation
    • ee_info.FPUrevision
    • ee_info.ICacheSize
    • ee_info.DCacheSize
    • ee_info.RAMSize
    • ee_info.MachineSize

  • var gs_info = System.getGPUInfo()
    • gs_info.id
    • gs_info.revision

  • var ram_usage = System.getMemoryStats()
    • ram_usage.core - Kernel + Native code size in RAM
    • ram_usage.nativeStack - Kernel + Native stack size
    • ram_usage.allocs - Dynamic allocated memory tracking
    • ram_usage.used - All above, but combined

Asynchronous functions:

  • System.threadCopyFile(source, dest)
  • var progress = System.getFileProgress()
    • progress.current
    • progress.final

Timer module

  • var timer = Timer.new()
  • Timer.getTime(timer)
  • Timer.setTime(src, value)
  • Timer.destroy(timer)
  • Timer.pause(timer)
  • Timer.resume(timer)
  • Timer.reset(timer)
  • Timer.isPlaying(timer)

Sound module

  • Sound.setVolume(volume, slot) *If slot is specified, it will change ADPCM slot volume, else it will change master volume.
  • var audio = Sound.load(path)
  • Sound.play(audio, slot) *ADPCM: If slot isn't specified, it will use 0.
  • Sound.free(audio)
  • var playing = Sound.isPlaying() *Doesn't apply for ADPCM
  • var msec = Sound.duration()
  • Sound.repeat(false) *Doesn't apply for ADPCM
  • Sound.pause(audio) *Doesn't apply for ADPCM
  • Sound.resume(audio) *Doesn't apply for ADPCM
  • Sound.deinit()

Archive module

  • var zip = Archive.open(fname)
  • var list = Archive.list(zip)
  • Archive.extractAll(zip)
  • Archive.close(zip)
  • Archive.untar(fname)

IOP module

  • var result = IOP.loadModule(fname, arg_len, args)

  • var result = IOP.loadModuleBuffer(mod_buf, arg_len, args)

  • IOP.loadDefaultModule(mod_id)
    • IOP.keyboard - USB Keyboard
    • IOP.mouse - USB Mouse
    • IOP.freeram - IOP RAM Info
    • IOP.ds34bt - Bluetooth DualShock 3/4 pads
    • IOP.ds34usb - USB DualShock 3/4 pads
    • IOP.network - Network drivers
    • IOP.pads - DualShock 1/2 pads
    • IOP.memcard - Memory Card
    • IOP.audio - Audio driver
    • IOP.usb_mass - USB Mass storage, supports FAT32 and exFAT
    • IOP.cdfs - Disc driver
    • IOP.hdd - Internal HDD driver
    • IOP.boot_device - Storage device used to boot Athena

  • IOP.reset()

  • var stats = IOP.getMemoryStats() - P.S.: Requires IOP.loadDefaultModule(IOP.freeram) first! • stats.free
    • stats.used

Network module

  • Network.init(ip, netmask, gateway, dns)
Network.init("192.168.0.10", "255.255.255.0", "192.168.0.1", "192.168.0.1"); //Static mode  
Network.init(); //DHCP Mode, dynamic.  
  • var conf = Network.getConfig()
    Returns conf.ip, conf.netmask, conf.gateway, conf.dns.

  • Network.deinit()
    Shutdown network module.

Request module

Construction:

  • var r = new Request()
var r = new Request();

Properties:

  • keepalive - bool
  • useragent - string
  • userpwd - string
  • headers - string array

Methods:

  • get(url)
  • head(url)
  • post(url, data)
  • download(url, fname)

Asynchronous methods:

  • asyncGet(url)
  • asyncDownload(url, fname)
  • ready(timeout, conn_timeout)
  • getAsyncData()
  • getAsyncSize()

Socket module

Construction:

  • var s = new Socket(domain, type)
var s = new Socket(AF_INET, SOCK_STREAM);

Methods:

  • connect(host, port)
  • bind(host, port)
  • listen()
  • send(data) - Send data with Buffer
  • recv(size) - Receive data to a buffer
  • close()

WebSocket module

Construction:

  • var s = new WebSocket(url)
var s = new WebSocket("wss://example.com");

Methods:

  • send(data) - Send data with Buffer
  • recv() - Receive data to a buffer

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AwesomeFeature)
  3. Commit your Changes (git commit -m 'Add some AwesomeFeature')
  4. Push to the Branch (git push origin feature/AwesomeFeature)
  5. Open a Pull Request

License

Distributed under GNU GPL-3.0 License. See LICENSE for more information.

Contact

Daniel Santos - @danadsees - danielsantos346@gmail.com

Project Link: https://github.com/DanielSant0s/AthenaEnv

Thanks

Here are some direct and indirect thanks to the people who made the project viable!

  • guiprav - for 3dcb-duktape, which was the inspiration for bringing Enceladus and JavaScript together
  • HowlingWolf&Chelsea - Tests, tips and many other things
  • Whole PS2DEV team