problem with C64IDE :( (2)

From: Ruud Baltissen (Ruud.Baltissen_at_abp.nl)
Date: 2001-10-19 07:43:56

Hallo allemaal,

Some extra info on the problem:

I ran the code without an HD attached. The code I used doesn't test the HD
so, with or without the HD, the same code is run every time. W/O the HD the
C64 behaves normal, I tried it over 10 times. But the first time you attach
a HD, bingo :(

Here is the part in question:



;**  CIA1 - 6526  **
.eq C1DRA        = $DC00                ; data register port A
.eq C1DRB        = $DC01                ; data register port B
.eq C1DDRA       = $DC02                ; data direction register port A
.eq C1DDRB       = $DC03                ; data direction register port B

;**  CIA2 - 6526  **
.eq C2DRA        = $DD00                ; data register port A
.eq C2DRB        = $DD01                ; data register port B
.eq C2DDRA       = $DD02                ; data direction register port A
.eq C2DDRB       = $DD03                ; data direction register port B


; Port B pinout:
; 0 = A0
; 1 = A1
; 2 = A2
; 3 = future
; 4 = CS0
; 5 = CS1
; 6 = IOWR
; 7 = IORD

; A0..3
; 0 dataregister
; 1 errorregister / write precompensation
; 2 sector count
; 3 sector number
; 4 track LB
; 5 track HB
; 6  0..3  head
;    4     drive select
;    5..7  101
; 7 commandregister
;   statusregister
;    0 previous command ended in error
;    1 index set to 1 each disk revolution
;    2 disk data read succesfully correctd
;    3 sector buffer requires servicing
;    4 seek complete
;    5 write fault
;    6 drive is ready
;    7 controller is executing command


.ba $8000

TestArea         nop
                 jsr ShowCIAs

                 sei

                 jsr SaveKBset
                 jsr InitUserPort
                 jsr DataOut

                 lda #$E0
                 sta   C1DRA            ; Command to port A

                 lda   #$EF             ; address 7, CS0 (L)
                 sta   C2DRB
                 and   #$7F             ; IOWR (L)
                 sta   C2DRB
                 ora   #$80             ; IOWR (H)
                 sta   C2DRB
                 lda   #$FF             ; all (H)
                 sta   C2DRB

;**  Read status
                 jsr DataIn

                 lda #7

                 pha
                 lda #$FF
                 sta C2DDRB
                 sta C2DRB
                 pla

                 ora   #$F8             ; only last 3 bits may be reset
                 sta   C2DRB
                 and   #$EF             ; CSO (L)
                 sta   C2DRB
                 and   #$BF             ; IORD (L)
                 sta   C2DRB

                 lda   C1DRA
                 pha

                 lda   C2DRB
                 ora   #$40             ; IORD (H)
                 sta   C2DRB
                 lda   #$FF             ; all (H)
                 sta   C2DRB

                 pla
                 sta 1064

                 cli

                 jsr RestKBset

                 cli

                 nop
                 rts

;---------------------------------------------------------------------------
-

ShowCIAs         ldx   #15
                 ldy   #61

Lsc001           lda   C1DRA,X
                 stx   $FF
                 jsr   Hex2Ascii
                 sta   1064,y
                 dey
                 txa
                 sta   1064,y
                 dey
                 dey
                 dey
                 ldx   $FF
                 dex
                 bpl   Lsc001

                 ldx   #15
                 ldy   #61

Lsc002           lda   C2DRA,X
                 stx   $FF
                 jsr   Hex2Ascii
                 sta   1144,y
                 dey
                 txa
                 sta   1144,y
                 dey
                 dey
                 dey
                 ldx   $FF
                 dex
                 bpl   Lsc002

                 rts


ShowCIAs2        ldx   #15
                 ldy   #61

Lsc003           lda   C1DRA,X
                 stx   $FF
                 jsr   Hex2Ascii
                 sta   1264,y
                 dey
                 txa
                 sta   1264,y
                 dey
                 dey
                 dey
                 ldx   $FF
                 dex
                 bpl   Lsc003


                 ldx   #15
                 ldy   #61

Lsc004           lda   C2DRA,X
                 stx   $FF
                 jsr   Hex2Ascii
                 sta   1344,y
                 dey
                 txa
                 sta   1344,y
                 dey
                 dey
                 dey
                 ldx   $FF
                 dex
                 bpl   Lsc004

                 rts


;---------------------------------------------------------------------------
-



;**  Set dataports to input
DataIn           jsr   SaveKBset

                 pha                    ; save A
                 lda   #$00
                 sta   C1DDRA           ; port A to input
                 sta   C1DDRB           ; port B to input
                 pla                    ; restore A

                 rts



;**  Set dataports to output
DataOut          jsr   SaveKBset

                 pha                    ; save A
                 lda   #$FF
                 sta   C1DDRA           ; port A to output
                 sta   C1DDRB           ; port B to output
                 pla                    ; restore A

                 rts


;**  Convert HEX into ASCII
;- in:  A hex byte
;- out: A low nibble
;       X high nibble
Hex2Ascii        pha
                 lsr
                 lsr
                 lsr
                 lsr
                 jsr   Lha000
                 tax

                 pla
                 and   #$0F
                 jsr   Lha000
                 rts

Lha000           cmp   #10
                 bcc   Lha001

                 sbc   #9
                 rts

Lha001           adc   #48
                 rts



;**  Init IDE-port
InitIDE          pha
                 lda   #$FF
                 sta   KBparams         ; keyboard settings not saved
                 pla

                 jsr   InitUserPort
                 jsr   Recalibrate
                 rts



;**  Init IDE-port
InitUserPort     sei
                 pha
                 lda   #$FF
                 sta   C2DRB            ; all outputs userport (H)
                 sta   C2DDRB           ; all pins userport output
                 pla
                 rts


;**  Restore keyboard settings
RestKBset        pha
                 lda   KBparams         ; settings already restored?


;####            bne   Lre0010          ; yes, ->


                 lda   #$FF
                 sta   KBparams

                 lda   KBparams+1
                 sta   C1DRA
                 lda   KBparams+2
                 sta   C1DDRA
                 lda   KBparams+3
                 sta   C1DRB
                 lda   KBparams+4
                 sta   C1DDRB

;####
                 lda   #$FF
                 sta   C1DDRA
                 lda   #$00
                 sta   C1DDRB


Lre0010          pla
                 rts



;**  Save keyboard settings
SaveKBset        jsr   InitUserPort

                 pha
                 lda   KBparams         ; settings already saved?
                 beq   Lre0010          ; yes, ->

                 lda   #0
                 sta   KBparams

                 lda   C1DRA
                 sta   KBparams+1
                 lda   C1DDRA
                 sta   KBparams+2
                 lda   C1DRB
                 sta   KBparams+3
                 lda   C1DDRB
                 sta   KBparams+4

Lsa0010          pla
                 rts

;===========================================================================
=

;**  Storage
DataL            .by 0
DataH            .by 0
KBparams         .by 0, 0, 0, 0, 0

.en




   ___
  / __|__
 / /  |_/     Groetjes, Ruud
 \ \__|_\
  \___|       http://Ruud.C64.org







       Message was sent through the cbm-hackers mailing list

Archive generated by hypermail 2.1.1.