MSX Village forum

La Place des Développeurs [EN COURS] SPRITES sur MSX. Mieux comprendre le SPRITE sur MSX.

igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 10/02/2014 à 11h09
Après un passage sur le Wiki du village => http://www.msxvillage.fr/wiki/wiki.php?title=sprite
Quelques recherches sur le net, j'ai relevé quelques extraits du Msx 2 Technical Handbook dont voici la source => http://www.konamiman.com/msx/msx2th/th-2.txt

Voici toutes les explications contenant le terme SPRITE contenu dans ce livre ;)

Code TEXT :
 
Extraits de MSX2 Technical Handbook (Konamiman.com)
 
* COLOR SPRITE (<sprite plane number>)=<colour>
StatementSets the colour to the sprite of <sprite plane
number> to the specified colour.
 
* COLOR SPRITE$ (<sprite plane number>)=<string expression>
StatementSets the colour of each horizontal line of the
sprite using <string expression>.
 
ON SPRITE GOSUB <linenumber>
StatementDefines the line to begin the piled-sprite interrupt
handling routine.
 
* PUT SPRITE <sprite plane number>[, {(X,Y) | STEP(X,Y)}[, <colour>[, <sprite
     pattern number>]]]
StatementDisplays the sprite pattern.
 
* SCREEN <screen mode>[, <sprite size>[, <key click switch>[, <cassette baud
 rate>[, <printer option>[, <interlace mode>]]]]]
StatementSets the screen mode and so on.
 
SPRITE {ON | OFF | STOP}
StatementAllows, supresses, or suspends the piled-sprite
interrupt.
 
SPRITE$ (<sprite pattern number>)
System variable Contains the sprite pattern.
 
* SCREEN <screen mode>[, <sprite size>[, <key click switch>[, <cassette baud
 rate>[, <printer option>[, <interlace mode>]]]]]
 
 
   Table 2.8  Correspondences between BASE set values and VRAM table
 
------------------------------------------------------
| Expression | Screen mode |     Table     |
|------------+-------------+-------------------------|
|     0      |    0   | Pattern name table      |
|     1      |    0   | N/A     |
|     2      |    0   | Pattern generator table |
|     3      |    0   | N/A     |
|     4      |    0   | N/A     |
|     5      |    1   | Pattern name table      |
|     6      |    1   | Colour table     |
|     7      |    1   | Pattern generator table |
|     8      |    1   | Sprite attribute table  |
|     9      |    1   | Sprite generator table  |
|    10      |    2   | Pattern name table      |
|    11      |    2   | Colour table     |
|    12      |    2   | Pattern generator table |
|     .      |    .   |.     |
      .     ..
      .     ..
|     |   |     |
|    43      |    8   | Sprite attribute table  |
|    44      |    8   | Sprite generator table  |
------------------------------------------------------
 
 
 
2.7 Additions or Modifications for Sprite
 
The sprites used in screen mode 4-8 of MSX2 are called sprite mode 2, which 
has upgraded a great deal as compared with MSX1. On MSX1, for example, one 
sprite could treat only one colour, while in this mode of MSX2 different 
colours can be specified for each horizontal line and so multi-coloured 
characters can be realised with one sprite. Additionally, it is a good idea 
to combine two sprites as though they were one sprite to paint each dot with 
different colours. And, on MSX1, when more than five sprites are arrayed on 
a horizontal line, the sprites after the fifth one were not displayed, but on 
MSX2 up to eight sprites can be displayed, so a higher flexibility is 
offered.
 
Colours which can be specified for sprites are shown in Table 2.4 (colour 
statement) except for screen mode 8. The sprite in screen mode 8, not capable 
of using the palette, uses the colour number for the specification, and only 
16 colours can be used (see Table 2.10).
 
 
 
   Table 2.10  Sprite colours in screen mode 8
 
-------------------------------------------------------------------------
| 0: Black  | 1: Deep Blue    | 2: Deep Red     | 3: Deep Purple|
|-----------------+-----------------+-----------------+-----------------|
| 4: Deep Green   | 5: Turquoise    | 6: Olive      | 7: Grey |
|-----------------+-----------------+-----------------+-----------------|
| 8: Light Orange | 9: Blue    | 10: Red      | 11: Purple|
|-----------------+-----------------+-----------------+-----------------|
| 12: Green  | 13: Light Blue  | 14: Yellow      | 15: White|
-------------------------------------------------------------------------
 
 
* PUT SPRITE <sprite plane number>[, {(X,Y) | STEP(X,Y)}[, <colour>[, <sprite
     pattern number>]]]
 
In screen modes 1 through 3, Y-coordinate was 209 for erasing the display of 
the specified sprite and was 208 for erasing the displays of the specified 
sprite and all sprites following it, but in screen modes 4 through 8, where 
the limit of Y-coordinate has been increased to 212 dots, the values to be 
specified are now 217 and 216, respectively.
 
 
* COLOR SPRITE$ (<sprite plane number>) = <string expression>
 
This statement specifies a colour for each horizontal line (see Figure 2.5).
 
<String expression> consists of one to sixteen characters. Bits 0 throgh 3 of 
the character's ASCII code are used for the colour specification, and bits 4 
throgh 7 are used to specify each function of the sprite (see Table 2.11). 
These specifications are valid only for screen modes 4 through 8.
 
COLOR SPRITE$ = CHR$ (colour of the first line) + CHR$ (colour of the second 
line) + ...... + CHR$ (colour of the eight line)
 
 
 
   Figure 2.5  Relation of the sprite and <string expression>
 
   ---------------------------------
