;***************************************************************
;
; ENAM1 With Multicolored Sprite and Borders
;
; Example program by Duane Alan Hahn (Random Terrain) using
; hints, tips, code snippets, and more from AtariAge members
; such as batari, SeaGtGruff, RevEng, Robert M, Nukey Shay,
; Atarius Maximus, jrok, supercat, GroovyBee, and bogax.
;
;```````````````````````````````````````````````````````````````
;
; If this program will not compile for you, get the latest
; version of batari Basic:
;
; http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#gettingstarted
;
;***************************************************************
;****************************************************************
;
; The kernel options below cause the loss of missile1 and
; missile0.
;
set kernel_options player1colors pfcolors no_blank_lines
;***************************************************************
;
; Variable aliases go here (DIMs).
;
; You can have more than one alias for each variable.
; If you use different aliases for bit operations,
; it's easier to understand and remember what they do.
;
; I start variable aliases with one underscore so I won't
; have to worry that I might be using bB keywords by mistake.
; I also start labels with two underscores for the same
; reason. The second underscore also makes labels stand out
; so I can tell at a glance that they are labels and not
; variables.
;
; Use bit operations any time you need a simple off/on
; variable. One variable essentially becomes 8 smaller
; variables when you use bit operations.
;
; I start my bit aliases with "_Bit" then follow that
; with the bit number from 0 to 7, then another underscore
; and the name. Example: _Bit0_Reset_Restrainer
;
;```````````````````````````````````````````````````````````````
; Border color.
;
dim _Border_Color = x
;```````````````````````````````````````````````````````````````
; Tiny little itty-bitty bit variables.
;
dim _Bit0_Reset_Restrainer = y
;```````````````````````````````````````````````````````````````
; Makes better random numbers.
;
dim rand16 = z
;***************************************************************
;
; Defines the edges of the playfield for an 8 x 5 sprite.
; If your sprite is a different size, you'll need to adjust
; the numbers.
;
const _P_Edge_Top = 6
const _P_Edge_Bottom = 89
const _P_Edge_Left = 1
const _P_Edge_Right = 152
;****************************************************************
;
; NTSC colors. Use these constants so you can quickly and
; easily swap them out for PAL-60 colors.
;
const _00 = $00
const _02 = $02
const _04 = $04
const _06 = $06
const _08 = $08
const _0A = $0A
const _0C = $0C
const _0E = $0E
const _10 = $10
const _12 = $12
const _14 = $14
const _16 = $16
const _18 = $18
const _1A = $1A
const _1C = $1C
const _1E = $1E
const _20 = $20
const _22 = $22
const _24 = $24
const _26 = $26
const _28 = $28
const _2A = $2A
const _2C = $2C
const _2E = $2E
const _30 = $30
const _32 = $32
const _34 = $34
const _36 = $36
const _38 = $38
const _3A = $3A
const _3C = $3C
const _3E = $3E
const _40 = $40
const _42 = $42
const _44 = $44
const _46 = $46
const _48 = $48
const _4A = $4A
const _4C = $4C
const _4E = $4E
const _50 = $50
const _52 = $52
const _54 = $54
const _56 = $56
const _58 = $58
const _5A = $5A
const _5C = $5C
const _5E = $5E
const _60 = $60
const _62 = $62
const _64 = $64
const _66 = $66
const _68 = $68
const _6A = $6A
const _6C = $6C
const _6E = $6E
const _70 = $70
const _72 = $72
const _74 = $74
const _76 = $76
const _78 = $78
const _7A = $7A
const _7C = $7C
const _7E = $7E
const _80 = $80
const _82 = $82
const _84 = $84
const _86 = $86
const _88 = $88
const _8A = $8A
const _8C = $8C
const _8E = $8E
const _90 = $90
const _92 = $92
const _94 = $94
const _96 = $96
const _98 = $98
const _9A = $9A
const _9C = $9C
const _9E = $9E
const _A0 = $A0
const _A2 = $A2
const _A4 = $A4
const _A6 = $A6
const _A8 = $A8
const _AA = $AA
const _AC = $AC
const _AE = $AE
const _B0 = $B0
const _B2 = $B2
const _B4 = $B4
const _B6 = $B6
const _B8 = $B8
const _BA = $BA
const _BC = $BC
const _BE = $BE
const _C0 = $C0
const _C2 = $C2
const _C4 = $C4
const _C6 = $C6
const _C8 = $C8
const _CA = $CA
const _CC = $CC
const _CE = $CE
const _D0 = $D0
const _D2 = $D2
const _D4 = $D4
const _D6 = $D6
const _D8 = $D8
const _DA = $DA
const _DC = $DC
const _DE = $DE
const _E0 = $E0
const _E2 = $E2
const _E4 = $E4
const _E6 = $E6
const _E8 = $E8
const _EA = $EA
const _EC = $EC
const _EE = $EE
const _F0 = $F0
const _F2 = $F2
const _F4 = $F4
const _F6 = $F6
const _F8 = $F8
const _FA = $FA
const _FC = $FC
const _FE = $FE
;***************************************************************
;***************************************************************
;
; PROGRAM START/RESTART
;
;
__Start_Restart
;***************************************************************
;
; Mutes volume of both sound channels.
;
AUDV0 = 0 : AUDV1 = 0
;***************************************************************
;
; Clears the normal 26 variables.
;
a = 0 : b = 0 : c = 0 : d = 0 : e = 0 : f = 0 : g = 0 : h = 0 : i = 0
j = 0 : k = 0 : l = 0 : m = 0 : n = 0 : o = 0 : p = 0 : q = 0 : r = 0
s = 0 : t = 0 : u = 0 : v = 0 : w = 0 : x = 0 : y = 0
;***************************************************************
;
; Sets background color.
;
COLUBK = _00
;***************************************************************
;
; Gets a random color from $0A to $FA for the border.
;
_Border_Color = ((rand&15)*16)+10
;***************************************************************
;
; Defines shape and color of player1 sprite.
;
player1:
%00000000
%01111000
%00111111
%00111111
%01111000
%11100000
end
player1color:
_00
_06
_04
_08
_0A
_0C
end
;***************************************************************
;
; Restrains the reset switch for the main loop.
;
; This bit fixes it so the reset switch becomes inactive if
; it hasn't been released after being pressed once.
;
_Bit0_Reset_Restrainer{0} = 1
;***************************************************************
;
; Sets starting position of player1 and missiles.
;
player1x = 62 : player1y = 50 : missile1x = 92 : missile0x = 152
;***************************************************************
;***************************************************************
;
; MAIN LOOP (MAKES THE PROGRAM GO)
;
;
__Main_Loop
;***************************************************************
;
; Turns on missile1 strip and sets 4 pixel wide missile and
; 1 copy of player and missile.
;
ENAM1{1} = 1 : NUSIZ1= $20
;***************************************************************
;
; Turns on missile0 strip and sets 4 pixel wide missile and
; 2 close-spaced copies of player0 and missile0.
;
ENAM0{1} = 1 : NUSIZ0= $21
;***************************************************************
;
; Sets border color.
;
COLUP0 = _Border_Color
;***************************************************************
;
; Moves player1 sprite with the joystick while keeping the
; sprite within the playfield area.
;
if joy0up && player1y > _P_Edge_Top then player1y = player1y - 1
if joy0down && player1y < _P_Edge_Bottom then player1y = player1y + 1
if joy0left && player1x > _P_Edge_Left then player1x = player1x - 1
if joy0right && player1x < _P_Edge_Right then player1x = player1x + 1
;***************************************************************
;
; Displays the screen.
;
drawscreen
;***************************************************************
;
; Reset switch check and end of main loop.
;
; Any Atari 2600 program should restart when the reset
; switch is pressed. It is part of the usual standards
; and procedures.
;
;```````````````````````````````````````````````````````````````
; Turns off reset restrainer bit and jumps to beginning of
; main loop if the reset switch is not pressed.
;
if !switchreset then _Bit0_Reset_Restrainer{0} = 0 : goto __Main_Loop
;```````````````````````````````````````````````````````````````
; Jumps to beginning of main loop if the reset switch hasn't
; been released after being pressed.
;
if _Bit0_Reset_Restrainer{0} then goto __Main_Loop
;```````````````````````````````````````````````````````````````
; Restarts the program.
;
goto __Start_Restart
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````
;
; END OF MAIN LOOP
;
;,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
;```````````````````````````````````````````````````````````````