diff --git a/src/game_vdp_graphics.h b/src/game_vdp_graphics.h index 3a4ee0c..7aa3be8 100644 --- a/src/game_vdp_graphics.h +++ b/src/game_vdp_graphics.h @@ -6,5 +6,6 @@ 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_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 58d0d0e..9fb8d17 100644 --- a/src/game_vdp_graphics.s +++ b/src/game_vdp_graphics.s @@ -10,6 +10,87 @@ NUM_TILE_OFFSET: .equ 0x14 .section code,text +vdp_draw_joystick: +T_NT_IDX$: .equ _Zp+4 +P_POS$: .equ _Zp+2 +T_Y$: .equ _Zp+1 +T_X$: .equ _Zp+0 + + ldx #0 + stx zp:T_NT_IDX$ + pha + + ; Clear the table + lda #29 + sta zp:T_X$ + lda #16 + sta zp:T_Y$ + jsr vdp_point_to_vram_xy + lda #0 + sta VDP_MEM + + lda #29 + sta zp:T_X$ + lda #18 + sta zp:T_Y$ + jsr vdp_point_to_vram_xy + lda #0 + sta VDP_MEM + + lda #28 + sta zp:T_X$ + lda #17 + sta zp:T_Y$ + jsr vdp_point_to_vram_xy + lda #0 + sta VDP_MEM + sta VDP_MEM + sta VDP_MEM + + ; Jump to the correct code to handle joystick drawing + pla + asl a + tax + lda _draw_joystick_jumptable$,x + sta zp:_Zp+0 + lda _draw_joystick_jumptable$+1,x + sta zp:_Zp+1 + sec + jmp (_Zp+0) + +J_Center$: + ldx #29 + ldy #18 + bcs J_Done$ +J_Up$: + ldx #29 + ldy #17 + bcs J_Done$ +J_Down$: + ldx #29 + ldy #19 + bcs J_Done$ +J_Left$: + ldx #28 + ldy #18 + bcs J_Done$ +J_Right$: + ldx #30 + ldy #18 +J_Done$: + stx zp:T_X$ + sty zp:T_Y$ + jsr vdp_point_to_vram_xy + lda #120 + sta VDP_MEM + + rts +_draw_joystick_jumptable$: + .word J_Center$ + .word J_Up$ + .word J_Down$ + .word J_Left$ + .word J_Right$ vdp_clear_gamegrid: T_NT_IDX$: .equ _Zp+4