?login_element?

Subversion Repositories NedoOS

Rev

Rev 2007 | 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)
  55.     and a
  56.     ret nz
  57.     ;call Wifi.continue
  58.     jr .loop
  59.  
  60.     ifdef GS
  61. loadMod:
  62.     xor a : call GeneralSound.init
  63.     ld hl, .progress : call DialogBox.msgNoWait
  64.     call makeRequest : jp c, Fetcher.fetchFromNet.error
  65.     call GeneralSound.loadModule
  66. .loop
  67.     ld hl, outputBuffer, (Wifi.buffer_pointer), hl
  68.     call Wifi.getPacket
  69.     ld a, (Wifi.closed) : and a : jr nz, .exit
  70.     ld hl, outputBuffer, bc, (Wifi.bytes_avail)
  71. .loadLoop
  72.     ld a, b : or c : and a : jr z, .nextFrame
  73.     ld a, (hl) : call GeneralSound.sendByte
  74.     dec bc
  75.     inc hl
  76.     jr .loadLoop
  77. .nextFrame
  78.     call pulsing
  79.     ;call Wifi.continue
  80.     jr .loop
  81. .exit
  82.     call GeneralSound.finishLoadingModule
  83.     ;jp History.back
  84.         jp MediaProcessor.processResource
  85. .progress db "MOD downloading directly to GS!", 0
  86.     endif
  87.  
  88. download:
  89.     ld de, historyBlock.locator
  90.     ld hl, de
  91. .findFileName
  92.     ld a, (de) : inc de
  93.     cp '/' : jr nz, .skip
  94.     ld hl, de
  95. .skip
  96.     and a : jr nz, .findFileName
  97. .copy
  98.     ;; HL - filename pointer
  99.     ld de, DialogBox.inputBuffer
  100. .copyFileName
  101.     ld a, (hl) : and a : jr z, .finishCopy
  102.  
  103.     ld (de), a : inc hl, de
  104.     jr .copyFileName
  105. .finishCopy
  106.     ld (de), a
  107.     call DialogBox.inputBox.noclear
  108.     ld a, (DialogBox.namedownload) : and a : jp z, History.back
  109.    
  110.     call makeRequest : jp c, Fetcher.fetchFromNet.error
  111.  
  112.     ld b, Dos.FMODE_CREATE, hl, DialogBox.namedownload
  113.     call Dos.fopen
  114.     ld (.fp), a
  115.    
  116.     ld hl, .progress : call DialogBox.msgNoWait
  117. .loop
  118.     ld hl, outputBuffer, (Wifi.buffer_pointer), hl
  119.     call Wifi.getPacket
  120.     ld a, (Wifi.closed) : and a : jr nz, .exit
  121.    
  122.     ld a, (.fp), hl, outputBuffer, bc, (Wifi.bytes_avail)
  123.     call Dos.fwrite
  124.     call pulsing
  125.     jr .loop
  126. .exit
  127.     ld a, (.fp)
  128.     call Dos.fclose
  129.     jp History.back
  130. .error
  131.     ld a, (.fp)
  132.     call Dos.fclose
  133.     ld hl, .err
  134.     call DialogBox.msgBox
  135.     jp History.back
  136.  
  137. .err db "Operation failed! Sorry! Check filename or disk space!",0
  138. .progress db "Downloading in progress! Wait a bit!", 0
  139. .fp db 0
  140. socket db 0
  141. pulsator db " "
  142. pulsing
  143.     ld de, #0B01 : call TextMode.gotoXY
  144.     ld a, (pulsator)
  145.     cp '*'
  146.     jp z, printasterix
  147.     call TextMode.putC
  148.     ld a, '*'
  149.     ld (pulsator),a
  150.     ret
  151. printasterix
  152.     call TextMode.putC
  153.     ld a, ' '
  154.     ld (pulsator),a
  155.     ret
  156.  
  157. requestbuffer ds #1ff
  158.     endmodule
  159.