Author Topic: Jade  (Read 21077 times)

0 Members and 1 Guest are viewing this topic.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Jade
« on: February 26, 2013, 03:16:23 pm »
After reading some Atari documentation and also seeing some of the documentation for the 84+C, the way I saw what was considered "acceptable" assembly completely changed. For the past few years, I have procrastinated on this project of mine, but last night I started from scratch and it is almost finished.

I have basically created an emulator for a processor that doesn't exist. I created the instruction set to emulate and the ports. I originally modeled instructions and interactions based on how the z80 does it and so the process of completing the instruction set was tedious. I completely changed my approach and here are the stats:

The instruction set is 6-bits, so there is room for 64 instructions but not all are finished. You have 256 bytes of RAM, the first 42 bytes (it will probably be more before this is finished) is for interacting with ports and the last 128 bytes is for a stack. There are 512 bytes of code space and there are no registers. This was the main spark of insight I had last night. Instead, you work directly with the RAM. Here are the instructions currently emulated:

Note that all values are 1-byte.

ld (addr1),(addr2) loads a byte from one RAM address to another.
ld (addr),const loads a byte into the RAM address
add (addr1),(addr2) adds two bytes of RAM together, storing the result to the first byte. Modifies C and Z flags
add (addr),const adds the constant value to the byte. Modifies C and Z flags

You get the idea, I am sure, so here are others that follow the same structure:
adc
sub
sbc
xor
or
and
cp    (compare two values)

And these are some more:
inc (addr)
dec (addr)
push (addr)
push const
pop (addr)
ex (addr1),(addr2)   ;exchange two bytes
ret
ret z
ret c
ldir (addr),size,data   ;copies inline data of the given number of bytes to a ram location specified by (addr)
ldir const,size,data   ;copies inline data of the given number of bytes to a ram location specified by (addr)

It is important to note that the ldir commands are very useful for setting up the ports.

there are also the jrf, jrb, callf, and callb commands. Each of these can work on a condition of c or z (not nc or nz).

jrf jumps forward a given number of bytes.
jrb jumps backwards a given number of bytes.
callf calls a relative routine that is within 256 bytes ahead
callb calls a relative routine that is within 256 bytes behind

Anytime a relative jump or call is made, it will never execute code from RAM. If you go past the 0~511 byte code range, it will loop back around.

There are 8 sets of 4 ports for sprites. The ports are ordered:
LSB of sprite data
MSB of sprite data
X coordinate
Y coordinate

In all, these makeup the first 32 bytes of RAM
Port 20h is the Sprite Update Port. When a sprite is drawn, its corresponding but gets set here. You can reset all of the bits here, then read from it to figure out when all of the sprites have been drawn.
Port 29h is the Sprite Mask Port. Set the corresponding but here to have the sprite drawn. Compare this port to port 20h to see if all the sprites are drawn.
Ports 21h~27h hold values for keypresses
Port 28h is the Key Mask Port which determines which groups of keys get polled

2Ah holds the stack pointer.


Anyways, I would offer an upload or something, but I cannot get it off of my calc, once again. Also, it is currently written in Grammer code, but I plan to convert it to an assembly program. My first attempt is going to make a Pong game and all I currently have done codewise setting up the ports All of the mentioned instructions work by the way, all I need to do is emulate the ports :)

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Jade
« Reply #1 on: February 26, 2013, 03:58:20 pm »
So is it kinda like a new programming language similar to assembly language, but as alternative to Grammer, Axe, Z80 ASM and BASIC? Or is it intended to be some sort of Atari emulator?

Offline ben_g

  • Hey cool I can set a custom title now :)
  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1002
  • Rating: +125/-4
  • Asm noob
    • View Profile
    • Our programmer's team: GameCommandoSquad
Re: Jade
« Reply #2 on: February 26, 2013, 04:00:15 pm »
Is it meant to be a safer and more compatible version of asm? Or is it just something random you liked to try out? Anyway, it sounds cool.
My projects
 - The Lost Survivors (Unreal Engine) ACTIVE [GameCommandoSquad main project]
 - Oxo, with single-calc multiplayer and AI (axe) RELEASED (screenshot) (topic)
 - An android version of oxo (java)  ACTIVE
 - A 3D collision detection library (axe) RELEASED! (topic)(screenshot)(more recent screenshot)(screenshot of it being used in a tilemapper)
Spoiler For inactive:
- A first person shooter with a polygon-based 3d engine. (z80, will probably be recoded in axe using GLib) ON HOLD (screenshot)
 - A java MORPG. (pc) DEEP COMA(read more)(screenshot)
 - a minecraft game in axe DEAD (source code available)
 - a 3D racing game (axe) ON HOLD (outdated screenshot of asm version)

This signature was last updated on 20/04/2015 and may be outdated

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #3 on: February 26, 2013, 05:21:32 pm »
I just wanted something to try out, but it definitely provides a safe way for people to use an assembly-like language. There is no risk of it editing any other data outside of saveSScreen. I might turn this into an app with a bunch of silly features like a debugger, hex editor/viewer, and program editor since the instruction set is ridiculously easy to create a compiler for. On top of that, games or game packs are limited to 512 bytes and they can be archived. Even if they were in RAM, they require no additional user RAM to run. This means that you could fit 32 "roms" in a single RAM page which would be great for TI-83, 82, and 82 STATS users!

