Notice: SSI.php was unable to load a session! This may cause problems with logout and other functions - please make sure SSI.php is included before *anything* else in all your scripts! in /home/tiplus/www/forum/SSI.php on line 180
This is the assembly stack application !
Post useful routines here (written by you or anybody else).

Posting a routine give you points that you can spend by voting for others routines :
Now some rules :

Code routines

; Do a scrolling animation using the byte given as parameter
; Input : a (byte to repeat)
; destroy bc, hl and the other things destroyed by FASTCOPY
SCROLL_BYTE_EFFECT:
ld b, 64
ld hl, plotsscreen

sbe_loop:
push bc
ld b, 12

sbe_loop2:
ld (hl), a
inc hl
djnz sbe_loop2

push af
push hl
call FASTCOPY
pop hl
pop af
pop bc
djnz sbe_loop

ret

PUT_BYTE:
ld hl, plotsscreen
ld (hl), 11001111b

ret


; Fill all screen (no scrolling)
; Input : a (byte to repeat)
; destroy bc, hl and the other things destroyed by FASTCOPY
FILL_BYTE_EFFECT:
ld b, 64
ld hl, plotsscreen

fbe_loop:
push bc
ld b, 12

fbe_loop2:
ld (hl), a
inc hl
djnz fbe_loop2

pop bc
djnz fbe_loop

call FASTCOPY
ret


SCROLL_BYTE_EFFECT_BLACK:
ld a,11111111b
call SCROLL_BYTE_EFFECT
ret


SCROLL_BYTE_EFFECT_WHITE:
ld a,00000000b
call SCROLL_BYTE_EFFECT
ret

SCROLL_BYTE_EFFECT_BLACK_THEN_WHITE:
call SCROLL_BYTE_EFFECT_BLACK
call SCROLL_BYTE_EFFECT_WHITE
ret
1 votesPlease log in to propose another solution or vote for this routine
; A bunch of operations on 24-bits numbers
;
;Outputs:
; AHL : always the result of the operation
; In many cases, BDE is destroyed, so you've better make like it always is



; Adds AHL to BDE (24 bits addition)
;Inputs :
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLplusBDE:
add hl,de
adc a,b
ret

; Substract BDE from AHL (24-bits substraction)
;Inputs :
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLminusBDE:
or a
sbc hl,de
sbc a,b
ret

; Shift AHL left B times (shift left is the same than multiplying by two)
;Inputs :
; AHL : 24-bits number
; B : times you want AHL to be shifted left
AHLslB:
ld c,a
xor a
cp b
jr z,AHLslBend
sla l
rl h
rl c
dec b
jr AHLslB+2 ; skips the "ld c,a xor a" instructions
AHLslBend:
ld a,c
ret

; Shift AHL right B times (shift right is the same than dividing by two)
;Inputs :
; AHL : 24-bits number
; B : times you want AHL to be shifted right
AHLsrB:
ld c,a
xor a
cp b
jr z,AHLsrBend
srl c
rr h
rr l
dec b
jr AHLsrB+2 ; skips the "ld c,a xor a" instructions
AHLsrBend:
ld a,c
ret

; Bitwises AHL and BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLandBDE:
and b
ld b,a
ld a,h
and d
ld d,a
ld a,l
and e
ld l,a
ld h,d
ld a,b
ret

; Bitwises AHL or BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLorBDE:
or b
ld b,a
ld a,h
or d
ld d,a
ld a,l
or e
ld l,a
ld h,d
ld a,b
ret

; Bitwises AHL xor BDE
;Inputs:
; AHL : first 24-bits number
; BDE : second 24-bits number
AHLxorBDE:
xor b
ld b,a
ld a,h
xor d
ld d,a
ld a,l
xor e
ld l,a
ld h,d
ld a,b
ret

; Inverts the content of AHL
;Inputs:
; AHL : 24-bits number
; Note : it's basically the same as AHL xor $FFFFFF
InvAHL:
cpl
ld b,a
ld a,h
cpl
ld d,a
ld a,l
cpl
ld l,a
ld h,d
ld a,b
ret
1 votesPlease log in to propose another solution or vote for this routine
; Compare the string pointed to by HL to the one pointed to by DE
; Return Z if the strings are equals, or NZ if not
;
;Inputs :
; HL = address of the first string
; DE = address of the second string
;
;Outputs :
; HL = address of the first unmatching character
; or end of string if the strings are equals
; DE = same as HL with the second string
; Z : set if strings are equal, unset otherwise
CompStrs:
ld a,(de)
cp (hl)
ret nz
or a
ret z
inc hl
inc de
jr CompStrs
1 votesPlease log in to propose another solution or vote for this routine
#include "ti83plus.inc"
#define progStart $9D95
.org progStart-2
.db $BB,$6D
bcall(_ClrLCDFull)
ld HL, 0
ld (PenCol), HL
ld HL, Message
bcall(_PutS) ; Displays the string
bcall(_NewLine)
ret
Message:
.db "Hello world!",0
1 votesPlease log in to propose another solution or vote for this routine
; hl = map to decompress
; de = destination
; Decompress a rle from hl to destination
rleDecompress = SAFERAM_OFFSET
rleRepeterPourTous:
; 1 Lire le nombre de fois que sera repete la valeur
ld b, (hl)

ld a, b
or a ; si 0
ret z ; fin du traitement
; 2 Lire la valeur a repeter
call loadNextHL
ld a, (hl)

rleRepeterPourUn:
ld (de), a
inc de
djnz rleRepeterPourUn

; 3 Passer au suivant
call loadNextHL
jr rleRepeterPourTous
;; Pas besoin de ret il est plus haut :)
1 votesPlease log in to propose another solution or vote for this routine
;-----> Copy the gbuf to the screen (fast)
;Input: nothing
;Output: graph buffer is copied to the screen
fastCopy:
di
ld a,$80
out ($10),a
ld hl,gbuf-12-(-(12*64)+1)
ld a,$20
ld c,a
inc hl
dec hl
fastCopyAgain:
ld b,64
inc c
ld de,-(12*64)+1
out ($10),a
add hl,de
ld de,10
fastCopyLoop:
add hl,de
inc hl
inc hl
inc de
ld a,(hl)
out ($11),a
dec de
djnz fastCopyLoop
ld a,c
cp $2B+1
jr nz,fastCopyAgain
ret
1 votesPlease log in to propose another solution or vote for this routine

Post your routine

You must log in to post routines