Skip to content

Commit

Permalink
Merge pull request #438 from kiwisincebirth/map/hbios-slice0
Browse files Browse the repository at this point in the history
Fix: If the Slice=0 and No CPM partition
  • Loading branch information
wwarthen authored Oct 15, 2024
2 parents f3e0de4 + 1f383a3 commit 30d79fe
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions Source/HBIOS/hbios.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4946,14 +4946,14 @@ EXT_SLICE:
LD A,E ; RESULTANT MEDIA ID TO ACCUM
LD (SLICE_MID),A ; INIT VALUE, MAY BE USED LATER
OR A ; SET FLAGS
JR Z, EXT_SLICE1A ; BAIL IF NO MEDIA
JR Z,EXT_SLICE1A ; BAIL IF NO MEDIA
CP MID_HD ; IS IT A HARD DISK
JR Z, EXT_SLICE1B ; IS HD, CONTINUE TO PROCESS HD
JR Z,EXT_SLICE1B ; IS HD, CONTINUE TO PROCESS HD
;
; NOT A HARD DISK, CHECK SLICE = 0
LD A,(SLICE_SLICE) ; GET THE SLICE
OR A ; SET FLAGS
JP NZ, EXT_SLICE5C ; SLICE NOT ZERO - SIGNAL ERROR AND RETURN
JP NZ,EXT_SLICE5C ; SLICE NOT ZERO - SIGNAL ERROR AND RETURN
;
EXT_SLICE1A:
; RETURN MEDIA ID (NOT HD) WITH SUCCESS
Expand Down Expand Up @@ -5035,8 +5035,8 @@ EXT_SLICE3A
; STARTING SECTOR - THIS IS A COMPRIMISE - OUT OF SEQUENCE PARTITIONS ARE UNLIKELY.
;
PUSH BC ; SAVE IT, BEING USED IN PARTITION LOOP
LD BC, 4 ; IF NOT ALREADY SET - COPY 4 BYTES
LD DE, SLICE_LBASIZ ; FROM PARTION LBA OFFSET (HL) - TO WORKING LBA SIZE (DE)
LD BC,4 ; IF NOT ALREADY SET - COPY 4 BYTES
LD DE,SLICE_LBASIZ ; FROM PARTION LBA OFFSET (HL) - TO WORKING LBA SIZE (DE)
LDIR ; COPY 4 BYTES
POP BC ; RESTORE
;
Expand All @@ -5047,10 +5047,10 @@ EXT_SLICE3A
;
EXT_SLICE3B:
; FOUND CP/M (HD1K) PARTITION - RECORD THIS
LD A, MID_HDNEW ; DISCOVERED HD1K MEDIA
LD (SLICE_MID), A ; STORE IT
LD BC, SPS_HD1K ; DISCOVERED HD1K MEDIA
LD (SLICE_SPS), BC ; STORE IT
LD A,MID_HDNEW ; DISCOVERED HD1K MEDIA
LD (SLICE_MID),A ; STORE IT
LD BC,SPS_HD1K ; DISCOVERED HD1K MEDIA
LD (SLICE_SPS),BC ; STORE IT
;
; CAPTURE THE LBA OFFSET AND SECTOR COUNT FROM PARTITION
; HL POINTS TO PART LBA OFFSET FIELD OF PART ENTRY
Expand All @@ -5061,26 +5061,31 @@ EXT_SLICE3B:
JR EXT_SLICE4A ; CONTINUE AND COMPUTE THE SLICE
;
EXT_SLICE3C:
; NO PARTITION TABLE FOUND / NO CPM PARTITION FOUND -> HD512
LD BC, SPS_HD512 ; WITH HD512 SECTORS PER SLICE
LD (SLICE_SPS), BC ; STORE IT
; NO PARTITION TABLE FOUND / NO CPM PARTITION
LD A,(SLICE_SLICE) ; IF SLICE = 0, WE BOOT THE DISK ITSELF. IGNORE SLICE(S)
OR A ; SET FLAGS FOR SLICE ARGUMENT, IF SLICE==0
JR Z,EXT_SLICE5Z ; BYPASS ALL CALCS / CHECKS - JUST BOOT THE DISK

; BOOT SLICE WITH LEGACY SPS
LD BC,SPS_HD512 ; WITH HD512 SECTORS PER SLICE
LD (SLICE_SPS),BC ; STORE IT

; DID WE FIND AN OTHER (NOT CPM) PARTITION
LD A,(SLICE_FND) ; HAVE WE ALREADY FOUND PROCESSED NON CPM
OR A ; PARTITION, AND CAPTURED ITS START SECTOR, SO
JR NZ,EXT_SLICE4A ; MEDIA SIZE IS KNOWN BASED ON START OF PARTITION

; FIND THE PHYSICAL CAPCITY OF THE MEDIA CALL (DIOCAP)
LD B, BF_DIOCAP ; HBIOS FUNC: TO GET DISK LBA CAPACITY
LD A, (SLICE_UNIT)
LD C, A ; PUT DISK UNIT IN C FOR FUNC CALL
LD B,BF_DIOCAP ; HBIOS FUNC: TO GET DISK LBA CAPACITY
LD A,(SLICE_UNIT)
LD C,A ; PUT DISK UNIT IN C FOR FUNC CALL
CALL DIO_DISPATCH ; DO IT - RETURNS SIZE in DE:HL
RET NZ ; ABORT ON ERROR

; UPDATE LBA SIZE FROM MEDIA SIZE
LD (SLICE_LBASIZ), HL ; LOWER ORDER BYTES - HL
LD (SLICE_LBASIZ),HL ; LOWER ORDER BYTES - HL
EX DE,HL
LD (SLICE_LBASIZ+2), HL ; HIGHER ORDER BYTES - DE
LD (SLICE_LBASIZ+2),HL ; HIGHER ORDER BYTES - DE
;
EXT_SLICE4A:
; COMPUTE THE START SECTOR (RELATIVE) FOR SLICE -> DE:HL
Expand All @@ -5089,8 +5094,7 @@ EXT_SLICE4A:
LD BC,(SLICE_SPS)
LD A,(SLICE_SLICE)
OR A ; SLICE NUMBER - SET FLAGS TO CHECK LOOP CTR
;JR Z,EXT_SLICE5A ; NOTHING TO COUNT
JR Z,EXT_SLICE6 ; BYPASS CAPACITY CHECK IF SLICE == 0
JR Z,EXT_SLICE5A ; NOTHING TO COUNT
EXT_SLICE4B:
ADD HL,BC ; ADD ONE SLICE (SPS) TO LOW WORD
JR NC,EXT_SLICE4C ; CHECK FOR CARRY
Expand All @@ -5104,8 +5108,8 @@ EXT_SLICE5A:
PUSH HL ; SAVE THE SECTOR OFFSET (SPS * SLICE NUMBER)
PUSH DE
;
ADD HL, BC ; ADD SPS, GET REQUIRED CAPCITY (UPPER SECTOR)
JR NC, EXT_SLICE5B
ADD HL,BC ; ADD SPS, GET REQUIRED CAPCITY (UPPER SECTOR)
JR NC,EXT_SLICE5B
INC DE
EXT_SLICE5B:
; DEHL HAS THE REQUIRED NUMBER OF SECTORS (ON MEDIA) FOR THE SLICE
Expand Down Expand Up @@ -5141,6 +5145,10 @@ EXT_SLICE5C:
OR A
RET
;
EXT_SLICE5Z:
LD HL,0 ; BOOT THE DISK TO LBA = 0
LD DE,0 ;
;
EXT_SLICE6:
; FINAL CALC AND RETURN SUCCESS
; ADD PARTITION OFFSET (START) TO DEHL TO GET ABSOLUTE SLICE OFFSET
Expand All @@ -5149,7 +5157,7 @@ EXT_SLICE6:
EX DE,HL ; FLIP DE INTO HL
LD BC,(SLICE_LBAOFF+2) ; MSB OF LBA OFFSET
ADC HL,BC ; ADD MSB
EX DE, HL ; FLIP BACK DE:HL AS SLICE OFFSET
EX DE,HL ; FLIP BACK DE:HL AS SLICE OFFSET
;
EXT_SLICE6A:
; SLICE FITS - RETURN CORRECTLY
Expand Down

0 comments on commit 30d79fe

Please sign in to comment.