Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Anyone else written a chip8 interpeter/emulator in agk?

Author
Message
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 11:31 Edited at: 30th Jul 2016 16:26
This is updated here instead from now on to be sure to get the latest files.
https://forum.thegamecreators.com/outbound?url=https%3A%2F%2Fforum.thegamecreators.com%2Fthread%2F217664

I have bin away from programmng in such a long time so i decided that i should do this for a project.

But yes there are many pitfalls when trying to convert all java,python and c turorials to agk

More intrested if anyone made a functional one so far in agk??

My own goes pretty slow as i have to write so many own commands like converting char to unicode and hex bitwise operations etc

It did not help that agk now only have unsigned bitshift and ot signed that it neads.

i have intended to release it as a free source in the codebase when its done . ( if its done )


Edited...............
In case you dont know wath chip8 is
http://www.markoskyritsis.com/index.php/open-source-development/chip8-online-emulator

Its the first emulator you are recomended to write before anyone else

edited............
added latest image of the progress
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Jul 2016 13:29 Edited at: 27th Jul 2016 13:31
i would start loading a bytecode file and in agk you need read this memory (memblock commands) and make functions for this opcodes.
then u need simulate the memory,register,graphics & sound (i read it have only a beep),input devices.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 13:34
I have all opcodes,cpu,rendering done
But i belive there is something with reading the rom file ???

The only thing missing is keyboard working but if its not rendering
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 13:50
Changed readline to read byte and it now at least only have 3000 no draw calls on each 50 draw call
With readline so did it have 22 000 no draw calls on each draw call

My problems is in reading the rom so far i belive ???
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 14:05
This is pong
Its supposed to be
changed to readbyte and converts it to a binary and then value so does it at least draw something
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 27th Jul 2016 15:12
Quote: "changed to readbyte and converts it to a binary and then value so does it at least draw something "


so you're converting the byte to a binary string or something ?? that's a lot of memory thrashing in something like a draing loop.

You can mask them to check what bits and set or clear.





Depending upon the number of colours, i'd actually unroll the into groups of 4 or 2 bits. Which reduce the runtime ovehead massively.







PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 17:06
Thanks kevin

Iam a bit stuck as i try to solve how to do the java command ( The bitwise ^ operator performs a bitwise exclusive OR operation ).

Iam completely stuck

Agk only have inclusive or.........
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Kevin Picone
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 27th Jul 2016 17:58

I remember needed to manually compute it way back in the every early DB classic days, would assume it's in AGK.

But if not,

Manually Computing XOR (Exclusive OR) using AND / OR operators

PlayBASIC To HTML5/WEB - Convert PlayBASIC To Machine Code
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 27th Jul 2016 18:11 Edited at: 27th Jul 2016 18:13
"BITWISE XOR signified by the symbol ~~ will XOR all bits of one value with another."
https://www.appgamekit.com/documentation/principles/2_operators.htm

don't know if you can use this
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 18:58 Edited at: 27th Jul 2016 19:03
I have read the bitwise page to death and tryed xor and everything

The hard part is that its enough that one line of 700 is wrong to trash everything

Spent about 1 week now and still not getting it to work

I could e as simple as agk is missing commands i nead
And it where a while i coded

edited.........
i found in one of the update pages for agk that they switched or to unsigned from signed that it says in the help file.

edited....
this is the pong rom i try to load if anyone have suggestions
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 22:43 Edited at: 27th Jul 2016 23:11
Thanks for all feedback

Iam getting closer at least as we now can see a 0 and 1 stacked on each other and the garbbled mess under is probably the bats and ball

Iam going thru the code over and over again

Edit...............
My hope is to do this and maybe looking at a msx/ spectrum type of emulator

edit........
now it renders pong but dont move
I feel it iam close
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 27th Jul 2016 23:45 Edited at: 28th Jul 2016 00:20
Kevin is this proper exclusive or you linked ???



Edited.................
Yaaayyyyy everything renders as it should now
Only have to find why it dont run ????
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 28th Jul 2016 10:44
Is anyone intrested if i release this as a comunity open source project???

Would be nice if anyone might expand the project even more

I still have alot left to do on it before its ready for release.

I do projects like this to keep the brain going and not for cash.
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 28th Jul 2016 11:09 Edited at: 28th Jul 2016 11:10
i am interested in the source code on how you solved it
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 28th Jul 2016 12:10 Edited at: 28th Jul 2016 12:14
Iam cleaning everything up and still have the problem it renders the screen but dont cycle thru the rom