Line 1 --> | * |   |   | * | * |   |   | * |
   |---+---+---+---+---+---+---+---|
Line 2 --> | * | * |   |   |   |   | * | * |
   |---+---+---+---+---+---+---+---|
   |   |   |   |   |   |   |   |   |
   |---+---+---+---+---+---+---+---|
   | * | * |   |   |   |   | * | * |
   |---+---+---+---+---+---+---+---|
   |   |   | * |   |   | * |   |   |
   |---+---+---+---+---+---+---+---|
   | * |   |   | * | * |   |   | * |
   |---+---+---+---+---+---+---+---|
   | * | * |   |   |   |   | * | * |
   |---+---+---+---+---+---+---+---|
Line 8 --> |   |   | * | * | * | * |   |   | The colour for each line
   --------------------------------- can be set.
 
 
   Table 2.11  Bitwise meanings of string expression
 
-------------------------------------------------------------------------
|    b7    | If 1, move the sprite to left by 32 dots.|
|----------+------------------------------------------------------------|
|   | If 1, move the sprites of the successive planes together.|
|    b6    | The priority and conflict of sprites are ignored, and when |
|   | sprites are piled up, they are displayed in the colour|
|   | which is OR-ed with their colour numbers. *|
|----------+------------------------------------------------------------|
|    b5    | If 1, the conflict of sprites are ignored. |
|----------+------------------------------------------------------------|
|    b4    | Unused.|
|----------+------------------------------------------------------------|
| b0 to b3 | Palette number.|
-------------------------------------------------------------------------
 
* For example, assuming that bit 6 of sprite plane 1 is "0" and bit 6 of 
sprite plane 2 is "1", only by moving sprite plane 1, will sprite plane 2 be 
displayed displayed to be piled at the same location.
 
 
* COLOR SPRITE (<sprite plane number>) = <expression>
 
This statement sets the whole sprite of the specified plane to the 
<expression>, this uses <expression> for colour specification. The format of 
the colour specification is the same as shown in Table 2.11, but the 
specification for b7 is disabled. These are valid for screen modes 4 through 
8.
 
 
 
   Table 2.20  List of intermediate codes
 
-------------------   -------------------   -------------------
| >  |    EE |   | ERR|    E2 |   | PAINT   |    BF |
| =  |    EF |   | ERROR|    A6 |   | PDL     | FF A4 |
| <  |    F0 |   | EXP| FF 8B |   | PEEK    | FF 97 |
| +  |    F1 |   | FIELD|    B1 |   | PLAY    |    C1 |
| -  |    F2 |   | FILES|    B7 |   | POINT   |    ED |
| *  |    F3 |   | FIX| FF A1 |   | POKE    |    98 |
| /  |    F4 |   | FN|    DE |   | POS     | FF 91 |
| ^  |    F5 |   | FOR|    82 |   | PRESET  |    C3 |
|   |    FC |   | FPOS| FF A7 |   | PRINT   |    91 |
| ABS  | FF 86 |   | FRE| FF 8F |   | PSET    |    C2 |
| AND  |    F6 |   | GET|    B2 |   | PUT     |    B3 |
| ASC  | FF 95 |   | GOSUB|    8D |   | READ    |    87 |
| ATN  | FF 8E |   | GOTO|    89 |   | REM     | 3A 8F |
| ATTR$   |    E9 |   | HEX$| FF 9B |   | RENUM   |    AA |
| AUTO  |    A9 |   | IF|    8B |   | RESTORE |    8C |
| BASE  |    C9 |   | IMP|    FA |   | RESUME  |    A7 |
| BEEP  |    C0 |   | INKEY$|    EC |   | RETURN  |    8E |
| BIN$  | FF 9D |   | INP| FF 90 |   | RIGHT$  | FF 82 |
| BLOAD   |    CF |   | INPUT|    85 |   | RND     | FF 88 |
| BSAVE   |    D0 |   | INSTR|    E5 |   | RSET    |    B9 |
| CALL  |    CA |   | INT| FF 85 |   | RUN     |    8A |
| CDBL  | FF A0 |   | IPL|    D5 |   | SAVE    |    BA |
| CHR$  | FF 96 |   | KEY|    CC |   | SCREEN  |    C5 |
| CINT  | FF 9E |   | KILL|    D4 |   | SET     |    D2 |
| CIRCLE  |    BC |   | LEFT$| FF 81 |   | SGN     | FF 84 |
| CLEAR   |    92 |   | LEN| FF 92 |   | SIN     | FF 89 |
| CLOAD   |    9B |   | LET|    88 |   | SOUND   |    C4 |
| CLOSE   |    B4 |   | LFILES|    BB |   | SPACE$  | FF 99 |
| CLS  |    9F |   | LINE|    AF |   | SPC(    |    DF |
| CMD  |    D7 |   | LIST|    93 |   | SPRITE  |    C7 |
| COLOR   |    BD |   | LLIST|    9E |   | SQR     | FF 87 |
| CONT  |    99 |   | LOAD|    B5 |   | STEP    |    DC |
| COPY  |    D6 |   | LOC| FF AC |   | STICK   | FF A2 |
| COS  | FF 8C |   | LOCATE|    D8 |   | STOP    |    90 |
| CSAVE   |    9A |   | LOF| FF AD |   | STR$    | FF 93 |
| CSNG  | FF 9F |   | LOG| FF 8A |   | STRIG   | FF A3 |
| CSRLIN  |    E8 |   | LPOS| FF 9C |   | STRING$ |    E3 |
| CVD  | FF AA |   | LPRINT|    9D |   | SWAP    |    A4 |
| CVI  | FF A8 |   | LSET|    B8 |   | TAB(    |    DB |
| CVS  | FF A9 |   | MAX|    CD |   | TAN     | FF 8D |
| DATA  |    84 |   | MERGE|    B6 |   | THEN    |    DA |
| DEF  |    97 |   | MID$| FF 83 |   | TIME    |    CB |
| DEFDBL  |    AE |   | MKD$| FF B0 |   | TO      |    D9 |
| DEFINT  |    AC |   | MKI$| FF AE |   | TROFF   |    A3 |
| DEFSNG  |    AD |   | MKS$| FF AF |   | TRON    |    A2 |
| DEFSTR  |    AB |   | MOD|    FB |   | USING   |    E4 |
| DELETE  |    A8 |   | MOTOR|    CE |   | USR     |    DD |
| DIM  |    86 |   | NAME|    D3 |   | VAL     | FF 94 |
| DRAW  |    BE |   | NEW|    94 |   | VARPTR  |    E7 |
| DSKF  | FF A6 |   | NEXT|    83 |   | VDP     |    C8 |
| DSKI$   |    EA |   | NOT|    E0 |   | VPEEK   | FF 98 |
| DSKO$   |    D1 |   | OCT$| FF 9A |   | VPOKE   |    C6 |
| ELSE  | 3A A1 |   | OFF|    EB |   | WAIT    |    96 |
| END  |    81 |   | ON|    95 |   | WIDTH   |    A0 |
| EOF  | FF AB |   | OPEN|    B0 |   | XOR     |    F8 |
| EQV  |    F9 |   | OR|    F7 |   -------------------
| ERASE   |    A5 |   | OUT|    9C |
| ERL  |    E1 |   | PAD| FF A5 |
-------------------   -------------------
 


Voici quelques lignes qui déterminent le fonctionnement tel qui m'intéresse:

1) Héro => Position déterminée par les variable X,Y
Code TEXT :
 
501 PUTSPRITE0,(X,Y),11,0
 


2) Tir => Position déterminée par les variables X+50,Y
Code TEXT :
 
