Skip to content

Commit ac56615

Browse files
Pure 6502.
1 parent 5948ed2 commit ac56615

File tree

5 files changed

+101
-84
lines changed

5 files changed

+101
-84
lines changed

docs/source/hardware.rst

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ for production in multiples of five. You won't be able to order only one board.
8181

8282
There are a ton of options you can change if you like. The defaults will get
8383
you a classic green and white board with lead (Pb) HASL. Consider getting the
84-
lead-free HASL upgrade if the other four boards will be kicking around in a drawer
85-
for the next 20 years.
84+
lead-free HASL upgrade if the other four boards will be kicking around in a
85+
drawer for the next 20 years.
8686

8787

8888
Step 3. Order Assembly
@@ -131,15 +131,15 @@ If something is out of stock, consult the `Parts Substitution`_ notes below.
131131

132132

133133
Step 5. Pi Pico Firmware
134-
=========================
134+
========================
135135

136136
Download the `UF2 files
137137
<https://github.com/picocomputer/rp6502/releases>`_.
138138

139139
To load firmware on a Pi Pico 2, hold its BOOTSEL button down while plugging it
140-
into a computer. The Pi Pico 2 will appear as a storage device. Copy the RIA UF2
141-
file to make a :doc:`ria_w` and the VGA UF2 file to make a :doc:`vga`. It should
142-
take less than 30 seconds to copy. The LED turns on when done.
140+
into a computer. The Pi Pico 2 will appear as a storage device. Copy the RIA W
141+
UF2 file to make a :doc:`ria_w` and the VGA UF2 file to make a :doc:`vga`. It
142+
should take less than 30 seconds to copy. The LED turns on when done.
143143

144144

145145
Acrylic Sandwich Case
@@ -152,7 +152,7 @@ top and 3.5 mm for the bottom.
152152

153153

154154
Full Parts List (All Components)
155-
=================================
155+
================================
156156

157157
`All Parts CSV <_static/rp6502-revb-full.csv>`_
158158

@@ -162,7 +162,7 @@ Full Parts List (All Components)
162162

163163

164164
Active Parts List (ICs Only)
165-
=============================
165+
============================
166166

167167
`Active Parts CSV <_static/rp6502-revb-active.csv>`_
168168

@@ -182,7 +182,7 @@ Alternative part numbers for the Pi Picos.
182182

183183

184184
Parts Substitution
185-
===================
185+
==================
186186

187187
All resistors are <= 1% tolerance. Any power rating. Leads must fit 0.8mm
188188
plated holes spaced 10mm apart. Recommended size is approximately 0.1" x 0.25"
@@ -220,7 +220,7 @@ The WDC W65C02S and W65C22S must not be substituted. Do not attempt to use
220220
NMOS chips (without the C in the number). Some older CMOS designs may work but
221221
there are no plans to support out-of-production ICs.
222222

223-
Only the Raspberry Pi design of the Pi Pico 2 has been tested. Both original and
224-
"H" (header) versions work great. Pin-compatible alternatives usually work, check
225-
the forums. The 3-pin SWD connection on the Pi Pico RIA is no longer used and
226-
may be ignored when looking for alternatives.
223+
Only the Raspberry Pi design of the Pi Pico 2 has been tested. Both original
224+
and "H" (header) versions work great. Pin-compatible alternatives usually work,
225+
check the forums. The 3-pin SWD connection on the Pi Pico RIA is no longer
226+
used and may be ignored when looking for alternatives.

docs/source/index.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
Picocomputer 6502
1212
==================
1313

14-
All the soul of the 6502. None of the compromises. You're welcome.
14+
Pure 6502. No governor. No speed limits.
1515

1616
The **Picocomputer 6502** is an open source, modern-retro gaming computer
17-
built around a real WDC 65C02. The design philosophy: keep the essence of
17+
built around a real WDC 65C02. The design philosophy: keep the soul of
1818
programming a 6502 and 6522, then rethink everything else.
1919