So its currently a chip 8 slideshow of the first screen in memory

It showed that i had 2 commands inside if calls that should be outside
When i found them so did it start rendering the first screen in memory

Iam really not a programmer but to dumb to understand that i shouldt be coding

Give me some time to clean stuff up and add proper explanations as the source is a mess right now from all tinkering

added 27 free roms i found and a simple rom selector screen.

Would love if someone finds wath the hell i have missed in all the code

Edited...........
i where probably dumb that started my first emulator with real rom file loading and not the simplier hex hacked files for loading.
But i wanted it to run all original roms as not all are converted to hex hacks.

Edited...
there is some cool demos out there i will include later

As soon as this is working will i upgrade it to super chip8 with higher display resolutions and more opcodes
It have cooler games also
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 29th Jul 2016 22:16
Ok
Extremely close now as some games do work but some do not?
Could be that the games that dont work use schip8?
Or so called super chip?
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Jul 2016 11:19
maybe mega chip?
you make a debugstop if there comes new opcodes?

Quote: "In 2007, another CHIP8 extension has been introduced, called Mega Chip (or MCHIP). Much like the SCHIP, it allows for a larger resolution (256x192), as well as the use of color graphics and sound. Like Super Chip, the MegaChip extension only adds a handful of new opcodes and is 100% backwards compatible with CHIP-8 and Super Chip. An emulator for Chip8/SuperChip/MegaChip, as well as an updated developers kit is available at the Revival Studios website. Various MegaChip games and demos (including an update of the infamous Blinky game) are available."
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 30th Jul 2016 11:36 Edited at: 30th Jul 2016 11:59
I uploading all source in to the agk showcase right now so please take a look there

The thread.
https://forum.thegamecreators.com/thread/217664
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Jul 2016 14:30
i revised this source code, take a look.
i gave the include files a extension.
i put the global vars in a struct, changed the screen drawing pixels, put the running loop into a function.
and useing #option_explicit add some declarations everywhere.

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Attachments

Login to view attachments
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 30th Jul 2016 14:43 Edited at: 30th Jul 2016 14:43
Things i had planned to do but i thought i should do a first release so you could check it out
Did you put your cleaned up one in the thread where i posted it ?
I want this project to spread so we see more emulators in agk
Cheers.

Ps..
I can say that i spent most of the coding on making the thing actually run something

Sorry i found it
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 30th Jul 2016 14:56
i think u need to verify all Opcode with a test modul.
and please verify the keyinput and wait for key.
this missile game works but after score i can't restart.

AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 30th Jul 2016 16:19
i changed the keys to keypressed instead off key state.
made some more changes and your cleaning and my changes is now version 0.11

Iam going to look some more later wath could be wrong???
Currently do i simply not know ????
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Aug 2016 07:35 Edited at: 2nd Aug 2016 07:36
hi,
i think the keys with state is better than just a press.
did you test the chip8 at github?
i saw you have the same roms. just to test if the roms are ok.
https://github.com/gsamokovarov/chip8.c
i will look in your new show case version later this week.
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 2nd Aug 2016 13:33
I do think i know wath the problem is
Going to try it.

Have to rewrite the rom loader a bit more complicated.

15.5.1 x-user-defined decoder

x-user-defined's decoder's handler, given a stream and byte, runs these steps:

1.If byte is end-of-stream, return finished.


2.If byte is an ASCII byte, return a code point whose value is byte.


3.Return a code point whose value is 0xF780 + byte − 0x80.

is wath i nead to do
Android 2.3 , ZTE Skate , 480x800 , 800 mhz , Samsung Galaxy Y , 240x320 , 832 mhz , Sony ericson arc 480x854 , 1 ghz
Android 4.0 , Dmtech 3g 9738B , 1024x768 , 9.7 inches , 1.2 ghz
Markus
Valued Member
19
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 2nd Aug 2016 18:31
aha ok
AGK (Steam) V2.0.20 : Windows 10 Pro 64 Bit : AMD (16.3.2) Radeon R7 265 : Mac mini OS X 10.10 (Yosemite)

Login to post a reply

Server time is: 2024-03-29 02:05:29
Your offset time is: 2024-03-29 02:05:29