1.1 --- a/switcher.oph Mon Aug 17 01:03:14 2015 +0200
1.2 +++ b/switcher.oph Mon Aug 17 14:55:26 2015 +0200
1.3 @@ -142,6 +142,7 @@
1.4 ; affects: (temporary stack usage)
1.5
1.6 handler:
1.7 + lda $fc ; obtain the original value of A
1.8 pha ; A -> stack
1.9 txa
1.10 pha ; X -> stack
1.11 @@ -171,9 +172,9 @@
1.12 ; obtain the stack location of the stored PC MSB
1.13
1.14 ldy #7 ; offset of MSB (_, _, Y, X, A, F, LSB, MSB)
1.15 - lda (SP), y
1.16
1.17 ; reference the stack location and compute PC MSB & $80
1.18 + lda (SP), y
1.19 and #$80
1.20 cmp #$80
1.21
1.22 @@ -281,6 +282,7 @@
1.23 pla
1.24 tax ; stack -> X
1.25 pla ; stack -> A
1.26 + sta $fc ; override the default handler's restoration of A
1.27 jmp (old_handler)
1.28
1.29
1.30 @@ -384,8 +386,16 @@
1.31 first_task_start:
1.32 lda #1
1.33 sta $7000
1.34 + lda #0
1.35 + sta $7001
1.36 first_task_continue:
1.37 - inc $7000
1.38 + clc
1.39 + lda $7000
1.40 + adc #1
1.41 + sta $7000
1.42 + lda $7001
1.43 + adc #0
1.44 + sta $7001
1.45 jmp first_task_continue
1.46
1.47
1.48 @@ -400,8 +410,16 @@
1.49 second_task_start:
1.50 lda #1
1.51 sta $7010
1.52 + lda #0
1.53 + sta $7011
1.54 second_task_continue:
1.55 - inc $7010
1.56 + clc
1.57 + lda $7010
1.58 + adc #1
1.59 + sta $7010
1.60 + lda $7011
1.61 + adc #0
1.62 + sta $7011
1.63 jmp second_task_continue
1.64
1.65
1.66 @@ -418,11 +436,8 @@
1.67 * stx $7028
1.68 .invoke call third_task_delay, +
1.69 * txa
1.70 - .invoke pushA
1.71 .invoke call remove_task, +
1.72 -* .invoke pullA
1.73 - tax
1.74 - inx ; move to next offset
1.75 +* inx ; move to next offset
1.76 inx ; which is 2 locations away
1.77 cpx #TASK_TABLE_LENGTH
1.78 beq +