2020
.. image:: _static/ria-w-sandwich.jpg
@@ -40,25 +40,33 @@ Specs
4040
- **ROM** — 1 MB of onboard flash for installing and auto-booting ROMs
4141
- **Video** — VGA and HD output; 3 planes, scanline programmable
4242
- **Sound** — PSG (8 voices) and OPL2 FM (9 voices)
43-
- **Clock** — Real-Time Clock with DST
43+
- **Clock** — Real-Time Clock with Daylight Savings Time
4444
- **TRNG** — True random number generator
4545

4646

47+
Quality of Life
48+
===============
49+
- **Open by Design** — DIY-friendly with fully open source hardware and software
50+
- **Storage** — Blazing fast 512 KB/sec USB flash drive reads and writes
51+
- **Keyboard** — International keyboard layout support
52+
- **Fonts** — Built-in code pages for international character sets
53+
54+
4755
Connectivity
4856
============
4957

5058
- **WiFi** — NTP time sync, Hayes modem emulation for dialing into BBSs
5159
- **Bluetooth LE** — keyboard, mouse, and gamepads
5260
- **USB Host** — keyboard, mouse, gamepads, hubs, UART serial, NFC, floppy drives, and flash drives
53-
- **USB Device** — driverless CDC ACM; mirrors the VGA ANSI terminal console
61+
- **USB Device** — driverless CDC ACM; console access (can operate headless)
5462

5563

5664
Programming
5765
===========
5866

5967
- **Protected OS** — 32-bit operating system; uses no 6502 RAM
6068
- **FAT filesystem** — read and write files on any USB flash or floppy drive
61-
- **POSIX-compatible API** — stdio.h and unistd.h for cc65 and llvm-mos
69+
- **API** — POSIX-like C library for familiar, portable programming
6270
- **cc65** — `VS Code integration for cc65 <https://github.com/picocomputer/vscode-cc65>`__
6371
- **llvm-mos** — `VS Code integration for llvm-mos <https://github.com/picocomputer/vscode-llvm-mos>`__
6472
- **AI Assistance** — The latest models via VS Code extensions or GitHub Copilot

docs/source/os.rst

Lines changed: 66 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,19 @@ as a C declaration like so:
8080

8181
.. c:function:: int doit(int arg0, int arg1);
8282
83-
The RIA has registers called ``RIA_A``, ``RIA_X``, and ``RIA_SREG``. An int is 16 bits,
84-
so we set the ``RIA_A`` and ``RIA_X`` registers with arg1. I'll use "A" for the 6502
85-
register and "RIA_A" for the RIA register in this explanation.
83+
The RIA has registers called ``RIA_A``, ``RIA_X``, and ``RIA_SREG``. An int
84+
is 16 bits, so we set the ``RIA_A`` and ``RIA_X`` registers with arg1. I'll
85+
use "A" for the 6502 register and "RIA_A" for the RIA register in this
86+
explanation.
8687

8788
We use the XSTACK for arg0. Reading ``RIA_XSTACK`` pops bytes; writing
8889
pushes bytes. It's a top-down stack, so push each argument left to
8990
right and maintain little-endian byte order.
9091

91-
To execute the call, store the operation ID in ``RIA_OP``. The operation begins
92-
immediately. You can keep doing 6502 things, like running a loading animation, by
93-
polling ``RIA_BUSY``. Alternatively, JSR to ``RIA_SPIN`` to block.
92+
To execute the call, store the operation ID in ``RIA_OP``. The operation
93+
begins immediately. You can keep doing 6502 things, like running a loading
94+
animation, by polling ``RIA_BUSY``. Alternatively, JSR to ``RIA_SPIN`` to
95+
block.
9496

9597
``JSR RIA_SPIN`` can unblock within 3 clock cycles and immediately loads A
9698
and X. Sequential operations run fastest with this technique. Under the hood,
@@ -116,13 +118,14 @@ flag N. Once clear, we read ``RIA_A`` and ``RIA_X`` with absolute instructions.
116118
LDA RIA_A
117119
LDX RIA_X
118120
119-
All operations returning ``RIA_A`` will also return ``RIA_X`` to assist with C
120-
integer promotion. ``RIA_SREG`` is only updated for 32-bit returns. ``RIA_ERRNO``
121-
is only updated if there is an error.
121+
All operations returning ``RIA_A`` will also return ``RIA_X`` to assist with
122+
C integer promotion. ``RIA_SREG`` is only updated for 32-bit returns.
123+
``RIA_ERRNO`` is only updated if there is an error.
122124

