Login

Subversion Repositories NedoOS

Rev

Rev 1775 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed


    MODULE TIME
    PUBLIC time
        #include "sysdefs.asm"
        RSEG CODE
time:
        push ix
        push iy
    ld c,CMD_GETTIMER ;out: dehl=timer
        call BDOS
        ld b,d
        ld c,e
        pop iy
        pop ix
        ret ;return bchl
        ENDMOD


;unsigned long OS_GETTIME (struct diskOp *); //out: ix=date, hl=time


    MODULE OS_GETTIME
    PUBLIC OS_GETTIME
        #include "sysdefs.asm"
        RSEG CODE
OS_GETTIME:
    push ix
    push iy
    ld c,CMD_GETTIME ;out: ix=date, hl=time
        call BDOS
        di
        push ix
        pop bc
        ei
        pop iy
    pop ix
    ret ;return bchl
        ENDMOD

        MODULE ERRNOMOD
        PUBLIC errno
        RSEG    NO_INIT
errno:
        defs 1
        ENDMOD
       
        MODULE MYGETCHAR
        PUBLIC getchar
        EXTERN _low_level_get
        RSEG CODE
getchar:
        call _low_level_get
        or a
        jr z,getchar
        ld l,a
        ld h,0
        ret    
        ENDMOD
       
        MODULE OS_RESERV_1
        PUBLIC os_reserv_1
        #include "sysdefs.asm"
        RSEG CODE
os_reserv_1:
        push bc
        push ix
        push iy
    ld c,CMD_RESERV_1
        call BDOS
        pop iy
        pop ix
        pop bc
        ret    
        ENDMOD
       
        MODULE SCRREDRAW
        PUBLIC scrredraw
        RSEG CODE
scrredraw:
        xor a
        ret    
        ENDMOD

        MODULE OSLOWGET
        PUBLIC bdosgetkey
        EXTERN scrredraw,exit,YIELD
        #include "sysdefs.asm"
        RSEG CODE
bdosgetkey:
        push de
        push bc
        push ix
        push iy
        ld c,CMD_YIELD
        call BDOS
        rst 0x08
        cp key_esc
        jp z,exit
        cp key_redraw
        call z,scrredraw
        ld l,a
        ld h,0
        pop iy
        pop ix
        pop bc
        pop de
        ret
        ENDMOD
   
        MODULE conv1251to866
        PUBLIC conv1251to866, t1251to866
        RSEG CODE
conv1251to866:  ;DE-string
        push de
ploop:
        ld a,(de)
        or a
        jr z,pexit
        cp 128
        jr c,asci
        add a,low(t1251to866-128)
        ld l,a
        ld a,0
        adc a,high(t1251to866-128)
        ld h,a
        ld a,(hl)
        ld (de),a
asci:
        inc de
        jr ploop
pexit:
        pop de
        ret
        RSEG    CONST
t1251to866:
        DEFB 0x3F, 0x3F, 0x27, 0x3F, 0x22, 0x3A, 0xC5, 0xD8, 0x3F, 0x25, 0x3F, 0x3C, 0x3F, 0x3F, 0x3F, 0x3F
        DEFB 0x30, 0x3F, 0x27, 0x27, 0x22, 0x22, 0x07, 0x2D, 0x2D, 0x54, 0x3F, 0x3E, 0x3F, 0x3F, 0x3F, 0x3F
        DEFB 0xFF, 0xF6, 0xF7, 0x3F, 0xFD, 0x3F, 0xB3, 0x15, 0xF0, 0x63, 0xF2, 0x3C, 0xBF, 0x2D, 0x52, 0xF4
        DEFB 0xF8, 0x2B, 0x3F, 0x3F, 0x3F, 0xE7, 0x14, 0xFA, 0xF1, 0xFC, 0xF3, 0x3E, 0x3F, 0x3F, 0x3F, 0xF5
        DEFB 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8E, 0x8F
        DEFB 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E, 0x9F
        DEFB 0xA0, 0xA1, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAB, 0xAC, 0xAD, 0xAE, 0xAF
        DEFB 0xE0, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xEE, 0xEF
        ENDMOD
       
        MODULE YIELD
        PUBLIC YIELD
        #include "sysdefs.asm"
        RSEG CODE
YIELD:
        push bc
        push de
        push ix
        push iy
        ld c,CMD_YIELD
        call BDOS
        pop iy
        pop ix
        pop de
        pop bc
        ret
        ENDMOD
       
        MODULE SETMUSIC
        PUBLIC OS_SETMUSIC
        #include "sysdefs.asm"
        RSEG CODE
