For some reason, I can't find how to input strings in C. How do I do so?
Spenceboy98 wrote:
For some reason, I can't find how to input strings in C. How do I do so?


C on the Prizm, I assume you mean to say specifically? If so, look at Kerm's routine, and if that doesn't cut it perhaps try working up from the more basic *MBString syscalls?
So, the MBString lets you input text where you want on the screen?
Spenceboy98 wrote:
So, the MBString lets you input text where you want on the screen?


No, it displays it with some customization on where to show the start of the string, where to put the cursor, etc. You'd have to write the actual input code on top of that. If you want something that can be used as-is, use Kerm's routine.
So, I can just copy and paste Kerms code into mine? Wouldn't it input somewhere at the top of the screen? Also, is there a Lbl type function? I can't find one of those either.
Spenceboy98 wrote:
So, I can just copy and paste Kerms code into mine? Wouldn't it input somewhere at the top of the screen? Also, is there a Lbl type function? I can't find one of those either.


Yes, put the function somewhere near the bottom of your source code, and prototype it near the top. Read the description to see how it works. And finally, "Lbl" function? What do you mean?
I mean, is there a function similar to "Lbl" in TI-Basic and/or "Goto"?
Spenceboy98 wrote:
I mean, is there a function similar to "Lbl" in TI-Basic and/or "Goto"?


Yes, and while it has it's admitted uses, for the most part you're going to want to use if/else/while/for/etc. control structures.
Ashbad, how did you get the main character in Raptor to move so swiftly and smoothly?
Spenceboy98 wrote:
Ashbad, how did you get the main character in Raptor to move so swiftly and smoothly?


It moves by 8 pixels at a time, plus the whole thing is optimized to blit as little as possible onto the screen at a time. Everything is drawn in about half the time it takes to render a full background from a picture.
Some Code:


Code:
int main() {     
MENU:
  int y = 129;   
  while(1) {     
    int key = PRGM_GetKey();     
    if(key == KEY_PRGM_MENU) {  GetKey(&key); }         
    CopySprite(BulletMenu, 0, 0, 384, 216);
    CopySpriteMasked(BulletMenuSelector, 7, y, 18, 16, COLOR_RED);
    if(keydown(KEY_PRGM_UP) && y>129)
    y-=16;
    if(keydown(KEY_PRGM_DOWN) && y<145)
    y+=16;
    if(keydown(KEY_PRGM_SHIFT) && y == 129)
    break;
    if(keydown(KEY_PRGM_SHIFT) && y == 145)
    goto PIZZA;
    Bdisp_PutDisp_DD();     
    Bdisp_AllCr_VRAM();

}
  struct Coord cur;   
  cur.x = 128;   
while(1) {     
    int key = PRGM_GetKey();     
    if(key == KEY_PRGM_MENU) {  GetKey(&key); }         
    moveCursor(&cur);   
    CopySprite(BulletBackground, 0, 0, 384, 216);
    CopySpriteMasked(SpenBullet, cur.x, 159, 38, 43, COLOR_RED);
    CopySpriteMasked(Banana, 0, 0, 75, 80, COLOR_RED);
    CopySpriteMasked(LSDOMG, 77, 0, 34, 34, COLOR_RED);
    Bdisp_PutDisp_DD();     
    Bdisp_AllCr_VRAM();
  }     
PIZZA:
while(1) {
    CopySprite(Instructions, 0, 0, 384, 216);
    if(keydown(KEY_PRGM_EXIT))
    goto MENU;
    Bdisp_PutDisp_DD();     
    Bdisp_AllCr_VRAM();
}
  return 0;     
}


It keeps saying,


Code:
main.c:72:3: error: a label can only be part of a statement and a declaration is
 not a statement
A label must be just before an instruction (and the line "int y = 129;" is not an instruction).

BTW, it is strongly discouraged to use goto in C. It's ugly and you can easily make anything without.
Is there a way to generate a random integer in C?
http://www.cplusplus.com/reference/clibrary/cstdlib/srand/

To initialize the generator, you have to call RTC_GetTicks() instead of time(NULL)
(RTC_GetTicks is the syscall 0x02C1)
How do I get a number between 45 and 340?
PierrotLL wrote:
A label must be just before an instruction (and the line "int y = 129;" is not an instruction).

BTW, it is strongly discouraged to use goto in C. It's ugly and you can easily make anything without.

Amen, int spaghetti code=mess.
Try to use function as much as possible, in my C programming book it highly persuades you from using Labels/Gotos
rand()%(340-45+1) + 45;
How do I reset variables to a new value?
Spenceboy98 wrote:
How do I reset variables to a new value?



Code:
int i = 0;
...
i = 1; // magic.. *snort snort*


Please take my earlier suggestion of reading a C tutorial Sad
I tried that. It didn't work. It said that the variables I reset were unused.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 4
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement