-
Notifications
You must be signed in to change notification settings - Fork 10
/
script05.s
115 lines (102 loc) · 3.13 KB
/
script05.s
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
include macros.s
include mainsym.s
; Script 5, code entry
numberIndex = menuCounter
org scriptCodeStart
dc.w EnterCode
dc.w EnterCodeLoop
; Enter keypad code script
;
; Parameters: -
; Returns: -
; Modifies: various
EnterCode: lda #0
ldx #2
EC_Reset: sta codeEntry,x
dex
bpl EC_Reset
lda #<EP_ENTERCODELOOP
ldx #>EP_ENTERCODELOOP
jsr SetScript
ldx #MENU_INTERACTION
jmp SetMenuMode
; Enter keypad code interaction loop
;
; Parameters: -
; Returns: -
; Modifies: various
EnterCodeLoop: gettext txtEnterCode
jsr PrintPanelTextIndefinite
ldy #$00
ldx #20
ECL_Redraw: cpy numberIndex
beq ECL_HasDigit
bcs ECL_EmptyDigit
ECL_HasDigit: lda codeEntry,y
ora #$30
skip2
ECL_EmptyDigit: lda #"-"
jsr PrintPanelChar
inx
iny
cpy #3
bcc ECL_Redraw
CheckForExit: lda joystick
and #JOY_DOWN
bne ECL_Finish
lda keyType
bpl ECL_Finish
jsr MenuControl
ldx numberIndex
lsr
bcs ECL_MoveLeft
lsr
bcs ECL_MoveRight
jsr GetFireClick
bcs ECL_Next
ECL_Done: rts
ECL_MoveLeft: lda #$fe ;C=1
skip2
ECL_MoveRight: lda #$00 ;C=1
adc codeEntry,x
bmi ECL_OverNeg
cmp #10
bcc ECL_NotOver
lda #0
skip2
ECL_OverNeg: lda #9
ECL_NotOver: sta codeEntry,x
ECL_Sound: lda #SFX_SELECT
jmp PlaySfx
ECL_Next: jsr ECL_Sound
inx
stx numberIndex
cpx #3
bcc ECL_Done
ldx #MAX_CODES-1
ECL_Verify: lda lvlObjNum
cmp codeObject,x ;All object numbers for code doors are unique, don't
beq ECL_VerifyFound ;need to check level
dex
bpl ECL_Verify ;This should never exit the loop
ECL_VerifyFound:txa
sta temp1
asl
adc temp1
tay
ldx #$00
ECL_VerifyLoop: lda codeEntry,x
cmp codes,y
bne ECL_Finish
iny
inx
cpx #$03
bcc ECL_VerifyLoop
jsr OO_RequirementOK ;Open the door if code right
ECL_Finish: jsr StopScript
jmp SetMenuMode ;X=0 on return
; Code entry object numbers
codeObject: dc.b $12,$29,$27,$16,$26,$22,$08,$31
; Messages
txtEnterCode: dc.b "ENTER CODE",0
checkscriptend