Skip to content

Commit

Permalink
OSCLI improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Aug 8, 2021
1 parent aba167e commit af03515
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ References:
- Can run BBC BASIC and most of the language ROMs.
- Saves and loads files from the host filesystem.
- Does some of the mode 7 text coloring using ANSI escape codes on the terminal. Try `VDU 65,129,66,130,67,132,68,135,69,13,10` on BBC BASIC.
- OSCLI comands suported:
- *QUIT: exit
- *HELP
- *FX
- *HOST cmd: execute a command on the host OS. Example: `*HOST ls -la`

## Usage

Expand Down
43 changes: 39 additions & 4 deletions osCLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,17 @@ func execOSCLI(env *environment) {
xy := uint16(x) + uint16(y)<<8
line := env.getStringFromMem(xy, 0x0d)
fields := strings.Fields(line)
command := fields[0]
command := strings.ToUpper(fields[0])
// The command-line interpreter does not distinguish between upper and lower case characters in the command name
command = strings.ToUpper(command)
params := fields[1:]

if command == "*" && len(params) > 0 {
// There are spaces between the * and the command
command = "*" + strings.ToUpper(params[0])
params = params[1:]
}

if strings.HasPrefix(command, "*FX") {
// *FX123 should be treated as *FX 123
fxNumber := command[3:]
Expand All @@ -32,10 +40,38 @@ func execOSCLI(env *environment) {
}
}

if strings.HasPrefix(command, "*|") {
// *|123 should be treated as *| 123
fxNumber := command[3:]
if len(fxNumber) != 0 {
command = "*|"
params = append([]string{fxNumber}, params...)
}
}

msg := ""
switch command {

case "*|":
/*
An operating system command-line with a ‘|’, string escape
character, as its first non-blank character will be ignored by the
operating system. This could be used to put comment lines into
a series of operating system commands placed in an EXEC file
for example.
*/
// do nothing

case "*H.":
fallthrough
case "*HELP":
msg = "\nbbz - Acorn MOS for 6502 adaptation layer, https://github.com/ivanizag/bbz\n"
msg = "bbz - Acorn MOS for 6502 adaptation layer, https://github.com/ivanizag/bbz"

case "*.":
fallthrough
case "*CAT":
// TODO
msg = "<<directory placeholder>>"

case "*QUIT":
env.stop = true
Expand Down Expand Up @@ -79,14 +115,13 @@ func execOSCLI(env *environment) {
// Send to OSBYTE
env.cpu.SetAXYP(uint8(argA), uint8(argX), uint8(argY), p)
execOSBYTE(env)
msg = ""

default:
env.raiseError(1 /* todo */, "Bad command")
}

if msg != "" {
fmt.Print(msg)
fmt.Printf("\n%s\n", msg)
}
env.log(fmt.Sprintf("OSCLI('%s %s')", command, strings.Join(params, " ")))
}

0 comments on commit af03515

Please sign in to comment.