?login_element?

Subversion Repositories NedoOS

Rev

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

  1. ;select word from table
  2. ;by index
  3. ;in A - index HL - table
  4. ;out HL -adress from table
  5.  
  6. sel_word:
  7.         add a,a
  8.         ld c,a
  9.         ld b,0
  10.         add hl,bc
  11.         ld a,(hl)
  12.         inc hl
  13.         ld h,(hl)
  14.         ld l,a
  15.         ret
  16.  
  17. ;hl-src de-dest string limiter -  0
  18. copystr_hlde:
  19.         ld a,(hl)
  20.         and a
  21.         ret z
  22.         ld (de),a
  23.         inc hl
  24.         inc de
  25.         jr copystr_hlde
  26. ;------------------------
  27. ;-setup interrupt
  28. int_set:
  29.         di
  30.         ld hl,0x0038
  31.         ld de,int_orig
  32.         ld bc,5
  33.         ldir
  34.         ld hl,0x0038
  35.         ld a,0xC3 ;jp
  36.         ld (hl),a
  37.         inc hl
  38.         ld de,int_proc
  39.         ld a,e
  40.         ld (hl),a
  41.         inc hl
  42.         ld a,d
  43.         ld (hl),a
  44.         ei
  45.         ret
  46.  
  47. int_reset:
  48.         di
  49.         ld de,0x0038
  50.         ld hl,int_orig
  51.         ld bc,3
  52.         ldir
  53.         ei
  54.         ret
  55.  
  56. int_proc
  57.         push af
  58.         ex af,af'
  59.        push af
  60.        push bc
  61.        push de
  62.        push hl
  63.        push ix
  64.        push iy
  65.        exx
  66.        push bc
  67.        push de
  68.        push hl
  69.  
  70. ;        ld a,1
  71. ;        out (0xfe),a
  72.  
  73.        ld a,(setpalflag)
  74.        or a
  75.        call nz,setpal_proc
  76. ;       ld a,(setscreenflag)
  77. ;       or a
  78. ;       call nz,setscreen_proc
  79.        GET_KEY
  80.        ld a,c
  81.        ld (keyreg),a
  82.        OS_GETKEYMATRIX
  83.        ld (keymatrixbc),bc
  84.        ld (keymatrixde),de
  85.        ld (keymatrixhl),hl
  86.        ld (keymatrixix),ix
  87.  
  88.  
  89.        ld a,0
  90. wlock equ $-1
  91.        and a      
  92.        CALL nz,anim_wait
  93.  
  94.  
  95.  
  96. ;        ld a,0
  97. ;        out (0xfe),a
  98.  
  99.        ld a,0
  100. screenswapper: equ $-1
  101.        and a
  102.        call nz,switchscreens
  103.  
  104.        pop hl
  105.        pop de
  106.        pop bc
  107.        exx
  108.        pop iy
  109.        pop ix
  110.        pop hl
  111.        pop de
  112.        pop bc
  113.        pop af
  114.        ex af,af'
  115.         pop af
  116. int_orig ds 5
  117.         jp 0x0038+5        
  118.  
  119. no_mus
  120.           call setmusicpage
  121.           ld a,(music_buf)
  122.           ld hl,PLR_MUTE
  123.           OS_SETMUSIC
  124.           call unsetmusicpage
  125.           halt
  126.           ret
  127. ;==========================
  128. switchscreens:
  129.         ld e,1
  130. swscrsw equ $-1
  131.         push de
  132.         OS_SETSCREEN
  133.         pop de
  134.         ld a,e
  135.         xor 1
  136.         ld (swscrsw),a
  137.         ret
  138.        
  139. ;---------------------
  140. filecreateeerror:
  141.         ld hl,txt_fcreateerror
  142.         jr openerror        
  143. filewriteerror:
  144.         call closestream_file
  145.         ld hl,txt_fwriteerror
  146.         jr openerror
  147. filereaderror:
  148.         call closestream_file
  149.         ld hl,txt_freaderror
  150.         jr openerror
  151. dirchangeerror
  152.         ld hl,txt_dircherror
  153.         jr openerror
  154. fileopenerror
  155.         ld hl,txt_fopenerror
  156. openerror:
  157.         push hl
  158.         ld e,6+0x80
  159.         OS_SETGFX
  160.         ld e,0
  161.         OS_CLS
  162.         pop  hl
  163.         call print_hl
  164.         ld hl,buf
  165.         call print_hl
  166.         ld hl,txt_nl
  167.         call print_hl
  168.         YIELDGETKEYLOOP
  169.         jp cmd_quit
  170.  
  171.  
  172. memoryerror
  173.         OS_CLOSEHANDLE
  174.         ld e,6+0x80
  175.         OS_SETGFX
  176.         ld e,0
  177.         OS_CLS
  178.         ld hl,txt_memoryerror
  179.         call print_hl
  180.         YIELDGETKEYLOOP
  181.         jp cmd_quit
  182.  
  183.  
  184. cmd_quit
  185. ;;      call closestream_file
  186.         ld e,6+0x80
  187.         OS_SETGFX
  188.         call int_reset
  189. ;;       call disablemusic
  190.         QUIT        
  191.  
  192. ;----------------------------------------        
  193. load_mus
  194.  
  195.         ld b,0
  196. old_mus EQU $-1
  197.         cp b
  198.         ret z
  199.         ld (old_mus),a
  200.  
  201.         and a
  202.         jp z,no_mus
  203.  
  204.        
  205.         call calc_mus
  206.  
  207.         call no_mus
  208.        
  209.         ;generate path to music file in 'buf'
  210.         ld hl,mus_path1
  211.         ld de,buf
  212.         call copystr_hlde ;'copy path  'mus/' '
  213.        
  214.         ld a,(mus_mode)
  215.         ld hl,mus_modes
  216.         call sel_word
  217.         call copystr_hlde ;copy "aym / s98 path"
  218.         ld hl,mus_path2
  219.         call copystr_hlde ;copy name without ext
  220.        
  221.         ld a,(mus_mode)
  222.         ld hl,plr_ext
  223.         call sel_word
  224.         call copystr_hlde  ;copy file ext
  225.         xor a
  226.         ld (de),a  ;string terminator
  227.  
  228.  
  229.  
  230.         call setmusicpage
  231.  
  232.                 ld de,buf
  233.                 call openstream_file
  234.                 or a
  235.                 jp nz,fileopenerror
  236.  
  237.                 ld hl,0x3000 ;len
  238.                 ld de,module ;addr
  239.                 call readstream_file
  240.                 or a
  241.                 jp nz,filereaderror
  242.  
  243.                 call closestream_file
  244.  
  245.                 ld a,0b00100000
  246.                 ld (SETUP),a
  247.                 ld hl,module
  248.  
  249.                 call PLR_INIT        ;init music
  250.  
  251.                 ld a,(music_buf)
  252.                 ld hl,PLR_PLAY
  253.                 OS_SETMUSIC        
  254.         jp unsetmusicpage
  255.  
  256. calc_mus:
  257.         call a_to_dec
  258.  
  259.         LD (mus_path2+5),A
  260.         LD A,B
  261.         LD (mus_path2+4),A
  262.         RET        
  263.  
  264. a_to_dec:
  265.         CP 30
  266.         JR C,calc_m0
  267.         SUB 30
  268.         LD B,"3"
  269.         JR calc_mus_f
  270. calc_m0   CP 20
  271.         JR C,calc_m1
  272.         SUB 20
  273.         LD B,"2"
  274.         jr calc_mus_f
  275. calc_m1   CP 10
  276.         JR C,calc_m2
  277.         SUB 10
  278.         LD B,"1"
  279.         JR calc_mus_f
  280. calc_m2   LD B,"0"
  281. calc_mus_f:
  282.          ADD A,"0"
  283.          ret
  284. ;------------------
  285. setmusicpage
  286.         OS_GETMAINPAGES
  287.         ld a,e
  288.         ld (tbank1),a
  289.         ld a,(music_buf)
  290.         SETPG4000
  291.         ret
  292.  
  293. unsetmusicpage
  294.         ld a,(tbank1)
  295.         SETPG4000
  296.         ret
  297.  
  298. ;---------------------
  299. setfontpage
  300.         push af
  301.         push bc
  302.         OS_GETMAINPAGES
  303.         ld a,h
  304.         ld (tbank2),a
  305.         ld a,(font_page)
  306.         SETPG8000
  307.         pop bc
  308.         pop af
  309.         ret
  310.  
  311. unsetfontpage
  312.         ld a,(tbank2)
  313.         SETPG8000
  314.         ret
  315. ;---------------------
  316. store8000c000
  317.         push af
  318.         push bc
  319.         OS_GETMAINPAGES
  320.         ld a,h
  321.         ld (tbank2),a
  322.         ld a,l
  323.         ld (tbank3),a
  324.         pop bc
  325.         pop af
  326.         ret
  327.  
  328. restore8000c000
  329.         ld a,(tbank2)
  330.         SETPG8000
  331.         ld a,(tbank3)
  332.         SETPGC000        
  333.         ret
  334. ;========================
  335. storec000
  336.         OS_GETMAINPAGES
  337.         ld a,l
  338.         ld (tbank3),a
  339.         ret
  340.  
  341. restorec000
  342.         ld a,(tbank3)
  343.         SETPGC000        
  344.         ret
  345. ;========================
  346. store8000
  347.         OS_GETMAINPAGES
  348.         ld a,h
  349.         ld (tbank2),a
  350.         ret
  351.  
  352. restore8000
  353.         ld a,(tbank2)
  354.         SETPG8000        
  355.         ret
  356. ;========================
  357. _load_common:
  358.         ld hl,33 ;len
  359.         ld de,buf
  360.         call readstream_file
  361.         or a
  362.         jp nz,filereaderror
  363.  
  364.         call closestream_file
  365.  
  366.         ld hl,buf
  367.         ld a,(hl)
  368.         inc a
  369.         jp nz,_load_save_exit
  370.         inc hl
  371.         ld de,OVL
  372.         ld bc,32
  373.         ldir
  374.         pop hl
  375.         jp BEG
  376.  
  377.  
  378.  
  379. ;========================
  380. _ram_load:
  381.         push hl
  382.         ld de,SAVETEMPL
  383.         call openstream_file
  384.         or a
  385.         jp nz,_load_save_exit
  386.         jp _load_common
  387.  
  388.  
  389.  
  390. _ram_save:
  391.         push hl
  392.  
  393.         ld hl,SAVESLOT
  394.         ld de,SAVESLOT+1
  395.         ld bc,32
  396.         ld (hl),0
  397.         ldir
  398.  
  399.        
  400.         ld hl,SAVESLOT        
  401.         ld de,LOADED
  402.        
  403.         ld (hl),#ff
  404.         inc hl
  405.         ex de,hl
  406.  
  407.         ld bc,32
  408.         ldir
  409.  
  410.  
  411. _retry_save:
  412.         ld de,SAVETEMPL
  413.         call openstream_file
  414.         or a
  415.         jp z,_save_slot_is_present
  416.         ; we should create file here
  417.  
  418.          LD DE,SAVETEMPL
  419.          OS_CREATEHANDLE
  420.          OR A
  421.          JP NZ,filecreateeerror
  422.          ld a,b
  423.          ld (filehandle),a
  424.  
  425. _save_slot_is_present:
  426.  
  427.         ld hl,33 ;len
  428.         ld de,SAVESLOT ;addr
  429.         call savestream_file
  430.         or a
  431.         jp nz,filewriteerror
  432.  
  433.         call closestream_file        
  434.  
  435.  
  436.  
  437. _load_save_exit:
  438.         ld a,NOKEY
  439.         pop hl
  440.         ret
  441.  
  442.  
  443. _is_quit:
  444.         pop hl
  445.         xor a
  446.         ld (wlock),a
  447.         jp _exitdark
  448.  
  449.  
  450. getkey
  451.         ld a,(keyreg)
  452.         ret
  453.  
  454.  
  455. waitkey_a
  456.         ld a,1
  457.         ld (wlock),a
  458.         call waitkey
  459.  
  460.  
  461.          CP "Q"
  462.          JR Z,_is_quit
  463.          CP "q"
  464.          JR Z,_is_quit
  465.  
  466.          CP "L"
  467.          CALL Z,_ram_load
  468.          CP "l"
  469.          CALL Z,_ram_load
  470.          CP "S"
  471.          CALL Z,_ram_save
  472.          CP "s"
  473.          CALL Z,_ram_save
  474.  
  475.  
  476.         cp NOKEY
  477.         jr z,waitkey_a
  478.  
  479.         push af
  480.         xor a
  481.         ld (wlock),a
  482.         pop af
  483.         ret
  484.  
  485. waitkey
  486.  
  487. waitkey_unpress ;Wait for enter unpress
  488.         ld a,(keymatrixix+1)
  489.         bit 0,a
  490.         jr z,waitkey_unpress
  491. waitkey_loop
  492.         call getkey
  493.         cp NOKEY
  494.         jr z,waitkey_loop
  495. waitkey0
  496.         ld (lastkey),a
  497.         call getkey
  498.         cp NOKEY
  499.         jr nz,waitkey0 ; purge key buffer
  500.         ld a,(lastkey)
  501.         ret
  502.         ;cp key_esc
  503.         ;jp z,cmd_quit
  504.         ;ret
  505. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  506.  
  507. change_cp1 ;#
  508.             LD A,186
  509.             RET
  510. change_cp2   ;@
  511.           LD A,188
  512.           RET
  513. change_cp
  514.          PUSH HL,DE
  515.          LD HL,TABLE_W
  516. CODEPAGE EQU $-2
  517.          SUB 128
  518.          LD D,0
  519.          LD E,A
  520.          ADD HL,DE
  521.          LD A,[HL]
  522.          POP DE,HL
  523.          RET
  524.  
  525. TABLE_W  DS 40,32
  526.          DB 134
  527.          DS 15,32
  528.          DB 194
  529.          DS 7,32
  530.          DB 129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160
  531.          DB 161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,188,189,190,191,192,193
  532.  
  533. TABLE_J  DS 13,32
  534.          DB 186,188 ;щ ъ        141 142
  535.          DS 15,32
  536.          DB 186,188 ;щ ъ        158 159
  537.          DB 189,190,191,192,193,129,130,131,132,133,134,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154
  538.          DB 155,156,157,158,159,160,161,162,163,164,165,166,194,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185
  539.          DB 186,188,189,190,191,192,193
  540.          DS 6,32
  541.          DB 143
  542.          DB 32,32,150
  543.          DB 32,154,155
  544.  
  545. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  546.  
  547.  
  548. WINCLR1 CALL waitkey_a
  549. WINCLR2
  550.         PUSH HL
  551.         CALL _clear_textbox  ;-0-0-3423566400------------------
  552.         POP HL
  553. COOOR   LD BC,txt_coor
  554.         CALL _pradd_p
  555.         ret
  556. ;;;;;;=====
  557. LOADOVL POP DE
  558.         ld de,OVL
  559.         call copystr_hlde
  560.         xor a
  561.         ld (DE),a
  562.         JP BEG
  563.  
  564.  
  565.  
  566.  
  567. outtype2 db 0   ;"P' 򮡷ᬠ ︨᳼. 'N' ⦧ ︨򳫨  '8' 򰱠갍
  568.  
  569.  
  570. _get_show_scr:
  571.         push af
  572.  
  573.         ld a,(script_buf1)
  574.         SETPG4000
  575.         ld a,(script_buf2)              
  576.         SETPG8000        
  577.  
  578.         ld hl,(0x4006)
  579.         ld a,h
  580.         add a,0x40
  581.         ld h,a
  582.        
  583.         pop af
  584.         call sel_word
  585.         ld a,h
  586.         add a,0x40
  587.         ld h,a      
  588.  
  589.         ld a,(hl)
  590.         ld (outtyp),a
  591.         inc hl
  592.         ld a,(hl)
  593.         ld (outtype2),a
  594.         inc hl
  595.  
  596.  
  597.  
  598.  
  599.         ld a,(outtype2)
  600.  
  601.         cp '8'
  602.         jp z,_it_is_overlay
  603.  
  604.         cp 'P'
  605.         jp z,_clear_screen_before
  606.  
  607. _show_screen_immedatelly:
  608.  
  609.         call load_gfx_to_load_buf
  610.  
  611.         jp _buffer_output        
  612. outtyp_conv: db 0,10,10,10,4,5,6,12,13,0,10,11
  613. _clear_screen_before:
  614.         push hl
  615.         ld a,(outtyp)
  616.         push af
  617.  
  618.         ld e,a
  619.         ld d,0
  620.         ld hl, outtyp_conv
  621.         add hl,de
  622.         ld a,(hl)
  623.         ld (outtyp),a
  624.  
  625.         ld hl,pal
  626.         ld de,mempal
  627.         ld bc,32
  628.          ldir
  629.  
  630.  
  631.         call _memory_output
  632.  
  633.     ;    ld hl,temppal
  634.      ;   ld de,pal
  635.       ;  ld bc,32
  636.        ; ldir
  637.  
  638.         pop af
  639.         ld (outtyp),a
  640.         pop hl
  641.         jp _show_screen_immedatelly
  642.  
  643. _it_is_overlay:
  644.         call store_name
  645.  
  646.  
  647.         call load_gfx_to_scr_buf
  648.  
  649.         call _sprite_output_mask_no_pal
  650.  
  651.  
  652.         ret
  653.  
  654.  
  655.  
  656.  
  657.  
  658. store_name:
  659.         push hl
  660.         ld hl,namebuf
  661.         ld de,namebuf+1
  662.         ld bc,13
  663.         ld (hl),0
  664.         ldir
  665.         pop hl
  666.         push hl
  667.         ld de,namebuf
  668.         call copystr_hlde
  669.         pop hl
  670.         ret        
  671.  
  672.  
  673.  
  674. cmpr_dehl:
  675.         ld a,(de)
  676.         and a
  677.         ret z   ;string fully equally and dtring in de not begin from 0
  678.  
  679.         cpi
  680.         ret nz
  681.         inc de
  682.         jr cmpr_dehl
  683.  
  684. C_Time_D:
  685. ;Outputs:
  686. ;     A is the result
  687. ;     B is 0
  688.      ld b,8          ;7           7
  689.      xor a           ;4           4
  690.        rlca          ;4*8        32
  691.        rlc c         ;8*8        64
  692.        jr nc,$+3     ;(12|11)    96|88
  693.          add a,d     ;--
  694.        djnz $-6      ;13*7+8     99
  695.      ret             ;10         10
  696.  
  697. ;___________________________________
  698. ;A15    A14     A13     A12     A11     A10      A9      A8
  699. ; G0     R0      B0      G1      1       1       R1      B1
  700.                
  701. ; D7     D6      D5      D4      D3      D2      D1      D0
  702. ; G2     R2      B2      G3      1       1       R3      B3
  703. palette_precalc:
  704.                 ld hl,pal
  705.                 ld de,pal_rgb
  706.  
  707.                 ld b,16
  708. mkpalATM3RGB
  709.                 push bc
  710.                 ld a,(hl)
  711.                 inc hl
  712.                 push hl
  713.                 ld h,(hl)
  714.                 ld l,a
  715.                 push de
  716.                
  717.                 call calchexcolor ;hl=color (DDp palette) ;out: ;b=B, d=R, e=G
  718.        
  719.                 ld a,e ;G
  720.                 add a,a
  721.                 add a,a
  722.                 add a,a
  723.                 add a,a
  724.                 or d ;R
  725.                 pop de
  726.                 ld c,a ;GR
  727.                 ld a,b
  728.                 add a,a
  729.                 add a,a
  730.                 add a,a
  731.                 add a,a
  732.                 ld (de),a ;B0
  733.                 inc de
  734.                 ld a,c
  735.                 ld (de),a ;GR
  736.                 inc de
  737.                 pop hl
  738.                 inc hl
  739.                 pop bc
  740.                 djnz mkpalATM3RGB
  741.                 ret
  742.  
  743. calchexcolor ;hl=color (DDp palette) ;out: ;b=B, d=R, e=G
  744. ;keep c!!!
  745. ;DDp palette: %grbG11RB(low),%grbG11RB(high)
  746. ;high B, high b, low B, low b
  747.                 ld b,0;0xff
  748.                 ld de,0;0xffff
  749.                 ld a,h
  750.                cpl
  751.                 rra
  752.                 rl b ;B high
  753.                 rra
  754.                 rl d ;R high
  755.                 rra
  756.                 rra
  757.                 rra
  758.                 rl e ;G high
  759.                 rra
  760.                 rl b ;b high
  761.                 rra
  762.                 rl d ;r high
  763.                 rra
  764.                 rl e ;g high
  765.                 ld a,l
  766.                cpl
  767.                 rra
  768.                 rl b ;B low
  769.                 rra
  770.                 rl d ;R low
  771.                 rra
  772.                 rra
  773.                 rra
  774.                 rl e ;G low
  775.                 rra
  776.                 rl b ;b low
  777.                 rra
  778.                 rl d ;r low
  779.                 rra
  780.                 rl e ;g low
  781. ;b=B
  782. ;d=R
  783. ;e=G
  784.         ret
  785. ;===================
  786. recolour
  787. ;hl=palfrom (RGB)
  788. ;de=palto (DDp)
  789. ;lx=brightness=0..15
  790.         di
  791.         ld (recoloursp),sp
  792.         ld sp,hl
  793.        ld h,tbright/256 ;once
  794.         ld hx,16
  795. bripalATM3
  796.          ;ld a,(hl) ;B0
  797.          ;inc hl
  798.          ;push hl
  799.          ;ld b,(hl) ;GR
  800.        pop bc
  801.        ld a,c
  802.          ;ld h,tbright/256
  803. ;de=palto
  804. ;h=tbright/256
  805. ;lx=brightness
  806. ;a,b = B0,GR
  807.          add a,lx
  808.         ld l,a
  809.         ld c,(hl) ;B colour component with brightness
  810.         ld a,b
  811.         and 0xf0
  812.          add a,lx
  813.         ld l,a
  814.         ld a,b
  815.         ld b,(hl) ;G colour component with brightness
  816.         add a,a
  817.         add a,a
  818.         add a,a
  819.         add a,a
  820.          add a,lx
  821.         ld l,a
  822.         ld l,(hl) ;R colour component with brightness
  823.  
  824.        ld a,b ;G
  825.        rlca ;g??G???? ;G10
  826.        xor l ;R
  827.        and 0b10010000;0b01000010 ;R10
  828.        xor l;gr?G??R?
  829.        rlca ;r?G??R?g
  830.        xor c ;B
  831.        and 0b10100101;0b01000010 ;B10
  832.        xor c;rbG??RBg
  833.        rrca ;grbG??RB
  834.         or 0b00001100 ;unused bits
  835.         ld (de),a ;low %grbG11RB
  836.         inc de ;TODO ld (),a
  837.  
  838.        ld a,b ;G
  839.        rlca ;?g??G??? ;G32
  840.        xor l ;R
  841.        and 0b01001000;0b00100001 ;R32
  842.        xor l;?gr?G??R
  843.        rlca ;gr?G??R?
  844.        xor c ;B
  845.        and 0b11010010;0b00100001 ;B32
  846.        xor c;grbG??RB
  847.         or 0b00001100 ;unused bits
  848.         ld (de),a ;high %grbG11RB
  849.         inc de ;TODO ld (),a
  850.  
  851.          ;pop hl
  852.          ;inc hl
  853.          dec hx
  854.          jp nz,bripalATM3 ;TODO dup..edup
  855. recoloursp=$+1
  856.         ld sp,0
  857.         ei
  858.         ret
  859. ;===================
  860.  
  861. fade_toblack:
  862.         ld hl,pal
  863.         ld de,temppal
  864.         ld bc,32
  865.         ldir        ;;
  866.  
  867.  
  868.         ld lx,8
  869. .fade0
  870.         dec lx
  871.         ld hl,pal_rgb
  872.         ld de,pal
  873.         call recolour
  874.         push ix
  875.  
  876.         ld a,1
  877.         ld (setpalflag),a
  878.  
  879.         halt
  880.         halt
  881.         halt
  882.         pop ix
  883.         ld a,lx
  884.         cp 0
  885.         jr nz,.fade0
  886.         halt
  887.         halt
  888.         halt
  889.         ret
  890.  
  891.  
  892. fade_towhite:
  893.         ld hl,pal
  894.         ld de,temppal
  895.         ld bc,32
  896.         ldir        ;;
  897.  
  898.  
  899.         ld lx,8
  900. .fadew0
  901.         inc lx
  902.  
  903.         ld hl,pal_rgb
  904.         ld de,pal
  905.         call recolour
  906.         push ix
  907.  
  908.         ld a,1
  909.         ld (setpalflag),a
  910.  
  911.  
  912.         halt
  913.         halt
  914.         halt
  915.         pop ix
  916.         ld a,lx
  917.         cp 15
  918.         jr nz,.fadew0
  919.         halt
  920.         halt
  921.         halt
  922.         ret
  923.  
  924.  
  925. fade_fromwhite:
  926.         ld hl,pal
  927.         ld de,temppal
  928.         ld bc,32
  929.         ldir        ;;
  930.  
  931.  
  932.         ld lx,15
  933. .fadew1
  934.         dec lx
  935.  
  936.         ld hl,pal_rgb
  937.         ld de,pal
  938.         call recolour
  939.         push ix
  940.  
  941.         ld a,1
  942.         ld (setpalflag),a
  943.  
  944.         halt
  945.         halt
  946.         halt
  947.         pop ix
  948.         ld a,lx
  949.         cp 8
  950.         jr nz,.fadew1
  951.         halt
  952.         halt
  953.         halt
  954.  
  955.         ld hl,temppal
  956.         ld bc,32
  957.         ld de,pal
  958.         ldir
  959.         ld a,1
  960.         ld (setpalflag),a
  961.         halt
  962.         ret
  963.  
  964.  
  965.  
  966. fade_fromblack:
  967.         ld hl,pal
  968.         ld de,temppal
  969.         ld bc,32
  970.         ldir        ;;
  971.  
  972.  
  973.         ld lx,0
  974. .fadeb1
  975.         inc lx
  976.  
  977.         ld hl,pal_rgb
  978.         ld de,pal
  979.         call recolour
  980.         push ix
  981.  
  982.         ld a,1
  983.         ld (setpalflag),a
  984.  
  985.         halt
  986.         halt
  987.         halt
  988.         pop ix
  989.         ld a,lx
  990.         cp 8
  991.         jr nz,.fadeb1
  992.         halt
  993.         halt
  994.         halt
  995.  
  996.         ld hl,temppal
  997.         ld bc,32
  998.         ld de,pal
  999.         ldir
  1000.         ld a,1
  1001.         ld (setpalflag),a
  1002.         halt
  1003.         ret
  1004.  
  1005. clear_ovlnamebuf:
  1006.         push hl
  1007.         push bc
  1008.         push de
  1009.         ld hl,ovlnamebuf
  1010.         ld de,ovlnamebuf+1
  1011.         ld bc,127
  1012.         ld (hl),0
  1013.         ldir
  1014.         pop de
  1015.         pop bc
  1016.         pop hl
  1017.         ret