title Cdos system calls ; *include cdos.def ; syscall call usrsav ;(17+160+10=187) save state push ix ;(15)\ pop bc ;(10) \ ld ix,(usrtab$) ;(20) \ ld hl,date5c4 ;(10) \ ld (ix+u.ddiskb),l ;(19) \ ld (ix+u.ddiskb+1),h ;(19) \ ld l,(ix+u.diskb) ;(19) \(232) ld h,(ix+u.diskb+1) ;(19) / ld (ix+u.sdiskb),l ;(19) / ld (ix+u.sdiskb+1),h ;(19) / ld hl,0 ;(10) get the stack pointer into HL add hl,sp ;(15) / ld (ix+u.rspl),l ;(19) Save the stack pointer ld (ix+u.rsph),h ;(19)/ call gistat ;17+29=46)get interrupt state ld (ix+u.riff),a ;(19)\ save interrupt state ld a,(ix+013h) ;(19) (42) and a ; (4)/ jr nz,pgmbba2 ;(7/12) ld sp,sysstk ;(10) create local stack pgmbba2 push bc ;(11)\ push de ;(11) \ ex (sp),iy ;(23) \ ld hl,sjtab1 ;(10) (85) ld d,[sjtab1e-sjtab1]/2 ; (7) / ld a,(ix+u.rc) ;(19) / and a ; (4)/ test msb - tells which table jp p,pgmbbb9 ;(10) which table? ld hl,sjtab2 ;(10) ld d,[sjtab2e-sjtab2]/2 ; (7) and 07fh ; (7) pgmbbb9 cp d ; (4)\ jr nc,syserr ; (7) (not taken) ld c,a ; (4) \ ld b,0 ; (7) \ add hl,bc ;(11) \ add hl,bc ;(11) \(96) ld e,(hl) ; (7) / inc hl ; (6) / ld d,(hl) ; (7) / ld hl,sysret ;(10) return address on stack push hl ;(11) / push de ;(11)/ jp usrrstr ;(17+187=204) restore state and return ; sysret ld a,(ix+u.riff) ;(19)\ return from system call ld l,(ix+u.rspl) ;(19) \ ld h,(ix+u.rsph) ;(19) \ pop iy ;(15) \ pop ix ;(15) (128) ld sp,hl ;(15) / and a ; (4)restore interrupts, if necessary jr z,pgmbbde ;((7)/12) ei ; ((4)) pgmbbde jp usrrstr ;(10)/ ; syserr ld c,u.rc call getusr$ ld (illsysn),hl ld c,u.rspl call getusr$ ld e,(hl) inc hl ld d,(hl) ex de,hl dec hl dec hl dec hl ld (illsys$),hl ld hl,illsysm call fprint jp $abort ; illsysm db 'Illegal system call ',80h illsysn db 0,0,'h at ',81h illsys$ db 0,0,'h',cr,lf,0 ; usrsav push af ;(11)\ save on user's stack push de ;(11) \ ex de,hl ; (4) \point HL to user save table ld hl,(usrtab$) ;(16) \ ld (hl),e ; (7) \save user's HL in usrtab inc hl ; (6) \ ld (hl),d ; (7) \ pop de ;(10) \save user's DE in usetab inc hl ; (6) \ ld (hl),e ; (7) \ inc hl ; (6) }(160) ld (hl),d ; (7) / inc hl ; (6) /save user's BC in usrtab ld (hl),c ; (7) / inc hl ; (6) / ld (hl),b ; (7) / pop de ;(10) /save user's AF in usertab inc hl ; (6) / ld (hl),e ; (7) / inc hl ; (6) / ld (hl),d ; (7)/ <<>> Assume one, (10) usrrstr ld hl,(usrtab$) ;(16)\recover register values from user table ld c,(hl) ; (7) \get user's HL and push ont user's stack inc hl ; (6) \ ld b,(hl) ; (7) \ push bc ;(11) \ inc hl ; (6) \get user's DE and push onto stack ld c,(hl) ; (7) \ inc hl ; (6) \ ld b,(hl) ; (7) \ push bc ;(11) \ inc hl ; (6) \recover user's BC ld c,(hl) ; (7) (187) inc hl ; (6) / ld b,(hl) ; (7) / inc hl ; (6) /push user's AF onto stack ld e,(hl) ; (7) / inc hl ; (6) / ld d,(hl) ; (7) / push de ;(11) / pop af ;(10) /restore AF pop de ;(10) /restore DE pop hl ;(10) /restore HL ret ;(10)/ ; usra ld (ix+u.ra),a ret ; usrbc ld (ix+u.rc),l ld (ix+u.rb),h ret ; sjtab1 dw $abort dw $conine dw $conout dw $rdrin dw $punout dw $lstout dw $conio dw $getiob dw $setiob dw $wrline dw $rdline dw $consta dw sys0c dw $reset dw $select dw $open dw $close dw $search dw $findnx dw $delete dw $rdnext dw $wrnext dw $create dw $rename dw $getdlv dw $getcur dw $setbuf dw $getall dw sysret dw $getwpv dw sysret dw syserr dw $usrcod dw $rdrand dw $wrrand dw $filsiz dw $setrnd dw sysret dw syserr dw syserr dw sys28 sjtab1e equ $ ; sjtab2 dw $conin dw $getusr dw $setabo dw $rdlogi dw $wrlogi dw sysret dw $format dw $dirupd dw $lnkpgm dw $mult dw $divd dw $home dw $eject dw $versio dw $setspe dw $setdat dw $getdat dw $settim dw $gettim dw $setret dw $setatt dw $rdlabe dw $mtroff dw $setram dw $rdcurr dw $wrcurr dw $chkall dw sys9b dw $dir dw $setopt dw $delext dw $getmst dw sysa0 dw sysa1 dw $desele sjtab2e equ $ ; trapcc push ix push iy push hl push de push bc push af ld c,u.trap$ call getusr$ ld a,h and l cp -1 jr nz,trapgo trapret pop af pop bc pop de pop hl pop iy pop ix ret ; trapgo ex de,hl ld hl,0 add hl,sp push hl ld c,u.rspl call getusr$ pop bc ld sp,hl push bc ex de,hl call jumphl pop hl ld sp,hl jr trapret ; jumphl jp (hl) ; ; Program abort ; $abort ld ix,(usrtab$) ld sp,sysstk call resdlv ld hl,(usrtab$) ld bc,u.curdsk add hl,bc ld a,(hl) push af push hl call resdsk pop hl pop af ld (hl),a ld de,2feh call $setopt modbd4a jp reenter ; ; Deselect current disk ; $desele ld b,(ix+u.curdsk) call pgmc365 ld c,001h jp pgmbdce ; ; Select current disk ; $select call drvok jr c,ss0e1 ld (ix+u.curdsk),e ss0e1 jp usra ; ; Get disk login vector ; $getdlv ld a,(dlogvct) jp usra ; ; Get current disk ; $getcur ld a,(ix+u.curdsk) jp usra ; ; Set disk buffer ; $setbuf ld c,u.diskb jp setusrx ; ; Get disk cluster map ; $getall ld b,(ix+u.curdsk) call pgmc379 ld b,(ix+u.curdsk) call pgmc34e call usrbc ld l,005h call gtddat$ ld a,(hl) call usra ld l,01ah call gtddat$ ld a,(hl) inc hl ld h,(hl) ld l,a ld c,u.re call setusr$ ld hl,0 ld c,u.rl jp setusr$ ; ; Get user register pointer ; $getusr ld hl,usrtab$ jp usrbc ; ; Set control c trap ; $setabo ld a,d or e jr nz,pgmbdaf ld de,$abort pgmbdaf ld c,u.trap$ jp setusrx ; ; Read logical block ; $rdlogi ld c,4 jr ss834 ; ; Write logical block ; $wrlogi ld c,6 ss834 bit 6,b jr nz,pgmbdc0 ld l,0 pgmbdc0 ld a,l push af ld a,b rlca and 001h add a,c ld c,u.diskb call getusr$ ld c,a pop af pgmbdce push af push bc push de ld a,b and 00fh jr z,pgmbddd ld e,a dec e call drvok jr c,pgmbdee pgmbddd ld a,b and 00fh call gtdrv1 ld a,b pop de pop bc ld b,a pop af call diskio pgmbdeb jp usra ; pgmbdee pop de pop bc pop af ld a,004h jr pgmbdeb ; ; Home drive ; $home ld c,00ah jr pgmbdce ; ; Eject disk ; $eject ld b,e ld c,003h jr pgmbdce ; ; Get O/S Version ; $versio ld hl,version call usrbc ld hl,0 ld a,l jp usra ; ; Set date ; $setdat ld hl,year settime ld (hl),e inc hl ld (hl),d inc hl ld (hl),b ret ; ; Set time ; $settim ld hl,year inc hl inc hl inc hl call settime jp i.strtck ; ; Read date ; $getdat ld hl,year jr rdtime ; ; Read time ; $gettim ld hl,year inc hl inc hl inc hl rdtime push hl call i.readck pop hl ld e,(hl) inc hl ld d,(hl) inc hl ex de,hl call usrbc ld a,(de) jp usra ; ; Set program return code ; $setret ld (ix+u.prgret),a ret ; ; Set ramtop ; $setram ld a,e ld hl,(maxramt) cp h jr c,pgmbe48 ld e,h pgmbe48 ld d,e ld e,0 ld hl,(ramtopv) ld (ramtopv),de ld (6),de ld bc,9 ldir ret ; ; Set options ; $setopt ld a,e and 04fh ld e,a and (ix+u.opts) call usra ld a,e cpl and (ix+u.opts) or d ld (ix+u.opts),a ret ; ; Get master drive ; $getmst ld a,(ix+u.mstdk) ld (ix+u.ra),a ld a,(ix+u.lstbdrv) ld (ix+u.rb),a ret ; sysa0 ld c,00ch jr pgmbe83 ; sysa1 ld c,00eh pgmbe83 ld a,l push af ld a,b rlca and 001h add a,c ld c,u.diskb call getusr$ ld c,a pop af jp pgmbdce ; ; Read/Write console ; $conio ld a,e cp -1 jp nz,i.cout call i.cstat call nz,i.cin jp usra ; ; Deselect current disk ? ; sys0c ld (ix+u.rh),0 ld (ix+u.rb),0 ld (ix+u.rl),22h ld (ix+u.ra),22h ret ; ; Returns with a = 0 & hl = 0 ; $getwpv sub a call usra ld hl,0 ld c,u.rl jp setusr$ ; $usrcod ld a,e dec a jr z,pgmbec8 ld (ix+02bh),a ret ; pgmbec8 ld e,(ix+02bh) ld (ix+u.re),e ret ; ; Read random record ; $rdrand sub a call pgmbedf jp nc,$rdcurr ret ; ; Write random record ; $wrrand scf call pgmbedf jp nc,$wrcurr ret ; ; iy = de (on entry) ; pgmbedf push af ld a,(iy+023h) and a jr nz,pgmbf32 ld a,(iy+022h) add a,a ld b,a ld a,006h jr c,pgmbf32 ld a,(iy+021h) bit 7,a jr z,pgmbef7 inc b pgmbef7 and 07fh ld c,a ld a,b push bc cp (iy+00ch) jr z,pgmbf26 call $close inc a ld a,003h jr z,pgmbf31 pop bc ld (iy+00ch),b push bc call $open inc a jr nz,pgmbf26 pop bc pop af push af push bc ld a,004h jr nc,pgmbf31 push de call $create pop de inc a ld a,005h jr z,pgmbf31 pgmbf26 pop bc pop af ld (iy+00ch),b ld (iy+020h),c sub a jr pgmbf34 ; pgmbf31 pop bc pgmbf32 pop bc scf pgmbf34 call usra ret ; $filsiz call pgmc370 call pgmc252 ld hl,00 pgmbf41 push hl call pgmc7e4 jr c,pgmbf52 pop hl jr nz,pgmbf53 ld a,b cp h jr c,pgmbf41 ld h,b ld l,c jr pgmbf41 ; pgmbf52 pop bc pgmbf53 jr pgmbf5b ; subttl system call 24h ; ; Set position for random read/write ; $setrnd ld b,(iy+00ch) ld c,(iy+020h) pgmbf5b srl b jr nc,pgmbf61 set 7,c pgmbf61 ld (iy+021h),c ld (iy+022h),b ld (iy+023h),000h ret ; ; subttl system call 28h ; sys28 scf call pgmbedf ret c push de call pgmd09b pop de jp nc,$wrrand push de ld hl,date5c4 ld (hl),000h ld d,h ld e,l inc de ld bc,7fh ldir pop de ld a,(iy+020h) call pgmcf76 jr c,pgmbfc5 ld l,005h call gtddat$ ld a,(hl) ld b,a dec a cpl and (iy+020h) pgmbf9c cp (iy+020h) jr z,pgmbfba push bc push af push de call gtdrv2 push bc call pgmca65 pop bc ex de,hl ld hl,date5c4 ld c,007h call diskio jr nz,pgmbfc0 pop de pop af pop bc pgmbfba inc a djnz pgmbf9c jp $wrrand ; pgmbfc0 pop de pop af pop bc ld a,001h pgmbfc5 jp usra ; pgmbfc8 push bc push de push iy call gtdrv2 call pgmbfd7 pop iy pop de pop bc ret ; pgmbfd7 push bc call setdrv$ ld e,b call pgmc28b ld c,a ld de,dlogvct ld a,(de) and c jr nz,pgmc008 ld a,(de) or c ld (de),a push hl call getdrv$ push hl pop iy pop hl call logout call hlogout call pgmc252 pgmbffb call pgmc1b7 dec a jr z,pgmbffb ld a,(hl) cp 081h call z,pgmc00a scf pgmc008 pop bc ret ; pgmc00a push ix push hl push hl pop ix ld a,(ix+00ch) ld (iy+005h),a ld l,(ix+00fh) ld h,000h push hl add hl,hl add hl,hl ld (iy+00ah),l ld (iy+00bh),h pop hl inc hl ld e,a ld d,000h call divhlde ld (iy+00ch),l ld a,(ix+00dh) ld (iy+00dh),a ld l,00eh call gtddat$ ex de,hl pop hl push hl inc hl ld bc,8 ldir push hl ld l,030h call gtddat$ ex de,hl pop hl ld bc,3 ldir call pgmc08f pop hl pop ix ret ; logout push hl push de push bc ld c,00ah call diskio ld (iy+005h),008h ld (iy+00ah),040h ld (iy+00bh),000h ld (iy+00ch),002h sub a ld (iy+00dh),a ld (iy+d.month),a ld (iy+d.day),a ld (iy+d.year),a ld l,d.label call gtddat$ ld b,008h pgmc083 ld (hl),' ' inc hl djnz pgmc083 call pgmc08f pop bc pop de pop hl ret ; pgmc08f ld l,(iy+d.nsurf) ld h,0 ld c,(iy+d.t.surf) ld b,(iy+d.t.surf+1) call mlt32 ld c,(iy+d.sr.trk) ld b,0 bit 6,(iy+d.dconfig) jr z,pgmc0ab ld c,(iy+d.dr.trk) pgmc0ab call mlt32 and a sbc hl,bc jr nc,pgmc0b4 dec de pgmc0b4 ld c,(iy+d.sr.trk) add hl,bc jr nc,pgmc0bb inc de pgmc0bb ld c,(iy+008h) ld b,(iy+009h) and a sbc hl,bc jr nc,pgmc0c7 dec de pgmc0c7 ld c,(iy+d.r.clust) ld b,0 call div32 push hl ld e,(iy+018h) ld d,(iy+019h) and a sbc hl,de pop hl jr c,pgmc0dd ex de,hl pgmc0dd bit 7,(iy+00dh) jr nz,pgmc0ee push hl ld de,dat00fe and a sbc hl,de pop hl jr c,pgmc0ee ex de,hl pgmc0ee ld (iy+01ah),l ld (iy+01bh),h ret ; hlogout push hl push de push bc ld e,(iy+027h) ld d,(iy+028h) ld c,(iy+029h) ld a,c or d or e jr z,pgmc147 ld a,(iy+d.nalt) ld l,a ld h,0 add hl,hl add hl,hl add hl,hl push hl ld l,(iy+d.alt$) ld h,(iy+d.alt$+1) push hl push bc pgmc118 ld b,008h pgmc11a ld (hl),0e5h inc hl djnz pgmc11a dec a jr nz,pgmc118 pop bc pop hl pgmc124 push hl push de push bc ld a,c call pgmc277 ld c,004h call diskio pop bc pop de pop hl ex (sp),hl push de ld de,80h and a sbc hl,de jr nc,pgmc14b add hl,de pop de ld b,h ld c,l pop de call pgmc277 ldir pgmc147 pop bc pop de pop hl ret ; pgmc14b pop de ex (sp),hl push de push bc ex de,hl call pgmc277 ld bc,80h ldir ex de,hl pop bc pop de inc de ld a,d or e jr nz,pgmc124 inc b jr pgmc124 ; pgmc163 ld a,b cp 0ffh ld a,000h jr z,pgmc175 push de call setdrv$ call pgmc1a5 call pgmc17d pop de pgmc175 push af ld a,e dec a call pgmc191 pop af ret ; pgmc17d call pgmc263 push bc ld c,005h call pgmc277 ld (datc18f),de call diskio pop bc ret ; datc18f dw 00 ; pgmc191 and 003h ld l,a ld h,000h add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl push bc push hl call pgmc277 pop bc add hl,bc pop bc sub a ret ; pgmc1a5 dec de srl d rr e srl d rr e push hl call pgmc60e add hl,de ex de,hl pop hl sub a ret ; pgmc1b7 push bc call pgmc238 push af inc de call pgmc623 jr c,pgmc1df ld a,e dec a and 003h jr z,pgmc1d2 pop af bit 7,a jr z,pgmc1d1 ld b,0ffh set 7,a pgmc1d1 push af pgmc1d2 pop af call pgmc245 call pgmc163 call pgmc222 pop bc and a ret ; pgmc1df pop af pop bc scf ret ; pgmc1e3 push bc call pgmc238 pop bc ld (ix+04fh),c bit 7,a jr nz,pgmc1f5 ld a,c and 003h jp nz,pgmc191 pgmc1f5 ld hl,(usrtab$) ld de,54h add hl,de ld a,c srl a srl a ex de,hl ld hl,0fh add hl,de cp (hl) jr nc,pgmc21f push bc call pgmca65 pop bc ex de,hl jr c,pgmc21c res 7,(ix+050h) call pgmc17d ld a,c jp pgmc191 ; pgmc21c ld a,2 ret ; pgmc21f ld a,1 ret ; pgmc222 push bc push de push hl ld hl,(usrtab$) ld de,54h add hl,de ex de,hl pop hl push hl ld bc,20h ldir pop hl pop de pop bc ret ; pgmc238 ld e,(ix+04dh) ld d,(ix+04eh) ld c,(ix+04fh) ld a,(ix+050h) ret ; pgmc245 ld (ix+04dh),e ld (ix+04eh),d ld (ix+04fh),c ld (ix+050h),a ret ; pgmc252 push af sub a ld (ix+04dh),a ld (ix+04eh),a ld (ix+04fh),a ld (ix+050h),080h pop af ret ; pgmc263 ld (ix+051h),e ld (ix+052h),d ld (ix+053h),a ret ; pgmc26d ld e,(ix+051h) ld d,(ix+052h) ld a,(ix+053h) ret ; pgmc277 ld l,(ix+u.ddiskb) ld h,(ix+u.ddiskb+1) ret ; pgmc27e call pgmc290 or (hl) ld (hl),a ret ; pgmc284 call pgmc290 cpl and (hl) ld (hl),a ret ; pgmc28b ld a,007h sub e jr pgmc2a0 ; pgmc290 push de srl d rr e srl d rr e srl d rr e add hl,de pop de ld a,e pgmc2a0 and 007h inc a push bc ld b,a sub a scf pgmc2a7 rra djnz pgmc2a7 pop bc ret ; ; Reset cdos & select drive A ; $reset call resdlv resdsk ld (ix+u.curdsk),0 ld hl,80h ld (ix+u.diskb),l ld (ix+u.diskb+1),h ret ; resdlv sub a ld (dlogvct),a ret ; dlogvct db 0 ; pgmc2c3 call setdrv$ call pgmc26d push bc call pgmc277 ld c,007h call diskio pop bc ld c,009h jp diskio ; pgmc2d8 push bc call pgmc34e push hl ld bc,00 pgmc2e0 ld a,(hl) cp 0ffh jr nz,pgmc2fd inc hl push hl ld hl,-8 add hl,de ex de,hl pop hl jr nc,pgmc30a ld a,d or e jr z,pgmc30a push hl ld hl,8 add hl,bc ld b,h ld c,l pop hl jr pgmc2e0 ; pgmc2fd push af pgmc2fe pop af rlca jr nc,pgmc30e inc bc dec de push af ld a,d or e jr nz,pgmc2fe pop af pgmc30a scf pop hl pop bc ret ; pgmc30e ld l,00dh call gtddat$ bit 7,(hl) jr nz,pgmc320 ld a,b and a jr nz,pgmc30a ld a,c cp 0ffh jr z,pgmc30a pgmc320 pop hl ld e,c ld d,b call pgmc27e pop bc and a ret ; pgmc329 push bc push de call pgmc34e ex (sp),hl push hl and a sbc hl,de pop hl ex de,hl pop hl jr z,pgmc33a jr nc,pgmc34c pgmc33a push hl call pgmc61a ld l,a ld h,0 push hl and a sbc hl,de pop hl pop hl jr nc,pgmc34c call pgmc284 pgmc34c pop bc ret ; pgmc34e push af call setdrv$ ld l,01ah call gtddat$ ld e,(hl) inc hl ld d,(hl) ld l,016h call gtddat$ ld a,(hl) inc hl ld h,(hl) ld l,a pop af ret ; pgmc365 ld e,b call pgmc28b ld hl,dlogvct cpl and (hl) ld (hl),a ret ; pgmc370 push bc call gtdrv2 call pgmc379 pop bc ret ; pgmc379 push iy push de push bc call gistat di ld (iff1),a call pgmbfd7 jr nc,pgmc3c5 call pgmc3ed call pgmc40c call pgmc591 jr nz,pgmc3c5 pgmc394 call pgmc1b7 jr c,pgmc3c5 cp 001h call z,pbdblkm call pgmc40c ld a,(hl) cp 0e5h jr z,pgmc394 bit 2,a jr z,pgmc394 ld c,0 pgmc3ac call pgmc1e3 cp 001h jr z,pgmc394 and a call z,pgmc40c inc c jr nz,pgmc3ac jr pgmc394 ; pbdblkm push hl ld hl,bdblkm call fprint pop hl ret ; pgmc3c5 ld a,(iff1) and a jr z,pgmc3cc ei pgmc3cc pop bc pop de pop iy ret ; iff1 db 0 ; bdblkm db 'Bad directory block ',80h db 0,0,'h',cr,lf,0 ; pgmc3ed push hl push de push bc call pgmc34e ld e,(iy+018h) ld d,(iy+019h) dec de ld a,0c0h pgmc3fc ld (hl),a sub a inc hl push hl ld hl,-8 add hl,de ex de,hl pop hl jr c,pgmc3fc pop bc pop de pop hl ret ; pgmc40c push ix push hl push de push bc push hl pop ix ld a,(hl) cp 0e5h jr z,pgmc45e ld a,(ix+00fh) and a jr z,pgmc45e call pgmc34e ld c,010h bit 7,(iy+00dh) jr z,pgmc42c ld c,008h pgmc42c push ix pop de push hl ld hl,10h add hl,de pgmc434 bit 7,(iy+00dh) jr nz,pgmc43f ld e,(hl) ld d,000h jr pgmc442 ; pgmc43f ld e,(hl) inc hl ld d,(hl) pgmc442 inc hl ex (sp),hl push hl ld l,01ah call gtddat$ ld a,(hl) inc hl ld h,(hl) ld l,a and a sbc hl,de jr c,pgmc458 pop hl push hl call pgmc27e pgmc458 pop hl ex (sp),hl dec c jr nz,pgmc434 pop hl pgmc45e pop bc pop de pop hl pop ix ret ; pgmc464 call setdrv$ push iy push hl call getdrv$ push hl pop iy pop hl bit 5,(iy+00dh) jr z,pgmc4ba ex af,af' push af ld a,(iy+02ah) or (iy+02bh) or (iy+02ch) jr z,pgmc4b8 ld de,-1 bit 7,(iy+00dh) jr nz,pgmc48e inc e pgmc48e ld c,0ffh pgmc490 push bc push hl call pgmc4ed jr z,pgmc4bd pop hl ex de,hl ex (sp),hl ex de,hl push de ld d,b ld e,c pop bc push bc push hl call pgmc556 ex af,af' and a jr z,pgmc4ad ex af,af' ld a,(hl) or e jr pgmc4b1 ; pgmc4ad ex af,af' ld a,e cpl and (hl) pgmc4b1 ld (hl),a pop hl pop bc ld c,d pop de jr pgmc490 ; pgmc4b8 pop af ex af,af' pgmc4ba pop iy ret ; pgmc4bd pop hl pop bc pop af ex af,af' push bc call pgmc4ce pop bc ld c,009h call diskio pop iy ret ; pgmc4ce inc c ret z dec c call pgmc4dc ld hl,sysstk ld c,006h jp diskio ; pgmc4dc ld a,(iy+02ah) add a,c ld e,a ld a,(iy+02bh) adc a,000h ld d,a ld a,(iy+02ch) adc a,000h ret ; pgmc4ed ld a,d or e ret z ld c,000h ld (ix+019h),c push de push hl ld hl,-1 push hl pgmc4fb sla e rl d jr c,pgmc52d pgmc501 ld a,(iy+005h) add a,c ld c,a cp 080h jr c,pgmc4fb pop bc pop hl pop de ld a,b and c inc a ret z ld a,(ix+019h) ld hl,dat7fff and a jr z,pgmc524 pgmc51a scf rr h rr l sub (iy+005h) jr nz,pgmc51a pgmc524 ld a,d and h ld d,a ld a,e and l ld e,a sub a inc a ret ; pgmc52d pop hl ex (sp),hl push hl push bc push de ld a,c call pgmca97 jr c,pgmc54f ld d,b ld e,c pop af pop bc pop hl ex (sp),hl push af push hl and a sbc hl,de pop hl jr c,pgmc54c ex de,hl pop de ld (ix+019h),c push de pgmc54c pop de jr pgmc553 ; pgmc54f pop de pop bc pop hl ex (sp),hl pgmc553 push hl jr pgmc501 ; pgmc556 ld a,d rra rra and 03fh cp c jr z,pgmc582 push de push bc push af ld a,c cp 0ffh jr z,pgmc56f call pgmc4ce pop af pop bc pop de push de push bc push af pgmc56f pop af ld d,a push de ld c,a call pgmc4dc ld hl,sysstk ld c,004h call diskio pop hl ld a,h pop bc pop de pgmc582 ld h,a push hl ld hl,sysstk ld a,d and 003h ld d,a call pgmc290 pop de ld e,a ret ; pgmc591 bit 5,(iy+00dh) ret z ld e,(iy+02ah) ld d,(iy+02bh) ld c,(iy+02ch) ld a,e or d or c ret z ld l,(iy+01ah) ld h,(iy+01bh) srl h rr l srl h rr l srl h rr l inc hl push hl ld l,(iy+016h) ld h,(iy+017h) pgmc5bd push hl push de push bc ld a,c ld hl,sysstk ld c,004h call diskio pop bc pop de pop hl ex (sp),hl push de ld de,80h and a sbc hl,de jr nc,pgmc5e3 add hl,de pop de ld b,h ld c,l pop de ld hl,sysstk ldir sub a inc a ret ; pgmc5e3 pop de ex (sp),hl push de push bc ex de,hl ld hl,sysstk ld bc,80h ldir ex de,hl pop bc pop de inc de ld a,d or e jr nz,pgmc5bd inc b jr pgmc5bd ; pgmc5fb push hl push de ld l,005h call gtddat$ ld e,(hl) ld d,000h ld h,d ld l,a call divhlde ld a,l pop de pop hl ret ; pgmc60e ld l,008h call gtddat$ push af ld a,(hl) inc hl ld h,(hl) ld l,a pop af ret ; pgmc61a push hl ld l,00ch call gtddat$ ld a,(hl) pop hl ret ; pgmc623 push hl push de ld l,00ah call gtddat$ ld e,(hl) inc hl ld d,(hl) ex de,hl pop de and a sbc hl,de pop hl ret ; $rdlabe call drvok2 jr nc,pgmc63e ld a,4 jp usra ; pgmc63e call pgmc370 push de ld hl,cdosfcb call pgmc660 pop de push de call gtdrv2 call setdrv$ call pgmc252 call pgmc1b7 pop de call usra and a ret nz ld a,(hl) cp 081h ret nz pgmc660 inc hl inc de ld bc,1fh ldir ret ; cdosfcb db 81h,' ',0,0,0 db 8,0,0,10h,0,1 db 0,0,0,0,0,0,0,0,0,0,0,0,0 ; drvok2 push de ld a,(de) and 03fh jr z,pgmc693 dec a ld e,a call drvok pgmc693 pop de ret ; drvok push hl push de ld hl,(drives$) ld a,(hl) dec a cp e jr c,drvnok ld d,0 inc hl add hl,de add hl,de ld a,(hl) inc hl or (hl) jr z,drvnok sub a jr drvoko ; drvnok ld a,-1 scf drvoko pop de pop hl ret ; ; List sys.dir ; $dir call drvok2 call usra ret c push de call pgmc370 inc de ld a,(de) cp ' ' jr nz,pgmc6d2 ld a,(iy+f.ext) cp ' ' jr nz,pgmc6d2 ld b,0bh ld a,'?' pgmc6ce ld (de),a inc de djnz pgmc6ce pgmc6d2 ld a,03fh ld (iy+f.ent),a ld hl,0 ld (tkdisp),hl ld (tnents),hl ld (tnfiles),hl call pgmc252 pgmc6e6 ld b,017h ;lines per screen pgmc6e8 pop de push de push bc call pgmc739 pop bc jr c,pgmc709 djnz pgmc6e8 call pgmc6f8 jr pgmc6e6 ; pgmc6f8 ld de,keypmsg call $wrline pgmc6fe call drdcon jr z,pgmc6fe ld de,dcrlf jp $wrline ; pgmc709 and a jr z,pgmc710 dec b call z,pgmc6f8 pgmc710 pop de call pgmc842 sub a jp usra ; keypmsg db 'Press any key to continue $' tkdisp dw 00 tnents dw 00 tnfiles dw 00 ; pgmc739 call pdirent ld a,0 ret c ;change this for mdos call space4 call pdirent push af ld de,dcrlf call $wrline pop af ld a,1 ret ; pdirent push hl push bc push de call pgmc7ba jr c,pgmc7b6 ld a,(hl) push af push de ld b,8 ;list filename pgmc75d inc hl ld e,(hl) ld a,e and a jp m,pgmc768 cp ' ' jr nc,pgmc76a pgmc768 ld e,'.' pgmc76a call $conout djnz pgmc75d call space2 ld b,3 ;list extension pgmc774 inc hl ld e,(hl) ld a,e and a jp m,pgmc77f cp ' ' jr nc,pgmc781 pgmc77f ld e,'.' pgmc781 call $conout djnz pgmc774 call space2 pop de call pgmc808 ex de,hl call pgmc8f3 ld e,'k' call $conout call space pop af ld hl,dattrch ld b,5 ;list attributes ld d,6 pgmc7a1 push af ld e,(hl) inc hl and (hl) jr z,pgmc7ab call $conout dec d pgmc7ab inc hl pop af djnz pgmc7a1 pgmc7af call space dec d jr nz,pgmc7af and a pgmc7b6 pop de pop bc pop hl ret ; pgmc7ba push de call drdcon scf jr nz,pgmc7e2 pgmc7c1 pop de push de call pgmc7e4 jr c,pgmc7e2 ld de,(tnents) inc de ld (tnents),de jr nz,pgmc7dd ld a,b cp 0ffh jr z,pgmc7dd ld a,c cp 080h jr z,pgmc7c1 pgmc7dd and a pop de ld e,c ld d,b ret ; pgmc7e2 pop de ret ; pgmc7e4 push de call gtdrv2 pgmc7e8 call pgmcb53 jr c,pgmc806 ld a,(hl) and 003h jr nz,pgmc7e8 ex de,hl ld hl,0ch add hl,de ld b,(hl) ld hl,0fh ld a,(de) bit 2,a jr z,pgmc803 ld hl,0eh pgmc803 add hl,de ld c,(hl) ex de,hl pgmc806 pop de ret ; pgmc808 ld l,d ld h,000h add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl add hl,hl ld d,000h add hl,de push hl ld l,005h call gtddat$ ld c,(hl) ld b,000h pop hl push bc call div16 ld a,d or e jr z,pgmc828 inc hl pgmc828 pop bc call mlt32 ld bc,8 call div16 ex de,hl ld hl,(tkdisp) add hl,de ld (tkdisp),hl ld hl,(tnfiles) inc hl ld (tnfiles),hl ret ; pgmc842 call gtdrv2 call setdrv$ push iy push hl call getdrv$ push hl pop iy pop hl ld hl,00 push hl ld l,(iy+016h) ld h,(iy+017h) ld e,(iy+01ah) ld d,(iy+01bh) pgmc862 ld c,(hl) ex (sp),hl ld b,008h pgmc866 rl c jr c,pgmc86b inc hl pgmc86b dec de ld a,d or e jr z,pdirsum djnz pgmc866 ex (sp),hl inc hl jr pgmc862 ; pdirsum pop de ld c,(iy+005h) ld b,000h call mlt32 ld bc,8 call div32 pop iy push hl ld de,dirstr call $wrline ld hl,(tnfiles) call pgmc8f7 ld de,dnfiles call $wrline ld hl,(tnents) call pgmc8f7 ld de,dnents call $wrline ld hl,(tkdisp) call pgmc8f7 ld de,dkdisp call $wrline pop hl call pgmc8f7 ld de,dkleft jp $wrline ; dirstr db '*** $' dnfiles db ' Files, $' dnents db ' Entries, $' dkdisp db ' K Displayed, $' dkleft db ' K Left ***$' dcrlf db cr,lf,$' ; pgmc8f3 ld b,004h jr pgmc8f9 ; pgmc8f7 ld b,001h pgmc8f9 push bc ld de,0ah call divhlde pop bc dec b ld a,h or l push de call nz,pgmc8f9 call pgmc916 pop de ld a,e add a,030h pgmc90f push bc ld e,a call $conout pop bc ret ; pgmc916 dec b ret m ld a,020h call pgmc90f jr pgmc916 ; space4 call space2 space2 call space space push hl push de push bc push af ld e,' ' call $conout pop af pop bc pop de pop hl ret ; drdcon call $consta and a ret z call $conin and a ret ; dattrch db 'E',80h db 'W',40h db 'R',20h db 'U',10h db 'S',8 ; ; Open disk file ; $open call drvok2 jp c,usra call pgmc370 call pgmc9e4 jr nz,pgmc9af and a jr z,pgmc95d ld a,0ffh jp usra ; pgmc95d call usra push de ld hl,0ch add hl,de ld b,015h pgmc967 ld (hl),000h inc hl djnz pgmc967 ld hl,0fh add hl,de push ix push hl call getdrv$ push hl pop ix pop hl ld a,(ix+00ah) ld d,(ix+00bh) srl d rra srl d rra ld (hl),a ld e,(ix+00ch) inc hl ld bc,-1 pgmc98e ld (hl),c bit 7,(ix+00dh) jr z,pgmc997 inc hl ld (hl),b pgmc997 inc hl pgmc998 inc bc ld a,c and a jr z,pgmc998 dec e jr nz,pgmc98e pop ix pop de ld a,(de) or 080h ld (de),a ld hl,20h add hl,de ld (hl),000h xor a ret ; pgmc9af call pgmc252 call pgmcae7 ld a,0ffh jr c,pgmc9c8 call pgmc9cb pgmc9bc ld a,(ix+04eh) and a ld a,0feh jr nz,pgmc9c8 ld a,(ix+04dh) dec a pgmc9c8 jp usra ; pgmc9cb push hl push de push bc ex de,hl ld a,(de) rlca and 0c0h or (hl) ld (hl),a inc de inc hl ld bc,dat001f call pgmdbe3 ld (hl),000h xor a pop bc pop de pop hl ret ; pgmc9e4 push bc push de push hl ld hl,sysdirf ld c,00bh inc de pgmc9ed ld a,(de) cp (hl) jr nz,pgmc9f7 inc de inc hl dec c jr nz,pgmc9ed ld a,(de) pgmc9f7 pop hl pop de pop bc ret ; sysdirf db 'SYS DIR' ; ; Read next record ; $rdnext call $rdcurr and a ret nz inc (hl) ret ; ; Read current record ; $rdcurr push iy push de pop iy ld a,(de) and 040h jr nz,pgmca5e ld a,(iy+020h) ld c,a cp 080h jr nz,pgmca36 ld a,(iy+00ch) inc a jr z,pgmca5e ld (iy+00ch),a ld c,000h ld (iy+020h),c push bc call $open pop bc cp 0ffh jr z,pgmca5e pgmca36 ld a,c ld hl,0fh add hl,de cp (hl) jr nc,pgmca5e push de push af call gtdrv2 pop af call pgmca65 jr nc,pgmca4e pop de ld a,002h jr pgmca60 ; pgmca4e pop de push de ld c,005h call pgmcad9 pop de ld a,000h ld hl,20h add hl,de jr pgmca60 ; pgmca5e ld a,001h pgmca60 pop iy jp usra ; pgmca65 push af call pgmca93 pop hl jr c,pgmca91 push af push de push bc push hl ld l,005h call gtddat$ ld c,(hl) ld b,000h pop hl ld l,h ld h,000h call div16 call pgmc60e add hl,de ex (sp),hl call mlt32 pop bc add hl,bc jr nc,pgmca8c inc de pgmca8c ld a,e pop de pop bc and a ret ; pgmca91 ld b,a ret ; pgmca93 ld hl,10h add hl,de pgmca97 ex de,hl push af call setdrv$ pop af call pgmc5fb ld l,00dh call gtddat$ ld l,(hl) bit 7,l jr z,pgmcaab add a,a pgmcaab ld c,a ld b,000h ex de,hl add hl,bc ld c,(hl) bit 7,e jr z,pgmcaba inc hl ld b,(hl) dec hl jr pgmcac0 ; pgmcaba ld b,000h inc c jr z,pgmcaca dec c pgmcac0 ld a,b or c jr z,pgmcacd inc bc ld a,b or c jr z,pgmcaca dec bc pgmcaca and a jr pgmcace ; pgmcacd scf pgmcace ld a,e ex de,hl ret ; pgmcad1 call gtdrv2 ld c,u.sdiskb jp getusr$ ; pgmcad9 push hl push af push bc call pgmcad1 ld a,b pop bc ld b,a pop af pop de jp diskio ; pgmcae7 res 1,(ix+050h) pgmcaeb call gtdrv2 pgmcaee call pgmcb53 ret c ld a,(hl) bit 0,a jr nz,pgmcb23 bit 2,a jr nz,pgmcb0d push hl push de push bc ld bc,0ch add hl,bc ex de,hl add hl,bc ld a,(de) cp (hl) pop bc pop de pop hl jr nz,pgmcaee and a ret ; pgmcb0d ld hl,0ch add hl,de ld c,(hl) push bc push de call pgmc1e3 pop de pop bc and a jr nz,pgmcaee ld a,(hl) bit 0,a jr nz,pgmcaee and a ret ; pgmcb23 bit 1,(ix+050h) jr z,pgmcaee and a ret ; gtdrv1 push af jr pgmcb30 ; gtdrv2 push af ld a,(de) pgmcb30 and 03fh ld b,a push hl push de ld hl,(drives$) ld a,(hl) cp b jr c,gtcurdr ld a,b and a jr z,gtcurdr dec b ld e,b ld d,0 inc hl add hl,de add hl,de ld a,(hl) inc hl or (hl) jr nz,pgmcb4f gtcurdr ld b,(ix+u.curdsk) pgmcb4f pop de pop hl pop af ret ; pgmcb53 push de call pgmc1b7 jr c,pgmcb75 pop de push de push bc push hl ld b,00bh pgmcb5f inc de inc hl ld a,(de) cp 03fh jr z,pgmcb69 cp (hl) jr nz,pgmcb70 pgmcb69 djnz pgmcb5f pop hl pop bc pop de and a ret ; pgmcb70 pop hl pop bc pop de jr pgmcb53 ; pgmcb75 pop de scf ret ; ; Format name to fcb ; $format push de ld a,' ' ld b,00bh pgmcb7d inc de ld (de),a djnz pgmcb7d pop de push de sub a ld (de),a inc hl ld a,(hl) dec hl cp 03ah jr nz,pgmcb97 ld a,(hl) call pgmce48 sub 040h jr c,pgmcbaf ld (de),a inc hl inc hl pgmcb97 inc de ld b,008h call pgmcbc2 cp 02eh jr nz,pgmcbaf ex de,hl pop hl push hl ld bc,f.ext add hl,bc ex de,hl inc hl ld b,003h call pgmcbc2 pgmcbaf pop de push hl ld hl,f.ent add hl,de sub a ld (hl),a ld hl,f.nxtrec add hl,de ld (hl),a pop hl ld c,u.rl jp setusr$ ; pgmcbc2 ld a,(hl) call pgmce48 cp '!' ret c cp '/' ret z cp '=' ret z cp ',' ret z cp '.' ret z inc b dec b jr z,pgmcbe0 cp 02ah jr z,pgmcbe3 ld (de),a dec b inc de pgmcbe0 inc hl jr pgmcbc2 ; pgmcbe3 ld a,03fh ld (de),a inc de djnz pgmcbe3 jr pgmcbe0 ; ; Divide integers ; $divd call divhlde push de ld c,u.rl call setusr$ pop de pgmcbf5 ld c,u.re jp setusrx ; ; Multiply integers ; $mult call mlthlde jr pgmcbf5 ; pgmcbff set 0,(ix+050h) jr pgmcc09 ; pgmcc05 res 0,(ix+050h) pgmcc09 res 1,(ix+050h) jr pgmcc0f ; pgmcc0f call gtdrv2 bit 6,(ix+050h) jr nz,pgmcc3f pgmcc18 call pgmcb53 ret c ld a,(hl) bit 0,a jr nz,pgmcc6e bit 0,(ix+050h) jr z,pgmcc2b bit 7,a jr nz,pgmcc18 pgmcc2b bit 2,a jr z,pgmcc39 set 6,(ix+050h) set 5,(ix+050h) and a ret ; pgmcc39 res 6,(ix+050h) and a ret ; pgmcc3f bit 5,(ix+050h) res 5,(ix+050h) jr z,pgmcc4f ld (ix+04fh),000h jr pgmcc54 ; pgmcc4f inc (ix+04fh) jr z,pgmcc18 pgmcc54 ld c,(ix+04fh) push bc push de call pgmc1e3 pop de pop bc and a jr z,pgmcc67 cp 001h jr z,pgmcc18 jr pgmcc4f ; pgmcc67 ld a,(hl) bit 0,a jr nz,pgmcc4f and a ret ; pgmcc6e bit 1,(ix+050h) jr z,pgmcc18 jr pgmcc39