powiesc w odcinkach
odcinek pierwszy
opt h-f+
org $d800
;
PBI_Entry:
PBI_rev: .byte '1.0';
PBI_DEVID1: .byte 0x80,0x00
PBI_PDIOR: jmp Karin_IO ;D90B
PBI_PDINT: jmp Karin_IRQ ;D898
PBI_DEVID2: .byte 0x91
PBI_PDSPC: .byte 0x00
PBI_PDVOPV: .word Karin_CIO_Open-1 ;D900
PBI_PDVCLV: .word Karin_CIO_Close-1 ;D900
PBI_PDVGBV: .word Karin_CIO_GetByte-1 ;D8F6
PBI_PDVPBV: .word Karin_CIO_PutByte-1 ;D900
PBI_PDVSTV: .word Karin_CIO_Status-1 ;D900
PBI_PDVSPV: .word Karin_CIO_Special-1 ;D900
PBI_PDINIT:
;-----------------------------------------------------------------------------------------
Karin_Init:
ldx #$4E ; N: device
ldy #$8F
lda #$E4 ; Point to Generic Parallel Device Table (GPDVV, 0xE48F)
jsr PENTV ; install new device
lda #$80 ; Karin-Maxi fixed PBI device number
sta PDVMSK ; report that back to the system
lda #$D0
sta WD177x_Command ; read track command
ldx #$1E
Karin_Init_wait1:
dex
bne Karin_Init_wait1
stx Karin_EnableIP ; enable Index Pulse singal comming from the drive
stx Karin_DslctDS0
stx Karin_DslctDS1 ; deselect both drives
Karin_Init_l1: stx Karin_AssertIP ; emulate Index Pulse
php ;
plp ; wait...
php ;
plp ;
stx Karin_DessertIP ; Index Pulse end
lda WD177x_Status
bmi Karin_Init_l1 ; repeat, if Motor On
lda WARMST
bne Karin_Init_End ; end here if this is warm start
stx Karin_EnableDD
inx ; set drive numer to #1
lda Karin_Config
and #$10 ; auto config?
bne Karin_AutoConfigure ; yes, so sense drives
Karin_Init_Config_l1:
sta Karin_DslctDS0
sta Karin_DslctDS1 ; deselect both drives
sta Karin_SlctDS0,X ; select desired drive
lda Karin_Config ; load configuration register
and Config_Table,X ; manual configured for 6ms?
beq Karin_Init_skip1 ; yes, so skip setting it to 3ms
lda #$03
sta ACMVAR+4,X
Karin_Init_skip1:
lda #$08
ora ACMVAR+4,X
sta WD177x_Command ; restore command (seek to track #0)
Karin_Init_wait2:
bit Karin_Status
bmi Karin_Init_wait2 ; wait until seek is complete
lda WD177x_Status
and #$04
sta ACMVAR,X ; bit 2 ov ACMVAR is now drive-present flag
beq Karin_Init_Next ; no drive here, check next drive
lda Karin_Config
and Config_Table+2,X ; check if configured for 80 tracks
beq Karin_Init_Next ; no, then configuration for that drive is done
lda ACMVAR,X
ora #$10
sta ACMVAR,X
Karin_Init_Next:
dex
bpl Karin_Init_Config_l1
Karin_Init_End:
Karin_IRQ: rts
;-----------------------------------------------------------------------------------------
Karin_AutoConfigure:
sta Karin_DslctDS0
sta Karin_DslctDS1 ; deselect both drives
sta Karin_SlctDS0,X ; select only actual one
lda #$08
sta WD177x_Command ; restore (seek to track 0) with spin-up sequence
Karin_AutoC_wait1:
bit Karin_Status
bmi Karin_AutoC_wait1 ; wait for INTRQ from WD177x
lda WD177x_Status
and #$04 ; bit 2 in ACMVAR,x is now drive-found flag
sta ACMVAR,X
beq Karin_AutoC_Next ; track 0 not found, check next drive
lda #$03 ; set stepping for 3ms
Karin_AutoC_ChangeStepping:
sta ACMVAR+4,X ; now ACMVAR+4,x contains stepping information 0x03 = 3ms, 0x00 = 6ms
ldy #45
sty WD177x_Data ; try to go to track 45
lda #$10
ora ACMVAR+4,X ; build command value with apriopriate flags
sta WD177x_Command ; seek command
Karin_AutoC_wait2:
bit Karin_Status
bmi Karin_AutoC_wait2 ; wait for INTRQ
Karin_AutoC_Step_l1:
lda #$60
sta WD177x_Command ; step-out
Karin_AutoC_wait3:
bit Karin_Status
bmi Karin_AutoC_wait3 ; wait for INTRQ
dey
lda WD177x_Status
and #$04 ; are we on track 0?
beq Karin_AutoC_Step_l1 ; no, so step out again
lda #$00 ; set stepping to 6ms (in case of retry) and reset 80 track drive marker
cpy #$00 ; track number is 0?
beq Karin_AutoC_80Tracks ; yes, 80 track drive found
cpy #$09 ; less than 9 tracks remaining?
bcc Karin_AutoC_40Tracks ; yes - so 40 track drive found, and stepping is 3ms
; no - set stepping to 6ms and try again
bcs Karin_AutoC_ChangeStepping
Karin_AutoC_80Tracks:
lda #$10 ; set 80 track drive marker
Karin_AutoC_40Tracks:
ora ACMVAR,X
sta ACMVAR,X ; save status of that drive
Karin_AutoC_Next:
dex
bpl Karin_AutoConfigure
rts
;-----------------------------------------------------------------------------------------
; Karin CIO routines - just for fun
;-----------------------------------------------------------------------------------------
Karin_CIO_GetByte:
lda RANDOM ;get random byte
ldy RANDOM
cpy #$88 ; is it EOF?
beq Karin_CIO_GetByte_EOF ; if so, return EOF
Karin_CIO_Open:
Karin_CIO_Close:
Karin_CIO_PutByte:
Karin_CIO_Status:
Karin_CIO_Special:
ldy #$01 ; set status to OK
Karin_CIO_GetByte_EOF:
sec
rts
;-----------------------------------------------------------------------------------------
Config_Table:
.byte $04,$08,$01,$02
jak widać, bity 0-5 rejestru konfiguracyjnego stacji, powinny być odwrócone:
D0 - DS0 number of tracks, 0 - 80 tracks drive, 1 - 40 tracks drive
D1 - DS1 number of tracks, 0 - 80 tracks drive, 1 - 40 tracks drive
D2 - stepping for DS0 - 0 - 3ms, 1 - 6ms
D3 - stepping for DS1 - 0 - 3ms, 1 - 6ms
D4 - 0 - Auto configure, 1 - manual config (depends on D2-D5)
D5 - boot order - 0 - SIO, 1 - KARIN MAXI first
przechodze na tumiwisizm