?login_element?

Subversion Repositories NedoOS

Rev

Rev 1642 | Rev 1852 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1.     module Gopher
  2. extractRequest:
  3.     ld hl, historyBlock.locator
  4.     ld de, requestbuffer
  5. .loop
  6.     ld a, (hl)
  7.     ld (de), a
  8.     inc hl
  9.     inc de
  10.     cp 0
  11.     jr z, .search
  12.     jr .loop
  13. .search
  14.     dec de
  15.     ld a, (historyBlock.mediaType)
  16.     cp MIME_INPUT
  17.     jr nz, .exit
  18.     ld hl, historyBlock.search
  19.     ld a, TAB
  20.     ld (de), a
  21.     inc de
  22. .searchCopy
  23.     ld a, (hl)
  24.     and a : jr z, .exit
  25.     ld (de), a
  26.     inc hl : inc de
  27.     jr .searchCopy
  28. .exit
  29.     xor a
  30.     ld (de), a
  31.     ret
  32.  
  33.  
  34. makeRequest:
  35.     call extractRequest
  36.  
  37.     ld hl, historyBlock.host
  38.     ld de, historyBlock.port
  39.     call Wifi.openTCP
  40.     ret c
  41.  
  42.     ld hl, requestbuffer
  43.     call Wifi.tcpSendZ
  44.     xor a : ld (Wifi.closed), a
  45.     ret
  46.  
  47.  
  48. loadBuffer:
  49.     ld hl, outputBuffer
  50.     ld (Wifi.buffer_pointer), hl
  51. .loop
  52.     call Wifi.getPacket
  53.     ld a, (Wifi.closed) : and a : ret nz
  54.     call Wifi.continue
  55.     jr .loop
  56.  
  57.     ifdef GS
  58. loadMod:
  59.     xor a : call GeneralSound.init
  60.     ld hl, .progress : call DialogBox.msgNoWait
  61.     call makeRequest : jp c, Fetcher.fetchFromNet.error
  62.     call GeneralSound.loadModule
  63. .loop
  64.     ld hl, outputBuffer, (Wifi.buffer_pointer), hl
  65.     call Wifi.getPacket
  66.     ld a, (Wifi.closed) : and a : jr nz, .exit
  67.     ld hl, outputBuffer, bc, (Wifi.bytes_avail)
  68. .loadLoop
  69.     ld a, b : or c : and a : jr z, .nextFrame
  70.     ld a, (hl) : call GeneralSound.sendByte
  71.     dec bc
  72.     inc hl
  73.     jr .loadLoop
  74. .nextFrame
  75.     call pulsing
  76.     call Wifi.continue
  77.     jr .loop
  78. .exit
  79.     call GeneralSound.finishLoadingModule
  80.     jp History.back
  81. .progress db "MOD downloading directly to GS!", 0
  82.     endif
  83.  
  84. download:
  85.     ld de, historyBlock.locator
  86.     ld hl, de
  87. .findFileName
  88.     ld a, (de) : inc de
  89.     cp '/' : jr nz, .skip
  90.     ld hl, de
  91. .skip
  92.     and a : jr nz, .findFileName
  93. .copy
  94.     ;; HL - filename pointer
  95.     ld de, DialogBox.inputBuffer
  96. .copyFileName
  97.     ld a, (hl) : and a : jr z, .finishCopy
  98.  
  99.     ld (de), a : inc hl, de
  100.     jr .copyFileName
  101. .finishCopy
  102.     ld (de), a
  103.     call DialogBox.inputBox.noclear
  104.     ld a, (DialogBox.namedownload) : and a : jp z, History.back
  105.    
  106.     call makeRequest : jp c, Fetcher.fetchFromNet.error
  107.  
  108.     ld b, Dos.FMODE_CREATE, hl, DialogBox.namedownload
  109.     call Dos.fopen
  110.     ld (.fp), a
  111.    
  112.     ld hl, .progress : call DialogBox.msgNoWait
  113. .loop
  114.     ld hl, outputBuffer, (Wifi.buffer_pointer), hl
  115.     call Wifi.getPacket
  116.     ld a, (Wifi.closed) : and a : jr nz, .exit
  117.    
  118.     ld a, (.fp), hl, outputBuffer, bc, (Wifi.bytes_avail)
  119.     call Dos.fwrite
  120.     call pulsing
  121.     call Wifi.continue
  122.     jr .loop
  123. .exit
  124.     ld a, (.fp)
  125.     call Dos.fclose
  126.     jp History.back
  127. .error
  128.     ld a, (.fp)
  129.     call Dos.fclose
  130.     ld hl, .err
  131.     call DialogBox.msgBox
  132.     jp History.back
  133.  
  134. .err db "Operation failed! Sorry! Check filename or disk space!",0
  135. .progress db "Downloading in progress! Wait a bit!", 0
  136. .fp db 0
  137. socket db 0
  138. pulsator db " "
  139. pulsing
  140.     ld de, #0B01 : call TextMode.gotoXY
  141.     ld a, (pulsator)
  142.     cp '*'
  143.     jp z, printasterix
  144.     ld a, '*'
  145.     ld (pulsator),a
  146.     ld a,' '
  147.     call TextMode.putC
  148.     ret
  149. printasterix
  150.     ld a, ' '
  151.     ld (pulsator),a
  152.     ld a,'*'
  153.     call TextMode.putC
  154.     ret
  155.  
  156. requestbuffer ds #1ff
  157.     endmodule
  158.