?login_element?

Subversion Repositories NedoOS

Rev

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

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