Switcher

Changeset

12:cc3ca407a7d6
2015-08-16 Paul Boddie raw files shortlog changelog graph Restructured the third "housekeeping" task to use an internal subroutine.
switcher.oph (file)
     1.1 --- a/switcher.oph	Sun Aug 16 21:49:17 2015 +0200
     1.2 +++ b/switcher.oph	Sun Aug 16 22:38:18 2015 +0200
     1.3 @@ -415,23 +415,10 @@
     1.4      .byte 0 ; saved flags
     1.5      .word third_task_start ; saved PC
     1.6  third_task_start:
     1.7 -    ldx #2
     1.8 -third_task_begin:
     1.9 -    ldy #0 ; reset counter LSB
    1.10 -    lda #0 ; reset counter MSB
    1.11 -    sta $7021
    1.12 -third_task_loop:
    1.13 -    stx $7028
    1.14 -    sty $7020
    1.15 -    cpy #$ff
    1.16 -    bne third_task_continue
    1.17 -    clc
    1.18 -    lda $7021 ; next MSB
    1.19 -    adc #1
    1.20 -    sta $7021
    1.21 -    cmp #$ff
    1.22 -    bne third_task_continue
    1.23 -    txa
    1.24 +    ldx #2 ; offset of first task to remove
    1.25 +*   stx $7028
    1.26 +    .invoke call third_task_delay, +
    1.27 +*   txa
    1.28      .invoke pushA
    1.29      .invoke call remove_task, +
    1.30  *   .invoke pullA
    1.31 @@ -440,12 +427,26 @@
    1.32      inx ; which is 2 locations away
    1.33      cpx #TASK_TABLE_LENGTH
    1.34      beq +
    1.35 -    jmp third_task_begin
    1.36 +    jmp ---
    1.37  *   ldx #0
    1.38 -    jmp third_task_begin
    1.39 -third_task_continue:
    1.40 +    jmp ----
    1.41 +third_task_delay:
    1.42 +    lda #0 ; reset counter MSB
    1.43 +*   sta $7021
    1.44 +*   ldy #0
    1.45 +*   sty $7020
    1.46 +    cpy #$ff
    1.47 +    beq +
    1.48      iny
    1.49 -    jmp third_task_loop
    1.50 +    jmp -
    1.51 +*   clc
    1.52 +    lda $7021 ; next MSB
    1.53 +    adc #1
    1.54 +    sta $7021
    1.55 +    cmp #$ff
    1.56 +    beq +
    1.57 +    jmp ---
    1.58 +*   .invoke return
    1.59  third_task_stack:
    1.60      .word 0
    1.61      .word 0