123125
Some operations return strings or structures on the stack. You must pull the
124126
entire stack before the next call. However, tail call optimizations are
125-
possible. For example, you can chain `read_xstack() <READ_XSTACK_>`_ and `write_xstack() <WRITE_XSTACK_>`_ to
127+
possible. For example, you can chain
128+
`read_xstack() <READ_XSTACK>`_ and `write_xstack() <WRITE_XSTACK>`_ to
126129
copy a file without using any RAM or XRAM.
127130

128131
Short Stacking
@@ -153,23 +156,24 @@ Bulk Data
153156
---------
154157

155158
Functions that move bulk data come in two flavors, depending on
156-
where the data lives. A RAM pointer is meaningless to the RIA because it cannot change 6502
157-
RAM. Instead, use the XSTACK or XRAM to move data.
159+
where the data lives. A RAM pointer is meaningless to the RIA because it
160+
cannot change 6502 RAM. Instead, use the XSTACK or XRAM to move data.
158161

159162
Bulk XSTACK Operations
160163
~~~~~~~~~~~~~~~~~~~~~~
161164

162165
These only work if the size is 512 bytes or less. Bulk data is passed on the
163166
XSTACK, which is 512 bytes. A pointer appears in the C prototype to indicate
164-
the type and direction (to or from the OS) of this data. Let's look at some examples.
167+
the type and direction (to or from the OS) of this data. Let's look at some
168+
examples.
165169

166170
.. code-block:: C
167171
168172
int open(const char *path, int oflag);
169173
170174
Send ``oflag`` in ``RIA_A``. ``RIA_X`` doesn't need to be set according to the
171-
`OPEN`_ docs. Send the path on XSTACK by pushing the string starting with the last
172-
character. You may omit pushing the terminating zero, but strings are
175+
`OPEN`_ docs. Send the path on XSTACK by pushing the string starting with
176+
the last character. You may omit pushing the terminating zero, but strings are
173177
limited to a length of 255. Calling this from the C SDK will "just work"
174178
because there's an implementation that pushes the string for you.
175179

@@ -178,18 +182,18 @@ because there's an implementation that pushes the string for you.
178182
int read_xstack(void *buf, unsigned count, int fildes)
179183
180184
Send ``count`` as a short stack and ``fildes`` in ``RIA_A``. ``RIA_X`` doesn't
181-
need to be set according to the `READ_XSTACK`_ docs. The returned value in AX indicates how
182-
many values must be pulled from the stack. If you call this from the C SDK
183-
then it will copy XSTACK to buf[] for you.
185+
need to be set according to the `READ_XSTACK`_ docs. The returned value in
186+
AX indicates how many values must be pulled from the stack. If you call this
187+
from the C SDK then it will copy XSTACK to buf[] for you.
184188

185189
.. code-block:: C
186190
187191
int write_xstack(const void *buf, unsigned count, int fildes)
188192
189193
Send ``fildes`` in ``RIA_A``. ``RIA_X`` doesn't need to be set according to the
190-
`WRITE_XSTACK`_ docs. Push the buf data to XSTACK. Do not send ``count``, the OS knows this
191-
from its internal stack pointer. If you call this from the C SDK then it
192-
will copy count bytes of buf[] to XSTACK for you.
194+
`WRITE_XSTACK`_ docs. Push the buf data to XSTACK. Do not send ``count``,
195+
the OS knows this from its internal stack pointer. If you call this from the
196+
C SDK then it will copy count bytes of buf[] to XSTACK for you.
193197

194198
Note that read() and write() are part of the C SDK, not an OS operation. C
195199
requires these to support a count larger than the XSTACK can return so the
@@ -198,26 +202,26 @@ implementation makes multiple OS calls as necessary.
198202
Bulk XRAM Operations
199203
~~~~~~~~~~~~~~~~~~~~
200204

201-
These load and save XRAM directly via `READ_XRAM`_ and `WRITE_XRAM`_. You can load game assets without
202-
going through 6502 RAM or capture a screenshot with ease.
205+
These load and save XRAM directly via `READ_XRAM`_ and `WRITE_XRAM`_. You can
206+
directly load assets without going through 6502 RAM.
203207

