Author Topic: Basic Efficient Collision Detection Routine  (Read 2026 times)

0 Members and 1 Guest are viewing this topic.

Offline ZbyniuR

  • 464 Plus
  • *****
  • Posts: 300
  • Country: pl
  • 6128 A1230 PSX Win7
    • Jedyne polskie forum o CPC. :)
  • Liked: 294
Re: Basic Efficient Collision Detection Routine
« Reply #25 on: 02:03, 01 April 18 »
10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT
20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC

I used to found this in some magazine. :)

And remember about TEST command, could be usefull to detect pixel color. :)
TREK is better than WARS.

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 2.751
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 977
Re: Basic Efficient Collision Detection Routine
« Reply #26 on: 19:01, 13 October 18 »
10 FOR a=1 TO 17:POKE 39999+a,VAL("&"+MID$("DD7E00CDB4BBF5CD60BB320000F1C3B4BB",a*2-1,2)):NEXT
20 LOCATE x,y:CALL 40000,0:PRINT CHR$(PEEK(0)) '  this works as COPYCHR$ in any CPC
This is great!
Can someone turn this into an RSX command please?  :)
What are the BASIC lines to create a small RSX command like |charCodeAt(x,y)Returns ASCII code for the character at location x,y
Or |code(x,y)

Offline asertus

  • CPC464
  • **
  • Posts: 31
  • Country: es
  • Liked: 25
Re: Basic Efficient Collision Detection Routine
« Reply #27 on: 21:41, 13 October 18 »
Basically all these are already implemented as RSX by 8 bits de poder i.e.:


|COLAY,umbral_ascii, #,@colision detecs collission with layout and returns 1 if true
|COLSP, #,@id returns 1st sprite collision with #
|COLSPALL,@quien%,@conquien% returns "quien" has collided and with whom

Offline mr_lou

  • 6128 Plus
  • ******
  • Posts: 2.751
  • Country: dk
    • index.php?action=treasury
    • 8-bit Memoirs - a Blu-ray diskmag-like eBook about the 8-bit era
  • Liked: 977
Re: Basic Efficient Collision Detection Routine
« Reply #28 on: 07:34, 14 October 18 »
Basically all these are already implemented as RSX by 8 bits de poder i.e.:

|COLAY,umbral_ascii, #,@colision detecs collission with layout and returns 1 if true
|COLSP, #,@id returns 1st sprite collision with #
|COLSPALL,@quien%,@conquien% returns "quien" has collided and with whom

It doesn't look like the same to me. There's a difference between a sprite and an ASCII character.

These are commands that checks for collision. That's not what I'm asking for. I just want to be able to get the ASCII code for the character on a certain location on the screen. The above BASIC code does that. All I need now is to turn it into an RSX command - and include the LOCATE command in the RSX as well. so I can call |charCodeAt,x,y  :)

Offline fgbrain

  • CPC6128
  • ****
  • Posts: 203
  • Country: gr
    • index.php?action=treasury
    • Chaos CPC Homepage
  • Liked: 106
Re: Basic Efficient Collision Detection Routine
« Reply #29 on: 02:26, 25 November 18 »
At your service  @mrlou ,

CALL &A500 to set command (fully relocatable!!)

then use: 

a%=0
|charcode,@a%,x,y

returns at a% = number of chr found else a%=0




Code: [Select]
org &A500

INITIALIZE:
    LD HL,WORK_SPACE ;RSX power - up Routine
    LD BC,RSX_TABLE
    JP &BCD1

WORK_SPACE: DEFS  4 ;Area for Kernel to use

RSX_TABLE: DEFW NAME_TABLE
    JP CHAR_CODE ;

NAME_TABLE: DEFB 'CHARCOD','E'+#80 ;
    DEFB #00

CHAR_CODE
CP 3
RET NZ  ;EXIT if not 3 parameters
LD D,(IX+5) ;
LD E,(IX+4) ; DE = ADR OF A%
LD H,(IX+2) ; H = X
LD L,(IX+0) ;  L = Y
CALL &BB75
CALL &BB60
LD(DE),A ; STORE VALUE IN A%
RET
_____

6128 (UK keyboard, Crtc type 0/2), 6128+ (UK keyboard), 3.5" and 5.25" drives, Reset switch and Digiblaster (selfmade), Inicron Romram box, Bryce Megaflash, SVideo & PS/2 mouse, , Magnum Lightgun, X-MEM, X4 Board, C4CPC, Multiface2 X4, RTC X4 and Gotek USB Floppy emulator.