Untitled adventure game, Milestone 2: Basic gameplay

A place where you can keep others updated about your NES-related projects through screenshots, videos or information in general.

Moderator: Moderators

tepples
Posts: 21720
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Untitled adventure game, Milestone 2: Basic gameplay

Post by tepples » Tue Feb 19, 2019 7:08 pm

bleubleu wrote:
  • $0e = reads argument 0 passed from the engine, puts in variable slot $01 (i have 32 variable slots). Note that the compiler detected we never access the second argument, so it ignores it. Minor optimization.
  • $05 = equality comparison. Compares whatever is in variable $01 (what we just read) to constant $02 (when the minus bit, $80, is set, it means that its not a variable, but a constant stored in a table somewhere else. Whenever I encounter an hardcoded constant at compile-time, I look to see if I've seen it before and add it to that table if its new. Constants like "0" comes back quite often, so this is efficient).
  • $0a = jump to the location indicated (10, which is the end) if the last test condition was false. My conditional statements are optimized for "ORs of ANDs" (or "Disjunctive normal form" if you want to sound pretentious).
  • $13 = calls an engine function (engine function $05 is "set_timer") that takes a single argument and puts in in "r0" (a zero page variable in my engine), which is the constant table at location $0a.
  • $1a = end.
One thing that tripped me up while reading your "assembly language" in the comments to the right was that most architectures' equality comparison behaves as != instead of ==: a subtraction that is true if they are different or false if not. That way, the interpreter can use the same logic for compare and subtract.

yaros
Posts: 145
Joined: Tue Aug 28, 2018 8:54 am
Location: Edmonton, Canada

Re: Untitled adventure game, Milestone 2: Basic gameplay

Post by yaros » Tue Feb 19, 2019 7:51 pm

bleubleu wrote: I hope this example can make it clear how easy it is to output this king of bytecode as you parse. Interpreting this is super easy, simple jump table, and a 32-byte array for your "RAM".
It does well, thank you.

bleubleu
Posts: 66
Joined: Wed Apr 04, 2018 7:29 pm
Location: Montreal, Canada

Re: Untitled adventure game, Milestone 2: Basic gameplay

Post by bleubleu » Tue Feb 19, 2019 8:05 pm

tepples wrote:One thing that tripped me up while reading your "assembly language" in the comments to the right was that most architectures' equality comparison behaves as != instead of ==: a subtraction that is true if they are different or false if not. That way, the interpreter can use the same logic for compare and subtract.
I see your point. But I really made it up as I went along. :) There was no masterplan, I didn't try to copy any existing architecture really.

Also, reusing the same opcodes for multiple things wasnt much of a concern. I favored large and very specific op-code that do a lot of things, as opposed to micro-ops that can be reused. The idea was to keep the bytecode compact, and have the ASM code be quite efficient. This mean that I probably have a lot more code in my interpreter, but that's ok.

-Mat

User avatar
Space Raft
Posts: 10
Joined: Thu Jul 05, 2018 3:21 pm
Location: Milwaukee WI
Contact:

Re: Untitled adventure game, Milestone 2: Basic gameplay

Post by Space Raft » Tue Jun 11, 2019 11:42 am

WOW,

This looks absolutely fantastic. I love the art style, the black outlines, the blinking eyes on the sprite, shadows, color palettes. So many nice visual touches. Very impressive :)

Are you looking for music by chance?

Post Reply