Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: sticksoft/ADCPU-16Emu
base: f4aefbc4e6
...
head fork: sticksoft/ADCPU-16Emu
compare: 27ace7468c
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 12 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 19, 2012
@sticksoft Updated menu shortcuts 6cd4113
Commits on Apr 21, 2012
@sticksoft Added help files
Added Assemble and Start/Stop to menu
27ace74
View
BIN  ADCPU16Emu.apk
Binary file not shown
View
8 AndroidManifest.xml
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="uk.co.sticksoft.adce"
- android:versionCode="7"
- android:versionName="0.18" >
+ android:versionCode="8"
+ android:versionName="0.19" >
<uses-sdk
android:minSdkVersion="4"
@@ -21,7 +21,9 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
- <activity android:name="DirectoryBrowserActivity"></activity>
+ <activity android:name="DirectoryBrowserActivity"></activity>
+ <activity android:name=".help.HelpActivity" android:label="Help"></activity>
+ <activity android:name=".help.TextActivity" android:label="Help"></activity>
</application>
</manifest>
View
6 README
@@ -1,7 +1,7 @@
ADCPU16Emu
==========
Android implementation of Notch's DCPU-16 (v1.1) (http://0x10c.com)
-Version 0.18
+Version 0.19
By Andrew "Stick" Boothroyd (@sticksoft)
Latest stable version: https://play.google.com/store/apps/details?id=uk.co.sticksoft.adce
Don't forget you can post issues / feature requests on GitHub :)
@@ -73,6 +73,10 @@ The asteroids are offset slightly on the radar
CHANGELOG
=========
+v0.19
+-----
+Added rudimentary help files and useful links.
+
v0.18
-----
Redone the CPU threading (should run about 5x faster now!)
View
47 res/raw/help_assembly.html
@@ -0,0 +1,47 @@
+<h1>What's Assembly Language?</h1>
+
+<h2>What's a computer?</h2>
+A computer is a general-purpose device that performs calculations according to a program that it is given. <br><br>
+The 'brain' of a computer is its CPU - the Central Processing Unit. Its short-term 'memory' is its RAM - Random Access Memory. <br><br>
+Its long-term memory is its hard disks, floppy disks, tapes, flash drives, and any other kind of permanent storage. <br><br>
+It communicates with the world through a variety of I/O (input / output) devices, including monitors and keyboards. <br><br>
+
+
+<h2>How's a computer controlled?</h2>
+Computers follow programs. Programs contain a list of instructions, and some associated data. <br/><br/>
+Each instruction of a program is "fed into" the CPU to be executed. <br/><br/>
+In high-level programming languages (more human-readable, such as Java, C++, Haskell, COBOL, BASIC, etc), a single statement may result in the CPU performing several operations. <br/><br/>
+However, in lower-level languages (less human-readable, such as C, Assembly and machine code), a single statement usually results in the CPU only performing a single, matching operation. <br/><br/>
+
+
+<h2>What's machine code?</h2>
+Machine code is the lowest-level "language" that can be used to control a computer. It is essentially a series of numbers that control the CPU directly. <br/><br/>
+Machine code consists of a list of instructions, which are executed one at a time, usually one after the other. <br/><br/>
+In the DCPU-16 architecture, instructions consist of an opcode (number identifying the operation to perform) and 0, 1 or 2 data values that immediately follow the opcode. <br/><br/>
+Unless you plan on writing your own emulator, you do not need to worry about how these opcodes work! <br/><br/>
+
+<h2>What's an operation?</h2>
+A single CPU operation will perform one calculation. For instance, the SET operation stores a value into the computer's memory. <br/><br/>
+The value can either be a constant (any old number, that is the same every time the program is run), or may be copied from an existing location in memory (this is useful to copy data and to store intermediate values in large, complex calculations). <br/><br/>
+Other operations include ADD (adding one value to another), SUB (subtracting one value from another), MUL (multiplying one value by another) and more. <br/><br/>
+
+<h2>Where'd the values come from?</h2>
+The CPU can access the computer's RAM, which stores all its current data (including the program itself), but also has a set of 'registers'. <br/><br/>
+Registers are a small number of areas that hold single values for the CPU while it is working out calculations. <br/><br/>
+The DCPU has 8 general registers (called A, B, C, X, Y, Z, I and J), which can be used for whatever the programmer wants. They are frequently used to store completely different things in different places in the program. <br/><br/>
+In a real CPU, accessing the registers is a lot faster than accessing the RAM (sometimes 40x faster!), so they are always being used for something. <br/><br/>
+The DCPU also has 3 special registers - PC, SP and O. <br/><br/>
+PC (program counter) is the location of the current machine-code instruction. This goes up by one after each instruction, and can be written to in order to jump around in a program. <br/><br/>
+SP (stack pointer) is the current location of the top of the 'stack' (part of the RAM that's used to store temporary values when the registers are all used, and for passing data when jumping around). <br/><br/>
+O (overflow) is set to the remainder of the last instruction if its result was too big to fit in one value (or negative). <br/><br/>
+
+<h2>What's assembly language?</h2>
+Assemply language is the second-lowest-level language used to control a computer. <br/><br/>
+It is the textual equivalent of machine code - instead of encoding operations in their opcode numbers, they are encoded in human-readble words and organised into rows. <br/><br/>
+Assembly language allows programmers to write machine code in an easier-to-manage form (no-one likes having to do 3 or more sums in their head every time they want to write an instruction!) <br/><br/>
+Higher-level languages are even easier to use, but give less fine-grained control over what the CPU actually does. <br/><br/>
+
+<h2>How's assembly language used?</h2>
+With the DCPU, assembly language is 'assembled' (converted to its machine-code equivalent) and inserted into the computer's memory. <br/><br/>
+The program counter (PC) is set to the location of the first instruction, and the CPU then proceeds to carry them out one by one. <br/><br/>
+It does this by understanding the numeric opcodes and carrying them out. <br/><br/>
View
49 res/raw/help_dasm_qr.html
@@ -0,0 +1,49 @@
+<h1>DASM Quick Reference</h1>
+The following information is copied / paraphrased from <a href="http://0x10c.com/doc/dcpu-16.txt">http://0x10c.com/doc/dcpu-16.txt</a>. <br/><br/><br/>
+
+In this document, anything within [brackets] is shorthand for "the value of the RAM at the location of the value inside the brackets". <br/>
+For example, SP means stack pointer, but [SP] means the value of the RAM at the location the stack pointer is pointing at. <br/> <br/>
+
+Whenever the CPU needs to read a word, it reads [PC], then increases PC by one. Shorthand for this is [PC++]. <br/>
+In some cases, the CPU will modify a value before reading it, in this case the shorthand is [++PC]. <br/> <br/><br/>
+
+Basic opcodes: (4 bits) <br/><br/>
+ 0x0: non-basic instruction - see below <br/><br/>
+ 0x1: SET a, b - sets a to b <br/><br/>
+ 0x2: ADD a, b - sets a to a+b, sets O to 0x0001 if there's an overflow, 0x0 otherwise <br/><br/>
+ 0x3: SUB a, b - sets a to a-b, sets O to 0xffff if there's an underflow, 0x0 otherwise <br/><br/>
+ 0x4: MUL a, b - sets a to a*b, sets O to ((a*b)&gt;&gt;16)&amp;0xffff <br/><br/>
+ 0x5: DIV a, b - sets a to a/b, sets O to ((a&lt;&lt;16)/b)&amp;0xffff. if b==0, sets a and O to 0 instead. <br/><br/>
+ 0x6: MOD a, b - sets a to a%b. if b==0, sets a to 0 instead. <br/><br/>
+ 0x7: SHL a, b - sets a to a&lt;&lt;b, sets O to ((a&lt;&lt;b)&gt;&gt;16)&0xffff <br/><br/>
+ 0x8: SHR a, b - sets a to a>>b, sets O to ((a&lt;&lt;16)&gt;&gt;b)&0xffff <br/><br/>
+ 0x9: AND a, b - sets a to a&amp;b <br/><br/>
+ 0xa: BOR a, b - sets a to a|b <br/><br/>
+ 0xb: XOR a, b - sets a to a^b <br/><br/>
+ 0xc: IFE a, b - performs next instruction only if a==b <br/><br/>
+ 0xd: IFN a, b - performs next instruction only if a!=b <br/><br/>
+ 0xe: IFG a, b - performs next instruction only if a&gt;b <br/><br/>
+ 0xf: IFB a, b - performs next instruction only if (a&amp;b)!=0 <br/><br/>
+
+<br/>
+
+Values: (6 bits) <br/><br/>
+ 0x00-0x07: register (A, B, C, X, Y, Z, I or J, in that order) <br/><br/>
+ 0x08-0x0f: [register] <br/><br/>
+ 0x10-0x17: [next word + register] <br/><br/>
+ 0x18: POP / [SP++] <br/><br/>
+ 0x19: PEEK / [SP] <br/><br/>
+ 0x1a: PUSH / [--SP] <br/><br/>
+ 0x1b: SP <br/><br/>
+ 0x1c: PC <br/><br/>
+ 0x1d: O <br/><br/>
+ 0x1e: [next word] <br/><br/>
+ 0x1f: next word (literal) <br/><br/>
+ 0x20-0x3f: literal value 0x00-0x1f (literal) <br/><br/> <br/>
+
+Non-basic opcodes: (6 bits) <br/><br/>
+ 0x00: reserved for future expansion <br/><br/>
+ 0x01: JSR a - pushes the address of the next instruction to the stack, then sets PC to a <br/><br/>
+ 0x02-0x3f: reserved <br/><br/>
+
+</pre>
View
39 res/raw/help_introduction.html
@@ -0,0 +1,39 @@
+<h1>Introduction</h1>
+<h2>What's 0x10c?</h2>
+0x10c is the name of a new game recently announced by Notch, the creator of Minecraft and founder of Mojang AB. <br/><br/>
+The game will involve space travel, in-depth engineering and programmable in-game computers. For more info, see <a href="http://0x10c.com">0x10c.com</a>. <br/><br/>
+
+<h2>What is ADCPU-16Emu?</h2>
+In 0x10c, the central processing unit of the programmable computer is known as the DCPU. <br/><br/>
+ADCPU-16Emu (or just ADCPU) is an Android implementation of the DCPU. <br/><br/>
+ADCPU contains an emulator (that simulates the operation of the DCPU), an assembler (that converts human-readable programs written in DCPU Assembly (or "DASM") into machine-readable executable code), a console (that displays output from the emulator's memory) and some extras like the virtual ship. <br/><br/>
+
+<h2>What can it do?</h2>
+Hopefully, ADCPU should be able to assemble and run any DCPU program written by your fine self, or found on the 'net. <br/><br/>
+The majority of programs at this stage do little more than run some computations and provide output via the console. <br/><br/>
+Some programs also accept keyboard input - this has not yet been implemented in ADCPU. <br/><br/>
+Unlike most other emulators, ADCPU links to a "virtual ship", that can be controlled by reading from and writing to several memory addresses. <br/><br/>
+
+<h2>How do you use it?</h2>
+<h3>Assembling a program</h3>
+Before you can use the DCPU, you must give it a program to execute. <br/><br/>
+Go to the ASM tab, and hit the menu key on your phone.
+Tap "Load..." to load a program, and select "radar.dasm". <br/><br/>
+This loads the program into the text entry area on the ASM tab.
+To insert this program into the DCPU's memory, scroll down to below the text area and hit the "Assemble" button. <br/><br/>
+This will assemble the above program into its machine code form, which the DCPU can understand. <br/><br/>
+(This is displayed beneath the button after assembly. Don't worry if you don't understand what all the numbers mean! It's only displayed to help advanced users find glitches in my assembler.) <br/><br/>
+
+<h3>Running the program</h3>
+Once the program is assembled, go back to the Control tab and hit the "Start" button (if your phone has a small screen, you might need to scroll down to find it). <br/><br/>
+That's it! The program is now running. <br/><br/>
+The reddy-brown window at the top of that tab shows the contents of the DCPU's memory. <br/>
+The assembled program is that top line of green-and-blue dots. <br/><br/>
+(The colour is determined by the value in memory. As this is a 16-bit computer, the values range from 0x0000 to 0xFFFF. The first high 8 bits are used as the green component, the low 8 bits are used as the blue component, so 0xFF00 is green and 0x00FF is blue, and 0xFFFF is cyan).
+
+<h3>Ship and Console</h3>
+On the Ship tab and you'll see the virtual ship moving along! <br/><br/>
+You can't control it directly (yet); the program you just assembled controls it automatically. <br/><br/>
+Check out move.dasm for slightly more advanced movement! <br/><br/>
+On the Console tab, you'll see any output from the current program. <br/><br/>
+With the radar.dasm program, this should be a collection of 'A's moving round an 'x' - A for Asteroid, x for your ship <br/><br/>
View
35 res/raw/help_io_qr.html
@@ -0,0 +1,35 @@
+<h1>I/O Quick Reference</h1>
+Currently, I/O consists of writing to the console (somewhat standardised), and interfacing with the ship (non-standard).
+
+<h2>Console</h2>
+Write to 0x8000 - 0x81FF for 7-bit ASCII output to 32x16 screen. <br/><br/>
+Format (16 bits): ffffbbbbcaaaaaaa <br/><br/>
+ffff is 4-bit foreground colour <br/><br/>
+bbbb is 4-bit background colour <br/><br/>
+c is the blink bit (not implemented) <br/><br/>
+aaaaaaa is the 7-bit ASCII value <br/><br/>
+<br/>
+Colours are 4-bit values of format: hrgb <br/><br/>
+h is highlight on/off (use brighter colours or not)<br/><br/>
+r is red component <br/><br/>
+g is green component <br/><br/>
+b is blue component <br/><br/>
+
+<h2>Harcoded memory addresses</h2>
+These are subject to change at any time. <br/><br/>
+0xAD00 - Throttle control <br/><br/>
+0xAD01 - (reserved for pitch) <br/><br/>
+0xAD02 - Yaw <br/><br/>
+0xAD03 - (reserved for roll) <br/><br/>
+0xAD04 - (reserved for pitch gyro) <br/><br/>
+0xAD05 - Yaw gyro <br/><br/>
+0xAD06 - (reserved for roll gyro) <br/><br/><br/>
+
+0xAD10 - Radar control. Set to 0xFFFF to get count, set to index number (starting at 1) for that contact's info. <br/><br/>
+0xAD11 - Radar contact count <br/><br/>
+0xAD12 - Current contact X <br/><br/>
+0xAD13 - (reserved for contact Y) <br/><br/>
+0xAD14 - Current contact Z <br/><br/>
+0xAD15 - (reserved for contact type) <br/><br/>
+0xAD16 - (reserved for contact size) <br/><br/>
+0xAD17 - (reserved for contact IFF code) <br/><br/>
View
11 res/raw/help_links.html
@@ -0,0 +1,11 @@
+<h1>Links</h1>
+<a href="http://0x10c.com">Official 0x10c site</a> <br/><br/>
+<a href="http://0x10c.com/doc/dcpu-16.txt">Official DCPU documentation</a> <br/><br/>
+<a href="https://twitter.com/#!/notch">Notch on Twitter</a> <br/><br/>
+<a href="http://www.0x10cforum.com/">0x10cforum.com</a> <br/><br/>
+<a href="http://0x10cwiki.com/wiki/Main_Page">0x10cwiki.com</a> <br/><br/>
+<a href="http://www.0x10cforum.com/forum/m/4932880/viewthread/2740607-dcpu16-ver-11-basic-tutorial-link-to">Tutorial by YurishoSan</a> <br/><br/>
+<a href="http://www.0x10cforum.com/forum/m/4932880/viewthread/2730356-dcpu-tutorial-workinprogress">Tutorial by Fred</a> <br/><br/>
+<a href="https://github.com/sticksoft/ADCPU-16Emu">Source code for this app</a> <br/><br/>
+<a href="https://github.com/sticksoft/ADCPU-16Emu/issues">Bugtracker for this app</a> <br/><br/>
+<a href="https://twitter.com/#!/sticksoft">Me (Stick) on Twitter</a> <br/><br/>
View
2  src/uk/co/sticksoft/adce/AssemblyEditorTab.java
@@ -98,7 +98,7 @@ private void autoload()
}
}
- private void assemble()
+ public void assemble()
{
main.stop();
autosave();
View
22 src/uk/co/sticksoft/adce/MainActivity.java
@@ -6,6 +6,7 @@
import uk.co.sticksoft.adce.asm.Assembler;
import uk.co.sticksoft.adce.cpu.CPU;
import uk.co.sticksoft.adce.hardware.Console;
+import uk.co.sticksoft.adce.help.HelpActivity;
import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
@@ -143,8 +144,8 @@ public View createTabContent(String tag)
private void checkVersion()
{
- final String currentVersion = "0.16";
- final String currentMessage = "NEW: Check out radar.dasm for radar info!";
+ final String currentVersion = "0.19";
+ final String currentMessage = "NEW: Help (press menu!)";
FileInputStream fis = null;
boolean up_to_date = false;
@@ -369,6 +370,9 @@ public boolean onCreateOptionsMenu(Menu menu)
{
menu.add(Menu.NONE, 1, Menu.NONE, "Load...");
menu.add(Menu.NONE, 2, Menu.NONE, "Save...");
+ menu.add(Menu.NONE, 3, Menu.NONE, "Assemble");
+ menu.add(Menu.NONE, 4, Menu.NONE, "Start/stop");
+ menu.add(Menu.NONE, 5, Menu.NONE, "Help");
return super.onCreateOptionsMenu(menu);
}
@@ -394,6 +398,20 @@ public boolean onOptionsItemSelected(MenuItem item)
startActivityForResult(intent, 2);
break;
}
+ case 3:
+ asmEditor.assemble();
+ break;
+ case 4:
+ if (running)
+ stop();
+ else
+ start();
+ break;
+ case 5:
+ {
+ Intent intent = new Intent(this, HelpActivity.class);
+ startActivity(intent);
+ }
}
return super.onOptionsItemSelected(item);
View
157 src/uk/co/sticksoft/adce/help/HelpActivity.java
@@ -0,0 +1,157 @@
+package uk.co.sticksoft.adce.help;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import uk.co.sticksoft.adce.R;
+
+import android.app.ListActivity;
+import android.content.Intent;
+import android.database.DataSetObserver;
+import android.os.Bundle;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ListAdapter;
+import android.widget.ListView;
+import android.widget.TextView;
+
+public class HelpActivity extends ListActivity implements ListAdapter
+{
+ /** Called when the activity is first created. */
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ setListAdapter(this);
+ }
+
+ public final static String[] helpEntries =
+ {
+ "Introduction",
+ "What's Assembly Language?",
+ "DASM Quick Reference",
+ "I/O Quick Reference",
+ "Links"
+ };
+
+ private void showTextRes(int resID)
+ {
+ Intent intent = new Intent(this, TextActivity.class);
+ intent.putExtra("text", resID);
+ startActivity(intent);
+ }
+
+ @Override
+ protected void onListItemClick(ListView l, View v, int position, long id)
+ {
+ super.onListItemClick(l, v, position, id);
+
+ switch (position)
+ {
+ case 0:
+ showTextRes(R.raw.help_introduction);
+ break;
+ case 1:
+ showTextRes(R.raw.help_assembly);
+ break;
+ case 2:
+ showTextRes(R.raw.help_dasm_qr);
+ break;
+ case 3:
+ showTextRes(R.raw.help_io_qr);
+ break;
+ case 4:
+ showTextRes(R.raw.help_links);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ @Override
+ public int getCount()
+ {
+ return helpEntries.length;
+ }
+
+ @Override
+ public Object getItem(int position)
+ {
+ return helpEntries[position];
+ }
+
+ @Override
+ public long getItemId(int position)
+ {
+ return position;
+ }
+
+ @Override
+ public int getItemViewType(int position)
+ {
+ return 0;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent)
+ {
+ TextView tv = null;
+ if (convertView != null && convertView instanceof TextView)
+ tv = (TextView)convertView;
+ else
+ {
+ tv = new TextView(this);
+ tv.setTextSize(26);
+ tv.setPadding(5, 10, 5, 10);
+ }
+
+ tv.setText(helpEntries[position]);
+
+ return tv;
+ }
+
+ @Override
+ public int getViewTypeCount()
+ {
+ return 1;
+ }
+
+ @Override
+ public boolean hasStableIds()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isEmpty()
+ {
+ return false;
+ }
+
+ Set<DataSetObserver> observers = new HashSet<DataSetObserver>();
+ @Override
+ public void registerDataSetObserver(DataSetObserver observer)
+ {
+ observers.add(observer);
+ }
+
+ @Override
+ public void unregisterDataSetObserver(DataSetObserver observer)
+ {
+ observers.remove(observer);
+ }
+
+ @Override
+ public boolean areAllItemsEnabled()
+ {
+ return true;
+ }
+
+ @Override
+ public boolean isEnabled(int position)
+ {
+ return true;
+ }
+}
View
63 src/uk/co/sticksoft/adce/help/TextActivity.java
@@ -0,0 +1,63 @@
+package uk.co.sticksoft.adce.help;
+
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+
+import android.app.Activity;
+import android.os.Bundle;
+import android.text.Html;
+import android.text.method.LinkMovementMethod;
+import android.text.util.Linkify;
+import android.widget.FrameLayout;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+public class TextActivity extends Activity
+{
+ @Override
+ protected void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+
+ FrameLayout lyt = new FrameLayout(this);
+
+ ScrollView scroll = new ScrollView(this);
+ lyt.addView(scroll);
+
+ TextView text = new TextView(this);
+ scroll.addView(text);
+
+ int textResID = getIntent().getIntExtra("text", 0);
+
+ if (textResID == 0)
+ {
+ finish();
+ return;
+ }
+
+ try
+ {
+ InputStream is = getResources().openRawResource(textResID);
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+
+ byte[] buffer = new byte[1024];
+ int read = -1;
+ while ((read = is.read(buffer)) > 0)
+ baos.write(buffer, 0, read);
+
+ String loadedText = new String(baos.toByteArray(), Charset.defaultCharset().name());
+
+ text.setText(Html.fromHtml(loadedText));
+ text.setMovementMethod(LinkMovementMethod.getInstance());
+ text.setTextSize(20);
+ }
+ catch (Exception ex)
+ {
+ finish();
+ return;
+ }
+
+ setContentView(lyt);
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.