506 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
 


3) Ennemis volants => Positions pseudo aléatoire déterminée par différentes combinaisons X+, X-, Y+, Y-, VDP(27) et -VDP(27).
Code TEXT :
 
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9,0
503 PUTSPRITE3,(-X-VDP(27),-Y),15,0
504 PUTSPRITE4,(-Y,X-VDP(27)),8,0
505 PUTSPRITE5,(X+Y,VDP(27)),6,0
 


4) Ennemis rampants => Position déterminée par coordonnées Fixes.
Code TEXT :
370  PUTSPRITE6,(150,100),1,0:PUTSPRITE7,(180,75),1,0:PUTSPRITE8,(180,125),1,0
380  PUTSPRITE9,(120,75),1,0:PUTSPRITE10,(120,125),1,0
 


5) Les moteurs qui incrémente les variables:
Code TEXT :
 
490 X=X-4:IFX<1THENX=0
500 VDP(27)=VDP(27)+1AND255
 


6) Les conditions de retour en début de boucle.
Code TEXT :
 
507 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
 



Voici le bout de listing simplement présenté:
Code TEXT :
 
340 '              Sprites ennemis rampants
350 '
360 'ONSPRITEGOSUB1090
370  PUTSPRITE6,(150,100),1,0:PUTSPRITE7,(180,75),1,0:PUTSPRITE8,(180,125),1,0
380  PUTSPRITE9,(120,75),1,0:PUTSPRITE10,(120,125),1,0
390 'SPRITE ON
400 '
410 '
460 '              SP gestion mouvement: HERO STATIQUE
470 '
480 '
490 X=X-4:IFX<1THENX=0
491 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(x,y),0
500 VDP(27)=VDP(27)+1AND255
501 PUTSPRITE0,(X,Y),11,0
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9,0
503 PUTSPRITE3,(-X-VDP(27),-Y),15,0
504 PUTSPRITE4,(-Y,X-VDP(27)),8,0
505 PUTSPRITE5,(X+Y,VDP(27)),6,0
506 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
507 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
 


Voici les charges qui m'intéressent:

1) Collision => Héro/Ennemis volants => disparition du Héro.
1b) Collision => Héro/Ennemis Rampants => Disparition du Héro.
2) Collision => Tir / Ennemis volants => Disparition Ennemi.
2b) Collision => Tir / Ennemis rampant => Disparition Ennemi.
3) # Collision => Ennemis Volants/Ennemis Volants.

Toute la difficulté étant de mettre à charge du MSX toutes ces conditions tout en restant suffisamment fluide au regard :oups Edité par igal Le 10/02/2014 à 11h31


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 10/02/2014 à 16h42
@EricB59: Je t'ai écouté et j'ai donc jeté un oeil sur le MSX2 Handbook page 172.



Les 8 Bits qui gèrent le SPRITE sont détaillés.



On peut y voir comme tu l'a précédemment dit ici => http://www.msxvillage.fr/forum/topic.php?quote=51162&id=2115&pt=4#go_bottom



ericb59 :
- Tu peux créer des sprites colorés, sans détection de collision Pour cela il faut utilisé le bit B5 dans la chaine de création du sprite.

Voir par exemple le bouquin MSX-BASIC 2.0 de SONY page 172.



- Ce que tu appel "identifiant" dans ton PUT SPRITE n'est pas indentifiant, mais le numéro du plan sur lequel tu veux afficher ton sprite.

PUT SPRITE <numero de plan>,(x,y),<couleur>,<numero de motif de sprite>

