Skip to content

Commit b11c41f

Browse files
moar
1 parent 9f4ff46 commit b11c41f

File tree

4 files changed

+59
-48
lines changed

4 files changed

+59
-48
lines changed

docs/source/os.rst

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ Introduction
99
============
1010

1111
The :doc:`ria` runs a 32-bit protected operating system that you can call
12-
from the 6502. The :doc:`os` does not use any 6502 system RAM and will not
12+
from the 6502. The OS does not use any 6502 system RAM and will not
1313
interfere with developing a native 6502 OS.
1414

15-
The :doc:`os` loosely follows POSIX with an Application Binary
15+
The OS loosely follows POSIX with an Application Binary
1616
Interface (ABI) similar to `cc65's fastcall
1717
<https://cc65.github.io/doc/cc65-intern.html>`__. It provides stdio.h and
1818
unistd.h services to both `cc65 <https://cc65.github.io>`__ and `llvm-mos
@@ -58,7 +58,7 @@ Application Binary Interface
5858

5959
The ABI for calling the operating system is based on fastcall from the
6060
`cc65 internals <https://cc65.github.io/doc/cc65-intern.html>`__. The
61-
:doc:`os` does not use or require anything from cc65 and is easy for
61+
OS does not use or require anything from cc65 and is easy for
6262
assembly programmers to use. At its core, the OS ABI is four simple rules.
6363

6464
* Stack arguments are pushed left to right.
@@ -145,16 +145,16 @@ below as "A regs".
145145
Bulk Data
146146
---------
147147

148-
Functions that move bulk data may come in two flavors. These are any
149-
function with a mutable pointer parameter. A RAM pointer is meaningless to the RIA because it cannot change 6502
148+
Functions that move bulk data come in two flavors, depending on
149+
where the data lives. A RAM pointer is meaningless to the RIA because it cannot change 6502
150150
RAM. Instead, use the XSTACK or XRAM to move data.
151151

152152
Bulk XSTACK Operations
153153
~~~~~~~~~~~~~~~~~~~~~~
154154

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

159159
.. code-block:: C
160160
@@ -200,7 +200,7 @@ going through 6502 RAM or capture a screenshot with ease.
200200
int write_xram(xram_addr buf, unsigned count, int fildes)
201201
202202
The OS expects `buf` and `count` on the XSTACK as integers with `filedes` in
203-
RIA_A. The :doc:`os` has direct access to XRAM so internally it will use
203+
RIA_A. The OS has direct access to XRAM so internally it will use
204204
something like &XRAM[buf]. You will need to use RIA_RW0 or RIA_RW1 to access
205205
this memory from the 6502.
206206

@@ -227,8 +227,8 @@ below has reordered arguments that are optimized for short stacking the long
227227
argument. But you don't have to call f_lseek() from C, you can call the
228228
usual lseek() which has the traditional argument order.
229229

230-
The :doc:`os` is built around FAT filesystems, which is the defacto
231-
standard for unsecured USB storage devices. POSIX filesystems are not fully
230+
The OS is built around FAT filesystems, the de facto standard for
231+
unsecured USB storage devices. POSIX filesystems are not fully
232232
compatible with FAT but there is a solid intersection of basic IO that is
233233
100% compatible. You will see some familiar POSIX functions like open() and
234234
others like f_stat() which are similar to the POSIX function but tailored to
@@ -329,8 +329,8 @@ LRAND
329329
330330
|
331331
332-
Generates a random number starting with entropy on the RIA. This is
333-
suitable for seeding a RNG or general use. The 16-bit rand() in the cc65
332+
Generates a 32-bit random number seeded with hardware entropy
333+
from the RIA. Suitable for seeding a PRNG or direct use. The 16-bit rand() in the cc65
334334
library can be seeded with this by calling its non-standard _randomize()
335335
function.
336336
@@ -351,8 +351,10 @@ STDIN_OPT
351351
buffer size - 1 to make gets() safe. This can also guarantee no split
352352
lines when using fgets() on STDIN.
353353
354-
*** Experimental *** Likely to be replaced with stty-like something. Drop
355-
your thoughts on the forums if you have specific needs.
354+
.. note::
355+
356+
**Experimental.** Likely to be replaced with a stty-like interface.
357+
Share your thoughts on the forums if you have specific needs.
356358
357359
:Op code: RIA_OP_STDIN_OPT 0x05
358360
:C proto: rp6502.h
@@ -374,13 +376,13 @@ ERRNO_OPT
374376
375377
|
376378
377-
:doc:`os` calls will set RIA_ERRNO when an error occurs. This is used to
379+
OS calls will set RIA_ERRNO when an error occurs. This is used to
378380
select which set of values to use because the compiler libraries each use
379381
different constants in errno.h. Both cc65 and llvm-mos call this
380382
automatically in the C runtime. The RIA_ERRNO behavior is undefined until
381383
it is set. Note that the C `errno` maps directly to RIA_ERRNO.
382384
383-
:doc:`os` will map FatFs errors onto errno. RP6502 emulation and
385+
The OS will map FatFs errors onto errno. RP6502 emulation and
384386
simulation software is expected to map their native errors as well. The
385387
table below shows the FatFs mappings. Because FatFs is so integral to the
386388
OS, calls are documented here with their native FatFs errors to assist

