Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Assemble strings in most basic form of DAT opcode

  • Loading branch information...
commit 697e97ab36ac01873b8d22e4e426de3271326ad3 1 parent 7add31c
Scott Ferguson authored
Showing with 23 additions and 36 deletions.
  1. +21 −21 asm/notchtest3.dasm
  2. +0 −2  assembler.go
  3. +0 −2  main.go
  4. +2 −11 video.go
42 asm/notchtest3.dasm
View
@@ -2,28 +2,28 @@
; http://i.imgur.com/XIXc4.jpg
; Supposed to show formatting.
:start
- set i, 0
- set j, 0
- set b, 0xf100
+ SET I, 0
+ SET J, 0
+ SET B, 0xf100
:nextchar
- set a, [data+i]
- ife a, 0
- set PC, end
- ifg a, 0xff
- set PC, setcolor
- bor a, b
- set [0x8000+j], a
- add i, 1
- add j, 1
- set PC, nextchar
+ SET A, [data+I]
+ IFE A, 0
+ SET PC, end
+ IFG A, 0xff
+ SET PC, setcolor
+ BOR A, B
+ SET [0x8000+J], A
+ ADD I, 1
+ ADD J, 1
+ SET PC, nextchar
:setcolor
- set b, a
- and b, 0xff
- shl b, 8
- ifg a, 0x1ff
- add b, 0x80 ; Add high bit to each character we color. So the character must be 7-bit ASCII
- add i, 1
- set PC, nextchar
+ SET B, A
+ AND B, 0xff
+ SHL B, 8
+ IFG A, 0x1ff
+ ADD B, 0x80 ; Add high bit to each character we color. So the character must be 7-bit ASCII
+ ADD I, 1
+ SET PC, nextchar
:data
dat 0x170, "Hello ", 0x2e1, "world", 0x170, ", how are you?", 0
; Color format:
@@ -34,4 +34,4 @@
; ANSI says: black is 0, white is 7, yellow is 3, blue is 4
; If black is 0 and grey is 7, it's <FORE> <BACK> <EXTRA BIT> or <FORE> <EXTRA BIT> <BACK>
:end
- set PC, start
+ SET PC, start
2  assembler.go
View
@@ -417,8 +417,6 @@ func main() {
instruction := op + (a << 4) + (b << 10)
- // fmt.Printf("%s: 0x%x\n", line, instruction)
-
writeToBuffer(instruction, nextAWord, nextBWord)
lineNumber++
2  main.go
View
@@ -4,7 +4,6 @@ import (
"github.com/nsf/termbox-go"
"io/ioutil"
"os"
- "fmt"
)
func run(program []Word) {
@@ -55,7 +54,6 @@ func main() {
var program []Word
for i := 0; i < fileLength; i += 2 {
- fmt.Printf("%d | %d\n", i, i + 1)
program = append(program, (Word(contents[i]) << 8) + Word(contents[i + 1]))
}
13 video.go
View
@@ -2,7 +2,6 @@ package main
import (
"github.com/nsf/termbox-go"
- // "fmt"
)
type Video struct {}
@@ -46,22 +45,14 @@ func (v *Video) DrawScreen() {
for x := 0; x < 32; x++ {
data := Memory[0x8000 + i]
- if data > 0 {
- // fmt.Printf("Value: %X\n", data)
- }
-
- /*
- colors := data >> 8
+ colors := data >> 7
fg := GetColor(colors & 0xf)
bg := GetColor(colors >> 4)
- */
character := rune(data & 0x7f)
- termbox.SetCell(x, y, character, termbox.ColorDefault, termbox.ColorDefault)
+ termbox.SetCell(x, y, character, fg, bg)
-// character := rune(data & 0x7f)
-// termbox.SetCell(x, y, character, termbox.ColorDefault, termbox.ColorDefault)
i++
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.