[B][/B]After hitting a roadblock on my GB emulator I decided to start a bit lower, a Chip 8 Emulator coded entirely in E2, runs 100% without unlimited 1. Originally, like the GB emulator this was merely meant to be a proof of concept but after writing it, debugging it and optimising it like fuck I've actually got it to more or less 100% speed of a real Chip 8, and a lot of games are not only fully playable but pretty damn fun.
Chip 8 is essentially a virtual machine developed for a few computers back in the 1970's. Here are a few specifications:
4KB of Addressable memory, 0x0 to 0x1FF are reserved but can be used for fonts.
32x64 monocolour display
16 8bit registers
2 12bit registers
a 12bit wide stack
35 16 bit instructions
More info: [URL="http://en.wikipedia.org/wiki/CHIP-8"]CHIP-8 - Wikipedia, the free encyclopedia[/URL]
My emulator currently emulates all of the chip 8's instructions, all Chip 8 games work.. Input is realised with the numpad currently, the Chip-8 has 16 input keys and each game uses them different, I'll end up adding customised controls for each game but not now. The flickering is more-or-less inherent to Chip 8 and the digital screen just makes it worse but playing with the timers might calm it down, I'll have to see.
Sound is fully emulated
Memory and Stack are fully emulated
Video is fully emulated
All registers and opcode's are fully emulated.
Input is fully emulated
You can switch between games by typing !load gamename. Here's a list of game names and any relevant information. Likewise there are several demos for testing the Chip 8 emulator and displaying its capabilities.
I suggest Tetris, Pong2, Rush Hour, AstroDodge, Pacman & Space Invaders as the games to try out first, they all boast the best gameplay.
Arcade Games:
Rush Hour
Pong
Pong2
Pacman
Astrododge
Tetris
Space invaders
Blitz
Worm
Vbrix
Tank
SYZYGY
brixh
WIPEOFF
Missile
UFO
VERS
Rush Hour
Demos/Test roms:
Pic
IBM
zero
sirpinski
maze
test
Puzzle games:
Hidden
TicTac
puzzle15
puzzle
connect4
guess
KALEID
Merlin
All Roms are contained within the E2 and are in the public domain, there are no legal issues.
Video:
[URL="http://www.xfire.com/video/3abfe1/"][IMG]http://video.xfire.com/3abfe1-4.jpg[/IMG][/URL]
[URL="http://www.xfire.com/video/3ac15c/"][IMG]http://video.xfire.com/3ac15c-4.jpg[/IMG][/URL]
Pictures:
[IMG]http://img151.imageshack.us/img151/7279/hl2gmod20101112193225.png[/IMG]
[IMG]http://img560.imageshack.us/img560/9642/hl2gmod20101112193547.png[/IMG]
[IMG]http://img89.imageshack.us/img89/8404/hl2gmod20101112193607.png[/IMG]
[IMG]http://img526.imageshack.us/img526/3508/hl2gmod20101112193623.png[/IMG]
[IMG]http://img442.imageshack.us/img442/2675/hl2gmod20101112193624.png[/IMG]
[IMG]http://img46.imageshack.us/img46/5797/hl2gmod20101112193636.png[/IMG]
[IMG]http://img209.imageshack.us/img209/4513/hl2gmod20101112193717.png[/IMG]
[IMG]http://img530.imageshack.us/img530/8938/hl2gmod20101112194111.png[/IMG]
[IMG]http://img837.imageshack.us/img837/9976/hl2gmod20101112194209.png[/IMG]
[IMG]http://img541.imageshack.us/img541/7165/hl2gmod20101112194229.png[/IMG]
[IMG]http://img301.imageshack.us/img301/7030/hl2gmod20101112194232.png[/IMG]
[IMG]http://img94.imageshack.us/img94/7716/hl2gmod20101112194234.png[/IMG]
[IMG]http://img694.imageshack.us/img694/3662/hl2gmod20101112194235.png[/IMG]
[IMG]http://img577.imageshack.us/img577/5063/hl2gmod20101112194236.png[/IMG]
[IMG]http://img408.imageshack.us/img408/5894/hl2gmod20101112194311.png[/IMG]
E2 Code, to use wire the Screen to a digital screen and the Pad to a wired numpad, make sure to re spawn the E2 after wiring and use a digital screen that's got a height to width ratio of 2:1
[code]
@name Chip-8 Emultator (Techni)
@inputs [Screen Pad]:wirelink
@persist PC J [V M Stack Video Input Games]:mtable Delay Sound #Chip-8 Vars
@persist Colour [Cart Mode LastSaid]:string K K2 SoundPlay Clock Owner:entity SaveX#E2 Vars
interval(20)
Input[0,number] = Pad[".",number]
Input[1,number] = Pad["7",number]
Input[2,number] = Pad["8",number]
Input[3,number] = Pad["9",number]
Input[4,number] = Pad["4",number]
Input[5,number] = Pad["5",number]
Input[6,number] = Pad["6",number]
Input[7,number] = Pad["1",number]
Input[8,number] = Pad["2",number]
Input[9,number] = Pad["3",number]
Input[0xA,number] = Pad["0",number]
Input[0xB,number] = Pad["enter",number]
Input[0xC,number] = Pad["/",number]
Input[0xD,number] = Pad["*",number]
Input[0xE,number] = Pad["-",number]
Input[0xF,number] = Pad["+",number]
if (Sound & !SoundPlay) {
soundPlay(1,10,"synth/sine_440.wav")
SoundPlay = 1
}elseif (!Sound & SoundPlay) {
soundStop(1)
SoundPlay = 0
}
Sound = clamp(Sound-1,0,60)
Delay = clamp(Delay-1,0,60)
if (Mode == "proc") {
Clock = 14
while (perf() & Clock) {
Clock--
Op = bShl(M[PC,number],8) + M[(PC+1)%0x1000,number]
PC = (PC+2)%0x1000
#print(toString(Op,16))
I = bShr(bAnd(Op,0xF000),12)
X = bShr(bAnd(Op,0x0F00),8)
Y = bShr(bAnd(Op,0x00F0),4)
N = bAnd(Op,0x000F)
NN = bAnd(Op,0x00FF)
NNN = bAnd(Op,0x0FFF)
if (!I) {
if (Op == 0x00E0) {Video = mtable(),Screen[1048574] = 1}
elseif (Op == 0x00EE) {PC = Stack:popNumber()}
}
elseif (I == 1) {PC = NNN}
elseif (I == 2) {Stack:pushNumber(PC),PC=NNN}
elseif (I == 3) {if (V[X,number] == NN) {PC = (PC+2)%0x1000}}
elseif (I == 4) {if (V[X,number] != NN) {PC = (PC+2)%0x1000}}
elseif (I == 5 & !N) {if(V[X,number] == V[Y,number]) {PC = (PC+2)%0x1000}}
elseif (I == 6) {V[X,number] = NN}
elseif (I == 7) {V[X,number] = (V[X,number] + NN)%0x100}
elseif (I == 8) {
if (N == 0) { V[X,number] = V[Y,number]} #LOAD
elseif (N == 1) { V[X,number] = bOr(V[Y,number],V[X,number])} #OR
elseif (N == 2) { V[X,number] = bAnd(V[Y,number],V[X,number])} #AND
elseif (N == 3) { V[X,number] = bXor(V[Y,number],V[X,number])} #XOR
elseif (N == 4) {
Temp = V[X,number] + V[Y,number]
V[0xF,number] = (Temp > 0xFF ? 1 : 0)
V[X,number] = Temp%0x100
}
elseif (N == 5) {
Temp = V[X,number] - V[Y,number]
V[0xF,number] = (Temp < 0 ? 0 : 1)
V[X,number] = Temp%0x100
}
elseif (N == 6) {
V[0xF,number] = bAnd(V[X,number],1)
V[X,number] = bShr(V[X,number],1)
}
elseif (N == 7) {
Temp = V[Y,number] - V[X,number]
V[0xF,number] = (Temp < 0 ? 0 : 1)
V[X,number] = Temp%0x100
}
elseif (N == 0xE) {
V[0xF,number] = (bAnd(V[X,number],0x80) == 0x80 ? 1 : 0)
V[X,number] = bShl(V[X,number],1)%0x100
}
}
elseif (I == 9 & !N) {if (V[X,number] != V[Y,number]) {PC = (PC+2)%0x1000}}
elseif (I == 0xA) {J = NNN}
elseif (I == 0xB) {PC = (NNN+V[0x0,number])%0x1000}
elseif (I == 0xC) {V[X,number] = bAnd(randint(0,0xFF),NN)}
elseif (I == 0xD) {
V[0xF,number] = 0x00
XCo = V[X,number]
YCo = V[Y,number]
for(K = 0,N-1) {
Byte = M[J+K,number]
YCo2 = YCo+K
ByteS = ("00000000" + toString(M[J+K,number],2)):right(8)
for (K2 = 1,8) {
if (ByteS:index(K2) == "1") {
XCo2 = XCo+K2
Coords = XCo+K2-1 + YCo2*64
if (Video[Coords,number] == 1){
Screen[Coords] = 0
Video[Coords,number] = 0
V[0xF,number] = 1
}
else{
Screen[Coords] = Colour
Video[Coords,number] = 1
}
}
}
}
}
elseif( I == 0xE & NN == 0x9E) {if (Input[V[X,number],number]) {PC = (PC+2)%0x1000}}
elseif (I == 0xE & NN == 0xA1) {if (!Input[V[X,number],number]) {PC = (PC+2)%0x1000}}
elseif (I == 0xF) {
if (NN == 0x07) {V[X,number] = Delay}
elseif (NN == 0x0A) {SaveX = X,Mode = "FX0A",break}
elseif (NN == 0x15) {Delay = V[X,number]}
elsei
It's great and all but.. is it a [I]contraption[/I]?
Yeah don't bother posting here on FP, since all the queers are gonna come here and complain that there's nothing "Contraption-ee" about it.
Great job, I love what you're doing, but it won't be truly appreciated here on FP.
I myself was going to work on a 16 bit microprocessor that would run compiled ASM, but Wire2 never got finished. I should attempt this in E2 seeing how it would be easier :P
I appreciate this, it functions well.
I'm a computer science student
this is relevant to my interests.
[img]http://static.facepunch.com/fp/ratings/heart.png[/img]
you'll all like this
[url=http://www.engadget.com/2010/11/15/chip-8-emulation-comes-to-half-life-2-you-can-finally-retire-yo/]CHIP-8 emulation comes to Half-Life 2, you can finally retire your Telmac 1800 (video) -- Engadget[/url]
Haha, oh wow
Congrats!
You can use Hex in e2?
Sorry, you need to Log In to post a reply to this thread.