mirror of https://github.com/wwarthen/RomWBW.git
committed by
GitHub
37 changed files with 723 additions and 415 deletions
@ -0,0 +1,33 @@ |
|||
|
|||
|
|||
CLI_ABRT_IF_OPT_FIRST: |
|||
LD A, (FCB+1) |
|||
CP '-' ; OPTION FIRST OR - MISSING FILENAME? |
|||
JP Z, ERRCMD ; SHOW USAGE |
|||
RET |
|||
|
|||
CLI_HAVE_HBIOS_SWITCH: |
|||
LD HL, CLIARGS ; TEST FOR --HBIOS ON COMNMAND LINE |
|||
LD DE, HBIOSOPT |
|||
CALL STRINDEX |
|||
JR NZ, CLI_HAVE_HBIOS_SWITCH1 |
|||
OR $FF ; IS NOT HBIOS |
|||
LD (HBIOSMD), A |
|||
RET |
|||
CLI_HAVE_HBIOS_SWITCH1: |
|||
AND 0 ; IS HBIOS |
|||
LD (HBIOSMD), A |
|||
RET |
|||
|
|||
CLI_ABRT_UNSUPPFILTYP: |
|||
PUSH AF |
|||
ISHBIOS |
|||
JR Z, CLI_ABRT_UNSUPPFILTYP1 |
|||
POP AF |
|||
CP TYPMYM |
|||
RET NZ |
|||
ERRWITHMSG(MSGUNSUP) ; EXIT WITH UNSUPPORTED FILE TYPE MESSAGE |
|||
|
|||
CLI_ABRT_UNSUPPFILTYP1: |
|||
POP AF |
|||
RET |
|||
@ -0,0 +1,4 @@ |
|||
CLIARGS .EQU $81 |
|||
RESTART .EQU $0000 ; CP/M restart vector |
|||
BDOS .EQU $0005 ; BDOS invocation vector |
|||
FCB .EQU $5C ; Location of default FCB |
|||
@ -0,0 +1,15 @@ |
|||
IDENT .EQU $FFFE ; loc of RomWBW HBIOS ident ptr |
|||
; |
|||
RMJ .EQU 3 ; intended CBIOS version - major |
|||
RMN .EQU 1 ; intended CBIOS version - minor |
|||
; |
|||
BF_SYSVER .EQU $F1 ; BIOS: VER function |
|||
BF_SYSGET .EQU $F8 ; HBIOS: SYSGET function |
|||
; |
|||
|
|||
BF_SND .EQU $50 |
|||
BF_SNDRESET .EQU BF_SND + 0 ; RESET SOUND SYSTEM |
|||
BF_SNDVOL .EQU BF_SND + 1 ; REQUEST SOUND VOL - D IS CHANNEL, E CONTAINS VOLUME (255 MAX, 0 SILENT) - SCALED AS REQUIRED BY DRIVER (EG: MAPS TO JUST 4 BIT RESOLUTION FOR SN76489) |
|||
BF_SNDPIT .EQU BF_SND + 2 ; REQUEST SOUND PITCH - D IS CHANNEL, HL CONTAINS PITCH (0 LOWEST NOTE, FFFF HIGHEST NOTE) - SCALED BY DRIVER (EG: MAPS TO JUST 10 BITS FOR SN76489 ) |
|||
BF_SNDPLAY .EQU BF_SND + 4 ; INITIATE THE REQUESTED SOUND COMMAND |
|||
BF_SNDQUERY .EQU BF_SND + 5 ; D IS CHANNEL, E IS SUBCOMMAND |
|||
@ -0,0 +1,175 @@ |
|||
; |
|||
; Print character in A without destroying any registers |
|||
; |
|||
PRTCHR: |
|||
PUSH BC ; save registers |
|||
PUSH DE |
|||
PUSH HL |
|||
LD E,A ; character to print in E |
|||
LD C,$02 ; BDOS function to output a character |
|||
CALL BDOS ; do it |
|||
POP HL ; restore registers |
|||
POP DE |
|||
POP BC |
|||
RET |
|||
; |
|||
PRTDOT: |
|||
; |
|||
; shortcut to print a dot preserving all regs |
|||
PUSH AF ; save af |
|||
LD A,'.' ; load dot char |
|||
CALL PRTCHR ; print it |
|||
POP AF ; restore af |
|||
RET ; done |
|||
; |
|||
PRTCR: |
|||
; |
|||
; shortcut to print a dot preserving all regs |
|||
PUSH AF ; save af |
|||
LD A,13 ; load CR value |
|||
CALL PRTCHR ; print it |
|||
POP AF ; restore af |
|||
RET ; done |
|||
; |
|||
; Print a zero terminated string at (DE) without destroying any registers |
|||
; |
|||
PRTSTR: |
|||
PUSH DE |
|||
; |
|||
PRTSTR1: |
|||
LD A,(DE) ; get next char |
|||
OR A |
|||
JR Z,PRTSTR2 |
|||
CALL PRTCHR |
|||
INC DE |
|||
JR PRTSTR1 |
|||
; |
|||
PRTSTR2: |
|||
POP DE ; restore registers |
|||
RET |
|||
; |
|||
; Print the value in A in hex without destroying any registers |
|||
; |
|||
PRTHEX: |
|||
PUSH AF ; save AF |
|||
PUSH DE ; save DE |
|||
CALL HEXASCII ; convert value in A to hex chars in DE |
|||
LD A,D ; get the high order hex char |
|||
CALL PRTCHR ; print it |
|||
LD A,E ; get the low order hex char |
|||
CALL PRTCHR ; print it |
|||
POP DE ; restore DE |
|||
POP AF ; restore AF |
|||
RET ; done |
|||
; |
|||
; print the hex word value in bc |
|||
; |
|||
PRTHEXWORD: |
|||
PUSH AF |
|||
LD A,B |
|||
CALL PRTHEX |
|||
LD A,C |
|||
CALL PRTHEX |
|||
POP AF |
|||
RET |
|||
; |
|||
; print the hex dword value in de:hl |
|||
; |
|||
PRTHEX32: |
|||
PUSH BC |
|||
PUSH DE |
|||
POP BC |
|||
CALL PRTHEXWORD |
|||
PUSH HL |
|||
POP BC |
|||
CALL PRTHEXWORD |
|||
POP BC |
|||
RET |
|||
; |
|||
; Convert binary value in A to ascii hex characters in DE |
|||
; |
|||
HEXASCII: |
|||
LD D,A ; save A in D |
|||
CALL HEXCONV ; convert low nibble of A to hex |
|||
LD E,A ; save it in E |
|||
LD A,D ; get original value back |
|||
RLCA ; rotate high order nibble to low bits |
|||
RLCA |
|||
RLCA |
|||
RLCA |
|||
CALL HEXCONV ; convert nibble |
|||
LD D,A ; save it in D |
|||
RET ; done |
|||
|
|||
; |
|||
; Convert low nibble of A to ascii hex |
|||
; |
|||
HEXCONV: |
|||
AND $0F ; low nibble only |
|||
ADD A,$90 |
|||
DAA |
|||
ADC A,$40 |
|||
DAA |
|||
RET |
|||
|
|||
; |
|||
; Print value of A or HL in decimal with leading zero suppression |
|||
; Use prtdecb for A or prtdecw for HL |
|||
; |
|||
PRTDECB: |
|||
PUSH HL |
|||
LD H,0 |
|||
LD L,A |
|||
CALL PRTDECW ; print it |
|||
POP HL |
|||
RET |
|||
; |
|||
PRTDECW: |
|||
PUSH AF |
|||
PUSH BC |
|||
PUSH DE |
|||
PUSH HL |
|||
CALL PRTDEC0 |
|||
POP HL |
|||
POP DE |
|||
POP BC |
|||
POP AF |
|||
RET |
|||
; |
|||
PRTDEC0: |
|||
LD E,'0' |
|||
LD BC,-10000 |
|||
CALL PRTDEC1 |
|||
LD BC,-1000 |
|||
CALL PRTDEC1 |
|||
LD BC,-100 |
|||
CALL PRTDEC1 |
|||
LD C,-10 |
|||
CALL PRTDEC1 |
|||
LD E,0 |
|||
LD C,-1 |
|||
PRTDEC1: |
|||
LD A,'0' - 1 |
|||
PRTDEC2: |
|||
INC A |
|||
ADD HL,BC |
|||
JR C,PRTDEC2 |
|||
SBC HL,BC |
|||
CP E |
|||
RET Z |
|||
LD E,0 |
|||
CALL PRTCHR |
|||
RET |
|||
; |
|||
; Start a new line |
|||
; |
|||
CRLF2: |
|||
CALL CRLF ; two of them |
|||
CRLF: |
|||
PUSH AF ; preserve AF |
|||
LD A,13 ; <CR> |
|||
CALL PRTCHR ; print it |
|||
LD A,10 ; <LF> |
|||
CALL PRTCHR ; print it |
|||
POP AF ; restore AF |
|||
RET |
|||
@ -0,0 +1,39 @@ |
|||
STRINDEX: ; SEARCH FOR STRING AT DE WITHIN STRING AT HL |
|||
|
|||
LD B, 0 |
|||
LD C, 0 |
|||
|
|||
TRYNEXT: |
|||
PUSH HL |
|||
PUSH DE |
|||
CALL STRCMP |
|||
POP DE |
|||
POP HL |
|||
RET Z |
|||
|
|||
INC HL |
|||
INC BC |
|||
LD A, (HL) |
|||
OR A |
|||
JR NZ, TRYNEXT |
|||
|
|||
OR $FF ; RETURN NZ |
|||
RET |
|||
|
|||
STRCMP: ; COMPARE STRING AT HL WITH DE - RETURN Z IF LIKE |
|||
LD A, (DE) |
|||
OR A |
|||
RET Z |
|||
|
|||
LD B, A |
|||
LD A, (HL) |
|||
OR A |
|||
JR NZ, STRCMP1 |
|||
OR $FF ; END OF STRING HL - SO NOT FOUND |
|||
RET |
|||
STRCMP1 |
|||
CP B |
|||
RET NZ |
|||
INC HL |
|||
INC DE |
|||
JR STRCMP |
|||
@ -0,0 +1,60 @@ |
|||
|
|||
; |
|||
; Wait for quark play time. Can use hardware timer if |
|||
; supported by hardware or simple delay loop otherwise. |
|||
; Delay loop requires QDLY to be pre-set to to achieve |
|||
; optimal 20ms wait time. |
|||
; |
|||
WAITQ LD A,(WMOD) ; Get delay mode |
|||
OR A ; Set flags |
|||
JR Z,DLY ; Delay mode |
|||
; |
|||
; Timer loop |
|||
CALL TIM2 ; Read timer LSB into A |
|||
LD C,A ; Init prev value |
|||
TIM1 PUSH BC ; Save prev value |
|||
CALL TIM2 ; Read timer LSB into A |
|||
POP BC ; Recover prev value |
|||
CP C ; Compare to prev |
|||
RET NZ ; Done if changed |
|||
JR TIM1 ; Else, loop |
|||
; |
|||
TIM2 LD B,$F8 ; BIOS SYSGET function |
|||
LD C,$D0 ; TIMER sub-function |
|||
RST 08 ; Call BIOS |
|||
LD A,L ; MSB to A |
|||
RET ; Return to loop |
|||
; |
|||
; Delay spin loop (40 tstates per loop) |
|||
DLY LD BC,(QDLY) ; Load quark delay factor |
|||
DLY1 DEC BC ; [6] |
|||
NOP ; [4] |
|||
NOP ; [4] |
|||
NOP ; [4] |
|||
NOP ; [4] |
|||
LD A,B ; [4] |
|||
OR C ; [4] |
|||
JP NZ,DLY1 ; [10] |
|||
RET |
|||
|
|||
; |
|||
; Test for timer running to determine if it can be used for delay |
|||
; Return string message in DE |
|||
; Assigned (WMOD) with 0 if no hardware time, 1 if hardware timer found |
|||
; |
|||
PROBETIMER: |
|||
LD B,BF_SYSGET ; HBIOS: GET function |
|||
LD C,$D0 ; TIMER subfunction |
|||
RST 08 ; DE:HL := current tick count |
|||
LD A,L ; DE:HL == 0? |
|||
OR H |
|||
OR E |
|||
OR D |
|||
LD A,0 ; Assume no timer |
|||
LD DE,MSGDLY ; Delay mode msg |
|||
JR Z,SETDLY ; If tick count is zero, no timer active |
|||
LD A,$FF ; Value for timer active |
|||
LD DE,MSGTIM ; Timer mode msg |
|||
SETDLY: |
|||
LD (WMOD),A ; Save wait mode |
|||
RET |
|||
@ -0,0 +1,4 @@ |
|||
#DEFINE ISHBIOS LD A, (HBIOSMD) \ OR A |
|||
#DEFINE PRTSTRDE(X) LD DE, X \ CALL PRTSTR |
|||
#DEFINE PRTCRLF CALL CRLF |
|||
#DEFINE ERRWITHMSG(X) LD DE, X \ JP ERR |
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue