void RedrawMain() { ResetVideo(); setupFont(); #ifndef CDROM1 set_tile_data(MB_bg); load_tile(0x1000); load_palette(0, MB_pal, 1); set_map_data(MB_map, 40, 30); load_map(0, 0, 0, 0, 40, 30); #ifdef SGFX if(sgx_detect()) { vpc_win_size(VPC_WIN_A, 0x01ff); vpc_win_size(VPC_WIN_B, 0x01ff); vpc_win_reg(VPC_WIN_A, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_B, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_AB, VDC_ON+VPC_NORM); vpc_win_reg(VPC_WIN_NONE, VDC_ON+VPC_NORM); sgx_set_screen_size(SCR_SIZE_32x32); sgx_disp_off(); sgx_set_tile_data(SMPTE75_bg); sgx_load_tile(0x1000); sgx_set_map_data(SMPTE75_map, 40, 30); sgx_load_map(0, 0, 0, 0, 40, 30); //load_palette(0, SMPTE75_pal, 16); sgx_disp_on(); sgx_scroll(40, 40); } #endif #else set_screen_size(SCR_SIZE_64x32); cd_loaddata(GPHX_OVERLAY, OFS_mainbg_PAL_bin, palCD, SIZE_mainbg_PAL_bin); load_palette(0, palCD, 1); cd_loadvram(GPHX_OVERLAY, OFS_mainbg_DATA_bin, 0x1000, SIZE_mainbg_DATA_bin); cd_loadvram(GPHX_OVERLAY, OFS_mainbg_BAT_bin, 0x0000, SIZE_mainbg_BAT_bin); #endif init_satb(); DrawSP(); satb_update(); Center224in240(); DisplaySystemInfo(); }
main() { int joie; cls(); init_satb(); reset_satb(); set_color(0,0); /* Je veux le noir */ set_color(1,511); /* Je veux le blanc */ set_font_color(1, 0); load_default_font(); put_string("TimeFend", 12, 12); put_string("First presented at AC2015", 4, 13); put_string("by Cr30s & Bjorn", 8, 15); for(;;) { joie = joy(0); if (joie & JOY_STRT) timefend(); } }
run_game() { /* init variables */ frame = 0; hero_walk_state = 0; spr_addr_hero = SPR_ADDR__HERO_D; joy1_dpad = 0; /* init sprites */ init_satb(); load_vram(SPR_ADDR__HERO_U, spr_hero_u, 0x400); load_vram(SPR_ADDR__HERO_UR, spr_hero_ur, 0x400); load_vram(SPR_ADDR__HERO_R, spr_hero_r, 0x400); load_vram(SPR_ADDR__HERO_DR, spr_hero_dr, 0x400); load_vram(SPR_ADDR__HERO_D, spr_hero_d, 0x400); load_vram(SPR_ADDR__HERO_DL, spr_hero_dl, 0x400); load_vram(SPR_ADDR__HERO_L, spr_hero_l, 0x400); load_vram(SPR_ADDR__HERO_UL, spr_hero_ul, 0x400); set_sprpal(PAL_NUM__HERO, pal_hero); /* hero sprite */ spr_set(SPR_NUM__HERO); spr_x(hero_x); spr_y(hero_y); spr_pattern(spr_addr_hero); spr_ctrl(SIZE_MAS|FLIP_MAS, SZ_32x32|NO_FLIP); spr_pal(PAL_NUM__HERO); spr_pri(1); /* font */ set_font_color(1, 0); set_font_pal(0); load_default_font(); satb_update(); vsync(); /******************************************************************************* GAME LOOP *******************************************************************************/ for(;;) { joy1 = joy(0); joy1a = joytrg(0); old_spr_addr_hero = spr_addr_hero; /* d-pad input */ #asm lda _joy1 lsr4 sta _joy1_dpad bne movement_input jmp no_movement_input movement_input: #endasm if (joy1 & JOY_UP) hero_y--; else if (joy1 & JOY_DOWN) hero_y++; if (joy1 & JOY_LEFT) hero_x--; else if (joy1 & JOY_RGHT) hero_x++; if (frame % 8 == 0) hero_walk_state++; #asm ldx _joy1_dpad ;// lower nibble of _spr_addr_hero already zeroed lda tbl_hero_spr_addr,X sta _spr_addr_hero+1 no_movement_input: #endasm /* a/b input */ if (joy1 & JOY_A) { spr_addr_hero_modifier = 0x300; if (spr_addr_hero != old_spr_addr_hero) { if (frame % 4) { spr_addr_hero = old_spr_addr_hero; } else { if (!(joy1a & JOY_A)) { spr_addr_hero = old_spr_addr_hero + 0x400; if (spr_addr_hero > 0x6C00) spr_addr_hero = 0x5000; } } } } else if (joy1 & JOY_B) { spr_addr_hero_modifier = 0x300; if (spr_addr_hero != old_spr_addr_hero) { if (frame % 4) { spr_addr_hero = old_spr_addr_hero; } else { if (!(joy1a & JOY_B)) { spr_addr_hero = old_spr_addr_hero - 0x400; if (spr_addr_hero < 0x5000) spr_addr_hero = 0x6C00; } } } } else { /* hero direction walk animation*/ if (hero_walk_state == 1) { spr_addr_hero_modifier = 0x100; } else if (hero_walk_state == 3) { spr_addr_hero_modifier = 0x200; } else{ spr_addr_hero_modifier = 0; } } spr_set(SPR_NUM__HERO); spr_pattern(spr_addr_hero + spr_addr_hero_modifier); spr_x(hero_x); spr_y(hero_y); hero_walk_state = hero_walk_state % 4; frame++; satb_update(); vsync(); } }