-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathh_coord_pos.dasm
138 lines (113 loc) · 1.85 KB
/
h_coord_pos.dasm
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
processor 6502
include "vcs.h"
include "macro.h"
seg.u variables
org $80
PlayerXPos byte
seg code
org $f000
Start:
sei
cld
ldx #$ff
txs
CLEAN_START
lda #40
sta PlayerXPos
lda #$aa
sta COLUBK
NextFrame:
lda #2
sta VSYNC
sta VBLANK
sta WSYNC
sta WSYNC
sta WSYNC
lda #0
sta VSYNC
lda PlayerXPos
and #$7F ; kinda dump way to be sure PlayerXPos is positive
sec
sta WSYNC
sta HMCLR ; clear all the horizontal movement
; all this shit is about to position p0 sprite horizontally
; (x + 68) / 15 cycles waiting
; x is TIA color cycles. Kinda pixels
; 68 because of horizontal blank
; 15 because it's 5 x 3. Where 5 is CPU cycles wasted by
; sbs and bcs, 2 and 3 cycles
; and x3 because 1 CPU cycle is 3 TIA cycles
; Reminder goes to fine hpos value
DivideLoop:
sbc #15
bcs DivideLoop
eor #7
asl
asl
asl
asl
sta HMP0 ; set fine value (from -8 to 7)
sta RESP0 ; set rough "15" value
sta WSYNC
sta HMOVE ; apply horizontal movement
REPEAT 35
sta WSYNC
REPEND
lda #0
sta VBLANK
REPEAT 50
sta WSYNC
REPEND
ldx #8
DrawPlayer:
lda Player,X
sta GRP0
lda PlayerColors,X
sta COLUP0
sta WSYNC
dex
bne DrawPlayer
lda #0
sta GRP0
REPEAT #134
STA WSYNC
REPEND
lda #2
sta VBLANK
REPEAT 30
sta WSYNC
REPEND
; to put movement in 40 to 80 range
sec
inc PlayerXPos
lda PlayerXPos
cmp #80
bcc Next
lda #40
sta PlayerXPos
Next
jmp NextFrame
org $ffea
Player:
byte %00000000 ;
byte %00111100 ; ####
byte %01111110 ; ######
byte %11111111 ; ########
byte %11111111 ; ########
byte %11111111 ; ########
byte %01111110 ; ######
byte %00010000 ; #
byte %00111000 ; ###
PlayerColors:
byte $40 ; Red gradient
byte $40 ; Red gradient
byte $42 ;
byte $44 ;
byte $44 ;
byte $48 ;
byte $48 ;
byte $ca ; Dark green
byte $c4 ; Dark green
org $fffc
.word Start
.word Start