Skip to content

Commit

Permalink
Fail on use of extended vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
ivanizag committed Sep 11, 2021
1 parent 384e6d0 commit 7e4bb59
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 17 deletions.
2 changes: 1 addition & 1 deletion acornMemory.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (m *acornMemory) loadRom(filename string, slot uint8) {
m.writeProtectRom[slot] = true

// Cache the ROM type
m.data[romTypeTable+uint16(slot)] = data[romTypeByte-romStartAddress]
m.data[mosRomTypeTable+uint16(slot)] = data[romTypeByte-romStartAddress]
}

func (m *acornMemory) completeWithRam() {
Expand Down
8 changes: 8 additions & 0 deletions bbz.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,17 @@ func RunMOS(env *environment) {
if pc == romStartAddress {
a, _, _, _ := env.cpu.GetAXYP()
env.log(fmt.Sprintf("LANGUAGE(A=%02x, ROM=%x)", a, env.mem.activeRom))

} else if pc == romServiceEntry {
a, _, _, _ := env.cpu.GetAXYP()
env.log(fmt.Sprintf("SERVICE(CMD=%02x, ROM=%x)", a, env.mem.activeRom))

} else if pc >= extentedVectorTableStart &&
pc < extentedVectorTableEnd {

// See http://beebwiki.mdfs.net/index.php/Paged_ROM
panic(fmt.Sprintf("Extender vectors not implemented, %04x was called", pc))

} else if pc >= entryPoints && pc <= epEntryPointsLast {
a, x, y, p := env.cpu.GetAXYP()

Expand Down
4 changes: 4 additions & 0 deletions beeb_fstest_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"os"
"strings"
"testing"
)
Expand All @@ -17,4 +18,7 @@ func Test_beeb_ftest(t *testing.T) {
t.Log(out)
t.Error("beeb-fstest failed")
}

os.Remove("+.0")
os.Remove("+.0.inf")
}
16 changes: 10 additions & 6 deletions constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ const (
zpErrorPointer uint16 = 0x00fd
zpEscapeFlag uint16 = 0x00ff

vectorBRK uint16 = 0x0202
mosVariablesStart uint16 = 0x0236
romTypeTable uint16 = 0x023a
spoolFileHandle uint16 = 0x0257
charDestinations uint16 = 0x027c
mosVariablesEnd uint16 = 0x028f
vectorBRK uint16 = 0x0202
mosVariablesStart uint16 = 0x0236
mosRomTypeTable uint16 = 0x023a
mosSpoolFileHandle uint16 = 0x0257
mosCharDestinations uint16 = 0x027c
mosCurrentLanguage uint16 = 0x028c
mosVariablesEnd uint16 = 0x028f

// ROM header https://tobylobster.github.io/mos/mos/S-s2.html#SP26
userMemBottom uint16 = 0x0e00
Expand Down Expand Up @@ -102,6 +103,9 @@ const (
sheilaStart uint16 = 0xf000
sheilaRomLatch uint16 = 0xfe30

extentedVectorTableStart uint16 = 0xff00
extentedVectorTableEnd uint16 = 0xff51

maxFiles uint8 = 100

// Maximim delay to detect a double control C to quit
Expand Down
6 changes: 4 additions & 2 deletions environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (env *environment) escape() {

func (env *environment) initUpperLanguage() {
for slot := 0xf; slot >= 0; slot-- {
romType := env.mem.data[romTypeTable+uint16(slot)]
romType := env.mem.data[mosRomTypeTable+uint16(slot)]
if romType&0x40 != 0 {
env.initLanguage(uint8(slot))
return
Expand All @@ -90,6 +90,8 @@ func (env *environment) initUpperLanguage() {
}

func (env *environment) initLanguage(slot uint8) {
//See https://github.com/raybellis/mos120/blob/master/mos120.s#L6186
env.mem.Poke(mosCurrentLanguage, slot)
env.mem.Poke(zpROMSelect, slot)
env.mem.Poke(sheilaRomLatch, slot)

Expand All @@ -103,7 +105,7 @@ func (env *environment) initLanguage(slot uint8) {
The MOS also automatically prints the ROM's title string (&8009) so that the user is acknowledged.
*/
language := env.mem.peekString(romTitleString, 0)
env.con.write(fmt.Sprintf("%s\n", language))
env.con.write(fmt.Sprintf("%s\n\n", language))

_, x, y, p := env.cpu.GetAXYP()
env.cpu.SetAXYP(1, x, y, p)
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.peekInternal(charDestinations)
charDest := env.mem.peekInternal(mosCharDestinations)
if charDest&0x10 != 0 {
// Spooled output is disabled
return
}

spoolHandle := env.mem.peekInternal(spoolFileHandle)
spoolHandle := env.mem.peekInternal(mosSpoolFileHandle)
if spoolHandle == 0 {
// No spool file defined
return
Expand Down
10 changes: 9 additions & 1 deletion osByte.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func execOSBYTE(env *environment) {
/*
On entry, the value in X determines the output device to be selected
*/
env.mem.Poke(charDestinations, x)
env.mem.Poke(mosCharDestinations, x)
isIO = true

case 0x04:
Expand Down Expand Up @@ -312,6 +312,14 @@ func execOSBYTE(env *environment) {
}

// Starting from a = 0xa6, we are reading mos variables.
case 0xa8:
option = "Read adress of extended vector table"
/*
On exit X and Y point to the start of the extended vectors for ROMs
*/
newX = uint8(extentedVectorTableStart & 0xff)
newY = uint8(extentedVectorTableStart >> 8)

case 0xda:
option = "R/W number of items in VDU"
/*
Expand Down
8 changes: 4 additions & 4 deletions osCLI.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func execOSCLI(env *environment) {
// Runs the first language ROM with no service entry
unhandled = true
for slot := 0xf; slot >= 0; slot-- {
romType := env.mem.data[romTypeTable+uint16(slot)]
romType := env.mem.data[mosRomTypeTable+uint16(slot)]
if romType&0b1100_0000 == 0b0100_0000 { // bit 7 clear, bit 6 set
env.initLanguage(uint8(slot))
unhandled = false
Expand Down Expand Up @@ -364,10 +364,10 @@ func execOSCLI(env *environment) {
case "SPOOL":
// *SPOOL filename
// *SPOOL
spoolFile := env.mem.Peek(spoolFileHandle)
spoolFile := env.mem.Peek(mosSpoolFileHandle)
if spoolFile != 0 {
env.closeFile(spoolFile)
env.mem.Poke(spoolFileHandle, 0)
env.mem.Poke(mosSpoolFileHandle, 0)
}

filename := ""
Expand All @@ -379,7 +379,7 @@ func execOSCLI(env *environment) {
if filename != "" {
// Activate spool
spoolFile := env.openFile(filename, 0x80 /*open for output*/)
env.mem.Poke(spoolFileHandle, spoolFile)
env.mem.Poke(mosSpoolFileHandle, spoolFile)
}

case "TAPE":
Expand Down
2 changes: 1 addition & 1 deletion test/notes/pascal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ROM2 has the command line interpreter
ROM1 has the compiler? May be invoked via OSBYTEa3(x=c0)


$ cd ROMs/Pascal/
$ go run ../../*.go -rom0 ../Pascal-1.10-2.rom -m
bbz - Acorn MOS for 6502 adaptation layer, https://github.com/ivanizag/bbz
(tip: uppercase is usually needed)
Expand Down

0 comments on commit 7e4bb59

Please sign in to comment.