Skip to content

Commit 051446a

Browse files
committed
Working on exercises
1 parent 7efcee5 commit 051446a

18 files changed

+2104
-5
lines changed

exercises/completed/exercise0.asm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
; Exercise 0
33
; In this exercise you will learn how to set the background color
44
;
5-
; Code is written for running in 8bitworkshop.com. Stub
6-
; is copied from there and "Making Games For The Atari 2600
5+
; Written for use with 8bitworkshop.com.
6+
; Code included there and "Making Games For The Atari 2600"
77
; by Steven Hugg
88
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
99

exercises/completed/exercise1.asm

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; Exercise 1
3+
; In this exercise you will cycle the background color, and
4+
; learn about the X register and decrementing
5+
;
6+
; Written for use with 8bitworkshop.com.
7+
; Code included there and "Making Games For The Atari 2600"
8+
; by Steven Hugg
9+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11+
;;;; Header
12+
;;;; Needed at top of all your source files
13+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14+
15+
processor 6502
16+
include "vcs.h"
17+
org $f000
18+
19+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20+
;;;; GENERAL INIT
21+
;;;; This code is necessary for initialization
22+
;;;; but you can ignore it until you get curious
23+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24+
25+
Start sei
26+
cld
27+
ldx #$ff
28+
txs
29+
lda #0 ;
30+
ldx #$ff
31+
ZeroZP sta $0,X
32+
dex
33+
bne ZeroZP
34+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35+
36+
NextFrame
37+
38+
;;; INSERT YOUR CODE BELOW THIS
39+
STX COLUBK
40+
DEX
41+
;;; AND ABOVE THIS
42+
43+
jmp NextFrame
44+
45+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
46+
;;;; Footer
47+
;;;; Needed at bottom of all your source files
48+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
49+
org $fffc
50+
.word Start
51+
.word Start

exercises/completed/exercise2.asm

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; Exercise 1
3+
; In this exercise you will cycle the background color, and
4+
; learn about the X register and decrementing
5+
;
6+
; Written for use with 8bitworkshop.com.
7+
; Code included there and "Making Games For The Atari 2600"
8+
; by Steven Hugg
9+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11+
;;;; Header
12+
;;;; Needed at top of all your source files
13+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14+
15+
processor 6502
16+
include "vcs.h"
17+
org $f000
18+
19+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20+
;;;; GENERAL INIT
21+
;;;; This code is necessary for initialization
22+
;;;; but you can ignore it until you get curious
23+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24+
25+
Start sei
26+
cld
27+
ldx #$ff
28+
txs
29+
lda #0 ;
30+
ldx #$ff
31+
ZeroZP sta $0,X
32+
dex
33+
bne ZeroZP
34+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35+
36+
NextFrame
37+
38+
;;; INSERT YOUR CODE BELOW THIS
39+
STX COLUBK
40+
DEX
41+
STA WSYNC
42+
;;; AND ABOVE THIS
43+
44+
jmp NextFrame
45+
46+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
47+
;;;; Footer
48+
;;;; Needed at bottom of all your source files
49+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
50+
org $fffc
51+
.word Start
52+
.word Start

exercises/completed/exercise3.asm

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; Exercise 1
3+
; In this exercise you will cycle the background color, and
4+
; learn about the X register and decrementing
5+
;
6+
; Written for use with 8bitworkshop.com.
7+
; Code included there and "Making Games For The Atari 2600"
8+
; by Steven Hugg
9+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11+
;;;; Header
12+
;;;; Needed at top of all your source files
13+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14+
15+
processor 6502
16+
include "vcs.h"
17+
org $f000
18+
19+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
20+
;;;; GENERAL INIT
21+
;;;; This code is necessary for initialization
22+
;;;; but you can ignore it until you get curious
23+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
24+
25+
Start sei
26+
cld
27+
ldx #$ff
28+
txs
29+
lda #0 ;
30+
ldx #$ff
31+
ZeroZP sta $0,X
32+
dex
33+
bne ZeroZP
34+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
35+
36+
NextFrame
37+
; next two lines turn off beam
38+
lda #2
39+
sta VBLANK
40+
; now three lines of vsync per spec
41+
sta VSYNC
42+
sta WSYNC
43+
sta WSYNC
44+
sta WSYNC
45+
46+
; turn off vsync
47+
lda #0
48+
sta VSYNC
49+
50+
; now loop through 36 vertical blank lines
51+
ldx #36
52+
VBlankLoop
53+
sta WSYNC
54+
dex
55+
bne VBlankLoop
56+
57+
; we will use our final vblank line to setup
58+
; any drawing
59+
;;; INSERT YOUR CODE BELOW THIS
60+
DEY
61+
STY COLUBK
62+
STA WSYNC
63+
64+
;;; AND ABOVE THIS
65+
66+
; now turn beam back on and draw 192 lines
67+
lda #0
68+
sta VBLANK
69+
ldx #192
70+
ScanLoop
71+
sta WSYNC
72+
dex
73+
bne ScanLoop
74+
75+
; now draw 30 lines of overscan after
76+
; turning beam off again
77+
lda #2
78+
sta VBLANK
79+
ldx #30
80+
OverscanLoop
81+
sta WSYNC
82+
dex
83+
bne OverscanLoop
84+
85+
;;; Now we've drawn our
86+
;;; 3 VSYNC lines
87+
;;; 37 VBLANK lines
88+
;;; 192 scan lines
89+
;;; 30 overscan lines
90+
91+
jmp NextFrame
92+
93+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
94+
;;;; Footer
95+
;;;; Needed at bottom of all your source files
96+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
97+
org $fffc
98+
.word Start
99+
.word Start