Tu ne peux mettre qu'un seul sprite par Plan. C'est pour cela que tes sprites clignotent si tu mets plusieurs sprites différents sur un même plan.

etc etc....




J'ai donc pensé à la chose suivante:



Il suffit de rendre d'activer la collision des SPRITES les uns après les autres à tour de rôle.

De la sorte, il ne serait plus nécessaire de déterminer la Longitude/Latitude du SPRITE pour savoir si c'est bien celui qui est touché!

Forcément, Un seul SPRITE étant "COLLISIONABLE", c'est donc obligatoirement celui ci qui est touché.

Ce SPRITE en question doit donc être détruit (Effacé)!



On peut même prédéterminer sa position puisque:



1) Soit le SPRITE actif à touché le HERO et donc sa localisation est => X,Y

2) Soit le SPRITE actif à touché le TIR et donc sa localisation est => X+50,Y



Dans les deux cas, le SPRITE est localisé de facto :top



La question est donc la suivante:

Comment modifier le [BIT 5] de ZERO à UN alternativement à tour de rôle sur les 4 SPRITES volants!



Code TEXT :
 
340 '              Sprites ennemis rampants
350 '
360 'ONSPRITEGOSUB1090
370  'PUTSPRITE6,(150,100),1,0:PUTSPRITE7,(180,75),1,0:PUTSPRITE8,(180,125),1,0
380  'PUTSPRITE9,(120,75),1,0:PUTSPRITE10,(120,125),1,0
390 'SPRITE ON
400 '
410 '
460 '              SP gestion mouvement: HERO STATIQUE
470 '
480 '
485 ONSPRITEGOSUB510:SPRITEON
490 X=X-4:IFX<1THENX=0
500 VDP(27)=VDP(27)+1AND255
501 PUTSPRITE0,(X,Y),11,0
 
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9,0 qui est donc => &B 0000 1001, 0  => Doit devenir &B 0100 1001, 0
503 PUTSPRITE3,(-X-VDP(27),-Y),15,0 qui est donc => &B 0000 1111, 0 => Doit devenir &B 0100 1111, 0
504 PUTSPRITE4,(-Y,X-VDP(27)),8,0 qui est donc => &B 0000 1000, 0 => Doit devenir &B 0100 1000, 0 
505 PUTSPRITE5,(X+Y,VDP(27)),6,0 qui est donc => &B 0000 0110, 0 => Doit devenir &B 0100 0110, 0
 
506 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
507 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
510 END
 




Alternativement veut dire que

La ligne 502 à le Bit 5 à 1 alors que les lignes 503, 504 et 505 restent le Bit 5 à 0

La ligne 503 à le Bit 5 à 1 alors que les lignes 502, 504 et 505 restent le Bit 5 a 0

La ligne 504 à le Bit 5 à 1 alors que les lignes 502, 503 et 505 restent le bit 5 a 0

La ligne 505 à le Bit 5 à 1 alors que les lignes 502, 503 et 504 restent le Bit 5 à 0



Question aux Codeurs :D

Comment faire pour changer seulement le cinquième BIT de plusieurs nombres (DEC, HEX ou BIN) sans modifier les autre Bits qui composent ces nombres :hum :hum :hum



Edit: L'autre très grand intérêt de taille est que les SPRITES ENNEMIS ne peuvent plus rentrer en COLLISION entre eux :top


Edité par igal Le 10/02/2014 à 16h57


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
Jipe Membre non connecté

Maire-adjoint

Rang

Avatar

Association

Inscrit le : 02/10/2009 à 19h41

Messages: 10353

Le 10/02/2014 à 17h22
dans ton programme c'est le BIT 6 qui change de valeur

si tu veux changer le BIT 6 tu fait la valeur XOR 64

si tu veux changer le BIT 5 tu fait la valeur XOR 32



:noel
Site web    
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 10/02/2014 à 18h26
Effectivement, Jipe, il s'agit bien de XOR32 pour le sixième Bit qui désactive la COLLISION individuellement.

J'ai donc rentré les commandes suivantes:

485 ONSPRITEGOSUB510:SPRITEON
490 X=X-4:IFX<1THENX=0
500 VDP(27)=VDP(27)+1AND255
501 PUTSPRITE0,(X,Y),11,0

502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
503 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
504 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
505 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0

506 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
507 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
510 END

Le problème c'est que le Bit 6 est bien basculé à 1 mais il reste dans cet état, donc il ne peut pas entrer en COLLISION avec le HERO ou le TIR :moue

Comment faire pour permuter à tour de role comme je l'explique au dessus ? Edité par igal Le 10/02/2014 à 18h30


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5485

Le 10/02/2014 à 18h33
tu fait par exemple un "9 MOD 32" pour revenir à l'état initiale


Moi je serais toi je définirais 2 motifs de sprites
1 avec collision, l'autre sans collision.

Tu alternes le motif de sprite dans ton PUT SPRITE Edité par ericb59 Le 10/02/2014 à 18h35


banniere-ericb59e
Site web    
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 10/02/2014 à 18h43
9 MOD 32 à bien l'air de remettre à ZERO et donc COLLISION réactivée sur chaque SPRITE.

En fait j'espère de l'aide pour une solution comprenant l’alternance des des deux états alternativement un SPRITE après l'autre!

Comment obtenir une lecture consécutive avec ces valeurs ?
485 ONSPRITEGOSUB510:SPRITEON
490 X=X-4:IFX<1THENX=0
500 VDP(27)=VDP(27)+1AND255
501 PUTSPRITE0,(X,Y),11,0

502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9MOD32,0
503 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
503 PUTSPRITE3,(-X-VDP(27),-Y),15MOD32,0
504 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
504 PUTSPRITE4,(-Y,X-VDP(27)),8MOD32,0
505 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
505 PUTSPRITE5,(X+Y,VDP(27)),6MOD32,0

506 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
507 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
510 END


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5485

Le 10/02/2014 à 18h51
Voici une formule qui permet de changer une variable alternativement entre 2 valeurs à chaque itération...

40 '
50 H=-(H=0)*1:SP=H+4
60 put sprite 1,(x,y),9,SP

à chaque fois que la ligne 50 sera exécutée, la valeur de SP changera alternativement entre 4 et 5

A supposer que ton sprite avec collision soit par exemple le N° 4 et celui sans collision le numéro 5

Si les sprites que tu veux interchanger sont d'autre n° alors change la formule...

H=-(H=0)*2:SP=H+6

SP sera égal à 6 ou 8

La formule pour déterminer les valeurs possible est

H=-(H=0)*"V":SP=H+"W"

première valeure = W
seconde valeur = W+V



EDIT tu peux aussi utiliser cette formule pour changer la couleur du sprite avec et sans collision.

code couleur avec collision =9
Code couleur sans collision = 9 XOR 32 = 41

La formule pour avoir les valeurs 9 et 41 alternativement devient :
H=-(H=0)*32:SP=H+9

501 H=-(H=0)*32:SP=H+9
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),SP,0


c'est pas bô ça ! :D Edité par ericb59 Le 10/02/2014 à 18h56


banniere-ericb59e
Site web    
Metalion Membre non connecté

Conseiller Municipal

Rang

Avatar

Inscrit le : 23/12/2009 à 15h32

Messages: 1487

Le 10/02/2014 à 19h28
igal :
Le problème c'est que le Bit 6 est bien basculé à 1 mais il reste dans cet état, donc il ne peut pas entrer en COLLISION avec le HERO ou le TIR :moue

Comment faire pour permuter à tour de role comme je l'explique au dessus ?


En utilisant toujours XOR 32, tout simplement.

XOR agit comme une bascule sur le bit concerné :



0 XOR 1 = 1

1 XOR 1 = 0



Donc, à chaque fois que tu exécutes "XOR32" tu vas basculer l'état du 6e bit : 0,1,0,1,0,1,0,1, ...



Pour modifier cette valeur, plutôt que d'exécuter à chaque fois l'instruction PUT SPRITE, tu peux aussi directement modifier la valeur dans la VRAM.

Dans la table des attributs des sprites, c'est la 3e valeur des 4 octets déterminants le Sprite.



Mais tu n'as pas besoin de tout ça ...



Tu es en MSX2+, et donc tu bénéficie des fonctionnalités du VDP du MSX2 (forcément), qui, lors d'une collision entre 2 sprites, te donne les coordonnées de la collision.

Les coordonnées sont contenues dans les registres de statut 3,4,5 et 6.



Code :
   Figure 4.69    Conflict of the sprite (sprite mode 2)

    MSB   7    6    5     4    3    2    1    0      LSB
    -----------------------------------------
S#0    | .  | .  | X  | .  | .  | .  | .  | .    |
    -----------------------------------------
            |     0: normal
            +-->
             1: conflict occurred


    ----------------------------
    |               |
    |  --------------------    |
    |  | \\\\\\\\ |    |
    |  | \\\\\\\\ |    |
    |  | \\\ ---------+----+-----------
    |  | \\\ | \\\ |    |          |
    |  | \\\ | \\\ |    |          |
    |  | \\\ | \\\ |    |          |
    |  | \\\ | \\\ |    |          |   the attribute of this line
    -  | \\\ |  -----+----+--------  -     -------------------------
    +-- |  | \\\ |  | xx | // | ///// |  | --> |  | 0| 0|    :  :  :  :  |
    |    -  ----------+---+----- // | ///// |  -     -------------------------
    |    |         |     | /////// | ///// |  |        |     |
    |    -------------+---+---------- ///// |  |        +-----+
    |             |     | /////////////// |  |   CC and IC bits are both "0"
    | the attribute  |     -------------------  |
    | of this line   |                  |
    |             |                  |
    |             --------------------------
    V
-------------------------
|  | 0| 0|  :  :  :  :    |
-------------------------
   |     |
   +-----+
CC and IC bits are both "0"


   Figure 4.70    Readout of the conflict coordinate

    MSB   7    6    5     4    3    2    1    0      LSB
    ----------------------------------------- --+
S#3    | X7 | X6 | X5 | X4 | X3 | X2 | X1 | X0 |   |
    -----------------------------------------   | X-coordinate where the
                            | conflict occurred
    -----------------------------------------   |
S#4    | 1  | 1  | 1  | 1  | 1  | 1  | 1  | X8 |   |
    ----------------------------------------- --+

    ----------------------------------------- --+
S#5    | Y7 | Y6 | Y5 | Y4 | Y3 | Y2 | Y1 | Y0 |   |
    -----------------------------------------   | Y-coordinate where the
                            | conflict occurred
    -----------------------------------------   |
S#6    | 1  | 1  | 1  | 1  | 1  | 1  | Y9 | Y8 |   |
    ----------------------------------------- --+


   Expression 4.5  Calculating the actual conflict coordinate

