From 267658ddfd636f51a99f37d4c25e456a8c27d386 Mon Sep 17 00:00:00 2001 From: Adam Megacz Date: Sat, 29 Aug 2009 16:05:21 -0700 Subject: [PATCH] Dvi.ship: software implementatino --- ships/Dvi.ship | 91 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 62 insertions(+), 29 deletions(-) diff --git a/ships/Dvi.ship b/ships/Dvi.ship index ee02bc4..100314f 100644 --- a/ships/Dvi.ship +++ b/ships/Dvi.ship @@ -551,36 +551,69 @@ NET sram_oe_b LOC="B12"; # Bank 20, Vcco=3.3V, DCI using 49.9 ohm == TeX ============================================================== == Fleeterpreter ==================================================== - - private java.awt.Frame frame = null; - public void service() { - if (box_inPixelX.dataReadyForShip() && - box_inPixelY.dataReadyForShip() && - box_inPixelValue.dataReadyForShip() - ) { - long x = box_inPixelX.removeDataForShip(); - long y = box_inPixelY.removeDataForShip(); - long d = box_inPixelValue.removeDataForShip(); - - if (frame==null) { - frame = new java.awt.Frame(); - java.awt.Dimension dim = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); - frame.setSize((int)dim.getWidth(),(int)dim.getHeight()); - frame.show(); - frame.setBackground(new java.awt.Color(0,0,0)); - } - java.awt.Color c = new java.awt.Color( - ((d & (1L<<2))!=0) ? 0xff : 0x00, - ((d & (1L<<1))!=0) ? 0xff : 0x00, - ((d & (1L<<0))!=0) ? 0xff : 0x00 - ); - java.awt.Graphics2D g = (java.awt.Graphics2D)frame.getGraphics(); - g.transform(java.awt.geom.AffineTransform.getScaleInstance(((double)frame.getWidth())/640, ((double)frame.getHeight())/480)); - g.setColor(c); - g.fillRect((int)x,(int)y,1,1); - +private java.awt.Frame frame = null; +private java.awt.Panel panel = null; +private long[][] bits; +public static int SCREEN_WIDTH = 577; +public static int SCREEN_HEIGHT = 478; +public void service() { + long x,y,d; + if (box_inPixelX.dataReadyForShip() && + box_inPixelY.dataReadyForShip() && + box_inPixelValue.dataReadyForShip()) { + x = box_inPixelX.removeDataForShip(); + y = box_inPixelY.removeDataForShip(); + d = box_inPixelValue.removeDataForShip(); + } else if (box_inAddrWrite.dataReadyForShip() && + box_inDataWrite.dataReadyForShip() && + box_out.readyForDataFromShip()) { + long addr = box_inAddrWrite.removeDataForShip(); + x = addr % SCREEN_WIDTH; + y = addr / SCREEN_WIDTH; + d = box_inDataWrite.removeDataForShip(); + box_out.addDataFromShip(0,true); + } else if (box_inAddrRead.dataReadyForShip() && + box_out.readyForDataFromShip()) { + long addr = box_inAddrRead.removeDataForShip(); + x = addr % SCREEN_WIDTH; + y = addr / SCREEN_WIDTH; + box_out.addDataFromShip(bits[(int)x][(int)y],false); + return; + } else { + return; + } + if (frame==null) { + frame = new java.awt.Frame(); + bits = new long[SCREEN_WIDTH][SCREEN_HEIGHT]; + for(int i=0; i> 12) & ~((-1L) << 6)) << 2), + (int)(((d >> 6) & ~((-1L) << 6)) << 2), + (int)(((d >> 0) & ~((-1L) << 6)) << 2) + ); + g2.setColor(c); + g2.fillRect((int)xx,(int)yy,1,1); + } + } + } + }; + frame.setLayout(new java.awt.BorderLayout()); + frame.add(panel, java.awt.BorderLayout.CENTER); + panel.setBackground(java.awt.Color.black); + frame.show(); } - } + bits[(int)x][(int)y] = d; + panel.repaint(); +} == FleetSim ============================================================== -- 1.7.10.4