Documentation ¶
Index ¶
- Constants
- Variables
- func SaveCartToFile(filename string, cart Cart) error
- type Cart
- type Command
- type Controller
- type Instruction
- type Machine
- func (vm *Machine) AddRAMListener(trigAddrs []byte, lnr RAMListener)
- func (vm *Machine) ExecuteCommand(cmd Command)
- func (vm *Machine) LoadCartridge(c *Cart)
- func (vm *Machine) LoadCartridgeFile(filename string)
- func (vm *Machine) PlugIn(prph Peripheral)
- func (vm *Machine) Reset()
- func (vm *Machine) Tick()
- func (vm *Machine) TickPeripherals()
- type MemMonitor
- type Nybble
- type Peripheral
- type RAMListener
- type Screen
- type SoundCard
- type Tone
Constants ¶
View Source
const ( SIZE_PROG = 256 SIZE_DATA = 4096 FILE_MODE = 0650 )
View Source
const ( CKI_UP = 0 CKI_DOWN = 1 CKI_LEFT = 2 CKI_RIGHT = 3 CKI_A = 4 CKI_B = 5 CKI_X = 6 CKI_Y = 7 )
Key indices
View Source
const ( FPG_P1_DPAD = 0x0 // Player 1 Direction-Pad FPG_P1_BTNS = 0x1 // Player 1 Buttons FPG_P2_DPAD = 0x2 // Player 2 Direction-Pad FPG_P2_BTNS = 0x3 // Player 2 Buttons FPG_SCR_X = 0x4 // Screen X Coord FPG_SCR_Y = 0x5 // Screen Y Coord FPG_SCR_VAL = 0x6 // Screen Pixel Value FPG_SCR_OPT = 0x7 // Screen Options FPG_SND_VOL = 0x8 // Sound Card Volume FPG_SND_PTC = 0x9 // Sound Card Pitch FPG_SND_OPT = 0xA // Sound Card reserved FPG_RAND = 0xB // Pseudo-Random Number FPG_DSK_H = 0xC // High-nyble of disk address \ FPG_DSK_M = 0xD // Middle-nyble of disk address } 12-bit Address FPG_DSK_L = 0xE // Low-nyble of disk address / FPG_DSK_VAL = 0xF // Value of the selected disk nyble )
F-page Addresses
View Source
const ( OCTAVE_2 = 0 OCTAVE_3 = 1 OCTAVE_4 = 2 OCTAVE_5 = 3 )
View Source
const ( WAVE_SQUARE = 0 WAVE_TRIANGLE = 1 WAVE_SAWTOOTH = 2 WAVE_NOISE = 3 )
View Source
const (
PERIPHERAL_PAGE = 0xF
)
View Source
const PNUM_CHAR = "#"
View Source
const SEMITONE_INTERVAL = 1.059463
Variables ¶
View Source
var ALL_INS = [16]Instruction{
{
Opcode: "BRK",
Binary: 0b0000,
Nargs: 0,
},
{
Opcode: "LDA imm.",
Binary: 0b0001,
Nargs: 1,
},
{
Opcode: "LDA mem.",
Binary: 0b0010,
Nargs: 2,
},
{
Opcode: "STA",
Binary: 0b0011,
Nargs: 2,
},
{
Opcode: "IDC",
Binary: 0b0100,
Nargs: 2,
},
{
Opcode: "ADD",
Binary: 0b0101,
Nargs: 2,
},
{
Opcode: "---",
Binary: 0b0110,
Nargs: 0,
},
{
Opcode: "---",
Binary: 0b0111,
Nargs: 0,
},
{
Opcode: "NOT",
Binary: 0b1000,
Nargs: 0,
},
{
Opcode: "ORA",
Binary: 0b1001,
Nargs: 2,
},
{
Opcode: "AND",
Binary: 0b1010,
Nargs: 2,
},
{
Opcode: "SHF",
Binary: 0b1011,
Nargs: 1,
},
{
Opcode: "SLP",
Binary: 0b1100,
Nargs: 2,
},
{
Opcode: "BNE",
Binary: 0b1101,
Nargs: 2,
},
{
Opcode: "JMP imm.",
Binary: 0b1110,
Nargs: 2,
},
{
Opcode: "JMP mem.",
Binary: 0b1111,
Nargs: 2,
},
}
All Instructions
View Source
var BMP_NO_CART = [16]uint16{
0b0000000000000000,
0b0001000101111000,
0b0001100101001000,
0b0001010101001000,
0b0001001101001000,
0b0001000101001000,
0b0001000101111000,
0b0000000000000000,
0b0000000000000000,
0b0110111011101110,
0b0100101010100100,
0b0100101010100100,
0b0100111011000100,
0b0100101010100100,
0b0110101010100100,
0b0000000000000000,
}
"No Cart" Screen
View Source
var MON_CLR = rl.SkyBlue
Functions ¶
func SaveCartToFile ¶
Types ¶
type Cart ¶
func LoadCartFromFile ¶
func (*Cart) GetListener ¶
func (c *Cart) GetListener(vm *Machine) ([]byte, RAMListener)
type Command ¶
type Command struct { Ins Instruction Args []Nybble }
type Controller ¶
func NewController ¶
func NewController(playerNr int) *Controller
func (*Controller) ButtonStatus ¶
func (c *Controller) ButtonStatus(cki int) Nybble
Returns the status (0/1) of whether a given button is pressed
func (*Controller) GetListener ¶
func (c *Controller) GetListener(vm *Machine) ([]byte, RAMListener)
func (*Controller) Reset ¶
func (c *Controller) Reset()
func (*Controller) Tick ¶
func (c *Controller) Tick(vm *Machine)
type Instruction ¶
func (Instruction) String ¶
func (i Instruction) String() string
type Machine ¶
type Machine struct { Accumulator Nybble RAM [16][16]Nybble RAMListeners map[byte][]RAMListener Program []Command Cart *Cart InsPointer byte IsRunning bool // contains filtered or unexported fields }
The actual 4RCH virtual machine
func NewMachine ¶
func NewMachine() *Machine
func (*Machine) AddRAMListener ¶
func (vm *Machine) AddRAMListener(trigAddrs []byte, lnr RAMListener)
func (*Machine) ExecuteCommand ¶
func (*Machine) LoadCartridge ¶
func (*Machine) LoadCartridgeFile ¶
Tries to load a cartridge from a file
func (*Machine) PlugIn ¶
func (vm *Machine) PlugIn(prph Peripheral)
func (*Machine) TickPeripherals ¶
func (vm *Machine) TickPeripherals()
type MemMonitor ¶
type MemMonitor struct {
// contains filtered or unexported fields
}
func NewMemMonitor ¶
func NewMemMonitor(hexAddrs []string) *MemMonitor
Creates a memory monitor from a list of hex addresses
func (*MemMonitor) GetListener ¶
func (mon *MemMonitor) GetListener(vm *Machine) ([]byte, RAMListener)
func (*MemMonitor) Reset ¶
func (mon *MemMonitor) Reset()
func (*MemMonitor) Tick ¶
func (mon *MemMonitor) Tick(vm *Machine)
type Peripheral ¶
type Peripheral interface { Tick(vm *Machine) GetListener(vm *Machine) ([]byte, RAMListener) Reset() }
type RAMListener ¶
type RAMListener func(val Nybble)
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
func (*Screen) GetListener ¶
func (s *Screen) GetListener(vm *Machine) ([]byte, RAMListener)
type SoundCard ¶
type SoundCard struct {
// contains filtered or unexported fields
}
func NewSoundCard ¶
func (*SoundCard) GetListener ¶
func (sc *SoundCard) GetListener(vm *Machine) ([]byte, RAMListener)
Click to show internal directories.
Click to hide internal directories.