Skip to content

Instantly share code, notes, and snippets.

@Azzizi
Last active October 31, 2015 00:32
Show Gist options
  • Save Azzizi/537dfc6201dc356ef457 to your computer and use it in GitHub Desktop.
Save Azzizi/537dfc6201dc356ef457 to your computer and use it in GitHub Desktop.
prog.sublime-project
prog.sublime-workspace
A game for the Octo Chip-8 assembler/simulator. Play by visiting:
http://johnearnest.github.io/Octo/index.html?gist=537dfc6201dc356ef457
{"tickrate":"100","fillColor":"#306230","fillColor2":"#8BAC0F","blendColor":"#9BBC0F","backgroundColor":"#0F380F","buzzColor":"#333333","quietColor":"#000000","shiftQuirks":false,"loadStoreQuirks":false,"vfOrderQuirks":false,"enableXO":true}
# 8s Revenge is a remake of the Atari VCS classic Yars Revenge, made by
# Corwyn Kalenda (ckalenda@gmail.com) for Octo-ber II, the 2015 Octo Game
# Jam.
#
# WASD to move, V to fire.
#
# Chip8 is a virtual machine designed in 1977 for programming video games.
# Octo is a high level assembler, disassembler and simulator for Chip8.
:alias px v3
:alias py v4
:alias qx v5
:alias qy v6
:alias mx v7
:alias my v8
:alias bx v9
:alias by va
:alias zx vb
:alias zy vc
:alias flags vd
:alias frame ve
:const swirlyAnimMask 0b00000011
:const swirlyPrepMask 0b00000100
:const swirlyMoveMask 0b00001000
:const shieldModeMask 0b00010000
:const zorlonPrepMask 0b00100000
:const zorlonShotMask 0b01000000
:const playerAnimMask 0b10000000
: score
0x00 0x00
: shieldoffset
0x00
: main
hires
flags := 0b01000011 # explicitly initialize, because assumptions.
zx := 0
zy := 32
plane 2
px := 8
py := 28
v0 := 8
i := playerright
i += v0
sprite px py 8
qx := 116
qy := 28
i := quotile
sprite qx qy 9
plane 3
mx := 108
my := 32
i := missile
sprite mx my 1
loop
: nzstart
# redraw the neutral zone
plane 1
i := main
v0 := random 0b1111111
i += v0
v1 := 50
v2 := 0
v0 := 16
sprite v1 v2 0
v2 += v0
i += v0
sprite v1 v2 0
v2 += v0
i += v0
sprite v1 v2 0
v2 += v0
i += v0
sprite v1 v2 0
: zorlonstart
plane 3
i := zorlon
: zorlonprep
v0 := zorlonPrepMask
v0 &= flags
if v0 == 0 then jump zorlonshot
sprite zx zy 2
zx := 0
zy := py
zy += 3
i := main
v0 := random 0b1111111
i += v0
load v1
i := zorlon
save v1
i := main
v0 := random 0b1111111
i += v0
load v1
i := zorlon
v2 := 2
i += v2
save v1
i := zorlon
sprite zx zy 2
: zorlonshot
v0 := zorlonShotMask
v0 &= flags
if v0 == 0 then jump zorlonDone
sprite zx zy 2
zx += 4
v0 := 0b10000000
v0 &= zx
if v0 != 0 then jump zorlonreset #zx is >= 128
i := main
v0 := random 0b1111111
i += v0
load v1
i := zorlon
save v1
i := main
v0 := random 0b1111111
i += v0
load v1
i := zorlon
v2 := 2
i += v2
save v1
i := zorlon
sprite zx zy 2
jump zorlonDone
: zorlonreset
v0 := zorlonShotMask
v1 := 0xFF
v0 ^= v1
flags &= v0
: zorlonDone
: quotilestart
# erase, update, and redraw Quotile
v0 := swirlyAnimMask
v0 &= flags
if v0 == 3
begin
i := quotile
sprite qx qy 9
#update position here
sprite qx qy 9
else
i := swirly
if v0 == 0
begin
v1 := 0
else
if v0 == 1
begin
v1 := 8
i += v1
else
if v0 == 2
begin
v1 := 16
i += v1
end
end
end
sprite qx qy 8
# set frame to next, draw, and update flags register
v0 += 1
v1 := 8
if v0 == 3
begin
v0 := 0
i := swirly
else
i += v1
end
sprite qx qy 8
v1 := 0b11111100
flags &= v1
flags |= v0
end
: missileStart
plane 3
v0 := 3
v0 &= frame
if v0 != 0 then jump missileDone
i := missile
sprite mx my 1
v0 := px
v0 += 4
if mx == v0 then jump missileY
v0 -= mx
v1 := 0b10000000
v0 &= v1
if v0 == 0 begin mx += 1 else mx += -1 end
: missileY
v0 := py
v0 += 4
if my == v0 then jump missileDraw
v0 -= my
v1 := 0b10000000
v0 &= v1
if v0 == 0 begin my += 1 else my += -1 end
: missileDraw
sprite mx my 1
: missileDone
: playerstart
plane 2
# erase player
i := playerright
v0 := playerAnimMask
v0 &= flags
if v0 == 0
begin
v0 := 8
i += v0
end
sprite px py 8
# update player position
v0 := 5 if v0 key begin py += -2 if py == 252 then py := 60 end # keyboard W
v0 := 8 if v0 key begin py += 2 if py == 60 then py := 252 end # keyboard S
v0 := 7 if v0 key begin if px != 8 then px += -2 end # keyboard A
v0 := 9 if v0 key begin if px != 114 then px += 2 end # keyboard D
# redraw player
i := playerright
v0 := playerAnimMask
flags ^= v0 # advance the animation frame by toggling the flag from last frame
v0 &= flags
if v0 == 0
begin
v0 := 8
i += v0
end
sprite px py 8
: bulletstart
plane 1
#first check to see if a bullet is active. If not, check for input
if bx != 0 then jump updatebullet
v0 := 0x0F
if v0 -key then jump bulletdone
bx := px
bx += 8
by := py
by += 3
i := bullet
sprite bx by 1
: updatebullet
# erase bullet, update, redraw
i := bullet
sprite bx by 1
bx += 4
v0 := 0b10000000
v0 &= bx
if v0 == 0 then jump bulletdraw #bx is < 128
bx := 0
jump bulletdone
: bulletdraw
sprite bx by 1
: bulletdone
: framedone
# lock the framerate of this program via the delay timer:
loop
vf := delay
if vf != 0 then
again
vf := 2
delay := vf
frame += 1
again
: playerright
0x1C 0x10 0x99 0xE6 0xE6 0x99 0x10 0x1C
0x40 0x70 0x99 0xE6 0xE6 0x99 0x70 0x40
: quotile
0x0F 0x1B 0x33 0xE3 0xFF 0xE3 0x33 0x1B
0x0F
: swirly
0x18 0x20 0x26 0x99 0x99 0x64 0x04 0x18
0x0C 0x10 0x90 0x9E 0x79 0x09 0x08 0x30
0x20 0x4E 0x49 0x78 0x1E 0x92 0x72 0x04
: bullet
0x80
: missile
0x7E 0x7E
: zorlon
0x00 0x00 0x00 0x00
: shield
#two copies of sheild buffer for scrolling/rotation purposes
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF 0xFF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment