?login_element?

Subversion Repositories NedoOS

Rev

Rev 559 | Rev 712 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1.         DEVICE ZXSPECTRUM128
  2.         ;device pentagon1024
  3.  
  4.         include "../_sdk/syssets.asm"
  5. TOPDOWNMEM=0;1
  6.  
  7.                 if atm != 2
  8. memport0000=0x37f7
  9. memport4000=0x77f7
  10. memport8000=0xb7f7
  11. memportc000=0xf7f7
  12. memportrom0000=0x3ff7
  13. memportrom4000=0x7ff7
  14. memportrom8000=0xbff7
  15. memportromc000=0xfff7
  16. pagexor=0xff
  17.         else
  18. memport0000=0x3ff7
  19. memport4000=0x7ff7
  20. memport8000=0xbff7
  21. memportc000=0xfff7
  22. memportrom0000=0x3ff7
  23. memportrom4000=0x7ff7
  24. memportrom8000=0xbff7
  25. memportromc000=0xfff7
  26. pagexor=0x7f
  27.         endif
  28.        
  29.         if NEMOIDE==1
  30. ;схема Nemo:
  31. hddstat=0xF0
  32. hddcmd=0xF0
  33. hddhead=0xD0
  34. hddcylhi=0xB0
  35. hddcyllo=0x90
  36. hddsec=0x70
  37. hddcount=0x50
  38. hdderr=0x30
  39. hdddatlo=0x10
  40. hdddathi=0x11
  41. hddupr=0xC8
  42. hdduprON=0
  43.         else
  44. ;схема ATM:
  45. hddstat=0xFEEF
  46. hddcmd=0xFEEF
  47. hddhead=0xFECF
  48. hddcylhi=0xFEAF
  49. hddcyllo=0xFE8F
  50. hddsec=0xFE6F
  51. hddcount=0xFE4F
  52. hdderr=0xFE2F
  53. hdddatlo=0xFE0F
  54. hdddathi=0xFF0F
  55. hddupr=0xFEBE ;при установленном b7 FFBA
  56. hdduprON=0xFFBA
  57. hddupr1=0xF7
  58. hddupr0=0x77
  59.         endif
  60. memport8000_hi=memport8000/256
  61. memportc000_hi=memportc000/256
  62.  
  63. SYSMINSTACK=0x3b00
  64.  
  65. resident=0x6000;0x6000+8000 (где не затрут при очистке экрана) ;pgtrdosfs
  66. trdos_catbuf=0x6300;0x3200 ;,0x900 ;pgtrdosfs (0x4000)
  67. trdos_sectorbuf=0x6c00
  68. trdos_fcbbuf=0x6d00 ;size=0x200*trdos_MAXFILES
  69. trdos_MAXFILES=8
  70. INTMUZSTACK=0x3e00 ;kernelspace
  71. INTSTACK1=0x3f00 ;kernelspace (для входа в обработчик без порчи стека)
  72. INTSTACK2=0x5f00;0x6000 ;pgkillable и pgtrdosfs (рабочий стек обработчика прерываний) (>=0x4000, иначе нельзя выключить теневые порты)
  73. TRDOSSTACK=0x5f00-96;0x6000-96 ;чтобы не пересекалось с INTSTACK (в промежутке между преключениями страниц может произойти системное прерывание), но и на экран не попало
  74. BDOSSTACK=0x4000 ;kernelspace
  75. STACK=0x4000 ;userspace
  76. ;при вызове BDOS стек некоторое время такой же, как в юзерспейсе
  77. ;поэтому на входе в BDOS надо иметь в 0x4000...0xffff страницы, которые не жалко
  78. ;предполагается, что юзер не имеет стек ниже 0x3b00, иначе он затрёт систему
  79.  
  80.         include "../_sdk/sys_h.asm"
  81.  
  82.         if TOPDOWNMEM
  83. pgtrdosfs=pagexor-(sys_npages-1)
  84. pgfatfs=pagexor-(sys_npages-2)
  85. pgsys=pagexor-(sys_npages-3)
  86. pgfatfs2=pagexor-(sys_npages-4) ;structs
  87.         else
  88. pgtrdosfs=pagexor-8
  89. pgfatfs=pagexor-9
  90. pgsys=pagexor-10
  91. pgfatfs2=pagexor-11 ;structs
  92.         endif
  93.  
  94. pgkillable=pagexor-4 ;в 128K памяти, т.к. можно портить
  95. ;pgfirstfree=pagexor-11
  96.  
  97. pgscr0_0=pagexor-1
  98. pgscr0_1=pagexor-5
  99. pgscr1_0=pagexor-3
  100. pgscr1_1=pagexor-7
  101.  
  102. fd_system=0x57;%01010111 ;%0x01sx1x ;для неисправленного АТМ2 надо A9=1, а номер страницы в 0x7ffd не будет влиять, если адресация по memportc000
  103. fd_system_getchar=0x56;%01010110 ;%0x01sx1x ;для неисправленного АТМ2 надо A9=1, а номер страницы в 0x7ffd не будет влиять, если адресация по memportc000
  104. fd_user=0x47;%01000111 ;%0x00sx1x ;для неисправленного АТМ2 надо A9=1, а номер страницы в 0x7ffd не будет влиять, если адресация по memportc000
  105.  
  106. ;условные страницы для sjasm
  107. COMPILEPG_INIT=0
  108. COMPILEPG_SYS0=4
  109. COMPILEPG_SYS1=6
  110.  
  111.         SLOT 1
  112.         page COMPILEPG_INIT
  113.         org 0x6000
  114. begin
  115.         xor a
  116.         out (0xfe),a
  117.        
  118.          ifdef KOE
  119.                 display "KOE!!!"
  120.                 ld a,0 ;turbo ;0x10 ;noturbo
  121.                 ld bc,0xeff7
  122.                 out (c),a ;for KOE
  123.                 ld a,0x10
  124.                 ld bc,0x7ffd
  125.                 out (c),a
  126.          endif
  127.                
  128.         LD (IY+1),0xCC
  129.  
  130.         if 1==0
  131.        ;IFN em3d13
  132.        ; LD HL,ONERR
  133.        ; LD (23747),HL
  134.        ;ENDIF
  135.        LD A,(23833)
  136.        ADD A,"A
  137.       LD (src),A
  138.       LD (dst),A
  139.       XOR A
  140.       LD (23658),A ;0x5c6a
  141.      ;LD L,A,H,L
  142.      ;LD (23802),HL
  143.        endif
  144.       XOR A
  145.         ld (0x5d10),a
  146.        
  147.        ;ld hl,0xc9f1 ;pop af:ret
  148.        ;ld (0x5cc2),hl
  149.        
  150.        ;ld bc,0xfbdf ;x
  151.        ;in l,(c)
  152.        ;ld b,0xff
  153.        ;in h,(c)
  154.        ;ld (init_oldmousecoords),hl
  155.  
  156. ;;;;;;;;;;;;;;;;;;; set gfx mode ;;;;;;;;;;;;;;;;;
  157.        halt
  158.        ;LD A,0xaa;%10101010 ;640x200 mode
  159.        ;LD A,0xae;%10101110 ;textmode
  160.                 if atm==1
  161.                         ;выясним откуда запустились
  162. init_rst_buf=0x4000
  163.                         ld hl,init_rst_buf
  164.                         rst 0x08
  165.                         defb 0x50,0x03
  166.                         rst 0x08        ; в D вернется текущий драйв
  167.                         defb 0x50,0x02
  168.                         ld a,d
  169.                         add a,a
  170.                         add a,a
  171.                         add a,a
  172.                         ld hl,init_rst_buf
  173.                         ld b,0
  174.                         ld c,a
  175.                         add hl,bc
  176.                         ld de,init_rst_buf+512
  177.                         ld bc,8
  178.                         ldir
  179.                         ld a,(init_rst_buf+512)
  180.                         rst 0x08
  181.                         defb 0x50,0x05
  182.                         ld a,(init_rst_buf+512)
  183.                         and 1 ;m/s
  184.                         ld hl,init_rst_buf
  185.                         ld bc,0x0000
  186.                         ld d,b
  187.                         ld e,c
  188.                         ld a,2
  189.                         ex af,af'
  190.                         ld a,1
  191.                         rst 0x08
  192.                         defb 0x50,0x04,0x02
  193.                         ld a,(init_rst_buf+512)
  194.                         ld d,12
  195.                         cp 0x0f
  196.                         jr z,.l3
  197.                         ld d,3
  198.                         cp 4
  199.                         jr z,.init_sysdev_part
  200.                         ld d,7
  201.                         cp 5
  202.                         jp nz,init_sysdev_end
  203. .init_sysdev_part
  204.                         ld hl,init_rst_buf+0x01BE+0x0008-12
  205. .l2
  206.                         inc d
  207.                         push de
  208.                         ld bc,12
  209.                         add hl,bc
  210.                         ld bc,0x0400
  211.                         ld de,init_rst_buf+512+3
  212. .l1                     ld a,(de)
  213.                         xor (hl)
  214.                         or c
  215.                         ld c,a
  216.                         inc de
  217.                         inc hl
  218.                         djnz .l1
  219.                         pop de
  220.                         or a
  221.                         jr nz,.l2
  222. .l3
  223.                         ld a,d
  224.                         ld (init_sysdrv_val),a
  225. init_sysdev_end
  226.                         halt
  227.                         ld bc,0xeff7
  228.                         ld a,0x80
  229.                         out (c),a
  230.                         ld a,0x10
  231.                         ld bc,0x7ffd
  232.                         out (c),a
  233.                         ld bc,0x01bf
  234.                         out (c),b
  235.                         LD A,0xa8;%10101000 ;320x200 mode
  236.                         ld bc,0xbd77    ;shadow ports and palette remain on
  237.                         out (c),a
  238.                         xor a
  239.                         out (0xbf),a
  240.                 else
  241.                         LD A,0xa8;%10101000 ;320x200 mode
  242.                         CALL INIT_OUTSHADON
  243.        endif
  244.        call INIT_blackpal
  245.  
  246.        di
  247.                 if atm==1 and PS2KBD
  248.                         ld bc,0xdef7   
  249.                         out (c),c              
  250.                         ld b,0xbe              
  251.                         ld a,2                 
  252.                         out (c),a
  253.                 endif
  254.                
  255.                 if atm==3 or atm==1
  256.                         ld a,0x7f-5
  257.                         ld bc,memportrom4000
  258.                         out (c),a ;отключаем 7ffd
  259.                         ld a,0x7f-2
  260.                         ld bc,memportrom8000
  261.                         out (c),a ;отключаем 7ffd
  262.                         ;ld a,0x7f-2
  263.                         ld bc,memportromc000
  264.                         out (c),a ;отключаем 7ffd
  265.                 endif
  266.                
  267.                 ifn atm==1
  268.                         call findpgdos
  269.                 else
  270.                         ;ld a,0x04
  271.                         ;in a,(0xbe)
  272.                         ;and 0xbf;%10111111
  273.                         ld a,0x8b
  274.                 endif
  275.         ld lx,a
  276.        ld (sys_pgdos),a ;до установки резидента
  277.  
  278.        ld a,pgsys
  279.        call INIT_setpg_c000
  280.        ld hl,0x8000
  281.        ld de,0xc000
  282.        ld bc,0x4000
  283.        ldir
  284.        
  285.        ld a,pgtrdosfs
  286.        call INIT_setpg_c000
  287.        ld hl,wastrdosfs
  288.        ld de,0xc000+idle;COMMANDLINE;PROGSTART ;idle code
  289.        ld bc,trdosfs_sz
  290.        ldir
  291.                         ld a,0xc3
  292.                         ld (0x5cc2),a
  293.                         ld hl,ONERR;ddrv
  294.                         ld (0x5cc3),hl
  295.                         ld hl,0x5c00
  296.                         ld de,0xc000+0x1c00
  297.                         ld bc,0x0200;0x5d3b-0x5c00
  298.                         ldir
  299.        ld hl,wasresident
  300.        ld de,resident+0xc000-0x4000
  301.        ld bc,resident_sz
  302.        ldir
  303.                         ld hl,0x5c4b
  304.                         ld de,varbas_stor+0x8000
  305.                         ld bc,32
  306.                         ldir
  307.        
  308.        ld hl,0xc000+trdos_fcbbuf-0x4000
  309.        ld d,h
  310.        ld e,l
  311.        inc de
  312.        ld bc,0x200*trdos_MAXFILES-1
  313.        ld (hl),l;0
  314.        ldir
  315.  
  316.        ;ld a,pgidle
  317.        ;call INIT_setpg_c000
  318.        ;ld hl,wasidle
  319.        ;ld de,0x0100+0xc000
  320.        ;ld bc,idle_sz
  321.        ;ldir
  322.        
  323.        ld a,pgsys
  324.        call INIT_setpg_8000
  325.        ld a,pgfatfs
  326.        call INIT_setpg_c000
  327.        
  328. ;перебрасываем 16K упакованный блок в 0xc000
  329.        ld hl,wassys+0x3fff
  330.        ld de,0xffff
  331.        ld bc,0x4000
  332.        lddr
  333. ;распаковываем в 0x6400
  334.        ld hl,0xc000;wassys
  335.        ld de,0x6400;0x8000
  336.        call DEC40 ;распаковываем в 0x8000 (там уже включены системные странички)
  337. ;перебрасываем 32K из 0x6400 в 0x8000
  338.        ld hl,0x6400+0x7fff
  339.        ld de,0x8000+0x7fff
  340.        ld bc,0x8000
  341.        lddr
  342.  
  343. fatfspatchaddr=0xc000
  344.        
  345.        ld hl,devices_init
  346.        ld (0xc000+FFS_DRV.init),hl
  347.        ld hl,disk_status
  348.        ld (0xc000+FFS_DRV.status),hl
  349.         ld hl,devices_read      ;read to userspace
  350.        ld (0xc000+FFS_DRV.rd_to_usp),hl
  351.         ld hl,devices_readnopg  ;read to buffer
  352.        ld (0xc000+FFS_DRV.rd_to_buf),hl
  353.         ld hl,devices_write     ;write from userspace
  354.        ld (0xc000+FFS_DRV.wr_fr_usp),hl
  355.         ld hl,devices_writenopg ;write from buffer
  356.        ld (0xc000+FFS_DRV.wr_fr_buf),hl
  357.        ld hl,get_fattime
  358.        ld (0xc000+FFS_DRV.RTC),hl
  359.         ld hl,strcpy_lib2usp   
  360.        ld (0xc000+FFS_DRV.strcpy_lib2usp),hl
  361.        ld hl,strcpy_usp2lib
  362.        ld (0xc000+FFS_DRV.strcpy_usp2lib),hl
  363.        ld hl,memcpy_lib2usp
  364.        ld (0xc000+FFS_DRV.memcpy_lib2usp),hl
  365.        ld hl,memcpy_usp2lib
  366.        ld (0xc000+FFS_DRV.memcpy_usp2lib),hl
  367.        ld hl,memcpy_buf2usp
  368.        ld (0xc000+FFS_DRV.memcpy_buf2usp),hl
  369.        ld hl,memcpy_usp2buf
  370.        ld (0xc000+FFS_DRV.memcpy_usp2buf),hl
  371.  
  372. ;инициализация менеджера памяти и вход в юзерспейс:
  373. ;HALT (чтобы прерывание не произошло когда не надо)
  374. ;[назначаем страницы системспейса (одна из них должна быть такая же, как в юзерспейсе) - уже есть общая страница 5]
  375. ;в юзерспейсе назначаем нижнюю страницу с керналем (вместо ПЗУ)
  376.        ld a,fd_user
  377.        out (0xfd),a
  378.                 if atm==3 or atm==1
  379.         ld a,0x7f
  380.         ld bc,memportrom0000
  381.         out (c),a ;отключаем ПЗУ
  382.         ld a,0x7f-5
  383.         ld bc,memportrom4000
  384.         out (c),a ;отключаем 7ffd
  385.         ld a,0x7f-2
  386.         ld bc,memportrom8000
  387.         out (c),a ;отключаем 7ffd
  388.         ;ld a,0x7f-2
  389.         ld bc,memportromc000
  390.         out (c),a ;отключаем 7ffd
  391.        endif
  392.        ld a,pgtrdosfs ;idle
  393.        ld bc,memport0000
  394.        out (c),a
  395.        
  396.        ;ld hl,wasuserkernel+0x8000
  397.        ;ld de,0
  398.        ;ld bc,userkernel_sz
  399.        ;ldir
  400.        
  401.        ld a,fd_system
  402.        out (0xfd),a
  403.                 if atm==3 or atm==1
  404.         ld a,0x7f
  405.         ld bc,memportrom0000
  406.         out (c),a ;отключаем ПЗУ
  407.         ;4000,8000,c000 уже отключили 7ffd выше
  408.        endif
  409.        ld a,pgsys
  410.        ld bc,memport0000
  411.        out (c),a
  412. ;в системспейсе:
  413. ;включить fatfs
  414. ;поставить резидент в 7fxx
  415. ;переходим в sys_intq, а оттуда в init_resident
  416.  
  417.        if 1==0
  418.        ld a,lx;(sys_pgdos)
  419.        ld bc,memportrom0000
  420.        out (c),a
  421.        LD A,0xa8;%10101000 ;320x200 mode
  422.         ld bc,0xff77 ;shadow ports off, palette off
  423.        out (c),a
  424.        ld a,1
  425.        ld c,1
  426.        call 0x3d13
  427.        ld c,0x18
  428.        call 0x3d13
  429.        ld hl,0xc000
  430.        ld de,0x0000
  431.        ld bc,0x0805
  432.        call 0x3d13
  433.        jr $
  434.        endif
  435.  
  436.        ld sp,BDOSSTACK
  437.        ;ei
  438.        ;halt ;чтобы прерывание не произошло когда не надо
  439.        ;di
  440.        ;jr $
  441. ;init_oldmousecoords=$+1
  442. ;        ld hl,0
  443. ;        ld (sys_oldmousecoords),hl
  444.          call BDOS_setpgstructs
  445.          ld hl,0xc000
  446.          ld de,0xc001
  447.          ld bc,0x3fff
  448.          ld (hl),l;0
  449.          ldir ;не помогло
  450. init_sysdrv_val=$+1
  451.          ld a,SYSDRV
  452.          ld (SYSDRV_VAL),a
  453.        jp setkernelpages_go ;di!!!
  454.        
  455.                 ifn atm==1
  456. INIT_OUTSHADON
  457.        ;LD BC,0xFF77 ;shadow ports remain off
  458.                         LD BC,0xBD77 ;shadow ports and palette remain on
  459.                         LD IX,10835
  460.                         PUSH IX
  461.                         JP 0x3D2F
  462.                 endif
  463.  
  464. INIT_setpg_low
  465.        LD BC,memportrom0000 ;page for 0x0000..0x3fff
  466.        OUT (C),A
  467.        ret
  468.  
  469. INIT_setpg_8000
  470.        LD BC,memport8000 ;page for 0x8000..0xbfff
  471.        OUT (C),A
  472.        ret
  473.  
  474. INIT_setpg_c000
  475.        LD BC,memportc000 ;page for 0xc000..0xffff
  476.        OUT (C),A
  477.        ret
  478.                
  479.                 ifn atm==1
  480. findpgdos
  481. ;если не найти страницу текущего доса, то на старых версиях ПЗУ ZX Evo не будет работать (в странице 0x83 почему-то не дос по умолчанию)
  482.        call crcdos
  483.        ld (doscrchi),de
  484.        ld (doscrclo),bc
  485.        ld lx,0x83
  486. findpgdos0
  487.        ld a,lx
  488.        call INIT_setpg_low
  489.        call crcdos
  490. doscrchi=$+1
  491.        ld hl,0
  492.        or a
  493.        sbc hl,de
  494.        jr nz,doscrcbad
  495. doscrclo=$+1
  496.        ld hl,0
  497.        or a
  498.        sbc hl,bc
  499.        jr nz,doscrcbad
  500.        ld a,lx
  501.        ret
  502. doscrcbad
  503.        ld a,lx
  504.        add a,4
  505.        ld lx,a
  506.        cp 0xc0
  507.        jr c,findpgdos0
  508.        ld a,0x83 ;not found
  509.        ret
  510. crcdos
  511.        ld hl,0x0000
  512.        ld bc,0
  513.        ld de,0
  514. crcdos0
  515.        ld a,d
  516.        add a,a
  517.        rl c
  518.        rl b
  519.        rl e
  520.        rl d
  521.        xor b
  522.        ld b,a
  523.        ld a,(hl)
  524.        xor c
  525.        ld c,a
  526.        inc hl
  527.        bit 6,h
  528.        jr z,crcdos0
  529.        ret
  530.                 endif
  531.  
  532. INIT_blackpal
  533.        LD HL,blackpalend
  534.        ;halt ;halt есть выше - убрано, чтобы не светилось ничего
  535.        LD DE,0xa80f ;0xab=6912 ;palette on, EGA, turbo
  536.        LD BC,0xBD77
  537.        OUT (C),D
  538. INIT_setpal0 LD A,E
  539.         and 7
  540.        BIT 3,E
  541.        OUT (0xFE),A
  542.        JR Z,$+4
  543.        OUT (0xF6),A
  544.        LD A,(HL)
  545.        DEC HL
  546.        ld b,(hl) ;DDp palette low bits
  547.        dec hl
  548.        ld c,0xff
  549.        OUT (c),a;(0xFF),A
  550.        DEC E
  551.        JP P,INIT_setpal0
  552.        ret
  553.  
  554.        ds 32,0xf3
  555. blackpalend=$-1
  556.  
  557.        include "unmegalz.asm" ;DEC40
  558.  
  559. wasresident
  560.        disp resident
  561.                 ifn atm==1
  562. readmouse  ;=$-wasresident+resident
  563. ;sp=0x7fxx
  564. ;e=gfxmode
  565. ;out: hl=mousecoords, d=mousebuttons
  566.                         call sys_SHADOFF
  567.                         ld bc,0xfadf ;buttons
  568.                         in d,(c)
  569.                         inc b ;ld bc,0xfbdf ;x
  570.                         in l,(c)
  571.                         ld b,0xff ;y
  572.                         in h,(c)
  573.                 endif
  574. shadon_pgsys  ;=$-wasresident+resident
  575.        LD A,e;0xa8;%10101000 ;320x200 mode
  576. shadon_pgsys_a  ;=$-wasresident+resident
  577.                 ifn atm==1
  578.                         CALL sys_SHADON
  579.                 else
  580.                         ld bc,0x01bf
  581.                         out (c),b
  582.                         ld bc,0xbd77    ;shadow ports and palette remain on
  583.                         out (c),a
  584.                         xor a
  585.                         out (0xbf),a
  586.                 endif
  587.                
  588.                 if atm==3 or atm==1
  589.                         ld a,0x7f
  590.                         call sys_setpg_low
  591.                         ld a,pgsys
  592.                         ld bc,memport0000
  593.                         jr sys_outca_jr
  594.         else
  595.                         ld a,0x7f-(pagexor-pgsys)
  596.         endif
  597. sys_setpg_low  ;=$-wasresident+resident
  598.                 ld bc,memportrom0000
  599.                 jr sys_outca_jr
  600. sys_SHADOFF  ;=$-wasresident+resident
  601. sys_pgdos=wasresident+(($+1)-resident) ;для патча
  602.                 ld a,0x83 ;48 basic switchable to DOS
  603.                 call sys_setpg_low
  604.        LD A,e;0xa8;%10101000 ;320x200 mode
  605.                 ld bc,0xff77 ;shadow ports off, palette off
  606. sys_outca_jr
  607.        out (c),a
  608.                 ret
  609.                 ifn atm==1
  610. sys_SHADON  ;=$-wasresident+resident
  611.                         LD bc,10835
  612.                         PUSH bc
  613.                         LD BC,0xBD77 ;shadow ports and palette remain on
  614.                         JP 0x3D2F
  615.                 endif
  616.  
  617. ;TODO убрать в pgtrdos
  618. dos3d13_resident  ;=$-wasresident+resident
  619.  
  620. ;сейчас включена pg5
  621. ;iy=23610
  622.        ld (dos3d13_sp_st),sp
  623.        ld sp,trdos_sp ;надо стек в 0x4000+ (не пересекающийся с INTSTACK, т.к. сейчас может произойти системное прерывание), по умолчанию стек был в 0x3fxx
  624.        ;call swap_sysvars
  625.        ex af,af'
  626.        call sys_SHADOFF ;включили ПЗУ
  627.                 ld (em3d13_de_st),de    ;push de ;e=gfxmode
  628.                  
  629.                 ;***************************** 
  630.                 ;call EM3D13PP;0x3d13
  631.                 ;собственно дpайвеp, аналогичный 0x3д13 (и с его использованием)
  632.                 ;на выходе - A pавно 0 - все окей, не 0 - ошибка
  633.                 ;вместо  пpоцедyp DRAW_WINDOWS, PRINT_WINDOWS и REST_WINDOW
  634.                 ;использyй свои.
  635.                 ;Kurleson
  636. ;EM3D13PP
  637.         ld      hl,em3d13pp_ret
  638.         push    hl
  639.         ld      (23613),sp
  640.         xor     a
  641.         ld (23801),a
  642.         ld      (23823),a
  643.         ld      (23824),a
  644.         ld hl,varbas_stor
  645.         ld de,0x5c4b
  646.         ld bc,32
  647.         ldir
  648.         if atm == 1
  649.                 xor a
  650.                 out (0xbf),a
  651.         endif
  652.         exx     ;pop hl,de,bc
  653.         ex af,af'
  654.         jp      0x3D13
  655.        
  656. ONERR
  657.         ex      (sp),hl
  658.         push    af
  659.         ld a,(0x5d0f)
  660.         or a
  661.         jr nz,em3d13pp_ret
  662.         ld      a,h
  663.         cp      0x0d
  664.         jr      z,em3d13_error
  665. ONERR_NO
  666.         pop     af
  667.         ex      (sp),hl
  668.         ret
  669. em3d13_error  
  670.         ld      a,0xff
  671.         ld (0x5d0f),a
  672. em3d13pp_ret
  673.        
  674. em3d13_de_st=$+1
  675.     ld de,0     ;e=gfxmode
  676.         di
  677.    call shadon_pgsys ;выключили ПЗУ (неатомарно - две записи в порт!!!)
  678.         ei
  679.        ;call swap_sysvars
  680. dos3d13_sp_st=$+1       ;-wasresident+resident
  681.         ld sp,0
  682.         ld a,(0x5d0f)   ;возврат ошибки
  683.         ret
  684.                
  685.         ifn atm==1
  686. NVRAM_REG=0xdf
  687. NVRAM_VAL=0xbf
  688. minmes  ;=$-wasresident+resident
  689.    ld h,a
  690.    xor a
  691.    srl h
  692.    rra
  693.    srl h
  694.    rra
  695.    srl h
  696.    rra
  697.    ret
  698.  
  699. bcd2bin  ;=$-wasresident+resident
  700.    ld b,NVRAM_REG
  701.    out (c),a
  702.    ld b,NVRAM_VAL
  703.    in a,(c)
  704.    ret
  705.    
  706. readtime  ;=$-wasresident+resident
  707. ;sp=0x7fxx
  708. ;e=gfxmode
  709. ;out: hl=date, de=time
  710. ;TODO атомарно
  711.         call sys_SHADOFF
  712.         LD A,e;0xa8;%10101000 ;320x200 mode
  713.         push af
  714.         ld bc,0xeff7
  715.         ld a,0x80
  716.         out (c),a
  717.         ld bc,0xf7 + (NVRAM_REG<<8)
  718.    ld a,0x0b
  719.    out (c),a
  720.    ld b,NVRAM_VAL
  721.    in a,(c)
  722.    or 0x04
  723.    out (c),a
  724.     xor a               ;sec
  725.    call bcd2bin
  726.    srl a
  727.    ld e,a
  728.    
  729.     ld a,2              ;min
  730.    call bcd2bin
  731.    call minmes
  732.    add a,e
  733.    ld e,a
  734.    ld d,h
  735.    
  736.     ld a,4              ;h
  737.    call bcd2bin
  738.    add a,a
  739.    add a,a
  740.    add a,a
  741.    add a,d
  742.    ld d,a
  743.    
  744.     ld a,7              ;day
  745.    call bcd2bin
  746.    ld l,a
  747.    
  748.     ld a,8              ;mes
  749.    call bcd2bin
  750.    call minmes
  751.    add a,l
  752.    ld l,a
  753.    
  754.     ld a,9              ;god
  755.    call bcd2bin
  756.    add a,20
  757.    add a,a
  758.    add a,h
  759.    ld h,a
  760.         ld bc,0xeff7
  761.         xor a
  762.         out (c),a
  763.         pop af
  764.         jp shadon_pgsys_a
  765.                 endif
  766.  
  767.         ;disp $-wasresident+resident
  768.  
  769.                
  770.                 ds 100
  771. trdos_sp
  772. varbas_stor
  773.                 ds 32
  774.        ent
  775. resident_sz=$-wasresident
  776.        display "residentend=",resident+resident_sz,"<=",trdos_catbuf
  777.  
  778. wastrdosfs
  779.        disp COMMANDLINE;PROGSTART
  780. idle
  781.        db "idle",0
  782.        ds PROGSTART-$
  783.        include "idle.asm"
  784. idle_sz=$-idle
  785.        ent
  786.        disp 0x4000+idle+idle_sz
  787.        include "trdosfs.asm"
  788.        include "trdosio.asm"
  789.        include "bdospg2.asm"
  790.        ent
  791. trdosfs_sz=$-wastrdosfs
  792.        display "trdosfs_sz=",/h,trdosfs_sz,"<=0x1c00"
  793.        
  794. end
  795. wassys
  796.  
  797.        SLOT 0
  798.        page COMPILEPG_SYS0
  799.        SLOT 1
  800.        page COMPILEPG_SYS1
  801.        org 0x0000
  802. sysbegin
  803.        include "syskrnl.asm"
  804. wasuserkernel
  805.        disp 0x0000
  806.        include "userkrnl.asm"
  807.        ent
  808. userkernel_sz=$-wasuserkernel
  809.         ;display "wasuserkernel=",/d,wasuserkernel
  810.         ;display "wasuserkernel_end=",/d,$
  811.         ;display "userkernel_sz=",/d,userkernel_sz
  812.        ds 0x4000-$
  813.        incbin "../fatfs4os/fatfs.raw"
  814. sysend
  815.  
  816.         ;display "begin=",/d,begin
  817.         ;display "end=",/d,end
  818.        
  819.         ;display "sysbegin=",/d,sysbegin
  820.         ;display "sysend=",/d,sysend
  821.  
  822.        SLOT 1
  823.        page COMPILEPG_INIT
  824.         savebin "initcode.c",begin,end-begin
  825.        
  826.        SLOT 0
  827.        page COMPILEPG_SYS0
  828.        SLOT 1
  829.        page COMPILEPG_SYS1
  830.         savebin "syscode.c",sysbegin,sysend-sysbegin
  831.        
  832.         LABELSLIST "..\..\us\user.l"
  833.