Commit 7675c775 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Shorten FRAMEBUFFER_PROPERTY to FRAMEBUFFER; Implement base support for framebuffers.

parent 3d83e322
...@@ -1760,7 +1760,7 @@ public final class Assembly ...@@ -1760,7 +1760,7 @@ public final class Assembly
case SystemCallIndex.ERROR_GET: case SystemCallIndex.ERROR_GET:
case SystemCallIndex.ERROR_SET: case SystemCallIndex.ERROR_SET:
case SystemCallIndex.EXIT: case SystemCallIndex.EXIT:
case SystemCallIndex.FRAMEBUFFER_PROPERTY: case SystemCallIndex.FRAMEBUFFER:
case SystemCallIndex.IPC_CALL: case SystemCallIndex.IPC_CALL:
case SystemCallIndex.GARBAGE_COLLECT: case SystemCallIndex.GARBAGE_COLLECT:
case SystemCallIndex.LOAD_STRING: case SystemCallIndex.LOAD_STRING:
...@@ -1912,7 +1912,7 @@ public final class Assembly ...@@ -1912,7 +1912,7 @@ public final class Assembly
break; break;
// Property of the framebuffer // Property of the framebuffer
case SystemCallIndex.FRAMEBUFFER_PROPERTY: case SystemCallIndex.FRAMEBUFFER:
try try
{ {
rv = SwingFramebuffer.instance().vfb.framebufferProperty( rv = SwingFramebuffer.instance().vfb.framebufferProperty(
......
...@@ -616,8 +616,11 @@ extern "C" ...@@ -616,8 +616,11 @@ extern "C"
/** Upload integer array. */ /** Upload integer array. */
#define SJME_FRAMEBUFFER_PROPERTY_UPLOAD_ARRAY_INT SJME_JINT_C(14) #define SJME_FRAMEBUFFER_PROPERTY_UPLOAD_ARRAY_INT SJME_JINT_C(14)
/** The backing object for the framebuffer, if there is one. */
#define SJME_FRAMEBUFFER_PROPERTY_BACKING_ARRAY_OBJECT SJME_JINT_C(15)
/** Maximum properties. */ /** Maximum properties. */
#define SJME_FRAMEBUFFER_PROPERTY_NUM_PROPERTIES SJME_JINT_C(15) #define SJME_FRAMEBUFFER_PROPERTY_NUM_PROPERTIES SJME_JINT_C(16)
/***************************************************************************** /*****************************************************************************
*************************** SUPERVISOR PROPERTIES **************************** *************************** SUPERVISOR PROPERTIES ****************************
......
...@@ -127,9 +127,18 @@ public interface FramebufferProperty ...@@ -127,9 +127,18 @@ public interface FramebufferProperty
public static final byte UPLOAD_ARRAY_INT = public static final byte UPLOAD_ARRAY_INT =
14; 14;
/**
* The array which backs the framebuffer, if there is one.
*
* @return The backing array object, if there is one.
* @since 2019/12/28
*/
public static final byte BACKING_ARRAY_OBJECT =
15;
/** The number of framebuffer properties. */ /** The number of framebuffer properties. */
public static final byte NUM_PROPERTIES = public static final byte NUM_PROPERTIES =
15; 16;
/** Screen is RGB 32-bit. */ /** Screen is RGB 32-bit. */
public static final byte FORMAT_INTEGER_RGB888 = public static final byte FORMAT_INTEGER_RGB888 =
......
...@@ -269,7 +269,7 @@ public interface SystemCallIndex ...@@ -269,7 +269,7 @@ public interface SystemCallIndex
* @param ... Undefined, this depends on the property selected. * @param ... Undefined, this depends on the property selected.
* @return Whatever value the frame buffer property will return. * @return Whatever value the frame buffer property will return.
*/ */
public static final byte FRAMEBUFFER_PROPERTY = public static final byte FRAMEBUFFER =
24; 24;
/** /**
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
package cc.squirreljme.runtime.lcdui.vfb; package cc.squirreljme.runtime.lcdui.vfb;
import cc.squirreljme.jvm.Assembly;
import cc.squirreljme.jvm.FramebufferProperty;
import cc.squirreljme.jvm.IPCCallback; import cc.squirreljme.jvm.IPCCallback;
/** /**
...@@ -30,6 +32,15 @@ public final class VirtualFramebuffer ...@@ -30,6 +32,15 @@ public final class VirtualFramebuffer
/** The callback to invoke with screen actions. */ /** The callback to invoke with screen actions. */
protected final IPCCallback ipc; protected final IPCCallback ipc;
/** The width. */
protected final int width;
/** The height. */
protected final int height;
/** The raw pixel data. */
protected final int[] pixels;
/** /**
* Initializes the virtual framebuffer. * Initializes the virtual framebuffer.
* *
...@@ -39,12 +50,33 @@ public final class VirtualFramebuffer ...@@ -39,12 +50,33 @@ public final class VirtualFramebuffer
*/ */
public VirtualFramebuffer(IPCCallback __ipc) public VirtualFramebuffer(IPCCallback __ipc)
throws NullPointerException throws NullPointerException
{
this(__ipc, DEFAULT_WIDTH, DEFAULT_HEIGHT);
}
/**
* Initializes the virtual framebuffer.
*
* @param __ipc The callback to forward events to.
* @param __w The width.
* @param __h The height.
* @throws NullPointerException On null arguments.
* @since 2019/12/28
*/
public VirtualFramebuffer(IPCCallback __ipc, int __w, int __h)
{ {
if (__ipc == null) if (__ipc == null)
throw new NullPointerException("NARG"); throw new NullPointerException("NARG");
// Set IPC to use // Set IPC to use
this.ipc = __ipc; this.ipc = __ipc;
// Set size
this.width = __w;
this.height = __h;
// Initialize raw pixel data
this.pixels = new int[__w * __h];
} }
/** /**
...@@ -151,7 +183,64 @@ public final class VirtualFramebuffer ...@@ -151,7 +183,64 @@ public final class VirtualFramebuffer
public final long framebufferProperty(int __pid, int __a, int __b, int __c, public final long framebufferProperty(int __pid, int __a, int __b, int __c,
int __d, int __e, int __g, int __h) int __d, int __e, int __g, int __h)
{ {
throw new todo.TODO(); // Depends on the property
switch (__pid)
{
// Raw address (since it is simulated, this is not set)
case FramebufferProperty.ADDRESS:
return 0;
// Width and scanline length
case FramebufferProperty.WIDTH:
case FramebufferProperty.SCANLEN:
return this.width;
// Height
case FramebufferProperty.HEIGHT:
return this.height;
// Flushes the display
case FramebufferProperty.FLUSH:
throw new todo.TODO();
// Pixel format is always integer
case FramebufferProperty.FORMAT:
return FramebufferProperty.FORMAT_INTEGER_RGB888;
// Scan line length in bytes
case FramebufferProperty.SCANLEN_BYTES:
return this.width * 4;
// The number of bytes per pixel
case FramebufferProperty.BYTES_PER_PIXEL:
return 4;
// Bits per pixel
case FramebufferProperty.BITS_PER_PIXEL:
return 32;
// The number of pixels
case FramebufferProperty.NUM_PIXELS:
return this.width * this.height;
// Backlight not supported
case FramebufferProperty.BACKLIGHT_LEVEL_GET:
case FramebufferProperty.BACKLIGHT_LEVEL_SET:
case FramebufferProperty.BACKLIGHT_LEVEL_MAX:
return 0;
// Upload integer array
case FramebufferProperty.UPLOAD_ARRAY_INT:
throw new todo.TODO();
// The backing array object
case FramebufferProperty.BACKING_ARRAY_OBJECT:
return Assembly.objectToPointer(this.pixels);
// Unknown
default:
return 0;
}
} }
} }
...@@ -67,14 +67,14 @@ public class DeviceControl ...@@ -67,14 +67,14 @@ public class DeviceControl
// Get maximum backlight level, stop if it is zero which means the // Get maximum backlight level, stop if it is zero which means the
// property is not supported or there is no backlight that can be // property is not supported or there is no backlight that can be
// controlled // controlled
int max = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER_PROPERTY, int max = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
FramebufferProperty.BACKLIGHT_LEVEL_MAX); FramebufferProperty.BACKLIGHT_LEVEL_MAX);
if (max == 0) if (max == 0)
return; return;
// Set the desired level as a percentage of the max // Set the desired level as a percentage of the max
int val = (max * __lvl) / 100; int val = (max * __lvl) / 100;
Assembly.sysCall(SystemCallIndex.FRAMEBUFFER_PROPERTY, Assembly.sysCall(SystemCallIndex.FRAMEBUFFER,
FramebufferProperty.BACKLIGHT_LEVEL_SET, FramebufferProperty.BACKLIGHT_LEVEL_SET,
(val < 0 ? 0 : (val > max ? max : val))); (val < 0 ? 0 : (val > max ? max : val)));
} }
......
...@@ -1311,11 +1311,14 @@ public class Display ...@@ -1311,11 +1311,14 @@ public class Display
synchronized (displays) synchronized (displays)
{ {
// Try to obtain the address of the framebuffer // Try to obtain the address of the framebuffer
int fbaddr = Assembly.sysCallV(SystemCallIndex. int fbaddr = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
FRAMEBUFFER_PROPERTY, FramebufferProperty.ADDRESS); FramebufferProperty.ADDRESS);
int fbaobj = Assembly.sysCallV(SystemCallIndex.FRAMEBUFFER,
FramebufferProperty.BACKING_ARRAY_OBJECT);
// There is only a single display if a framebuffer is supported // There is only a single display if a framebuffer is supported
int numdisplays = (fbaddr != 0 ? 1 : 0); // It could be mapped to an object or otherwise raw memory
int numdisplays = (fbaddr != 0 || fbaobj != 0 ? 1 : 0);
for (int i = 0; i < numdisplays; i++) for (int i = 0; i < numdisplays; i++)
rv.add(Display.__mapDisplay(i)); rv.add(Display.__mapDisplay(i));
} }
......
...@@ -127,9 +127,18 @@ public interface FramebufferProperty ...@@ -127,9 +127,18 @@ public interface FramebufferProperty
public static final byte UPLOAD_ARRAY_INT = public static final byte UPLOAD_ARRAY_INT =
14; 14;
/**
* The array which backs the framebuffer, if there is one.
*
* @return The backing array object, if there is one.
* @since 2019/12/28
*/
public static final byte BACKING_ARRAY_OBJECT =
15;
/** The number of framebuffer properties. */ /** The number of framebuffer properties. */
public static final byte NUM_PROPERTIES = public static final byte NUM_PROPERTIES =
15; 16;
/** Screen is RGB 32-bit. */ /** Screen is RGB 32-bit. */
public static final byte FORMAT_INTEGER_RGB888 = public static final byte FORMAT_INTEGER_RGB888 =
......
...@@ -269,7 +269,7 @@ public interface SystemCallIndex ...@@ -269,7 +269,7 @@ public interface SystemCallIndex
* @param ... Undefined, this depends on the property selected. * @param ... Undefined, this depends on the property selected.
* @return Whatever value the frame buffer property will return. * @return Whatever value the frame buffer property will return.
*/ */
public static final byte FRAMEBUFFER_PROPERTY = public static final byte FRAMEBUFFER =
24; 24;
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment