home *** CD-ROM | disk | FTP | other *** search
/ ticalc.org / ticalc_org_rev_b.iso / archives / 83 / asm / source / ashell83 / mrhappy.z80 < prev    next >
Encoding:
Text File  |  2001-07-01  |  4.9 KB  |  236 lines

  1. .NOLIST
  2. #define equ .equ
  3. #define EQU .equ
  4. #define end .end
  5. #include "ti83asm.inc"
  6. #include "tokens.inc"
  7. .LIST
  8. #DEFINE BOXX 8265h
  9. #DEFINE BOXY 8266h
  10.  
  11. .org 9327h
  12.  
  13.     nop                 ;these 2 lines identify the program
  14.     jr      prog_start  ;as AShell-compatable
  15.     .dw     $0000       ;Version of table
  16.     .dw     name       ;Points to the program description
  17.     .dw     $0000 
  18.  
  19. BEGIN:
  20.     call _clrLCDFull ;Clear Screen
  21.     call _runIndicOff ;Stops run indicator
  22.     call _grbufclr ;Clears Graph Buffer
  23.     call _homeup ;Goes to 0,0
  24.     ld a,40 ;Initial X & Y coords
  25.     ld (BOXX),a ;of box
  26.     ld a,55
  27.     ld (BOXY),a
  28.     jp moveloop
  29.  
  30. moveloop:
  31.     call putbox ;Call put box
  32.     jp getky
  33.  
  34. getky: ;routine getkey
  35.     ld a,0ffh
  36.     out (1),a
  37.     ld a,0feh
  38.     out (1),a
  39.     in a,(1)
  40.     cp 253 ;Is key Left?
  41.     jp z,left ;Goto Left
  42.     cp 251 ;Is the key right?
  43.     jp z,right ;Goto Right
  44.     cp 254 ;Is key Up?
  45.     jp z,up ;Goto up
  46.     cp 247 ;Is the key down?
  47.     jp z,down ;Goto Down
  48.     ld a,0ffh
  49.     out (1),a 
  50.     ld a,0fdh
  51.     out (1),a
  52.     in a,(1)
  53.     cp 191 ;Is the key clear?
  54.     jp z,quit ;If so, goto quit
  55.     jp getky ;No key ? Go back to getkey!
  56.  
  57. left:
  58.     call putbox       
  59.     ld a,(BOXX) ;Load XCoord Variable into A
  60.     dec a ;Decrease A
  61.     cp 0
  62.     jp z,BOOM
  63.     ld (BOXX),a ;Load back into BOXX
  64.     jp moveloop ;goto moveloop
  65.  
  66. right:       
  67.     call putbox       
  68.     ld a,(BOXX) ;Load XCoord Variable into A
  69.     inc a ;Increase A
  70.     cp 86
  71.     jp z,BOOM
  72.     ld (BOXX),a ;Load back into BOXX
  73.     jp moveloop ;goto moveloop
  74.  
  75. down:       
  76.     call putbox
  77.     ld a,(BOXY) ;Load YCoord Variable into A
  78.     dec a ;Decrease A
  79.     cp 0
  80.     jp z,BOOM
  81.     ld (BOXY),a ;Load back into BOXY
  82.     jp moveloop ;goto moveloop
  83.                
  84. up:       
  85.     call putbox       
  86.     ld a,(BOXY) ;Load YCoord Variable into A
  87.     inc a ;Increase A
  88.     cp 95
  89.     jp z,BOOM
  90.     ld (BOXY),a ;Load back into BOXY
  91.     jp moveloop ;goto moveloop
  92.                 
  93. putbox:       
  94.     ld a,(BOXY)       
  95.     ld e,a ;Stores 55 -> e , where e = y
  96.     ld a,(BOXX) ;Stores 40 -> x , where x = x
  97.     ld bc,box ;Load sprite name to bc
  98.     call SPRXOR ;Call movax' Sprite Routine 
  99.     call _grbufcpy_v       
  100.     ret
  101.  
  102. BOOM:       
  103.     ld a,(BOXY)       
  104.     ld e,a ;Stores 55 -> e , where e = y
  105.     ld a,(BOXX) ;Stores 40 -> x , where x = x
  106.     ld bc,boompic ;Load sprite name to bc
  107.     call SPRXOR ;Call movax' Sprite Routine 
  108.     call _grbufcpy_v       
  109.     jp DONE
  110.  
  111.  
  112.                                 
  113. quit:       
  114.     call _clrLCDFull
  115.     call _grbufclr
  116.     call _dispDone
  117.     ret
  118.  
  119. SPRXOR:
  120.  
  121.         push    bc              ; Save sprite address
  122.  
  123. ;████   Calculate the address in graphbuf   ████
  124.  
  125.         ld      hl,0            ; Do y*12
  126.         ld      d,0
  127.         add     hl,de
  128.         add     hl,de
  129.         add     hl,de
  130.         add     hl,hl
  131.         add     hl,hl
  132.  
  133.         ld      d,0             ; Do x/8
  134.         ld      e,a
  135.         srl     e
  136.         srl     e
  137.         srl     e
  138.         add     hl,de
  139.  
  140.         ld      de,8e29h
  141.         add     hl,de           ; Add address to graphbuf
  142.  
  143.         ld      b,00000111b     ; Get the remainder of x/8
  144.         and     b
  145.         cp      0               ; Is this sprite aligned to 8*n,y?
  146.         jp      z,ALIGN
  147.  
  148.  
  149. ;████   Non aligned sprite blit starts here   ████
  150.  
  151.         pop     ix              ; ix->sprite
  152.         ld      d,a             ; d=how many bits to shift each line
  153.  
  154.         ld      e,8             ; Line loop
  155. LILOP:  ld      b,(ix+0)        ; Get sprite data
  156.  
  157.         ld      c,0             ; Shift loop
  158.         push    de
  159. SHLOP:  srl     b
  160.         rr      c
  161.         dec     d
  162.         jp      nz,SHLOP
  163.         pop     de
  164.  
  165.         ld      a,b             ; Write line to graphbuf
  166.         xor     (hl)
  167.         ld      (hl),a
  168.         inc     hl
  169.         ld      a,c
  170.         xor     (hl)
  171.         ld      (hl),a
  172.  
  173.         ld      bc,11           ; Calculate next line address
  174.         add     hl,bc
  175.         inc     ix              ; Inc spritepointer
  176.  
  177.         dec     e
  178.         jp      nz,LILOP        ; Next line
  179.  
  180.         jp      DONE1
  181.  
  182.  
  183. ;████   Aligned sprite blit starts here   ████
  184.  
  185. ALIGN:                          ; Blit an aligned sprite to graphbuf
  186.         pop     de              ; de->sprite
  187.         ld      b,8
  188. ALOP1:  ld      a,(de)
  189.         xor     (hl)
  190.         ld      (hl),a
  191.         inc     de
  192.         push    bc
  193.         ld      bc,12
  194.         add     hl,bc
  195.         pop     bc
  196.         djnz    ALOP1
  197.  
  198. DONE1:
  199.         ret
  200.   
  201. DONE:
  202.     ld a,0ffh
  203.     out (1),a 
  204.     ld a,0fdh
  205.     out (1),a
  206.     in a,(1)
  207.     cp 191 ;Is the key clear?
  208.     jp z,quit ;If so, goto quit
  209.     jp DONE ;No key ? Go back to getkey!
  210.  
  211.  
  212. box:       
  213.     .db 11111111b       
  214.     .db 10000001b       
  215.     .db 10100101b
  216.     .db 10000001b       
  217.     .db 10011001b
  218.     .db 11000011b       
  219.     .db 10111101b       
  220.     .db 11111111b 
  221.  
  222. boompic:
  223.     .db 10101010b
  224.     .db 01010101b
  225.     .db 10101010b
  226.     .db 01010101b
  227.     .db 10101010b
  228.     .db 01010101b
  229.     .db 10101010b
  230.     .db 01010101b
  231.  
  232. name:   .db "Mr.Happy =)",$00
  233.  
  234. .end 
  235. END 
  236.