[A83] To scroll a pic larger than the screen... ?


[Prev][Next][Index][Thread]

[A83] To scroll a pic larger than the screen... ?



Alright..... I discovered TCPA's scrolling routine a while ago, I wrote an 
example program for myself using it. The program scrolls a 96x64 size 
pic/sprite, in a constant loop (so if left is pressed, then pic scrolls left 
and whatever goes off screen shows up on the right). I haven't looked at it 
awhile, and now I want to change it so it can scroll something larger than 
96x64 (128x96 for example), in the same similar looping style and in a style 
that will scroll to the end of the pic and stop. Could someone please help me 
with this, modify the included source, or tell me which parts to edit?

example_prog:
  ld   hl,scrollio_pic
  ld   de,plotsscreen
  ld   bc,768
  ldir
  call ionFastCopy
key_loop:
  ld   a,kReset
  out  (1),A
  ld   a,Group1
  out  (1),A
  in   a,(1)
  cp   kLeft
  call z,Scroll_Left
  cp   kRight
  call z,Scroll_Right
  cp   kUp
  call z,Scroll_Up
  cp   kDown
  call z,Scroll_Down
  ld   a,kReset
  out  (1),A
  ld   a,Group2
  out  (1),A
  in   a,(1)
  cp   kClear
  ret  z
  jp   key_loop




scrollio_pic:
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $18,$00,$00,$00,$00,$7F,$00,$FC,$00,$00,$00,$00
 .db $3F,$F0,$00,$00,$00,$FF,$81,$FE,$00,$00,$00,$00
 .db $3F,$FE,$00,$00,$00,$FF,$C3,$FE,$00,$00,$00,$00
 .db $3F,$FF,$E0,$00,$00,$FF,$C3,$FF,$00,$00,$00,$00
 .db $1F,$FF,$F1,$80,$00,$F3,$C1,$DF,$00,$60,$00,$00
 .db $00,$FF,$F3,$C0,$00,$F3,$C0,$0F,$80,$F0,$00,$00
 .db $00,$F7,$E3,$C0,$00,$FB,$C0,$0F,$80,$F0,$00,$00
 .db $00,$F0,$01,$80,$00,$FF,$C0,$07,$80,$F0,$00,$00
 .db $00,$F0,$00,$00,$00,$7F,$C1,$DF,$80,$F0,$00,$00
 .db $00,$F0,$06,$00,$00,$3F,$83,$FF,$8F,$F0,$E0,$00
 .db $00,$F0,$0F,$00,$00,$7F,$03,$FF,$1F,$FF,$F0,$00
 .db $00,$F0,$0F,$07,$C0,$FF,$83,$FF,$9F,$FF,$F0,$00
 .db $01,$F0,$0F,$0F,$E1,$FF,$81,$FF,$CF,$FF,$E0,$00
 .db $01,$F0,$0F,$0F,$E1,$F7,$80,$07,$C0,$FF,$C0,$00
 .db $01,$E0,$0F,$07,$C1,$E7,$80,$03,$C1,$F0,$00,$00
 .db $03,$E0,$1F,$00,$01,$FF,$80,$C3,$C1,$F0,$00,$00
 .db $03,$E0,$1F,$00,$01,$FF,$81,$FB,$C1,$E0,$00,$00
 .db $01,$C0,$1E,$00,$00,$FF,$81,$FF,$C1,$E0,$00,$00
 .db $00,$00,$0C,$00,$00,$7F,$01,$FF,$C1,$E0,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$FF,$80,$C0,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$1F,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $1F,$80,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $3F,$CF,$01,$F0,$F0,$00,$00,$00,$00,$00,$00,$00
 .db $3F,$FF,$83,$F9,$F8,$00,$00,$00,$70,$07,$FC,$00
 .db $1F,$FF,$C7,$FF,$FE,$FE,$0F,$C1,$FC,$FF,$FF,$C0
 .db $01,$FF,$FF,$FF,$FF,$FF,$7F,$FF,$FF,$FF,$FF,$E0
 .db $00,$FF,$FF,$BF,$FF,$FF,$FF,$FF,$FF,$FF,$FF,$E0
 .db $00,$01,$FF,$1F,$8F,$FF,$FF,$FF,$FF,$FC,$0F,$C0
 .db $00,$00,$FC,$00,$07,$C7,$F8,$7F,$8F,$80,$00,$00
 .db $00,$00,$00,$00,$00,$03,$E0,$07,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$03,$01,$80,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$07,$83,$C0,$00,$00,$00
 .db $03,$C0,$00,$00,$00,$00,$07,$83,$C0,$60,$00,$00
 .db $07,$E0,$00,$00,$00,$00,$07,$83,$C0,$F0,$00,$00
 .db $1F,$E0,$00,$00,$00,$00,$07,$83,$C0,$F0,$00,$00
 .db $3F,$C0,$00,$00,$00,$00,$07,$87,$C0,$60,$00,$00
 .db $3F,$00,$7F,$0C,$F0,$00,$0F,$87,$C0,$01,$F0,$00
 .db $3C,$00,$FF,$9F,$F8,$60,$0F,$87,$80,$03,$FC,$00
 .db $3C,$00,$FF,$9F,$F8,$F0,$0F,$07,$83,$03,$FE,$00
 .db $3E,$01,$FF,$1F,$F8,$FC,$1F,$0F,$87,$87,$FE,$00
 .db $3F,$C1,$F0,$1F,$F9,$FF,$1F,$0F,$8F,$87,$DE,$00
 .db $3F,$E1,$E0,$1F,$B3,$FF,$9E,$0F,$1F,$8F,$9F,$00
 .db $0F,$F1,$E0,$3F,$07,$FF,$9E,$0F,$1F,$0F,$9F,$00
 .db $07,$F1,$E0,$3E,$07,$CF,$9E,$0F,$1E,$0F,$0F,$00
 .db $00,$F1,$E7,$BE,$07,$8F,$9E,$0F,$3E,$0F,$FF,$00
 .db $0C,$F1,$FF,$FC,$07,$8F,$BE,$0F,$3E,$0F,$FF,$00
 .db $1F,$F1,$FF,$FC,$07,$FF,$3E,$1F,$3C,$0F,$FE,$00
 .db $1F,$F0,$FF,$98,$07,$FF,$3C,$1F,$3C,$07,$FC,$00
 .db $1F,$F0,$7E,$00,$03,$FE,$3C,$1E,$3C,$00,$00,$00
 .db $0F,$C0,$00,$00,$01,$FC,$18,$0C,$18,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
 .db $00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00
