Skip to content

Commit

Permalink
Allow Mobile's colors to affect every usual B/W rendering method
Browse files Browse the repository at this point in the history
This includes M3D. Sometime in the future, a new option to change
the rendering colors to simulate those early Nokia and Siemens
phones should arrive.
  • Loading branch information
AShiningRay committed Dec 16, 2024
1 parent d1b5399 commit 1b98110
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/com/nokia/mid/m3d/M3D.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ public class M3D
private double near;
private double far;

private int color = 0xFF000000;
private int clearcolor = 0xFFFFFFFF;
private int color = 0xFF000000|Mobile.lcduiTextColor;
private int clearcolor = 0xFF000000|Mobile.lcduiBGColor;


private M3D() { }
Expand Down Expand Up @@ -235,12 +235,12 @@ public void popMatrix()

public void color4ub(byte r, byte g, byte b, byte a)
{
color = ((0xFF)<<24) | ((r&0xFF)<<16) | ((g&0xFF)<<8) | (b&0xFF);
color = (((0xFF)<<24) | ((r&0xFF)<<16) | ((g&0xFF)<<8) | (b&0xFF))|Mobile.lcduiTextColor;
}

public void clearColor4ub(byte r, byte g, byte b, byte a)
{
clearcolor = ((0xFF)<<24) | ((r&0xFF)<<16) | ((g&0xFF)<<8) | (b&0xFF);
clearcolor = (((0xFF)<<24) | ((r&0xFF)<<16) | ((g&0xFF)<<8) | (b&0xFF))|Mobile.lcduiBGColor;
}

public void vertexPointerub(int a, int b, byte[] vertices)
Expand Down
3 changes: 2 additions & 1 deletion src/com/nokia/mid/m3d/Texture.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import javax.microedition.lcdui.Image;

import org.recompile.mobile.Mobile;
import org.recompile.mobile.PlatformImage;

public class Texture
Expand All @@ -39,7 +40,7 @@ public class Texture

private double[] tempm = new double[9]; // scratch

private int[] colors = {0xFFFFFFFF, 0xFF000000};
private int[] colors = {0xFF000000|Mobile.lcduiBGColor, 0xFF000000|Mobile.lcduiTextColor};

public Texture() { }
public Texture(int a, int b, Image c)
Expand Down
1 change: 1 addition & 0 deletions src/javax/microedition/lcdui/Alert.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public String renderScreen(int x, int y, int width, int height) {
return "";
}

graphics.setColor(Mobile.lcduiTextColor);
for(int l=0;l<lines.size();l++) {
int ystart = margin + l*Font.getDefaultFont().getHeight() + (l > 0 ? (l-1)*lineSpacing : 0);
int yend = ystart + Font.getDefaultFont().getHeight();
Expand Down
3 changes: 1 addition & 2 deletions src/javax/microedition/lcdui/Canvas.java
Original file line number Diff line number Diff line change
Expand Up @@ -260,12 +260,11 @@ private void paintCommandsBar()

int padding = 2;

graphics.setColor(Mobile.lcduiTextColor);
if (!commands.isEmpty())
{
graphics.setColor(Mobile.lcduiTextColor);
graphics.drawString(commands.size() > 2 ? "Options" : commands.get(0).getLabel(), padding, height-barHeight, Graphics.LEFT);
}

if (commands.size() == 2)
{
graphics.drawString(commands.get(1).getLabel(), width-padding, height-barHeight, Graphics.RIGHT);
Expand Down
4 changes: 3 additions & 1 deletion src/javax/microedition/lcdui/Displayable.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,15 @@ protected void render()
}

graphics.drawString(commands.get(i).getLabel(), width/2, y, Graphics.HCENTER);

graphics.setColor(Mobile.lcduiTextColor);

y += itemHeight;
}
}

currentY += contentHeight;

graphics.setColor(Mobile.lcduiTextColor);
graphics.drawString("Okay", xPadding, currentY+titlePadding, Graphics.LEFT);
graphics.drawString("Back", width-xPadding, currentY+titlePadding, Graphics.RIGHT);
}
Expand All @@ -219,6 +220,7 @@ protected void render()
itemCommand = ((Form)this).getItemCommand();
}

graphics.setColor(Mobile.lcduiTextColor);
switch(commands.size())
{
case 0: break;
Expand Down
1 change: 1 addition & 0 deletions src/javax/microedition/lcdui/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ protected void renderItemLabel(PlatformGraphics graphics, int x, int y, int item
{
Font oldFont = graphics.getFont();
graphics.setFont(Font.getDefaultFont());
graphics.setColor(Mobile.lcduiTextColor);
graphics.drawString(getLabel(), x, y, 0);
graphics.setFont(oldFont);
}
Expand Down
1 change: 1 addition & 0 deletions src/javax/microedition/lcdui/StringItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ protected void renderItem(PlatformGraphics graphics, int x, int y, int width, in
}
else
{
graphics.setColor(Mobile.lcduiTextColor);
for(int l=0;l<lines.size();l++)
{
graphics.drawString( lines.get(l), x,
Expand Down
2 changes: 1 addition & 1 deletion src/org/recompile/mobile/PlatformGraphics.java
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ public void drawPixels(byte[] pixels, byte[] transparencyMask, int offset, int s
if (pixels == null) { throw new NullPointerException("drawPixels(byte) received a null pixel array"); }
if (offset < 0 || offset >= (pixels.length * 8)) { throw new ArrayIndexOutOfBoundsException("drawPixels(byte) index out of bounds:" + width + " * " + height + "| pixels len:" + (pixels.length * 8) + "| offset:" + offset); }

int[] Type1 = {0xFFFFFFFF, 0xFF000000, 0x00FFFFFF, 0x00000000};
int[] Type1 = {0xFF000000|Mobile.lcduiBGColor, 0xFF000000|Mobile.lcduiTextColor, 0x00000000|Mobile.lcduiBGColor, 0x00000000|Mobile.lcduiTextColor};
int c = 0;
BufferedImage temp = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);// Nokia DirectGraphics states that image width and height CAN be zero.
final int[] data = ((DataBufferInt) temp.getRaster().getDataBuffer()).getData();
Expand Down

0 comments on commit 1b98110

Please sign in to comment.