home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
8bitfiles.net/archives
/
archives.tar
/
archives
/
genie-commodore-file-library
/
C64Demos
/
BOINK.SDA
/
BOINK.ASM
next >
Wrap
Assembly Source File
|
2019-04-13
|
4KB
|
203 lines
;=================================
;64 BOINK!
;(C) 1986 STEVE GOLDSMITH
;ALL RIGHTS RESERVED
;USE COMMODORE'S MACRO ASSEMBLER
;TO ASSEMBLE
;=================================
;
IRQVEC = $0314 ;OS IRQ INTERRUPT VECTOR
VIC2 = $D000 ;VIC2 CHIP
SPRPTR = $07F8 ;SPRITE POINTER
SID = $D400 ;SOUND CHIP
PRINT = $FFD2 ;OUTPUT A CHARACTER
* = $0900
;
;INITILIZE SPRITE, IRQ, AND PRINT MESSAGE
;
LDA #$05
STA TIMER ;INIT ROTATION TIMER
LDA #$05
STA STIMER ;INIT SOUND EFFECT TIMER
LDA #$00
STA XDIR ;INIT X DIR
STA YDIR ;INIT Y DIR
STA COLOR ;INIT REFLECTION COLOR
STA SETOGL ;INIT SOUND EFFECT TOGGLE
STA ROTDIR ;INIT ROTATION DIRECTION
SEI
LDA IRQVEC ;GET CURRENT IRQ VECTOR
STA NORIRQ ;SET UP INDIRECT JUMP
LDA IRQVEC+1
STA NORIRQ+1
LDA #<NEWIRQ ;CHANGE IRQ VECTOR
STA IRQVEC
LDA #>NEWIRQ
STA IRQVEC+1
CLI
LDX #$00 ;PRINT MESSAGE
LOOP17 LDA TEXT,X
JSR PRINT
INX
CPX #$27
BNE LOOP17
LDA #$00 ;BLACK
STA VIC2+$21 ;SCREEN COLOR
LDA #$2C ;SPRITE #44
STA SPRPTR ;TELL VIC2 WHERE SPRITE 0 IS
LDA #$A0 ;X POSITION
STA VIC2
LDA #$81 ;Y POSITION
STA VIC2+1
LDA #$01
STA VIC2+$1C ;SET MULTI-COLOR MODE
LDA #$06 ;BLUE
STA VIC2+$25 ;SET BIT PAIR 01
LDA #$01 ;WHITE
STA VIC2+$26 ;SET BIT PAIR 11
LDA #$02 ;RED
STA VIC2+$27 ;BIT PAIR 10
LDA #$01
STA VIC2+$17 ;EXPAND Y 2X
STA VIC2+$1D ;EXPAND X 2X
STA VIC2+$15 ;TURN SPRITE ON
LDA #$0F
STA SID+$18 ;TURN ON MASTER VOLUME
RTS
;
;ROTATE AND MOVE SPRITE
;
NEWIRQ LDA XDIR ;GET X DIRECTION 0=RIGHT ; 1=LEFT
BNE LOOP1
LDA VIC2+$10 ;GET MSB X POS
BNE LOOP3 ;SET?
LDA VIC2 ;GET LSB X POS
CMP #$FF ;REACHED SPRITE SEEM?
BNE LOOP2
LDA #$01
STA VIC2+$10 ;SET MSB X POS
JMP LOOP2
LOOP3 LDA VIC2
CMP #$3C ;RIGHT EDGE OF SCREEN
BNE LOOP2
LDA #$01
STA XDIR ;CHANGE DIRECTION
STA ROTDIR ;CHANGE ROTATION DIR
JSR SOUND ;SOUND EFFECT
JMP LOOP4
LOOP2 INC VIC2 ;MOVE RIGHT
JMP LOOP4 ;MOVE Y DIR
LOOP1 LDA VIC2+$10 ;GET MSB X POS
BEQ LOOP6 ;SET?
LDA VIC2 ;GET LSB X POS
BNE LOOP5 ;REACHED SPRITE SEEM?
LDA #$00
STA VIC2+$10 ;SET MSB X POS
JMP LOOP5
LOOP6 LDA VIC2
CMP #$08 ;LEFT EDGE OF SCREEN
BNE LOOP5
LDA #$00
STA XDIR ;CHANGE DIRECTION
STA ROTDIR ;CHANGE ROTATION DIR
JSR SOUND ;SOUND EFFECT
JMP LOOP4
LOOP5 DEC VIC2 ;MOVE LEFT
LOOP4 LDA YDIR ;GET Y DIRECTION 0=DOWN ; 1=UP
BNE LOOP7
LDA VIC2+1 ;GET Y POS
CMP #$D6 ;BOTTOM OF SCREEN
BNE LOOP8
LDA #$01
STA YDIR
STA ROTDIR ;CHANGE ROTATION DIR
JSR SOUND ;SOUND EFFECT
JMP LOOP9
LOOP8 INC VIC2+1 ;MOVE DOWN
JMP LOOP9
LOOP7 LDA VIC2+1 ;GET Y POS
CMP #$2C ;TOP OF SCREEN
BNE LOOP10
LDA #$00
STA YDIR
STA ROTDIR ;CHANGE ROTATION DIR
JSR SOUND ;SOUND EFFECT
JMP LOOP9
LOOP10 DEC VIC2+1 ;MOVE DOWN
LOOP9 DEC TIMER
BNE LOOP11 ;TIMER = 0?
LDA #$05
STA TIMER ;RESET TIMER
LDA ROTDIR ;GET ROTATION DIRECTION
BNE LOOP15 ;1= LEFT 0=RIGHT
LDA SPRPTR
CMP #$3F
BNE LOOP12 ;HAS SPRITE MADE FULL ROTATION?
LDA #$00
STA COLOR ;RESET COLOR COUNTER
LDA #$2C
STA SPRPTR
JMP LOOP11
LOOP12 INC SPRPTR ;ROTATE 1 STEP RIGHT
LDX COLOR
INC COLOR
LDA C1DATA,X
STA VIC2+$26 ;COLOR REFLECTION
JMP LOOP11
LOOP15 LDA SPRPTR
CMP #$2C
BNE LOOP16 ;HAS SPRITE MADE FULL ROTATION?
LDA #$13
STA COLOR ;RESET COLOR COUNTER
LDA #$3F
STA SPRPTR
JMP LOOP11
LOOP16 DEC SPRPTR ;ROTATE 1 STEP LEFT
LDX COLOR
DEC COLOR
LDA C1DATA,X
STA VIC2+$26 ;COLOR REFLECTION
LOOP11 LDA SETOGL
BNE LOOP13
JMP (NORIRQ) ;NORMAL IRQ PROCESSING
LOOP13 DEC STIMER
BNE LOOP14
LDA #%10000000
STA SID+$04 ;START RELEASE
LDA #$00
STA SETOGL ;RESET TOGGLE
LOOP14 JMP (NORIRQ) ;NORMAL IRQ PROCESSING
;
;SOUND EFFECT
;
SOUND LDA #$85
STA SID+$05 ;SET ATTACK/DECAY
LDA #$75
STA SID+$06 ;SET SUSTAIN/RELEASE
LDA #$88
STA SID ;SET LO FREQ
LDA #$03
STA SID+1 ;SET HI FREQ
LDA #%10000001
STA SID+$04 ;SET RANDOM NOISE AND GATE BIT
LDA #$05
STA STIMER ;SET SUSTAIN TIMER
STA SETOGL ;SET SOUND EFFECT TOGGLE
RTS
;
;VARIABLES AND DATA
;
TEXT .BYTE 13,05,'64 BOINK!'
.BYTE 13,'BY STEVE GOLDSMITH'
.BYTE 13,'10/06/86'
C1DATA .BYTE 11,11,11,12,15,1,15,12,11,11,11,11,11,12,15,1,15,12,11,11
TIMER .BYTE 0 ;ROTATION TIMER
ROTDIR .BYTE 0 ;ROTATION DIRECTION
XDIR .BYTE 0 ;SPRITE X DIRECTION
YDIR .BYTE 0 ;SPRITE Y DIRECTION
SETOGL .BYTE 0 ;SOUND EFFECT TOGGLE
STIMER .BYTE 0 ;SUSTAIN TIMER
COLOR .BYTE 0 ;CURRENT REFLECTION COLOR
NORIRQ .BYTE 0,0 ;IRQ JUMP VECTOR
.END