Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > checking multiple conditions
2010-08-01 15:25
Trap

Registered: Jul 2010
Posts: 223
checking multiple conditions

Hi,

Still trying to get up to speed. So, I have this boundary check I want to do. For some reason it is turning out to be a struggle.

I want to do an upper and lower boundary check on a set of coordinates. I can have the plot anywhere, so the boundary check must take into account that the plot can be way out of boundary.
For some reason I can't get around it - my memory is not serving me well right now.

I have a currentpos and I want to compare it to a lower and upper boundary. If it is out of bounds I want to branch.

Any help is appreciated.

Trap
2010-08-01 16:22
Oswald

Registered: Apr 2002
Posts: 5094
http://www.6502.org/tutorials/compare_instructions.html

see the part:

"Use of Branch Instructions with Compare"
2010-08-01 17:50
Trap

Registered: Jul 2010
Posts: 223
Awesome. Thanks Oswald.

Another great website added to the list :)

Trap
2010-08-01 20:47
null
Account closed

Registered: Jun 2006
Posts: 645
ldx currentpos
cpx boundry_x
bpl main
cpx boundry_y
bpl main

;--- plot stuff here ---

jmp main


Okay, maybe that's not the best way to do it, if it works at all, but... yeah.


edit: whoops, I'm a bit late. And I think wrong as well. oh well. You can still laugh at me. ;_)

------------------------------------
http://zomgwtfbbq.info
2010-08-01 21:43
Fresh

Registered: Jan 2005
Posts: 101
The easiest solution is:

check:	lda coord
	cmp lower
	bcc out
	cmp upper
	bcs out
	...

out:	...


but this code does an asymmetric check (lower<=coord<upper).
You can instead use this:

check:	lda coord
	cmp upper
	bcs out
	sbc lower
	bcc out
	adc lower		
	...

out:	...

Which checks if lower<coord<Upper.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Chesser/Blazon
deetsay
Weetibix
zscs
Courage
iAN CooG/HVSC
ciccior2003/HF
ArturoDente
Guests online: 115
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Triad  (9.3)
5 Censor Design  (9.3)
Top Graphicians
1 Mirage  (9.8)
2 Archmage  (9.7)
3 Pal  (9.6)
4 Carrion  (9.6)
5 Sulevi  (9.6)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.052 sec.