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 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: # TODO:
Speed up monitor rendering. Speed up monitor rendering.

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