Programs that I think are quite feasible:
Pong
A tunnel game
Tic-Tac-Toe
A Space Invaders like game
Block Eater (a game I made)
Maybe pacman

And I do think these are feasible in 512 bytes, but my thoughts might change XD

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Jade
« Reply #4 on: February 26, 2013, 06:37:02 pm »
Sounds interesting, another random idea of xeda, lol, but awesome :D

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline Juju

  • Incredibly sexy mare
  • Coder Of Tomorrow
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 5730
  • Rating: +500/-19
  • Weird programmer
    • View Profile
    • juju2143's shed
Re: Jade
« Reply #5 on: February 26, 2013, 07:10:24 pm »
So you created a whole new CPU? That's pretty cool, I like the idea there's no register and you have to directly do stuff with the RAM :P

Remember the day the walrus started to fly...

I finally cleared my sig after 4 years you're happy now?
THEGAME
This signature is ridiculously large you've been warned.

The cute mare that used to be in my avatar is Yuki Kagayaki, you can follow her on Facebook and Tumblr.

Offline TIfanx1999

  • ಠ_ಠ ( ͡° ͜ʖ ͡°)
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 6173
  • Rating: +191/-9
    • View Profile
Re: Jade
« Reply #6 on: February 26, 2013, 07:34:17 pm »
This is a pretty neat idea. I've put some thought into doing something similar myself, but on a computer. What made you decide to leave out registers?
« Last Edit: February 26, 2013, 07:35:35 pm by Art_of_camelot »

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #7 on: February 26, 2013, 08:28:01 pm »
The simple answer is that it makes things so much easier to handle, you get a ton of variety in commands, and there are a lot less instructions. For example, you can use 32 bytes of RAM as variables and perform all math operations on any combination of variables using the same instructions.

Offline Xeda112358

  • they/them
  • Moderator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 4704
  • Rating: +719/-6
  • Calc-u-lator, do doo doo do do do.
    • View Profile
Re: Jade
« Reply #8 on: February 27, 2013, 07:46:53 am »
I have begun the process of converting this to assembly now, so once it is complete, I will be able to have a copy of it on my computer (and so I can upload it here). I currently have all of the jumps and calls emulated and now I just have the math operations to finish and the others random things. For an example of the code that I wrote (in hex on my calc) that was emulated:
Code: [Select]
3020        ;jrf 32             ;jumps over the next 32 bytes
<32 bytes of masked sprite data>
1F2802      ;ldir keymask,2     ;copies two bytes to the RAM location at keyMask (these are ports keymask and sMask)
0303        ;.db 3,3
1F0008      ;ldir sLSB0,8       ;copies 8 bytes to the first two sets of sprite data ports
  02000303  ;.dw 2 \ .db 3,3    ;location of the sprite, coordinates
  12005535  ;.dw 18 \ .db 85,53 ;location of the second sprite, coordinates
3302        ;jrb $              ;jumps back two bytes to the start of this instruction. Causes an infinite loop.

Offline Spyro543

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1189
  • Rating: +74/-3
    • View Profile
Re: Jade
« Reply #9 on: February 27, 2013, 08:59:43 am »
This is a pretty neat idea. I've put some thought into doing something similar myself, but on a computer.
I've started programming a virtual CPU, too!

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Jade
« Reply #10 on: February 27, 2013, 10:54:15 am »
ooh, this sounds really fun =)
and yeah, it could be a very helpful way to introduce people to asm as well.

What made you decide to leave out registers?
the only reason to have registers in a processor is to make things faster, so you don't have to be accessing ram constantly.

Offline TheNlightenedOne

  • LV6 Super Member (Next: 500)
  • ******
  • Posts: 427
  • Rating: +16/-1
    • View Profile
Re: Re: Jade
« Reply #11 on: February 27, 2013, 02:23:27 pm »
This is really cool! I like it a lot.
Slightly offtopic: is there a CPU yet that does support direct operations on RAM?
"Eris" (Ndless 3.1)
"Keto" (Ndless 3.1)
"Luna" (AMS 3.10, HW4)
"Aurora" (2.55MP)

Offline Streetwalrus

  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3821
  • Rating: +80/-8
    • View Profile
Re: Jade
« Reply #12 on: February 27, 2013, 02:30:32 pm »
It's pretty nice indeed ! I'm not sure I'm capable of such things, though... Well, I'll maybe learn someday. :D

Offline Sorunome

  • Fox Fox Fox Fox Fox Fox Fox!
  • Support Staff
  • LV13 Extreme Addict (Next: 9001)
  • *************
  • Posts: 7920
  • Rating: +374/-13
  • Derpy Hooves
    • View Profile
    • My website! (You might lose the game)
Re: Jade
« Reply #13 on: February 27, 2013, 09:16:48 pm »
Now you have to re-write grammer for that CPU, and the CPU itself is written in the grammer for that CPU so in order to run the CPU you must use grammer which needs the CPU... D:
mind=blown

THE GAME
Also, check out my website
If OmnomIRC is screwed up, blame me!
Click here to give me an internet!

Offline chickendude

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 817
  • Rating: +90/-1
  • Pro-Riot Squad
    • View Profile
Re: Jade
« Reply #14 on: March 01, 2013, 09:57:50 pm »
Xeda, i would love to play around with this if you ever get around to releasing something! I like the idea of trying to make games fit in small places and working with memory directly sounds interesting. Is the code then stored in your hex format and parsed?