Clean up Assembly files (#1003)

This commit is contained in:
MrBrain295
2021-05-08 09:57:36 -05:00
committed by GitHub
parent 45856bf57b
commit 7f7369291b
20 changed files with 174 additions and 196 deletions

View File

@@ -1,6 +1,4 @@
;
; hello.asm
;
; A "Hello, World!" which illustrates an Atari 2600 programming
; introduction talk (slides at http://slideshare.net/chesterbr).
;
@@ -13,69 +11,68 @@
PROCESSOR 6502
INCLUDE "vcs.h"
ORG $F000 ; Start of "cart area" (see Atari memory map)
ORG $F000
StartFrame:
lda #%00000010 ; Vertical sync is signaled by VSYNC's bit 1...
lda #%00000010
sta VSYNC
REPEAT 3 ; ...and lasts 3 scanlines
sta WSYNC ; (WSYNC write => wait for end of scanline)
REPEAT 3
sta WSYNC
REPEND
lda #0
sta VSYNC ; Signal vertical sync by clearing the bit
sta VSYNC
PreparePlayfield: ; We'll use the first VBLANK scanline for setup
lda #$00 ; (could have done it before, just once)
sta ENABL ; Turn off ball, missiles and players
PreparePlayfield:
lda #$00
sta ENABL
sta ENAM0
sta ENAM1
sta GRP0
sta GRP1
sta COLUBK ; Background color (black)
sta PF0 ; PF0 and PF2 will be "off" (we'll focus on PF1)...
sta COLUBK
sta PF0
sta PF2
lda #$FF ; Playfield collor (yellow-ish)
lda #$FF
sta COLUPF
lda #$00 ; Ensure we will duplicate (and not reflect) PF
lda #$00
sta CTRLPF
ldx #0 ; X will count visible scanlines, let's reset it
REPEAT 37 ; Wait until this (and the other 36) vertical blank
sta WSYNC ; scanlines are finished
ldx #0
REPEAT 37
sta WSYNC
REPEND
lda #0 ; Vertical blank is done, we can "turn on" the beam
lda #0
sta VBLANK
Scanline:
cpx #174 ; "HELLO WORLD" = (11 chars x 8 lines - 1) x 2 scanlines =
bcs ScanlineEnd ; 174 (0 to 173). After that, skip drawing code
txa ; We want each byte of the hello world phrase on 2 scanlines,
lsr ; which means Y (bitmap counter) = X (scanline counter) / 2.
tay ; For division by two we use (A-only) right-shift
lda Phrase,y ; "Phrase,Y" = mem(Phrase+Y) (Y-th address after Phrase)
sta PF1 ; Put the value on PF bits 4-11 (0-3 is PF0, 12-15 is PF2)
cpx #174
bcs ScanlineEnd
txa
lsr
tay
lda Phrase,y
sta PF1
ScanlineEnd:
sta WSYNC ; Wait for scanline end
inx ; Increase counter; repeat untill we got all kernel scanlines
sta WSYNC
inx
cpx #191
bne Scanline
Overscan:
lda #%01000010 ; "turn off" the beam again...
sta VBLANK ;
REPEAT 30 ; ...for 30 overscan scanlines...
lda #%01000010
sta VBLANK
REPEAT 30
sta WSYNC
REPEND
jmp StartFrame ; ...and start it over!
jmp StartFrame
Phrase:
.BYTE %00000000 ; H
.BYTE %00000000
.BYTE %01000010
.BYTE %01111110
.BYTE %01000010
.BYTE %01000010
.BYTE %01000010
.BYTE %00000000
.BYTE %00000000 ; E
.BYTE %00000000
.BYTE %01111110
.BYTE %01000000
.BYTE %01111100
@@ -83,7 +80,7 @@ Phrase:
.BYTE %01000000
.BYTE %01111110
.BYTE %00000000
.BYTE %00000000 ; L
.BYTE %00000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01000000
@@ -91,14 +88,14 @@ Phrase:
.BYTE %01000000
.BYTE %01111110
.BYTE %00000000
.BYTE %00000000 ; L
.BYTE %00000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01111110
.BYTE %00000000 ; O
.BYTE %00000000
.BYTE %00000000
.BYTE %00111100
.BYTE %01000010
@@ -107,7 +104,6 @@ Phrase:
.BYTE %01000010
.BYTE %00111100
.BYTE %00000000
.BYTE %00000000 ; white space
.BYTE %00000000
.BYTE %00000000
.BYTE %00000000
@@ -115,7 +111,8 @@ Phrase:
.BYTE %00000000
.BYTE %00000000
.BYTE %00000000
.BYTE %00000000 ; W
.BYTE %00000000
.BYTE %00000000
.BYTE %01000010
.BYTE %01000010
.BYTE %01000010
@@ -123,7 +120,7 @@ Phrase:
.BYTE %01011010
.BYTE %00100100
.BYTE %00000000
.BYTE %00000000 ; O
.BYTE %00000000
.BYTE %00111100
.BYTE %01000010
.BYTE %01000010
@@ -131,7 +128,7 @@ Phrase:
.BYTE %01000010
.BYTE %00111100
.BYTE %00000000
.BYTE %00000000 ; R
.BYTE %00000000
.BYTE %01111100
.BYTE %01000010
.BYTE %01000010
@@ -139,7 +136,7 @@ Phrase:
.BYTE %01000100
.BYTE %01000010
.BYTE %00000000
.BYTE %00000000 ; L
.BYTE %00000000
.BYTE %01000000
.BYTE %01000000
.BYTE %01000000
@@ -147,21 +144,19 @@ Phrase:
.BYTE %01000000
.BYTE %01111110
.BYTE %00000000
.BYTE %00000000 ; D
.BYTE %00000000
.BYTE %01111000
.BYTE %01000100
.BYTE %01000010
.BYTE %01000010
.BYTE %01000100
.BYTE %01111000
.BYTE %00000000 ; Last byte written to PF1 (important, ensures lower tip
; of letter "D" won't "bleeed")
.BYTE %00000000)
ORG $FFFA ; Cart config (so 6502 can start it up)
.WORD StartFrame ; NMI
.WORD StartFrame ; RESET
.WORD StartFrame ; IRQ
ORG $FFFA
.WORD StartFrame
.WORD StartFrame
.WORD StartFrame
END