bits.c'r xbits.c"%yTEXTCWIE'r xe#include #include #include #include "bits.h" #include "sprite.h" #define max_bits 48 // Structure containing information for one bit. typedef struct { long x,y; // Coordinate of bit. long spx,spy; // Speed int u,v; // Position in VRAM. u_char valid; // If this bit is being used or not. } bit; static bit bits[max_bits]; // Array of all bits that can be used. static int nextbit = 0; // Next bit that is to be used. void AddBit(short x, short y, int u, int v); // Add single bit at coordinate x,y. Sprite at VRAM coords u,v. void Bits(GsOT *OT) { static u_char startup = 1; GsSPRITE bitspr; int i; // If this is being called for the first time invalidate all bits. if (startup) { startup = 0; for (i=0;i 256<<8) bits[i].valid = 0; bits[i].spy+=64; bitspr.x = bits[i].x>>8; bitspr.y = bits[i].y>>8; CalcSprPos(bitspr, bits[i].u, bits[i].v); GsSortFastSprite(&bitspr, OT, 6); } } } void AddBits(card *c, short areax, short areay) { int u,v,x,y; // Add suit icon bit. AddBit(areax, areay, 640+(c->suit*8), 40); // Add number bit. switch(c->suit) { case heart: case diamond: AddBit(areax+8, areay+16, 640+((c->value-1)*8), 24); break; case spade: case club: AddBit(areax+8, areay+16, 640+((c->value-1)*8), 32); break; } // Work out VRAM coords for back of card sprite. if (c->value>10) { u = 640+16*(c->value-10); v = 0; } else {u = 640; v = 0;} // Split card into 6 bits. for (y=0;y<3;y++) { for (x=0;x<2;x++) { AddBit(areax+x*8, areay+y*8, u+8*x, v+8*y); } } } void AddBit(short x, short y, int u, int v) { bits[nextbit].x = x<<8; bits[nextbit].y = y<<8; bits[nextbit].spx = (rand() & 2047) - 1024; bits[nextbit].spy = -(rand() & 2047); bits[nextbit].u = u; bits[nextbit].v = v; bits[nextbit].valid = 1; if ((nextbit++) == max_bits) nextbit = 0; }ZZRxlzbits.crrior IDE 2.0.3encesallerTEXTCWIEr'_fA*"m#H &T0g;|(`;|Y/ N0-H" rN,p&@`6/ 0-HД-@0-H n00H.g &@N0-RmH Monaco1'U1'U ZZRNX1RMPSRMWBB*LR