exercises/completed/exercise4.asm

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
2+
; Exercise 4
3+
; In this exercise you will cycle the background color more slowly
4+
; and learn about variables
5+
;
6+
; Written for use with 8bitworkshop.com.
7+
; Code included there and "Making Games For The Atari 2600"
8+
; by Steven Hugg
9+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
10+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
11+
;;;; Header
12+
;;;; Needed at top of all your source files
13+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
14+
15+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
16+
17+
processor 6502
18+
include "vcs.h"
19+
20+
;;;;;;;;;;;;;;;;;; VARIABLE SEGMENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;
21+
22+
seg.u Variables
23+
org $80
24+
25+
;;; INSERT YOUR VARIABLES BELOW THIS
26+
BackgroundColor .byte
27+
CycleSpeed .byte
28+
;;; AND ABOVE THIS
29+
30+
;;;;;;;;;;;;;;;;;; CODE SEGMENT ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31+
32+
seg Code
33+
org $f000
34+
35+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
36+
;;;; GENERAL INIT
37+
;;;; This code is necessary for initialization
38+
;;;; but you can ignore it until you get curious
39+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
40+
41+
Start sei
42+
cld
43+
ldx #$ff
44+
txs
45+
lda #0 ;
46+
ldx #$ff
47+
ZeroZP sta $0,X
48+
dex
49+
bne ZeroZP
50+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
51+
52+
;;; INITIALIZE YOUR VARIABLES BELOW THIS
53+
LDA #10
54+
STA CycleSpeed
55+
TAY
56+
LDA #40
57+
STA BackgroundColor
58+
;;; AND ABOVE THIS
59+
60+
61+
NextFrame
62+
; next two lines turn off beam
63+
lda #2
64+
sta VBLANK
65+
; now three lines of vsync per spec
66+
sta VSYNC
67+
sta WSYNC
68+
sta WSYNC
69+
sta WSYNC
70+
71+
; turn off vsync
72+
lda #0
73+
sta VSYNC
74+
75+
; now loop through 36 vertical blank lines
76+
ldx #36
77+
VBlankLoop
78+
sta WSYNC
79+
dex
80+
bne VBlankLoop
81+
82+
; we will use our final vblank line to setup
83+
; any drawing
84+
;;; INSERT YOUR CODE BELOW THIS
85+
DEY
86+
BNE SkipDecrementColor
87+
LDY BackgroundColor
88+
DEY
89+
STY BackgroundColor
90+
LDY CycleSpeed
91+
SkipDecrementColor
92+
LDA BackgroundColor
93+
STA COLUBK
94+
;;; AND ABOVE THIS
95+
sta WSYNC
96+
97+
; now turn beam back on and draw 192 lines
98+
lda #0
99+
sta VBLANK
100+
ldx #192
101+
ScanLoop
102+
sta WSYNC
103+
dex
104+
bne ScanLoop
105+
106+
; now draw 30 lines of overscan after
107+
; turning beam off again
108+
lda #2
109+
sta VBLANK
110+
ldx #30
111+
OverscanLoop
112+
sta WSYNC
113+
dex
114+
bne OverscanLoop
115+
116+
;;; Now we've drawn our
117+
;;; 3 VSYNC lines
118+
;;; 37 VBLANK lines
119+
;;; 192 scan lines
120+
;;; 30 overscan lines
121+
122+
jmp NextFrame
123+
124+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
125+
;;;; Footer
126+
;;;; Needed at bottom of all your source files
127+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
128+
org $fffc
129+
.word Start
130+
.word Start

0 commit comments

Comments
 (0)