204208
.. code-block:: C
205209
206210
int read_xram(xram_addr buf, unsigned count, int fildes)
207211
int write_xram(xram_addr buf, unsigned count, int fildes)
208212
209-
The OS expects ``buf`` and ``count`` on the XSTACK as integers with ``fildes`` in
210-
``RIA_A``. The OS has direct access to XRAM so internally it will use
211-
something like ``&XRAM[buf]``. You will need to use ``RIA_RW0`` or ``RIA_RW1`` to access
212-
this memory from the 6502.
213+
The OS expects ``buf`` and ``count`` on the XSTACK as integers with
214+
``fildes`` in ``RIA_A``. The OS has direct access to XRAM so internally it
215+
will use something like ``&XRAM[buf]``. You will need to use ``RIA_RW0`` or
216+
``RIA_RW1`` to access this memory from the 6502.
213217

214218
These operations stand out for their high performance and ability to
215219
run in the background while the 6502 does other work. Expect close to
216-
64 KB/sec, meaning a game level's worth of assets loads in under a
217-
second.
220+
512 KB/sec, meaning a full 64KB of XRAM can load or save in under 150ms.
218221

219-
Bulk XRAM operations are why the Picocomputer 6502 was designed without
220-
paged memory.
222+
Bulk XRAM operations are why the Picocomputer 6502 doesn't have paged memory.
223+
It's not necessary when "disk" access has no seek time and can move data as
224+
fast or faster then the CPU.
221225

222226

223227
Application Programmer Interface
@@ -243,10 +247,10 @@ The OS is built around FAT filesystems, the de facto standard for
243247
unsecured USB storage devices. POSIX filesystems are not fully
244248
compatible with FAT but there is a solid intersection of basic IO that is
245249
100% compatible. You will see some familiar POSIX functions like ``open()`` and
246-
others like ``f_stat()`` which are similar to the POSIX function but tailored to
247-
FAT. Should it ever become necessary to have a POSIX ``stat()``, it can be
248-
implemented in the C standard library or in an application by translating
249-
``f_stat()`` data.
250+
others like ``f_stat()`` which are similar to the POSIX function but
251+
tailored to FAT. Should it ever become necessary to have a POSIX ``stat()``,
252+
it can be implemented in the C standard library or in an application by
253+
translating ``f_stat()`` data.
250254

