?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../../_sdk/sys_h.asm"  
  3.  
  4. STACK=0x4000;0x61a8
  5. GAMESTACK=0x4000;0xFFFF
  6. L_FDFD=0xfdfd
  7. L_FE00=0xfe00
  8.  
  9. scrbase=0x4000+4
  10. sprmaxwid=32
  11. sprmaxhgt=32
  12. scrwid=160 ;double pixels
  13. scrhgt=192;200
  14. INTSTACK=0x3f00
  15. tempsp=0x3f06 ;6 bytes for prspr
  16. ;UVSCROLL_SCRWID=320 ;8*(TILEMAPWID-2)
  17. ;UVSCROLL_SCRHGT=192 ;(фхышЄё  эр 16!!!) ;8*(TILEMAPHGT-2) ;ўЄюс√ т√тюфшЄ№ тёхуфр 12 ьхЄрЄрщыют (3 сыюър яю 8) яю т√ёюЄх
  18.  
  19. screenYtable=0x8b00
  20.  
  21. EGA=1
  22.  
  23.         org PROGSTART
  24. begin
  25.         jp begin2 ;/prsprqwid (sprites in file are made so that they return here)
  26. begin2
  27.         ld sp,STACK
  28.         OS_HIDEFROMPARENT
  29.  
  30.         ld e,0+0x80 ;EGA+keep
  31.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  32.  
  33.         ;ld e,1
  34.         ;OS_SETSCREEN
  35.         ld e,0 ;color byte
  36.         OS_CLS
  37.         ;ld e,0
  38.         ;OS_SETSCREEN
  39.         ;ld e,0 ;color byte
  40.         ;OS_CLS
  41.  
  42.         OS_GETMAINPAGES
  43. ;dehl=pages in 0000,4000,8000,c000
  44.         ld a,e
  45.         ld (pggfx),a
  46.         ld a,h
  47.         ld (pgcode8000),a
  48.         ld a,l
  49.         ld (pgcodec000),a
  50.         ;jr $
  51.  
  52.         OS_NEWPAGE
  53.         ld a,e
  54.         ld (pgmain4000),a
  55.  
  56.         if 1==1
  57.         ld de,res_path
  58.         OS_CHDIR
  59.  
  60.         call setpgsscr40008000
  61.  
  62.         ld de,emptypal
  63.         OS_SETPAL
  64.         ;ld de,bmpfilename
  65.         ;call openstream_file
  66.         ;call readbmphead_pal
  67.         ;call readbmpscr
  68.         ;call closestream_file
  69.         ;ld de,path
  70.         ;OS_CHDIR
  71.         ;ld a,(pgscrdata0)
  72.         ld de,filename0 ;шь  Їрщыр
  73.         ld hl,0x4000 ;ъєфр уЁєчшь
  74.         call loadfile_in_hl ;чруЁєчшыш юфшэ ¤ъЁрээ√щ Їрщы т юфэє ёЄЁрэшЎє
  75.         ;ld a,(pgscrdata1)
  76.         ld de,filename1 ;шь  Їрщыр
  77.         ld hl,0x8000 ;ъєфр уЁєчшь
  78.         call loadfile_in_hl ;чруЁєчшыш фЁєующ ¤ъЁрээ√щ Їрщы т фЁєує■ ёЄЁрэшЎє
  79.         ld hl,0x4000+8000 ;Єрь т ърЁЄшэъх ярышЄЁр (яю срщЄє эр ЎтхЄ)
  80.         ld de,pal
  81.         ld b,16
  82. copypal0
  83.         ld a,(hl)
  84.         inc hl
  85.         ld (de),a
  86.         inc de
  87.         ld (de),a
  88.         inc de
  89.         djnz copypal0 ;ёъюяшЁютрыш ярышЄЁє т pal (яю 2 срщЄр эр ЎтхЄ)
  90.         ld de,pal
  91.         OS_SETPAL
  92.        
  93.         call setpgsmain40008000
  94.  
  95.         ;ld b,50
  96.         ;halt
  97.         ;djnz $-1
  98.         YIELDGETKEYLOOP
  99.  
  100.         ld e,3+8+0x80 ;6912+noturbo+keep
  101.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  102.         ld e,0 ;color byte
  103.         OS_CLS
  104.         ld de,standardpal
  105.         OS_SETPAL
  106.         YIELD
  107.         endif
  108.  
  109.         if 1==1
  110.         ld a,(user_scr0_high) ;ok
  111.         SETPG16K
  112.         ;ld a,(pggfx)
  113.         ;SETPG32KLOW
  114.         call setpggfxc000
  115.         ld hl,0xc000
  116.         ld de,0x4000
  117.         ld bc,0x4000
  118.         ldir
  119.         ;ld a,(user_scr0_high)
  120.         ;SETPG16K
  121.         ;ld a,(pgcode8000)
  122.         ;SETPG32KLOW
  123.         call setpgcodec000
  124.         endif
  125.         ;ld a,(user_scr0_high) ;ok
  126.         ;SETPG16K
  127.        
  128.         call swapimer
  129.  
  130.         if EGA
  131.         ld hl,prsprqwid
  132.         ld (0x0101),hl ;sprites in file are made so that they return in 0x0100
  133.         endif
  134.  
  135.         YIELDGETKEYLOOP
  136.        
  137.         ;jr $
  138.         jp GO
  139.  
  140.         ;include "pal.ast" ;slabpal
  141. standardpal
  142.         STANDARDPAL
  143. pal
  144.         ds 32,0xff
  145. emptypal
  146.         ds 32,0xff
  147.  
  148. jphl
  149.         jp (hl)
  150.  
  151. CheckBreak
  152.         ld a,0xfe
  153.         in a,(0xfe)
  154.         rra
  155.         ret c
  156.         ld a,0x7f
  157.         in a,(0xfe)
  158.         rra
  159.         ret
  160. PlayMusic_CheckQuit
  161.         call PlayMusic
  162.         call CheckBreak
  163.         ret c
  164. quiter
  165.         if 1==0
  166.         halt
  167. pgmuznum=$+1
  168.         ld a,0
  169.         SETPG32KHIGH
  170.           ld hl,muz
  171.           OS_SETMUSIC
  172.         halt
  173.         endif
  174.         call swapimer
  175.         im 1
  176.         QUIT
  177.  
  178. redattr_killable2b
  179.         dw 0
  180.  
  181. ;L_5B00 ;= #5b00
  182. ;        db 0
  183.  
  184. setpggfxc000
  185. pggfx=$+1
  186.         ld a,0
  187.         SETPG32KHIGH
  188.         ret
  189. setpgcodec000
  190. pgcodec000=$+1
  191.         ld a,0
  192.         SETPG32KHIGH
  193.         ret
  194.  
  195. swapimer
  196.         di
  197.         ld de,0x0038
  198.         ld hl,oldimer
  199.         ld bc,3
  200. swapimer0
  201.         ld a,(de)
  202.         ldi ;[oldimer] -> [0x0038]
  203.         dec hl
  204.         ld (hl),a ;[0x0038] -> [oldimer]
  205.         inc hl
  206.         jp pe,swapimer0
  207.         ei
  208.         ret
  209. oldimer
  210.         jp on_int ;чрьхэшЄё  эр ъюф шч 0x0038
  211.         jp 0x0038+3    
  212.  
  213. reter
  214.         ret
  215.  
  216. tstarttime       DB       #00,#00,#00
  217. curgametimer       DB       #00,#00,#00
  218. stoptimer       DB       #00
  219. curtimerlow       DB       #00
  220. ;
  221. on_int
  222. ;restore stack with de
  223.         EX DE,HL
  224.         EX (SP),HL ;de="hl", stack contains "de"
  225.         LD (on_int_jp),HL
  226.         LD (on_int_sp),SP
  227.         LD SP,INTSTACK
  228.         push af
  229.         push bc
  230.         push de ;"hl"
  231.         exx
  232.         ex af,af' ;'
  233.         push af
  234.         push bc
  235.         push de
  236.         push hl
  237.         push ix
  238.         push iy
  239.         ;DI
  240. ;curscrnum_int=$+1
  241. ;        ld e,0
  242. ;        OS_SETSCREEN
  243.         call oldimer ;ei
  244.          GET_KEY
  245.          jr nz,Imer_nofocus
  246.          ;ld a,(user_scr0_high) ;ok
  247.          ;SETPG16K ;TODO redraw screen when retake focus???
  248. Imer_nofocus
  249.         ;LD     A,(stoptimer)
  250.         ;OR     A
  251.         ;CALL   Z,DecTimer
  252.         pop iy
  253.         pop ix
  254.         pop hl
  255.         pop de
  256.         pop bc
  257.         pop af
  258.         ex af,af' ;'
  259.         exx
  260.         pop hl
  261.         pop bc
  262.         pop af        
  263. on_int_sp=$+1
  264.         ld sp,0
  265.         pop de
  266.         ei
  267. on_int_jp=$+1
  268.         jp 0
  269. ;
  270. ;
  271. RIGHTPIX=0x38;0xb8;%10111000
  272. LEFTPIX=0x07;0x47;%01000111
  273.         macro FONTBYTE
  274.         ld a,(de)
  275.         ld c,a
  276.         xor a
  277.         rl c
  278.         jr nc,$+4
  279.          or LEFTPIX
  280.         rl c
  281.         jr nc,$+4
  282.          or RIGHTPIX
  283.         ld (hl),a
  284.         ld a,h
  285.         add a,0x40
  286.         ld h,a
  287.         xor a
  288.         rl c
  289.         jr nc,$+4
  290.          or LEFTPIX
  291.         rl c
  292.         jr nc,$+4
  293.          or RIGHTPIX
  294.         ld (hl),a
  295.         ld a,h
  296.         add a,0x20-0x40
  297.         ld h,a
  298.         xor a
  299.         rl c
  300.         jr nc,$+4
  301.          or LEFTPIX
  302.         rl c
  303.         jr nc,$+4
  304.          or RIGHTPIX
  305.         ld (hl),a
  306.         ld a,h
  307.         add a,0x40
  308.         ld h,a
  309.         xor a
  310.         rl c
  311.         jr nc,$+4
  312.          or LEFTPIX
  313.         rl c
  314.         jr nc,$+4
  315.          or RIGHTPIX
  316.         ld (hl),a
  317.         endm
  318.  
  319. PrintCharA_EGA
  320.         push bc
  321.         push de
  322.         push hl
  323.        push af
  324.         call setpgsscr40008000
  325.         LD      DE,(curprintyx)
  326.         sla e
  327.         sla e
  328.         sla e
  329.         ld a,d ;x
  330.          add a,4
  331.         ld l,e ;y
  332.         ld h,0
  333.         ld d,h
  334.         ld e,l
  335.         add hl,hl
  336.         add hl,hl
  337.         add hl,de ;*5
  338.          add hl,hl
  339.          add hl,hl
  340.          add hl,hl ;*40
  341.         add a,l
  342.         ld l,a
  343.         ld a,h
  344.         adc a,0x40
  345.         ld h,a
  346.        pop af
  347.         PUSH    HL
  348.         LD      DE,font-256;L_BE02
  349.         LD      H,#00
  350.         LD      L,A
  351.         ADD     HL,HL
  352.         ADD     HL,HL
  353.         ADD     HL,HL
  354.         ADD     HL,DE
  355.         EX      DE,HL
  356.         POP     HL
  357.         LD      hx,#08
  358.  
  359. PrintCharA_EGA0
  360.         FONTBYTE
  361.         ld bc,40-0x6000
  362.         add hl,bc
  363.         INC     DE
  364.         dec hx
  365.         jr nz,PrintCharA_EGA0
  366.        
  367.         LD      DE,(curprintyx)
  368.         INC     D
  369.         LD      A,D
  370.         CP      #20
  371.         JR      NZ,PrintCharA_EGAq
  372.         INC     E
  373.         LD      D,#00
  374.         LD      A,E
  375.         CP      #18
  376.         JR      NZ,PrintCharA_EGAq
  377.         LD      E,#00
  378. PrintCharA_EGAq
  379.         LD      (curprintyx),DE
  380.         call setpgsmain40008000
  381.         pop hl
  382.         pop de
  383.         pop bc
  384.         ret
  385.        
  386. PrintCharA
  387.         PUSH    DE
  388.         PUSH    HL
  389.         PUSH    BC
  390.         PUSH    AF
  391.         LD      DE,(curprintyx)
  392.         LD      A,E
  393.         AND     #18
  394.         OR      #40
  395.         LD      H,A
  396.         LD      A,E
  397.         AND     #07
  398.         OR      A
  399.         RRA
  400.         RRA
  401.         RRA
  402.         RRA
  403.         ADD     A,D
  404.         LD      L,A
  405.         POP     AF
  406.         PUSH    HL
  407.         LD      DE,font-256;L_BE02
  408.         LD      H,#00
  409.         LD      L,A
  410.         ADD     HL,HL
  411.         ADD     HL,HL
  412.         ADD     HL,HL
  413.         ADD     HL,DE
  414.         EX      DE,HL
  415.         POP     HL
  416.         LD      B,#08
  417. L_C6EB  LD      A,(DE)
  418.         LD      (HL),A
  419.         INC     H
  420.         INC     DE
  421.         DJNZ    L_C6EB
  422.         LD      DE,(curprintyx)
  423.         INC     D
  424.         LD      A,D
  425.         CP      #20
  426.         JR      NZ,L_C705
  427.         INC     E
  428.         LD      D,#00
  429.         LD      A,E
  430.         CP      #18
  431.         JR      NZ,L_C705
  432.         LD      E,#00
  433. L_C705  LD      (curprintyx),DE
  434.         POP     BC
  435.         POP     HL
  436.         POP     DE
  437.         RET
  438. ;
  439. curprintyx       DW       #0000
  440. ;
  441. PrintStringHL
  442.         LD      A,(HL)
  443.         OR      A
  444.         RET     Z
  445.         CP      #16
  446.         JR      Z,L_C71C
  447.         CALL    PrintCharA
  448.         INC     HL
  449.         JR      PrintStringHL
  450. L_C71C  INC     HL
  451.         LD      E,(HL)
  452.         INC     HL
  453.         LD      D,(HL)
  454.         INC     HL
  455.         LD      (curprintyx),DE
  456.         JR      PrintStringHL
  457. ;
  458. PrintStringHL_EGA
  459.         LD      A,(HL)
  460.         OR      A
  461.         RET     Z
  462.         CP      #16
  463.         JR      Z,L_C71C_EGA
  464.         CALL    PrintCharA_EGA
  465.         INC     HL
  466.         JR      PrintStringHL_EGA
  467. L_C71C_EGA
  468.         INC     HL
  469.         LD      E,(HL)
  470.         INC     HL
  471.         LD      D,(HL)
  472.         INC     HL
  473.         LD      (curprintyx),DE
  474.         JR      PrintStringHL_EGA
  475.  
  476. font
  477.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  478.        DB       #00,#18,#3C,#18,#00,#18,#18,#00       ;..<.....
  479.        DB       #00,#36,#36,#6C,#00,#00,#00,#00       ;.66l....
  480.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  481.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  482.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  483.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  484.        DB       #00,#1C,#38,#00,#00,#00,#00,#00       ;..8.....
  485.        DB       #00,#0E,#1C,#1C,#1C,#1C,#0E,#00       ;........
  486.        DB       #00,#70,#38,#38,#38,#38,#70,#00       ;.p8888p.
  487.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  488.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  489.        DB       #00,#00,#00,#00,#00,#18,#18,#30       ;.......0
  490.        DB       #00,#00,#00,#3C,#3C,#00,#00,#00       ;...<<...
  491.        DB       #00,#00,#00,#00,#00,#18,#18,#00       ;........
  492.        DB       #00,#06,#0E,#1C,#38,#70,#60,#00       ;....8p`.
  493.        DB       #00,#3C,#72,#76,#7A,#72,#3C,#00       ;.<rvzr<.
  494.        DB       #00,#1C,#3C,#1C,#1C,#1C,#7E,#00       ;..<...~.
  495.        DB       #00,#7C,#0E,#0E,#3C,#70,#7E,#00       ;.|..<p~.
  496.        DB       #00,#7C,#0E,#3C,#0E,#0E,#7C,#00       ;.|.<..|.
  497.        DB       #00,#4E,#4E,#4E,#3E,#0E,#0E,#00       ;.NNN>...
  498.        DB       #00,#7C,#60,#7C,#0E,#0E,#7C,#00       ;.|`|..|.
  499.        DB       #00,#3C,#70,#7C,#72,#72,#3C,#00       ;.<p|rr<.
  500.        DB       #00,#7E,#06,#0E,#1C,#18,#18,#00       ;.~......
  501.        DB       #00,#3C,#72,#3C,#72,#72,#3C,#00       ;.<r<rr<.
  502.        DB       #00,#3C,#4E,#4E,#3E,#0E,#3C,#00       ;.<NN>.<.
  503.        DB       #00,#18,#18,#00,#00,#18,#18,#00       ;........
  504.        DB       #00,#18,#18,#00,#00,#18,#18,#30       ;.......0
  505.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  506.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  507.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  508.        DB       #7C,#0E,#0E,#0E,#1C,#00,#18,#00       ;|.......
  509.        DB       #00,#00,#00,#00,#00,#00,#00,#00       ;........
  510.        DB       #00,#3C,#72,#72,#7E,#72,#72,#00       ;.<rr~rr.
  511.        DB       #00,#7C,#72,#7C,#72,#72,#7C,#00       ;.|r|rr|.
  512.        DB       #00,#3E,#70,#70,#70,#70,#3E,#00       ;.>pppp>.
  513.        DB       #00,#7C,#72,#72,#72,#72,#7C,#00       ;.|rrrr|.
  514.        DB       #00,#3E,#70,#7C,#70,#70,#3E,#00       ;.>p|pp>.
  515.        DB       #00,#3E,#70,#7C,#70,#70,#70,#00       ;.>p|ppp.
  516.        DB       #00,#3E,#70,#70,#76,#72,#3C,#00       ;.>ppvr<.
  517.        DB       #00,#72,#72,#7E,#72,#72,#72,#00       ;.rr~rrr.
  518.        DB       #00,#7F,#1C,#1C,#1C,#1C,#7F,#00       ;........
  519.        DB       #00,#0E,#0E,#0E,#4E,#4E,#3C,#00       ;....NN<.
  520.        DB       #00,#72,#72,#7C,#72,#72,#72,#00       ;.rr|rrr.
  521.        DB       #00,#70,#70,#70,#70,#70,#3E,#00       ;.ppppp>.
  522.        DB       #00,#3E,#75,#75,#75,#75,#75,#00       ;.>uuuuu.
  523.        DB       #00,#7C,#72,#72,#72,#72,#72,#00       ;.|rrrrr.
  524.        DB       #00,#3C,#72,#72,#72,#72,#3C,#00       ;.<rrrr<.
  525.        DB       #00,#7C,#72,#72,#7C,#70,#70,#00       ;.|rr|pp.
  526.        DB       #00,#3C,#72,#72,#72,#7A,#3C,#08       ;.<rrrz<.
  527.        DB       #00,#7C,#72,#72,#7C,#72,#72,#00       ;.|rr|rr.
  528.        DB       #00,#3C,#70,#3C,#0E,#0E,#7C,#00       ;.<p<..|.
  529.        DB       #00,#7F,#1C,#1C,#1C,#1C,#1C,#00       ;........
  530.        DB       #00,#72,#72,#72,#72,#72,#3C,#00       ;.rrrrr<.
  531.        DB       #00,#72,#72,#72,#72,#34,#18,#00       ;.rrrr4..
  532.        DB       #00,#71,#71,#75,#75,#75,#3E,#00       ;.qquuu>.
  533.        DB       #00,#72,#72,#3C,#72,#72,#72,#00       ;.rr<rrr.
  534.        DB       #00,#4E,#4E,#4E,#3E,#0E,#3C,#00       ;.NNN>.<.
  535.        DB       #00,#7E,#0E,#1C,#38,#70,#7E,#00       ;.~..8p~.
  536.        DB       #00,#1E,#1C,#1C,#1C,#1C,#1E,#00       ;........
  537.        DB       #00,#60,#70,#38,#1C,#0E,#06,#00       ;.`p8....
  538.        DB       #00,#78,#38,#38,#38,#38,#78,#00       ;.x8888x.
  539.        DB       #00,#08,#1C,#3E,#5D,#1C,#1C,#00       ;...>]...
  540.        DB       #00,#78,#38,#3C,#3A,#3A,#3C,#00       ;.x8<::<.
  541.        DB       #00,#76,#79,#79,#79,#79,#76,#00       ;.vyyyyv.
  542.        DB       #00,#3C,#72,#72,#7E,#72,#72,#00       ;.<rr~rr.
  543.        DB       #00,#7C,#70,#7C,#72,#72,#7C,#00       ;.|p|rr|.
  544.        DB       #00,#4E,#4E,#4E,#4E,#4E,#3E,#02       ;.NNNNN>.
  545.        DB       #00,#1E,#2E,#2E,#2E,#2E,#7E,#42       ;......~B
  546.        DB       #00,#3E,#70,#7C,#70,#70,#3E,#00       ;.>p|pp>.
  547.        DB       #00,#3E,#5D,#5D,#3E,#1C,#1C,#00       ;.>]]>...
  548.        DB       #00,#3E,#70,#70,#70,#70,#70,#00       ;.>ppppp.
  549.        DB       #00,#72,#72,#3C,#72,#72,#72,#00       ;.rr<rrr.
  550.        DB       #00,#72,#72,#76,#7A,#72,#72,#00       ;.rrvzrr.
  551.        DB       #08,#72,#72,#76,#7A,#72,#72,#00       ;.rrvzrr.
  552.        DB       #00,#72,#72,#7C,#72,#72,#72,#00       ;.rr|rrr.
  553.        DB       #00,#3E,#4E,#4E,#4E,#4E,#4E,#00       ;.>NNNNN.
  554.        DB       #00,#71,#7B,#75,#71,#71,#71,#00       ;.q{uqqq.
  555.        DB       #00,#72,#72,#7E,#72,#72,#72,#00       ;.rr~rrr.
  556.        DB       #00,#3C,#72,#72,#72,#72,#3C,#00       ;.<rrrr<.
  557.        DB       #00,#7E,#4E,#4E,#4E,#4E,#4E,#00       ;.~NNNNN.
  558.        DB       #00,#3E,#4E,#4E,#3E,#4E,#4E,#00       ;.>NN>NN.
  559.        DB       #00,#7C,#72,#72,#7C,#70,#70,#00       ;.|rr|pp.
  560.        DB       #00,#3E,#70,#70,#70,#70,#3E,#00       ;.>pppp>.
  561.        DB       #00,#7F,#1C,#1C,#1C,#1C,#1C,#00       ;........
  562.        DB       #00,#4E,#4E,#4E,#3E,#0E,#3C,#00       ;.NNN>.<.
  563.        DB       #00,#5D,#5D,#3E,#5D,#5D,#5D,#00       ;.]]>]]].
  564.        DB       #00,#7C,#72,#7C,#72,#72,#7C,#00       ;.|r|rr|.
  565.        DB       #00,#70,#70,#7C,#72,#72,#7C,#00       ;.pp|rr|.
  566.        DB       #00,#72,#72,#7C,#72,#72,#7C,#00       ;.rr|rr|.
  567.        DB       #00,#7C,#0E,#3C,#0E,#0E,#7C,#00       ;.|.<..|.
  568.        DB       #00,#75,#75,#75,#75,#75,#3E,#00       ;.uuuuu>.
  569.        DB       #00,#7C,#0E,#3E,#0E,#0E,#7C,#00       ;.|.>..|.
  570.        DB       #00,#75,#75,#75,#75,#75,#3F,#01       ;.uuuuu?.
  571.        DB       #00,#4E,#4E,#4E,#3E,#0E,#0E,#00       ;.NNN>...
  572.        DB       #00,#00,#3E,#70,#70,#3E,#00,#00       ;..>pp>..
  573.  
  574.  
  575. setpgsmain40008000
  576. pgmain4000=$+1
  577.         ld a,0
  578.         SETPG16K
  579. pgcode8000=$+1
  580.         ld a,0
  581.         SETPG32KLOW
  582.         ret
  583.  
  584. setpgsscr40008000;_current
  585.         call getuser_scr_low_cur
  586.         SETPG16K
  587.         call getuser_scr_high_cur
  588.         SETPG32KLOW
  589.         ret
  590.  
  591.         if 1==0
  592. setpgsscr40008000
  593.         call getuser_scr_low
  594.         SETPG16K
  595.         call getuser_scr_high
  596.         SETPG32KLOW
  597.         ret
  598.         endif
  599.  
  600. getuser_scr_low
  601. getuser_scr_low_patch=$+1
  602. getuser_scr_low_patchN=0xff&(user_scr0_low^user_scr1_low)
  603.         ld a,(user_scr1_low) ;ok
  604.         ret
  605.  
  606. getuser_scr_high
  607. getuser_scr_high_patch=$+1
  608. getuser_scr_high_patchN=0xff&(user_scr0_high^user_scr1_high)
  609.         ld a,(user_scr1_high) ;ok
  610.         ret
  611.  
  612. getuser_scr_low_cur
  613. getuser_scr_low_cur_patch=$+1
  614. getuser_scr_low_cur_patchN=0xff&(user_scr0_low^user_scr1_low)
  615.         ld a,(user_scr0_low) ;ok
  616.         ret
  617.  
  618. getuser_scr_high_cur
  619. getuser_scr_high_cur_patch=$+1
  620. getuser_scr_high_cur_patchN=0xff&(user_scr0_high^user_scr1_high)
  621.         ld a,(user_scr0_high) ;ok
  622.         ret
  623.  
  624. changescrpg_current
  625.         ld hl,getuser_scr_low_patch
  626.         ld a,(hl)
  627.         xor getuser_scr_low_patchN
  628.         ld (hl),a
  629.         ld hl,getuser_scr_high_patch
  630.         ld a,(hl)
  631.         xor getuser_scr_high_patchN
  632.         ld (hl),a
  633.         ld hl,getuser_scr_low_cur_patch
  634.         ld a,(hl)
  635.         xor getuser_scr_low_cur_patchN
  636.         ld (hl),a
  637.         ld hl,getuser_scr_high_cur_patch
  638.         ld a,(hl)
  639.         xor getuser_scr_high_cur_patchN
  640.         ld (hl),a
  641.  
  642.         ld a,1
  643. curscrnum=$+1
  644.         xor 0
  645.         ld ($-1),a
  646.         ret
  647.        
  648.         if 1==0
  649. changescrpg
  650.         call changescrpg_current
  651.         ld (curscrnum_int),a
  652.         ret
  653.         endif
  654.  
  655. primgega
  656. ;b=hgt,c=wid (/2)
  657. ;de=gfx
  658. ;hl=scr
  659.         push bc
  660.         call setpgsscr40008000
  661.         call setpggfxc000
  662.         pop bc
  663. primgega0
  664.         push bc
  665.         ld hx,b
  666.         push hl
  667.         ld bc,40
  668. primgegacolumn0
  669.         ld a,(de)
  670.         inc de
  671.         ld (hl),a
  672.         add hl,bc
  673.         dec hx
  674.         jr nz,primgegacolumn0
  675.         pop hl
  676.         ld a,0x9f;0xa0
  677.         cp h
  678.         ld bc,0x4000
  679.         adc hl,bc
  680.         jp pe,primgegacolumn0q ;т яюыютшэх ёыєўрхт
  681. ;8000->ё000 (эрфю 6000) шыш a000->e001 (эрфю 4001)
  682.          inc a
  683.         xor h
  684.         ld h,a
  685. primgegacolumn0q
  686.         pop bc
  687.         dec c
  688.         jr nz,primgega0
  689.         call setpgcodec000
  690.         jp setpgsmain40008000
  691.  
  692. clsega
  693.         call setpgsscr40008000
  694.         ld hl,0x4000
  695.         ld de,0x4001
  696.         ld bc,0x7fff
  697.         ld (hl),l;0
  698.         ldir
  699.         jp setpgsmain40008000
  700.  
  701.         if 1==0;EGA
  702. DrawTile_A_X2Y2DE
  703.         sla     D
  704.         sla     E
  705. DrawTile_A_XYDE
  706.         LD      H,a
  707.         LD      L,0
  708.         srl h
  709.         rr l
  710.         LD      bc,tilegfx
  711.         ADD     HL,bc
  712.         ex de,hl
  713. ;hl=xy
  714.         ld a,h ;x
  715.          add a,4
  716.         ;ld l,l ;y
  717.         ld h,0
  718.         ld b,h
  719.         ld c,l
  720.         add hl,hl
  721.         add hl,hl
  722.         add hl,bc ;*5
  723.          add hl,hl
  724.          add hl,hl
  725.          add hl,hl ;*40
  726.          add hl,hl
  727.          add hl,hl
  728.          add hl,hl
  729.         add a,l
  730.         ld l,a
  731.         ld a,h
  732.         adc a,0x40
  733.         ld h,a
  734.         ld bc,0x1008 ;b=hgt,c=wid (/2)
  735. ;de=gfx
  736. ;hl=scr
  737.         jp primgega
  738.         endif
  739.  
  740.        if EGA
  741. ;DrawSprite_Akeep_DExy
  742.         ;LD     (cursprite),A
  743. DrawSprite_A_DExy
  744. ;A=sprnum
  745. ;DE=xy
  746.         push bc
  747.         push de
  748.         push iy
  749.         add a,a
  750.         ld l,a
  751.         ld h,0xc0
  752.         call setpggfxc000
  753.         ld a,(hl)
  754.         ld ly,a
  755.         inc l
  756.         ld a,(hl)
  757.         ld hy,a
  758.         call setpgsscr40008000
  759.         ld c,e ;y
  760.         ld a,d ;x
  761.         srl a
  762.         add a,sprmaxwid-1
  763.         ld e,a
  764. ;e=x = -(sprmaxwid-1)..159 (ъюфшЁєхЄё  ъръ x+(sprmaxwid-1))
  765. ;c=y = -(sprmaxhgt-1)..199 (ъюфшЁєхЄё  ъръ хёЄ№)
  766.         call prspr
  767.         pop iy
  768.         call setpgcodec000
  769.         call setpgsmain40008000
  770.         pop de
  771.         pop bc
  772.         ret
  773.        endif
  774.  
  775.         include "prspr.asm"
  776.  
  777.         if EGA
  778. gettilebuf
  779.        ds 128
  780.         endif
  781.        if EGA
  782. GetTileToHL_DEXY
  783. ;hl=addr
  784. ;e=Y
  785. ;d=X
  786.         push bc
  787.         push de
  788.         sla d
  789.         sla d
  790.         sla d
  791.         sla e
  792.         sla e
  793.         sla e        
  794.         ld bc,0x1008 ;b=hgt,c=wid (/2)
  795.         jr GetBuf2CxB_DExy_ToHL
  796.        if 1==0
  797.        ld b,12*8
  798. gettilefake0
  799.        ld a,r
  800.        ld (hl),a
  801.        inc hl
  802.        djnz gettilefake0
  803.        pop de
  804.        pop bc
  805.        ret
  806.        endif
  807. GetBuf24x16_DExy
  808. ;e=y
  809. ;d=x
  810.         push bc
  811.         push de
  812.         ld bc,0x100c ;b=hgt,c=wid (/2)
  813.         ld hl,rebuf24x16
  814. GetBuf2CxB_DExy_ToHL
  815.         push hl ;gfx
  816.         ld a,d ;x
  817.         srl a
  818.         srl a
  819.         srl a
  820.          add a,4
  821.         ld l,e ;y
  822.         ld h,0
  823.         ld d,h
  824.         ld e,l
  825.         add hl,hl
  826.         add hl,hl
  827.         add hl,de ;*5
  828.          add hl,hl
  829.          add hl,hl
  830.          add hl,hl ;*40
  831.         add a,l
  832.         ld l,a
  833.         ld a,h
  834.         adc a,0x40
  835.         ld h,a
  836.         pop de ;gfx
  837. ;de=gfx
  838. ;hl=scr
  839.         push bc
  840.         call setpgsscr40008000
  841.         pop bc
  842. getimgega0
  843.         push bc
  844.         ld hx,b
  845.         push hl
  846.         ld bc,40
  847. getimgegacolumn0
  848.         ld a,(hl)
  849.         ld (de),a
  850.         inc de
  851.         add hl,bc
  852.         dec hx
  853.         jr nz,getimgegacolumn0
  854.         pop hl
  855.         ld a,0x9f;0xa0
  856.         cp h
  857.         ld bc,0x4000
  858.         adc hl,bc
  859.         jp pe,getimgegacolumn0q ;т яюыютшэх ёыєўрхт
  860. ;8000->ё000 (эрфю 6000) шыш a000->e001 (эрфю 4001)
  861.          inc a
  862.         xor h
  863.         ld h,a
  864. getimgegacolumn0q
  865.         pop bc
  866.         dec c
  867.         jr nz,getimgega0
  868.         call setpgsmain40008000
  869.         pop de
  870.         pop bc
  871.         ret
  872.  
  873. ReBuf24x16_DExy
  874. ;e=y
  875. ;d=x (width 16 if multiple of 8)
  876.         push bc
  877.         push de
  878.         ld bc,0x1008 ;b=hgt,c=wid (/2)
  879.         ld a,d
  880.         and 7
  881.         jr z,$+4
  882.          ld c,0x0c
  883.         ld a,d ;x
  884.         srl a
  885.         srl a
  886.         srl a
  887.          add a,4
  888.         ld l,e ;y
  889.         ld h,0
  890.         ld d,h
  891.         ld e,l
  892.         add hl,hl
  893.         add hl,hl
  894.         add hl,de ;*5
  895.          add hl,hl
  896.          add hl,hl
  897.          add hl,hl ;*40
  898.         add a,l
  899.         ld l,a
  900.         ld a,h
  901.         adc a,0x40
  902.         ld h,a
  903.         ld de,rebuf24x16
  904. ;de=gfx
  905. ;hl=scr
  906.         call primgega
  907.         pop de
  908.         pop bc
  909.         ret
  910.  
  911. buf24x16
  912.         ds 12*16
  913. buf24x16_2
  914.         ds 12*16
  915. gettilebuf2
  916.         ds 8*16
  917. rebuf24x16
  918.         ds 12*16
  919.        endif
  920.  
  921.        if EGA
  922. DrawSprite16x16_HL_DExy
  923. ;hl=gfx
  924. ;e=y
  925. ;d=x (pixel perfect!)
  926.         push bc
  927.         push de
  928.         ex de,hl
  929.         ld b,0
  930.         ld a,h ;x
  931.         srl a
  932.         ;ld l,l ;y
  933.         ld c,l
  934.         srl a ;x bit 0
  935.         ;ld h,0x40/32/2
  936.         ;jr nc,$+4 ;x bit 0
  937.         ; ld h,0x80/32/2
  938.          ld h,b;0
  939.          rl h
  940.          inc h ;0x40/32/2 шыш 0x80/32/2
  941.         srl a ;x bit 1
  942.          rl h
  943.         add hl,hl
  944.         add hl,hl
  945.         add hl,bc
  946.         add hl,hl
  947.         add hl,hl
  948.         add hl,hl ;y*40+scrbase
  949.          if scrbase&0xff
  950.          add a,scrbase&0xff
  951.          endif
  952. ;a=x/4
  953.         add a,l
  954.         ld l,a
  955.         adc a,h
  956.         sub l
  957.         ld h,a ;hl=scr
  958. ;de=gfx
  959. ;hl=scr
  960.         ld bc,0x1008 ;b=hgt,c=wid (/2)
  961.         call primgega
  962.         pop de
  963.         pop bc
  964.         ret
  965.        endif
  966.  
  967.        if EGA
  968. ClearTile_DExy
  969.         ;ret
  970. ;E=y
  971. ;D=x (width 24 if not multiple of 8)
  972.         push bc
  973.         push de
  974.         ld bc,0x1008 ;b=hgt,c=wid (/2)
  975.         ld a,d ;x
  976.         and 7
  977.         jr z,$+4
  978.          ld c,0x0c ;wid (/2)
  979.         ld a,d
  980.         srl a
  981.         srl a
  982.         srl a
  983.          add a,4
  984.         ld l,e ;y
  985.         ld h,0
  986.         ld d,h
  987.         ld e,l
  988.         add hl,hl
  989.         add hl,hl
  990.         add hl,de ;*5
  991.          add hl,hl
  992.          add hl,hl
  993.          add hl,hl ;*40
  994.         add a,l
  995.         ld l,a
  996.         ld a,h
  997.         adc a,0x40
  998.         ld h,a
  999.         ld de,zeros24x16
  1000. ;de=gfx
  1001. ;hl=scr
  1002.         call primgega
  1003.         pop de
  1004.         pop bc
  1005.         ret
  1006. zeros24x16
  1007.         ds 12*16
  1008.        endif
  1009.  
  1010. readbmphead_pal
  1011.         ld de,bgpush_bmpbuf
  1012.         ld hl,14+2;54+(4*16)
  1013. ;de=buf
  1014. ;hl=size
  1015.         call readstream_file
  1016.         ld de,bgpush_bmpbuf
  1017.         ld hl,(bgpush_bmpbuf+14)
  1018.         dec hl
  1019.         dec hl
  1020. ;de=buf
  1021. ;hl=size
  1022.         call readstream_file
  1023.         ld de,bgpush_bmpbuf
  1024.         ld hl,+(4*16)
  1025. ;de=buf
  1026. ;hl=size
  1027.         call readstream_file
  1028.  
  1029.         ld hl,bgpush_bmpbuf;+54
  1030.         ld ix,pal
  1031.         ld b,16
  1032. recodepal0
  1033.         ld e,(hl)
  1034.         inc hl
  1035.         ld d,(hl)
  1036.         inc hl
  1037.         push hl
  1038.         ld l,(hl) ;e=B, d=G, l=R
  1039.         call readfile_rgbtopal
  1040.         pop hl
  1041.         inc hl
  1042.         inc hl
  1043.         djnz recodepal0
  1044.         ret
  1045.  
  1046.         macro RECOLOR
  1047.         ld a,(de)
  1048.         inc de
  1049.         ld ($+4),a
  1050.         ld a,(trecolor)
  1051.         ld (hl),a
  1052.         endm
  1053. readbmpscr
  1054.         ld hl,0x4000+(199*40)
  1055.         ld b,200
  1056. readbmpscr0
  1057.         push bc
  1058.         push hl
  1059.         ld de,bgpush_bmpbuf
  1060.         ld hl,320/2
  1061. ;de=buf
  1062. ;hl=size
  1063.         push de
  1064.         call readstream_file
  1065.         pop de
  1066.         pop hl
  1067.         push hl
  1068.         ld b,40
  1069. readbmpscr00        
  1070.         RECOLOR
  1071.         ld a,h
  1072.         add a,0x40
  1073.         ld h,a
  1074.         RECOLOR
  1075.         ld a,h
  1076.         add a,0x20-0x40
  1077.         ld h,a
  1078.         RECOLOR
  1079.         ld a,h
  1080.         add a,0x40
  1081.         ld h,a
  1082.         RECOLOR
  1083.         ld a,h
  1084.         sub 0x60
  1085.         ld h,a
  1086.         inc hl
  1087.         djnz readbmpscr00
  1088.         pop hl
  1089.         ld bc,-40
  1090.         add hl,bc
  1091.         pop bc
  1092.         djnz readbmpscr0
  1093.         ret
  1094.  
  1095. readfile_rgbtopal
  1096. ;e=B, d=G, l=R
  1097.         call calcRGBtopal_pp
  1098.         ld (ix+1),a
  1099.         call calcRGBtopal_pp
  1100.         ld (ix),a
  1101.         inc ix
  1102.         inc ix
  1103.         ret
  1104.  
  1105. calcRGBtopal_pp
  1106. ;e=B, d=G, l=R
  1107. ;DDp palette: %grbG11RB(low),%grbG11RB(high), ??oN????N
  1108.         xor a
  1109.         rl e  ;B
  1110.         rra
  1111.         rl l  ;R
  1112.         rra
  1113.         rrca
  1114.         rrca
  1115.         rl d  ;G
  1116.         rra
  1117.         rl e  ;b
  1118.         rra
  1119.         rl l  ;r
  1120.         rra
  1121.         rl d  ;g
  1122.         rra
  1123.         cpl
  1124.         ret
  1125.  
  1126. ;------------------
  1127. ; Keyboard scanning
  1128. ;------------------
  1129. ; from keyboard and s-inkey$
  1130. ; returns 1 or 2 keys in DE, most significant shift first if any
  1131. ; key values 0-39 else 255
  1132.  
  1133. ;; KEY-SCAN
  1134. L028E   LD      L,$2F           ; initial key value
  1135.                                 ; valid values are obtained by subtracting
  1136.                                 ; eight five times.
  1137.         LD      DE,$FFFF        ; a buffer for 2 keys.
  1138.  
  1139.         LD      BC,$FEFE        ; the commencing port address
  1140.                                 ; B holds 11111110 initially and is also
  1141.                                 ; used to count the 8 half-rows
  1142. ;; KEY-LINE
  1143. L0296   IN      A,(C)           ; read the port to A - bits will be reset
  1144.                                 ; if a key is pressed else set.
  1145.         CPL                     ; complement - pressed key-bits are now set
  1146.         AND     $1F             ; apply 00011111 mask to pick up the
  1147.                                 ; relevant set bits.
  1148.  
  1149.         JR      Z,L02AB         ; forward to KEY-DONE if zero and therefore
  1150.                                 ; no keys pressed in row at all.
  1151.  
  1152.         LD      H,A             ; transfer row bits to H
  1153.         LD      A,L             ; load the initial key value to A
  1154.  
  1155. ;; KEY-3KEYS
  1156. L029F   INC     D               ; now test the key buffer
  1157.         RET     NZ              ; if we have collected 2 keys already
  1158.                                 ; then too many so quit.
  1159.  
  1160. ;; KEY-BITS
  1161. L02A1   SUB     $08             ; subtract 8 from the key value
  1162.                                 ; cycling through key values (top = $27)
  1163.                                 ; e.g. 2F>   27>1F>17>0F>07
  1164.                                 ;      2E>   26>1E>16>0E>06
  1165.         SRL     H               ; shift key bits right into carry.
  1166.         JR      NC,L02A1        ; back to KEY-BITS if not pressed
  1167.                                 ; but if pressed we have a value (0-39d)
  1168.  
  1169.         LD      D,E             ; transfer a possible previous key to D
  1170.         LD      E,A             ; transfer the new key to E
  1171.         JR      NZ,L029F        ; back to KEY-3KEYS if there were more
  1172.                                 ; set bits - H was not yet zero.
  1173.  
  1174. ;; KEY-DONE
  1175. L02AB   DEC     L               ; cycles 2F>2E>2D>2C>2B>2A>29>28 for
  1176.                                 ; each half-row.
  1177.         RLC     B               ; form next port address e.g. FEFE > FDFE
  1178.         JR      C,L0296         ; back to KEY-LINE if still more rows to do.
  1179.  
  1180.         LD      A,D             ; now test if D is still FF ?
  1181.         INC     A               ; if it is zero we have at most 1 key
  1182.                                 ; range now $01-$28  (1-40d)
  1183.         RET     Z               ; return if one key or no key.
  1184.  
  1185.         CP      $28             ; is it capsshift (was $27) ?
  1186.         RET     Z               ; return if so.
  1187.  
  1188.         CP      $19             ; is it symbol shift (was $18) ?
  1189.         RET     Z               ; return also
  1190.  
  1191.         LD      A,E             ; now test E
  1192.         LD      E,D             ; but first switch
  1193.         LD      D,A             ; the two keys.
  1194.         CP      $18             ; is it symbol shift ?
  1195.         RET                     ; return (with zero set if it was).
  1196.                                 ; but with symbol shift now in D
  1197.  
  1198.  
  1199.         align 256
  1200. trecolor
  1201. ;%00003210 => %.3...210
  1202.         dup 256
  1203. _3=$&8
  1204. _210=$&7
  1205. _3L=($>>4)&8
  1206. _210L=($>>4)&7
  1207.         db (_3L*0x08) + (_210L*0x01) + (_3*0x10) + (_210*0x08)
  1208.         edup
  1209.  
  1210. bgpush_bmpbuf
  1211.         ds 320
  1212.  
  1213. res_path
  1214.         db "barbaria",0
  1215. ;bmpfilename
  1216. ;        db "solkey.bmp",0
  1217. filename0
  1218.         db "0barbari.bmx",0
  1219. filename1
  1220.         db "1barbari.bmx",0
  1221.  
  1222. loadfile_in_hl
  1223. ;de=шь  Їрщыр
  1224. ;hl=ъєфр уЁєчшь (0xc000)
  1225.         ;SETPG32KHIGH ;тъы■ўшыш ёЄЁрэшЎє A т 0xc000
  1226.         push hl ;ъєфр уЁєчшь
  1227.         OS_OPENHANDLE
  1228.         pop de ;ъєфр уЁєчшь
  1229.         push bc ;b=handle
  1230.         ld hl,0x4000 ;ёЄюы№ъю уЁєчшь (хёыш ёЄюы№ъю хёЄ№ т Їрщых)
  1231.         OS_READHANDLE
  1232.         pop bc ;b=handle
  1233.         OS_CLOSEHANDLE
  1234.         ret;jp setpgmainc000 ;тъы■ўшыш ёЄЁрэшЎє яЁюуЁрьь√ т c000, ъръ с√ыю
  1235.  
  1236.         include "../../_sdk/file.asm"
  1237.  
  1238.         ds 0x3f00-$
  1239.         ds 0x4000-$
  1240.         incbin "screen.scr"
  1241.         ;incbin "slabage/sprdata.bin"
  1242. ;tilegfx=$+0x8000
  1243.         ;incbin "slabage/tiles.bin"
  1244. ;panelgfx=$+0x8000
  1245.         ;incbin "slabage/panel.bin"
  1246.  
  1247.         ds 0x6600-$
  1248. L_6600
  1249.         incbin  "font.bin"
  1250.         ds 0x6880-$
  1251.         include "FILE.ASM"
  1252. end
  1253.  
  1254.         display "End=",end
  1255.         ;display "Free after end=",/d,#c000-end
  1256.         display "Size ",/d,end-begin," bytes"
  1257.         savebin "barbaria.com",begin,end-begin
  1258.         LABELSLIST "../../../us/user.l"
  1259.