jmechner April 17, 2012
Attempted line ending fix

0 contributors

## Users on GitHub who have contributed to this file

100755 619 lines (478 sloc) 7.529 kb

- Edit this file
- Raw
- Blame
- History

    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
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    329
    330
    331
    332
    333
    334
    335
    336
    337
    338
    339
    340
    341
    342
    343
    344
    345
    346
    347
    348
    349
    350
    351
    352
    353
    354
    355
    356
    357
    358
    359
    360
    361
    362
    363
    364
    365
    366
    367
    368
    369
    370
    371
    372
    373
    374
    375
    376
    377
    378
    379
    380
    381
    382
    383
    384
    385
    386
    387
    388
    389
    390
    391
    392
    393
    394
    395
    396
    397
    398
    399
    400
    401
    402
    403
    404
    405
    406
    407
    408
    409
    410
    411
    412
    413
    414
    415
    416
    417
    418
    419
    420
    421
    422
    423
    424
    425
    426
    427
    428
    429
    430
    431
    432
    433
    434
    435
    436
    437
    438
    439
    440
    441
    442
    443
    444
    445
    446
    447
    448
    449
    450
    451
    452
    453
    454
    455
    456
    457
    458
    459
    460
    461
    462
    463
    464
    465
    466
    467
    468
    469
    470
    471
    472
    473
    474
    475
    476
    477
    478
    479
    480
    481
    482
    483
    484
    485
    486
    487
    488
    489
    490
    491
    492
    493
    494
    495
    496
    497
    498
    499
    500
    501
    502
    503
    504
    505
    506
    507
    508
    509
    510
    511
    512
    513
    514
    515
    516
    517
    518
    519
    520
    521
    522
    523
    524
    525
    526
    527
    528
    529
    530
    531
    532
    533
    534
    535
    536
    537
    538
    539
    540
    541
    542
    543
    544
    545
    546
    547
    548
    549
    550
    551
    552
    553
    554
    555
    556
    557
    558
    559
    560
    561
    562
    563
    564
    565
    566
    567
    568
    569
    570
    571
    572
    573
    574
    575
    576
    577
    578
    579
    580
    581
    582
    583
    584
    585
    586
    587
    588
    589
    590
    591
    592
    593
    594
    595
    596
    597
    598
    599
    600
    601
    602
    603
    604
    605
    606
    607
    608
    609
    610
    611
    612
    613
    614
    615
    616
    617
    618
     lst off tr on org $D000 xc off
    *-------------------------------------------------** 07/02/87** Unidisk 3.5 interface for* 18 sector read/write routine** 09/05/89 Version for //e**  Copyright 1985, 1987*  by Roland Gustafsson**-------------------------------------------------
    sigblock = 16+315
    ** Permanent vars*
    slot = $FDtrack = $FE;lastrack = $FF ;NOT USED
    * Zero page usage:
    temp = $40command = $41
    *------------------------------------------------- jmp RW18*-------------------------------------------------GS? ds 1 ;bpl if not, bmi if GS
    OFFSET = 16 ;default offset
    *-------------------------------------------------** READ/WRITE 18 sectors!*
    READ lda #1 hex 2CWRITE lda #2 sta SPcommand
    * Calculate starting block* (OFFSET+track*9)
     lda track  ;0-34 asl asl asl tax  ;x=lo
     lda #0 rol tay  ;y=hi
     txa adc track tax
     tya adc #0 tay
     txa adc #OFFSETBOFFLO = *-1 sta BLOCKLO
     tya adc #>OFFSETBOFFHI = *-1 sta BLOCKHI
    * Loop for 18 sectors, 2 at a time.
     ldy #0:0 tya pha
    * Do 2 sectors
     lda BUFTABLE,Y sta ]rbuf0 sta ]wbuf0 ldx BUFTABLE+1,Y stx ]rbuf1 stx ]wbuf1 dex cpx ]rbuf0 jsr RWSECTS
     pla tay
     bcs :rts
    * Next 2 sectors
     inc BLOCKLO bne :1 inc BLOCKHI
    :1 iny iny cpy #18 bne :0
     clc:rts rts
    *-----------** Read or write 2 sectors** If the two sectors are sequential* then just go to the Device Driver.*
    RWSECTS bne :noncont
    * We are dealing with contiguous sectors...* if aux mem is set in any way, then we must* load them using the non-contiguous routine..
     bit ]RAMread? bmi :noncont bit ]RAMwrite? bpl JMPSP
    * Non-contiguous...
    :noncont ldy SPcommand dey bne WSECTS
    * Read two non-contiguous sectors
    RSECTS lda ]rbuf0 ora ]rbuf1 clc beq :rts
     jsr JMPSPBUF bcs :rts
    * Now move them to where they belong
     ldx #$2C  ; bit ABS ldy #$99  ; sta ABS,Y
    * If this sector is to be ignored,* then change sta $FF00,Y to bit.
     sty ]rmod0 lda ]rbuf0 bne *+5 stx ]rmod0
     sty ]rmod1 lda ]rbuf1 bne *+5 stx ]rmod1
     ldy #0:0 lda BLOCKBUF,Y]rmod0 sta $FF00,Y]rbuf0 = *-1 lda BLOCKBUF+256,Y]rmod1 sta $FF00,Y]rbuf1 = *-1 iny bne :0
    :rts rts
    *-----------** Write two non-contiguous sectors*
    WSECTS ldy #0:0 lda $FF00,Y]wbuf0 = *-1 sta BLOCKBUF,Y lda $FF00,Y]wbuf1 = *-1 sta BLOCKBUF+256,Y iny bne :0
    JMPSPBUF lda #>BLOCKBUF
    *-------------------------------------------------** Jump to Smart Port driver** Enter: A - address of buffer*
    JMPSP sta SPbufhi
    * If ERROR? hi bit is set, then just return sec
     asl ERROR? bcs ]rtserr
    * Force main memory
     sta $C002 sta $C004
    * Trick here, first time through, calculates* the entry point into the SmartPort, from* then on, direct access is available.
    ]SPjsr jsr calcSPjsrSPcommand db $11 da SPcmdlist
    restAux sta $C002 lda #$11]RAMread? = *-1 bpl *+5 sta $C003
     sta $C004 lda #$11]RAMwrite? = *-1 bpl *+5 sta $C005
    ]rtserr rts
    calcSPjsr lda slot lsr lsr lsr lsr ora #$C0 sta ]SPjsr+2 sta :calcSPmod+2
    :calcSPmod lda $C5FF clc adc #3 sta ]SPjsr+1 jmp (]SPjsr+1)
    SPcmdlist db 3unit_num db 1 ;unit one db 0 ;SPbuflo=$00SPbufhi db $11BLOCKLO db $11 ;"low"BLOCKHI db $11 ;"med" db 0 ;"high" always zero!
    *------------------------------------------------- RW18** Entry point into RW18*
    RW18 pla sta GOTBYTE+1 pla sta GOTBYTE+2
     bit $CFFF
    * Remember aux memory settings
     lda $C013 sta ]RAMread? lda $C014 sta ]RAMwrite?
    * Save aux text page if running on a GS
     bit GS? bpl *+5 jsr saveTaux
    * Save zpage
     ldx #0:zsave lda 0,x sta ZPAGEBUF,x inx bne :zsave
    * Get the command
     jsr GETBYTE sta command and #$0F asl tax
     lda cmdadr,X sta :1+1 lda cmdadr+1,X sta :1+2
    :1 jsr $FFFF
    * Restore aux text page if running on a GS
     bit GS? bpl *+5 jsr restTaux
    * Restore aux memory settings
     jsr restAux
    * Restore zpage
     ldy track ldx #0:zrest lda ZPAGEBUF,x sta 0,x inx bne :zrest sty track
     lda GOTBYTE+2 pha lda GOTBYTE+1 pha
    rts rts
    cmdadr da CMdriveon da rts  ; CMDRIVOFF da CMseek da CMreadseq da CMreadgroup da CMwriteseq da CMwritegroup da CMid da CMoffset
    *------------------------------------------------- CMseek** SEEK* <check disk for lastrack?>,* <track>*
    CMseek jsr GETBYTE jsr GETBYTE sta track rts
    *------------------------------------------------- CMreadseq*------------------------------------------------- CMreadgroup** Read sequence* <buf adr>** Read group* <18 buf adr's>*
    CMreadseq ldx #1 hex 2CCMreadgroup ldx #18 jsr CMADINFO
    CMREAD2 jsr READ
    *-------------------------------------------------** READ/WRITE exit.*INCTRAK? bit command bcs WHOOP?
    * If bit 6 set, then inc track
     bvc ]rts inc track]rts rts
    * If bit 7 set then whoop speaker* WARNING:use only with READ
    WHOOP? bpl ]rts ldy #0:1 tya bit $C030:2 sec sbc #1 bne :2 dey bne :1 beq CMREAD2
    *------------------------------------------------- CMdriveon** "DriveOn" is when we check for the POP disk*
    ERROR? db 0
    CMdriveon ldy #sigblock lda #>sigblock sty BLOCKLO sta BLOCKHI
     lda #1 ;read sta SPcommand
     jsr JMPSPBUF ;read in sig block bcs :9
     ldy #-1:chksig iny lda :sig,y beq :9 eor BLOCKBUF,y beq :chksig sec
    :9 lda #0 ror sta ERROR? rts
    :sig asc 'Prince of Persia 3.5!',00
    *------------------------------------------------- CMwriteseq*------------------------------------------------- CMwritegroup** Same as READ*
    CMwriteseq ldx #1 hex 2CCMwritegroup ldx #18 jsr CMADINFO jsr WRITE jmp INCTRAK?
    *------------------------------------------------- CMid** Change offset based on ID*
    CMid jsr GETBYTE sta :IDmod+1
     ldy #-3:0 iny iny iny lda :IDlist,y beq :rts
    :IDmod cmp #$11 bne :0
     lda :IDlist+1,y sta BOFFLO lda :IDlist+2,y sta BOFFHI
    :rts rts
    :IDlist db $A9 dw 16 ;side one
     db $AD dw 16+315+1 ;side two
     db $79 dw 16+315+1+315 ;side three!!!
     db 0 ;end of list
    *-------------------------------------------------** Set new block offset*
    CMoffset jsr GETBYTE sta BOFFLO jsr GETBYTE sta BOFFHI rts
    *-------------------------------------------------** Get buffer info.*
    CMADINFO stx temp ldx #0:0 jsr GETBYTE jsr auxTfix sta BUFTABLE,X inx cpx temp bcc :0 tay
    * If sequence, then fill table
    :1 iny cpx #18 beq :2 tya jsr auxTfix sta BUFTABLE,X inx bne :1
    :2 rts
    *-------------------------------------------------** Only if running on a GS:** If loading into text page, then change to* load into internal buffer instead.*
    auxTfix bit GS? bpl :0
     cmp #4 bcc :0 cmp #8 bcs :0 adc #>auxTPAGEsave-$400
    :0 rts
    *-------------------------------------------------** Only if running on a GS:** Save the aux memory text page to internal buffer*
     xc xc
    saveTaux clc xce rep $30 ldx #$0400 ldy #auxTPAGEsave lda #$400-1 phb mvn $10400,0 plb sec xce rts
    *-------------------------------------------------** Only if running on a GS:** Restore aux text page from internal buffer
    restTaux clc xce rep $30 ldx #auxTPAGEsave ldy #$0400 lda #$400-1 phb mvn 0,$10400 plb sec xce rts
     xc off
    *-------------------------------------------------
    GETBYTE inc GOTBYTE+1 bne GOTBYTE inc GOTBYTE+2GOTBYTE lda $FFFF rts
    *-------------------------------------------------
     sav rw1835.pop
    *-------------------------------------------------
     lst on
    ZPAGEBUF ds $100BUFTABLE ds 18 ds \BLOCKBUF ds 512
    auxTPAGEsave ds 1024
     da *
     lst off
    *------------------------------------------------- EOF

