Skip to content

Commit 24da510

Browse files
DerThoreWDrijver
andauthored
Bordercollision for GELS (#131)
* Fixed Typo in copper.h * Add Interlace modes, prepare SuperHires * Implement setwritemask * Implement minterms * Implement minterms * Implement minterms * Implement minterms * Implement minterms * Implement minterms * Implement minterms * WritePixel rewrite * dragging and swapping screens * Show screens while dragging needs an "anti flicker" in future. * Repair requesters Show requesters with raster background correctly * Temp workaround for SysInfo * Temp workaround for SysInfo * Better detection of matching screenmode * Better detection of matching screenmode * Mouse Pointer visible in flipped screen * Better detection for CGX screens * Aktualisieren von bestmodeida.c * Aktualisieren von bestmodeida.c * Aktualisieren von bestmodeida.c * Update bestmodeida.c * Correcting parameter order * Update amigavideo_hiddclass.c Activate prepared SuperHires * Update videocontrol.c Correct some, added missing ones. * Update videocontrol.c added missing define * Remove RT from AllocMem * Remove RT from AllocMem * Enhance GELS with HWSprites * Update drawglist.c * Update start.c for new core * added missing pointer added missing pointer and BORDER collision preset * DA/DD bus * DA/DD IDE Bus * DA/DD IDE Bus * DA/DD IDE Bus * DD/DA IDE Bus * DA/DD IDE Bus * DA/DD IDE Bus * DA/DD Gayle * DA/DD Gayle * DA/DD Gayle * DA/DD Gayle * DA/DD Gayle * Add GadGImage * Make LoadRGB4 more 1.3 and 3.1 compatible * Aktualisieren von loadrgb4.c * Add CL Poke Funcs * Add CL Poke Funcs * Update setrgb4.c * Aktualisieren von setrgb4.c * Aktualisieren von setrgb4.c * Update setrgb4.c * Update loadrgb4.c * change CL in any case * Implement Changesprite * Update loadrgb4.c * Update setrgb4.c * Immediate color change * Immediate color change * Avoid black regions when BOB gets moved * Use Sprite Precision * Mask Genlock Bits * Border Collision --------- Co-authored-by: Willem Drijver <60568860+WDrijver@users.noreply.github.com>
1 parent d25c4e9 commit 24da510

6 files changed

Lines changed: 100 additions & 13 deletions

File tree

rom/graphics/docollision.c

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 1995-2007, The AROS Development Team. All rights reserved.
2+
Copyright © 1995-2007, The AROS Development Team. All rights reserved.
33
$Id$
44
55
Desc: Graphics function DoCollision()
@@ -52,10 +52,19 @@
5252

5353
struct VSprite * CurVSprite, * _CurVSprite;
5454
int shift, _shift;
55+
BOOL brdh;
56+
struct Layer *layer;
57+
struct VSprite brdSprite, *brds;
5558

5659
if (NULL != rp->GelsInfo)
5760
{
5861
CurVSprite = rp->GelsInfo->gelHead->NextVSprite;
62+
63+
brdh = (LONG)(rp->GelsInfo->collHandler->collPtrs[0]) != 0;
64+
layer = rp->Layer;
65+
if(layer)
66+
ObtainSemaphore(&layer->Lock);
67+
5968
if (CurVSprite->Flags & VSPRITE)
6069
shift = 1;
6170
else
@@ -64,6 +73,67 @@
6473
while (NULL != CurVSprite->NextVSprite)
6574
{
6675
_CurVSprite = CurVSprite->NextVSprite;
76+
77+
// For safety, break at the tail GEL
78+
if(CurVSprite == rp->GelsInfo->gelTail)
79+
break;
80+
81+
/*
82+
* Check border collision
83+
*/
84+
brds = CurVSprite;
85+
if(layer && (brds->Flags & VSPRITE))
86+
{
87+
brdSprite = *CurVSprite;
88+
brds = &brdSprite;
89+
brds->X = brds->X - (layer->bounds.MinX - layer->Scroll_X);
90+
brds->Y = brds->Y - (layer->bounds.MinY - layer->Scroll_Y);
91+
}
92+
if(brdh)
93+
{
94+
if(brds->HitMask | 0)
95+
{
96+
WORD hit = 0;
97+
WORD lr;
98+
99+
// top hit
100+
if(brds->Y <= rp->GelsInfo->topmost)
101+
{
102+
hit = 1;
103+
}
104+
// bottom hit
105+
if( ((brds->Y + brds->Height) ) >= rp->GelsInfo->bottommost)
106+
{
107+
hit |= 2;
108+
}
109+
// left hit
110+
lr = rp->GelsInfo->leftmost - brds->X;
111+
if(lr >= 0)
112+
{
113+
if(lr > (brds->Width << 4))
114+
lr = (brds->Width << 4);
115+
hit |= 4;
116+
}
117+
// right hit
118+
lr = (brds->X + (brds->Width << 4)) - rp->GelsInfo->rightmost;
119+
if(lr >= 0)
120+
{
121+
if(lr > (brds->Width << 4))
122+
lr = (brds->Width << 4);
123+
hit |= 8;
124+
}
125+
/*
126+
* Did we hit a border? Then call Collision 0
127+
*/
128+
if(hit != 0)
129+
{
130+
if(CurVSprite->VSBob && (CurVSprite->VSBob->Flags & BOBSAWAY))
131+
{}
132+
else
133+
rp->GelsInfo->collHandler->collPtrs[0]( CurVSprite, hit);
134+
}
135+
}
136+
}
67137

68138
/*
69139
* As long as they can overlap vertically..
@@ -212,7 +282,7 @@
212282
if (collision)
213283
{
214284
UWORD mask = CurVSprite->MeMask & _CurVSprite->HitMask;
215-
int i = 0;
285+
int i = 1;
216286
while (i < 16 && 0 != mask)
217287
{
218288
if (mask & 0x01)
@@ -232,6 +302,9 @@
232302
}
233303
CurVSprite = CurVSprite->NextVSprite;
234304
}
305+
306+
if(layer)
307+
ReleaseSemaphore( &layer->Lock);
235308
}
236309

237310
AROS_LIBFUNC_EXIT

rom/graphics/drawglist.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,15 +311,26 @@
311311
struct Spr *spr = (struct Spr *)0xdff120;
312312

313313
WORD tx, ty, t, dy, dx, h;
314-
UWORD pos, ctl, offset;
314+
UWORD pos, ctl, offset, xprec;
315315
WORD *nextline, *image;
316316

317317
nextline = rp->GelsInfo->nextLine + pick;
318318
tx = GfxBase->ActiView->DxOffset;
319319
ty = GfxBase->ActiView->DyOffset;
320320

321321
if(CurVSprite->X < 0)dx = 0; else dx = CurVSprite->X;
322-
tx = tx + dx; // Should we do Hires >>1, SHIRES >> 2 ??
322+
xprec = 0;
323+
if(vp->Modes & 0x20)
324+
{
325+
tx = tx + (dx>>2);
326+
xprec = 2;
327+
}
328+
else if(vp->Modes & 0x8000)
329+
{
330+
tx = tx + (dx>>1);
331+
xprec = 1;
332+
}
333+
else tx = tx + dx;
323334

324335
if(CurVSprite->Y < 0) dy = 0; else dy = CurVSprite->Y;
325336
ty = ty + dy;
@@ -331,7 +342,11 @@
331342
{
332343
// PosCtl
333344
pos = (ty<<8) | ((tx >> 1) & 0xff); //(y<<15) | (x >> 1);
334-
ctl = (t << 8) | ((ty>>6)&0x4) | ((t>>7)&0x2) | (tx&0x1);
345+
ctl = ((t&0xff) << 8) | ((ty>>6)&0x4) | ((t>>7)&0x2) | (tx&0x1) | ((ty>>3)&0x40) | ((t>>4)&0x20);
346+
if(xprec > 0)
347+
{
348+
ctl |= (((CurVSprite->X) & (3 >> (2-xprec))) << (5-xprec));
349+
}
335350

336351
// image clipping
337352
image = CurVSprite->ImageData + ((UWORD)CurVSprite->Depth * (UWORD)(dy-CurVSprite->Y));

rom/graphics/gels_internal.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 1995-2016, The AROS Development Team. All rights reserved.
2+
Copyright © 1995-2016, The AROS Development Team. All rights reserved.
33
$Id$
44
55
Desc: Internal function for improved gels handling.
@@ -235,12 +235,13 @@ void _ClearBobAndFollowClearPath(struct VSprite * CurVSprite,
235235
/*
236236
* No background was saved. So let's restore the
237237
* standard background!
238-
*/
238+
* Edit: This is not really correct, this might end up in black squares. Just do nothing here
239239
EraseRect(rp,
240240
CurVSprite->OldX,
241241
CurVSprite->OldY,
242242
CurVSprite->OldX + ( CurVSprite->Width << 4 ) - 1,
243243
CurVSprite->OldY + CurVSprite->Height - 1);
244+
*/
244245
}
245246
/*
246247
* Mark the BOB as cleared.

rom/graphics/getrgb4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright © 1995-2012, The AROS Development Team. All rights reserved.
2+
Copyright © 1995-2012, The AROS Development Team. All rights reserved.
33
$Id$
44
55
Desc: Graphics function GetRGB4()
@@ -60,7 +60,7 @@
6060

6161
/* All we're currently doing is read the entry and return it. */
6262
CT = colormap->ColorTable;
63-
return CT[entry];
63+
return CT[entry] & 0xFFF;
6464

6565
AROS_LIBFUNC_EXIT
6666

rom/graphics/loadrgb4.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,7 @@ static struct CopIns *pokeCI(struct CopIns *ci, UWORD *field1, short field2)
204204

205205
// To make it visible immediately we need to update the view. To simplify it, we call MrgCop
206206
MrgCop(GfxBase->ActiView);
207-
if(TypeOfMem(GfxBase->ActiView->LOFCprList->start) == MEMF_CHIP)
208-
GfxBase->LOFlist = GfxBase->ActiView->LOFCprList->start;
207+
LoadView(GfxBase->ActiView);
209208

210209
AROS_LIBFUNC_EXIT
211210

rom/graphics/setrgb4.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@
9898
SetRGB32( vp, n, r, g, b );
9999

100100
MrgCop(GfxBase->ActiView);
101-
if(TypeOfMem(GfxBase->ActiView->LOFCprList->start) == MEMF_CHIP)
102-
GfxBase->LOFlist = GfxBase->ActiView->LOFCprList->start;
101+
LoadView(GfxBase->ActiView);
103102

104103
/************************************************************
105104
/ This is the code that works correctly on the real thing

0 commit comments

Comments
 (0)