?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.         macro NEXTCOLUMN
  7.         bit 6,h
  8.         set 6,h
  9.         jr z,1f;shapes_linehorR_incxok
  10.         ld a,h
  11.         xor 0x60
  12.         ld h,a
  13.         and 0x20
  14.         jr nz,1f;shapes_linehorR_incxok
  15.         inc hl
  16. 1 ;shapes_linehorR_incxok
  17.         endm
  18.  
  19. print_v_limit:   equ 0x17
  20. print_p_len:     equ 53
  21. txt_coor:        equ 0x1400
  22. x_txt_coor  =    low txt_coor
  23.  
  24.  
  25. txt_coor2:        equ 0x1420
  26.  
  27. module equ 0xc000
  28. player_load = 0x4000
  29.  
  30. ovl_start = 0x4000
  31.  
  32. PLR_INIT  = 0x4000
  33. PLR_PLAY  = 0x4005
  34. PLR_MUTE  = 0x4007
  35.  
  36.  
  37. ;LOCVARS  = 0x3900
  38. ;ACTMENU  = 0x3a00
  39. GLOBVARS = 0x3c00 ;0x3800
  40. ILINK    = 0x3d00
  41. STK_MENU = 0x3e00
  42.  
  43. FONT     = 0x8000
  44. FONT2    = 0x9000
  45.  
  46. ANIM_BFF  = 0x9000
  47. ANIM_BFFR = 0x5000        
  48.  
  49. sp_main = 0x4000
  50. sp_alt  = 0x3f90
  51.  
  52. cmd_begin
  53.                     OS_HIDEFROMPARENT
  54.                     ld sp,sp_main
  55.                     call pre_init    
  56.  
  57.  
  58. begin:
  59.                         ld a,6
  60.                         ld (outtyp),a
  61.  
  62.                
  63.                         ld a,(menu_mus)
  64.                         call load_mus
  65.  
  66.  
  67.  
  68.         ld hl,menu_pic
  69.         call load_big_img_dark2
  70.  
  71.  
  72.  
  73.         call palette_precalc
  74.         call fade_fromwhite
  75.  
  76.  
  77.  
  78. _main_menu:
  79. _main_menu_mmm:
  80.  
  81.         ld hl,loc_main_menu
  82.         ld de,menu_main_action
  83.  
  84.         push de
  85.         ld a,(language)
  86.         call sel_word
  87.        
  88.         call _pre_setup
  89.         call _pre_menu_store_bgnd
  90.         call _draw_menu_box
  91.         call _prt_menu
  92.  
  93.  
  94.  
  95. _mmnu_r1        
  96.         call _sel_menu
  97.         cp 0xff
  98.         jr z,_mmnu_r1 ;block esc
  99.  
  100.         call _pre_menu_restore_bgnd
  101.  
  102.         pop hl
  103.         call sel_word
  104.         jp (hl)
  105. ;       call waitkey
  106. _gamequit
  107.         xor a
  108.         call no_mus
  109.         jp cmd_quit
  110.  
  111.  
  112. _loadgame
  113.         ld hl,loc_load_menu
  114.         ld de,menu_load_action        
  115.  
  116.         push de
  117.         ld a,(language)
  118.         call sel_word
  119.        
  120.         call _pre_setup
  121.         call _pre_menu_store_bgnd
  122.         call _draw_menu_box
  123.         call _prt_menu
  124.        
  125.         call _sel_menu
  126.         call _pre_menu_restore_bgnd
  127.         pop hl
  128.  
  129.         cp 0xff
  130.         jp z,_main_menu_mmm
  131.  
  132.         call sel_word
  133.         jp (hl)
  134.  
  135. _load_slot1:
  136.         ld a,1
  137.         jr _load_slot
  138. _load_slot2:
  139.         ld a,2
  140.         jr _load_slot
  141. _load_slot3:
  142.         ld a,3
  143.         jr _load_slot
  144. _load_slot4:
  145.         ld a,4
  146. _load_slot:
  147.         add a,"0"
  148.         ld (SAVETEMPL_N),a
  149.  
  150.  
  151.         ld de,SAVETEMPL
  152.         call openstream_file
  153.         or a
  154.         jp nz,_loadgame
  155.  
  156. _load_common:
  157.         ;load screenshot to load_buf with palette
  158.  
  159.         ;call no_mus ;!!!!!!!!!
  160.  
  161.         call store8000c000
  162.  
  163.         ld a,(load_buf1)
  164.         SETPG8000
  165.  
  166.         ld a,(load_buf2)
  167.         SETPGC000
  168.  
  169.  
  170.          ld hl,0x8000
  171.          ld de,0x8000
  172.          call readstream_file
  173.          or a
  174.         jp nz,filereaderror
  175.  
  176.         call restore8000c000
  177.  
  178.         ld de,t_pal;curpal
  179.         ld hl,32
  180.         call readstream_file
  181.         or a
  182.         jp nz,filereaderror
  183.  
  184.  
  185.         ld de,GLOBVARS
  186.         ld hl,256
  187.         call readstream_file
  188.         or a
  189.         jp nz,filereaderror
  190.  
  191.  
  192.         ld de,loadedCg
  193.         ld hl,32
  194.         call readstream_file
  195.         or a
  196.         jp nz,filereaderror
  197.  
  198.         ld de,OVL
  199.         ld hl,32
  200.         call readstream_file
  201.         or a
  202.         jp nz,filereaderror
  203.  
  204.  
  205.         ld de,text_pointer
  206.         ld hl,2
  207.         call readstream_file
  208.         or a
  209.         jp nz,filereaderror
  210.  
  211.         ld de,redraw_border
  212.         ld hl,1
  213.         call readstream_file
  214.         or a
  215.         jp nz,filereaderror
  216.  
  217.         ld de,t_mus
  218.         ld hl,1
  219.         call readstream_file
  220.         or a
  221.         jp nz,filereaderror
  222.  
  223.         call closestream_file
  224.  
  225. freddd:
  226. ;_redraw screen
  227.         ld hl,OVL
  228.         call load_ovl_to_script_buf
  229.  
  230. ;memorize ovl name
  231.                 ld hl,OVL
  232.                 ld de,LOADED
  233.                 call copystr_hlde
  234.                 xor a
  235.                 ld (de),a
  236.  
  237.         ;clear OVL variable
  238.                 ld hl,OVL
  239.                 ld de,OVL+1
  240.                 ld (hl),0
  241.                 ld bc,31
  242.                 ldir
  243.  
  244.         ;//load CG to mem buf
  245.         ld hl,loadedCg
  246.         ld a,(hl)
  247.         and a
  248.         call nz,load_gfx_to_mem_buf
  249.  
  250. ;;;;F_o
  251.         ld a,(t_mus)
  252.         call load_mus
  253.  
  254.  
  255.         call _B_O_sub
  256.  
  257.         ld a,(redraw_border)
  258.         jr nz,.nnn
  259.  
  260.  
  261.         ld hl,t_pal
  262.         ld de,pal
  263.         ld bc,32
  264.         ldir
  265.  
  266.         xor a
  267.         ld (outtyp),a
  268.         inc a
  269.         ld (setpalflag),a
  270.         halt
  271.  
  272.         call update_satus_bar
  273.  
  274.         ld hl,loadedCg
  275.         ld a,(hl)
  276.         and a    
  277.         call nz,_buffer_output
  278.  
  279.  
  280. .nnn
  281.         call _clear_textbox
  282.         ld hl,(text_pointer)
  283.  
  284.  
  285.         jp _txt_out   ;hl-pointer to ovl name to load.
  286.  
  287. ;------------------------------------------------
  288. _newgame:
  289. NWGAM:
  290.         ld a,1
  291.         ld (redraw_border),a
  292.         xor a
  293.         LD HL,GLOBVARS
  294.         LD B,A
  295.         LD (HL),A
  296.         INC HL
  297.         DJNZ $-2
  298.         ld hl,FSTOVL
  299.  
  300. GAMESTART1:      
  301.         ld de,OVL
  302.         call copystr_hlde
  303.         xor a
  304.         ld (de),a        
  305.  
  306.         call clear_whole_screen
  307.  
  308.  
  309. GAMESTART:
  310. BEG:
  311.  
  312.  
  313. ;load ovl
  314.         ld hl,OVL
  315.         call load_ovl_to_script_buf
  316. ;memorize ovl name
  317.         ld hl,OVL
  318.         ld de,LOADED
  319.         call copystr_hlde
  320.         xor a
  321.         ld (de),a
  322.  
  323. ;clear OVL variable
  324.         ld hl,OVL
  325.         ld de,OVL+1
  326.         ld (hl),0
  327.         ld bc,31
  328.         ldir
  329.  
  330.           ld a,(redraw_border)
  331.           and a
  332.           call z,update_satus_bar
  333.  
  334.         CALL _clear_textbox
  335.  
  336.  
  337.         ld hl,0x4000 ;script start adress
  338. ;---------------------------------------------------
  339. _txt_out:
  340.  
  341.         ;TODO
  342.         ld bc ,txt_coor
  343.         call _pradd_p
  344.  
  345.         ld a,1
  346.         ld (first_word),a
  347.         ld (first_letter),a
  348.         ld (just_cr),a
  349.  
  350.  
  351. ;---------------------------------------------------
  352. ;print routine
  353. _print:
  354.         push hl
  355.         call clear_txt_buff
  356.  
  357.         pop hl
  358.  
  359.         ld a,(script_buf1)
  360.         SETPG4000
  361.         ld a,(script_buf2)
  362.         SETPG8000
  363.  
  364.         ld de,txt_buff        
  365.         ld c,0   ;//symbol counter
  366.  
  367. .p0:
  368.         LD A,(HL)
  369.         CP 32+1
  370.         JR C,.p1 ;is control code
  371.         ;copy string yo buffer
  372.  
  373.         ld (de),a
  374.  
  375.         ld a,(first_word)
  376.         and a
  377.         jr z,.pm0
  378.         ld a,(first_letter)
  379.         and a
  380.         jr z,.pm0
  381.         xor a
  382.         ld (first_letter),a
  383.         ld (text_pointer),hl
  384.        
  385.  
  386. .pm0
  387.         inc hl
  388.         inc de
  389.         inc c
  390.         jr .p0
  391.  
  392.  
  393. .p1:
  394.         push af
  395.         ld a,c
  396.         and a
  397.         jr nz,.p1_1     ;buffer not empty. print string
  398.         pop af
  399.  
  400.         cp 32
  401.         jp nz,_print_token
  402.  
  403.         ld a,(just_cr)
  404.         and a
  405.         jr nz,.p1_0 ;if just go to new line - do not print space
  406.  
  407.         ld a,32
  408.         ld (de),a ;print space
  409.         inc hl
  410.         inc c
  411. ;        jr .p1_0
  412. ;.p1_01:
  413. ;        xor a
  414. ;        ld (just_cr),a    
  415. .p1_0:
  416.  
  417.         push af
  418. .p1_1:
  419.         ld a,c
  420.         ld bc,(CORDS_P)           ;B-y C-X
  421.         add a,c
  422.         cp print_p_len
  423.  
  424.         jr c,.p1_no_overflow
  425.  
  426.         call _linefeed
  427.  
  428.        jr .npo
  429. .p1_no_overflow:
  430.         xor a
  431.         ld (just_cr),a
  432. .npo:
  433.  
  434.         ld a,(first_word)
  435.         and a
  436.         jr z,.npo0
  437.  
  438.         dec de
  439.         ld a,(de)
  440.         cp ':'
  441.         jr nz,.npo00
  442.         push hl
  443. ;        ld hl,0x4080 ;index 8 magenta
  444.         ld hl,0x0108 ; index 1
  445.         ld (_type_color),hl
  446.         pop hl
  447.         jr .npo0
  448. .npo00        
  449.         xor a
  450.         ld (first_word),a
  451. .npo0      
  452.         call _print_txt_buf_p
  453.  
  454.         ld a,(first_word)
  455.         and a
  456.         jr z,.npo3
  457.                 xor a
  458.                 ld (first_word),a
  459.                 push hl
  460.                 ld hl,0x47b8
  461.                 ld (_type_color),hl
  462.                 pop hl
  463. .npo3
  464.         pop af
  465.         jp _print
  466.  
  467. _print_token:
  468.  
  469.         push hl
  470.         ld hl,_tokenTable
  471.         ld c,a
  472. .p2:
  473.         ld a,(hl)
  474.         inc hl
  475.         cp 0xff
  476.         jr z,.p4  ;table end
  477.         cp c
  478.         jr z,.p3  ;code found
  479.         inc hl
  480.         inc hl
  481.         jr .p2
  482. .p3:
  483.         ld a,(hl)
  484.         inc hl
  485.         ld h,(hl)
  486.         ld l,a
  487.         ex (sp),hl
  488.         ret
  489. .p4:
  490.         pop hl
  491.  
  492.         ;    inc hl ;!debug! skip unused code
  493.         ;jr _print
  494. ;;;;;!!!!!!!!!!!!
  495.  
  496.         push hl
  497.  
  498.         ld hl,stdpal
  499.         ld bc,32
  500.         ld de,pal
  501.         ldir
  502.  
  503.         ld a,1
  504.         ld (setpalflag),a
  505.  
  506.         pop  hl
  507.  
  508.     ld a,(hl)
  509.     call a_to_dec
  510.     ld hl,buf+2
  511.     ld (hl),0
  512.     dec hl
  513.     ld (hl),a
  514.     dec hl
  515.     ld a,b
  516.     ld (hl),a
  517.     ld hl,txt_unkcode
  518.     jp openerror
  519.  
  520. ;;;;;!!!!!!!!!!!!
  521. _linefeed:
  522.                 ld a,1
  523.        ld (just_cr),a
  524.  
  525.         ld bc,(CORDS_P)
  526.         inc b
  527.         ld c,x_txt_coor
  528.         call _pradd_p
  529.  
  530.         ld bc,(CORDS_P)
  531.         LD A,B
  532.         CP print_v_limit
  533.         CALL NC, WINCLR1
  534.         ret
  535.  
  536.         call waitkey
  537.         jp _gamequit
  538.  
  539.  
  540.  
  541. _tokenTable
  542.         db 0x01
  543.         dw WINCLR  ;IF PRESSED KEY              ;++++
  544.  
  545.         db 0x04
  546.         dw _loadovl
  547.  
  548.         db 0x06
  549.         dw _CDPLAY
  550.  
  551.         db 0x0b
  552.         dw _group0b ;!!!!!!!!
  553.  
  554.         db 0x0f
  555.         dw _gameend
  556.  
  557.         db 0x10
  558.         dw _cls
  559.  
  560.         db 0x13
  561.         dw _group13 ;!!!!!!!!
  562.  
  563.         db 0x14
  564.         dw _group14;!!!!!!!!
  565.  
  566.         db 0x16
  567.         dw _flash
  568.  
  569.         db 0x17
  570.         dw _T_WAIT
  571.  
  572.         db 0x18
  573.         dw _gata
  574.  
  575.         db 0x19
  576.         dw _group19 ;!!!!!!!!
  577.  
  578.         db 0xff
  579.  
  580.  
  581.  
  582. _tokenTable0b
  583.         db 0x01
  584.         dw _var_plus
  585.         db 0x05
  586.         dw _var_equal
  587.         db 0x0d
  588.         dw _var_minus
  589.         db 0x0e
  590.         dw _var_div
  591.         db 0x0f
  592.         dw _var_down
  593.  
  594.         db 0x36
  595.         dw _goto
  596.         db 0x39
  597.         dw _jtbl
  598.         db 0x40
  599.         dw _flg_if
  600.        
  601.         db 0xff
  602.  
  603. _tokenTable13
  604.         db 0x01
  605.         dw _EVENT_CG ; show cg
  606.         db 0x02
  607.         dw _SCREENOUTPUT1
  608.         db 0x03
  609.         dw _T_CG
  610.         db 0x04
  611.         dw _LOAD_TO_MEM
  612.         db 0x0f
  613.         dw _COPY_MEM_2_LOAD    
  614.         db 0xff
  615.  
  616.  
  617. _tokenTable14
  618.         db 0x03
  619.         dw _F_O   ;clear cg screen to black
  620.         db 0x04
  621.         dw _B_O   ;whole screen blackout
  622.  
  623.         db 0x08
  624.         dw _SCR_SET
  625.  
  626.         db 0xff
  627.  
  628. _tokenTable19
  629.         db 0x01
  630.         dw _MENU_SET
  631.         db 0xff
  632.  
  633.  
  634. _group0b:
  635.         ld de,_tokenTable0b
  636.         jr _groups
  637. _group19:
  638.         ld de,_tokenTable19
  639.         jr _groups
  640. _group13:
  641.         ld de,_tokenTable13
  642.         jr _groups
  643. _group14:
  644.         ld de,_tokenTable14
  645. _groups:
  646.         inc hl
  647.         ld a,(hl)
  648.         inc hl
  649.         push hl
  650.         ex de,hl
  651.  
  652.         ld c,a
  653. .p5_6:
  654.         ld a,(hl)
  655.         inc hl
  656.         cp 0xff
  657.         jr z,.p5_8
  658.         cp c
  659.         jr z,.p5_7
  660.         inc hl
  661.         inc hl
  662.         jr .p5_6
  663. .p5_7:
  664.         ld a,(hl)
  665.         inc hl
  666.         ld h,(hl)
  667.         ld l,a
  668.         ex (sp),hl
  669.         ret
  670. .p5_8:
  671.         pop hl
  672.         jp _print    
  673.  
  674.  
  675.  
  676.  
  677.  
  678. txt_buff: ds 256,0
  679.  
  680. main_end:
  681.         include "../../_sdk/file.asm"
  682.  
  683. gf_func_start:
  684.         include "gfx_func.asm"
  685. gf_func_end:
  686.  
  687. sub_func_start:
  688.         include "sub_func.asm"
  689.  
  690. sub_func2_start:
  691.         include "sub_func2.asm"
  692.  
  693. sub_func_end:
  694.  
  695. sub_vars_start:
  696.         include "sub_vars.asm"
  697. sub_vars_end:
  698.  
  699. sub_dsk_start:
  700.         include "sub_dsk.asm"
  701. sub_dsk_end:
  702.  
  703. sub_variables_start:
  704.         include "variables.asm"
  705. sub_variables_end:
  706.  
  707.  
  708.  
  709. code_end:
  710. ;FONT:   incbin  "font_rus.bin"
  711.  
  712.  
  713.  
  714.  
  715.  
  716.         align 256
  717. font_buf                ds 16,0
  718.  
  719.         align 256
  720. t_s98_file00_pages_list:  ds 256,0
  721.  
  722. PUSH_DATA:  ds 256,0  ;//wait animation
  723. CUR_DATA:   ds 128,0
  724. CUR_BGND_STORE: ds 128,0
  725.  
  726.  
  727.         macro BRIGHTBYTE x
  728. _=x
  729.         if _>15
  730. _=15
  731.         endif
  732. _g0=~_&1
  733. _g1=(~_>>1)&1
  734. _g2=(~_>>2)&1
  735. _g3=(~_>>3)&1
  736. ;0g20G3G3
  737.         ;db _
  738.         db (_g0<<6)+(_g2<<5)+(_g1<<3)+(_g3<<2)+(_g1<<1)+(_g3<<0)
  739.         endm
  740.  
  741.         align 256
  742. tbright
  743. ;brightness levels (black 0..7 less than original, 8 equal, 9..15 to white)
  744. ;0, 1/12, 1/8, 3/16, 2/8, 3/8, 4/8, 6/8, 1
  745. _lev=0
  746.         dup 16 ;colour component level
  747. _antilev=15-_lev
  748.         BRIGHTBYTE _lev*0
  749.         BRIGHTBYTE _lev/12
  750.         BRIGHTBYTE _lev*1/8
  751.         BRIGHTBYTE _lev*3/16
  752.         BRIGHTBYTE _lev*2/8
  753.         BRIGHTBYTE _lev*3/8
  754.         BRIGHTBYTE _lev*4/8
  755.         BRIGHTBYTE _lev*6/8
  756.  
  757.         BRIGHTBYTE _lev
  758.  
  759.         BRIGHTBYTE 15-(_antilev*6/8)
  760.         BRIGHTBYTE 15-(_antilev*4/8)
  761.         BRIGHTBYTE 15-(_antilev*3/8)
  762.         BRIGHTBYTE 15-(_antilev*2/8)
  763.         BRIGHTBYTE 15-(_antilev*3/16)
  764.         BRIGHTBYTE 15-(_antilev*1/8)
  765.         BRIGHTBYTE 15
  766.  
  767. _lev=_lev+1
  768.         edup
  769.  
  770.         align 256
  771. tx
  772.         dup 256
  773.         db ($&0xff)/4
  774.         edup
  775.         dup 64
  776.         db 0x80
  777.         db 0xc0
  778.         db 0xa0
  779.         db 0xe0
  780.         edup
  781. ty
  782.         dup 200
  783.         db 0xff&(($&0xff)*40)
  784.         edup
  785.         ds 56,0xff&8000
  786.         dup 200
  787.         db (($&0xff)*40)/256
  788.         edup
  789.         ds 56,8000/256
  790.  
  791.  
  792. ;dw sprite adress
  793. ;dw sprite scr adress
  794. ;db len
  795. ;db hgt
  796. ;db num of phases
  797. ;db seq position
  798. ;db next seq counter
  799. ;ds 7,0 placeholder
  800.  
  801. ;0x0000 EOF
  802.         align 256
  803. SCTBL:          ;structure
  804.         DW      S1, S2, S3, S4, S5, S6, S7, S8
  805.         dw 0xffff    
  806.  
  807. COMTBL:         ;tree
  808.         DW      CM1, CM2, CM3, CM4, CM5, CM6, CM7, CM8
  809.         dw 0xffff
  810.  
  811. CM1:    DW      0 ,    -1  ;0  - adress od menu name string
  812. CM2:    DW      0 ,    -1
  813. CM3:    DW      0 ,    -1
  814. CM4:    DW      0 ,    -1
  815. CM5:    DW      0 ,    -1
  816. CM6:    DW      0 ,    -1
  817. CM7:    DW      0 ,    -1
  818. CM8:    DW      0 ,    -1
  819.         DW      0xffff
  820. S1:     DW      0,-1,1, 1 ;0  - adress od menu name string
  821. S2:     DW      0,-1,2, 1 ;1 - goto addr.
  822. S3:     DW      0,-1,3, 1
  823. S4:     DW      0,-1,4, 1        
  824. S5:     DW      0,-1,5, 1
  825. S6:     DW      0,-1,6, 1
  826. S7:     DW      0,-1,7, 1
  827. S8:     DW      0,-1,8, 1        
  828.         DW      0xffff
  829. buf:            
  830.          include "buf.asm"
  831.  
  832. ;buf_ext             ds 538-(buf_ext-txt_setup),0
  833.  
  834. cmd_end:        
  835.         include "ptsplay.asm"
  836. ;        include "intro.eng.asm"
  837. ;        include "intro.rus.asm"
  838.  
  839.  
  840.  
  841.         display "main.com free space ",/d,GLOBVARS-buf," bytes"
  842.  
  843.        display "main.com code_length ",/d,code_end-cmd_begin ," bytes"
  844.  
  845.         display "main.com length ",/d,main_end-cmd_begin," bytes"
  846.         display "gf_func length ",/d,gf_func_end-gf_func_start," bytes"
  847.         display "sub_func length ",/d,sub_func_end-sub_func_start," bytes"
  848.         display "sub_vars length ",/d,sub_vars_end-sub_vars_start," bytes"
  849.         display "sub_dsk length ",/d,sub_dsk_end-sub_dsk_start," bytes"
  850.         display "sub_variables length ",/d,sub_variables_end-sub_variables_start," bytes"
  851.  
  852.         display "buf lenght",/d,cmd_end-buf," bytes"
  853.  
  854.  
  855.         savebin "tenkosei.com",cmd_begin,cmd_end-cmd_begin
  856.         savebin "aym_plr.bin",ptsbegin,ptsend-ptsbegin
  857.         LABELSLIST "../../../us/user.l",1
  858.