?login_element?

Subversion Repositories NedoOS

Rev

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