---------------------------------------------------------
|                            |
|     (X-coordinate where the conflict occurred) =    |
|     (X-coordinate of S#3 and S#4) - 12        |
|                            |
|     (Y-coordinate where the conflict occurred) =    |
|     (Y-coordinate of S#5 and S#6) - 8         |
|                            |
---------------------------------------------------------
Edité par Metalion Le 10/02/2014 à 19h47


MSX1: Daewoo DPC-200 / Yamaha CX5M
MSX2: Sony HB-F9P
MSXVR
Vidéo: V9990 (GFX-9)
Audio: MSX-Music (FM-PAC) / MSX-Audio (Audiowave) / OPL4 (Monster Sound FM Blaster) / OPNB (Neotron)
   
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5485

Le 10/02/2014 à 20h08
ben tu dis pas tout Metalion :moue
Comment tu fais pour lire ces registres depuis le basic ? :gne


banniere-ericb59e
Site web    
Metalion Membre non connecté

Conseiller Municipal

Rang

Avatar

Inscrit le : 23/12/2009 à 15h32

Messages: 1487

Le 10/02/2014 à 20h19
En utilisant la commande VDP, évidemment ...

Les registres de statut sont en négatif.
Pour lire le registre de statut 1, il faut faire VDP(-1). Edité par Metalion Le 10/02/2014 à 20h20


MSX1: Daewoo DPC-200 / Yamaha CX5M
MSX2: Sony HB-F9P
MSXVR
Vidéo: V9990 (GFX-9)
Audio: MSX-Music (FM-PAC) / MSX-Audio (Audiowave) / OPL4 (Monster Sound FM Blaster) / OPNB (Neotron)
   
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5485

Le 10/02/2014 à 20h22
Metalion :
En utilisant la commande VDP, évidemment ...



Les registres de statut sont en négatif.

Pour lire le registre de statut 1, il faut faire VDP(-1).




c'etait évident :oups pour celui qui sait :| :lol



Merci :top


banniere-ericb59e
Site web    
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 10/02/2014 à 21h58
@Métalion:

Pour être sur de ne pas faire une fausse manipulation, J'ai doublé le nombre lignes qui défini l'état de chaque SPRITE.
La première ligne Désactive la collision, mais la seconde ligne ne semble pas réactiver la collision

Code TEXT :
 
10 'DEFUSR=&HD000:A=USR(0):FORP=0TO10:NEXT:POKE&HFD9F,201:SAVE"vdp27.asc",a
20 VDP(10)=(0):WIDTH80:SCREEN5,2:COLOR 15,1,1:SETPAGE0,0:CLS:DEFINTA-Z
30 '
40 '            Chargement ecran des niveaux en page 3
50 '
60 SETPAGE0,3:BLOAD"fondw.sc5",S
70 '
80 '            Chargement ecran des "sprites" en page 2
90 '
100 SETPAGE0,1:BLOAD"winnie.sc5",S
110 COLOR=RESTORE
120 '
130 ' -----------INSERTION DES MUSIQUES ET SONS----------
140 'GOTO 1790
150 'DEFUSR=&HD000:A=USR(0):'STOP LA MUSIQUE
160 'DEFUSR=&HD000:A=USR(0):POKE&HCFFF,30:A=USR2(0):' MUSIQUE STAGE 6
170 '
180 '            Cr‚ation d'un sprite pour masque en page 0
190 '
200 SETPAGE0,0
210 FORI=&H7800TO&H781F:VPOKEI,255:NEXTI
220 'PUTSPRITE0,(100,100),7,0
230 '
240 '            Initialisation des varibles
250 '
260  V=3
270  C=0:X=100:Y=80:D=52:A=0:N=1:M=0
280 '
290 '              Mise en place d‚cors
300 '
310 GOSUB 1700
320 COPY(0,0)-(255,31),0TO(0,192),0:' Overscan
330 '
340 '              Sprites ennemis rampants
350 '
360  ONSPRITEGOSUB560
370 'PUTSPRITE6,(150,100),1,0:PUTSPRITE7,(180,75),1,0:PUTSPRITE8,(180,125),1,0
380 'PUTSPRITE9,(120,75),1,0:PUTSPRITE10,(120,125),1,0
390  SPRITE ON
400 '
410 '
460 '              SP gestion mouvement: STATIQUE
470 '
480 '
490 X=X-4:IFX<1THENX=0
491 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
500 VDP(27)=VDP(27)+1AND255
501 PUTSPRITE0,(X,Y),11,0
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
503 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
504 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
505 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
506 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
507 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
508 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
509 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
510 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),1,0
511 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
560 END
570 '              SP gestion mouvement: HAUT
580 '
590 X=X-1:IFX<1THENX=0
591 Y=Y-6:IFY<-6THENY=-7:VDP(24)=VDP(24)+1
592 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
593 VDP(27)=VDP(27)+1AND255
594 PUTSPRITE0,(X,Y),11,0
595 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
596 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
597 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
598 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
599 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
600 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
601 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
602 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
606 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X,Y-50),9,0
607 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
660 '
670 '              SP gestion mouvement: HAUT/DROITE
680 '
690 X=X+4:IFX>200THENX=196
691 Y=Y-6:IFY<-6THENY=-7:VDP(24)=VDP(24)+1
692 VDP(24)=VDP(24)-1AND255
693 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
694 VDP(27)=VDP(27)+1AND255
695 PUTSPRITE0,(X,Y),11,0
696 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
697 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
698 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
699 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
700 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
701 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
702 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
703 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
706 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X,Y),0,0
707 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
760 '
770 '              SP gestion mouvement: DROITE
780 '
790 X=X+4:IFX>200THENX=196
791 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
792 VDP(27)=VDP(27)+1AND255
793 PUTSPRITE0,(X,Y),11,0
794 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
795 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
796 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
797 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
798 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
799 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
800 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
801 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
806 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X+50,Y),15,0:'PUTSPRITE1,(X,Y),0,0
807 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
850 '
860 '              SP gestion mouvement: DROITE/BAS
870 '
880 X=X+4:IFX>200THENX=196
881 Y=Y+6:IFY>189THENY=190:VDP(24)=VDP(24)-1
882 VDP(24)=VDP(24)+1AND255
900 VDP(27)=VDP(27)+1AND255
901 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
902 VDP(27)=VDP(27)+1AND255
903 PUTSPRITE0,(X,Y),11,0
904 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
905 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
906 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
907 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
908 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
909 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
910 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
911 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
912 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X,Y),0,0
913 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
950 '
960 '              SP gestion mouvement: BAS
970 '
980 X=X-1:IFX<1THENX=0
981 Y=Y+6:IFY>189THENY=190:VDP(24)=VDP(24)-1
982 VDP(24)=VDP(24)+1AND255
983 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
984 VDP(27)=VDP(27)+1AND255
985 PUTSPRITE0,(X,Y),11,0
986 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
987 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
988 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
989 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
990 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
991 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
992 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
993 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1006 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X,Y+50),8,0
1007 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
1050 '
1060 '              SP gestion mouvement: BAS/GAUCHE
1070 '
1080 X=X-4:IFX<1THENX=0
1081 Y=Y+6:IFY>189THENY=190:VDP(24)=VDP(24)-1
1082 VDP(24)=VDP(24)+1AND255
1083 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
1084 VDP(27)=VDP(27)+1AND255
1085 PUTSPRITE0,(X,Y),11,0
1086 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1087 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1088 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1089 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1090 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1091 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1092 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1093 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1106 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X,Y),0,0
1107 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
1150 '
1160 '              SP gestion mouvement: GAUCHE
1170 '
1180 X=X-6:IFX<1THENX=0 
1181 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
1182 VDP(27)=VDP(27)+1AND255
1183 PUTSPRITE0,(X,Y),11,0
1184 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1185 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1186 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1187 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1188 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1189 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1190 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1191 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1216 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X-50,Y),6,0
1217 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
1240 '
1250 '              SP gestion mouvement: GAUCHE/HAUT
1260 '
1270 X=X-4:IFX<1THENX=0
1271 Y=Y-6:IFY<-6THENY=-7:VDP(24)=VDP(24)+1
1272 VDP(24)=VDP(24)-1AND255
1273 COPY(16+VDP(27),191)-(31+VDP(27),206),1TO(X,Y),0
1274 VDP(27)=VDP(27)+1AND255
1275 PUTSPRITE0,(X,Y),11,0
1276 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1277 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0
1278 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1279 PUTSPRITE3,(-X-VDP(27),-Y),15XOR32,0
1280 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1281 PUTSPRITE4,(-Y,X-VDP(27)),8XOR32,0
1282 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1283 PUTSPRITE5,(X+Y,VDP(27)),6XOR32,0
1284 IFSTRIG(0)THENPOKE&HCFFF,11:A=USR2(0):PUTSPRITE1,(X-50,Y),6,0
1285 S=STICK(0):ONS+1GOTO490,590,690,790,880,980,1080,1180,1270
1340 '
1350 '                Collisions
1360 '
1370 IF P=10THEN1520  ' si trou -> SP tombe
1380 COPY(X,Y)-(X+34,Y+50),2TO(0,0),3
1390 COPY(D,A)-(D+25,A+37),1TO(4,4),3,TPSET
1400 COPY(0,0)-(34,50),3TO(X,Y),0
1410 POKE&HFD9F,201
1420 PSET(INT((X+15)/16),202+INT((Y+4)/16)),15:B=P*6:F=P*5
1430 COPY(240,191)-(255,206),1TO((INT((X+15)/16))*16,(INT((Y+36)/16))*16),2
1440 COPY(208,P*16-112)-(223,P*16-97),1TO(C*16+32,196),0
1450 POKE&HFD9F,201:POKE&HFDA0,&H6:POKE&HFDA1,&HD0:POKE&HFD9F,&HC3
1460 POKE&HCFFF,82:A=USR2(0)
1470 C=C+1
1480 GOTO 430
1490 '
1500 '              SP chute dans le trou
1510 '
1520 FORI=0TO36STEP2
1530 COPY(X,Y)-(X+34,Y+50),2TO(0,0),3
1540 COPY(D,A)-(D+25,A+37-I),1TO(4,4+I),3,TPSET
1550 COPY(0,0)-(34,50),3TO(X,Y),0
1560 A=A+38:IFA=190THENA=38
1570 B=I+40:POKE&HCFFF,70:A=USR2(0)
1580 IFPLAY(0)=-1THEN1580
1590 NEXT
1600 M=0:N=0
1610 LINE(32,196)-(255,212),1,BF
1620 V=V-1:IFV=0THEN1640
1630 GOTO 270
1640 SCREEN0:PRINT"                GAME OVER
1650 GOTO1650  
1660 '
1670 '              SP Mise en place du d‚cor
1680 '
1690 COPY(0,200)-(15,211),0TO(M*16,200),3
1700 COPY(N*16,200)-(15+N*16,211),3TO(0,200),0
1710 'poke&HCFFF,69:A=USR2(0)
1720 FORI=0TO15:FORJ=0TO11:P=POINT(I,J+200):COPY(P*16,191)-(15+P*16,206),1TO(I*16,J*16),0
1730 NEXTJ:NEXTI
1740 COPY(0,0)-(256,192),0TO(0,0),2
1750 M=N
1760 'BEEP
1770 RETURN
1780 GOTO 1780
1790 '---------DEBUT DE SALAMANDER DEMO MODIFIE----------------
1800 'POKE&HFBB1,1: 'EMPECHE CONTROL+STOP
1810 BLOAD"1.006":DEFUSR4=&HD600:' CHARGE LE PLAYER ?
1820 BLOAD"1.007":U=USR4(1):' CHARGE SONS ET MUSIQUES
1830 BLOAD"1.008":U=USR4(2):' CHARGE SONS ET MUSIQUES
1840 BLOAD"1.009":U=USR4(3):' CHARGE SONS ET MUSIQUES
1850 BLOAD"1.010":U=USR4(4):' CHARGE SONS ET MUSIQUES
1860 BLOAD"1.011":FORT=0TO2000:NEXT
1870 DEFUSR=&HD000:A=USR(0): 'PREREQUIS ARRET LA MUSIQUE
1880 DEFUSR2=&HD003:' PREREQUIS FONCTION INCONNUE
1890 POKE&HFD9F,201
1900 POKE&HFDA0,&H6:POKE&HFDA1,&HD0:POKE&HFD9F,&HC3
1910 ' LISTE COMPLETE DES MUSIQUES ET SONS DANS POKE SALAMANDER
1920 '
1930 DEFUSR=&HD000:A=USR(0):POKE&HCFFF,32:A=USR2(0):' MUSIQUE STAGE 6
1940 'POKE&HCFFF,67:A=USR2(0):' EXPLOSION D'ENNEMI MOYENNE
1950 '
1960 'DEFUSR=&HD000:A=USR(0):FORP=0TO10:NEXT:POKE&HFD9F,201:'PERMET ACCES DISK MAIS ARRETER MUSIQUE AVANT
1970 GOTO 150:' RETOUR A L ANIMATION
1980 '
1990 '---------FIN DE SALAMANDER DEMO MODIFIE-------------------
 


