Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Caustic

Pages: [1]
1
Axe / Re: Axe 2048 help?
« on: April 04, 2014, 03:10:09 am »
Alright, I'll try. I'm not too good myself, but I can offer a quick take on 2048
Then you can try merging in parts you like.
2048 is relatively simple, so I favour readability over optimization.
Please pardon me if my schematics or writing conventions are off, I don't know how to write tokens properly on this forum. And maybe it isn't allowed to use quote tags instead of code tags for code? (These code tags don't allow for any syntax highlighting rules :( )

Spoiler For Spoiler:
Quote
.Z2048B
........................
..Init
........................
Fix 5
DiagnosticOff
ClrHome:ClrDraw
1 -> Z
.This 'resets' L1
.(32 bytes because each element is 2 bytes,
.and we have 16 elements
.on a 4 by 4 array!)
Fill(L1,32)
........................
..Main loop
........................
Repeat getKey(14)
.Input
If getKey<5
    1 -> Z
    If getKey(1)
        UP()
   ElseIf getKey(2)
        LEFT()
   ElseIf getKey(3)
        RIGHT()
   ElseIf getKey(4)
        DOWN()
   End
End

If Z
   0 -> Z
   UPDATE()
End

RENDER()
End
Return
........................
..Functions!
........................
..
Lbl UP
Return
Lbl CUP
Return

Lbl LEFT
Return
Lbl CLEFT
Return


Lbl RIGHT
Return
Lbl CRIGHT
Return
..
. !!! Just look at DOWN/CDOWN; Same concept. But you'll have to deal with rows/columns being transposed.
. *Omited for brevity


Lbl DOWN
    For(I, 0, 11)
       If {I * 2 + L1)r -> A
            CDOWN()
        End
    End
Return

Lbl CDOWN
    .For from one row past evaluated element until last row
    For(J, I / 4 + 1, 3)
        .Column
        I ^ 4 -> C
        .If value of next row element == value of evaluated cell
        If {J * 4 + C * 2 + L1}r -> V = A
            .Double of value is stored and evaluated cell is zero'd
            A * 2 -> {J * 4 + C * 2 + L1}r
            0 -> {I * 2 + L1)r
        Return
        ElseIf V = 0
        .If value of next row element != value of evaluated cell, but not equal to 0
        ElseIf
            .Cell is zero'd, and its value, still in A, is moved to one row before the evaluated cell
            0 -> {I * 2 + L1}r
            A -> {J * 4 + C * 2 - 8 + L1}r
            Return
        End
    End
    .If we're already here, that means none of the evaluated rows met our conditions.
    0 -> {I * 2 + L1)r
    A -> {12 + C * 2 + L1}r
Return

.Creates an array of every
.free address with a sum
.Writes '2' to a random free address
Lbl UPDATE
For(I, 0, 15)
    -1 -> A
    !If{I * 2 + L1}r
         I * 2 + L1 -> {A * 2 + L2}r
         A++
    End
End
If A = -1
    Return
End
2 -> {{rand^A * 2 + L2}r}r
Return

Lbl RENDER
ClrDraw
For(I, 0, 15)
    Text(I / 4 * 32, I ^ 4 * 8, {I * 2 + L1}r
End
DispGraph

Edit: I can see why I shouldn't have used quotes now :P (It's huge!). I hope the moderators are fine with this once in a while.
Edi2: Spoiler tags save the screen!

2
Axe / Re: Axe Q&A
« on: April 11, 2013, 02:40:49 pm »
There's a pretty ingenious (at least I thought so when I learned it years ago) way to handle this. Keep track of the total number of bullets with some variable. When you add a bullet, increase the bullet total and put the new bullet at the end of the list of bullets, which should be at the memory location old_total*6+list_start. This all probably seems pretty standard. But the trick is in bullet removal: decrease the bullet total and move the data for the last bullet in the list into the position of the bullet that was just removed. In Axe, the code for that might look something like this:

Code: [Select]
.Deletes the bullet at index r₁ (0-indexed)
.Updates bullet total N
Lbl Del
Copy(N--*6+<list_start>,r₁*6+<list_start>,6)
Return

Thank you so so much for your quick reply, as always. But I feel so cheap having such an obvious (albeit impressive and practical) solution spoonfed to me... ;_; it's figuring out these solutions that make programming such a wonderful experience.

Thanks again, anyhow. O(^^O)

Edit: Modern Smartphones are so good at the one or two things they should do, like typing a forum post without subtly sneaking a typo or two in.

3
Axe / Re: Axe Q&A
« on: April 11, 2013, 02:17:12 pm »
Right now I'm making (yet another, but even "yet another" is taken) shmup bullet hell game. I'm quite impressed with the amount of data Axe can handle at once, but I've hit a dead end. I think I tackled the initial problem of storing bullet data like how anyone would, in the safe RAM areas, every 6 bytes account for one bullet, as x, y, dx and dy. Enough of boring you with things you are well familiar with, how do I search for empty 2-byte elements in a buffer? Or to solve (and ruin) my solution, what is the most effective way of replacing bullets that have gone offscreen with newer bullets?

Right now, my main loop involves going through every six bytes in the designated buffers, adding dy dx to x and y, and finally check if it's out of screen, and making it zero. The loop ignores data when x + y = 0.

If I need to elaborate further for your benefit, do ask.

4
Axe / Re: Axe Q&A
« on: April 07, 2013, 02:03:41 pm »
Also to search : http://megapowers.net/v/search.htm
Forum search is completely disabled because of lag. It was really slow anyway. ;)