251255
ZXSTACK
252256
-------
@@ -299,14 +303,16 @@ ARGV
299303
.. c:function:: int _argv (char *argv, int size)
300304
301305
302-
The virtual _argv is called by C initialization to provide argc and argv for main().
303-
It returns an array of zero terminated string indexes followed by the strings.
306+
The virtual _argv is called by C initialization to provide argc and
307+
argv for main(). It returns an array of zero terminated string indexes
308+
followed by the strings.
304309
e.g. ["ABC", "DEF"] is 06 00 0A 00 00 00 41 42 43 00 44 45 46 00
305310
The returned data is guaranteed to be valid.
306311
307-
Because this can use up to 512 bytes of RAM you must opt-in by providing storage
308-
for the argv data. You may use static memory, or dynamically allocated memory which
309-
can be freed after use. You may also reject an oversized argv by returning NULL.
312+
Because this can use up to 512 bytes of RAM you must opt-in by
313+
providing storage for the argv data. You may use static memory, or
314+
dynamically allocated memory which can be freed after use. You may also
315+
reject an oversized argv by returning NULL.
310316
311317
.. code-block:: c
312318
@@ -332,12 +338,14 @@ EXEC
332338
333339
The data sent by _exec() will be checked for pointer safety and sanity, but
334340
will assume the path points to a loadable ROM file. If EINVAL is returned,
335-
the argv buffer is cleared so further attempts to _argv() will return an empty set.
336-
If the ROM is invalid, the user will be left on the console with an error message.
341+
the argv buffer is cleared so further attempts to _argv() will return an
342+
empty set. If the ROM is invalid, the user will be left on the console
343+
with an error message.
337344
338345
:Op code: RIA_OP_EXEC 0x09
339346
:C proto: rp6502.h
340-
:returns: Does not return on success — the new ROM begins executing. -1 on error.
347+
:returns: Does not return on success — the new ROM begins
348+
executing. -1 on error.
341349
:errno: EINVAL
342350
343351
@@ -430,8 +438,9 @@ TZSET
430438
char dstname[5]; /* Name when daylight true, e.g. CEST */
431439
};
432440
433-
The virtual _tzset() is called internally by tzset(). Use `help set tz` on the
434-
console monitor to learn about configuring your time zone.
441+
The virtual _tzset() is called internally by tzset(). Use
442+
`help set tz` on the console monitor to learn about configuring your
443+
time zone.
435444
436445
:Op code: RIA_OP_TZSET 0x0D
437446
:C proto: time.h
@@ -784,8 +793,8 @@ STAT
784793
char fname[255 + 1];
785794
} f_stat_t;
786795
787-
Returns file or directory info for requested path.
788-
See the `FatFs documentation <https://elm-chan.org/fsw/ff/doc/sfileinfo.html>`__
796+
Returns file or directory info for requested path. See the
797+
`FatFs documentation <https://elm-chan.org/fsw/ff/doc/sfileinfo.html>`__
789798
for details about the data structure.
790799
791800
:Op code: RIA_OP_STAT 0x1F
@@ -825,8 +834,8 @@ READDIR
825834
.. c:function:: int f_readdir (f_stat_t* dirent, int dirdes)
826835
827836
828-
Returns directory entry info for the current read position of a directory descriptor,
829-
then advances the read position.
837+
Returns directory entry info for the current read position of a
838+
directory descriptor, then advances the read position.
830839
831840
:Op code: RIA_OP_READDIR 0x21
832841
:C proto: rp6502.h
@@ -1162,8 +1171,8 @@ ROM Cartridge Menu
11621171
11631172
The most straightforward use of the launcher is a menu-driven ROM selector,
11641173
analogous to inserting a physical cartridge into a retro console. The launcher
1165-
ROM scans the storage device for ``.rp6502`` files, presents a list to the user,
1166-
and calls `EXEC`_ with the chosen filename. When that ROM stops — whether
1174+
ROM scans the storage device for ``.rp6502`` files, presents a list to the
1175+
user, and calls `EXEC`_ with the chosen filename. When that ROM stops — whether
11671176
normally or due to an error — the process manager automatically re-executes the
11681177
launcher, returning the user to the selection menu.
11691178
@@ -1187,9 +1196,9 @@ OS cannot alter the launcher ROM; OS launchers are meant to stay simple and
11871196
trustworthy. This indirection provides important capabilities:
11881197
11891198
* **Fault recovery** — If the OS kernel encounters a fatal error it cannot
1190-
handle internally, it calls `EXIT`_ rather than locking up. The process manager
1191-
re-executes the launcher, which can choose to relaunch the kernel or take
1192-
some other action.
1199+
handle internally, it calls `EXIT`_ rather than locking up. The process
1200+
manager re-executes the launcher, which can choose to relaunch the kernel
1201+
or take some other action.
11931202
11941203
* **Self-update** — An OS can prepare its own ROM update and call `EXIT`_. The
11951204
launcher detects the pending update, applies it, and boots the new OS ROM —
@@ -1224,9 +1233,9 @@ get-only attribute also returns -1 with ``EINVAL``.
12241233
* - | 0x02
12251234
| ``RIA_ATTR_CODE_PAGE``
12261235
- Active OEM code page used by the filesystem, console, and default
1227-
:doc:`VGA <vga>` font. Reverts to the system setting when the ROM stops. If the
1228-
requested page is unavailable, the system setting is selected;
1229-
follow a set with a get to confirm the result.
1236+
:doc:`VGA <vga>` font. Reverts to the system setting when the ROM
1237+
stops. If the requested page is unavailable, the system setting is
1238+
selected; follow a set with a get to confirm the result.
12301239
One of: 437, 720, 737, 771, 775, 850, 852, 855, 857, 860, 861, 862,
12311240
863, 864, 865, 866, 869, 932, 936, 949, 950.
12321241
* - | 0x03

0 commit comments

Comments
 (0)