.main. hcd65xx v3.1 10july87 page 1 0:x571 burst.src,s,r error addr code seq source statement 1 2 ;* ------------------------ * 3 ;* 1571 BURST SUBROUTINES * 4 ;* ------------------------ * 5 ;* 6 ;* The following burst subroutines have been designed for use in * 7 ;* BASIC and machine language programs. * 8 ;* 9 ;* If you are programming in assembly language, you can use these * 10 ;* routines as is, or you can use them as a framework to build upon. * 11 ;* 12 ;* If you are programming in C128 BASIC, you should follow the * 13 ;* procedure shown below. (Note: you cannot use the burst commands * 14 ;* with the C64.) * 15 ;* 16 ;* BLOAD the binary file containing the burst routines. * 17 ;* The file name is "1571 BURST.BIN". * 18 ;* 19 ;* Assign a logical file number to the command channel to the 1571. * 20 ;* 21 ;* Open the command channel within your BASIC program. * 22 ;* 23 ;* Execute the BANK 0 command. This will tell BASIC to PEEK and * 24 ;* POKE to the RAM under the BASIC ROM. * 25 ;* 26 ;* POKE the logical file number to LF. * 27 ;* 28 ;* POKE the appropriate parameters into the proper variable * 29 ;* locations, and SYS to the desired routine. * 30 ;* 31 ;* The BURST protocol and handshaking will be done automatically. * 32 ;* The BASIC program can then PEEK any values returned. * 33 ;* 34 ;* If you are using a RAM buffer, be sure that the buffer uses only the * 35 ;* memory between the end of BASIC text and $C000. The KERNEL and I/O * 36 ;* will need the space after $C000. BASIC programs normally start at * 37 ;* $1C00. If you enable bit-map graphics, then your program will start * 38 ;* at $4000. The binary file containing these BURST routines loads at * 39 ;* $1300, so that they are in a safe place below the BASIC text area. * 40 ;* 41 ;* If you want to make your program intelligent, the pointers to the * 42 ;* exact beginning and end of the BASIC program are in locations $002D * 43 ;* and $1210 respectively. For the most part, however, there is no need * 44 ;* to look at those values. As a general rule, if you use memory * 45 ;* by working backwards from $C000, you'll be OK. When you PEEK and * 46 ;* POKE this memory from BASIC, be sure to execute the BANK 0 command. * 47 ;* This tells BASIC to PEEK and POKE to the RAM under the BASIC ROM. * 48 ;* 49 ;* NOTE: There is no BURST FORMAT routine provided here. If you need * 50 ;* do formatting then use BASIC. The following BASIC command * 51 ;* will format physical tracks 10 through 20 of the disk with 5 * 52 ;* 1024 byte MFM sectors per side (sectors 1-5). * 53 ;* 54 ;* OPEN 1,8,15 * 55 ;* PRINT#1,"U0"CHR$(38)CHR$(129)CHR$(0)CHR$(3)CHR$(10)CHR$(5) * 56 ;* CHR$(10)CHR$(10); * 57 ;* .main. hcd65xx v3.1 10july87 page 2 0:x571 burst.src,s,r error addr code seq source statement 58 ;* 59 ;* 60 ;* Note the use of the semicolon (;) at the end of the statement. This * 61 ;* is very important! If there was no semicolon, the C128 would * 62 ;* send a carriage return after the last parameter. Since the 1571 * 63 ;* counts the number of bytes sent to determine the number of optional * 64 ;* parameters that are being sent, it would misinterpret the carriage * 65 ;* return as the next optional parameter. In this case, it would be * 66 ;* fill byte. * 67 ;* * 68 69 ;********************************************************************* 70 ;* * 71 ;* VARIABLE DECLARATIONS * 72 ;* * 73 ;* These variables are parameters passed between a BURST routine and * 74 ;* its calling program. * 75 ;* * 76 ;************************************************************************ 77 78 =1300 79 *=$1300 80 1300 00 81 STATUS .byte 0 ; status byte 1301 08 82 DEV .byte 8 ; device number 1302 08 83 LF .byte 8 ; logical file number 1303 =1304 84 TRACK *=*+1 ; track 1304 =1305 85 SECTOR *=*+1 ; sector 1305 =1306 86 NUMSEC *=*+1 ; Number of sectors. 1306 =1308 87 BUFLOC *=*+2 ; Page # of buffer to get/put data. 1308 =1309 88 SECSIZE *=*+1 ; Sector size (1=256, 2=512, 4=1024) 1309 =130a 89 SIDE *=*+1 ; Physical side of the disk (0 or 1). 130a =130b 90 MINSEC *=*+1 ; Minimum logical sector found in QUERY. 130b =130c 91 MAXSEC *=*+1 ; Maximum logical sector found in QUERY. 130c =130d 92 INTLV *=*+1 ; Physical interleave found in QUERY. 130d =130e 93 FLAG *=*+1 ; Empty track flag. 94 ; This flag is used to indicate that the 95 ; track or data just read contains all 0's. This is handy in some cases, 96 ; such as during a disk copy program. When a disk is formatted, the 97 ; sectors are filled with 0's. If a sector to be copied contains 98 ; all 0's, then we don't bother to write it to the destination disk 99 100 101 ;****************************************************************** 102 ;* * 103 ;* Here are other variables used internally by the BURST routines.* 104 ;* * 105 ;****************************************************************** 106 107 130e 108 cmdline 130e 55 30 109 .byte 'u0' =131a 110 *=*+10 ; Parameter space for burst command. 131a =131b 111 cmdlen *=*+1 ; Length of the command string (# of bytes). 131b =131c 112 oldclk *=*+1 ; Status of clock line. 131c =131d 113 temp *=*+1 114 .main. hcd65xx v3.1 10july87 page 3 0:x571 burst.src,s,r error addr code seq source statement 115 116 ;************************************************************************ 117 ;* * 118 ;* JUMP TABLE * 119 ;* * 120 ;* This jump table gives the locations of each of the BURST routines. * 121 ;* The jump table positions will never change, even if the routines * 122 ;* below are modified. Always SYS to this table from BASIC, or JSR or * 123 ;* JMP to this table from assembly language. * 124 ;* * 125 ;************************************************************************ 126 =1340 127 *=$1340 128 1340 129 J_INQUIRE_FORMAT 1340 4c 146a 130 jmp INQUIRE_FORMAT 1343 131 J_PHYSICAL_READ 1343 4c 1355 132 jmp PREAD 1346 133 J_PHYSICAL_WRITE 1346 4c 13d6 134 jmp PWRITE 1349 135 J_QUERY_FORMAT 1349 4c 1493 136 jmp QUERY_FORMAT 134c 137 J_COMPARE_MEMORY 134c 4c 151b 138 jmp COMPARE_MEMORY 134f 139 J_SENDCMD 134f 4c 1555 140 jmp SENDCMD 1352 141 J_OPEN_CHANNEL 1352 4c 156e 142 jmp OPEN_CHANNEL 143 144 ;************************************************ 145 ;* * 146 ;* KERNAL EQUATES * 147 ;* * 148 ;************************************************ 149 =ffc9 150 chkout=$ffc9 ; kernel channel output routine =ffcc 151 clrchn=$ffcc ; kernel clear channel routine =ffba 152 setlfs=$ffba ; kernel set logical file # routine =ffbd 153 setnam=$ffbd ; kernel set file name routine =ffd2 154 bsout =$ffd2 ; kernel basic i/o routine =ffc0 155 open =$ffc0 ; kernel open logical file for I/O routine =ff47 156 spin_out=$ff47 ; Set up fast serial for input or output 157 ; SEC for output, CLC for input. 158 159 ;************************************************************************ 160 ;* * 161 ;* These addresses are memory locations used by the BURST subroutines. * 162 ;* * 163 ;************************************************************************ 164 =dd00 165 d2pra =$dd00 ; C128 serial port location =0010 166 clkout=$10 ; slow serial clock output bit mask =0040 167 clkin =$40 ; slow serial clock input bit mask =dc0d 168 d1icr =$dc0d ; 6526 CIA interrupt control register =dc0c 169 d1sdr =$dc0c ; 6526 CIA serial data register =00fa 170 buffer=$fa ; zero page pointer variable =00fc 171 buffer2=$fc ; zero page pointer variable .main. hcd65xx v3.1 10july87 page 4 0:x571 burst.src,s,r error addr code seq source statement 172 173 174 ;*************************************************************** 175 ;* * 176 ;* BURST COMMAND PRIMITIVES * 177 ;* * 178 ;* These are the BURST commands as the 1571 sees them. * 179 ;* * 180 ;*************************************************************** 181 182 =0000 183 PBURSTRD =$00 ; Burst read. =0002 184 PBURSTWR =$02 ; Burst write. =0004 185 BURST_INQUIRE =$04 ; Burst inquire. =0086 186 BURST_QUERY =$86 ; Query disk format. 187 188 189 ;**************************************************************** 190 ;* * 191 ;* THE BURST ROUTINES * 192 ;* * 193 ;**************************************************************** 194 195 1355 196 PREAD ;This BURST routine reads sectors from device LF. 197 ; 198 ; Required Parameters: 199 ; LF Logical file number to read from. 200 ; TRACK Track to be read from. 201 ; SECTOR Sector to be read from. 202 ; BUFLOC Pointer to the starting location of the 203 ; buffer in RAM bank 0. As the characters 204 ; are read, they are put in this buffer. 205 ; SECSIZE Physical sector size (1=256, 2=512, 4=1024) 206 ; NUMSEC The number of sectors to be read. 207 ; SIDE Physical side of the disk to read from, 208 ; 0 or 1. SIDE is ignored if the disk is GCR. 209 ; 210 ; Returned Parameters: 211 ; STATUS Status byte returned after read is attempted. 212 213 1355 a9 00 214 lda #PBURSTRD ;Physical burst read command. 1357 ae 1309 215 ldx SIDE ; Check which side to read from. 135a f0 02 216 beq 1$ 135c 09 10 217 ora #$10 ; If side 1, then set bit in the command byte. 135e 8d 1310 218 1$ sta cmdline+2 219 1361 220 READ 221 1361 ad ff00 222 lda $ff00 ;Save old MMU setup. 1364 48 223 pha 224 1365 a9 0e 225 lda #$0e ;Set MMU for RAM0,KERNEL,I/O. 1367 8d ff00 226 sta $ff00 227 136a 20 157a 228 jsr SETU0 ;Put "U0" at start of command string. .main. hcd65xx v3.1 10july87 page 5 0:x571 burst.src,s,r error addr code seq source statement 229 230 136d ad 1303 231 lda TRACK 1370 8d 1311 232 sta CMDLINE+3 ; track 1373 ad 1304 233 lda SECTOR 1376 8d 1312 234 sta CMDLINE+4 ; sector 1379 ad 1305 235 lda NUMSEC 137c 8d 1313 236 sta CMDLINE+5 ; Number of sectors to read. 237 137f a9 06 238 lda #$06 ; Length of command string. 1381 8d 131a 239 sta CMDLEN 1384 20 1555 240 jsr sendcmd ; send cmd string 241 1387 ad 1306 242 lda BUFLOC ; Set up zero page indirect pointer. 138a 85 fa 243 sta BUFFER 138c ad 1307 244 lda BUFLOC+1 138f 85 fb 245 sta BUFFER+1 246 1391 a0 00 247 ldy #0 ; clear the 'empty sector(s)' flag. 1393 8c 130d 248 sty flag 249 1396 78 250 sei ; No irq's allowed during handshake. 251 1397 2c dc0d 252 bit d1icr ; clear pending 253 139a 20 1599 254 jsr CLK_CHNG ;Change state of clock. 255 139d ae 1308 256 1$ ldx SECSIZE ; Sector size gives # of pages per sector. 257 13a0 20 15a2 258 jsr WAIT ;Wait for fast byte (1st is status). 13a3 ad dc0c 259 lda d1sdr ;Get status byte. 13a6 8d 1300 260 sta STATUS 261 13a9 29 0f 262 and #15 ;Was there an error? 13ab c9 02 263 cmp #2 ; 13ad b0 21 264 bcs 5$ ; branch if error occured. 265 13af 20 1599 266 jsr CLK_CHNG ;Change clock so next byte is sent. 267 13b2 20 15a2 268 3$ jsr WAIT ;Wait for the next byte. 269 13b5 20 1599 270 jsr CLK_CHNG ;Change state of clock so next byte is sent. 13b8 ad dc0c 271 lda D1SDR ;Get the data byte 13bb 91 fa 272 sta (buffer),y ; and save it 273 ; while next byte is being transmitted. 13bd 0d 130d 274 ora flag 13c0 8d 130d 275 sta flag ;Update 'zero' sector flag. 276 13c3 c8 277 iny ;Any more in this page? 13c4 d0 ec 278 bne 3$ 279 13c6 e6 fb 280 inc BUFFER+1 13c8 ca 281 dex ;Loop for the # of pages per sector. 13c9 d0 e7 282 bne 3$ 283 13cb ce 1313 284 dec CMDLINE+5 ;Loop for the number of sectors. 13ce d0 cd 285 bne 1$ .main. hcd65xx v3.1 10july87 page 6 0:x571 burst.src,s,r error addr code seq source statement 286 287 13d0 58 288 5$ cli 289 13d1 68 290 pla ;Restore MMU to old configuration. 13d2 8d ff00 291 sta $ff00 292 13d5 60 293 rts 294 295 ;************************************************************* 296 13d6 297 PWRITE ; This BURST subroutine writes physical sectors to device LF. 298 ; 299 ; Required Parameters: 300 ; LF Logical file number to write to. 301 ; TRACK Track to be written to. 302 ; SECTOR Sector to be written to. 303 ; BUFLOC Location of the beginning of the C128 buffer 304 ; where the characters are to be read from. 305 ; SECSIZE Physical sector size (1=256, 2=512, 4=1024). 306 ; NUMSEC The number of sectors to be written. 307 ; SIDE Physical side of the disk to write to, 308 ; 0 or 1. SIDE is ignored if the disk is GCR. 309 ; 310 ; Returned Parameters: 311 ; STATUS Status byte returned after write is attempted. 312 13d6 a9 02 313 lda #PBURSTWR ;Physical burst write command. 13d8 ae 1309 314 ldx SIDE ; Check which side to write to. 13db f0 02 315 beq 1$ 13dd 09 10 316 ora #$10 ; If side 1, then set bit in the command byte. 13df 8d 1310 317 1$ sta cmdline+2 318 319 13e2 320 WRITE 13e2 ad ff00 321 lda $ff00 ;Save old MMU setup. 13e5 48 322 pha 323 13e6 a9 0e 324 lda #$0e ;Set MMU for RAM0,KERNEL,I/O. 13e8 8d ff00 325 sta $ff00 326 13eb 20 157a 327 jsr SETU0 ;Put "U0" at start of command string. 13ee ad 1303 328 lda TRACK 13f1 8d 1311 329 sta CMDLINE+3 ; track 13f4 ad 1304 330 lda SECTOR 13f7 8d 1312 331 sta CMDLINE+4 ; sector 13fa ad 1305 332 lda NUMSEC 13fd 8d 1313 333 sta CMDLINE+5 ; Number of sectors to write. 334 1400 a9 06 335 lda #$06 1402 8d 131a 336 sta CMDLEN ;Command length. 1405 20 1555 337 jsr sendcmd ; send cmd string 338 1408 ad 1306 339 lda BUFLOC ; Set up zero page indirect pointer. 140b 85 fa 340 sta BUFFER 140d ad 1307 341 lda BUFLOC+1 1410 85 fb 342 sta BUFFER+1 .main. hcd65xx v3.1 10july87 page 7 0:x571 burst.src,s,r error addr code seq source statement 343 344 1412 a9 40 345 lda #clkin ;Initial clock status. 1414 8d 131b 346 sta oldclk 347 1417 a0 00 348 ldy #0 1419 78 349 sei ; no irq's during burst handshake 350 141a ae 1308 351 1$ ldx SECSIZE ; Sector size gives # of pages per sector. 141d 38 352 sec ;Turn fast serial to output mode. 141e 20 ff47 353 jsr spin_out 354 1421 ad dd00 355 2$ lda d2pra ;Wait for state change. 1424 4d 131b 356 eor oldclk 1427 29 40 357 and #clkin 1429 f0 f6 358 beq 2$ 359 142b 4d 131b 360 eor oldclk ;Change status of OLDCLK. 142e 8d 131b 361 sta oldclk 362 1431 b1 fa 363 lda (buffer),y ; get data 1433 8d dc0c 364 sta d1sdr ; & send it 365 1436 20 15a2 366 jsr WAIT ;Wait for the byte to be transmitted. 367 1439 c8 368 iny 143a d0 e5 369 bne 2$ ;Any more left in this page? 370 143c e6 fb 371 inc buffer+1 143e ca 372 dex ;Loop for the # of pages per sector. 143f d0 e0 373 bne 2$ 374 1441 18 375 clc ;Turn around to input mode to get STATUS. 1442 20 ff47 376 jsr spin_out 1445 2c dc0d 377 bit d1icr ; clear pending 378 1448 20 1585 379 jsr clklo ; set clock low when ready for status 380 144b 20 15a2 381 jsr WAIT ;Wait for the byte to be shifted in. 144e ad dc0c 382 lda d1sdr ;Get the status byte. 1451 8d 1300 383 sta STATUS ;Save it. 1454 48 384 pha 1455 20 1590 385 jsr clkhi ;Release the slow clock line. 1458 68 386 pla 387 1459 29 0f 388 and #15 ;Check for any error. 145b c9 02 389 cmp #2 145d b0 05 390 bcs 7$ ; branch if there was an error. 391 145f ce 1313 392 dec CMDLINE+5 ;Loop for the number of sectors. 1462 d0 b6 393 bne 1$ 394 1464 58 395 7$ cli 396 1465 68 397 pla ;Restore old memory configuration. 1466 8d ff00 398 sta $ff00 1469 60 399 rts .main. hcd65xx v3.1 10july87 page 8 0:x571 burst.src,s,r error addr code seq source statement 400 401 402 ;************************************************************** 403 146a 404 INQUIRE_FORMAT ; This BURST subroutine sends an INQUIRE DISK command to 405 ; drive indicated by LF. 406 ; 407 ; Required Parameters: 408 ; LF Logical file number of device to inquire. 409 ; SIDE Physical side of the disk to inquire about, 410 ; 0 or 1. SIDE is ignored if the disk is GCR. 411 ; 412 ; Returned Parameters: 413 ; STATUS Status byte returned. 414 146a 20 157a 415 jsr SETU0 ;Put "U0" at start of command string. 146d a9 04 416 lda #BURST_INQUIRE ; inquire burst command 146f 8d 1310 417 sta cmdline+2 418 1472 ae 1309 419 ldx SIDE ; Check which side to check. 1475 f0 02 420 beq 1$ 1477 09 10 421 ora #$10 ; If side 1, then set bit in the command byte. 422 1479 a9 03 423 1$ lda #$03 ; length of command. 147b 8d 131a 424 sta CMDLEN 147e 20 1555 425 jsr sendcmd ; send cmd string 1481 78 426 sei ;Disable interrupts during handshake. 1482 2c dc0d 427 bit D1ICR ;Clear any byte ready that's pending. 428 1485 20 1599 429 jsr CLK_CHNG ;Change clock so 1571 sends next. 1488 20 15a2 430 jsr WAIT ;Wait for the byte to be shifted in. 148b ad dc0c 431 lda D1SDR ;Get the status byte. 148e 8d 1300 432 sta STATUS ;Save it off. 433 1491 58 434 cli 1492 60 435 rts 436 437 ;********************************************************* 438 1493 439 QUERY_FORMAT ; This BURST subroutine sends a QUERY DISK FORMAT 440 ; command to drive indicated by LF. 441 ; 442 ; Required Parameters: 443 ; LF Logical file number of device to query. 444 ; TRACK Physical track number to query. 445 ; SIDE Physical side of the disk to query, 446 ; 0 or 1. SIDE is ignored if the disk is GCR. 447 ; 448 ; Returned Parameters: 449 ; NUMSEC Number of sectors found on the track. 450 ; TRACK Logical track number found in the sector headers. 451 ; MINSEC Minimum logical sector no. found in sector headers. 452 ; MAXSEC Maximum logical sector no. found in sector headers. 453 ; INTLV Physical interleave between sectors. 454 ; STATUS This is the byte that QUERY_FORMAT returns. 455 ; If an error is encountered, then none of the 456 ; returned parameters are valid except STATUS. .main. hcd65xx v3.1 10july87 page 9 0:x571 burst.src,s,r error addr code seq source statement 457 458 1493 20 157a 459 jsr SETU0 ;Put "U0" at start of command string. 460 1496 a9 86 461 lda #BURST_QUERY ;QUERY DISK burst command 462 1498 ae 1309 463 ldx SIDE ; Set the side bit accordingly. 149b d0 02 464 bne 4$ 149d 09 10 465 ora #$10 466 149f 8d 1310 467 4$ sta cmdline+2 468 14a2 ad 1303 469 lda TRACK ; Physical track offset. 14a5 8d 1311 470 sta cmdline+3 14a8 a9 04 471 lda #$04 ; length of command. 14aa 8d 131a 472 sta CMDLEN 14ad 20 1555 473 jsr sendcmd ; send cmd string 474 14b0 78 475 sei ;Disable interrupts during handshake. 14b1 2c dc0d 476 bit D1ICR ;Clear any byte ready that's pending. 477 14b4 20 1599 478 jsr CLK_CHNG ;Change state of clock so 1571 sends next. 14b7 20 15a2 479 jsr WAIT ;Wait for the first status byte. 14ba ad dc0c 480 lda D1SDR ;Get the status byte (status of track 0). 14bd 8d 1300 481 sta STATUS ;Save it off. 482 14c0 29 0f 483 and #$0f ;Was there an error? 14c2 c9 02 484 cmp #2 14c4 b0 53 485 bcs 5$ ; branch if there was an error. 486 14c6 ad 1300 487 lda STATUS ;Is the format GCR (if so no bytes follow)? 14c9 10 4e 488 bpl 5$ 489 14cb 20 1599 490 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 14ce 20 15a2 491 jsr WAIT ;Wait for next status byte to be ready. 14d1 ad dc0c 492 lda D1SDR ;Get it (status of track TRACK). 14d4 8d 1300 493 sta STATUS ;Save it. 494 14d7 29 0f 495 and #$0f ;Was there an error in compiling MFM info? 14d9 c9 02 496 cmp #2 14db b0 3c 497 bcs 5$ ; branch if an error. 498 14dd 20 1599 499 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 14e0 20 15a2 500 jsr WAIT ;Wait for 'number of sectors byte' to be ready 14e3 ad dc0c 501 lda D1SDR ;Get it. 14e6 8d 1305 502 sta NUMSEC ;Save it. 503 14e9 20 1599 504 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 14ec 20 15a2 505 jsr WAIT ;Wait for 'logical track #' byte to be ready. 14ef ad dc0c 506 lda D1SDR ;Get it. 14f2 8d 1303 507 sta TRACK ;Save it. 508 14f5 20 1599 509 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 14f8 20 15a2 510 jsr WAIT ;Wait for 'minimum sector #' byte to be ready. 14fb ad dc0c 511 lda D1SDR ;Get it. 14fe 8d 130a 512 sta MINSEC ;Save it. 513 .main. hcd65xx v3.1 10july87 page 10 0:x571 burst.src,s,r error addr code seq source statement 514 1501 20 1599 515 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 1504 20 15a2 516 jsr WAIT ;Wait for 'maximum sector #' byte to be ready. 1507 ad dc0c 517 lda D1SDR ;Get it. 150a 8d 130b 518 sta MAXSEC ;Save it. 519 150d 20 1599 520 jsr CLK_CHNG ;Change state of clock, so 1571 sends next. 1510 20 15a2 521 jsr WAIT ;Wait for 'interleave' byte to be ready. 1513 ad dc0c 522 lda D1SDR ;Get it. 1516 8d 130c 523 sta INTLV ;Save it. 524 1519 58 525 5$ cli 151a 60 526 rts 527 528 ;********************************************************* 529 151b 530 COMPARE_MEMORY ; This subroutine compares memory blocks in C128 memory. 531 ; 532 ; Required Parameters: 533 ; .A Number of pages to compare 534 ; .X First page of first memory block 535 ; .Y First page of second memory block 536 ; 537 ; Returned Parameters: 538 ; STATUS This is the byte that COMPARE_MEMORY 539 ; returns, 0 if the two blocks are equal. 540 151b 8d 131c 541 sta temp 542 151e ad ff00 543 lda $ff00 ;Save old MMU setup. 1521 48 544 pha 545 1522 a9 0e 546 lda #$0e ;Set MMU for RAM0,KERNEL,I/O. 1524 8d ff00 547 sta $ff00 548 1527 86 fb 549 stx buffer+1 ;Set up MSB of 1st memory pointer. 1529 84 fd 550 sty buffer2+1 ;Set up MSB of 2nd memory pointer. 152b ae 131c 551 ldx temp ;Number of pages to compare. 552 152e a9 00 553 lda #0 ;Set up LSB's of memory pointers. 1530 85 fa 554 sta buffer 1532 85 fc 555 sta buffer2 556 1534 8d 1300 557 sta STATUS ;Initialize STATUS. 558 1537 a0 00 559 ldy #0 1539 b1 fa 560 2$ lda (buffer),y 153b d1 fc 561 cmp (buffer2),y 153d f0 07 562 beq 1$ 563 153f a9 ff 564 lda #$ff ;Not equal! Load STATUS with nonzero. 1541 8d 1300 565 sta STATUS 1544 d0 0a 566 bne 99$ ; (branch always) 567 1546 c8 568 1$ iny 1547 d0 f0 569 bne 2$ ;More in this page? 570 .main. hcd65xx v3.1 10july87 page 11 0:x571 burst.src,s,r error addr code seq source statement 571 1549 e6 fb 572 inc buffer+1 154b e6 fd 573 inc buffer2+1 154d ca 574 dex ;# of pages counter. 154e d0 e9 575 bne 2$ 576 1550 68 577 99$ pla ;Restore old memory configuration. 1551 8d ff00 578 sta $ff00 579 1554 60 580 rts 581 582 ;********************************************************* 583 1555 584 SENDCMD ; This BURST subroutine sends a command to logical file LF. 585 ; 586 ; Required Parameters: 587 ; LF Logical file number to send command to. 588 ; CMDLINE Command string to send. 589 ; CMDLEN Length of command string. 590 ; 591 ; No parameter is returned. 592 1555 ae 1302 593 ldx LF 1558 20 ffc9 594 jsr chkout ; channel output (pointed to by .X) 155b a2 00 595 ldx #0 155d ac 131a 596 ldy cmdlen ; send cmd 1560 bd 130e 597 1$ lda cmdline,x 1563 20 ffd2 598 jsr bsout 1566 e8 599 inx 1567 88 600 dey 1568 d0 f6 601 bne 1$ 602 156a 20 ffcc 603 jsr clrchn ; send buffered char & eoi 156d 60 604 rts 605 606 ;********************************************************* 607 156e 608 OPEN_CHANNEL ; This BURST subroutine opens up a channel to device .X 609 ; and assigns it a logical file number with an optional 610 ; secondary address. This subroutine performs the same 611 ; function as the BASIC open statement. 612 ; 613 ; Required Parameters: 614 ; .X Device number 615 ; .A Logical file number 616 ; .Y This is the secondary address. This 617 ; number should be set to $FF if no 618 ; secondary address is desired. 619 ; 620 ; Returned Parameters: 621 ; .A This is the byte that OPEN_CHANNEL returns 622 ; 1 if the routine was successful, 623 ; 0 otherwise. If an error was encountered, 624 ; then OPEN_CHANNEL will also set the CARRY 625 ; bit. 626 ; 627 .main. hcd65xx v3.1 10july87 page 12 0:x571 burst.src,s,r error addr code seq source statement 628 156e 20 ffba 629 jsr SETLFS ;Setup the logical file. 630 1571 a9 00 631 lda #0 ;No name/command string for OPEN (length=0). 1573 20 ffbd 632 jsr SETNAM ;Setup the filename/command string for OPEN. 633 1576 20 ffc0 634 jsr OPEN ;Open the logical file. 635 1579 60 636 rts 637 638 ;********************************************************* 639 157a a9 55 640 SETU0 lda #85 ;'U' 157c 8d 130e 641 sta CMDLINE 157f a9 30 642 lda #48 ;'0' 1581 8d 130f 643 sta CMDLINE+1 1584 60 644 rts 645 646 1585 647 CLKLO ; set clock low 1585 48 648 pha 1586 ad dd00 649 lda d2pra 1589 09 10 650 ora #clkout 158b 8d dd00 651 sta d2pra 158e 68 652 pla 158f 60 653 rts 654 1590 655 CLKHI ; set clock high 1590 ad dd00 656 lda d2pra 1593 29 ef 657 and #$ff-clkout 1595 8d dd00 658 sta d2pra 1598 60 659 rts 660 1599 661 CLK_CHNG ; change the state of the clock line output. 1599 ad dd00 662 lda D2PRA 159c 49 10 663 eor #clkout 159e 8d dd00 664 sta D2PRA 15a1 60 665 rts 666 15a2 667 WAIT ; wait for the shift register to be full or empty. 15a2 a9 08 668 1$ lda #8 15a4 2c dc0d 669 bit D1ICR 15a7 f0 f9 670 beq 1$ 15a9 60 671 rts 672 673 674 .end 0 errors detected .main. hcd65xx v3.1 10july87 page 13 symbol table = label, <=> = symbol, <+>= multibly defined bsout =ffd2 buffer =00fa buffer2 =00fc bufloc 1306 burst_inquire =0004 burst_query =0086 chkout =ffc9 clkhi 1590 clkin =0040 clklo 1585 clkout =0010 clk_chng 1599 clrchn =ffcc cmdlen 131a cmdline 130e compare_memory 151b d1icr =dc0d d1sdr =dc0c d2pra =dd00 dev 1301 flag 130d inquire_format 146a intlv 130c j_compare_memory 134c j_inquire_format 1340 j_open_channel 1352 j_physical_read 1343 j_physical_write 1346 j_query_format 1349 j_sendcmd 134f lf 1302 maxsec 130b minsec 130a numsec 1305 oldclk 131b open =ffc0 open_channel 156e pburstrd =0000 pburstwr =0002 pread 1355 pwrite 13d6 query_format 1493 read 1361 secsize 1308 sector 1304 sendcmd 1555 setlfs =ffba setnam =ffbd setu0 157a side 1309 spin_out =ff47 status 1300 temp 131c track 1303 wait 15a2 write 13e2