Skip to content

Commit

Permalink
address some api issues from #66
Browse files Browse the repository at this point in the history
  • Loading branch information
stevesims committed Nov 24, 2024
1 parent 48ba8f5 commit c5c431d
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/mos_api.asm
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,7 @@ mos_api_block2_size: EQU ($ - mos_api_block2_start) / 2

mos_api_not_implemented:
LD HL, 23 ; MOS_NOT_IMPLEMENTED
LD A, 23 ; MOS_NOT_IMPLEMENTED
RET

; Get keycode
Expand Down Expand Up @@ -527,7 +528,7 @@ mos_api_sysvars: LD IX, _sysvars
; Invoke the line editor
; HLU: Address of the buffer
; BCU: Buffer length
; E: 0 to not clear buffer, 1 to clear
; E: flags
; Returns:
; A: Key that was used to exit the input loop (CR=13, ESC=27)
;
Expand All @@ -538,7 +539,7 @@ mos_api_editline: LD A, MB ; Check if MBASE is 0
;
CALL NZ, SET_AHL24 ; If it is running in classic Z80 mode, set U to MB
;
PUSH DE ; UINT8 clear
PUSH DE ; UINT8 flags
PUSH BC ; int bufferLength
PUSH HL ; char * buffer
CALL _mos_EDITLINE
Expand All @@ -554,6 +555,7 @@ mos_api_editline: LD A, MB ; Check if MBASE is 0
; Returns:
; A: Filehandle, or 0 if couldn't open
;
; TODO: why the push/pop of HL, DE, IX and IY?
mos_api_fopen: PUSH BC
PUSH DE
PUSH HL
Expand Down Expand Up @@ -965,7 +967,10 @@ mos_api_getfil: PUSH BC ; UINT8 fh
; Returns:
; DEU: Number of bytes read
;
mos_api_fread: PUSH DE ; UINT24 btr
mos_api_fread: LD A, MB ; Check if MBASE is 0
OR A, A
CALL NZ, SET_AHL24
PUSH DE ; UINT24 btr
PUSH HL ; UINT24 buffer
PUSH BC ; UINT8 fh
CALL _mos_FREAD
Expand All @@ -983,7 +988,10 @@ mos_api_fread: PUSH DE ; UINT24 btr
; Returns:
; DEU: Number of bytes read
;
mos_api_fwrite: PUSH DE ; UINT24 btr
mos_api_fwrite: LD A, MB ; Check if MBASE is 0
OR A, A
CALL NZ, SET_AHL24
PUSH DE ; UINT24 btr
PUSH HL ; UINT24 buffer
PUSH BC ; UINT8 fh
CALL _mos_FWRITE
Expand Down Expand Up @@ -1165,10 +1173,9 @@ ffs_api_fread: LD A, MB ; A: MB
LD A, MB ; A: MB
CALL Z, SET_AHL24 ; No it's zero, so convert HL to an address in segment A (MB)
;
$$: EXX
LD HL, _scratchpad ; Scratchpad RAM
PUSH HL ; UINT * br
EXX
$$: PUSH HL
LD HL, _scratchpad
EX (SP), HL ; UINT * br
PUSH BC ; UINT btr
PUSH DE ; void * buff
PUSH HL ; FILE * fp
Expand Down Expand Up @@ -1198,10 +1205,9 @@ ffs_api_fwrite: LD A, MB ; A: MB
LD A, MB ; A: MB
CALL Z, SET_AHL24 ; No it's zero, so convert HL to an address in segment A (MB)
;
$$: EXX
LD HL, _scratchpad ; Scratchpad RAM
PUSH HL ; UINT * bw
EXX
$$: PUSH HL
LD HL, _scratchpad
EX (SP), HL ; UINT * bw
PUSH BC ; UINT btw
PUSH DE ; void * buff
PUSH HL ; FILE * fp
Expand Down

0 comments on commit c5c431d

Please sign in to comment.