• Hey Guest. Check out your NeoGAF Wrapped 2025 results here!

Petit Computer (BASIC Programming Software) Coming to the DSi/3DS eShop in NA

Well, here's my first experiment and warm up if anyone is curious.

Just a little bouncing box demo. 29 boxes bouncing around the screen. Press A to Beep. LOL.

CLS
CLEAR
SW=256
SH=191
XDIR=RND(1-9)
YDIR=RND(1-9)
XPOS=1
YPOS=1
DIM XP(49)
DIM YP(49)
DIM XD(49)
DIM YD(49)

FOR I=0 TO 28
XP(I)=RND(255)
YP(I)=RND(191)
XD(I)=RND(1-9)
YD(I)=RND(1-9)
NEXT

GCLS

COLOR 0
CLS
'CLEAR

@MAIN
VSYNC 1
GPAGE 0,2,0

GCLS 0

GBOX XPOS,YPOS,XPOS+10,YPOS+10,78
GOSUB @DRAWP

LOCATE 3,3:PRINT "PARTICLE DEMO V.001";

GOSUB @CHANGE
GOSUB @CHANGE2
GOSUB @PRESS
GPAGE 0,0,2
GOTO @MAIN

@REST
GLINE RND(200),RND(100),RND(200),RND(100),RND(150)
RETURN

@DOT
GCIRCLE RND(100),RND(100),RND(100),RND(100)
RETURN


@BOX
GBOX 1,1,5,5,RND(255)
RETURN

@CHANGE
XPOS=XPOS+XDIR
YPOS=YPOS+YDIR
IF XPOS>SW THEN XDIR=XDIR*-1
IF YPOS>SH THEN YDIR=YDIR*-1
IF XPOS<0 THEN XDIR=XDIR*-1
IF YPOS<0 THEN YDIR=YDIR*-1
RETURN

@DRAWP
FOR I=0 TO 28

GBOX XP(I),YP(I),XP(I)+10,YP(I)+10,RND(255)
NEXT
RETURN


@CHANGE2
FOR I=0 TO 28
XP(I)=XP(I)+XD(I)
YP(I)=YP(I)+YD(I)
IF XP(I)>SW THEN XD(I)=XD(I)*-1
IF YP(I)>SH THEN YD(I)=YD(I)*-1
IF XP(I)<0 THEN XD(I)=XD(I)*-1
IF YP(I)<0 THEN YD(I)=YD(I)*-1
NEXT
RETURN

@PRESS
BT=BUTTON()
IF BT==16 THEN BEEP
RETURN
 
Well, here's my first experiment and warm up if anyone is curious.

Just a little bouncing box demo. 29 boxes bouncing around the screen. Press A to Beep. LOL.
nice demo

QR for your code...
qr000.png
 
I was wondering if a beginner could get some tips:

pitchck2v10.png


Just a dumb little program that lets the user pick a BEEP noise, and listen to the pitch increase constantly by the amount of their choosing. Just something I'm toying with, and expanding on to get a feel for the options available. I plan to let the user interact further, with the up or down on the d-pad, to affect the pitch in real-time. But that's for later.

Below is a minimalistic version of the code, so that I need to type less:

-----------------
@LOOP1
Y=-8192 'lowest pitch possible
Z=0 'preventative measure against "out of memory" error

INPUT "pick a sound"; S
INPUT "enter a value"; P

@LOOP2
CLS
BEEP S,Y 'first parameter (S) picks a sound, second parameter (Y) controls the pitch
Y=Y+P 'to increase the pitch
Z=Z+1
IF Y>8192 THEN @LOOP1
IF Z>254 THEN @LOOP1 'if the pitch is changed 256 times, I get an "out of memory" error
WAIT 4
GOSUB @LOOP2
------------------

And if someone wants to tell me an easier way to bring the code over to a computer for display (such as on a forum), if there is a way, that'd be appreciated.

My problems:

1. The "out of memory" error. It happens after 256 cycles through the @LOOP2. I tried using the CLEAR function, but no change. I figure this is a problem worth solving or if not solvable, worth considering for future program making. I guess I could just tell it to EXEC this program before it runs out of memory, huh?

2. If the user enters a string (letters) instead of numbers. The program will automatically work through this, with a "?Redo from start" prompt, but I'd just like to make it look nicer.

3. The INPUT function always adds a question mark. I tried using the LOCATE function to just replace it with a space or nothing, but no change. Again, just something to make the finished product look nicer.

4. Is there a way to view the remaining memory? The FREEMEM function only seems to return one value in this program (in this case, 1023). I set it up to display and refresh the FREEMEM display every time it goes through @LOOP2, thinking it would return a diminishing number as the memory is used up, but not so.

