?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4. INTSTACK=0x3800
  5.  
  6.         org PROGSTART
  7. begin
  8.         ;ld ix,(1<<9)+(2<<5)+12
  9.         ;ld hl,(7<<11)+(34<<5)+(23/2) ;ix=date, hl=time
  10.         ;OS_SETTIME
  11.  
  12.         ;ld e,6 ;textmode
  13.         ;OS_SETGFX
  14.         call initstdio
  15.  
  16.         ld a,0x01 ;ld bc
  17.         ld (callcommand),a
  18.         ld hl,tfreetime
  19.         call prtext
  20.         call looper
  21.         call prdword_dehl
  22.         call crlf
  23.  
  24.         ld a,0xcd ;call
  25.         ld (callcommand),a
  26.         ld hl,tfreetimeos
  27.         call prtext
  28.         call looper
  29.         call prdword_dehl
  30.         call crlf
  31.  
  32.         call swapimer
  33.        
  34.         call yieldgetkeyloop
  35.  
  36.         QUIT
  37.        
  38. looper        
  39.         halt
  40.         call swapimer
  41.         ld hl,timeloop
  42.         ld (on_int_q),hl
  43.         ld de,0
  44.         ld hl,timeloopq
  45.         ld hx,8+1
  46.         ds 0x200-1-$
  47.         halt ;quit to timeloop
  48. timeloop
  49.         ld (on_int_q),hl
  50.         ds 256-4-4
  51.         inc de
  52.         jp timeloop
  53. timeloopq
  54.         ld hl,(on_int_jp)
  55. ;d,e,l=NOPs
  56.         ld h,e
  57.         ld e,d
  58.         ld d,0
  59. ;dehl=NOPs
  60.         dup 3
  61.         srl d
  62.         rr e
  63.         rr h
  64.         rr l
  65.         edup
  66.         push de
  67.         push hl
  68.         call swapimer
  69.         pop hl
  70.         pop de
  71.         ret
  72.  
  73. prtext
  74. ;hl=text
  75.         push hl
  76.         call strlen ;hl=length
  77.         pop de ;de=text
  78.         jp sendchars
  79.  
  80. strlen
  81. ;hl=str
  82. ;out: hl=length
  83.         xor a
  84.         ld b,a
  85.         ld c,a ;чтобы точно найти терминатор
  86.         cpir ;найдём обязательно, если длина=0, то bc=-1 и т.д.
  87.         ld hl,-1
  88.         or a
  89.         sbc hl,bc
  90.         ret
  91.  
  92. swapimer
  93.         di
  94.         ld de,0x0038
  95.         ld hl,oldimer
  96.         ld bc,3
  97. swapimer0
  98.         ld a,(de)
  99.         ldi ;[oldimer] -> [0x0038]
  100.         dec hl
  101.         ld (hl),a ;[0x0038] -> [oldimer]
  102.         inc hl
  103.         jp pe,swapimer0
  104.         ei
  105.         ret
  106. oldimer
  107.         jp on_int ;заменится на код из 0x0038
  108.         jp 0x0038+3
  109.  
  110. on_int
  111. ;restore stack with de
  112.         EX DE,HL
  113.         EX (SP),HL ;de="hl", в стеке "de"
  114.         LD (on_int_jp),HL
  115.         LD (on_int_sp),SP
  116.         LD SP,INTSTACK
  117.         push af
  118.         push bc
  119.         push de ;"hl"
  120.         exx
  121.         ex af,af' ;'
  122.         push af
  123.         push bc
  124.         push de
  125.         push hl
  126.         push ix
  127.         push iy
  128. callcommand=$
  129.         call oldimer ;ei ;а что если выйдем поздно (по yield)? надо в конце обработчика убрать ei, но и это не поможет, т.к. yield сейчас с включенными прерываниями!!!      
  130.  
  131.         pop iy
  132.         pop ix
  133.         pop hl
  134.         pop de
  135.         pop bc
  136.         pop af
  137.         ex af,af' ;'
  138.         exx
  139.         pop hl
  140.         pop bc
  141.         pop af        
  142. on_int_sp=$+1
  143.         ld sp,0
  144.         pop de
  145.         ei
  146.         dec hx
  147. on_int_jp=$+1
  148.         jp nz,0;jp 0
  149. on_int_q=$+1
  150.         jp timeloop ;/timeloopq
  151.  
  152. crlf
  153.         ld hl,2 ;hl=length
  154.         ld de,tcrlf ;de=text
  155.         jp sendchars
  156.  
  157. tcrlf
  158.         db 13,10
  159. tfreetime
  160.         db "Free time with generic user INT handler (NOPs)=",0
  161. tfreetimeos
  162.         db "Free time with generic user INT handler (NOPs)=",0
  163.        
  164.         include "../_sdk/stdio.asm"
  165.         include "../_sdk/prdword.asm"
  166. end
  167.         savebin "freetime.com",begin,end-begin
  168.  
  169.         LABELSLIST "../../us/user.l",1
  170.