?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM48
  2.         include "../../_sdk/sys_h.asm"
  3.         org PROGSTART
  4.  
  5.  
  6. print_p_len: equ 51
  7. txt_coor:       equ 0x1400
  8. x_txt_coor= low txt_coor
  9.  
  10.  
  11.  
  12. module equ 0x5000
  13. player_load = 0x4000
  14.  
  15. ovl_start = 0x4000
  16.  
  17. PLR_INIT  = 0x4000
  18. PLR_PLAY  = 0x4005
  19. PLR_MUTE  = 0x4007
  20.  
  21. GLOBVARS = 0x3800
  22. LOCVARS  = 0x3900
  23. ACTMENU  = 0x3a00
  24. ILINK    = 0x3b00
  25. STK_MENU = 0x3c00
  26. STK_SUB  = 0x3d64
  27.  
  28. FONT     = 0x8000
  29. FONT2    = 0x9000
  30.  
  31. ANIM_BFF  = 0x9000
  32. ANIM_BFFR = 0x5000        
  33.  
  34. cmd_begin
  35.     OS_HIDEFROMPARENT
  36.     ld sp,0x4000
  37.     call pre_init    
  38.  
  39.  
  40.  
  41. ;----------------------------------------------------
  42.  
  43.  
  44. begin:
  45.         ld a,6
  46.         ld (outtyp),a
  47.  
  48.        ; ld a,0x12
  49.        ; ld (COOOR+2),a ;y coord for ingame initial text position
  50.  
  51.         ld a,(menu_mus)
  52.         call load_mus
  53.  
  54.  
  55.         ld a,0
  56. intro_switch equ $-1
  57.         and a
  58.         call z,introduction
  59.  
  60.  
  61. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  62. ; load menu picture
  63.         ld hl,menu_pic
  64.         call load_big_img_dark2
  65.  
  66.  
  67.  
  68.         LD bc,0
  69.         CALL _pradd2
  70.         LD HL,TEXT1
  71.         CALL _type_txt_buf
  72.  
  73.         LD BC,#0100
  74.         CALL _pradd2
  75.         LD HL,TEXT3
  76.         CALL _type_txt_buf
  77.  
  78.  
  79.         LD BC,#1800
  80.         CALL _pradd2
  81.         LD HL,TEXT2
  82.         CALL _type_txt_buf
  83.  
  84. ;;;;;;;;;;;
  85.         LD BC,#090f
  86.         CALL _pradd2
  87.         LD HL,menu1
  88.         CALL _type_txt_buf
  89.  
  90.  
  91.         LD BC,#0a0f
  92.         CALL _pradd2
  93.         LD HL,menu2
  94.         CALL _type_txt_buf
  95.  
  96.  
  97.         LD BC,#0b0f
  98.         CALL _pradd2
  99.         LD HL,menu3
  100.         CALL _type_txt_buf
  101.  
  102.  
  103. ;;;;;;;;;;;
  104.         ld a,(dc_enabled)
  105.         and a
  106.         jr z,_nnn
  107.  
  108.         LD BC,#0d0f
  109.         CALL _pradd2
  110.         LD HL,menu4
  111.         CALL _type_txt_buf
  112.  
  113.  
  114. _nnn:
  115.         call palette_precalc
  116.         call fade_fromwhite
  117.  
  118.  
  119.  
  120. _main_menu:
  121.         ld hl,TABLE_W
  122.         ld (CODEPAGE),hl
  123.  
  124.  
  125. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  126. 1       CALL waitkey
  127.         CP "4"
  128.         JR Z,NWGAM_DC
  129.         CP "1"
  130.         JR Z,NWGAM
  131.         CP "2"
  132.         JR Z,CONT_GAME
  133.         CP "3"
  134.         JR NZ,1B
  135. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  136. _gamequit
  137.         call no_mus
  138.         jp cmd_quit
  139.  
  140.  
  141. CONT_GAME:
  142.         ld de,SAVETEMPL
  143.         call openstream_file
  144.         or a
  145.         jr nz,_main_menu
  146.  
  147.         ld hl,33 ;len
  148.         ld de,buf
  149.         call readstream_file
  150.         or a
  151.         jp nz,filereaderror
  152.  
  153.         call closestream_file
  154.  
  155.         ld hl,buf
  156.         ld a,(hl)
  157.         inc a
  158.         jp nz,_main_menu
  159.         inc hl
  160.         jp GAMESTART1
  161.  
  162. ;------------------------------------------------
  163. _newgame:
  164. NWGAM_DC:
  165.         ld a,(dc_enabled)
  166.         and a
  167.         jp z,_main_menu
  168.  
  169.         ld a,1
  170.         jr NWGAMa
  171. NWGAM:
  172.         xor a
  173. NWGAMa:
  174.         ld (v_mode),a
  175.         ld hl,FSTOVL
  176. GAMESTART1        
  177.         ld de,OVL
  178.         call copystr_hlde
  179.         xor a
  180.         ld (de),a        
  181.  
  182.  
  183.  
  184.         call clear_whole_screen
  185. GAMESTART
  186.         ld hl,TABLE_W
  187.         ld (CODEPAGE),HL
  188. ;---------------------------------------------
  189.  
  190.  
  191. ;---------------------------------------------
  192. BEG
  193.  
  194.  
  195.  
  196.  
  197.         CALL _clear_textbox
  198.         ;call clear_whole_screen
  199.  
  200.  
  201.         LD BC,#1600
  202.         CALL _pradd
  203.  
  204.         ld hl,#eee6
  205.         ld (clr1),hl
  206.         ld (clr2),hl
  207.        
  208.         ld hl,help_text
  209.         call _type_txt_buf
  210.        
  211.  
  212.         ld hl,0
  213.         ld (clr1),hl
  214.         ld (clr2),hl
  215.  
  216.  
  217.  
  218.         ld hl,OVL
  219.         call load_ovl_to_script_buf
  220.  
  221.         ;store loaded ovl name
  222.         ld hl,OVL
  223.         ld de,LOADED
  224.         call copystr_hlde
  225.         xor a
  226.         ld (de),a
  227.  
  228.  
  229.         ld hl,OVL
  230.         ld de,OVL+1
  231.         ld (hl),0
  232.         ld bc,31
  233.         ldir
  234.  
  235.         ld hl,#4000
  236.     ;//load mus
  237.         PUSH HL
  238.         LD A,(HL)
  239.         CALL load_mus
  240.         POP HL
  241.         INC HL
  242.     ;//load bg
  243.         push hl
  244.  
  245.         ld de,ovlnamebuf
  246.  
  247.         ld a,(v_mode)
  248.         and a
  249.         jr z,.skip1_dc
  250.         ld hl,dc_prefix
  251.         call copystr_hlde
  252.  
  253.  
  254. .skip1_dc
  255.         pop hl      
  256.         call copystr_hlde
  257.         inc hl
  258.         push hl
  259.         ld hl,ovlnamebuf
  260.         call load_gfx_to_load_buf
  261.  
  262.         call clear_ovlnamebuf
  263.  
  264.  
  265.         ld de,ovlnamebuf
  266.         ld a,(v_mode)
  267.         and a
  268.         jr z,.skip2_dc
  269.         ld hl,dc_prefix
  270.         call copystr_hlde
  271. .skip2_dc
  272.         pop hl
  273.         call copystr_hlde
  274.         inc hl
  275.         push hl
  276.         ld hl,ovlnamebuf
  277.         call load_gfx_to_scr_buf
  278.  
  279.         call clear_ovlnamebuf
  280.  
  281.         call DECR_SPR
  282.         call _buffer_output
  283.  
  284.         pop hl
  285.  
  286.  
  287.         jp _main_txtout ;@@@@@@@@@@@@
  288. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  289.  
  290.  
  291. _exitlight:
  292.         call fade_towhite
  293.         CALL clear_whole_screen
  294.  
  295.         ld de,PERSISTSAVE
  296.         call openstream_file
  297.         or a
  298.         jr z,.skip_ps
  299.  
  300.          LD DE,PERSISTSAVE
  301.          OS_CREATEHANDLE
  302.          OR A
  303.          JP NZ,filecreateeerror
  304.          ld a,b
  305.          ld (filehandle),a      
  306.  
  307.         ld hl,1 ;len
  308.         ld de,buf ;addr
  309.         call savestream_file
  310.         or a
  311.         jp nz,filewriteerror
  312.         call closestream_file        
  313.                
  314.         ld a,1
  315.         ld (dc_enabled),a
  316.  
  317. .skip_ps
  318.  
  319.         jp begin
  320. _exitdark
  321.         call fade_toblack
  322.         CALL clear_whole_screen
  323.         jp begin
  324.  
  325.  
  326.  
  327. _scenario:
  328.         ld de,OVL      
  329.         call copystr_hlde
  330.         jp BEG
  331.  
  332.         call waitkey
  333.         jp _gamequit
  334.  
  335.  
  336. _menu_s:
  337.         ld de,namebuf1
  338.         call copystr_hlde
  339.         xor a
  340.         ld (de),a
  341.         inc hl
  342.         ld de,namebuf2
  343.         call copystr_hlde
  344.         xor a
  345.         ld (de),a
  346.         inc hl
  347.        
  348.         push hl
  349.         ld bc,#1200
  350.         call _pradd_p2
  351.         ld hl,lines1
  352.         call _type_txt_buf_p
  353.  
  354.         ld bc,#1203
  355.         call _pradd_p2
  356.         pop hl
  357.         call _print_b
  358.  
  359.         push hl
  360.         ld bc,#1400
  361.         call _pradd_p2
  362.         ld hl,lines2
  363.         call _type_txt_buf_p
  364.  
  365.         ld bc,#1403
  366.         call _pradd_p2
  367.         pop hl
  368.         call _print_b
  369.  
  370.  
  371. 1       call waitkey_a
  372.         CP "1"
  373.         JR Z,_g1a
  374.         CP "2"
  375.         JR Z,_g2a
  376.         jr 1b
  377.  
  378. _g1a:    ld hl,namebuf1
  379.         jr _g3a
  380. _g2a:    ld hl,namebuf2
  381. _g3a:     jp _scenario
  382.        
  383.  
  384.  
  385.  
  386. ;//////////////////////////////////////
  387. _print_b:
  388.         call clear_txt_buff
  389. _print_b1
  390.         ld de,txt_buff        
  391.         ld c,0   ;//symbol counter
  392. .txt_lp1
  393.         ld a,(hl)
  394.         cp 32+1
  395.         jr c, _printb_controlcode
  396.  
  397.         ;copy string yo buffer
  398.         ld (de),a
  399.         inc hl
  400.         inc de
  401.         inc c
  402.         jr .txt_lp1
  403.  
  404.  
  405. _printb_controlcode:
  406.         push af
  407.                 ;check if buffer overflow  
  408.                 ld a,c
  409.                 and a
  410.                 jr z,_printb_cc_sp_tk   ;buffer is empty. attempt to print space or token
  411.  
  412.                 ;buffer not empty. print string
  413.                 ld bc,(CORDS_P)           ;B-y C-X
  414.                 add a,c
  415.                 cp print_p_len
  416.                 jr nc,_printb_overflow
  417.  
  418.                 call _print_txt_buf_p
  419.         pop af
  420.         jp _print_b1
  421.  
  422.  
  423. _printb_cc_sp_tk:
  424.         pop af   ;restore curren symbol
  425.  
  426.         inc hl;!!!!!!!!!!!!
  427.  
  428.         cp 32
  429.         ret nz  ;char is token
  430.         ; print space
  431.         ld bc,(CORDS_P)
  432.         ld a,c          ;check for overflow
  433.         inc a
  434.         cp print_p_len
  435.         jr nc,_printb_overflow1  ;not restore af
  436.         ld a,32
  437.         ld (de),a
  438.         call _print_txt_buf_p
  439.         jp _print_b1
  440.        
  441.        
  442. _printb_overflow:
  443.          pop af
  444. _printb_overflow1:
  445.         ld bc,(CORDS_P)
  446.         inc b
  447.         ld c,x_txt_coor
  448.         call _pradd_p2
  449.  
  450.         ld bc,(CORDS_P)
  451.         LD A,B
  452.         CP #17
  453.          CALL NC,WINCLR1
  454.  
  455.         call _print_txt_buf_p
  456.         jr _print_b1
  457.    
  458.  
  459.  
  460. ;//////////////////////////////////////
  461.  
  462. _main_txtout:
  463.  
  464.         ;//ovl print pre-init
  465.  
  466.  
  467. _txtout:
  468.         LD BC,txt_coor
  469.         CALL _pradd_p
  470.        
  471.  
  472.  
  473.  
  474. _txtout1:
  475. _txtout2:
  476.  
  477.         push hl
  478.         call clear_txt_buff
  479.         pop hl
  480.         ld a,(script_buf1)
  481.         SETPG4000
  482.         ld a,(script_buf2)
  483.         SETPG8000        
  484.  
  485.  
  486.         ld de,txt_buff        
  487.         ld c,0   ;//symbol counter
  488. .txt_lp1
  489.         ld a,(hl)
  490.         cp 32+1
  491.         jr c, _txtout_controlcode
  492.  
  493.         ;copy string yo buffer
  494.         ld (de),a
  495.         inc hl
  496.         inc de
  497.         inc c
  498.         jr .txt_lp1
  499.  
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506. _txtout_controlcode:
  507.         push af
  508.                 ;check if buffer overflow  
  509.                 ld a,c
  510.                 and a
  511.                 jr z,_txtout_cc_sp_tk   ;buffer is empty. attempt to print space or token
  512.  
  513.                 ;buffer not empty. print string
  514.                 ld bc,(CORDS_P)           ;B-y C-X
  515.                 add a,c
  516.                 cp print_p_len
  517.                 jr nc,_ttout_overflow
  518.  
  519.                 call _print_txt_buf_p
  520.         pop af
  521.         jp _txtout2        
  522.                                                                        
  523.                                                                        
  524.                                          
  525. ;buffer is empty. attempt to print space or token      AF in stack
  526. _txtout_cc_sp_tk:
  527.         pop af   ;restore curren symbol
  528.  
  529.         inc hl;!!!!!!!!!!!!
  530.  
  531.         cp 32
  532.         jr nz,_txtout_cc_token  ;char is token
  533.         ; print space
  534.         ld bc,(CORDS_P)
  535.         ld a,c          ;check for overflow
  536.         inc a
  537.         cp print_p_len
  538.         jr nc,_ttout_overflow1  ;not restore af
  539.         ld a,32
  540.         ld (de),a
  541.         call _print_txt_buf_p
  542.         jp _txtout2
  543.        
  544.        
  545. _ttout_overflow:
  546.          pop af
  547. _ttout_overflow1:
  548.         ld bc,(CORDS_P)
  549.         inc b
  550.         ld c,x_txt_coor
  551.         call _pradd_p
  552.  
  553.         ld bc,(CORDS_P)
  554.         LD A,B
  555.         CP #17
  556.          CALL NC,     WINCLR1                                                                                                                          
  557.  
  558.         call _print_txt_buf_p
  559.         jr _txtout2
  560.    
  561. _txtout_cc_token:
  562.         and a
  563.         jr nz,_tt_opcodes1
  564.         push hl
  565.         call WINCLR1
  566.         pop hl
  567.         jp _txtout2
  568.  
  569.  
  570. _tt_opcodes1:
  571.           CP 2
  572.           JP Z,_exitdark
  573.       cp 4
  574.           JP Z,_exitlight
  575.           CP 1
  576.           JP Z,_scenario
  577.           CP 3
  578.           JP Z,_menu_s
  579.  
  580.          LD A,4
  581.          OUT (#FE),A
  582.         jp $
  583.  
  584.  
  585. _print_txt_buf:
  586.             push hl
  587.                     ld hl,txt_buff
  588.                     call _type_txt_buf
  589.                     call clear_txt_buff
  590.             pop hl
  591.             ret
  592.  
  593. _type_txt_buf:
  594.             ld a,(hl)
  595.             and a
  596.             ret z
  597.                 CP 128
  598.                 CALL NC,change_cp
  599.             sub 32
  600.             push hl
  601.             call _type
  602.             pop hl
  603.             inc hl
  604.             jr _type_txt_buf
  605.  
  606. _print_txt_buf_p:
  607.             push hl
  608.                     ld hl,txt_buff
  609.                     call _type_txt_buf_p
  610.                     call clear_txt_buff
  611.             pop hl
  612.             ret
  613.  
  614. _type_txt_buf_p:
  615.             ld c,1
  616. .l1
  617.             ld a,(hl)
  618.             and a
  619.             ret z
  620.       ;         CP 128
  621.        ;        CALL NC,change_cp
  622.      ;       sub 32
  623.             push hl
  624.             call _type_p
  625.             pop hl
  626.             inc hl
  627.             jr .l1
  628.  
  629. clear_txt_buff:
  630.         push bc,de
  631.         xor a
  632.         ld b,64
  633.         ld de,txt_buff
  634. .lp1
  635.         ld (de),a
  636.         inc de
  637.         djnz .lp1
  638.         pop de,bc
  639.         ret
  640.        
  641.  
  642.  
  643.  
  644. txt_buff: ds 64,0
  645.  
  646. main_end:
  647.         include "../../_sdk/file.asm"
  648.  
  649. gf_func_start:
  650.         include "gfx_func.asm"
  651. gf_func_end:
  652.  
  653. sub_func_start:
  654.         include "sub_func.asm"
  655. sub_func_end:
  656.  
  657. sub_vars_start:
  658.         include "sub_vars.asm"
  659. sub_vars_end:
  660.  
  661. sub_dsk_start:
  662.         include "sub_dsk.asm"
  663. sub_dsk_end:
  664.  
  665. sub_variables_start:
  666.         include "variables.asm"
  667. sub_variables_end:
  668.  
  669.  
  670.  
  671.  
  672. ;FONT:   incbin  "font_rus.bin"
  673.  
  674.  
  675.  
  676.         align 256
  677. font_buf ds 16,0
  678.         align 256
  679. PUSH_DATA:  ds 256,0  ;//wait animation
  680.  
  681.  
  682.         macro BRIGHTBYTE x
  683. _=x
  684.         if _>15
  685. _=15
  686.         endif
  687. _g0=~_&1
  688. _g1=(~_>>1)&1
  689. _g2=(~_>>2)&1
  690. _g3=(~_>>3)&1
  691. ;0g20G3G3
  692.         ;db _
  693.         db (_g0<<6)+(_g2<<5)+(_g1<<3)+(_g3<<2)+(_g1<<1)+(_g3<<0)
  694.         endm
  695.  
  696.         align 256
  697. tbright
  698. ;brightness levels (black 0..7 less than original, 8 equal, 9..15 to white)
  699. ;0, 1/12, 1/8, 3/16, 2/8, 3/8, 4/8, 6/8, 1
  700. _lev=0
  701.         dup 16 ;colour component level
  702. _antilev=15-_lev
  703.         BRIGHTBYTE _lev*0
  704.         BRIGHTBYTE _lev/12
  705.         BRIGHTBYTE _lev*1/8
  706.         BRIGHTBYTE _lev*3/16
  707.         BRIGHTBYTE _lev*2/8
  708.         BRIGHTBYTE _lev*3/8
  709.         BRIGHTBYTE _lev*4/8
  710.         BRIGHTBYTE _lev*6/8
  711.  
  712.         BRIGHTBYTE _lev
  713.  
  714.         BRIGHTBYTE 15-(_antilev*6/8)
  715.         BRIGHTBYTE 15-(_antilev*4/8)
  716.         BRIGHTBYTE 15-(_antilev*3/8)
  717.         BRIGHTBYTE 15-(_antilev*2/8)
  718.         BRIGHTBYTE 15-(_antilev*3/16)
  719.         BRIGHTBYTE 15-(_antilev*1/8)
  720.         BRIGHTBYTE 15
  721.  
  722. _lev=_lev+1
  723.         edup
  724.  
  725.  
  726. ;dw sprite adress
  727. ;dw sprite scr adress
  728. ;db len
  729. ;db hgt
  730. ;db num of phases
  731. ;db seq position
  732. ;db next seq counter
  733. ;ds 7,0 placeholder
  734.  
  735. ;0x0000 EOF
  736.  
  737.  
  738. buf:            
  739.          include "buf.asm"
  740.  
  741. ;buf_ext             ds 538-(buf_ext-txt_setup),0
  742.  
  743. cmd_end:        
  744.         include "ptsplay.asm"
  745. ;        include "intro.eng.asm"
  746. ;        include "intro.rus.asm"
  747.  
  748.  
  749.  
  750.         display "main.com free space ",/d,GLOBVARS-buf," bytes"
  751.  
  752.  
  753.  
  754.         display "main.com length ",/d,main_end-cmd_begin," bytes"
  755.         display "gf_func length ",/d,gf_func_end-gf_func_start," bytes"
  756.         display "sub_func length ",/d,sub_func_end-sub_func_start," bytes"
  757.         display "sub_vars length ",/d,sub_vars_end-sub_vars_start," bytes"
  758.         display "sub_dsk length ",/d,sub_dsk_end-sub_dsk_start," bytes"
  759.         display "sub_variables length ",/d,sub_variables_end-sub_variables_start," bytes"
  760.  
  761.         display "buf lenght",/d,cmd_end-buf," bytes"
  762.  
  763.  
  764.         savebin "BOD.com",cmd_begin,cmd_end-cmd_begin
  765.         savebin "BOD/aym_plr.bin",ptsbegin,ptsend-ptsbegin
  766.         LABELSLIST "../../../us/user.l",1
  767.