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

  1. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  2. ;│█████ Z80 ██████│ HardwareScroll │█████████████████████│ movax │████████████│
  3. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  4.  
  5.     .org     9327h
  6.  
  7. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  8. ;│█████ Z80 ██████│      CODE      │█████████████████████│ movax │████████████│
  9. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  10.  
  11. START:
  12.         call    INIT                    ; Initialize screen and stuff
  13.  
  14.         ld      a,40h                   ; We want too start at offset 0 (40h+0)
  15.         push    af                      ; Push it on the stack to use it later
  16.  
  17. MAIN:
  18.         ld      a,(SPEED)               ; Load the current speed
  19.         cp      8                       ; If it's 8 then don't accelerate more
  20.     jp    z,SKP1
  21.         dec     a                       ; Accelerate (lower value=faster scroll)
  22.     ld    (SPEED),a
  23. SKP1:
  24.  
  25.         ld      a,0ffh                  ; Reset the keyport (kinda)
  26.         out     (1),a
  27.         ld      a,0feh                  ; Enable the arrows
  28.     out    (1),a
  29.     in    a,(1)
  30.  
  31.         cp      254                     ; Has anyone pressed down?
  32.     jp    nz,NODOWN
  33.         pop     af                      ; Get offset from stack
  34.         dec     a                       ; Decrement offset
  35.     jp    SCROLL
  36.  
  37. NODOWN:
  38.         cp      247                     ; Has anyone pressed up?
  39.     jp    nz,NOUP
  40.         pop     af                      ; Get offset from stack
  41.         inc     a                       ; Increase offset
  42.     jp    SCROLL
  43.  
  44. NOUP:
  45.         ld      a,64                    ; Reset speed if no key pressed
  46.         ld      (SPEED),a               ; (64 = slowest)
  47.     pop    af
  48.  
  49. SCROLL:
  50.         and     01111111b               ; Clr bit 7 (we don't want values >7fh)
  51.         or      01000000b               ; Set bit 6 (we don't want values <40h)
  52.         out     (010h),a                ; Out current offset to LCD instr. port
  53.     push    af
  54.  
  55.         call    WAIT                    ; Wait
  56.  
  57.         ld      a,0ffh                  ; Reset the keyport (kinda)
  58.         out     (1),a
  59.         ld      a,0fdh                  ; Enable the row with clear
  60.     out    (1),a
  61.     in    a,(1)
  62.  
  63.         cp      191                     ; Check for clear
  64.         jp      nz,MAIN                 ; If not pressed, jump to MAIN
  65.  
  66. XIT:                                    ; If pressed, quit
  67.         pop     af
  68.         ld      a,40h                   ; Set screen to offset 0 (40h+0)
  69.         out     (010h),a                ; Out it to the LCD instructions port
  70.  
  71.         call    CLRTSHD                 ; Clear textshadow
  72.         call    GOHOME                  ; Go to the homescreen
  73.         call    HOMEUP                  ; Place cursor at home
  74.  
  75.         ld      hl,MSG                  ; Print message
  76.         call    STRING
  77.         call    WAITKEY                 ; Pick up the keypress from clear
  78.  
  79.         ret                             ; Exit program
  80.  
  81. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  82. ;│█████ Z80 ██████│   PROCEDURES   │█████████████████████│ movax │████████████│
  83. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  84.  
  85. ;▄████████████▀  INIT  ▀███████████████████████████████████████████████████████
  86. INIT:
  87.  
  88.     call    RINDOFF         ; Runindicator off
  89.  
  90.         ld      hl,PIC                  ; Copy picture to graphbuf
  91.     ld    de,8e29h
  92.     ld    bc,768
  93.     ldir
  94.  
  95.     call    BUFCOPY         ; Copy graphbuf to LCD
  96.  
  97.     ret
  98. ;▄████████████▄  INIT  ▄███████████████████████████████████████████████████████
  99.  
  100.  
  101. ;▄████████████▀  WAIT  ▀███████████████████████████████████████████████████████
  102. WAIT:
  103.         push    bc
  104.  
  105.         ld      hl,SPEED                ; Time to wait depends on SPEED
  106.         ld      c,(hl)
  107. WLOP2:                                  ; Outer loop
  108.  
  109.  
  110.     ld    b,0
  111. WLOP1:  nop                             ; Inner loop
  112.         nop
  113.  
  114.         dec     b                       ; Decrease b (you can use djnz here)
  115.         jp      nz,WLOP1                ; Loop to WLOP1 if not zero
  116.  
  117.  
  118.         dec     c                       ; Decrease c
  119.         jp      nz,WLOP2                ; Loop to WLOP2 if not zero
  120.  
  121.     pop    bc
  122.     ret
  123. ;▄████████████▄  WAIT  ▄███████████████████████████████████████████████████████
  124.  
  125. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  126. ;│█████ Z80 ██████│     EQUALS     │█████████████████████│ movax │████████████│
  127. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  128.  
  129. WAITKEY .equ     4CFEh  ; Wait for a key and read
  130. BUFCLR    .equ     515Bh    ; Clear the graph backup
  131. BUFCOPY .equ     5164h    ; Copy the graph backup to the screen
  132. RINDOFF .equ     4795h    ; Turn off runindicator
  133. PRINTHL .equ     4709h    ; Print HL in dec. on the screen
  134. OP2TOP1 .equ     41C2h    ; Move OP2 to OP1
  135. CONVOP1 .equ     4EFCh    ; Convert fp value in OP1 to a 2 byte hex
  136. READKEY .equ     4A18h    ; Read key and place it in OP2 as a fp value
  137. GOHOME    .equ     47A1h    ; Go to home screen (finish gfx program)
  138. CLRTSHD .equ     4765h    ; Clear text shadow
  139. HOMEUP    .equ     4775h    ; Place cursor at home
  140. STRING    .equ     470Dh    ; Print 0 terminated string to screen (hl->string)
  141.  
  142. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  143. ;│█████ Z80 ██████│      DATA      │█████████████████████│ movax │████████████│
  144. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  145.  
  146. .include        pic.db                  ; The picture
  147.  
  148. SPEED   .db     64                      ; Speed of the scroll (lower = faster)
  149. MSG     .db     "HAVE A NICE DAY!",0    ; Message
  150.  
  151. .end
  152. ;┌────────────────┬────────────────┬─────────────────────┬───────┬────────────┐
  153. ;│█████ Z80 ██████│ HardwareScroll │█████████████████████│ movax │████████████│
  154. ;└────────────────┴────────────────┴─────────────────────┴───────┴────────────┘
  155.  
  156.