1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-12-01 13:50:30 +00:00
8bitworkshop/presets/vcs/examples/testlibrary.a

265 lines
4.8 KiB
Plaintext

processor 6502
include "vcs.h"
include "macro.h"
include "xmacro.h"
include "xtimer.h"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
seg.u Variables
org $80
Temp1 .byte
Temp2 .byte
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
seg Code
org $f000
jmp Start
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
include "setpos.inc" ; SetHorizPos routine
include "xtimer.inc" ; WaitForScanline routine and lookup table
include "multisprite.inc" ; multi 2-player color 2-line kernel w/ background
include "6digit.inc" ; 6-digit scoreboard
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Initialize and set initial X and Y offsets of objects.
Start
CLEAN_START
jsr MSpriteInit
ldx #0
lda #MinYPos
ldy #40
InitLoop
sty XPos0,x
sta YPos0,x
sta Flags0,x
clc
adc #23
iny
iny
iny
iny
iny
iny
inx
cpx #NSprites
bne InitLoop
lda #0
sta Shape0
lda #1
sta Shape0+1
lda #2
sta Shape0+2
sta Shape0+4
sta Shape0+6
lda #3
sta Shape0+3
sta Shape0+5
sta Shape0+7
lda #>Start
sta PF0Ptr+1
lda #>Start+1
sta PF1Ptr+1
lda #>Start+1
sta PF2Ptr+1
lda YPos0+1
adc #9
sta YPos0+1
; Next frame loop
NextFrame
VERTICAL_SYNC
TIMER_SETUP 37
; Do joystick movement
ldy #1
jsr MoveJoystick
jsr GetDigitPtrs
jsr MSpritePre
TIMER_WAIT
; end of VBLANK
; Needed for single-line kernel
TIMER_TABLE_SETUP
; Scoreboard
jsr DrawDigits
; Scanline loop
lda #$90
sta COLUBK
lda #22
jsr MSpriteDraw2
; Overscan
TIMER_SETUP 28
; Clear all colors to black before overscan
ldx #0
stx COLUBK
stx COLUP0
stx COLUP1
stx COLUPF
; add score
ldy #0
ldx #0
lda #1
jsr AddScore
; 30-2 lines of overscan
TIMER_WAIT
; Go to next frame
jmp NextFrame
; Read joystick movement and apply to object 0
MoveJoystick subroutine
; Move vertically
ldx YPos0,y
lda #%00010000 ;Up?
bit SWCHA
bne .SkipMoveUp
cpx #MinYPos+1
bcc .SkipMoveUp
dex
.SkipMoveUp
lda #%00100000 ;Down?
bit SWCHA
bne .SkipMoveDown
cpx #180
bcs .SkipMoveDown
inx
.SkipMoveDown
stx YPos0,y
; Move horizontally
ldx XPos0,y
lda #%01000000 ;Left?
bit SWCHA
bne .SkipMoveLeft
cpx #5
bcc .SkipMoveLeft
dex
lda #$08
sta Flags0,y
.SkipMoveLeft
lda #%10000000 ;Right?
bit SWCHA
bne .SkipMoveRight
cpx #160
bcs .SkipMoveRight
inx
lda #$00
sta Flags0,y
.SkipMoveRight
stx XPos0,y
rts
; TODO: do we need trailing padding?
; Bitmap data "standing" position
Frame0
.byte #0
.byte #%01101100;$F6
.byte #%00101000;$86
.byte #%00101000;$86
.byte #%00111000;$86
.byte #%10111010;$C2
.byte #%10111010;$C2
.byte #%01111100;$C2
.byte #%00111000;$C2
.byte #%00111000;$16
.byte #%01000100;$16
.byte #%01111100;$16
.byte #%01111100;$18
.byte #%01010100;$18
.byte #%01111100;$18
.byte #%11111110;$F2
.byte #%00111000;$F4
; Bitmap data "throwing" position
Frame1
.byte #0
.byte #%01101100;$F6
.byte #%01000100;$86
.byte #%00101000;$86
.byte #%00111000;$86
.byte #%10111010;$C2
.byte #%10111101;$C2
.byte #%01111101;$C2
.byte #%00111001;$C2
.byte #%00111000;$16
.byte #%01101100;$16
.byte #%01111100;$16
.byte #%01111100;$18
.byte #%01010100;$18
.byte #%01111100;$18
.byte #%11111110;$F2
.byte #%00111000;$F4
; Color data for each line of sprite
ColorFrame0
.byte #16 ; height
.byte #$F6;
.byte #$86;
.byte #$86;
.byte #$86;
.byte #$C2;
.byte #$C2;
.byte #$C2;
.byte #$C2;
.byte #$16;
.byte #$16;
.byte #$16;
.byte #$18;
.byte #$18;
.byte #$18;
.byte #$F2;
.byte #$F4;
; Enemy cat-head graphics data
EnemyFrame0
.byte #0
.byte #%00111100;$AE
.byte #%01000010;$AE
.byte #%11100111;$AE
.byte #%11111111;$AC
.byte #%10011001;$8E
.byte #%01111110;$8E
.byte #%11000011;$98
.byte #%10000001;$98
; Enemy cat-head color data
EnemyColorFrame0
.byte #8 ; height
.byte #$AE;
.byte #$AC;
.byte #$A8;
.byte #$AC;
.byte #$8E;
.byte #$8E;
.byte #$98;
.byte #$94;
; Enemy cat-head color data
EnemyColorFrame1
.byte #8 ; height
.byte #$FE;
.byte #$FC;
.byte #$28;
.byte #$2C;
.byte #$EE;
.byte #$EE;
.byte #$D8;
.byte #$D4;
; Mapping of sprite shapes to sprite data
SpriteDataMap
.word Frame0,ColorFrame0
.word Frame1,ColorFrame0
.word EnemyFrame0,EnemyColorFrame0
.word EnemyFrame0,EnemyColorFrame1
; Epilogue
org $fffc
.word Start
.word Start