CodeWalrus

Development => Calculators => Calc Projects, Programming & Tutorials => Topic started by: Switchblade on June 27, 2017, 01:35:21 AM

Title: [Axe] Using OS Pic Variables
Post by: Switchblade on June 27, 2017, 01:35:21 AM
How can I display a user pic variable, i.e. Pic1, in Axe? I know you need to use [Pic1r] -> Pointer, but when I try to display it using Copy(Pointer,L6) the screen is filled with junk. Can someone give me some example code? Thanks :)
Title: Re: [Axe] Using OS Pic Variables
Post by: mazhat on June 27, 2017, 02:20:59 AM
Pic1 stores a sprite 8*8 in size.
Or 1*8 bytes.

e.x. for a smiley face:
[7E81A581A599817E]->Pic1 ;store into user space
ptOff(X,Y,Pic1) ;to display the sprite without any bitwise-arithmetic

For a picture that would fill the entire screen
you must use the keyword "Bitmap(".
This is 96*64 pixels in size,
or 12*64 bytes in size.

Edit: Perhaps Pic1 can be used to hold a bitmap in it. I haven't had a chance to use Bitmap( that way yet.
Title: Re: [Axe] Using OS Pic Variables
Post by: c4ooo on June 27, 2017, 02:26:23 AM
Quote from: mazhat on June 27, 2017, 02:20:59 AM
Pic1 stores a sprite 8*8 in size.
Or 1*8 bytes.

e.x. for a smiley face:
[7E81A581A599817E]->Pic1

For a picture that would fill the entire screen
you must use the keyword "Bitmap(".
This is 96*64 pixels in size,
or 12*64 bytes in size.
This is wrong. ;)
"PicN" is just a constant that points to some data, just like "StrN". You could do [7E81A581A599817E]->Str1 or "Hello World"->Pic1 and axe wouldn't care. You could even do 5->Pic1 , and then Pic1*2 would return 10.
Putting Pic1 in square brackets (this also works with other data types) just tells the compiler to copy the data from that OS variable into your program, and returns a pointer to that data.
Title: Re: [Axe] Using OS Pic Variables
Post by: mazhat on June 27, 2017, 02:28:37 AM
@c4ooo I pre-corrected myself with an edit.
Don't worry, I know that it's "generic".
I have a standard practice, sometime I forget things are possible.

Edit:
Sorry, Switchblade. I must have sounded very patronising and pretentious.
Switchblade is actually a smart boy, he makes arcade game ports and such and it's pretty cool.
Title: Re: Using OS Pic Variables
Post by: ben_g on June 27, 2017, 12:26:42 PM
Quote from: Switchblade on June 27, 2017, 01:35:21 AM
...[Pic1r] ->Pointer...
...Copy(Pointer,L6)...
[Pic1r] -> pointer will store the OS pic variable in 8x8 chunks that can then be drawn using the Pt-on( command (or at least that's how I understand it from the command list (https://axe.eeems.ca/Commands.html)). It has to move some bytes around for that since OS Pic variables aren't stored in 8x8 chunks. Copying that directly to the screen will then show what's basically a scrambled version of your image.

If you just write it as [Pic1] -> pointer then it should add the OS Pic variable in the program memory as-is, and using it with Copy(Pointer,L6) should show it on the screen. The bottom row may still look weird though, Pic variables store only 63 rows while the screen is 64 pixels tall. Copying it to the screen will also copy the 12 bytes of data after that to the screen. A simple workaround is to add that last row manually, like this:

`:[Pic1]->Pointer:[000000000000000000000000]`Which will store an extra white row at the bottom. Use F instead of 0 if you want a black row instead.