OS_SETMUSIC:    ;DE - proc_ptr, A - ?
        ld h,d
        ld l,e
        ld a,c
    ex af,af'
        push ix
        push iy
        ld c,CMD_SETMUSIC       ;hl=muzaddr (0x4000..0x7fff), a=muzpg
        call BDOS
        pop iy
        pop ix
        ret
        ENDMOD
       
        MODULE OSGETCONFIG
        PUBLIC OS_GETCONFIG
        #include "sysdefs.asm"
        RSEG CODE
OS_GETCONFIG:
    push bc
        ld c,CMD_GETCONFIG
        push de
        push ix
        push iy
        call BDOS
        pop iy
        pop ix
        pop de
    pop bc
        ret
        ENDMOD

        MODULE GETMAINPAGES
        PUBLIC OS_GETMAINPAGES,OS_GETAPPMAINPAGES
    EXTERN errno
        #include "sysdefs.asm"
        RSEG CODE
OS_GETAPPMAINPAGES:
    ld c,CMD_GETAPPMAINPAGES
    jr l1
OS_GETMAINPAGES:
        ld c,CMD_GETMAINPAGES
l1
        push de
        push ix
        push iy
        call BDOS
        ld b,d ;out: d,e,h,l=pages in 0000,4000,8000,c000, c=flags, a=error
        ld c,e
        pop iy
        pop ix
        pop de
        LD (errno), a
        ret
        ENDMOD

        MODULE SETPG32KHIGH
        PUBLIC SETPG32KHIGH
        #include "sysdefs.asm"
        RSEG CODE
SETPG32KHIGH:
        push bc
        push ix
        push iy
        ld a,e
        rst 0x28
        pop iy
        pop ix
        pop bc
        ret
        ENDMOD

        MODULE MAIN_ARGS
        PUBLIC main_args
        RSEG CODE
main_args
        ld hl,args
        ld de,0x0080
get_cmd_args_l2
        ld (hl),e
        inc hl
        ld (hl),d
        inc hl
        dec de
get_cmd_args_l
        inc de
        ld a,(de)
        or a
        jr z,get_cmd_args_end
        cp '
'
        jr nz,get_cmd_args_l
        xor a
        ld (de),a
skipspaces
        inc de
        ld a,(de)
        or a
        jr z,get_cmd_args_end
        cp '
'
        jr nz,get_cmd_args_l2
        jr skipspaces
get_cmd_args_end:
        ld bc,args
        sbc hl,bc
        ex de,hl
        srl e
        ret
        RSEG    NO_INIT
args:
        defs 32
        ENDMOD


        MODULE OSDROPAPP
        PUBLIC OS_DROPAPP
        #include "sysdefs.asm"
        RSEG CODE
OS_DROPAPP:     ;e=id ; hl=result
        ld c,CMD_DROPAPP
        push ix
        push iy
        call BDOS
        pop iy
        pop ix
        ret
        ENDMOD

        MODULE OS_SETGFX
        PUBLIC OS_SETGFX
        #include "sysdefs.asm"
        RSEG CODE
OS_SETGFX:      ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;eF=-1: disable gfx (out: e=old gfxmode)
    push bc
        push hl
        push ix
        push iy
        ld c,CMD_SETGFX
        call BDOS
        pop iy
        pop ix
        pop hl
        pop bc
        ret
        ENDMOD

        MODULE OSGETPAGEOWNER   ;e=page ;out: e=owner id (0=free, 0xff=system)
        PUBLIC OS_GETPAGEOWNER
        #include "sysdefs.asm"
        RSEG CODE
OS_GETPAGEOWNER:
    push bc
        ld c,CMD_GETPAGEOWNER
        push de
        push ix
        push iy
        call BDOS
        LD a, e
        pop iy
        pop ix
        pop de
    pop bc
        ret
        ENDMOD
       
        MODULE  my_im2
        PUBLIC  my_im2_init
        RSEG    INTJP
        DEFS 3
        RSEG    INTTABLE
        DEFS 257
        RSEG    CODE
my_im2_init
        di
        ld a,0xc3
        ld (SFB(INTJP)),a
        ld (SFB(INTJP)+1),de
        ld a,HIGH(SFB(INTTABLE))
        ld i,a
        inc a
        ld hl,SFB(INTTABLE)-1
tloop
        inc hl
        ld (hl),HIGH(SFB(INTJP))
        cp h
        jr nz,tloop
        im 2
        ret
        ENDMOD

;Kulich Area

        MODULE OS_NEWPAGE       ;out: a=0 (OK)/!=0 (fail), e=page
        PUBLIC OS_NEWPAGE
        #include "sysdefs.asm"
        RSEG CODE
OS_NEWPAGE:
    push bc
        ld c,CMD_NEWPAGE
        push ix
        push iy
        call BDOS
        pop iy
        pop ix
    pop bc
        ld h,a                  ;error
        ld l,e                  ;page
        ret
        ENDMOD


