aboutsummaryrefslogtreecommitdiff
path: root/shared/diskun.s
blob: 83497489a3c8de13c9f05eafce23933cba52012a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
;;; Simple sprite that can be moved with the dpad easily. Use it to have
;;; something funny moving.

.include "joypad.s"

.scope Diskun
    m_screen_x = $30
    m_screen_y = $31

    .proc init_palettes
        lda #$3F
        sta $2006                   ; PPUADDR
        lda #$00
        sta $2006                   ; PPUADDR

        ldx #0
    @load_palettes_loop:
        lda palettes, x
        sta $2007                   ; PPUDATA
        inx
        cpx #$20
        bne @load_palettes_loop
        rts
    palettes:
        DEFAULT_COLOR = $11

        ;; Background
        .byte DEFAULT_COLOR, $36, $17, $0F
        .byte DEFAULT_COLOR, $28, $0F, $30
        .byte DEFAULT_COLOR, $20, $0F, $30
        .byte DEFAULT_COLOR, $2F, $20, $30

        ;; Foreground
        .byte DEFAULT_COLOR, $28, $0F, $30
        .byte DEFAULT_COLOR, $00, $00, $00
        .byte DEFAULT_COLOR, $00, $00, $00
        .byte DEFAULT_COLOR, $00, $00, $00

        rts
    .endproc

    .proc update
        lda #Joypad::BUTTON_UP
        and Joypad::m_buttons1
        beq @check_down

        dec Diskun::m_screen_y
        dec Diskun::m_screen_y
        jmp @check_left
    @check_down:
        lda #Joypad::BUTTON_DOWN
        and Joypad::m_buttons1
        beq @check_left

        inc Diskun::m_screen_y
        inc Diskun::m_screen_y
    @check_left:
        lda #Joypad::BUTTON_LEFT
        and Joypad::m_buttons1
        beq @check_right

        dec Diskun::m_screen_x
        dec Diskun::m_screen_x
    @check_right:
        lda #Joypad::BUTTON_RIGHT
        and Joypad::m_buttons1
        beq @end

        inc Diskun::m_screen_x
        inc Diskun::m_screen_x
    @end:
        rts
    .endproc

    .proc nmi_update
        lda Diskun::m_screen_x
        sta $203
        sta $20B
        clc
        adc #8
        sta $207
        sta $20F

        lda Diskun::m_screen_y
        sta $200
        sta $204
        clc
        adc #8
        sta $208
        sta $20C

        rts
    .endproc
.endscope