void pad_autoread() { print(PSTR("pad autoread\n\r")); pad_init(); uint8_t ld =0; while(!uart_read_ready()) { uint8_t d = pad_read(); if (ld!=d) { print_hb(0,d); ld=d; } } }
int main(void) { init(); while (pad_read()) { update(); draw(); sceDisplayWaitVblankStart(); sceGuSwapBuffers(); } sceGuTerm(); return 0; }
uint8_t pad_do_prompt() { char cmd[17]; scan_key(cmd,17); if (strcmp(cmd,"init")==0) { pad_init(); return 1; } if ((strcmp(cmd,"test")==0) || (strcmp(cmd,"ping")==0)) { if (pad_ping()) { print_ok_nl(); } else { print_err_nl(); } return 1; } if (strcmp(cmd,"state")==0) { uint8_t d = pad_state(); if (d == PAD_REMOTE_ERROR) { print_err_nl(); } else { print_hb(0,d); print_nl(); } return 1; } if (strcmp(cmd,"led")==0) { pad_led(); return 1; } if (strcmp(cmd,"rled")==0) { pad_remote_led(); return 1; } if (strcmp(cmd,"read")==0) { uint8_t d = pad_read(); print_hb(0,d); print_nl(); return 1; } if (strcmp(cmd,"write")==0) { uint8_t v0 = scan_uint8(); if (pad_write(v0)) { print_ok_nl(); } else { print_err_nl(); } return 1; } if (strcmp(cmd,"autoread")==0) { pad_autoread(); return 1; } return 1; }
main() { DB db[2]; /* packet double buffer */ DB *cdb; /* current db */ MATRIX rottrans; /* rot-trans matrix */ int i; /* work */ int dmy, flg; /* dummy */ CVECTOR col[12]; /* cube color */ u_long cnt; etc.near_clip=500; etc.far_clip=5000; etc.clip_off=0; PadInit(0); /* initialize PAD */ ResetGraph(0); /* reset graphic subsystem (0:cold,1:warm) */ SetGraphDebug(0); /* set debug mode (0:off, 1:monitor, 2:dump) */ InitGeom(); /* initialize geometry subsystem */ SetGeomOffset(320, 240); /* set geometry origin as (160, 120) */ SetGeomScreen(SCR_Z); /* distance to viewing-screen */ SetLightMatrix(&LLM); SetColorMatrix(&LCM); SetBackColor(BK.vx,BK.vy,BK.vz); SetFarColor(FC.vx,FC.vy,FC.vz); SetFogNear(1*SCR_Z,SCR_Z); /* initialize environment for double buffer (interlace) * buffer ID VRAM address *------------------------------------------------------- * buffer #0 (0, 0)-(640,480) * buffer #1 (0, 0)-(640,480) */ SetDefDrawEnv(&db[0].draw, 0, 0, 640, 480); SetDefDrawEnv(&db[1].draw, 0, 0, 640, 480); SetDefDispEnv(&db[0].disp, 0, 0, 640, 480); SetDefDispEnv(&db[1].disp, 0, 0, 640, 480); FntLoad(960,256); SetDumpFnt(FntOpen(64,64,256,200,0,512)); SetRCnt(RCntCNT2,0xffff,RCntMdNOINTR|RCntMdFR); StartRCnt(RCntCNT2); /* set surface colors */ for (i = 0; i < 12; i+=2) { col[i].r = col[i+1].r = 0xff/*rand()*/; /* R */ col[i].g = col[i+1].g = 0xff/*rand()*/; /* G */ col[i].b = col[i+1].b = 0xff/*rand()*/; /* B */ col[i].cd = col[i+1].cd = CODE_G3; /* cd */ } init_prim(&db[0]); /* set primitive parameters on buffer #0 */ init_prim(&db[1]); /* set primitive parameters on buffer #1 */ SetDispMask(1); /* enable to display (0:inhibit, 1:enable) */ while (pad_read(&rottrans) == 0) { cdb = (cdb==db)? db+1: db; /* swap double buffer ID */ ClearOTagR(cdb->ot, OTSIZE); /* clear ordering table */ /* add cube */ ResetRCnt(RCntCNT2); add_cube(cdb->ot, cdb->s, v, n, col); cnt= GetRCnt(RCntCNT2); FntPrint("cnt=%d\n",cnt); /* swap buffer */ DrawSync(0); /* wait for end of drawing */ VSync(0); /* wait for the next V-BLNK */ PutDrawEnv(&cdb->draw); /* update drawing environment */ PutDispEnv(&cdb->disp); /* update display environment */ DrawOTag(cdb->ot+OTSIZE-1); /* draw */ FntFlush(-1); } PadStop(); exit(); }
int main(void) { music_init(); music_play(3); u16 delay_mod = 4; u16 col_inc_cnt = 0; setup(); reset_demo: hint_val = 3; col = 0; col_off = 0; phrase_num = 0; scroll_off = 0; dscroll = 0; term_pos = 0; term_scrolling = 0; sprites_dma_simple(); term_pos = 0; VDP_setHInterrupt(0); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); // Greyscale palette for text VDP_setPaletteColor(0,0x000); VDP_setPaletteColor(1,0x444); VDP_setPaletteColor(2,0x888); VDP_setPaletteColor(3,0xEEE); VDP_setScreenWidth256(); bios_boot_demo(); VDP_setScreenWidth320(); VDP_clearPlan(VDP_PLAN_A, 0); VDP_clearPlan(VDP_PLAN_B, 0); awful_put_logo(8, 2); startup_stretch(); VDP_setVerticalScroll(PLAN_A, 252); VDP_setVerticalScroll(PLAN_B, 252); VDP_setHIntCounter(hint_val); SYS_setHIntCallback((_voidCallback *)h_int); volatile u8 p1 = pad_read(0); sprites_init(); col_puts40(8,0,"Computer Science House"); // Initialize background stars star stars[NUM_STARS]; u16 i = 0; for (i = 0; i < NUM_STARS; i++) { stars[i].x = i * 5; stars[i].y = 128 + i * 8; stars[i].speed = (i % 7) + 1; stars[i].offset = (3 * i) % 4; stars[i].size = (i % 4 == 0) ? ('.' + COL_FONT_VRAM_OFFSET) : (128 + '.' + COL_FONT_VRAM_OFFSET); } print_phrase(8); u16 delay = 0; u8 dir = 0; VDP_setHInterrupt(1); for (;;) { delay++; if (col_inc_cnt == 0) { col_inc_cnt = hint_val; col_off += 0x002; } else { col_inc_cnt--; } if (delay == 512) { if (phrase_num == 8) { phrase_num = 0; VDP_setHInterrupt(0); sprite_set(0, 0, 0, 0, 0, 0); sprites_dma_simple(); while (vbl_wait) { __asm__("nop"); } vbl_wait = 1; goto reset_demo; } hint_val++; if (hint_val == 10) { hint_val = 3; } delay_mod = delay_mod >> 1; if (delay_mod == 0) { delay_mod = delay_mod = 4; } VDP_setHIntCounter(hint_val); VDP_setHInterrupt(0); print_phrase(phrase_num); VDP_setHInterrupt(1); phrase_num++; delay = 0; } process_stars(&stars); while (vbl_wait) { __asm__("nop"); } VDP_setHInterrupt(0); VDP_setPaletteColor(14,palette[col]); col = col_off; vbl_wait = 1; sprites_dma_simple(); VDP_setHInterrupt(1); } return 0; }
u16 input_read(void) { return pad_read(&_pad, 0) | gpio_read(); }