Author Topic: Free RAM and drawing stuff  (Read 5193 times)

0 Members and 3 Guests are viewing this topic.

Offline macweirdo

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-3
    • View Profile
Free RAM and drawing stuff
« on: November 20, 2011, 04:39:34 pm »
So let's say I wanted to have a way to store two bits per pixel on the screen (768 bytes of data, * 2.) into RAM so I could manipulate it. How would I go about doing this, and which safeRam areas should I use (if I use L6, I'll just end up drawing directly to the screen, but I want 4scale as well, and I know it's possible.)

The first one, I'm guessing might be L3, and everytime I want to access data, I'll just do
for bit one:
Code: [Select]
{L3}+(number of pixel)
and bit two:
Code: [Select]
{other safeRam}+(number of pixel)
so to draw the screen, I just have to do a
Code: [Select]
DispGraph(L3,other safeRam)^r
So tl;dr, which safeRam besides L3 should I use for holding the entire screen?
Thanks in advance!

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Free RAM and drawing stuff
« Reply #1 on: November 20, 2011, 04:58:04 pm »
You could wither use L6, which is the main buffer, or use L1 after Reallocating the variables elsewhere. To reallocate the variables, use something like #Realloc(L4).
Good luck. :)

Offline macweirdo

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-3
    • View Profile
Re: Free RAM and drawing stuff
« Reply #2 on: November 20, 2011, 05:01:41 pm »
use L6, which is the main buffer

You're serious? Waht? Doesn't that corrupt buffer drawing or something? (btw, I don't understand that statement)

Good luck. :)

Looks like I'll need it. Thanks :D

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Free RAM and drawing stuff
« Reply #3 on: November 20, 2011, 05:07:58 pm »
use L6, which is the main buffer

