93 lines
1.4 KiB
Go
93 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
type TIS_CPU struct {
|
|
nodes [][]TIS_Node
|
|
nodes_per_row int
|
|
}
|
|
|
|
type NodeType int
|
|
|
|
const (
|
|
NODE_TYPE_CODE = iota
|
|
NODE_TYPE_STACK
|
|
)
|
|
|
|
func GetDefaultCPU() *TIS_CPU {
|
|
t := &TIS_CPU{nodes_per_row: 4}
|
|
t.addRow()
|
|
t.addRow()
|
|
return t
|
|
}
|
|
|
|
func (t *TIS_CPU) addRow() bool {
|
|
t.nodes = append(t.nodes, make([]TIS_Node, t.nodes_per_row))
|
|
for i := 0; i < t.nodes_per_row; i++ {
|
|
t.addNode(len(t.nodes) - 1)
|
|
}
|
|
return true
|
|
}
|
|
|
|
func (t *TIS_CPU) addNode(row int) bool {
|
|
if row >= len(t.nodes) {
|
|
return false
|
|
}
|
|
t.nodes[row] = append(t.nodes[row], NewTISCodeNode())
|
|
return true
|
|
}
|
|
|
|
func (t *TIS_CPU) ChangeNodeType(x, y int, new_type NodeType) {
|
|
|
|
}
|
|
|
|
func (t *TIS_CPU) GetNode(x, y int) *TIS_Node {
|
|
if x < t.nodes_per_row && y < len(t.nodes) {
|
|
return &t.nodes[y][x]
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type TIS_Node interface {
|
|
}
|
|
|
|
type TIS_CodeNode struct {
|
|
Reg_ACC int
|
|
Reg_BAK int
|
|
|
|
// Code: 18w by 15h
|
|
code [15]string
|
|
|
|
UpBuffer *TIS_Buffer
|
|
RightBuffer *TIS_Buffer
|
|
DownBuffer *TIS_Buffer
|
|
LeftBuffer *TIS_Buffer
|
|
}
|
|
|
|
func NewTISCodeNode() *TIS_CodeNode {
|
|
return &TIS_CodeNode{}
|
|
}
|
|
|
|
type TIS_StackNode struct {
|
|
stack []int
|
|
max_size int
|
|
}
|
|
|
|
func NewTISStackNode() *TIS_StackNode {
|
|
return &TIS_StackNode{max_size: 15}
|
|
}
|
|
|
|
func (n *TIS_StackNode) addToStack(p int) bool {
|
|
if len(n.stack) < 15 {
|
|
n.stack = append(n.stack, p)
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
/* Buffers are the go-betweens for nodes */
|
|
type TIS_Buffer interface {
|
|
}
|