docs/source/ria.rst

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -131,30 +131,35 @@ Registers
131131
- Write the OS operation id here to begin an OS call.
132132
* - $FFF0
133133
- IRQ
134-
- Set bit 0 high to enable VSYNC interrupts. Verify source
135-
with VSYNC increment then read or write this register to clear
136-
interrupt.
134+
- Set bit 0 high to enable VSYNC interrupts. To clear the
135+
interrupt, first verify the source by checking the VSYNC
136+
counter, then read or write this register.
137137
* - $FFF1
138138
- RETURN
139-
- Always $80, BRA. Entry to blocking OS call.
139+
- Always $80 (the BRA opcode). JSR here to spin-wait for an
140+
OS call: the CPU loops on this BRA until BUSY clears, then
141+
falls through to LDA and LDX below.
140142
* - $FFF2
141143
- BUSY
142144
- Bit 7 high while OS operation is running.
143145
* - $FFF3
144146
- LDA
145-
- Always $A9.
147+
- Always $A9 (the LDA immediate opcode). Part of the
148+
spin-loop return sequence.
146149
* - $FFF4
147150
- A
148151
- OS call register A.
149152
* - $FFF5
150153
- LDX
151-
- Always $A2.
154+
- Always $A2 (the LDX immediate opcode). Part of the
155+
spin-loop return sequence.
152156
* - $FFF6
153157
- X
154158
- OS call register X.
155159
* - $FFF7
156160
- RTS
157-
- Always $60.
161+
- Always $60 (the RTS opcode). Ends the spin-loop return
162+
sequence, returning to the caller with A and X loaded.
158163
* - | $FFF8 -
159164
| $FFF9
160165
- SREG
@@ -190,10 +195,10 @@ portal would make moving XRAM very slow since data would have to
190195
buffer in 6502 RAM. Ideally, you won't move XRAM and can use the pair
191196
for better optimizations.
192197

193-
STEP0 and STEP1 are reset to 1. These are signed so you can go
194-
backwards and reverse data. These adders allow for very fast sequential
195-
access, which typically makes up for the slightly slower random access
196-
compared to 6502 system RAM.
198+
STEP0 and STEP1 default to 1 after reset. Both are signed, so
199+
negative values traverse XRAM in reverse. These auto-increment
200+
adders enable very fast sequential access, which more than offsets
201+
the slightly slower random access compared to 6502 system RAM.
197202

198203
Extended Stack (XSTACK)
199204
-----------------------
@@ -314,9 +319,10 @@ in XRAM.
314319
xreg_ria_keyboard(xaddr); // macro shortcut
315320
316321
The RIA continuously updates XRAM with a bit array of USB HID
317-
keyboard codes. Note that these are not PS/2 scancodes.
318-
Each bit represents one key with the first four bits/codes having special
319-
meaning:
322+
keyboard keycodes. Note that these are not PS/2 scancodes.
323+
Each keycode is one bit in the array — bit N is 1 when the key
324+
with HID keycode N is currently pressed. The first four keycodes
325+
have special meaning:
320326

321327
- 0 - No key pressed
322328
- 1 - Num Lock on
@@ -402,7 +408,7 @@ use a specific gamepad or include a "AB or BA" option.
402408
Retro-style gamepads are designed with button mappings for emulators while
403409
emulators expect the button layout of a modern gamepad. These do not cancel
404410
each other out. Instead, you end up with wonky button mappings that do not
405-
follow the defacto standard for modern gamepads.
411+
follow the de facto standard for modern gamepads.
406412

407413
Enable and disable access to the RIA gamepad XRAM registers by setting
408414
the extended register. The register value is the XRAM start address of
@@ -513,9 +519,9 @@ with extended register device 0 channel 1 address 0x00.
513519
* Stereo panning.
514520
* PWM for all waveforms.
515521

516-
Each of the eight oscillators requires eight bytes of XRAM for
517-
configuration. The unused byte is padding so multiplication is a fast
518-
bit shift.
522+
Each of the eight oscillators uses eight bytes of XRAM for
523+
configuration. The structure size is a power of two so indexing
524+
into the oscillator array is a bit shift rather than a multiply.
519525

520526
.. code-block:: C
521527
@@ -557,13 +563,13 @@ shenanigans.
557563
- 0-255 (0-100%) Duty cycle of oscillator. This affects all
558564
waveforms.
559565
* - vol_attack
560-
- Attack volume and rate.
566+
- Attack phase volume and rate.
561567

562568
* bits 7-4 - 0-15 volume attenuation.
563569
* bits 3-0 - 0-15 attack rate.
564570

565571
* - vol_decay
566-
- Decay volume and rate.
572+
- Decay phase volume and rate.
567573

