tidy up
This commit is contained in:
parent
a2139c12ea
commit
4d3949def5
20
appleii.txt
20
appleii.txt
|
@ -21,14 +21,14 @@ http://vavivavi.blogspot.com/
|
||||||
|
|
||||||
* DONE
|
* DONE
|
||||||
|
|
||||||
improve pad control
|
improve pad control
|
||||||
disk selection mode
|
disk selection mode
|
||||||
virtual keyboard
|
virtual keyboard
|
||||||
.nib reader
|
.nib reader
|
||||||
|
|
||||||
* INSTALL
|
* INSTALL
|
||||||
|
|
||||||
1. unpack bdjappleii-x.xx.rar
|
1. unpack bdjappleii-x.xx.rar
|
||||||
|
|
||||||
2. copy AVCHD directory into
|
2. copy AVCHD directory into
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ http://vavivavi.blogspot.com/
|
||||||
|
|
||||||
3. copy APPLE2E.ROM into .../AVCHD directory
|
3. copy APPLE2E.ROM into .../AVCHD directory
|
||||||
|
|
||||||
4. copy your .dsk image into .../AVCHD directory
|
4. copy your .dsk or .nib image into .../AVCHD directory
|
||||||
|
|
||||||
5. modify .../AVCHD/appleii.properties
|
5. modify .../AVCHD/appleii.properties
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ http://vavivavi.blogspot.com/
|
||||||
BLUE Button Goto DISK DRIVE 1 MODE
|
BLUE Button Goto DISK DRIVE 1 MODE
|
||||||
GREEN Button Restart
|
GREEN Button Restart
|
||||||
|
|
||||||
3. DISK DRIVE 1 MODE
|
3. DISK DRIVE 1 MODE
|
||||||
|
|
||||||
CIRCLE Select disk image
|
CIRCLE Select disk image
|
||||||
SQUARE Release disk image
|
SQUARE Release disk image
|
||||||
|
@ -79,7 +79,7 @@ http://vavivavi.blogspot.com/
|
||||||
BLUE Button Goto DISK DRIVE 2 MODE
|
BLUE Button Goto DISK DRIVE 2 MODE
|
||||||
GREEN Button Restart
|
GREEN Button Restart
|
||||||
|
|
||||||
4. DISK DRIVE 2 MODE
|
4. DISK DRIVE 2 MODE
|
||||||
|
|
||||||
CIRCLE Select disk image
|
CIRCLE Select disk image
|
||||||
SQUARE Release disk image
|
SQUARE Release disk image
|
||||||
|
@ -91,7 +91,7 @@ http://vavivavi.blogspot.com/
|
||||||
* ROMz
|
* ROMz
|
||||||
|
|
||||||
http://apple2.org.za/gswv/a2zine/System/
|
http://apple2.org.za/gswv/a2zine/System/
|
||||||
ftp://ftp.apple.asimov.net/pub/apple_II/
|
ftp://ftp.apple.asimov.net/pub/apple_II/
|
||||||
|
|
||||||
* GAMEz
|
* GAMEz
|
||||||
|
|
||||||
|
@ -101,7 +101,7 @@ http://vavivavi.blogspot.com/
|
||||||
|
|
||||||
0.12 09-Oct-2008
|
0.12 09-Oct-2008
|
||||||
|
|
||||||
improve pad control (i fogot keyReleased() method calling at base ;-P)
|
improve pad control (i forgot keyReleased() method calling at base ;-P)
|
||||||
|
|
||||||
0.11 28-Sep-2008
|
0.11 28-Sep-2008
|
||||||
|
|
||||||
|
@ -110,8 +110,8 @@ http://vavivavi.blogspot.com/
|
||||||
0.10 26-Sep-2008
|
0.10 26-Sep-2008
|
||||||
|
|
||||||
virtual keyboard
|
virtual keyboard
|
||||||
add disk selection mode
|
add disk selection mode
|
||||||
.nib reader
|
.nib reader
|
||||||
|
|
||||||
0.00 15-Sep-2008
|
0.00 15-Sep-2008
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<?xml version="1.0" encoding="Windows-31J"?>
|
<?xml version="1.0" encoding="UTf-8"?>
|
||||||
|
|
||||||
<!-- ////////////////////////////////////////////////////////////////////// -->
|
<!-- ////////////////////////////////////////////////////////////////////// -->
|
||||||
<!-- Copyright (c) 2008 by umjammer, All rights reserved. -->
|
<!-- Copyright (c) 2008 by umjammer, All rights reserved. -->
|
||||||
|
@ -7,13 +7,14 @@
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- BD-J Apple II -->
|
<!-- BD-J Apple II -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- @author umjammer -->
|
<!-- @author umjammer -->
|
||||||
<!-- @version 0.00 080912 nsano initial version -->
|
<!-- @version 0.00 080912 umjammer initial version -->
|
||||||
<!-- -->
|
<!-- -->
|
||||||
<!-- ////////////////////////////////////////////////////////////////////// -->
|
<!-- ////////////////////////////////////////////////////////////////////// -->
|
||||||
|
|
||||||
<project name="bdj Apple II" default="run" basedir=".">
|
<project name="bdj Apple II" default="run" basedir=".">
|
||||||
|
|
||||||
|
<property environment="env"/>
|
||||||
<property file="local.properties" />
|
<property file="local.properties" />
|
||||||
|
|
||||||
<property name="dir.build" value="build"/>
|
<property name="dir.build" value="build"/>
|
||||||
|
@ -57,7 +58,7 @@
|
||||||
destdir="${dir.build}"
|
destdir="${dir.build}"
|
||||||
source="1.3"
|
source="1.3"
|
||||||
target="1.3"
|
target="1.3"
|
||||||
deprecation="true">
|
deprecation="true">
|
||||||
<!--
|
<!--
|
||||||
<bootclasspath>
|
<bootclasspath>
|
||||||
<pathelement location="${dir.bdj}/lib/basis.jar" />
|
<pathelement location="${dir.bdj}/lib/basis.jar" />
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -886,7 +886,7 @@ System.err.println("mode: -> MODE_NORMAL");
|
||||||
final int KEY_SHIFT = -2;
|
final int KEY_SHIFT = -2;
|
||||||
int keyIndex;
|
int keyIndex;
|
||||||
/** normal, shift */
|
/** normal, shift */
|
||||||
int[][] keyDatum = {
|
int[][] keyData = {
|
||||||
{ 0x1b, 0x1b }, // esc
|
{ 0x1b, 0x1b }, // esc
|
||||||
{ -1, -1 }, // f1
|
{ -1, -1 }, // f1
|
||||||
{ -1, -1 },
|
{ -1, -1 },
|
||||||
|
@ -1007,7 +1007,7 @@ stat.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void keyPressed() {
|
private void keyPressed() {
|
||||||
int keyCode = keyDatum[keyIndex][shiftIndex];
|
int keyCode = keyData[keyIndex][shiftIndex];
|
||||||
switch (keyCode) {
|
switch (keyCode) {
|
||||||
case KEY_SHIFT:
|
case KEY_SHIFT:
|
||||||
shiftIndex = 1 - shiftIndex;
|
shiftIndex = 1 - shiftIndex;
|
||||||
|
|
|
@ -13,15 +13,15 @@ package vavi.apps.appleii;
|
||||||
* Connects EmAppleII, AppleCanvas
|
* Connects EmAppleII, AppleCanvas
|
||||||
*/
|
*/
|
||||||
public class AppleIIGo {
|
public class AppleIIGo {
|
||||||
// Class instances
|
// Class instances
|
||||||
private EmAppleII apple;
|
private EmAppleII apple;
|
||||||
private AppleDisplay display;
|
private AppleDisplay display;
|
||||||
// private AppleSpeaker speaker;
|
// private AppleSpeaker speaker;
|
||||||
private DiskII disk;
|
private DiskII disk;
|
||||||
|
|
||||||
// Machine variables
|
// Machine variables
|
||||||
private boolean isCpuPaused;
|
private boolean isCpuPaused;
|
||||||
private boolean isCpuDebugEnabled;
|
private boolean isCpuDebugEnabled;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public boolean isCpuDebugEnabled() {
|
public boolean isCpuDebugEnabled() {
|
||||||
|
@ -29,19 +29,19 @@ public class AppleIIGo {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Keyboard variables
|
// Keyboard variables
|
||||||
private boolean keyboardUppercaseOnly;
|
private boolean keyboardUppercaseOnly;
|
||||||
|
|
||||||
// Paddle variables
|
// Paddle variables
|
||||||
private boolean isPaddleInverted;
|
private boolean isPaddleInverted;
|
||||||
|
|
||||||
// Disk variables
|
// Disk variables
|
||||||
private String diskDriveResource[] = new String[2];
|
private String diskDriveResource[] = new String[2];
|
||||||
|
|
||||||
public String getDiskDriveResource(int drive) {
|
public String getDiskDriveResource(int drive) {
|
||||||
return diskDriveResource[drive];
|
return diskDriveResource[drive];
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean diskWritable;
|
private boolean diskWritable;
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
public interface View {
|
public interface View {
|
||||||
|
@ -194,91 +194,91 @@ public class AppleIIGo {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On applet initialization
|
* On applet initialization
|
||||||
*/
|
*/
|
||||||
public void init() {
|
public void init() {
|
||||||
System.err.println("init()");
|
System.err.println("init()");
|
||||||
|
|
||||||
// Activate listeners
|
// Activate listeners
|
||||||
|
|
||||||
// Initialize Apple II emulator
|
// Initialize Apple II emulator
|
||||||
apple = new EmAppleII(view);
|
apple = new EmAppleII(view);
|
||||||
loadRom(getParameter("cpuRom", ""));
|
loadRom(getParameter("cpuRom", ""));
|
||||||
apple.setCpuSpeed(new Integer(getParameter("cpuSpeed", "1000")).intValue());
|
apple.setCpuSpeed(new Integer(getParameter("cpuSpeed", "1000")).intValue());
|
||||||
isCpuPaused = getParameter("cpuPaused", "false").equals("true");
|
isCpuPaused = getParameter("cpuPaused", "false").equals("true");
|
||||||
isCpuDebugEnabled = getParameter("cpuDebugEnabled", "false").equals("true");
|
isCpuDebugEnabled = getParameter("cpuDebugEnabled", "false").equals("true");
|
||||||
apple.setStepMode(getParameter("cpuStepMode", "false").equals("true"));
|
apple.setStepMode(getParameter("cpuStepMode", "false").equals("true"));
|
||||||
|
|
||||||
// Keyboard
|
// Keyboard
|
||||||
keyboardUppercaseOnly = getParameter("keyboardUppercaseOnly", "true").equals("true");
|
keyboardUppercaseOnly = getParameter("keyboardUppercaseOnly", "true").equals("true");
|
||||||
|
|
||||||
// Display
|
// Display
|
||||||
display = new AppleDisplay(apple);
|
display = new AppleDisplay(apple);
|
||||||
display.setScale(new Float(getParameter("displayScale", "1")).floatValue());
|
display.setScale(new Float(getParameter("displayScale", "1")).floatValue());
|
||||||
display.setRefreshRate(new Integer(getParameter("displayRefreshRate", "10")).intValue());
|
display.setRefreshRate(new Integer(getParameter("displayRefreshRate", "10")).intValue());
|
||||||
display.setColorMode(new Integer(getParameter("displayColorMode", "0")).intValue());
|
display.setColorMode(new Integer(getParameter("displayColorMode", "0")).intValue());
|
||||||
setStatMode(getParameter("displayStatMode", "false").equals("true"));
|
setStatMode(getParameter("displayStatMode", "false").equals("true"));
|
||||||
setGlare(getParameter("displayGlare", "false").equals("true"));
|
setGlare(getParameter("displayGlare", "false").equals("true"));
|
||||||
|
|
||||||
// Speaker
|
// Speaker
|
||||||
// speaker = new AppleSpeaker(apple);
|
// speaker = new AppleSpeaker(apple);
|
||||||
// speaker.setVolume(new Integer(getAppletParameter("speakerVolume", "3")).intValue());
|
// speaker.setVolume(new Integer(getAppletParameter("speakerVolume", "3")).intValue());
|
||||||
|
|
||||||
// Peripherals
|
// Peripherals
|
||||||
disk = new DiskII();
|
disk = new DiskII();
|
||||||
apple.setPeripheral(disk, 6);
|
apple.setPeripheral(disk, 6);
|
||||||
|
|
||||||
// Initialize disk drives
|
// Initialize disk drives
|
||||||
diskWritable = getParameter("diskWritable", "false").equals("true");
|
diskWritable = getParameter("diskWritable", "false").equals("true");
|
||||||
mountDisk(0, getParameter("diskDrive1", ""));
|
mountDisk(0, getParameter("diskDrive1", ""));
|
||||||
mountDisk(1, getParameter("diskDrive2", ""));
|
mountDisk(1, getParameter("diskDrive2", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
// Start CPU
|
// Start CPU
|
||||||
if (!isCpuPaused) {
|
if (!isCpuPaused) {
|
||||||
resume();
|
resume();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On applet destruction
|
* On applet destruction
|
||||||
*/
|
*/
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
System.err.println("destroy()");
|
System.err.println("destroy()");
|
||||||
unmountDisk(0);
|
unmountDisk(0);
|
||||||
unmountDisk(1);
|
unmountDisk(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pause emulator
|
* Pause emulator
|
||||||
*/
|
*/
|
||||||
public void pause() {
|
public void pause() {
|
||||||
System.err.println("pause()");
|
System.err.println("pause()");
|
||||||
isCpuPaused = true;
|
isCpuPaused = true;
|
||||||
apple.setPaused(isCpuPaused);
|
apple.setPaused(isCpuPaused);
|
||||||
display.setPaused(isCpuPaused);
|
display.setPaused(isCpuPaused);
|
||||||
// speaker.setPaused(isCpuPaused);
|
// speaker.setPaused(isCpuPaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resume emulator
|
* Resume emulator
|
||||||
*/
|
*/
|
||||||
public void resume() {
|
public void resume() {
|
||||||
System.err.println("resume()");
|
System.err.println("resume()");
|
||||||
isCpuPaused = false;
|
isCpuPaused = false;
|
||||||
// speaker.setPaused(isCpuPaused);
|
// speaker.setPaused(isCpuPaused);
|
||||||
display.setPaused(isCpuPaused);
|
display.setPaused(isCpuPaused);
|
||||||
apple.setPaused(isCpuPaused);
|
apple.setPaused(isCpuPaused);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Restarts emulator
|
* Restarts emulator
|
||||||
*/
|
*/
|
||||||
public void restart() {
|
public void restart() {
|
||||||
System.err.println("restart()");
|
System.err.println("restart()");
|
||||||
apple.restart();
|
apple.restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets emulator
|
* Resets emulator
|
||||||
|
@ -288,82 +288,82 @@ System.err.println("reset()");
|
||||||
apple.reset();
|
apple.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load ROM
|
* Load ROM
|
||||||
*/
|
*/
|
||||||
public void loadRom(String resource) {
|
public void loadRom(String resource) {
|
||||||
System.err.println("loadRom(resource: " + resource + ")");
|
System.err.println("loadRom(resource: " + resource + ")");
|
||||||
apple.loadRom(dao, resource);
|
apple.loadRom(dao, resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mount a disk
|
* Mount a disk
|
||||||
*/
|
*/
|
||||||
public boolean mountDisk(int drive, String resource) {
|
public boolean mountDisk(int drive, String resource) {
|
||||||
System.err.println("mountDisk(drive: " + drive + ", resource: " + resource + ")");
|
System.err.println("mountDisk(drive: " + drive + ", resource: " + resource + ")");
|
||||||
|
|
||||||
if ((drive < 0) || (drive > 2)) {
|
if ((drive < 0) || (drive > 2)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
unmountDisk(drive);
|
unmountDisk(drive);
|
||||||
|
|
||||||
diskDriveResource[drive] = resource;
|
diskDriveResource[drive] = resource;
|
||||||
|
|
||||||
System.err.println("mount: dirve: " + drive + ", " + resource);
|
System.err.println("mount: dirve: " + drive + ", " + resource);
|
||||||
disk.readDisk(dao, drive, resource, 254, false);
|
disk.readDisk(dao, drive, resource, 254, false);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (e instanceof IllegalStateException) {
|
if (e instanceof IllegalStateException) {
|
||||||
System.err.println("mount: drive: " + drive + ": no disk");
|
System.err.println("mount: drive: " + drive + ": no disk");
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unmount a disk
|
* Unmount a disk
|
||||||
*/
|
*/
|
||||||
public void unmountDisk(int drive) {
|
public void unmountDisk(int drive) {
|
||||||
System.err.println("unmount: drive: " + drive);
|
System.err.println("unmount: drive: " + drive);
|
||||||
if ((drive < 0) || (drive > 2)) {
|
if ((drive < 0) || (drive > 2)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!diskWritable) {
|
if (!diskWritable) {
|
||||||
System.err.println("unmount: drive: " + drive + ", not writable");
|
System.err.println("unmount: drive: " + drive + ", not writable");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
disk.writeDisk(drive, diskDriveResource[drive]);
|
disk.writeDisk(drive, diskDriveResource[drive]);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
if (e instanceof NullPointerException) {
|
if (e instanceof NullPointerException) {
|
||||||
System.err.println("unmount: drive: " + drive + ": no disk");
|
System.err.println("unmount: drive: " + drive + ": no disk");
|
||||||
} else {
|
} else {
|
||||||
e.printStackTrace(System.err);
|
e.printStackTrace(System.err);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set color mode
|
* Set color mode
|
||||||
*/
|
*/
|
||||||
public void setColorMode(int value) {
|
public void setColorMode(int value) {
|
||||||
System.err.println("setColorMode(value: " + value + ")");
|
System.err.println("setColorMode(value: " + value + ")");
|
||||||
display.setColorMode(value);
|
display.setColorMode(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get disk activity
|
* Get disk activity
|
||||||
*/
|
*/
|
||||||
public boolean getDiskActivity() {
|
public boolean getDiskActivity() {
|
||||||
return (!isCpuPaused && disk.isMotorOn());
|
return (!isCpuPaused && disk.isMotorOn());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* */
|
/* */
|
||||||
|
|
|
@ -10,206 +10,206 @@ package vavi.apps.appleii;
|
||||||
|
|
||||||
|
|
||||||
public class DiskII extends Peripheral {
|
public class DiskII extends Peripheral {
|
||||||
// ROM (with boot wait cycle optimization)
|
// ROM (with boot wait cycle optimization)
|
||||||
private static final int[] rom = {
|
private static final int[] rom = {
|
||||||
0xa2, 0x20, 0xa0, 0x00, 0xa2, 0x03, 0x86, 0x3c, 0x8a, 0x0a, 0x24, 0x3c, 0xf0, 0x10, 0x05, 0x3c,
|
0xa2, 0x20, 0xa0, 0x00, 0xa2, 0x03, 0x86, 0x3c, 0x8a, 0x0a, 0x24, 0x3c, 0xf0, 0x10, 0x05, 0x3c,
|
||||||
0x49, 0xff, 0x29, 0x7e, 0xb0, 0x08, 0x4a, 0xd0, 0xfb, 0x98, 0x9d, 0x56, 0x03, 0xc8, 0xe8, 0x10,
|
0x49, 0xff, 0x29, 0x7e, 0xb0, 0x08, 0x4a, 0xd0, 0xfb, 0x98, 0x9d, 0x56, 0x03, 0xc8, 0xe8, 0x10,
|
||||||
0xe5, 0x20, 0x58, 0xff, 0xba, 0xbd, 0x00, 0x01, 0x0a, 0x0a, 0x0a, 0x0a, 0x85, 0x2b, 0xaa, 0xbd,
|
0xe5, 0x20, 0x58, 0xff, 0xba, 0xbd, 0x00, 0x01, 0x0a, 0x0a, 0x0a, 0x0a, 0x85, 0x2b, 0xaa, 0xbd,
|
||||||
0x8e, 0xc0, 0xbd, 0x8c, 0xc0, 0xbd, 0x8a, 0xc0, 0xbd, 0x89, 0xc0, 0xa0, 0x50, 0xbd, 0x80, 0xc0,
|
0x8e, 0xc0, 0xbd, 0x8c, 0xc0, 0xbd, 0x8a, 0xc0, 0xbd, 0x89, 0xc0, 0xa0, 0x50, 0xbd, 0x80, 0xc0,
|
||||||
0x98, 0x29, 0x03, 0x0a, 0x05, 0x2b, 0xaa, 0xbd, 0x81, 0xc0, 0xa9, 0x56, 0xa9, 0x00, 0xea, 0x88,
|
0x98, 0x29, 0x03, 0x0a, 0x05, 0x2b, 0xaa, 0xbd, 0x81, 0xc0, 0xa9, 0x56, 0xa9, 0x00, 0xea, 0x88,
|
||||||
0x10, 0xeb, 0x85, 0x26, 0x85, 0x3d, 0x85, 0x41, 0xa9, 0x08, 0x85, 0x27, 0x18, 0x08, 0xbd, 0x8c,
|
0x10, 0xeb, 0x85, 0x26, 0x85, 0x3d, 0x85, 0x41, 0xa9, 0x08, 0x85, 0x27, 0x18, 0x08, 0xbd, 0x8c,
|
||||||
0xc0, 0x10, 0xfb, 0x49, 0xd5, 0xd0, 0xf7, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0xc9, 0xaa, 0xd0, 0xf3,
|
0xc0, 0x10, 0xfb, 0x49, 0xd5, 0xd0, 0xf7, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0xc9, 0xaa, 0xd0, 0xf3,
|
||||||
0xea, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0xc9, 0x96, 0xf0, 0x09, 0x28, 0x90, 0xdf, 0x49, 0xad, 0xf0,
|
0xea, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0xc9, 0x96, 0xf0, 0x09, 0x28, 0x90, 0xdf, 0x49, 0xad, 0xf0,
|
||||||
0x25, 0xd0, 0xd9, 0xa0, 0x03, 0x85, 0x40, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0x2a, 0x85, 0x3c, 0xbd,
|
0x25, 0xd0, 0xd9, 0xa0, 0x03, 0x85, 0x40, 0xbd, 0x8c, 0xc0, 0x10, 0xfb, 0x2a, 0x85, 0x3c, 0xbd,
|
||||||
0x8c, 0xc0, 0x10, 0xfb, 0x25, 0x3c, 0x88, 0xd0, 0xec, 0x28, 0xc5, 0x3d, 0xd0, 0xbe, 0xa5, 0x40,
|
0x8c, 0xc0, 0x10, 0xfb, 0x25, 0x3c, 0x88, 0xd0, 0xec, 0x28, 0xc5, 0x3d, 0xd0, 0xbe, 0xa5, 0x40,
|
||||||
0xc5, 0x41, 0xd0, 0xb8, 0xb0, 0xb7, 0xa0, 0x56, 0x84, 0x3c, 0xbc, 0x8c, 0xc0, 0x10, 0xfb, 0x59,
|
0xc5, 0x41, 0xd0, 0xb8, 0xb0, 0xb7, 0xa0, 0x56, 0x84, 0x3c, 0xbc, 0x8c, 0xc0, 0x10, 0xfb, 0x59,
|
||||||
0xd6, 0x02, 0xa4, 0x3c, 0x88, 0x99, 0x00, 0x03, 0xd0, 0xee, 0x84, 0x3c, 0xbc, 0x8c, 0xc0, 0x10,
|
0xd6, 0x02, 0xa4, 0x3c, 0x88, 0x99, 0x00, 0x03, 0xd0, 0xee, 0x84, 0x3c, 0xbc, 0x8c, 0xc0, 0x10,
|
||||||
0xfb, 0x59, 0xd6, 0x02, 0xa4, 0x3c, 0x91, 0x26, 0xc8, 0xd0, 0xef, 0xbc, 0x8c, 0xc0, 0x10, 0xfb,
|
0xfb, 0x59, 0xd6, 0x02, 0xa4, 0x3c, 0x91, 0x26, 0xc8, 0xd0, 0xef, 0xbc, 0x8c, 0xc0, 0x10, 0xfb,
|
||||||
0x59, 0xd6, 0x02, 0xd0, 0x87, 0xa0, 0x00, 0xa2, 0x56, 0xca, 0x30, 0xfb, 0xb1, 0x26, 0x5e, 0x00,
|
0x59, 0xd6, 0x02, 0xd0, 0x87, 0xa0, 0x00, 0xa2, 0x56, 0xca, 0x30, 0xfb, 0xb1, 0x26, 0x5e, 0x00,
|
||||||
0x03, 0x2a, 0x5e, 0x00, 0x03, 0x2a, 0x91, 0x26, 0xc8, 0xd0, 0xee, 0xe6, 0x27, 0xe6, 0x3d, 0xa5,
|
0x03, 0x2a, 0x5e, 0x00, 0x03, 0x2a, 0x91, 0x26, 0xc8, 0xd0, 0xee, 0xe6, 0x27, 0xe6, 0x3d, 0xa5,
|
||||||
0x3d, 0xcd, 0x00, 0x08, 0xa6, 0x2b, 0x90, 0xdb, 0x4c, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
0x3d, 0xcd, 0x00, 0x08, 0xa6, 0x2b, 0x90, 0xdb, 0x4c, 0x01, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||||
};
|
};
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
private static final int NUM_DRIVES = 2;
|
private static final int NUM_DRIVES = 2;
|
||||||
private static final int DOS_NUM_SECTORS = 16;
|
private static final int DOS_NUM_SECTORS = 16;
|
||||||
private static final int DOS_NUM_TRACKS = 35;
|
private static final int DOS_NUM_TRACKS = 35;
|
||||||
private static final int DOS_TRACK_BYTES = 256 * DOS_NUM_SECTORS;
|
private static final int DOS_TRACK_BYTES = 256 * DOS_NUM_SECTORS;
|
||||||
private static final int RAW_TRACK_BYTES = 6656; // TODO 6250 ???
|
private static final int RAW_TRACK_BYTES = 6656; // TODO 6250 ???
|
||||||
|
|
||||||
// Disk II direct access variables
|
// Disk II direct access variables
|
||||||
private int drive = 0;
|
private int drive = 0;
|
||||||
private boolean isMotorOn = false;
|
private boolean isMotorOn = false;
|
||||||
|
|
||||||
private byte[][][] disk = new byte[NUM_DRIVES][DOS_NUM_TRACKS][];
|
private byte[][][] disk = new byte[NUM_DRIVES][DOS_NUM_TRACKS][];
|
||||||
private boolean[] isWriteProtected = new boolean[NUM_DRIVES];
|
private boolean[] isWriteProtected = new boolean[NUM_DRIVES];
|
||||||
|
|
||||||
private int currPhysTrack;
|
private int currPhysTrack;
|
||||||
private int currNibble;
|
private int currNibble;
|
||||||
|
|
||||||
// Caches
|
// Caches
|
||||||
private int[] driveCurrPhysTrack = new int[NUM_DRIVES];
|
private int[] driveCurrPhysTrack = new int[NUM_DRIVES];
|
||||||
private byte[] realTrack;
|
private byte[] realTrack;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Disk II emulation:
|
* Disk II emulation:
|
||||||
*
|
*
|
||||||
* C0xD, C0xE -> Read write protect
|
* C0xD, C0xE -> Read write protect
|
||||||
* C0xE, C0xC -> Read data from disk
|
* C0xE, C0xC -> Read data from disk
|
||||||
* Write data to disk -> C0xF, C0xC
|
* Write data to disk -> C0xF, C0xC
|
||||||
* Write data to disk -> C0xD, C0xC
|
* Write data to disk -> C0xD, C0xC
|
||||||
*
|
*
|
||||||
* We use 'fast mode', i.e. no 65(C)02 clock reference
|
* We use 'fast mode', i.e. no 65(C)02 clock reference
|
||||||
* We use simplified track handling (only adjacent phases)
|
* We use simplified track handling (only adjacent phases)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Internal registers
|
// Internal registers
|
||||||
private int latchAddress;
|
private int latchAddress;
|
||||||
private int latchData;
|
private int latchData;
|
||||||
private boolean writeMode;
|
private boolean writeMode;
|
||||||
|
|
||||||
// GCR encoding and decoding tables
|
// GCR encoding and decoding tables
|
||||||
private static final int[] gcrEncodingTable = {
|
private static final int[] gcrEncodingTable = {
|
||||||
0x96, 0x97, 0x9a, 0x9b, 0x9d, 0x9e, 0x9f, 0xa6,
|
0x96, 0x97, 0x9a, 0x9b, 0x9d, 0x9e, 0x9f, 0xa6,
|
||||||
0xa7, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb2, 0xb3,
|
0xa7, 0xab, 0xac, 0xad, 0xae, 0xaf, 0xb2, 0xb3,
|
||||||
0xb4, 0xb5, 0xb6, 0xb7, 0xb9, 0xba, 0xbb, 0xbc,
|
0xb4, 0xb5, 0xb6, 0xb7, 0xb9, 0xba, 0xbb, 0xbc,
|
||||||
0xbd, 0xbe, 0xbf, 0xcb, 0xcd, 0xce, 0xcf, 0xd3,
|
0xbd, 0xbe, 0xbf, 0xcb, 0xcd, 0xce, 0xcf, 0xd3,
|
||||||
0xd6, 0xd7, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
|
0xd6, 0xd7, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
|
||||||
0xdf, 0xe5, 0xe6, 0xe7, 0xe9, 0xea, 0xeb, 0xec,
|
0xdf, 0xe5, 0xe6, 0xe7, 0xe9, 0xea, 0xeb, 0xec,
|
||||||
0xed, 0xee, 0xef, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
0xed, 0xee, 0xef, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6,
|
||||||
0xf7, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
0xf7, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
|
||||||
};
|
};
|
||||||
// private int[] gcrDecodingTable = new int[256];
|
// private int[] gcrDecodingTable = new int[256];
|
||||||
private int[] gcrSwapBit = {0, 2, 1, 3};
|
private int[] gcrSwapBit = {0, 2, 1, 3};
|
||||||
private int[] gcrBuffer = new int[256];
|
private int[] gcrBuffer = new int[256];
|
||||||
private int[] gcrBuffer2 = new int[86];
|
private int[] gcrBuffer2 = new int[86];
|
||||||
|
|
||||||
// Physical sector to DOS 3.3 logical sector table
|
// Physical sector to DOS 3.3 logical sector table
|
||||||
private static final int[] gcrLogicalSector = {
|
private static final int[] gcrLogicalSector = {
|
||||||
0x0, 0x7, 0xe, 0x6, 0xd, 0x5, 0xc, 0x4,
|
0x0, 0x7, 0xe, 0x6, 0xd, 0x5, 0xc, 0x4,
|
||||||
0xb, 0x3, 0xa, 0x2, 0x9, 0x1, 0x8, 0xf
|
0xb, 0x3, 0xa, 0x2, 0x9, 0x1, 0x8, 0xf
|
||||||
};
|
};
|
||||||
|
|
||||||
// Temporary variables for conversion
|
// Temporary variables for conversion
|
||||||
private byte[] gcrNibbles = new byte[RAW_TRACK_BYTES];
|
private byte[] gcrNibbles = new byte[RAW_TRACK_BYTES];
|
||||||
private int gcrNibblesPos;
|
private int gcrNibblesPos;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
public DiskII() {
|
public DiskII() {
|
||||||
readDisk(null, 0, null, 254, false);
|
readDisk(null, 0, null, 254, false);
|
||||||
readDisk(null, 1, null, 254, false);
|
readDisk(null, 1, null, 254, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I/O read
|
* I/O read
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
public int ioRead(int address) {
|
public int ioRead(int address) {
|
||||||
int phase;
|
int phase;
|
||||||
|
|
||||||
switch (address & 0xf) {
|
switch (address & 0xf) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
case 0x2:
|
case 0x2:
|
||||||
case 0x4:
|
case 0x4:
|
||||||
case 0x6:
|
case 0x6:
|
||||||
// Q0, Q1, Q2, Q3 off
|
// Q0, Q1, Q2, Q3 off
|
||||||
break;
|
break;
|
||||||
case 0x1:
|
case 0x1:
|
||||||
// Q0 on
|
// Q0 on
|
||||||
phase = currPhysTrack & 3;
|
phase = currPhysTrack & 3;
|
||||||
if (phase == 1) {
|
if (phase == 1) {
|
||||||
if (currPhysTrack > 0) {
|
if (currPhysTrack > 0) {
|
||||||
currPhysTrack--;
|
currPhysTrack--;
|
||||||
}
|
}
|
||||||
} else if (phase == 3) {
|
} else if (phase == 3) {
|
||||||
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
||||||
currPhysTrack++;
|
currPhysTrack++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0x3:
|
case 0x3:
|
||||||
// Q1 on
|
// Q1 on
|
||||||
phase = currPhysTrack & 3;
|
phase = currPhysTrack & 3;
|
||||||
if (phase == 2) {
|
if (phase == 2) {
|
||||||
if (currPhysTrack > 0) {
|
if (currPhysTrack > 0) {
|
||||||
currPhysTrack--;
|
currPhysTrack--;
|
||||||
}
|
}
|
||||||
} else if (phase == 0) {
|
} else if (phase == 0) {
|
||||||
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
||||||
currPhysTrack++;
|
currPhysTrack++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0x5:
|
case 0x5:
|
||||||
// Q2 on
|
// Q2 on
|
||||||
phase = currPhysTrack & 3;
|
phase = currPhysTrack & 3;
|
||||||
if (phase == 3) {
|
if (phase == 3) {
|
||||||
if (currPhysTrack > 0) {
|
if (currPhysTrack > 0) {
|
||||||
currPhysTrack--;
|
currPhysTrack--;
|
||||||
}
|
}
|
||||||
} else if (phase == 1) {
|
} else if (phase == 1) {
|
||||||
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
||||||
currPhysTrack++;
|
currPhysTrack++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0x7:
|
case 0x7:
|
||||||
// Q3 on
|
// Q3 on
|
||||||
phase = currPhysTrack & 3;
|
phase = currPhysTrack & 3;
|
||||||
if (phase == 0) {
|
if (phase == 0) {
|
||||||
if (currPhysTrack > 0) {
|
if (currPhysTrack > 0) {
|
||||||
currPhysTrack--;
|
currPhysTrack--;
|
||||||
}
|
}
|
||||||
} else if (phase == 2) {
|
} else if (phase == 2) {
|
||||||
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
if (currPhysTrack < ((2 * DOS_NUM_TRACKS) - 1)) {
|
||||||
currPhysTrack++;
|
currPhysTrack++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0x8:
|
case 0x8:
|
||||||
// Motor off
|
// Motor off
|
||||||
isMotorOn = false;
|
isMotorOn = false;
|
||||||
break;
|
break;
|
||||||
case 0x9:
|
case 0x9:
|
||||||
// Motor on
|
// Motor on
|
||||||
isMotorOn = true;
|
isMotorOn = true;
|
||||||
break;
|
break;
|
||||||
case 0xa:
|
case 0xa:
|
||||||
// Drive 1
|
// Drive 1
|
||||||
driveCurrPhysTrack[drive] = currPhysTrack;
|
driveCurrPhysTrack[drive] = currPhysTrack;
|
||||||
drive = 0;
|
drive = 0;
|
||||||
currPhysTrack = driveCurrPhysTrack[drive];
|
currPhysTrack = driveCurrPhysTrack[drive];
|
||||||
|
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0xb:
|
case 0xb:
|
||||||
// Drive 2
|
// Drive 2
|
||||||
driveCurrPhysTrack[drive] = currPhysTrack;
|
driveCurrPhysTrack[drive] = currPhysTrack;
|
||||||
drive = 1;
|
drive = 1;
|
||||||
currPhysTrack = driveCurrPhysTrack[drive];
|
currPhysTrack = driveCurrPhysTrack[drive];
|
||||||
|
|
||||||
realTrack = disk[drive][currPhysTrack >> 1];
|
realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
break;
|
break;
|
||||||
case 0xc:
|
case 0xc:
|
||||||
return ioLatchC();
|
return ioLatchC();
|
||||||
case 0xd:
|
case 0xd:
|
||||||
ioLatchD(0xff);
|
ioLatchD(0xff);
|
||||||
break;
|
break;
|
||||||
case 0xe:
|
case 0xe:
|
||||||
return ioLatchE();
|
return ioLatchE();
|
||||||
case 0xf:
|
case 0xf:
|
||||||
ioLatchF(0xff);
|
ioLatchF(0xff);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rand.nextInt(256);
|
return rand.nextInt(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,35 +217,35 @@ public class DiskII extends Peripheral {
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
public void ioWrite(int address, int value) {
|
public void ioWrite(int address, int value) {
|
||||||
switch (address & 0xf) {
|
switch (address & 0xf) {
|
||||||
case 0x0:
|
case 0x0:
|
||||||
case 0x1:
|
case 0x1:
|
||||||
case 0x2:
|
case 0x2:
|
||||||
case 0x3:
|
case 0x3:
|
||||||
case 0x4:
|
case 0x4:
|
||||||
case 0x5:
|
case 0x5:
|
||||||
case 0x6:
|
case 0x6:
|
||||||
case 0x7:
|
case 0x7:
|
||||||
case 0x8:
|
case 0x8:
|
||||||
case 0x9:
|
case 0x9:
|
||||||
case 0xa:
|
case 0xa:
|
||||||
case 0xb:
|
case 0xb:
|
||||||
ioRead(address);
|
ioRead(address);
|
||||||
break;
|
break;
|
||||||
case 0xc:
|
case 0xc:
|
||||||
ioLatchC();
|
ioLatchC();
|
||||||
break;
|
break;
|
||||||
case 0xd:
|
case 0xd:
|
||||||
ioLatchD(value);
|
ioLatchD(value);
|
||||||
break;
|
break;
|
||||||
case 0xe:
|
case 0xe:
|
||||||
ioLatchE();
|
ioLatchE();
|
||||||
break;
|
break;
|
||||||
case 0xf:
|
case 0xf:
|
||||||
ioLatchF(value);
|
ioLatchF(value);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,15 +254,15 @@ public class DiskII extends Peripheral {
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
public int memoryRead(int address) {
|
public int memoryRead(int address) {
|
||||||
return rom[address & 0xff];
|
return rom[address & 0xff];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset peripheral
|
* Reset peripheral
|
||||||
*/
|
*/
|
||||||
public void reset() {
|
public void reset() {
|
||||||
ioRead(0x8);
|
ioRead(0x8);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads a disk
|
* Loads a disk
|
||||||
|
@ -271,10 +271,10 @@ public class DiskII extends Peripheral {
|
||||||
* @param drive Disk II drive
|
* @param drive Disk II drive
|
||||||
* @throws IllegalStateException
|
* @throws IllegalStateException
|
||||||
*/
|
*/
|
||||||
public void readDisk(AppleIIGo.Dao dao, int drive, String resource, int volume, boolean isWriteProtected) {
|
public void readDisk(AppleIIGo.Dao dao, int drive, String resource, int volume, boolean isWriteProtected) {
|
||||||
byte[] track = new byte[RAW_TRACK_BYTES];
|
byte[] track = new byte[RAW_TRACK_BYTES];
|
||||||
|
|
||||||
boolean isNib = false;
|
boolean isNib = false;
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
dao.openInputStream(resource);
|
dao.openInputStream(resource);
|
||||||
if (resource.toLowerCase().endsWith(".nib")) {
|
if (resource.toLowerCase().endsWith(".nib")) {
|
||||||
|
@ -284,25 +284,25 @@ System.err.println("DRIVE[" + drive + "]: NIB");
|
||||||
System.err.println("DRIVE[" + drive + "]: DSK");
|
System.err.println("DRIVE[" + drive + "]: DSK");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (int trackNum = 0; trackNum < DOS_NUM_TRACKS; trackNum++) {
|
for (int trackNum = 0; trackNum < DOS_NUM_TRACKS; trackNum++) {
|
||||||
disk[drive][trackNum] = new byte[RAW_TRACK_BYTES];
|
disk[drive][trackNum] = new byte[RAW_TRACK_BYTES];
|
||||||
|
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
if (isNib) {
|
if (isNib) {
|
||||||
dao.read(disk[drive][trackNum], 0, RAW_TRACK_BYTES);
|
dao.read(disk[drive][trackNum], 0, RAW_TRACK_BYTES);
|
||||||
} else {
|
} else {
|
||||||
dao.read(track, 0, DOS_TRACK_BYTES);
|
dao.read(track, 0, DOS_TRACK_BYTES);
|
||||||
trackToNibbles(track, disk[drive][trackNum], volume, trackNum);
|
trackToNibbles(track, disk[drive][trackNum], volume, trackNum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (resource != null) {
|
if (resource != null) {
|
||||||
dao.closeInputStream();
|
dao.closeInputStream();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.realTrack = disk[drive][currPhysTrack >> 1];
|
this.realTrack = disk[drive][currPhysTrack >> 1];
|
||||||
this.isWriteProtected[drive] = isWriteProtected;
|
this.isWriteProtected[drive] = isWriteProtected;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a disk
|
* Writes a disk
|
||||||
|
@ -310,115 +310,115 @@ System.err.println("DRIVE[" + drive + "]: DSK");
|
||||||
* @param resource filename
|
* @param resource filename
|
||||||
* @param drive Disk II drive
|
* @param drive Disk II drive
|
||||||
*/
|
*/
|
||||||
public void writeDisk(int drive, String resource) {
|
public void writeDisk(int drive, String resource) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Motor on indicator
|
* Motor on indicator
|
||||||
*/
|
*/
|
||||||
public boolean isMotorOn() {
|
public boolean isMotorOn() {
|
||||||
return isMotorOn;
|
return isMotorOn;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I/O read Latch C
|
* I/O read Latch C
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
private int ioLatchC() {
|
private int ioLatchC() {
|
||||||
if (writeMode) {
|
if (writeMode) {
|
||||||
// Write data: C0xD, C0xC
|
// Write data: C0xD, C0xC
|
||||||
realTrack[currNibble] = (byte) latchData;
|
realTrack[currNibble] = (byte) latchData;
|
||||||
} else {
|
} else {
|
||||||
// Read data: C0xE, C0xC
|
// Read data: C0xE, C0xC
|
||||||
latchData = (realTrack[currNibble] & 0xff);
|
latchData = (realTrack[currNibble] & 0xff);
|
||||||
}
|
}
|
||||||
|
|
||||||
currNibble++;
|
currNibble++;
|
||||||
if (currNibble >= RAW_TRACK_BYTES) {
|
if (currNibble >= RAW_TRACK_BYTES) {
|
||||||
currNibble = 0;
|
currNibble = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
latchAddress = 0xc;
|
latchAddress = 0xc;
|
||||||
return latchData;
|
return latchData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I/O write Latch D
|
* I/O write Latch D
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
private void ioLatchD(int value) {
|
private void ioLatchD(int value) {
|
||||||
// Prepare write
|
// Prepare write
|
||||||
writeMode = true;
|
writeMode = true;
|
||||||
latchData = value;
|
latchData = value;
|
||||||
latchAddress = 0xd;
|
latchAddress = 0xd;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I/O read Latch E
|
* I/O read Latch E
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
private int ioLatchE() {
|
private int ioLatchE() {
|
||||||
// Read write-protect: C0xD, C0xE
|
// Read write-protect: C0xD, C0xE
|
||||||
if (latchAddress == 0xd) {
|
if (latchAddress == 0xd) {
|
||||||
latchAddress = 0xe;
|
latchAddress = 0xe;
|
||||||
return isWriteProtected[drive] ? 0x80 : 0x00;
|
return isWriteProtected[drive] ? 0x80 : 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
writeMode = false;
|
writeMode = false;
|
||||||
latchAddress = 0xe;
|
latchAddress = 0xe;
|
||||||
return 0x3c;
|
return 0x3c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I/O write Latch F
|
* I/O write Latch F
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
*/
|
*/
|
||||||
private void ioLatchF(int value) {
|
private void ioLatchF(int value) {
|
||||||
// Prepare write
|
// Prepare write
|
||||||
writeMode = true;
|
writeMode = true;
|
||||||
latchData = value;
|
latchData = value;
|
||||||
latchAddress = 0xf;
|
latchAddress = 0xf;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* TRACK CONVERSION ROUTINES
|
* TRACK CONVERSION ROUTINES
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a nibble
|
* Writes a nibble
|
||||||
*
|
*
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
private final void gcrWriteNibble(int value) {
|
private final void gcrWriteNibble(int value) {
|
||||||
gcrNibbles[gcrNibblesPos] = (byte) value;
|
gcrNibbles[gcrNibblesPos] = (byte) value;
|
||||||
gcrNibblesPos++;
|
gcrNibblesPos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes sync bits
|
* Writes sync bits
|
||||||
*
|
*
|
||||||
* @param length Number of bits
|
* @param length Number of bits
|
||||||
*/
|
*/
|
||||||
private final void writeSync(int length) {
|
private final void writeSync(int length) {
|
||||||
while(length > 0) {
|
while(length > 0) {
|
||||||
length--;
|
length--;
|
||||||
gcrWriteNibble(0xff);
|
gcrWriteNibble(0xff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write an FM encoded value, used in writing address fields
|
* Write an FM encoded value, used in writing address fields
|
||||||
*
|
*
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
private final void encode44(int value) {
|
private final void encode44(int value) {
|
||||||
gcrWriteNibble((value >> 1) | 0xaa);
|
gcrWriteNibble((value >> 1) | 0xaa);
|
||||||
gcrWriteNibble(value | 0xaa);
|
gcrWriteNibble(value | 0xaa);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Encode in 6:2
|
* Encode in 6:2
|
||||||
|
@ -426,22 +426,22 @@ System.err.println("DRIVE[" + drive + "]: DSK");
|
||||||
* @param track Sectorized track data
|
* @param track Sectorized track data
|
||||||
* @param offset Offset in this data
|
* @param offset Offset in this data
|
||||||
*/
|
*/
|
||||||
private void encode62(byte[] track, int offset) {
|
private void encode62(byte[] track, int offset) {
|
||||||
// 86 * 3 = 258, so the first two byte are encoded twice
|
// 86 * 3 = 258, so the first two byte are encoded twice
|
||||||
gcrBuffer2[0] = gcrSwapBit[track[offset + 1] & 0x03];
|
gcrBuffer2[0] = gcrSwapBit[track[offset + 1] & 0x03];
|
||||||
gcrBuffer2[1] = gcrSwapBit[track[offset] & 0x03];
|
gcrBuffer2[1] = gcrSwapBit[track[offset] & 0x03];
|
||||||
|
|
||||||
// Save higher 6 bits in gcrBuffer and lower 2 bits in gcrBuffer2
|
// Save higher 6 bits in gcrBuffer and lower 2 bits in gcrBuffer2
|
||||||
for(int i = 255, j = 2; i >= 0; i--, j = j == 85 ? 0: j + 1) {
|
for(int i = 255, j = 2; i >= 0; i--, j = j == 85 ? 0: j + 1) {
|
||||||
gcrBuffer2[j] = ((gcrBuffer2[j] << 2) | gcrSwapBit[track[offset + i] & 0x03]);
|
gcrBuffer2[j] = ((gcrBuffer2[j] << 2) | gcrSwapBit[track[offset + i] & 0x03]);
|
||||||
gcrBuffer[i] = (track[offset + i] & 0xff) >> 2;
|
gcrBuffer[i] = (track[offset + i] & 0xff) >> 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear off higher 2 bits of GCR_buffer2 set in the last call
|
// Clear off higher 2 bits of GCR_buffer2 set in the last call
|
||||||
for(int i = 0; i < 86; i++) {
|
for(int i = 0; i < 86; i++) {
|
||||||
gcrBuffer2[i] &= 0x3f;
|
gcrBuffer2[i] &= 0x3f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write address field
|
* Write address field
|
||||||
|
@ -449,71 +449,71 @@ System.err.println("DRIVE[" + drive + "]: DSK");
|
||||||
* @param track Sectorized track data
|
* @param track Sectorized track data
|
||||||
* @param offset Offset in this data
|
* @param offset Offset in this data
|
||||||
*/
|
*/
|
||||||
private final void writeAddressField(int volumeNum, int trackNum, int sectorNum) {
|
private final void writeAddressField(int volumeNum, int trackNum, int sectorNum) {
|
||||||
// Write address mark
|
// Write address mark
|
||||||
gcrWriteNibble(0xd5);
|
gcrWriteNibble(0xd5);
|
||||||
gcrWriteNibble(0xaa);
|
gcrWriteNibble(0xaa);
|
||||||
gcrWriteNibble(0x96);
|
gcrWriteNibble(0x96);
|
||||||
|
|
||||||
// Write volume, trackNum, sector & checksum
|
// Write volume, trackNum, sector & checksum
|
||||||
encode44(volumeNum);
|
encode44(volumeNum);
|
||||||
encode44(trackNum);
|
encode44(trackNum);
|
||||||
encode44(sectorNum);
|
encode44(sectorNum);
|
||||||
encode44(volumeNum ^ trackNum ^ sectorNum);
|
encode44(volumeNum ^ trackNum ^ sectorNum);
|
||||||
|
|
||||||
// Write epilogue
|
// Write epilogue
|
||||||
gcrWriteNibble(0xde);
|
gcrWriteNibble(0xde);
|
||||||
gcrWriteNibble(0xaa);
|
gcrWriteNibble(0xaa);
|
||||||
gcrWriteNibble(0xeb);
|
gcrWriteNibble(0xeb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Write data field
|
* Write data field
|
||||||
*/
|
*/
|
||||||
private void writeDataField() {
|
private void writeDataField() {
|
||||||
int last = 0;
|
int last = 0;
|
||||||
int checksum;
|
int checksum;
|
||||||
|
|
||||||
// Write prologue
|
// Write prologue
|
||||||
gcrWriteNibble(0xd5);
|
gcrWriteNibble(0xd5);
|
||||||
gcrWriteNibble(0xaa);
|
gcrWriteNibble(0xaa);
|
||||||
gcrWriteNibble(0xad);
|
gcrWriteNibble(0xad);
|
||||||
|
|
||||||
// Write GCR encoded data
|
// Write GCR encoded data
|
||||||
for (int i = 0x55; i >= 0; i--) {
|
for (int i = 0x55; i >= 0; i--) {
|
||||||
checksum = last ^ gcrBuffer2[i];
|
checksum = last ^ gcrBuffer2[i];
|
||||||
gcrWriteNibble(gcrEncodingTable[checksum]);
|
gcrWriteNibble(gcrEncodingTable[checksum]);
|
||||||
last = gcrBuffer2[i];
|
last = gcrBuffer2[i];
|
||||||
}
|
}
|
||||||
for (int i = 0; i < 256; i++) {
|
for (int i = 0; i < 256; i++) {
|
||||||
checksum = last ^ gcrBuffer[i];
|
checksum = last ^ gcrBuffer[i];
|
||||||
gcrWriteNibble(gcrEncodingTable[checksum]);
|
gcrWriteNibble(gcrEncodingTable[checksum]);
|
||||||
last = gcrBuffer[i];
|
last = gcrBuffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write checksum
|
// Write checksum
|
||||||
gcrWriteNibble(gcrEncodingTable[last]);
|
gcrWriteNibble(gcrEncodingTable[last]);
|
||||||
|
|
||||||
// Write epilogue
|
// Write epilogue
|
||||||
gcrWriteNibble(0xde);
|
gcrWriteNibble(0xde);
|
||||||
gcrWriteNibble(0xaa);
|
gcrWriteNibble(0xaa);
|
||||||
gcrWriteNibble(0xeb);
|
gcrWriteNibble(0xeb);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a track to nibbles
|
* Converts a track to nibbles
|
||||||
*/
|
*/
|
||||||
private void trackToNibbles(byte[] track, byte[] nibbles, int volumeNum, int trackNum) {
|
private void trackToNibbles(byte[] track, byte[] nibbles, int volumeNum, int trackNum) {
|
||||||
this.gcrNibbles = nibbles;
|
this.gcrNibbles = nibbles;
|
||||||
gcrNibblesPos = 0;
|
gcrNibblesPos = 0;
|
||||||
|
|
||||||
for (int sectorNum = 0; sectorNum < DOS_NUM_SECTORS; sectorNum++) {
|
for (int sectorNum = 0; sectorNum < DOS_NUM_SECTORS; sectorNum++) {
|
||||||
encode62(track, gcrLogicalSector[sectorNum] << 8);
|
encode62(track, gcrLogicalSector[sectorNum] << 8);
|
||||||
writeSync(12);
|
writeSync(12);
|
||||||
writeAddressField(volumeNum, trackNum, sectorNum);
|
writeAddressField(volumeNum, trackNum, sectorNum);
|
||||||
writeSync(8);
|
writeSync(8);
|
||||||
writeDataField();
|
writeDataField();
|
||||||
}
|
}
|
||||||
writeSync(RAW_TRACK_BYTES - gcrNibblesPos);
|
writeSync(RAW_TRACK_BYTES - gcrNibblesPos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -9,94 +9,94 @@ package vavi.apps.appleii;
|
||||||
|
|
||||||
|
|
||||||
public class Paddle {
|
public class Paddle {
|
||||||
// Public variables
|
// Public variables
|
||||||
public static final int PADDLE_LOW = 0;
|
public static final int PADDLE_LOW = 0;
|
||||||
public static final int PADDLE_CENTER = 127;
|
public static final int PADDLE_CENTER = 127;
|
||||||
public static final int PADDLE_HIGH = 255;
|
public static final int PADDLE_HIGH = 255;
|
||||||
|
|
||||||
public static final int PADDLEMODE_DIRECT = 0;
|
public static final int PADDLEMODE_DIRECT = 0;
|
||||||
public static final int PADDLEMODE_FILTERED = 1;
|
public static final int PADDLEMODE_FILTERED = 1;
|
||||||
|
|
||||||
// Instances of other classes
|
// Instances of other classes
|
||||||
private EmAppleII apple;
|
private EmAppleII apple;
|
||||||
|
|
||||||
// Button variables
|
// Button variables
|
||||||
private int[] buttonRegister = new int[4];
|
private int[] buttonRegister = new int[4];
|
||||||
|
|
||||||
// Paddle variables
|
// Paddle variables
|
||||||
// private int paddleMode;
|
// private int paddleMode;
|
||||||
|
|
||||||
private int[] paddleClockEvent = new int[4];
|
private int[] paddleClockEvent = new int[4];
|
||||||
private int[] paddleClockInc = new int[4];
|
private int[] paddleClockInc = new int[4];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Paddle class constructor
|
* Paddle class constructor
|
||||||
*
|
*
|
||||||
* @param apple The EmAppleII instance
|
* @param apple The EmAppleII instance
|
||||||
*/
|
*/
|
||||||
public Paddle(EmAppleII apple) {
|
public Paddle(EmAppleII apple) {
|
||||||
this.apple = apple;
|
this.apple = apple;
|
||||||
|
|
||||||
setPaddlePos(0, PADDLE_CENTER);
|
setPaddlePos(0, PADDLE_CENTER);
|
||||||
setPaddlePos(1, PADDLE_CENTER);
|
setPaddlePos(1, PADDLE_CENTER);
|
||||||
setPaddlePos(2, PADDLE_CENTER);
|
setPaddlePos(2, PADDLE_CENTER);
|
||||||
setPaddlePos(3, PADDLE_CENTER);
|
setPaddlePos(3, PADDLE_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set button state
|
* Set button state
|
||||||
*
|
*
|
||||||
* @param button Paddle button
|
* @param button Paddle button
|
||||||
* @param state State
|
* @param state State
|
||||||
*/
|
*/
|
||||||
public void setButton(int button, boolean pressed) {
|
public void setButton(int button, boolean pressed) {
|
||||||
buttonRegister[button] = (pressed ? 0x80 : 0x00);
|
buttonRegister[button] = (pressed ? 0x80 : 0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Button register
|
* Button register
|
||||||
*
|
*
|
||||||
* @param button Paddle button
|
* @param button Paddle button
|
||||||
*/
|
*/
|
||||||
public int getButtonRegister(int button) {
|
public int getButtonRegister(int button) {
|
||||||
return buttonRegister[button];
|
return buttonRegister[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set paddle position
|
* Set paddle position
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
public void setPaddlePos(int paddle, int value) {
|
public void setPaddlePos(int paddle, int value) {
|
||||||
/*
|
/*
|
||||||
* Magic formula, see ROM $FB1E-$FB2E,
|
* Magic formula, see ROM $FB1E-$FB2E,
|
||||||
* We calculate the numbers of cycles after which
|
* We calculate the numbers of cycles after which
|
||||||
* the RC circuit of a triggered paddle will discharge.
|
* the RC circuit of a triggered paddle will discharge.
|
||||||
*/
|
*/
|
||||||
paddleClockInc[paddle] = value * 11 + 8;
|
paddleClockInc[paddle] = value * 11 + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Trigger paddle register
|
* Trigger paddle register
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
public void triggerRegister() {
|
public void triggerRegister() {
|
||||||
paddleClockEvent[0] = apple.clock + paddleClockInc[0];
|
paddleClockEvent[0] = apple.clock + paddleClockInc[0];
|
||||||
paddleClockEvent[1] = apple.clock + paddleClockInc[1];
|
paddleClockEvent[1] = apple.clock + paddleClockInc[1];
|
||||||
paddleClockEvent[2] = apple.clock + paddleClockInc[2];
|
paddleClockEvent[2] = apple.clock + paddleClockInc[2];
|
||||||
paddleClockEvent[3] = apple.clock + paddleClockInc[3];
|
paddleClockEvent[3] = apple.clock + paddleClockInc[3];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get paddle register
|
* Get paddle register
|
||||||
*
|
*
|
||||||
* @param address Address
|
* @param address Address
|
||||||
* @param value Value
|
* @param value Value
|
||||||
*/
|
*/
|
||||||
public int getPaddleRegister(int paddle) {
|
public int getPaddleRegister(int paddle) {
|
||||||
return ((((paddleClockEvent[paddle] - apple.clock) & 0x7fffffff) < 0x40000000) ? 0x80 : 0x00);
|
return ((((paddleClockEvent[paddle] - apple.clock) & 0x7fffffff) < 0x40000000) ? 0x80 : 0x00);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,25 +12,25 @@ import java.util.Random;
|
||||||
|
|
||||||
|
|
||||||
public class Peripheral {
|
public class Peripheral {
|
||||||
protected Random rand = new Random();
|
protected Random rand = new Random();
|
||||||
|
|
||||||
public Peripheral() {
|
public Peripheral() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int ioRead(int address) {
|
public int ioRead(int address) {
|
||||||
return rand.nextInt(256);
|
return rand.nextInt(256);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ioWrite(int address, int value) {
|
public void ioWrite(int address, int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public int memoryRead(int address) {
|
public int memoryRead(int address) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void memoryWrite(int address, int value) {
|
public void memoryWrite(int address, int value) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue