Skip to content

Instantly share code, notes, and snippets.

Created October 12, 2014 03:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/54a4047fca37b1dbe796 to your computer and use it in GitHub Desktop.
Save anonymous/54a4047fca37b1dbe796 to your computer and use it in GitHub Desktop.
Octo Chip8 Program
Play this game by pasting the program into http://johnearnest.github.io/Octo/
{"tickrate":7,"fillColor":"#FFCC00","backgroundColor":"#996600","buzzColor":"#FFAA00","quietColor":"#000000","shiftQuirks":false,"loadStoreQuirks":false}
: smile
0b00100100
0b00100100
0b00000000
0b10000001
0b01000010
0b00111100
: body
v2 := 0
loop
v0 := random 0b01111111
v1 := random 0b00111111
sprite v0 v1 6
v2 += 1
if v2 != 32 then
again
clear
;
: main
# uncomment for SuperChip high resolution mode:
hires
i := smile
loop
draw-board
v0 := key
again
:alias piecex vA
:alias piecey vB
:alias piece vC
: draw-board
piecex := 0
piecey := 0
clear
loop
# v1 = piecey * 8
v1 <<= piecey
v1 <<= v1
v1 <<= v1
# piece := board[piecex + 8*piecey]
i := board
i += piecex
i += v1
load v0
piece := v0
if piece == 0 then jump next-pos
i := white-sprites
# check if black
v0 <<= piece
if vF == 1 then i := black-sprites
# i := (white/black)-sprites[piece_number * 8]
# note that v0 already is piece_number * 2
v0 <<= v0
v0 <<= v0
i += v0
# v2 = 32 + piecex * 8
v2 <<= piecex
v2 <<= v2
v2 <<= v2
v2 += 32
# now, v1 = piecey * 8 and v2 = 32 + piecex * 8. draw sprite!
sprite v2 v1 8
: next-pos
piecex += 1
if piecex == 8 then piecey += 1
if piecex == 8 then piecex := 0
if piecey != 8 then
again
;
# piece is:
# 000S0PPP, where S is 0/1 for white/black, and P
: board
0x82 0x83 0x84 0x85 0x86 0x84 0x83 0x82
0x81 0x81 0x81 0x81 0x81 0x81 0x81 0x81
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00
0x01 0x01 0x01 0x01 0x01 0x01 0x01 0x01
: white-sprites # HACK: need white-sprites to be 8 bytes before the pawn
0x02 0x03 0x04 0x05 0x06 0x04 0x03 0x02
: white-pawn 0x38 0x44 0x44 0x28 0x44 0x82 0xfe 0x00
: white-rook 0xaa 0xd6 0x82 0x44 0x44 0x82 0xfe 0x00
: white-knight 0x14 0x68 0x94 0xc4 0x22 0x42 0xfe 0x00
: white-bishop 0x7c 0x92 0xba 0x92 0x54 0x82 0xfe 0x00
: white-queen 0xaa 0xaa 0xaa 0x7c 0x44 0x82 0xfe 0x00
: black-sprites
: white-king 0x10 0x38 0x92 0xee 0x44 0x82 0xfe 0x00
: black-pawn 0x38 0x7c 0x7c 0x38 0x7c 0xfe 0xfe 0x00
: black-rook 0xaa 0xfe 0xfe 0x7c 0x7c 0xfe 0xfe 0x00
: black-knight 0x14 0xe8 0xf8 0x38 0x7c 0xfe 0xfe 0x00
: black-bishop 0x7c 0xee 0xc6 0xee 0x6c 0xfe 0xfe 0x00
: black-queen 0xaa 0xaa 0xaa 0x7c 0x7c 0xfe 0xfe 0x00
: black-king 0x10 0x38 0x92 0xfe 0x7c 0xfe 0xfe 0x00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment