diff --git a/README.md b/README.md index 52235f1..d292482 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,13 @@ Error messages can be viewed at - [x] sha1sum assembly code (currently not used yet because it's slow) - [x] language card tests - [x] main/auxiliary memory softswitch behavior tests +- [x] softswitch reading tests ### TODO +- [ ] Incorporate Cxxx testing into data-driven test +- [ ] Add testcases for Cxxx testing +- [ ] weirder softswitch behavior corner cases - [ ] floating-bus tests ## Raison d'être diff --git a/audit/audit.asm b/audit/audit.asm index fc5528c..4c53578 100644 --- a/audit/audit.asm +++ b/audit/audit.asm @@ -11,6 +11,7 @@ LCRESULT = $10 LCRESULT1 = $11 AUXRESULT = $12 + SOFTSWITCHRESULT = $13 CSW = $36 KSW = $38 @@ -31,11 +32,13 @@ !addr DST = $08 !addr SHAINPUT = $eb !addr SHALENGTH = $ee + !addr tmp0 = $f9 !addr tmp1 = $fa !addr tmp2 = $fb !addr tmp3 = $fc !addr tmp4 = $fd !addr tmp5 = $fe + !addr tmp6 = $ff ;; Softswitch locations. RESET_80STORE = $C000 @@ -62,6 +65,14 @@ SET_SLOTC3ROM = $C00B READ_SLOTC3ROM = $C017 + RESET_80COL = $C00C + SET_80COL = $C00D + READ_80COL = $C01F + + RESET_ALTCHRSET = $C00E + SET_ALTCHRSET = $C00F + READ_ALTCHRSET = $C01E + RESET_TEXT = $C050 SET_TEXT = $C051 READ_TEXT = $C01A @@ -77,9 +88,14 @@ RESET_HIRES = $C056 SET_HIRES = $C057 READ_HIRES = $C01D - + RESET_INTC8ROM = $CFFF + ;; Readable things without corresponding set/reset pairs. + READ_HRAM_BANK2 = $C011 + READ_HRAMRD = $C012 + READ_VBL = $C019 + ;; CXXX utility routine locations AUXMOVE = $C311 ;; Monitor locations. @@ -118,6 +134,9 @@ main: ;; Auxiliary memory card tests. jsr AUXMEMTESTS + ;; Tests of softswitch-reading + jsr SOFTSWITCHTESTS + ;; ROM SHA-1 checks. ;; jsr SHASUMTESTS - do this later, because it's SLOW! @@ -129,8 +148,9 @@ end: !src "langcard.asm" !src "auxmem.asm" - ;!src "shasumtests.asm" + !src "softswitch.asm" !src "resetall.asm" + ;!src "shasumtests.asm" print lda $C081 diff --git a/audit/audit.dsk b/audit/audit.dsk index 53657d9..9c466c6 100644 Binary files a/audit/audit.dsk and b/audit/audit.dsk differ diff --git a/audit/auxmem.asm b/audit/auxmem.asm index 37f15b5..eaeaa67 100644 --- a/audit/auxmem.asm +++ b/audit/auxmem.asm @@ -63,13 +63,13 @@ AUXMEMTESTS lda #$44 sta $D17B - jsr .zptoaux + jsr zptoaux sta SET_ALTZP jsr LANGCARDTESTS_NO_CHECK sta RESET_ALTZP - jsr .zpfromaux + jsr zpfromaux lda LCRESULT bne + @@ -374,7 +374,7 @@ AUXMEMTESTS +++ rts ;;; Copy zero page to aux mem. Assumes zp pointing at main mem, and leaves it that way. -.zptoaux +zptoaux ldx #0 - sta RESET_ALTZP lda 0,x @@ -386,7 +386,7 @@ AUXMEMTESTS rts ;;; Copy zero page from aux mem. Assumes zp pointing at main mem, and leaves it that way. -.zpfromaux +zpfromaux ldx #0 - sta SET_ALTZP lda 0,x diff --git a/audit/softswitch.asm b/audit/softswitch.asm new file mode 100644 index 0000000..ae01479 --- /dev/null +++ b/audit/softswitch.asm @@ -0,0 +1,243 @@ +;;; Apple IIe softswitch-reading tests +;;; Copyright © 2017 Zellyn Hunter + +!zone softswitch { + + .resetloc = tmp1 + .setloc = tmp3 + .readloc = tmp5 + .loopcount = tmp0 + .switch = SRC + .testtimes = 8 + +SOFTSWITCHTESTS + lda #1 + sta SOFTSWITCHRESULT + + lda MACHINE + cmp #4 + bcs + + +print + !text "NOT IIE OR IIC:SKIPPING SOFTSWITCH TEST",$8D + +printed + sec + rts + ++ +print + !text "TESTING SOFTSWITCHES",$8D + +printed + + ;; Test write-softswitches + lda #<.writeswitches + sta SRC + lda #>.writeswitches + sta SRC+1 + lda #(.readswitches-.writeswitches)/6 + sta .loopcount + +.wrtloop + ;; Copy reset/set/read locations to .resetloc, .setloc, .readloc + ldy #0 + ldx #0 +- lda (SRC),y + sta .resetloc,x + inc SRC + bne + + inc SRC+1 ++ inx + cpx #6 + bne - + + jsr RESETALL + jsr zptoaux + + ;; Initial RESET + ldy #0 + sta (.resetloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bpl + ;ok + ldx #$80 + jsr RESETALL + jsr .fail ++ dex + bne - + + ;; Ensure that reading doesn't do anything. + ldy #0 + lda (.setloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bpl + ;ok + ldx #$02 ;TODO: create "LEAVE" fail message + jsr RESETALL + jsr .fail ++ dex + bne - + + ;; Actual SET + ldy #0 + sta (.setloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bmi + ;ok + ldx #$82 + jsr RESETALL + jsr .fail ++ dex + bne - + + ;; RESET again + ldy #0 + sta (.resetloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bpl + ;ok + ldx #$80 + jsr RESETALL + jsr .fail ++ dex + bne - + + dec .loopcount + bne .wrtloop + + lda #(.endswitches-.readswitches)/6 + sta .loopcount + + +.readloop + ;; Copy reset/set/read locations to .resetloc, .setloc, .readloc + ldy #0 + ldx #0 +- lda (SRC),y + sta .resetloc,x + inc SRC + bne + + inc SRC+1 ++ inx + cpx #6 + bne - + + jsr RESETALL + jsr zptoaux + + ;; Initial RESET + ldy #0 + lda (.resetloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bpl + ;ok + ldx #$00 + jsr RESETALL + jsr .fail ++ dex + bne - + + ;; Actual SET + ldy #0 + lda (.setloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bmi + ;ok + ldx #$02 + jsr RESETALL + jsr .fail ++ dex + bne - + + ;; RESET again + ldy #0 + lda (.resetloc),y + ldx #.testtimes ; test `.testtimes` times +- lda (.readloc),y + bpl + ;ok + ldx #$00 + jsr RESETALL + jsr .fail ++ dex + bne - + + dec .loopcount + bne .readloop + + +.end + jsr RESETALL + lda SOFTSWITCHRESULT + bne .success + sec + rts +.success + +print + !text "SOFTSWITCH TESTS SUCCEEDED",$8D + +printed + clc + rts + +;;; Print failure message. +;;; High bit of X = write. Low two bits of X: 0 = .resetloc, 2 = .setloc +;;; A = actual value read (which tells what we expected: the opposite) +.fail + sta SCRATCH + txa + bmi + + +print + !text "READ" + +printed + beq ++ ++ +print + !text "WRITE" + +printed +++ +print + !text " AT " + +printed + txa + and #$3 + tax + ldy .resetloc+1,x + lda .resetloc,x + tax + jsr PRNTYX + +print + !text " SHOULD " + +printed + lda SCRATCH + bpl + + +print + !text "RE" + +printed ++ +print + !text "SET " + +printed + ldx .readloc + ldy .readloc+1 + jsr PRNTYX + +print + !text ";GOT $" + +printed + lda SCRATCH + jsr PRBYTE + lda #$8D + jsr COUT + lda #0 + sta SOFTSWITCHRESULT + ldx #1 + rts + +.writeswitches + !word RESET_80STORE, SET_80STORE, READ_80STORE + !word RESET_RAMRD, SET_RAMRD, READ_RAMRD + !word RESET_RAMWRT, SET_RAMWRT, READ_RAMWRT + !word RESET_INTCXROM, SET_INTCXROM, READ_INTCXROM + !word RESET_ALTZP, SET_ALTZP, READ_ALTZP + !word RESET_SLOTC3ROM, SET_SLOTC3ROM, READ_SLOTC3ROM + !word RESET_80COL, SET_80COL, READ_80COL + !word RESET_ALTCHRSET, SET_ALTCHRSET, READ_ALTCHRSET +.readswitches + !word RESET_TEXT, SET_TEXT, READ_TEXT + !word RESET_MIXED, SET_MIXED, READ_MIXED + !word RESET_PAGE2, SET_PAGE2, READ_PAGE2 + !word RESET_HIRES, SET_HIRES, READ_HIRES +.endswitches +} ;softswitch