/* Handlers... WHY?! * GOTTA FIND A MODULAR SOLUTION!! */ void joyAtkHandler ( u16 joy, u16 joyChanged, u16 state ) { int xc = fix32ToInt(p1.x); int yc = fix32ToInt(p1.y); // Player 1 if (joy == JOY_1) { if ( (state & BUTTON_A) || (state & BUTTON_B) || (state & BUTTON_C) ) // if (state & BUTTON_B ) { if (p1_dir.y != 0) { VDP_drawText( "XXX", xc - 1, fix32ToInt(p1.y - p1_dir.y) ); VDP_drawText( "XXX", xc - 1, fix32ToInt(p1.y - 2*p1_dir.y) ); } else if (p1_dir.x != 0) { VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc - 1 ); VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc ); VDP_drawText( "XX", fix32ToInt(p1.x + 2*p1_dir.x), yc + 1 ); } } VDP_setTileMapXY( VDP_PLAN_A, 0, xc, yc ); VDP_setTileMapXY( VDP_PLAN_A, 0, fix32ToInt(p1.x + p1_dir.x), fix32ToInt(p1.y - p1_dir.y) ); } }
int main() { x=0; y=0; oldx=0; oldy=0; VDP_loadTileData( (const u32 *)tile1, 1, 1, 0); VDP_setTileMapXY(APLAN, 1, x+2, y+2); JOY_init(); JOY_setEventHandler( &myJoyHandler ); //VDP_drawText("Hello World!", x, y); while(1) { VDP_drawText(" ", oldx, oldy); VDP_drawText("Hello World!", x, y); VDP_setTileMapXY(APLAN, 1, x+2, y+2); VDP_waitVSync(); } return (0); }
u16 RSE_writerDrawString(char *str) { char c; u16 i, fade, faded_idx; for (fade = 0; fade < 4; fade++) { faded_idx = current_char_idx + fade; c = str[faded_idx]; if (fade == 0 && c == 0) return FALSE; if (c != ' ') { i = charToTileIndex(c); if (faded_idx < current_string_len && i != 0xFF) VDP_setTileMapXY(current_plan, TILE_USERINDEX + i + (FONT_LINE_OFFSET * fade), current_char_x + fade + x_offset, TILE_ATTR_FULL(current_pal, FALSE, FALSE, FALSE, current_char_y)); } } current_char_x++; current_char_idx++; return TRUE; }
void SetupForegroundLayer() { s16 tilepositionx = PIXEL_TO_TILE(-scrollData.scrollx_vdp) - 1; // divide by 8 s16 tilepositiony = PIXEL_TO_TILE(scrollData.scrolly_vdp) - 1; // // compute start and end tiles s16 starttilex = tilepositionx; s16 endtilex = (tilepositionx + TILE_UPDATE_AREA_WIDTH); s16 starttiley = tilepositiony; s16 endtiley = (tilepositiony + TILE_UPDATE_AREA_HEIGHT); s16 loop = 0; s16 innerLoop = 0; u16 tileNumber = 0; u16 arrayStart = 0; const u16 tileBaseValue = TILE_ATTR_FULL(PAL3, 0, 0, 0, 0) + foregroundLoadedTileInfo.startIndex; for (loop = starttiley; loop <= endtiley; loop++) { arrayStart = loop * levelData.foreground->width; for (innerLoop = starttilex; innerLoop <= endtilex; innerLoop++) { tileNumber = ARRAY_ITEM_VALUE(levelData.foreground->tilemap, arrayStart + innerLoop); tileNumber = GetTile(tileNumber, tileBaseValue); VDP_setTileMapXY(APLAN, tileNumber, innerLoop & 63, loop & 63); } } }
static void createPauseMenu(u8 player){ u8 x = leftEdge(player), y = Y_PAUSE; u8 i; VDP_drawText(" OPTIONS", x, y); //draw underline for (i=x+6; i<x+13; i++){ VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+4), i, y+1); } VDP_drawText("Coming soon...", x, y+2); VDP_drawText("Double-tap START", x, y+5); VDP_drawText("to resume", x, y+6); }
void text_draw ( u8 *str, u8 x, u8 y, u16 ms ) { #define POSITION _base + _positions[chr] * _tiles + inc u8 chr; u16 k; u16 j; u16 i = 0; u16 inc = 0; u8 *aux = str; while ( (chr = *aux++) ) { inc = 0; chr -= ' '; if ( chr >= 96 ) chr = 0; if ( ! _positions[chr] ) { _positions[chr] = _counter++; VDP_loadTileData ( _genres->sprites[chr], POSITION, _tiles, TRUE ); VDP_waitDMACompletion(); } } while ( (chr = *str++) ) { inc = 0; chr -= ' '; if ( chr >= 96 ) chr = 0; for ( j = 0; j < _height; j++ ) { for ( k = 0; k < _width; k++ ) { VDP_setTileMapXY ( BPLAN, TILE_ATTR_FULL ( _palette, TRUE, 0, 0, POSITION ), i*_width + x + j, y + k ); ++inc; } } waitMs ( ms ); ++i; } }
void transition_fx(u8 frames, u16 vramindex_start) { s16 i, j, k, l; u16 sw, sh; current_plan = VDP_PLAN_A; current_pal = PAL0; SYS_disableInts(); vramIndex = vramindex_start; // u16 VDP_getPlanWidth(); // u16 VDP_getPlanHeight(); VDP_drawImageEx(APLAN, &transition_pattern_0, TILE_ATTR_FULL(PAL1, FALSE, FALSE, FALSE, vramIndex), 0, 0, FALSE, FALSE); // vramIndex += transition_pattern_0.tileset->numTile; SYS_enableInts(); sw = VDP_getPlanWidth(); sh = VDP_getPlanHeight(); for(i = 0; i < sw + WIPE_TILE_WIDTH; i++) { VDP_waitVSync(); for(j = 0; j < sh; j++) for(k = 0; k < WIPE_TILE_WIDTH; k++) { l = i - k; if (l < 0) l = 0; else if (l > sw) l = sw - 1; l -= j; if (l < 0) break; else if (l > sw) break; VDP_setTileMapXY(current_plan, vramIndex + k, l, j); //TILE_ATTR_FULL(current_pal, FALSE, FALSE, FALSE, j)); } } }
void FMP_draw ( FMP *fmp, s8 x_pos, s8 y_pos, s8 x_inner, s8 y_inner, u8 width, u8 height ) { SYS_disableInts(); u16 x, y; const u16 *map = fmp->map->map ; for ( y = 0; y < height; y++ ) { u16 aux = ( y + y_inner ) * fmp->map->width + x_inner; for ( x = 0; x < width; x++ ) { u16 tile = TILE_ATTR_FULL ( fmp->pal, fmp->prio, 0, 0, map [ aux + x ] + fmp->vram ); VDP_setTileMapXY ( fmp->plan, tile, x + x_pos, y + y_pos ); } } SYS_enableInts(); }
void inline RSE_writerUpdateLine(void) { if (WRT_HAS_OPTION(WRT_OPT_HALF_SPEED)) if (writer_state == WRT_WRITE_CUR_LINE) { writer_switch = ~writer_switch; if (writer_switch) return; } if (WRT_HAS_OPTION(WRT_OPT_WRITE_TO_PLAN_A)) { current_plan = VDP_PLAN_A; current_pal = PAL0; } else { current_plan = VDP_PLAN_B; current_pal = PAL1; } switch(writer_state) { case WRT_CENTER_CUR_LINE: current_string_len = computeStringLen((char *)demo_strings[current_string_idx]); current_char_x = ((320 / 8) - current_string_len) >> 1; writer_state = WRT_WRITE_CUR_LINE; break; case WRT_WRITE_CUR_LINE: if (!RSE_writerDrawString((char *)demo_strings[current_string_idx])) { writer_timer = 0; writer_state = WRT_WAIT; } break; case WRT_WAIT: if (writer_timer++ > writer_display_duration) { writer_state = WRT_CLEAR_LINE; current_char_x = 0; } break; case WRT_CLEAR_LINE: VDP_setTileMapXY(current_plan, 0, current_char_x + x_offset, current_char_y); current_char_x++; if (current_char_x > 320 / 8) { current_char_x = 0; current_char_idx = 0; current_string_idx++; if (demo_strings[current_string_idx][0] == '\0') { writer_is_done = TRUE; if (WRT_HAS_OPTION(WRT_OPT_AUTO_RESTART)) current_string_idx = 0; else { writer_state = WRT_IDLE_MODE; return; } } else if (demo_strings[current_string_idx][0] == '\1') current_char_y = initial_char_y; writer_state = WRT_CENTER_CUR_LINE; } break; case WRT_IDLE_MODE: return; } }
void HUD_updateStatusView(u8 joy, u8 bA, u8 bB, u8 bC, u8 bStart, u8 statusCode){ u8 i,j; u8 channel; char status[20]; //for each line for (j=0;j<9;j++){ if (statusCode & statusCodes[j]){ drawStatusMsg(joy,j); } } // u16 x = X0 + (joy * (WIDTH_TILES/2)); // if (joy) x--; // u16 x = (joy * ((WIDTH_TILES-(HORIZONTAL_MARGIN*2)) / 2)) + (HORIZONTAL_MARGIN); u16 x = leftEdge(joy); u16 y = Y_STATUS; if (bStart && statusCode){ bA = bB = bC = 0; } else{ if (bA > 0) bA = 1; if (bB > 0) bB = 1; if (bC > 0) bC = 1; } //draw either grey or white circles to represent the fingering buttons VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bA), x+X_BUTTONS, y+Y_BUTTONS); VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bB), x+X_BUTTONS+2, y+Y_BUTTONS); VDP_setTileMapXY(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+bC), x+X_BUTTONS+4, y+Y_BUTTONS); char solfege[3]; u8 mode = modeList[joy][keyIndex[joy]]; u8 scalePitch = Instrument_buttonsToScalePitch(bA, bB, bC) % 7; u8 truePitch = SCALES[mode][scalePitch]; switch (scalePitch){ case 0: strcpy(solfege, "Do"); break; case 1: strcpy(solfege, (truePitch == 1) ? "Ra" : "Re"); break; case 2: strcpy(solfege, (truePitch == 3) ? "Me" : "Mi"); break; case 3: strcpy(solfege, (truePitch == 6) ? "Fi" : "Fa"); break; case 4: strcpy(solfege, (truePitch == 8) ? "Si" : (truePitch == 6) ? "Se" : "Sol"); break; case 5: strcpy(solfege, (truePitch == 10) ? "Li" : (truePitch == 8) ? "Le" : "La"); break; case 6: strcpy(solfege, (truePitch == 10) ? "Te" : "Ti"); break; default: strcpy(solfege, ""); break; } drawText(solfege, x+X_BUTTONS+6, y+Y_BUTTONS, 0, 3); // VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, 25, 1, 2); //draw musical note if (playing[joy]){ VDP_fillTileMapRectInc(APLAN, TILE_ATTR_FULL(PAL0, 0, 0, 0, TILE_USERINDEX+2), x+X_NOTE, Y_NOTE, 1, 2); } else { VDP_clearTileMapRect(APLAN, x+X_NOTE, Y_NOTE, 1, 2); } }