Skip to content

Commit

Permalink
eZ80 Compatibility Enhancements
Browse files Browse the repository at this point in the history
See Issue #400
  • Loading branch information
wwarthen committed Oct 4, 2024
1 parent 5239eed commit fb9f977
Show file tree
Hide file tree
Showing 11 changed files with 90 additions and 11 deletions.
2 changes: 2 additions & 0 deletions Source/HBIOS/ez80cpudrv.asm
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@ DELAY:
RET

VDELAY:
EZ80_DELAY
EZ80_DELAY
EZ80_DELAY
DEC DE
LD A,D
Expand Down
1 change: 1 addition & 0 deletions Source/HBIOS/fd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,7 @@ FD_DETECT2:
; A FLOATING BUS.
CALL DLY32 ; WAIT A BIT
LD C,FDC_MSR ; POINT TO MSR PORT
EZ80_IO
IN A,(C) ; READ USING (C) FORM OF INPUT
;CALL PC_SPACE ; *DEBUG*
;CALL PRTHEXBYTE ; *DEBUG*
Expand Down
15 changes: 13 additions & 2 deletions Source/HBIOS/ide.asm
Original file line number Diff line number Diff line change
Expand Up @@ -1598,8 +1598,19 @@ IDE_WAIT001:
LD C,(IY+IDE_IOBASE)
LD B,8 ; NUMBER OF REGISTERS TO CHECK
IDE_WAIT002:
EZ80_IO
IN A,(C) ; GET REGISTER VALUE

; THE EZ80_IO ROUTINE SEEMS TO ALWAYS RETURN $00 FOR UNOCCUPIED
; PORTS. THAT CAUSES AN INORDINATE DELAY HERE, SO WE HANDLE
; 16 BIT I/O OURSELVES.

;;;EZ80_IO
;;;IN A,(C) ; GET REGISTER VALUE
PUSH BC ; SAVE LOOP CONTROL
LD B,$FF ; MSB FOR I/O
IN A,(C) ; READ PORT
POP BC ; RESTORE LOOP CONTROL
;CALL PC_SPACE
;CALL PRTHEXBYTE
OR A ; SET FLAGS
Expand Down
16 changes: 14 additions & 2 deletions Source/HBIOS/imm.asm
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ IMM_DETECT:
ADD A,IMM_IOSETUP ; BUMP TO SETUP PORT
LD C,A ; MOVE TO C FOR I/O
LD A,$82 ; CONFIG A OUT, B IN, C OUT
EZ80_IO
OUT (C),A ; DO IT
CALL DELAY ; BRIEF DELAY FOR GOOD MEASURE
#ENDIF
Expand Down Expand Up @@ -479,6 +480,7 @@ IMM_GEOM:
;
IMM_WRITEDATA:
LD C,(IY+IMM_IOBASE) ; DATA PORT IS AT IOBASE
EZ80_IO
OUT (C),A ; WRITE THE BYTE
;CALL DELAY ; IS THIS NEEDED???
RET ; DONE
Expand All @@ -501,6 +503,7 @@ IMM_WRITECTRL:
LD C,(IY+IMM_IOBASE) ; GET BASE IO ADDRESS
INC C ; BUMP TO CONTROL PORT
INC C
EZ80_IO
OUT (C),A ; WRITE TO CONTROL PORT
;CALL DELAY ; IS THIS NEEDED?
RET ; DONE
Expand All @@ -519,6 +522,7 @@ IMM_WRITECTRL:
IMM_READSTATUS:
LD C,(IY+IMM_IOBASE) ; IOBASE TO C
INC C ; BUMP TO STATUS PORT
EZ80_IO
IN A,(C) ; READ IT
;
#IF (IMMMODE == IMMMODE_MG014)
Expand Down Expand Up @@ -963,9 +967,11 @@ IMM_GETBLOCK:
;
IMM_GETBLOCK1:
EXX ; ALT REGS
EZ80_IO
OUT (C),D ; SEND FIRST CLOCK
IMM_GETBLOCK_A .EQU $+1
EZ80_IO
IN A,($FF) ; GET LOW NIBBLE
IMM_GETBLOCK_A .EQU $-1
#IF (IMMMODE == IMMMODE_MG014)
AND $0F ; RELEVANT BITS ONLY
ADD A,MG014_STATMAPLO & $FF ; LOW BYTE OF MAP PTR
Expand All @@ -981,9 +987,11 @@ IMM_GETBLOCK_A .EQU $+1
RLCA ; MOVE TO LOW NIBBLE
LD L,A ; SAVE NIBBLE IN L
#ENDIF
EZ80_IO
OUT (C),E ; SEND SECOND CLOCK
IMM_GETBLOCK_B .EQU $+1
EZ80_IO
IN A,($FF) ; GET HIGH NIBBLE
IMM_GETBLOCK_B .EQU $-1
#IF (IMMMODE == IMMMODE_MG014)
AND $0F ; RELEVANT BITS ONLY
ADD A,MG014_STATMAPHI & $FF ; HIGH BYTE OF MAP PTR
Expand Down Expand Up @@ -1079,13 +1087,17 @@ IMM_PUTBLOCK:
IMM_PUTBLOCK1:
LD A,(DE) ; GET NEXT BYTE
IMM_PUTBLOCK_A .EQU $+1
EZ80_IO
OUT ($FF),A ; PUT ON BUS
INC DE ; INCREMENT BUF POS
EZ80_IO
OUT (C),H ; FIRST CLOCK
LD A,(DE) ; GET NEXT BYTE
IMM_PUTBLOCK_B .EQU $+1
EZ80_IO
OUT ($FF),A ; PUT ON BUS
INC DE ; INCREMENT BUF POS
EZ80_IO
OUT (C),L ; SECOND CLOCK
DJNZ IMM_PUTBLOCK1 ; LOOP
RET ; DONE
Expand Down
5 changes: 5 additions & 0 deletions Source/HBIOS/kbd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ KBD_IST:
; A=0, Z SET FOR NOTHING PENDING, OTHERWISE DATA PENDING
;
LD C,(IY+KBD_ST) ; STATUS PORT
EZ80_IO
IN A,(C) ; GET STATUS
AND $01 ; ISOLATE INPUT PENDING BIT
RET
Expand All @@ -180,6 +181,7 @@ KBD_OST:
; A=0, Z SET FOR NOT READY, OTHERWISE READY TO WRITE
;
LD C,(IY+KBD_ST) ; STATUS PORT
EZ80_IO
IN A,(C) ; GET STATUS
AND $02 ; ISOLATE OUTPUT EMPTY BIT
XOR $02 ; FLIP IT FOR APPROPRIATE RETURN VALUES
Expand Down Expand Up @@ -210,6 +212,7 @@ KBD_PUTCMD1:
CALL PRTHEXBYTE
#ENDIF
LD C,(IY+KBD_CMD) ; COMMAND PORT
EZ80_IO
OUT (C),A ; WRITE IT
KBD_PUTCMD2:
XOR A ; SIGNAL SUCCESS
Expand Down Expand Up @@ -239,6 +242,7 @@ KBD_PUTDATA1:
CALL PRTHEXBYTE
#ENDIF
LD C,(IY+KBD_DAT) ; DATA PORT
EZ80_IO
OUT (C),A ; WRITE IT
KBD_PUTDATA2:
XOR A ; SIGNAL SUCCESS
Expand All @@ -259,6 +263,7 @@ KBD_GETDATA0:
RET
KBD_GETDATA1:
LD C,(IY+KBD_DAT) ; DATA PORT
EZ80_IO
IN A,(C) ; GET THE DATA VALUE
#IF (KBDTRACE >= 2)
PUSH AF
Expand Down
17 changes: 15 additions & 2 deletions Source/HBIOS/lcd.asm
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,17 @@ LCD_PREINIT:
; RESET LCD CONTROLLER, DELAYS ARE FIXED, BUSY FLAG
; CANNOT BE USED YET, CONTROLLER MAY NOT EXIST!
LD A,LCD_FUNC_SET | %11000
EZ80_IO
OUT (LCD_FUNC),A
LD DE,50000/16 ; WAIT >40MS, WE USE 50MS
CALL VDELAY ; DO IT
LD A,LCD_FUNC_SET | %11000
EZ80_IO
OUT (LCD_FUNC),A
LD DE,5000/16 ; WAIT >4.1MS, WE USE 5MS
CALL VDELAY ; DO IT
LD A,LCD_FUNC_SET | %11000
EZ80_IO
OUT (LCD_FUNC),A
LD DE,5000/16 ; WAIT >4.1MS, WE USE 5MS
CALL VDELAY ; DO IT
Expand Down Expand Up @@ -78,7 +81,7 @@ LCD_PREINIT:
CALL LCD_GOTORC
LD HL,LCD_CPU
LD A,(HB_CPUTYPE) ; GET CPU TYPE
RRCA ; WORD OFFSET
RLCA ; WORD OFFSET
CALL ADDHLA ; ADD OFFSET
LD E,(HL) ; GET LSB
INC HL ; BUMP
Expand Down Expand Up @@ -316,14 +319,18 @@ LCD_DETECT_Z:
LCD_DETECT_PASS:
CALL LCD_DELAY ; WAIT
LD A,LCD_FUNC_DDADR
EZ80_IO
OUT (LCD_FUNC),A ; POINT TO FIRST BYTE
CALL LCD_DELAY ; WAIT
LD A,C ; TEST VALUE
EZ80_IO
OUT (LCD_DATA),A ; WRITE IT
CALL LCD_DELAY ; WAIT
LD A,LCD_FUNC_DDADR
EZ80_IO
OUT (LCD_FUNC),A ; POINT TO FIRST BYTE
CALL LCD_DELAY
EZ80_IO
IN A,(LCD_DATA) ; GET VALUE
CP C ; AS WRITTEN?
RET
Expand All @@ -340,10 +347,12 @@ LCD_DELAY:
LCD_OUTF:
PUSH AF ; SAVE CODE
LCD_OUTF1:
EZ80_IO
IN A,(LCD_STAT) ; GET STATUS
AND $80 ; ISOLATE BUSY FLAG
JR NZ,LCD_OUTF1 ; LOOP TILL NOT BUSY
POP AF ; RECOVER CODE
EZ80_IO
OUT (LCD_FUNC),A ; SEND IT
RET ; DONE
;
Expand All @@ -363,10 +372,12 @@ LCD_OUTFS:
LCD_OUTD:
PUSH AF ; SAVE BYTE
LCD_OUTD1:
EZ80_IO
IN A,(LCD_STAT) ; GET STATUS
AND $80 ; ISOLATE BUSY FLAG
JR NZ,LCD_OUTD1 ; LOOP TILL NOT BUSY
POP AF ; RECOVER BYTE
EZ80_IO
OUT (LCD_DATA),A ; SEND IT
RET ; DONE
;
Expand Down Expand Up @@ -397,10 +408,12 @@ LCD_OUTDS:
; GET DATA BYTE INTO A
;
LCD_IND:
EZ80_IO
IN A,(LCD_STAT) ; GET STATUS
AND $80 ; ISOLATE BUSY FLAG
JR NZ,LCD_IND ; LOOP TILL NOT BUSY
POP AF ; RECOVER BYTE
EZ80_IO
IN A,(LCD_DATA) ; GET IT
RET ; DONE
;
Expand Down Expand Up @@ -488,7 +501,7 @@ LCD_CPU_Z180 .DB "Z180",0
LCD_CPU_Z180K .DB "Z180-K",0
LCD_CPU_Z180N .DB "Z180-N",0
LCD_CPU_Z280 .DB "Z280",0
LCD_CPU_EZ80 .DB "EZ80",0
LCD_CPU_EZ80 .DB "eZ80",0
;
LCD_MSGTBL:
.DW LCD_MSG_LDR_SEL
Expand Down
17 changes: 17 additions & 0 deletions Source/HBIOS/lpt.asm
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ LPT_OUT:
CALL LPT_OST ; READY TO SEND?
JR Z,LPT_OUT ; LOOP IF NOT
LD C,(IY+3) ; PORT 0 (DATA)
EZ80_IO
OUT (C),E ; OUTPUT DATA TO PORT
#IF (LPTMODE == LPTMODE_SPP)
LD A,%00001101 ; SELECT & STROBE, LEDS OFF
Expand All @@ -185,6 +186,7 @@ LPT_OUT:
#IF (LPTMODE == LPTMODE_S100)
DEC C ; PUT CONTROL PORT IN C
#ENDIF
EZ80_IO
OUT (C),A ; OUTPUT DATA TO PORT
CALL DELAY
#IF (LPTMODE == LPTMODE_SPP)
Expand All @@ -196,6 +198,7 @@ LPT_OUT:
#IF (LPTMODE == LPTMODE_S100)
LD A,%11111111 ; STROBE
#ENDIF
EZ80_IO
OUT (C),A ; OUTPUT DATA TO PORT
CALL DELAY
XOR A ; SIGNAL SUCCESS
Expand All @@ -218,6 +221,7 @@ LPT_OST:
#IF (LPTMODE == LPTMODE_S100)
DEC C ; SELECT STATUS PORT
#ENDIF
EZ80_IO
IN A,(C) ; GET STATUS INFO
#IF (LPTMODE == LPTMODE_SPP)
AND %10000000 ; ISOLATE /BUSY
Expand Down Expand Up @@ -245,13 +249,16 @@ LPT_INITDEVX:
;
LD C,(IY+3) ; PORT 0 (DATA)
XOR A ; CLEAR ACCUM
EZ80_IO
OUT (C),A ; SEND IT
INC C ; BUMP TO
INC C ; ... PORT 2
LD A,%00001000 ; SELECT AND ASSERT RESET, LEDS OFF
EZ80_IO
OUT (C),A ; SEND IT
CALL LDELAY ; HALF SECOND DELAY
LD A,%00001100 ; SELECT AND DEASSERT RESET, LEDS OFF
EZ80_IO
OUT (C),A ; SEND IT
XOR A ; SIGNAL SUCCESS
RET ; RETURN
Expand All @@ -263,12 +270,15 @@ LPT_INITDEVX:
ADD A,3 ; BUMP TO CONTROL PORT
LD C,A ; MOVE TO C FOR I/O
LD A,$82 ; CONFIG A OUT, B IN, C OUT
EZ80_IO
OUT (C),A ; DO IT
DEC C ; OUTPUT PORT
LD A,$81 ; STROBE OFF, SELECT ON, RES ON, LED ON
EZ80_IO
OUT (C),A ; SEND IT
CALL LDELAY ; HALF SECOND DELAY
LD A,$05 ; STROBE OFF, SELECT ON, RES OFF, LED OFF
EZ80_IO
OUT (C),A ; SEND IT
XOR A ; SIGNAL SUCCESS
RET ; RETURN
Expand All @@ -278,6 +288,7 @@ LPT_INITDEVX:
LD C,(IY+3) ; BASE PORT
DEC C ; DEC TO CONTROL PORT
LD A,$FF ; INIT VALUE
EZ80_IO
OUT (C),A ; DO IT
RET ; RETURN
#ENDIF
Expand Down Expand Up @@ -330,6 +341,7 @@ LPT_DETECT2:
INC C ; PORT C FOR I/O
INC C ; ...
XOR A ; DEFAULT VALUE (TRI-STATE OFF)
EZ80_IO
OUT (C),A ; SEND IT
;
;IN A,(C) ; READ IT
Expand All @@ -345,7 +357,9 @@ LPT_DETECT2:
DEC C ; BACK TO BASE PORT
DEC C ; ...
LD A,$A5 ; TEST VALUE
EZ80_IO
OUT (C),A ; SEND IT
EZ80_IO
IN A,(C) ; READ IT BACK
CP $A5 ; CORRECT?
RET ; RETURN (ZF SET CORRECTLY)
Expand All @@ -366,11 +380,14 @@ LPT_DETECT:
ADD A,3 ; BUMP TO CONTROL PORT
LD C,A ; PUT IN C
LD A,$80 ; SET PORT A TO WRITE
EZ80_IO
OUT (C),A ; WRITE IT
;
LD C,(IY+3) ; PPI PORT A
LD A,$A5 ; TEST VALUE
EZ80_IO
OUT (C),A ; PUSH VALUE TO PORT
EZ80_IO
IN A,(C) ; GET PORT VALUE
#IF (LPTTRACE >= 3)
CALL PC_SPACE
Expand Down
Loading

0 comments on commit fb9f977

Please sign in to comment.