?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1.     MODULE Dos
  2. ; API methods
  3. ESX_GETSETDRV = #89
  4. ESX_FOPEN = #9A
  5. ESX_FCLOSE = #9B
  6. ESX_FSYNC = #9C
  7. ESX_FREAD = #9D
  8. ESX_FWRITE = #9E
  9.  
  10. ; File modes
  11. FMODE_READ = #01
  12. FMODE_WRITE = #06
  13. FMODE_CREATE = #0E
  14.  
  15.     MACRO esxCall func
  16.     rst #8 : db func
  17.     ENDM
  18.  
  19. ; HL - filename in ASCIIZ
  20. loadBuffer:
  21.     ld b, Dos.FMODE_READ: call Dos.fopen
  22.     push af
  23.         ld hl, outputBuffer, bc, #ffff - outputBuffer : call Dos.fread
  24.         ld hl, outputBuffer : add hl, bc : xor a : ld (hl), a : inc hl : ld (hl), a
  25.     pop af
  26.     call Dos.fclose
  27.     ret
  28.  
  29. ; Returns:
  30. ;  A - current drive
  31. getDefaultDrive:
  32.     ld a, 0 : esxCall ESX_GETSETDRV
  33.     ret
  34.  
  35. ; Opens file on default drive
  36. ; B - File mode
  37. ; HL - File name
  38. ; Returns:
  39. ;  A - file stream id
  40. fopen:
  41.     push bc : push hl
  42.     call getDefaultDrive
  43.     pop ix : pop bc
  44.     esxCall ESX_FOPEN
  45.     ret
  46.  
  47. ; A - file stream id
  48. fclose:
  49.     esxCall ESX_FCLOSE
  50.     ret
  51.  
  52. ; A - file stream id
  53. ; BC - length
  54. ; HL - buffer
  55. ; Returns
  56. ;  BC - length(how much was actually read)
  57. fread:
  58.     push hl : pop ix
  59.     esxCall ESX_FREAD
  60.     ret
  61.  
  62. ; A - file stream id
  63. ; BC - length
  64. ; HL - buffer
  65. ; Returns:
  66. ;   BC - actually written bytes
  67. fwrite:
  68.     push hl : pop ix
  69.     esxCall ESX_FWRITE
  70.     ret
  71.    
  72. ; A - file stream id
  73. fsync:
  74.     esxCall ESX_FSYNC
  75.     ret
  76.  
  77.     ENDMODULE