Author |
Message |
|
Jim e
Advanced Member
Joined: 05 Sep 2005 Posts: 360
|
Posted: 27 Mar 2006 04:22:02 pm Post subject: |
|
|
Yeah all that setting and restting accmoplishes nothing, add a,b \ rra is all you need. Though I don't know if that can be considered a routine. |
|
Back to top |
|
|
kermmartian Site Admin Kemetech
Calc Guru
Joined: 20 Mar 2004 Posts: 1220
|
Posted: 27 Mar 2006 09:08:46 pm Post subject: |
|
|
Better Hotspot
Code: ;----------Hot spot detection-----------
;inputs: b,c (first x and y cor)
; d,e (last x and y cor)
; h,l (current x,y)
;output: "z" flag [either true (set) or false (reset)]
hdetect:
ld a,h
cp b
jr c,hno_detect
cp d
jr nc,hno_detect
ld a,l
cp c
jr c,hno_detect
cp e
jr nc,hno_detect
hyes_detect:
xor a
or a
ret
hno_detect:
xor a
cp 1
ret
|
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 28 Mar 2006 12:35:09 pm Post subject: |
|
|
What's a hot spot?
It would be more efficient if you used the 'c' flag:
Code: ;----------Hot spot detection-----------
;inputs: b,c (first x and y cor)
; d,e (last x and y cor)
; h,l (current x,y)
;output: "c" flag [either true (set) or false (reset)]
hdetect:
ld a,h
cp b
ccf
ret nc
cp d
ret nc
ld a,l
cp c
ccf
ret nc
cp e
ret
Last edited by Guest on 28 Mar 2006 03:13:25 pm; edited 1 time in total |
|
Back to top |
|
|
kermmartian Site Admin Kemetech
Calc Guru
Joined: 20 Mar 2004 Posts: 1220
|
Posted: 28 Mar 2006 02:11:02 pm Post subject: |
|
|
Thought of that after I posted it. :)
Hotspot: basically it checks if h>b, l>c, h<d, and l<e.
Last edited by Guest on 28 Mar 2006 02:11:55 pm; edited 1 time in total |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 28 Mar 2006 05:08:40 pm Post subject: |
|
|
does somebody have a routine that sees if two sprites collide by XORing the contents to see if they overlap? |
|
Back to top |
|
|
Rezek Better Than You
Calc Guru
Joined: 24 Apr 2005 Posts: 1229
|
Posted: 28 Mar 2006 06:15:42 pm Post subject: |
|
|
XOR them both to the screen using ionsprite, then use bounding box detection.
Last edited by Guest on 28 Mar 2006 06:16:01 pm; edited 1 time in total |
|
Back to top |
|
|
CoBB
Active Member
Joined: 30 Jun 2003 Posts: 720
|
Posted: 29 Mar 2006 02:47:50 am Post subject: |
|
|
What would be the point of that?
The solution isn't too complicated. First do a bounding box check to see if collision is possible at all. If those overlap, determine which bytes they share. For the rest, you need a sprite-sized buffer. LD the conflicting bytes of the first sprite to the buffer (after shifting, of course), and start ANDing the second (again, only AND the bytes that are shared with the other sprite and ignore the rest). If the result of an AND is nonzero, you have a pixel-level collision. If every conflicting byte gives zero after the ANDing, there is no collision. |
|
Back to top |
|
|
D-Tal
Newbie
Joined: 23 Mar 2006 Posts: 7
|
Posted: 29 Mar 2006 10:22:35 am Post subject: |
|
|
CoBB wrote: [quote name='D-Tal' date='Mar 27 2006, 04:21 PM']add a,b
res 0, a
jr nc, label ; corrected syntax...
set 0, a
label:
rrca
Why not just add a,b \ rra?
[post="73161"]<{POST_SNAPBACK}>[/post]
[/quote]
HehHeh...
And what happens if you try to average 250 and 252 then, mmm? |
|
Back to top |
|
|
CoBB
Active Member
Joined: 30 Jun 2003 Posts: 720
|
Posted: 29 Mar 2006 11:02:15 am Post subject: |
|
|
You get 251.
1. You should read up on rotate and shift instructions.
2. You should actually run the code before questioning its correctness. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 29 Mar 2006 11:49:21 am Post subject: |
|
|
It's that "carry bit gets rotated back in" thing. |
|
Back to top |
|
|
D-Tal
Newbie
Joined: 23 Mar 2006 Posts: 7
|
Posted: 29 Mar 2006 03:20:20 pm Post subject: |
|
|
ouch
oops -----> :confused: -----> -----> :blush:
Still, thanks for the tip. I would have gone off and used my old code, wasting untold bytes! |
|
Back to top |
|
|
Rezek Better Than You
Calc Guru
Joined: 24 Apr 2005 Posts: 1229
|
Posted: 29 Mar 2006 04:58:31 pm Post subject: |
|
|
Quote: What would be the point of that?
Maybe I misunderstood what he meant, I thought he wanted something that would write two sprites to gbuf, and then check if they had collided or not. Guess not though! |
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 29 Mar 2006 08:46:43 pm Post subject: |
|
|
CoBB wrote: What would be the point of that?
The solution isn't too complicated. First do a bounding box check to see if collision is possible at all. If those overlap, determine which bytes they share. For the rest, you need a sprite-sized buffer. LD the conflicting bytes of the first sprite to the buffer (after shifting, of course), and start ANDing the second (again, only AND the bytes that are shared with the other sprite and ignore the rest). If the result of an AND is nonzero, you have a pixel-level collision. If every conflicting byte gives zero after the ANDing, there is no collision.
[post="73309"]<{POST_SNAPBACK}>[/post]
thanks! i ask only because somebody wrote a 68k version that does that. |
|
Back to top |
|
|
Adm.Wiggin aka Tianon
Know-It-All
Joined: 02 Jun 2003 Posts: 1874
|
Posted: 20 Apr 2006 04:52:19 pm Post subject: |
|
|
Wow. I turn my back for a few months, and you guys have a total disregard for the rules. Disgraceful. I guess we can now nullify the discussion rule, seeing as how nobody really followed it. Oh well, it seems like you had some good discussion. Keep bringing in the cool routines and stuff! |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 17 May 2006 06:26:57 pm Post subject: |
|
|
time to revive the topic...
Center Text
Code: ;input:hl points to string
;output: string displayed centered on screen
;destroyed: all registers
;other remarks: (penrow) must be set before calling this sub-routine
; first byte of string must be the length of the string
centertxt:
bcall(_SStringLength)
ld a,96 ;width of screen
sub b ;subtract width of string
rra ;divide by 2 to be centered
ld (pencol),a
ld b,(hl)
inc hl
bcall(_VPutSN)
ret
;to call:
...
ld hl,0
ld (penrow),hl
ld hl,txtTest
call centertxt
...
txtTest:
.db 11,"Sample Text"
|
|
Back to top |
|
|
Liazon title goes here
Bandwidth Hog
Joined: 01 Nov 2005 Posts: 2007
|
Posted: 17 May 2006 09:42:08 pm Post subject: |
|
|
that is kinda cool to have. |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 18 May 2006 04:37:39 pm Post subject: |
|
|
Small useful piece of code (Might not be so useful for intermediate-advance programmers).
Type Write
Code: ;input: hl points to string (optional argument: b to set type speed)
;output: string displayed at set location (must set penrow and pencol before calling)
;destroyed: all but c
type:
ld a,(hl)
or a
ret z
inc hl
; cp b ;optional line
;call nz,pause ; -or- (next 2 lines)
ld b,30
call pause
bcall(_VPutMap)
jr type
pause:
ei
halt
djnz pause
di
ret
;To call:
...
ld hl,0
ld (penrow),hl
ld b,
ld hl,txtTest
call type
...
txtTest:
.db "Sample Text",0
|
|
Back to top |
|
|
alexrudd pm me if you read this
Bandwidth Hog
Joined: 06 Oct 2004 Posts: 2335
|
Posted: 18 May 2006 06:04:20 pm Post subject: |
|
|
What's the point of calling pause instead of just copying the code where you need it? |
|
Back to top |
|
|
WikiGuru ADOS (Attention deficit... Oh! Shiny!)
Elite
Joined: 15 Sep 2005 Posts: 923
|
Posted: 19 May 2006 05:28:27 pm Post subject: |
|
|
Sorry, I wasn't specific enough. It's a type-writer effect. |
|
Back to top |
|
|
DarkerLine ceci n'est pas une |
Super Elite (Last Title)
Joined: 04 Nov 2003 Posts: 8328
|
Posted: 19 May 2006 05:51:35 pm Post subject: |
|
|
What he means is, instead of doing Code: type:
ld a,(hl)
or a
ret z
inc hl
ld b,30
call pause
bcall(_VPutMap)
jr type
pause:
ei
halt
djnz pause
di
ret you could do Code: type:
ld a,(hl)
or a
ret z
inc hl
ld b,30
ei
pause:
halt
djnz pause
di
bcall(_VPutMap)
jr type
ret
Last edited by Guest on 19 May 2006 05:51:58 pm; edited 1 time in total |
|
Back to top |
|
|
|