568574
* bits 7-4 - 0-15 volume attenuation.
569575
* bits 3-0 - 0-15 decay rate.
@@ -676,10 +682,10 @@ registers. The OPL2 registers must begin on a page boundary.
676682
If, for example, xaddr is 0x4200 then the 256 registers of an OPL2 chip
677683
are mapped into XRAM from 0x4200 to 0x42FF.
678684

679-
Timers, interrupts, and the status register are not supported and were
680-
not widely used. These were in Yamaha OPL chips to assist with cost
681-
reducing consumer devices and rarely used in computers which had their
682-
own timers.
685+
Timers, interrupts, and the status register are not supported.
686+
These features existed in Yamaha OPL chips primarily to help
687+
cost-reduce consumer devices; computers of the era had their own
688+
timers and rarely used them.
683689

684690

685691
Virtual Communications Port
@@ -740,7 +746,8 @@ and ``len`` bytes of raw binary data:
740746
* - Field
741747
- Description
742748
* - ``addr``
743-
- Destination address in 6502 RAM or XRAM.
749+
- Destination address in 6502 RAM (0x0000-0xFEFF) or XRAM
750+
(0x10000-0x1FFFF).
744751
* - ``len``
745752
- Number of raw binary bytes that immediately follow this line.
746753
* - ``crc``

docs/source/ria_w.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Introduction
99
============
1010

1111
The **RP6502 Interface Adapter W** is a Raspberry Pi Pico 2 W running
12-
the RP6502-RIA-W firmware. The :doc:`ria_w` provides all the features
12+
the RP6502-RIA-W firmware. It provides all the features
1313
of the :doc:`ria` plus wireless services, as described below.
1414

1515

@@ -44,7 +44,7 @@ Network Time Protocol (NTP)
4444
===========================
4545

4646
The real-time clock (RTC) automatically synchronizes with internet time
47-
servers when connected. Check NTP status with the ``status`` command.
47+
servers when connected to WiFi. Check NTP status with the ``status`` command.
4848

4949
- **Set Time Zone:**
5050
To use local time instead of UTC, set your time zone with ``SET TZ``.
@@ -57,7 +57,7 @@ Once WiFi and time zone are configured, timekeeping is automatic.
5757
Modem Emulation
5858
===============
5959

60-
The :doc:`ria_w` can emulate a Hayes modem for BBS access. Raw TCP and
60+
The RP6502-RIA-W can emulate a Hayes modem for BBS access. Raw TCP and
6161
telnet connections are unencrypted in transit.
6262

6363
- **AT Commands:**
@@ -81,7 +81,7 @@ Example AT commands:
8181
- ``AT&V`` — View profile
8282
- ``AT&W`` — Write profile to NVRAM
8383
- ``AT&Z0=example.com:23`` — Save "telephone number" to NVRAM
84-
- ``AT+RF=your_ssid`` and ``AT+RF?`` — Access RIA setting RF
84+
- ``AT+RF=0`` or ``AT+RF=1`` and ``AT+RF?`` — Access RIA setting RF
8585
- ``AT+RFCC=your_ssid`` and ``AT+RFCC?`` — Access RIA setting RFCC
8686
- ``AT+SSID=your_ssid`` and ``AT+SSID?`` — Access RIA setting SSID
8787
- ``AT+PASS=your_pass`` and ``AT+PASS?`` — Access RIA setting PASS
@@ -96,7 +96,7 @@ profiles.
9696
Bluetooth
9797
=========
9898

99-
The :doc:`ria_w` supports Bluetooth LE (BLE) keyboards, mice, and
99+
The RP6502-RIA-W supports Bluetooth LE (BLE) keyboards, mice, and
100100
gamepads. Bluetooth Classic (BR/EDR) is not supported.
101101
BLE has been widely available since Bluetooth 4.0 (June 2010),
102102
so compatible devices are easy to find, though the occasional oddball

docs/source/vga.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Introduction
88
=============
99

1010
The RP6502 Video Graphics Array is a Raspberry Pi Pico 2 with
11-
:doc:`vga` firmware. Its primary data connection is to a :doc:`ria`
11+
RP6502-VGA firmware. Its primary data connection is to a :doc:`ria`
1212
over a 5-wire PIX bus. More than one VGA module can be put on a PIX
1313
bus. Note that all VGA modules share the same 64K of XRAM and only
1414
the first one will generate frame numbers and vsync interrupts.
@@ -46,8 +46,10 @@ ANSI palette of 16 colors, followed by 216 colors (6x6x6), followed
4646
by 24 greys.
4747

4848
16-bit colors are built with the following bit logic. Setting the
49-
alpha bit will make the color opaque. The built-in ANSI color
50-
palette has the alpha bit set on all colors except color 0 black.
49+
alpha bit makes the color opaque; clearing it makes the color
50+
transparent. Despite the name, this is a binary flag, not a
51+
blending factor. The built-in ANSI color palette has the alpha bit
52+
set on all colors except color 0 (black), which is transparent.
5153

5254
.. code-block:: C
5355

0 commit comments

Comments
 (0)