Author Topic: Map editor help: more appvar reading/creating issues  (Read 17585 times)

0 Members and 1 Guest are viewing this topic.

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Map editor help: more appvar reading/creating issues
« on: June 03, 2010, 03:21:14 am »
Ok, so definitively, I have absolutely no luck with Axe APPVARS. Always had trouble with them.

Basically I am trying to write a map editor that reads/write to a map stored into an APPVAR, but my problem seems similar to the one I got when trying to write a screen capture program for Kindermoumoute two weeks ago. In the current case, though, it's the bottom of the data that seems glitched up. Anyway, here is my code for the appvar creation (before I even started making the map at all), then the map editing tool (which lets you scrolll around the map and edit every two tile, the top-left-most one, so far):

Quote
:.APPVAR
:"vMAP"?GDB1
:GetCalc(GDB1,16800)

Quote
:.AMAP
:[FFFFFFFFFFFFFFFF00000000000000000123456789ABCDEFFEDCBA987654321002468ACEFDB97531369258147ADBECF0?Pic1
:"vMAP"?GDB0
:GetCalc(GDB0)?Q
:!If Q
:Return
:End
:0?L?S?X?Y
:Fix 5
:Fix 1
:Repeat getKey(15)
:ClrDraw
:For(A,0,5
:For(B,0,6
:{B*120+A+L+Q}?C            <-note, this is from our dear friend tutorial at http://ourl.ca/4550 (thanks btw)
:C^16?D
:C/16?C
:Pt-On(A*16,B*8,C*8+Pic1
:Pt-On(A*16+8,B*8,D*8+Pic1
:End
:End
:Pt-On(4,56,S*8+Pic1
:Text(16,56,L?Dec
:DispGraph
:getKey?Z
:L-(Z=2)+(Z=3)-(120*(Z=4))+(120*(Z=1))?L
:If L>60000
:0?L
:End
:If L>15961
:15961?L
:End
:If Z=54
:S?{Q+L}
:End
:If Z=55
:S+1?S
:If S=6
:0?S
:End
:End
:End
:ClrDraw
:DispGraph
:Fix 4
:Fix 0

Basically, this is for a 240x140 tile map. Since I use half-byte compression, each row of tiles are 120 bytes each.

Note sorry if the sprites looks horrible, this is just for testing. And yes it uses half-bytes. I'll try to figure out later how to store tiles to each half-byte. For now, I am more worried about what am I doing wrong?
« Last Edit: June 03, 2010, 03:25:08 am by DJ Omnimaga »

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: Map editor help: more appvar reading/creating issues
« Reply #1 on: June 03, 2010, 05:17:03 am »
First thing I noticed is that you're scrolling by 2 bytes at a time when moving left and right since these are half bytes.  What I would to do make this less of a nightmare is to write a subroutine that returns the sprite number times 8 (the sprite index) at a given a coordinate position on the map.

Code: [Select]
:.Input
:.D=x-position
:.Ans=y-position
:
:Lbl XY
:{*120+(D/2)+data}→C
:If D^2
:C^16*8
:Return
:End
:C/16*8
:Return

Use different temporary variables if C or D are locked up.

This makes it much easier to draw maps and read tiles:
Code: [Select]
:For(A,0,11
:For(B,0,6
:A+X→D
:Pt-On(A*8,B*8,B+Ysub(XY)+Pic1)
:End
:End

Here I'm not using L, I'm using an X and a Y coordinate since its much easier to program and there is less math to do.  Only downside is that now you need 2 variables to keep track of position instead of 1.

X must be in the range 0-227 and Y must be in the range 0-133 otherwise you're drawing random garbage outside the appvar.
« Last Edit: June 04, 2010, 03:20:54 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #2 on: June 03, 2010, 09:13:34 am »
Yeah thanks for this, but sadly it won't solve my glitch issue. The 2 tiles jumping issue you reported is something I'll worry about later. Now this is not the topic question. Thanks, though, but I would like to know how to fix my bug. If people dwell on the other issues (such as the 2 bytes scrolling, which I was very well aware of), I'll have to stop my project altogether, since I can't fix my bug in the first place by myself.

So I ask again, can anyone help me solve my issue with the tilemap glitching up at the bottom? It seems like when I check through it, I'm off by about 500 bytes or so, or garbage is added at the end when creating the app, but I checked the former and I am certain I made my prog read from the right memory locations.
« Last Edit: June 03, 2010, 09:15:37 am by DJ Omnimaga »

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: Map editor help: more appvar reading/creating issues
« Reply #3 on: June 03, 2010, 01:40:27 pm »
Did you zero the data in the appvar before looking at the map?

:"vMAP"→GDB1
:Return!If GetCalc(GDB1,16800)->A
:fill(0->{A},16799)

The reason I suggested the one byte at a time method was because I though this might be a boundary problem where you went past the end of the data at the bottom resulting in random tiles being shown.  I don't know how to restrict the movement with a single variable used for both coordinates which is why I split it up.
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #4 on: June 03, 2010, 03:55:04 pm »
Oh wait I forgot to do that. I'll give this a try.

However I think for now I'll resort to 1 byte tiles instead. It seems like half bytes + scrolling == major hassle. It will be even worse when I try adding smooth scrolling and while at work I thought about it, and I am fairly certain I'll hit the 8K code limit much faster with all the additional code resulting from half byte checks and stuff. Yes the data will be twice larger, but I think it might be better this way, especially that this is one of my first real venture into tilemapping.

I'll check all the code you posted and stuff, though, to see if what I could do. Thanks

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: Map editor help: more appvar reading/creating issues
« Reply #5 on: June 03, 2010, 10:10:07 pm »
This looks really cool!  Good luck DJ! ;D

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #6 on: June 03, 2010, 10:15:37 pm »
Btw, SirCmpwn had a half-byte-based scrolling tilemapper, as he told me a few hours ago somewhere, but he also had the speed issue, I think, because he told me it didn't feature smooth scrolling.

Player had issues with Rally-X. If you wondered why Rally-X isn't much faster, it's because of the amount of time it takes to handle everything from an half-byte tilemapper

Offline jsj795

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1105
  • Rating: +84/-3
    • View Profile
Re: Map editor help: more appvar reading/creating issues
« Reply #7 on: June 03, 2010, 11:24:56 pm »
aww that's sad. I was thinking of making a scrolling tilemapper for the Axe contest, but if it's hard to do, then I might just as well make it screen to screen map (like Illusiat 13, Elmgon, Serenity, etc.)


Spoiler For funny life mathematics:
1. ROMANCE MATHEMATICS
Smart man + smart woman = romance
Smart man + dumb woman = affair
Dumb man + smart woman = marriage
Dumb man + dumb woman = pregnancy
2. OFFICE ARITHMETIC
Smart boss + smart employee = profit
Smart boss + dumb employee = production
Dumb boss + smart employee = promotion
Dumb boss + dumb employee = overtime
3. SHOPPING MATH
A man will pay $2 for a $1 item he needs.
A woman will pay $1 for a $2 item that she doesn't need.
4. GENERAL EQUATIONS & STATISTICS
A woman worries about the future until she gets a husband.
A man never worries about the future until he gets a wife.
A successful man is one who makes more money than his wife can spend.
A successful woman is one who can find such a man.
5. HAPPINESS
To be happy with a man, you must understand him a lot and love him a little.
To be happy with a woman, you must love her a lot and not try to understand her at all.
6. LONGEVITY
Married men live longer than single men do, but married men are a lot more willing to die.
7. PROPENSITY TO CHANGE
A woman marries a man expecting he will change, but he doesn't.
A man marries a woman expecting that she won't change, and she does.
8. DISCUSSION TECHNIQUE
A woman has the last word in any argument.
Anything a man says after that is the beginning of a new argument.

Girls = Time * Money (Girls are a combination of time and money)
Time = Money (Time is money)
Girls = Money squared (So, girls are money squared)
Money = sqrt(Evil) (Money is also the root of all evil)
Girls = sqrt(Evil) squared (So, girls are the root of all evil squared)
Girls = Evil (Thus, girls are evil)
*Girls=Evil credit goes to Compynerd255*

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #8 on: June 03, 2010, 11:41:16 pm »
screen to screen would work pretty well with half bytes, because you just need to uncompress your map data into L1 then use that uncompressed data for collision detection/event triggering.

If you use bytes, though, then you should be able to have smooth scrolling fine, though. However, with how crappy the LCD is, I am unsure if smooth scrolling looks good on a real calc if it's too fast. My guess is that you might need to update the screen like 15-16 times a second max

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #9 on: June 04, 2010, 02:18:57 am »
In reference to your post at http://ourl.ca/5989/93100 , do I need to swap the ^ and / for the routine above?

I Integrated it in my code, but regardless of if I swap the ^ and / or not, I see garbage displayed in both cases.

EDIT: screenshot attached to post. Code coming soon.
« Last Edit: June 04, 2010, 03:08:43 am by DJ Omnimaga »

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: Map editor help: more appvar reading/creating issues
« Reply #10 on: June 04, 2010, 02:51:29 am »
At what values of X and Y do you see garbage?  Also, you mentioned before that you were going to fill the appvar with the 0 tile before looking at it, was that implemented in your test?
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #11 on: June 04, 2010, 03:01:59 am »
yep, the appvar is filled with zeros and the garbage happens at every single values of X from 0 to227 and Y from 0 to 133

I checked if I made a typo and couldn't find anything wrong :/

EDIT: screenshot attached, altough at wrong post x.x



EDIT 2: code below:

Code: [Select]
:.APPVAR
:"vMAP"→GDB1
:Return!If GetCalc(GDB1,16800)→A
:Fill 0→{A},16799)

Code: [Select]
:.AMAP
:[FFFFFFFFFFFFFFFF00000000000000000123456789ABCDEFFEDCBA987654321002468ACEFDB97531369258147ADBECF0FFFBDFFDEFFFBFFE80AAB4AAB4BE80FF→Pic1
:"vMAP"→GDB0
:GetCalc(GDB0)→Q
:!If Q
:Return
:End
:0→S→X→Y
:Fix 5
:Fix 1
:Repeat getKey(15)
:ClrDraw
:For(A,0,11
:For(B,0,6
:A+X→D
:Pt-On(A*8,B*8,B+Ysub(XY)+Pic1)
:End
:End
:Pt-On(0,56,S*8+Pic1
:Text(12,56,X►Dec
:Text(32,56,Y►Dec
:Text(52,56,120*Y+X►Dec
:DispGraph
:X-getKey(2)+getKey(3)→X
:Y-getKey(4)+getKey(1)→Y
:If X=65535
:0→X
:End
:If X>227
:227→X
:End
:If Y=65535
:0→Y
:End
:If Y>133
:133→Y
:End
:If getKey(55)
:S+1→S
:If S=8
:0→S
:End
:End
:End
:ClrDraw
:DispGraph
:Fix 4
:Fix 0
:Return
:Lbl XY
:{*120+(D/2)}→C
:If D^2
:C^16*8
:Return
:End
:C/2/2/2/2*8
:Return

I must have integrated your routine the wrong way :/
« Last Edit: June 04, 2010, 03:13:37 am by DJ Omnimaga »

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: Map editor help: more appvar reading/creating issues
« Reply #12 on: June 04, 2010, 03:15:24 am »
What is that last number?  You shouldn't have "L" in your code anymore since you're using X and Y instead.  Also, I can't really help without seeing the code you're using.

EDIT: nevermind, saw your edit, will look at code.

EDIT2:

:{*120+(D/2)}→C

should be

:{*120+(D/2)+Q}→C
« Last Edit: June 04, 2010, 03:19:35 am by Quigibo »
___Axe_Parser___
Today the calculator, tomorrow the world!

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55941
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Map editor help: more appvar reading/creating issues
« Reply #13 on: June 04, 2010, 03:33:03 am »
oh ok I forgot the "data" part. Thanks!

Now how would I change a tile in the tilemap?

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: Map editor help: more appvar reading/creating issues
« Reply #14 on: June 04, 2010, 03:53:34 am »
Code: [Select]
:.Input:
:.D = x-position
:.C = y-position
:.Ans = tile to store there
:
:Lbl ST
:→E
:C*120+(D/2)+data→C
:If D^2
:{C} and 240+E→{C}
:Return
:End
:{C}^16+(E*16)→{C}
:Return

Note that that 240 is actually the decimal for b11110000 (a high nibble mask) and has nothing to do with the the map size.
___Axe_Parser___
Today the calculator, tomorrow the world!