repo_name stringlengths 7 104 | file_path stringlengths 13 198 | context stringlengths 67 7.15k | import_statement stringlengths 16 4.43k | code stringlengths 40 6.98k | prompt stringlengths 227 8.27k | next_line stringlengths 8 795 |
|---|---|---|---|---|---|---|
lumag/JBookReader | src/org/jbookreader/ui/swing/painter/ImageRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java
// public abstract class AbstractInlineRenderingObject extends
// AbstractRenderingObject implements IInlineRenderingObject {
//
// private double myDepth;
//
// public AbstractInlineRenderingObject(IBookPainter painter, INode node) {
// super(painter, node);
// }
//
// public double getDepth() {
// return this.myDepth;
// }
//
// protected void setDepth(double depth) {
// this.myDepth = depth;
// }
//
// @Override
// public final void renderContents() {
// IBookPainter painter = getPainter();
// painter.addVerticalStrut(getHeight() - getDepth());
// renderInline();
// painter.addHorizontalStrut(-getWidth());
// painter.addVerticalStrut(getDepth());
// }
//
// public abstract void renderInline();
//
// public int getAdjustability() {
// return 0;
// }
//
// public void adjustWidth(double width) throws UnsupportedOperationException {
// throw new UnsupportedOperationException("adjusting of this objects isn't supported");
// }
// }
| import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.objects.AbstractInlineRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.ui.swing.painter;
/**
* This is a class representing Swing/ImageIO images for the FE.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
class ImageRenderingObject extends AbstractInlineRenderingObject {
/**
* Loaded image.
*/
private final BufferedImage myImage;
/**
* This constructs the image for specified <code>painter</code> from
* data in <code>stream</code>.
* @param painter the painter to construct the image date.
* @param node the node containing the image
* @param stream the stream with image data
* @throws IOException in case of I/O problems
*/ | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/objects/AbstractInlineRenderingObject.java
// public abstract class AbstractInlineRenderingObject extends
// AbstractRenderingObject implements IInlineRenderingObject {
//
// private double myDepth;
//
// public AbstractInlineRenderingObject(IBookPainter painter, INode node) {
// super(painter, node);
// }
//
// public double getDepth() {
// return this.myDepth;
// }
//
// protected void setDepth(double depth) {
// this.myDepth = depth;
// }
//
// @Override
// public final void renderContents() {
// IBookPainter painter = getPainter();
// painter.addVerticalStrut(getHeight() - getDepth());
// renderInline();
// painter.addHorizontalStrut(-getWidth());
// painter.addVerticalStrut(getDepth());
// }
//
// public abstract void renderInline();
//
// public int getAdjustability() {
// return 0;
// }
//
// public void adjustWidth(double width) throws UnsupportedOperationException {
// throw new UnsupportedOperationException("adjusting of this objects isn't supported");
// }
// }
// Path: src/org/jbookreader/ui/swing/painter/ImageRenderingObject.java
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.io.InputStream;
import javax.imageio.ImageIO;
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.objects.AbstractInlineRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.ui.swing.painter;
/**
* This is a class representing Swing/ImageIO images for the FE.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
class ImageRenderingObject extends AbstractInlineRenderingObject {
/**
* Loaded image.
*/
private final BufferedImage myImage;
/**
* This constructs the image for specified <code>painter</code> from
* data in <code>stream</code>.
* @param painter the painter to construct the image date.
* @param node the node containing the image
* @param stream the stream with image data
* @throws IOException in case of I/O problems
*/ | public ImageRenderingObject(SwingBookPainter painter, INode node, InputStream stream) throws IOException { |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/AbstractRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IRenderingObject.java
// public interface IRenderingObject {
//
// /**
// * Returns the total height of the object.
// * @return the total height of the object.
// */
// double getHeight();
//
// /**
// * Returns the width of the object.
// * @return the width of the object.
// */
// double getWidth();
//
// /**
// * Renders the object to assigned
// * {@link org.jbookreader.formatengine.IBookPainter}.
// *
// */
// void render();
//
// /**
// * Returns the node which this rendering object represents.
// * @return the node which this rendering object represents.
// */
// INode getNode();
//
// void setMarginTop(double margin);
// void setMarginRight(double margin);
// void setMarginBottom(double margin);
// void setMarginLeft(double margin);
//
// boolean isSplittable();
// }
| import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents an abstract rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public abstract class AbstractRenderingObject implements IRenderingObject {
interface BoxSides {
int TOP = 0;
int RIGHT = 1;
int BOTTOM = 2;
int LEFT = 3;
}
/**
* The height of the rendering object above the baseline.
*/
private double myHeight;
/**
* The width of the rendering object
*/
private double myWidth;
private double[] myMargins = new double[4];
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IRenderingObject.java
// public interface IRenderingObject {
//
// /**
// * Returns the total height of the object.
// * @return the total height of the object.
// */
// double getHeight();
//
// /**
// * Returns the width of the object.
// * @return the width of the object.
// */
// double getWidth();
//
// /**
// * Renders the object to assigned
// * {@link org.jbookreader.formatengine.IBookPainter}.
// *
// */
// void render();
//
// /**
// * Returns the node which this rendering object represents.
// * @return the node which this rendering object represents.
// */
// INode getNode();
//
// void setMarginTop(double margin);
// void setMarginRight(double margin);
// void setMarginBottom(double margin);
// void setMarginLeft(double margin);
//
// boolean isSplittable();
// }
// Path: src/org/jbookreader/formatengine/objects/AbstractRenderingObject.java
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents an abstract rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public abstract class AbstractRenderingObject implements IRenderingObject {
interface BoxSides {
int TOP = 0;
int RIGHT = 1;
int BOTTOM = 2;
int LEFT = 3;
}
/**
* The height of the rendering object above the baseline.
*/
private double myHeight;
/**
* The width of the rendering object
*/
private double myWidth;
private double[] myMargins = new double[4];
| private INode myNode; |
lumag/JBookReader | src/org/jbookreader/formatengine/objects/AbstractRenderingObject.java | // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IRenderingObject.java
// public interface IRenderingObject {
//
// /**
// * Returns the total height of the object.
// * @return the total height of the object.
// */
// double getHeight();
//
// /**
// * Returns the width of the object.
// * @return the width of the object.
// */
// double getWidth();
//
// /**
// * Renders the object to assigned
// * {@link org.jbookreader.formatengine.IBookPainter}.
// *
// */
// void render();
//
// /**
// * Returns the node which this rendering object represents.
// * @return the node which this rendering object represents.
// */
// INode getNode();
//
// void setMarginTop(double margin);
// void setMarginRight(double margin);
// void setMarginBottom(double margin);
// void setMarginLeft(double margin);
//
// boolean isSplittable();
// }
| import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IRenderingObject; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents an abstract rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public abstract class AbstractRenderingObject implements IRenderingObject {
interface BoxSides {
int TOP = 0;
int RIGHT = 1;
int BOTTOM = 2;
int LEFT = 3;
}
/**
* The height of the rendering object above the baseline.
*/
private double myHeight;
/**
* The width of the rendering object
*/
private double myWidth;
private double[] myMargins = new double[4];
private INode myNode;
| // Path: src/org/jbookreader/book/bom/INode.java
// public interface INode {
//
// /**
// * Returns the text contained in the node.
// * @return the text contained in the node.
// */
// String getText();
//
// /**
// * Returns the tag-name of the node.
// * @return the tag-name of the node.
// */
// String getTagName();
//
// /**
// * Returns the class of the node.
// * @return the class of the node.
// */
// String getNodeClass();
//
// /**
// * Sets the class of the node.
// * @param nodeClass the class of the node
// */
// void setNodeClass(String nodeClass);
//
// /**
// * Returns the parent node (the node, containing this one).
// * @return the parent node.
// */
// IContainerNode getParentNode();
//
// /**
// * Returns the ID of this node or null if this node has no ID.
// * @return the ID of this node.
// */
// String getID();
//
// /**
// * Sets the ID of this node
// * @param id new ID
// */
// void setID(String id);
//
// /**
// * Returns a book containing this node.
// * @return a book containing this node.
// */
// IBook getBook();
//
// String getNodeReference();
// }
//
// Path: src/org/jbookreader/formatengine/IBookPainter.java
// public interface IBookPainter {
// /**
// * Clears the output device, if it makes sense.
// *
// */
// void clear();
//
// /**
// * Returns the width of the device.
// *
// * @return the width of the device.
// */
// double getWidth();
//
// /**
// * Returns the height of the device.
// *
// * @return the height of the device.
// */
// double getHeight();
//
// /**
// * This adds the horizontal space of given size.
// *
// * @param size the size of necessary horizontal space.
// */
// void addHorizontalStrut(double size);
//
// /**
// * This adds the vertical space of given size.
// *
// * @param size the size of necessary vertical space.
// */
// void addVerticalStrut(double size);
//
// /**
// * Allocates and returns specified font.
// *
// * @param name the name of the font
// * @param size font size
// * @return the allocated font object.
// */
// IFont getFont(String name, int size);
//
// /**
// * Returns current X coordinate.
// *
// * @return current X coordinate.
// */
// double getXCoordinate();
//
// /**
// * Returns current Y coordinate.
// *
// * @return current Y coordinate.
// */
// double getYCoordinate();
//
// /**
// * Returns a rendering object for the image or <code>null</code> if
// * the image can't be rendered.
// * @param node the node representing the image
// * @param contentType the content type of the image
// * @param stream the stream with the image
// *
// * @return a rendering object for the image.
// */
// IInlineRenderingObject getImage(INode node, String contentType, InputStream stream);
// }
//
// Path: src/org/jbookreader/formatengine/IRenderingObject.java
// public interface IRenderingObject {
//
// /**
// * Returns the total height of the object.
// * @return the total height of the object.
// */
// double getHeight();
//
// /**
// * Returns the width of the object.
// * @return the width of the object.
// */
// double getWidth();
//
// /**
// * Renders the object to assigned
// * {@link org.jbookreader.formatengine.IBookPainter}.
// *
// */
// void render();
//
// /**
// * Returns the node which this rendering object represents.
// * @return the node which this rendering object represents.
// */
// INode getNode();
//
// void setMarginTop(double margin);
// void setMarginRight(double margin);
// void setMarginBottom(double margin);
// void setMarginLeft(double margin);
//
// boolean isSplittable();
// }
// Path: src/org/jbookreader/formatengine/objects/AbstractRenderingObject.java
import org.jbookreader.book.bom.INode;
import org.jbookreader.formatengine.IBookPainter;
import org.jbookreader.formatengine.IRenderingObject;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.jbookreader.formatengine.objects;
/**
* This class represents an abstract rendering object.
*
* @author Dmitry Baryshkov (dbaryshkov@gmail.com)
*
*/
public abstract class AbstractRenderingObject implements IRenderingObject {
interface BoxSides {
int TOP = 0;
int RIGHT = 1;
int BOTTOM = 2;
int LEFT = 3;
}
/**
* The height of the rendering object above the baseline.
*/
private double myHeight;
/**
* The width of the rendering object
*/
private double myWidth;
private double[] myMargins = new double[4];
private INode myNode;
| private IBookPainter myPainter; |
lumag/JBookReader | src/org/jbookreader/ui/swing/MainWindowComponentListener.java | // Path: src/org/jbookreader/ui/swing/actions/QuitAction.java
// @SuppressWarnings("serial")
// public class QuitAction extends AbstractAction {
//
// private QuitAction() {
// putValue(NAME, Messages.getString("QuitAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Integer.valueOf(Messages.getString("QuitAction.Mnemonic").charAt(0))); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("QuitAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new QuitAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// String posref = MainWindow.getMainWindow().getBookComponent().getDisplayNodeReference();
// if (posref != null) {
// Config.getConfig().setStringValue("book_position", posref);
// try {
// Config.getConfig().save();
// } catch (IOException e1) {
// e1.printStackTrace();
// }
// }
// MainWindow.getMainWindow().getFrame().dispose();
// }
//
// }
| import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.io.IOException;
import org.jbookreader.ui.swing.actions.QuitAction; | /*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowComponentListener extends ComponentAdapter {
@Override
public void componentMoved(ComponentEvent e) {
Point point = MainWindow.getMainWindow().getFrame().getLocation();
Config.getConfig().setIntValue("main_x", point.x);
Config.getConfig().setIntValue("main_y", point.y);
try {
Config.getConfig().save();
} catch (IOException e1) {
e1.printStackTrace();
}
}
@Override
public void componentResized(ComponentEvent e) {
Dimension dim = MainWindow.getMainWindow().getFrame().getSize();
Config.getConfig().setIntValue("main_width", dim.width);
Config.getConfig().setIntValue("main_height", dim.height);
try {
Config.getConfig().save();
} catch (IOException e1) {
e1.printStackTrace();
}
}
@Override
public void componentHidden(ComponentEvent e) { | // Path: src/org/jbookreader/ui/swing/actions/QuitAction.java
// @SuppressWarnings("serial")
// public class QuitAction extends AbstractAction {
//
// private QuitAction() {
// putValue(NAME, Messages.getString("QuitAction.Name")); //$NON-NLS-1$
// putValue(MNEMONIC_KEY, Integer.valueOf(Messages.getString("QuitAction.Mnemonic").charAt(0))); //$NON-NLS-1$
// putValue(SHORT_DESCRIPTION, Messages.getString("QuitAction.Description")); //$NON-NLS-1$
// }
//
// private static Action ourAction;
//
// /**
// * Returns the instance of this action type.
// * @return the instance of this action type.
// */
// public static Action getAction() {
// if (ourAction == null) {
// ourAction = new QuitAction();
// }
//
// return ourAction;
// }
//
// public void actionPerformed(ActionEvent e) {
// String posref = MainWindow.getMainWindow().getBookComponent().getDisplayNodeReference();
// if (posref != null) {
// Config.getConfig().setStringValue("book_position", posref);
// try {
// Config.getConfig().save();
// } catch (IOException e1) {
// e1.printStackTrace();
// }
// }
// MainWindow.getMainWindow().getFrame().dispose();
// }
//
// }
// Path: src/org/jbookreader/ui/swing/MainWindowComponentListener.java
import java.awt.Dimension;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ComponentEvent;
import java.io.IOException;
import org.jbookreader.ui.swing.actions.QuitAction;
/*
* JBookReader - Java FictionBook Reader
* Copyright (C) 2006 Dmitry Baryshkov
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
*
*/
package org.jbookreader.ui.swing;
class MainWindowComponentListener extends ComponentAdapter {
@Override
public void componentMoved(ComponentEvent e) {
Point point = MainWindow.getMainWindow().getFrame().getLocation();
Config.getConfig().setIntValue("main_x", point.x);
Config.getConfig().setIntValue("main_y", point.y);
try {
Config.getConfig().save();
} catch (IOException e1) {
e1.printStackTrace();
}
}
@Override
public void componentResized(ComponentEvent e) {
Dimension dim = MainWindow.getMainWindow().getFrame().getSize();
Config.getConfig().setIntValue("main_width", dim.width);
Config.getConfig().setIntValue("main_height", dim.height);
try {
Config.getConfig().save();
} catch (IOException e1) {
e1.printStackTrace();
}
}
@Override
public void componentHidden(ComponentEvent e) { | QuitAction.getAction().actionPerformed(new ActionEvent(e.getSource(), e.getID(), null)); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/DmgSound2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class DmgSound2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/DmgSound2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class DmgSound2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("blargg/dmg_sound-2"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/DmgSound2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class DmgSound2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/dmg_sound-2");
}
public DmgSound2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/DmgSound2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class DmgSound2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/dmg_sound-2");
}
public DmgSound2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | RomTestUtils.testRomWithMemory(rom); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gui/SwingController.java | // Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// public interface ButtonListener {
//
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// void onButtonPress(Button button);
//
// void onButtonRelease(Button button);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/Controller.java
// public interface Controller {
//
// void setButtonListener(ButtonListener listener);
//
// Controller NULL_CONTROLLER = listener -> {};
// }
| import eu.rekawek.coffeegb.controller.ButtonListener;
import eu.rekawek.coffeegb.controller.ButtonListener.Button;
import eu.rekawek.coffeegb.controller.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.lang.reflect.Field;
import java.security.InvalidParameterException;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors; | package eu.rekawek.coffeegb.gui;
public class SwingController implements Controller, KeyListener {
private static final Logger LOG = LoggerFactory.getLogger(SwingController.class);
| // Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// public interface ButtonListener {
//
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// void onButtonPress(Button button);
//
// void onButtonRelease(Button button);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/Controller.java
// public interface Controller {
//
// void setButtonListener(ButtonListener listener);
//
// Controller NULL_CONTROLLER = listener -> {};
// }
// Path: src/main/java/eu/rekawek/coffeegb/gui/SwingController.java
import eu.rekawek.coffeegb.controller.ButtonListener;
import eu.rekawek.coffeegb.controller.ButtonListener.Button;
import eu.rekawek.coffeegb.controller.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.lang.reflect.Field;
import java.security.InvalidParameterException;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
package eu.rekawek.coffeegb.gui;
public class SwingController implements Controller, KeyListener {
private static final Logger LOG = LoggerFactory.getLogger(SwingController.class);
| private ButtonListener listener; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gui/SwingController.java | // Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// public interface ButtonListener {
//
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// void onButtonPress(Button button);
//
// void onButtonRelease(Button button);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/Controller.java
// public interface Controller {
//
// void setButtonListener(ButtonListener listener);
//
// Controller NULL_CONTROLLER = listener -> {};
// }
| import eu.rekawek.coffeegb.controller.ButtonListener;
import eu.rekawek.coffeegb.controller.ButtonListener.Button;
import eu.rekawek.coffeegb.controller.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.lang.reflect.Field;
import java.security.InvalidParameterException;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors; | package eu.rekawek.coffeegb.gui;
public class SwingController implements Controller, KeyListener {
private static final Logger LOG = LoggerFactory.getLogger(SwingController.class);
private ButtonListener listener;
| // Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// public interface ButtonListener {
//
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// void onButtonPress(Button button);
//
// void onButtonRelease(Button button);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/ButtonListener.java
// enum Button {
// RIGHT(0x01, 0x10), LEFT(0x02, 0x10), UP(0x04, 0x10), DOWN(0x08, 0x10),
// A(0x01, 0x20), B(0x02, 0x20), SELECT(0x04, 0x20), START(0x08, 0x20);
//
// private final int mask;
//
// private final int line;
//
// Button(int mask, int line) {
// this.mask = mask;
// this.line = line;
// }
//
// public int getMask() {
// return mask;
// }
//
// public int getLine() {
// return line;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/controller/Controller.java
// public interface Controller {
//
// void setButtonListener(ButtonListener listener);
//
// Controller NULL_CONTROLLER = listener -> {};
// }
// Path: src/main/java/eu/rekawek/coffeegb/gui/SwingController.java
import eu.rekawek.coffeegb.controller.ButtonListener;
import eu.rekawek.coffeegb.controller.ButtonListener.Button;
import eu.rekawek.coffeegb.controller.Controller;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.lang.reflect.Field;
import java.security.InvalidParameterException;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.stream.Collectors;
package eu.rekawek.coffeegb.gui;
public class SwingController implements Controller, KeyListener {
private static final Logger LOG = LoggerFactory.getLogger(SwingController.class);
private ButtonListener listener;
| private Map<Integer, Button> mapping; |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/PpuTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class PpuTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/PpuTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class PpuTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/ppu"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/PpuTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class PpuTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/ppu");
}
public PpuTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/PpuTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class PpuTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/ppu");
}
public PpuTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CpuInstrsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CpuInstrsTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CpuInstrsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CpuInstrsTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("blargg/cpu_instrs"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CpuInstrsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CpuInstrsTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/cpu_instrs");
}
public CpuInstrsTest(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CpuInstrsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CpuInstrsTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/cpu_instrs");
}
public CpuInstrsTest(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | RomTestUtils.testRomWithSerial(rom); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc5.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType; | package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc5 implements AddressSpace {
private final CartridgeType type;
private final int romBanks;
private final int ramBanks;
private final int[] cartridge;
private final int[] ram;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc5.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc5 implements AddressSpace {
private final CartridgeType type;
private final int romBanks;
private final int ramBanks;
private final int[] cartridge;
private final int[] ram;
| private final Battery battery; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/sound/Sound.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/debug/command/apu/Channel.java
// public class Channel implements Command {
//
// private static final CommandPattern PATTERN = CommandPattern.Builder
// .create("apu chan")
// .withDescription("enable given channels (1-4)")
// .build();
//
// private final Sound sound;
//
// public Channel(Sound sound) {
// this.sound = sound;
// }
//
// @Override
// public CommandPattern getPattern() {
// return PATTERN;
// }
//
// @Override
// public void run(CommandPattern.ParsedCommandLine commandLine) {
// Set<String> channels = new HashSet<>(commandLine.getRemainingArguments());
// for (int i = 1; i <= 4; i++) {
// sound.enableChannel(i - 1, channels.contains(String.valueOf(i)));
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.debug.command.apu.Channel;
import eu.rekawek.coffeegb.memory.Ram; | package eu.rekawek.coffeegb.sound;
public class Sound implements AddressSpace {
private static final int[] MASKS = new int[] {
0x80, 0x3f, 0x00, 0xff, 0xbf,
0xff, 0x3f, 0x00, 0xff, 0xbf,
0x7f, 0xff, 0x9f, 0xff, 0xbf,
0xff, 0xff, 0x00, 0x00, 0xbf,
0x00, 0x00, 0x70,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
private final AbstractSoundMode[] allModes = new AbstractSoundMode[4];
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/debug/command/apu/Channel.java
// public class Channel implements Command {
//
// private static final CommandPattern PATTERN = CommandPattern.Builder
// .create("apu chan")
// .withDescription("enable given channels (1-4)")
// .build();
//
// private final Sound sound;
//
// public Channel(Sound sound) {
// this.sound = sound;
// }
//
// @Override
// public CommandPattern getPattern() {
// return PATTERN;
// }
//
// @Override
// public void run(CommandPattern.ParsedCommandLine commandLine) {
// Set<String> channels = new HashSet<>(commandLine.getRemainingArguments());
// for (int i = 1; i <= 4; i++) {
// sound.enableChannel(i - 1, channels.contains(String.valueOf(i)));
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/sound/Sound.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.debug.command.apu.Channel;
import eu.rekawek.coffeegb.memory.Ram;
package eu.rekawek.coffeegb.sound;
public class Sound implements AddressSpace {
private static final int[] MASKS = new int[] {
0x80, 0x3f, 0x00, 0xff, 0xbf,
0xff, 0x3f, 0x00, 0xff, 0xbf,
0x7f, 0xff, 0x9f, 0xff, 0xbf,
0xff, 0xff, 0x00, 0x00, 0xbf,
0x00, 0x00, 0x70,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
private final AbstractSoundMode[] allModes = new AbstractSoundMode[4];
| private final Ram r = new Ram(0xff24, 0x03); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
| private final AddressSpace memory; |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
private final AddressSpace memory;
public TimingTest() { | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
private final AddressSpace memory;
public TimingTest() { | memory = new Ram(0x00, 0x10000); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
private final AddressSpace memory;
public TimingTest() {
memory = new Ram(0x00, 0x10000); | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
package eu.rekawek.coffeegb.cpu;
public class TimingTest {
private static final int OFFSET = 0x100;
private final Cpu cpu;
private final AddressSpace memory;
public TimingTest() {
memory = new Ram(0x00, 0x10000); | cpu = new Cpu(memory, new InterruptManager(false), null, Display.NULL_DISPLAY, new SpeedMode()); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals; | assertTiming(12, 0xe0, 0x05); // LD (ff00+05),A
assertTiming(12, 0xf0, 0x05); // LD A,(ff00+05)
assertTiming(4, 0xb7); // OR
assertTiming(4, 0x7b); // LDA A,E
assertTiming(8, 0xd6, 0x00); // SUB A,d8
assertTiming(8, 0xcb, 0x12); // RL D
assertTiming(4, 0x87); // ADD A
assertTiming(4, 0xf3); // DI
assertTiming(8, 0x32); // LD (HL-),A
assertTiming(12, 0x36); // LD (HL),d8
assertTiming(16, 0xea, 0x00, 0x00); // LD (a16),A
assertTiming(8, 0x09); // ADD HL,BC
assertTiming(16, 0xc7); // RST 00H
assertTiming(8, 0x3e, 0x51); // LDA A,51
assertTiming(4, 0x1f); // RRA
assertTiming(8, 0xce, 0x01); // ADC A,01
assertTiming(4, 0x00); // NOP
}
private void assertTiming(int expectedTiming, int... opcodes) {
for (int i = 0; i < opcodes.length; i++) {
memory.setByte(OFFSET + i, opcodes[i]);
}
cpu.clearState();
cpu.getRegisters().setPC(OFFSET);
int ticks = 0; | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
// public class Opcode {
//
// private final int opcode;
//
// private final String label;
//
// private final List<Op> ops;
//
// private final int length;
//
// Opcode(OpcodeBuilder builder) {
// this.opcode = builder.getOpcode();
// this.label = builder.getLabel();
// this.ops = Collections.unmodifiableList(new ArrayList<>(builder.getOps()));
// this.length = ops.stream().mapToInt(o -> o.operandLength()).max().orElse(0);
// }
//
// public int getOperandLength() {
// return length;
// }
//
// @Override
// public String toString() {
// return String.format("%02x %s", opcode, label);
// }
//
// public List<Op> getOps() {
// return ops;
// }
//
// public String getLabel() {
// return label;
// }
//
// public int getOpcode() {
// return opcode;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Display.java
// public interface Display {
//
// void putDmgPixel(int color);
//
// void putColorPixel(int gbcRgb);
//
// void requestRefresh();
//
// void waitForRefresh();
//
// void enableLcd();
//
// void disableLcd();
//
// Display NULL_DISPLAY = new Display() {
//
// @Override
// public void putDmgPixel(int color) {
// }
//
// @Override
// public void putColorPixel(int gbcRgb) {
// }
//
// @Override
// public void requestRefresh() {
// }
//
// @Override
// public void waitForRefresh() {
// }
//
// @Override
// public void enableLcd() {
// }
//
// @Override
// public void disableLcd() {
// }
// };
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/cpu/TimingTest.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.opcode.Opcode;
import eu.rekawek.coffeegb.gpu.Display;
import eu.rekawek.coffeegb.memory.Ram;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
assertTiming(12, 0xe0, 0x05); // LD (ff00+05),A
assertTiming(12, 0xf0, 0x05); // LD A,(ff00+05)
assertTiming(4, 0xb7); // OR
assertTiming(4, 0x7b); // LDA A,E
assertTiming(8, 0xd6, 0x00); // SUB A,d8
assertTiming(8, 0xcb, 0x12); // RL D
assertTiming(4, 0x87); // ADD A
assertTiming(4, 0xf3); // DI
assertTiming(8, 0x32); // LD (HL-),A
assertTiming(12, 0x36); // LD (HL),d8
assertTiming(16, 0xea, 0x00, 0x00); // LD (a16),A
assertTiming(8, 0x09); // ADD HL,BC
assertTiming(16, 0xc7); // RST 00H
assertTiming(8, 0x3e, 0x51); // LDA A,51
assertTiming(4, 0x1f); // RRA
assertTiming(8, 0xce, 0x01); // ADC A,01
assertTiming(4, 0x00); // NOP
}
private void assertTiming(int expectedTiming, int... opcodes) {
for (int i = 0; i < opcodes.length; i++) {
memory.setByte(OFFSET + i, opcodes[i]);
}
cpu.clearState();
cpu.getRegisters().setPC(OFFSET);
int ticks = 0; | Opcode opcode = null; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Registers.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB; |
public int getAF() {
return a << 8 | flags.getFlagsByte();
}
public int getBC() {
return b << 8 | c;
}
public int getDE() {
return d << 8 | e;
}
public int getHL() {
return h << 8 | l;
}
public int getSP() {
return sp;
}
public int getPC() {
return pc;
}
public Flags getFlags() {
return flags;
}
public void setA(int a) { | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Registers.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB;
public int getAF() {
return a << 8 | flags.getFlagsByte();
}
public int getBC() {
return b << 8 | c;
}
public int getDE() {
return d << 8 | e;
}
public int getHL() {
return h << 8 | l;
}
public int getSP() {
return sp;
}
public int getPC() {
return pc;
}
public Flags getFlags() {
return flags;
}
public void setA(int a) { | checkByteArgument("a", a); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Registers.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB; | checkByteArgument("b", b);
this.b = b;
}
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) { | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Registers.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB;
checkByteArgument("b", b);
this.b = b;
}
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) { | checkWordArgument("af", af); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Registers.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB; | this.b = b;
}
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) {
checkWordArgument("af", af); | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Registers.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB;
this.b = b;
}
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) {
checkWordArgument("af", af); | a = getMSB(af); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Registers.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB; | }
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) {
checkWordArgument("af", af);
a = getMSB(af); | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getLSB(int word) {
// checkWordArgument("word", word);
// return word & 0xff;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int getMSB(int word) {
// checkWordArgument("word", word);
// return word >> 8;
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Registers.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getLSB;
import static eu.rekawek.coffeegb.cpu.BitUtils.getMSB;
}
public void setC(int c) {
checkByteArgument("c", c);
this.c = c;
}
public void setD(int d) {
checkByteArgument("d", d);
this.d = d;
}
public void setE(int e) {
checkByteArgument("e", e);
this.e = e;
}
public void setH(int h) {
checkByteArgument("h", h);
this.h = h;
}
public void setL(int l) {
checkByteArgument("l", l);
this.l = l;
}
public void setAF(int af) {
checkWordArgument("af", af);
a = getMSB(af); | flags.setFlagsByte(getLSB(af)); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/TimerTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class TimerTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/TimerTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class TimerTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/timer"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/TimerTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class TimerTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/timer");
}
public TimerTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/TimerTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class TimerTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/timer");
}
public TimerTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/OamBug2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class OamBug2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/OamBug2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class OamBug2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("blargg/oam_bug-2"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/OamBug2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class OamBug2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/oam_bug-2");
}
public OamBug2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/OamBug2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class OamBug2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/oam_bug-2");
}
public OamBug2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | RomTestUtils.testRomWithMemory(rom); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/timer/Timer.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/InterruptManager.java
// public class InterruptManager implements AddressSpace {
//
// public enum InterruptType {
// VBlank(0x0040), LCDC(0x0048), Timer(0x0050), Serial(0x0058), P10_13(0x0060);
//
// private final int handler;
//
// InterruptType(int handler) {
// this.handler = handler;
// }
//
// public int getHandler() {
// return handler;
// }
// }
//
// private final boolean gbc;
//
// private boolean ime;
//
// private int interruptFlag = 0xe1;
//
// private int interruptEnabled;
//
// private int pendingEnableInterrupts = -1;
//
// private int pendingDisableInterrupts = -1;
//
// public InterruptManager(boolean gbc) {
// this.gbc = gbc;
// }
//
// public void enableInterrupts(boolean withDelay) {
// pendingDisableInterrupts = -1;
// if (withDelay) {
// if (pendingEnableInterrupts == -1) {
// pendingEnableInterrupts = 1;
// }
// } else {
// pendingEnableInterrupts = -1;
// ime = true;
// }
// }
//
// public void disableInterrupts(boolean withDelay) {
// pendingEnableInterrupts = -1;
// if (withDelay && gbc) {
// if (pendingDisableInterrupts == -1) {
// pendingDisableInterrupts = 1;
// }
// } else {
// pendingDisableInterrupts = -1;
// ime = false;
// }
// }
//
// public void requestInterrupt(InterruptType type) {
// interruptFlag = interruptFlag | (1 << type.ordinal());
// }
//
// public void clearInterrupt(InterruptType type) {
// interruptFlag = interruptFlag & ~(1 << type.ordinal());
// }
//
// public void onInstructionFinished() {
// if (pendingEnableInterrupts != -1) {
// if (pendingEnableInterrupts-- == 0) {
// enableInterrupts(false);
// }
// }
// if (pendingDisableInterrupts != -1) {
// if (pendingDisableInterrupts-- == 0) {
// disableInterrupts(false);
// }
// }
// }
//
// public boolean isIme() {
// return ime;
// }
//
// public boolean isInterruptRequested() {
// return (interruptFlag & interruptEnabled) != 0;
// }
//
// public boolean isHaltBug() {
// return (interruptFlag & interruptEnabled & 0x1f) != 0 && !ime;
// }
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff0f || address == 0xffff;
// }
//
// @Override
// public void setByte(int address, int value) {
// switch (address) {
// case 0xff0f:
// interruptFlag = value | 0xe0;
// break;
//
// case 0xffff:
// interruptEnabled = value;
// break;
// }
// }
//
// @Override
// public int getByte(int address) {
// switch (address) {
// case 0xff0f:
// return interruptFlag;
//
// case 0xffff:
// return interruptEnabled;
//
// default:
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/SpeedMode.java
// public class SpeedMode implements AddressSpace {
//
// private boolean currentSpeed;
//
// private boolean prepareSpeedSwitch;
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff4d;
// }
//
// @Override
// public void setByte(int address, int value) {
// prepareSpeedSwitch = (value & 0x01) != 0;
// }
//
// @Override
// public int getByte(int address) {
// return (currentSpeed ? (1 << 7) : 0) | (prepareSpeedSwitch ? (1 << 0) : 0) | 0b01111110;
// }
//
// boolean onStop() {
// if (prepareSpeedSwitch) {
// currentSpeed = !currentSpeed;
// prepareSpeedSwitch = false;
// return true;
// } else {
// return false;
// }
// }
//
// public int getSpeedMode() {
// return currentSpeed ? 2 : 1;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.InterruptManager;
import eu.rekawek.coffeegb.cpu.SpeedMode; | package eu.rekawek.coffeegb.timer;
public class Timer implements AddressSpace {
private final SpeedMode speedMode;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/InterruptManager.java
// public class InterruptManager implements AddressSpace {
//
// public enum InterruptType {
// VBlank(0x0040), LCDC(0x0048), Timer(0x0050), Serial(0x0058), P10_13(0x0060);
//
// private final int handler;
//
// InterruptType(int handler) {
// this.handler = handler;
// }
//
// public int getHandler() {
// return handler;
// }
// }
//
// private final boolean gbc;
//
// private boolean ime;
//
// private int interruptFlag = 0xe1;
//
// private int interruptEnabled;
//
// private int pendingEnableInterrupts = -1;
//
// private int pendingDisableInterrupts = -1;
//
// public InterruptManager(boolean gbc) {
// this.gbc = gbc;
// }
//
// public void enableInterrupts(boolean withDelay) {
// pendingDisableInterrupts = -1;
// if (withDelay) {
// if (pendingEnableInterrupts == -1) {
// pendingEnableInterrupts = 1;
// }
// } else {
// pendingEnableInterrupts = -1;
// ime = true;
// }
// }
//
// public void disableInterrupts(boolean withDelay) {
// pendingEnableInterrupts = -1;
// if (withDelay && gbc) {
// if (pendingDisableInterrupts == -1) {
// pendingDisableInterrupts = 1;
// }
// } else {
// pendingDisableInterrupts = -1;
// ime = false;
// }
// }
//
// public void requestInterrupt(InterruptType type) {
// interruptFlag = interruptFlag | (1 << type.ordinal());
// }
//
// public void clearInterrupt(InterruptType type) {
// interruptFlag = interruptFlag & ~(1 << type.ordinal());
// }
//
// public void onInstructionFinished() {
// if (pendingEnableInterrupts != -1) {
// if (pendingEnableInterrupts-- == 0) {
// enableInterrupts(false);
// }
// }
// if (pendingDisableInterrupts != -1) {
// if (pendingDisableInterrupts-- == 0) {
// disableInterrupts(false);
// }
// }
// }
//
// public boolean isIme() {
// return ime;
// }
//
// public boolean isInterruptRequested() {
// return (interruptFlag & interruptEnabled) != 0;
// }
//
// public boolean isHaltBug() {
// return (interruptFlag & interruptEnabled & 0x1f) != 0 && !ime;
// }
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff0f || address == 0xffff;
// }
//
// @Override
// public void setByte(int address, int value) {
// switch (address) {
// case 0xff0f:
// interruptFlag = value | 0xe0;
// break;
//
// case 0xffff:
// interruptEnabled = value;
// break;
// }
// }
//
// @Override
// public int getByte(int address) {
// switch (address) {
// case 0xff0f:
// return interruptFlag;
//
// case 0xffff:
// return interruptEnabled;
//
// default:
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/SpeedMode.java
// public class SpeedMode implements AddressSpace {
//
// private boolean currentSpeed;
//
// private boolean prepareSpeedSwitch;
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff4d;
// }
//
// @Override
// public void setByte(int address, int value) {
// prepareSpeedSwitch = (value & 0x01) != 0;
// }
//
// @Override
// public int getByte(int address) {
// return (currentSpeed ? (1 << 7) : 0) | (prepareSpeedSwitch ? (1 << 0) : 0) | 0b01111110;
// }
//
// boolean onStop() {
// if (prepareSpeedSwitch) {
// currentSpeed = !currentSpeed;
// prepareSpeedSwitch = false;
// return true;
// } else {
// return false;
// }
// }
//
// public int getSpeedMode() {
// return currentSpeed ? 2 : 1;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/timer/Timer.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.InterruptManager;
import eu.rekawek.coffeegb.cpu.SpeedMode;
package eu.rekawek.coffeegb.timer;
public class Timer implements AddressSpace {
private final SpeedMode speedMode;
| private final InterruptManager interruptManager; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/debug/Command.java | // Path: src/main/java/eu/rekawek/coffeegb/debug/CommandPattern.java
// public static class ParsedCommandLine {
//
// private Map<String, String> argumentMap;
//
// private List<String> remainingArguments;
//
// private ParsedCommandLine(Map<String, String> argumentMap, List<String> remainingArguments) {
// this.argumentMap = argumentMap;
// this.remainingArguments = remainingArguments;
// }
//
// public String getArgument(String name) {
// return argumentMap.get(name);
// }
//
// public List<String> getRemainingArguments() {
// return remainingArguments;
// }
// }
| import eu.rekawek.coffeegb.debug.CommandPattern.ParsedCommandLine; | package eu.rekawek.coffeegb.debug;
public interface Command {
CommandPattern getPattern();
| // Path: src/main/java/eu/rekawek/coffeegb/debug/CommandPattern.java
// public static class ParsedCommandLine {
//
// private Map<String, String> argumentMap;
//
// private List<String> remainingArguments;
//
// private ParsedCommandLine(Map<String, String> argumentMap, List<String> remainingArguments) {
// this.argumentMap = argumentMap;
// this.remainingArguments = remainingArguments;
// }
//
// public String getArgument(String name) {
// return argumentMap.get(name);
// }
//
// public List<String> getRemainingArguments() {
// return remainingArguments;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/debug/Command.java
import eu.rekawek.coffeegb.debug.CommandPattern.ParsedCommandLine;
package eu.rekawek.coffeegb.debug;
public interface Command {
CommandPattern getPattern();
| void run(ParsedCommandLine commandLine); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/InstrTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InstrTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/InstrTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InstrTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/instr"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/InstrTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InstrTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/instr");
}
public InstrTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/InstrTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InstrTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/instr");
}
public InstrTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/Dumper.java | // Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
// public static int[] zip(int data1, int data2, boolean reverse, int[] pixelLine) {
// for (int i = 7; i >= 0; i--) {
// int mask = (1 << i);
// int p = 2 * ((data2 & mask) == 0 ? 0 : 1) + ((data1 & mask) == 0 ? 0 : 1);
// if (reverse) {
// pixelLine[i] = p;
// } else {
// pixelLine[7 - i] = p;
// }
// }
// return pixelLine;
// }
| import static eu.rekawek.coffeegb.gpu.Fetcher.zip; | package eu.rekawek.coffeegb;
public final class Dumper {
private Dumper() {
}
public static void dump(AddressSpace addressSpace, int offset, int length) {
for (int i = offset; i < (offset + length); i++) {
System.out.print(String.format("%02X ", addressSpace.getByte(i)));
if ((i - offset + 1) % 16 == 0) {
//System.out.print(" ");
//dumpText(addressSpace, i - 16);
System.out.println();
}
}
}
private static void dumpText(AddressSpace addressSpace, int offset) {
for (int i = 0; i < 16; i++) {
System.out.print(Character.toString((char) addressSpace.getByte(offset + i)));
}
}
public static void dumpTile(AddressSpace addressSpace, int offset) {
for (int i = 0; i < 16; i += 2) {
dumpTileLine(addressSpace.getByte(offset + i), addressSpace.getByte(offset + i + 1));
System.out.println();
}
}
public static void dumpTileLine(int data1, int data2) { | // Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
// public static int[] zip(int data1, int data2, boolean reverse, int[] pixelLine) {
// for (int i = 7; i >= 0; i--) {
// int mask = (1 << i);
// int p = 2 * ((data2 & mask) == 0 ? 0 : 1) + ((data1 & mask) == 0 ? 0 : 1);
// if (reverse) {
// pixelLine[i] = p;
// } else {
// pixelLine[7 - i] = p;
// }
// }
// return pixelLine;
// }
// Path: src/main/java/eu/rekawek/coffeegb/Dumper.java
import static eu.rekawek.coffeegb.gpu.Fetcher.zip;
package eu.rekawek.coffeegb;
public final class Dumper {
private Dumper() {
}
public static void dump(AddressSpace addressSpace, int offset, int length) {
for (int i = offset; i < (offset + length); i++) {
System.out.print(String.format("%02X ", addressSpace.getByte(i)));
if ((i - offset + 1) % 16 == 0) {
//System.out.print(" ");
//dumpText(addressSpace, i - 16);
System.out.println();
}
}
}
private static void dumpText(AddressSpace addressSpace, int offset) {
for (int i = 0; i < 16; i++) {
System.out.print(Character.toString((char) addressSpace.getByte(offset + i)));
}
}
public static void dumpTile(AddressSpace addressSpace, int offset) {
for (int i = 0; i < 16; i += 2) {
dumpTileLine(addressSpace.getByte(offset + i), addressSpace.getByte(offset + i + 1));
System.out.println();
}
}
public static void dumpTileLine(int data1, int data2) { | for (int pixel : zip(data1, data2, false, new int[8])) { |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/SpriteBug.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
| import eu.rekawek.coffeegb.AddressSpace; | package eu.rekawek.coffeegb.gpu;
public final class SpriteBug {
public enum CorruptionType {
INC_DEC, POP_1, POP_2, PUSH_1, PUSH_2, LD_HL;
}
private SpriteBug() {
}
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/SpriteBug.java
import eu.rekawek.coffeegb.AddressSpace;
package eu.rekawek.coffeegb.gpu;
public final class SpriteBug {
public enum CorruptionType {
INC_DEC, POP_1, POP_2, PUSH_1, PUSH_2, LD_HL;
}
private SpriteBug() {
}
| public static void corruptOam(AddressSpace addressSpace, CorruptionType type, int ticksInLine) { |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/OamDmaTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class OamDmaTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/OamDmaTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class OamDmaTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/oam_dma"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/OamDmaTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class OamDmaTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/oam_dma");
}
public OamDmaTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/OamDmaTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class OamDmaTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/oam_dma");
}
public OamDmaTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/BlarggRomTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
| import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithMemory;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithSerial; | package eu.rekawek.coffeegb.integration.blargg;
public class BlarggRomTest {
@Test
public void testCgbSound() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/BlarggRomTest.java
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithMemory;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithSerial;
package eu.rekawek.coffeegb.integration.blargg;
public class BlarggRomTest {
@Test
public void testCgbSound() throws IOException { | testRomWithMemory(getPath("cgb_sound.gb")); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/BlarggRomTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
| import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithMemory;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithSerial; | package eu.rekawek.coffeegb.integration.blargg;
public class BlarggRomTest {
@Test
public void testCgbSound() throws IOException {
testRomWithMemory(getPath("cgb_sound.gb"));
}
@Test
public void testCpuInstrs() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/BlarggRomTest.java
import org.junit.Ignore;
import org.junit.Test;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithMemory;
import static eu.rekawek.coffeegb.integration.support.RomTestUtils.testRomWithSerial;
package eu.rekawek.coffeegb.integration.blargg;
public class BlarggRomTest {
@Test
public void testCgbSound() throws IOException {
testRomWithMemory(getPath("cgb_sound.gb"));
}
@Test
public void testCpuInstrs() throws IOException { | testRomWithSerial(getPath("cpu_instrs.gb")); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/sound/SweepTest.java | // Path: src/main/java/eu/rekawek/coffeegb/Gameboy.java
// public static final int TICKS_PER_SEC = 4_194_304;
| import org.junit.Test;
import static eu.rekawek.coffeegb.Gameboy.TICKS_PER_SEC;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; | */
private void syncSweep() {
wregNR(10, 0x11);
wregNR(13, 0xff);
wregNR(14, 0x83);
while (sweep.isEnabled()) {
sweep.tick();
}
}
private void wregNR(int reg, int value) {
switch (reg) {
case 10:
sweep.setNr10(value);
break;
case 13:
sweep.setNr13(value);
break;
case 14:
sweep.setNr14(value);
break;
default:
throw new IllegalArgumentException();
}
}
private void delayApu(int apuCycles) { | // Path: src/main/java/eu/rekawek/coffeegb/Gameboy.java
// public static final int TICKS_PER_SEC = 4_194_304;
// Path: src/test/java/eu/rekawek/coffeegb/sound/SweepTest.java
import org.junit.Test;
import static eu.rekawek.coffeegb.Gameboy.TICKS_PER_SEC;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
*/
private void syncSweep() {
wregNR(10, 0x11);
wregNR(13, 0xff);
wregNR(14, 0x83);
while (sweep.isEnabled()) {
sweep.tick();
}
}
private void wregNR(int reg, int value) {
switch (reg) {
case 10:
sweep.setNr10(value);
break;
case 13:
sweep.setNr13(value);
break;
case 14:
sweep.setNr14(value);
break;
default:
throw new IllegalArgumentException();
}
}
private void delayApu(int apuCycles) { | for (int i = 0; i < TICKS_PER_SEC / 256 * apuCycles; i++) { |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/MemTiming2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class MemTiming2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/MemTiming2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class MemTiming2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("blargg/mem_timing-2"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/MemTiming2Test.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class MemTiming2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/mem_timing-2");
}
public MemTiming2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/MemTiming2Test.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class MemTiming2Test {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/mem_timing-2");
}
public MemTiming2Test(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | RomTestUtils.testRomWithMemory(rom); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/Mmu.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
| import eu.rekawek.coffeegb.AddressSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument; | public void setByte(int address, int value) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Writing value {} to void address {}", Integer.toHexString(value), Integer.toHexString(address));
}
@Override
public int getByte(int address) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Reading value from void address {}", Integer.toHexString(address));
return 0xff;
}
};
private final List<AddressSpace> spaces = new ArrayList<>();
public void addAddressSpace(AddressSpace space) {
spaces.add(space);
}
@Override
public boolean accepts(int address) {
return true;
}
@Override
public void setByte(int address, int value) { | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/Mmu.java
import eu.rekawek.coffeegb.AddressSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
public void setByte(int address, int value) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Writing value {} to void address {}", Integer.toHexString(value), Integer.toHexString(address));
}
@Override
public int getByte(int address) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Reading value from void address {}", Integer.toHexString(address));
return 0xff;
}
};
private final List<AddressSpace> spaces = new ArrayList<>();
public void addAddressSpace(AddressSpace space) {
spaces.add(space);
}
@Override
public boolean accepts(int address) {
return true;
}
@Override
public void setByte(int address, int value) { | checkByteArgument("value", value); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/Mmu.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
| import eu.rekawek.coffeegb.AddressSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument; | if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Writing value {} to void address {}", Integer.toHexString(value), Integer.toHexString(address));
}
@Override
public int getByte(int address) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Reading value from void address {}", Integer.toHexString(address));
return 0xff;
}
};
private final List<AddressSpace> spaces = new ArrayList<>();
public void addAddressSpace(AddressSpace space) {
spaces.add(space);
}
@Override
public boolean accepts(int address) {
return true;
}
@Override
public void setByte(int address, int value) {
checkByteArgument("value", value); | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkWordArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xffff, "Argument {} should be a word", argumentName);
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/Mmu.java
import eu.rekawek.coffeegb.AddressSpace;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.checkWordArgument;
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Writing value {} to void address {}", Integer.toHexString(value), Integer.toHexString(address));
}
@Override
public int getByte(int address) {
if (address < 0 || address > 0xffff) {
throw new IllegalArgumentException("Invalid address: " + Integer.toHexString(address));
}
LOG.debug("Reading value from void address {}", Integer.toHexString(address));
return 0xff;
}
};
private final List<AddressSpace> spaces = new ArrayList<>();
public void addAddressSpace(AddressSpace space) {
spaces.add(space);
}
@Override
public boolean accepts(int address) {
return true;
}
@Override
public void setByte(int address, int value) {
checkByteArgument("value", value); | checkWordArgument("address", address); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/DmgPixelFifo.java | // Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
| import eu.rekawek.coffeegb.memory.MemoryRegisters; | package eu.rekawek.coffeegb.gpu;
public class DmgPixelFifo implements PixelFifo {
private final IntQueue pixels = new IntQueue(16);
private final IntQueue palettes = new IntQueue(16);
private final IntQueue pixelType = new IntQueue(16); // 0 - bg, 1 - sprite
private final Display display;
private final Lcdc lcdc;
| // Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/DmgPixelFifo.java
import eu.rekawek.coffeegb.memory.MemoryRegisters;
package eu.rekawek.coffeegb.gpu;
public class DmgPixelFifo implements PixelFifo {
private final IntQueue pixels = new IntQueue(16);
private final IntQueue palettes = new IntQueue(16);
private final IntQueue pixelType = new IntQueue(16); // 0 - bg, 1 - sprite
private final Display display;
private final Lcdc lcdc;
| private final MemoryRegisters registers; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/AluFunctions.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/op/DataType.java
// public enum DataType {
//
// D8, D16, R8
//
// }
| import eu.rekawek.coffeegb.cpu.op.DataType;
import java.util.HashMap;
import java.util.Map; | package eu.rekawek.coffeegb.cpu;
public class AluFunctions {
private Map<FunctionKey, IntRegistryFunction> functions = new HashMap<>();
private Map<FunctionKey, BiIntRegistryFunction> biFunctions = new HashMap<>();
| // Path: src/main/java/eu/rekawek/coffeegb/cpu/op/DataType.java
// public enum DataType {
//
// D8, D16, R8
//
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/AluFunctions.java
import eu.rekawek.coffeegb.cpu.op.DataType;
import java.util.HashMap;
import java.util.Map;
package eu.rekawek.coffeegb.cpu;
public class AluFunctions {
private Map<FunctionKey, IntRegistryFunction> functions = new HashMap<>();
private Map<FunctionKey, BiIntRegistryFunction> biFunctions = new HashMap<>();
| public IntRegistryFunction findAluFunction(String name, DataType argumentType) { |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/MiscTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class MiscTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/MiscTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class MiscTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/misc"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/MiscTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class MiscTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/misc");
}
public MiscTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/MiscTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class MiscTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/misc");
}
public MiscTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/InterruptsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InterruptsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/InterruptsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InterruptsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/interrupts"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/InterruptsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InterruptsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/interrupts");
}
public InterruptsTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/InterruptsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class InterruptsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/interrupts");
}
public InterruptsTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/SerialTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class SerialTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/SerialTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class SerialTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/serial"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/SerialTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class SerialTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/serial");
}
public SerialTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/SerialTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class SerialTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/serial");
}
public SerialTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/BitsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class BitsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/BitsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class BitsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance/bits"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/BitsTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class BitsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/bits");
}
public BitsTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/BitsTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class BitsTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance/bits");
}
public BitsTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/Dma.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/SpeedMode.java
// public class SpeedMode implements AddressSpace {
//
// private boolean currentSpeed;
//
// private boolean prepareSpeedSwitch;
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff4d;
// }
//
// @Override
// public void setByte(int address, int value) {
// prepareSpeedSwitch = (value & 0x01) != 0;
// }
//
// @Override
// public int getByte(int address) {
// return (currentSpeed ? (1 << 7) : 0) | (prepareSpeedSwitch ? (1 << 0) : 0) | 0b01111110;
// }
//
// boolean onStop() {
// if (prepareSpeedSwitch) {
// currentSpeed = !currentSpeed;
// prepareSpeedSwitch = false;
// return true;
// } else {
// return false;
// }
// }
//
// public int getSpeedMode() {
// return currentSpeed ? 2 : 1;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.SpeedMode; | package eu.rekawek.coffeegb.memory;
public class Dma implements AddressSpace {
private final AddressSpace addressSpace;
private final AddressSpace oam;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/SpeedMode.java
// public class SpeedMode implements AddressSpace {
//
// private boolean currentSpeed;
//
// private boolean prepareSpeedSwitch;
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff4d;
// }
//
// @Override
// public void setByte(int address, int value) {
// prepareSpeedSwitch = (value & 0x01) != 0;
// }
//
// @Override
// public int getByte(int address) {
// return (currentSpeed ? (1 << 7) : 0) | (prepareSpeedSwitch ? (1 << 0) : 0) | 0b01111110;
// }
//
// boolean onStop() {
// if (prepareSpeedSwitch) {
// currentSpeed = !currentSpeed;
// prepareSpeedSwitch = false;
// return true;
// } else {
// return false;
// }
// }
//
// public int getSpeedMode() {
// return currentSpeed ? 2 : 1;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/Dma.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.SpeedMode;
package eu.rekawek.coffeegb.memory;
public class Dma implements AddressSpace {
private final AddressSpace addressSpace;
private final AddressSpace oam;
| private final SpeedMode speedMode; |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CgbSoundTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CgbSoundTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CgbSoundTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CgbSoundTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("blargg/cgb_sound"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CgbSoundTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CgbSoundTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/cgb_sound");
}
public CgbSoundTest(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/blargg/individual/CgbSoundTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.blargg.individual;
@RunWith(Parameterized.class)
public class CgbSoundTest {
private final Path rom;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("blargg/cgb_sound");
}
public CgbSoundTest(String name, Path rom) {
this.rom = rom;
}
@Test
public void test() throws IOException { | RomTestUtils.testRomWithMemory(rom); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/cart/type/Rom.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.CartridgeType; | package eu.rekawek.coffeegb.memory.cart.type;
public class Rom implements AddressSpace {
private final int[] rom;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/type/Rom.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
package eu.rekawek.coffeegb.memory.cart.type;
public class Rom implements AddressSpace {
private final int[] rom;
| public Rom(int[] rom, CartridgeType type, int romBanks, int ramBanks) { |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/gpu/PixelFifoTest.java | // Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
| import eu.rekawek.coffeegb.memory.MemoryRegisters;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals; | package eu.rekawek.coffeegb.gpu;
public class PixelFifoTest {
private DmgPixelFifo fifo;
@Before
public void createFifo() { | // Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/gpu/PixelFifoTest.java
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import org.junit.Before;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import static java.util.Arrays.asList;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
package eu.rekawek.coffeegb.gpu;
public class PixelFifoTest {
private DmgPixelFifo fifo;
@Before
public void createFifo() { | MemoryRegisters r = new MemoryRegisters(GpuRegister.values()); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/sound/SoundMode3.java | // Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
| import eu.rekawek.coffeegb.memory.Ram; | package eu.rekawek.coffeegb.sound;
public class SoundMode3 extends AbstractSoundMode {
private static final int[] DMG_WAVE = new int[] {
0x84, 0x40, 0x43, 0xaa, 0x2d, 0x78, 0x92, 0x3c,
0x60, 0x59, 0x59, 0xb0, 0x34, 0xb8, 0x2e, 0xda
};
private static final int[] CGB_WAVE = new int[] {
0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff
};
| // Path: src/main/java/eu/rekawek/coffeegb/memory/Ram.java
// public class Ram implements AddressSpace {
//
// private int[] space;
//
// private int length;
//
// private int offset;
//
// public Ram(int offset, int length) {
// this.space = new int[length];
// this.length = length;
// this.offset = offset;
// }
//
// private Ram(int offset, int length, Ram ram) {
// this.offset = offset;
// this.length = length;
// this.space = ram.space;
// }
//
// public static Ram createShadow(int offset, int length, Ram ram) {
// return new Ram(offset, length, ram);
// }
//
// @Override
// public boolean accepts(int address) {
// return address >= offset && address < offset + length;
// }
//
// @Override
// public void setByte(int address, int value) {
// space[address - offset] = value;
// }
//
// @Override
// public int getByte(int address) {
// int index = address - offset;
// if (index < 0 || index >= space.length) {
// throw new IndexOutOfBoundsException("Address: " + address);
// }
// return space[index];
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/sound/SoundMode3.java
import eu.rekawek.coffeegb.memory.Ram;
package eu.rekawek.coffeegb.sound;
public class SoundMode3 extends AbstractSoundMode {
private static final int[] DMG_WAVE = new int[] {
0x84, 0x40, 0x43, 0xaa, 0x2d, 0x78, 0x92, 0x3c,
0x60, 0x59, 0x59, 0xb0, 0x34, 0xb8, 0x2e, 0xda
};
private static final int[] CGB_WAVE = new int[] {
0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff,
0x00, 0xff, 0x00, 0xff, 0x00, 0xff, 0x00, 0xff
};
| private final Ram waveRam = new Ram(0xff30, 0x10); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/GeneralTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class GeneralTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/GeneralTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class GeneralTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/acceptance"); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/GeneralTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class GeneralTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance");
}
public GeneralTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/GeneralTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class GeneralTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/acceptance");
}
public GeneralTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test(timeout = 5000)
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Flags.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit; | package eu.rekawek.coffeegb.cpu;
public class Flags {
private static int Z_POS = 7;
private static int N_POS = 6;
private static int H_POS = 5;
private static int C_POS = 4;
private int flags;
public int getFlagsByte() {
return flags;
}
public boolean isZ() { | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Flags.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit;
package eu.rekawek.coffeegb.cpu;
public class Flags {
private static int Z_POS = 7;
private static int N_POS = 6;
private static int H_POS = 5;
private static int C_POS = 4;
private int flags;
public int getFlagsByte() {
return flags;
}
public boolean isZ() { | return getBit(flags, Z_POS); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Flags.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit; | package eu.rekawek.coffeegb.cpu;
public class Flags {
private static int Z_POS = 7;
private static int N_POS = 6;
private static int H_POS = 5;
private static int C_POS = 4;
private int flags;
public int getFlagsByte() {
return flags;
}
public boolean isZ() {
return getBit(flags, Z_POS);
}
public boolean isN() {
return getBit(flags, N_POS);
}
public boolean isH() {
return getBit(flags, H_POS);
}
public boolean isC() {
return getBit(flags, C_POS);
}
public void setZ(boolean z) { | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Flags.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit;
package eu.rekawek.coffeegb.cpu;
public class Flags {
private static int Z_POS = 7;
private static int N_POS = 6;
private static int H_POS = 5;
private static int C_POS = 4;
private int flags;
public int getFlagsByte() {
return flags;
}
public boolean isZ() {
return getBit(flags, Z_POS);
}
public boolean isN() {
return getBit(flags, N_POS);
}
public boolean isH() {
return getBit(flags, H_POS);
}
public boolean isC() {
return getBit(flags, C_POS);
}
public void setZ(boolean z) { | flags = setBit(flags, Z_POS, z); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/Flags.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
| import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit; |
public boolean isN() {
return getBit(flags, N_POS);
}
public boolean isH() {
return getBit(flags, H_POS);
}
public boolean isC() {
return getBit(flags, C_POS);
}
public void setZ(boolean z) {
flags = setBit(flags, Z_POS, z);
}
public void setN(boolean n) {
flags = setBit(flags, N_POS, n);
}
public void setH(boolean h) {
flags = setBit(flags, H_POS, h);
}
public void setC(boolean c) {
flags = setBit(flags, C_POS, c);
}
public void setFlagsByte(int flags) { | // Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static void checkByteArgument(String argumentName, int argument) {
// checkArgument(argument >= 0 && argument <= 0xff, "Argument {} should be a byte", argumentName);
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static boolean getBit(int byteValue, int position) {
// return (byteValue & (1 << position)) != 0;
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int setBit(int byteValue, int position, boolean value) {
// return value ? setBit(byteValue, position) : clearBit(byteValue, position);
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/Flags.java
import static eu.rekawek.coffeegb.cpu.BitUtils.checkByteArgument;
import static eu.rekawek.coffeegb.cpu.BitUtils.getBit;
import static eu.rekawek.coffeegb.cpu.BitUtils.setBit;
public boolean isN() {
return getBit(flags, N_POS);
}
public boolean isH() {
return getBit(flags, H_POS);
}
public boolean isC() {
return getBit(flags, C_POS);
}
public void setZ(boolean z) {
flags = setBit(flags, Z_POS, z);
}
public void setN(boolean n) {
flags = setBit(flags, N_POS, n);
}
public void setH(boolean h) {
flags = setBit(flags, H_POS, h);
}
public void setC(boolean c) {
flags = setBit(flags, C_POS, c);
}
public void setFlagsByte(int flags) { | checkByteArgument("flags", flags); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/controller/Joypad.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/InterruptManager.java
// public class InterruptManager implements AddressSpace {
//
// public enum InterruptType {
// VBlank(0x0040), LCDC(0x0048), Timer(0x0050), Serial(0x0058), P10_13(0x0060);
//
// private final int handler;
//
// InterruptType(int handler) {
// this.handler = handler;
// }
//
// public int getHandler() {
// return handler;
// }
// }
//
// private final boolean gbc;
//
// private boolean ime;
//
// private int interruptFlag = 0xe1;
//
// private int interruptEnabled;
//
// private int pendingEnableInterrupts = -1;
//
// private int pendingDisableInterrupts = -1;
//
// public InterruptManager(boolean gbc) {
// this.gbc = gbc;
// }
//
// public void enableInterrupts(boolean withDelay) {
// pendingDisableInterrupts = -1;
// if (withDelay) {
// if (pendingEnableInterrupts == -1) {
// pendingEnableInterrupts = 1;
// }
// } else {
// pendingEnableInterrupts = -1;
// ime = true;
// }
// }
//
// public void disableInterrupts(boolean withDelay) {
// pendingEnableInterrupts = -1;
// if (withDelay && gbc) {
// if (pendingDisableInterrupts == -1) {
// pendingDisableInterrupts = 1;
// }
// } else {
// pendingDisableInterrupts = -1;
// ime = false;
// }
// }
//
// public void requestInterrupt(InterruptType type) {
// interruptFlag = interruptFlag | (1 << type.ordinal());
// }
//
// public void clearInterrupt(InterruptType type) {
// interruptFlag = interruptFlag & ~(1 << type.ordinal());
// }
//
// public void onInstructionFinished() {
// if (pendingEnableInterrupts != -1) {
// if (pendingEnableInterrupts-- == 0) {
// enableInterrupts(false);
// }
// }
// if (pendingDisableInterrupts != -1) {
// if (pendingDisableInterrupts-- == 0) {
// disableInterrupts(false);
// }
// }
// }
//
// public boolean isIme() {
// return ime;
// }
//
// public boolean isInterruptRequested() {
// return (interruptFlag & interruptEnabled) != 0;
// }
//
// public boolean isHaltBug() {
// return (interruptFlag & interruptEnabled & 0x1f) != 0 && !ime;
// }
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff0f || address == 0xffff;
// }
//
// @Override
// public void setByte(int address, int value) {
// switch (address) {
// case 0xff0f:
// interruptFlag = value | 0xe0;
// break;
//
// case 0xffff:
// interruptEnabled = value;
// break;
// }
// }
//
// @Override
// public int getByte(int address) {
// switch (address) {
// case 0xff0f:
// return interruptFlag;
//
// case 0xffff:
// return interruptEnabled;
//
// default:
// return 0xff;
// }
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.InterruptManager;
import java.util.HashSet;
import java.util.Set; | package eu.rekawek.coffeegb.controller;
public class Joypad implements AddressSpace {
private Set<ButtonListener.Button> buttons = new HashSet<>();
private int p1;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/InterruptManager.java
// public class InterruptManager implements AddressSpace {
//
// public enum InterruptType {
// VBlank(0x0040), LCDC(0x0048), Timer(0x0050), Serial(0x0058), P10_13(0x0060);
//
// private final int handler;
//
// InterruptType(int handler) {
// this.handler = handler;
// }
//
// public int getHandler() {
// return handler;
// }
// }
//
// private final boolean gbc;
//
// private boolean ime;
//
// private int interruptFlag = 0xe1;
//
// private int interruptEnabled;
//
// private int pendingEnableInterrupts = -1;
//
// private int pendingDisableInterrupts = -1;
//
// public InterruptManager(boolean gbc) {
// this.gbc = gbc;
// }
//
// public void enableInterrupts(boolean withDelay) {
// pendingDisableInterrupts = -1;
// if (withDelay) {
// if (pendingEnableInterrupts == -1) {
// pendingEnableInterrupts = 1;
// }
// } else {
// pendingEnableInterrupts = -1;
// ime = true;
// }
// }
//
// public void disableInterrupts(boolean withDelay) {
// pendingEnableInterrupts = -1;
// if (withDelay && gbc) {
// if (pendingDisableInterrupts == -1) {
// pendingDisableInterrupts = 1;
// }
// } else {
// pendingDisableInterrupts = -1;
// ime = false;
// }
// }
//
// public void requestInterrupt(InterruptType type) {
// interruptFlag = interruptFlag | (1 << type.ordinal());
// }
//
// public void clearInterrupt(InterruptType type) {
// interruptFlag = interruptFlag & ~(1 << type.ordinal());
// }
//
// public void onInstructionFinished() {
// if (pendingEnableInterrupts != -1) {
// if (pendingEnableInterrupts-- == 0) {
// enableInterrupts(false);
// }
// }
// if (pendingDisableInterrupts != -1) {
// if (pendingDisableInterrupts-- == 0) {
// disableInterrupts(false);
// }
// }
// }
//
// public boolean isIme() {
// return ime;
// }
//
// public boolean isInterruptRequested() {
// return (interruptFlag & interruptEnabled) != 0;
// }
//
// public boolean isHaltBug() {
// return (interruptFlag & interruptEnabled & 0x1f) != 0 && !ime;
// }
//
// @Override
// public boolean accepts(int address) {
// return address == 0xff0f || address == 0xffff;
// }
//
// @Override
// public void setByte(int address, int value) {
// switch (address) {
// case 0xff0f:
// interruptFlag = value | 0xe0;
// break;
//
// case 0xffff:
// interruptEnabled = value;
// break;
// }
// }
//
// @Override
// public int getByte(int address) {
// switch (address) {
// case 0xff0f:
// return interruptFlag;
//
// case 0xffff:
// return interruptEnabled;
//
// default:
// return 0xff;
// }
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/controller/Joypad.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.cpu.InterruptManager;
import java.util.HashSet;
import java.util.Set;
package eu.rekawek.coffeegb.controller;
public class Joypad implements AddressSpace {
private Set<ButtonListener.Button> buttons = new HashSet<>();
private int p1;
| public Joypad(InterruptManager interruptManager, Controller controller) { |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc2.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType; | package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc2 implements AddressSpace {
private final CartridgeType type;
private final int romBanks;
private final int[] cartridge;
private final int[] ram;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc2.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc2 implements AddressSpace {
private final CartridgeType type;
private final int romBanks;
private final int[] cartridge;
private final int[] ram;
| private final Battery battery; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java | // Path: src/main/java/eu/rekawek/coffeegb/cpu/op/Op.java
// public interface Op {
//
// default boolean readsMemory() {
// return false;
// }
//
// default boolean writesMemory() {
// return false;
// }
//
// default int operandLength() {
// return 0;
// }
//
// default int execute(Registers registers, AddressSpace addressSpace, int[] args, int context) {
// return context;
// }
//
// default void switchInterrupts(InterruptManager interruptManager) {
// }
//
// default boolean proceed(Registers registers) {
// return true;
// }
//
// default boolean forceFinishCycle() {
// return false;
// }
//
// default SpriteBug.CorruptionType causesOemBug(Registers registers, int context) {
// return null;
// }
//
// String toString();
// }
| import eu.rekawek.coffeegb.cpu.op.Op;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List; | package eu.rekawek.coffeegb.cpu.opcode;
public class Opcode {
private final int opcode;
private final String label;
| // Path: src/main/java/eu/rekawek/coffeegb/cpu/op/Op.java
// public interface Op {
//
// default boolean readsMemory() {
// return false;
// }
//
// default boolean writesMemory() {
// return false;
// }
//
// default int operandLength() {
// return 0;
// }
//
// default int execute(Registers registers, AddressSpace addressSpace, int[] args, int context) {
// return context;
// }
//
// default void switchInterrupts(InterruptManager interruptManager) {
// }
//
// default boolean proceed(Registers registers) {
// return true;
// }
//
// default boolean forceFinishCycle() {
// return false;
// }
//
// default SpriteBug.CorruptionType causesOemBug(Registers registers, int context) {
// return null;
// }
//
// String toString();
// }
// Path: src/main/java/eu/rekawek/coffeegb/cpu/opcode/Opcode.java
import eu.rekawek.coffeegb.cpu.op.Op;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
package eu.rekawek.coffeegb.cpu.opcode;
public class Opcode {
private final int opcode;
private final String label;
| private final List<Op> ops; |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/EmulatorOnlyTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class EmulatorOnlyTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/EmulatorOnlyTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class EmulatorOnlyTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException { | return ParametersProvider.getParameters("mooneye/emulator-only", Integer.MAX_VALUE); |
trekawek/coffee-gb | src/test/java/eu/rekawek/coffeegb/integration/mooneye/EmulatorOnlyTest.java | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
| import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection; | package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class EmulatorOnlyTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/emulator-only", Integer.MAX_VALUE);
}
public EmulatorOnlyTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | // Path: src/test/java/eu/rekawek/coffeegb/integration/support/ParametersProvider.java
// public final class ParametersProvider {
//
// static final List<String> EXCLUDES = Arrays.asList(
// "-mgb.gb",
// "-sgb.gb",
// "-sgb2.gb",
// "-S.gb",
// "-A.gb"
// );
//
// private ParametersProvider() {
// }
//
// public static Collection<Object[]> getParameters(String dirName) throws IOException {
// return getParameters(dirName, EXCLUDES, 1);
// }
//
// public static Collection<Object[]> getParameters(String dirName, int maxDepth) throws IOException {
// return getParameters(dirName, EXCLUDES, maxDepth);
// }
//
// public static Collection<Object[]> getParameters(String dirName, List<String> excludes, int maxDepth) throws IOException {
// Path dir = Paths.get("src/test/resources/roms", dirName);
// return Files.walk(dir, maxDepth)
// .filter(Files::isRegularFile)
// .filter(f -> f.toString().endsWith(".gb"))
// .filter(f -> !excludes.stream().anyMatch(p -> f.toString().endsWith(p)))
// .map(p -> new Object[] { dir.relativize(p).toString(), p })
// .collect(Collectors.toList());
// }
//
// }
//
// Path: src/test/java/eu/rekawek/coffeegb/integration/support/RomTestUtils.java
// public final class RomTestUtils {
//
// private RomTestUtils() {
// }
//
// public static void testRomWithMemory(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MemoryTestRunner runner = new MemoryTestRunner(romPath.toFile(), System.out);
// MemoryTestRunner.TestResult result = runner.runTest();
// assertEquals("Non-zero return value", 0, result.getStatus());
// }
//
// public static void testRomWithSerial(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// SerialTestRunner runner = new SerialTestRunner(romPath.toFile(), System.out);
// String result = runner.runTest();
// assertTrue(result.contains("Passed"));
// }
//
// public static void testMooneyeRom(Path romPath) throws IOException {
// System.out.println("\n### Running test rom " + romPath.getFileName() + " ###");
// MooneyeTestRunner runner = new MooneyeTestRunner(romPath.toFile(), System.out);
// assertTrue(runner.runTest());
// }
// }
// Path: src/test/java/eu/rekawek/coffeegb/integration/mooneye/EmulatorOnlyTest.java
import eu.rekawek.coffeegb.integration.support.ParametersProvider;
import eu.rekawek.coffeegb.integration.support.RomTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Collection;
package eu.rekawek.coffeegb.integration.mooneye;
@RunWith(Parameterized.class)
public class EmulatorOnlyTest {
private final Path romPath;
@Parameterized.Parameters(name = "{0}")
public static Collection<Object[]> data() throws IOException {
return ParametersProvider.getParameters("mooneye/emulator-only", Integer.MAX_VALUE);
}
public EmulatorOnlyTest(String name, Path romPath) {
this.romPath = romPath;
}
@Test
public void test() throws IOException { | RomTestUtils.testMooneyeRom(romPath); |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY; | package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY;
package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
| private final AddressSpace videoRam0; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY; | package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
private final AddressSpace videoRam0;
private final AddressSpace videoRam1;
private final AddressSpace oemRam;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY;
package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
private final AddressSpace videoRam0;
private final AddressSpace videoRam1;
private final AddressSpace oemRam;
| private final MemoryRegisters r; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY; | package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
private final AddressSpace videoRam0;
private final AddressSpace videoRam1;
private final AddressSpace oemRam;
private final MemoryRegisters r;
private final Lcdc lcdc;
private final boolean gbc;
private final int[] pixelLine = new int[8];
private State state;
private boolean fetchingDisabled;
private int mapAddress;
private int xOffset;
private int tileDataAddress;
private boolean tileIdSigned;
private int tileLine;
private int tileId;
private TileAttributes tileAttributes;
private int tileData1;
private int tileData2;
private int spriteTileLine;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY;
package eu.rekawek.coffeegb.gpu;
public class Fetcher {
private enum State {
READ_TILE_ID, READ_DATA_1, READ_DATA_2, PUSH,
READ_SPRITE_TILE_ID, READ_SPRITE_FLAGS, READ_SPRITE_DATA_1, READ_SPRITE_DATA_2, PUSH_SPRITE
}
private static final int[] EMPTY_PIXEL_LINE = new int[8];
private final PixelFifo fifo;
private final AddressSpace videoRam0;
private final AddressSpace videoRam1;
private final AddressSpace oemRam;
private final MemoryRegisters r;
private final Lcdc lcdc;
private final boolean gbc;
private final int[] pixelLine = new int[8];
private State state;
private boolean fetchingDisabled;
private int mapAddress;
private int xOffset;
private int tileDataAddress;
private boolean tileIdSigned;
private int tileLine;
private int tileId;
private TileAttributes tileAttributes;
private int tileData1;
private int tileData2;
private int spriteTileLine;
| private SpritePosition sprite; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY; | case READ_SPRITE_DATA_1:
if (lcdc.getSpriteHeight() == 16) {
tileId &= 0xfe;
}
tileData1 = getTileData(tileId, spriteTileLine, 0, 0x8000, false, spriteAttributes, lcdc.getSpriteHeight());
state = State.READ_SPRITE_DATA_2;
break;
case READ_SPRITE_DATA_2:
tileData2 = getTileData(tileId, spriteTileLine, 1, 0x8000, false, spriteAttributes, lcdc.getSpriteHeight());
state = State.PUSH_SPRITE;
break;
case PUSH_SPRITE:
fifo.setOverlay(zip(tileData1, tileData2, spriteAttributes.isXflip()), spriteOffset, spriteAttributes, spriteOamIndex);
state = State.READ_TILE_ID;
break;
}
}
private int getTileData(int tileId, int line, int byteNumber, int tileDataAddress, boolean signed, TileAttributes attr, int tileHeight) {
int effectiveLine;
if (attr.isYflip()) {
effectiveLine = tileHeight - 1 - line;
} else {
effectiveLine = line;
}
int tileAddress;
if (signed) { | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/gpu/phase/OamSearch.java
// public static class SpritePosition {
//
// private final int x;
//
// private final int y;
//
// private final int address;
//
// public SpritePosition(int x, int y, int address) {
// this.x = x;
// this.y = y;
// this.address = address;
// }
//
// public int getX() {
// return x;
// }
//
// public int getY() {
// return y;
// }
//
// public int getAddress() {
// return address;
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/MemoryRegisters.java
// public class MemoryRegisters implements AddressSpace {
//
// public interface Register {
// int getAddress();
//
// RegisterType getType();
// }
//
// public enum RegisterType {
// R(true, false), W(false, true), RW(true, true);
//
// private final boolean allowsRead;
//
// private final boolean allowsWrite;
//
// RegisterType(boolean allowsRead, boolean allowsWrite) {
// this.allowsRead = allowsRead;
// this.allowsWrite = allowsWrite;
// }
// }
//
// private Map<Integer, Register> registers;
//
// private Map<Integer, Integer> values = new HashMap<>();
//
// public MemoryRegisters(Register... registers) {
// Map<Integer, Register> map = new HashMap<>();
// for (Register r : registers) {
// if (map.containsKey(r.getAddress())) {
// throw new IllegalArgumentException("Two registers with the same address: " + r.getAddress());
// }
// map.put(r.getAddress(), r);
// values.put(r.getAddress(), 0);
// }
// this.registers = Collections.unmodifiableMap(map);
// }
//
// private MemoryRegisters(MemoryRegisters original) {
// this.registers = original.registers;
// this.values = Collections.unmodifiableMap(new HashMap<>(original.values));
// }
//
// public int get(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// return values.get(reg.getAddress());
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public void put(Register reg, int value) {
// if (registers.containsKey(reg.getAddress())) {
// values.put(reg.getAddress(), value);
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// public MemoryRegisters freeze() {
// return new MemoryRegisters(this);
// }
//
// public int preIncrement(Register reg) {
// if (registers.containsKey(reg.getAddress())) {
// int value = values.get(reg.getAddress()) + 1;
// values.put(reg.getAddress(), value);
// return value;
// } else {
// throw new IllegalArgumentException("Not valid register: " + reg);
// }
// }
//
// @Override
// public boolean accepts(int address) {
// return registers.containsKey(address);
// }
//
// @Override
// public void setByte(int address, int value) {
// if (registers.get(address).getType().allowsWrite) {
// values.put(address, value);
// }
// }
//
// @Override
// public int getByte(int address) {
// if (registers.get(address).getType().allowsRead) {
// return values.get(address);
// } else {
// return 0xff;
// }
// }
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/cpu/BitUtils.java
// public static int toSigned(int byteValue) {
// if ((byteValue & (1 << 7)) == 0) {
// return byteValue;
// } else {
// return byteValue - 0x100;
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/gpu/Fetcher.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.gpu.phase.OamSearch.SpritePosition;
import eu.rekawek.coffeegb.memory.MemoryRegisters;
import java.util.EnumSet;
import static eu.rekawek.coffeegb.cpu.BitUtils.toSigned;
import static eu.rekawek.coffeegb.gpu.GpuRegister.LY;
case READ_SPRITE_DATA_1:
if (lcdc.getSpriteHeight() == 16) {
tileId &= 0xfe;
}
tileData1 = getTileData(tileId, spriteTileLine, 0, 0x8000, false, spriteAttributes, lcdc.getSpriteHeight());
state = State.READ_SPRITE_DATA_2;
break;
case READ_SPRITE_DATA_2:
tileData2 = getTileData(tileId, spriteTileLine, 1, 0x8000, false, spriteAttributes, lcdc.getSpriteHeight());
state = State.PUSH_SPRITE;
break;
case PUSH_SPRITE:
fifo.setOverlay(zip(tileData1, tileData2, spriteAttributes.isXflip()), spriteOffset, spriteAttributes, spriteOamIndex);
state = State.READ_TILE_ID;
break;
}
}
private int getTileData(int tileId, int line, int byteNumber, int tileDataAddress, boolean signed, TileAttributes attr, int tileHeight) {
int effectiveLine;
if (attr.isYflip()) {
effectiveLine = tileHeight - 1 - line;
} else {
effectiveLine = line;
}
int tileAddress;
if (signed) { | tileAddress = tileDataAddress + toSigned(tileId) * 0x10; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc1.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc1 implements AddressSpace {
private static final Logger LOG = LoggerFactory.getLogger(Mbc1.class);
private static int[] NINTENDO_LOGO = {
0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D,
0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99,
0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
};
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc1.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc1 implements AddressSpace {
private static final Logger LOG = LoggerFactory.getLogger(Mbc1.class);
private static int[] NINTENDO_LOGO = {
0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D,
0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99,
0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
};
| private final CartridgeType type; |
trekawek/coffee-gb | src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc1.java | // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
| import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; | package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc1 implements AddressSpace {
private static final Logger LOG = LoggerFactory.getLogger(Mbc1.class);
private static int[] NINTENDO_LOGO = {
0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D,
0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99,
0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
};
private final CartridgeType type;
private final int romBanks;
private final int ramBanks;
private final int[] cartridge;
private final int[] ram;
| // Path: src/main/java/eu/rekawek/coffeegb/AddressSpace.java
// public interface AddressSpace {
//
// boolean accepts(int address);
//
// void setByte(int address, int value);
//
// int getByte(int address);
//
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/battery/Battery.java
// public interface Battery {
//
// void loadRam(int[] ram);
//
// void saveRam(int[] ram);
//
// void loadRamWithClock(int[] ram, long[] clockData);
//
// void saveRamWithClock(int[] ram, long[] clockData);
//
// Battery NULL_BATTERY = new Battery() {
// @Override
// public void loadRam(int[] ram) {
// }
//
// @Override
// public void saveRam(int[] ram) {
// }
//
// @Override
// public void loadRamWithClock(int[] ram, long[] clockData) {
// }
//
// @Override
// public void saveRamWithClock(int[] ram, long[] clockData) {
// }
// };
// }
//
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/CartridgeType.java
// public enum CartridgeType {
//
// ROM(0x00),
// ROM_MBC1(0x01),
// ROM_MBC1_RAM(0x02),
// ROM_MBC1_RAM_BATTERY(0x03),
// ROM_MBC2(0x05),
// ROM_MBC2_BATTERY(0x06),
// ROM_RAM(0x08),
// ROM_RAM_BATTERY(0x09),
// ROM_MMM01(0x0b),
// ROM_MMM01_SRAM(0x0c),
// ROM_MMM01_SRAM_BATTERY(0x0d),
// ROM_MBC3_TIMER_BATTERY(0x0f),
// ROM_MBC3_TIMER_RAM_BATTERY(0x10),
// ROM_MBC3(0x11),
// ROM_MBC3_RAM(0x12),
// ROM_MBC3_RAM_BATTERY(0x13),
// ROM_MBC5(0x19),
// ROM_MBC5_RAM(0x1a),
// ROM_MBC5_RAM_BATTERY(0x01b),
// ROM_MBC5_RUMBLE(0x1c),
// ROM_MBC5_RUMBLE_SRAM(0x1d),
// ROM_MBC5_RUMBLE_SRAM_BATTERY(0x1e);
//
// private final int id;
//
// CartridgeType(int id) {
// this.id = id;
// }
//
// public boolean isMbc1() {
// return nameContainsSegment("MBC1");
// }
//
// public boolean isMbc2() {
// return nameContainsSegment("MBC2");
// }
//
// public boolean isMbc3() {
// return nameContainsSegment("MBC3");
// }
//
// public boolean isMbc5() {
// return nameContainsSegment("MBC5");
// }
//
// public boolean isMmm01() {
// return nameContainsSegment("MMM01");
// }
//
// public boolean isRam() {
// return nameContainsSegment("RAM");
// }
//
// public boolean isSram() {
// return nameContainsSegment("SRAM");
// }
//
// public boolean isTimer() {
// return nameContainsSegment("TIMER");
// }
//
// public boolean isBattery() {
// return nameContainsSegment("BATTERY");
// }
//
// public boolean isRumble() {
// return nameContainsSegment("RUMBLE");
// }
//
// private boolean nameContainsSegment(String segment) {
// Pattern p = Pattern.compile("(^|_)" + Pattern.quote(segment) + "($|_)");
// return p.matcher(name()).find();
// }
//
// public static CartridgeType getById(int id) {
// for (CartridgeType t : values()) {
// if (t.id == id) {
// return t;
// }
// }
// throw new IllegalArgumentException("Unsupported cartridge type: " + Integer.toHexString(id));
// }
// }
// Path: src/main/java/eu/rekawek/coffeegb/memory/cart/type/Mbc1.java
import eu.rekawek.coffeegb.AddressSpace;
import eu.rekawek.coffeegb.memory.cart.battery.Battery;
import eu.rekawek.coffeegb.memory.cart.CartridgeType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package eu.rekawek.coffeegb.memory.cart.type;
public class Mbc1 implements AddressSpace {
private static final Logger LOG = LoggerFactory.getLogger(Mbc1.class);
private static int[] NINTENDO_LOGO = {
0xCE, 0xED, 0x66, 0x66, 0xCC, 0x0D, 0x00, 0x0B, 0x03, 0x73, 0x00, 0x83, 0x00, 0x0C, 0x00, 0x0D,
0x00, 0x08, 0x11, 0x1F, 0x88, 0x89, 0x00, 0x0E, 0xDC, 0xCC, 0x6E, 0xE6, 0xDD, 0xDD, 0xD9, 0x99,
0xBB, 0xBB, 0x67, 0x63, 0x6E, 0x0E, 0xEC, 0xCC, 0xDD, 0xDC, 0x99, 0x9F, 0xBB, 0xB9, 0x33, 0x3E
};
private final CartridgeType type;
private final int romBanks;
private final int ramBanks;
private final int[] cartridge;
private final int[] ram;
| private final Battery battery; |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/LireValueSource.java | // Path: src/main/java/net/semanticmetadata/lire/solr/tools/RandomAccessBinaryDocValues.java
// public class RandomAccessBinaryDocValues extends BinaryDocValues {
//
// private final Supplier<BinaryDocValues> supplier;
// private BinaryDocValues docValues;
//
// public RandomAccessBinaryDocValues(Supplier<BinaryDocValues> supplier) {
// super();
// this.supplier = supplier;
// this.docValues = supplier.get();
// }
//
// @Override
// public BytesRef binaryValue() throws IOException {
// if (docValues == null) {
// return new BytesRef(BytesRef.EMPTY_BYTES);
// }
// return docValues.binaryValue();
// }
//
// @Override
// public boolean advanceExact(int target) throws IOException {
// resetIfNeeded(target);
// if (docValues == null) {
// return false;
// }
// return docValues.advanceExact(target);
// }
//
// @Override
// public int docID() {
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.docID();
// }
//
// @Override
// public int nextDoc() throws IOException {
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.nextDoc();
// }
//
// @Override
// public int advance(int target) throws IOException {
// resetIfNeeded(target);
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.advance(target);
// }
//
// @Override
// public long cost() {
// if (docValues == null) {
// return 0;
// }
// return docValues.cost();
// }
//
// private void resetIfNeeded(int target) {
// if (docValues == null) {
// docValues = supplier.get();
// } else {
// int id = docValues.docID();
// if (id != -1 && id != NO_MORE_DOCS
// && target < docValues.docID()) {
// docValues = supplier.get();
// }
// }
// }
// }
| import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.ColorLayout;
import net.semanticmetadata.lire.solr.tools.RandomAccessBinaryDocValues; | return Double.toString(maxDistance);
}
@Override
public Object objectVal(int doc) {
return maxDistance;
}
@Override
public String toString(int doc) {
return description() + '=' + strVal(doc);
}
public double doubleVal(int doc) {
return maxDistance;
}
};
}
} */
@Override
/**
* Check also {@link org.apache.lucene.queries.function.valuesource.BytesRefFieldSource}
*/
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
final FieldInfo fieldInfo = readerContext.reader().getFieldInfos().fieldInfo(field);
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.BINARY) {
// final BinaryDocValues binaryValues = DocValues.getBinary(readerContext.reader(), field);
// final Bits docsWithField = DocValues.getDocsWithField(readerContext.reader(), field); | // Path: src/main/java/net/semanticmetadata/lire/solr/tools/RandomAccessBinaryDocValues.java
// public class RandomAccessBinaryDocValues extends BinaryDocValues {
//
// private final Supplier<BinaryDocValues> supplier;
// private BinaryDocValues docValues;
//
// public RandomAccessBinaryDocValues(Supplier<BinaryDocValues> supplier) {
// super();
// this.supplier = supplier;
// this.docValues = supplier.get();
// }
//
// @Override
// public BytesRef binaryValue() throws IOException {
// if (docValues == null) {
// return new BytesRef(BytesRef.EMPTY_BYTES);
// }
// return docValues.binaryValue();
// }
//
// @Override
// public boolean advanceExact(int target) throws IOException {
// resetIfNeeded(target);
// if (docValues == null) {
// return false;
// }
// return docValues.advanceExact(target);
// }
//
// @Override
// public int docID() {
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.docID();
// }
//
// @Override
// public int nextDoc() throws IOException {
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.nextDoc();
// }
//
// @Override
// public int advance(int target) throws IOException {
// resetIfNeeded(target);
// if (docValues == null) {
// return NO_MORE_DOCS;
// }
// return docValues.advance(target);
// }
//
// @Override
// public long cost() {
// if (docValues == null) {
// return 0;
// }
// return docValues.cost();
// }
//
// private void resetIfNeeded(int target) {
// if (docValues == null) {
// docValues = supplier.get();
// } else {
// int id = docValues.docID();
// if (id != -1 && id != NO_MORE_DOCS
// && target < docValues.docID()) {
// docValues = supplier.get();
// }
// }
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/LireValueSource.java
import java.io.IOException;
import java.util.Arrays;
import java.util.Map;
import org.apache.lucene.index.BinaryDocValues;
import org.apache.lucene.index.DocValues;
import org.apache.lucene.index.DocValuesType;
import org.apache.lucene.index.FieldInfo;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.queries.function.FunctionValues;
import org.apache.lucene.queries.function.ValueSource;
import org.apache.lucene.queries.function.docvalues.DocTermsIndexDocValues;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.BytesRefBuilder;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.ColorLayout;
import net.semanticmetadata.lire.solr.tools.RandomAccessBinaryDocValues;
return Double.toString(maxDistance);
}
@Override
public Object objectVal(int doc) {
return maxDistance;
}
@Override
public String toString(int doc) {
return description() + '=' + strVal(doc);
}
public double doubleVal(int doc) {
return maxDistance;
}
};
}
} */
@Override
/**
* Check also {@link org.apache.lucene.queries.function.valuesource.BytesRefFieldSource}
*/
public FunctionValues getValues(Map context, LeafReaderContext readerContext) throws IOException {
final FieldInfo fieldInfo = readerContext.reader().getFieldInfos().fieldInfo(field);
if (fieldInfo != null && fieldInfo.getDocValuesType() == DocValuesType.BINARY) {
// final BinaryDocValues binaryValues = DocValues.getBinary(readerContext.reader(), field);
// final Bits docsWithField = DocValues.getDocsWithField(readerContext.reader(), field); | final BinaryDocValues binaryValues = new RandomAccessBinaryDocValues(() -> { |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/tools/DataConversion.java | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
| import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalByteFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalDoubleFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalShortFeature;
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.utils.CommandLineUtils;
import java.io.IOException;
import java.util.Base64;
import java.util.Properties; | package net.semanticmetadata.lire.solr.tools;
/**
* Simple class to call from Python to create a Base64 encoded feature representation
* compatible with LireSolr from a list of floats / ints
*/
public class DataConversion {
static String helpMessage = "$> DataConversion [-t <double|float|int|short>] -d <data>\n\n" +
"Options\n" +
"=======\n" +
"-t \t type to be expected, using double as a default.\n" +
"-d \t actual data in the for of \"0.55;0.33;...\"";
public static void main(String[] args) throws IOException {
// TODO: integrate Bitsampling ... | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/tools/DataConversion.java
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalByteFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalDoubleFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalShortFeature;
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.utils.CommandLineUtils;
import java.io.IOException;
import java.util.Base64;
import java.util.Properties;
package net.semanticmetadata.lire.solr.tools;
/**
* Simple class to call from Python to create a Base64 encoded feature representation
* compatible with LireSolr from a list of floats / ints
*/
public class DataConversion {
static String helpMessage = "$> DataConversion [-t <double|float|int|short>] -d <data>\n\n" +
"Options\n" +
"=======\n" +
"-t \t type to be expected, using double as a default.\n" +
"-d \t actual data in the for of \"0.55;0.33;...\"";
public static void main(String[] args) throws IOException {
// TODO: integrate Bitsampling ... | HashingMetricSpacesManager.init(); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashCSV.java | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
| import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import org.apache.commons.cli.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.io.*;
import java.util.*; | package net.semanticmetadata.lire.solr.tools;
/**
* Command line utility that takes a csv file with the file name in the first col and converts
* it to an XML file Solr can handle. We assume that the rest of the columns is a feature vector, i.e. from a CNN.
*/
public class EncodeAndHashCSV implements Runnable {
public static final int TOP_N_CLASSES = 32;
public static final int TOP_N_CLASSES_FOR_QUERY = 5;
public static final double TOP_CLASSES_FACTOR = 10d;
public static final double THRESHOLD_RELATIVE_SIGNIFICANCE_TO_MAXIMUM = 0.8;
File infile, outfile;
public EncodeAndHashCSV(File infile, File outfile) {
this.infile = infile;
this.outfile = outfile;
}
public static void main(String[] args) throws ParseException { | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashCSV.java
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import org.apache.commons.cli.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.io.*;
import java.util.*;
package net.semanticmetadata.lire.solr.tools;
/**
* Command line utility that takes a csv file with the file name in the first col and converts
* it to an XML file Solr can handle. We assume that the rest of the columns is a feature vector, i.e. from a CNN.
*/
public class EncodeAndHashCSV implements Runnable {
public static final int TOP_N_CLASSES = 32;
public static final int TOP_N_CLASSES_FOR_QUERY = 5;
public static final double TOP_CLASSES_FACTOR = 10d;
public static final double THRESHOLD_RELATIVE_SIGNIFICANCE_TO_MAXIMUM = 0.8;
File infile, outfile;
public EncodeAndHashCSV(File infile, File outfile) {
this.infile = infile;
this.outfile = outfile;
}
public static void main(String[] args) throws ParseException { | HashingMetricSpacesManager.init(); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashCSV.java | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
| import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import org.apache.commons.cli.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.io.*;
import java.util.*; | Iterator<String> iterator = hm.keySet().iterator();
do {
String cl = iterator.next();
currentWeight = hm.get(cl);
if (currentWeight > minimumWeight) {
field_classes_significant_text.append(cl);
field_classes_significant_text.append(' ');
i++;
}
} while (iterator.hasNext() && currentWeight > minimumWeight); // do this while there are still elements and the weight is above the threshold.
Element field_classes_ws = doc.addElement("field");
field_classes_ws.addAttribute("name", "classes_ws");
field_classes_ws.addText(field_classes_ws_text.toString().trim());
Element field_query_s = doc.addElement("field");
field_query_s.addAttribute("name", "query_s");
field_query_s.addText(field_query_s_text.toString().trim());
Element field_query_b = doc.addElement("field");
field_query_b.addAttribute("name", "query_boosted_s");
field_query_b.addText(field_query_boosted_text.toString().trim());
Element field_classes_significant_ws = doc.addElement("field");
field_classes_significant_ws.addAttribute("name", "classes_significant_ws");
field_classes_significant_ws.addText(field_classes_significant_text.toString().trim());
}
private void addFeatureVector(double[] feature, String[] classes, Element doc) {
Element field_file;
int[] hashes; | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashCSV.java
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import org.apache.commons.cli.*;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.io.*;
import java.util.*;
Iterator<String> iterator = hm.keySet().iterator();
do {
String cl = iterator.next();
currentWeight = hm.get(cl);
if (currentWeight > minimumWeight) {
field_classes_significant_text.append(cl);
field_classes_significant_text.append(' ');
i++;
}
} while (iterator.hasNext() && currentWeight > minimumWeight); // do this while there are still elements and the weight is above the threshold.
Element field_classes_ws = doc.addElement("field");
field_classes_ws.addAttribute("name", "classes_ws");
field_classes_ws.addText(field_classes_ws_text.toString().trim());
Element field_query_s = doc.addElement("field");
field_query_s.addAttribute("name", "query_s");
field_query_s.addText(field_query_s_text.toString().trim());
Element field_query_b = doc.addElement("field");
field_query_b.addAttribute("name", "query_boosted_s");
field_query_b.addText(field_query_boosted_text.toString().trim());
Element field_classes_significant_ws = doc.addElement("field");
field_classes_significant_ws.addAttribute("name", "classes_significant_ws");
field_classes_significant_ws.addText(field_classes_significant_text.toString().trim());
}
private void addFeatureVector(double[] feature, String[] classes, Element doc) {
Element field_file;
int[] hashes; | ShortFeatureCosineDistance f1 = new ShortFeatureCosineDistance(); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/FeatureRegistry.java | // Path: src/main/java/net/semanticmetadata/lire/solr/features/DoubleFeatureCosineDistance.java
// public class DoubleFeatureCosineDistance extends GenericGlobalDoubleFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Double> d = new LinkedList<>();
// double[] data = getFeatureVector();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// double datum = data[i];
// if (datum != 0) {
// d.add((double) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((double) data.length);
// numDimensions = 0; // re-using a variable.
// double[] s = new double[d.size()];
// for (Iterator<Double> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// double[] s = SerializationUtils.toDoubleArray(featureData, offset, length);
// double[] data = new double[(int) s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[(int) s[i]] = s[i+1];
// }
// setData(data);
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
| import net.semanticmetadata.lire.imageanalysis.features.GenericDoubleLireFeature;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.*;
import net.semanticmetadata.lire.imageanalysis.features.global.joint.JointHistogram;
import net.semanticmetadata.lire.imageanalysis.features.global.spatialpyramid.SPCEDD;
import net.semanticmetadata.lire.solr.features.DoubleFeatureCosineDistance;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import java.util.HashMap;
import java.util.Iterator; | package net.semanticmetadata.lire.solr;
/**
* This file is part of LIRE Solr, a Java library for content based image retrieval.
*
* @author Mathias Lux, mathias@juggle.at, 28.11.2014
*/
public class FeatureRegistry {
/**
* Naming conventions for code: 2 letters for global features. More for local ones.
*/
private static HashMap<String, Class<? extends GlobalFeature>> codeToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
/**
* Caching the entries for fast retrieval or Strings without generating new objects.
*/
private static HashMap<String, Class<? extends GlobalFeature>> hashFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, Class<? extends GlobalFeature>> featureFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, String> hashFieldToFeatureField = new HashMap<String, String>(16);
private static HashMap<Class<? extends GlobalFeature>, String> classToCode = new HashMap<Class<? extends GlobalFeature>, String>(16);
// Constants.
public static final String featureFieldPostfix = "_hi"; // contains the histogram
public static final String hashFieldPostfix = "_ha"; // contains the hash
public static final String metricSpacesFieldPostfix = "_ms"; // contains the hash
static {
// initial adding of the supported features:
// classical features from the first implementation
codeToClass.put("cl", ColorLayout.class);
codeToClass.put("eh", EdgeHistogram.class);
codeToClass.put("jc", JCD.class);
codeToClass.put("oh", OpponentHistogram.class);
codeToClass.put("ph", PHOG.class);
// additional global features
codeToClass.put("ac", AutoColorCorrelogram.class);
codeToClass.put("ad", ACCID.class);
codeToClass.put("ce", CEDD.class);
codeToClass.put("fc", FCTH.class);
codeToClass.put("fo", FuzzyOpponentHistogram.class);
codeToClass.put("jh", JointHistogram.class);
codeToClass.put("sc", ScalableColor.class);
codeToClass.put("pc", SPCEDD.class);
// GenericFeatures filled with whatever one prefers. | // Path: src/main/java/net/semanticmetadata/lire/solr/features/DoubleFeatureCosineDistance.java
// public class DoubleFeatureCosineDistance extends GenericGlobalDoubleFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Double> d = new LinkedList<>();
// double[] data = getFeatureVector();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// double datum = data[i];
// if (datum != 0) {
// d.add((double) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((double) data.length);
// numDimensions = 0; // re-using a variable.
// double[] s = new double[d.size()];
// for (Iterator<Double> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// double[] s = SerializationUtils.toDoubleArray(featureData, offset, length);
// double[] data = new double[(int) s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[(int) s[i]] = s[i+1];
// }
// setData(data);
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/FeatureRegistry.java
import net.semanticmetadata.lire.imageanalysis.features.GenericDoubleLireFeature;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.*;
import net.semanticmetadata.lire.imageanalysis.features.global.joint.JointHistogram;
import net.semanticmetadata.lire.imageanalysis.features.global.spatialpyramid.SPCEDD;
import net.semanticmetadata.lire.solr.features.DoubleFeatureCosineDistance;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import java.util.HashMap;
import java.util.Iterator;
package net.semanticmetadata.lire.solr;
/**
* This file is part of LIRE Solr, a Java library for content based image retrieval.
*
* @author Mathias Lux, mathias@juggle.at, 28.11.2014
*/
public class FeatureRegistry {
/**
* Naming conventions for code: 2 letters for global features. More for local ones.
*/
private static HashMap<String, Class<? extends GlobalFeature>> codeToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
/**
* Caching the entries for fast retrieval or Strings without generating new objects.
*/
private static HashMap<String, Class<? extends GlobalFeature>> hashFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, Class<? extends GlobalFeature>> featureFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, String> hashFieldToFeatureField = new HashMap<String, String>(16);
private static HashMap<Class<? extends GlobalFeature>, String> classToCode = new HashMap<Class<? extends GlobalFeature>, String>(16);
// Constants.
public static final String featureFieldPostfix = "_hi"; // contains the histogram
public static final String hashFieldPostfix = "_ha"; // contains the hash
public static final String metricSpacesFieldPostfix = "_ms"; // contains the hash
static {
// initial adding of the supported features:
// classical features from the first implementation
codeToClass.put("cl", ColorLayout.class);
codeToClass.put("eh", EdgeHistogram.class);
codeToClass.put("jc", JCD.class);
codeToClass.put("oh", OpponentHistogram.class);
codeToClass.put("ph", PHOG.class);
// additional global features
codeToClass.put("ac", AutoColorCorrelogram.class);
codeToClass.put("ad", ACCID.class);
codeToClass.put("ce", CEDD.class);
codeToClass.put("fc", FCTH.class);
codeToClass.put("fo", FuzzyOpponentHistogram.class);
codeToClass.put("jh", JointHistogram.class);
codeToClass.put("sc", ScalableColor.class);
codeToClass.put("pc", SPCEDD.class);
// GenericFeatures filled with whatever one prefers. | codeToClass.put("df", DoubleFeatureCosineDistance.class); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/FeatureRegistry.java | // Path: src/main/java/net/semanticmetadata/lire/solr/features/DoubleFeatureCosineDistance.java
// public class DoubleFeatureCosineDistance extends GenericGlobalDoubleFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Double> d = new LinkedList<>();
// double[] data = getFeatureVector();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// double datum = data[i];
// if (datum != 0) {
// d.add((double) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((double) data.length);
// numDimensions = 0; // re-using a variable.
// double[] s = new double[d.size()];
// for (Iterator<Double> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// double[] s = SerializationUtils.toDoubleArray(featureData, offset, length);
// double[] data = new double[(int) s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[(int) s[i]] = s[i+1];
// }
// setData(data);
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
| import net.semanticmetadata.lire.imageanalysis.features.GenericDoubleLireFeature;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.*;
import net.semanticmetadata.lire.imageanalysis.features.global.joint.JointHistogram;
import net.semanticmetadata.lire.imageanalysis.features.global.spatialpyramid.SPCEDD;
import net.semanticmetadata.lire.solr.features.DoubleFeatureCosineDistance;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import java.util.HashMap;
import java.util.Iterator; | package net.semanticmetadata.lire.solr;
/**
* This file is part of LIRE Solr, a Java library for content based image retrieval.
*
* @author Mathias Lux, mathias@juggle.at, 28.11.2014
*/
public class FeatureRegistry {
/**
* Naming conventions for code: 2 letters for global features. More for local ones.
*/
private static HashMap<String, Class<? extends GlobalFeature>> codeToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
/**
* Caching the entries for fast retrieval or Strings without generating new objects.
*/
private static HashMap<String, Class<? extends GlobalFeature>> hashFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, Class<? extends GlobalFeature>> featureFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, String> hashFieldToFeatureField = new HashMap<String, String>(16);
private static HashMap<Class<? extends GlobalFeature>, String> classToCode = new HashMap<Class<? extends GlobalFeature>, String>(16);
// Constants.
public static final String featureFieldPostfix = "_hi"; // contains the histogram
public static final String hashFieldPostfix = "_ha"; // contains the hash
public static final String metricSpacesFieldPostfix = "_ms"; // contains the hash
static {
// initial adding of the supported features:
// classical features from the first implementation
codeToClass.put("cl", ColorLayout.class);
codeToClass.put("eh", EdgeHistogram.class);
codeToClass.put("jc", JCD.class);
codeToClass.put("oh", OpponentHistogram.class);
codeToClass.put("ph", PHOG.class);
// additional global features
codeToClass.put("ac", AutoColorCorrelogram.class);
codeToClass.put("ad", ACCID.class);
codeToClass.put("ce", CEDD.class);
codeToClass.put("fc", FCTH.class);
codeToClass.put("fo", FuzzyOpponentHistogram.class);
codeToClass.put("jh", JointHistogram.class);
codeToClass.put("sc", ScalableColor.class);
codeToClass.put("pc", SPCEDD.class);
// GenericFeatures filled with whatever one prefers.
codeToClass.put("df", DoubleFeatureCosineDistance.class);
// codeToClass.put("df", GenericGlobalDoubleFeature.class);
codeToClass.put("if", GenericGlobalIntFeature.class); | // Path: src/main/java/net/semanticmetadata/lire/solr/features/DoubleFeatureCosineDistance.java
// public class DoubleFeatureCosineDistance extends GenericGlobalDoubleFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Double> d = new LinkedList<>();
// double[] data = getFeatureVector();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// double datum = data[i];
// if (datum != 0) {
// d.add((double) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((double) data.length);
// numDimensions = 0; // re-using a variable.
// double[] s = new double[d.size()];
// for (Iterator<Double> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// double[] s = SerializationUtils.toDoubleArray(featureData, offset, length);
// double[] data = new double[(int) s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[(int) s[i]] = s[i+1];
// }
// setData(data);
// }
// }
//
// Path: src/main/java/net/semanticmetadata/lire/solr/features/ShortFeatureCosineDistance.java
// public class ShortFeatureCosineDistance extends GenericGlobalShortFeature {
// @Override
// public double getDistance(LireFeature feature) {
// return MetricsUtils.cosineDistance(getFeatureVector(), feature.getFeatureVector());
// }
//
// @Override
// public byte[] getByteArrayRepresentation() {
// int numDimensions = 0;
// LinkedList<Short> d = new LinkedList<>();
// for (int i = 0, dataLength = data.length; i < dataLength; i++) {
// short datum = data[i];
// if (datum != 0) {
// d.add((short) i);
// d.add(datum);
// numDimensions++;
// }
// }
// d.addFirst((short) data.length);
// numDimensions = 0; // re-using a variable.
// short[] s = new short[d.size()];
// for (Iterator<Short> iterator = d.iterator(); iterator.hasNext(); ) {
// s[numDimensions++] = iterator.next();
// }
// return SerializationUtils.toByteArray(s);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData) {
// setByteArrayRepresentation(featureData, 0, featureData.length);
// }
//
// @Override
// public void setByteArrayRepresentation(byte[] featureData, int offset, int length) {
// short[] s = SerializationUtils.toShortArray(featureData, offset, length);
// data = new short[s[0]];
// for (int i = 1; i < s.length; i+=2) {
// data[s[i]] = s[i+1];
// }
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/FeatureRegistry.java
import net.semanticmetadata.lire.imageanalysis.features.GenericDoubleLireFeature;
import net.semanticmetadata.lire.imageanalysis.features.GlobalFeature;
import net.semanticmetadata.lire.imageanalysis.features.global.*;
import net.semanticmetadata.lire.imageanalysis.features.global.joint.JointHistogram;
import net.semanticmetadata.lire.imageanalysis.features.global.spatialpyramid.SPCEDD;
import net.semanticmetadata.lire.solr.features.DoubleFeatureCosineDistance;
import net.semanticmetadata.lire.solr.features.ShortFeatureCosineDistance;
import java.util.HashMap;
import java.util.Iterator;
package net.semanticmetadata.lire.solr;
/**
* This file is part of LIRE Solr, a Java library for content based image retrieval.
*
* @author Mathias Lux, mathias@juggle.at, 28.11.2014
*/
public class FeatureRegistry {
/**
* Naming conventions for code: 2 letters for global features. More for local ones.
*/
private static HashMap<String, Class<? extends GlobalFeature>> codeToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
/**
* Caching the entries for fast retrieval or Strings without generating new objects.
*/
private static HashMap<String, Class<? extends GlobalFeature>> hashFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, Class<? extends GlobalFeature>> featureFieldToClass = new HashMap<String, Class<? extends GlobalFeature>>(16);
private static HashMap<String, String> hashFieldToFeatureField = new HashMap<String, String>(16);
private static HashMap<Class<? extends GlobalFeature>, String> classToCode = new HashMap<Class<? extends GlobalFeature>, String>(16);
// Constants.
public static final String featureFieldPostfix = "_hi"; // contains the histogram
public static final String hashFieldPostfix = "_ha"; // contains the hash
public static final String metricSpacesFieldPostfix = "_ms"; // contains the hash
static {
// initial adding of the supported features:
// classical features from the first implementation
codeToClass.put("cl", ColorLayout.class);
codeToClass.put("eh", EdgeHistogram.class);
codeToClass.put("jc", JCD.class);
codeToClass.put("oh", OpponentHistogram.class);
codeToClass.put("ph", PHOG.class);
// additional global features
codeToClass.put("ac", AutoColorCorrelogram.class);
codeToClass.put("ad", ACCID.class);
codeToClass.put("ce", CEDD.class);
codeToClass.put("fc", FCTH.class);
codeToClass.put("fo", FuzzyOpponentHistogram.class);
codeToClass.put("jh", JointHistogram.class);
codeToClass.put("sc", ScalableColor.class);
codeToClass.put("pc", SPCEDD.class);
// GenericFeatures filled with whatever one prefers.
codeToClass.put("df", DoubleFeatureCosineDistance.class);
// codeToClass.put("df", GenericGlobalDoubleFeature.class);
codeToClass.put("if", GenericGlobalIntFeature.class); | codeToClass.put("sf", ShortFeatureCosineDistance.class); |
dermotte/liresolr | src/test/java/net/semanticmetadata/lire/solr/indexing/UtilitiesTest.java | // Path: src/main/java/net/semanticmetadata/lire/solr/tools/Utilities.java
// public class Utilities {
// public static String hashesArrayToString(int[] array) {
// StringBuilder sb = new StringBuilder(array.length * 8);
// for (int i = 0; i < array.length; i++) {
// if (i > 0) sb.append(' ');
// sb.append(Integer.toHexString(array[i]));
// }
// return sb.toString();
// }
//
// /**
// * Sorts a map by value ... from https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values
// * @param map
// * @param <K>
// * @param <V>
// * @return
// */
// public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
// List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
// list.sort((Comparator<Entry<K, V>> & Serializable)
// (c1, c2) -> -c1.getValue().compareTo(c2.getValue()));
//
// Map<K, V> result = new LinkedHashMap<>();
// for (Entry<K, V> entry : list) {
// result.put(entry.getKey(), entry.getValue());
// }
//
// return result;
// }
//
// /**
// * Does a max normalization of the input vector.
// * @param featureVector the input double values, is left untouched.
// * @return new object with normalized values.
// */
// public static double[] normalize(double[] featureVector) {
// double[] result = new double[featureVector.length];
// double max = Arrays.stream(featureVector).reduce(Double::max).getAsDouble();
// double min = Arrays.stream(featureVector).reduce(Double::min).getAsDouble();
// for (int i = 0; i < featureVector.length; i++) {
// result[i] = (featureVector[i] - min)/ (max-min);
//
// }
// return result;
// }
//
// /**
// * Quantizes a normalized input vector to the maximum range of short.
// * @param featureVector the normalized input.
// * @return the short[] result, ideally quantized over the whole number space of short.
// */
// public static short[] quantizeToShort(double[] featureVector) {
// short[] result = new short[featureVector.length];
// for (int i = 0; i < featureVector.length; i++) {
// double d = featureVector[i] * Short.MAX_VALUE * 2 + Short.MIN_VALUE;
// assert (d <= Short.MAX_VALUE && d >= Short.MIN_VALUE);
// result[i] = (short) (d);
// }
// return result;
// }
//
// /**
// * Cuts off after the first numDimensions .. the rest is set to zero.
// * @param feature
// * @return
// */
// public static double[] toCutOffArray(double[] feature, int numDimensions) {
// double[] clone = feature.clone();
// Arrays.sort(clone);
// double cutOff = clone[clone.length-numDimensions];
// for (int i = 0; i < feature.length; i++) {
// clone[i] = (feature[i]>cutOff)?feature[i]:0d;
// }
// return clone;
// }
//
// public static short[] toShortArray(double[] feature) {
// short[] arr = new short[feature.length];
// for (int i = 0; i < arr.length; i++) {
// arr[i] = (short) (feature[i]*100d);
// }
// return arr;
// }
// }
| import junit.framework.TestCase;
import net.semanticmetadata.lire.solr.tools.Utilities;
import java.util.Arrays; | package net.semanticmetadata.lire.solr.indexing;
public class UtilitiesTest extends TestCase {
public void testNormalize() {
double[] d = {1.0, 2.0, 3.0, 4.0, 5.0}; | // Path: src/main/java/net/semanticmetadata/lire/solr/tools/Utilities.java
// public class Utilities {
// public static String hashesArrayToString(int[] array) {
// StringBuilder sb = new StringBuilder(array.length * 8);
// for (int i = 0; i < array.length; i++) {
// if (i > 0) sb.append(' ');
// sb.append(Integer.toHexString(array[i]));
// }
// return sb.toString();
// }
//
// /**
// * Sorts a map by value ... from https://stackoverflow.com/questions/109383/sort-a-mapkey-value-by-values
// * @param map
// * @param <K>
// * @param <V>
// * @return
// */
// public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
// List<Entry<K, V>> list = new ArrayList<>(map.entrySet());
// list.sort((Comparator<Entry<K, V>> & Serializable)
// (c1, c2) -> -c1.getValue().compareTo(c2.getValue()));
//
// Map<K, V> result = new LinkedHashMap<>();
// for (Entry<K, V> entry : list) {
// result.put(entry.getKey(), entry.getValue());
// }
//
// return result;
// }
//
// /**
// * Does a max normalization of the input vector.
// * @param featureVector the input double values, is left untouched.
// * @return new object with normalized values.
// */
// public static double[] normalize(double[] featureVector) {
// double[] result = new double[featureVector.length];
// double max = Arrays.stream(featureVector).reduce(Double::max).getAsDouble();
// double min = Arrays.stream(featureVector).reduce(Double::min).getAsDouble();
// for (int i = 0; i < featureVector.length; i++) {
// result[i] = (featureVector[i] - min)/ (max-min);
//
// }
// return result;
// }
//
// /**
// * Quantizes a normalized input vector to the maximum range of short.
// * @param featureVector the normalized input.
// * @return the short[] result, ideally quantized over the whole number space of short.
// */
// public static short[] quantizeToShort(double[] featureVector) {
// short[] result = new short[featureVector.length];
// for (int i = 0; i < featureVector.length; i++) {
// double d = featureVector[i] * Short.MAX_VALUE * 2 + Short.MIN_VALUE;
// assert (d <= Short.MAX_VALUE && d >= Short.MIN_VALUE);
// result[i] = (short) (d);
// }
// return result;
// }
//
// /**
// * Cuts off after the first numDimensions .. the rest is set to zero.
// * @param feature
// * @return
// */
// public static double[] toCutOffArray(double[] feature, int numDimensions) {
// double[] clone = feature.clone();
// Arrays.sort(clone);
// double cutOff = clone[clone.length-numDimensions];
// for (int i = 0; i < feature.length; i++) {
// clone[i] = (feature[i]>cutOff)?feature[i]:0d;
// }
// return clone;
// }
//
// public static short[] toShortArray(double[] feature) {
// short[] arr = new short[feature.length];
// for (int i = 0; i < arr.length; i++) {
// arr[i] = (short) (feature[i]*100d);
// }
// return arr;
// }
// }
// Path: src/test/java/net/semanticmetadata/lire/solr/indexing/UtilitiesTest.java
import junit.framework.TestCase;
import net.semanticmetadata.lire.solr.tools.Utilities;
import java.util.Arrays;
package net.semanticmetadata.lire.solr.indexing;
public class UtilitiesTest extends TestCase {
public void testNormalize() {
double[] d = {1.0, 2.0, 3.0, 4.0, 5.0}; | d = Utilities.normalize(d); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/tools/FlickrSolrIndexingTool.java | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
| import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.utils.CommandLineUtils;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; | package net.semanticmetadata.lire.solr.tools;
/**
* Simple tool for grabbing data from the Flickr public feed to index something in the LireSolr search service. Used to
* to create an XML file that can be uploaded to Solr.
*
* @author Mathias Lux, mathias@juggle.at, Dec 2016
*/
public class FlickrSolrIndexingTool {
static String helpMessage = "$> FlickrSolrIndexingTool -o <outfile.xml|auto> [-n <number_of_photos>] [-s]\n\n" +
"Options\n" +
"=======\n" +
"-s \t store the images locally as temp files.";
private static int numThreads = 8;
protected static boolean saveDownloadedImages = false;
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, InterruptedException { | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/tools/FlickrSolrIndexingTool.java
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import net.semanticmetadata.lire.utils.CommandLineUtils;
import org.xml.sax.SAXException;
import javax.xml.parsers.ParserConfigurationException;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
package net.semanticmetadata.lire.solr.tools;
/**
* Simple tool for grabbing data from the Flickr public feed to index something in the LireSolr search service. Used to
* to create an XML file that can be uploaded to Solr.
*
* @author Mathias Lux, mathias@juggle.at, Dec 2016
*/
public class FlickrSolrIndexingTool {
static String helpMessage = "$> FlickrSolrIndexingTool -o <outfile.xml|auto> [-n <number_of_photos>] [-s]\n\n" +
"Options\n" +
"=======\n" +
"-s \t store the images locally as temp files.";
private static int numThreads = 8;
protected static boolean saveDownloadedImages = false;
public static void main(String[] args) throws ParserConfigurationException, SAXException, IOException, InterruptedException { | HashingMetricSpacesManager.init(); |
dermotte/liresolr | src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashStax.java | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
| import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalShortFeature;
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import org.apache.solr.common.util.XML;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
import java.io.*;
import java.util.Base64; | package net.semanticmetadata.lire.solr.tools;
public class EncodeAndHashStax {
static BufferedWriter bw;
public static void main(String[] args) throws XMLStreamException, IOException { | // Path: src/main/java/net/semanticmetadata/lire/solr/HashingMetricSpacesManager.java
// public class HashingMetricSpacesManager {
// /**
// * Pre-load the static members of MetricSpaces to make sure hash generation is on time.
// */
// public static void init() {
// ClassLoader classloader = Thread.currentThread().getContextClassLoader();
// try {
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_CEDD.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_ColorLayout.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_EdgeHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_FCTH.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_OpponentHistogram.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/logos-ca-ee_PHOG.msd.gz")));
// MetricSpaces.loadReferencePoints(new GZIPInputStream(classloader.getResourceAsStream("metricspaces/jpg_us_filter_JCD.msd.gz")));
// } catch (Exception e) {
// e.printStackTrace();
// }
// try {
// BitSampling.readHashFunctions(classloader.getResourceAsStream("lsh/LshBitSampling_2048.obj")); // load BitSampling data from disk.
// } catch (IOException e) {
// e.printStackTrace();
// }
//
// }
// }
// Path: src/main/java/net/semanticmetadata/lire/solr/tools/EncodeAndHashStax.java
import net.semanticmetadata.lire.imageanalysis.features.global.GenericGlobalShortFeature;
import net.semanticmetadata.lire.indexers.hashing.BitSampling;
import net.semanticmetadata.lire.solr.HashingMetricSpacesManager;
import org.apache.solr.common.util.XML;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
import java.io.*;
import java.util.Base64;
package net.semanticmetadata.lire.solr.tools;
public class EncodeAndHashStax {
static BufferedWriter bw;
public static void main(String[] args) throws XMLStreamException, IOException { | HashingMetricSpacesManager.init(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarEntityConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
import br.com.soapboxrace.jpa.OwnedCarEntity; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarEntityConverter implements AttributeConverter<OwnedCarEntity, String> {
@Override
public String convertToDatabaseColumn(OwnedCarEntity ownedCarEntity) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarEntityConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
import br.com.soapboxrace.jpa.OwnedCarEntity;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarEntityConverter implements AttributeConverter<OwnedCarEntity, String> {
@Override
public String convertToDatabaseColumn(OwnedCarEntity ownedCarEntity) { | return MarshalXML.marshal(ownedCarEntity); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarEntityConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
import br.com.soapboxrace.jpa.OwnedCarEntity; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarEntityConverter implements AttributeConverter<OwnedCarEntity, String> {
@Override
public String convertToDatabaseColumn(OwnedCarEntity ownedCarEntity) {
return MarshalXML.marshal(ownedCarEntity);
}
@Override
public OwnedCarEntity convertToEntityAttribute(String ownedCarEntityString) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarEntityConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
import br.com.soapboxrace.jpa.OwnedCarEntity;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarEntityConverter implements AttributeConverter<OwnedCarEntity, String> {
@Override
public String convertToDatabaseColumn(OwnedCarEntity ownedCarEntity) {
return MarshalXML.marshal(ownedCarEntity);
}
@Override
public OwnedCarEntity convertToEntityAttribute(String ownedCarEntityString) { | return (OwnedCarEntity) UnmarshalXML.unMarshal(ownedCarEntityString, new OwnedCarEntity()); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_MessageType.java | // Path: src/main/java/br/com/soapboxrace/engine/Session.java
// public class Session extends Router {
//
// private static String xmppIp = "127.0.0.1";
//
// private static int xmppPort = 5222;
//
// private static String raceUdpIp = "127.0.0.1";
//
// private static int raceUdpPort = 9998;
//
// private static String freeRoamUdpIp = "127.0.0.1";
//
// private static int freeRoamUdpPort = 9999;
//
// private static String xmppServerType = "OpenFire";
//
// private static long currentMpSessionId = 10000L;
//
// public String getChatInfo() {
// ChatServerType chatServer = new ChatServerType();
// chatServer.setRooms(getRooms());
// chatServer.setIp(xmppIp);
// chatServer.setPort(xmppPort);
// return MarshalXML.marshal(chatServer);
// }
//
// public static String getXmppIp() {
// return xmppIp;
// }
//
// public static void setXmppIp(String xmppIp) {
// Session.xmppIp = xmppIp;
// }
//
// public static long getNextMpSessionId() {
// return currentMpSessionId++;
// }
//
// public static int getXmppPort() {
// return xmppPort;
// }
//
// public static void setXmppPort(int xmppPort) {
// Session.xmppPort = xmppPort;
// }
//
// public static String getRaceUdpIp() {
// return raceUdpIp;
// }
//
// public static void setRaceUdpIp(String raceUdpIp) {
// Session.raceUdpIp = raceUdpIp;
// }
//
// public static int getRaceUdpPort() {
// return raceUdpPort;
// }
//
// public static void setRaceUdpPort(int raceUdpPort) {
// Session.raceUdpPort = raceUdpPort;
// }
//
// public static String getFreeRoamUdpIp() {
// return freeRoamUdpIp;
// }
//
// public static void setFreeRoamUdpIp(String freeRoamUdpIp) {
// Session.freeRoamUdpIp = freeRoamUdpIp;
// }
//
// public static int getFreeRoamUdpPort() {
// return freeRoamUdpPort;
// }
//
// public static void setFreeRoamUdpPort(int freeRoamUdpPort) {
// Session.freeRoamUdpPort = freeRoamUdpPort;
// }
//
// public static String getXmppServerType() {
// return xmppServerType;
// }
//
// public static void setXmppServerType(String xmppServerType) {
// Session.xmppServerType = xmppServerType;
// }
//
// }
| import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.engine.Session; | package br.com.soapboxrace.xmpp.jaxb;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "messageType", propOrder = { "body", "subject" })
@XmlRootElement(name = "message")
public class XMPP_MessageType {
@XmlElement(required = true)
private String body;
@XmlAttribute(name = "from")
private String from = "";
@XmlAttribute(name = "id")
private String id = "JN_1234567";
@XmlAttribute(name = "to")
private String to;
@XmlElement(required = true)
private Long subject;
public XMPP_MessageType() { | // Path: src/main/java/br/com/soapboxrace/engine/Session.java
// public class Session extends Router {
//
// private static String xmppIp = "127.0.0.1";
//
// private static int xmppPort = 5222;
//
// private static String raceUdpIp = "127.0.0.1";
//
// private static int raceUdpPort = 9998;
//
// private static String freeRoamUdpIp = "127.0.0.1";
//
// private static int freeRoamUdpPort = 9999;
//
// private static String xmppServerType = "OpenFire";
//
// private static long currentMpSessionId = 10000L;
//
// public String getChatInfo() {
// ChatServerType chatServer = new ChatServerType();
// chatServer.setRooms(getRooms());
// chatServer.setIp(xmppIp);
// chatServer.setPort(xmppPort);
// return MarshalXML.marshal(chatServer);
// }
//
// public static String getXmppIp() {
// return xmppIp;
// }
//
// public static void setXmppIp(String xmppIp) {
// Session.xmppIp = xmppIp;
// }
//
// public static long getNextMpSessionId() {
// return currentMpSessionId++;
// }
//
// public static int getXmppPort() {
// return xmppPort;
// }
//
// public static void setXmppPort(int xmppPort) {
// Session.xmppPort = xmppPort;
// }
//
// public static String getRaceUdpIp() {
// return raceUdpIp;
// }
//
// public static void setRaceUdpIp(String raceUdpIp) {
// Session.raceUdpIp = raceUdpIp;
// }
//
// public static int getRaceUdpPort() {
// return raceUdpPort;
// }
//
// public static void setRaceUdpPort(int raceUdpPort) {
// Session.raceUdpPort = raceUdpPort;
// }
//
// public static String getFreeRoamUdpIp() {
// return freeRoamUdpIp;
// }
//
// public static void setFreeRoamUdpIp(String freeRoamUdpIp) {
// Session.freeRoamUdpIp = freeRoamUdpIp;
// }
//
// public static int getFreeRoamUdpPort() {
// return freeRoamUdpPort;
// }
//
// public static void setFreeRoamUdpPort(int freeRoamUdpPort) {
// Session.freeRoamUdpPort = freeRoamUdpPort;
// }
//
// public static String getXmppServerType() {
// return xmppServerType;
// }
//
// public static void setXmppServerType(String xmppServerType) {
// Session.xmppServerType = xmppServerType;
// }
//
// }
// Path: src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_MessageType.java
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.engine.Session;
package br.com.soapboxrace.xmpp.jaxb;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "messageType", propOrder = { "body", "subject" })
@XmlRootElement(name = "message")
public class XMPP_MessageType {
@XmlElement(required = true)
private String body;
@XmlAttribute(name = "from")
private String from = "";
@XmlAttribute(name = "id")
private String id = "JN_1234567";
@XmlAttribute(name = "to")
private String to;
@XmlElement(required = true)
private Long subject;
public XMPP_MessageType() { | from = "nfsw.engine.engine@" + Session.getXmppIp(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/VinylsConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.VinylsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class VinylsConverter implements AttributeConverter<VinylsType, String> {
@Override
public String convertToDatabaseColumn(VinylsType vinyls) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/VinylsConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.VinylsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class VinylsConverter implements AttributeConverter<VinylsType, String> {
@Override
public String convertToDatabaseColumn(VinylsType vinyls) { | return MarshalXML.marshal(vinyls); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/VinylsConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.VinylsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class VinylsConverter implements AttributeConverter<VinylsType, String> {
@Override
public String convertToDatabaseColumn(VinylsType vinyls) {
return MarshalXML.marshal(vinyls);
}
@Override
public VinylsType convertToEntityAttribute(String vinylsString) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/VinylsConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.VinylsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class VinylsConverter implements AttributeConverter<VinylsType, String> {
@Override
public String convertToDatabaseColumn(VinylsType vinyls) {
return MarshalXML.marshal(vinyls);
}
@Override
public VinylsType convertToEntityAttribute(String vinylsString) { | return (VinylsType) UnmarshalXML.unMarshal(vinylsString, new VinylsType()); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/SkillModPartsConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/SkillModPartsType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "SkillModPartsType", propOrder = { "skillModPartTrans" })
// @XmlRootElement(name = "SkillModParts")
// public class SkillModPartsType {
//
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(propOrder = { "IsFixed", "SkillModPartAttribHash" })
// @XmlRootElement(name = "SkillModPartTrans")
// public static class SkillModPartTrans {
// @XmlElement(name = "SkillModPartAttribHash")
// private String SkillModPartAttribHash;
// @XmlElement(name = "IsFixed")
// private String IsFixed;
//
// public String getIsFixed() {
// return IsFixed;
// }
//
// public String getSkillModPartAttribHash() {
// return SkillModPartAttribHash;
// }
//
// public void setIsFixed(String IsFixed) {
// this.IsFixed = IsFixed;
// }
//
// public void setSkillModPartAttribHash(String SkillModPartAttribHash) {
// this.SkillModPartAttribHash = SkillModPartAttribHash;
// }
// }
//
// @XmlElement(name = "SkillModPartTrans")
// private SkillModPartTrans[] skillModPartTrans;
//
// public SkillModPartTrans[] getSkillModPartTrans() {
// return skillModPartTrans;
// }
//
// public void setSkillModPartTrans(SkillModPartTrans[] SkillModPartTrans) {
// this.skillModPartTrans = SkillModPartTrans;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.SkillModPartsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class SkillModPartsConverter implements AttributeConverter<SkillModPartsType, String> {
@Override
public String convertToDatabaseColumn(SkillModPartsType skillModParts) { | // Path: src/main/java/br/com/soapboxrace/jaxb/SkillModPartsType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "SkillModPartsType", propOrder = { "skillModPartTrans" })
// @XmlRootElement(name = "SkillModParts")
// public class SkillModPartsType {
//
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(propOrder = { "IsFixed", "SkillModPartAttribHash" })
// @XmlRootElement(name = "SkillModPartTrans")
// public static class SkillModPartTrans {
// @XmlElement(name = "SkillModPartAttribHash")
// private String SkillModPartAttribHash;
// @XmlElement(name = "IsFixed")
// private String IsFixed;
//
// public String getIsFixed() {
// return IsFixed;
// }
//
// public String getSkillModPartAttribHash() {
// return SkillModPartAttribHash;
// }
//
// public void setIsFixed(String IsFixed) {
// this.IsFixed = IsFixed;
// }
//
// public void setSkillModPartAttribHash(String SkillModPartAttribHash) {
// this.SkillModPartAttribHash = SkillModPartAttribHash;
// }
// }
//
// @XmlElement(name = "SkillModPartTrans")
// private SkillModPartTrans[] skillModPartTrans;
//
// public SkillModPartTrans[] getSkillModPartTrans() {
// return skillModPartTrans;
// }
//
// public void setSkillModPartTrans(SkillModPartTrans[] SkillModPartTrans) {
// this.skillModPartTrans = SkillModPartTrans;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/SkillModPartsConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.SkillModPartsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class SkillModPartsConverter implements AttributeConverter<SkillModPartsType, String> {
@Override
public String convertToDatabaseColumn(SkillModPartsType skillModParts) { | return MarshalXML.marshal(skillModParts); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/SkillModPartsConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/SkillModPartsType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "SkillModPartsType", propOrder = { "skillModPartTrans" })
// @XmlRootElement(name = "SkillModParts")
// public class SkillModPartsType {
//
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(propOrder = { "IsFixed", "SkillModPartAttribHash" })
// @XmlRootElement(name = "SkillModPartTrans")
// public static class SkillModPartTrans {
// @XmlElement(name = "SkillModPartAttribHash")
// private String SkillModPartAttribHash;
// @XmlElement(name = "IsFixed")
// private String IsFixed;
//
// public String getIsFixed() {
// return IsFixed;
// }
//
// public String getSkillModPartAttribHash() {
// return SkillModPartAttribHash;
// }
//
// public void setIsFixed(String IsFixed) {
// this.IsFixed = IsFixed;
// }
//
// public void setSkillModPartAttribHash(String SkillModPartAttribHash) {
// this.SkillModPartAttribHash = SkillModPartAttribHash;
// }
// }
//
// @XmlElement(name = "SkillModPartTrans")
// private SkillModPartTrans[] skillModPartTrans;
//
// public SkillModPartTrans[] getSkillModPartTrans() {
// return skillModPartTrans;
// }
//
// public void setSkillModPartTrans(SkillModPartTrans[] SkillModPartTrans) {
// this.skillModPartTrans = SkillModPartTrans;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.SkillModPartsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class SkillModPartsConverter implements AttributeConverter<SkillModPartsType, String> {
@Override
public String convertToDatabaseColumn(SkillModPartsType skillModParts) {
return MarshalXML.marshal(skillModParts);
}
@Override
public SkillModPartsType convertToEntityAttribute(String skillModPartsString) { | // Path: src/main/java/br/com/soapboxrace/jaxb/SkillModPartsType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "SkillModPartsType", propOrder = { "skillModPartTrans" })
// @XmlRootElement(name = "SkillModParts")
// public class SkillModPartsType {
//
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(propOrder = { "IsFixed", "SkillModPartAttribHash" })
// @XmlRootElement(name = "SkillModPartTrans")
// public static class SkillModPartTrans {
// @XmlElement(name = "SkillModPartAttribHash")
// private String SkillModPartAttribHash;
// @XmlElement(name = "IsFixed")
// private String IsFixed;
//
// public String getIsFixed() {
// return IsFixed;
// }
//
// public String getSkillModPartAttribHash() {
// return SkillModPartAttribHash;
// }
//
// public void setIsFixed(String IsFixed) {
// this.IsFixed = IsFixed;
// }
//
// public void setSkillModPartAttribHash(String SkillModPartAttribHash) {
// this.SkillModPartAttribHash = SkillModPartAttribHash;
// }
// }
//
// @XmlElement(name = "SkillModPartTrans")
// private SkillModPartTrans[] skillModPartTrans;
//
// public SkillModPartTrans[] getSkillModPartTrans() {
// return skillModPartTrans;
// }
//
// public void setSkillModPartTrans(SkillModPartTrans[] SkillModPartTrans) {
// this.skillModPartTrans = SkillModPartTrans;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/SkillModPartsConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.SkillModPartsType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class SkillModPartsConverter implements AttributeConverter<SkillModPartsType, String> {
@Override
public String convertToDatabaseColumn(SkillModPartsType skillModParts) {
return MarshalXML.marshal(skillModParts);
}
@Override
public SkillModPartsType convertToEntityAttribute(String skillModPartsString) { | return (SkillModPartsType) UnmarshalXML.unMarshal(skillModPartsString, new SkillModPartsType()); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/engine/Session.java | // Path: src/main/java/br/com/soapboxrace/jaxb/ChatServerType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "ChatServerType", propOrder = { "rooms", "ip", "port", "prefix" })
// @XmlRootElement(name = "chatServer")
// public class ChatServerType {
//
// @XmlElement(name = "chatRoom", type = ChatRoomType.class)
// @XmlElementWrapper(name = "Rooms", required = true)
// protected List<ChatRoomType> rooms;
//
// @XmlElement(name = "ip", required = true)
// protected String ip;
//
// @XmlElement(name = "port", required = true)
// protected int port = 5222;
// @XmlElement(name = "prefix", required = true)
// protected String prefix = "nfsw";
//
// public List<ChatRoomType> getRooms() {
// return rooms;
// }
//
// public void setRooms(List<ChatRoomType> rooms) {
// this.rooms = rooms;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
| import br.com.soapboxrace.jaxb.ChatServerType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import static br.com.soapboxrace.definition.ChatRooms.getRooms; | package br.com.soapboxrace.engine;
public class Session extends Router {
private static String xmppIp = "127.0.0.1";
private static int xmppPort = 5222;
private static String raceUdpIp = "127.0.0.1";
private static int raceUdpPort = 9998;
private static String freeRoamUdpIp = "127.0.0.1";
private static int freeRoamUdpPort = 9999;
private static String xmppServerType = "OpenFire";
private static long currentMpSessionId = 10000L;
public String getChatInfo() { | // Path: src/main/java/br/com/soapboxrace/jaxb/ChatServerType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "ChatServerType", propOrder = { "rooms", "ip", "port", "prefix" })
// @XmlRootElement(name = "chatServer")
// public class ChatServerType {
//
// @XmlElement(name = "chatRoom", type = ChatRoomType.class)
// @XmlElementWrapper(name = "Rooms", required = true)
// protected List<ChatRoomType> rooms;
//
// @XmlElement(name = "ip", required = true)
// protected String ip;
//
// @XmlElement(name = "port", required = true)
// protected int port = 5222;
// @XmlElement(name = "prefix", required = true)
// protected String prefix = "nfsw";
//
// public List<ChatRoomType> getRooms() {
// return rooms;
// }
//
// public void setRooms(List<ChatRoomType> rooms) {
// this.rooms = rooms;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
// Path: src/main/java/br/com/soapboxrace/engine/Session.java
import br.com.soapboxrace.jaxb.ChatServerType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import static br.com.soapboxrace.definition.ChatRooms.getRooms;
package br.com.soapboxrace.engine;
public class Session extends Router {
private static String xmppIp = "127.0.0.1";
private static int xmppPort = 5222;
private static String raceUdpIp = "127.0.0.1";
private static int raceUdpPort = 9998;
private static String freeRoamUdpIp = "127.0.0.1";
private static int freeRoamUdpPort = 9999;
private static String xmppServerType = "OpenFire";
private static long currentMpSessionId = 10000L;
public String getChatInfo() { | ChatServerType chatServer = new ChatServerType(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/engine/Session.java | // Path: src/main/java/br/com/soapboxrace/jaxb/ChatServerType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "ChatServerType", propOrder = { "rooms", "ip", "port", "prefix" })
// @XmlRootElement(name = "chatServer")
// public class ChatServerType {
//
// @XmlElement(name = "chatRoom", type = ChatRoomType.class)
// @XmlElementWrapper(name = "Rooms", required = true)
// protected List<ChatRoomType> rooms;
//
// @XmlElement(name = "ip", required = true)
// protected String ip;
//
// @XmlElement(name = "port", required = true)
// protected int port = 5222;
// @XmlElement(name = "prefix", required = true)
// protected String prefix = "nfsw";
//
// public List<ChatRoomType> getRooms() {
// return rooms;
// }
//
// public void setRooms(List<ChatRoomType> rooms) {
// this.rooms = rooms;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
| import br.com.soapboxrace.jaxb.ChatServerType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import static br.com.soapboxrace.definition.ChatRooms.getRooms; | package br.com.soapboxrace.engine;
public class Session extends Router {
private static String xmppIp = "127.0.0.1";
private static int xmppPort = 5222;
private static String raceUdpIp = "127.0.0.1";
private static int raceUdpPort = 9998;
private static String freeRoamUdpIp = "127.0.0.1";
private static int freeRoamUdpPort = 9999;
private static String xmppServerType = "OpenFire";
private static long currentMpSessionId = 10000L;
public String getChatInfo() {
ChatServerType chatServer = new ChatServerType();
chatServer.setRooms(getRooms());
chatServer.setIp(xmppIp);
chatServer.setPort(xmppPort); | // Path: src/main/java/br/com/soapboxrace/jaxb/ChatServerType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "ChatServerType", propOrder = { "rooms", "ip", "port", "prefix" })
// @XmlRootElement(name = "chatServer")
// public class ChatServerType {
//
// @XmlElement(name = "chatRoom", type = ChatRoomType.class)
// @XmlElementWrapper(name = "Rooms", required = true)
// protected List<ChatRoomType> rooms;
//
// @XmlElement(name = "ip", required = true)
// protected String ip;
//
// @XmlElement(name = "port", required = true)
// protected int port = 5222;
// @XmlElement(name = "prefix", required = true)
// protected String prefix = "nfsw";
//
// public List<ChatRoomType> getRooms() {
// return rooms;
// }
//
// public void setRooms(List<ChatRoomType> rooms) {
// this.rooms = rooms;
// }
//
// public String getIp() {
// return ip;
// }
//
// public void setIp(String ip) {
// this.ip = ip;
// }
//
// public int getPort() {
// return port;
// }
//
// public void setPort(int port) {
// this.port = port;
// }
//
// public String getPrefix() {
// return prefix;
// }
//
// public void setPrefix(String prefix) {
// this.prefix = prefix;
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
// Path: src/main/java/br/com/soapboxrace/engine/Session.java
import br.com.soapboxrace.jaxb.ChatServerType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import static br.com.soapboxrace.definition.ChatRooms.getRooms;
package br.com.soapboxrace.engine;
public class Session extends Router {
private static String xmppIp = "127.0.0.1";
private static int xmppPort = 5222;
private static String raceUdpIp = "127.0.0.1";
private static int raceUdpPort = 9998;
private static String freeRoamUdpIp = "127.0.0.1";
private static int freeRoamUdpPort = 9999;
private static String xmppServerType = "OpenFire";
private static long currentMpSessionId = 10000L;
public String getChatInfo() {
ChatServerType chatServer = new ChatServerType();
chatServer.setRooms(getRooms());
chatServer.setIp(xmppIp);
chatServer.setPort(xmppPort); | return MarshalXML.marshal(chatServer); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/dao/db/UserDao.java | // Path: src/main/java/br/com/soapboxrace/db/SoapboxDao.java
// public abstract class SoapboxDao implements ISoapboxDao {
//
// @Override
// public ISoapBoxEntity save(ISoapBoxEntity entity) {
// if (entity.getId() == null) {
// this.persist(entity);
// } else {
// entity = (ISoapBoxEntity) this.merge(entity);
// }
// return entity;
// }
//
// @Override
// public void del(ISoapBoxEntity entity) {
// if (entity.getId() != null) {
// this.remove(entity);
// }
// }
//
// public ISoapBoxEntity findById(Class<? extends ISoapBoxEntity> entityClass, Long id) {
// EntityManager manager = ConnectionDB.getManager();
// manager.clear();
// return manager.find(entityClass, id);
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public List<ISoapBoxEntity> find(ISoapBoxEntity entity) {
// EntityManager manager = ConnectionDB.getManager();
// manager.clear();
// Session sessao = (Session) manager.getDelegate();
// Example example = Example.create(entity);
// example.excludeZeroes();
// Criteria criteria = sessao.createCriteria(entity.getClass());
// criteria.add(example);
// return criteria.list();
// }
//
// private void persist(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// manager.persist(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// }
//
// private Object merge(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// Object merge = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// merge = manager.merge(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// return merge;
// }
//
// private void remove(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// manager.remove(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// }
//
// protected EntityManager getManager() {
// return ConnectionDB.getManager();
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jpa/UserEntity.java
// @Entity
// @Table(name = "USER")
// public class UserEntity implements ISoapBoxEntity {
//
// private static final long serialVersionUID = -6748416062022703056L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "ID", nullable = false)
// private Long id;
//
// @Column(name = "EMAIL", length = 255)
// private String email;
//
// @Column(name = "PASSWORD", length = 41)
// private String password;
//
// @OneToMany(mappedBy = "user", targetEntity = PersonaEntity.class)
// private List<PersonaEntity> listOfPersona;
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getEmail() {
// return this.email;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getPassword() {
// return this.password;
// }
//
// public void setListOfPersona(List<PersonaEntity> listOfPersona) {
// this.listOfPersona = listOfPersona;
// }
//
// public List<PersonaEntity> getListOfPersona() {
// return this.listOfPersona;
// }
// }
| import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import br.com.soapboxrace.dao.factory.IUserDao;
import br.com.soapboxrace.db.SoapboxDao;
import br.com.soapboxrace.jpa.UserEntity; | package br.com.soapboxrace.dao.db;
public class UserDao extends SoapboxDao implements IUserDao {
@Override | // Path: src/main/java/br/com/soapboxrace/db/SoapboxDao.java
// public abstract class SoapboxDao implements ISoapboxDao {
//
// @Override
// public ISoapBoxEntity save(ISoapBoxEntity entity) {
// if (entity.getId() == null) {
// this.persist(entity);
// } else {
// entity = (ISoapBoxEntity) this.merge(entity);
// }
// return entity;
// }
//
// @Override
// public void del(ISoapBoxEntity entity) {
// if (entity.getId() != null) {
// this.remove(entity);
// }
// }
//
// public ISoapBoxEntity findById(Class<? extends ISoapBoxEntity> entityClass, Long id) {
// EntityManager manager = ConnectionDB.getManager();
// manager.clear();
// return manager.find(entityClass, id);
// }
//
// @Override
// @SuppressWarnings("unchecked")
// public List<ISoapBoxEntity> find(ISoapBoxEntity entity) {
// EntityManager manager = ConnectionDB.getManager();
// manager.clear();
// Session sessao = (Session) manager.getDelegate();
// Example example = Example.create(entity);
// example.excludeZeroes();
// Criteria criteria = sessao.createCriteria(entity.getClass());
// criteria.add(example);
// return criteria.list();
// }
//
// private void persist(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// manager.persist(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// }
//
// private Object merge(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// Object merge = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// merge = manager.merge(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// return merge;
// }
//
// private void remove(ISoapBoxEntity entity) {
// EntityTransaction tx = null;
// try {
// EntityManager manager = ConnectionDB.getManager();
// tx = manager.getTransaction();
// tx.begin();
// manager.remove(entity);
// tx.commit();
// } catch (Exception e) {
// if (tx != null && tx.isActive()) {
// tx.rollback();
// e.printStackTrace();
// }
// }
// }
//
// protected EntityManager getManager() {
// return ConnectionDB.getManager();
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jpa/UserEntity.java
// @Entity
// @Table(name = "USER")
// public class UserEntity implements ISoapBoxEntity {
//
// private static final long serialVersionUID = -6748416062022703056L;
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "ID", nullable = false)
// private Long id;
//
// @Column(name = "EMAIL", length = 255)
// private String email;
//
// @Column(name = "PASSWORD", length = 41)
// private String password;
//
// @OneToMany(mappedBy = "user", targetEntity = PersonaEntity.class)
// private List<PersonaEntity> listOfPersona;
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getId() {
// return this.id;
// }
//
// public void setEmail(String email) {
// this.email = email;
// }
//
// public String getEmail() {
// return this.email;
// }
//
// public void setPassword(String password) {
// this.password = password;
// }
//
// public String getPassword() {
// return this.password;
// }
//
// public void setListOfPersona(List<PersonaEntity> listOfPersona) {
// this.listOfPersona = listOfPersona;
// }
//
// public List<PersonaEntity> getListOfPersona() {
// return this.listOfPersona;
// }
// }
// Path: src/main/java/br/com/soapboxrace/dao/db/UserDao.java
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import br.com.soapboxrace.dao.factory.IUserDao;
import br.com.soapboxrace.db.SoapboxDao;
import br.com.soapboxrace.jpa.UserEntity;
package br.com.soapboxrace.dao.db;
public class UserDao extends SoapboxDao implements IUserDao {
@Override | public UserEntity findById(Long id) { |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jpa/EventDefinitionEntity.java | // Path: src/main/java/br/com/soapboxrace/jaxb/EngagePointType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "EngagePointType", propOrder = { "x", "y", "z" })
// public class EngagePointType {
//
// @XmlElement(name = "X")
// protected float x;
// @XmlElement(name = "Y")
// protected float y;
// @XmlElement(name = "Z")
// protected float z;
//
// public float getX() {
// return x;
// }
//
// public void setX(float value) {
// this.x = value;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float value) {
// this.y = value;
// }
//
// public float getZ() {
// return z;
// }
//
// public void setZ(float value) {
// this.z = value;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/RewardModesType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "RewardModesType", propOrder = { "_int" })
// public class RewardModesType {
//
// @XmlElement(name = "int", type = Integer.class)
// protected List<Integer> _int;
//
// public List<Integer> getInt() {
// if (_int == null) {
// _int = new ArrayList<Integer>();
// }
// return this._int;
// }
//
// }
| import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.jaxb.EngagePointType;
import br.com.soapboxrace.jaxb.RewardModesType; | package br.com.soapboxrace.jpa;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EventDefinitionType", propOrder = { "carClassHash", "coins", "engagePoint", "id",
"eventLocalization", "eventModeDescriptionLocalization", "eventModeIcon", "eventModeId",
"eventModeLocalization", "isEnabled", "isLocked", "laps", "length", "maxClassRating", "maxEntrants", "maxLevel",
"minClassRating", "minEntrants", "minLevel", "regionLocalization", "rewardModes", "timeLimit", "trackLayoutMap",
"trackLocalization" })
@Entity
@Table(name = "EVENTDEFINITION")
public class EventDefinitionEntity implements ISoapBoxEntity {
private static final long serialVersionUID = -1170162152186670454L;
@Id
@Column(name = "eventId")
@XmlElement(name = "EventId")
protected Long id;
@XmlElement(name = "CarClassHash")
protected int carClassHash;
@XmlElement(name = "Coins")
protected int coins;
@XmlElement(name = "EngagePoint", required = true)
@Transient | // Path: src/main/java/br/com/soapboxrace/jaxb/EngagePointType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "EngagePointType", propOrder = { "x", "y", "z" })
// public class EngagePointType {
//
// @XmlElement(name = "X")
// protected float x;
// @XmlElement(name = "Y")
// protected float y;
// @XmlElement(name = "Z")
// protected float z;
//
// public float getX() {
// return x;
// }
//
// public void setX(float value) {
// this.x = value;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float value) {
// this.y = value;
// }
//
// public float getZ() {
// return z;
// }
//
// public void setZ(float value) {
// this.z = value;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/RewardModesType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "RewardModesType", propOrder = { "_int" })
// public class RewardModesType {
//
// @XmlElement(name = "int", type = Integer.class)
// protected List<Integer> _int;
//
// public List<Integer> getInt() {
// if (_int == null) {
// _int = new ArrayList<Integer>();
// }
// return this._int;
// }
//
// }
// Path: src/main/java/br/com/soapboxrace/jpa/EventDefinitionEntity.java
import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.jaxb.EngagePointType;
import br.com.soapboxrace.jaxb.RewardModesType;
package br.com.soapboxrace.jpa;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "EventDefinitionType", propOrder = { "carClassHash", "coins", "engagePoint", "id",
"eventLocalization", "eventModeDescriptionLocalization", "eventModeIcon", "eventModeId",
"eventModeLocalization", "isEnabled", "isLocked", "laps", "length", "maxClassRating", "maxEntrants", "maxLevel",
"minClassRating", "minEntrants", "minLevel", "regionLocalization", "rewardModes", "timeLimit", "trackLayoutMap",
"trackLocalization" })
@Entity
@Table(name = "EVENTDEFINITION")
public class EventDefinitionEntity implements ISoapBoxEntity {
private static final long serialVersionUID = -1170162152186670454L;
@Id
@Column(name = "eventId")
@XmlElement(name = "EventId")
protected Long id;
@XmlElement(name = "CarClassHash")
protected int carClassHash;
@XmlElement(name = "Coins")
protected int coins;
@XmlElement(name = "EngagePoint", required = true)
@Transient | protected EngagePointType engagePoint = new EngagePointType(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jpa/EventDefinitionEntity.java | // Path: src/main/java/br/com/soapboxrace/jaxb/EngagePointType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "EngagePointType", propOrder = { "x", "y", "z" })
// public class EngagePointType {
//
// @XmlElement(name = "X")
// protected float x;
// @XmlElement(name = "Y")
// protected float y;
// @XmlElement(name = "Z")
// protected float z;
//
// public float getX() {
// return x;
// }
//
// public void setX(float value) {
// this.x = value;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float value) {
// this.y = value;
// }
//
// public float getZ() {
// return z;
// }
//
// public void setZ(float value) {
// this.z = value;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/RewardModesType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "RewardModesType", propOrder = { "_int" })
// public class RewardModesType {
//
// @XmlElement(name = "int", type = Integer.class)
// protected List<Integer> _int;
//
// public List<Integer> getInt() {
// if (_int == null) {
// _int = new ArrayList<Integer>();
// }
// return this._int;
// }
//
// }
| import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.jaxb.EngagePointType;
import br.com.soapboxrace.jaxb.RewardModesType; | @XmlElement(name = "EventModeIcon", required = true)
protected String eventModeIcon;
@XmlElement(name = "EventModeId")
protected int eventModeId;
@XmlElement(name = "EventModeLocalization")
protected int eventModeLocalization;
@XmlElement(name = "IsEnabled", required = true)
protected String isEnabled;
@XmlElement(name = "IsLocked", required = true)
protected String isLocked;
@XmlElement(name = "Laps")
protected int laps;
@XmlElement(name = "Length")
protected int length;
@XmlElement(name = "MaxClassRating")
protected int maxClassRating;
@XmlElement(name = "MaxEntrants")
protected int maxEntrants;
@XmlElement(name = "MaxLevel")
protected int maxLevel;
@XmlElement(name = "MinClassRating")
protected int minClassRating;
@XmlElement(name = "MinEntrants")
protected int minEntrants;
@XmlElement(name = "MinLevel")
protected int minLevel;
@XmlElement(name = "RegionLocalization")
protected int regionLocalization;
@XmlElement(name = "RewardModes", required = true)
@Transient | // Path: src/main/java/br/com/soapboxrace/jaxb/EngagePointType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "EngagePointType", propOrder = { "x", "y", "z" })
// public class EngagePointType {
//
// @XmlElement(name = "X")
// protected float x;
// @XmlElement(name = "Y")
// protected float y;
// @XmlElement(name = "Z")
// protected float z;
//
// public float getX() {
// return x;
// }
//
// public void setX(float value) {
// this.x = value;
// }
//
// public float getY() {
// return y;
// }
//
// public void setY(float value) {
// this.y = value;
// }
//
// public float getZ() {
// return z;
// }
//
// public void setZ(float value) {
// this.z = value;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/RewardModesType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "RewardModesType", propOrder = { "_int" })
// public class RewardModesType {
//
// @XmlElement(name = "int", type = Integer.class)
// protected List<Integer> _int;
//
// public List<Integer> getInt() {
// if (_int == null) {
// _int = new ArrayList<Integer>();
// }
// return this._int;
// }
//
// }
// Path: src/main/java/br/com/soapboxrace/jpa/EventDefinitionEntity.java
import java.util.List;
import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlTransient;
import javax.xml.bind.annotation.XmlType;
import br.com.soapboxrace.jaxb.EngagePointType;
import br.com.soapboxrace.jaxb.RewardModesType;
@XmlElement(name = "EventModeIcon", required = true)
protected String eventModeIcon;
@XmlElement(name = "EventModeId")
protected int eventModeId;
@XmlElement(name = "EventModeLocalization")
protected int eventModeLocalization;
@XmlElement(name = "IsEnabled", required = true)
protected String isEnabled;
@XmlElement(name = "IsLocked", required = true)
protected String isLocked;
@XmlElement(name = "Laps")
protected int laps;
@XmlElement(name = "Length")
protected int length;
@XmlElement(name = "MaxClassRating")
protected int maxClassRating;
@XmlElement(name = "MaxEntrants")
protected int maxEntrants;
@XmlElement(name = "MaxLevel")
protected int maxLevel;
@XmlElement(name = "MinClassRating")
protected int minClassRating;
@XmlElement(name = "MinEntrants")
protected int minEntrants;
@XmlElement(name = "MinLevel")
protected int minLevel;
@XmlElement(name = "RegionLocalization")
protected int regionLocalization;
@XmlElement(name = "RewardModes", required = true)
@Transient | protected RewardModesType rewardModes = new RewardModesType(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarTransConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.OwnedCarTransType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarTransConverter implements AttributeConverter<OwnedCarTransType, String> {
@Override
public String convertToDatabaseColumn(OwnedCarTransType ownedCarTrans) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarTransConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.OwnedCarTransType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarTransConverter implements AttributeConverter<OwnedCarTransType, String> {
@Override
public String convertToDatabaseColumn(OwnedCarTransType ownedCarTrans) { | return MarshalXML.marshal(ownedCarTrans); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarTransConverter.java | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
| import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.OwnedCarTransType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML; | package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarTransConverter implements AttributeConverter<OwnedCarTransType, String> {
@Override
public String convertToDatabaseColumn(OwnedCarTransType ownedCarTrans) {
return MarshalXML.marshal(ownedCarTrans);
}
@Override
public OwnedCarTransType convertToEntityAttribute(String ownedCarTransTypeString) { | // Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/UnmarshalXML.java
// public class UnmarshalXML {
//
// public static Object unMarshal(String xmlStr, Object obj) {
// Object objTmp = null;
// try {
// StringReader reader = new StringReader(xmlStr);
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller();
// XMLStreamReader xsr = XMLInputFactory.newFactory().createXMLStreamReader(reader);
// XMLReaderWithoutNamespace xr = new XMLReaderWithoutNamespace(xsr);
// objTmp = jaxbUnmarshaller.unmarshal(xr);
// // objTmp = jaxbUnmarshaller.unmarshal(reader);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return objTmp;
// }
// }
// Path: src/main/java/br/com/soapboxrace/jaxb/convert/OwnedCarTransConverter.java
import javax.persistence.AttributeConverter;
import javax.persistence.Converter;
import br.com.soapboxrace.jaxb.OwnedCarTransType;
import br.com.soapboxrace.jaxb.util.MarshalXML;
import br.com.soapboxrace.jaxb.util.UnmarshalXML;
package br.com.soapboxrace.jaxb.convert;
@Converter
public class OwnedCarTransConverter implements AttributeConverter<OwnedCarTransType, String> {
@Override
public String convertToDatabaseColumn(OwnedCarTransType ownedCarTrans) {
return MarshalXML.marshal(ownedCarTrans);
}
@Override
public OwnedCarTransType convertToEntityAttribute(String ownedCarTransTypeString) { | return (OwnedCarTransType) UnmarshalXML.unMarshal(ownedCarTransTypeString, new OwnedCarTransType()); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/config/Config.java | // Path: src/main/java/br/com/soapboxrace/dao/factory/SaveType.java
// public enum SaveType {
// XML, DB
// }
| import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import br.com.soapboxrace.dao.factory.SaveType; | package br.com.soapboxrace.config;
public class Config {
private int httpPort;
private String xmppIp;
private int xmppPort;
private String freeRoamUdpIp;
private int freeRoamUdpPort;
private String raceUdpIp;
private int raceUdpPort;
private String openFireToken;
private String xmppServerType;
private String dbDriver; | // Path: src/main/java/br/com/soapboxrace/dao/factory/SaveType.java
// public enum SaveType {
// XML, DB
// }
// Path: src/main/java/br/com/soapboxrace/config/Config.java
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.Properties;
import br.com.soapboxrace.dao.factory.SaveType;
package br.com.soapboxrace.config;
public class Config {
private int httpPort;
private String xmppIp;
private int xmppPort;
private String freeRoamUdpIp;
private int freeRoamUdpPort;
private String raceUdpIp;
private int raceUdpPort;
private String openFireToken;
private String xmppServerType;
private String dbDriver; | private SaveType saveType; |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/engine/Catalog.java | // Path: src/main/java/br/com/soapboxrace/bo/CatalogBO.java
// public class CatalogBO {
//
// private IProductDao productDao = DaoFactory.getProductDao();
// private ICategoryDao categoryDao = DaoFactory.getCategoryDao();
//
// public ArrayOfProductTrans productsInCategory(String categoryName, String clientProductType) {
// List<ProductEntity> products = productDao.findByCategoryNameClientProductType(categoryName, clientProductType);
// ArrayOfProductTrans arrayOfProductTrans = new ArrayOfProductTrans();
// arrayOfProductTrans.setProductTransList(products);
// return arrayOfProductTrans;
// }
//
// public ArrayOfCategoryTrans categories() {
// return categoryDao.getAll();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
| import br.com.soapboxrace.bo.CatalogBO;
import br.com.soapboxrace.jaxb.ArrayOfCategoryTrans;
import br.com.soapboxrace.jaxb.ArrayOfProductTrans;
import br.com.soapboxrace.jaxb.util.MarshalXML; | package br.com.soapboxrace.engine;
public class Catalog extends Router {
private CatalogBO catalogBO = new CatalogBO();
public String productsInCategory() {
String categoryName = getParam("categoryName");
String clientProductType = getParam("clientProductType");
ArrayOfProductTrans productsInCategory = catalogBO.productsInCategory(categoryName, clientProductType);
| // Path: src/main/java/br/com/soapboxrace/bo/CatalogBO.java
// public class CatalogBO {
//
// private IProductDao productDao = DaoFactory.getProductDao();
// private ICategoryDao categoryDao = DaoFactory.getCategoryDao();
//
// public ArrayOfProductTrans productsInCategory(String categoryName, String clientProductType) {
// List<ProductEntity> products = productDao.findByCategoryNameClientProductType(categoryName, clientProductType);
// ArrayOfProductTrans arrayOfProductTrans = new ArrayOfProductTrans();
// arrayOfProductTrans.setProductTransList(products);
// return arrayOfProductTrans;
// }
//
// public ArrayOfCategoryTrans categories() {
// return categoryDao.getAll();
// }
// }
//
// Path: src/main/java/br/com/soapboxrace/jaxb/util/MarshalXML.java
// public class MarshalXML {
//
// public static String marshal(Object obj) {
// StringWriter stringWriter = new StringWriter();
// try {
// JAXBContext jaxbContext = JAXBContext.newInstance(obj.getClass());
// Marshaller jaxbMarshaller = jaxbContext.createMarshaller();
// jaxbMarshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
// jaxbMarshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
// jaxbMarshaller.marshal(obj, stringWriter);
// } catch (Exception e) {
// e.printStackTrace();
// }
// return stringWriter.toString();
// }
// }
// Path: src/main/java/br/com/soapboxrace/engine/Catalog.java
import br.com.soapboxrace.bo.CatalogBO;
import br.com.soapboxrace.jaxb.ArrayOfCategoryTrans;
import br.com.soapboxrace.jaxb.ArrayOfProductTrans;
import br.com.soapboxrace.jaxb.util.MarshalXML;
package br.com.soapboxrace.engine;
public class Catalog extends Router {
private CatalogBO catalogBO = new CatalogBO();
public String productsInCategory() {
String categoryName = getParam("categoryName");
String clientProductType = getParam("clientProductType");
ArrayOfProductTrans productsInCategory = catalogBO.productsInCategory(categoryName, clientProductType);
| return MarshalXML.marshal(productsInCategory); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/engine/Powerups.java | // Path: src/main/java/br/com/soapboxrace/xmpp/XmppFactory.java
// public class XmppFactory {
//
// private static IXmppSender instance;
//
// public static IXmppSender getXmppSenderInstance(String xmppServerType) {
// if (instance == null) {
// instance = newXmppSender(xmppServerType);
// }
// return instance;
// }
//
// private static IXmppSender newXmppSender(String xmppServerType) {
// if ("OpenFire".equals(xmppServerType)) {
// return new OpenFireSoapBoxCli();
// } else if ("Offline".equals(xmppServerType)) {
// return new XmppSrv();
// }
// return null;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_PowerupActivatedType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "XMPP_PowerupActivatedType", propOrder = { "count", "id", "personaId", "targetPersonaId" })
// public class XMPP_PowerupActivatedType {
// @XmlElement(name = "Count", required = true)
// private Integer count = 1;
// @XmlElement(name = "Id", required = true)
// private Long id;
// @XmlElement(name = "PersonaId", required = true)
// private Long personaId;
// @XmlElement(name = "TargetPersonaId", required = true)
// private Long targetPersonaId;
//
// public Integer getCount() {
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getPersonaId() {
// return personaId;
// }
//
// public void setPersonaId(Long personaId) {
// this.personaId = personaId;
// }
//
// public Long getTargetPersonaId() {
// return targetPersonaId;
// }
//
// public void setTargetPersonaId(Long targetPersonaId) {
// this.targetPersonaId = targetPersonaId;
// }
// }
| import br.com.soapboxrace.xmpp.IXmppSender;
import br.com.soapboxrace.xmpp.XmppFactory;
import br.com.soapboxrace.xmpp.jaxb.XMPP_PowerupActivatedType;
import br.com.soapboxrace.xmpp.jaxb.XMPP_ResponseTypePowerupActivated; | package br.com.soapboxrace.engine;
public class Powerups extends Router {
private Long getPowerupHash() {
long powerupHash = 0L;
String[] targetSplitted = getTarget().split("/");
if (targetSplitted.length == 6) {
powerupHash = Long.valueOf(targetSplitted[5]);
}
return powerupHash;
}
public String activated() {
XMPP_ResponseTypePowerupActivated powerupActivatedResponse = new XMPP_ResponseTypePowerupActivated(); | // Path: src/main/java/br/com/soapboxrace/xmpp/XmppFactory.java
// public class XmppFactory {
//
// private static IXmppSender instance;
//
// public static IXmppSender getXmppSenderInstance(String xmppServerType) {
// if (instance == null) {
// instance = newXmppSender(xmppServerType);
// }
// return instance;
// }
//
// private static IXmppSender newXmppSender(String xmppServerType) {
// if ("OpenFire".equals(xmppServerType)) {
// return new OpenFireSoapBoxCli();
// } else if ("Offline".equals(xmppServerType)) {
// return new XmppSrv();
// }
// return null;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_PowerupActivatedType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "XMPP_PowerupActivatedType", propOrder = { "count", "id", "personaId", "targetPersonaId" })
// public class XMPP_PowerupActivatedType {
// @XmlElement(name = "Count", required = true)
// private Integer count = 1;
// @XmlElement(name = "Id", required = true)
// private Long id;
// @XmlElement(name = "PersonaId", required = true)
// private Long personaId;
// @XmlElement(name = "TargetPersonaId", required = true)
// private Long targetPersonaId;
//
// public Integer getCount() {
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getPersonaId() {
// return personaId;
// }
//
// public void setPersonaId(Long personaId) {
// this.personaId = personaId;
// }
//
// public Long getTargetPersonaId() {
// return targetPersonaId;
// }
//
// public void setTargetPersonaId(Long targetPersonaId) {
// this.targetPersonaId = targetPersonaId;
// }
// }
// Path: src/main/java/br/com/soapboxrace/engine/Powerups.java
import br.com.soapboxrace.xmpp.IXmppSender;
import br.com.soapboxrace.xmpp.XmppFactory;
import br.com.soapboxrace.xmpp.jaxb.XMPP_PowerupActivatedType;
import br.com.soapboxrace.xmpp.jaxb.XMPP_ResponseTypePowerupActivated;
package br.com.soapboxrace.engine;
public class Powerups extends Router {
private Long getPowerupHash() {
long powerupHash = 0L;
String[] targetSplitted = getTarget().split("/");
if (targetSplitted.length == 6) {
powerupHash = Long.valueOf(targetSplitted[5]);
}
return powerupHash;
}
public String activated() {
XMPP_ResponseTypePowerupActivated powerupActivatedResponse = new XMPP_ResponseTypePowerupActivated(); | XMPP_PowerupActivatedType powerupActivated = new XMPP_PowerupActivatedType(); |
michelinus/nfsw-server | src/main/java/br/com/soapboxrace/engine/Powerups.java | // Path: src/main/java/br/com/soapboxrace/xmpp/XmppFactory.java
// public class XmppFactory {
//
// private static IXmppSender instance;
//
// public static IXmppSender getXmppSenderInstance(String xmppServerType) {
// if (instance == null) {
// instance = newXmppSender(xmppServerType);
// }
// return instance;
// }
//
// private static IXmppSender newXmppSender(String xmppServerType) {
// if ("OpenFire".equals(xmppServerType)) {
// return new OpenFireSoapBoxCli();
// } else if ("Offline".equals(xmppServerType)) {
// return new XmppSrv();
// }
// return null;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_PowerupActivatedType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "XMPP_PowerupActivatedType", propOrder = { "count", "id", "personaId", "targetPersonaId" })
// public class XMPP_PowerupActivatedType {
// @XmlElement(name = "Count", required = true)
// private Integer count = 1;
// @XmlElement(name = "Id", required = true)
// private Long id;
// @XmlElement(name = "PersonaId", required = true)
// private Long personaId;
// @XmlElement(name = "TargetPersonaId", required = true)
// private Long targetPersonaId;
//
// public Integer getCount() {
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getPersonaId() {
// return personaId;
// }
//
// public void setPersonaId(Long personaId) {
// this.personaId = personaId;
// }
//
// public Long getTargetPersonaId() {
// return targetPersonaId;
// }
//
// public void setTargetPersonaId(Long targetPersonaId) {
// this.targetPersonaId = targetPersonaId;
// }
// }
| import br.com.soapboxrace.xmpp.IXmppSender;
import br.com.soapboxrace.xmpp.XmppFactory;
import br.com.soapboxrace.xmpp.jaxb.XMPP_PowerupActivatedType;
import br.com.soapboxrace.xmpp.jaxb.XMPP_ResponseTypePowerupActivated; | package br.com.soapboxrace.engine;
public class Powerups extends Router {
private Long getPowerupHash() {
long powerupHash = 0L;
String[] targetSplitted = getTarget().split("/");
if (targetSplitted.length == 6) {
powerupHash = Long.valueOf(targetSplitted[5]);
}
return powerupHash;
}
public String activated() {
XMPP_ResponseTypePowerupActivated powerupActivatedResponse = new XMPP_ResponseTypePowerupActivated();
XMPP_PowerupActivatedType powerupActivated = new XMPP_PowerupActivatedType();
powerupActivated.setId(getPowerupHash());
powerupActivated.setTargetPersonaId(Long.valueOf(getParam("targetId")));
powerupActivated.setPersonaId(getLoggedPersonaId());
powerupActivatedResponse.setPowerupActivated(powerupActivated);
for (String receiver : getParam("receivers").split("-")) {
Long receiverPersonaId = Long.valueOf(receiver);
if (receiverPersonaId > 10) { | // Path: src/main/java/br/com/soapboxrace/xmpp/XmppFactory.java
// public class XmppFactory {
//
// private static IXmppSender instance;
//
// public static IXmppSender getXmppSenderInstance(String xmppServerType) {
// if (instance == null) {
// instance = newXmppSender(xmppServerType);
// }
// return instance;
// }
//
// private static IXmppSender newXmppSender(String xmppServerType) {
// if ("OpenFire".equals(xmppServerType)) {
// return new OpenFireSoapBoxCli();
// } else if ("Offline".equals(xmppServerType)) {
// return new XmppSrv();
// }
// return null;
// }
//
// }
//
// Path: src/main/java/br/com/soapboxrace/xmpp/jaxb/XMPP_PowerupActivatedType.java
// @XmlAccessorType(XmlAccessType.FIELD)
// @XmlType(name = "XMPP_PowerupActivatedType", propOrder = { "count", "id", "personaId", "targetPersonaId" })
// public class XMPP_PowerupActivatedType {
// @XmlElement(name = "Count", required = true)
// private Integer count = 1;
// @XmlElement(name = "Id", required = true)
// private Long id;
// @XmlElement(name = "PersonaId", required = true)
// private Long personaId;
// @XmlElement(name = "TargetPersonaId", required = true)
// private Long targetPersonaId;
//
// public Integer getCount() {
// return count;
// }
//
// public void setCount(Integer count) {
// this.count = count;
// }
//
// public Long getId() {
// return id;
// }
//
// public void setId(Long id) {
// this.id = id;
// }
//
// public Long getPersonaId() {
// return personaId;
// }
//
// public void setPersonaId(Long personaId) {
// this.personaId = personaId;
// }
//
// public Long getTargetPersonaId() {
// return targetPersonaId;
// }
//
// public void setTargetPersonaId(Long targetPersonaId) {
// this.targetPersonaId = targetPersonaId;
// }
// }
// Path: src/main/java/br/com/soapboxrace/engine/Powerups.java
import br.com.soapboxrace.xmpp.IXmppSender;
import br.com.soapboxrace.xmpp.XmppFactory;
import br.com.soapboxrace.xmpp.jaxb.XMPP_PowerupActivatedType;
import br.com.soapboxrace.xmpp.jaxb.XMPP_ResponseTypePowerupActivated;
package br.com.soapboxrace.engine;
public class Powerups extends Router {
private Long getPowerupHash() {
long powerupHash = 0L;
String[] targetSplitted = getTarget().split("/");
if (targetSplitted.length == 6) {
powerupHash = Long.valueOf(targetSplitted[5]);
}
return powerupHash;
}
public String activated() {
XMPP_ResponseTypePowerupActivated powerupActivatedResponse = new XMPP_ResponseTypePowerupActivated();
XMPP_PowerupActivatedType powerupActivated = new XMPP_PowerupActivatedType();
powerupActivated.setId(getPowerupHash());
powerupActivated.setTargetPersonaId(Long.valueOf(getParam("targetId")));
powerupActivated.setPersonaId(getLoggedPersonaId());
powerupActivatedResponse.setPowerupActivated(powerupActivated);
for (String receiver : getParam("receivers").split("-")) {
Long receiverPersonaId = Long.valueOf(receiver);
if (receiverPersonaId > 10) { | IXmppSender xmppSenderInstance = XmppFactory.getXmppSenderInstance(Session.getXmppServerType()); |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.