home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 82 / asm / source / ash / bounce.asm < prev    next >
Encoding:
Assembly Source File  |  2001-07-01  |  3.0 KB  |  117 lines

  1. ;                    *** Bounce ver 1.1 ***
  2. ; This is the TI82 version of the zshell program called
  3. ; bounce made by Dan Eble. The program works in exactly
  4. ; the same way as the zshell program, the only difference
  5. ; is that adresses has been changed to TI82, and that the
  6. ; pixel rutines now uses the display controller.
  7. ;
  8. ; This program uses the graphics rutines from Graph.inc
  9. ;
  10. ; Dines Justesen, 1997
  11.  
  12. #INCLUDE "ti82.h"
  13. #INCLUDE "graph.h"
  14.  
  15. ;────────────────────────────────────────────────────────────────────────────
  16. ; Program data
  17. ;────────────────────────────────────────────────────────────────────────────
  18.  
  19. Y  =TEXT_MEM   ; y position
  20. X  =TEXT_MEM+1 ; x position
  21. DY =TEXT_MEM+2 ; y velocity
  22. DX =TEXT_MEM+3 ; x velocity
  23.  
  24. .ORG START_ADDR
  25. .DB "Bounce ver 1.1 by Dan Eble",0
  26.         GRAPH_START
  27. Launch:
  28.         SUB A
  29.         LD (Y), A       ; set initial values
  30.         INC A
  31.         LD (X), A
  32.         INC A
  33.         LD (DX), A
  34.         LD A, 11
  35.         LD (DY), A
  36.  
  37. Fly:
  38.         LD BC, (Y)      ; load ball coordinates into BC
  39.         PUSH BC
  40.         CALL Point_on   ; display the square ball
  41.         DEC B
  42.         CALL Point_on
  43.         INC C
  44.         CALL Point_on
  45.         INC B
  46.         CALL Point_on
  47.         CALL Delay      ; wait a while
  48.         LD HL, DY
  49.         LD A, (HL)
  50.         DEC A           ; decrease y velocity (accelerate toward the ground)
  51.         LD (HL), A
  52.         LD A, (Y)
  53.         ADD A, (hl)     ; change y position
  54.         BIT 7, A        ; if y>=0, don't bounce
  55.         JR Z, NoBounce
  56.         LD A, (HL)      ; if y<0, don't bounce
  57.         NEG             ; make the downward velocity negative (point it up)
  58.         LD B, A         ; multiply it by 7/8 (don't bounce as high)
  59.         SLA A
  60.         ADD A, B
  61.         SLA A
  62.         ADD A, B
  63.         SRL A
  64.         SRL A
  65.         SRL A
  66.         LD (HL), A
  67.         SUB A
  68. NoBounce:
  69.         LD (Y), A
  70.         LD HL, DX       ; change x position
  71.         LD A, (X)
  72.         ADD A, (HL)
  73.         LD (X), A
  74.         POP BC
  75.         CP 96           ; if x>=96 ... (continued below)
  76.         PUSH AF
  77.         CALL Point_off       ; first erase ball
  78.         DEC B
  79.         CALL Point_off
  80.         INC C
  81.         CALL Point_off
  82.         INC B
  83.         CALL Point_off
  84.         POP AF          ; (continued from above) ... launch ball again
  85.         JR NC, Launch
  86.  
  87.         CALL GET_KEY
  88.         CP $37
  89.         JR  NZ,Fly  ; otherwise, keep ball in flight
  90.         RET
  91.  
  92. ;────────────────────────────────────────────────────────────────────────────
  93. ; Graphics rutines
  94. ;────────────────────────────────────────────────────────────────────────────
  95.  
  96. #INCLUDE "graph.inc"
  97.  
  98. ;────────────────────────────────────────────────────────────────────────────
  99. ; Produce delay
  100. ;────────────────────────────────────────────────────────────────────────────
  101.  
  102. Delay:
  103.         PUSH AF
  104.         PUSH BC
  105.         LD BC, $2000
  106. DelayLoop:
  107.         DEC BC
  108.         LD A, B
  109.         OR C
  110.         JR NZ, DelayLoop
  111.         POP BC
  112.         POP AF
  113.         RET
  114.  
  115. .END
  116.  
  117.