From bb03d1a3a4eb97ff4e0b7ca4b642a47828cfd778 Mon Sep 17 00:00:00 2001 From: "B. Watson" Date: Mon, 1 Feb 2016 02:28:49 -0500 Subject: playing with PMG for explosions --- explosion.s.flash | 66 ++++++++++++++++++++++++++++++++++++++ explosion.s.pm | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ newtitle.s | 53 ++++++++++++++++++++++++++++++ 3 files changed, 215 insertions(+) create mode 100644 explosion.s.flash create mode 100644 explosion.s.pm diff --git a/explosion.s.flash b/explosion.s.flash new file mode 100644 index 0000000..581e987 --- /dev/null +++ b/explosion.s.flash @@ -0,0 +1,66 @@ +; 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. maybe there should be screen-shaking going on? + +; 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 + .import _jsleep + +color1save = tmp1 +color2save = tmp2 + +; 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 + + ; dark text + lda #0 + sta COLOR1 + + ldy #3 ; loop counter, counts 3 2 1 + +; { +@loop: + lda color2save + ora #$0c ; embrighten text background (without changing the hue) + sta COLOR2 + + ldx #0 ;\ + lda #$0a ; | jsleep(10); + jsr _jsleep ;/ + + lda color2save ; put text bg back like it was... + sta COLOR2 + + ldx #0 ; ...and jsleep(10) again + lda #$0a + jsr _jsleep + + dey + bne @loop ; we're done if Y==0 +; } + + lda color1save ; restore text color + sta COLOR1 + rts +; } diff --git a/explosion.s.pm b/explosion.s.pm new file mode 100644 index 0000000..81bc213 --- /dev/null +++ b/explosion.s.pm @@ -0,0 +1,96 @@ +; explosion seen when we're hit by enemy fire. +; this draws something that looks a bit like TV static, only +; it's a lot more regular and less random. it somewhat approximates +; the apple version's explosion, but not all that closely. + + .export _explosion + .include "atari.inc" + .importzp tmp1, tmp2 + .import _jsleep + +static_loop_count = tmp1 + +; extern void explosion(void); +; { +_explosion: + + ldy #3 ; explosion_loop counter, counts 3 2 1 + +; { +@explosion_loop: + lda #$05 ; static_loop runs 3 times + sta static_loop_count + +; { +@static_loop: + ldx #0 ; jsleep(2) + lda #$01 + jsr _jsleep + + ldx #2 + +; { +; { +; let the top part of the screen display normally. +; garbage begins to display on gr.0 line 8 (the one above the tops +; of the top row of lorchas). +@wait4scanline: + lda VCOUNT + cmp #(4+8)*4 + bne @wait4scanline +; } + +; { +; store random stuff into the players/missiles +@randpm: + sta WSYNC + lda RANDOM + sta GRAFP0 + lda RANDOM + sta GRAFP1 + lda RANDOM + sta GRAFP2 + lda RANDOM + sta GRAFP3 + lda RANDOM + sta GRAFM + + lda VCOUNT + cmp #(4+23)*4 + bne @randpm ; stop garbage 2 lines after the bottom row of lorchas +; } + + ; clear P/M for rest of frame + lda #0 + sta GRAFP0 + sta GRAFP1 + sta GRAFP2 + sta GRAFP3 + sta GRAFM + + lda RTCLOK+2 +; { +; wait for start of next TV frame. +@wait4frame: +cmp RTCLOK+2 + beq @wait4frame +; } + + dex + bne @wait4scanline +; } + + dec static_loop_count + bne @static_loop +; } + + ldx #0 ; jsleep(10) + lda #$0a + jsr _jsleep + + dey + bne @explosion_loop ; we're done if Y==0 +; } + + rts +; } diff --git a/newtitle.s b/newtitle.s index 6387ace..953a3cb 100644 --- a/newtitle.s +++ b/newtitle.s @@ -159,6 +159,59 @@ start: ; wait for the next frame, to avoid graphics glitching jsr wait1jiffy +;; ; For use with explosion.s.pm: +;; ; set player/missiles. we don't use P/M here, it's for the explosion +;; ; sequence, but doing it here is "free" (it doesn't add to the size of +;; ; the main xex segment). also note that we don't enable ANTIC P/M DMA +;; ; (no SDMCTL or GRACTL bits set): the explosion routine writes directly +;; ; to the GRAFP/GRAFM registers. +;; +;; ; colors +;; lda #$0f ; bright white +;; sta PCOLR0 +;; sta PCOLR1 +;; sta PCOLR2 +;; sta PCOLR3 +;; +;; ; make sure they're not showing +;; lda #0 +;; sta GRAFP0 +;; sta GRAFP1 +;; sta GRAFP2 +;; sta GRAFP3 +;; sta GRAFM +;; +;; ; positions +;; lda #$30 ; text columns 0-1 +;; sta HPOSM3 +;; lda #$38 ; text columns 2-3 +;; sta HPOSM2 +;; lda #$40 ; 4-5 +;; sta HPOSM1 +;; lda #$48 ; 6-7 +;; sta HPOSM0 +;; lda #$50 ; 8-15 +;; sta HPOSP0 +;; lda #$70 ; 16-23 +;; sta HPOSP1 +;; lda #$90 ; 24-31 +;; sta HPOSP2 +;; lda #$B0 ; 32-39 +;; sta HPOSP3 +;; +;; ; priority +;; lda #8 ; PF 0,1 on top of players (then PF 2,3 on bottom) +;; sta GPRIOR +;; +;; ; width +;; lda #3 +;; sta SIZEP0 ; 3 = quad-width +;; sta SIZEP1 +;; sta SIZEP2 +;; sta SIZEP3 +;; lda #$FF +;; sta SIZEM ; FF = quad width, all missiles + ; setup our display list lda SDLSTL sta FR0 -- cgit v1.2.3