<Omikron Basic> How do I test if a bit is set on screen?

Moderators: exxos, simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

<Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Thu Feb 04, 2010 8:24 am

Hello!

First of all I am happy to see that the forums are back online! Today I like to improve my coding skills. My question is, how do I test if a bit is set at the position x,y on the screen at ST-HIGH? I know about the POINT command, but I like to find a faster way. Any ideas?

Tnx, Omi
Last edited by Omikronman on Thu Feb 04, 2010 8:41 am, edited 1 time in total.

User avatar
BoNuS
Atari Super Hero
Atari Super Hero
Posts: 723
Joined: Mon Jan 19, 2009 12:45 pm
Location: The Netherlands
Contact:

Re: How do I test if a bit is set on screen?

Postby BoNuS » Thu Feb 04, 2010 8:37 am

In GFA basic there is a command calld PTST.
I think you can use that.

A%=PTST(X,Y), AFAIK its much faster then POINT.
http://bonus.home.xs4all.nl/
2 x Falcon 030 - a mint Atari TT - Mega STE - 2x STE - 1x Mega 2 - 2x STFM - 1 x STF - 3x SC1224 - 2x SM124 - 1x SM125 2x Portofolio+interface
- 3x 1435 monitor - 1 x Ult.Ripper cardridge - Mega 1,2,and 4 ( just to much Atari stuff)

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Thu Feb 04, 2010 8:42 am

Oh, I had forgotten to say that I try to do it with Omikron.Basic (unfortunately there isn´t a Omikron.Basic section in the forums so I did my thread into "other basic". Maybe some sort of PEEK command would work, but I don´t know how.

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Nyh » Thu Feb 04, 2010 8:55 am

Omikronman wrote:Hello!

First of all I am happy to see that the forums are back online! Today I like to improve my coding skills. My question is, how do I test if a bit is set at the position x,y on the screen at ST-HIGH? I know about the POINT command, but I like to find a faster way. Any ideas?

The hard way to find out is:

peek(lpeek($44e)+y*80+x\8) and (1 shl(7-(x and 7)))

If this is not zero the pixel is set.

Hans Wessels

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Thu Feb 04, 2010 9:03 am

Ah, tnx! I will play around with that and do some tests!

User avatar
BoNuS
Atari Super Hero
Atari Super Hero
Posts: 723
Joined: Mon Jan 19, 2009 12:45 pm
Location: The Netherlands
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby BoNuS » Thu Feb 04, 2010 9:40 am

Omikronman wrote:Oh, I had forgotten to say that I try to do it with Omikron.Basic (unfortunately there isn´t a Omikron.Basic section in the forums so I did my thread into "other basic". Maybe some sort of PEEK command would work, but I don´t know how.


Could have guest that with a name as omikronman :)
For Omikron no one better than Nyh
http://bonus.home.xs4all.nl/
2 x Falcon 030 - a mint Atari TT - Mega STE - 2x STE - 1x Mega 2 - 2x STFM - 1 x STF - 3x SC1224 - 2x SM124 - 1x SM125 2x Portofolio+interface
- 3x 1435 monitor - 1 x Ult.Ripper cardridge - Mega 1,2,and 4 ( just to much Atari stuff)

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Thu Feb 04, 2010 9:44 am

Tnx anyway BoNus ^^.

I played around with it and I need some advice. I loose time when using

peek(lpeek($44e)+y*80+x\8) and (1 shl(7-(x and 7)))

because I need in addition to that line a IF ... THEN ... statement to get results of 0 or 1 dependend of the pixel (IF peek ... >0 then result=1). I am not good in maths, but is it possible perhaps to modify the line to get results of 0 and 1?

Tnx, Omi :)

User avatar
Nyh
Atari God
Atari God
Posts: 1496
Joined: Tue Oct 12, 2004 2:25 pm
Location: Netherlands

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Nyh » Thu Feb 04, 2010 11:42 am

Omikronman wrote:Tnx anyway BoNus ^^.

I played around with it and I need some advice. I loose time when using

peek(lpeek($44e)+y*80+x\8) and (1 shl(7-(x and 7)))

because I need in addition to that line a IF ... THEN ... statement to get results of 0 or 1 dependend of the pixel (IF peek ... >0 then result=1). I am not good in maths, but is it possible perhaps to modify the line to get results of 0 and 1?


(peek(lpeek($44e)+y*80+x\8) shr(7-(x and 7))) and 1

Not tested but it should work...

Hans Wessels

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Thu Feb 04, 2010 12:35 pm

Tnx, I will play around with it. =) Omi

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2231
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby lp » Thu Feb 04, 2010 3:21 pm

Take the screen address and pre-calculate a table to the start of each scan line, so the Y is an offset into the table. This will reduce the math and speed it up. :wink:

Likewise tables can be made for the X as well, to figure out the byte offset and the bit and avoid the math.

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Fri Feb 05, 2010 4:13 am

Thx! With your tips I was able to improve the performance of my ASCII-art program. A picture can now be calculated up to 35 % faster by testing the pixles more quickly.

rockyone
Captain Atari
Captain Atari
Posts: 302
Joined: Thu Jan 20, 2011 8:47 pm
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby rockyone » Sat Feb 12, 2011 8:21 pm

Peut on voir ascii art

User avatar
Omikronman
Atari Super Hero
Atari Super Hero
Posts: 525
Joined: Wed Dec 01, 2004 12:13 am
Location: Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby Omikronman » Sat Feb 12, 2011 8:25 pm


User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 1997
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby charles » Sun Feb 13, 2011 1:17 am

in gfa basic i used set bits on a monochrome screen
by finding the screen address
then poking/peeking at the 32000 byte buffer

this seems to only work on mono chrome since color uses some bizzare resolution and format for the color pallette

charles
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
lp
Fuji Shaped Bastard
Fuji Shaped Bastard
Posts: 2231
Joined: Wed Nov 12, 2003 11:09 pm
Location: GFA Headquarters
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby lp » Sun Feb 13, 2011 1:32 am

charles wrote:this seems to only work on mono chrome since color uses some bizzare resolution and format for the color pallette


Its not bizarre, its called interleaved bit planes and its well documented in almost every ST programming book I've ever picked up.

Anyway, nice video. :wink:

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 4774
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby simonsunnyboy » Sun Feb 13, 2011 9:14 am

Well it would require reading documentation again :roll:
Simon Sunnyboy/Paradize - http://paradize.atari.org/ - STOT: http://www.npoi.de/stot/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

Jabber: simonsunnyboy@atari-jabber.org

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 1997
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: <Omikron Basic> How do I test if a bit is set on screen?

Postby charles » Sun Feb 13, 2011 3:43 pm

it always requires reading document again!
charles
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!


Social Media

     

Return to “Other BASIC”

Who is online

Users browsing this forum: No registered users and 1 guest