Author Topic: drawing from oversized buffers  (Read 3136 times)

0 Members and 1 Guest are viewing this topic.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
drawing from oversized buffers
« on: October 12, 2011, 08:27:20 pm »
is there any fast way to draw a specified 96*64 window directly from a larger buffer (say 104*72)?

what i mean is just using an x and y offset to determine which position to start and drawing from

Offline ralphdspam

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 841
  • Rating: +38/-1
  • My name is actually Matt.
    • View Profile
Re: drawing from oversized buffers
« Reply #1 on: October 12, 2011, 08:54:37 pm »
Changing the Y offset should be easy, but Changing the X offset is more difficult.  The calculator stores pixels in Byte-Sized pieces (no pun intended), so you can only have an X offset as a multiple of 8 without having to do nasty rotation and shifting. 
Code: (PseudoCode) [Select]
\\For this example, let's say that X is the X offset, Y is the Y offset, and B is the buffer.
B+(Y*13)+(X/8)->C \\104/8=13 There are 13 bytes in a buffer of 104
L6->D
For(A,1,64)
Copy(C,D,12)
C+13->C \\Again, the X length of the buffer is 13 bytes.
D+12->D \\PlotSScreen is 12 bytes wide.
End
This code is probably very buggy.  This is just for the general idea.  You want to copy 12 bytes from the buffer, loop to the next line, and repeat for 64 lines.
Unfortunately, this method limits itself to 8 pixel increments.  Similarly, the buffer X width can only be divisible by 8.  These problems can be overcome by doing bit rotation and shifting, but that would be more time consuming and probably require inline ASM.
« Last Edit: October 12, 2011, 08:57:54 pm by ralphdspam »
ld a, 0
ld a, a

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: drawing from oversized buffers
« Reply #2 on: October 12, 2011, 09:09:23 pm »
I assume this is for line clipping?  I have to think there must be a better way to do this x.x Not to mention Axe's default line drawing routine won't work on a buffer that is wider than 12 bytes.

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: drawing from oversized buffers
« Reply #3 on: October 12, 2011, 09:35:09 pm »
ok, i can cross of that option then, i guess. i was just trying to think of any possible alternative solutions to a problem i've been running into, and i figured i'd ask if anything had changed, since i'm a little behind on the new axe syntax.
thanks =)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: drawing from oversized buffers
« Reply #4 on: October 12, 2011, 10:54:29 pm »
I think the best bet to create an Axe clipped line would be to manually cull the points to the domain of the screen, although that can be a little math heavy D:

Offline Quigibo

  • The Executioner
  • CoT Emeritus
  • LV11 Super Veteran (Next: 3000)
  • *
  • Posts: 2031
  • Rating: +1075/-24
  • I wish real life had a "Save" and "Load" button...
    • View Profile
Re: drawing from oversized buffers
« Reply #5 on: October 13, 2011, 10:42:40 pm »
If you think that math is hard, try writing it in pure assembly O_O.  Hopefully I will eventually finish that clipped line routine...
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: drawing from oversized buffers
« Reply #6 on: October 14, 2011, 09:09:15 am »
ouch. asm == hard
I'm not a nerd but I pretend: