Skip to content

Commit

Permalink
Replace undocumented op-codes (HC-95 turbo mode support)
Browse files Browse the repository at this point in the history
  • Loading branch information
lfantoniosi committed Nov 5, 2023
1 parent 181d3e0 commit 88374eb
Show file tree
Hide file tree
Showing 12 changed files with 1,808 additions and 81 deletions.
27 changes: 26 additions & 1 deletion source/kernel/Makefile
Expand Up @@ -64,7 +64,7 @@ endef
### MAIN RULE ###
###################

all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm
all: base ide ide-masteronly ide-emu ide-masteronly-emu ascii8 ascii16 mfrsd flashjacks ocm tang

TOOLS := $(N80) $(LK80) $(LB80) objcopy sdcc $(MKNEXROM) dd

Expand Down Expand Up @@ -593,3 +593,28 @@ clean:
rm -f bank0/b0lab*.inc
rm -f bank2/b2labels.inc
rm -f bank4/b4rdlabs.inc

### Tang

tang: drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM

drivers/Tang/Nextor-$(VERSION).WonderTANG.ROM: \
nextor_base.dat \
drivers/Tang/driver.bin \
drivers/Tang/chgbnk.bin \
256.bytes

cat 256.bytes drivers/Tang/driver.bin > drivers/Tang/_driver.bin
$(MKNEXROM) nextor_base.dat $@ /d:drivers/Tang/_driver.bin /m:drivers/Tang/chgbnk.bin
$(call copy_to_bin,$@)
cp $@ /mnt/d/src/fpga/wonderTANG/WonderTANG/fpga/src/roms/Nextor-$(VERSION).WonderTANG-HC95.ROM.bin

drivers/Tang/chgbnk.bin: \
drivers/Tang/chgbnk.mac

$(call assemble,drivers/Tang/chgbnk.mac,--build-type abs --output-file-extension bin)

drivers/Tang/driver.bin: \
drivers/Tang/driver.mac

$(call assemble,drivers/Tang/driver.mac,--build-type abs --output-file-extension bin)
8 changes: 4 additions & 4 deletions source/kernel/bank0/init.mac
Expand Up @@ -2143,7 +2143,7 @@ scan_loop:
ld e,(hl)
inc hl
ld d,(hl)
db 0FDh,67h ;LD IYh,A
LD_IYH_N a ;db 0FDh,67h ;LD IYh,A
push de
pop ix
call CALSLT
Expand Down Expand Up @@ -2173,10 +2173,10 @@ TNEX_LOOP:
push hl
push bc
and 10001111b
db 0FDh,67h ;LD IYh,A
LD_IYH_N a ;db 0FDh,67h ;LD IYh,A
ld a,(MASTER_SLOT##)
db 0FDh,0BCh ;CP IYh
db 0FDh,7Ch ;LD A,IYh
CP_IYH ;db 0FDh,0BCh ;CP IYh
LD_N_IYH a ;db 0FDh,7Ch ;LD A,IYh
ld h,40h
ld ix,DV_TIRQ##
call call_drv
Expand Down
9 changes: 5 additions & 4 deletions source/kernel/bank1/dosinit.mac
Expand Up @@ -1564,7 +1564,8 @@ _U_CALLRAM:
ex af,af
... < call _GET_P1 >
push af
ld a,iyl
LD_N_IYL A
;ld a,iyl
... < call _PUT_P1 >
ex af,af
call CALSLT##
Expand Down Expand Up @@ -1651,7 +1652,7 @@ _U_CALLRAM2:
dec ix
dec ix
push ix
ld iyl,e
LD_IYL_N e ;ld iyl,e

ld a,d
and 00111111b
Expand All @@ -1675,13 +1676,13 @@ _U_CALLRAM2:
ld bc,(MAP_TAB##)
add hl,bc
ld a,(hl) ;A = Slot to call
ld iyh,a
LD_IYH_N a ;ld iyh,a

ex af,af'
exx
inc sp
inc sp
jr _U_CALLRAM
jp _U_CALLRAM
;
;-----------------------------------------------------------------------------
;
Expand Down
38 changes: 19 additions & 19 deletions source/kernel/bank4/partit.mac
Expand Up @@ -209,14 +209,14 @@ DO_EXTPAR:
jp nz,UNEX_PART

ld a,(ix+POFF_PSTART) ;Save the start sector number of the outer extended partition
ld iyl,a ;(the one that includes all other extended partitions).
LD_IYL_N a ;ld iyl,a ;(the one that includes all other extended partitions).
ld a,(ix+POFF_PSTART+1) ;We need it to calculate the offsets of the inner
ld iyh,a ;extended partitions.
LD_IYH_N a ;ld iyh,a ;extended partitions.
push iy
ld a,(ix+POFF_PSTART+2)
ld iyl,a
LD_IYL_N a ;ld iyl,a
ld a,(ix+POFF_PSTART+3)
ld iyh,a
LD_IYH_N a ;ld iyh,a
push iy

;=== Loop for extended partition search ===
Expand Down Expand Up @@ -355,7 +355,7 @@ DEV_READ:
push de
push hl

ld iyh,c
LD_IYH_N c ;ld iyh,c
ld ix,DEV_RW##
ld (BK4_ADD##),ix
ld ix,CALDRV##
Expand Down Expand Up @@ -597,7 +597,7 @@ AUTODRV_DRVLOOP:
; A = Relative drive for the driver

ld c,a
ld a,iyl
LD_N_IYL A ;ld a,iyl
ld (ix+UD1_SLOT##),a ;Set slot number in table entry
ld a,c
ld (ix+UD1_RELATIVE_DRIVE##),a
Expand All @@ -607,7 +607,7 @@ AUTODRV_DRVLOOP:
push iy
push ix

ld a,iyh ;ld a,(iy+4)
LD_N_IYH a ;ld a,iyh ;ld a,(iy+4)
and 00000100b ;Driver provides config?
jr z,AUTODRV_DRVL2
push ix
Expand Down Expand Up @@ -708,7 +708,7 @@ AUTOD_UDFND:
;--- Check if it is assigned to a device based driver

ld a,(ix+UD_SLOT##)
ld iyh,a
LD_IYH_N a ;ld iyh,a

ld c,a
ld a,(KER250##)
Expand Down Expand Up @@ -1067,7 +1067,7 @@ AA_CHKDUP_OK:
;--- Obtain device information

ld a,(ix+AAD_DRIVER_SLOT)
ld iyh,a
LD_IYH_N a ;ld iyh,a
ld hl,LUN_INFO##
ld (BK4_ADD##),hl
ld hl,($SECBUF##)
Expand Down Expand Up @@ -1566,7 +1566,7 @@ AA_WSEC:
AA_RSEC:
or a
AA_DOSEC:
ld iyh,c
LD_IYH_N c ;ld iyh,c
ld hl,DEV_RW##
ld (BK4_ADD##),hl
ld c,b
Expand Down Expand Up @@ -2482,7 +2482,7 @@ F_CDRVR_GO:
ret nz

ld (BK4_ADD##),de
ld iyh,c
LD_IYH_N c ;ld iyh,c
ld l,(ix)
ld h,(ix+1)
push hl
Expand Down Expand Up @@ -2630,10 +2630,10 @@ UNMAP_LOOP:
inc hl
ld h,(hl)
ld l,a
cp iyl
CP_IYL ;cp iyl
jr nz,UNMAP_OK1
ld a,h
cp iyh
CP_IYH ;cp iyh
jr z,UNMAP_NEXT2 ;It is the unit not to be unassigned
UNMAP_OK1:

Expand Down Expand Up @@ -3084,7 +3084,7 @@ MAP_SPECIFIC:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
ld iyh,c
LD_IYH_N c ;ld iyh,c
ld hl,($SECBUF##)
ld ix,CALDRV##
call CALSLT
Expand Down Expand Up @@ -3121,7 +3121,7 @@ MAP_SPECIFIC:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
ld iyh,c
LD_IYH_N c ;ld iyh,c
ld ix,CALDRV##
call CALSLT
pop iy
Expand Down Expand Up @@ -3650,7 +3650,7 @@ MAPDOS1_DEF:
push hl
push ix
ld a,(ix+UD1_SLOT##)
ld iyh,a
LD_IYH_N a ;ld iyh,a
call GET_DV_TYPE
pop ix
pop hl
Expand Down Expand Up @@ -3815,7 +3815,7 @@ MAPDOS1_CHK_NEXT:
ld c,(iy)
ld a,(iy+2)
ld b,(iy+3)
ld iyh,c
LD_IYH_N c ;ld iyh,c
ld hl,($SECBUF##)
ld ix,CALDRV##
call CALSLT
Expand Down Expand Up @@ -5954,7 +5954,7 @@ DRVS1LOOP:
pop de
jr c,DRVS1NEXT ;Skip if not a Nextor kernel

ld iyh,e
LD_IYH_N e ;ld iyh,e
call GET_DV_TYPE
bit 0,a ;Device-based?
jr z,DRVS1NEXT ;No: skip
Expand Down Expand Up @@ -6192,7 +6192,7 @@ ASK_DRIVE_CONFIG:
push de
push bc ;BC=DOS mode and relative unit
ld a,(ix+UD_SLOT##)
ld iyh,a
LD_IYH_N a ;ld iyh,a
ld hl,DV_CONFIG##
ld (BK4_ADD##),hl
ld a,CFG_DEVLUN
Expand Down
1 change: 1 addition & 0 deletions source/kernel/condasm.inc
Expand Up @@ -16,5 +16,6 @@ RR equ 0 ;Level of release (0: no release level)
;
;-----------------------------------------------------------------------------
;

.list
;
35 changes: 18 additions & 17 deletions source/kernel/drivers/SunriseIDE/sunride.asm
Expand Up @@ -6,6 +6,7 @@
; By FRS

;MASTER_ONLY constant must be defined externally to generate the master-only variant.
INCLUDE ../../macros.inc

org 4000h
ds 4100h-$,0 ; DRV_START must be at 4100h
Expand Down Expand Up @@ -1052,8 +1053,8 @@ DEV_RW2:
ld b,0
ret
DEV_RW_NO0SEC:
ld iyl,e
ld iyh,d
LD_IYL_N e ;ld iyl,e
LD_IYH_N d ;ld iyh,d
ld a,(iy+3)
and 11110000b
jp nz,DEV_RW_NOSEC ;Only 28 bit sector numbers supported
Expand Down Expand Up @@ -1091,7 +1092,7 @@ DEV_ATA_RD:

call CHK_RW_FAULT
ret c
ld iyl,b ; iyl=number of blocks
LD_IYL_N b ;ld iyl,b ; iyl=number of blocks
ex de,hl ; de=destination address

ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN)
Expand All @@ -1108,7 +1109,7 @@ DEV_ATA_WR:
ld a,ATACMD.PWRSECTRT ; PIO write sector with retry
call PIO_CMD
jp c,DEV_RW_ERR
ld iyl,b ; iyl=number of blocks
LD_IYL_N B ;ld iyl,b ; iyl=number of blocks

ld bc,512 ; block size ***Hardcoded. Ignores (BLKLEN)
call WRITE_DATA
Expand All @@ -1126,8 +1127,8 @@ DEV_ATAPI_RW:
push de
ld e,(ix+DEVINFO.pBASEWRK) ; hl=pointer to WorkArea
ld d,(ix+DEVINFO.pBASEWRK+1)
ld iyl,e
ld iyh,d ; iy=WRKAREA pointer
LD_IYL_N e ;ld iyl,e
LD_IYH_N d ;ld iyh,d ; iy=WRKAREA pointer
pop de

; Set the block size
Expand Down Expand Up @@ -1174,7 +1175,7 @@ DEV_ATAPI_RD:
push bc
push hl
push iy
ld iyl,1 ; 1 block
LD_IYL_N 1 ;ld iyl,1 ; 1 block
ld hl,WRKAREA.PCTBUFF
ld bc,PCTRW10._SIZE ; block size=10 bytes
call WRITE_DATA ; Send the packet to the device
Expand Down Expand Up @@ -1217,13 +1218,13 @@ DEV_ATAPI_RD:
ex de,hl ; de=destination address
.loopsector:
push bc
ld iyl,c ; get the number of blocks per sector
LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector
.loopblock:
call WAIT_DRQ
jr c,.rderr
ld hl,IDE_DATA
call RUN_HLPR
dec iyl
DEC_IYL ;dec iyl
jr nz,.loopblock
pop bc
djnz .loopsector
Expand All @@ -1245,7 +1246,7 @@ DEV_ATAPI_WR:
push bc
push hl
push iy
ld iyl,1 ; 1 block
LD_IYL_N 1 ;ld iyl,1 ; 1 block
ld hl,WRKAREA.PCTBUFF
ld bc,PCTRW10._SIZE ; block size=10 bytes
call WRITE_DATA ; Send the packet to the device
Expand Down Expand Up @@ -1287,15 +1288,15 @@ DEV_ATAPI_WR:
pop bc
.loopsector:
push bc
ld iyl,c ; get the number of blocks per sector
LD_IYL_N C ;ld iyl,c ; get the number of blocks per sector
.loopblock:
call WAIT_DRQ
jr c,.rderr
ld de,IDE_DATA
call RUN_HLPR
call CHK_RW_FAULT
jr c,.rderr
dec iyl
DEC_IYL ;dec iyl
jp nz,.loopblock
pop bc
djnz .loopsector
Expand Down Expand Up @@ -1841,13 +1842,13 @@ LUN_NFO_ATAPI:

ld a,ATAPICMD.PACKET ; PIO send PACKET command
call PIO_CMD
jr c,.errorpop
jp c,.errorpop

pop hl
push hl ; Source=PCTBUF
ld bc,12 ; 12 byte packet
push iy
ld iyl,1
LD_IYL_N 1 ;ld iyl,1
call WRITE_DATA ; Send the packet to the device
pop iy
jr nc,.rdmediapropr ; No error? Then read media proprieties
Expand All @@ -1865,7 +1866,7 @@ LUN_NFO_ATAPI:
pop de ; Destination=PCTBUFF
ld bc,8 ; 8 byte response
push iy
ld iyl,1
LD_IYL_N 1 ;ld iyl,1
call READ_DATA
pop iy
jr c,LUN_INFO_ERROR
Expand Down Expand Up @@ -2462,7 +2463,7 @@ READ_DATA:
ret c
ld hl,IDE_DATA
call RUN_HLPR
dec iyl
DEC_IYL ;dec iyl
jp nz,.loop
ret

Expand All @@ -2481,7 +2482,7 @@ WRITE_DATA:
call RUN_HLPR
call CHK_RW_FAULT
ret c
dec iyl
DEC_IYL ;dec iyl
jp nz,.loop
ret

Expand Down

0 comments on commit 88374eb

Please sign in to comment.