?login_element?

Subversion Repositories NedoOS

Rev

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

  1.         DEVICE ZXSPECTRUM128
  2.         include "../../_sdk/sys_h.asm"
  3. ;│┐│-│-TПTВTМ:
  4. ;0x0100..0x3eff - subroutines
  5. ;0x3f00..0x3fff - stack
  6. ;0x4000..0x7fff - VRAM
  7. ;0x8000..0xbfff - game/paged for screen
  8. ;0xc000..0xffff - scratchpad RAM/paged for screen
  9.  
  10. INTSTACK=0x0100;0x3f00
  11. STACK=INTSTACK-64
  12.  
  13.         org PROGSTART
  14. begin
  15.         ld sp,STACK
  16.         OS_HIDEFROMPARENT
  17.  
  18.         ld e,0 ;EGA
  19.         OS_SETGFX ;e=0:EGA, e=2:MC, e=3:6912, e=6:text ;+SET FOCUS ;e=-1: disable gfx (out: e=old gfxmode)
  20.  
  21.         ld e,0
  22.         OS_SETSCREEN
  23.         ld e,0 ;color byte
  24.         OS_CLS
  25.         ld e,1
  26.         OS_SETSCREEN
  27.         ld e,0 ;color byte
  28.         OS_CLS
  29.  
  30.         OS_GETMAINPAGES
  31. ;dehl=pages in 0000,4000,8000,c000
  32.         ld a,e
  33.         ld (pgcode4000),a
  34.         ld a,h
  35.         ld (pgcode8000),a
  36.         ld a,l
  37.         ld (pgcodec000),a
  38.  
  39.         ld a,e
  40.         ld hl,MUZHOOK
  41.         OS_SETMUSIC
  42.  
  43.         OS_NEWPAGE
  44.         ld a,e
  45.         ld (pgtiles),a
  46.  
  47.         ld de,pal
  48.         OS_SETPAL
  49.  
  50.         call swapimer
  51.  
  52.         jp GO
  53.  
  54. pal
  55. ;DDp palette: %grbG11RB(low),%grbG11RB(high), inverted
  56.                    ;bg=1  ;зел  ;салат  ;син  ;небо  ;крас  ;ярко-голуб
  57.         dw 0xffff,0xffff,0xcfcf,0x4f4f,0xdede,0xcccc,0xfdfd,0xcece
  58.         dw 0xbdbd,0xacac,0x2d2d,0x2c2c,0xefef,0x4e4e,0xecec,0x0c0c
  59.            ;флаг  ;роз   ;древко ;лим  ;тзел  ;???    ;road
  60. timer
  61.         dw 0
  62. oldtimer
  63.         dw 0
  64. quiter
  65.         halt
  66.         ;ld a,(pgmuznum)
  67.         ;SETPG32KHIGH
  68.         ;call muz
  69.         call shutay
  70.         call swapimer
  71.         QUIT
  72.  
  73.  
  74. swapimer
  75.         di
  76.         ld de,0x0038
  77.         ld hl,oldimer
  78.         ld bc,3
  79. swapimer0
  80.         ld a,(de)
  81.         ldi ;[oldimer] -> [0x0038]
  82.         dec hl
  83.         ld (hl),a ;[0x0038] -> [oldimer]
  84.         inc hl
  85.         jp pe,swapimer0
  86.         ei
  87.         ret
  88. oldimer
  89.         jp on_int ;заменится на код из 0x0038
  90.         jp 0x0038+3
  91.  
  92. on_int
  93. ;restore stack with de
  94.         ld (on_int_hl),hl
  95.         ld (on_int_sp),sp
  96.         pop hl
  97.         ld (on_int_sp2),sp
  98.         ld (on_int_jp),hl
  99.        
  100.         ld sp,INTSTACK
  101.        
  102.         push af
  103.         push bc
  104.         push de
  105.        
  106. ;imer_curscreen_value=$+1
  107.          ;ld a,0
  108.          ;ld bc,0x7ffd
  109.          ;out (c),a
  110.  
  111.         ex de,hl;ld hl,0
  112. on_int_sp=$+1
  113.         ld (0),hl ;восстановили запоротый стек
  114.        
  115.         push ix
  116.         push iy
  117.         ex af,af' ;'
  118.         exx
  119.         push af
  120.         push bc
  121.         push de
  122.         push hl
  123. ;curpalette=$+1
  124.         ;ld de,wolfpal
  125.         ;OS_SETPAL
  126.  
  127. curscrnum_int=$+1
  128.         ld e,0
  129.         OS_SETSCREEN
  130.        
  131. ;pgmuznum=$+1
  132. ;        ld a,0
  133. ;        SETPG32KHIGH
  134.        
  135.          call oldimer
  136.        
  137.         GET_KEY
  138.         ld (curkey),a
  139.         if 1==0
  140.         ld a,(curpg32klow) ;ok
  141.         push af
  142.         ld a,(curpg32khigh) ;ok
  143.         push af
  144.         call setpgcode8000c000
  145.         call MUZHOOK ;muzplay
  146.         pop af
  147.         SETPG32KHIGH
  148.         pop af
  149.         SETPG32KLOW
  150. ;pgc000=$+1
  151. ;        ld a,0
  152. ;        SETPG32KHIGH
  153.         endif
  154.        
  155.         pop hl
  156.         pop de
  157.         pop bc
  158.         pop af
  159.         exx
  160.         ex af,af' ;'
  161.         pop iy
  162.         pop ix
  163.        
  164.         ld hl,(timer)
  165.         inc hl
  166.         ld (timer),hl
  167.  
  168.         pop de
  169.         pop bc
  170.         pop af
  171.        
  172. on_int_hl=$+1
  173.         ld hl,0
  174. on_int_sp2=$+1
  175.         ld sp,0
  176.         ei
  177. on_int_jp=$+1
  178.         jp 0
  179.  
  180. setpgtiles4000
  181. pgtiles=$+1
  182.         ld a,0
  183.         SETPG16K
  184.         ret
  185.  
  186. setpgtiles8000
  187.         ld a,(pgtiles)
  188.         SETPG32KLOW
  189.         ret
  190.  
  191. setpgcode4000
  192. pgcode4000=$+1
  193.         ld a,0
  194.         SETPG16K
  195.         ret
  196.  
  197. setpgcode8000c000
  198. pgcode8000=$+1
  199.         ld a,0
  200.         SETPG32KLOW
  201. pgcodec000=$+1
  202.         ld a,0
  203.         SETPG32KHIGH
  204.         ret
  205.  
  206. gentiles
  207.         ;call setpgtiles4000
  208.  
  209.         ld l,0
  210. gentiles0
  211.         ld h,0x20
  212.         ld d,0x40/8
  213.         ld a,l
  214.         add a,a
  215.         rl d
  216.         add a,a
  217.         rl d
  218.         add a,a
  219.         rl d
  220.         ld e,a
  221.         dup 8
  222.         ld a,(de)
  223.          ld (hl),-1;0
  224.          rla
  225.          rr (hl)
  226.          rla
  227.          rr (hl)
  228.         set 3,h
  229.          ld (hl),-1;0
  230.          rla
  231.          rr (hl)
  232.          rla
  233.          rr (hl)
  234.         res 3,h
  235.         set 4,h
  236.          ld (hl),-1;0
  237.          rla
  238.          rr (hl)
  239.          rla
  240.          rr (hl)
  241.         set 3,h
  242.          ld (hl),-1;0
  243.          rla
  244.          rr (hl)
  245.          rla
  246.          rr (hl)        
  247.         res 3,h
  248.         res 4,h
  249.         inc e
  250.         inc h
  251.         edup
  252.        
  253.         ld h,0x20
  254. gentiles0atr0
  255.         ld d,0x60/8
  256.         ld a,l
  257.         add a,a
  258.         rl d
  259.         add a,a
  260.         rl d
  261.         add a,a
  262.         rl d
  263.         xor h
  264.         and 0xf8
  265.         xor h
  266.         ld e,a
  267.         ld a,(de) ;IiiiPppp
  268.         rra
  269.         rra
  270.         rra
  271.         rra
  272.         call geninkbyte
  273.         ld c,a
  274.         ld a,(de)
  275.         call geninkbyte
  276.         ld b,a
  277.         ;ld bc,0b0000000011111111
  278. ;c=ink (IIiiiiii)
  279. ;b=paper (PPpppppp)
  280.         ld a,(hl)
  281.         rla
  282.         sbc a,a
  283.         ld e,a ;RRRRRRRR
  284.         ld a,(hl)
  285.         rla
  286.         rla
  287.         sbc a,a ;LLLLLLLL
  288.         xor e
  289.         and 0b01000111
  290.         xor e
  291.         ld d,a
  292. ;a=%RLRRRLLL        
  293.         and c ;ink (IIiiiiii)
  294.         ld e,a
  295.         ld a,d
  296.         cpl
  297.         and b ;paper (PPpppppp)
  298.         or e
  299.         ld (hl),a
  300.         inc h
  301.         bit 6,h
  302.         jr z,gentiles0atr0
  303.        
  304.         inc l
  305.         jp nz,gentiles0
  306.  
  307.         ;call setpgcode4000
  308. ;gen sprites
  309. ;The Sprite Pattern Table occupies 2 KB of VRAM from 3800H to 3FFFH. It contains two hundred and fifty-six 8x8 pixel patterns, numbered from 0 to 255.
  310. ;AC
  311. ;BD
  312. ;8 bytes block A
  313. ;8 bytes block B
  314. ;8 bytes block C
  315. ;8 bytes block D
  316. ;pattern 0..3 = pattern 0, pattern 4..7 = pattern 1...
  317. ;(decoded to 128 bytes per pattern in pgtiles)
  318.         call setpgtiles8000
  319.  
  320.         ld hl,0x4000+0x1800
  321.         ld de,0x8000
  322.  
  323.         ld b,2*64 ;halfsprites
  324. genspr0
  325.         push bc
  326.        
  327.         ld ix,0b0100000010000000
  328.         ld a,b
  329.         cp 2*64-7
  330.         jr nc,$+2+4
  331.         ld ix,0b0100011110111000
  332.        
  333.         ld c,4
  334. genspr0subcolumns
  335.         push hl
  336.         ld b,16
  337. genspr00
  338. ;colors:
  339. ;0b1110 - road  (and 0b1111)
  340. ;0b0001?- shadow
  341. ;0b0110 -our car(and 0b0111)
  342. ;0b0000 - enemy (and 0b0000)
  343.         ld a,0xff
  344.         rlc (hl)
  345.         jr nc,$+4
  346.         xor hx;0b01000000 ;change left pixel
  347.         rlc (hl)
  348.         jr nc,$+4
  349.         xor lx;0b10000000 ;change right pixel
  350.         ld (de),a
  351.         inc hl
  352.         inc de
  353.         djnz genspr00
  354.         pop hl
  355.         dec c
  356.         jr nz,genspr0subcolumns
  357.         ld bc,16
  358.         add hl,bc ;next column (halfsprite)
  359.         pop bc
  360.         djnz genspr0
  361.        
  362.         call setpgcode8000c000
  363.  
  364.         ret
  365.  
  366. geninkbyte
  367. ;a=????Iiii
  368. ;out: a=IIiiiiii
  369.         ld b,a
  370.         rla
  371.         rla
  372.         rla
  373.         xor b
  374.         and 0b01111000
  375.         xor b ;?Iiiiiii
  376.         rla   ;Iiiiiii?
  377.         rlca  ;iiiiii?I
  378.         rra   ;Iiiiiii? (CY=I)
  379.         rra
  380.         ret
  381.  
  382. ;0 чёрный
  383. ;1 чёрный
  384. ;2 тёмно-зелёный с синевой
  385. ;3 ярко-зелёный
  386. ;4 синий
  387. ;5 фиолетовый
  388. ;6 красный
  389. ;7 тёмно-голубой
  390. ;8 ярко-красный
  391. ;9 розовый
  392. ;a ярко-жёлтый
  393. ;b лимонный
  394. ;c тёмно-зелёный
  395. ;d ярко-голубой
  396. ;e серый (дорога)
  397. ;f белый
  398.         MACRO SPRCOLUMN
  399.        dup 15
  400.         ld a,(de)
  401.         and (hl)
  402.         ld (hl),a;0xaa
  403.         inc e
  404.         add hl,bc ;40
  405.        edup
  406.         ld a,(de)
  407.         and (hl)
  408.         ld (hl),a;0xaa
  409.         inc e
  410.         endm
  411.  
  412.         macro NEXTCOLUMN
  413.         bit 6,h
  414.         set 6,h
  415.         jr z,$+2+4+2+2+1
  416.         ld a,h
  417.         xor 0x60
  418.         ld h,a
  419.         and 0x20
  420.         jr nz,$+3
  421.         inc hl
  422.         endm
  423.  
  424. ;The Name Table occupies 768 bytes of VRAM from 1800H to 1AFFH (!!!3800!!!), the same as in 32x24 Text Mode. The table is initialized with the character code sequence 0 to 255 repeated three times and is then left untouched, in this mode it is the Character Pattern Table which is modified during normal operation.
  425.  
  426. ;The Character Pattern Table occupies 6 KB of VRAM from 0000H to 17FFH. While its structure is the same as in the text modes it does not contain a character set but is initialized to all 0 pixels. The first 2 KB of the Character Pattern Table is addressed by the character codes from the first third of the Name Table, the second 2 KB by the central third of the Name Table and the last 2 KB by the final third of the Name Table. Because of the sequential pattern in the Name Table the entire Character Pattern Table is read out linearly during a video frame.
  427.  
  428. emulVDP
  429.         push bc
  430.         push de
  431.         push hl
  432. curkey=$+1
  433.         ld a,0
  434.         cp key_esc
  435.         jp z,quiter
  436. ;wait for screen change
  437. EmulatePPU_waitforscreenready0
  438.         ld hl,(timer)
  439. endoflastredrawtimer=$+1
  440.         ld de,0
  441.         or a
  442.         sbc hl,de
  443.         jr z,EmulatePPU_waitforscreenready0
  444.  
  445.         ;ld a,(user_scr0_low) ;ok
  446.         ;SETPG32KLOW
  447.         ;ld a,(user_scr0_high) ;ok
  448.         ;SETPG32KHIGH
  449.         call setpgsscr8000c000
  450. ;TODO draw only changed tiles
  451.         ld de,0x4000+0x3800 ;tilemap
  452.         ld hl,0x8000+4 ;screen
  453.         ;ld hx,0x40 ;tile gfx base
  454.         ld b,24
  455. emulVDPtiles0
  456.         push bc
  457.         ld a,24
  458.         sub b
  459.         rra
  460.         rra
  461.         rra
  462.         and 3
  463.         add a,0x40/8
  464.         ld hx,a ;tile gfx base
  465.         push hl
  466.         ld b,32
  467. emulVDPtiles1
  468.         ld a,(de) ;tile
  469.         push bc
  470.         push de
  471.         push hl
  472.        
  473.         ld bc,40
  474.        
  475.         ld e,a
  476.        
  477.         push hl
  478.        
  479.         ld d,0x20
  480.         push hl
  481.         dup 7
  482.         ld a,(de)
  483.         ld (hl),a
  484.         inc d
  485.         add hl,bc
  486.         edup
  487.         ld a,(de)
  488.         ld (hl),a
  489.         pop hl
  490.        
  491.         set 6,h
  492.        
  493.         ld d,0x28
  494.         dup 7
  495.         ld a,(de)
  496.         ld (hl),a
  497.         inc d
  498.         add hl,bc
  499.         edup
  500.         ld a,(de)
  501.         ld (hl),a
  502.        
  503.         pop hl
  504.         set 5,h
  505.        
  506.         ld d,0x30
  507.         push hl
  508.         dup 7
  509.         ld a,(de)
  510.         ld (hl),a
  511.         inc d
  512.         add hl,bc
  513.         edup
  514.         ld a,(de)
  515.         ld (hl),a
  516.         pop hl
  517.        
  518.         set 6,h
  519.        
  520.         ld d,0x38
  521.         dup 7
  522.         ld a,(de)
  523.         ld (hl),a
  524.         inc d
  525.         add hl,bc
  526.         edup
  527.         ld a,(de)
  528.         ld (hl),a
  529.        
  530.         pop hl
  531.         pop de
  532.         pop bc
  533.         inc de
  534.         inc hl
  535.         dec b
  536.         jp nz,emulVDPtiles1
  537.         pop hl
  538.         ld bc,40*8
  539.         add hl,bc
  540.         pop bc
  541.         dec b
  542.         jp nz,emulVDPtiles0
  543.        
  544. ;The Sprite Attribute Table occupies 128 bytes of VRAM from 1B00H to 1B7FH /3b00/. The table contains thirty-two four byte blocks, one for each sprite. The first block controls sprite 0 (the "top" sprite), the ;second controls sprite 1 and so on to sprite 31. The format of each block is as below:
  545.  
  546. ;   Vertical Position   Byte 0
  547. ;   Horizontal Position Byte 1
  548. ;   Pattern Number      Byte 2
  549. ;   EC  0       0       0       Colour Code(bits 3..0)  Byte 3
  550. ;In Byte 3, the Early Clock bit is normally 0 but will shift the sprite thirty-two pixels to the left when set to 1. This is so that sprites can slide in from the left of the screen, there being no spare coordinates in the horizontal direction.    
  551.  
  552. ;The Sprite Pattern Table occupies 2 KB of VRAM from 3800H to 3FFFH /1800/. It contains two hundred and fifty-six 8x8 pixel patterns, numbered from 0 to 255.
  553. ;AC
  554. ;BD
  555. ;8 bytes block A
  556. ;8 bytes block B
  557. ;8 bytes block C
  558. ;8 bytes block D
  559. ;for 16x16 sprites: pattern 0..3 = pattern 0, pattern 4..7 = pattern 1...
  560.         ld hl,0x4000+0x3B7F
  561. emulVDPsprites0
  562.         ld a,(hl) ;d3..0=colour code, d7=early clock (x-=32)
  563.         dec l
  564.         ld d,(hl) ;pattern number
  565.         dec l
  566.         ld c,(hl) ;x
  567.         dec l
  568.         ld b,(hl) ;y
  569.         or a
  570.         jp z,emulVDPsprites0_skip ;colour 0
  571.           inc b
  572.         ld a,b
  573.         cp 0xd1+1 ;???
  574.         jp nc,emulVDPsprites0_skip
  575.           inc c
  576.          srl c
  577.          srl c
  578.          srl c
  579.          ld a,c
  580.          add a,4
  581.          ld c,a
  582.          ;srl b
  583.          ;srl b
  584.          ;srl b
  585.          ld a,b
  586.          cp 24 *8
  587.          jp nc,emulVDPsprites0_skip
  588.         push hl
  589. ;bc=yx
  590.         ld a,c ;x
  591.         ld l,b ;y
  592.         ld h,0
  593.         ld b,h
  594.         ld c,l
  595.         add hl,hl
  596.         add hl,hl
  597.         add hl,bc ;*5
  598.          add hl,hl
  599.          add hl,hl
  600.          add hl,hl ;*40
  601.          ;add hl,hl
  602.          ;add hl,hl
  603.          ;add hl,hl
  604.         add a,l
  605.         ld l,a
  606.         ld a,h
  607.         adc a,0x80
  608.         ld h,a
  609.  
  610.         call setpgtiles4000
  611.  
  612.         ld bc,40
  613. ;d=pattern number
  614.         ld e,0
  615.          srl d
  616.          srl d ;pattern 0..3 = pattern 0, pattern 4..7 = pattern 1...
  617.         srl d
  618.         rr e
  619.         set 6,d ;ld d,0x40;+0x38 ;sprites
  620.         dup 8-1
  621.         push hl
  622.         SPRCOLUMN
  623.         pop hl
  624.         NEXTCOLUMN
  625.         edup
  626.         SPRCOLUMN
  627.        
  628.         call setpgcode4000
  629.        
  630.         pop hl
  631. emulVDPsprites0_skip
  632.         dec l
  633.         jp p,emulVDPsprites0
  634.  
  635.         ld hl,(timer)
  636.         ld (endoflastredrawtimer),hl
  637.         call changescrpg
  638.        
  639.         call setpgcode8000c000
  640.         pop hl
  641.         pop de
  642.         pop bc
  643.         ret
  644.  
  645. pause
  646.         push af
  647.         push bc
  648.         push de
  649.         push hl
  650.         exx
  651.         ex af,af' ;'
  652.         push af
  653.         push bc
  654.         push de
  655.         push hl
  656.         push ix
  657.         push iy
  658.         halt ;YIELD
  659.         pop iy
  660.         pop ix
  661.         pop hl
  662.         pop de
  663.         pop bc
  664.         pop af
  665.         ex af,af' ;'
  666.         exx
  667.         pop hl
  668.         pop de
  669.         pop bc
  670.         pop af
  671.         ret
  672.  
  673. muztest
  674.         ei
  675.         halt
  676.         call L_9266 ;music player
  677.         jr muztest
  678.  
  679. L0020
  680. ;DCOMPR
  681. ;Address  : #0020
  682. ;Function : Compares HL with DE
  683. ;Input    : HL, DE
  684. ;Output   : Z-flag set if HL and DE are equal. C-flag set if HL is less than DE.
  685. ;Registers: AF
  686.         push hl
  687.         or a
  688.         sbc hl,de
  689.         pop hl
  690.         ret
  691.  
  692. L003D
  693. ;???
  694. ;INIFNK
  695. ;Address  : #003E
  696. ;Function : Initialises the contents of the function keys
  697. ;Registers: All
  698.         ret
  699.  
  700. L0047        
  701. ;WRTVDP
  702. ;Address  : #0047
  703. ;Function : write data in the VDP-register
  704. ;Input    : B  - data to write
  705. ;           C  - number of the register
  706. ;Registers: AF, BC
  707. ;can spoil bc
  708. ;TODO
  709.         ret
  710.        
  711. L004D
  712. ;WRTVRM
  713. ;Address  : #004D
  714. ;Function : Writes data in VRAM
  715. ;Input    : HL - address write (0..3fff)
  716. ;           A  - value write
  717. ;Registers: AF
  718.         push hl
  719.         set 6,h
  720.         ld (hl),a
  721.         pop hl
  722.         ret
  723.        
  724. L0056
  725. ;FILVRM
  726. ;Address  : #0056
  727. ;Function : fill VRAM with value
  728. ;Input    : A  - data byte
  729. ;           BC - length of the area to be written
  730. ;           HL - start address
  731. ;Registers: AF, BC
  732.         push bc
  733.         push hl
  734.         set 6,h
  735. FILVRM0
  736.         ld (hl),a
  737.         cpi
  738.         jp pe,FILVRM0
  739.         pop hl
  740.         pop bc ;unneeded?
  741.         ret
  742.  
  743. L005C        
  744. ;LDIRVM
  745. ;Address  : #005C
  746. ;Function : Block transfer to VRAM from memory
  747. ;Input    : BC - blocklength
  748. ;           DE - Start address of VRAM
  749. ;           HL - Start address of memory
  750. ;Registers: All
  751.         push bc
  752.         push de
  753.         push hl
  754.         set 6,d
  755.         ldir
  756.         pop hl
  757.         pop de
  758.         pop bc ;unneeded?
  759.         ret
  760.        
  761. L00D5
  762. ;GTSTCK
  763. ;Address  : #00D5
  764. ;Function : Returns the joystick status
  765. ;Input    : A  - Joystick number to test (0 = cursors, 1 = port 1, 2 = port 2)
  766. ;Output   : A  - Direction (1 up, 3 right, 5 down, 7 left)
  767. ;Registers: All
  768.         or a
  769.         jp nz,GTSTCK2
  770.          push bc
  771.          ld a,0x7f
  772.          in a,(0xfe)
  773.          bit 2,a ;'M'
  774.          jr nz,nomuzoff
  775.          ld a,(muzoff)
  776.          xor 0x80
  777.          ld (muzoff),a
  778.          push de
  779.          push hl
  780.          push ix
  781.         LD      A,#07
  782.         CALL    L0096
  783.         AND     #C0
  784.         OR      #38
  785.         LD      E,A
  786.         LD      A,#07
  787.         CALL    L0093
  788.         LD      E,#0e
  789.         LD      A,#08
  790.         CALL    L0093
  791.         LD      A,#0a
  792.         CALL    L0093
  793.         halt
  794.         halt
  795.         halt
  796.          pop ix
  797.          pop hl
  798.          pop de
  799. nomuzoff
  800.          ld a,0xfe
  801.          in a,(0xfe)
  802.          bit 0,a
  803.          jr nz,nocheat
  804.          ld a,0xfd
  805.          in a,(0xfe)
  806.          bit 3,a
  807.          jr nz,nofuelcheat
  808.          xor a
  809.          ;ld (fuelcheat1),a
  810.          ld b,a
  811.          ld c,a
  812.          ld (fuelcheat2),bc
  813. nofuelcheat
  814.          ld a,0xbf
  815.          in a,(0xfe)
  816.          bit 1,a
  817.          jr nz,nolivescheat
  818.          xor a
  819.          ld (livescheat),a
  820. nolivescheat
  821.          ld a,0xfb
  822.          in a,(0xfe)
  823.          bit 2,a
  824.          jr nz,noenemycheat
  825.          ld a,0xc9
  826.          ld (EnemyCollision),a
  827. noenemycheat
  828. nocheat
  829.         ld a,0xef
  830.         in a,(0xfe)
  831.          ld bc,0xdffe
  832.          in b,(c)
  833.          bit 0,b ;'p'
  834.          jr nz,$+4
  835.          res 3,a
  836.          bit 1,b ;'o'
  837.          jr nz,$+4
  838.          res 4,a
  839.          ld bc,0xfbfe
  840.          in b,(c)
  841.          bit 0,b ;'q'
  842.          jr nz,$+4
  843.          res 1,a
  844.          ld bc,0xfdfe
  845.          in b,(c)
  846.          bit 0,b ;'a'
  847.          jr nz,$+4
  848.          res 2,a
  849.          pop bc
  850.         rra
  851.         and 0x0f
  852.         ld hl,tstick
  853.         add a,l
  854.         ld l,a
  855.         jr nc,$+3
  856.         inc h
  857.         ld a,(hl)
  858.         ret
  859. tstick
  860.         db 0,0,0,0
  861.         db 0,6,8,7
  862.         db 0,4,2,3
  863.         db 0,5,1,0
  864. GTSTCK2
  865.         xor a
  866.         ret
  867.  
  868. L00D8
  869. ;GTTRIG
  870. ;Address  : #00D8
  871. ;Function : Returns current trigger status
  872. ;Input    : A  - trigger button to test
  873. ;           0 = spacebar
  874. ;           1 = port 1, button A
  875. ;           2 = port 2, button A
  876. ;           3 = port 1, button B
  877. ;           4 = port 2, button B
  878. ;Output   : A  - #00 trigger button not pressed
  879. ;                #FF trigger button pressed
  880. ;Registers: AF
  881.         or a
  882.         jr nz,GTTRIG2
  883.          ld a,0x7f
  884.          in a,(0xfe)
  885.          cpl
  886.          rra
  887.          jr c,gttrigok
  888.         ld a,0xef
  889.         in a,(0xfe)
  890.         cpl
  891.         rra
  892. gttrigok
  893.         sbc a,a
  894.         ret
  895. GTTRIG2
  896.         xor a
  897.         ret
  898.  
  899. setpgsscr8000c000
  900.         call getuser_scr_low
  901.         SETPG32KLOW
  902.         call getuser_scr_high
  903.         SETPG32KHIGH
  904.         ret
  905.  
  906. getuser_scr_low
  907. getuser_scr_low_patch=$+1
  908. getuser_scr_low_patchN=0xff&(user_scr0_low^user_scr1_low)
  909.         ld a,(user_scr1_low) ;ok
  910.         ret
  911.  
  912. getuser_scr_high
  913. getuser_scr_high_patch=$+1
  914. getuser_scr_high_patchN=0xff&(user_scr0_high^user_scr1_high)
  915.         ld a,(user_scr1_high) ;ok
  916.         ret
  917.  
  918. changescrpg
  919.         ld hl,getuser_scr_low_patch
  920.         ld a,(hl)
  921.         xor getuser_scr_low_patchN
  922.         ld (hl),a
  923.         ld hl,getuser_scr_high_patch
  924.         ld a,(hl)
  925.         xor getuser_scr_high_patchN
  926.         ld (hl),a
  927.         ld a,(curscrnum_int)
  928.         xor 1
  929.         ld (curscrnum_int),a
  930.         ret
  931.  
  932.         display $
  933.         ds 0x2000-$
  934.  
  935.         include "HWC1.ASM"
  936.  
  937. ;>=0x4000 for system INT
  938. MUZHOOK;#FD9F ;$FD9F is one of the interrupt service routine hooks (HTIMI) and it's called every 50/60 times per second by the BIOS.
  939.         ret
  940.         ret
  941.         ret
  942.  
  943. L0090
  944. ;GICINI
  945. ;Address  : #0090
  946. ;Function : Initialises PSG and sets initial value for the PLAY statement
  947. ;Registers: All
  948. shutay
  949.         push bc
  950.         push de
  951.         ld de,0xe00
  952. shutay0
  953.         dec d
  954.         ld bc,0xfffd
  955.         out (c),d
  956.         ld b,0xbf
  957.         out (c),e
  958.         jr nz,shutay0
  959.         pop de
  960.         pop bc
  961.         ret
  962.        
  963. L0093
  964. ;WRTPSG
  965. ;Address  : #0093
  966. ;Function : Writes data to PSG-register
  967. ;Input    : A  - PSG register number
  968. ;           E  - data write
  969.         push bc
  970.         ld bc,0xfffd
  971.         out (c),a
  972.         ld b,0xbf
  973.         out (c),e
  974.         pop bc
  975.         ret
  976.        
  977. L0096
  978. ;RDPSG
  979. ;Address  : #0096
  980. ;Function : Reads value from PSG-register
  981. ;Input    : A  - PSG-register read
  982. ;Output   : A  - value read
  983.         push bc
  984.         ld bc,0xfffd
  985.         out (c),a
  986.         in a,(c)
  987.         pop bc
  988.         ret
  989.  
  990. end
  991.  
  992.         display "End=",end
  993.         ;display "Free after end=",/d,#c000-end
  994.         display "Size ",/d,end-begin," bytes"
  995.         savebin "hws.com",begin,end-begin
  996.         LABELSLIST "../../../us/user.l"
  997.