Skip to content

Commit

Permalink
Alter memorymap layout to support constant definitions. Add sinclair …
Browse files Browse the repository at this point in the history
…basic tokens
  • Loading branch information
peter-mount committed Nov 3, 2021
1 parent 1f3dcdf commit d2f7544
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 3 deletions.
10 changes: 10 additions & 0 deletions content/sinclair/spectrum/basic/_index.html
@@ -0,0 +1,10 @@
---
type: "manual"
title: "Basic"
linkTitle: "Basic"
description: "Notes on BASIC for the Spectrum"
weight: 60
categories:
- spectrum
#no_list: true
---
33 changes: 33 additions & 0 deletions content/sinclair/spectrum/basic/tokens/_index.html
@@ -0,0 +1,33 @@
---
type: "manual"
title: "Basic Tokens"
linkTitle: "Basic Tokens"
description: "Tokens used to store BASIC programs in memory"
categories:
- spectrum
no_list: true
memorymap:
- name: "BAS_CODE"
value: 0xAF
desc: "CODE"
- name: "BAS_CLEAR"
value: 0xFD
desc: "CLEAR statement"
- name: "BAS_LOAD"
value: 0xEF
desc: "LOAD statement"
- name: "BAS_PRINT"
value: 0xF5
desc: "PRINT statement"
- name: "BAS_RANDOMIZE"
value: 0xF9
desc: "RANDOMIZE statement"
- name: "BAS_USR"
value: 0xC0
desc: "USR function"

---
<h3>BASIC Tokens</h3>
<p>
This table is currently incomplete, but it is enough for the Machine Code examples.
</p>
15 changes: 13 additions & 2 deletions themes/area51/layouts/partials/6502/memorymap.html
@@ -1,25 +1,32 @@
{{- if isset .Params "memorymap" -}}
{{- $hasAddr := 0 -}}
{{- $hasLen := 0 -}}
{{- $hasName := 0 -}}
{{- $hasVal := 0 -}}
{{- $hasFormat := 0 -}}
{{- $hasDefaultVal := 0 -}}
{{- range $.Params.memorymap -}}
{{- with .address}}{{$hasAddr =1}}{{end -}}
{{- with .length}}{{$hasLen =1}}{{end -}}
{{- with .name}}{{$hasName =1}}{{end -}}
{{- with .value}}{{$hasVal =1}}{{end -}}
{{- with .format}}{{$hasFormat =1}}{{end -}}
{{- with .default}}{{$hasDefaultVal =1}}{{end -}}
{{- end -}}
<div class="printPageBreakAvoid">
<table class="memory">
<thead>
<tr>
<th>Address</th>
{{- if $hasAddr -}}<th>Address</th>{{- end -}}
{{- if $hasLen -}}
<th>Len</th>
{{- end -}}
{{- if $hasName -}}
<th>Name</th>
{{- end -}}
{{- if $hasVal -}}
<th>Value</th>
{{- end -}}
{{- if $hasFormat -}}
<th>Bit 7</th>
<th>Bit 6</th>
Expand All @@ -39,14 +46,18 @@
<tbody>
{{- range $.Params.memorymap -}}
<tr>

{{- if $hasAddr -}}
<td {{- if isset . "offset"}} class="offset"{{end}}>{{.address}}</td>
{{- end -}}
{{- if $hasLen -}}
<td>{{.length}}</td>
{{- end -}}
{{- if $hasName -}}
<td>{{.name}}</td>
{{- end -}}
{{- if $hasVal -}}
<td>{{.value}}</td>
{{- end -}}

{{- if $hasFormat -}}
{{- with .format -}}
Expand Down
8 changes: 7 additions & 1 deletion tools/generator/autodoc/extract.go
Expand Up @@ -44,9 +44,15 @@ func (s *Autodoc) extractMemoryMap(ctx context.Context, fm *hugo.FrontMatter) er

return util2.ForEachInterface(ctx.Value("other"), func(e interface{}) error {
return util2.IfMap(e, func(m map[interface{}]interface{}) error {
var val string
if e, exists := m["address"]; exists {
val = "0x" + util2.DecodeString(e, "") // Valid as address is always in hex
} else if e, exists := m["value"]; exists {
val = util2.DecodeString(e, "")
}
return headers.Add(&Header{
Label: util2.DecodeString(m["name"], ""),
Value: "0x" + util2.DecodeString(m["address"], ""), // Valid as address is always in hex
Value: val,
Comment: util2.DecodeString(m["desc"], ""),
})
})
Expand Down

0 comments on commit d2f7544

Please sign in to comment.