Author Topic: Program-making programs  (Read 5478 times)

0 Members and 1 Guest are viewing this topic.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Program-making programs
« on: March 03, 2011, 12:59:15 am »
I have had many struggles with my drawing program, Maros. Now that it's functional, I want to make a program that reads the AppVar created by Maros and writes an Axe program that consists of the commands encoded in the AppVar alongside their properly formatted coordinates. Does anyone have any ideas on how to do that?
« Last Edit: March 03, 2011, 01:00:55 am by Freyaday »
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Program-making programs
« Reply #1 on: March 03, 2011, 07:06:41 am »
As in, Axe Source?

You could, it would be reasonably difficult, but not impossible.

What format is the data in?

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Program-making programs
« Reply #2 on: March 03, 2011, 08:18:42 am »
Yes, the program would make an Axe source. The data are formatted thusly:  The word width is 3 bytes. The command number is in the first byte, the X coordinate in the second byte, and the Y coordinate in the third byte. All commands save number three, Pxl-Change, are two words wide, and the command number doesn't really matter on the first command, so long as it's a two word command. In other words, for the double-width commands, the command type can change from the first word to the second one, and it's only the second one that counts.
Here's what I have so far:
Code: [Select]

.Write
GetCalc("appvMAROS",Y1)->P
If P
{Y1-2}[sup]r[/sup]->S
GetCalc("appvMTEMP",S)->J
GetCalc("appvNTEMP",S/2*58)->M
.^Where the program bytes are going to be stored while it's still being created. I've determined S/2*58 to be the maximum possible size of the resulting program.
Copy(Y1,J,S)
0->L
0->D
.D is length of code in NTEMP
[3AA8]->Str1
.^:DrawInv HEX
If 0
.Writing to NTEMP is here for the time being until I get the rest of the program written
[3A]->{M+D}
D+1->D
If V=2 or (V=5 or (V=7
.^These are the commands that turn pixels off. They're just the corresponding On command with a DrawInv each on the line before and the line after.
Copy(Str1,M+D,2)
D+2->D
End
Copy(Str0,M+D,length(Str0))
D+length(Str0)->D
If V=2 or (V=5 or (V=7
Copy(Str1,M+D,2)
D+2->D
End
Lbl L
X->T
Y->U
1->L
Return
End
For(Z,0,S/3-1)
{3*Z+J}->V
3*Z+J+1->x
3*Z+J+2->Y
If V=1 or (V=2
If L
[A5]{T}[2C]{U}[2C302DBC28]{T}[2D]{X}[29122B2828]{U}[2D]{Y}[291229292900]->Str0
.^As far as I know, this should be the bytes that Circle(T,U,0-sqrt((T-X)[sup]2[/sup]+((U-Y)[sup]2[/sup]))) gets stored as.
0->L
Else
sub(L
End
ElseIf V=3
Does anyone know whether or not I'm on the right track?






« Last Edit: March 05, 2011, 12:36:11 pm by squidgetx »
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline Munchor

  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 6199
  • Rating: +295/-121
  • Code Recycler
    • View Profile
Re: Program-making programs
« Reply #3 on: March 04, 2011, 11:01:14 am »
The first thing I have to say is to use code tags:

Code: [Select]
[code]
This is code
[/code]

Offline aeTIos

  • Nonbinary computing specialist
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3915
  • Rating: +184/-32
    • View Profile
    • wank.party
Re: Program-making programs
« Reply #4 on: March 04, 2011, 12:56:44 pm »
sometimes that is not useful, Scout. For example when you want to explain something with the exponential E, or with the radians r.
And, Freyaday, I think you can better use this for storing your pictures:
Code: [Select]
////TO STORE////
... drawing things here...
GetCalc("appvNAMEOFYOURAPPVAR",768)->P
Copy(L6,P,768
////TO READ////
GetCalc("appvNAMEOFYOURAPPVAR")->P
Copy(P,L6,768
DispGraph
////TO STORE TO A PIC VAR////
Repeat the STORE part, but instead of
GetCalc("appvNAMEOFYOURAPPVAR",768
use
GetCalc("PicNUMBERFROM0-9",768
/////////////////////////////////
Maybe this is more convenient to use...
But it's all up to you!
« Last Edit: March 04, 2011, 01:05:20 pm by aeTIos »
I'm not a nerd but I pretend:

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Program-making programs
« Reply #5 on: March 04, 2011, 03:06:41 pm »
The idea here is to take the appvar MAROS, which is a recording of things done to the graph screen in my Axe Program MAROS, and turn it into an Axe source so that all the commands can be edited and then incorporated into a program. This is intended to be used by BASIC coders instead of using Pic variables. Also, the drawing process kinda looks cool....
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Program-making programs
« Reply #6 on: March 04, 2011, 03:26:17 pm »
Ok. What you should do is make a table of the commands and their tokens...In this table you should have as the first byte, how many tokens the command is, then the token itself, then how many arguments. This will make for a table entry width of 1+1+2=4

So for example, let's say the line drawing command is command number 1. And the rectangle command is number 2.
These (I think) are one byte commands, so our table will start like this;
([t] means the superscript t found in the matrix menu)
Code: [Select]
[01][t]Line([0004]
[01][t]Rect([0002]
We use the null 00 as a filler since the tokens are one byte. If they are two bytes then we won't use them

So for an appvar that uses your method, the data to draw a line from one corner to the screen and then a rectangle at the top...(width 96 height 2)
1 0 0 | 1 96 64
2 0 0 | 2 96 2

What we want to do now with this is to create a program that can do the following, keeping track of the current "location" in the output file and a "location" in the appvar:
Code: [Select]
1) Run through the appvar data with a for() loop
2) Use the current byte of the appvar to determine the table entry of the command we want
3) Use the table entry to paste in the appropriate token into the output file
4) Use the table entry to advance our location in the program appropriately.
5) Run a loop for the amount of arguments for a particular command
6) Paste in the hex from the appvar and add commas as necessary
7) Add a newline
9) Repeat


Now let's assume that the table is at pointer GDB1....

Code: [Select]
"01234567890ABCDEF"->Str0  //Hex digit list
GetCalc("appvNAME",Y1)
GetCalc("appvOUTPUT",size)->P
0->L //L will be the current position in the program

For(E,0,{Y1-2}^^r)  //for the length of the appvar
 {Y1+E}*4+GDB1->T //Now T holds the pointer to the start of table entry...
 Copy(T+1,P+L,{T}) //Copy the token (at offest 1) to the current place in the program, and remember {T} holds how big the token is
 L+{T}->L //Increment L appropriately
 For(A,0,{T+3})  //For the amount of arguments...
  [t]E->{P+L}   //scientific notation E since we will be using hex input...
  {{Y1+E+A}/16+Str0}->{P+L+1}  //The left nibble first
  {{Y1+E+A}^16+Str0}->{P+L+2}  //And the right nibble
  [t],->{P+L+3}   //A comma...
  L+4->L  //Increment L appropriately
  !If A-2 //If A=2, it is time to move on to the next 3 byte set so we need to
   A+1->A  //Skip over a byte
  End
 End

 E 3F->{P+L}  // The scientific notation E again...3F is a newline.
 E+{T+3}->E //Move forward appropriately in the offset code
 L+1->L  //Increment L again since we added the newline, which counts as a byte

End
Hopefully this will work to some extent, I did not test any of it so there could be some wrong parts. Hopefully it conveys the general method of how to do it though.
End
« Last Edit: March 06, 2011, 11:25:52 am by squidgetx »

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Program-making programs
« Reply #7 on: March 04, 2011, 11:07:39 pm »
Given that you would have to translate the the command number back into normal tokens when you finally create the source file, wouldn't it be simpler to just write the actual, literal token values to the appvar then just simply copy the appvar to the program?
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 Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Program-making programs
« Reply #8 on: March 05, 2011, 02:20:59 am »
It wouldn't be easier to just store the program to the appvar in the first place, because that's non-human editable, and it makes it impossible to load with Maros later and add on to. That, and because there's no undo feature, these things tend towards commands in the thousands, and having that huge of an appvar just sitting there in memory doesn't look too good.
@Squidgetx: your solution seems like mad genius (in a good way) but I'm really and truely stumbling in the dark with Axe here & I'm much confused
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Program-making programs
« Reply #9 on: March 06, 2011, 11:27:02 am »
Edited with a pseudo-code explanation. Let me know if there are any particular parts of the code you don't understand.

Offline Freyaday

  • The One And Only Serial Time Killing Catboy-Capoeirista-Ballerino
  • LV10 31337 u53r (Next: 2000)
  • **********
  • Posts: 1970
  • Rating: +128/-15
  • I put on my robe and pixel hat...
    • View Profile
Re: Program-making programs
« Reply #10 on: March 06, 2011, 05:35:08 pm »
I'm still slightly confused here, but from what I understand, you're doing the same thing I am, but with loops and stored data instead of hard coding and ElseIfs.
In other news, Frey continues kicking unprecedented levels of ass.
Proud member of LF#N--Lolis For #9678B6 Names


I'm a performer at heart; I stole it last week.
My Artwork!

Offline willrandship

  • Omnimagus of the Multi-Base.
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2953
  • Rating: +98/-13
  • Insert sugar to begin programming subroutine.
    • View Profile
Re: Program-making programs
« Reply #11 on: March 06, 2011, 06:09:43 pm »
This is the beginning of AI :P