DEV Community

Eduardo Alvarez
Eduardo Alvarez

Posted on • Originally published at Medium

Kieszeń first game lesson

Disclaimer: All the credits for this post should go to Nick Morgan for creating this amazing MOS 6502 tutorial Easy 6502 ebook I just adapted for my modified IDE that focus on 2d gaming.

What is Kieszeń

Kieszeń is a startup idea about creating a portable game console where people can create games withouth previous experience. By using simple, constrained 2d games, so the limitations can bring creativity and problem solving, instead of relying on adding feature after feature hopping that some special effect or gimmick saves our gameplay.

Road to our first game

So, let’s dive in! Click here to open Kieszeń Create, the webpage where you can make your own video games. Copy as paste the text below (don’t worry we will explain what it means)

LDA #1
STA $512
LDA #16
STA $513
LDA #8 
STA $514

Now press Play. Hopefully the screen area on the right now has Pac-man on the top left.

So, what just happened? Let’s step through it by analyzing the text. First reload the page, then press Analyze game to show a panel with extra information. Press Next line once. If you were watching carefully, you’ll have noticed that something called Accumulator changed from #0 to #1.

In Kieszeń Create, anything prefixed with # is considered a number. Anything with $ refers to a memory location.

Equipped with that knowledge, you should be able to see that the instruction LDA #1 loads the number 1 into the processor Accumulator. We will go into more detail on processor inner workings in upcoming lessons.

Press Next line again to check the second instruction. The top-left part of the screen should now display the Pac-man character. Kieszeń uses the memory locations $512 to $768 to store, display and modify graphics on the screen. The values #1 to #255 represent the 255 different graphics that the console can remember at the same time (#0 means no character), so storing the value #1 at memory location $512 draws a game graphic at the top left corner.

Finally, the instruction STA $512 stores the value of the Accumulator register to memory location $512. Keep pressing Next line to check the rest of the instructions, keeping an eye on the Accumulator as it changes.

Exercises

  1. By opening this image, try changing the graphics to one of your favorite game characters.
  2. Change the first character position to draw at the bottom-right corner. (memory location $513 and $514)
  3. Add more instructions to add more game characters (don’t forget to write the position of each character as well).

Top comments (0)