http://www.youtube.com/watch?v=4AYlEo3rJHs
Petit Computer is DSiware that allows you to program cool things for your DSi, DSiXL or 3DS using the BASIC programming language. The program seems designed for simple game development, including a variety of commands for working with sprites and backgrounds, but you could theoretically program any number of useful apps.
It includes some sample graphics, music and sounds, and also editors to create your own. You can save your creations to the SD card, connect it to your computer, and generate QR codes to share it with others. I believe you can also just share the file, but QR means others don't have to futz with SD cards.
We're getting it in America on July 19 for $8. This thread's a bit premature I admit, but it's never too early to start learning to program and getting acquainted with what you can do. The
program's website includes a
samples page with code for all of the included programs. As an example, here's the first demo program:
'+------------------------+
'| SAMPLE1 |
'| Output characters |
'| to console |
'+------------------------+
VISIBLE 1,1,0,0,0,0
CLS:COLOR 0
'--- Character display
PRINT"Ж:NICO Mark"
PRINT"ALPHABET"
PRINT"12345";"KATAKANA"
'--- Assign color
COLOR 12:PRINT"а";
COLOR 13:PRINT"б";
COLOR 11:PRINT"Я";
COLOR 9:PRINT"в"
COLOR 0
'--- Use variable
APPLE=56
ORANGE=123
'--- Assign display location
LOCATE 5,10
PRINT"Apples = ";APPLE;"
LOCATE 5,11
PRINT"Oranges = ";ORANGE;"
LOCATE 5,12
PRINT"-----------"
LOCATE 5,13
TOTAL=APPLE+ORANGE
PRINT"Total = ";TOTAL
'--- end
PRINT ""
PRINT "─"*32;
PRINT "PUSH А"
@KLOOP
VSYNC 1
IF BTRIG()!=16 THEN @KLOOP
END
We are getting version 2 of the software which included many improvements such as the ability to share your programs (users used to upload video of their source code!). This program's been around in Japan for a while, and I never expected it to be localized. I'm pretty excited for it!
In Japan it's known as
Puchicon for short. You can click that link to see a search of Youtube for the term, which shows a lot of programs that have already been made. Here are some noteworthy examples:
A port of OutrunSpectacle Hurricane, a Space Harrier cloneSuper TryGunners, a space shooterA port of Genesis's ColumnsAn introductory animation from Ys 3, showing off smooth scrolling
The Japanese version included speech synthesis for generating Japanese speech, which is not included in our version. There were a couple sample programs teaching how to use it which are conspicuously absent from the english sample page.
The software includes
8 banks of sprites like this one:
4 banks of backgrounds like this one:
30 built-in songs and 70 sound effects, with 128 instrument MIDI and custom waveforms.
Here are some of the
program's specifications:
- Programs with names of up to 8 characters, supporting 9999 lines of code, though you can launch other programs from within your program and include additional program data. I'm not sure whether program size is virtually unlimited because of this or if there are other caveats.
- Strings and numeric variables with names of up to 16 characters. Integers must be in the range of ± 524,287.
- Arrays of up to two dimensions, with up to 262,144 individual elements. String arrays must contain fewer elements, I believe.
- During program execution, the use of every DSi button other than select, which is used to return to the console screen. You can also use the touch screen for conventional touch coordinates or virtual keyboard input.
- 100 simultaneous sprites, which can be sized in almost any combination from 8x8 pixels to 64x64.* They can be used for characters, enemies, bullets, particles, any number of things. Sprites are optimized for ease of movement, animation, rotation, scaling, and collision detection. There are built-in commands for
all of these that will
vastly help streamline game creation.
* no 8x64, 16x64, 64x8, or 64x16.
- Multiple drawing layers, as follows:
- At the back, a default background color.
- A drawing plane where you can output manually-drawn images of lines, filled shapes etc. If I'm reading the specs correctly, this plane contains two pages per DSi screen that you can flip between in order to create smooth animations, i.e. you can draw to the offscreen page and display it when ready.
- Two graphics planes used for BG tiles. While DSi's screens are 256x192, these planes are 512x512 and can be offset from their default position to scroll the image around. They also support transparency for layering purposes; as an example, see the BG bank above. You'd draw the stump on the lower layer and the tree's leaves on the second. You can also use them for parallax scrolling, mountains in the far background etc.
- At the front, the console display on the top screen and keyboard on the bottom screen. The console supports 32x24 characters and can be used for simple text programs or very basic games. These planes can be hidden to work with only the graphical planes below.
- Individual sprites can be positioned between any of the above planes.
That is probably enough for an OP.
There is a third party editor that allows you to edit all aspects of your programs via PC and convert back to the DSi format, saving you tons of mental anguish from typing on DSi's touch screen. I will post about that in a bit.
Posts
Frankly, with all those extra features, they should have used an OO language.
3DS: 0473-8507-2652
Switch: SW-5185-4991-5118
PSN: AbEntropy
That said, this is still very cool. I expect to see more and more games like this, as time goes on. With Notch's assembly emulator in his next game, and now this, I hope this becomes a trend.
3DS: 0473-8507-2652
Switch: SW-5185-4991-5118
PSN: AbEntropy
There have been a number of improvements to it here that make it a little more user friendly - for example, while it still uses line numbers, I believe you can insert new lines wherever you want and it re-numbers the rest of the program, and "goto" uses @labels instead of line numbers. It's also got a number of syntax changes to bring it in line with other languages, for example, using != instead of <>.
Anyway.
So somebody elsewhere linked a port someone in Japan made of the old Star Trek BASIC game. He mentions a javascript-generated QR code of the source, which meant that there must be some way to edit Petit Computer's files on a PC. Since his Star Trek page was in decent english, I decided to drop him a line and asked whether PC editing was possible. He told me it was, and provided a link to this program:
PTCUtilities, a full suite for editing Petit Computer programs
An english version is in progress. You can download it now and it's mostly there already.
This will make creating programs for DSi much easier. You can import graphics from any source and generate palettes and graphic banks. You can search for text in your program and jump between labels. And most importantly, you can type on an actual keyboard. :P
So it's nice to have a good utility like this available even before day one of release.
Here's the manual run through Google Translate. You may need to manually change the "p02" at the top to other page numbers (p03, p04 etc.) if the page links aren't working. And here is a cool single page command reference (also run through Google Translate).
Smileboom has been posting free graphic sets you can use for your own games. The ones they've given out recently are for people who want to make their own Advance Wars! QR codes at the links, including palettes:
http://smileboom.com/special/ptcm2/co_present/html_present03.php
http://smileboom.com/special/ptcm2/co_present/html_present04.php
Other stuff:
Here is an amazing massive music synthesizer someone made. Seriously it's ~60 QR codes long. Looks like professional software you might pay for (video).
A post from GAF:
A friggin' raytracer someone made.
Actually here's the Japanese wiki where people have posted all sorts of programs.
I love me some basic. If I find the code I wrote for a Pokémon clone back in the late 90's on my old hard drive I'll try and bring it out for all to see.
I started in C++ :P Honestly I've never really coded in BASIC, though I can't see it being *that* hard (albeit cumbersome I'd imagine)
As for the comment about coding on a PC, that would be quite nice. To be honest, I'd rather not try to type with a stylus if I can avoid it Looks like the program is in Japanese though which is a shame. I hope someone translates it (not that I'm sure it wouldn't be that hard to figure out, but still...)
There's so many permutations of BASIC that any one implementation can be quite different from another, from very modern variants like Visual Basic all the way back to very primitive dialects. This thing looks more similar to the old school, programming-on-a-70s-microcomputer versions.
Line numbers man. Nostalgia'd up.
Did you download it? It's actually already mostly in english, and he's improving it regularly. I have no trouble understanding how to use it.
All you really need to start with is the PRG editor. Type some BASIC code, generate a QR code from it, read it with your DS.
I did download the Star Trek game though, that's really well done! I honestly don't know how to really *play* it (though I actually did use to have that way back when), but the interface and everything are nice. Even if they do spell Klingons "Kilins" (or something stupid like that). I'm tempted to go into the code and fix the numerous spelling errors and typos
The "other version" they link to somewhere on that page sucks though. "Type 1-5" and you are just supposed to know what those refer to :P (ex: 1 = warp, etc)
The synthesizer was also cool (took freaking forever to download) but I don't really know how to use it. Other than hitting random buttons and ruining the sound quality :P
Edit: Holy crap!
http://translate.google.com/translate?sl=auto&tl=en&js=n&prev=_t&hl=en&ie=UTF-8&layout=2&eotf=1&u=http://wiki.hosiken.jp/petc/?Toukou&act=url
Someone made a rudimentary version of Scorched Earth (or whatever game Scorched Earth ripped off, which in turn was ripped off by Worms)
He said he did that on purpose to avoid copyright issues or something.
Some of the built in programs have weird translation issues though. I was in the CHR editor and went to load a new palette and it asked me if I wanted to load the splite palette! And when you try to run away in the dungeon game, you'll either "not got escape" or "get escape." :P
but I bought it anyways.
Anyways I made a little sound test program to try out all the sounds and bgm included with petit computer.
Edit:
Ok, now I've made something to draw 3D triangles
Starts having issues at about 8 triangles, might be able to improve it by clipping the lines smarter. Pretty cool to fly around though.
Up-Down to move in and out, Left Right to pan left right, and L and R to pan up and down
Same as for numbers, just use "$" at the end of the array name. (And sort works just fine, in case you were wondering.)
DIM ArrayName$(ArraySize)
FOR i=0 TO ArraySize-1
ArrayName$(i) = "string"+STR$(ArraySize-i)
NEXT
http://www.youtube.com/watch?v=be1Z0GjsA1Y
Also, Ys Book I + II intro this time (what makes this especially noteworthy is halfway through the video)
http://www.youtube.com/watch?v=ARi5C_0dTV4
Side note, that little Star Trek game is a lot of fun. I really wish he'd have laid the buttons out logically though. He should have just made the keypad match the directions that the numbers refer to. I had to mentally keep track of it which is pretty annoying.
I wanted to start with a nice big map to scroll around, but who wants to bother making their own? I looked up Dragon Quest'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.
http://i.imgur.com/ROcaM.png
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!
http://i.imgur.com/xMF8m.png
You can scroll around the whole Dragon Quest 1 map smoothly. Diagonals are a little jittery because Petit Computer is not fast enough to draw both a horizontal and vertical row of tiles in the same frame. It wouldn't be a problem if I split up the horizontal/vertical drawing between two frames but this is just a demo.
As it says on the pic, the program draws new tiles just off screen when it needs to scroll in that direction. If you're moving to the right, it draws the next column to the right. If you're moving downward, it draws the next row downward. When drawing columns it actually draws one extra tile on the top and bottom so it takes care of the corner tile when moving diagonally.
Took a lot of messing around but it's satisfying to have it working. I know it's not impressive on the surface, games are expected to be able to do things like this, but that's why routines like this are necessary. I could add some more user-defined variables and make it very adaptable for any type of map array, usable in platformers etc. Of course it'd still be pretty complicated to use.
http://i.imgur.com/vjzfq.png
Wow, impressive! I still need to figure out how to code anything on here :P heh... Shame it's not some form of C, it'd be a lot easier to read the examples' source code (although yours has probably made more sense than anything else I've looked at).
NEXT takes a variable as an argument, but I can't just give it 10000 to end the loop so I'm not sure what options that opens up. So do I=agazillion : NEXT : GOTO when you need to jump out of a loop.
X=0
@LOOP
X=X+1
'do stuff including jumping out with GOTO if necessary
IF X<1000 GOTO @LOOP
Or if you want to do more advanced things like use sprites and the background I can help with that too. I would rather make stuff that is fun to me rather than making tutorial programs all the time, but just explaining how stuff works isn't too hard. Sprites and background are actually pretty easy.
I'm not asking you to make a tutorial; I'm wondering if tutorials exist. There are some in Japanese on the official website although I don't know if they explain anything complicated.
So you have
Imagine that all the DATA statements are removed and put in their own file. Your program doesn't have to reach a DATA statement for it to do anything, you can put DATA anywhere in your program.
You can then use the READ command to read it. this reads from the first DATA statement, and onto the second and third because we put in three variables, and loads that data into those variables. so x$ is now "Growbalow", y is 20, and z is -1.23.
if we do another READ to a string variable, we'll get "adios amigo", as this is the last DATA statement, any more reads will cause the program to crash. If you're using DATA statements where you don't know how many there are, you'll want to have something at the bottom that you can check so that you know you're at the end, of either the program or just the section of DATA you want to read.
To get more out of READ, you'll want to use RESTORE.
RESTORE changes what DATA statement you'll read from. so RESTORE @mySecondLabel and then READ would get you -1.23, or we could go all the way back to the beginning with RESTORE @myFirstLabel. It uses the exact same labels that goto and gosub use, but relative to the DATA statements.
This is useful if you want to have one print function to throw up a full screen's worth of text.
The simpliest code I've attempted to use is this...
DIM CARD(2,2)
CARD(0,0)=1
CARD(0,1)=2
CARD(1,0)=3
CARD(1,1)=4
PRINT CARD (0,0)
PRINT CARD (0,0)
PRINT CARD (0,0)
PRINT CARD (0,0)
I realise I'm treating the array as a typical varitable, and maybe that is my problem, however in even attempting to use this code I get an error on the DIM line saying "Duplicate Definition". Am I misunderstanding the proper function of arrays entirely or is there something I'm missing?
Also in use of arrays (if I havn't fudged things up already), would I be able to use both numerics and strings within the same array set?
You need to start your program with CLEAR, that will erase all arrays, reset variables to 0 etc.
Yes, you can mix strings and numbers, just reference the array like CARD$(0,0) to store/read strings.
For cards there is some binary trickery you could do where the four suits are 16,32,64,128. Add the suit number to the card number(0-12 for ace-king) and store it in the array. Then you can test the suit with suit AND card, grab just the number with 15 AND card.
For a more flexible approach, you could have each card take up multiple array slots. So if a card has 3 attributes(number,face,suit) you would have each card in the array take up 3 slots.
I don't think tutorials exist for this program. Tutorials exist for BASIC, but there are enough little differences that it would probably be frustrating.
But yeah, DATA is just to store stuff inside your program. Think about ways you might do that. One way would be this:
A=10 : B=10 : C=5 : D=10 : E=20 : F=20 : G=10
(Colons are like putting code on a new line, so imagine that all stretched out vertically)
Or if you did it in a single array, like this, which isn't really any better:
A(0)=10 : A(1)=10 : A(2)=5 : A(3)=10 : A(4)=20 : A(5)=20 : A(6)=10
That's really cumbersome and possibly annoying to find the part you need to modify later. It's not well organized and not something you can loop through automatically. So instead, we have DATA which is very helpful for assigning numbers and strings into variables easily.
RESTORE @DATALOCATION
FOR X=0 to 6
READ A(X)
NEXT
@DATALOCATION
DATA 10,10,5,10,20,20,10
READ A(X) means A(X)=<next sequential thing stored in DATA>. Every time you use READ, it reads the next piece of data from wherever it left off, unless you've changed the read location with RESTORE.
You can use it for all sorts of things. In my program, they're a set of text strings to be printed based on the page you're on. You can use it to make built-in maps out of a series of numbers. You can use it to keep small tables of information like what frames of animation should play with what timing - maybe the character is skipping along so you want to display frames 1,1,1,2,3,3,3,4.
You're doing it exactly right. It's just a matrix, or a 2x2 spreadsheet of cells. DIM is what sets up the size, and as you figured out it starts with 0 and will end one less than the DIM. And referencing a part of an array is literally the same as any other variable. If you type PRINT AWESOME or PRINT AMAZING(36,54), it's all the same sort of thing.
I'm not sure why you'd store cards in an array, it doesn't seem all that useful. It's more useful for a collection of things that are similar but need to be recorded separately. So in an RPG, a monster has a type (bat, goblin), HP, MP, status effects, maybe X and Y on the screen if it's an action RPG, etc. And you'll have a maximum of 10 enemies or something. ENEMY(0,0) is the type of the first enemy, ENEMY(1,0) is the type of the second enemy, and so on. ENEMY(15,1) is the remaining HP of the 16th enemy.
Well I will admit that relying on arrays for something that can be mathmatically simple as playing cards is a bit unnessesary I have a few reasons for doing this. Primarily to get my feet wet using arrays, but also I plan on making a bulk card engine that I can use to simplify not only the simple Black Jack game I plan on starting with, but something I could use down the road to simplfy getting information on each card for say a game of Solitare or Poker. So instead of having to DECK(Card)%4 in each command where I need to find it's suit I can just refer to DECK(Card,4) (4 being the row in the array where I dicate the suit).
That said, I am having a few issues with the preiminary deck building array I have now. Here's the coding I have in place so far
CLEAR:CLS:DIM DECK(52,5):CARD=0
FOR CARD=0 TO 51
IF CARD<=36 THEN DECK(CARD,0)=FLOOR(CARD/4)+2:DECK(CARD,4)=DECK(CARD,0)
IF CARD>=35 AND CARD<=40 THEN DECK$(CARD,0)="J"
IF CARD>=39 AND CARD<=44 THEN DECK$(CARD,0)="Q"
IF CARD>=43 AND CARD<=48 THEN DECK$(CARD,0)="K"
IF CARD>=47 THEN DECK$(CARD,0)="A":DECK(CARD,4)=1
IF CARD>=35 AND CARD<=48 THEN DECK(CARD,4)=10
DECK(CARD,1)=CARD%4
DECK(CARD,3)=CARD%2
NEXT
--
It's what I have so far. For the sake of mentioning 0 is kept for the printed card face, 1 for a numerical suit reference, 2 will be the printed suit (not implimented in this code yet), 3 the suit color (again for the sake of easier reference instead of mathmatically searching it every time) and 4 is currently used for it's value in a BlackJack hand (I'll be putting in-hand code to determain the differences between 1 and 11 for Aces). Further numbers will be used for other game specific values like proper card order in Solitare or Poker). Currently I'm building the deck starting with 2, following through the four suits, going to 3 and repeating until the aces at the end of the line.
I'm currently running into an error in the 4th line 'Subscript out of range'. I checked the coding and while I seem to have a mild overflow for the IF/THEN statement (in that it seems to convert more cards then I intend to), but the error seems to stem from the DECK$ declaration. Do I need to alter this assignment for the sake of the "J" and other printed strings?
EDIT - And just after posting this I realised I'll come into another stump down in road when I'm attempting to PRINT the results of column 0 and half of them are numerical and the other are strings. Attempting to change the numerics to strings however gives me the same error on that line as I did with the other, so I guess I know what my problem is. How should I go about putting these strings into the array?