public interface API
The Program API interface. This API provides programmatic control of the emulator at a very granular level. It supports direct access to CPU/PPU/APU Memory and registers, to controller input and to save states. And, it offers a multitude of listeners that enable programs to tap into emulation events.
Programs written in Java can be loaded directly into the emulator for execution. Programs written other languages can control the emulator through the Remote API, which uses an internal socket connection for interprocess communication.
Programs developed to control the emulator are written as if they were
standalone applications; the entrypoint of the program is the main()
method. To load the program into the emulator, it must be compiled and
bundled into a JAR. From the Run Program dialog, enter the path to the JAR
file or press the Find JAR button to browse to it. The Load JAR button
scans the JAR for classes containing main()
and it lists them in
a combo box. If the JAR manifest specifies the application's entrypoint,
the associated class will appear first in the list. If the JAR is modified
during development, press the Load JAR button again to import the changes. To
run the JAR, select the main class, enter any arguments to pass to
main()
, and press the Run button. The standard output and error
streams are redirected to a text area within the Run Program dialog. To
terminate the program, press Stop.
As far as a program is concerned, the API is a singleton. Classes interested in using the API can declare an object constant via the following code to make the reference available to all methods.
private final API api = ApiSource.getAPI();
The API starts out as disabled and while disabled only the add/remove
listener methods work. After adding listeners, a program calls run()
to activate the API; it signals that everything is setup and the program is
ready to receive events. Listeners are cached and they rarely need to be
removed. In the event that the API is temporarily disabled, listeners
do not need to be re-added. They are automatically removed on program
shutdown. And, most of the API methods that modify internal states do
not have the side effect of triggering listeners. For example, a
program that receives events when a region of CPU memory is updated can
modify the same region from the event listener without creating infinite
recursion.
The easiest way for a program to do something once-per-frame is within
a FrameListener
, which is called back immediately after a full frame
was rendered, but just before the frame is displayed to the user.
ScanlineListener
works in a similar way, but it is invoked after a
specified scanline was rendered. ScanlineCycleListener
takes that one
step further and responds to a specified dot. A program can manipulate
controller input from a ControllersListener
, which is called back
immediately after the controllers were probed for data, but just
before the probed data is exposed to the machine. AccessPointListener
is triggered by a specified CPU Memory read or write, or instruction
execution point and SpriteZeroListener
is triggered by sprite zero
hits. Finally, ActivateListener
, DeactivateListener
,
StatusListener
and StopListener
respond to API enabled
events, API disabled events, status message events and Stop button events,
respectively.
The Program API is single-threaded. After the main()
thread
calls run()
, the only thread that can safely invoke API methods
is the one that executes the listeners. While a listener is executing,
the emulator is effectively frozen; listeners need to return in a timely
manner to avoid slowing down emulation. Programs can spawn off additional
threads to perform parallel computations; however, the results of those
computations should be exposed to and used from the listeners to act on the
API.
The Remote API is exposed from the Start Program Server dialog, which accepts a local hostname and port to listen on. The Remote API provides a way for programs written in other languages to control the emulator. It uses a socket connection for interprocess communication enabling external programs to run on the same box as the emulator or a completely different machine.
For external Java programs, add a line similar to the following to the
main()
method and use the API in the same way as described above.
ApiSource.initRemoteAPI("localhost", 9999);
In the Remote API, run()
never returns. Instead, it enters an
infinite loop that maintains the network connection. Add a
StatusListener
to monitor the loop.
Implementations of the Remote API for other languages is not discussed here.
Modifier and Type | Method and Description |
---|---|
void |
acknowledgeInterrupt()
Acknowledges an interrupt.
|
void |
addAccessPointListener(AccessPointListener listener,
int accessPointType,
int address)
Adds an
AccessPointListener , which is invoked when an access
point is encountered. |
void |
addAccessPointListener(AccessPointListener listener,
int accessPointType,
int minAddress,
int maxAddress)
Adds an
AccessPointListener , which is invoked when an access
point is encountered. |
void |
addAccessPointListener(AccessPointListener listener,
int accessPointType,
int minAddress,
int maxAddress,
int bank)
Adds an
AccessPointListener , which is invoked when an access
point is encountered. |
void |
addActivateListener(ActivateListener listener)
Adds an
ActivateListener . |
void |
addCheat(int address,
int value,
int compare,
java.lang.String description,
boolean enabled)
Adds a new cheat or if the
address , value and
compare match an existing cheat, updates the existing cheat
with the specified description and enabled values. |
void |
addControllersListener(ControllersListener listener)
Adds a
ControllersListener . |
void |
addDeactivateListener(DeactivateListener listener)
Adds an
DeactivateListener . |
void |
addFrameListener(FrameListener listener)
Adds a
FrameListener . |
void |
addGameGenie(java.lang.String gameGenieCode,
java.lang.String description,
boolean enabled)
Adds a new Game Genie code or if the code matches an existing one, updates
the existing
description and enabled values. |
void |
addProActionRocky(java.lang.String proActionRockyCode,
java.lang.String description,
boolean enabled)
Adds a new Pro Action Rocky code or if the code matches an existing one,
updates the existing
description and enabled values. |
void |
addScanlineCycleListener(ScanlineCycleListener listener,
int scanline,
int scanlineCycle)
Adds a
ScanlineCycleListener that will be invoked at the specified
scanline and scanlineCycle values. |
void |
addScanlineListener(ScanlineListener listener,
int scanline)
Adds a
ScanlineListener that will be invoked after rendering the
specified scanline . |
void |
addSpriteZeroListener(SpriteZeroListener listener)
Adds a
SpriteZeroListener that will be called back immediately
after the sprite zero flag is set. |
void |
addStatusListener(StatusListener listener)
Adds a
StatusListener . |
void |
addStopListener(StopListener listener)
Adds a
StopListener . |
void |
clipRect(int x,
int y,
int width,
int height)
Intersects the current clip with the specified rectangle.
|
void |
close()
Terminates the currently running file.
|
void |
copyArea(int x,
int y,
int width,
int height,
int dx,
int dy)
Copies an area by a distance specified by
dx and dy . |
void |
createSprite(int id,
int width,
int height,
int[] pixels)
Creates a sprite with the specified
width , height and
9-bit extended palette index values. |
void |
deleteSprite(int id)
Removes the sprite with the specified identifier.
|
void |
draw3DRect(int x,
int y,
int width,
int height,
boolean raised)
Draws a 3-D highlighted outline of the specified rectangle.
|
void |
drawArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Draws the outline of a circular or elliptical arc covering the specified
rectangle.
|
void |
drawChar(char c,
int x,
int y)
Draws a character in the current color.
|
void |
drawChars(char[] chars,
int offset,
int length,
int x,
int y,
boolean monospaced)
Draws text in the current color using either a monospaced or a
proportional font.
|
void |
drawLine(int x1,
int y1,
int x2,
int y2)
Draws a colored line between the points
(x1, y1) and
(x2, y2) . |
void |
drawOval(int x,
int y,
int width,
int height)
Draws the outline of an oval.
|
void |
drawPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a closed polygon defined by arrays of x and y
coordinates.
|
void |
drawPolyline(int[] xPoints,
int[] yPoints,
int nPoints)
Draws a sequence of connected lines defined by arrays of x and
y coordinates.
|
void |
drawRect(int x,
int y,
int width,
int height)
Draws the outline of the specified rectangle.
|
void |
drawRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Draws an outlined round-cornered rectangle using in the current color.
|
void |
drawSprite(int id,
int x,
int y)
Draws a sprite with its upper-left corner at (x, y).
|
void |
drawString(java.lang.String str,
int x,
int y,
boolean monospaced)
Draws text in the current color using either a monospaced or a
proportional font.
|
void |
ejectDisk()
Ejects the currently inserted Famicom Disk Card.
|
void |
fill3DRect(int x,
int y,
int width,
int height,
boolean raised)
Paints a 3-D highlighted rectangle filled with the current color.
|
void |
fillArc(int x,
int y,
int width,
int height,
int startAngle,
int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle.
|
void |
fillOval(int x,
int y,
int width,
int height)
Fills an oval bounded by the specified rectangle with the current
color.
|
void |
fillPolygon(int[] xPoints,
int[] yPoints,
int nPoints)
Fills a closed polygon defined by arrays of x and y
coordinates.
|
void |
fillRect(int x,
int y,
int width,
int height)
Fills the specified rectangle.
|
void |
fillRoundRect(int x,
int y,
int width,
int height,
int arcWidth,
int arcHeight)
Fills the specified rounded corner rectangle with the current color.
|
void |
flipDiskSide()
Ejects the currently inserted Famicom Disk Card, turns it over to the
opposite side and reinserts it into the drive.
|
int |
getA()
Returns the contents of CPU register A, the 8-bit accumulator.
|
java.lang.String[] |
getArchiveEntries(java.lang.String archiveFileName)
Returns the list of files within a specified archive that can be opened.
|
int |
getCameraX()
Returns the horizontal coordinate of the left side of the rectangular
region of the nametables surface that is visible to the user.
|
int |
getCameraY()
Returns the vertical coordinate of the top of the rectangular region of
the nametables surface that is visible to the user.
|
int |
getCharsWidth(char[] chars,
boolean monospaced)
Provides the pixel width of the specified characters measured using either
a monospaced or a proportional font.
|
int |
getChrRomSize()
Provides the number of bytes of CHR ROM or 0 if CHR ROM is not present.
|
int |
getColor()
Gets the drawing/filling color, a 9-bit extended palette index.
|
java.lang.String |
getContentDirectory()
Returns the configured generated content directory.
|
java.lang.String |
getDefaultArchiveEntry(java.lang.String archiveFileName)
Returns the preferred entry file name within a specified archive, which is
based on the configured region and other file codes.
|
int |
getDiskSides()
Provides the total number of Famicom Disk Card sides containing data.
|
int |
getDot()
Returns the current scanline cycle number, a value in the range [0, 340].
|
java.lang.String |
getFileInfo()
Provides a detailed description of the currently loaded file.
|
int |
getFrameCount()
Returns the index of the current frame.
|
int |
getP()
Returns the CPU status flag bits.
|
int |
getPC()
Returns the contents of CPU register PC, the 16-bit program counter.
|
int |
getPixel(int x,
int y)
Obtains the extended palette index of a pixel at the specified
coordinates.
|
void |
getPixels(int[] pixels)
Captures the entire surface into the provided array.
|
int |
getPPUt()
Returns the contents of PPU register t, the temporary VRAM address
(the 15-bit address of the top-left on-screen tile).
|
int |
getPPUv()
Returns the contents of PPU register v, the current VRAM address
(15 bits).
|
int |
getPPUx()
Returns the contents of PPU register x, the fine X scroll (3 bits).
|
int |
getPrgRomSize()
Provides the number of bytes of PRG ROM or 0 if PRG ROM is not present.
|
int |
getS()
Returns the contents of CPU register S, the 8-bit stack pointer.
|
int |
getScanline()
Returns the current scanline number.
|
int |
getScanlineCount()
Returns the total number of scanlines in the current TV system.
|
int |
getStringWidth(java.lang.String str,
boolean monospaced)
Provides the pixel width of the specified
String measured using
either a monospaced or a proportional font. |
java.lang.String |
getTVSystem()
Returns the television encoding system.
|
java.lang.String |
getWorkingDirectory()
Returns the directory containing the emulator resources.
|
int |
getX()
Returns the contents of CPU register X, the 8-bit index register.
|
int |
getY()
Returns the contents of CPU register Y, the 8-bit index register.
|
int |
getZapperX()
Gets the Zapper X-coordinate or
-1 if the Zapper is not pointed
at the screen. |
int |
getZapperY()
Gets the Zapper Y-coordinate or
-1 if the Zapper is not pointed
at the screen. |
void |
glitch()
Induces a graphical glitch.
|
void |
insertCoin()
Inserts a coin into the VS.
|
void |
insertDisk(int disk,
int side)
Inserts a specified Famicom Disk Card into the drive flipped to a
particular side.
|
boolean |
isC()
Returns the CPU carry flag value that stores the carry/borrow/shift/rotate
out/in bit for/from an operation.
|
boolean |
isD()
Returns the CPU decimal mode flag value, indicating whether arithmetic
operations are performed in binary (
false ) or binary coded decimal
(true ). |
boolean |
isI()
Returns the CPU interrupt mask flag value, indicating whether maskable
interrupts are enabled (
false ) or disabled (true ). |
boolean |
isN()
Returns the CPU negative flag value, indicating if the most significant bit
of a prior result was set.
|
boolean |
isPaused()
Returns the paused mode.
|
boolean |
isPPUw()
Returns the PPU first/second write toggle flag.
|
boolean |
isSpriteZeroHit()
Returns the value of the sprite zero hit flag, which indicates if an
opaque pixel of sprite 0 overlapped an opaque pixel of the background in
the current frame (the flag is reset on dot 1 of the pre-render scanline).
|
boolean |
isV()
Returns the CPU overflow flag value, indicating if an arithmetic overflow
occurred.
|
boolean |
isZ()
Returns the CPU zero flag value, indicating if a prior result was 0.
|
boolean |
isZapperTrigger()
Gets the state of the Zapper trigger.
|
void |
loadState(java.lang.String stateFileName)
Resumes emulation from a saved state file.
|
void |
open(java.lang.String fileName)
Loads a file and starts emulation.
|
void |
openArchiveEntry(java.lang.String archiveFileName,
java.lang.String entryFileName)
Loads a file from an archive and starts emulation.
|
void |
openDefaultArchiveEntry(java.lang.String archiveFileName)
Loads the preferred file from an archive and starts emulation.
|
int |
peekCPU(int address)
Reads a byte from CPU Memory without triggering side effects.
|
int |
peekCPU16(int address)
Reads a 16-bit little-endian word from CPU Memory without side effects.
|
int |
peekCPU32(int address)
Reads a 32-bit little-endian word from CPU Memory without side effects.
|
void |
powerCycle()
Presses the power button twice, once to turn the machine off and a second
time to turn it back on again.
|
void |
pressServiceButton()
Presses the VS.
|
void |
quickLoadState(int slot)
Resumes emulation from a saved state slot.
|
void |
quickSaveState(int slot)
Captures the current emulation state into a state slot.
|
int |
readChrRom(int index)
Reads a byte from CHR ROM.
|
int |
readCPU(int address)
Reads a byte from CPU Memory.
|
int |
readCPU16(int address)
Reads a 16-bit little-endian word from CPU Memory.
|
int |
readCPU32(int address)
Reads a 32-bit little-endian word from CPU Memory.
|
boolean |
readGamepad(int gamepad,
int button)
Gets a gamepad button value.
|
int |
readOAM(int address)
Reads a byte from Object Attribute Memory.
|
int |
readPaletteRAM(int address)
Reads a byte from Palette RAM.
|
int |
readPPU(int address)
Reads a byte from PPU Memory.
|
int |
readPrgRom(int index)
Reads a byte from PRG ROM.
|
void |
removeAccessPointListener(AccessPointListener listener)
Removes an
AccessPointListener . |
void |
removeActivateListener(ActivateListener listener)
Removes an
ActivateListener . |
void |
removeCheat(int address,
int value,
int compare)
Deletes all cheats matching the specified parameters.
|
void |
removeControllersListener(ControllersListener listener)
Removes a
ControllersListener . |
void |
removeDeactivateListener(DeactivateListener listener)
Removes a
DeactivateListener . |
void |
removeFrameListener(FrameListener listener)
Removes a
FrameListener . |
void |
removeGameGenie(java.lang.String gameGenieCode)
Deletes a Game Genie code.
|
void |
removeProActionRocky(java.lang.String proActionRockyCode)
Deletes a Pro Action Rocky code.
|
void |
removeScanlineCycleListener(ScanlineCycleListener listener)
Removes a
ScanlineCycleListener . |
void |
removeScanlineListener(ScanlineListener listener)
Removes a
ScanlineListener . |
void |
removeSpriteZeroListener(SpriteZeroListener listener)
Removes a
SpriteZeroListener . |
void |
removeStatusListener(StatusListener listener)
Removes a
StatusListener . |
void |
removeStopListener(StopListener listener)
Removes a
StopListener . |
void |
requestInterrupt()
Requests an interrupt.
|
void |
reset()
Presses the reset button.
|
void |
resetClip()
Removes the current clipping area.
|
void |
run()
Activates the API.
|
void |
saveScreenshot()
Captures a screenshot to the configured screenshots directory.
|
void |
saveState(java.lang.String stateFileName)
Captures the current emulation state into a state file.
|
void |
screamIntoMicrophone()
Briefly yells into the controller 2 microphone on the traditional Famicom.
|
void |
setA(int A)
Stores the specified value within CPU register A, the 8-bit accumulator.
|
void |
setC(boolean C)
Sets the CPU carry flag value.
|
void |
setCameraX(int cameraX)
Sets the horizontal coordinate of the left side of the rectangular
region of the nametables surface that is visible to the user.
|
void |
setCameraY(int cameraY)
Sets the vertical coordinate of the top of the rectangular region of the
nametables surface that is visible to the user.
|
void |
setClip(int x,
int y,
int width,
int height)
Sets the current clip to the rectangle specified by the given
coordinates.
|
void |
setColor(int color)
Sets the drawing/filling color to the specified 9-bit extended
palette index.
|
void |
setD(boolean D)
Sets the CPU decimal mode flag, indicating whether arithmetic
operations are performed in binary (
false ) or binary coded decimal
(true ). |
void |
setFullscreenMode(boolean fullscreenMode)
Enters or exits fullscreen exclusive mode.
|
void |
setI(boolean I)
Sets the CPU interrupt mask flag value, indicating whether maskable
interrupts are enabled (
false ) or disabled (true ). |
void |
setN(boolean N)
Sets the CPU negative flag.
|
void |
setP(int P)
Sets the CPU status flag bits.
|
void |
setPaused(boolean paused)
Pauses or resumes emulation.
|
void |
setPC(int PC)
Stores the specified value within CPU register PC, the 16-bit program
counter.
|
void |
setPixel(int x,
int y,
int color)
Draws a pixel at the specified coordinates and in the provided
color.
|
void |
setPPUt(int t)
Stores the specified value within PPU register t, the temporary VRAM
address (the 15-bit address of the top-left on-screen tile).
|
void |
setPPUv(int v)
Stores the specified value within PPU register v, the current VRAM
address (15 bits).
|
void |
setPPUw(boolean w)
Sets the PPU first/second write toggle flag.
|
void |
setPPUx(int x)
Stores the specified value within PPU register x, the fine X scroll
(3 bits).
|
void |
setS(int S)
Stores the specified value within CPU register S, the 8-bit stack pointer.
|
void |
setSpeed(int percent)
Sets the emulation speed as a percentage of normal speed.
|
void |
setSpriteZeroHit(boolean spriteZeroHit)
Assigns a value to the sprite zero hit flag.
|
void |
setTVSystem(java.lang.String tvSystem)
Sets the television encoding system.
|
void |
setV(boolean V)
Sets the CPU overflow flag.
|
void |
setX(int X)
Stores the specified value within CPU register X, the 8-bit index register.
|
void |
setY(int Y)
Stores the specified value within CPU register Y, the 8-bit index register.
|
void |
setZ(boolean Z)
Sets the CPU zero flag value.
|
void |
setZapperTrigger(boolean zapperTrigger)
Sets the state of the Zapper trigger.
|
void |
setZapperX(int x)
Sets the Zapper X-coordinate.
|
void |
setZapperY(int y)
Sets the Zapper Y-coordinate.
|
void |
showMessage(java.lang.String message)
Briefly displays a message to the user.
|
void |
stepToNextFrame()
Resumes emulation for one frame.
|
void |
writeChrRom(int index,
int value)
Writes a byte to CHR ROM.
|
void |
writeCPU(int address,
int value)
Writes a byte to CPU Memory.
|
void |
writeCPU16(int address,
int value)
Writes a 16-bit little-endian word to CPU Memory.
|
void |
writeCPU32(int address,
int value)
Writes a 32-bit little-endian word to CPU Memory.
|
void |
writeGamepad(int gamepad,
int button,
boolean value)
Sets a gamepad button value.
|
void |
writeOAM(int address,
int value)
Writes a byte to Object Attribute Memory.
|
void |
writePaletteRAM(int address,
int value)
Writes a byte to Palette RAM.
|
void |
writePPU(int address,
int value)
Writes a byte to PPU Memory.
|
void |
writePrgRom(int index,
int value)
Writes a byte to PRG ROM.
|
void addActivateListener(ActivateListener listener)
Adds an ActivateListener
. This listener is called back when the
API is enabled, providing an opportunity to perform initialization tasks.
It is invoked immediately after the run
method is called
if the emulator is actively running a file; otherwise, it will be invoked
when a file is opened. The Remote API is not enabled until a socket
connection is established.
The API starts out as disabled and while disabled only the add/remove
listener methods work. Ideally, all listeners should be added prior to
calling run()
. Listeners are cached; they do not
need to be re-added in the event that the API is temporarily disabled.
listener
- The ActivateListener
to notify.addDeactivateListener(nintaco.api.DeactivateListener)
,
removeActivateListener(nintaco.api.ActivateListener)
void removeActivateListener(ActivateListener listener)
ActivateListener
.listener
- The ActivateListener
to remove.addActivateListener(nintaco.api.ActivateListener)
void addDeactivateListener(DeactivateListener listener)
Adds an DeactivateListener
. This listener is called back when
the API transitions from enabled to disabled. It will be invoked when a
file that is actively running in the emulator is closed. The Remote API
is disabled if the socket connection is disrupted.
The API starts out as disabled and while disabled only the add/remove
listener methods work. Ideally, all listeners should be added prior to
calling run()
. Listeners are cached; they do not
need to be re-added in the event that the API is temporarily disabled.
listener
- The DeactivateListener
to notify.addActivateListener(nintaco.api.ActivateListener)
,
removeDeactivateListener(nintaco.api.DeactivateListener)
void removeDeactivateListener(DeactivateListener listener)
DeactivateListener
.listener
- The DeactivateListener
to remove.addDeactivateListener(nintaco.api.DeactivateListener)
void addStopListener(StopListener listener)
Adds a StopListener
. This listener is only applicable to
programs running locally within the emulator. It is invoked when the Stop
button is pressed in the Run Program dialog, providing an opportunity to
perform cleanup operations such as terminating spawned threads, closing
open streams and freeing allocated resources. However, it is not necessary
to remove listeners; all added program listeners will be automatically
removed after the StopListener
returns.
Pressing the Stop button does not disable the API; it will not trigger
DeactivateListener
s and the StopListener
can make API
calls.
listener
- The StopListener
to notify.removeStopListener(nintaco.api.StopListener)
void removeStopListener(StopListener listener)
StopListener
.listener
- The StopListener
to remove.addStopListener(nintaco.api.StopListener)
void addAccessPointListener(AccessPointListener listener, int accessPointType, int address)
Adds an AccessPointListener
, which is invoked when an access
point is encountered. An access point is a specified CPU Memory read or
write, or instruction execution point.
The CPU Memory read and write methods do not trigger access points. Consequentially, they can be called within the listener without causing recursive loops.
listener
- The AccessPointListener
to notify.accessPointType
- One of the AccessPointType
constants,
indicating the type of access points that triggers the listener.address
- The CPU Memory address that triggers the listener.AccessPointType
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int,
int)
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int,
int, int)
void addAccessPointListener(AccessPointListener listener, int accessPointType, int minAddress, int maxAddress)
Adds an AccessPointListener
, which is invoked when an access
point is encountered. An access point is a specified CPU Memory read or
write, or instruction execution point.
The CPU Memory read and write methods do not trigger access points. Consequentially, they can be called within the listener without causing recursive loops.
listener
- The AccessPointListener
to notify.accessPointType
- One of the AccessPointType
constants,
indicating the type of access points that triggers the listener.minAddress
- The lower bound in the range of CPU Memory addresses
that triggers the listener. If the range consists of a single memory
address, use this parameter for that address.maxAddress
- The upper bound in the range of CPU Memory addresses
that triggers the listener. If the range consists of a single memory
address, set the lower and upper bounds to the same value or set this
parameter to -1 to indicate that it should be ignored.AccessPointType
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int)
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int,
int, int)
void addAccessPointListener(AccessPointListener listener, int accessPointType, int minAddress, int maxAddress, int bank)
Adds an AccessPointListener
, which is invoked when an access
point is encountered. An access point is a specified CPU Memory read or
write, or instruction execution point.
The CPU Memory read and write methods do not trigger access points. Consequentially, they can be called within the listener without causing recursive loops.
listener
- The AccessPointListener
to notify.accessPointType
- One of the AccessPointType
constants,
indicating the type of access points that triggers the listener.minAddress
- The lower bound in the range of CPU Memory addresses
that triggers the listener. If the range consists of a single memory
address, use this parameter for that address.maxAddress
- The upper bound in the range of CPU Memory addresses
that triggers the listener. If the range consists of a single memory
address, set the lower and upper bounds to the same value or set this
parameter to -1 to indicate that it should be ignored.bank
- For PRG ROM addresses, this parameter specifies the bank that
triggers the listener. The PRG ROM bank size and access index is
controlled by the mapper. Use -1 to indicate that all banks can trigger
the listener.AccessPointType
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int)
,
addAccessPointListener(nintaco.api.AccessPointListener, int, int,
int)
void removeAccessPointListener(AccessPointListener listener)
AccessPointListener
.listener
- The AccessPointListener
to remove.addAccessPointListener(nintaco.api.AccessPointListener, int, int,
int, int)
void addControllersListener(ControllersListener listener)
ControllersListener
. The listener will be called back
immediately after the controllers were probed for data, just
before the probed data is exposed to the machine.listener
- The ControllersListener
to notify.removeControllersListener(nintaco.api.ControllersListener)
void removeControllersListener(ControllersListener listener)
ControllersListener
.listener
- The ControllersListener
to remove.addControllersListener(nintaco.api.ControllersListener)
void addFrameListener(FrameListener listener)
FrameListener
. The listener will be called back immediately
after a full frame was rendered, just before the frame is displayed to the
user.listener
- The FrameListener
to notify.removeFrameListener(nintaco.api.FrameListener)
void removeFrameListener(FrameListener listener)
FrameListener
.listener
- The FrameListener
to remove.addFrameListener(nintaco.api.FrameListener)
void addScanlineListener(ScanlineListener listener, int scanline)
ScanlineListener
that will be invoked after rendering the
specified scanline
. The listener is called back during scanline
cycle 321, after the PPU fetches the sprite tile data for the successive
scanline and before register v is incremented during the initial
background tile fetches.listener
- The ScanlineListener
to notify.scanline
- The associated scanline. Use -1 for the pre-render
scanline.removeScanlineListener(nintaco.api.ScanlineListener)
void removeScanlineListener(ScanlineListener listener)
ScanlineListener
.listener
- The ScanlineListener
to remove.addScanlineListener(nintaco.api.ScanlineListener, int)
void addScanlineCycleListener(ScanlineCycleListener listener, int scanline, int scanlineCycle)
ScanlineCycleListener
that will be invoked at the specified
scanline
and scanlineCycle
values.listener
- The ScanlineCycleListener
to notify.scanline
- The associated scanline. Use -1 for the pre-render
scanline.scanlineCycle
- The associated scanline cycle (the dot number), a
value in the range [0, 340].removeScanlineCycleListener(nintaco.api.ScanlineCycleListener)
void removeScanlineCycleListener(ScanlineCycleListener listener)
ScanlineCycleListener
.listener
- The ScanlineCycleListener
to remove.addScanlineCycleListener(nintaco.api.ScanlineCycleListener, int,
int)
void addSpriteZeroListener(SpriteZeroListener listener)
SpriteZeroListener
that will be called back immediately
after the sprite zero flag is set.listener
- The SpriteZeroListener
to notify.removeSpriteZeroListener(nintaco.api.SpriteZeroListener)
void removeSpriteZeroListener(SpriteZeroListener listener)
SpriteZeroListener
.listener
- The SpriteZeroListener
to remove.addSpriteZeroListener(nintaco.api.SpriteZeroListener)
void addStatusListener(StatusListener listener)
StatusListener
. The listener is used to report status
change messages. For instance, in the Remote API, it will be called back
when the network connection is established or disrupted.listener
- The StatusListener
to notify.removeStatusListener(nintaco.api.StatusListener)
void removeStatusListener(StatusListener listener)
StatusListener
.listener
- The StatusListener
to remove.addStatusListener(nintaco.api.StatusListener)
void run()
Activates the API. The API starts out as disabled and while disabled
only the add/remove listener methods work. Ideally, all listeners should be
added prior to calling this method; run()
provides a way to signal
that everything is setup and the program is ready to receive events.
Shortly after invoking run()
, the ActivateListener
s
will be called back to signal that the API is enabled, if the emulator
is actively running a file.
In the Remote API, run()
never returns. Rather, it enters
an infinite loop that maintains the network connection. Add a
StatusListener
to monitor the loop.
run()
should only be called once near the start of a program; it
does not need to be invoked again in the event that the API is temporarily
disabled. Similarly, listeners are cached and they never need to be
re-added.
ActivateListener
,
DeactivateListener
,
StopListener
,
StatusListener
void powerCycle()
reset()
void reset()
powerCycle()
void setPaused(boolean paused)
paused
- true
to pause; false
to resume.isPaused()
boolean isPaused()
true
if paused; false
otherwise.setPaused(boolean)
int getFrameCount()
int getA()
setA(int)
void setA(int A)
A
- Only the lower 8 bits are used.getA()
int getS()
setS(int)
void setS(int S)
S
- Only the lower 8 bits are used.getS()
int getPC()
setPC(int)
void setPC(int PC)
PC
- Only the lower 16 bits are used.getPC()
int getX()
setX(int)
void setX(int X)
X
- Only the lower 8 bits are used.getX()
int getY()
setY(int)
void setY(int Y)
Y
- Only the lower 8 bits are used.getY()
int getP()
NV10DIZC
setP(int)
void setP(int P)
P
- NV..DIZC
getP()
boolean isN()
setN(boolean)
void setN(boolean N)
N
- The negative flag value.isN()
boolean isV()
setV(boolean)
void setV(boolean V)
V
- The overflow flag value.isV()
boolean isD()
false
) or binary coded decimal
(true
).setD(boolean)
void setD(boolean D)
false
) or binary coded decimal
(true
).D
- The decimal mode flag value.isD()
boolean isI()
false
) or disabled (true
).setI(boolean)
void setI(boolean I)
false
) or disabled (true
).I
- The interrupt mask flag value.isI()
boolean isZ()
setZ(boolean)
void setZ(boolean Z)
Z
- The zero flag value.isZ()
boolean isC()
setC(boolean)
void setC(boolean C)
C
- The carry flag value.isC()
int getPPUv()
setPPUv(int)
void setPPUv(int v)
v
- Only the lower 15 bits are used.getPPUv()
int getPPUt()
setPPUt(int)
void setPPUt(int t)
t
- Only the lower 15 bits are used.getPPUt()
int getPPUx()
setPPUx(int)
void setPPUx(int x)
x
- Only the lower 3 bits are used.getPPUx()
boolean isPPUw()
setPPUw(boolean)
void setPPUw(boolean w)
w
- The write flag value.isPPUw()
int getCameraX()
Returns the horizontal coordinate of the left side of the rectangular
region of the nametables surface that is visible to the user. Within each
scanline, this method will only function properly after dot 257, i.e.,
after the PPU copies all bits related to horizontal position from register
t to register v. The easiest way to ensure that is by
calling this method from a ScanlineListener
or a
ScanlineCycleListener
. The returned value is extracted from
registers v and x via the following code:
((v >> 2) & 0x100) | ((v << 3) & 0xF8) | (x & 0x07)
getPPUv()
,
getPPUx()
,
setCameraX(int)
,
setCameraY(int)
,
getCameraY()
void setCameraX(int cameraX)
ScanlineListener
or a
ScanlineCycleListener
. This method updates registers v and
x via the following code:
x = cameraX & 0x07;
v = (v & 0x7BE0) | ((cameraX & 0x100) << 2) | ((cameraX & 0xF8) >> 3);
cameraX
- The X-coordinate of the camera window.getCameraX()
,
getCameraY()
,
setCameraY(int)
,
setPPUv(int)
,
setPPUx(int)
int getCameraY()
Returns the vertical coordinate of the top of the rectangular region of
the nametables surface that is visible to the user. Within each scanline,
this method will only function properly after dot 257, i.e., after the PPU
copies all bits related to horizontal position from register t to
register v. The easiest way to ensure that is by calling this method
from a ScanlineListener
or a ScanlineCycleListener
. The
returned value is extracted from registers v and x via the
following code:
((v >> 2) & 0x100) | ((v << 3) & 0xF8) | (x & 0x07)
setCameraY(int)
,
setCameraX(int)
,
getCameraX()
,
getPPUv()
,
getPPUx()
void setCameraY(int cameraY)
ScanlineListener
or a ScanlineCycleListener
. This
method updates registers v and x via the following code:
x = cameraX & 0x07;
v = (v & 0x7BE0) | ((cameraX & 0x100) << 2) | ((cameraX & 0xF8) >> 3);
cameraY
- The Y-coordinate of the camera window.getCameraY()
,
getCameraX()
,
setCameraX(int)
,
setPPUv(int)
,
setPPUx(int)
int getScanline()
-1
refers to the pre-render
scanline. The maximum value is equal to getScanlineCount() - 2
.getDot()
,
getScanlineCount()
int getDot()
getScanline()
boolean isSpriteZeroHit()
setSpriteZeroHit(boolean)
void setSpriteZeroHit(boolean spriteZeroHit)
Assigns a value to the sprite zero hit flag. Modifying this flag affects bit 6 of PPUSTATUS ($2002). Normally, the flag is set when an opaque pixel of sprite 0 overlaps an opaque pixel of the background in the current frame; and, it is reset on dot 1 of the pre-render scanline.
Setting the sprite zero hit flag will not trigger
SpriteZeroListener
s.
spriteZeroHit
- The sprite zero hit flag value.isSpriteZeroHit()
int getScanlineCount()
void requestInterrupt()
acknowledgeInterrupt()
is
invoked (assuming that nothing else is pulling it low and that the mapper
does not acknowledge it earlier).acknowledgeInterrupt()
void acknowledgeInterrupt()
requestInterrupt()
forces the IRQ line low
and it will remain low until this method is called. However, the mapper
has control of the same request and acknowledgement mechanism. And, other
components are connected to the line.requestInterrupt()
int peekCPU(int address)
address
- Only the lower 16 bits are used.peekCPU16(int)
,
peekCPU32(int)
,
readCPU(int)
int readCPU(int address)
peekCpu
.address
- Only the lower 16 bits are used.readCPU16(int)
,
readCPU32(int)
,
peekCPU(int)
void writeCPU(int address, int value)
address
- Only the lower 16 bits are used.value
- The lower 8 bits contains the value to write.writeCPU16(int, int)
,
writeCPU32(int, int)
,
readCPU(int)
,
peekCPU(int)
int peekCPU16(int address)
Reads a 16-bit little-endian word from CPU Memory without side effects. For instance, peeking from the controller port registers will not modify the state of the controllers.
Bytes are read from sequentially increasing memory addresses.
address
- Only the lower 16 bits are used.int readCPU16(int address)
Reads a 16-bit little-endian word from CPU Memory. Bytes are read from sequentially increasing memory addresses.
Reading may have side effects. For instance, reading from the controller
port registers will modify the state of the controllers. This can be
avoided by using peekCpu16
.
address
- Only the lower 16 bits are used.peekCPU16(int)
void writeCPU16(int address, int value)
0xAABB
to address 0x0100
is equivalent to:
writeCpu(0x0100, 0xBB);
writeCpu(0x0101, 0xAA);
address
- Only the lower 16 bits are used.value
- The lower 16 bits contains the value to write.writeCPU(int, int)
int peekCPU32(int address)
Reads a 32-bit little-endian word from CPU Memory without side effects. For instance, peeking from the controller port registers will not modify the state of the controllers.
Bytes are read from sequentially increasing memory addresses.
address
- Only the lower 16 bits are used.int readCPU32(int address)
Reads a 32-bit little-endian word from CPU Memory. Bytes are read from sequentially increasing memory addresses.
Reading may have side effects. For instance, reading from the controller
port registers will modify the state of the controllers. This can be
avoided by using peekCpu32
.
address
- The lower 32 bits contains the memory address.peekCPU32(int)
void writeCPU32(int address, int value)
0xAABBCCDD
to address 0x0100
is equivalent to:
writeCpu(0x0100, 0xDD);
writeCpu(0x0101, 0xCC);
writeCpu(0x0102, 0xBB);
writeCpu(0x0103, 0xAA);
address
- Only the lower 16 bits are used.value
- The value to write.writeCPU(int, int)
int readPPU(int address)
address
- The lower 14 bits contains the memory address.void writePPU(int address, int value)
address
- The lower 14 bits contains the memory address.value
- The lower 8 bits contains the value to write.int readPaletteRAM(int address)
address
- The lower 5 bits contains the Palette RAM address.void writePaletteRAM(int address, int value)
address
- The lower 5 bits contains the Palette RAM address.value
- The lower 8 bits contains the value to write.int readOAM(int address)
address
- The lower 8 bits contain the OAM address.void writeOAM(int address, int value)
address
- The lower 8 bits contain the OAM address.value
- The lower 8 bits contains the value to write.boolean readGamepad(int gamepad, int button)
ControllersListener.controllersProbed()
, it will return one of the
cached button values that be applied in the subsequent frame generation
period. If it is invoked prior to the listener callback, then the returned
value is the one being used in the current frame generation period.
However, this method also returns changes made via
writeGamepad
, which might
apply to the next frame generation period, depending on when it was called.gamepad
- 0–3 (inclusive); 2 and 3 are applicable in multitap
games.button
- One of the GamepadButtons
constants.true
is pressed; false
is released.writeGamepad(int, int, boolean)
,
ControllersListener.controllersProbed()
,
GamepadButtons
void writeGamepad(int gamepad, int button, boolean value)
Sets a gamepad button value. If this method is invoked within
ControllersListener.controllersProbed()
, the modified value will
be applied in the subsequent frame generation period. If it is invoked
prior to the listener callback, the change will not be applied
immediately; rather, it will be applied automatically within the next
ControllersListener.controllersProbed()
callback.
The cached button values can be obtained via
readGamepad
.
gamepad
- 0–3 (inclusive); 2 and 3 are applicable in multitap
games.button
- One of the GamepadButtons
constantsvalue
- true
is pressed; false
is released.readGamepad(int, int)
,
ControllersListener.controllersProbed()
,
GamepadButtons
boolean isZapperTrigger()
ControllersListener.controllersProbed()
, it will return the
cached trigger value that be applied in the subsequent frame generation
period. If it is invoked prior to the listener callback, then the returned
value is the one being used in the current frame generation period.
However, this method also returns changes made via
setZapperTrigger
, which might
apply to the next frame generation period, depending on when it was called.true
is pulled; false
is released.setZapperTrigger(boolean)
,
ControllersListener.controllersProbed()
void setZapperTrigger(boolean zapperTrigger)
Sets the state of the Zapper trigger. If this method is invoked within
ControllersListener.controllersProbed()
, the modified value will
be applied in the subsequent frame generation period. If it is invoked
prior to the listener callback, the change will not be applied
immediately; rather, it will be applied automatically within the next
ControllersListener.controllersProbed()
callback.
The cached trigger value can be obtained via
isZapperTrigger
.
zapperTrigger
- true
is pulled; false
is released.isZapperTrigger()
,
ControllersListener.controllersProbed()
int getZapperX()
-1
if the Zapper is not pointed
at the screen. If this method is invoked within
ControllersListener.controllersProbed()
, it will return the
cached coordinate value that be applied in the subsequent frame generation
period. If it is invoked prior to the listener callback, then the returned
value is the one being used in the current frame generation period.
However, this method also returns changes made via
setZapperX
, which might apply to the next frame
generation period, depending on when it was called.-1
if the
Zapper is not pointed at the screen.setZapperX(int)
,
ControllersListener.controllersProbed()
void setZapperX(int x)
Sets the Zapper X-coordinate. Use -1
to indicate that the Zapper
is not pointed at the screen.
If this method is invoked within
ControllersListener.controllersProbed()
, the modified value will
be applied in the subsequent frame generation period. If it is invoked
prior to the listener callback, the change will not be applied
immediately; rather, it will be applied automatically within the next
ControllersListener.controllersProbed()
callback.
x
- A value in the range 0–255 (inclusive) or -1
if the
Zapper is not pointed at the screen.getZapperX()
,
ControllersListener.controllersProbed()
int getZapperY()
-1
if the Zapper is not pointed
at the screen. If this method is invoked within
ControllersListener.controllersProbed()
, it will return the
cached coordinate value that be applied in the subsequent frame generation
period. If it is invoked prior to the listener callback, then the returned
value is the one being used in the current frame generation period.
However, this method also returns changes made via
setZapperY
, which might apply to the next frame
generation period, depending on when it was called.-1
if the
Zapper is not pointed at the screen.setZapperY(int)
,
ControllersListener.controllersProbed()
void setZapperY(int y)
Sets the Zapper Y-coordinate. Use -1
to indicate that the Zapper
is not pointed at the screen.
If this method is invoked within
ControllersListener.controllersProbed()
, the modified value will
be applied in the subsequent frame generation period. If it is invoked
prior to the listener callback, the change will not be applied
immediately; rather, it will be applied automatically within the next
ControllersListener.controllersProbed()
callback.
y
- A value in the range 0–239 (inclusive) or -1
if the
Zapper is not pointed at the screen.getZapperY()
,
ControllersListener.controllersProbed()
void setColor(int color)
Sets the drawing/filling color to the specified 9-bit extended palette index. Subsequent graphics operations will use it.
color
- The lower 6 bits contain the palette index and the upper 3
bits contain the color emphasis. Colors
provides constants
for the non-emphasized colors.getColor()
,
Colors
int getColor()
Gets the drawing/filling color, a 9-bit extended palette index.
Colors
provides constants
for the non-emphasized colors.setColor(int)
,
Colors
void setClip(int x, int y, int width, int height)
Sets the current clip to the rectangle specified by the given coordinates. This method sets the user clip, which is independent of the clipping associated with device bounds and window visibility. Rendering operations have no effect outside of the clipping area.
If this method is invoked within FrameListener.frameRendered()
,
it will take effect as soon as the listener returns. If it is
invoked prior to the listener callback, it will be done automatically
within the next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the new clip rectangle.y
- The Y-coordinate of the new clip rectangle.width
- The width of the new clip rectangle.height
- The height of the new clip rectangle.clipRect(int, int, int, int)
,
resetClip()
void clipRect(int x, int y, int width, int height)
Intersects the current clip with the specified rectangle. The resulting
clipping area is the intersection of the current clipping area and the
specified rectangle. If there is no current clipping area, either because
the clip has never been set, or the clip has been cleared using
resetClip()
, the specified rectangle becomes the
new clip. This method sets the user clip, which is independent of the
clipping associated with device bounds and window visibility. This method
can only be used to make the current clip smaller. To set the current clip
larger, use setClip
methods.
Rendering operations have no effect outside of the clipping area.
If this method is invoked within FrameListener.frameRendered()
,
it will take effect as soon as the listener returns. If it is
invoked prior to the listener callback, it will be done automatically
within the next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to intersect the clip with.y
- The Y-coordinate of the rectangle to intersect the clip with.width
- The width of the rectangle to intersect the clip with.height
- The height of the rectangle to intersect the clip with.setClip(int, int, int, int)
,
resetClip()
void resetClip()
Removes the current clipping area. This method resets the user clip, which is independent of the clipping associated with the device bounds and window visibility. Rendering operations have no effect outside of the clipping area.
If this method is invoked within FrameListener.frameRendered()
,
it will take effect as soon as the listener returns. If it is
invoked prior to the listener callback, it will be done automatically
within the next FrameListener.frameRendered()
callback.
void copyArea(int x, int y, int width, int height, int dx, int dy)
Copies an area by a distance specified by dx
and dy
.
From the point specified by x
and y
, this method copies
downwards and to the right. To copy an area to the left or upwards, specify
a negative value for dx
or dy
. If a portion of the source
rectangle lies outside the window bounds or it is obscured by another
window or component copyArea
will be unable to copy the associated
pixels.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the source rectangle.y
- The Y-coordinate of the source rectangle.width
- The width of the source rectangle.height
- The height of the source rectangle.dx
- The horizontal distance to copy the pixels.dy
- The vertical distance to copy the pixels.getPixels(int[])
void drawLine(int x1, int y1, int x2, int y2)
Draws a colored line between the points (x1, y1)
and
(x2, y2)
.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x1
- The first point's X-coordinate.y1
- The first point's Y-coordinate.x2
- The second point's X-coordinate.y2
- The second point's Y-coordinate.setPixel(int, int, int)
void drawOval(int x, int y, int width, int height)
Draws the outline of an oval. The result is a circle or ellipse that fits within the rectangle specified by the x, y, width, and height arguments.
The oval covers an area that is width + 1
pixels wide and
height + 1
pixels tall.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the upper-left corner of the oval to be drawn.y
- The Y-coordinate of the upper-left corner of the oval to be drawn.width
- The width of the oval to be drawn.height
- The height of the oval to be drawn.fillOval(int, int, int, int)
void drawPolygon(int[] xPoints, int[] yPoints, int nPoints)
Draws a closed polygon defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point.
This method draws the polygon defined by nPoint
line segments,
where the first nPoint - 1
line segments are line segments from
(xPoints[i - 1], yPoints[i - 1])
to
(xPoints[i], yPoints[i])
, for 1 ≤ i ≤ nPoint
. The
figure is automatically closed by drawing a line connecting the final point
to the first point, if those points are different.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
xPoints
- An array of X-coordinates.yPoints
- An array of Y-coordinates.nPoints
- The total number of points.fillPolygon(int[], int[], int)
,
drawPolyline(int[], int[], int)
void drawPolyline(int[] xPoints, int[] yPoints, int nPoints)
Draws a sequence of connected lines defined by arrays of x and y coordinates. Each pair of (x, y) coordinates defines a point. The figure is not closed if the first point differs from the last point.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
xPoints
- An array of X-coordinates.yPoints
- An array of Y-coordinates.nPoints
- The total number of points.drawPolygon(int[], int[], int)
void drawRect(int x, int y, int width, int height)
Draws the outline of the specified rectangle. The left and right edges
of the rectangle are at x
and x + width
. The top and bottom
edges are at y
and y + height
.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be drawn.y
- The Y-coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.fillRect(int, int, int, int)
void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Draws an outlined round-cornered rectangle using in the current color.
The left and right edges of the rectangle are at x
and
x + width
, respectively. The top and bottom edges of the rectangle
are at y
and y + height
.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be drawn.y
- The Y-coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.arcWidth
- The horizontal diameter of the arc at the four corners.arcHeight
- The vertical diameter of the arc at the four corners.fillRoundRect(int, int, int, int, int, int)
void drawChar(char c, int x, int y)
Draws a character in the current color. (x, y) is position for the upper-left corner of the character.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
c
- The character to be drawn.x
- The X-coordinate of the left side of the character.y
- The Y-coordinate of the top of the character.drawChars(char[], int, int, int, int, boolean)
,
drawString(java.lang.String, int, int, boolean)
void drawChars(char[] chars, int offset, int length, int x, int y, boolean monospaced)
Draws text in the current color using either a monospaced or a proportional font. (x, y) is position for the upper-left corner of the first character in the array.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
chars
- The array of characters to be drawn.offset
- The start offset in the data.length
- The number of characters to be drawn.x
- The X-coordinate of the left side of the first character.y
- The Y-coordinate of the top of the first character.monospaced
- The font type. true
for monospaced; false
for proportional.drawChar(char, int, int)
,
drawString(java.lang.String, int, int, boolean)
void drawString(java.lang.String str, int x, int y, boolean monospaced)
Draws text in the current color using either a monospaced or a proportional font. (x, y) is position for the upper-left corner of the first character in the string.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
str
- The string to be drawn.x
- The X-coordinate of the left side of the first character.y
- The Y-coordinate of the top of the first character.monospaced
- The font type. true
for monospaced; false
for proportional.drawChar(char, int, int)
,
drawChars(char[], int, int, int, int, boolean)
void createSprite(int id, int width, int height, int[] pixels)
width
, height
and
9-bit extended palette index values. The provided id
is used to
reference the sprite for drawing or deleting. Completely transparent
regions are supported, but translucent regions are not.id
- An identifier for the sprite used for drawing or deleting. If a
sprite with the provided identifier already exists, it will be replaced.width
- The width of the sprite.height
- The height of the sprite.pixels
- The lower 6 bits of each int
is the palette index
and the upper 3 is the color emphasis. -1
indicates transparency.setColor(int)
,
getColor()
,
drawSprite(int, int, int)
,
deleteSprite(int)
,
Colors
void drawSprite(int id, int x, int y)
Draws a sprite with its upper-left corner at (x, y). Transparent pixels in the sprite do not affect whatever pixels are already there.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
id
- The sprite to draw. This identifier was specified
when the sprite was created
.x
- The X-coordinate for upper-left corner of the sprite to be drawn.y
- The Y-coordinate for upper-left corner of the sprite to be drawn.createSprite(int, int, int, int[])
,
deleteSprite(int)
void deleteSprite(int id)
id
- The sprite to delete. This identifier is same as the one
provided when the sprite was
created
.createSprite(int, int, int, int[])
,
drawSprite(int, int, int)
void draw3DRect(int x, int y, int width, int height, boolean raised)
Draws a 3-D highlighted outline of the specified rectangle. The edges of the rectangle are highlighted so that they appear to be beveled and lit from the upper-left corner.
The colors used for the highlighting effect are determined based on the
current color. The resulting rectangle covers an area that is
width + 1
pixels wide by height + 1
pixels tall.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be drawn.y
- The Y-coordinate of the rectangle to be drawn.width
- The width of the rectangle to be drawn.height
- The height of the rectangle to be drawn.raised
- A boolean that determines whether the rectangle appears to be
raised above the surface or sunk into the surface.fill3DRect(int, int, int, int, boolean)
void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Draws the outline of a circular or elliptical arc covering the specified rectangle.
The resulting arc begins at startAngle
and extends for
arcAngle
degrees, using the current color. Angles are interpreted
such that 0 degrees is at the 3 o'clock position. A positive value
indicates a counter-clockwise rotation while a negative value indicates a
clockwise rotation.
The center of the arc is the center of the rectangle whose origin is
(x, y) and whose size is specified by the width
and
height
arguments.
The resulting arc covers an area width + 1
pixels wide by
height + 1
pixels tall.
The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the upper-left corner of the arc to be drawn.y
- The Y-coordinate of the upper-left corner of the arc to be drawn.width
- The width of the arc to be drawn.height
- The height of the arc to be drawn.startAngle
- The beginning angle.arcAngle
- The angular extent of the arc, relative to the start angle.fillArc(int, int, int, int, int, int)
void fill3DRect(int x, int y, int width, int height, boolean raised)
Paints a 3-D highlighted rectangle filled with the current color. The edges of the rectangle will be highlighted so that it appears as if the edges were beveled and lit from the upper-left corner. The colors used for the highlighting effect will be determined from the current color.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be filled.y
- The Y-coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.raised
- A boolean value that determines whether the rectangle appears
to be raised above the surface or etched into the surface.draw3DRect(int, int, int, int, boolean)
void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle)
Fills a circular or elliptical arc covering the specified rectangle.
The resulting arc begins at startAngle
and extends for
arcAngle
degrees, using the current color. Angles are interpreted
such that 0 degrees is at the 3 o'clock position. A positive value
indicates a counter-clockwise rotation while a negative value indicates a
clockwise rotation.
The center of the arc is the center of the rectangle whose origin is
(x, y) and whose size is specified by the width
and
height
arguments.
The resulting arc covers an area width + 1
pixels wide by
height + 1
pixels tall.
The angles are specified relative to the non-square extents of the bounding rectangle such that 45 degrees always falls on the line from the center of the ellipse to the upper right corner of the bounding rectangle. As a result, if the bounding rectangle is noticeably longer in one axis than the other, the angles to the start and end of the arc segment will be skewed farther along the longer axis of the bounds.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the upper-left corner of the arc to be filled.y
- The Y-coordinate of the upper-left corner of the arc to be filled.width
- The width of the arc to be filled.height
- The height of the arc to be filled.startAngle
- The beginning angle.arcAngle
- The angular extent of the arc, relative to the start angle.drawArc(int, int, int, int, int, int)
void fillOval(int x, int y, int width, int height)
Fills an oval bounded by the specified rectangle with the current color.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the upper-left corner of the oval to be
filled.y
- The Y-coordinate of the upper-left corner of the oval to be
filled.width
- The width of the oval to be filled.height
- The height of the oval to be filled.drawOval(int, int, int, int)
void fillPolygon(int[] xPoints, int[] yPoints, int nPoints)
Fills a closed polygon defined by arrays of x and y coordinates.
This method draws the polygon defined by nPoint
line segments,
where the first nPoint - 1
line segments are line segments from
(xPoints[i - 1], yPoints[i - 1])
to
(xPoints[i], yPoints[i])
, for 1 ≤ i ≤ nPoints
. The
figure is automatically closed by drawing a line connecting the final point
to the first point, if those points are different.
The area inside the polygon is defined using an even-odd fill rule, also known as the alternating rule.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
xPoints
- An array of X-coordinates.yPoints
- An array of Y-coordinates.nPoints
- The total number of points.drawPolygon(int[], int[], int)
,
drawPolyline(int[], int[], int)
void fillRect(int x, int y, int width, int height)
Fills the specified rectangle. The left and right edges of the rectangle
are at x
and x + width - 1
. The top and bottom edges are at
y
and y + height - 1
. The resulting rectangle covers an
area width
pixels wide by height
pixels tall. The rectangle
is filled using the current color.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be filled.y
- The Y-coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.drawRect(int, int, int, int)
void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight)
Fills the specified rounded corner rectangle with the current color. The
left and right edges of the rectangle are at x
and
x + width - 1
, respectively. The top and bottom edges of the
rectangle are at y
and y + height - 1
.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the rectangle to be filled.y
- The Y-coordinate of the rectangle to be filled.width
- The width of the rectangle to be filled.height
- The height of the rectangle to be filled.arcWidth
- The horizontal diameter of the arc at the four corners.arcHeight
- The vertical diameter of the arc at the four corners.drawRoundRect(int, int, int, int, int, int)
void setPixel(int x, int y, int color)
Draws a pixel at the specified coordinates and in the provided color.
If this method is invoked within FrameListener.frameRendered()
,
the drawing will be displayed as soon as the listener returns. If it is
invoked prior to the listener callback, the drawing will not be
rendered immediately; rather, it will be done automatically within the
next FrameListener.frameRendered()
callback.
x
- The X-coordinate of the pixel to be drawn, a value in the range
[0, 255].y
- The Y-coordinate of the pixel to be drawn, a value in the range
[0, 239].color
- The lower 6 bits is the palette index and the upper 3 bits is
the color emphasis. The associated color is opaque (alpha is not
supported).setColor(int)
,
getColor()
,
getPixel(int, int)
,
getPixels(int[])
int getPixel(int x, int y)
Obtains the extended palette index of a pixel at the specified coordinates.
If this method is invoked within FrameListener.frameRendered()
,
the returned value will be from the frame that is about to be displayed. If
it is invoked prior to the listener callback, the returned value could be
from a prior frame.
x
- The X-coordinate of the pixel, a value in the range [0, 255].y
- The Y-coordinate of the pixel, a value in the range [0, 239].setColor(int)
,
getColor()
,
setPixel(int, int, int)
,
getPixels(int[])
void getPixels(int[] pixels)
Captures the entire surface into the provided array.
If this method is invoked within FrameListener.frameRendered()
,
the pixel values will be from the frame that is about to be displayed. If
it is invoked prior to the listener callback, some of the values could be
from a prior frame.
pixels
- The array to fill with 9-bit extended palette indices. It
must have a length of 256 × 240 = 61440 to capture the entire
surface. The lower 6 bits of each int
contain the palette index and
the upper 3 contain the color emphasis.getPixel(int, int)
,
setPixel(int, int, int)
,
Colors
void setSpeed(int percent)
percent
- The relative speed. 100 is normal speed. Greater values
speed up emulation. Lesser values slow it down, with the exception of 0 (or
below), which represents maximum speed.void stepToNextFrame()
setPaused(boolean)
,
isPaused()
void showMessage(java.lang.String message)
message
- The message to display.drawString(java.lang.String, int, int, boolean)
java.lang.String getWorkingDirectory()
getContentDirectory()
java.lang.String getContentDirectory()
getWorkingDirectory()
void open(java.lang.String fileName)
fileName
- The file to load. This is an absolute file path or a path
relative to the emulator's working directory. iNES, NES 2.0, Famicom Disk
System, UNIF, and NES Sound files are supported.openArchiveEntry(java.lang.String, java.lang.String)
,
openDefaultArchiveEntry(java.lang.String)
,
close()
,
getWorkingDirectory()
void openArchiveEntry(java.lang.String archiveFileName, java.lang.String entryFileName)
archiveFileName
- The archive file. This is an absolute file path or a
path relative to the emulator's working directory. Several archive formats
are supported including zip, rar, 7z, and various tar formats.entryFileName
- The entry file. This is a path relative to the root of
the archive. iNES, NES 2.0, Famicom Disk System, UNIF, and NES Sound files
are supported.open(java.lang.String)
,
openDefaultArchiveEntry(java.lang.String)
,
close()
,
getWorkingDirectory()
java.lang.String[] getArchiveEntries(java.lang.String archiveFileName)
archiveFileName
- The archive file. This is an absolute file path or a
path relative to the emulator's working directory. Several archive formats
are supported including zip, rar, 7z, and various tar formats.getDefaultArchiveEntry(java.lang.String)
java.lang.String getDefaultArchiveEntry(java.lang.String archiveFileName)
archiveFileName
- The archive file. This is an absolute file path or a
path relative to the emulator's working directory. Several archive formats
are supported including zip, rar, 7z, and various tar formats.getArchiveEntries(java.lang.String)
void openDefaultArchiveEntry(java.lang.String archiveFileName)
archiveFileName
- The archive file. This is an absolute file path or a
path relative to the emulator's working directory. Several archive formats
are supported including zip, rar, 7z, and various tar formats.getDefaultArchiveEntry(java.lang.String)
,
open(java.lang.String)
,
openArchiveEntry(java.lang.String, java.lang.String)
,
close()
void close()
void saveState(java.lang.String stateFileName)
stateFileName
- The state file. This is an absolute file path or a
path relative to the emulator's working directory. Preferably, the file
name should end with the .save extension.quickSaveState(int)
,
loadState(java.lang.String)
,
quickLoadState(int)
void loadState(java.lang.String stateFileName)
stateFileName
- The state file. This is an absolute file path or a
path relative to the emulator's working directory. The file name should end
with the .save extension.quickLoadState(int)
,
saveState(java.lang.String)
,
quickSaveState(int)
void quickSaveState(int slot)
slot
- Slots are numbered 1 to 9. 0 indicates the least recently used
slot.quickLoadState(int)
,
loadState(java.lang.String)
,
saveState(java.lang.String)
void quickLoadState(int slot)
slot
- Slots are numbered 1 to 9. 0 indicates the most recently used
slot.quickSaveState(int)
,
loadState(java.lang.String)
,
saveState(java.lang.String)
void setTVSystem(java.lang.String tvSystem)
tvSystem
- Supports "NTSC", "PAL" and "Dendy".java.lang.String getTVSystem()
int getDiskSides()
insertDisk(int, int)
,
flipDiskSide()
,
ejectDisk()
void insertDisk(int disk, int side)
disk
- The disk number, starting from 0.side
- 0 indicates side A and 1 indicates side B.getDiskSides()
,
flipDiskSide()
,
ejectDisk()
void flipDiskSide()
getDiskSides()
,
insertDisk(int, int)
,
ejectDisk()
void ejectDisk()
getDiskSides()
,
insertDisk(int, int)
,
flipDiskSide()
void insertCoin()
pressServiceButton()
void pressServiceButton()
insertCoin()
void screamIntoMicrophone()
void glitch()
java.lang.String getFileInfo()
void setFullscreenMode(boolean fullscreenMode)
fullscreenMode
- true
for fullscreen mode; false
for
window mode.void saveScreenshot()
void addCheat(int address, int value, int compare, java.lang.String description, boolean enabled)
Adds a new cheat or if the address
, value
and
compare
match an existing cheat, updates the existing cheat
with the specified description
and enabled
values.
Cheats intercept CPU reads and conditionally substitute the read value with an alternative value.
address
- The CPU read address. This can be any value in the range
$0000-FFFF
, not just $8000
or above.value
- The alternative value conditionally read at the CPU address.compare
- If the actual value at the CPU read address matches this
one, then the provided alternative value is substituted in its place.
-1
indicates no comparison; the alternative value will always be
used.description
- A summary of what the cheat does.enabled
- Activates or deactivates the cheat.void removeCheat(int address, int value, int compare)
address
- The CPU read address. This can be any value in the range
$0000-FFFF
, not just $8000
or above.value
- The alternative value conditionally read at the CPU address.compare
- If the actual value at the CPU read address matches this
one, then the provided alternative value is substituted in its place.
-1
indicates no comparison; the alternative value will always be
used.void addGameGenie(java.lang.String gameGenieCode, java.lang.String description, boolean enabled)
description
and enabled
values.gameGenieCode
- The Game Genie code.description
- A summary of what the Game Genie code does.enabled
- Activates or deactivates the Game Genie code.void removeGameGenie(java.lang.String gameGenieCode)
gameGenieCode
- The Game Genie code to remove.void addProActionRocky(java.lang.String proActionRockyCode, java.lang.String description, boolean enabled)
description
and enabled
values.proActionRockyCode
- The Pro Action Rocky code.description
- A summary of what the Pro Action Rocky code does.enabled
- Activates or deactivates the Pro Action Rocky code.void removeProActionRocky(java.lang.String proActionRockyCode)
proActionRockyCode
- The Pro Action Rocky code to remove.int getPrgRomSize()
int readPrgRom(int index)
index
- The offset into PRG ROM from which to read.index
or -1
if PRG ROM is not available or the index
is out of range.void writePrgRom(int index, int value)
index
- The offset into PRG ROM to which to write.value
- They byte value to write at the specified PRG ROM
index
.int getChrRomSize()
int readChrRom(int index)
index
- The offset into CHR ROM from which to read.index
or -1
if CHR ROM is not available or the index
is out of range.void writeChrRom(int index, int value)
index
- The offset into CHR ROM to which to write.value
- They byte value to write at the specified CHR ROM
index
.int getStringWidth(java.lang.String str, boolean monospaced)
String
measured using
either a monospaced or a proportional font. The height is always 8.str
- The String
to measure.monospaced
- The font type. true
for monospaced; false
for proportional.getCharsWidth(char[], boolean)
,
drawChars(char[], int, int, int, int, boolean)
,
drawString(java.lang.String, int, int, boolean)
int getCharsWidth(char[] chars, boolean monospaced)
chars
- The characters to measure.monospaced
- The font type. true
for monospaced; false
for proportional.getStringWidth(java.lang.String, boolean)
,
drawChars(char[], int, int, int, int, boolean)
,
drawString(java.lang.String, int, int, boolean)
Copyright © 2017 nintaco.com
Nintaco is free software; you can redistribute it and/or modify it under the terms of LGPLv2.1.