?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. pushscrtop=scrbase+0;10
  2. pushwid=40;20
  3. pushhgt=512;200 ;сколько строк графики разложено в ldpush (не менее scrhgt)
  4. ;pushpghgt=192 ;сколько строк графики помещается в одной странице (считается автоматически: строка, попавшая в +0x3fxx, переносится на +0x40xx, так что одна страничка = 0x3f00)
  5.  
  6. PUSHLINESZ=2+(pushwid*2)+2
  7.  
  8. bgpush_prepare
  9. ;de=filename
  10.         call openstream_file
  11.  
  12.         ld ix,tpushpgs
  13.         call genpush
  14.  
  15.         ld ix,tpushpgs+1
  16.         call genpush
  17.  
  18.         ld ix,tpushpgs+2
  19.         call genpush
  20.  
  21.         ld ix,tpushpgs+3
  22.         call genpush
  23.  
  24.         call readbmphead_pal
  25.  
  26.         ld (bgpush_ldbmp_sp),sp
  27.         ld sp,bgpush_loadbmplinestack+(pushhgt*2)+32
  28. ;загрузить графику bmp в ld-push
  29.         ld ix,tpushpgs
  30.         ld hl,pushbase
  31.         ld bc,pushhgt
  32. bgpush_ldbmp0
  33.        push hl ;ix в стек не кладём, иначе будет больше килобайта стека - переполнение ниже 0x3b00
  34.         ld de,PUSHLINESZ
  35.         add hl,de
  36.         ld a,h
  37.         cp pushbase/256+63
  38.         jr nz,bgpush_ldbmp0_nonextpg
  39.         ld h,pushbase/256
  40.         ld de,4
  41.         add ix,de
  42. bgpush_ldbmp0_nonextpg
  43.         dec bc
  44.         ld a,b
  45.         or c
  46.         jr nz,bgpush_ldbmp0
  47.        
  48.         ld bc,216;pushhgt
  49. bgpush_ldbmp1
  50.         ld a,h ;curln code addr
  51.        pop hl
  52.         cp h ;prevln code addr (<=curln)
  53.         jr nc,bgpush_ldbmp1_noprevpg
  54.         dec ix
  55.         dec ix
  56.         dec ix
  57.         dec ix
  58. bgpush_ldbmp1_noprevpg
  59.         inc hl
  60.         inc hl ;skip ld sp,hl:exx
  61.         ld a,pushwid/2
  62.         call bgpush_ldbmp_line
  63.         dec bc
  64.         ld a,b
  65.         or c
  66.         jr nz,bgpush_ldbmp1
  67. bgpush_ldbmp_sp=$+1
  68.         ld sp,0
  69.         jp closestream_file
  70.  
  71.  
  72. ;делаем push для одного слоя (в одной страничке помещается pushwid*pushpghgt = 38*200 или 40*192 байт пуша)
  73. ;в страничке такой код:
  74. ;ld sp,hl ;/jp (ix)
  75. ;exx
  76. ;ld bc:push bc *N ;de=0!!!
  77. ;exx
  78. ;add hl,bc ;de=0!!!
  79. ;и в самом конце jp pushbase
  80. ;задача - правильно пропатчить выход и вызвать (hl=pushscrtop+pushwid+(N*0x2000))
  81.  
  82. ;можно все строчки сгенерировать заранее, но тогда придётся на каждой четверти строчки (или один раз на строчку, если включены обе страницы экрана) вызывать переключение страниц (потому что строчка может быть в рандомной странице)
  83. ;можно все строчки сгенерировать заранее и копировать в код (но они будут разной длины!) и копирование 8 или 16 строк за фрейм долго
  84.  
  85. ;чтобы сгенерировать большую картинку 320x512 для скролла:
  86. ;- в конце странички переключалку страничек и jp pushbase
  87. ;- genpush должен сам заказывать странички
  88. ;- расчёт адреса патча/входа должен учитывать страничку
  89. ;- патч выхода должен учитывать страничку
  90. ;- вход должен учитывать страничку
  91. ;- в конце зацикливалка должна включать начальную страничку
  92.  
  93. ;переключалка страниц (на неё патч не должен попадать):
  94. ;exx ;нельзя портить bc
  95. ;ld a,N
  96. ;ld bc,pushbase+
  97. ;jp bgpush_setpg
  98.  
  99.         ds 8
  100. bgpush_setpg_stack
  101. bgpush_setpg
  102.         ld sp,bgpush_setpg_stack
  103.         push bc
  104.         SETPGPUSHBASE ;в будущем кернале это может быть call!!!
  105.         exx
  106.         ret;jp pushbase
  107.  
  108. bgpush_jppushbase
  109.         ld sp,bgpush_setpg_stack
  110.         exx ;нельзя портить bc
  111.         SETPGPUSHBASE ;в будущем кернале это может быть call!!!
  112.         exx
  113.         jp pushbase
  114.  
  115. genpush
  116.         call genpush_newpage ;заказывает страницу, заносит в tpushpgs, a=pg
  117.         SETPGPUSHBASE
  118.          ld (genpush_firstpage),a
  119.         ld hl,pushbase
  120.         ld bc,pushhgt
  121. genpush0
  122.         push bc
  123.         ld a,h
  124.         cp pushbase/256+63
  125.         call z,genpush_nextpg
  126.         ld (hl),0xf9 ;ld sp,hl
  127.         inc hl
  128.         ld (hl),0xd9 ;exx
  129.         inc hl
  130.         ld b,pushwid/2
  131. genpush1
  132.         ld (hl),1 ;ld bc
  133.         inc hl
  134.         ;ld a,r
  135.         ld (hl),0;a
  136.         inc hl
  137.         ;ld a,r
  138.         ld (hl),0;a
  139.         inc hl
  140.         ld (hl),0xc5 ;push bc
  141.         inc hl
  142.         djnz genpush1
  143.         ld (hl),0xd9 ;exx
  144.         inc hl
  145.         ld (hl),0x09 ;add hl,bc
  146.         inc hl
  147.         ;ld (hl),0xe9 ;jp (hl)
  148.         ;inc hl
  149.         pop bc
  150.         dec bc
  151.         ld a,b
  152.         or c
  153.         jr nz,genpush0
  154.         ld (hl),0x3e ;ld a,
  155.         inc hl
  156. genpush_firstpage=$+1
  157.         ld (hl),0
  158.         inc hl
  159.         ld (hl),0xc3 ;jp
  160.         inc hl
  161.         ld (hl),bgpush_jppushbase&0xff
  162.         inc hl
  163.         ld (hl),bgpush_jppushbase/256
  164.         ;inc hl
  165.         ret
  166. genpush_nextpg
  167.         ld c,l
  168.         ld b,pushbase/256
  169.         push bc ;pushbase+
  170.         call genpush_newpage ;заказывает страницу, заносит в tpushpgs, a=pg
  171.         ld (hl),0xd9 ;exx
  172.         inc hl
  173.         ld (hl),0x3e ;ld a,
  174.         inc hl
  175.         ld (hl),a
  176.         inc hl
  177.         ld (hl),0x01 ;ld bc,
  178.         inc hl
  179.         ld (hl),c
  180.         inc hl
  181.         ld (hl),b
  182.         inc hl
  183.         ld (hl),0xc3 ;jp
  184.         inc hl
  185.         ld (hl),bgpush_setpg&0xff
  186.         inc hl
  187.         ld (hl),bgpush_setpg/256
  188.         push bc
  189.         SETPGPUSHBASE
  190.         pop bc        
  191.         ;ld hl,pushbase
  192.         pop hl ;pushbase+
  193.         ret
  194.  
  195. bgpush_inccurscroll
  196. ;bc=scroll increment (signed)
  197.         ld hl,(callpush_curscroll)
  198.         add hl,bc
  199.         ld bc,pushhgt
  200.         ld a,h
  201.         or a
  202.         jp m,bgpush_inccurscroll_negative
  203.         sbc hl,bc
  204.         jr nc,$+3
  205. bgpush_inccurscroll_negative
  206.         add hl,bc
  207.         ld (callpush_curscroll),hl
  208.         ret
  209.  
  210. bgpush_draw
  211.         ;call setpgsscr40008000
  212.         call setpgscrlow4000
  213.  
  214. ;адрес входа = f(curscroll)
  215. ;адрес патча-распатча = f((curscroll+scrhgt)mod scrollhgt)
  216.  
  217. callpush_curscroll=$+1
  218.         ld bc,0 ;0..199 ;изначально 199 = выводим фон с самого начала
  219. ;mul PUSHLINESZ:
  220.         ld a,PUSHLINESZ ;<256
  221.         ld hl,0
  222.         rla
  223.         jr nc,$+4
  224.          ld h,b
  225.          ld l,c
  226.         dup 7
  227.         add hl,hl
  228.         rla
  229.         jr nc,$+3
  230.         add hl,bc
  231.         edup
  232.         ld c,-1
  233.         ld a,h
  234.          sub 63
  235.          inc c
  236.         jr nc,$-3
  237.         add a,63
  238.         ld h,a
  239.         ld a,c
  240.         add a,a
  241.         add a,a
  242.         ld (callpush_callpg),a
  243.         ld bc,pushbase+2
  244.         add hl,bc ;hl = curscroll*PUSHLINESZ + pushbase + 2
  245.         ld (callpushjp),hl
  246.  
  247.         ld hl,(callpush_curscroll) ;0..199
  248.         ld bc,scrhgt
  249.         add hl,bc
  250.         ld bc,pushhgt
  251.         sbc hl,bc
  252.         jr nc,$+3
  253.         add hl,bc
  254.         ld b,h
  255.         ld c,l
  256. ;mul PUSHLINESZ:
  257.         ld a,PUSHLINESZ ;<256
  258.         ld hl,0
  259.         rla
  260.         jr nc,$+4
  261.          ld h,b
  262.          ld l,c
  263.         dup 7
  264.         add hl,hl
  265.         rla
  266.         jr nc,$+3
  267.         add hl,bc
  268.         edup
  269.         ld c,-1
  270.         ld a,h
  271.          sub 63
  272.          inc c
  273.         jr nc,$-3
  274.         add a,63
  275.         ld h,a
  276.         ld a,c
  277.         add a,a
  278.         add a,a
  279.         ld (callpush_patchpg),a
  280.         ld bc,pushbase
  281.         add hl,bc ;hl = ((curscroll+scrhgt)mod scrollhgt)*PUSHLINESZ + pushbase
  282.         ld (call_patchaddr),hl
  283.         ld (call_unpatchaddr),hl
  284.  
  285.         ld ix,callpushq
  286.        
  287.         ld iy,tpushpgs
  288.         ld hl,pushscrtop+pushwid+(0*0x2000)
  289.         exx
  290.         call callpush
  291.         inc iy
  292.          inc iy
  293.         ld hl,pushscrtop+pushwid+(1*0x2000)
  294.         exx
  295.         call callpush
  296.         ;inc iy
  297.          dec iy
  298.        
  299.         call setpgscrhigh4000
  300.        
  301.         ld hl,pushscrtop+pushwid+(0*0x2000)
  302.         exx
  303.         call callpush
  304.         inc iy
  305.          inc iy
  306.         ld hl,pushscrtop+pushwid+(1*0x2000)
  307.         exx
  308.         call callpush
  309.        
  310.         jp setpgsmain40008000
  311.  
  312. ;TODO fill pushlines from tiles
  313.  
  314.  
  315. callpush
  316. ;hl'=end of top line of screen
  317. ;включить ту страницу, которую надо патчить
  318. callpush_patchpg=$+2
  319.         ld a,(iy+0)
  320.         SETPGPUSHBASE
  321.         ld hl,0xe9dd ;jp (ix)
  322. call_patchaddr=$+1
  323.         ld (0),hl
  324.         ld de,0 ;этим числом будем портить левый край при прерывании
  325.         exx
  326. ;включить ту страницу, которую надо вызвать
  327. callpush_callpg=$+2
  328.         ld a,(iy+0)
  329.         SETPGPUSHBASE
  330.         ld bc,40
  331.         ld d,b
  332.         ld e,b ;этим числом будем портить левый край при прерывании
  333.         ld (callpushsp),sp
  334.          ld sp,hl
  335.          exx ;вместо запатченного места
  336. callpushjp=$+1
  337.         jp 0
  338. callpushq
  339. ;на выходе уже включена та страница, которую надо распатчить
  340. callpushsp=$+1
  341.         ld sp,0        
  342.         ld hl,0xd9f9
  343. call_unpatchaddr=$+1
  344.         ld (0),hl
  345.         ret
  346.