mirror of
https://github.com/brouhaha/a2-liron.git
synced 2025-02-10 15:30:34 +00:00
read_packet
This commit is contained in:
parent
be176b9ff9
commit
86f8f8183d
174
liron-if.asm
174
liron-if.asm
@ -1,6 +1,7 @@
|
|||||||
; Apple II UniDisk 3.5 (Liron) disk interface card firmware
|
; Apple II UniDisk 3.5 (Liron) disk interface card firmware
|
||||||
; Firmware P/N 341-????
|
; Firmware P/N 341-????
|
||||||
; Copyright 2018 Eric Smith <spacewar@gmail.com>
|
; Copyright 1985 Apple Computer, Inc.
|
||||||
|
; Disassembly copyright 2018 Eric Smith <spacewar@gmail.com>
|
||||||
|
|
||||||
cpu 6502
|
cpu 6502
|
||||||
|
|
||||||
@ -54,23 +55,23 @@ prodos_buffer equ $44
|
|||||||
prodos_block equ $46
|
prodos_block equ $46
|
||||||
|
|
||||||
Z48 equ $48
|
Z48 equ $48
|
||||||
Z4b equ $4b
|
group_count equ $4b ; count of seven-byte groups
|
||||||
Z4c equ $4c
|
odd_byte_count equ $4c ; count of "odd bytes"
|
||||||
Z4d equ $4d
|
Z4d equ $4d ; rx packet data status byte
|
||||||
Z4e equ $4e
|
Z4e equ $4e ; rx packet aux type
|
||||||
Z4f equ $4f
|
Z4f equ $4f ; rx packet type
|
||||||
Z50 equ $50
|
Z50 equ $50 ; rx packet source ID
|
||||||
Z51 equ $51
|
Z51 equ $51 ; rx packet destination ID
|
||||||
Z52 equ $52
|
Z52 equ $52
|
||||||
Z53 equ $53
|
Z53 equ $53
|
||||||
|
|
||||||
Z54 equ $54
|
Z54 equ $54
|
||||||
Z55 equ $55
|
|
||||||
Z56 equ $56
|
Z56 equ $56
|
||||||
Z57 equ $57
|
|
||||||
slot equ $58
|
slot equ $58
|
||||||
Z59 equ $59
|
Z59 equ $59
|
||||||
Z5a equ $5a
|
Z5a equ $5a ; destination ID
|
||||||
Z5b equ $5b
|
Z5b equ $5b ; packet type
|
||||||
|
|
||||||
|
|
||||||
; per-slot screen holes (index by slot)
|
; per-slot screen holes (index by slot)
|
||||||
@ -173,13 +174,15 @@ Lcn14: ldx #$c0 + slotnum
|
|||||||
jmp shared_rom_entry
|
jmp shared_rom_entry
|
||||||
|
|
||||||
|
|
||||||
; continuation of Sc960 subroutine (in shared ROM)
|
; continuation of smartport_bus_read_packet subroutine (in shared ROM)
|
||||||
Lcn21: ldy #$00
|
Lcn21: ldy #$00
|
||||||
lda Z4b
|
|
||||||
pha
|
|
||||||
bne Lcn2b
|
|
||||||
jmp Lcnb8
|
|
||||||
|
|
||||||
|
lda group_count ; get group count
|
||||||
|
pha ; and save for later
|
||||||
|
bne Lcn2b
|
||||||
|
jmp Lcnb8 ; no groups, skip
|
||||||
|
|
||||||
|
; read seven-byte groups
|
||||||
Lcn2b: lda iwm_q6l + (slotnum << 4)
|
Lcn2b: lda iwm_q6l + (slotnum << 4)
|
||||||
bpl Lcn2b
|
bpl Lcn2b
|
||||||
sta Z59
|
sta Z59
|
||||||
@ -200,7 +203,7 @@ Lcn3e: lda iwm_q6l + (slotnum << 4)
|
|||||||
sta checksum
|
sta checksum
|
||||||
iny
|
iny
|
||||||
bne Lcn51
|
bne Lcn51
|
||||||
inc Z57
|
inc Z56+1
|
||||||
|
|
||||||
Lcn51: lda iwm_q6l + (slotnum << 4)
|
Lcn51: lda iwm_q6l + (slotnum << 4)
|
||||||
bpl Lcn51
|
bpl Lcn51
|
||||||
@ -226,7 +229,7 @@ Lcn6f: lda iwm_q6l + (slotnum << 4)
|
|||||||
sta checksum
|
sta checksum
|
||||||
iny
|
iny
|
||||||
bne Lcn82
|
bne Lcn82
|
||||||
inc Z57
|
inc Z56+1
|
||||||
|
|
||||||
Lcn82: ldx Z59
|
Lcn82: ldx Z59
|
||||||
Lcn84: lda iwm_q6l + (slotnum << 4)
|
Lcn84: lda iwm_q6l + (slotnum << 4)
|
||||||
@ -252,15 +255,17 @@ Lcna2: lda iwm_q6l + (slotnum << 4)
|
|||||||
eor checksum
|
eor checksum
|
||||||
sta checksum
|
sta checksum
|
||||||
iny
|
iny
|
||||||
dec Z4b
|
|
||||||
|
dec group_count
|
||||||
beq Lcnb8
|
beq Lcnb8
|
||||||
jmp Lcn2b
|
jmp Lcn2b
|
||||||
|
|
||||||
Lcnb8: lda iwm_q6l + (slotnum << 4)
|
Lcnb8: lda iwm_q6l + (slotnum << 4)
|
||||||
bpl Lcnb8
|
bpl Lcnb8
|
||||||
sta Z59
|
sta Z59
|
||||||
pla
|
|
||||||
sta Z4b
|
pla ; restore group count
|
||||||
|
sta group_count
|
||||||
|
|
||||||
Lcnc2: lda iwm_q6l + (slotnum << 4)
|
Lcnc2: lda iwm_q6l + (slotnum << 4)
|
||||||
bpl Lcnc2
|
bpl Lcnc2
|
||||||
@ -273,7 +278,7 @@ Lcncd: ldy iwm_q6l + (slotnum << 4)
|
|||||||
bpl Lcncd
|
bpl Lcncd
|
||||||
cpy #$c8
|
cpy #$c8
|
||||||
bne Lcnf2
|
bne Lcnf2
|
||||||
ldx Z4c
|
ldx odd_byte_count
|
||||||
beq Lcne2
|
beq Lcne2
|
||||||
|
|
||||||
ldy #$00
|
ldy #$00
|
||||||
@ -364,17 +369,17 @@ Lc82c: asl iwm_q6l,x
|
|||||||
|
|
||||||
jsr send_80 ; aux type
|
jsr send_80 ; aux type
|
||||||
|
|
||||||
jsr send_80 ; data statys byte
|
jsr send_80 ; data status byte
|
||||||
|
|
||||||
lda Z4c ; length of packet "odd bytes", 0-6
|
lda odd_byte_count ; length of packet "odd bytes", 0-6
|
||||||
ora #$80
|
ora #$80
|
||||||
jsr send_nib7
|
jsr send_nib7
|
||||||
|
|
||||||
lda Z4b ; number of encoded 7-byte groups
|
lda group_count ; number of encoded 7-byte groups
|
||||||
ora #$80
|
ora #$80
|
||||||
jsr send_nib7
|
jsr send_nib7
|
||||||
|
|
||||||
lda Z4c ; any "odd bytes"?
|
lda odd_byte_count ; any "odd bytes"?
|
||||||
beq Lc873 ; no, skip
|
beq Lc873 ; no, skip
|
||||||
|
|
||||||
; send "odd bytes"
|
; send "odd bytes"
|
||||||
@ -386,11 +391,11 @@ Lc862: asl iwm_q6l,x
|
|||||||
iny
|
iny
|
||||||
lda (Z54),y
|
lda (Z54),y
|
||||||
ora #$80
|
ora #$80
|
||||||
cpy Z4c
|
cpy odd_byte_count
|
||||||
bcc Lc862
|
bcc Lc862
|
||||||
|
|
||||||
; send groups
|
; send groups
|
||||||
Lc873: lda Z4b ; any groups to send?
|
Lc873: lda group_count ; any groups to send?
|
||||||
bne Lc87a ; yes
|
bne Lc87a ; yes
|
||||||
|
|
||||||
jmp send_checksum ; no
|
jmp send_checksum ; no
|
||||||
@ -414,7 +419,7 @@ Lc888: ldy iwm_q6l,x
|
|||||||
rol Z41
|
rol Z41
|
||||||
iny
|
iny
|
||||||
bne Lc8a1
|
bne Lc8a1
|
||||||
inc Z57
|
inc Z56+1
|
||||||
jmp Lc8a3
|
jmp Lc8a3
|
||||||
|
|
||||||
Lc8a1: pha
|
Lc8a1: pha
|
||||||
@ -447,7 +452,7 @@ Lc8a3: lda #$02
|
|||||||
rol Z41
|
rol Z41
|
||||||
iny
|
iny
|
||||||
bne Lc8dd
|
bne Lc8dd
|
||||||
inc Z57
|
inc Z56+1
|
||||||
jmp Lc8df
|
jmp Lc8df
|
||||||
Lc8dd: pha
|
Lc8dd: pha
|
||||||
pla
|
pla
|
||||||
@ -476,7 +481,7 @@ Lc8df: lda Z51
|
|||||||
rol Z41
|
rol Z41
|
||||||
iny
|
iny
|
||||||
|
|
||||||
dec Z4b ; sent last group?
|
dec group_count ; sent last group?
|
||||||
beq send_checksum ; yes
|
beq send_checksum ; yes
|
||||||
|
|
||||||
jmp Lc87d ; no, send another group
|
jmp Lc87d ; no, send another group
|
||||||
@ -538,23 +543,29 @@ packet_sync_sequence:
|
|||||||
packet_sync_sequence_len equ *-packet_sync_sequence
|
packet_sync_sequence_len equ *-packet_sync_sequence
|
||||||
|
|
||||||
|
|
||||||
|
; delay routine - unused?
|
||||||
jsr Sc95b
|
jsr Sc95b
|
||||||
nop
|
nop
|
||||||
nop
|
nop
|
||||||
Sc95b: nop
|
Sc95b: nop
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
Lc95d: jmp Sc93d
|
Lc95d: jmp Sc93d
|
||||||
|
|
||||||
|
|
||||||
Sc960: lda #$00
|
; on entry, Z54
|
||||||
|
smartport_bus_read_packet: lda #$00
|
||||||
sta checksum
|
sta checksum
|
||||||
|
|
||||||
|
; copy buffer pointer to group pointer
|
||||||
lda Z54
|
lda Z54
|
||||||
sta Z56
|
sta Z56
|
||||||
lda Z55
|
lda Z54+1
|
||||||
sta Z57
|
sta Z56+1
|
||||||
|
|
||||||
lda #$21 ; point Z52 at LCn21 for later continuation of execution
|
; point Z52 at LCn21 for later continuation of execution
|
||||||
|
lda #$21
|
||||||
sta Z52
|
sta Z52
|
||||||
lda slot
|
lda slot
|
||||||
clc
|
clc
|
||||||
@ -576,26 +587,28 @@ Lc987: lda iwm_q6l,x ; read a nibble
|
|||||||
cmp #$c3 ; is it the sync byte?
|
cmp #$c3 ; is it the sync byte?
|
||||||
bne Lc987 ; loop if not
|
bne Lc987 ; loop if not
|
||||||
|
|
||||||
ldy #$06
|
ldy #$06 ; read first six nibbles of packet
|
||||||
Lc995: lda iwm_q6l,x ; read a nibble
|
Lc995: lda iwm_q6l,x ; read a nibble
|
||||||
bpl Lc995 ; loop if don't have a nibble yet
|
bpl Lc995 ; loop if don't have a nibble yet
|
||||||
and #$7f
|
and #$7f
|
||||||
sta Z4b,y
|
sta group_count,y ; store in reverse order
|
||||||
eor #$80
|
eor #$80
|
||||||
eor checksum
|
eor checksum
|
||||||
sta checksum
|
sta checksum
|
||||||
dey
|
dey
|
||||||
bpl Lc995
|
bpl Lc995
|
||||||
|
|
||||||
lda Z4c
|
lda odd_byte_count ; any odd bytes?
|
||||||
beq Lc9d3
|
beq Lc9d3 ; no
|
||||||
clc
|
|
||||||
|
clc ; advance group pointer by number of odd bytes
|
||||||
adc Z54
|
adc Z54
|
||||||
sta Z56
|
sta Z56
|
||||||
lda Z55
|
lda Z54+1
|
||||||
adc #$00
|
adc #$00
|
||||||
sta Z57
|
sta Z56+1
|
||||||
|
|
||||||
|
; receive "odd bytes"
|
||||||
ldy #$00
|
ldy #$00
|
||||||
Lc9b9: lda iwm_q6l,x
|
Lc9b9: lda iwm_q6l,x
|
||||||
bpl Lc9b9
|
bpl Lc9b9
|
||||||
@ -608,8 +621,9 @@ Lc9c1: lda iwm_q6l,x
|
|||||||
eor #$80
|
eor #$80
|
||||||
Lc9cc: sta (Z54),y
|
Lc9cc: sta (Z54),y
|
||||||
iny
|
iny
|
||||||
cpy Z4c
|
cpy odd_byte_count
|
||||||
bcc Lc9c1
|
bcc Lc9c1
|
||||||
|
|
||||||
Lc9d3: jmp (Z52) ; continue from slot ROM space
|
Lc9d3: jmp (Z52) ; continue from slot ROM space
|
||||||
|
|
||||||
|
|
||||||
@ -740,7 +754,7 @@ Lcabc: rts
|
|||||||
Scabd: ldy slot
|
Scabd: ldy slot
|
||||||
lda #$05
|
lda #$05
|
||||||
sta sh_04f8,y
|
sta sh_04f8,y
|
||||||
Lcac4: jsr Sc960
|
Lcac4: jsr smartport_bus_read_packet
|
||||||
bcc Lcad8
|
bcc Lcad8
|
||||||
|
|
||||||
ldy #1
|
ldy #1
|
||||||
@ -774,12 +788,12 @@ Dcaeb: fcb $00,$7f,$ff
|
|||||||
; number of 7-byte groups and the number of "odd bytes"
|
; number of 7-byte groups and the number of "odd bytes"
|
||||||
Scaee: ldx Z4e ; high byte of length
|
Scaee: ldx Z4e ; high byte of length
|
||||||
beq Lcb05
|
beq Lcb05
|
||||||
lda Z55
|
lda Z54+1
|
||||||
sta Z57
|
sta Z56+1
|
||||||
lda #$80
|
lda #$80
|
||||||
cpx #$01
|
cpx #$01
|
||||||
beq Lcb00
|
beq Lcb00
|
||||||
inc Z57
|
inc Z56+1
|
||||||
lda #$00
|
lda #$00
|
||||||
Lcb00: clc
|
Lcb00: clc
|
||||||
adc Z54
|
adc Z54
|
||||||
@ -787,9 +801,9 @@ Lcb00: clc
|
|||||||
|
|
||||||
; divide high byte of length by 7 using table lookup
|
; divide high byte of length by 7 using table lookup
|
||||||
Lcb05: lda page_div_7_tab,x
|
Lcb05: lda page_div_7_tab,x
|
||||||
sta Z4b
|
sta group_count
|
||||||
lda page_rem_7_tab,x
|
lda page_rem_7_tab,x
|
||||||
sta Z4c
|
sta odd_byte_count
|
||||||
|
|
||||||
ldx #$05 ; start table lookup at entry for 2^7
|
ldx #$05 ; start table lookup at entry for 2^7
|
||||||
|
|
||||||
@ -805,15 +819,15 @@ Lcb18: asl Z59
|
|||||||
|
|
||||||
lda pow2_rem_7,x
|
lda pow2_rem_7,x
|
||||||
Lcb1f: clc
|
Lcb1f: clc
|
||||||
adc Z4c
|
adc odd_byte_count
|
||||||
cmp #$07
|
cmp #$07
|
||||||
bcc Lcb28
|
bcc Lcb28
|
||||||
sbc #$07
|
sbc #$07
|
||||||
Lcb28: sta Z4c
|
Lcb28: sta odd_byte_count
|
||||||
|
|
||||||
lda pow2_div_7,x
|
lda pow2_div_7,x
|
||||||
adc Z4b
|
adc group_count
|
||||||
sta Z4b
|
sta group_count
|
||||||
|
|
||||||
Lcb31: dex
|
Lcb31: dex
|
||||||
bmi Lcb3a
|
bmi Lcb3a
|
||||||
@ -821,7 +835,7 @@ Lcb31: dex
|
|||||||
tya
|
tya
|
||||||
jmp Lcb1f
|
jmp Lcb1f
|
||||||
|
|
||||||
Lcb3a: lda Z55
|
Lcb3a: lda Z54+1
|
||||||
pha
|
pha
|
||||||
lda #$00
|
lda #$00
|
||||||
ldx Z4e
|
ldx Z4e
|
||||||
@ -835,8 +849,8 @@ Lcb46: eor (Z54),y
|
|||||||
eor (Z56),y
|
eor (Z56),y
|
||||||
cpx #$01
|
cpx #$01
|
||||||
beq Lcb57
|
beq Lcb57
|
||||||
inc Z55
|
inc Z54+1
|
||||||
Lcb57: inc Z55
|
Lcb57: inc Z54+1
|
||||||
Lcb59: ldy Z4d
|
Lcb59: ldy Z4d
|
||||||
beq Lcb66
|
beq Lcb66
|
||||||
eor (Z54),y
|
eor (Z54),y
|
||||||
@ -846,8 +860,8 @@ Lcb5f: eor (Z54),y
|
|||||||
eor (Z54),y
|
eor (Z54),y
|
||||||
Lcb66: sta checksum
|
Lcb66: sta checksum
|
||||||
pla
|
pla
|
||||||
sta Z55
|
sta Z54+1
|
||||||
ldy Z4c
|
ldy odd_byte_count
|
||||||
dey
|
dey
|
||||||
lda #$00
|
lda #$00
|
||||||
sta Z59
|
sta Z59
|
||||||
@ -858,13 +872,13 @@ Lcb72: lda (Z54),y
|
|||||||
bpl Lcb72
|
bpl Lcb72
|
||||||
sec
|
sec
|
||||||
ror Z59
|
ror Z59
|
||||||
lda Z4c
|
lda odd_byte_count
|
||||||
clc
|
clc
|
||||||
adc Z54
|
adc Z54
|
||||||
sta Z56
|
sta Z56
|
||||||
lda Z55
|
lda Z54+1
|
||||||
adc #$00
|
adc #$00
|
||||||
sta Z57
|
sta Z56+1
|
||||||
ldy #$06
|
ldy #$06
|
||||||
Lcb8c: sec
|
Lcb8c: sec
|
||||||
lda (Z56),y
|
lda (Z56),y
|
||||||
@ -881,7 +895,7 @@ Lcb95: ror Z41
|
|||||||
adc #$07
|
adc #$07
|
||||||
sta Z56
|
sta Z56
|
||||||
bcc Lcba8
|
bcc Lcba8
|
||||||
inc Z57
|
inc Z56+1
|
||||||
Lcba8: rts
|
Lcba8: rts
|
||||||
|
|
||||||
|
|
||||||
@ -901,25 +915,25 @@ Lcbb6: tya
|
|||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
Scbbf: lda Z4b
|
Scbbf: lda group_count
|
||||||
tay
|
tay
|
||||||
ldx #$00
|
ldx #$00
|
||||||
stx Z4b
|
stx group_count
|
||||||
ldx #$03
|
ldx #$03
|
||||||
Lcbc8: asl
|
Lcbc8: asl
|
||||||
rol Z4b
|
rol group_count
|
||||||
dex
|
dex
|
||||||
bne Lcbc8
|
bne Lcbc8
|
||||||
clc
|
clc
|
||||||
adc Z4c
|
adc odd_byte_count
|
||||||
bcc Lcbd5
|
bcc Lcbd5
|
||||||
inc Z4b
|
inc group_count
|
||||||
Lcbd5: sty Z4c
|
Lcbd5: sty odd_byte_count
|
||||||
sec
|
sec
|
||||||
sbc Z4c
|
sbc odd_byte_count
|
||||||
bcs Lcbde
|
bcs Lcbde
|
||||||
dec Z4b
|
dec group_count
|
||||||
Lcbde: ldy Z4b
|
Lcbde: ldy group_count
|
||||||
rts
|
rts
|
||||||
|
|
||||||
|
|
||||||
@ -999,7 +1013,7 @@ Lcc30: tax
|
|||||||
Lcc3c: lda sh_05f8,y ; set Z54 to point to cmd num -1
|
Lcc3c: lda sh_05f8,y ; set Z54 to point to cmd num -1
|
||||||
sta Z54
|
sta Z54
|
||||||
lda sh_0678,y
|
lda sh_0678,y
|
||||||
sta Z55
|
sta Z54+1
|
||||||
|
|
||||||
ldy #$01 ; copy SmartPort command
|
ldy #$01 ; copy SmartPort command
|
||||||
lda (Z54),y
|
lda (Z54),y
|
||||||
@ -1010,7 +1024,7 @@ Lcc3c: lda sh_05f8,y ; set Z54 to point to cmd num -1
|
|||||||
tax
|
tax
|
||||||
iny
|
iny
|
||||||
lda (Z54),y
|
lda (Z54),y
|
||||||
sta Z55
|
sta Z54+1
|
||||||
stx Z54
|
stx Z54
|
||||||
|
|
||||||
lda #$01
|
lda #$01
|
||||||
@ -1091,7 +1105,7 @@ Lcccf: lda #$28
|
|||||||
lda #$00
|
lda #$00
|
||||||
sta Z4e
|
sta Z4e
|
||||||
|
|
||||||
sta Z55
|
sta Z54+1
|
||||||
lda #$42
|
lda #$42
|
||||||
sta Z54
|
sta Z54
|
||||||
|
|
||||||
@ -1121,7 +1135,7 @@ Lcd02: lda Z5a
|
|||||||
lda prodos_buffer
|
lda prodos_buffer
|
||||||
sta Z54
|
sta Z54
|
||||||
lda prodos_buffer+1
|
lda prodos_buffer+1
|
||||||
sta Z55
|
sta Z54+1
|
||||||
|
|
||||||
ldx prodos_command
|
ldx prodos_command
|
||||||
lda Dcde3,x
|
lda Dcde3,x
|
||||||
@ -1140,7 +1154,7 @@ Lcd02: lda Z5a
|
|||||||
sta Z54
|
sta Z54
|
||||||
pla
|
pla
|
||||||
bcc Lcd4f
|
bcc Lcd4f
|
||||||
inc Z55
|
inc Z54+1
|
||||||
jmp Lcd4f
|
jmp Lcd4f
|
||||||
Lcd41: cpx #$02
|
Lcd41: cpx #$02
|
||||||
bne Lcd4b
|
bne Lcd4b
|
||||||
@ -1167,7 +1181,7 @@ Lcd60: ldy slot
|
|||||||
lda #$45
|
lda #$45
|
||||||
ldx #$00
|
ldx #$00
|
||||||
sta Z54
|
sta Z54
|
||||||
stx Z55
|
stx Z54+1
|
||||||
Lcd73: jsr Scabd
|
Lcd73: jsr Scabd
|
||||||
bcs Lcd5c
|
bcs Lcd5c
|
||||||
jsr Scbbf
|
jsr Scbbf
|
||||||
@ -1267,7 +1281,7 @@ Scded: pha
|
|||||||
lda #$42
|
lda #$42
|
||||||
sta Z54
|
sta Z54
|
||||||
lda #$00
|
lda #$00
|
||||||
sta Z55
|
sta Z54+1
|
||||||
lda #$80
|
lda #$80
|
||||||
sta Z5b
|
sta Z5b
|
||||||
jsr smartport_bus_disable
|
jsr smartport_bus_disable
|
||||||
@ -1283,7 +1297,7 @@ Lce19: inc Z5a
|
|||||||
dec Z5a
|
dec Z5a
|
||||||
jmp Lce34
|
jmp Lce34
|
||||||
|
|
||||||
Lce2d: jsr Sc960
|
Lce2d: jsr smartport_bus_read_packet
|
||||||
lda Z4d
|
lda Z4d
|
||||||
beq Lce19
|
beq Lce19
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user