;**************************************** ;* SNG v1.0 * ;* Shell avec Niveaux de Gris * ;* * ;* par Marc Plouhinec * ;* le 15/07/2004 * ;* site: http://thebestof.vze.com * ;* Email: mailto://m_plouhinec@yahoo.fr * ;* * ;**************************************** ;Routines à copier dans son code GET_RAND: ;Donne un nombre entre 0 et 255 ld a,$A6 ; <--------------------------------------I push hl ; I RAND1: ; I ld hl,$8243 ;<------------------------------I I inc l ; I I dec h ; I I add a,(hl) ; I I ld (RAND1+1),hl ; Modifie le nombre '$8243'-I I rlca ; I rlca ; I sub h ; I add a,l ; I pop hl ; I ld (GET_RAND+1),a ; Modifie le nombre '$A6'-------I ret PAUSE: ; Attend la pression de la touche [ENTER] ROM_CALL(GET_KEY) cp G_ENTER ret z halt jr PAUSE HL_DECI: ; Convertit le nombre décimal contenu dans HL en chaine de caractère, HL pointera vers la chaine. push de ld bc,$0504 ld de,OP6+5 xor a ld (de),a HL_DECI1: call UNPACK_HL add a,48 dec de ld (de),a djnz HL_DECI1 ex de,hl pop de ld a,48 HL_DECI2: cp (hl) jr nz,HL_DECI3 inc hl dec c jr nz,HL_DECI2 HL_DECI3: ld a,4 sub c ret SPRITE: ;drawsprite: ;Version 1.2, July 23 1998 ld hl,$88B8 SPRITE_HL: push de ld de,12 inc c DS_Row: dec c jr z,DS_Donerow add hl,de jr DS_Row DS_Donerow: ld a,b DS_Byte: cp 8 jr c,DS_Donebyte sub 8 inc hl jr DS_Byte DS_Donebyte: pop de push af DS_Return: pop af ex de,hl ld b,(hl) ld c,0 push af DS_Shift: or a jr z,DS_Doneshift dec a srl b rr c jr DS_Shift DS_Doneshift: ex de,hl ld a,(hl) or b ld (hl),a inc hl ld a,(hl) or c ld (hl),a pop af inc de push de ld de,11 add hl,de pop de push af ld a,(slength) dec a ld (slength),a CP 0 ;or a jr nz,DS_Return pop af ret slength .DB 0 ld hl,$88B8 REMOVE_SPRITE_HL: push de ld de,12 inc c RS_Row: dec c jr z,RS_Donerow add hl,de jr RS_Row RS_Donerow: ld a,b RS_Byte: cp 8 jr c,RS_Donebyte sub 8 inc hl jr RS_Byte RS_Donebyte: pop de push af RS_Return: pop af ex de,hl ld b,(hl) ld c,0 push af RS_Shift: or a jr z,RS_Doneshift dec a srl b rr c jr RS_Shift RS_Doneshift: ex de,hl ld a,b cpl and (hl) ld (hl),a inc hl ld a,c cpl and (hl) ld (hl),a pop af inc de push de ld de,11 add hl,de pop de push af ld a,(slength) dec a ld (slength),a or a jr nz,RS_Return pop af RET GRAYSPRITE: ;b = x ;c = y ;de = adresse du premier octet du sprite ;A = taille du sprite (lignes) LD (slength),A PUSH BC PUSH AF PUSH DE LD HL,GRAPH_MEM CALL SPRITE_HL POP DE POP AF POP BC LD (slength),A LD H,0 LD L,A ADD HL,DE EX DE,HL LD HL,APD_BUF3 CALL SPRITE_HL RET GRAYREMOVE_SPRITE: ;b = x ;c = y ;de = adresse du premier octet du sprite ;A = taille du sprite (lignes) LD (slength),A PUSH BC PUSH AF PUSH DE LD HL,GRAPH_MEM CALL REMOVE_SPRITE_HL POP DE POP AF POP BC LD (slength),A LD H,0 LD L,A ADD HL,DE EX DE,HL LD HL,APD_BUF3 CALL REMOVE_SPRITE_HL RET ;pour les anciennes TI-82 ;#define P_HI %11000000 ;code to put port high $C0 ;#define P_LO %11111100 ;code to put port low $FC ;pour les nouvelles TI-82 (merci à www.paneteti82.fr.st) #define P_HI $C0 ;code to put port high $C0 #define P_LO $C3 ;code to put port low $FC #define C_PORT %00000000 ;addres of com port $00 ;HL = ton ;DE = durée BEEP: ;by Eric Linenberg push af push bc ; di set_low: ld b,P_LO ld c,C_PORT out (c),b push hl Delay16bit1: dec hl ld a,l or h jr nz,Delay16bit1 pop hl set_high: ld b,P_HI ld c,C_PORT out (c),b push hl Delay16bit2: dec hl ld a,l or h jr nz,Delay16bit2 pop hl dec de ld a,d ; ei pop bc pop af RET HL_HEX: ; Convertit le nombre hexadécimal contenu dans HL en chaine de caractère, HL pointera vers la chaine. ld a,h and $0f0 rrca rrca rrca rrca add a,$30 cp $3a jr c,HL_HEX0 add a, $7 HL_HEX0: ld (OP1),a ld a,h and $0f add a,$30 cp $3a jr c,HL_HEX1 add a, $7 HL_HEX1: ld (OP1+1),a ld a,l and $0f0 rrca rrca rrca rrca add a,$30 cp $3a jr c,HL_HEX2 add a, $7 HL_HEX2: ld (OP1+2),a ld a,l and $0f add a,$30 cp $3a jr c,HL_HEX3 add a, $7 HL_HEX3: ld (OP1+3),a xor a ld (OP1+4),a ld hl,OP1 RET