diff --git a/tfv/tfv_worldmap.s b/tfv/tfv_worldmap.s index 83fd86c9..cce5241d 100644 --- a/tfv/tfv_worldmap.s +++ b/tfv/tfv_worldmap.s @@ -1,6 +1,14 @@ ODD EQU $7B DIRECTION EQU $7C REFRESH EQU $7D +ON_BIRD EQU $7E +MOVED EQU $7F +STEPS EQU $80 +TFV_X EQU $81 +TFV_Y EQU $82 +NEWX EQU $83 +NEWY EQU $84 + ; In Town @@ -49,42 +57,221 @@ world_map: lda #$0 sta ODD + sta ON_BIRD lda #$1 sta DIRECTION sta REFRESH + lda #15 + sta TFV_X + + lda #20 + sta TFV_Y + + ;================== + ; MAIN LOOP + ;================== + worldmap_loop: + lda #$0 + sta MOVED + lda TFV_X + sta NEWX + lda TFV_Y + sta NEWY + worldmap_keyboard: - jsr get_key ; get keypress + jsr get_key ; get keypress lda LASTKEY - cmp #('Q') ; if quit, then return - bne worldmap_check_up +worldmap_handle_q: + cmp #('Q') ; if quit, then return + bne worldmap_handle_up rts -worldmap_check_up: +worldmap_handle_up: + cmp #('W') + bne worldmap_handle_down + dec NEWY + dec NEWY + inc MOVED + +worldmap_handle_down: + cmp #('S') + bne worldmap_handle_left + + inc NEWY + inc NEWY + inc MOVED + +worldmap_handle_left: + cmp #('A') + bne worldmap_handle_right + + + +worldmap_handle_right: + cmp #('D') + bne worldmap_handle_enter + +worldmap_handle_enter: + cmp #13 + bne worldmap_handle_help + + ; jsr city_map + inc REFRESH + +worldmap_handle_help: + cmp #('H') + bne worldmap_handle_battle + + ; jsr print_help + +worldmap_handle_battle: + cmp #('B') + bne worldmap_handle_info + + ; jsr do_battle + inc REFRESH + +worldmap_handle_info: + cmp #('I') + bne worldmap_handle_map + + ; jsr print_info + inc REFRESH + +worldmap_handle_map: + cmp #('M') + bne worldmap_done_keyboard + + ; jsr show_map + inc REFRESH + +worldmap_done_keyboard: + + ;=========================== + ; Handle Movement + ;=========================== + + lda MOVED + bne worldmap_refresh_screen + inc ODD + inc STEPS + + ; Handle Collision Detection + + + + ;============================ + ; Refresh screen if needed + ;============================ +worldmap_refresh_screen: lda REFRESH beq worldmap_copy_background - jsr load_map_bg - dec REFRESH worldmap_copy_background: + + ; Copy background + jsr gr_copy_to_current + + ; Handle ground scatter + + ; Draw background trees + + ; Draw TFV + + lda #1 + bit ODD + bne standing + +walking: + lda DIRECTION + bne walking_right +walking_left: + lda #>tfv_walk_left + sta INH + lda #tfv_walk_right + sta INH + lda #tfv_stand_left + sta INH + lda #tfv_stand_right + sta INH + lda #=60) { + ; steps=0; + ; time_minutes++; + ; if (time_minutes>=60) { + ; time_hours++; + ; time_minutes=0; + ; } + ; } + jmp worldmap_loop + load_map_bg: lda #$0c