jmechner
100755 212 lines (176 sloc) 2.764 kb
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
* purple.main

 lst off

* The job of this routine is to set $DA to $01
* ( in aux-zpage!!! )

slot = $FD

*-------------------------------------------------
*
* HLS APPLE COPY PROTECTION
* COPYRIGHT (C) 1987 HLS DUPLICATION
*
* HLS 408-773-1500
*
* Modified by Roland Gustafsson 8/25/89
* for Prince of Persia copy protection.
*
*-------------------------------------------------

* ZERO PAGE

OBJSCT = $07 ;PHYSICAL SECTOR #

HDRC = $40
HDRS = HDRC+1
HDRT = HDRC+2
HDRV = HDRC+3 HEADER SECTOR
LSRETRY = HDRC+4 ;NIB READ RETRIES
PRETRY = HDRC+5 ;OBJSCT RETRIES
NPTR = HDRC+6
NPTRH = HDRC+7
MEM1 = HDRC+8
MEM2 = HDRC+9

zpage = HDRC
zpagelen = 13

*-------------------------------------------------
*
* Here is the code that ends up at $6321.
* Assemble it and run "make.purple.hex" which
* reverses the code and puts it in a text file.
*
*-------------------------------------------------

 org $2000

 da len6321

 dum $6254
zpagebuf ds zpagelen
 dend

 org $6321

strt6321 jsr swapzpage
 lda #10
 sta LSRETRY
 ldx slot
 lda $C089,X
 lda $C08E,X
 lda #:NIBS ; !!!!! LOW BYTE
 sta NPTR
 lda #>:NIBS ; !!!!! HIGH BYTE
 sta NPTRH
:AGAIN lda #$80
 sta PRETRY
:M1 dec PRETRY
 beq :LSFAIL
 jsr RADR16
 bcs :LSFAIL
 lda HDRS
 cmp #OBJSCT
 bne :M1

 ldy #0
:M2 lda $C08C,X
 bpl :M2
 dey
 beq :LSFAIL
 cmp #$D5
 bne :M2
 ldy #0

:M3 lda $C08C,X
 bpl :M3
 dey
 beq :LSFAIL
 cmp #$E7
 bne :M3

:M4 lda $C08C,X
 bpl :M4
 cmp #$E7
 bne :LSFAIL

:M5 lda $C08C,X
 bpl :M5
 cmp #$E7
 bne :LSFAIL

 lda $C08D,X
 ldy #$10
 bit $6 ;3 US. ( FOR //C)
:M6 lda $C08C,X
 bpl :M6
 dey
 beq :LSFAIL
 cmp #$EE
 bne :M6

* NOW AT 1/2 NIBBLES

 ldy #7
:M7 lda $C08C,X * READ DISK DATA
 bpl :M7
 cmp (NPTR),Y * COMPARE AGAINST TABLE
 bne :LSFAIL
 dey
 bpl :M7
 bmi :GOOD
:LSFAIL jmp :LSFAIL1

* A O K

:GOOD jsr swapzpage
 lda #0
 sta $C009-zpagelen,x
 rol
 sta $DA-zpagelen,x
 sta $C008-zpagelen,x
 clc
 rts

* FAILED

:LSFAIL1 dec LSRETRY
 beq :ERROR
 jmp :AGAIN

:NIBS db $FC,$EE,$EE,$FC
 db $E7,$EE,$FC,$E7

* Note that drive motor is still on

:ERROR
swapzpage ldx #0
:0 ldy zpagebuf,x
 lda zpage,x
 sty zpage,x
 sta zpagebuf,x
 inx
 cpx #zpagelen
 bne :0
 rts

*-------------------------------------------------
*
* Read address mark
*

RADR16 ldy #$FD ;READ ADR HDR
 sty MEM1
:RA1 iny
 bne :RA2
 inc MEM1
 beq :RAEXIT
:RA2 lda $C08C,X
 bpl :RA2
:RA3 cmp #$D5
 bne :RA1
 nop
:RA4 lda $C08C,X
 bpl :RA4
 cmp #$AA
 bne :RA3
 ldy #3
:RA5 lda $C08C,X
 bpl :RA5
 cmp #$96
 bne :RA3
 lda #0
:RA6 sta MEM2
:RA7 lda $C08C,X
 bpl :RA7
 rol
 sta MEM1
:RA8 lda $C08C,X
 bpl :RA8
 and MEM1
 sta HDRC,Y
 eor MEM2
 dey
 bpl :RA6
 tay
 nop
 clc
 rts

:RAEXIT sec
 rts

len6321 = *-strt6321

 org

*------------------------------------------------- EOF

 sav purple.main

Markdown Cheat Sheet

Format Text

Headers

# This is an <h1> tag
## This is an <h2> tag
###### This is an <h6> tag

Text styles

*This text will be italic*
_This will also be italic_
**This text will be bold**
__This will also be bold__

*You **can** combine them*

Lists

Unordered

* Item 1
* Item 2
  * Item 2a
  * Item 2b

Ordered

1. Item 1
2. Item 2
3. Item 3
   * Item 3a
   * Item 3b

Miscellaneous

Images

![GitHub Logo](/images/logo.png)
Format: ![Alt Text](url)

Links

http://github.com - automatic!
[GitHub](http://github.com)

Blockquotes

As Kanye West said:

> We're living the future so
> the present is our past.

Code Examples in Markdown

Syntax highlighting with GFM

```javascript
function fancyAlert(arg) {
  if(arg) {
    $.facebox({div:'#foo'})
  }
}
```

Or, indent your code 4 spaces

Here is a Python code example
without syntax highlighting:

    def foo:
      if not bar:
        return true

Inline code for comments

I think you should use an
`<addr>` element here instead.

Something went wrong with that request. Please try again. Dismiss

Looking for the GitHub logo?