Concrètement, la Commande XOR 32 met le Sixième Bits à 1, mais en répétant l'opération avec un nouveau XOR sur le même SPRITE, le sixième Bit ne repasse pas à Zéro!

Au final, on se retrouve avec...

ON SPRITE GOSUB: SPRITE ON => Active l'interruption SPRITE.
502 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0 => Désactive la COLLISION de ce SPRITE seulement.
503 PUTSPRITE2,(-X+VDP(27),X-VDP(27)),9XOR32,0 => Devrait réactiver la COLLISION de ce SPRITE mais reste sans effet! (La COLLISION n'est donc pas restaurée) Edité par igal Le 10/02/2014 à 21h59


Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
ericb59 Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++ Groupe : Shoutbox

Inscrit le : 17/04/2012 à 10h25

Messages: 5485

Le 11/02/2014 à 06h20
pour que ça fontionne il faut mettre ta valeur dans une variable.

C=c xor 32
put sprite ...... (x,y),c,1


banniere-ericb59e
Site web    
Metalion Membre non connecté

Conseiller Municipal

Rang

Avatar

Inscrit le : 23/12/2009 à 15h32

Messages: 1487

Le 11/02/2014 à 10h48
Igal, il est évident que 9XOR32 donnera toujours le même résultat puisque les données sont fixes !!!
Comme Eric le souligne, il faut travailler avec une variable.

Sinon, tu as lu TOUT mon message ?


MSX1: Daewoo DPC-200 / Yamaha CX5M
MSX2: Sony HB-F9P
MSXVR
Vidéo: V9990 (GFX-9)
Audio: MSX-Music (FM-PAC) / MSX-Audio (Audiowave) / OPL4 (Monster Sound FM Blaster) / OPNB (Neotron)
   
igal Membre non connecté

Conseiller Municipal

Rang

Avatar

Groupe : compte ++

Inscrit le : 29/07/2010 à 17h19

Messages: 5492

Le 12/02/2014 à 00h51
Salut Métalion.

Oui j'ai bien lu ton message et ca a l'air très intéressant même si je sais absolument pas comment exploiter cette possibilité.

En gros, à ce que j'ai compris.
1) Le VDP (9938 et 9958) génère génère et stock en Hardware les coordonnées X,Y de toutes les COLLISIONS qu'il détecte.
2) Pour relever ces coordonnées, il faut "interroger" les registres 3,4,5,6 en BASIC VDP(2),VDP(3),VDP(4),VDP(5).

