Change font.

main
Astoria 7 months ago
parent 7d519709e3
commit 4435e0a790

@ -8,7 +8,7 @@ Bigfoot - Original emulator in C, rpcboot.bin, tetris.img, slideshow.img, and re
Simon816 - Creator of J65el02, the implementation that without this machine would not be possible. - https://github.com/simon816/J65el02
Timmie3054, Amon, Pcmaster160, CadenDonuts, and HanFox - Original source of the font which I have used in this emulator. https://bdcraft.net/community/viewtopic.php?t=354
Style64 - Font used inside this. Slightly modified purely to adjust character positions for ease of coding, no true visual modifications have been made. https://style64.org/c64-truetype
# TODO:
Speed up monitor rendering.

@ -6,10 +6,13 @@ import com.simon816.j65el02.device.RPMonitor;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Objects;
import static com.simon816.j65el02.device.RPMonitor.HEIGHT;
@ -18,14 +21,11 @@ import static com.simon816.j65el02.device.RPMonitor.WIDTH;
public class BasicMonitorDriver implements MonitorDriver, KeyListener {
BufferedImage display;
BufferedImage fontSheet;
final int width = 8;
final int height = 8;
int rows = 16;
int cols = 16;
BufferedImage[] sprites = new BufferedImage[rows * cols];
ImageIcon[] characters = new ImageIcon[rows * cols];
JLabel[][] displayArray = new JLabel[HEIGHT][WIDTH];
JLabel[] lines = new JLabel[HEIGHT];
Machine emu;
int xoffset = 32;
@ -34,22 +34,6 @@ public class BasicMonitorDriver implements MonitorDriver, KeyListener {
this.emu = emu;
try{
display = ImageIO.read(Objects.requireNonNull(getClass().getResourceAsStream("/display.png")));
fontSheet = ImageIO.read(Objects.requireNonNull(getClass().getResourceAsStream("/font.png")));
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
sprites[(i * cols) + j] = fontSheet.getSubimage(
j * width,
i * height,
width,
height
);
}
}
for(int i = 0; i < characters.length; i++){
characters[i] = new ImageIcon(sprites[i]);
}
} catch(IOException e){
System.out.print("No image!");
}
@ -59,18 +43,33 @@ public class BasicMonitorDriver implements MonitorDriver, KeyListener {
JFrame frame = new JFrame("Monitor");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
for(int y = 0; y < displayArray.length; y++){
for(int x = 0; x < displayArray[y].length; x++){
displayArray[y][x] = new JLabel(new ImageIcon(sprites[' ']));
displayArray[y][x].setBounds(xoffset + (x * 8), yoffset + (y * 8), 8, 8);
displayArray[y][x].setVisible(true);
panel.add(displayArray[y][x]);
}
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
Font bescii;
try {
bescii = Font.createFont(Font.TRUETYPE_FONT, new File(getClass().getResource("/C64ProMonoMonitor.ttf").toURI()));
ge.registerFont(bescii);
} catch (FontFormatException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
bescii = bescii.deriveFont(Font.PLAIN, 8f);
for(int i = 0; i < HEIGHT; i++){
lines[i] = new JLabel();
lines[i].setFont(bescii);
lines[i].setBounds(xoffset, yoffset + i * 8, 8 * WIDTH, 16);
lines[i].setForeground(Color.GREEN);
panel.add(lines[i]);
}
JLabel label = new JLabel(new ImageIcon(display.getScaledInstance(350 * 2,230 * 2,0)));
label.setBounds(0, 0, 350 * 2, 230 * 2);
panel.add(label);
frame.add(panel);
frame.addKeyListener(this);
@ -101,11 +100,13 @@ public class BasicMonitorDriver implements MonitorDriver, KeyListener {
@Override
public void update(byte[][] windowData) {
for(int y = 0; y < windowData.length; y++){
for(int x = 0; x < windowData[y].length; x++){
char chars = (char) windowData[y][x];
displayArray[y][x].setIcon(characters[chars % 255]);
for(int y = windowData.length - 1; y >= 0; y--){
String text = "";
for(int x = 0; x<windowData[y].length; x++){
int temp = Math.floorMod(windowData[y][x] , 256);
text += (char)((temp + 0xDED0));
}
lines[y].setText(text);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

Loading…
Cancel
Save