initial commit

This commit is contained in:
R-type
2015-12-14 14:00:35 +01:00
commit 5a96c0ca66
377 changed files with 149124 additions and 0 deletions
+28
View File
@@ -0,0 +1,28 @@
diff -rN -u old-nestedvm/src/org/ibex/nestedvm/UnixRuntime.java new-nestedvm/src/org/ibex/nestedvm/UnixRuntime.java
--- old-nestedvm/src/org/ibex/nestedvm/UnixRuntime.java 2008-06-27 17:29:32.437400000 -0400
+++ new-nestedvm/src/org/ibex/nestedvm/UnixRuntime.java 2008-06-27 17:29:32.650400000 -0400
@@ -9,6 +9,7 @@
import java.util.*;
import java.net.*;
import java.lang.reflect.*; // For lazily linked RuntimeCompiler
+import java.security.AccessControlException;
// FEATURE: vfork
@@ -1169,6 +1170,7 @@
tasks = new UnixRuntime[maxProcs+1];
if(defaultMounts) {
File root = null;
+ try {
if(Platform.getProperty("nestedvm.root") != null) {
root = new File(Platform.getProperty("nestedvm.root"));
if(!root.isDirectory()) throw new IllegalArgumentException("nestedvm.root is not a directory");
@@ -1189,6 +1191,7 @@
addMount("/" + name.toLowerCase(),new HostFS(roots[i]));
}
}
+ } catch (AccessControlException e) {}
addMount("/dev",new DevFS());
addMount("/resource",new ResourceFS());
+496
View File
@@ -0,0 +1,496 @@
/*
* atari800.java - Java NestedVM port of atari800
*
* Copyright (C) 2007-2008 Perry McFarlane
* Copyright (C) 1998-2013 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
import org.ibex.nestedvm.Runtime;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import java.util.*;
import javax.sound.sampled.*;
import java.applet.*;
class AtariCanvas extends Canvas implements KeyListener {
byte pixels[];
MemoryImageSource mis;
IndexColorModel icm;
Image image;
int atari_width;
int atari_height;
int atari_visible_width;
int atari_left_margin;
int width;
int height;
int scalew;
int scaleh;
int size;
boolean windowClosed = false;
Vector keyqueue;
Hashtable kbhits;
byte[][] paletteTable;
byte[] temp;
public void paint(Graphics g) {
update(g);
}
public void update(Graphics g) {
g.drawImage(image,0,0,width*scalew,height*scaleh,null);
}
public void init(){
width = atari_visible_width;
temp = new byte[width];
height = atari_height;
size = width*height;
pixels = new byte[size];
for(int i=0;i<size;i++){
pixels[i]=0;
}
keyqueue = new Vector();
addKeyListener(this);
kbhits = new Hashtable();
}
/* Init the palette*/
/* colortable is a runtime memory pointer*/
public void initPalette(Runtime rt, int colortable){
paletteTable = new byte[3][256];
int entry=0;
for(int i=0; i<256; i++){
try {
entry = rt.memRead(colortable+i*4);
} catch(Exception e) {
System.err.println(e);
}
paletteTable[0][i]=(byte)((entry>>>16)&0xff);
paletteTable[1][i]=(byte)((entry>>>8)&0xff);
paletteTable[2][i]=(byte)(entry&0xff);
}
icm = new IndexColorModel(8,256,paletteTable[0],paletteTable[1],paletteTable[2]);
mis = new MemoryImageSource(width,height,icm,pixels,0,width);
mis.setAnimated(true);
mis.setFullBufferUpdates(true);
image = createImage(mis);
}
public void displayScreen(Runtime rt, int atari_screen){
int ao = atari_screen + atari_left_margin;
int po = 0;
for(int h=0; h<240;h++){
try {
rt.copyin(ao,temp,width);
System.arraycopy(temp,0,pixels,po,width);
} catch(Exception e) {
System.err.println(e);
}
ao += atari_width;
po += width;
}
mis.newPixels();
repaint();
}
/* called when the user closes the window */
public void setWindowClosed() {
windowClosed = true;
}
// KeyListener methods:
public void keyPressed(KeyEvent event) {
char chr = event.getKeyChar();
int key = event.getKeyCode();
int loc = event.getKeyLocation();
keyqueue.addElement(event);
Integer[] val = new Integer[2];
val[0] = new Integer(key);
val[1] = new Integer(loc);
kbhits.put(Arrays.asList(val), new Boolean(true));
//System.err.println("keyPressed: "+key+" location: "+loc);
}
public void keyReleased(KeyEvent event) {
char chr = event.getKeyChar();
int key = event.getKeyCode();
int loc = event.getKeyLocation();
keyqueue.addElement(event);
Integer[] val = new Integer[2];
val[0] = new Integer(key);
val[1] = new Integer(loc);
kbhits.remove(Arrays.asList(val));
}
public void keyTyped(KeyEvent event) {
}
/* get a keyboard key state */
int getKbhits(int key, int loc){
Integer[] val = new Integer[2];
val[0] = new Integer(key);
val[1] = new Integer(loc);
if (kbhits.get(Arrays.asList(val)) != null ){
return 1;
}
else{
return 0;
}
}
/* event points to an array of 4 values*/
int pollKeyEvent(Runtime rt, int return_event){
if (keyqueue.isEmpty()){
return 0;
}
KeyEvent event = (KeyEvent)keyqueue.firstElement();
keyqueue.removeElement(event);
int type = event.getID();
int key = event.getKeyCode();
char uni = event.getKeyChar();
int loc = event.getKeyLocation();
try{
/* write the data to the array pointed to by event*/
rt.memWrite(return_event+0*4,type);
rt.memWrite(return_event+1*4,key);
rt.memWrite(return_event+2*4,(int)uni);
rt.memWrite(return_event+3*4,loc);
} catch(Exception e) {
System.err.println(e);
}
return 1;
}
/* 1 if the Window was closed */
int getWindowClosed(){
return windowClosed ? 1 : 0;
}
}
public class atari800 extends Applet implements Runnable {
AtariCanvas canvas;
Frame frame;
SourceDataLine line;
byte[] soundBuffer;
boolean isApplet;
Thread thread;
private volatile boolean threadSuspended;
//Applet constructor:
public atari800() {
isApplet = true;
}
//Application constructor:
public atari800(Frame f) {
isApplet = false;
frame = f;
}
private void initGraphics(int scalew, int scaleh, int atari_width, int atari_height, int atari_visible_width, int atari_left_margin){
canvas = new AtariCanvas();
canvas.atari_width = atari_width;
canvas.atari_height = atari_height;
canvas.atari_visible_width = atari_visible_width;
canvas.atari_left_margin = atari_left_margin;
canvas.init();
canvas.setFocusTraversalKeysEnabled(false); //allow Tab key to work
canvas.setFocusable(true);
if (!isApplet) {
frame.addWindowListener(new WindowAdapter() {
public void windowsGainedFocus(WindowEvent e) {
canvas.requestFocusInWindow();
}
public void windowClosing(WindowEvent e) {
canvas.setWindowClosed();
}
});
}
canvas.requestFocusInWindow();
canvas.setSize(new Dimension(canvas.width*scalew,canvas.height*scaleh));
canvas.scalew = scalew;
canvas.scaleh = scaleh;
if (isApplet) {
this.add(canvas);
canvas.requestFocus();
}
else {
frame.add(canvas);
frame.setResizable(false);
frame.pack();
Insets insets = frame.getInsets();
frame.setSize(new Dimension(canvas.width*scalew+insets.left+insets.right, canvas.height*scaleh+insets.top+insets.bottom));
frame.setVisible(true);
}
}
private void initSound(int sampleRate, int bitsPerSample, int channels, boolean isSigned, boolean bigEndian, int bufferSize){
AudioFormat format = new AudioFormat(sampleRate, bitsPerSample, channels, isSigned, bigEndian);
DataLine.Info info = new DataLine.Info(SourceDataLine.class,format);
try {
if (line != null) line.close();
line = (SourceDataLine) AudioSystem.getLine(info);
line.open(format, bufferSize);
soundBuffer = new byte[line.getBufferSize()];
} catch(Exception e) {
System.err.println(e);
}
}
//Applet init
public void init() {
//System.out.println("init()");
setLayout(null);
}
//Applet start
public synchronized void start() {
//System.out.println("start()");
if (thread == null) {
thread = new Thread(this);
thread.start();
}
threadSuspended = false;
thread.interrupt();
}
//Applet stop
public synchronized void stop() {
//System.out.println("stop()");
threadSuspended = true;
}
//Applet destroy
public void destroy() {
//System.out.println("destroy()");
if (line!=null) line.close();
if (canvas!=null) this.remove(canvas);
Thread dead = thread;
thread = null;
dead.interrupt();
}
//Applet run thread
public void run() {
//System.out.println("run()");
String args = getParameter("args");
this.main2(args.split("\\s"));
}
public void paint(Graphics g) {
//System.out.println("paint");
if (canvas!=null) canvas.paint(g);
}
public static void main(String[] args) {
Frame f = new Frame();
final atari800 app = new atari800(f);
f.setTitle("atari800");
app.main2(args);
}
// used by both Application and Applet
public void main2(String[] args) {
//Place holder for command line arguments
String[] appArgs = new String[args.length +1];
try {
final Thread thisThread = Thread.currentThread();
//Application name
appArgs[0] = "atari800";
//Fill in the rest of the command line arguments
for(int i=0;i<args.length;i++) appArgs[i+1] = args[i];
//Make a Runtime instantiation
final Runtime rt;
String className = "atari800_runtime";
/*TO use the interpreter:*/
/*
if(className.endsWith(".mips")){
rt = new org.ibex.nestedvm.Interpreter(className);
} else {*/
Class c = Class.forName(className);
if(!Runtime.class.isAssignableFrom(c)) {
System.err.println(className + " isn't a MIPS compiled class");
System.exit(1);
}
rt = (Runtime) c.newInstance();
//}
rt.setCallJavaCB(new Runtime.CallJavaCB() {
public int call(int a, int b, int c, int d) {
switch(a) {
case 1:
/*static void JAVANVM_DisplayScreen(void *as){
_call_java(1, (int)as, 0, 0);
}*/
canvas.displayScreen(rt,b);
return 0;
case 2:
/*static void JAVANVM_InitPalette(void *ct){
_call_java(2, (int)ct, 0, 0);
}*/
canvas.initPalette(rt, b);
return 0;
case 3:
/*static int JAVANVM_Kbhits(int key, int loc){
return _call_java(3, key, loc, 0);
}*/
return canvas.getKbhits(b, c);
case 4:
/*static int JAVANVM_PollKeyEvent(void *event){
return _call_java(4, (int)event, 0, 0);
}*/
return canvas.pollKeyEvent(rt, b);
case 5:
/*static int JAVANVM_GetWindowClosed(void){
return _call_java(5, 0, 0, 0);
}*/
return canvas.getWindowClosed();
case 6:
/*static int JAVANVM_Sleep(int millis){
return _call_java(6, millis, 0, 0);
}*/
try {
Thread.sleep((long)b);
} catch(Exception e) {}
return 0;
case 7:
/*static int JAVANVM_InitGraphics(void *config){
return _call_java(7, (int)config, 0, 0);
}*/
int scaleh = 2;
int scalew = 2;
int atari_width = 384;
int atari_height = 240;
int atari_visible_width = 336;
int atari_left_margin = 24;
try {
scalew = rt.memRead(b+4*0);
scaleh = rt.memRead(b+4*1);
atari_width = rt.memRead(b+4*2);
atari_height = rt.memRead(b+4*3);
atari_visible_width = rt.memRead(b+4*4);
atari_left_margin = rt.memRead(b+4*5);
} catch(Exception e) {
System.err.println(e);
}
initGraphics(scaleh,scalew,atari_width,atari_height,atari_visible_width,atari_left_margin);
return 0;
case 8:
/*static int JAVANVM_InitSound(void *config){
return _call_java(8, (int)config, 0, 0);
}*/
int sampleRate = 44100;
int bitsPerSample = 16;
int channels = 2;
boolean isSigned = true;
boolean bigEndian = true;
int bufferSize = 1024;
try {
sampleRate = rt.memRead(b+4*0);
bitsPerSample = rt.memRead(b+4*1);
channels = rt.memRead(b+4*2);
isSigned = (rt.memRead(b+4*3) != 0);
bigEndian = (rt.memRead(b+4*4) != 0);
bufferSize = rt.memRead(b+4*5);
} catch(Exception e) {
System.err.println(e);
return 0; // Indicate failure
}
initSound(sampleRate, bitsPerSample, channels, isSigned, bigEndian, bufferSize);
return line.getBufferSize();
case 9:
/*static int JAVANVM_SoundExit(void){
return _call_java(9, 0, 0, 0);
}*/
line.close();
return 0;
case 10:
/*static int JAVANVM_SoundAvailable(void){
return _call_java(9, 0, 0, 0);
}*/
return line.available();
case 11:
/*static int JAVANVM_SoundWrite(void const *buffer,int len){
return _call_java(10, (int)buffer, len, 0);
}*/
try {
rt.copyin(b,soundBuffer,c);
} catch(Exception e) {
System.err.println(e);
}
line.write(soundBuffer,0,c);
return 0;
case 12:
/*static int JAVANVM_SoundPause(void){
return _call_java(11, 0, 0, 0);
}*/
line.stop();
return 0;
case 13:
/*static int JAVANVM_SoundContinue(void){
return _call_java(12, 0, 0, 0);
}*/
line.start();
return 0;
case 14:
/*static int JAVANVM_CheckThreadStatus(void){
return _call_java(13, 0, 0, 0);
}*/
if (isApplet && threadSuspended) {
if (line!=null) line.stop();
try {
synchronized(this) {
while (threadSuspended && thread == thisThread) {
wait();
}
}
} catch (InterruptedException e) {}
if (thread != thisThread) {
return 1;
}
if (line!=null) line.start();
}
return 0;
default:
return 0;
}
}
});
if (isApplet) {
}
//Run the emulator:
if (!isApplet) {
System.exit(rt.run(appArgs));
} else {
rt.run(appArgs);
}
} catch(Exception e) {
System.err.println(e);
}
}
}
/*
vim:ts=4:sw=4:
*/
+807
View File
@@ -0,0 +1,807 @@
/*
* javanvm/input.c - NestedVM-specific port code - input device support
*
* Copyright (c) 2001-2002 Jacek Poplawski (original atari_sdl.c)
* Copyright (c) 2007-2008 Perry McFarlane (javanvm port)
* Copyright (C) 2001-2008 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
* Atari800 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.
* Atari800 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 Atari800; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "javanvm/input.h"
#include "akey.h"
#include "atari.h"
#include "binload.h"
#include "../input.h"
#include "platform.h"
#include "ui.h"
#include "javanvm/javanvm.h"
/* joystick emulation */
/* a runtime switch for the kbd_joy_X_enabled vars is in the UI */
int kbd_joy_0_enabled = TRUE; /* enabled by default, doesn't hurt */
int kbd_joy_1_enabled = FALSE; /* disabled, would steal normal keys */
static int KBD_TRIG_0 = VK_CONTROL;
static int KBD_TRIG_0_LOC = KEY_LOCATION_LEFT;
static int KBD_STICK_0_LEFT = VK_NUMPAD4;
static int KBD_STICK_0_LEFT_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_RIGHT = VK_NUMPAD6;
static int KBD_STICK_0_RIGHT_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_DOWN = VK_NUMPAD2;
static int KBD_STICK_0_DOWN_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_UP = VK_NUMPAD8;
static int KBD_STICK_0_UP_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_LEFTUP = VK_NUMPAD7;
static int KBD_STICK_0_LEFTUP_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_RIGHTUP = VK_NUMPAD9;
static int KBD_STICK_0_RIGHTUP_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_LEFTDOWN = VK_NUMPAD1;
static int KBD_STICK_0_LEFTDOWN_LOC = KEY_LOCATION_NUMPAD;
static int KBD_STICK_0_RIGHTDOWN = VK_NUMPAD3;
static int KBD_STICK_0_RIGHTDOWN_LOC = KEY_LOCATION_NUMPAD;
static int KBD_TRIG_1 = VK_TAB;
static int KBD_TRIG_1_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_LEFT = VK_A;
static int KBD_STICK_1_LEFT_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_RIGHT = VK_D;
static int KBD_STICK_1_RIGHT_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_DOWN = VK_X;
static int KBD_STICK_1_DOWN_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_UP = VK_W;
static int KBD_STICK_1_UP_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_LEFTUP = VK_Q;
static int KBD_STICK_1_LEFTUP_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_RIGHTUP = VK_E;
static int KBD_STICK_1_RIGHTUP_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_LEFTDOWN = VK_Z;
static int KBD_STICK_1_LEFTDOWN_LOC = KEY_LOCATION_STANDARD;
static int KBD_STICK_1_RIGHTDOWN = VK_C;
static int KBD_STICK_1_RIGHTDOWN_LOC = KEY_LOCATION_STANDARD;
static int swap_joysticks = 0;
/* These functions call the NestedVM runtime */
static int JAVANVM_Kbhits(int key, int loc)
{
return _call_java(JAVANVM_FUN_Kbhits, key, loc, 0);
}
static int JAVANVM_PollKeyEvent(void *event)
{
return _call_java(JAVANVM_FUN_PollKeyEvent, (int)event, 0, 0);
}
static int JAVANVM_GetWindowClosed(void)
{
return _call_java(JAVANVM_FUN_GetWindowClosed, 0, 0, 0);
}
int PLATFORM_Keyboard(void)
{
static int lastkey = 0, key_pressed = 0, key_control = 0;
static int lastuni = 0;
static int lastloc = KEY_LOCATION_UNKNOWN;
int shiftctrl = 0;
int event[JAVANVM_KeyEventSIZE];
/* Exit if the user closed the window */
if (JAVANVM_GetWindowClosed()) {
return AKEY_EXIT;
}
if (JAVANVM_PollKeyEvent(event)) {
switch (event[JAVANVM_KeyEventType]) {
case KEY_PRESSED:
lastkey = event[JAVANVM_KeyEventKeyCode];
lastuni = event[JAVANVM_KeyEventKeyChar];
lastloc = event[JAVANVM_KeyEventKeyLocation];
key_pressed = 1;
break;
case KEY_RELEASED:
lastkey = event[JAVANVM_KeyEventKeyCode];
lastuni = 0;
key_pressed = 0;
break;
}
}
else if (!key_pressed)
return AKEY_NONE;
UI_alt_function = -1;
if (JAVANVM_Kbhits(VK_ALT,KEY_LOCATION_LEFT)) {
if (key_pressed) {
switch (lastkey) {
case VK_F:
key_pressed = 0;
/*SwitchFullscreen();*/
break;
case VK_G:
key_pressed = 0;
/*SwitchWidth();*/
break;
case VK_B:
key_pressed = 0;
/*SwitchBW();*/
break;
case VK_J:
key_pressed = 0;
/*SwapJoysticks();*/
break;
case VK_R:
UI_alt_function = UI_MENU_RUN;
break;
case VK_Y:
UI_alt_function = UI_MENU_SYSTEM;
break;
case VK_O:
UI_alt_function = UI_MENU_SOUND;
break;
case VK_W:
UI_alt_function = UI_MENU_SOUND_RECORDING;
break;
case VK_A:
UI_alt_function = UI_MENU_ABOUT;
break;
case VK_S:
UI_alt_function = UI_MENU_SAVESTATE;
break;
case VK_D:
UI_alt_function = UI_MENU_DISK;
break;
case VK_L:
UI_alt_function = UI_MENU_LOADSTATE;
break;
case VK_C:
UI_alt_function = UI_MENU_CARTRIDGE;
break;
case VK_T:
UI_alt_function = UI_MENU_CASSETTE;
break;
case VK_BACK_SLASH:
return AKEY_PBI_BB_MENU;
break;
break;
}
}
if (UI_alt_function != -1) {
key_pressed = 0;
return AKEY_UI;
}
}
/* SHIFT STATE */
if ((JAVANVM_Kbhits(VK_SHIFT,KEY_LOCATION_LEFT)) || (JAVANVM_Kbhits(VK_SHIFT,KEY_LOCATION_RIGHT)))
INPUT_key_shift = 1;
else
INPUT_key_shift = 0;
/* CONTROL STATE */
if ((JAVANVM_Kbhits(VK_CONTROL,KEY_LOCATION_LEFT)) || (JAVANVM_Kbhits(VK_CONTROL,KEY_LOCATION_RIGHT)))
key_control = 1;
else
key_control = 0;
BINLOAD_pause_loading = FALSE;
/* OPTION / SELECT / START keys */
INPUT_key_consol = INPUT_CONSOL_NONE;
if (JAVANVM_Kbhits(VK_F2,KEY_LOCATION_STANDARD))
INPUT_key_consol &= (~INPUT_CONSOL_OPTION);
if (JAVANVM_Kbhits(VK_F3,KEY_LOCATION_STANDARD))
INPUT_key_consol &= (~INPUT_CONSOL_SELECT);
if (JAVANVM_Kbhits(VK_F4,KEY_LOCATION_STANDARD))
INPUT_key_consol &= (~INPUT_CONSOL_START);
if (key_pressed == 0)
return AKEY_NONE;
/* Handle movement and special keys. */
switch (lastkey) {
case VK_F1:
key_pressed = 0;
return AKEY_UI;
case VK_F5:
key_pressed = 0;
return INPUT_key_shift ? AKEY_COLDSTART : AKEY_WARMSTART;
case VK_F8:
key_pressed = 0;
return (PLATFORM_Exit(1) ? AKEY_NONE : AKEY_EXIT);
case VK_F9:
return AKEY_EXIT;
case VK_F10:
key_pressed = 0;
return INPUT_key_shift ? AKEY_SCREENSHOT_INTERLACE : AKEY_SCREENSHOT_INTERLACE;
case VK_F12:
key_pressed = 0;
return AKEY_TURBO;
}
/* keyboard joysticks: don't pass the keypresses to emulation
* as some games pause on a keypress (River Raid, Bruce Lee)
*/
#define LQE(x) (lastkey == KBD_##x && lastloc == KBD_##x##_LOC)
if (!UI_is_active && kbd_joy_0_enabled) {
if (LQE(STICK_0_LEFT) || LQE(STICK_0_RIGHT) ||
LQE(STICK_0_UP) || LQE(STICK_0_DOWN) ||
LQE(STICK_0_LEFTUP) || LQE(STICK_0_LEFTDOWN) ||
LQE(STICK_0_RIGHTUP) || LQE(STICK_0_RIGHTDOWN) ||
LQE(TRIG_0)) {
key_pressed = 0;
return AKEY_NONE;
}
}
if (!UI_is_active && kbd_joy_1_enabled) {
if (LQE(STICK_1_LEFT) || LQE(STICK_1_RIGHT) ||
LQE(STICK_1_UP) || LQE(STICK_1_DOWN) ||
LQE(STICK_1_LEFTUP) || LQE(STICK_1_LEFTDOWN) ||
LQE(STICK_1_RIGHTUP) || LQE(STICK_1_RIGHTDOWN) ||
LQE(TRIG_1)) {
key_pressed = 0;
return AKEY_NONE;
}
}
#undef LQE
if (INPUT_key_shift)
shiftctrl ^= AKEY_SHFT;
if (Atari800_machine_type == Atari800_MACHINE_5200 && !UI_is_active && lastloc == KEY_LOCATION_STANDARD) {
if (lastkey == VK_F4)
return AKEY_5200_START ^ shiftctrl;
switch (lastuni) {
case 'p':
return AKEY_5200_PAUSE ^ shiftctrl;
case 'r':
return AKEY_5200_RESET ^ shiftctrl;
case '0':
return AKEY_5200_0 ^ shiftctrl;
case '1':
return AKEY_5200_1 ^ shiftctrl;
case '2':
return AKEY_5200_2 ^ shiftctrl;
case '3':
return AKEY_5200_3 ^ shiftctrl;
case '4':
return AKEY_5200_4 ^ shiftctrl;
case '5':
return AKEY_5200_5 ^ shiftctrl;
case '6':
return AKEY_5200_6 ^ shiftctrl;
case '7':
return AKEY_5200_7 ^ shiftctrl;
case '8':
return AKEY_5200_8 ^ shiftctrl;
case '9':
return AKEY_5200_9 ^ shiftctrl;
case '#':
case '=':
return AKEY_5200_HASH ^ shiftctrl;
case '*':
return AKEY_5200_ASTERISK ^ shiftctrl;
}
return AKEY_NONE;
}
if (key_control)
shiftctrl ^= AKEY_CTRL;
if (lastloc == KEY_LOCATION_STANDARD) switch (lastkey) {
case VK_BACK_QUOTE:
return AKEY_ATARI ^ shiftctrl;
case VK_END:
case VK_F6:
return AKEY_HELP ^ shiftctrl;
case VK_PAGE_DOWN:
return AKEY_F2 | AKEY_SHFT;
case VK_PAGE_UP:
return AKEY_F1 | AKEY_SHFT;
case VK_HOME:
return (key_control ? AKEY_LESS : AKEY_CLEAR)|shiftctrl;
case VK_PAUSE:
case VK_F7:
if (BINLOAD_wait_active) {
BINLOAD_pause_loading = TRUE;
return AKEY_NONE;
}
else
return AKEY_BREAK;
case VK_CAPS_LOCK:
if (INPUT_key_shift)
return AKEY_CAPSLOCK|shiftctrl;
else
return AKEY_CAPSTOGGLE|shiftctrl;
case VK_SPACE:
return AKEY_SPACE ^ shiftctrl;
case VK_BACK_SPACE:
return AKEY_BACKSPACE|shiftctrl;
case VK_ENTER:
return AKEY_RETURN ^ shiftctrl;
case VK_LEFT:
return (INPUT_key_shift ? AKEY_PLUS : AKEY_LEFT) ^ shiftctrl;
case VK_RIGHT:
return (INPUT_key_shift ? AKEY_ASTERISK : AKEY_RIGHT) ^ shiftctrl;
case VK_UP:
return (INPUT_key_shift ? AKEY_MINUS : AKEY_UP) ^ shiftctrl;
case VK_DOWN:
return (INPUT_key_shift ? AKEY_EQUAL : AKEY_DOWN) ^ shiftctrl;
case VK_ESCAPE:
return AKEY_ESCAPE ^ shiftctrl;
case VK_TAB:
return AKEY_TAB ^ shiftctrl;
case VK_DELETE:
if (INPUT_key_shift)
return AKEY_DELETE_LINE|shiftctrl;
else
return AKEY_DELETE_CHAR;
case VK_INSERT:
if (INPUT_key_shift)
return AKEY_INSERT_LINE|shiftctrl;
else
return AKEY_INSERT_CHAR;
}
if (INPUT_cx85 && lastloc == KEY_LOCATION_NUMPAD) switch (lastkey) {
case VK_NUMPAD1:
return AKEY_CX85_1;
case VK_NUMPAD2:
return AKEY_CX85_2;
case VK_NUMPAD3:
return AKEY_CX85_3;
case VK_NUMPAD4:
return AKEY_CX85_4;
case VK_NUMPAD5:
return AKEY_CX85_5;
case VK_NUMPAD6:
return AKEY_CX85_6;
case VK_NUMPAD7:
return AKEY_CX85_7;
case VK_NUMPAD8:
return AKEY_CX85_8;
case VK_NUMPAD9:
return AKEY_CX85_9;
case VK_NUMPAD0:
return AKEY_CX85_0;
case VK_DECIMAL:
return AKEY_CX85_PERIOD;
case VK_SUBTRACT:
return AKEY_CX85_MINUS;
case VK_ENTER:
return AKEY_CX85_PLUS_ENTER;
case VK_DIVIDE:
return (key_control ? AKEY_CX85_ESCAPE : AKEY_CX85_NO);
case VK_MULTIPLY:
return AKEY_CX85_DELETE;
case VK_ADD:
return AKEY_CX85_YES;
}
/* Handle CTRL-0 to CTRL-9 and others */
if (key_control && lastloc == KEY_LOCATION_STANDARD) {
switch(lastuni) {
case '.':
return AKEY_FULLSTOP|shiftctrl;
case ',':
return AKEY_COMMA|shiftctrl;
case ';':
return AKEY_SEMICOLON|shiftctrl;
case '/':
return AKEY_SLASH|shiftctrl;
}
switch (lastkey) {
case VK_BACK_SLASH:
/* work-around for Windows */
return AKEY_ESCAPE|shiftctrl;
case VK_PERIOD:
return AKEY_FULLSTOP|shiftctrl;
case VK_COMMA:
return AKEY_COMMA|shiftctrl;
case VK_SEMICOLON:
return AKEY_SEMICOLON|shiftctrl;
case VK_SLASH:
return AKEY_SLASH|shiftctrl;
case VK_0:
return AKEY_CTRL_0|shiftctrl;
case VK_1:
return AKEY_CTRL_1|shiftctrl;
case VK_2:
return AKEY_CTRL_2|shiftctrl;
case VK_3:
return AKEY_CTRL_3|shiftctrl;
case VK_4:
return AKEY_CTRL_4|shiftctrl;
case VK_5:
return AKEY_CTRL_5|shiftctrl;
case VK_6:
return AKEY_CTRL_6|shiftctrl;
case VK_7:
return AKEY_CTRL_7|shiftctrl;
case VK_8:
return AKEY_CTRL_8|shiftctrl;
case VK_9:
return AKEY_CTRL_9|shiftctrl;
}
}
/* Host Caps Lock will make lastuni switch case, so prevent this*/
if(lastuni>='A' && lastuni <= 'Z' && !INPUT_key_shift) lastuni += 0x20;
if(lastuni>='a' && lastuni <= 'z' && INPUT_key_shift) lastuni -= 0x20;
/* Uses only UNICODE translation, no shift states (this was added to
* support non-US keyboard layouts)*/
if (lastloc == KEY_LOCATION_STANDARD) {
switch (lastuni) {
case 1:
return AKEY_CTRL_a|shiftctrl;
case 2:
return AKEY_CTRL_b|shiftctrl;
case 3:
return AKEY_CTRL_c|shiftctrl;
case 4:
return AKEY_CTRL_d|shiftctrl;
case 5:
return AKEY_CTRL_e|shiftctrl;
case 6:
return AKEY_CTRL_f|shiftctrl;
case 7:
return AKEY_CTRL_g|shiftctrl;
case 8:
return AKEY_CTRL_h|shiftctrl;
case 9:
return AKEY_CTRL_i|shiftctrl;
case 10:
return AKEY_CTRL_j|shiftctrl;
case 11:
return AKEY_CTRL_k|shiftctrl;
case 12:
return AKEY_CTRL_l|shiftctrl;
case 13:
return AKEY_CTRL_m|shiftctrl;
case 14:
return AKEY_CTRL_n|shiftctrl;
case 15:
return AKEY_CTRL_o|shiftctrl;
case 16:
return AKEY_CTRL_p|shiftctrl;
case 17:
return AKEY_CTRL_q|shiftctrl;
case 18:
return AKEY_CTRL_r|shiftctrl;
case 19:
return AKEY_CTRL_s|shiftctrl;
case 20:
return AKEY_CTRL_t|shiftctrl;
case 21:
return AKEY_CTRL_u|shiftctrl;
case 22:
return AKEY_CTRL_v|shiftctrl;
case 23:
return AKEY_CTRL_w|shiftctrl;
case 24:
return AKEY_CTRL_x|shiftctrl;
case 25:
return AKEY_CTRL_y|shiftctrl;
case 26:
return AKEY_CTRL_z|shiftctrl;
case 'A':
return AKEY_A;
case 'B':
return AKEY_B;
case 'C':
return AKEY_C;
case 'D':
return AKEY_D;
case 'E':
return AKEY_E;
case 'F':
return AKEY_F;
case 'G':
return AKEY_G;
case 'H':
return AKEY_H;
case 'I':
return AKEY_I;
case 'J':
return AKEY_J;
case 'K':
return AKEY_K;
case 'L':
return AKEY_L;
case 'M':
return AKEY_M;
case 'N':
return AKEY_N;
case 'O':
return AKEY_O;
case 'P':
return AKEY_P;
case 'Q':
return AKEY_Q;
case 'R':
return AKEY_R;
case 'S':
return AKEY_S;
case 'T':
return AKEY_T;
case 'U':
return AKEY_U;
case 'V':
return AKEY_V;
case 'W':
return AKEY_W;
case 'X':
return AKEY_X;
case 'Y':
return AKEY_Y;
case 'Z':
return AKEY_Z;
case ':':
return AKEY_COLON;
case '!':
return AKEY_EXCLAMATION;
case '@':
return AKEY_AT;
case '#':
return AKEY_HASH;
case '$':
return AKEY_DOLLAR;
case '%':
return AKEY_PERCENT;
case '^':
return AKEY_CARET;
case '&':
return AKEY_AMPERSAND;
case '*':
return AKEY_ASTERISK;
case '(':
return AKEY_PARENLEFT;
case ')':
return AKEY_PARENRIGHT;
case '+':
return AKEY_PLUS;
case '_':
return AKEY_UNDERSCORE;
case '"':
return AKEY_DBLQUOTE;
case '?':
return AKEY_QUESTION;
case '<':
return AKEY_LESS;
case '>':
return AKEY_GREATER;
case 'a':
return AKEY_a;
case 'b':
return AKEY_b;
case 'c':
return AKEY_c;
case 'd':
return AKEY_d;
case 'e':
return AKEY_e;
case 'f':
return AKEY_f;
case 'g':
return AKEY_g;
case 'h':
return AKEY_h;
case 'i':
return AKEY_i;
case 'j':
return AKEY_j;
case 'k':
return AKEY_k;
case 'l':
return AKEY_l;
case 'm':
return AKEY_m;
case 'n':
return AKEY_n;
case 'o':
return AKEY_o;
case 'p':
return AKEY_p;
case 'q':
return AKEY_q;
case 'r':
return AKEY_r;
case 's':
return AKEY_s;
case 't':
return AKEY_t;
case 'u':
return AKEY_u;
case 'v':
return AKEY_v;
case 'w':
return AKEY_w;
case 'x':
return AKEY_x;
case 'y':
return AKEY_y;
case 'z':
return AKEY_z;
case ';':
return AKEY_SEMICOLON;
case '0':
return AKEY_0;
case '1':
return AKEY_1;
case '2':
return AKEY_2;
case '3':
return AKEY_3;
case '4':
return AKEY_4;
case '5':
return AKEY_5;
case '6':
return AKEY_6;
case '7':
return AKEY_7;
case '8':
return AKEY_8;
case '9':
return AKEY_9;
case ',':
return AKEY_COMMA;
case '.':
return AKEY_FULLSTOP;
case '=':
return AKEY_EQUAL;
case '-':
return AKEY_MINUS;
case '\'':
return AKEY_QUOTE;
case '/':
return AKEY_SLASH;
case '\\':
return AKEY_BACKSLASH;
case '[':
return AKEY_BRACKETLEFT;
case ']':
return AKEY_BRACKETRIGHT;
case '|':
return AKEY_BAR;
}
}
return AKEY_NONE;
}
int JAVANVM_INPUT_Initialise(int *argc, char *argv[])
{
if (INPUT_cx85) {
kbd_joy_0_enabled = FALSE;
}
return TRUE;
}
static void do_platform_PORT(UBYTE *s0, UBYTE *s1)
{
#define KBHITS(x) (JAVANVM_Kbhits(x,x##_LOC))
int stick0, stick1;
stick0 = stick1 = INPUT_STICK_CENTRE;
if (kbd_joy_0_enabled) {
if (KBHITS(KBD_STICK_0_LEFT))
stick0 = INPUT_STICK_LEFT;
if (KBHITS(KBD_STICK_0_RIGHT))
stick0 = INPUT_STICK_RIGHT;
if (KBHITS(KBD_STICK_0_UP))
stick0 = INPUT_STICK_FORWARD;
if (KBHITS(KBD_STICK_0_DOWN))
stick0 = INPUT_STICK_BACK;
if ((KBHITS(KBD_STICK_0_LEFTUP))
|| ((KBHITS(KBD_STICK_0_LEFT)) && (KBHITS(KBD_STICK_0_UP))))
stick0 = INPUT_STICK_UL;
if ((KBHITS(KBD_STICK_0_LEFTDOWN))
|| ((KBHITS(KBD_STICK_0_LEFT)) && (KBHITS(KBD_STICK_0_DOWN))))
stick0 = INPUT_STICK_LL;
if ((KBHITS(KBD_STICK_0_RIGHTUP))
|| ((KBHITS(KBD_STICK_0_RIGHT)) && (KBHITS(KBD_STICK_0_UP))))
stick0 = INPUT_STICK_UR;
if ((KBHITS(KBD_STICK_0_RIGHTDOWN))
|| ((KBHITS(KBD_STICK_0_RIGHT)) && (KBHITS(KBD_STICK_0_DOWN))))
stick0 = INPUT_STICK_LR;
}
if (kbd_joy_1_enabled) {
if (KBHITS(KBD_STICK_1_LEFT))
stick1 = INPUT_STICK_LEFT;
if (KBHITS(KBD_STICK_1_RIGHT))
stick1 = INPUT_STICK_RIGHT;
if (KBHITS(KBD_STICK_1_UP))
stick1 = INPUT_STICK_FORWARD;
if (KBHITS(KBD_STICK_1_DOWN))
stick1 = INPUT_STICK_BACK;
if ((KBHITS(KBD_STICK_1_LEFTUP))
|| ((KBHITS(KBD_STICK_1_LEFT)) && (KBHITS(KBD_STICK_1_UP))))
stick1 = INPUT_STICK_UL;
if ((KBHITS(KBD_STICK_1_LEFTDOWN))
|| ((KBHITS(KBD_STICK_1_LEFT)) && (KBHITS(KBD_STICK_1_DOWN))))
stick1 = INPUT_STICK_LL;
if ((KBHITS(KBD_STICK_1_RIGHTUP))
|| ((KBHITS(KBD_STICK_1_RIGHT)) && (KBHITS(KBD_STICK_1_UP))))
stick1 = INPUT_STICK_UR;
if ((KBHITS(KBD_STICK_1_RIGHTDOWN))
|| ((KBHITS(KBD_STICK_1_RIGHT)) && (KBHITS(KBD_STICK_1_DOWN))))
stick1 = INPUT_STICK_LR;
}
if (swap_joysticks) {
*s1 = stick0;
*s0 = stick1;
}
else {
*s0 = stick0;
*s1 = stick1;
}
}
static void do_platform_TRIG(UBYTE *t0, UBYTE *t1)
{
int trig0, trig1, i;
trig0 = trig1 = 1;
if (kbd_joy_0_enabled) {
trig0 = KBHITS(KBD_TRIG_0) ? 0 : 1;
}
if (kbd_joy_1_enabled) {
trig1 = KBHITS(KBD_TRIG_1) ? 0 : 1;
}
if (swap_joysticks) {
*t1 = trig0;
*t0 = trig1;
}
else {
*t0 = trig0;
*t1 = trig1;
}
}
#undef KBHITS
int PLATFORM_PORT(int num)
{
#ifndef DONT_DISPLAY
if (num == 0) {
UBYTE a, b;
do_platform_PORT(&a, &b);
return (b << 4) | (a & 0x0f);
}
#endif
return 0xff;
}
int PLATFORM_TRIG(int num)
{
#ifndef DONT_DISPLAY
UBYTE a, b;
do_platform_TRIG(&a, &b);
switch (num) {
case 0:
return a;
case 1:
return b;
default:
break;
}
#endif
return 1;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef JAVANVM_INPUT_H_
#define JAVANVM_INPUT_H_
int JAVANVM_INPUT_Initialise(int *argc, char *argv[]);
#endif /* JAVANVM_INPUT_H_ */
+276
View File
@@ -0,0 +1,276 @@
/*
* javanvm/javanvm.h - NestedVM-specific port code - C<->Java interface
*
* Copyright (c) 2001-2002 Jacek Poplawski (original atari_sdl.c)
* Copyright (c) 2007-2008 Perry McFarlane (javanvm port)
* Copyright (C) 2001-2013 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
* Atari800 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.
* Atari800 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 Atari800; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef JAVANVM_H_
#define JAVANVM_H_
extern int _call_java(int a, int b, int c, int d);
enum {
JAVANVM_FUN_DisplayScreen = 1,
JAVANVM_FUN_InitPalette = 2,
JAVANVM_FUN_Kbhits = 3,
JAVANVM_FUN_PollKeyEvent = 4,
JAVANVM_FUN_GetWindowClosed = 5,
JAVANVM_FUN_Sleep = 6,
JAVANVM_FUN_InitGraphics = 7,
JAVANVM_FUN_InitSound = 8,
JAVANVM_FUN_SoundExit = 9,
JAVANVM_FUN_SoundAvailable = 10,
JAVANVM_FUN_SoundWrite = 11,
JAVANVM_FUN_SoundPause = 12,
JAVANVM_FUN_SoundContinue = 13,
JAVANVM_FUN_CheckThreadStatus = 14
};
/* These constants are for use with arrays passed to and from the NestedVM runtime */
enum {
JAVANVM_KeyEventType = 0,
JAVANVM_KeyEventKeyCode = 1,
JAVANVM_KeyEventKeyChar = 2,
JAVANVM_KeyEventKeyLocation = 3,
JAVANVM_KeyEventSIZE = 4
};
enum {
JAVANVM_InitGraphicsScalew = 0,
JAVANVM_InitGraphicsScaleh = 1,
JAVANVM_InitGraphicsScreen_WIDTH = 2,
JAVANVM_InitGraphicsScreen_HEIGHT = 3,
JAVANVM_InitGraphicsATARI_VISIBLE_WIDTH = 4,
JAVANVM_InitGraphicsATARI_LEFT_MARGIN = 5,
JAVANVM_InitGraphicsSIZE = 6
};
enum {
JAVANVM_InitSoundSampleRate = 0,
JAVANVM_InitSoundBitsPerSample = 1,
JAVANVM_InitSoundChannels = 2,
JAVANVM_InitSoundSigned = 3,
JAVANVM_InitSoundBigEndian = 4,
JAVANVM_InitSoundBufferSize = 5,
JAVANVM_InitSoundSIZE = 6
};
/* Java Keys */
enum {
CHAR_UNDEFINED = 65535,
KEY_FIRST = 400,
KEY_LAST = 402,
KEY_LOCATION_LEFT = 2,
KEY_LOCATION_NUMPAD = 4,
KEY_LOCATION_RIGHT = 3,
KEY_LOCATION_STANDARD = 1,
KEY_LOCATION_UNKNOWN = 0,
KEY_PRESSED = 401,
KEY_RELEASED = 402,
KEY_TYPED = 400,
VK_0 = 48,
VK_1 = 49,
VK_2 = 50,
VK_3 = 51,
VK_4 = 52,
VK_5 = 53,
VK_6 = 54,
VK_7 = 55,
VK_8 = 56,
VK_9 = 57,
VK_A = 65,
VK_ACCEPT = 30,
VK_ADD = 107,
VK_AGAIN = 65481,
VK_ALL_CANDIDATES = 256,
VK_ALPHANUMERIC = 240,
VK_ALT = 18,
VK_ALT_GRAPH = 65406,
VK_AMPERSAND = 150,
VK_ASTERISK = 151,
VK_AT = 512,
VK_B = 66,
VK_BACK_QUOTE = 192,
VK_BACK_SLASH = 92,
VK_BACK_SPACE = 8,
VK_BRACELEFT = 161,
VK_BRACERIGHT = 162,
VK_C = 67,
VK_CANCEL = 3,
VK_CAPS_LOCK = 20,
VK_CIRCUMFLEX = 514,
VK_CLEAR = 12,
VK_CLOSE_BRACKET = 93,
VK_CODE_INPUT = 258,
VK_COLON = 513,
VK_COMMA = 44,
VK_COMPOSE = 65312,
VK_CONTROL = 17,
VK_CONVERT = 28,
VK_COPY = 65485,
VK_CUT = 65489,
VK_D = 68,
VK_DEAD_ABOVEDOT = 134,
VK_DEAD_ABOVERING = 136,
VK_DEAD_ACUTE = 129,
VK_DEAD_BREVE = 133,
VK_DEAD_CARON = 138,
VK_DEAD_CEDILLA = 139,
VK_DEAD_CIRCUMFLEX = 130,
VK_DEAD_DIAERESIS = 135,
VK_DEAD_DOUBLEACUTE = 137,
VK_DEAD_GRAVE = 128,
VK_DEAD_IOTA = 141,
VK_DEAD_MACRON = 132,
VK_DEAD_OGONEK = 140,
VK_DEAD_SEMIVOICED_SOUND = 143,
VK_DEAD_TILDE = 131,
VK_DEAD_VOICED_SOUND = 142,
VK_DECIMAL = 110,
VK_DELETE = 127,
VK_DIVIDE = 111,
VK_DOLLAR = 515,
VK_DOWN = 40,
VK_E = 69,
VK_END = 35,
VK_ENTER = 10,
VK_EQUALS = 61,
VK_ESCAPE = 27,
VK_EURO_SIGN = 516,
VK_EXCLAMATION_MARK = 517,
VK_F = 70,
VK_F1 = 112,
VK_F10 = 121,
VK_F11 = 122,
VK_F12 = 123,
VK_F13 = 61440,
VK_F14 = 61441,
VK_F15 = 61442,
VK_F16 = 61443,
VK_F17 = 61444,
VK_F18 = 61445,
VK_F19 = 61446,
VK_F2 = 113,
VK_F20 = 61447,
VK_F21 = 61448,
VK_F22 = 61449,
VK_F23 = 61450,
VK_F24 = 61451,
VK_F3 = 114,
VK_F4 = 115,
VK_F5 = 116,
VK_F6 = 117,
VK_F7 = 118,
VK_F8 = 119,
VK_F9 = 120,
VK_FINAL = 24,
VK_FIND = 65488,
VK_FULL_WIDTH = 243,
VK_G = 71,
VK_GREATER = 160,
VK_H = 72,
VK_HALF_WIDTH = 244,
VK_HELP = 156,
VK_HIRAGANA = 242,
VK_HOME = 36,
VK_I = 73,
VK_INPUT_METHOD_ON_OFF = 263,
VK_INSERT = 155,
VK_INVERTED_EXCLAMATION_MARK = 518,
VK_J = 74,
VK_JAPANESE_HIRAGANA = 260,
VK_JAPANESE_KATAKANA = 259,
VK_JAPANESE_ROMAN = 261,
VK_K = 75,
VK_KANA = 21,
VK_KANA_LOCK = 262,
VK_KANJI = 25,
VK_KATAKANA = 241,
VK_KP_DOWN = 225,
VK_KP_LEFT = 226,
VK_KP_RIGHT = 227,
VK_KP_UP = 224,
VK_L = 76,
VK_LEFT = 37,
VK_LEFT_PARENTHESIS = 519,
VK_LESS = 153,
VK_M = 77,
VK_META = 157,
VK_MINUS = 45,
VK_MODECHANGE = 31,
VK_MULTIPLY = 106,
VK_N = 78,
VK_NONCONVERT = 29,
VK_NUM_LOCK = 144,
VK_NUMBER_SIGN = 520,
VK_NUMPAD0 = 96,
VK_NUMPAD1 = 97,
VK_NUMPAD2 = 98,
VK_NUMPAD3 = 99,
VK_NUMPAD4 = 100,
VK_NUMPAD5 = 101,
VK_NUMPAD6 = 102,
VK_NUMPAD7 = 103,
VK_NUMPAD8 = 104,
VK_NUMPAD9 = 105,
VK_O = 79,
VK_OPEN_BRACKET = 91,
VK_P = 80,
VK_PAGE_DOWN = 34,
VK_PAGE_UP = 33,
VK_PASTE = 65487,
VK_PAUSE = 19,
VK_PERIOD = 46,
VK_PLUS = 521,
VK_PREVIOUS_CANDIDATE = 257,
VK_PRINTSCREEN = 154,
VK_PROPS = 65482,
VK_Q = 81,
VK_QUOTE = 222,
VK_QUOTEDBL = 152,
VK_R = 82,
VK_RIGHT = 39,
VK_RIGHT_PARENTHESIS = 522,
VK_ROMAN_CHARACTERS = 245,
VK_S = 83,
VK_SCROLL_LOCK = 145,
VK_SEMICOLON = 59,
VK_SEPARATER = 108,
VK_SEPARATOR = 108,
VK_SHIFT = 16,
VK_SLASH = 47,
VK_SPACE = 32,
VK_STOP = 65480,
VK_SUBTRACT = 109,
VK_T = 84,
VK_TAB = 9,
VK_U = 85,
VK_UNDEFINED = 0,
VK_UNDERSCORE = 523,
VK_UNDO = 65483,
VK_UP = 38,
VK_V = 86,
VK_W = 87,
VK_X = 88,
VK_Y = 89,
VK_Z = 90
};
#endif /* JAVANVM_H_ */
+106
View File
@@ -0,0 +1,106 @@
/*
* javanvm/main.c - NestedVM-specific port code - main interface
*
* Copyright (c) 2001-2002 Jacek Poplawski (original atari_sdl.c)
* Copyright (c) 2007-2008 Perry McFarlane (javanvm port)
* Copyright (C) 2001-2008 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
*
* Atari800 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.
*
* Atari800 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 Atari800; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* Atari800 includes */
#include "../input.h"
#include "monitor.h"
#include "platform.h"
#include "sound.h"
#include "javanvm/javanvm.h"
/* These functions call the NestedVM runtime */
static int JAVANVM_Sleep(int millis)
{
return _call_java(JAVANVM_FUN_Sleep, millis, 0, 0);
}
static int JAVANVM_CheckThreadStatus(void)
{
return _call_java(JAVANVM_FUN_CheckThreadStatus, 0, 0, 0);
}
int PLATFORM_Initialise(int *argc, char *argv[])
{
if (!JAVANVM_VIDEO_Initialise(argc, argv)
#ifdef SOUND
|| !Sound_Initialise(argc, argv)
#endif
|| !JAVANVM_INPUT_Initialise(argc, argv))
return FALSE;
return TRUE;
}
int PLATFORM_Exit(int run_monitor){
int restart;
if (run_monitor) {
#ifdef SOUND
Sound_Pause();
#endif
restart = MONITOR_Run();
#ifdef SOUND
Sound_Continue();
#endif
}
else {
restart = FALSE;
}
if (restart) {
return 1;
}
return restart;
}
void PLATFORM_Sleep(double s){
JAVANVM_Sleep((int)(s*1e3));
}
int main(int argc, char **argv)
{
/* initialise Atari800 core */
if (!Atari800_Initialise(&argc, argv))
return 3;
/* main loop */
for (;;) {
INPUT_key_code = PLATFORM_Keyboard();
Atari800_Frame();
if (Atari800_display_screen)
PLATFORM_DisplayScreen();
if (JAVANVM_CheckThreadStatus()) {
Atari800_Exit(FALSE);
exit(0);
}
}
}
/*
vim:ts=4:sw=4:
*/
+110
View File
@@ -0,0 +1,110 @@
/*
* javanvm/sound.c - NestedVM-specific port code - sound output
*
* Copyright (c) 2001-2002 Jacek Poplawski (original atari_sdl.c)
* Copyright (c) 2007-2008 Perry McFarlane (javanvm port)
* Copyright (C) 2001-2013 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
* Atari800 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.
* Atari800 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 Atari800; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "atari.h"
#include "platform.h"
#include "sound.h"
#include "javanvm/javanvm.h"
/* These functions call the NestedVM runtime */
static int JAVANVM_InitSound(void *config)
{
return _call_java(JAVANVM_FUN_InitSound, (int)config, 0, 0);
}
static int JAVANVM_SoundExit(void)
{
return _call_java(JAVANVM_FUN_SoundExit, 0, 0, 0);
}
static int JAVANVM_SoundAvailable(void)
{
return _call_java(JAVANVM_FUN_SoundAvailable, 0, 0, 0);
}
static int JAVANVM_SoundWrite(void const *buffer,int len)
{
return _call_java(JAVANVM_FUN_SoundWrite, (int)buffer, len, 0);
}
static int JAVANVM_SoundPause(void)
{
return _call_java(JAVANVM_FUN_SoundPause, 0, 0, 0);
}
static int JAVANVM_SoundContinue(void)
{
return _call_java(JAVANVM_FUN_SoundContinue, 0, 0, 0);
}
int PLATFORM_SoundSetup(Sound_setup_t *setup)
{
int sconfig[JAVANVM_InitSoundSIZE];
int hw_buffer_size;
if (setup->buffer_frames == 0)
/* Set buffer_frames automatically. */
setup->buffer_frames = Sound_NextPow2(setup->freq * 4 / 50);
sconfig[JAVANVM_InitSoundSampleRate] = setup->freq;
sconfig[JAVANVM_InitSoundBitsPerSample] = setup->sample_size * 8;
sconfig[JAVANVM_InitSoundChannels] = setup->channels;
sconfig[JAVANVM_InitSoundSigned] = setup->sample_size == 2;
sconfig[JAVANVM_InitSoundBigEndian] = TRUE;
sconfig[JAVANVM_InitSoundBufferSize] = setup->buffer_frames * setup->sample_size * setup->channels;
hw_buffer_size = JAVANVM_InitSound((void *)sconfig);
if (hw_buffer_size == 0)
return FALSE;
setup->buffer_frames = hw_buffer_size / setup->sample_size / setup->channels;
return TRUE;
}
void PLATFORM_SoundExit(void)
{
JAVANVM_SoundExit();
}
void PLATFORM_SoundPause(void)
{
/* stop audio output */
JAVANVM_SoundPause();
}
void PLATFORM_SoundContinue(void)
{
/* start audio output */
JAVANVM_SoundContinue();
}
unsigned int PLATFORM_SoundAvailable(void)
{
return JAVANVM_SoundAvailable();
}
void PLATFORM_SoundWrite(UBYTE const *buffer, unsigned int size)
{
JAVANVM_SoundWrite(buffer, size);
}
+102
View File
@@ -0,0 +1,102 @@
/*
* javanvm/video.c - NestedVM-specific port code - video display
*
* Copyright (c) 2001-2002 Jacek Poplawski (original atari_sdl.c)
* Copyright (c) 2007-2008 Perry McFarlane (javanvm port)
* Copyright (C) 2001-2008 Atari800 development team (see DOC/CREDITS)
*
* This file is part of the Atari800 emulator project which emulates
* the Atari 400, 800, 800XL, 130XE, and 5200 8-bit computers.
* Atari800 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.
* Atari800 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 Atari800; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include "javanvm/video.h"
#include "colours.h"
#include "screen.h"
#include "log.h"
#include "platform.h"
#include "util.h"
#include "javanvm/javanvm.h"
/* These functions call the NestedVM runtime */
static void JAVANVM_DisplayScreen(void *as)
{
_call_java(JAVANVM_FUN_DisplayScreen, (int)as, 0, 0);
}
static void JAVANVM_InitPalette(void *ct)
{
_call_java(JAVANVM_FUN_InitPalette, (int)ct, 0, 0);
}
static int JAVANVM_InitGraphics(void *config)
{
return _call_java(JAVANVM_FUN_InitGraphics, (int)config, 0, 0);
}
void PLATFORM_PaletteUpdate(void)
{
JAVANVM_InitPalette((void *)&Colours_table[0]);
}
int JAVANVM_VIDEO_Initialise(int *argc, char *argv[])
{
int i, j;
int help_only = FALSE;
int scale = 2;
for (i = j = 1; i < *argc; i++) {
int i_a = (i + 1 < *argc); /* is argument available? */
int a_m = FALSE; /* error, argument missing! */
if (strcmp(argv[i], "-scale") == 0) {
if (i_a)
scale = Util_sscandec(argv[++i]);
else a_m = TRUE;
}
else {
if (strcmp(argv[i], "-help") == 0) {
help_only = TRUE;
Log_print("\t-scale <n> Scale width and height by <n>");
}
argv[j++] = argv[i];
}
if (a_m) {
Log_print("Missing argument for '%s'", argv[i]);
return FALSE;
}
}
*argc = j;
if (!help_only) {
int config[JAVANVM_InitGraphicsSIZE];
config[JAVANVM_InitGraphicsScalew] = scale;
config[JAVANVM_InitGraphicsScaleh] = scale;
config[JAVANVM_InitGraphicsScreen_WIDTH] = Screen_WIDTH;
config[JAVANVM_InitGraphicsScreen_HEIGHT] = Screen_HEIGHT;
config[JAVANVM_InitGraphicsATARI_VISIBLE_WIDTH] = 336;
config[JAVANVM_InitGraphicsATARI_LEFT_MARGIN] = 24;
JAVANVM_InitGraphics((void *)&config[0]);
JAVANVM_InitPalette((void *)&Colours_table[0]);
}
return TRUE;
}
void PLATFORM_DisplayScreen(void){
JAVANVM_DisplayScreen((void *)Screen_atari);
return;
}
+6
View File
@@ -0,0 +1,6 @@
#ifndef JAVANVM_VIDEO_H_
#define JAVANVM_VIDEO_H_
int JAVANVM_VIDEO_Initialise(int *argc, char *argv[]);
#endif /* JAVANVM_VIDEO_H_ */