diff --git a/src/game_vdp_graphics.h b/src/game_vdp_graphics.h index e659301..a6d4c38 100644 --- a/src/game_vdp_graphics.h +++ b/src/game_vdp_graphics.h @@ -13,7 +13,7 @@ void vdp_clear_gamegrid(void); void vdp_clear_dialog(void); uint8_t vdp_draw_numtile(uint8_t type, uint8_t x, uint8_t y); -void vdp_redraw_tiles(void); +void vdp_redraw_tiles(uint8_t *grid); void vdp_draw_joystick(uint8_t position); #endif /* _GAME_VDP_GRAPHICS_HEADER_ */ diff --git a/src/game_vdp_graphics.s b/src/game_vdp_graphics.s index 1825f93..f0e9352 100644 --- a/src/game_vdp_graphics.s +++ b/src/game_vdp_graphics.s @@ -4,14 +4,52 @@ .extern _Zp .extern VDP_MEM, VDP_REG - .extern vdp_point_to_vram_xy + .extern vdp_point_to_vram_xy, vdp_hide_sprite, vdp_show_sprite, vdp_set_sprite_tile NUM_TILE_OFFSET: .equ 0x14 .section code,text vdp_redraw_tiles: - ;;; TODO +P_GRID_H$: .equ _Zp+9 +P_GRID_L$: .equ _Zp+8 + + lda zp:_Zp+0 + sta zp:P_GRID_L$ + lda zp:_Zp+1 + sta zp:P_GRID_H$ + + ldy #24 +SetSprtLoop$: + lda (zp:P_GRID_L$),y + bne SkipHide$ + pha + tya + pha + jsr vdp_hide_sprite + pla + tay + pla + jmp SkipSprite$ +SkipHide$: + pla + tay + pla + sta zp:_Zp+0 + dec zp:_Zp+0 + tya + pha + jsr vdp_set_sprite_tile + pla + tay + pha + jsr vdp_show_sprite + pla + tay +SkipSprite$: + dey + bpl SetSprtLoop$ + rts vdp_draw_joystick: diff --git a/src/vddlg_main.c b/src/vddlg_main.c index 319f829..e94c01e 100644 --- a/src/vddlg_main.c +++ b/src/vddlg_main.c @@ -36,6 +36,7 @@ void main(void) { num_to_decbuf(state_page->hi_score, 6, score_buf); decbuf_to_ascii(6, score_buf); + vdp_hide_sprites(); vdp_clear_dialog(); vdp_switch_nt(1); // Make sure VDP shows the correct dialog nametable @@ -48,17 +49,14 @@ void main(void) { switch(dld->mode) { case DLOG_MODE_WIN: snd_festive(); - //ddraw_endgame_box(1, dld->score, state_page->hi_score); vdp_print_string(1, 11, 8, "YOU WIN!!!"); break; case DLOG_MODE_LOSE: snd_sad_scale(); - //ddraw_endgame_box(-1, dld->score, state_page->hi_score); vdp_print_string(1, 11, 8, "GAME OVER!"); break; default: case DLOG_MODE_START: - //ddraw_endgame_box(0, dld->score, state_page->hi_score); vdp_print_string(1, 7, 8, "WELCOME TO TK2048!"); snd_start(); break; @@ -71,7 +69,7 @@ void main(void) { shared_page->master_command = MASTER_COMMAND_NONE; } - shared_page->next_module_idx = MODULE_GAME; // Go to the GAME module + shared_page->next_module_idx = MODULE_GAME_VDP; // Go to the GAME module gad->mode = GAME_MODE_NORMAL; // Set the proper start mode for the game while(!read_any_key() && (wait_counter != WAIT_COUNTER_END)) { @@ -80,7 +78,7 @@ void main(void) { } if (wait_counter == WAIT_COUNTER_END) { - shared_page->next_module_idx = MODULE_DEMO; // Actually go to the DEMO module + shared_page->next_module_idx = MODULE_DEMO_VDP; // Actually go to the DEMO module return; } diff --git a/src/vdgam_main.c b/src/vdgam_main.c index f4ea8da..08c0e76 100644 --- a/src/vdgam_main.c +++ b/src/vdgam_main.c @@ -54,6 +54,7 @@ void main(void) { dlog_data *gad = (dlog_data *)(shared_page->module_data); // Make sure the buffers are pointing to the correct memory and are clear + vdp_hide_sprites(); vdp_clear_gamegrid(); vdp_switch_nt(0); // Make sure VDP shows the gamegrid @@ -90,7 +91,7 @@ void main(void) { vdp_draw_joystick(JS_POS_CENTER); // Center the joystick - vdp_redraw_tiles(); + vdp_redraw_tiles(get_front_grid()); __enable_interrupts(); @@ -167,7 +168,6 @@ void main(void) { decbuf_to_ascii(6, text_buf); __disable_interrupts(); vdp_print_string(0, SCORE_TEXT_X, SCORE_TEXT_Y, (char*)text_buf); - __enable_interrupts(); break; } @@ -186,17 +186,18 @@ void main(void) { decbuf_to_ascii(6, text_buf); __disable_interrupts(); vdp_print_string(0, SCORE_TEXT_X, SCORE_TEXT_Y, (char*)text_buf); - vdp_redraw_tiles(); + vdp_redraw_tiles(get_front_grid()); __enable_interrupts(); } dld->mode = (done > 0) ? DLOG_MODE_WIN : DLOG_MODE_LOSE; dld->score = score; + vdp_redraw_tiles(get_front_grid()); + + WAIT(0xFF); + __disable_interrupts(); - - // One last update to the tiles - vdp_redraw_tiles(); return; } diff --git a/src/vdp_utils.s b/src/vdp_utils.s index 1b1c8f5..fed1fdd 100644 --- a/src/vdp_utils.s +++ b/src/vdp_utils.s @@ -282,6 +282,7 @@ VdpFound$: ;;; ;;; Clobbers: ;;; - A, Y, X +;;; - Zp 1, 2, 3, 4, 5, 6, 7 ;;; vdp_hide_sprites: ldy #0 @@ -294,6 +295,9 @@ HideLoop$: cpy #25 bne HideLoop$ + ; Make sure the table gets updated in memory + jsr _vdp_write_interleaved_sat + rts ;;; vdp_hide_sprite: