Tomchi / Hylst
2 participants
Page 1 sur 1
Tomchi / Hylst
Hop hop hop !!!
C'est quand même un peu chez nous aussi ici !!
On a un petit échange avec Hylst pour faire une routine qui affiche une croix à l'écran et qui dessine un point quand on fait clic gauche.
Voilà ce que j'ai fait ce matin :
C'est quand même un peu chez nous aussi ici !!
On a un petit échange avec Hylst pour faire une routine qui affiche une croix à l'écran et qui dessine un point quand on fait clic gauche.
Voilà ce que j'ai fait ce matin :
- Code:
./ si ce prog n'est pas lancé en basse il y aura des bugs
RESERVE 60000
rez&=XBIOS(4)
IF rez&
ALERT 3,"Basse resolution stp !!",1,"Ok, dsl ...",a%
EDIT
ENDIF
HIDEM
CLS ! comme un bourrin
./ ---------------------------------------------- motif croix
x&=3
y&=3
LINE x&-3,y&,x&-1,y&
LINE x&+1,y&,x&+3,y&
LINE x&,y&-3,x&,y&-1
LINE x&,y&+1,x&,y&+3
buffer.croix%=MALLOC(8*160) ! pour utiliser RC_COPY
croix%=buffer.croix% ! le sprite
background%=croix%+8 ! 16px plus loin la sauvegarde
mid.background%=croix%+16
old.background%=croix%+24
pixels%=croix%+7*160 ! pour remplacer PSET
.
RC_COPY XBIOS(2),0,0,7,7 TO croix%,0,0 ! stocke le motif
./
./ ---------------------------------------------- les PIXELS
.
CLS ! la delicatesse meme
FOR pixel&=0 TO 15 ! la aussi ya du boeuf
PSET pixel&+pixel&*16,0,15
RC_COPY XBIOS(2),pixel&*16,0,16,1 TO pixels%,pixel&*16,0
NEXT pixel&
./
./ ---------------------------------------------- les diagonales
.
CLS ! bourrin man de retour !
LINE 0,0,319,199
LINE 319,0,0,199
./ ---------------------------------------------- INITS adresses ecran etc
.
@super ! Superviseur, on rigole pas
phy.high|=BYTE{&HFF8201} ! XBIOS(2)
phy.midb|=BYTE{&HFF8203}
phy%=XBIOS(2)
buffer%=MALLOC(32255)
log%=(buffer%+255) AND &HFFFF00
log.high|=SWAP(log%)
log.midb|=AND(SHR(log%,8),&HFF)
./
RC_COPY phy%,0,0,320,200 TO log%,0,0 ! copie phy% dans log%
./
SETMOUSE 160,100 ! pour pas avoir de bug
x&=MOUSEX
y&=MOUSEY
mid.x&=x&
mid.y&=y&
old.x&=x&
old.y&=y&
RC_COPY log%,x&-3,y&-3,7,7 TO background%,0,0 ! sauve le fond
RC_COPY background%,0,0,7,7 TO mid.background%,0,0
RC_COPY background%,0,0,7,7 TO old.background%,0,0
./
./ ------------------------------------------------------------------ MAIN LOOP
./ ----------------------------------------------------------------------------
DO
SWAP old.x&,mid.x&
SWAP old.y&,mid.y&
SWAP mid.x&,x&
SWAP mid.y&,y&
SWAP old.background%,mid.background%
SWAP mid.background%,background%
./
SWAP log%,phy%
SWAP phy.high|,log.high|
SWAP phy.midb|,log.midb|
BYTE{&HFF8201}=phy.high|
BYTE{&HFF8203}=phy.midb|
SETCOLOR 0,&H555
VSYNC
SETCOLOR 0,&H777
./
x&=MOUSEX
y&=MOUSEY
k&=MOUSEK
IF x&<3 !./ Bon,
x&=3 !./ Je te laisse gerer
ELSE IF x&>316 !./ Ca hein ?!
x&=316 !./ une petite gestion
ENDIF !./ des parametres
IF y&<3 !./ RC_COPY
y&=3 !./ pour pouvoir
ELSE IF y&>196 !./ dessiner dans
y&=196 !./ tout l ecran
ENDIF !./ bisous bisettes !!
.
./ ! restaure ancien fond !
RC_COPY old.background%,0,0,7,7 TO log%,old.x&-3,old.y&-3 !
./ ------------------------------------------------------------------ !
.
IF je.dessine&=1 ! Si j'ai fait un point
. ! a la frame precedente
. ! je dois le recopier
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,yd&,4
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,yd&,7
ENDIF
.
./ -------------------------------------------- ET SI ON DESSINAIT ???
je.dessine&=0
IF k&=1
je.dessine&=1
x.ofst&=SHL&(x& AND &HF,4) ! quel bloc de 16px ds pixels%
x.adr&=x& AND &HFF0 ! quelle adresse a l ecran
yd&=y&
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,y&,4
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,y&,7
ENDIF
./ -------------------------------------------- HEYYYY ... Quel artiste !!!!
.
RC_COPY log%,x&-3,y&-3,7,7 TO background%,0,0 ! sauve le fond
./
./ ! affiche pointeur
RC_COPY croix%,0,0,7,7 TO log%,x&-3,y&-3,4 ! NOT source AND dest
RC_COPY croix%,0,0,7,7 TO log%,x&-3,y&-3,7 ! source OR dest
./
LOOP UNTIL k&=2
./ ----------------------------------------------------------------------------
~MFREE(buffer%)
~MFREE(buffer.croix%)
@user
~XBIOS(5,L:phy%,L:phy%,-1)
.
.
PROCEDURE super
super%=GEMDOS(&H20,L:0)
RETURN
.
PROCEDURE user
~GEMDOS(&H20,L:super%)
RETURN
tomchi- Messages : 52
Date d'inscription : 15/09/2018
Age : 49
Re: Tomchi / Hylst
Après tests, ce listing fonctionne compilé mais pas sous interpréteur, du fait que le GFA ne peut pas faire rentrer le résultat d'une manipulation sur un long dans une variable byte|. Ici c'est dans la récupération des bytes de l'adresse ecran.
Bref, on est arrivé à contourner le problème, la routine suivante tourne sous l'éditeur:
Bref, on est arrivé à contourner le problème, la routine suivante tourne sous l'éditeur:
- Code:
./ si ce prog n'est pas lancé en basse il y aura des bugs
RESERVE 60000
rez&=XBIOS(4)
IF rez&
ALERT 3,"Basse resolution stp !!",1,"Ok, dsl ...",a%
EDIT
ENDIF
HIDEM
CLS ! comme un bourrin
./ ---------------------------------------------- motif croix
x&=3
y&=3
LINE x&-3,y&,x&-1,y&
LINE x&+1,y&,x&+3,y&
LINE x&,y&-3,x&,y&-1
LINE x&,y&+1,x&,y&+3
buffer.croix%=MALLOC(8*160) ! pour utiliser RC_COPY
croix%=buffer.croix% ! le sprite
background%=croix%+8 ! 16px plus loin la sauvegarde
mid.background%=croix%+16
old.background%=croix%+24
pixels%=croix%+7*160 ! pour remplacer PSET
.
RC_COPY XBIOS(2),0,0,7,7 TO croix%,0,0 ! stocke le motif
./
./ ---------------------------------------------- les PIXELS
.
CLS ! la delicatesse meme
FOR pixel&=0 TO 15 ! la aussi ya du boeuf
PSET pixel&+pixel&*16,0,15
RC_COPY XBIOS(2),pixel&*16,0,16,1 TO pixels%,pixel&*16,0
NEXT pixel&
./
./ ---------------------------------------------- les diagonales
.
CLS ! bourrin man de retour !
LINE 0,0,319,199
LINE 319,0,0,199
./ ---------------------------------------------- INITS adresses ecran etc
.
@super ! Superviseur, on rigole pas
phy.high&=BYTE{&HFF8201} ! XBIOS(2)
phy.midb&=BYTE{&HFF8203}
phy%=XBIOS(2)
buffer%=MALLOC(32255)
log%=(buffer%+255) AND &HFFFF00
log.high%=SWAP(log%)
log.high&=AND(&HFF,log.high%)
log.midb%=AND(SHR(log%,8),&HFF)
log.midb&=log.midb%
./
RC_COPY phy%,0,0,320,200 TO log%,0,0 ! copie phy% dans log%
./
SETMOUSE 160,100 ! pour pas avoir de bug
x&=MOUSEX
y&=MOUSEY
mid.x&=x&
mid.y&=y&
old.x&=x&
old.y&=y&
RC_COPY log%,x&-3,y&-3,7,7 TO background%,0,0 ! sauve le fond
RC_COPY background%,0,0,7,7 TO mid.background%,0,0
RC_COPY background%,0,0,7,7 TO old.background%,0,0
./
./ ------------------------------------------------------------------ MAIN LOOP
./ ----------------------------------------------------------------------------
DO
SWAP old.x&,mid.x&
SWAP old.y&,mid.y&
SWAP mid.x&,x&
SWAP mid.y&,y&
SWAP old.background%,mid.background%
SWAP mid.background%,background%
./
SWAP log%,phy%
SWAP phy.high&,log.high&
SWAP phy.midb&,log.midb&
BYTE{&HFF8201}=phy.high&
BYTE{&HFF8203}=phy.midb&
SETCOLOR 0,&H555
VSYNC
SETCOLOR 0,&H777
./
x&=MOUSEX
y&=MOUSEY
k&=MOUSEK
IF x&<3 !./ Bon,
x&=3 !./ Je te laisse gerer
ELSE IF x&>316 !./ Ca hein ?!
x&=316 !./ une petite gestion
ENDIF !./ des parametres
IF y&<3 !./ RC_COPY
y&=3 !./ pour pouvoir
ELSE IF y&>196 !./ dessiner dans
y&=196 !./ tout l ecran
ENDIF !./ bisous bisettes !!
.
./ ! restaure ancien fond !
RC_COPY old.background%,0,0,7,7 TO log%,old.x&-3,old.y&-3 !
./ ------------------------------------------------------------------ !
.
IF je.dessine&=1 ! Si j'ai fait un point
. ! a la frame precedente
. ! je dois le recopier
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,yd&,4
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,yd&,7
ENDIF
.
./ -------------------------------------------- ET SI ON DESSINAIT ???
je.dessine&=0
IF k&=1
je.dessine&=1
x.ofst&=SHL&(x& AND &HF,4) ! quel bloc de 16px ds pixels%
x.adr&=x& AND &HFF0 ! quelle adresse a l ecran
yd&=y&
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,y&,4
RC_COPY pixels%,x.ofst&,0,16,1 TO log%,x.adr&,y&,7
ENDIF
./ -------------------------------------------- HEYYYY ... Quel artiste !!!!
.
RC_COPY log%,x&-3,y&-3,7,7 TO background%,0,0 ! sauve le fond
./
./ ! affiche pointeur
RC_COPY croix%,0,0,7,7 TO log%,x&-3,y&-3,4 ! NOT source AND dest
RC_COPY croix%,0,0,7,7 TO log%,x&-3,y&-3,7 ! source OR dest
./
LOOP UNTIL k&=2
./ ----------------------------------------------------------------------------
~MFREE(buffer%)
~MFREE(buffer.croix%)
@user
~XBIOS(5,L:phy%,L:phy%,-1)
.
.
PROCEDURE super
super%=GEMDOS(&H20,L:0)
RETURN
.
PROCEDURE user
~GEMDOS(&H20,L:super%)
RETURN
tomchi- Messages : 52
Date d'inscription : 15/09/2018
Age : 49
Hylst aime ce message
Re: Tomchi / Hylst
Fonctionnement impeccable !
Code référence pour un affichage double buffer video, pour un affichage stable en double écran, avec gestion d'effacement et affichage via swapping / gliding de coordonnées et buffer d'affichage / sprite / plot entre ancienne, actuelle, et intermédiaires , plutôt optimal pour un code court ^^
Tu assures comme d'hab' en GFA Tomchi.
A implémenter et adapter dans mon utilitaire en chantier depuis trop lontemps, d'aide à la conception de jeux et démos, à venir ... un jour ^^
Code référence pour un affichage double buffer video, pour un affichage stable en double écran, avec gestion d'effacement et affichage via swapping / gliding de coordonnées et buffer d'affichage / sprite / plot entre ancienne, actuelle, et intermédiaires , plutôt optimal pour un code court ^^
Tu assures comme d'hab' en GFA Tomchi.
A implémenter et adapter dans mon utilitaire en chantier depuis trop lontemps, d'aide à la conception de jeux et démos, à venir ... un jour ^^
Hylst- Messages : 3
Date d'inscription : 16/06/2020
tomchi aime ce message
Page 1 sur 1
Permission de ce forum:
Vous ne pouvez pas répondre aux sujets dans ce forum
|
|