;---------------------------------------------------------------------;
;  Background Scrolling Routines: Scrolls Up, Down, Left, and Right.  ;
;  By Matthew Landry & Scott Dial with help from Dan, Jason, & Chris. ;
;            MODIFIED FOR USE FOR THIS DEMO (SCROLLIO)
;---------------------------------------------------------------------;
;                                                                     ;
;    While writing this routine we came across a little descrepancy.  ;
; In the left to right loop, you can either use twelve RR (hl)'s and  ;
; "inc hl"s or do a loop. The one problem is that the loop saves many ;
; bytes, but uses way more clocks. And writing it all out saves some  ;
; clocks, but wastes many bytes. Usually, when dealing with graphics, ;
; it is better to go for speed, but since the routine was already so  ;
; fast, I decided to use the looping method.                          ;
;                                                                     ;
;           | Writing the rr's and inc's | Doing the loop | Saved |   ;
;           | ========================== | ============== | ===== |   ;
;  Bytes:   |             36             |        6       |  30   |   ;
;  Clocks:  |             252            |       416      |  164  |   ;
;                                                                     ;
;---------------------------------------------------------------------;

Scroll_Right:
        ld de, 12
        ld hl, Plotsscreen-1
        ld b, 64
Right_Carry:
        push hl
        add hl,de
        ld a, 1
        and (hl)
        NEG
        pop hl
        ld c, b
        ld b, 12
Right_Loop:
        inc hl
        RR (hl)
        djnz Right_Loop
        ld b, c
        djnz Right_Carry
        call   ionFastCopy
        ret

Scroll_Left:
        ld hl, Plotsscreen-1
        ld de, 12
        ld b, 64
Left_Carry:
        inc hl
        ld a, (hl)
        and %10000000
        add hl, de
        sub %10000000
        CCF
        ld c, b
        ld b, 12
Left_Loop:
        dec hl
        RL (hl)
        djnz Left_Loop
        ld b, c
        dec hl
        add hl, de
        djnz Left_Carry
        call   ionFastCopy
        ret

Scroll_Up:
        ld hl, Plotsscreen
        ld de, OP1
        ld bc, 12
        LDIR
        ld hl, Plotsscreen+12
        ld de, Plotsscreen
        ld bc, 756
        LDIR
        ld hl, OP1
        ld de, Plotsscreen+756
        ld bc, 12
        LDIR
        call   ionFastCopy
        ret

Scroll_Down:
        ld hl, Plotsscreen+756
        ld de, OP1
        ld bc, 12
        LDIR
        ld hl, Plotsscreen+755
        ld de, Plotsscreen+767
        ld bc, 756
        LDDR
        ld hl, OP1
        ld de, Plotsscreen
        ld bc, 12
        LDIR
        call ionFastCopy
        ret



#include "keys.inc"
.end
END