Skip to content

Commit

Permalink
Acceptance testing, OSRDRM, OSBYTE86, OSBYTE97
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Sep 10, 2021
1 parent 6243196 commit 0f37a43
Show file tree
Hide file tree
Showing 12 changed files with 104 additions and 46 deletions.
6 changes: 6 additions & 0 deletions acornMemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ func (m *acornMemory) Peek(address uint16) uint8 {
}
}

return m.peekInternal(address)
}

func (m *acornMemory) peekInternal(address uint16) uint8 {
value := m.data[address]

if romStartAddress <= address && address <= romEndAddress && len(m.sideRom[m.activeRom]) > 0 {
slot := m.sideRom[m.activeRom]
if len(slot) > int(address-romStartAddress) {
Expand Down
15 changes: 15 additions & 0 deletions bbz.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ func RunMOS(env *environment) {
// The selected ROM has not defined a custom BRKV
panic("Unhandled BRK")

case epRDRM: // OSRDRM
currentRom := env.mem.Peek(sheilaRomLatch)
address := env.mem.peekWord(zpAddress)
env.mem.Poke(sheilaRomLatch, y)
value := env.mem.Peek(address)

env.cpu.SetAXYP(value, currentRom, 0, p)
env.mem.Poke(sheilaRomLatch, currentRom)
env.logIO(fmt.Sprintf("OSRDRM(%v:%04x)=%02x", y, address, value))

case epSYSBRK: // 6502 BRK handler
/*
When the 6512 encounters a BRK instruction the operating system places
Expand Down Expand Up @@ -181,6 +191,11 @@ func RunMOS(env *environment) {

env.log(fmt.Sprintf("BREAK(ERR=%02x, '%s')", faultNumber, faultString))

if env.panicOnErr && faultNumber == 0 && faultString == "" {
// The code is probably running on zeroed memory
panic("Running on zeroed memory")
}

default:
env.notImplemented(fmt.Sprintf("MOS(EP=0x%04x,A=0x%02x,X=0x%02x,y=0x%02x)", pc, a, x, y))
}
Expand Down
14 changes: 3 additions & 11 deletions beeb_fstest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,15 @@ import (
)

func Test_beeb_ftest(t *testing.T) {

def := "BASIC.ROM"
roms := []*string{&def}

env := newEnvironment(roms, false, false, false, false, false)
con := newConsoleMock(env, []string{
out := integrationTestBasic([]string{
"LOAD \"test/beeb-fstest/0/$.FSTEST\"",
"1661 GOTO 1690", // Skip OSGBPB 06 and 07 tests
"1791 GOTO 2130", // Skip OSGBPB 08 tests
"RUN",
})
env.con = con

RunMOS(env)

if !strings.Contains(con.output, "GOOD. TOOK") {
t.Log(con.output)
if !strings.Contains(out, "GOOD. TOOK") {
t.Log(out)
t.Error("beeb-fstest failed")
}
}
3 changes: 1 addition & 2 deletions consoleMock.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ func (c *consoleMock) readline() (string, bool) {
return "", true
}
line := c.linesIn[c.lineIn]
c.env.writeSpool(line)
c.env.writeSpool("\n")
c.write(line + "\n")
c.lineIn++
return line, false
}
Expand Down
6 changes: 4 additions & 2 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ const (
zpY uint16 = 0x00f1
zpStr uint16 = 0x00f2 // OSCLI command line
zpROMSelect uint16 = 0x00f4
zpAddress uint16 = 0x00f6
zpAccumulator uint16 = 0x00fc
zpErrorPointer uint16 = 0x00fd
zpEscapeFlag uint16 = 0x00ff
Expand Down Expand Up @@ -51,8 +52,8 @@ const (
//serviceNoOperation uint8 = 0
serviceOSCLI uint8 = 4
serviceOSBYTE uint8 = 7
//serviceOSWORD uint8 = 8
serviceHELP uint8 = 9
serviceOSWORD uint8 = 8
serviceHELP uint8 = 9

// Scratch area for errors in page 0xfa
errorArea uint16 = 0xfa00
Expand Down Expand Up @@ -96,6 +97,7 @@ const (
epEntryPointsLast uint16 = 0xfb1f

// Fred, Jim and Sheila
sheilaStart uint16 = 0xf000
sheilaRomLatch uint16 = 0xfe30

maxFiles uint8 = 100
Expand Down
4 changes: 2 additions & 2 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func newEnvironment(roms []*string, cpuLog bool, apiLog bool, apiLogIO bool, mem
env.lastTimerUpdate = time.Now()
env.lastEscapeTimestamp = time.Now()
env.mem = newAcornMemory(memLog)
env.cpu = core6502.NewNMOS6502(env.mem)
//env.cpu = core6502.NewCMOS65c02(env.mem)
//env.cpu = core6502.NewNMOS6502(env.mem)
env.cpu = core6502.NewCMOS65c02(env.mem)
env.cpu.SetTrace(cpuLog)
env.vdu = newVdu(&env)
env.apiLog = apiLog
Expand Down
4 changes: 2 additions & 2 deletions files.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ func (env *environment) closeFile(handle uint8) {
}

func (env *environment) writeSpool(s string) {
charDest := env.mem.Peek(charDestinations)
charDest := env.mem.peekInternal(charDestinations)
if charDest&0x10 != 0 {
// Spooled output is disabled
return
}

spoolHandle := env.mem.Peek(spoolFileHandle)
spoolHandle := env.mem.peekInternal(spoolFileHandle)
if spoolHandle == 0 {
// No spool file defined
return
Expand Down
13 changes: 13 additions & 0 deletions integrationTesting.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package main

func integrationTestBasic(lines []string) string {

def := "BASIC.ROM"
roms := []*string{&def}

env := newEnvironment(roms, false, false, false, false, false)
con := newConsoleMock(env, lines)
env.con = con
RunMOS(env)
return con.output
}
10 changes: 10 additions & 0 deletions osByte.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ func execOSBYTE(env *environment) {
newX = uint8(romStartAddress & 0xff)
newY = uint8(romStartAddress >> 8)

case 0x86:
option = "Read text cursor position"
// Not implemented. Returns 1, 1
newX = 1
newY = 1

case 0x87:
option = "Read character at text cursor position"
/*
Expand Down Expand Up @@ -284,6 +290,10 @@ func execOSBYTE(env *environment) {
env.initLanguage(x)
newA = 1

case 0x97:
option = "Write SHEILA"
env.mem.Poke(sheilaStart+uint16(x), y)

case 0xa0:
option = "Read VDU variable value"
/*
Expand Down
28 changes: 12 additions & 16 deletions osCLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ func execOSCLI(env *environment) {
execOSCLIfx(env, 0x8d, line, pos)

case "ROMS":
selectedROM := env.mem.Peek(sheilaRomLatch)
currentRom := env.mem.Peek(sheilaRomLatch)
for i := 0xf; i >= 0; i-- {
if env.mem.writeProtectRom[i] {
env.mem.Poke(sheilaRomLatch, uint8(i))
Expand All @@ -286,7 +286,7 @@ func execOSCLI(env *environment) {
env.con.write(fmt.Sprintf("RAM %X 16K\n", i))
}
}
env.mem.Poke(sheilaRomLatch, selectedROM)
env.mem.Poke(sheilaRomLatch, currentRom)

case "SAVE":
// *SAVE <filename> <start addr> <end addr or length> [<exec addr>] [<reload addr>]
Expand Down Expand Up @@ -387,31 +387,27 @@ func execOSCLI(env *environment) {
func execOSCLIfx(env *environment, argA uint8, line string, pos int) {
argX := uint8(0)
argY := uint8(0)
fail := false
var valid bool

if line[pos] != '\r' {
if line[pos] != ',' {
env.raiseError(254, "Bad Command")
return
if line[pos] == ',' {
pos++ // Skip ','
}
pos++ // Skip ','
pos = parseSkipSpaces(line, pos)
pos, argX, fail = parseByte(line, pos)
if fail {
pos, argX, valid = parseByte(line, pos)
if !valid {
env.raiseError(254, "Bad Command")
return
}
}

if line[pos] != '\r' {
if line[pos] != ',' {
env.raiseError(254, "Bad Command")
return
if line[pos] == ',' {
pos++ // Skip ','
}
pos++ // Skip ','
pos = parseSkipSpaces(line, pos)
_, argY, fail = parseByte(line, pos)
if fail {
_, argY, valid = parseByte(line, pos)
if !valid {
env.raiseError(254, "Bad Command")
return
}
Expand Down Expand Up @@ -465,7 +461,7 @@ func parseByte(line string, pos int) (int, uint8, bool) {
return cursor, 0, false
}

cursor = parseSkipSpaces(line, pos)
cursor = parseSkipSpaces(line, cursor)
return cursor, uint8(value), true
}

Expand Down
36 changes: 26 additions & 10 deletions osCLI_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,36 @@ import (
)

func Test_OSCLI_HELP(t *testing.T) {
out := integrationTestBasic([]string{
"*HELP",
})

def := "BASIC.ROM"
roms := []*string{&def}
if !strings.Contains(out, "BBZ") {
t.Log(out)
t.Error("*HELP is not returning BBZ")
}
}

env := newEnvironment(roms, false, false, false, false, false)
con := newConsoleMock(env, []string{
"*HELP",
func Test_OSCLI_FX_commas(t *testing.T) {
out := integrationTestBasic([]string{
"*FX 200,3",
"IF ERR=40 PRINT \"PA\" + \"SS\"",
})
env.con = con

RunMOS(env)
if !strings.Contains(out, "PASS") {
t.Log(out)
t.Error("*FX error")
}
}

if !strings.Contains(con.output, "BBZ") {
t.Log(con.output)
t.Error("*HELP is not returning BBZ")
func Test_OSCLI_FX_spaces(t *testing.T) {
out := integrationTestBasic([]string{
"*FX200 3 1",
"IF ERR=40 PRINT \"PA\" + \"SS\"",
})

if !strings.Contains(out, "PASS") {
t.Log(out)
t.Error("*FX error")
}
}
11 changes: 10 additions & 1 deletion osWord.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,15 @@ func execOSWORD(env *environment) {
env.log(fmt.Sprintf("OSWORD08('Define envelope',NUMBER=%v)", number))

default:
env.notImplemented(fmt.Sprintf("OSWORD%02x", a))

// Send to the other ROMS if available.
env.mem.Poke(zpA, a)
env.mem.Poke(zpX, x)
env.mem.Poke(zpY, y)
env.cpu.SetAXYP(serviceOSWORD, x, y, p)

env.cpu.SetPC(procServiceRoms)
env.log(fmt.Sprintf("OSWORD%02x_to_roms(X=0x%02x,Y=0x%02x)", a, x, y))
// procServiceRoms issues a 254-Bad command if the command is not handled by any ROM
}
}

0 comments on commit 0f37a43

Please sign in to comment.