What do you mean by "not work"? Does it not compile? Or doesn't it do what expected when running? I'm very bad at C coding, but I can't see any problem in your code, if that helps anything.
Currently, it allows exactly one keypress per piece before denying everything. I'm failing to find the flaw in my logic, though, which is why I was soliciting some fresh eyes to examine it. I'm playing around with it now, though; this would be much faster if we had a better emulator.
possible error:
you say
Code:
it should probably be
Code:
you say
Code:
} else if (key == KEY_SHIFT) {
it should probably be
Code:
} else if (key == KEY_PRGM_SHIFT) {
Yes, I found and fixed that after I copied the code to the post; that was preventing it from compiling, but the behavior I described was after fixing that.
Edit: Looks like I managed to clean all that up. Now I'm looking at a segfault somewhere in the double-for-loop here. If I comment everything except the outer for loop and the DrawNumberCentered(), it still segfaults. Commenting out the outer for loop and the DNC() as well makes it stop segfaulting.
Code:
Edit: I can't believe I forgot that dereferencing integers causes a segfault when they're not aligned (on 4-byte boundaries). Fail on me, that cost me hours of debugging.
Edit: Looks like I managed to clean all that up. Now I'm looking at a segfault somewhere in the double-for-loop here. If I comment everything except the outer for loop and the DrawNumberCentered(), it still segfaults. Commenting out the outer for loop and the DNC() as well makes it stop segfaulting.
Code:
unsigned char hstable[NMODES*(3+4)];
if (0 <= (fh = Bfile_OpenFile_OS(HSFile,0x01))) { //_OPENMODE_READ
Bfile_ReadFile_OS(fh,(void*)hstable,NMODES*(3+4),0);
Bfile_CloseFile_OS(fh);
}
while(gameactive == 0) {
RenderTetrizmBackground(0,0,0);
CopySprite(selmode,136,30,107,52);
CopySprite(modebmps[mode],73,28,20,143);
for(int i=0; i<NMODES; i++) {
for(int j=0; j<2; j++) {
char* PlrInit = "XXA";
PlrInit[2] = hstable[i*(3+4)+j];
PrintXY(7+j,4+i,PlrInit,0x20,3);
}
DrawNumberCentered(*((int*)(hstable+(i*(3+4)+3))), 190, 110+(14*i), 60);
}
Bdisp_PutDisp_DD();
Edit: I can't believe I forgot that dereferencing integers causes a segfault when they're not aligned (on 4-byte boundaries). Fail on me, that cost me hours of debugging.
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
» Go to Registration page
» Goto page Previous 1, 2, 3, 4
» View previous topic :: View next topic
» View previous topic :: View next topic
Page 4 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
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