Any help is appreciated.
 
The memory error is because you're using GOSUB instead of GOTO for your loop. You're overflowing the stack. FREEMEM is supposed to represent how much more code you can put in your program, I believe.
 
2. If the user enters a string (letters) instead of numbers. The program will automatically work through this, with a "?Redo from start" prompt, but I'd just like to make it look nicer.

3. The INPUT function always adds a question mark. I tried using the LOCATE function to just replace it with a space or nothing, but no change. Again, just something to make the finished product look nicer.

If you use LINPUT, no question mark is generated. That doesn't solve the first problem (although LINPUT -will- accept blank lines for entry), but you might find it handy.

Technically, LINPUT is supposed to be for entering responses a line at a time, including special characters, but...
 
If you use LINPUT, no question mark is generated. That doesn't solve the first problem (although LINPUT -will- accept blank lines for entry), but you might find it handy.

Technically, LINPUT is supposed to be for entering responses a line at a time, including special characters, but...
If there's an input command such as LINPUT that accepts blank lines, is a reasonable compromise printing a ? character manually, then calling the input command?
 
The memory error is because you're using GOSUB instead of GOTO for your loop. You're overflowing the stack.

Brilliant (in the North American sense, not the British one). Glad to hear I'm making a mistake rather than this being a limitation of Petit Computer.

If you use LINPUT, no question mark is generated.

Thanks for that. I picked up the use of INPUT from the included example programs.
 
Is there a way to go from a QR code to basic for translating purposes and such?
You should be able to load the QR code(s), look what program(s) were loaded, go to write program, and type LOAD"ULTRATETRIS or something like that. That should load the program, and then you can just click the edit button to look at, modify, save-as, etc. the code.

If memory serves me correctly at least.
 
For a moment I got excited that ULTRATETRIS existed, but that would be too many characters, sigh.
Well now you've got something to write! And you can call it UTETRIS, for uTetris, as in microTetris, since it'll be a very simple and small version of tetris! So clever, huh.
 
Except Tetris is trademarked, so you can't use the name. I'm really surprised there aren't a bunch of Tetris clones out for this thing though. I wish that one TGM clone had a QR code for it. I don't want to make a tetromino game myself unless it's significantly different from any other game that already exists.
 
But new devices/development systems are all about remaking existing things, not creating new stuff, thus the breakout clone from earlier in the thread, etc. =P
 
I'm trying to delve into the package save system. It's intended for making custom graphics, music, etc. and packing that in along with your program so you can share a more complex game with others.

Without packaging, if I had a game with custom graphics, I would have to share my program file with you and also share the graphics separately and say "hey make sure you name the BG file COOLPIX, I've got a LOAD statement in there that depends on it." But with packaging, I can load all the necessary files myself and save the program with them already loaded. Every time someone runs the program, those files are automatically loaded when it is run, with no extra naming or file dependance on their part.

The way you do it is something like this:

LOAD "COOLGAME"
LOAD "BG0:COOLPIX"
SAVE "COOLPACK","0100"

Where 0100 is the hex string representing which parts to include. In this case it means save exactly one thing along with the program, the graphics currently loaded into BG0. This results in a larger file with more QR codes to share, but presumably no messing around for the person on the receiving end.

You can find out more about how this works and which bits signify what in the manual. When doing it yourself, be sure to remove any LOAD statements within it to give yourself a true impression of whether the process worked, as if you had no extra files on your system.

Package saving is potentially dangerous. If you type something crazy like "FFFFFF" you will end up with a huge package. Your little 1.4 kB program will suddenly be ~400k. If you have nothing custom loaded, Petit Computer will still be happy to package all those defaults along with your program, so be careful how you use this command.

I also do not see a way to undo this process. I've tried saving "TESTPRG","000000" but the file remains large. There may be a way to signify saving the program by itself again such as SAVE "PRG:X" or "PRG0:X" but I recommend saving the package under a different name and double checking your file size to make sure you didn't mess something up.

Finally, I have a problem with it that I can probably only solve through lots of experimentation or simply circumventing it. I can't save COL files, the palettes. My first few tests with package saving have resulted in the custom graphics surviving the process fine, but with entirely wrong colors. I have no idea why and the only thing I can think of to fix it is to set up the palette manually within the program through RGB values. If anyone else can figure this out, please let me know.
 
Updates and such for everyone...

1) Hunt the Wumpus appears to work fine. I'll polish up a few bits and put a QR code up soon. It's not optimized for the DS, though -- pure text game.

2) Someone on the SomethingAwful forums noticed http://petitcomputer.wikia.com and even made a contribution to it. Outside editors approach!

3) I made a simple vertical shooter-type game. I'm polishing it up and I'll offer a QR code.

4) DAMAXIAN DEEP LABEL (http://togetter.com/li/323144, http://www.youtube.com/watch?v=6lNUbZ8k-ns) looks neat, but I can't get the QR codes for it. The first link has a copy of them, but it's too poor quality to scan. I tried following the Twitter link, but it appears you need to be a Twitter user AND approved to see his post. If anyone does that, let me know, as I'd like to try the game out.

5) I haven't started on the Oregon Trail port yet. That should come soon.
 
Updates and such for everyone...

1) Hunt the Wumpus appears to work fine. I'll polish up a few bits and put a QR code up soon. It's not optimized for the DS, though -- pure text game.

2) Someone on the SomethingAwful forums noticed http://petitcomputer.wikia.com and even made a contribution to it. Outside editors approach!

3) I made a simple vertical shooter-type game. I'm polishing it up and I'll offer a QR code.

4) DAMAXIAN DEEP LABEL (http://togetter.com/li/323144, http://www.youtube.com/watch?v=6lNUbZ8k-ns) looks neat, but I can't get the QR codes for it. The first link has a copy of them, but it's too poor quality to scan. I tried following the Twitter link, but it appears you need to be a Twitter user AND approved to see his post. If anyone does that, let me know, as I'd like to try the game out.

5) I haven't started on the Oregon Trail port yet. That should come soon.
I'm a twitter user but I didn't see anything linking to a qr code.

Edit: I found this. http://blog.livedoor.jp/cobinee/lite/archives/1717511.html
 
Turns out I was being really stupid about the packaging problem I was having. I used ACLS at the beginning of my program, which resets all the nice custom colors that were loaded at launch. >_<

So now I can package graphics and palettes together to share with peeps. I'll see if I can get one of my demos set up after I get home.
 
So, I drew a box with GBOX, but now how I delete it? Is stuck on the console now even after I stopped the execution of the program. >_<
 
So, I drew a box with GBOX, but now how I delete it? Is stuck on the console now even after I stopped the execution of the program. >_<

When you are outside of the program sitting at the console screen, you can use just about any regular programming statements as well and it will execute them immediately. ACLS will clear everything visually. There might be a graphic layer specific clear command, I forget.

You will have this same problem if you play some music and then break out of the program with the stop button or Select. The music will keep playing and you have to type BGMSTOP unless you want a soundtrack as you program.
 
Thanks for the answers. Can someone give me a quick rundown on how the DATA constructs works? Thanks in Advance.
 
You should be able to load the QR code(s), look what program(s) were loaded, go to write program, and type LOAD"ULTRATETRIS or something like that. That should load the program, and then you can just click the edit button to look at, modify, save-as, etc. the code.

If memory serves me correctly at least.

I'd really prefer editing it from my PC. That way its easier to translate.
 
Thanks for the answers. Can someone give me a quick rundown on how the DATA constructs works? Thanks in Advance.

You can store anything you want in data (variables and strings). Basically, this is how you do it:

@COOLDATA 'Label to signify the start of data

DATA 1
DATA 2
DATA 3
DATA 4,5,6 'You can list data individually or broken up with commas

RESTORE @COOLDATA 'Tell the program where to start reading data from

READ A,B,C 'Read data into variables
READ X,Y,Z

PRINT A 'Print those variables
PRINT B
PRINT C

And the program would output:

1
2
3

Hmm.....I remember the manual claiming that programs would end after 145 minutes....

Or, maybe not, I dunno.
Section 16. System Variables --> Numeric System Variables

Next to MAINCNTL: "Frames elapsed since start of program (max. 145 minutes)"

I bet that's just because it's the maximum a variable can hold. Presumably the program would keep going, but you wouldn't get any useful data from the frame counter. The time variable should keep updating though.
 
Useful tidbits:

* Having a blank space at the end of a line/label name seems to make PTCutilities crash.

* LET seems to generate errors if used. I thought it was optional, but now it looks like you can't use it at all...

I need to finish these things up. I keep converting new programs and finding myself having to endlessly tweak them...
 
Alright, here's my first major test program.

I wanted to start with a nice big map to scroll around, but who wants to bother making their own? I looked up DQ1's map data (which is simple RLE compressed), wrote a program to convert the raw binary to a series of DATA statements, wrote a decompression routine, discovered some really weird quirks, modified the data a bit, and finally ended up with this.


As the pic says, it displays part of the DQ1 map that you can scroll around while listening to the town theme. It's awkward right now since I'm just drawing a chunk to the 512x512 background and not touching it again, so it cuts off abruptly and repeats in every direction.

The next step is modifying it so that it scrolls properly, which is more complicated. Every tick of the CPU, you check what direction you're moving in and draw the next row or column of tiles if necessary. Not sure if Petit Computer is fast enough to do this well, but we'll see.

