This is an archived, read-only copy of the United-TI subforum , including posts and topic from May 2003 to April 2012. If you would like to discuss any of the topics in this forum, you can visit Cemetech's Calculator Programming subforum. Some of these topics may also be directly-linked to active Cemetech topics. If you are a Cemetech member with a linked United-TI account, you can link United-TI topics here with your current Cemetech topics.

This forum is locked: you cannot post, reply to, or edit topics. General Coding and Design => Calculator Programming
Author Message
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 17 Jun 2003 02:03:15 pm    Post subject:

Did anyone here bother to learn Qbasic? If so, do you know if I can check a pixel and see if it is turned on or not? (Possibly even color?)

I've searched through the index, but I was hoping someone had better luck finding it than I did.

Thanks!

Spyderbyte
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 17 Jun 2003 05:23:41 pm    Post subject:

This get's the colour of the pixel at x,y and puts it in c:

DEF SEG &HA000 //set memory offset for peek
c = peek(X+Y*320&) //load colour of pixel in c

Anyway, the idea is to get the value from the memory, so you'll need peek, but I'm not sure if screen settings affect the memory address.

Note that this works fine in screen 13.


Last edited by Guest on 17 Jun 2003 05:30:14 pm; edited 1 time in total
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 17 Jun 2003 10:45:19 pm    Post subject:

Sweet thanks! I had looked at peek, but I couldn't figure out exactly how it worked.

So I just enter that code exactly?

DEF SEG &HA000
c = peek(X+Y*320&)

Why is there an and symbol after the 320?

Thanks again!

Spyderbyte
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 18 Jun 2003 07:41:57 am    Post subject:

Jup, just enter it like that and put the x and y coordinates of the pixel you want to test in x and y.

320& would be the width of the screen in memory but I have no idea what the & stands for, it's probably similar to how % and $ in Ti83 ASM stand for binary and hex values respectively.

Another idea as to what it could mean would be that it tells the comp to read the data after X+Y*320 instead of at X+Y*320.

But I'm just guessing, I'll see if I can find some info on this.

Edit:

Ah, how could I forget, the & stands for long integer and is just a type-declaration character.

http://www.cerritos.edu/jwilson/CIS_103/La..._User_Guide.htm


Last edited by Guest on 18 Jun 2003 08:20:24 am; edited 1 time in total
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 18 Jun 2003 12:05:20 pm    Post subject:

Cool, thanks again!

Spyderbyte
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 23 Jun 2003 10:14:57 pm    Post subject:

Um once I type in "def seg &ha000" and press enter or the down arrow for a new line, the gray error box pops up and says "Expected: = or end-of-statement"

I entered this as the second line of my program just to test it, after screen 13. Is there something I need to do first?

Thanks!

Spyderbyte

EDIT

Whoops! I realized that first line should be "def seg = ha000" At least I think it should. I tried testing (15,20) first thing in the program (well after screen 13), and printing out the result.

It said that c equaled 2, which is green! Neutral The address is ha000, right?

Thanks again!

Spyderbyte


Last edited by Guest on 23 Jun 2003 10:46:16 pm; edited 1 time in total
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 24 Jun 2003 02:06:33 am    Post subject:

Make sure you have the latest version of the compiler and type the address in case sensitive, DEF SEG &HA000.

The number it returns should be between 0 and 255 (apparently the memory is in hex) and you can use POKE X+Y*320&, C to write the number back to the video memory and display a pixel with the colour returned by PEEK. So if oyu want to make the player die when he hits a red pixel, you'll have to see which number red is, to find that out you can use a for loop displaying the number of the colour in it's colour (like COLOR X, PRINT X, but using 256 colours instead of the regular 16).

I found my old stash of Basic programs yesterday so I'll check if there's something in there that can help you with the colours. I remember writing half a dozen programs that used 256 colours, most of them to display which colour was which number so there might be one of those around.


Last edited by Guest on 24 Jun 2003 02:09:07 am; edited 1 time in total
Back to top
Spyderbyte


Advanced Member


Joined: 29 May 2003
Posts: 372

Posted: 24 Jun 2003 01:04:03 pm    Post subject:

Yeah I've got one that will show 0-15, and another that will show 0-255. (I can post them if you want, I found them someplace else)

I think we were both right (or both wrong Very Happy ) The command that returned zero for c was "DEF SEG = &HA000)

Also, will Poke also display the pixel, or just be detected if I used peek later? Because couldn't I just use PSET (x,y)?

Thanks!

Spyderbyte
Back to top
Arcane Wizard
`semi-hippie`


Super Elite (Last Title)


Joined: 02 Jun 2003
Posts: 8993

Posted: 25 Jun 2003 06:54:55 am    Post subject:

POKE should display the pixel.

You can use PSET(x,y) but copying stuff right into memory is much faster (ie. using POKE is faster).

Here's a good example of using PEEk and POKE: clickity
Back to top
Display posts from previous:   
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
    »
» View previous topic :: View next topic  
Page 1 of 1 » All times are UTC - 5 Hours

 

Advertisement