1.1 --- a/vga.S Sat Jun 03 19:13:09 2017 +0200
1.2 +++ b/vga.S Sat Jun 03 22:04:36 2017 +0200
1.3 @@ -675,6 +675,7 @@
1.4 nop
1.5
1.6
1.7 +
1.8 /* Interrupt servicing. */
1.9
1.10 .org 0x200
1.11 @@ -753,47 +754,10 @@
1.12 li $v1, (1 << 3) /* CHBCIF = 0 */
1.13 sw $v1, CLR($v0)
1.14
1.15 - /*
1.16 - Update the line data address if the line counter (referring to the
1.17 - next line) is even.
1.18 - */
1.19 -
1.20 - andi $t8, $s0, 1
1.21 - bnez $t8, irq_exit
1.22 - nop
1.23 -
1.24 - /* Reference the next line and update the DMA source address. */
1.25 -
1.26 - addiu $s2, $s2, LINE_LENGTH
1.27 -
1.28 - /* Test for wraparound. */
1.29 -
1.30 - li $t8, (SCREEN_BASE + SCREEN_SIZE)
1.31 - sltu $t8, $s2, $t8
1.32 - bnez $t8, irq_dma_update
1.33 - nop
1.34 + /* Jump to the DMA update routine. */
1.35
1.36 - /* Reset the source address. */
1.37 -
1.38 - li $s2, SCREEN_BASE
1.39 -
1.40 -irq_dma_update:
1.41 -
1.42 - /* Disable line channel. */
1.43 -
1.44 - la $v0, DCH0CON
1.45 - li $v1, 0b10000000
1.46 - sw $v1, CLR($v0)
1.47 -
1.48 - /* Update the source address. */
1.49 -
1.50 - la $v0, DCH0SSA
1.51 - sw $s2, 0($v0)
1.52 -
1.53 - /* Enable line channel. */
1.54 -
1.55 - la $v0, DCH0CON
1.56 - sw $v1, SET($v0)
1.57 + j visible_update_address
1.58 + nop
1.59
1.60 irq_exit:
1.61 /* Save state. */
1.62 @@ -823,7 +787,7 @@
1.63
1.64 exc_handler:
1.65 li $t9, 0x80000000
1.66 - mfc0 $t6, CP0_CAUSE
1.67 + mfc0 $t6, CP0_ERROREPC
1.68 nop
1.69 exc_loop:
1.70 and $t7, $t9, $t6
1.71 @@ -924,6 +888,58 @@
1.72
1.73
1.74
1.75 +/* DMA update routine. */
1.76 +
1.77 +visible_update_address:
1.78 +
1.79 + /*
1.80 + Update the line data address if the line counter (referring to the
1.81 + next line) is even.
1.82 + */
1.83 +
1.84 + andi $t8, $s0, 1
1.85 + bnez $t8, _visible_update_ret
1.86 + nop
1.87 +
1.88 + /* Reference the next line and update the DMA source address. */
1.89 +
1.90 + addiu $s2, $s2, LINE_LENGTH
1.91 +
1.92 + /* Test for wraparound. */
1.93 +
1.94 + li $t8, (SCREEN_BASE + SCREEN_SIZE)
1.95 + sltu $t8, $s2, $t8
1.96 + bnez $t8, _visible_dma_update
1.97 + nop
1.98 +
1.99 + /* Reset the source address. */
1.100 +
1.101 + li $s2, SCREEN_BASE
1.102 +
1.103 +_visible_dma_update:
1.104 +
1.105 + /* Disable line channel. */
1.106 +
1.107 + la $v0, DCH0CON
1.108 + li $v1, 0b10000000
1.109 + sw $v1, CLR($v0)
1.110 +
1.111 + /* Update the source address. */
1.112 +
1.113 + la $v0, DCH0SSA
1.114 + sw $s2, 0($v0)
1.115 +
1.116 + /* Enable line channel. */
1.117 +
1.118 + la $v0, DCH0CON
1.119 + sw $v1, SET($v0)
1.120 +
1.121 +_visible_update_ret:
1.122 + j irq_exit
1.123 + nop
1.124 +
1.125 +
1.126 +
1.127 /* Within the vertical front porch. */
1.128
1.129 vfp_active: