Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
TomR
Apr 1, 2003
I both own and operate a pirate ship.

Internet Janitor posted:

I'm working on something more elaborate, but I just whipped up a rough version of an idea discussed on IRC- a minimalist pipe-dream clone that runs in basic chip-8 at a stock clock speed:



http://johnearnest.github.io/Octo/index.html?gist=405eb32fe11acb8440bd76977617035f

This may be worth a little more polish.

Did you ever get a chance to think about this more? It looked like it had potential.

Adbot
ADBOT LOVES YOU

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

TomR posted:

Did you ever get a chance to think about this more? It looked like it had potential.
Yes, I liked it as well. I have some ideas for making a much fancier game based on FUSE's core mechanic. Maybe I'll make an XO-Chip version as a next step.

In other news, we're only a month and a half away from yet another Octojam, so I decided to spend a little time giving this project some love. Octo programmers everywhere, rejoice- I have added macros!

quote:

Sometimes your code will contain repetitive patterns that don't make sense to break out into subroutines. Perhaps they differ by the registers they operate upon, or for performance reasons you need to avoid the overhead of a call and a return. The :macro command is the solution. It takes a name, followed by names for 0 or more arguments, then a {, a sequence of arbitrary Octo statements and finally a terminal }. When you reference the name of a macro, you must provide tokens corresponding to each argument, and then Octo will inline the contents of the macro with any instances of the argument names substituted by the input tokens. Here's a trivial use and definition example:
code:
:macro swap A B {
	vf := A
	A  := B
	B  := vf
}

...

swap v0 v1
swap v2 v1
This generates code equivalent to the following:
code:
vf := v0
v0 := v1
v1 := vf
vf := v2
v2 := v1
v1 := vf
Macros must be defined before expansion, and macro definitions may not be nested, but macro invocations may appear within macro definitions.

See the commit here to see some old example programs I have simplified using this feature. I have a few more ideas for refining this new functionality, and I'd love to hear feedback.

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
lookin good

http://johnearnest.github.io/Octo/index.html?gist=3d9cf05648af4aa6f8fa1d0f97d77d71

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

That's... not quite what I had in mind when I designed the feature, but I suppose it demonstrates the flexibility of the mechanism. :sweatdrop:

I have also added another feature which is frequently demanded and relatively common (in some form or another) in assemblers: compile-time calculations. These can be handy in all sorts of places where there's a relationship between constants in your program. Expressing these relationships in code is much easier and less error-prone than leaving them up to the programmer to do by hand.

Using :calc in combination with :macro permits some fun and exotic programming techniques:



code:
: main
	hires
	loop
		scroll-down 2
		i := table
		i += v2
		load v1
		i := thin
		sprite v0 v3 2
		i := thick
		sprite v1 v3 2
		v2 += 2
	again

: thin  0x0F 0x0F
: thick 0xFF 0xFF

: table
	:macro S2 {
		:calc rads { ( HERE - table ) * ( 2 * PI ) / 256 }
		:calc val1 { 56 + 38 * sin rads } :byte val1
		:calc val2 { 56 + 16 * cos rads } :byte val2
	}

	# expand S2 2*8*8 times for a 256-byte table:
	:macro S1 { S2 S2 S2 S2 S2 S2 S2 S2 }
	:macro S0 { S1 S1 S1 S1 S1 S1 S1 S1 }
	S0 S0

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Nice IJ. I immediately wondered how the macro system would handle use of labels inside the macro. It works but I had to pass in a unique label so I could instantiate the macro more than once. Would you be interested in a PR that adds a unique counter to the end of labels inside macros that are used more than once?

code:
# Memory address is in registers addrhi and addrlo, which must be an adjacent register pair
# Data will be loaded from that address into registers deststart through destend
:macro indirect-load addrhi addrlo deststart destend label {
	i := label
	save addrhi - addrlo
	0xF0 0x00 
	: label
	0x00 0x00
	load deststart - destend
}

: main
# Load v0-v3 with data from 0x400
v5 := 0x04    v6 := 0x00
indirect-load v5 v6 v0 v3 label1
:breakpoint first

# Reverse load v1-v0 with data from 0x403
v5 := 0x04    v6 := 0x03
indirect-load v5 v6 v1 v0 label2
:breakpoint theend

:org 0x400
0x10 0x20 0x30 0x40 0x50
e: those compile time calculations are going to make a lot of stuff easier to program without resorting to external tools

taqueso fucked around with this message at 17:32 on Aug 14, 2017

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

taqueso posted:

Would you be interested in a PR that adds a unique counter to the end of labels inside macros that are used more than once?

I'd hold off for now. I've been thinking about this kind of use case, and I'm not quite sure how I want to proceed with it. I don't want to add things hastily, so I'd like to spend some time working with macros as they currently exist. Passing in "nonce" labels as arguments to macros is a reasonable workaround for the time being.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Is it possible to concatenate two tokens?

Buffis
Apr 29, 2006

I paid for this
Fallen Rib
I just realized that I'll be traveling in Asia for over two weeks in October, which means I'll miss most of Octojam :(

I'll still probably participate, but will probably end up with something more limited this year. Spent quite a lot of time on Binding of Cosmac last year...

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

It's all good, you can Octojam from anywhere in the world that has internet.

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."

taqueso posted:

Is it possible to concatenate two tokens?

I've been thinking about this. Might be worth adding a :suffix for such a purpose.

In other news, the Octojam IV page is together:


http://www.awfuljams.com/octojam-iv

Mastigophoran
Oct 1, 2016

Not exactly immortal...
but close enough


Greetings fellow Octonauts!

With Octojam 4 just around the corner, I feel now is a good time to post this as I'll be on holiday! After last year's implausibly successful SuperChip ShowCase, the HP48 calculator will be returning to run your SCHIP and computationally demanding CHIP8 games on real hardware.

This year, our range of calculators has expanded from 1 to 2, now including the mighty HP48-GX, which packs twice the CPU power of the HP48-S calculator we used last year. This increase in power is held back a little by sharing the same RAM frequency, but still translates to around a 50% boost in speed in the SCHIP interpreter on the G series calculators, the details of which can be found here, however the crux of it is as follows:

As you may know, unlike in Octo, on both the COSMAC VIP and the HP48 SCHIP platforms, some instructions just take longer than others. The worst offender that you're likely to be doing a lot of in a main loop is the sprite command. The more weighted towards or away from graphics your game is, the slower or faster you can expect it to run. Here is an advisory as to the speeds you might want to set Octo on to get an idea of how things will run on the GX calculator (You may need to provide a custom GIST)
  • 64x32 lores, graphics benchmark speed: 17 Cycles/Frame
  • 128x64 hires, graphics benchmark speed: 33 Cycles/Frame
  • ALU operations benchmark speed: 50 Cycles/Frame
Note that lores graphics ops tank performance big time. A fairly computationally intensive game with simple but hires graphics will run at the higher speeds. My Octojam 2 game, Octopeg, is an example of a game that actually runs very well on the calculators - it depends on performing quite a lot of mathematics to move a single 2x2 block around a hires screen. This year's banner is an example of one that does not fair very well at all, due to operating in lores, and aiming to redraw several large sprites every frame.

As before, I have all the period interpreters that will run programs as per the relevant quirks modes Octo has (and other issues) as well as SCHPC, which more closely mirros the COSMAC, and thus Octo's quirkless behavior which should be able to run anything if the quirks are getting you down. If you have any questions and hope to make a game that will run on hardware, I'm on the SA GameDev Discord and IRC, and am always happy to answer questions or offer any help, about SCHIP or anything CHIP8 related really. I've made quite a lot of notes on the oddities of SCHIP, and compiled them here and the full list of key notes can be found in my post from last year here, the most germane of which are reproduced (and augmented) here:

Superchip 1.1 expresses the following quirks:
  • <<= and >>= modify vx in place and ignore vy.
  • load and store operations leave i unchanged.
  • clip sprites at screen edges instead of wrapping.
  • 4 high bits of target address determines the offset register of jump0 instead of v0. For example, supplying address 0x420 will use the value of V4 instead of V0.
  • 16x16 sprites work in hires mode only. 0 height sprites will draw 8x16 sprites in lores mode.
  • Roms can only be 3583 bytes maximum (1 byte remaining).
  • No hex characters in large font
  • Sprite collisions will store number of rows that collide in vF. Test vF <> 0 instead of vF == 1.
  • Sprite rows that run off the screen downwards vertically will also be added into vF, even if sprite row is empty.
  • The buzzer actually does make a noise that I will have to hear with my ears. I can turn it off though.
  • Memory space is not initialised 0 unless specified as such in your ROM. Low memory (0 to 0x1FF) will be hex characters and then noise.
  • Scrolling left/right in lores mode will move effectively 2 px, instead of 4px. Vertical scrolling also divided by 2, half pixels should be avoided!

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Internet Janitor posted:

I've been thinking about this. Might be worth adding a :suffix for such a purpose.
First, I have to say the new metaprogramming features are really great. I feel a lot more productive. A big feature of macros I didn't appreciate at first is flexibility. With a function, the ABI is fixed, but you can use any registers you want in a macro, assuming you pass them in as parameters.

An example of concatenation being useful: I have been making some macros for 16-bit math, and I would really like to be able to use MACRO_ADD_U16 v01 v23 and have it turn v01 (etc) into v01-hi and v01-lo, which I would define as aliases for v0 and v1. Currently, I invoke the macro as MACRO_ADD_U16 v0 v1 v2 v3 which works but is more cumbersome and error prone. I tried making a macro that defined v01 as { v0 v1 }, but octo doesn't seem to like to expand macros that are parameters.

Another thing I've been wishing for is a way to conditionally compile, something like :if { expression-evaluating-to-zero-or-nonzero } { <octo commands here> }. I have some macros I want to disable when not debugging, so I make two definitions, one with an empty body, and only define the one I want. It would be nice if that could happen to a bunch of macros with a single :const change.

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

It's October :spooky:

Dr. Stab
Sep 12, 2010
👨🏻‍⚕️🩺🔪🙀😱🙀
I made a little spaceship

http://johnearnest.github.io/Octo/index.html?gist=6be5db905087c99cca632e40575dc4f8

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

Octojam livestream is happening now: http://twitch.tv/awfuljams

Adbot
ADBOT LOVES YOU

Doom Goon
Sep 18, 2008


Almost missed Octojam again! Just played the games and then watched the stream. My top 3 were probably Kesha Was NIIInja (great return to form!), Sub-Terr8nia, and octoroads. Honorable mentions to H8 and Tetris. If any of the contributors of Octojam IV happen upon this: Great stuff this year! Thanks!

  • Locked thread