Jump to content
Serguei2

Pressing buttons won't work

Recommended Posts

I can't manage to make pressing buttons to work.

 

 

 

 

#include <coleco.h>
#include <getput1.h>

const byte gtsNAME[] = {
0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0x85, 0x20, 0xFF};
const byte gtsPATTERN[] = {
0xFE, 0x00, 0xFE, 0x00, 0x89, 0x00, 0x01, 0x1C, 0x38, 0x82, 0x18, 0x02, 0x00, 0x18, 0x18,
0x82, 0x66, 0x85, 0x00, 0x21, 0x44, 0xFE, 0x44, 0x44, 0xFE, 0x44, 0x00, 0x18, 0x3E, 0x60, 0x3C,
0x06, 0x7C, 0x18, 0x00, 0xFF, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0x81, 0xFF, 0x3C, 0x66, 0x3C, 0x38,
0x67, 0x66, 0x3F, 0x00, 0x06, 0x0C, 0x18, 0x84, 0x00, 0x01, 0x0C, 0x18, 0x82, 0x30, 0x04, 0x18,
0x0C, 0x00, 0x30, 0x18, 0x82, 0x0C, 0x08, 0x18, 0x30, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66,
0x82, 0x00, 0x81, 0x18, 0x02, 0x7E, 0x18, 0x18, 0x86, 0x00, 0x81, 0x18, 0x00, 0x30, 0x82, 0x00,
0x00, 0x7E, 0x88, 0x00, 0x81, 0x18, 0x81, 0x00, 0x10, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00,
0x3C, 0x66, 0xCE, 0xD6, 0xE6, 0xCC, 0x78, 0x00, 0x18, 0x38, 0x83, 0x18, 0x2C, 0x1C, 0x30, 0x0E,
0x1E, 0x36, 0x06, 0xFC, 0xC0, 0xFE, 0x00, 0x0E, 0x1E, 0x36, 0x06, 0x3C, 0x86, 0xFE, 0x00, 0x0E,
0x1E, 0x36, 0x66, 0xFE, 0x06, 0x06, 0x00, 0x1E, 0x3E, 0x70, 0xE0, 0xFC, 0x0E, 0xFE,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0x42, 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6,
0x00, 0x1C, 0x3E, 0x66, 0xC6, 0xC6, 0xCC, 0x78, 0x00, 0x0E, 0x1E, 0x36, 0x66, 0xFC, 0xC0, 0xC0,
0x00, 0x1C, 0x3E, 0x66, 0xC6, 0xD6, 0xDC, 0x77, 0x00, 0x0E, 0x1E, 0x36, 0x66, 0xF8, 0xCC, 0xC6,
0x00, 0x0E, 0x1E, 0x32, 0x60, 0xFE, 0x06, 0xFE, 0x00, 0x7E, 0xFC, 0x83, 0x30, 0x02, 0x38, 0x60,
0x26, 0x82, 0x66, 0x04, 0xE6, 0xC6, 0xFE, 0x00, 0x26, 0x82, 0x66, 0x26, 0xE6, 0x6C, 0x38, 0x00,
0x62, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC4, 0x00, 0x26, 0x66, 0xEC, 0x38, 0x7C, 0xEE, 0xC6, 0x00,
0x26, 0x66, 0xEC, 0x38, 0x18, 0x18, 0x1C, 0x30, 0x3E, 0x66, 0xCC, 0x18, 0x32, 0x66, 0xFE, 0x00,
0xFF, 0xE0, 0xE0, 0x84, 0x80, 0x00, 0xFF, 0x86, 0x00, 0x02, 0xFF, 0x07, 0x07, 0x84, 0x01, 0x87,
0x80, 0x87, 0x01, 0x00, 0x00, 0x86, 0xFE, 0x87, 0x7F, 0x87, 0xFE, 0x00, 0xFF, 0x86, 0xC0, 0x00,
0xFF, 0x86, 0x03, 0x86, 0x80, 0x00, 0xFF, 0x86, 0x01, 0x88, 0xFF, 0x00, 0x00, 0x85, 0x7F, 0x81,
0x00, 0x85, 0xFE, 0x81, 0x00, 0x0A, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7E, 0x7E,
0x00, 0x86, 0x7E, 0x00, 0x00, 0x82, 0x7E, 0x81, 0x00, 0x86, 0x7F, 0x82, 0x03, 0x00, 0xFF, 0x83,
0x01, 0x82, 0xC0, 0x00, 0xFF, 0x83, 0x80, 0x00, 0xFF, 0x86, 0x80, 0x00, 0xFF, 0x86, 0x01, 0x97,
0xFF, 0x00, 0x00, 0x85, 0x7F, 0x81, 0x00, 0x85, 0xFE, 0x0A, 0x00, 0xF7, 0xB7, 0xB5, 0xBD, 0xBD,
0xED, 0xEF, 0xEF, 0x00, 0x40, 0x85, 0x00, 0x87, 0xFF, 0x81, 0x00, 0x83, 0x3C, 0x81, 0x00, 0x84,
0x80, 0x81, 0xE0, 0x00, 0xFF, 0x86, 0x00, 0x00, 0xFF, 0x84, 0x01, 0x81, 0x07, 0x00, 0xFF, 0xFE,
0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0x97,
0x00, 0xFF};
const byte gtsCOLOR[] = {
0xFE, 0x41, 0xFC, 0x41, 0x83, 0x41, 0x87, 0x61, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xD2,
0x41, 0xA7, 0xA1, 0x98, 0x51, 0x8E, 0x5F, 0x8F, 0x51, 0x87, 0x11, 0x8F, 0x61, 0x97, 0x81, 0x87,
0xA1, 0x82, 0x5F, 0x84, 0x51, 0x82, 0x5F, 0x94, 0x51, 0x87, 0x71, 0x87, 0x21, 0x87, 0xE1, 0x8F,
0x41, 0x87, 0xBA, 0x87, 0x96, 0x87, 0xB1, 0x9F, 0xA1, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0x97, 0x41, 0xFF};
void nmi(void) {}