Love at first sight, thanks for the link, runner, though you got ninja'd by a certain search engine. Dp forgove the strange order of the paragraph. You may blame the creators of the search egine for amking a terrible operating system. I cant even read what Imm writimg stm. Thanks for the suggestion by I just used some Google syntax to do it. It wasn't that I couldn't search the forums, it was just a hassle to switch tabs on a plastic brick that makes my calculator feel like one of IBM'S supercalcs... er comps, whatever the difference is.
If you're interested in on-calc assembly coding, probably the best tool for that is Mimas.

5
Axe / Re: Axe Q&A
« on: April 07, 2013, 01:14:42 pm »
Incredible, thank you for addressing all my questions. I really spent the whole day scratching my head over grayscale.
*Tosses over ambitious 4 level grayscale RPG-adventure-harvestmoon-simcity-eveonline game into bin.

I wonder if programming asm on calc is practical enough, I don't really feel like using a modern computer to assist me...
I'm sure I can find it if I could actually search the forums, because the native search bar here is disabled for me. :(

6
Axe / Re: Axe Q&A
« on: April 07, 2013, 05:08:04 am »
How long does Pause 1 actually last?

7
Axe / Re: Axe Q&A
« on: April 07, 2013, 03:45:22 am »
Alright. Just to clarify, if the interrupting routine lasts longer than the timer (I.e Pause 3000) will there be some sort of queue of interrupt calls? Trying to execute dispGraph at 60Hz sharp is quite a pain in Axe...

8
Axe / Re: Axe Q&A
« on: April 07, 2013, 03:19:08 am »
I doubt it, because I have to remove the batteries every time I execute this. Thanks for the tip on LnRegr

Edit:It's probably an Axe bug because I tried a few code samples for "perfect" grayscale that all seem to work fine. But I want to understand why my own test didn't work in the interest of preventing this problem on a larger scale.

9
Axe / Re: Axe Q&A
« on: April 07, 2013, 03:07:20 am »
Do forgive me if this has already been asked... couldn't search and it's becoming increasinfrrrftgly urgent. posting on a phone is hard enough.

What follows is a simple code sample that I don't understand why it refuses to run:

Nothing after setting up the interrupt is ran. The comments are results of some troubleshooting. Anything I change after ".Main" and the following "Return" is completely ignored during runtime. I commented out the pause in the Interrupt subroutine to see if it made any difference...
Code: [Select]
.AA
ClrDrawrr
Rect(0,0,32,32)r
fnInt(A,6)

.Main
Repeat getKey(0)
End
LnReg
Return

Lbl A
.Pause 75
DispGraphr

Pages: [1]