// DE - ╤Б╤В╨░╤А╨╛╨╡ ╨╕╨╝╤П, ╨▓╨╛╨╖╨╝╨╛╨╢╨╜╨╛ ╤Б ╨┐╨╛╨╗╨╜╤Л╨╝ ╨╕╨╗╨╕ ╨╛╤В╨╜╨╛╤Б╨╕╤В╨╡╨╗╤М╨╜╤Л╨╝ ╨┐╤Г╤В╤С╨╝ (ASCIIZ). HL - ╨╜╨╛╨▓╨╛╨╡ ╨╕╨╝╤П, ╨┐╨╛╨║╨░ ╤З╤В╨╛ ╤В╤А╨╡╨▒╤Г╨╡╤В╤Б╤П ╤В╨░╨║╨╛╨╣ ╨╢╨╡ ╨┐╤Г╤В╤М, ╨║╨░╨║ ╨▓ DE.
// out HL - ╤Г╨║╨░╨╖╨░╤В╨╡╨╗╤М ╨╜╨░ ╨┐╨╛╤Б╨╗╨╡╨┤╨╜╨╕╨╣ ╤Н╨╗╨╡╨╝╨╡╨╜╤В ╨┐╤Г╤В╨╕ ╨▓ ╤Н╤В╨╛╨╝ ╨▒╤Г╤Д╨╡╤А╨╡ (NOT MSXDOS compatible! with Drive/path!)
        MODULE OS_RENAME
        PUBLIC OS_RENAME
        #include "sysdefs.asm"
        RSEG CODE
OS_RENAME:
;           ld de, oldname
;       ld bc, newname
        ld h,b
        ld l,c
        push ix
        push iy
        ld c,CMD_RENAME
        call BDOS
        pop iy
        pop ix
        ret
        ENDMOD

// DE - ╨╕╨╝╤П ╤Д╨░╨╣╨╗╨░, ╨▓╨╛╨╖╨╝╨╛╨╢╨╜╨╛ ╤Б ╨┐╨╛╨╗╨╜╤Л╨╝ ╨╕╨╗╨╕ ╨╛╤В╨╜╨╛╤Б╨╕╤В╨╡╨╗╤М╨╜╤Л╨╝ ╨┐╤Г╤В╤С╨╝ (ASCIIZ).; ╨Р - ╨╛╤И╨╕╨▒╨║╨░. ╨Х╤Б╨╗╨╕ 0x00, ╤В╨╛ ╨╛╤И╨╕╨▒╨║╨╕ ╨╜╨╡╤В.                                                                                        
        MODULE OS_DELETE
        PUBLIC OS_DELETE
        #include "sysdefs.asm"
        RSEG CODE
OS_DELETE:
        push bc
        push ix
        push iy
        ld c,CMD_DELETE
        call BDOS
        pop iy
        pop ix
        pop bc
        ld h,0
        ld l,a
        ret
        ENDMOD





        MODULE OS_READSECTORS   ;de= pointer to diskOp structure
        PUBLIC OS_READSECTORS
        #include "sysdefs.asm"
        RSEG CODE
OS_READSECTORS:
        push bc
        push de
        push ix
        push iy

        ex de,hl
        ld b,(hl)       ;drive
        inc l
        ld e,(hl)       ;buffer L
        inc l
        ld d,(hl)       ;buffer H
        inc l
        push de
        ld e,(hl)       ;sector L
        inc l
        ld d,(hl)       ;sector H
        inc l
        ld  a,(hl)      ;sector X
        ld  ixl,a
        inc l
        ld  a,(hl)      ;sector I
        ld  ixh,a
        inc l
        ld  a,(hl)      ;count
        pop hl
        ex de,hl
        ld c,CMD_READSECTORS
        ex af,af'
;'
    call BDOS ;c=CMD
        pop iy
        pop ix
        pop de
        pop bc
        ret             ;BCHL
        ENDMOD 
       
        MODULE OS_WRITESECTORS  ;de= pointer to diskOp structure
        PUBLIC OS_WRITESECTORS
        #include "sysdefs.asm"
        RSEG CODE
OS_WRITESECTORS:
        push bc
        push de
        push ix
        push iy

        ex de,hl
        ld b,(hl)       ;drive
        inc l
        ld e,(hl)       ;buffer L
        inc l
        ld d,(hl)       ;buffer H
        inc l
        push de
        ld e,(hl)       ;sector L
        inc l
        ld d,(hl)       ;sector H
        inc l
        ld  a,(hl)      ;sector X
        ld  ixl,a
        inc l
        ld  a,(hl)      ;sector I
        ld  ixh,a
        inc l
        ld  a,(hl)      ;count
        pop hl
        ex de,hl
        ld c,CMD_WRITESECTORS
        ex af,af' ;'
    call BDOS ;c=CMD
        pop iy
        pop ix
        pop de
        pop bc
        ret             ;BCHL  
        ENDMOD

        MODULE OS_GETPATH
        PUBLIC OS_GETPATH
        #include "sysdefs.asm"
        RSEG CODE
