299 lines
3.9 KiB
ArmAsm
Raw Normal View History

2022-05-02 22:50:11 -04:00
; random scroll bot
2022-05-03 00:36:58 -04:00
; 162 bytes -- working code
; 158 bytes -- play with bitmap
; 156 bytes -- use HGR2 to init screen (and A)
; 155 bytes -- remove use of LINE count
; 155 bytes -- use ZP for output
; 153 bytes -- count X backwards
; 150 bytes -- use $28 to center Y trick
; 146 bytes -- inline update scroll, makes it scroll right rather than up
; 144 bytes -- share common sta OUTH
; 141 bytes -- more wrapping loop stuff
2022-05-02 22:50:11 -04:00
; ***** *****
; ***** *****
; ** ** @@ @@@@@@
; ** ** @@ @@
; ** ** @@@@@@ @@@@@@ @@@@@@
; ***** ***** @@ @@ @@ @@
; ***** ***** @@@@@@ @@@@@@ @@
; by Vince `deater` Weaver
FULLGR = $C052
PAGE1 = $C054
PAGE2 = $C055
LORES = $C056 ; Enable LORES graphics
2022-05-03 00:36:58 -04:00
HGR2 = $F3D8
2022-05-02 22:50:11 -04:00
PLOT = $F800 ; PLOT AT Y,A (A colors output, Y preserved)
GBASCALC = $F847 ; Y in A, put addr in GBASL/GBASH
SETGR = $FB40
WAIT = $FCA8 ; delay 1/2(26+27A+5A^2) us
GBASL = $26
GBASH = $27
2022-05-03 00:36:58 -04:00
OUTL = $FC
OUTH = $FD
2022-05-02 22:50:11 -04:00
PAGE = $FE
LINE = $FF
pattern1 = $f000 ; location in memory
random:
2022-05-03 00:36:58 -04:00
jsr HGR2 ; set HIRES, FULLSCREEN
bit LORES ; set LORES
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; A is 0 from HGR2
sta OUTL
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; lda #$4
main_loop:
sta PAGE ; start at page 1
asl ; make OUTH $4 or $8 depending on value in PAGE
; which we have in A above or at end of loop
asl ; C is 0
adc #4
sta OUTH
lda #200
jsr WAIT
2022-05-02 22:50:11 -04:00
;============================
; draw an interleaved line
line_loop:
2022-05-03 00:36:58 -04:00
ldy #119
2022-05-02 22:50:11 -04:00
screen_loop:
2022-05-03 00:36:58 -04:00
tya ; extrapolate Y from X
2022-05-02 22:50:11 -04:00
and #$7
2022-05-03 00:36:58 -04:00
tax
2022-05-02 22:50:11 -04:00
pattern_smc:
2022-05-03 00:36:58 -04:00
lda pattern1,X
2022-05-02 22:50:11 -04:00
inner_loop_smc:
2022-05-03 00:36:58 -04:00
sta (OUTL),Y
dey
2022-05-02 22:50:11 -04:00
bpl screen_loop
;=================================
; move to next pattern
2022-05-03 00:36:58 -04:00
; jsr scroll_pattern
scroll_pattern:
clc
lda pattern_smc+1
adc #8
and #$1f
sta pattern_smc+1
; rts
2022-05-02 22:50:11 -04:00
; move to next line
clc
2022-05-03 00:36:58 -04:00
lda OUTL
2022-05-02 22:50:11 -04:00
adc #$80
2022-05-03 00:36:58 -04:00
sta OUTL
bcc line_loop
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; A is $00 if we get here
adc OUTH
sta OUTH
and #$3
2022-05-02 22:50:11 -04:00
bne line_loop
2022-05-03 00:36:58 -04:00
done_bg:
2022-05-02 22:50:11 -04:00
;=======================================
; done drawing frame
;=======================================
;======================
; draw bitmap
2022-05-03 00:36:58 -04:00
ldx #7
2022-05-02 22:50:11 -04:00
boxloop:
txa
2022-05-03 00:36:58 -04:00
jsr GBASCALC ; calc address of X
; note we center to middle of screen
; by noting the middle 8 lines
; are offset by $28 from first 8 lines
2022-05-02 22:50:11 -04:00
; GBASL is in A at this point
clc
2022-05-03 00:36:58 -04:00
adc #12+$28
sta GBASL ; center x-coord and y-coord at same time
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
lda PAGE ; want to add 0 or 4 (not 0 or 1)
2022-05-02 22:50:11 -04:00
asl
2022-05-03 00:36:58 -04:00
asl ; this sets C to 0
2022-05-02 22:50:11 -04:00
adc GBASH
sta GBASH
ldy #15
draw_line_loop:
2022-05-03 00:36:58 -04:00
lda bitmap2,X ; get low bit of bitmap2 into carry
lsr
lda #$00 ; black is default color
ror bitmap,X ; 16-bit rotate (in memory)
ror bitmap2,X
2022-05-02 22:50:11 -04:00
bcc its_black
lda #$ff
its_black:
sta (GBASL),Y ; partway down screen
dey
bpl draw_line_loop
2022-05-03 00:36:58 -04:00
dex
bpl boxloop
2022-05-02 22:50:11 -04:00
;=========================
; scroll one line
2022-05-03 00:36:58 -04:00
; jsr scroll_pattern
; to scroll up need to add 8?
inc pattern_smc+1
2022-05-02 22:50:11 -04:00
; switch page
lda PAGE
tax
ldy PAGE1,X ; flip page
eor #$1
2022-05-03 00:36:58 -04:00
; sta PAGE ; is 0 or 1
2022-05-02 22:50:11 -04:00
; reset page smc
2022-05-03 00:36:58 -04:00
; OUTH is either C00 or 800
; want C00 to go to 400 and 800 to stay the same
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; asl
; asl ; C is 0
; adc #4
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; sta OUTH
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; lda #200
; jsr WAIT
2022-05-02 22:50:11 -04:00
2022-05-03 00:36:58 -04:00
; A is 0 after
jmp main_loop ; bra
.if 0
2022-05-02 22:50:11 -04:00
scroll_pattern:
clc
lda pattern_smc+1
adc #8
and #$1f
sta pattern_smc+1
rts
2022-05-03 00:36:58 -04:00
.endif
2022-05-02 22:50:11 -04:00
;01234567|01234567
;
; @@@@ @@@@
; @@ @@
; @@ @@
; @@ @@
; @@@@ @@@@
;
;@@@@@@@@@@@@@@@@
bitmap:
.byte $FF ;,$FF
.byte $E1 ;,$87
.byte $F9 ;,$9F
.byte $F9 ;,$9F
.byte $F9 ;,$9F
.byte $E1 ;,$87
.byte $FF ;,$FF
.byte $00 ;,$00
bitmap2:
.byte $FF
.byte $87
.byte $9F
.byte $9F
.byte $9F
.byte $87
.byte $FF
.byte $00
; want this at $3F5
2022-05-03 00:36:58 -04:00
; we are 141 bytes long, so 36b
2022-05-02 22:50:11 -04:00
jmp random
.if 0
;======================
; draw box
ldx #16
boxloop:
txa
jsr GBASCALC
lda PAGE
asl
asl
; clc
adc GBASH
sta GBASH
color_smc:
lda #$FF ; white bar
ldy #30
draw_line_loop:
sta (GBASL),Y ; partway down screen
dey
cpy #10
bne draw_line_loop
dex
cpx #6
bne boxloop
.endif