Omnimaga
Calculator Community => TI Calculators => ASM => Topic started by: MGOS on September 30, 2012, 06:45:32 am
-
Writing some program in axe, I needed a fast vertical line routine to substitute this:
Rect(X,22-E,1,E*2+1)
The routine should draw a vertical, at y=22 centered line expanding E pixels up and down to a total length of E*2+1 in column X.
This is my idea:
Axe
:X:asm(E5) ;push hl
:^8:asm(23E5) ;inc hl, push hl (gets the number of rotating cycles needed)
:E
:asm(The routine)
Stack: #Rotation cycles, X
HL : E
pop bc ; #Rotation cycles , Stack: 1
pop de ; X Stack: 0
srl e ; Div 8
srl e
srl e ; DE: X/8
ld a,l ; A: E
add hl,hl ; 2E
inc hl ; 2E+1
ld b,l ; B: 2E+1, #Lines
push bc ; #Lines, #Rotation cycles , Stack: 1
ld b,a ; B: E
ld a, 22 ; A: 22
sub b ; A: 22-E
ld l,a ; HL: 22-E
ld c,l
ld b,h ; BC: 22-E MUL 12
add hl,hl ; *2
add hl,bc ; *3
add hl,hl ; *6
add hl,hl ; *12
add hl,de ; HL: (22-E)*12+(X/8)
ld de, $9340 ; plotsscreen
add hl,de ; HL: Start byte
pop bc ; #Lines, #Rotation cycles , Stack: 0
Lineloop:
ld d,b ; backup b
ld b,c ; #Rotation cycles
ld a,(hl) ; A: Byte to modify
Sloop1:
rla ; rotate
djnz Sloop1
scf ; Pixel on
ld b,c ; #Rotation cycles
Sloop2:
rra ; rotate back
djnz Sloop2
ld (hl),a ; restore modified byte
ld b,d ; Restore b
ld de,12 ; DE: 12
add hl,de ; Next line
djnz Lineloop ; until #Lines-- = 0
I hope somebody can help me finding the error, I'm stuck :/
Edit: It doesn't crash immediately, it does it when the program returns. The error is before lineloop I think