You're serious? Waht? Doesn't that corrupt buffer drawing or something? (btw, I don't understand that statement)
The main buffer is what gets displayed with a DispGraph.  If there's something else there, that will be drawn instead.
For instance, try this code and see if you can figure out what is happening:
Code: [Select]
:ClrDraw
:255->{L6}
:rand->{L6+766}r // This is the superscript r
:DispGraph
:Repeat getKey(15)
:End

Offline macweirdo

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-3
    • View Profile
Re: Free RAM and drawing stuff
« Reply #4 on: November 20, 2011, 05:12:20 pm »
use L6, which is the main buffer

You're serious? Waht? Doesn't that corrupt buffer drawing or something? (btw, I don't understand that statement)
The main buffer is what gets displayed with a DispGraph.  If there's something else there, that will be drawn instead.
For instance, try this code and see if you can figure out what is happening:
Code: [Select]
:ClrDraw
:255->{L6}
:rand->{L6+766}r // This is the superscript r
:DispGraph
:Repeat getKey(15)
:End

So storing data there is just like doing a Pxl-On( to that buffer?

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Free RAM and drawing stuff
« Reply #5 on: November 20, 2011, 05:58:59 pm »
Kind of, yes. Pxl-On( places the sprite data in a specific arrangement on the buffer.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline ztrumpet

  • The Rarely Active One
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5712
  • Rating: +364/-4
  • If you see this, send me a PM. Just for fun.
    • View Profile
Re: Free RAM and drawing stuff
« Reply #6 on: November 20, 2011, 05:59:27 pm »
use L6, which is the main buffer

You're serious? Waht? Doesn't that corrupt buffer drawing or something? (btw, I don't understand that statement)
The main buffer is what gets displayed with a DispGraph.  If there's something else there, that will be drawn instead.
For instance, try this code and see if you can figure out what is happening:
Code: [Select]
:ClrDraw
:255->{L6}
:rand->{L6+766}r // This is the superscript r
:DispGraph
:Repeat getKey(15)
:End

So storing data there is just like doing a Pxl-On( to that buffer?
Kind of.  It's just another way of drawing stuff.
Remember that the data on the buffer is stored in binary, and because of this 255 = FFh = 11111111b makes 8 pixels in a row black.

Offline macweirdo

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-3
    • View Profile
Re: Free RAM and drawing stuff
« Reply #7 on: November 20, 2011, 07:48:36 pm »
use L6, which is the main buffer

You're serious? Waht? Doesn't that corrupt buffer drawing or something? (btw, I don't understand that statement)
The main buffer is what gets displayed with a DispGraph.  If there's something else there, that will be drawn instead.
For instance, try this code and see if you can figure out what is happening:
Code: [Select]
:ClrDraw
:255->{L6}
:rand->{L6+766}r // This is the superscript r
:DispGraph
:Repeat getKey(15)
:End

So storing data there is just like doing a Pxl-On( to that buffer?
Kind of.  It's just another way of drawing stuff.
Remember that the data on the buffer is stored in binary, and because of this 255 = FFh = 11111111b makes 8 pixels in a row black.
Yeah, don't worry, I have prior programming experience.

EDIT: why do I have -3 karma?
« Last Edit: November 20, 2011, 07:49:26 pm by macweirdo »

Offline Yeong

  • Not a bridge
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3739
  • Rating: +278/-12
  • Survivor of Apocalypse
    • View Profile
Re: Free RAM and drawing stuff
« Reply #8 on: November 20, 2011, 08:06:09 pm »
track your posts. You'll see which posts got derated.
Sig wipe!

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Free RAM and drawing stuff
« Reply #9 on: November 21, 2011, 12:11:30 am »
Just an FYI, if you absolutely needed more free ram and all the buffers are taken, you could create an appvar and use that:

Code: [Select]
getCalc("appvMYAPPV", 766)->A
3->{A+766}
DispGraph(L3,A)^^r

You could also do something like
Code: [Select]
Buff(766,0)->A
3->{A+766}
DispGraph(L3,A)^^r
...although you'd be adding the buffer directly to the program itself (inflating its size by 766 bytes) + I don't think you can modify buffers you have inside the program if you turn your program into an app.
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline calc84maniac

  • eZ80 Guru
  • Coder Of Tomorrow
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2912
  • Rating: +471/-17
    • View Profile
    • TI-Boy CE
Re: Free RAM and drawing stuff
« Reply #10 on: November 21, 2011, 09:25:34 am »
Two things I must mention. First, buffers are 768 bytes. Second, creating a variable of size 766 in A and storing a value to A+766 will corrupt whatever is next in memory. Why is 3 being stored there, anyway?
"Most people ask, 'What does a thing do?' Hackers ask, 'What can I make it do?'" - Pablos Holman

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Free RAM and drawing stuff
« Reply #11 on: November 21, 2011, 10:23:39 am »

EDIT: why do I have -3 karma?


Because three people disliked this post and downvoted it.
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline macweirdo

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 16
  • Rating: +0/-3
    • View Profile
Re: Free RAM and drawing stuff
« Reply #12 on: November 21, 2011, 07:56:29 pm »

EDIT: why do I have -3 karma?


Because three people disliked this post and downvoted it.

Deleted it because I recently lost respect even though that post is ancient. Thanks for taking the time to find that post :D

EDIT To prevent a double post:

Just an FYI, if you absolutely needed more free ram and all the buffers are taken, you could create an appvar and use that:

Code: [Select]
getCalc("appvMYAPPV", 766)->A
3->{A+766}
DispGraph(L3,A)^^r

You could also do something like
Code: [Select]
Buff(766,0)->A
3->{A+766}
DispGraph(L3,A)^^r
...although you'd be adding the buffer directly to the program itself (inflating its size by 766 bytes) + I don't think you can modify buffers you have inside the program if you turn your program into an app.

I'm trying to keep it as fast as I can, but I'm never making it an App, this program might be less than 1500 bytes.
Can't wait to release my first Axe game :D
« Last Edit: November 21, 2011, 08:00:44 pm by macweirdo »

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Free RAM and drawing stuff
« Reply #13 on: November 22, 2011, 01:44:11 am »
Two things I must mention. First, buffers are 768 bytes. Second, creating a variable of size 766 in A and storing a value to A+766 will corrupt whatever is next in memory.
Ah, you're right.  I was just copying down the numbers/examples that were used before.  Whoops.

Why is 3 being stored there, anyway?
No reason.  Prime numbers are cool, I guess.
« Last Edit: November 22, 2011, 01:44:18 am by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.