Subversion Repositories NedoOS

Rev

Rev 502 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

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