bank walk two pass partially working

This commit is contained in:
Dagen Brock 2015-10-14 20:41:18 -05:00
parent da20f80628
commit 8acb7b8fa2
1 changed files with 149 additions and 26 deletions

175
src/mmt.s
View File

@ -153,6 +153,7 @@ TestInit
inc _testIteration ;actually, set to 1. let test passes be indicated in natural numbers. see, i'm not such a bad guy. inc _testIteration ;actually, set to 1. let test passes be indicated in natural numbers. see, i'm not such a bad guy.
stz _testIteration+1 stz _testIteration+1
stz _testState stz _testState
stz _walkState
TestMasterLoop clc TestMasterLoop clc
xce xce
@ -224,9 +225,11 @@ TestKeyHandler sta $C010
* This should just flip-flop, no matter what, on TwoPass mode... otherwise W/R (BOTH in one pass)
mx %10 mx %10
TestSetState lda TestTwoPass ;read pass then write pass? TestSetState lda TestTwoPass ;read pass then write pass?
stal $020010
stal $030234
bne :twopass bne :twopass
lda #TESTSTATE_BOTH ;r&w lda #TESTSTATE_BOTH ;r&w
sta _testState sta _testState
@ -243,6 +246,7 @@ TestSetState lda TestTwoPass ;read pass
rts rts
* Prints whether "Reading", "Writing", or "W/R" (Both)
TestPrintState PushAll TestPrintState PushAll
sep #$10 sep #$10
lda _testState lda _testState
@ -263,6 +267,7 @@ TestPrintState PushAll
PopAll PopAll
rts rts
* Prints current test pass string
TestPrintIteration PushAll TestPrintIteration PushAll
sep #$10 sep #$10
PRINTXY #53;#10;Mesg_TestPass PRINTXY #53;#10;Mesg_TestPass
@ -275,6 +280,7 @@ TestPrintIteration PushAll
PopAll PopAll
rts rts
* Prints current test error counts string
TestPrintErrors PushAll TestPrintErrors PushAll
sep #$10 sep #$10
PRINTXY #53;#11;Mesg_Errors PRINTXY #53;#11;Mesg_Errors
@ -287,6 +293,7 @@ TestPrintErrors PushAll
PopAll PopAll
rts rts
* Pauses on test error (when enabled, otherwise immediately returns)
TestPauseError lda TestErrorPause ;is this option enabled? TestPauseError lda TestErrorPause ;is this option enabled?
beq :no beq :no
PushAll PushAll
@ -306,6 +313,7 @@ TestPauseError lda TestErrorPause ;is this o
PopAll PopAll
:no rts :no rts
* Print a console error detailing the spot in memory where the error occured
TestLogError PushAll TestLogError PushAll
php php
sta _stash+12 ;8 or 16 bit? YES! sta _stash+12 ;8 or 16 bit? YES!
@ -440,7 +448,7 @@ TestUpdateStatus ldy _updateTick
:noprint rts :noprint rts
_updateTick dw #0 _updateTick dw #0
_updateInterval = #$0327 _updateInterval = #$0002 ;327 works well
@ -507,10 +515,10 @@ TestMemoryLocation
TestMemoryLocationTwoPass TestMemoryLocationTwoPass
lda TestSize16Bit lda TestSize16Bit
bne :test16 bne :test16
:test8 lda TestType
:test8 lda TestType ;8-bit tests
cmp #TT_BITPATTERN cmp #TT_BITPATTERN
bne :checkrand bne :checkrand
jmp Test_8BitPatternTP jmp Test_8BitPatternTP
@ -524,8 +532,8 @@ TestMemoryLocationTwoPass
bne :UNHANDLED bne :UNHANDLED
jmp Test_8BitWalk1TP jmp Test_8BitWalk1TP
:test16 rep #$30 ;full 16-bit for long M
:test16 rep #$30 ;full 16-bit for long M
lda TestType lda TestType
and #$00ff and #$00ff
cmp #TT_BITPATTERN cmp #TT_BITPATTERN
@ -540,6 +548,7 @@ TestMemoryLocationTwoPass
:check16walk1 cmp #TT_BITWALK1 :check16walk1 cmp #TT_BITWALK1
bne :UNHANDLED bne :UNHANDLED
jmp Test_16BitWalk1TP jmp Test_16BitWalk1TP
:UNHANDLED sep #$30 :UNHANDLED sep #$30
rep #$10 rep #$10
@ -547,14 +556,57 @@ TestMemoryLocationTwoPass
* TWO PASS TESTS * TWO PASS TESTS
mx %10 mx %10
Test_8BitWalk1TP Test_8BitWalk1TP
Test_8BitWalk0TP
Test_16RandomTP Test_16RandomTP
Test_16BitWalk1TP Test_16BitWalk1TP
Test_16BitWalk0TP Test_16BitWalk0TP
Test_16BitPatternTP Test_16BitPatternTP
rts rts
_walkState db 0 ;use to track in two pass mode
Test_8BitWalk0TP lda _walkState
asl
phx ;TRICKY! THEY ALL NEED TO PULL X WHEN THEY REACH THEIR JMP!
tax
jmp (_walkTbl8B0,x)
_walkTbl8B0 da Walk8B0_0,Walk8B0_1,Walk8B0_2,Walk8B0_3,Walk8B0_4,Walk8B0_5,Walk8B0_6,Walk8B0_7
Walk8B0_0 plx
lda #%01111111
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_1 plx
lda #%10111111
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_2 plx
lda #%11011111
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_3 plx
lda #%11101111
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_4 plx
lda #%11110111
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_5 plx
lda #%11111011
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_6 plx
lda #%11111101
sta HexPattern
jmp Test_8BitPatternTP
Walk8B0_7 plx
lda #%11111110
sta HexPattern
jmp Test_8BitPatternTP
Test_8RandomTP jsr GetRandByte ;should match with seeds? Test_8RandomTP jsr GetRandByte ;should match with seeds?
sta HexPattern sta HexPattern
jmp Test_8BitPatternTP jmp Test_8BitPatternTP
@ -928,8 +980,7 @@ TestTwoPassRestoreSeed
rts rts
TestTwoPassMakeSeed TestTwoPassMakeSeed ;jsr GetRandByte ;update our two-pass seed (even if we aren't in random mode. too lazy to check.)
;jsr GetRandByte ;update our two-pass seed (even if we aren't in random mode. too lazy to check.)
sta TwoPassSeed ; sta TwoPassSeed ;
sta _seed16b sta _seed16b
sta _seed sta _seed
@ -941,33 +992,104 @@ TestTwoPassMakeSeed
rts rts
* TWO PASS has lots of exceptions where it doesn't advance the bank right away
TestGetNextBank lda CurBank
bne :notInitialBank ;can't be bank 00 so we must be starting a new test
jmp SetInitialBank ;will RTS back - THIS IS THE SAME FOR ALL TESTS
:notInitialBank
lda TestTwoPass ;see if we are doing two-passes of the bank
bne :TwoPass ;nope, no additional logic needed
jmp SetNextBank ;regular way to advance the bank
TestGetNextBank lda TestTwoPass ;see if we are doing two-passes of the bank :TwoPass jsr TwoPassBankLogics
beq :notTwoPass ;nope, no additional logic needed bcs SetNextBank
lda _testState
cmp #TESTSTATE_READ ;don't change bank on read pass of two-pass
bne :twoPassNextBank
jsr TestTwoPassRestoreSeed
rts rts
:twoPassNextBank jsr TestTwoPassMakeSeed
:notTwoPass lda TestDirection * Just sets the CurBank to either the StartAddr or EndAddr, depending on direction
SetInitialBank lda TestDirection
bne :descending bne :descending
:ascending lda CurBank :ascending lda StartBank
bne :notInitialBank bra :storeInitialBank
lda StartBank :descending lda EndBank
sta CurBank :storeInitialBank sta CurBank
rts rts
:notInitialBank inc CurBank
* INCs or DECs CurBank, depending on direction. No value checking at all.
SetNextBank lda TestDirection
bne :descending
inc CurBank
rts rts
:descending lda CurBank :descending dec CurBank
bne :notInitialBank2
lda EndBank
sta CurBank
rts rts
:notInitialBank2 dec CurBank
* This is really TestGetNextBank for TwoPass!!!
* Set CARRY on return to advance bank
TwoPassBankLogics
lda _testState
cmp #TESTSTATE_READ ;don't change bank on read pass of two-pass. (we read during this pass)
bne :checkWrite
lda TestType
:checkReadRandom cmp #TT_RANDOM
bne :checkReadBitwalk0
jsr TestTwoPassRestoreSeed ;for RANDOM, restore our write seed
:checkReadBitwalk0 cmp #TT_BITWALK0
bne :checkReadBitwalk1
; jmp TestUpdateWalkState ;for BITWALK0, update walkpass and SEC when loops
clc
rts rts
:checkReadBitwalk1 cmp #TT_BITWALK1
bne :unknown
; jmp TestUpdateWalkState ;for BITWALK1, update walkpass and SEC when loops
clc
rts
:checkWrite ;we're in write mode.
lda TestType
:checkWriteRandom cmp #TT_RANDOM
bne :checkWriteBitwalk0
jsr TestTwoPassMakeSeed ;for RANDOM, make a write seed
:checkWriteBitwalk0 cmp #TT_BITWALK0
bne :checkWriteBitwalk1
jmp TestUpdateWalkState ;for BITWALK0, update walkpass and SEC when loops
:checkWriteBitwalk1 cmp #TT_BITWALK1
bne :unknown
jmp TestUpdateWalkState ;for BITWALK1, update walkpass and SEC when loops
:unknown sec ;unknown - advance? should not occur.
rts
* sets carry when last test complete
TestUpdateWalkState
inc _walkState ;walkstate++
lda Test_16Bit
bne :walk16
:walk8
lda _walkState
cmp #8
beq :resetWalkState
clc
rts
:walk16
lda _walkState
cmp #16
beq :resetWalkState
clc
rts
:resetWalkState brk $f0 ;walkstate=0
stz _walkState
sec
rts
TestPatchBanks lda CurBank TestPatchBanks lda CurBank
@ -1708,3 +1830,4 @@ BankMap ds 256 ;page-alig
_stash ds 256 _stash ds 256
ds \ ds \