Advertisement
Guest User

hello.z80

a guest
Dec 2nd, 2017
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.        .org $5cd2
  2. ; We want a black screen.
  3.  
  4.        ld a,71             ; white ink (7) on black paper (0),
  5.                            ; bright (64).
  6.        ld (23693),a        ; set our screen colours.
  7.        xor a               ; quick way to load accumulator with zero.
  8.        call 8859           ; set permanent border colours.
  9.  
  10. ; Set up the graphics.
  11.  
  12.        ld hl,blocks        ; address of user-defined graphics data.
  13.        ld (23675),hl       ; make UDGs point to it.
  14.  
  15. ; Okay, let's start the game.
  16.  
  17.        call 3503           ; ROM routine - clears screen, opens chan 2.
  18.  
  19. ; Initialise coordinates.
  20.  
  21.        ld hl,21+15*256     ; load hl pair with starting coords.
  22.        ld (plx),hl         ; set player coords.
  23.  
  24.        call basexy         ; set the x and y positions of the player.
  25.        call splayr         ; show player base symbol.
  26.  
  27. ; This is the main loop.
  28.  
  29. mloop  .equ $
  30.  
  31. ; Delete the player.
  32.  
  33.        call basexy         ; set the x and y positions of the player.
  34.        call wspace         ; display space over player.
  35.  
  36. ; Now we've deleted the player we can move him before redisplaying him
  37. ; at his new coordinates.
  38.  
  39.        ld bc,63486         ; keyboard row 1-5/joystick port 2.
  40.        in a,(c)            ; see what keys are pressed.
  41.        rra                 ; outermost bit = key 1.
  42.        push af             ; remember the value.
  43.        call nc,mpl         ; it's being pressed, move left.
  44.        pop af              ; restore accumulator.
  45.        rra                 ; next bit along (value 2) = key 2.
  46.        push af             ; remember the value.
  47.        call nc,mpr         ; being pressed, so move right.
  48.        pop af              ; restore accumulator.
  49.        rra                 ; next bit (value 4) = key 3.
  50.        push af             ; remember the value.
  51.        call nc,mpd         ; being pressed, so move down.
  52.        pop af              ; restore accumulator.
  53.        rra                 ; next bit (value 8) reads key 4.
  54.        call nc,mpu         ; it's being pressed, move up.
  55.  
  56. ; Now he's moved we can redisplay the player.
  57.  
  58.        call basexy         ; set the x and y positions of the player.
  59.        call splayr         ; show player.
  60.  
  61.        halt                ; delay.
  62.  
  63. ; Jump back to beginning of main loop.
  64.  
  65.        jp mloop
  66.  
  67. ; Move player left.
  68.  
  69. mpl:
  70.        ld hl,ply           ; remember, y is the horizontal coord!
  71.        ld a,(hl)           ; what's the current value?
  72.        and a               ; is it zero?
  73.        ret z               ; yes - we can't go any further left.
  74.        dec (hl)            ; subtract 1 from y coordinate.
  75.        ret
  76.  
  77. ; Move player right.
  78.  
  79. mpr:
  80.        ld hl,ply           ; remember, y is the horizontal coord!
  81.        ld a,(hl)           ; what's the current value?
  82.        cp 31               ; is it at the right edge (31)?
  83.        ret z               ; yes - we can't go any further left.
  84.        inc (hl)            ; add 1 to y coordinate.
  85.        ret
  86.  
  87. ; Move player up.
  88.  
  89. mpu:
  90.        ld hl,plx           ; remember, x is the vertical coord!
  91.        ld a,(hl)           ; what's the current value?
  92.        cp 4                ; is it at upper limit (4)?
  93.        ret z               ; yes - we can go no further then.
  94.        dec (hl)            ; subtract 1 from x coordinate.
  95.        ret
  96.  
  97. ; Move player down.
  98.  
  99. mpd:  
  100.        ld hl,plx           ; remember, x is the vertical coord!
  101.        ld a,(hl)           ; what's the current value?
  102.        cp 21               ; is it already at the bottom (21)?
  103.        ret z               ; yes - we can't go down any more.
  104.        inc (hl)            ; add 1 to x coordinate.
  105.        ret
  106.  
  107. ; Set up the x and y coordinates for the player's gunbase position,
  108. ; this routine is called prior to display and deletion of gunbase.
  109.  
  110. basexy:
  111.        ld a,22             ; AT code.
  112.        rst 16
  113.        ld a,(plx)          ; player vertical coord.
  114.        rst 16              ; set vertical position of player.
  115.        ld a,(ply)          ; player's horizontal position.
  116.        rst 16              ; set the horizontal coord.
  117.        ret
  118.  
  119. ; Show player at current print position.
  120.  
  121. splayr:
  122.        ld a,69             ; cyan ink (5) on black paper (0),
  123.                            ; bright (64).
  124.        ld (23695),a        ; set our temporary screen colours.
  125.        ld a,144            ; ASCII code for User Defined Graphic 'A'.
  126.        rst 16              ; draw player.
  127.        ret
  128.  
  129. wspace:
  130.        ld a,71             ; white ink (7) on black paper (0),
  131.                            ; bright (64).
  132.        ld (23695),a        ; set our temporary screen colours.
  133.        ld a,32             ; SPACE character.
  134.        rst 16              ; display space.
  135.        ret
  136.  
  137. plx    .defb 0              ; player's x coordinate.
  138. ply    .defb 0              ; player's y coordinate.
  139.  
  140. ; UDG graphics.
  141.  
  142. blocks .defb 16,16,56,56,124,124,254,254    ; player base.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement