Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions antora/modules/ROOT/nav.adoc
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* xref:index.adoc[]
* xref:8bit.adoc[]
182 changes: 182 additions & 0 deletions docs/aam-specification-1.1-8bit.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
= Å-machine 8-bit Addendum

This document describes target-specific conventions that layer on top of the
main Å-machine specification, for the 6502 engines (Commodore 64, Apple II,
and the aambox test platform). All other parts of the main specification apply
unchanged.

The main specification is the versioned document `aam-specification-1.1.adoc`;
where this addendum and the main document disagree about a 6502 target, this
addendum wins.

== Changes in v1.1

* The `USTY` chunk replaces `LOOK` on 8-bit targets.
* 8-bit interpreters no longer parse CSS at startup. The style table is
precompiled by the bundler.

== The USTY chunk

`USTY` is produced by `aambundle` when targeting an 8-bit platform. It is a
direct substitute for `LOOK` in the same class index space, so every
`ENTER_DIV`, `ENTER_SPAN`, `SET_BODY`, and `ENTER_STATUS` operand keeps its
meaning; nothing in the `CODE` chunk needs rewriting.

This chunk is not intended to be emitted by the Dialog compiler. The bundler
drops `LOOK` and creates `USTY` in its place.

A `USTY` table is target-specific: it is built for the palette and
capabilities of the machine it ships beside.

The bundler may produce a `.ustory` file containing the `USTY` chunk for
debugging purposes. These are not valid Aa-machine stories and should not
be distributed.

=== Tag byte

* `BYTE`: "tag", target in the high nibble, format version in the low nibble

[cols="1,1,4"]
|===
| Tag | Target | Notes
| `0x00` | aambox | test platform; no styling beyond geometry
| `0x10` | Commodore 64 | per-character foreground color
| `0x20` | Apple II | reverse video only
|===

The USTY format is identified by integer, which is truncated to 0..15 and
put in the low nibble.

Version 0 is described here.

=== Header

* `BYTE`: "nclass", number of style classes (1..255)
* `BYTE`: "nxsty", number of body records (0..255)
* `BYTE`: reserved, written as 0
* `WORD`: "totalwords", size in words of the resident table (big-endian)
* `WORD`: "xstyoff", offset of the body array from the record base, i.e. from
byte 8 (big-endian)

Immediately after the header come `nclass` class records, eight bytes each,
indexed directly by class number:

----
0 width ; columns, or percent if relw
1 height ; rows, or percent if relh
2 margin-top ; rows
3 margin-bottom ; rows
4 styon ; style bits to set
5 styoff ; style bits to reset
6 flags ; see below
7 fg ; foreground color, $80 = inherit, $81 = initial
----

`styon`/`styoff` use the same bit values as the main specification:

----
$01 reverse
$02 bold
$04 italic
$08 fixed
----

A bit that the target cannot render is masked out of both bytes before the
table is written, so it can be ignored by the interpreter:

[cols="1,1,3"]
|===
| Target | Mask | Notes
| aambox | `$00` | no styling
| Commodore 64 | `$01 \| $02 \| $04` | fixed is not rendered
| Apple II | `$01` | reverse only
|===

`fg` is a target palette index, or one of two sentinels, which are
recognized by having bit 7 set:

[cols="1,4"]
|===
| Value | Meaning

| `$80` | `inherit`. Keep the explicit color selected by the enclosing
elements. This is a no-op, and is also what `transparent` maps to.
| `$81` | `initial`. Discard the explicit color selected by the enclosing
elements and fall back to the color implied by the current style bits.
|===

Colors appear only on the Commodore 64, whose palette is the
standard 16-entry VIC-II palette. The parser accepts one of the canonical
color names below, or a bare index 0..15.

[cols="1,2,2,1,2,2"]
|===
| Index | Name | Reference | Index | Name | Reference

| 0 | `black` | `#000000` | 8 | `orange` | `#dd8855`
| 1 | `white` | `#ffffff` | 9 | `brown` | `#664400`
| 2 | `red` | `#880000` | 10 | `lightred` | `#ff7777`
| 3 | `cyan` | `#aaffee` | 11 | `darkgrey` | `#333333`
| 4 | `purple` | `#cc44cc` | 12 | `mediumgrey` | `#777777`
| 5 | `green` | `#00cc55` | 13 | `lightgreen` | `#aaff66`
| 6 | `blue` | `#0000aa` | 14 | `lightblue` | `#0088ff`
| 7 | `yellow` | `#eeee77` | 15 | `lightgrey` | `#bbbbbb`
|===

The reference RGB values are given only to help choose a color; the bundler
does not accept RGB notation in a style declaration.
Hex (`#rgb`/`#rrggbb`) and `rgb()`/`rgba()` values are rejected with a
warning.

If a class specifies both a color and bold/italic styling, the color takes
precedence on the Commodore 64: the frontend uses the explicit color instead
of the palette entry it would otherwise choose for the style bits.