Comment faire pour exploiter cette possibilité :oups

De mon coté, j'ai voulu en avoir le coeur net avec les XOR.

J'ai donc fait ce petit programme pour tester les commandes relatives aux SPRITES:
Code TEXT :
10 FORI=&H7800TO&H781F:VPOKEI,255:NEXTI:x=100
20 ONSPRITEGOSUB130:SPRITEON
30 X=X-4:IFX<1THENX=0
50 VDP(27)=VDP(27)+1AND255
60 C=CXOR32:PUTSPRITE5,(X+Y,VDP(27)),6+C,0:C=CXOR32
70 C=CXOR32:PUTSPRITE2,(-X+VDP(27),X-VDP(27)),6+C,0:C=CXOR32
80 C=CXOR32:PUTSPRITE3,(-X-VDP(27),-Y+VDP(27)),1+C,0:C=CXOR32
90 C=CXOR32:PUTSPRITE4,(-Y,X-VDP(27)),8+C,0:C=CXOR32
100 PUTSPRITE0,(X+80,Y+150),15OR32,0
110 IFSTRIG(0)THENPUTSPRITE1,(X+50,Y),1,0
120 S=STICK(0):ONS+1GOTO30,30,30,30,30,30,30,30,30
130 END







Tiens... voila du boudin, voila du boudin, voila du boudin... :siffle
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie