?login_element?

Subversion Repositories NedoOS

Rev

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

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