void main(void)
{
screen_mode_2_text();
paper(0xc);
upload_default_ascii(NORMAL);
duplicate_pattern();
rle2vram (gtsPATTERN,0x0000);
rle2vram (gtsCOLOR,0x2000);
rle2vram (gtsNAME,0x1800);
cls();
screen_on();
print_at(1,1,"FIRE");
loop:
if(joypad_1&FIRE1){
print_at(1,3,"BANG!");
}
goto loop;
}
Edited by Serguei2

Share this post


Link to post
Share on other sites

Never mind.

 

I didn't included enable_nmi();.

 

 

 

#include <coleco.h>
#include <getput1.h>

const byte gtsNAME[] = {
0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0xFE, 0x20, 0x85, 0x20, 0xFF};
const byte gtsPATTERN[] = {
0xFE, 0x00, 0xFE, 0x00, 0x89, 0x00, 0x01, 0x1C, 0x38, 0x82, 0x18, 0x02, 0x00, 0x18, 0x18,
0x82, 0x66, 0x85, 0x00, 0x21, 0x44, 0xFE, 0x44, 0x44, 0xFE, 0x44, 0x00, 0x18, 0x3E, 0x60, 0x3C,
0x06, 0x7C, 0x18, 0x00, 0xFF, 0x81, 0xB9, 0xA5, 0xB9, 0xA5, 0x81, 0xFF, 0x3C, 0x66, 0x3C, 0x38,
0x67, 0x66, 0x3F, 0x00, 0x06, 0x0C, 0x18, 0x84, 0x00, 0x01, 0x0C, 0x18, 0x82, 0x30, 0x04, 0x18,
0x0C, 0x00, 0x30, 0x18, 0x82, 0x0C, 0x08, 0x18, 0x30, 0x00, 0x00, 0x66, 0x3C, 0xFF, 0x3C, 0x66,
0x82, 0x00, 0x81, 0x18, 0x02, 0x7E, 0x18, 0x18, 0x86, 0x00, 0x81, 0x18, 0x00, 0x30, 0x82, 0x00,
0x00, 0x7E, 0x88, 0x00, 0x81, 0x18, 0x81, 0x00, 0x10, 0x03, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00,
0x3C, 0x66, 0xCE, 0xD6, 0xE6, 0xCC, 0x78, 0x00, 0x18, 0x38, 0x83, 0x18, 0x2C, 0x1C, 0x30, 0x0E,
0x1E, 0x36, 0x06, 0xFC, 0xC0, 0xFE, 0x00, 0x0E, 0x1E, 0x36, 0x06, 0x3C, 0x86, 0xFE, 0x00, 0x0E,
0x1E, 0x36, 0x66, 0xFE, 0x06, 0x06, 0x00, 0x1E, 0x3E, 0x70, 0xE0, 0xFC, 0x0E, 0xFE, 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x42, 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6,
0x00, 0x1C, 0x3E, 0x66, 0xC6, 0xC6, 0xCC, 0x78, 0x00, 0x0E, 0x1E, 0x36, 0x66, 0xFC, 0xC0, 0xC0,
0x00, 0x1C, 0x3E, 0x66, 0xC6, 0xD6, 0xDC, 0x77, 0x00, 0x0E, 0x1E, 0x36, 0x66, 0xF8, 0xCC, 0xC6,
0x00, 0x0E, 0x1E, 0x32, 0x60, 0xFE, 0x06, 0xFE, 0x00, 0x7E, 0xFC, 0x83, 0x30, 0x02, 0x38, 0x60,
0x26, 0x82, 0x66, 0x04, 0xE6, 0xC6, 0xFE, 0x00, 0x26, 0x82, 0x66, 0x26, 0xE6, 0x6C, 0x38, 0x00,
0x62, 0xC6, 0xC6, 0xD6, 0xFE, 0xEE, 0xC4, 0x00, 0x26, 0x66, 0xEC, 0x38, 0x7C, 0xEE, 0xC6, 0x00,
0x26, 0x66, 0xEC, 0x38, 0x18, 0x18, 0x1C, 0x30, 0x3E, 0x66, 0xCC, 0x18, 0x32, 0x66, 0xFE, 0x00,
0xFF, 0xE0, 0xE0, 0x84, 0x80, 0x00, 0xFF, 0x86, 0x00, 0x02, 0xFF, 0x07, 0x07, 0x84, 0x01, 0x87,
0x80, 0x87, 0x01, 0x00, 0x00, 0x86, 0xFE, 0x87, 0x7F, 0x87, 0xFE, 0x00, 0xFF, 0x86, 0xC0, 0x00,
0xFF, 0x86, 0x03, 0x86, 0x80, 0x00, 0xFF, 0x86, 0x01, 0x88, 0xFF, 0x00, 0x00, 0x85, 0x7F, 0x81,
0x00, 0x85, 0xFE, 0x81, 0x00, 0x0A, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0xFF, 0xFF, 0x00, 0x7E, 0x7E,
0x00, 0x86, 0x7E, 0x00, 0x00, 0x82, 0x7E, 0x81, 0x00, 0x86, 0x7F, 0x82, 0x03, 0x00, 0xFF, 0x83,
0x01, 0x82, 0xC0, 0x00, 0xFF, 0x83, 0x80, 0x00, 0xFF, 0x86, 0x80, 0x00, 0xFF, 0x86, 0x01, 0x97,
0xFF, 0x00, 0x00, 0x85, 0x7F, 0x81, 0x00, 0x85, 0xFE, 0x0A, 0x00, 0xF7, 0xB7, 0xB5, 0xBD, 0xBD,
0xED, 0xEF, 0xEF, 0x00, 0x40, 0x85, 0x00, 0x87, 0xFF, 0x81, 0x00, 0x83, 0x3C, 0x81, 0x00, 0x84,
0x80, 0x81, 0xE0, 0x00, 0xFF, 0x86, 0x00, 0x00, 0xFF, 0x84, 0x01, 0x81, 0x07, 0x00, 0xFF, 0xFE,
0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0xFE, 0x00, 0x97,
0x00, 0xFF};
const byte gtsCOLOR[] = {
0xFE, 0x41, 0xFC, 0x41, 0x83, 0x41, 0x87, 0x61, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xD2,
0x41, 0xA7, 0xA1, 0x98, 0x51, 0x8E, 0x5F, 0x8F, 0x51, 0x87, 0x11, 0x8F, 0x61, 0x97, 0x81, 0x87,
0xA1, 0x82, 0x5F, 0x84, 0x51, 0x82, 0x5F, 0x94, 0x51, 0x87, 0x71, 0x87, 0x21, 0x87, 0xE1, 0x8F,
0x41, 0x87, 0xBA, 0x87, 0x96, 0x87, 0xB1, 0x9F, 0xA1, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE,
0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0xFE, 0x41, 0x97, 0x41, 0xFF};
void nmi(void) {}

void main(void)
{
screen_mode_2_text();
paper(0xc);
upload_default_ascii(NORMAL);
duplicate_pattern();
rle2vram (gtsPATTERN,0x0000);
rle2vram (gtsCOLOR,0x2000);
rle2vram (gtsNAME,0x1800);
enable_nmi();
cls();
screen_on();
print_at(1,1,"FIRE");
loop:
if(joypad_1&FIRE1){
print_at(1,3,"BANG!");
}
goto loop;
}

 

Now everything works fine.

Share this post


Link to post
Share on other sites

One thing to add to a game loop is delay(1);. It acts like WAIT command like in IntyBASIC. It keeps the game at 60fps. Right after delay(1); is updatesprites(0,64); to avoid sprite tear. If you hold the fire button in that loop, it'll eventually print someplace else in VRAM due to how NMI works so it'll partly corrupt your VRAM. So do VRAM update right after delay(1); so it doesn't get interrupted when the screen is finished drawing. For mass VRAM update like loading the graphic tables, disable_nmi() is correct in your post.

enable_nmi();
while(game==1){

delay(1);

updatesprites(0,64);

*vram stuff like update score and stuff here*

*CPU stuff*
}

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...