OS_GETPATH:
        push bc
        push ix
        push iy
        ld c,CMD_GETPATH
        call BDOS
        pop iy
        pop ix
        pop bc
        ld hl,0
        ret
        ENDMOD

        MODULE OS_SETSYSDRV                    
        PUBLIC OS_SETSYSDRV                    
        #include "sysdefs.asm"
        RSEG CODE      
OS_SETSYSDRV
        push bc
        push de
        push ix
        push iy
        ld c,CMD_SETSYSDRV                      ; out: A: A!=0 -- ╤Б╨╕╤Б╤В╨╡╨╝╨╜╤Л╨╣ ╨┤╨╕╤Б╨║ ╨╜╨╡ ╨┐╤А╨╕╨╝╨╛╨╜╤В╨╕╤А╨╛╨▓╨░╨╜. L: -- ╨╛╨▒╤Й╨╡╨╡ ╨║╨╛╨╗╨╕╤З╨╡╤Б╤В╨▓╨╛ ╨┐╤А╨╕╨╝╨╛╨╜╤В╨╕╤А╨╛╨▓╨░╨╜╨╜╤Л╤Е ╨┤╨╕╤Б╨║╨╛╨▓.
        call BDOS
        pop iy
        pop ix
        pop de
        pop bc
        ld h,a                                          ;h = error l = No of disks
        ret
        ENDMOD

        MODULE OS_CHDIR
        PUBLIC OS_CHDIR
        #include "sysdefs.asm"
        RSEG CODE
OS_CHDIR:
        push bc
        push ix
        push iy
        ld c,CMD_CHDIR                          ;DE = Pointer to ASCIIZ string. Out A=error
        call BDOS
        pop iy
        pop ix
        pop bc
        ld l,0
        ld h,a                                          ;h = error
        ret
        ENDMOD


        MODULE OS_NEWAPP
        PUBLIC OS_NEWAPP
        #include "sysdefs.asm"
        RSEG CODE
OS_NEWAPP:
        push bc
        ld (strPtr), de
        push ix
        push iy
        ld c,CMD_NEWAPP                         ;out: b=id, a=error, dehl=newapp pages in 0000,4000,8000,c000 ;MAKE NEW DISABLED APP
        call BDOS
        pop iy
        pop ix
        ld c,a
        push hl
        ld hl,(strPtr)
        ld (hl),d
        inc hl
        ld (hl),e
        pop hl
        ex de,hl
        ld hl,(strPtr)
        inc hl
        inc hl
        ld (hl),d
        inc hl
        ld (hl),e
        inc hl
        ld (hl),b
        inc hl
        ld (hl),c
        pop bc
        ret
strPtr
        DEFW 0000
        ENDMOD

        MODULE OS_RUNAPP
        PUBLIC OS_RUNAPP
        #include "sysdefs.asm"
        RSEG CODE
OS_RUNAPP:     
        push hl
        push bc
        push ix
        push iy
        ld c,CMD_RUNAPP ;e=id ;ACTIVATE DISABLED APP
        call BDOS
        pop iy
        pop ix
    pop bc
        pop hl
        ret
        ENDMOD

        MODULE OS_WAITPID
        PUBLIC OS_WAITPID
        #include "sysdefs.asm"
        RSEG CODE
OS_WAITPID:
        push bc
        push ix
        push iy
    ld c,CMD_SETWAITING
        call BDOS
        ld c,CMD_YIELD
        call BDOS
        ld c,CMD_GETCHILDRESULT
        call BDOS
        pop iy
        pop ix
        pop bc
        ret
        ENDMOD




        MODULE OS_HIDEFROMPARENT
        PUBLIC OS_HIDEFROMPARENT
        #include "sysdefs.asm"
        RSEG CODE
OS_HIDEFROMPARENT:     
        push bc
        push ix
        push iy
        ld c,CMD_HIDEFROMPARENT
        call BDOS
        pop iy
        pop ix
    pop bc
        ret
        ENDMOD

        MODULE OS_CLS
        PUBLIC OS_CLS
        #include "sysdefs.asm"
        RSEG CODE
OS_CLS:
        push bc
        push hl
        push ix
        push iy
        ld c,CMD_CLS
        call BDOS
        pop iy
        pop ix
        pop bc
        pop hl
        ret
        ENDMOD

        MODULE OS_DIHALT
        PUBLIC OS_DIHALT
        RSEG CODE
OS_DIHALT:
        DI
        HALT
        ret
        //ENDMOD
        END