Some points of interest:

30,30 - the start of the game, Tantagel Castle, etc.
0,0 - Garinham
91,60 - Rimuldar
60,85 - Cantlin

Let me know what you think!
 
I futzed around with the JP release of this but I couldn't get over how much of a pain in the ass it is to program with the touchpen. Is everyone using that for input or is there some much easier method that I'm not aware of?
 
Very cool work. I hope there don't end up being some sort of legal issues with the Petit BASIC program due to people dumping sprites etc. from ROMs.

I futzed around with the JP release of this but I couldn't get over how much of a pain in the ass it is to program with the touchpen. Is everyone using that for input or is there some much easier method that I'm not aware of?
Program on computer, use PC utilities to convert to QR code, scan that in and test.
 
What exactly does putting a semicolon at the end of a PRINT command do? For example:

PRINT "A";

I've noticed that if I try printing something at the bottom of the screen without the semi-colon after it I get weird errors where previously printed text starts scrolling upwards. I'm just curious why the semi-colon seems to fix it.
 
What exactly does putting a semicolon at the end of a PRINT command do? For example:

PRINT "A";
The semicolon prints the line without the carriage return (new line/line feed) - the next print statement continues from that point instead of a new line.

In your case, printing will advance to a new page -- printing at the bottom of the page drops the cursor to the next line, and thus moves the text up as the screen scrolls down.
 
The semicolon prints the line without the carriage return (new line/line feed) - the next print statement continues from that point instead of a new line.

In your case, printing will advance to a new page -- printing at the bottom of the page drops the cursor to the next line, and thus moves the text up as the screen scrolls down.
Great, thanks. I figured it had something to do with carriage return but it's great to have a confirmation.
 
I found an error in the manual. On the specs page it says we can only have 32,768 array elements, but we can actually have 262,144 elements...which it correctly says in the Japanese manual. Strange.

262,144 is 512x512, and as expected, I can DIM ARRAY(512,512) no problem. Trying to DIM any other arrays after this results in Out Of Memory, though you can still have other normal variables.

Just something to keep in mind.
 
Okay, so 4096=1 implies 2^-12 is the smallest number. It rounds numbers off to 0.001 when you print them, so 2^-12 displays as 0, so I try 1000*2^-12 and I get 0.244. Okay, so I try 1000*0.0002449, but it gives 0, even though 0.0002449 is greater than 2^-12, yet 1000*0.000245 gives 0.244 as an answer. It might seem like a small error, but it propagates: it registers 0.0007349 as 0.000488 and 0.000735 as 0.000732, even though 0.0007349 is greater than 0.000732. This thing thinks 100000*PI()=314135.742, which is an error of 23.523! So don't count on using this thing as a calculator, lol.
 
Okay, so 4096=1 implies 2^-12 is the smallest number. It rounds numbers off to 0.001 when you print them, so 2^-12 displays as 0, so I try 1000*2^-12 and I get 0.244. Okay, so I try 1000*0.0002449, but it gives 0, even though 0.0002449 is greater than 2^-12, yet 1000*0.000245 gives 0.244 as an answer. It might seem like a small error, but it propagates: it registers 0.0007349 as 0.000488 and 0.000735 as 0.000732, even though 0.0007349 is greater than 0.000732. This thing thinks 100000*PI()=314135.742, which is an error of 23.523! So don't count on using this thing as a calculator, lol.

I'm quite fine with these limitations since it means faster execution :P
 
Yeah, it's going to be inaccurate at small numbers unless you really know what you are doing when dealing with fixed-point numbers. From what I gather, their documentation statement probably meant something like, "The number 4096 in a 32-bit number would correspond to 1.0 in our system".

So I guess it could be summed up like:

20 bit integer part
12 bit decimal part
Range: ±524287.999755859375
Most numbers won't be representable in this range, of course.

Note 1: &B and &H seem to be able to set the integer part only.

Note 2: &B10000000000000000000 represents -0, not -524288. Probably so that the program can recognize when a user enters -0 (which you can do).

As an aside...
Label Character String said:
Charactor strings model variable containing the lavel name which starts with @ mark.
Uh..huh. I suspect there were bits of machine translation here and there. With no proofreading afterwards...

The manual sorta sucks despite its vast importance.
 
The first part of the official online manual is now online: http://www.petitcomputer.com/manual/

The error chart shows up as dark text on a dark background for me. Kinda weird.

----------------------------------------------------------------------------------

Also, I updated Cycle Game. 2 Player works now. I had some X's and Y's mixed up apparently.

ltcycle.png



And for those, like me, just getting into BASIC, here's a simple little program called French Fries:

friesc.png
 
Top Bottom