=== Flags

----
$01 relw ; width is a percentage of the parent width (0-100)
$02 relh ; height is a percentage of the parent height (0-100)
$40 floatl ; float: left
$80 floatr ; float: right
----

Bits 2..5 are reserved and written as 0.

=== The body array

The class records are followed by the body array, at `xstyoff` bytes past the
record base. Each record is

----
0 index ; raw class index; $ff ends the array
1 datalen ; number of data bytes that follow
2 data[datalen]
----

and the array is a single `$ff` index byte when empty. The array is scanned,
not indexed, by the opcode that consumes it.
The chunk is padded to an even length so that `totalwords * 2` is exactly the
size of the resident table.

No target emits body records in
version 0; the layout is fixed here so that they can be added without moving
the class records.

== Conditional declarations

A style declaration whose key begins `-iftf-sys-<target>-` applies only to the
named target, where `<target>` is `c64`, `apple2`, or `aambox`. So

----
-iftf-sys-c64-color: red
----

sets the foreground color on the Commodore 64 and is ignored elsewhere. A
prefixed declaration overrides an unprefixed declaration of the same property,
regardless of their order in the style sheet.

Because the bundler parses `LOOK` into `USTY`, it is the bundler that decides
what a declaration means. It warns about, and otherwise ignores, unrecognized
properties and unknown targets. The 8-bit interpreter never sees the original
style sheet.
5 changes: 5 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ Project website:

Release notes:

1.0.4:

Aambundle now replaces the LOOK chunk with an internal USTY
chunk for 6502 targets. Use --help-all to see new warnings.

1.0.3:

New Apple II interpreter:
Expand Down
6 changes: 3 additions & 3 deletions src/6502/Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
VERSION=1.1.0
CFLAGS=-Wall -O2 -DVERSION=\"$(VERSION)\"

all: aambox6502 aambox_frontend.bin c64_crunched.bin c64_drivecode.bin c64_loader.prg a2.system a2_0boot.bin a2_sboot.bin
all: aambox6502 aambox_frontend.bin c64_crunched.bin c64_drivecode.bin c64_loader.prg a2.system a2_0boot.bin a2_sboot.bin

check_xa:
@if ! command -v xa >/dev/null 2>&1; then \
Expand All @@ -20,7 +20,7 @@ check_acme:
exit 1; fi

clean:
rm -rf aambox6502 cruncher labels c64.labels mkfont
rm -rf aambox6502 aambox_frontend.bin cruncher labels c64.labels mkfont
rm -f a2_frontend.bin a2_prorwts2.bin a2.labels a2.system a2_0boot.bin a2_sboot.bin a2_sboot.labels

mkfont: mkfont.c
Expand All @@ -35,7 +35,7 @@ aambox_frontend.bin: aambox_frontend.s engine.s | check_xa
xa -l aambox.labels -o $@ $< -DRAMTOP=49152

c64_frontend.bin: c64_frontend.s engine.s font.bin | check_xa
xa -l c64.labels -o $@ $< -DVERSION=\"$(VERSION)\"
xa -l c64.labels -P c64_frontend.lst -o $@ $< -DVERSION=\"$(VERSION)\"

font.bin: fontdef.txt mkfont
./mkfont <$< >$@
Expand Down
1 change: 1 addition & 0 deletions src/6502/a2_frontend.s
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ HAVE_STATUS = 1
HAVE_STYLE = 0 ; reverse alone is not enough to qualify
SAVERESTORE = 1
UNDO = 1
FGCOLOR = 0

TRACE_INST = 0
TRACE_STORE = 0
Expand Down
1 change: 1 addition & 0 deletions src/6502/aambox_frontend.s
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ PRSHIFT = 0
HAVE_QUIT = 1
HAVE_STATUS = 0
HAVE_STYLE = 0
FGCOLOR = 0

wrappos = $00
xpos = $01
Expand Down
13 changes: 12 additions & 1 deletion src/6502/c64_frontend.s
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ TRACE_STORE = 0
MEASURE_TIME = 0
UNDO = 1
SAVERESTORE = 1
FGCOLOR = 1

DEFWIDTH = 40
PREXTRA = 8
Expand Down Expand Up @@ -509,9 +510,12 @@ io_mstyle
; input a = style bits
; 1 reverse, 2 bold, 4 italic
; Or on C64:
; 1 warm, 2 light, 4 saturated
; 1 warm, 2 light, 4 blue
; input x = fg color or $80 if unset

.(
cpx #0
bpl color_override
pha
jsr io_mflush
pla
Expand All @@ -520,6 +524,13 @@ io_mstyle
lda palette,x
sta currfg
rts
color_override
txa
pha
jsr io_mflush
pla
sta currfg
rts
palette
.byt $0 ; normal = black
.byt $1 ; reverse = white (warm)
Expand Down
Loading
Loading