aboutsummaryrefslogtreecommitdiff
path: root/explosion.s.with_shaking
blob: e5d297cca7037e848a0e68e5980bd34656a8cc9c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
; explosion seen when we're hit by enemy fire.
; currently just flashes the screen. the apple version is
; kinda funky-looking, best way I can describe it is that it
; looks like TV static. would be hard to imitate that on the
; atari.

; this version shakes the screen, but I'm not happy with how it
; looks. Might revisit at some point.

; original code was in C, and looked like:
;; for(i = 0; i < 3; i++) {
;; 	unsigned char color = PEEK(710) & 0xf0;
;; 	unsigned char textcolor = PEEK(709);
;; 	POKE(709,0);
;; 	POKE(710, color | 0x0c);
;; 	jsleep(10);
;; 	POKE(710, color & 0xf0);
;; 	jsleep(10);
;; 	POKE(709,textcolor);
;; }

 .export _explosion
 .include "atari.inc"
 .importzp tmp1, tmp2, tmp3, ptr1
 .import _jsleep

color1save = tmp1
color2save = tmp2
shakectr = tmp3
dlptr = ptr1

; extern void explosion(void);
_explosion:
; {
 ; save original colors (don't hardcode, they can be changed on the title screen)
 lda COLOR1
 sta color1save
 lda COLOR2
 sta color2save

 ; setup display list pointer (for screen shaking)
 lda SDLSTL
 sta dlptr
 lda SDLSTL+1
 sta dlptr+1

 ; dark text
 lda #0
 sta COLOR1

 ldy #2 ; loop counter, counts 2 1 0

;   {
@loop:
 lda color2save
 ora #$0c   ; embrighten text background (without changing the hue)
 sta COLOR2

 lda #2
 sta shakectr ; screen shaking counter

;       {
@shakeloop:
 lda #$30 ; display list "blank 4 lines", replaces standard "blank 8 lines"
 sta (dlptr),y

 ldx #0      ;\
 lda #$05    ; | jsleep(1)... _jsleep must NOT modify Y reg!
 jsr _jsleep ;/

 lda #$70 ; display list "blank 8 lines", put it back like it was
 sta (dlptr),y

 ldx #0      ;\
 lda #$05    ; | jsleep(1);
 jsr _jsleep ;/

 dec shakectr
 bne @shakeloop
;      }

 lda color2save ; put text bg back like it was...
 sta COLOR2

 ldx #0         ; ...and jsleep(10)
 lda #$0a
 jsr _jsleep

 dey
 bpl @loop ; we're done if Y < 0
;   }

 lda color1save ; restore text color
 sta COLOR1
 rts
; }