## Keyboard Shortcuts (see all)

### Site wide shortcuts

s
  Focus site search

?
  Bring up this help dialog

### Commit list

j
  Move selection down

k
  Move selection up

c or o or enter
  Open commit

y
  Expand URL to its canonical form

### Pull request list

j
  Move selection down

k
  Move selection up

o or enter
  Open issue

⌘ctrl + enter
  Submit comment

### Issues

j
  Move selection down

k
  Move selection up

x
  Toggle selection

o or enter
  Open issue

⌘ctrl + enter
  Submit comment

I
  Mark selection as read

U
  Mark selection as unread

y
  Remove selection from view

c
  Create issue

l
  Create label

i
  Back to inbox

u
  Back to issues

/
  Focus issues search

### Issues Dashboard

j
  Move selection down

k
  Move selection up

o or enter
  Open issue

### Network Graph

← or h
  Scroll left

→ or l
  Scroll right

↑ or k
  Scroll up

↓ or j
  Scroll down

t
  Toggle visibility of head labels

shift ← or shift h
  Scroll all the way left

shift → or shift l
  Scroll all the way right

shift ↑ or shift k
  Scroll all the way up

shift ↓ or shift j
  Scroll all the way down

### Source Code Browsing

t
  Activates the file finder

l
  Jump to line

w
  Switch branch/tag

y
  Expand URL to its canonical form

### Browsing Commits

⌘ctrl + enter
  Submit comment

escape
  Close form

## 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?

- #### GitHub Logo

  Download

- #### The Octocat

  Download