?login_element?

Subversion Repositories NedoOS

Rev

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