From: <ljs...@us...> - 2009-02-03 02:22:12
|
Revision: 619 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=619&view=rev Author: ljsebald Date: 2009-02-03 01:33:58 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Removing the old Maple API from a bunch of examples. Modified Paths: -------------- kos/examples/dreamcast/2ndmix/2ndmix.c kos/examples/dreamcast/cpp/clock/clock.cc kos/examples/dreamcast/cpp/dcplib/fnt_test.cc kos/examples/dreamcast/cpp/gltest/gltest.cpp kos/examples/dreamcast/cpp/modplug_test/example.cpp kos/examples/dreamcast/kgl/basic/gl/gltest.c kos/examples/dreamcast/kgl/basic/scissor/scissor.c kos/examples/dreamcast/kgl/basic/texenv/texenv.c kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c kos/examples/dreamcast/kgl/basic/vq/vq-example.c kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp Added Paths: ----------- kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m Modified: kos/examples/dreamcast/2ndmix/2ndmix.c =================================================================== --- kos/examples/dreamcast/2ndmix/2ndmix.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/2ndmix/2ndmix.c 2009-02-03 01:33:58 UTC (rev 619) @@ -780,7 +780,8 @@ /* Main program: init and loop drawing polygons */ int main() { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; printf("2ndMix/KallistiOS starting\n"); @@ -797,10 +798,14 @@ printf("Starting display\n"); while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; + if((cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER)) != NULL) { + state = (cont_state_t *)maple_dev_status(cont); + + if(state == NULL) + break; + if(state->buttons & CONT_START) + break; + } draw_one_frame(); } Modified: kos/examples/dreamcast/cpp/clock/clock.cc =================================================================== --- kos/examples/dreamcast/cpp/clock/clock.cc 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/clock/clock.cc 2009-02-03 01:33:58 UTC (rev 619) @@ -120,27 +120,29 @@ case, but it's nice and verbose. */ int read_input () { - uint8 mcont = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) - { - return 0; - } + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(!cont) + { + return 0; + } /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond)) - { - printf("Error getting controller status\n"); - return 1; - } + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + { + printf("Error getting controller status\n"); + return 1; + } - if (!(cond.buttons & CONT_START)) - { - printf("Pressed start\n"); - return 1; - } + if(state->buttons & CONT_START) + { + printf("Pressed start\n"); + return 1; + } + return 0; } Modified: kos/examples/dreamcast/cpp/dcplib/fnt_test.cc =================================================================== --- kos/examples/dreamcast/cpp/dcplib/fnt_test.cc 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/dcplib/fnt_test.cc 2009-02-03 01:33:58 UTC (rev 619) @@ -161,63 +161,61 @@ pvr_scene_finish (); } - /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int read_input () { - uint8 mcont = 0; + maple_device_t *cont; + cont_state_t *state; static bool aHeldDown = false; static bool bHeldDown = false; - cont_cond_t cond; - - if (!mcont) - { - mcont = maple_first_controller(); - if (!mcont) - { - printf("No controllers attached\n"); - return 1; - } - } - + + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(!cont) + { + return 0; + } + /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond)) - { - printf("Error getting controller status\n"); - return 1; - } + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + { + printf("Error getting controller status\n"); + return 1; + } + + if(state->buttons & CONT_START) + { + printf("Pressed start\n"); + return 1; + } - if (!(cond.buttons & CONT_START)) - { - printf("Pressed start\n"); - return 1; - } + if(state->buttons & CONT_A) + { + if(!aHeldDown) + { + aHeldDown = true; + switchFont (); + } + } + else + { + aHeldDown = false; + } - if (!(cond.buttons & CONT_A)) - { - if (!aHeldDown) - { - aHeldDown = true; - switchFont (); - } - } + if(state->buttons & CONT_B) + { + if(!bHeldDown) + { + bHeldDown = true; + switchFilterMode (); + } + } else - { - aHeldDown = false; - } - if (!(cond.buttons & CONT_B)) - { - if (!bHeldDown) - { - bHeldDown = true; - switchFilterMode (); - } - } - else - { - bHeldDown = false; - } + { + bHeldDown = false; + } + return 0; } Modified: kos/examples/dreamcast/cpp/gltest/gltest.cpp =================================================================== --- kos/examples/dreamcast/cpp/gltest/gltest.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/gltest/gltest.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -150,8 +150,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; float r = 0.0f; float dr = 2.0f; float z = -14.0f; @@ -193,20 +193,21 @@ new Cube(0.0f, 5.0f, 0.0f), new Cube(0.0f, -5.0f, 0.0f) }; - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) z -= 0.1f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) z += 0.1f; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { /* If manual rotation is requested, then stop the automated rotation */ dr = 0.0f; @@ -214,13 +215,13 @@ cubes[i]->rotate(- 2.0f); r -= 2.0f; } - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + if (state->buttons & CONT_DPAD_RIGHT) { dr = 0.0f; for (int i=0; i<4; i++) cubes[i]->rotate(+ 2.0f); r += 2.0f; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/cpp/modplug_test/example.cpp =================================================================== --- kos/examples/dreamcast/cpp/modplug_test/example.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/cpp/modplug_test/example.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -25,8 +25,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; uint8 *mod_buffer; uint32 hnd; char filename[]="/rd/test.s3m"; @@ -83,9 +83,10 @@ while(1) { /* Check key status */ - c = maple_first_controller(); - if (cont_get_cond(c, &cond) >= 0) { - if (!(cond.buttons & CONT_START)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + if(state && state->buttons & CONT_START) break; } Added: kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m =================================================================== (Binary files differ) Property changes on: kos/examples/dreamcast/cpp/modplug_test/romdisk/test.s3m ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: kos/examples/dreamcast/kgl/basic/gl/gltest.c =================================================================== --- kos/examples/dreamcast/kgl/basic/gl/gltest.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/gl/gltest.c 2009-02-03 01:33:58 UTC (rev 619) @@ -97,8 +97,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; float r = 0.0f; float dr = 2; float z = -14.0f; @@ -141,28 +141,30 @@ while(1) { /* Check key status */ - c = maple_first_controller(); - if (c) { - if (cont_get_cond(c, &cond) < 0) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { + state = (cont_state_t *)maple_dev_status(cont); + if(!state) { printf("Error reading controller\n"); } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) z -= 0.1f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) z += 0.1f; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { /* If manual rotation is requested, then stop the automated rotation */ dr = 0.0f; r -= 2.0f; } - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + if (state->buttons & CONT_DPAD_RIGHT) { dr = 0.0f; r += 2.0f; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/kgl/basic/scissor/scissor.c =================================================================== --- kos/examples/dreamcast/kgl/basic/scissor/scissor.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/scissor/scissor.c 2009-02-03 01:33:58 UTC (rev 619) @@ -231,8 +231,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; static GLboolean ap = GL_FALSE; /* Initialize KOS */ @@ -251,33 +251,34 @@ printf("A button selects demo.\n"); printf(" %s\n", demo[selected]); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (cond.buttons & CONT_DPAD_UP) + if (!(state->buttons & CONT_DPAD_UP)) y-=8; if (y < -224) y = -224; - if (cond.buttons & CONT_DPAD_DOWN) + if (!(state->buttons & CONT_DPAD_DOWN)) y+=8; if (y > 448) y = 448; - if (cond.buttons & CONT_DPAD_LEFT) + if (!(state->buttons & CONT_DPAD_LEFT)) x+=8; if (x > 632) x = 632; - if (cond.buttons & CONT_DPAD_RIGHT) + if (!(state->buttons & CONT_DPAD_RIGHT)) x-=8; if (x < -288) x = -288; /* Demo select button */ - if (!(cond.buttons & CONT_A) && !ap) { + if ((state->buttons & CONT_A) && !ap) { ap = GL_TRUE; selected++; selected %= NUM_DEMOS; printf(" %s\n", demo[selected]); } - if (cond.buttons & CONT_A) + if (!(state->buttons & CONT_A)) ap = GL_FALSE; Modified: kos/examples/dreamcast/kgl/basic/texenv/texenv.c =================================================================== --- kos/examples/dreamcast/kgl/basic/texenv/texenv.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/texenv/texenv.c 2009-02-03 01:33:58 UTC (rev 619) @@ -81,8 +81,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; int trans = 0; GLuint texture1, texture2, texture3; @@ -108,16 +108,17 @@ loadtxr("/rd/crate.pcx", &texture2); loadtxr_tga("/rd/kgl.tga", &texture3); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { /* This weird logic is to avoid bouncing back and forth before the user lets go of the button. */ Modified: kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c =================================================================== --- kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/texwrap/texwrap.c 2009-02-03 01:33:58 UTC (rev 619) @@ -84,8 +84,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLuint texture; /* Initialize KOS */ @@ -109,14 +109,15 @@ glClearColor(0.4f, 0.4f, 0.8f, 1.0f); - c = maple_first_controller(); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); while(1) { /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/basic/vq/vq-example.c =================================================================== --- kos/examples/dreamcast/kgl/basic/vq/vq-example.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/basic/vq/vq-example.c 2009-02-03 01:33:58 UTC (rev 619) @@ -106,8 +106,8 @@ } int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init_defaults(); @@ -134,15 +134,22 @@ return 0; } - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (!cont) { + printf("No controllers connected\n"); + break; + } + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c =================================================================== --- kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/benchmarks/quadmark/quadmark.c 2009-02-03 01:33:58 UTC (rev 619) @@ -38,14 +38,18 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (cont_get_cond(addr, &cond) < 0) - return 0; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(cond.buttons & CONT_START); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + return state->buttons & CONT_START; + } + + return 0; } pvr_poly_hdr_t hdr; Modified: kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c =================================================================== --- kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/benchmarks/trimark/trimark.c 2009-02-03 01:33:58 UTC (rev 619) @@ -1,6 +1,6 @@ /* KallistiGL ##version## - pvrmark.c + quadmark.c (c)2002 Dan Potter, Paul Boese */ @@ -38,14 +38,18 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (cont_get_cond(addr, &cond) < 0) - return 0; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(cond.buttons & CONT_START); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + return state->buttons & CONT_START; + } + + return 0; } pvr_poly_hdr_t hdr; @@ -74,12 +78,12 @@ x = rand() % 640; y = rand() % 480; z = rand() % 100 + 1; - size = rand() % 50; - col = (rand () % 255) * 0.00391f; + size = rand() % 50 + 1; + col = (rand () % 255)*0.00391f; glColor3f(col, col, col); - glVertex3f(x-size, y+size, z); glVertex3f(x-size, y-size, z); + glVertex3f(x+size, y-size, z); glVertex3f(x+size, y+size, z); } glEnd(); @@ -92,7 +96,7 @@ time_t start; void switch_tests(int ppf) { printf("Beginning new test: %d polys per frame (%d per second at 60fps)\n", - ppf, ppf * 60); + ppf*2, ppf*2*60); avgfps = -1; polycnt = ppf; } @@ -103,7 +107,7 @@ now = time(NULL); if (now >= (start + 5)) { start = time(NULL); - printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps)); + printf(" Average Frame Rate: ~%f fps (%d pps)\n", avgfps, (int)(polycnt * avgfps * 2)); switch(phase) { case PHASE_HALVE: if (avgfps < 55) { @@ -123,7 +127,7 @@ break; case PHASE_DECR: if (avgfps < 55) { - switch_tests(polycnt - 20); + switch_tests(polycnt - 30); } else { printf(" Entering PHASE_FINAL\n"); phase = PHASE_FINAL; @@ -158,3 +162,4 @@ } + Modified: kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c =================================================================== --- kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/demos/bubbles/bubbles.c 2009-02-03 01:33:58 UTC (rev 619) @@ -207,8 +207,8 @@ } void do_sphere_test() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; int mode = 0; int a_was_down = 0; @@ -225,15 +225,16 @@ else sphere_frame_trans(); - addr = maple_first_controller(); - if (addr == 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; - if (cont_get_cond(addr, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { return; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (a_was_down) continue; a_was_down = 1; mode ^= 1; Modified: kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp =================================================================== --- kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp 2008-12-04 23:39:46 UTC (rev 618) +++ kos/examples/dreamcast/kgl/demos/tunnel/tunnel.cpp 2009-02-03 01:33:58 UTC (rev 619) @@ -309,7 +309,7 @@ static float max[2] = { 0.0, 0.0 }; static float min[2] = { 255.0, 255.0 }, center[2]; -static void do_joy(cont_cond_t *cond) { +static void do_joy(cont_state_t *cond) { JOYINFO joy; @@ -352,19 +352,20 @@ } static GLboolean yp = GL_FALSE; -int do_controller(uint8 c) { +int do_controller(maple_device_t *cont) { static int dpad = 0; static int dpadrep = DPAD_REPEAT_INTERVAL; - static cont_cond_t cond; + cont_state_t *state; /* Check key status */ - if (cont_get_cond(c, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) return 0; /* DPAD Menu controls */ - if (!(cond.buttons & CONT_DPAD_UP)) { + if (state->buttons & CONT_DPAD_UP) { if (dpad == 0) { dpad |= 0x1000; if (help) { @@ -375,7 +376,7 @@ } else dpad &= ~0x1000; - if (!(cond.buttons & CONT_DPAD_DOWN)) { + if (state->buttons & CONT_DPAD_DOWN) { if (dpad == 0) { dpad |= 0x0100; if (help) { @@ -386,7 +387,7 @@ } else dpad &= ~0x0100; - if (!(cond.buttons & CONT_DPAD_LEFT)) { + if (state->buttons & CONT_DPAD_LEFT) { if (dpad == 0) { dpad |= 0x0001; if (help) { @@ -397,7 +398,7 @@ } else dpad &= ~0x0001; - if (!(cond.buttons & CONT_DPAD_RIGHT)) { + if (state->buttons & CONT_DPAD_RIGHT) { if (dpad == 0) { dpad |= 0x0010; if (help) { @@ -419,18 +420,18 @@ dpadrep = DPAD_REPEAT_INTERVAL; /* Help toggle */ - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; help = !help; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; /* Reset view */ - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) reset_view(); - do_joy(&cond); + do_joy(state); v = (float)(velocity/100.0f); @@ -443,16 +444,15 @@ extern uint8 romdisk[]; int main(void) { - uint8 c; pvr_stats_t stats; + maple_device_t *cont; do_init(); - - c = maple_first_controller(); printf("[DCTunnel] Entering Main Loop\n"); while(1) { - if (!do_controller(c)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont && !do_controller(cont)) break; /* Begin frame */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 15:59:44
|
Revision: 620 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=620&view=rev Author: ljsebald Date: 2009-02-03 15:59:40 +0000 (Tue, 03 Feb 2009) Log Message: ----------- Updating another bunch of examples to not use the old Maple API. Modified Paths: -------------- kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c kos/examples/dreamcast/libdream/keyboard/keyboard.c kos/examples/dreamcast/libdream/lcd/lcd.c kos/examples/dreamcast/libdream/mouse/mouse.c kos/examples/dreamcast/libdream/spu/spu.c kos/examples/dreamcast/libdream/ta/ta.c kos/examples/dreamcast/libdream/vmu/vmu.c Modified: kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe02/nehe02.c 2009-02-03 15:59:40 UTC (rev 620) @@ -47,8 +47,8 @@ }; int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Get basic stuff initialized */ pvr_init(¶ms); @@ -62,14 +62,16 @@ glMatrixMode(GL_MODELVIEW); glLoadIdentity(); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe05/nehe05.c 2009-02-03 15:59:40 UTC (rev 620) @@ -103,8 +103,8 @@ }; int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init(¶ms); @@ -126,14 +126,16 @@ glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe06/nehe06.c 2009-02-03 15:59:40 UTC (rev 620) @@ -103,8 +103,8 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; /* Initialize KOS */ pvr_init(¶ms); @@ -130,14 +130,16 @@ /* Set up the texture */ loadtxr("/rd/NeHe.pcx", &texture[0]); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe08/nehe08.c 2009-02-03 15:59:40 UTC (rev 620) @@ -116,16 +116,16 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean xp = GL_FALSE; GLboolean yp = GL_FALSE; GLboolean blend = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); - printf("nehe06 beginning\n"); + printf("nehe08 beginning\n"); /* Get basic stuff initialized */ glKosInit(); @@ -152,40 +152,42 @@ loadtxr("/rd/glass.pcx", &texture[1]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) z -= 0.02f; - if (!(cond.buttons & CONT_B)) + if (state->buttons & CONT_B) z += 0.02f; - if (!(cond.buttons & CONT_X) && !xp) { + if ((state->buttons & CONT_X) && !xp) { xp = GL_TRUE; filter += 1; if (filter > 1) filter = 0; } - if (cond.buttons & CONT_X) + if (!(state->buttons & CONT_X)) xp = GL_FALSE; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; blend = !blend; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) + if (state->buttons & CONT_DPAD_LEFT) yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) + if (state->buttons & CONT_DPAD_RIGHT) yspeed += 0.01f; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe09/nehe09.c 2009-02-03 15:59:40 UTC (rev 620) @@ -7,6 +7,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <GL/gl.h> #include <GL/glu.h> #include <pcx/pcx.h> @@ -113,12 +114,12 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean yp = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); printf("nehe09 beginning\n"); @@ -150,28 +151,30 @@ /* Set up the texture */ loadtxr("/rd/Star.pcx", &texture[0]); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) tilt -= 0.5f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) tilt += 0.5f; - if (!(cond.buttons & CONT_A)) + if (state->buttons & CONT_A) zoom -= 0.2f; - if (!(cond.buttons & CONT_B)) + if (state->buttons & CONT_B) zoom += 0.2f; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; twinkle = !twinkle; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe16/nehe16.c 2009-02-03 15:59:40 UTC (rev 620) @@ -122,16 +122,13 @@ KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; GLboolean xp = GL_FALSE; GLboolean yp = GL_FALSE; - GLboolean ap = GL_FALSE; - GLboolean bp = GL_FALSE; - GLboolean blend = GL_FALSE; /* Initialize KOS */ - pvr_init(¶ms); + pvr_init(¶ms); printf("nehe16 beginning\n"); @@ -167,42 +164,44 @@ loadtxr("/rd/crate.pcx", &texture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_FILTER, GL_FILTER_BILINEAR); - c = maple_first_controller(); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (z >= -15.0f) z -= 0.02f; } - if (!(cond.buttons & CONT_B)) { + if (state->buttons & CONT_B) { if (z <= 0.0f) z += 0.02f; } - if (!(cond.buttons & CONT_X) && !xp) { + if ((state->buttons & CONT_X) && !xp) { xp = GL_TRUE; - fogType = ( ++fogType ) % 3; - glFogi( GL_FOG_MODE, fogMode[fogType] ); - printf("%s\n", cfogMode[fogType]); + fogType = (fogType + 1) % 3; + glFogi( GL_FOG_MODE, fogMode[fogType] ); + printf("%s\n", cfogMode[fogType]); } - if (cond.buttons & CONT_X) + if (!(state->buttons & CONT_X)) xp = GL_FALSE; - if (!(cond.buttons & CONT_Y) && !yp) { + if ((state->buttons & CONT_Y) && !yp) { yp = GL_TRUE; fog = !fog; } - if (cond.buttons & CONT_Y) + if (!(state->buttons & CONT_Y)) yp = GL_FALSE; - if (!(cond.buttons & CONT_DPAD_UP)) + if (state->buttons & CONT_DPAD_UP) xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) + if (state->buttons & CONT_DPAD_DOWN) xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) + if (state->buttons & CONT_DPAD_LEFT) yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) + if (state->buttons & CONT_DPAD_RIGHT) yspeed += 0.01f; /* Begin frame */ Modified: kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c =================================================================== --- kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/kgl/nehe/nehe26/nehe26.c 2009-02-03 15:59:40 UTC (rev 620) @@ -9,6 +9,7 @@ #include <kos.h> #include <stdio.h> +#include <stdlib.h> #include <math.h> #include <GL/gl.h> #include <GL/glu.h> @@ -298,14 +299,14 @@ /* Vertex buffer size 512K */ 512*1024 }; -#define NOT_LAST (cond.buttons & last) +#define NOT_LAST !(state->buttons & last) extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); int main(int argc, char **argv) { - cont_cond_t cond; - uint8 c; + maple_device_t *cont; + cont_state_t *state; uint16 last = CONT_A; xrot = yrot = zrot = 0.0f; @@ -320,51 +321,51 @@ glKosInit(); initGL(); - c = maple_first_controller(); - printf("Entering main loop\n"); while(1) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + /* Check key status */ - if (cont_get_cond(c, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { printf("Error reading controller\n"); break; } - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) break; - if (!(cond.buttons & CONT_A) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_A) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph1; last = CONT_A; } - if (!(cond.buttons & CONT_X) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_X) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph2; last = CONT_X; } - if (!(cond.buttons & CONT_Y) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_Y) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph3; last = CONT_Y; } - if (!(cond.buttons & CONT_B) && !morph && NOT_LAST) { - morph = TRUE; + if ((state->buttons & CONT_B) && !morph && NOT_LAST) { + morph = TRUE; dest = &morph4; last = CONT_B; } - if (!(cond.buttons & CONT_DPAD_UP)) - xspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_DOWN)) - xspeed += 0.01f; - if (!(cond.buttons & CONT_DPAD_LEFT)) - yspeed -= 0.01f; - if (!(cond.buttons & CONT_DPAD_RIGHT)) - yspeed += 0.01f; - if (cond.rtrig > 0x7f) + if (state->buttons & CONT_DPAD_UP) + xspeed -= 0.01f; + if (state->buttons & CONT_DPAD_DOWN) + xspeed += 0.01f; + if (state->buttons & CONT_DPAD_LEFT) + yspeed -= 0.01f; + if (state->buttons & CONT_DPAD_RIGHT) + yspeed += 0.01f; + if (state->rtrig > 0x7f) zspeed += 0.01f; - if (cond.ltrig > 0x7f) + if (state->ltrig > 0x7f) zspeed -= 0.01f; - /* Begin frame */ glKosBeginFrame(); Modified: kos/examples/dreamcast/libdream/keyboard/keyboard.c =================================================================== --- kos/examples/dreamcast/libdream/keyboard/keyboard.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/keyboard/keyboard.c 2009-02-03 15:59:40 UTC (rev 620) @@ -1,29 +1,30 @@ #include <kos.h> void kb_test() { - uint8 mcont, mkb; - cont_cond_t cond; + maple_device_t *cont, *kbd; + cont_state_t *state; int k, x = 20, y = 20+24; printf("Now doing keyboard test\n"); while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; - mkb = maple_first_kb(); - if (!mkb) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + kbd = maple_enum_type(0, MAPLE_FUNC_KEYBOARD); + if (!kbd) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return; } - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); /* Check for keyboard input */ /* if (kbd_poll(mkb)) { @@ -33,6 +34,11 @@ /* Get queued keys */ while ( (k = kbd_get_key()) != -1) { + if (k == 27) { + printf("ESC pressed\n"); + return; + } + if (k > 0xff) printf("Special key %04x\n", k); @@ -44,13 +50,8 @@ y += 24; } } - - if (k == 27) { - printf("ESC pressed\n"); - break; - } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/lcd/lcd.c =================================================================== --- kos/examples/dreamcast/libdream/lcd/lcd.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/lcd/lcd.c 2009-02-03 15:59:40 UTC (rev 620) @@ -12,19 +12,20 @@ /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int check_start() { - uint8 mcont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) return 0; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return 0; } - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return 1; } Modified: kos/examples/dreamcast/libdream/mouse/mouse.c =================================================================== --- kos/examples/dreamcast/libdream/mouse/mouse.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/mouse/mouse.c 2009-02-03 15:59:40 UTC (rev 620) @@ -1,45 +1,47 @@ #include <kos.h> void mouse_test() { - mouse_cond_t mcond; - cont_cond_t cond; - uint8 mcont, mmouse; + maple_device_t *cont, *mouse; + cont_state_t *cstate; + mouse_state_t *mstate; int c = 'M', x = 20, y = 20; printf("Now doing mouse test\n"); while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; - mmouse = maple_first_mouse(); - if (!mmouse) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + mouse = maple_enum_type(0, MAPLE_FUNC_MOUSE); + if (!mouse) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) { + cstate = (cont_state_t *)maple_dev_status(cont); + if (!cstate) { printf("Error getting controller status\n"); return; } - if (!(cond.buttons & CONT_START)) { + if (cstate->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); /* Check for mouse input */ - if (mouse_get_cond(mmouse, &mcond) < 0) + mstate = (mouse_state_t *)maple_dev_status(mouse); + if (!mstate) continue; /* Move the cursor if applicable */ - if (mcond.dx || mcond.dy || mcond.dz) { + if (mstate->dx || mstate->dy || mstate->dz) { vid_clear(0,0,0); - x += mcond.dx; - y += mcond.dy; - c += mcond.dz; + x += mstate->dx; + y += mstate->dy; + c += mstate->dz; bfont_draw(vram_s + (y*640+x), 640, 0, c); } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/spu/spu.c =================================================================== --- kos/examples/dreamcast/libdream/spu/spu.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/spu/spu.c 2009-02-03 15:59:40 UTC (rev 620) @@ -32,23 +32,24 @@ } void wait_start() { - uint8 mcont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; while (1) { - mcont = maple_first_controller(); - if (!mcont) continue; + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { printf("Pressed start\n"); return; } - usleep(10 * 1000); + thd_sleep(10); } } Modified: kos/examples/dreamcast/libdream/ta/ta.c =================================================================== --- kos/examples/dreamcast/libdream/ta/ta.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/ta/ta.c 2009-02-03 15:59:40 UTC (rev 620) @@ -6,18 +6,20 @@ /* This is really more complicated than it needs to be in this particular case, but it's nice and verbose. */ int check_start() { - uint8 mcont = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - mcont = maple_first_controller(); - if (!mcont) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) return 0; /* Check for start on the controller */ - if (cont_get_cond(mcont, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return 0; - - if (!(cond.buttons & CONT_START)) { + } + + if (state->buttons & CONT_START) { printf("Pressed start\n"); return 1; } @@ -26,7 +28,6 @@ } - /* A little test program -- creates twelve rainbow polygons and moves them around over a color-shifting background. */ typedef struct { Modified: kos/examples/dreamcast/libdream/vmu/vmu.c =================================================================== --- kos/examples/dreamcast/libdream/vmu/vmu.c 2009-02-03 01:33:58 UTC (rev 619) +++ kos/examples/dreamcast/libdream/vmu/vmu.c 2009-02-03 15:59:40 UTC (rev 620) @@ -10,7 +10,7 @@ /* Draws one file entry, along with its "description" in the boot rom file manager. */ int y1 = 20+36; -void draw_one(uint8 addr, char *fn, uint16 hdrblock) { +void draw_one(maple_device_t *addr, char *fn, uint16 hdrblock) { bfont_draw_str(vram_s+y1*640+10, 640, 0, "File "); bfont_draw_str(vram_s+y1*640+10+5*12, 640, 0, fn); @@ -31,7 +31,7 @@ /* We only do the monochrome one here to avoid having to parse through the FAT. */ -void draw_icondata(uint8 addr, uint16 block) { +void draw_icondata(maple_device_t *addr, uint16 block) { uint8 buf[512], *icon; uint16 *buf16 = (uint16*)buf, *vr = vram_s + 20*640+20; uint16 monoicon; @@ -62,7 +62,8 @@ /* The full read test */ void vmu_read_test() { int i, n, drawn = 0; - uint8 addr = maple_first_vmu(), *ent; + maple_device_t *addr = maple_enum_type(0, MAPLE_FUNC_MEMCARD); + uint8 *ent; uint8 buf[512]; uint16 *buf16 = (uint16*)buf, dirblock, dirlength, *ent16; @@ -128,7 +129,7 @@ /* Do VMU read test */ vmu_read_test(); - usleep(5 * 1000 * 1000); + thd_sleep(5 * 1000); return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2009-02-03 18:28:57
|
Revision: 621 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=621&view=rev Author: ljsebald Date: 2009-02-03 18:28:53 +0000 (Tue, 03 Feb 2009) Log Message: ----------- More examples claned to not use the old Maple API. Modified Paths: -------------- kos/examples/dreamcast/modem/basic/example1.c kos/examples/dreamcast/parallax/bubbles/bubbles.c kos/examples/dreamcast/pvr/pvrmark/pvrmark.c kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c kos/examples/dreamcast/sound/hello-mp3/mp3test.c kos/examples/dreamcast/sound/hello-ogg/vorbistest.c kos/examples/dreamcast/vmu/vmu_pkg/vmu.c Modified: kos/examples/dreamcast/modem/basic/example1.c =================================================================== --- kos/examples/dreamcast/modem/basic/example1.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/modem/basic/example1.c 2009-02-03 18:28:53 UTC (rev 621) @@ -14,11 +14,21 @@ int buttonPressed(int button) { - cont_cond_t controller; + maple_device_t *cont; + cont_state_t *state; - cont_get_cond(maple_addr(0, 0), &controller); + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); - return !(controller.buttons & button); + if (cont) + { + state = (cont_state_t *)maple_dev_status(cont); + if (state) + { + return state->buttons & button; + } + } + + return 0; } int main() Modified: kos/examples/dreamcast/parallax/bubbles/bubbles.c =================================================================== --- kos/examples/dreamcast/parallax/bubbles/bubbles.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/parallax/bubbles/bubbles.c 2009-02-03 18:28:53 UTC (rev 621) @@ -169,8 +169,8 @@ } void do_sphere_test() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; int mode = 0; int a_was_down = 0; @@ -186,15 +186,16 @@ else sphere_frame_trans(); - addr = maple_first_controller(); - if (addr == 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; - if (cont_get_cond(addr, &cond) < 0) + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) { + if (state->buttons & CONT_START) { return; } - if (!(cond.buttons & CONT_A)) { + if (state->buttons & CONT_A) { if (a_was_down) continue; a_was_down = 1; mode ^= 1; Modified: kos/examples/dreamcast/pvr/pvrmark/pvrmark.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark/pvrmark.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark/pvrmark.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark_strips/pvrmark_strips.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c =================================================================== --- kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/pvr/pvrmark_strips_direct/pvrmark_strips_direct.c 2009-02-03 18:28:53 UTC (rev 621) @@ -5,6 +5,7 @@ */ #include <kos.h> +#include <stdlib.h> #include <time.h> pvr_init_params_t pvr_params = { @@ -37,15 +38,16 @@ int check_start() { - uint8 addr; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; - addr = maple_first_controller(); - if (addr) { - if (cont_get_cond(addr, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (cont) { + state = (cont_state_t *)maple_dev_status(cont); + if (!state) return 0; - return !(cond.buttons & CONT_START); + return (state->buttons & CONT_START); } else return 0; } Modified: kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c =================================================================== --- kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2009-02-03 18:28:53 UTC (rev 621) @@ -229,10 +229,10 @@ } /* Handle controller input */ -static uint8 mcont = 0; void check_controller() { static int up_moved = 0, down_moved = 0, a_pressed = 0, y_pressed = 0; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; if ((!(sndoggvorbis_isplaying())) && (lst_playing != -1)) { @@ -249,14 +249,14 @@ start(lst_entries[lst_playing].fn); } } - - if (!mcont) { - mcont = maple_first_controller(); - if (!mcont) { return; } - } - if (cont_get_cond(mcont, &cond)) { return; } - if (!(cond.buttons & CONT_DPAD_UP)) { + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) { return; } + + state = (cont_state_t *)maple_dev_status(cont); + if (!state) { return; } + + if (state->buttons & CONT_DPAD_UP) { if ((framecnt - up_moved) > 10) { if (selected > 0) { selected--; @@ -267,7 +267,7 @@ up_moved = framecnt; } } - if (!(cond.buttons & CONT_DPAD_DOWN)) { + if (state->buttons & CONT_DPAD_DOWN) { if ((framecnt - down_moved) > 10) { if (selected < (num_entries - 1)) { selected++; @@ -279,7 +279,7 @@ down_moved = framecnt; } } - if (cond.ltrig > 0) { + if (state->ltrig > 0) { if ((framecnt - up_moved) > 10) { // selected -= 14; selected -= 10; @@ -289,7 +289,7 @@ up_moved = framecnt; } } - if (cond.rtrig > 0) { + if (state->rtrig > 0) { if ((framecnt - down_moved) > 10) { // selected += 14; selected += 10; @@ -301,11 +301,11 @@ down_moved = framecnt; } } - if (!(cond.buttons & CONT_B) && sndoggvorbis_isplaying()) { + if ((state->buttons & CONT_B) && sndoggvorbis_isplaying()) { stop(); } - if (!(cond.buttons & CONT_Y)) { + if (state->buttons & CONT_Y) { if ((framecnt - y_pressed) > 10) { strcat(workstring,curdir); @@ -323,7 +323,7 @@ y_pressed=framecnt; } - if (!(cond.buttons & CONT_A) && !load_queued) { + if ((state->buttons & CONT_A) && !load_queued) { if ((framecnt - a_pressed) > 10) { if (!strcmp(entries[selected].fn, "Error!")) Modified: kos/examples/dreamcast/sound/hello-mp3/mp3test.c =================================================================== --- kos/examples/dreamcast/sound/hello-mp3/mp3test.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/hello-mp3/mp3test.c 2009-02-03 18:28:53 UTC (rev 621) @@ -25,7 +25,8 @@ int main(int argc, char **argv) { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; print_d("mp3 Decoder Library Example Program\n\n"); @@ -45,24 +46,30 @@ while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; - if (!(cond.buttons & CONT_Y)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if(cont) { - printf("main: restarting oggvorbis\r\n"); - mp3_stop(); - mp3_start("/rd/test.mp3",0); + state = (cont_state_t *)maple_dev_status(cont); + if (!state) + break; + if (state->buttons & CONT_START) + break; + if (state->buttons & CONT_Y) + { + printf("main: restarting mp3\r\n"); + mp3_stop(); + mp3_start("/rd/test.mp3",0); + } + // timer_spin_sleep(10); <-- causes infinite loop sometimes! + thd_sleep(10); + /* bitratenew=sndoggvorbis_getbitrate(); + if (bitratenew != bitrateold) + { + printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); + bitrateold = bitratenew; + } */ } - // timer_spin_sleep(10); <-- causes infinite loop sometimes! - thd_sleep(10); - /* bitratenew=sndoggvorbis_getbitrate(); - if (bitratenew != bitrateold) - { - printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); - bitrateold = bitratenew; - } */ } mp3_stop(); Modified: kos/examples/dreamcast/sound/hello-ogg/vorbistest.c =================================================================== --- kos/examples/dreamcast/sound/hello-ogg/vorbistest.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/sound/hello-ogg/vorbistest.c 2009-02-03 18:28:53 UTC (rev 621) @@ -23,7 +23,8 @@ int main(int argc, char **argv) { - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; print_d("Vorbis Decoder Library Example Program\n\n"); @@ -43,24 +44,30 @@ while(1) { - if (cont_get_cond(maple_first_controller(), &cond) < 0) - break; - if (!(cond.buttons & CONT_START)) - break; - if (!(cond.buttons & CONT_Y)) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + + if (cont) { - printf("main: restarting oggvorbis\r\n"); - sndoggvorbis_stop(); - sndoggvorbis_start("/rd/test.ogg",0); + state = (cont_state_t *)maple_dev_status(cont); + if(!state) + break; + if (state->buttons & CONT_START) + break; + if (state->buttons & CONT_Y) + { + printf("main: restarting oggvorbis\r\n"); + sndoggvorbis_stop(); + sndoggvorbis_start("/rd/test.ogg",0); + } + // timer_spin_sleep(10); <-- causes infinite loop sometimes! + thd_sleep(10); + bitratenew=sndoggvorbis_getbitrate(); + if (bitratenew != bitrateold) + { + printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); + bitrateold = bitratenew; + } } - // timer_spin_sleep(10); <-- causes infinite loop sometimes! - thd_sleep(10); - bitratenew=sndoggvorbis_getbitrate(); - if (bitratenew != bitrateold) - { - printf("main: Vorbisfile current bitrate %ld\r\n",bitratenew); - bitrateold = bitratenew; - } } sndoggvorbis_stop(); Modified: kos/examples/dreamcast/vmu/vmu_pkg/vmu.c =================================================================== --- kos/examples/dreamcast/vmu/vmu_pkg/vmu.c 2009-02-03 15:59:40 UTC (rev 620) +++ kos/examples/dreamcast/vmu/vmu_pkg/vmu.c 2009-02-03 18:28:53 UTC (rev 621) @@ -9,6 +9,7 @@ any other VMU file from the BIOS menus. */ #include <kos.h> +#include <kos/string.h> extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); @@ -53,19 +54,20 @@ } int wait_start() { - uint8 cont; - cont_cond_t cond; + maple_device_t *cont; + cont_state_t *state; for(;;) { new_vmu(); - - cont = maple_first_controller(); - if (cont == 0) continue; - if (cont_get_cond(cont, &cond) < 0) + cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER); + if (!cont) continue; + + state = (cont_state_t *)maple_dev_status(cont); + if (!state) continue; - if (!(cond.buttons & CONT_START)) + if (state->buttons & CONT_START) return 0; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2010-12-28 03:19:58
|
Revision: 697 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=697&view=rev Author: ljsebald Date: 2010-12-28 03:19:51 +0000 (Tue, 28 Dec 2010) Log Message: ----------- Fix up a few more examples that use threads so that the new thread stuff doesn't cause problems with them directly. Modified Paths: -------------- kos/examples/dreamcast/network/httpd/httpd.c kos/examples/dreamcast/network/httpd/simhost.c kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c Modified: kos/examples/dreamcast/network/httpd/httpd.c =================================================================== --- kos/examples/dreamcast/network/httpd/httpd.c 2010-12-28 03:09:03 UTC (rev 696) +++ kos/examples/dreamcast/network/httpd/httpd.c 2010-12-28 03:19:51 UTC (rev 697) @@ -207,7 +207,7 @@ #define BUFSIZE (256*1024) -void client_thread(void *p) { +void *client_thread(void *p) { http_state_t * hs = (http_state_t *)p; char * buf, * ext; const char * ct; @@ -277,6 +277,7 @@ st_destroy(hs); if (f >= 0) fs_close(f); + return NULL; } /**********************************************************************/ @@ -361,7 +362,7 @@ if (hs->socket < 0) { st_destroy(hs); } else { - hs->thd = thd_create(client_thread, hs); + hs->thd = thd_create(1, client_thread, hs); // hs->thd = sys_thread_new(client_thread, hs, 0); } /* else if (ioctl(hs->socket, FIONBIO, &tmp) < 0) { Modified: kos/examples/dreamcast/network/httpd/simhost.c =================================================================== --- kos/examples/dreamcast/network/httpd/simhost.c 2010-12-28 03:09:03 UTC (rev 696) +++ kos/examples/dreamcast/network/httpd/simhost.c 2010-12-28 03:19:51 UTC (rev 697) @@ -6,14 +6,15 @@ KOS_INIT_ROMDISK(romdisk); void httpd(); -void do_httpd(void * foo) { +void *do_httpd(void * foo) { httpd(); + return NULL; } int main(int argc, char **argv) { net_init(); lwip_kos_init(); - thd_create(do_httpd, NULL); + thd_create(1, do_httpd, NULL); vid_clear(50,0,70); bfont_draw_str(vram_s + 20*640+20, 640, 0, "KOSHttpd active"); Modified: kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c =================================================================== --- kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2010-12-28 03:09:03 UTC (rev 696) +++ kos/examples/dreamcast/sound/ghettoplay-vorbis/songmenu.c 2010-12-28 03:19:51 UTC (rev 697) @@ -104,7 +104,7 @@ } -static void load_song_list(void * p) { +static void *load_song_list(void * p) { file_t d; d = fs_open(curdir, O_RDONLY | O_DIR); @@ -117,7 +117,7 @@ strcpy(entries[0].fn,"Error!"); entries[0].size = 0; mutex_unlock(mut); - return; + return NULL; } } { @@ -142,6 +142,7 @@ } fs_close(d); load_queued = 0; + return NULL; } /* Draws the song listing */ @@ -406,7 +407,7 @@ /* If we don't have a file listing, get it now */ if (num_entries == 0 && !load_queued) { load_queued = 1; - thd_create(load_song_list, NULL); + thd_create(1, load_song_list, NULL); } /* if (load_queued) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ljs...@us...> - 2012-04-09 17:49:36
|
Revision: 760 http://cadcdev.svn.sourceforge.net/cadcdev/?rev=760&view=rev Author: ljsebald Date: 2012-04-09 17:49:30 +0000 (Mon, 09 Apr 2012) Log Message: ----------- Fix compilation of two examples that didn't compile before. Modified Paths: -------------- kos/examples/dreamcast/conio/adventure/hdr.h kos/examples/dreamcast/conio/adventure/init.c kos/examples/dreamcast/conio/adventure/main.c kos/examples/dreamcast/network/httpd/httpd.c kos/examples/dreamcast/network/httpd/simhost.c Modified: kos/examples/dreamcast/conio/adventure/hdr.h =================================================================== --- kos/examples/dreamcast/conio/adventure/hdr.h 2012-04-09 12:08:51 UTC (rev 759) +++ kos/examples/dreamcast/conio/adventure/hdr.h 2012-04-09 17:49:30 UTC (rev 760) @@ -185,7 +185,7 @@ int forced (int locc); void getin (char **wrd1, char **wrd2); int here (int objj); -void init (void); +void my_init (void); void juggle (int); int liq (void); int liqloc (int locc); Modified: kos/examples/dreamcast/conio/adventure/init.c =================================================================== --- kos/examples/dreamcast/conio/adventure/init.c 2012-04-09 12:08:51 UTC (rev 759) +++ kos/examples/dreamcast/conio/adventure/init.c 2012-04-09 17:49:30 UTC (rev 760) @@ -60,7 +60,7 @@ static void linkdata (void); void -init() /* everything for 1st time run */ +my_init() /* everything for 1st time run */ { rdata(); /* read data from orig. file */ linkdata(); Modified: kos/examples/dreamcast/conio/adventure/main.c =================================================================== --- kos/examples/dreamcast/conio/adventure/main.c 2012-04-09 12:08:51 UTC (rev 759) +++ kos/examples/dreamcast/conio/adventure/main.c 2012-04-09 17:49:30 UTC (rev 760) @@ -80,7 +80,7 @@ setgid(getgid()); #endif - init(); /* Initialize everything */ + my_init(); /* Initialize everything */ /* signal(SIGINT,trapdel); */ #if 0 Modified: kos/examples/dreamcast/network/httpd/httpd.c =================================================================== --- kos/examples/dreamcast/network/httpd/httpd.c 2012-04-09 12:08:51 UTC (rev 759) +++ kos/examples/dreamcast/network/httpd/httpd.c 2012-04-09 17:49:30 UTC (rev 760) @@ -4,9 +4,9 @@ Copyright (C)2003 Dan Potter */ -#include <kos.h> #include <lwip/lwip.h> #include <lwip/sockets.h> +#include <stdio.h> #include <sys/queue.h> struct http_state; Modified: kos/examples/dreamcast/network/httpd/simhost.c =================================================================== --- kos/examples/dreamcast/network/httpd/simhost.c 2012-04-09 12:08:51 UTC (rev 759) +++ kos/examples/dreamcast/network/httpd/simhost.c 2012-04-09 17:49:30 UTC (rev 760) @@ -1,9 +1,14 @@ -#include <kos.h> #include <lwip/lwip.h> -#include <unistd.h> +#include <kos/thread.h> +#include <dc/video.h> +#include <dc/biosfont.h> +#include <dc/maple.h> +#include <dc/maple/controller.h> + extern uint8 romdisk[]; KOS_INIT_ROMDISK(romdisk); +KOS_INIT_FLAGS(INIT_DEFAULT | INIT_NET); void httpd(); void *do_httpd(void * foo) { @@ -12,7 +17,6 @@ } int main(int argc, char **argv) { - net_init(); lwip_kos_init(); thd_create(1, do_httpd, NULL); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |