mov #0x80,r2
shll16 r2
shll8 r2
mov r2,r3

l:
    mov.l VIDEO_BASE,r0
    mov.l OFFSET,r1
    add r1,r0

    mov r0,r1
    shlr16 r1
    i:
        mov r3,r4
        shar r4
        shar r4
        sub r4,r2
        add r2,r3
        mov r3,r4
        shar r4
        shar r4
        sub r4,r2

        mov r9,r8
        mov #21,r7
        shld r7,r8
        add r8,r2 ! x += (f << 19)

        mov r2,r6
        mov #-23,r7
        shld r7,r6
        mov r3,r5
        shad r7,r5
        mov #85,r7
        mul.l r5,r7
        sts MACL,r7
        mov #-7,r8
        shad r8,r7
        mov #40,r8
        shll2 r8
        shll2 r8
        mul.l r7,r8
        sts macl,r8
        add r8,r6
        shll2 r6
        mov.l r12,@(r0,r6)
        dt r1
        bf i
    
    mov.l C,r11
    mov.l VIDEO_BASE,r0
    mov.l SS,r10
    s:
        mov.l @(r0,r10),r7
        add r11,r7
        mov.l r7,@(r0,r10)
        add #-3,r10
        dt r10
        bf s
        nop
    bra l
    add #1,r9

.align 2
    VIDEO_BASE: .long 0xa5200000
    OFFSET: .long 0x96100
    C: .long 0x00030201
    F: .long 0xffffff
    SS: .long 0x12C000
