?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../_sdk/sys_h.asm"
  3.  
  4.         org PROGSTART
  5. cmd_begin
  6.         ld sp,0x4000
  7.        
  8.         ld e,3 ;6912
  9.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  10.         YIELD ;set palette
  11.         OS_GETMAINPAGES
  12.         ld (reset_hook_place+5),de
  13.         ld (reset_hook_place+7),hl
  14.  
  15.         ;OS_GETSCREENPAGES
  16. ;de=pages of screen 0 (d=higher page), hl=pages of screen 1 (h=higher page)
  17.         ld a,(user_scr0_low) ;ok
  18.         ld (cmdpgscreen0_0),a
  19.  
  20. hobetarunner=0x4100
  21.  
  22.     OS_GETCONFIG
  23.     ld d,l
  24.     ld a,l    
  25.     cp 1
  26.     jr nz,no_eva
  27.  
  28.     OS_SETSYSDRV
  29.     ld sp,0x0000
  30.     ld hl,nmisvc_starter
  31.     ld de,0x0080
  32.     ld bc,nmisvc_starter_size
  33.     ldir
  34.     ld de,str_nmisvc
  35.     OS_OPENHANDLE
  36.     jp nmisvc_start
  37.    
  38. nmisvc_starter
  39.     disp 0x0080
  40. str_nmisvc
  41.     defb "/bin/nmisvc.com",0
  42. nmisvc_start
  43.     push bc
  44.         ld de,0x0100
  45.         ld hl,0xc000
  46.         OS_READHANDLE
  47.     pop bc
  48.     OS_CLOSEHANDLE
  49.     jp PROGSTART
  50.     ent
  51. nmisvc_starter_size=$-nmisvc_starter
  52.  
  53. no_eva    
  54.     ld (pcconf),a
  55.     ld c,0xff
  56.     cp 2
  57.     jr z,atm_1f
  58.     cp 3
  59.     jr nz,not_atm_1f
  60. atm_1f
  61.     ld c,0x7f
  62.     ld d,0
  63. not_atm_1f
  64.     ld (reset_hook_place+3),de
  65.     ld a,0x1f^0xff
  66.     and c
  67.     SETPGC000
  68.     ld hl,reset_hook_place
  69.     ld de,0xc000
  70.     ld bc,reset_hook_end - reset_hook_begin
  71.     ldir
  72.     ld hl,0xaa55
  73.     ld (0xfffe),hl
  74.     xor a
  75.     ld (0xfffd),a
  76.     ld hl,0xc000
  77.     ld e,a
  78. hook_crc_loop
  79.     add a,(hl)
  80.     adc a,e
  81.     inc hl
  82.     bit 7,h
  83.     jr nz,hook_crc_loop
  84.     neg
  85.     ld (0xfffd),a
  86.     di
  87. cmdpgscreen0_0=$+1
  88.         ld a,0xff-1
  89.         SETPG32KLOW
  90.         inc a ;ld a,0xff-0
  91.         SETPG32KHIGH
  92.  
  93.  
  94.     ld a,(cmdpgscreen0_0)
  95.     sub 4-1 ;ld a,0xff-4 ;pgkillable
  96.     SETPG16K
  97.  
  98.     ld hl,washobetarunner
  99.     ld de,hobetarunner
  100.     ld bc,hobetarunner_sz
  101.     ldir
  102.     jp hobetarunner
  103.  
  104.    
  105. washobetarunner
  106.         disp hobetarunner ;in pgkillable
  107.         di
  108.         ld a,0x7f-5
  109.         ld bc,0xbff7
  110.         out (c),a
  111.         ld a,0x7f-4
  112.         ld bc,0xfff7
  113.         out (c),a
  114.         ld hl,0xc000
  115.         ld de,0x8000
  116.         ld bc,0x4000
  117.         ldir ;pg4 -> pg5
  118.         ld a,0x7f-8;pgtrdosfs
  119.         ld bc,0xfff7
  120.         out (c),a
  121.         ld hl,0x1c00+0xc000
  122.         ld de,0x1c00+0x8000
  123.         ld bc,0x400
  124.         ldir ;restore sysvars
  125.         ld a,0x7f-2
  126.         ld bc,0xbff7
  127.         out (c),a
  128.         ld a,0x7f-1
  129.         ld bc,0xfff7
  130.         out (c),a
  131.         ld hl,0xc000
  132.         ld de,0x8000
  133.         ld bc,0x4000
  134.         ldir ;pg1 -> pg2
  135.         ld a,0x7f-0+0x80
  136.         ld bc,0xfff7
  137.         out (c),a
  138.         ld a,0x00
  139.         ld bc,0x7ffd
  140.         out (c),a
  141.         ld a,0x01 ;128 basic (with 7ffd)
  142.         ld bc,0x3ff7
  143.         out (c),a
  144.         ld a,0x7f-5
  145.         ld bc,0x7ff7
  146.         out (c),a
  147. ;128: pages 128/DOS,5,2,0(7ffd)
  148.         ld a,0x10
  149.         ld bc,0x7ffd
  150.         out (c),a
  151. ;48: pages 2,4,4,4
  152.         ld a,0x7f-5
  153.         ld bc,0x7ff7
  154.         out (c),a
  155.         ld a,0x7f-2
  156.         ld bc,0xbff7
  157.         out (c),a
  158.         ld a,0x7f-0+0x80
  159.         ld bc,0xfff7
  160.         out (c),a
  161.         ld a,0x83 ;48 basic switchable to DOS
  162.         ld bc,0x3ff7
  163.         out (c),a
  164. ;48: pages 48/DOS,5,2,0(7ffd)
  165.        
  166.         LD A,%10100011 ;6912
  167.         ld bc,0xff77 ;shadow ports off, palette off
  168.         out (c),a
  169.         ld sp,0x6000
  170.         ld bc,0xeff7
  171.         ld a,0x10
  172.         out (c),a
  173.        
  174.     ld a,0x10
  175.     ld bc,0x7ffd
  176.     out (c),a ;for 128 basic (проверено, работает, 48 тоже работает)
  177. pcconf=$ - hobetarunner + washobetarunner + 1
  178.     ld a,1
  179.     cp 2
  180.     jr z,set_xbios
  181.     cp 3
  182.     jr nz,not_set_xbios
  183. set_xbios
  184.     ld a,(0x3CBC)
  185.     cp 0x87
  186.     call z,0x3C9E   ;переключить в vtrdos
  187. not_set_xbios  
  188.     ld a,0
  189.     ld bc,0x7ffd
  190.     out (c),a ;for 128 basic (проверено, работает, 48 тоже работает)
  191.     ld a,7
  192.     out (0xfe),a
  193.     ld hl,0
  194.     push hl
  195.         ei
  196. hobetarunner_jp=$+1
  197.         jp 0 ;0x3d2f ;0;0x6000
  198. ;АТМный перехватчик ресета
  199.         ent
  200. hobetarunner_sz=$-washobetarunner
  201.  
  202. reset_hook_place
  203.     disp 0xc000
  204. reset_hook_begin
  205.     jp reset_hook_start
  206.     defs 10
  207. reset_hook_start
  208.     di
  209.     xor a
  210.     ld (reset_hook_begin),a
  211.     ld hl,reset_hook_begin
  212.     ld de,0x8000
  213.     ld bc,reset_hook_end - reset_hook_begin
  214.     ldir
  215.     jp $ + 3 - 0x4000
  216.     ld a,0x57
  217.     ld bc,0x7ffd
  218.     out (c),a
  219.     ld de,(0x8003)
  220.     ld iy,0x3f7f
  221.     ld ix,0xbfff
  222.     dec d
  223.     inc d
  224.     jr z,rest_atm2
  225.     ld iy,0x3777
  226.     ld ix,0xb7f7
  227. rest_atm2
  228.     ld a,0x7f
  229.     ld bc,0x3FF7
  230.     out (c),a
  231.     ld b,iyh
  232.     out (c),e
  233.     ld e,0x7b
  234.     ld b,0x7f
  235.     out (c),e
  236.     ld b,0xff
  237.     out (c),e
  238.     ld e,0x47
  239.     ld bc,0x7ffd
  240.     out (c),e
  241.     ld hl,(0x8005)
  242.     ld bc,0x3FF7
  243.     out (c),a
  244.     ld b,iyh
  245.     out (c),h
  246.     ld b,0x7F
  247.     out (c),a
  248.     ld b,iyl
  249.     out (c),l
  250.     ld hl,(0x8007)
  251.     ld b,0xfF
  252.     out (c),a
  253.     ld b,ixl
  254.     out (c),l
  255.     ld bc,0xbd77
  256.     ld a,0xae
  257.     out (c),a
  258.     ld sp,0x4000
  259.     im 1
  260.     ei
  261.     jp 0x0000
  262.    
  263. reset_hook_end
  264.         ent
  265.     nop
  266. cmd_end
  267.  
  268.         display "Size ",/d,cmd_end-cmd_begin," bytes"
  269.  
  270.         savebin "reset.com",cmd_begin,cmd_end-cmd_begin
  271.        
  272.         ;LABELSLIST "../us/user.l"
  273.